FLine is our main high level geometry container for lines, meshes and lists of points. FLines consist of a list of drawing instructions, or nodes: `line.moveTo(...).lineTo(...).cubicTo(...)` .etc This is essentially the common postscript / pdf / java2d drawing model with a few key difference
| 51 | * <p> |
| 52 | * The caching of the flattening of this line into MeshBuilder data (ready for OpenGL) cascades into MeshBuilder's cache structure. Thus, we have three levels of caching in total: FLine caches |
| 53 | * whether or not the geometry has |
| 54 | * changed at all, MeshBuilder caches whether or not there's any point sending anything to the OpenGL |
| 55 | * underlying Buffers or whether this piece of geometry can be skipped, and finally individual ArrayBuffers can elect to skip the upload to OpenGL. This means that static geometry is extremely cheap |
| 56 | * to draw. |
| 57 | */ |
| 58 | public class FLine implements Supplier<FLine>, fieldlinker.AsMap, HandlesCompletion, Serializable_safe, OverloadedMath { |
| 59 | |
| 60 | static { |
| 61 | new StandardFLineDrawing(); // cause properties to be loaded |
| 62 | } |
| 63 | |
| 64 | public List<Node> nodes = new ArrayList<>(); |
| 65 | public Dict attributes = new Dict(); |
| 66 | transient protected Set<String> knownNonProperties; |
| 67 | long mod = 0; |
| 68 | WeakHashMap<MeshBuilder, BookmarkCache> cache = new WeakHashMap<>(); |
| 69 | WeakHashMap<MeshBuilder, BookmarkCache> cache_thickening = new WeakHashMap<>(); |
| 70 | private Map<Integer, Function<Node, Object>> auxProperties; |
| 71 | |
| 72 | public FLine() { |
| 73 | } |
| 74 | |
| 75 | public FLine(Map<Object, Object> attributes) { |
| 76 | for (Map.Entry e : attributes.entrySet()) { |
| 77 | String name = (String) Conversions.convert(e.getKey(), String.class); |
| 78 | asMap_set(name, e.getValue()); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | @HiddenInAutocomplete |
| 83 | static public Vec2 evaluateCubicFrame(double ax, double ay, double c1x, double c1y, double c2x, double c2y, double bx, double by, double alpha, Vec2 out) { |
| 84 | if (out == null) out = new Vec2(); |
| 85 | |
| 86 | double oma = 1 - alpha; |
| 87 | double oma2 = oma * oma; |
| 88 | double oma3 = oma2 * oma; |
| 89 | double alpha2 = alpha * alpha; |
| 90 | double alpha3 = alpha2 * alpha; |
| 91 | |
| 92 | out.x = ax * oma3 + 3 * c1x * alpha * oma2 + 3 * c2x * alpha2 * oma + bx * alpha3; |
| 93 | out.y = ay * oma3 + 3 * c1y * alpha * oma2 + 3 * c2y * alpha2 * oma + by * alpha3; |
| 94 | |
| 95 | return out; |
| 96 | } |
| 97 | |
| 98 | @HiddenInAutocomplete |
| 99 | static public Vec3 evaluateCubicFrame(double ax, double ay, double az, double c1x, double c1y, double c1z, double c2x, double c2y, double c2z, double bx, double by, double bz, double alpha, |
| 100 | Vec3 out) { |
| 101 | if (out == null) out = new Vec3(); |
| 102 | |
| 103 | double oma = 1 - alpha; |
| 104 | double oma2 = oma * oma; |
| 105 | double oma3 = oma2 * oma; |
| 106 | double alpha2 = alpha * alpha; |
| 107 | double alpha3 = alpha2 * alpha; |
| 108 | |
| 109 | out.x = ax * oma3 + 3 * c1x * alpha * oma2 + 3 * c2x * alpha2 * oma + bx * alpha3; |
| 110 | out.y = ay * oma3 + 3 * c1y * alpha * oma2 + 3 * c2y * alpha2 * oma + by * alpha3; |
no outgoing calls
no test coverage detected