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
#2
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 josemendez - 01-05-2024, 01:17 PM