HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Physic help

09-12-2008, 10:33 PM#1
MaD[Lion]
Oki ive been working with my physic engine again, and everything is working nicely, the physic laws are really good now, friction and collisions impulse based.

Now i have a problem, anyone know a way to simulate the friction between objects in collision, so that they can stack on eachother at rest and not just push/slide eachother away?

And another thing is if anyone know formula for spring constraint.
And how to make it stift so tat i can simulate a straight rope.
09-13-2008, 05:25 AM#2
grim001
I don't believe that friction between objects, constraint-based collision solving, or other methods like that are feasible or needed in WC3. If you just want your balls to stack on top of each other in a crater, it is possible without that.

Assuming your problem is that the problem is that they remain too energetic to come to rest on top of one another, then the problem is most likely one or all of the following:

1.) Are you using conservation of momentum formula as the basis for collision resolution?

2.) Are you using coefficient of restitution? In order for collisions to cause a net loss of energy, the COR of the collision must be < 1. With a COR <1, you should see the balls quickly lose energy as they collide and begin to settle together and on top of one another.

3.) When you calculate a bounce off the ground or a collision, are you moving the ball to the exact point of collision? Then you must deduct that elapsed amount of time from the time the object moves for at the end of the frame. For example, assuming the period were 0.025, if a bounce occured at 0.01 seconds into the frame, update its position to the exact point of contact with the ground, adjust the object's velocity, then make sure the ball only moves for 0.015 seconds at the end of the frame. Same thing with collisions. Skipping this will produce too much energy when objects bounce or collide, causing them to jitter.

4.) At the beginning of a frame you need to calculate the total acceleration for that object, and apply half of it at first, then apply the other half at the end of the frame (after movement). In other words, the ball's velocity when it bounces or collides needs to be the average for the frame, not the amount it would have had at the end of the frame. If you skip this step, balls will produce excess energy when they bounce or collide, which causes jittering.

Assuming you do all of that, the balls should come to rest together and stack very nicely, however you are going to unleash a whole new problem, which is that you're going to lag very badly with 20 or 30 balls in constant physical contact with one another. But resolving that is a whole other topic of discussion.
09-13-2008, 05:48 AM#3
grim001
I just started working on it again the other day when I have time... I didn't even have wc3 installed for a couple months.
09-13-2008, 12:48 PM#4
MaD[Lion]
my problem is not they are too energetic, i just want them stack. and if its needed for wc3 or not tats wc3's problem XD Im just making alot of stuff for wc3. Regular expression engine, pathfinding, and soon fluid simulation. But first i need to make this thing work.
I want balls to stack on a pile, not crater cus they already do

and yes i do have impulse and conservation of momentum and COR and all tat corrently. And the acceleration i add at beginning of frame with a small trick to make it come to rest which isnt the same as ur. I dont have any crazy enegertic balls or anything.

And the performance is ok for me, it is around ur system with a minus. Cus my system was originally bad, too late to save it now ^^
But if u wanna share the performance thing then i would like to hear ^^ Or more like i want u to share it
09-13-2008, 02:02 PM#5
grim001
If you are forming a pyramid of balls without a crater, all you need is for the balls on the bottom to have very high friction/mass and they should be able to support the weight without slipping.

Pipedream is the only one on this site I know of who knows anything about solving collisions using constraints, the last paper I looked at on that subject was full of calculus and I decided it probably won't run very well in wc3. It might be fun though.