06-05-2022, 08:01 AM
(05-05-2022, 07:49 PM)snowtv Wrote: That's reasonable. So for the particle index for each vertex data, will this gets updated at runtime based on changes on constraints/tearing, etc.?
Yes, this does get updated at runtime.
(05-05-2022, 07:49 PM)snowtv Wrote: Also can you point me to the document for particle index for each vertex please?
This isn't really documented anywhere, as it's very low-level stuff: to generate cloth from a mesh, Obi uses a half-edge data structure. You can find the implementation in HalfEdgeMesh.cs file. The half-edge structure contains a rawToWelded array with as many entries as vertices in your mesh. For each vertex, it contains the index of the actor particle that represents that vertex.
The cloth blueprint has a public "topology" member, which is of type HalfEdgeMesh.
Tearable cloth actors create a copy of their blueprint at runtime, since they need to modify the topology (the half-edge structure) so they can't share the same blueprint, unlike other cloth types. This copy gets updated every time the cloth is torn, as I mentioned above.
Wrapping up: to get the particle for vertex N at runtime, do:
Code:
int actorParticleIndex = cloth.blueprint.topology.rawToWelded[N];