From 0262c14aeb650e51ff12dd52345fedb6594c8c84 Mon Sep 17 00:00:00 2001 From: driAn Date: Sat, 27 Sep 2008 13:08:34 +0000 Subject: [PATCH] faster mapmodel collision test git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2777 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/physics.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 083c491a..a7b47892 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -107,9 +107,10 @@ bool cornertest(int mip, int x, int y, int dx, int dy, int &bx, int &by, int &bs return stest; } -void mmcollide(physent *d, float &hi, float &lo) // collide with a mapmodel +bool mmcollide(physent *d, float &hi, float &lo) // collide with a mapmodel { const float eyeheight = d->dyneyeheight(); + const float playerheight = eyeheight + d->aboveeye; loopv(ents) { entity &e = ents[i]; @@ -123,8 +124,10 @@ void mmcollide(physent *d, float &hi, float &lo) // collide with a map const float dz = d->o.z-eyeheight; if(dzlo) lo = mmz+mmi.h; + if(hi-lo < playerheight) return false; } } + return true; } bool objcollide(physent *d, vec &objpos, float objrad, float objheight) // collide with custom/typeless objects @@ -205,9 +208,7 @@ bool collide(physent *d, bool spawn, float drop, float rise) if(d!=player1) if(!plcollide(d, player1, headspace, hi, lo)) return false; headspace -= 0.01f; - mmcollide(d, hi, lo); // collide with map models - - if(hi-lo < playerheight) return false; + if(!mmcollide(d, hi, lo)) return false; // collide with map models if(spawn) {