New Physics Engine

Topics: User Forum
Feb 25, 2009 at 5:32 AM
Hey guys i thought you might be interested: i am making a new physics engine called AtomPhysics. This engine will simulate small points called Atoms and can be used (at least soon i hope) to model stuff like realistically deforming objects, destroyable objects, and more! i probably won't release it to the public (unless i use it for a game or something) because its primarily a learning project for implementing stuff and expanding my math abilities. Anyway, the reason i am mentioning this is because the points are modeled as perfect circles and it might be useful to your efforts to add perfect circles to your game engine. However, since i dont know how to do some things i might ask you for hints from time to time. For example: i want to make code that takes in a set of points (similar to the one your geoms use) and outputs a list of points i can use in construction of groups of these atoms. Im thinking something like the distance grid would work, but im not sure how to take that technique and turn it into a method that i can use to make said atom groups. One last thing: my engine is patterned heavily after yours (it uses a lot of the same code constructs like a separate broad and narrow phase collider, interfaces, factories, etc.), so thanks for a great engine! by the way, if you have any ideas about what would be a good learning experience to add, please tell me and i just might add it!
Feb 25, 2009 at 8:42 AM
Sounds great RCIX. Looking forward to see what you come up with.
Feb 26, 2009 at 7:29 AM
Thanks! i'm having a problem though: i implemented a simple joint type thing that constrains 2 atoms to a fixed distance between one another, but when i try to make a chain it explodes.

            Vector2 posDiff = _a2.Position - _a1.Position;
            Vector2 posDiffNormal = posDiff;
            //the direction of the collision
            float posDiffLength = posDiff.Length();
            float distanceOffTargetLength = _targetLength - posDiffLength;
            if (distanceOffTargetLength - _maxError >= _targetLength)

            Vector2 impulseAmount = Vector2.Multiply(posDiffNormal, distanceOffTargetLength);

By looking over the code, can you tell if i am doing anything wrong? (the ApplyImpulse functions directly affect the bodies position)
Mar 7, 2009 at 10:12 AM
Update: i've made significant progress on the engine (adding constraints, installing factories, etc). I've switched to a verlet integrator (i think its unique, but i'm probably wrong) for my updating process and it seems to be much more stable now (on a side note, what kind of integration do you use? forward euler, verlet?). I need to clean up my code, add a few features, and do some more investigation for other ones, but i plan to release it in some form soon (i hope). I'm thinking ill write an article about the construction of the engine and post it over on CodeProject. Not sure about this though, so stay tuned.