Code center > Suggestions

Outsourcing physics

(1/3) > >>

Numsgil:
I'm redesigning the C++ source from the top down (the broader strokes of the code architecture), and it's pretty easy to "pop" the physics entity from a bot, shot, tie, and shape.  What I mean is it's possible to encapsulate the physics entirely from the rest of the code.

This means it's really not all that hard to move to a 3rd party physics library.  Since this isn't a commercial title, alot of possibilities are open to us:

* PhysX (formerly novodex) is my initial pick.  It's a commercial library recently released for free to non commercial projects since they're trying to hype their new Physics card (the so called PPU).

Which means if we used this library, we have the likely chance of actual physics hardware acceleration in the not so distant future, depending on who ends up winning the API war

* NewtonDynamics would be the other choice in my mind.  It's also free.  For me personally this might be better since I could learn an API that could be used in a potential indie commercial game without paying licensing fees.I'll probably pick one as I come to understand what the different APIs are like, and other factors.  They're both probably doing more than we really need anyway

Why move to a 3rd party physics solution?  Isn't it overkill?:
* Physics is hard to get right.  It's a full time job getting any sort of physics simulation working right.  While the current physics engine in the C++ source is very pleasing (to me atleast), it took alot of time to get that way.  It's still not perfect, and it's possible a more dedicated library could do what I got DB to do but better and faster.
* Expandibility - Really, since these physics engines are used for things a little more complex than spheres rolling around, we should be able to add some new things we think up without any problem.  Physics no longer becomes a conceptual bottleneck.
* Programmer time - More programming time being spent programming ALIfe things instead of tweaking physics constants and algorithms.I'd abstract the interface for the physics engine so you could swap in or out the current physics system for comparison of aesthetics and speed.  Should be fairly trivial.

What are people's thoughts?

EricL:
This would be totally cool.  I probably spend half my time on physics stuff today - more effecient collision routines, etc.  I agonize over whether to add physcis code here or there, whether the perf cost would be worth it.  Wouldn't it be cool if ties were visable, were solid, could be shot, would hit a shape or prevent a multibot from going down a narrow passage, providing selection pressure towards smaller tie lengths....  All of these and each of these is new physics.  It's all circle and rectangle and point and capsule intersection code, something I feel a lot more confident writing today then I did 6 months ago  - something that would be quite ameanable to hardware acceleration I imagine - but its code I would love not to have to write....

One of the fundemental hurdles in ALife is that things don't interact unless programmed to interact.  Things don't collide, bounce, drag, appear visible, exhert force, torque, etc. unless someone writes the code to allow those interactions.  This is completly opposite of the way the physical world works.  The physical world is messy.  You have to go to tremendous lengths to prevent things from interacting in the physcial world and it's this messiness, this plethora of interactions that is critical and necessary or at least as necessary as other factors for biological evolution to occur.

So, the more interactions we can allow, the richer our virtual world will be and the more varied and complex the resulting organisms will be.  I'm a total fan of this.

Testlund:
So there's a physic accelerator card? I had no idea. If it whould improve performance for these kind of programs considerably it whould be worth buying one. I'm just wondering if it whould be difficult to come by. I imagine there wont be much demand for such card. Otherwise I'm all for improvements so I say go for it.  

Numsgil:
At present the cards are about $300 and the common consensus is that there just aren't any games out yet that really need the horsepower of a dedicated physics card.

I think the company has a sort of "if you build it, they will come" mentality.

Physics can also be done on graphics cards since the advent of programmable vertex and fragment shaders (if that sounds greek to you, just nod and smile ).  At present there's a discussion over wether you need a dedicated physics card or if you're better off using the graphics card (or multiple graphics cards).

Don't know if any of this really effects Darwinbots at the moment.  Our physics needs are orders of magnitude less complex than AAA games.

EricL:

--- Quote from: Numsgil ---Our physics needs are orders of magnitude less complex than AAA games.
--- End quote ---

But orders of magnitude more parallel.  Graphics cards are optimized for drawning lots of polygons and doing projections but not necessarily for detecting collisions.  The needs of DB are different than most games.

Navigation

[0] Message Index

[#] Next page

Go to full version