29-04-2022, 03:58 PM
(28-04-2022, 11:02 PM)josemendez Wrote: HI there!
"Scripting particles" refers to the act of controlling particles via script. It's not the name of a thing .
Particles are not classes or structs. Obi uses a data-oriented approach, which means particles are just an index, that you can use to access data in several arrays of the same length. Quoting the manual:
So to access the position of the Nth particle in a cloth, you do:
Code:var pos = solver.positions[cloth.solverIndices[N]];
Similarly, to access its velocity:
Code:var pos = solver.velocities[cloth.solverIndices[N]];
FYI, Unity's DOTS (data-oriented technology stack) uses the same approach: entities are not classes or structs, an entity is just an index into arrays of components.
The main advantage of this approach is the ability to deal with large amounts of data in a very performant way, because cache misses are minimized and memory is used efficiently: when you need to operate over say, particle positions and velocities, you *only* operate on that. No need to bring single every property from memory (mass, radius, color, etc) like you'd be forced to do if particles were structs - since you could not have partial access to a particle.
Orientations are only used by some actors, and cloth isn't one of them: cloth particles are just points in space with no orientation.
Currently, only rods (ObiRope) and soft bodies (ObiSoftbody) use oriented particles.
kind regards,
Thanks for the explanation!
I'm trying to implement a cutting algorithm, find a list of pairs of particles connected by DistanceConstraints that are as close as along a given straight line. I think that I need the particle orientation to determine if two particles connected by a DistanceConstraint don't have any "mesh gap" between them. Because my mesh has two sides that are close to each other, and I'm worrying that Obi will create constraints from the outside vertices to the inside vertices.
If Obi won't create DistanceConstraint between two cloth particles if there is "mesh gap" between them, then I probably don't need the particle orientation.
Or, is it possible to get the mesh vertex index for a corresponding particle/closest to a particle? Maybe I can resolve my issue if I can get the vertex information.