Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I've made a bounce script, but don't know how to optimize
#3
Wow thank you for the prompt reply!

Ah, I have to iterate because I need to add the propagate force to nearby particles, not just the particle involved in the contact.
But given it's very heavy I can consider skipping that propagate effect for now.

Quote:
(01-05-2024, 01:17 PM)josemendez Wrote: Hi!

Not sure why you need to iterate trough all particles for every contact, just to find which particle is closest to the contact? Contacts already give you the index of the particle involved in the contact, you can use that. See:
http://obi.virtualmethodstudio.com/manua...sions.html

Code:
// get the particle index directly, as all simplices are guaranteed to have size 1:
int particleIndex = solver.simplices[contact.bodyA];

// do something with the particle, for instance get its position:
var position = solver.positions[particleIndex];
Reply


Messages In This Thread
RE: I've made a bounce script, but don't know how to optimize - by spikebor - 01-05-2024, 01:46 PM