Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  ObiRope Points
#10
(19-10-2021, 11:47 AM)Matbee Wrote: I got it to display several different positions for all particles, but most of the particles have the same position as in the screenshot below

Yes, those are the pooled (inactive) particles. Quoting myself:

Quote:For instance, to print the solver-space position of all particles (including inactive ones):
Code:
for (int i = 0; i < actor.solverIndices.Length; ++i)
{
Debug.Log(solver.positions[actor.solverIndices[i]]);
}

A certain amount of extra particles are preallocated when you create a rope blueprint. These are collectively referred to as the particle "pool", and start out inactive (invisible, and not used in the simulation). If you do not plan on resizing or cutting the rope at runtime, you can set the blueprint's pool size to zero. No inactive particles will be added to the rope.

The reason for preallocating particles and activating/deactivating them instead of just creating/destroying particles at runtime is -as with most pooling strategies in Unity- to avoid runtime allocation and minimize garbage collection. See:
http://obi.virtualmethodstudio.com/manua...setup.html

Quote:Pooled particles:
(Ropes only). Extra particles allocated to be used when tearing or resizing the rope. You can set this value to zero if you do not plan on tearing or resizing the rope at runtime, as no extra particles besides the initial ones will be needed.

Assuming you do have a non-empty pool, if you want to only get the active particles you should do:
Code:
for (int i = 0; i < actor.activeParticleCount; ++i)
{
Debug.Log(solver.positions[actor.solverIndices[i]]);
}
Reply


Messages In This Thread
ObiRope Points - by Matbee - 19-10-2021, 10:26 AM
RE: ObiRope Points - by josemendez - 19-10-2021, 10:50 AM
RE: ObiRope Points - by Matbee - 19-10-2021, 11:24 AM
RE: ObiRope Points - by josemendez - 19-10-2021, 11:27 AM
RE: ObiRope Points - by Matbee - 19-10-2021, 11:00 AM
RE: ObiRope Points - by josemendez - 19-10-2021, 11:24 AM
RE: ObiRope Points - by Matbee - 19-10-2021, 11:28 AM
RE: ObiRope Points - by josemendez - 19-10-2021, 11:29 AM
RE: ObiRope Points - by Matbee - 19-10-2021, 11:47 AM
RE: ObiRope Points - by josemendez - 19-10-2021, 12:02 PM
RE: ObiRope Points - by Matbee - 19-10-2021, 01:26 PM
RE: ObiRope Points - by josemendez - 19-10-2021, 01:30 PM
RE: ObiRope Points - by Matbee - 19-10-2021, 02:36 PM
RE: ObiRope Points - by josemendez - 19-10-2021, 02:50 PM
RE: ObiRope Points - by Matbee - 19-10-2021, 02:52 PM
RE: ObiRope Points - by josemendez - 19-10-2021, 03:02 PM
RE: ObiRope Points - by Matbee - 19-10-2021, 04:23 PM
RE: ObiRope Points - by josemendez - 19-10-2021, 04:36 PM
RE: ObiRope Points - by Matbee - 20-10-2021, 09:23 AM
RE: ObiRope Points - by josemendez - 20-10-2021, 09:53 AM
RE: ObiRope Points - by Matbee - 20-10-2021, 02:12 PM
RE: ObiRope Points - by josemendez - 20-10-2021, 02:30 PM
RE: ObiRope Points - by Matbee - 20-10-2021, 04:06 PM
RE: ObiRope Points - by josemendez - 20-10-2021, 05:41 PM
RE: ObiRope Points - by Matbee - 21-10-2021, 10:14 PM
RE: ObiRope Points - by josemendez - 21-10-2021, 10:26 PM
RE: ObiRope Points - by Matbee - 21-10-2021, 10:42 PM
RE: ObiRope Points - by josemendez - 22-10-2021, 07:18 AM
RE: ObiRope Points - by Matbee - 22-10-2021, 07:56 AM
RE: ObiRope Points - by josemendez - 22-10-2021, 08:04 AM
RE: ObiRope Points - by Matbee - 22-10-2021, 08:20 AM
RE: ObiRope Points - by josemendez - 22-10-2021, 08:30 AM
RE: ObiRope Points - by Matbee - 22-10-2021, 08:41 AM
RE: ObiRope Points - by josemendez - 22-10-2021, 08:46 AM
RE: ObiRope Points - by Matbee - 22-10-2021, 12:40 PM
RE: ObiRope Points - by josemendez - 25-10-2021, 08:44 AM
RE: ObiRope Points - by josemendez - 22-10-2021, 08:46 AM