Vehicle collision detection/resolution for Players?
by Daniel Buckmaster · in Technical Issues · 03/29/2009 (10:49 am) · 1 replies
Is this an even remotely sane idea? I've been running into problems with the default Player collision scheme and what I want Players to be able to do, and I'm wondering whether it'd be easier to simply replace the Player box-convex scheme with penetration/impulse collision code like vehicles use.
Is this collision method inherently slower or less stable than Player's standard collision detection?
My thinking is that currently, Players use a large, rigid box to collide against the world. The engine relies on the fact that this box will not penetrate geometry under any circumstances.
I want to add a lot of freedom of movement and agility to Players. A large bounding box simply doesn't cut it. I'd like to be able to use smaller, fitted convex hulls instead, and for them to animate. It seems that if I just checked for these hulls (as mesh objects) to penetrate world geometry, then altered the Player's velocity to resolve penetrations, I'd have a far more flexible system to work with.
Is this collision method inherently slower or less stable than Player's standard collision detection?
My thinking is that currently, Players use a large, rigid box to collide against the world. The engine relies on the fact that this box will not penetrate geometry under any circumstances.
I want to add a lot of freedom of movement and agility to Players. A large bounding box simply doesn't cut it. I'd like to be able to use smaller, fitted convex hulls instead, and for them to animate. It seems that if I just checked for these hulls (as mesh objects) to penetrate world geometry, then altered the Player's velocity to resolve penetrations, I'd have a far more flexible system to work with.
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
Torque Owner Daniel Buckmaster
T3D Steering Committee
Current Player physics:
-Update move: update our current velocity based on control input and some environmental factors
---First, update rotation solely based on user input
---Next, search for ground contacts utilising a flat box at our feet
---Update movement forces, including gravity
-Update pos: attempt to collide with objects while moving in a straight line along our velocity
---Early out if the collision box at our destination is empty
---Loop multiple times through the move routine, adjusting out starting position and velocity each time
---Call onImpact and queue collisions
Current Vehicle physics:
-Update move: converts move data into control inputs
-Update pos: updates the position based on the rigid’s velocity
---Calls the functions below
---Calls onImpact
-Update forces: determine forces acting on our rigid body due to control inputs (and wheels, stabs, etc.)
---Modifies force and torque on the rigid body
---Calls rigid->updateVelocity
---Takes control inputs indirectly
-Update collisions: uses the convex to add collision data to a list
-Resolve collisions: uses impulses to correct penetrations
---Queues collisions
-Resolve contacts: uses spring forces to come to rest on a surface
New Player physics:
-Update move: convert move data to control inputs and do simple processing of things like triggers
---Use a box search to determine whether we have a surface to move on
---Attach to moving platforms, etc.
---Use move values to decide on a directional force
---Use rotation values to get a rotation speed?
---Update stances
---Handle prediction
---Updates limb contraction springs, if applicable
---Updates spring forces, if applicable
-Update pos: updates our velocity and performs collision checks
Convert forces into acceleration and rotation
---Update our velocity
---Call the following functions:
-Update collisions: uses the convex to generate a list of collisions
-Resolve collisions: uses impulses to correct collisions
---Calls onImpact
---Queues collisions
---Applies impulses to other Player objects collided with
There's some my-game specific stuff in there, but you get the general idea of how it breaks down. It's basically a hybrid system, using the Player method of updating our velocity (though we do store things as forces, instead of affecting velocity directly from the move data), and the Vehicle method of resolving collisions.
Players would utilise a ShapeBaseConvex to deal with collisions, rather than a box.