Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


Ok, I'm stumped on a problem. The said problem is halving the speed of my physics benchmark and causing fps go up and down a lot, like a little monkey on a bungee cord. Ok, so that was the worst analogy of the week, but that's beside the point. The problem has two parts and I'm going to describe them first.

Collision detection in Spineless uses ODE, and ODE must of course know the location of collision geometry to do its thing. So the Space class, responsible for spatial relations of nodes, keeps track of locations of nodes with collision geometry and forwards them to ODE.

Physics simulation in Spineless also uses ODE, and locations of rigid bodies must, of course, be extracted from ODE to use them in the engine. So each step after physics simulation is updated, the Physics class sets locations of all nodes which contain a body.

Combine the behavior described in the last two chapters with the fact that the ODE geometry and body are already linked and maintain the same location, and you can probably see the problem. That is; for each physically simulated node for each step, location of the collision geometry is set completely in waste, because it's already correct.

Now, an obvious first thought for a solution would be to just disable location updates for collision geometry with connected rigid bodies. This would also prevent the user from changing the location of these nodes, so it's no good. I could set a private flag in the Node for each physics update, check it in Space and not update location if it's set, but that reeks of a stinky hack to me.

Bright ideas, please? I'll give you as many cookies as I'm able to find! :)

EDIT: Esteban (my partner in crim... I mean coding) came up with an excellent solution to the problem: for nodes with physically simulated rigid bodies, physics simulation becomes the "owner" of the node's location, and updating it directly doesn't work anymore. You have to update the rigid body's location instead. IMO this is good because it's making it explicit that you're "cheating" the physics and doing something unusual.

# This doesn't work anymore
node = Node()
node.body = Body()
node.position = Vector(1, 2, 3)

# This is the way to do it from now on
node = Node()
node.body = Body()
node.body.position = Vector(1, 2, 3)

Comments about this solution are of course still welcome.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!