That’s not trivial thing to do, though.
Especially if to do that on the level of Blender. But maybe the Blender’s deps graph could give some inspiration.
Personally, I’ll try with something simple like @property / _isDirty / update()
That’s not trivial thing to do, though.
Especially if to do that on the level of Blender. But maybe the Blender’s deps graph could give some inspiration.
Personally, I’ll try with something simple like @property / _isDirty / update()
Blender is different. It model the system as a mesh not as a parametric geometry.
→ Blender = mesh modeling system (approximate geometry)
→ CAD = kernel-based system (exact geometry)
But yeah it’s not something easy but still worth it for Babylonjs to have at least the basic functionality of this for some use cases.
I’ve used dependency graph, then depth- or breadth-first search depending on links-to-parent or links-to-children (one search per node set) gives you processing order. Anything changes and start search/processing at the changed nodes. Prevents looping through multiple times looking for “dirty.” Is that what we’re already talking about?
Yes, Blender is totally different in this matter, but the dependency handling is basically the same: it only updates those meshes affected by changes, just like we need to only update affected VertexData. The changes in Blender come from UI, animation, modifiers, constraints, drivers, scripts, probably something more. And all that stuff is interconnnected and handled by depgraph.
In Babylon the dependencies are implemented in a very hardcore way, with _isDirty and if (this._isDirty) this.recalculate() hardcoded all around the codebase. And it doesn’t work well somethimes (i.e. getAbsolutePosition() for animated meshes implies kinda another layer of _isVeryDirty)
If you’ll manage to solve that in a generic way, you’ll be a hero! ![]()
Well… I will only copy other hero work to Babylonjs
(a lot of other open source engines handle this issue in better ways)
Honestly I’m open to improve the node geometry to support live update!! If someone wants to help I’ll be more than happy to review the PR.
This could be a fantastic update
I love to
Ok.
In very general, i see at least two reasonable levels of difficulty (following Cynefin scheme):
The simplest case can be relatively easy solved by implementing classes for parametric primitives, transformation rules, and a master function to compute parameters. And then just putting them all into main parent node.
We still have to deal with case of overlapping surfaces, but that could be solved manually according to a specific construction scheme.
And this is actually what nodes intended to solve, except they are not real-time and also self-destructive.
The complex case requires modifying geometry drastically, such as adding new faces or splitting manifolds. And that cannot be done in-place reusing the same VertexData.
The somplicated case requires running simulation or optimization algorithms, which are all either NP-hard or non-deterministic, and totally not real-time. Some real-time-ization is acheved via using pre-calculated templates that themselves fit into simpler categories.
Although it’s simplest to implement, because whole geometry just regenerates.
Do I miss something?
Personally, i’m interested mainly in the 1st category.
And the idea of re-inventing geometry nodes still bothers me.
Is there a chance the nodes could be refactored to solve the evaluateContext issue automatically?
Maybe, via some recursive dirtyness or something?
That alone would bring the nodes to quite another level.
Careful reuse of VertexData can result in dramatic increase in speed. So too, can reducing the generation of large temporary arrays. In my applications, I usually design for repeated generation of vertex data, into the same buffer if possible.
Most Babylon mesh generation functions take Array() as input, but some also take Float32Array. It’s unclear to me whether those that take Float32Array also copy that array before using it as a vertex buffer (in some cases, the arrangement is different, so it must copy).
Usually, the pattern I adopt is
Or
Or, with thinInstanceMatrix that might grow in number,
My biggest issue with CSG2 is that there is no “update in place” or “use this array if big enough”. If reusing a mesh with CSG2, then it may be worth managing CSG2/mesh references for repeated use. It’s kind of a chore, though.