Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Multiple Rope Cursors on single rope
#5
(01-11-2019, 11:31 AM)TheMunk Wrote: Adding another issue to this; 
When changing rope length with a cursor while baking particles, the playback will do some weird stuff. Is this a known bug?

EDIT:
Also, when trying to get the positions of all active particles in order to spawn and update a position for gameobjects, the indices jumps around when deleting from both ends. It's very obscure to get a list of all active particles.

Hi,

Adding new particles to a baked simulation won't behave nicely (since the new particles do not have any cached information, it's impossible to expect the playback to work). Anyway the baker is undocumented, unmaintained and pretty much unsupported as of now (in fact, it's entirely gone in 5.0). It was written way back in Obi 1.0 when there was no good way of getting baked simulations into Unity, but nowadays Alembic does a much better job of importing them so there's little motivation to maintain a system that does the same, but worse.  See this thread:
http://obi.virtualmethodstudio.com/forum...p?tid=1455

When adding particles from a rope, particles are appended/removed from the particle list, but aren't sorted in any particular way. If for some reason you need to get all particles in the rope in order (from first to last), you need to iterate over structural constraints (distance constraints for ropes, stretch/shear constraints for rods). Each structural constraint holds 2 particles together, and unlike particles, they are guaranteed to alway be correctly sorted:

Code:
int constraintCount = rope.GetStructuralConstraintCount();
for (int i = 0; i < constraintCount; ++i)
{
    int particle1 = -1, particle2 = -1;
    if (rope.GetStructuralConstraintParticles(i,ref particle1,ref particle2))
       {
        Vector3 pos1 = rope.GetParticlePosition(particle1)
               Vector3 pos2 = rope.GetParticlePosition(particle2));
    }
}

Or if you just want to iterate over all active particles in no particular order:
Code:
for (int i = 0; i < rope.particleIndices.Length; ++i)
{
    if (rope.active[i])
    {
    //do stuff
    }
}
Reply


Messages In This Thread
Multiple Rope Cursors on single rope - by TheMunk - 30-10-2019, 04:32 PM
RE: Multiple Rope Cursors on single rope - by josemendez - 02-11-2019, 08:35 AM