Sunday, November 2, 2008

Table gun

Based on recent [lack of] progress I've put the floatsinspace project on hold for a while. It's tricky to deal with multiple physics spaces when I still haven't written the basics, so I made a new project folder (called "mod" for +1 Creativity) and started over. The goal with this one is to get an entity system, player movement and interaction, and Wire kind of stuff working. If it goes really well I will use it as a base for some tests with networked play and we will kill Garry's Mod and probably rule the world (waaay out there though).

I put in some basic player movement a few weeks ago. The player is represented by a capsule object (a cylinder with hemispheres on the ends) and is moved by applying equal and opposite forces to the "ground" (whatever is below the player) and the player itself. It works, but I got bored with walking around and jumping so I thought a weapon/tool system would be a good next addition.

The code for the tool system is a complete mess (polymorphism by arrays of void* and lots of reinterpret_cast) but it will work until I rewrite it as an object hierarchy. The first set of test tools I created were a table making tool and a deleter. The table maker spawns tables (roughly like the one my monitor sits on) wherever you are looking. The deleter deletes stuff.

Here's a picture of the table maker in action (BAMF! Look at that table!):


The underlying system is about as simple as it can be right now. I'm using the Open Dynamics Engine as both a physics engine and collision system. The world state is stepped at 100 Hz and the renderer goes as quickly as it can without exceeding 60 FPS or the speed of the simulation. Performance seems to be okay even with lots of tables in weird positions.

This was going at 60 FPS (good sign that performance won't suck too much):


The two problems I'm seeing right now are some interobject penetration and some stacking instability. Dropping a table on another at a right angle results in the falling table shoving through the stationary one and they end up stacked in the wrong order. The table top is only 2 cm thick so this will probably be less of a problem for collisions between big things, but it means I may have to up the physics step rate. Uniform stacks of a few tables are no problem but they wobble if you stand perfectly still on them. Again, this might be helped by increasing the physics step rate but there are definite limits to doing that. I was originally testing with a 1 kHz step rate which looked good until I realized how slow it got with more than ten objects in existence.

No comments:

Post a Comment