Open photonstorm opened 11 years ago
There are a few strategies that will help with the mashing problem:
sim.frame(32)
. It is set to 16 currently.Depending on the effect you're looking for, 4 is probably the most bullet proof way to handle this case. AngularConstraints are computationally more expensive than DistanceConstraints currently. However adding a few AngularConstraints to the inner skeleton of an object should help too.
As for collision detection:
Perfect inelastic collisions would be really difficult (impossible?) to implement in verlet. However you may be able to do something similar if you created a type of distant constraint that repels particles when they are within a threshold distance from each-other. A good name for this type of constraint could be: RepulsiveConstraint. This is something I have been wanting to implement but I've been hung up on other things =)
Thanks. I had tried increasing the steps but it didn't seem to make a huge difference. Re: #4 is there any rule (logic/math) I can apply to the velocity of the particles to ensure they are capped off properly? I don't want to just throw in random values and hope for the best if there's an accurate way of working it out.
Thanks for the RepulsiveConstraint idea. I've been re-reading Bitterli's classic post (http://www.gamedev.net/page/resources/_/technical/math-and-physics/a-verlet-based-approach-for-2d-game-physics-r2714) to see if there was a way to adapt verlet-js to use his rigid-body approach, but haven't got too far yet.
Yes, it would be similar to DistantConstraint which actually does both contracting and repulsing. As a start you could copy DistantConstraint, and when the distance is > than the distance value, have the RepulsiveConstraint do nothing.
Is there a way to stop a composite from getting mashed-up when you slam it against a wall with a lot of force? For example the particles can collapse on themselves and either seemingly vanish (from a visual point of view) or are combining on-top of themselves.
I've tried the new bounds check in the Pull Request but it happens for that also. I've tried setting stiffness to 1 but it doesn't seem to prevent it. Am I missing something obvious?
Also any pointers on how to handle collision between two composite objects?