• entries
155
100
• views
94042

# Probs

87 views

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 anymorenode = Node()node.body = Body()node.position = Vector(1, 2, 3)# This is the way to do it from now onnode = Node()node.body = Body()node.body.position = Vector(1, 2, 3)

There are no comments to display.

## Create an account

Register a new account