Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How do I set a particle position at runtime ?
#11
If you set a particle position, it can move immediately after due to one of two things:
- The particle is part of an attachment. In that case, as soon as the attachment is updated it will set the particle position so that it doesn't violate the attachment.
- The new position you set violates a constraint. In that case, as soon as the solver is updated, it will set the position to the closest position that does not violate the constraint.

It does not make sense to set the position of an attached particle (you should set the position of whatever it is attached to instead, or set its position and immediately Bind() the attachment)

Setting the position of a single particle without setting all other particles accordingly will cause the solver to immediately modify it as a result of simulating constraints. For instance: if you set a single particle far away from the rest, the solver will immediately project all particles in the rope so that distance constraints are met and the rope keeps its length.

The only way to set a particle position and make sure it is not modified by the simulation is to set its inverse mass to zero, as explained in the docs:
http://obi.virtualmethodstudio.com/tutor...icles.html
Code:
An inverse mass of 0 means the particle's mass is infinite, so its position will be unaffected by dynamics (allowing you to override it manually).

Also, remember that all particle properties are expressed in solver space. So if you set positions, make sure to express them in solver space (meaning, the solver's local space).
Reply
#12
(02-04-2020, 11:48 AM)josemendez Wrote: If you set a particle position, it can move immediately after due to one of two things:
- The particle is part of an attachment. In that case, as soon as the attachment is updated it will set the particle position so that it doesn't violate the attachment.
- The new position you set violates a constraint. In that case, as soon as the solver is updated, it will set the position to the closest position that does not violate the constraint.

It does not make sense to set the position of an attached particle (you should set the position of whatever it is attached to instead, or set its position and immediately Bind() the attachment)

Setting the position of a single particle without setting all other particles accordingly will cause the solver to immediately modify it as a result of simulating constraints. For instance: if you set a single particle far away from the rest, the solver will immediately project all particles in the rope so that distance constraints are met and the rope keeps its length.

The only way to set a particle position and make sure it is not modified by the simulation is to set its inverse mass to zero, as explained in the docs:
http://obi.virtualmethodstudio.com/tutor...icles.html
Code:
An inverse mass of 0 means the particle's mass is infinite, so its position will be unaffected by dynamics (allowing you to override it manually).

Also, remember that all particle properties are expressed in solver space. So if you set positions, make sure to express them in solver space (meaning, the solver's local space).

Alright. This should help a lot and it clears out a lot of the things I misunderstood !
I didn't understand what setting the mass to zero was for, even though I've read the doc so many times.

Thank you very much, Jose. I don't think I'll be having any problem with this issue. 
I don't know how to thank you enough for all you've done on ObiRope and for the customer support.
If you guys have a donation button or a Patreon just let me know.
Thank you !  Sonrojado
Reply
#13
(04-04-2020, 01:39 PM)slugGoddess Wrote: Alright. This should help a lot and it clears out a lot of the things I misunderstood !
I didn't understand what setting the mass to zero was for, even though I've read the doc so many times.

This thread can also give you a bit more insight on why inverse mass is used, instead of mass:
http://obi.virtualmethodstudio.com/forum...p?tid=2130

(The thread is ObiCloth-related, but masses work in the same way in all Obi packages so it doesn't really matter)

(04-04-2020, 01:39 PM)slugGoddess Wrote: Thank you very much, Jose. I don't think I'll be having any problem with this issue. 
I don't know how to thank you enough for all you've done on ObiRope and for the customer support.
If you guys have a donation button or a Patreon just let me know.
Thank you !  Sonrojado

No worries, if you have time (and feel like it) reviews in the store are always appreciated Sonrisa.

Let me know if I can be of further help.
Reply