29-04-2025, 11:01 AM
(This post was last modified: 29-04-2025, 11:16 AM by josemendez.)
(29-04-2025, 10:52 AM)ozeecode Wrote: Hello again,
I’ve managed to work around the async issues for now.
Regarding your comment when adding particles:
How can I determine the last active particle here? In other words, what should particle1 and particle2 be?Code:while (rope.activeParticleCount < particleCount)
{
rope.elements.Add(new ObiStructuralElement
{
particle1 = rope.elements[^1].particle1, //--> these are not correct!
particle2 = rope.elements[^1].particle2, //--> these are not correct!
restLength = rope.interParticleDistance
});
rope.ActivateParticle();
}
What this code does is simply append a new element and a new particle to the rope. "()" being a particle and "-----" being an element linking 2 particles, a rope looks like this:
( A )------( B )-----( C )------( D )
And the list of elements for this rope would be:
element 1: particle1 = A, particle2 = B
element 2: particle1 = B, particle2 = C,
element 3: particle1 = C, particle2 = D
(29-04-2025, 10:52 AM)ozeecode Wrote: I was not able to acquire index of the particle that was activated last.
Just like elements, particles are stored in a list. Activating a particle simply adds an active particle to the list. So rope.activeParticleCount is the index of the particle that's going to get activated next, and rope.activeParticleCount-1 the index of the last active particle.
So when adding a new element, its first particle must be the second particle of the previous element. Its second particle must of course be the new particle we are about to activate.
Code:
rope.elements.Add(new ObiStructuralElement
{
particle1 = rope.elements[^1].particle2,
particle2 = rope.solverIndices[rope.activeParticleCount],
restLength = rope.interParticleDistance
});
kind regards