[Algorithms] Kinematic Collision
Brought to you by:
vexxed72
|
From: Johan G. <spi...@gm...> - 2009-09-01 22:34:12
|
Does anyone know any good paper on handling collision between kinematic
objects & static shapes, I dont know the correct term but I think I'm
aiming at the collision model used in almost all games today, i.e. a
none-physical solution with bump & slide. My current implementation is
almost working but I have a couple of question marks I need to sort out,
mainly stability, performance and slope/stepping.
The way I'm doing it now is a recursive collision response, performing
the following steps.
While iterations are not to high
Step 1:
If our current position is our target position we can end, otherwise
do a capsulesweep from our current position to our target position + a
small bias, if no collision is reported we can end otherwise continue to
step 2
Step 2:
Calculate the closest position before the collision point and offset
with the bias, Set our current position to this location.
* NewPosition = Position + Direction * (DistanceToImpact - Bias)
Step 3:
Find the vector from the new position and the target location and
retrieve the reflection/tangent components. Set new target position to
the new current position and add both components scaled by a
bounce/friction value [0, 1] to it..
* NormalMotion = NormalComponent * Bounce
* TangentMotion = TangentComponent * Friction
* NewTargetPosition = NewPosition + NormalMotion + TangentMotion
Repeat Step 1:
This algo is not very stable, sometimes when I calculate the position
right before the impact point it will closer then my bias, resulting in
weird behavior, but I'm unsure how this can happen since I make sure to
include the bias during the offset, and I have also tried setting the
collision point with 2x bias as offset.
I'm also worried that it will fail to solve the collision before running
out of iterations, but building the level with some constraints is maybe
enough promise to never allow this to happen? How are you guys doing
this? I have also peaked on the NxCharacter source and it looks ALOT
more advanced then my simple algo and I take it like I'm missing to
perform some important steps?
I also whonder how stepping & sloping could be handled, right now I was
hoping that the capsule hemispheres would automatically solve this issue
by giving me tangential motion for objects small enough, causing
automatic stepping, but so far no luck, but this is probably due to the
bias issue.
Atleast the capsule cannot interpenetrate objects, but I need to be able
to handle slops & stairs, any link to a good paper or personal
experience/knowledge is highly appreciated.
|