Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Bouncy Ropes?
#4
(15-12-2022, 11:27 AM)roberthey Wrote: Regarding what you said about applying force to the particles: I had a look at the article - very helpful, thanks. Is the only way I can apply force to modify the velocity of the particles or is there a AddForce like method to do it aswell?

Hi!

There's an externalForces array in the solver that you can write forces into, similar to how you would for all other particle data arrays (velocities, positions, etc). However, all data in this array gets reset to zero at the end of each simulation step (in order to stop applying forces on subsequent frames) which means writing to it during the contact callback doesn't have any effect, as forces aren't carried over to the next frame.

So if you're applying forces during the contact callback, the best way is to modify the velocities itself. Note that F = ma, so a = F/m. Keeping this in mind you can convert a force to an acceleration (that is, a change in velocity) very easily:

Code:
solver.velocities[particleIndex] += yourForce * solver.invMasses[particleIndex] * deltaTime;
Reply


Messages In This Thread
Bouncy Ropes? - by roberthey - 14-12-2022, 06:56 PM
RE: Bouncy Ropes? - by josemendez - 15-12-2022, 09:11 AM
RE: Bouncy Ropes? - by roberthey - 15-12-2022, 11:27 AM
RE: Bouncy Ropes? - by josemendez - 15-12-2022, 11:37 AM
RE: Bouncy Ropes? - by roberthey - 15-12-2022, 12:34 PM