dpjudas / SurrealEngine

Unreal Tournament Engine Reimplementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Collision cylinders aren't being respected properly

Xaleros opened this issue · comments

Lot of weird things happening here, the main symptoms I notice are

  • Your own projectiles blow up in your face immediately (collision too big)
  • Gibs/carcasses land offset from the ground (collision height being treated larger than it actually is)
  • Trace seems to pass through bots when it shouldn't (collision too small)

Currently debugging carcass falling behavior in a test map

Couple of interesting findings using a 512x512x512 test cube map, where highest Z is 256 and lowest Z is -256

  1. Using a custom decoration with falling physics (subclassed from TMale2Carcass) and logging the HitNormal in event Landed, UE1 shows HitNormal.Z of -240, UTEngine shows -214 exactly. From UE1, I would've expected (-256 + CollisionHeight) where CollisionHeight is 13, but its slightly off. Might need to test with other decoration types

  2. Actors seem to have an almost "capsule" like hitbox, if I walk over the carcass in UE1, there is a flat Z increase after walking on top of the carcass. In UTEngine, there is some progression in Z going up and down as I walk across

Will take a look at what collision is used and how it is implemented for TryMove

About 1), TraceCylinderLevel::Trace needs to use TraceAABBModel instead of TraceSphereModel for actor/level collision. This involves fully implementing TraceAABBModel::Trace. UE1 used some kind of hull planes intersection test here with acceleration structures in the BSP (the hull planes). I'm not 100% sure which algorithm this is relying on exactly. We need to either figure out what algorithm that is (any links to describing it would be most welcome), OR we need to build our own that effectively performs the same AABB intersection test.

The CollisionHeight thing might still be off after doing that, but then at least we know it is down to some extra padding or missing math mapping CollisionHeight to the collision extents. As it is right now the spheres approximation for cylinders/AABBs are causing too much trouble.

About 2), TraceCylinderLevel::Trace is using two spheres for actor/actor collision. CollisionHash::ActorSphereIntersect needs to be replaced with with an ActorCylinderIntersect function that does a proper cylinder/cylinder collision detection. That should make it go up and down correctly.