Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find out which particle group to attach with the ObiParticleAttachment
#12
(24-08-2021, 04:47 PM)josemendez Wrote: Nope. Data layout at runtime changes significantly compared to the data stored in the blueprint. See:
http://obi.virtualmethodstudio.com/manua...aints.html

But the document says that "Arranging constraints into batches can be a very time consuming process (known as graph-coloring), so it is generally not done at runtime: it happens as part of blueprint generation"?

I think I don't fully understand the document, can I have a more detailed example?

Let's say there is ObiActor OA1 and ObiActor OA2, both under the same solver. And there is Batch1 and Batch2, and there are two types of constraints C1 and C2, and OA1 has one C1 which will be C11 and one C2 which will be C21. OA2 also has one C1 which is C12 and one C2 which is C22.

So, OA1 has a C11 and a C21, OA2 has a C12 and a C22. How can these four constraints layout in the two batches? And how can I get the data for these constraints?

(24-08-2021, 04:47 PM)josemendez Wrote: Nope. Data layout at runtime changes significantly compared to the data stored in the blueprint. See:
http://obi.virtualmethodstudio.com/manua...aints.html

Actually, lemme just send you my code.

So in this function I'm trying to store info about a single particle in one of my softbody (all my softbodies are under one solver because I need them to collide)

So for my understanding, the first level of data structure are the batches, so I need to store the batch index for my particle, then each batch store a bunch constraints, so I also need the index for the constraint which contains my particle, then finally I need the index for the particle in that constraint. And I need to find every ShapeMatchingConstraint that include that particle, so I go through all constraints in all batches (similar to the DeformationToColors.cs which you pointed me to earlier)

Looking at the code in DeformationToColors.cs, it looks to me that the constraint index and everything are the same in blueprint and runtime, the difference is the runtime softbody changes which alters values such as solverBatch.linearTransforms.

Anyway, here is my code:


Code:
public void GetParticleShapeMatchingConstraintBatchIndexInfo(ObiActor colonSoftbody, ObiSolver solver, int softBodyParticleIndex,
        ref List<int> softBodyParticleBlueprintBatchIndexes, ref List<int> softBodyParticleBlueprintClusterBatchIndexes, ref List<int> softBodyParticleBlueprintClusterIndexes,
        ref List<int> softBodyParticleRuntimeBatchIndexes, ref List<int> softBodyParticleRuntimeClusterBatchIndexes, ref List<int> softBodyParticleRuntimeClusterIndexes)
    {
        // Get constraints stored in the actor
        ObiConstraints<ObiShapeMatchingConstraintsBatch> bpConstraints = colonSoftbody.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints<ObiShapeMatchingConstraintsBatch>;

        for (int bi = 0; bi < bpConstraints.batches.Count; bi++) // Search through all batches
        {
            ObiShapeMatchingConstraintsBatch batch = bpConstraints.batches[bi] as ObiShapeMatchingConstraintsBatch;

            for (int ci = 0; ci < bpConstraints.batches[bi].activeConstraintCount; ci++) // Search through all shape matching constraints for this softbody in the current batch
            {
                int offset = colonSoftbody.solverBatchOffsets[(int)Oni.ConstraintType.ShapeMatching][bi];

                for (int pi = 0; pi < batch.numIndices[ci + offset]; ++pi) // Search through all indices of particles maintained in this shape matching constraint
                {
                    // If this particle is the target particle
                    if (batch.particleIndices[batch.firstIndex[ci + offset] + pi] == softBodyParticleIndex)
                    {
                        softBodyParticleBlueprintBatchIndexes.Add(bi);
                        softBodyParticleBlueprintClusterBatchIndexes.Add(ci + offset);
                        softBodyParticleBlueprintClusterIndexes.Add(batch.firstIndex[ci + offset] + pi);
                        softBodyParticleRuntimeBatchIndexes.Add(bi);
                        softBodyParticleRuntimeClusterBatchIndexes.Add(ci + offset);
                        softBodyParticleRuntimeClusterIndexes.Add(batch.firstIndex[ci + offset] + pi);
                    }
                }
            }
        }
    }
Reply


Messages In This Thread
RE: Find out which particle group to attach with the ObiParticleAttachment - by snowtv - 30-08-2021, 03:12 PM