adonthell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-devel] Collision woes ...


From: Kai Sterker
Subject: [Adonthell-devel] Collision woes ...
Date: Sun, 10 Feb 2008 18:15:13 +0100

After further refinement of collision debug output, I have possibly
found what is wrong with climbing up stairs. It's not lack of speed,
but rather some odd behavior of the collision code itself. I'll try to
explain what happens, in the hope that a simple solution comes forth
(beware the ASCII art).

Consider this:

-------+   <----  O
       +--------------

Our character (a sphere) is nearing the stair. Movement is parallel to
the ground, so it won't collide with anything.

        \
-------+\O
       +-\-------------

At some point, we hit the stair and movement is deflected along a
tangent through the collision point. This is where the problem occurs:
at that point, movement is no longer parallel to the ground, but the
sphere is still resting on it. This is detected as a collision, even
though the sphere only touches the ground and is actually moving away
from it.

The tangent is now parallel to the ground, so the new velocity will
also be parallel to the ground, albeit smaller than at first. We
collide with the actual stair again and the vicious circle continues.

The following output shows the oscillating velocity (Vel) as we
collide (Col) either with the stair (0, 2, 4) or the ground (1, 3, 5).
At a recursion depth of 6 the algorithm bails out and we're stuck
right before the stair.

[0] Pos [2.5038, 0.2842, 1.0000] Vel [0.0750, 0.0000, 0.0000]
    Col [3.0000, 0.2842, 0.1250] Dst 0.01211
[1] Pos [2.5158, 0.2842, 1.0000] Vel [0.0574, 0.0000, 0.0318]
    Col [2.5158, 0.2842, 2.0000] Dst 0.00000
[2] Pos [2.5158, 0.2842, 1.0000] Vel [0.0574, 0.0000, 0.0000]
    Col [3.0000, 0.2842, 0.1250] Dst 0.00005
[3] Pos [2.5158, 0.2842, 1.0000] Vel [0.0440, 0.0000, 0.0243]
    Col [2.5158, 0.2842, 2.0000] Dst 0.00000
[4] Pos [2.5158, 0.2842, 1.0000] Vel [0.0440, 0.0000, 0.0000]
    Col [3.0000, 0.2842, 0.1250] Dst 0.00005
[5] Pos [2.5158, 0.2842, 1.0000] Vel [0.0337, 0.0000, 0.0186]
    Col [2.5158, 0.2842, 2.0000] Dst 0.00000
[6] Pos [2.5158, 0.2842, 1.0000] Vel [0.0337, 0.0000, 0.0000]

Obviously, resting on a surface and moving away from it should not
count as a collision ... it should probably be sorted out as
backfacing before. However, our ground tiles have a front and a back
and a thickness of 0. So I could imagine that the back of the ground
faces the same direction as the sphere movement and hence the
collision.

As a solution, perhaps our ground tiles shouldn't have a back side to
begin with ... or they should have thickness at least, so that a
character standing on the ground won't collide with the "underground"
:-).


And once again, writing stuff down seems to bring a solution more
easily than attempting to solve stuff by trial and error. If things
work out, a fix should be in CVS soon ... meaning we're closing in on
v0.4 alpha 2 :-).

Kai




reply via email to

[Prev in Thread] Current Thread [Next in Thread]