implemented playerclip and monsterclip brush support for q3bsp levels
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 11 Apr 2005 02:27:30 +0000 (02:27 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 11 Apr 2005 02:27:30 +0000 (02:27 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5175 d7cf8633-e32d-0410-b094-e92efae38249

bspfile.h
model_brush.c
world.c

index b063041..f01c46e 100644 (file)
--- a/bspfile.h
+++ b/bspfile.h
@@ -180,6 +180,9 @@ typedef struct
 #define SUPERCONTENTS_BODY                     0x00000020
 #define SUPERCONTENTS_CORPSE           0x00000040
 #define SUPERCONTENTS_NODROP           0x00000080
+#define SUPERCONTENTS_PLAYERCLIP       0x00000100
+#define SUPERCONTENTS_MONSTERCLIP      0x00000200
+#define SUPERCONTENTS_DONOTENTER       0x00000400
 #define SUPERCONTENTS_LIQUIDSMASK      (SUPERCONTENTS_LAVA | SUPERCONTENTS_SLIME | SUPERCONTENTS_WATER)
 
 /*
index ce9dcd3..be396fd 100644 (file)
@@ -5337,6 +5337,12 @@ static int Mod_Q3BSP_SuperContentsFromNativeContents(model_t *model, int nativec
                supercontents |= SUPERCONTENTS_CORPSE;
        if (nativecontents & CONTENTSQ3_NODROP)
                supercontents |= SUPERCONTENTS_NODROP;
+       if (nativecontents & CONTENTSQ3_PLAYERCLIP)
+               supercontents |= SUPERCONTENTS_PLAYERCLIP;
+       if (nativecontents & CONTENTSQ3_MONSTERCLIP)
+               supercontents |= SUPERCONTENTS_MONSTERCLIP;
+       if (nativecontents & CONTENTSQ3_DONOTENTER)
+               supercontents |= SUPERCONTENTS_DONOTENTER;
        return supercontents;
 }
 
@@ -5357,6 +5363,12 @@ static int Mod_Q3BSP_NativeContentsFromSuperContents(model_t *model, int superco
                nativecontents |= CONTENTSQ3_CORPSE;
        if (supercontents & SUPERCONTENTS_NODROP)
                nativecontents |= CONTENTSQ3_NODROP;
+       if (supercontents & SUPERCONTENTS_PLAYERCLIP)
+               nativecontents |= CONTENTSQ3_PLAYERCLIP;
+       if (supercontents & SUPERCONTENTS_MONSTERCLIP)
+               nativecontents |= CONTENTSQ3_MONSTERCLIP;
+       if (supercontents & SUPERCONTENTS_DONOTENTER)
+               nativecontents |= CONTENTSQ3_DONOTENTER;
        return nativecontents;
 }
 
diff --git a/world.c b/world.c
index 6cc992f..fb21271 100644 (file)
--- a/world.c
+++ b/world.c
@@ -433,7 +433,7 @@ Handles selection or creation of a clipping hull, and offseting (and
 eventually rotation) of the end points
 ==================
 */
-trace_t SV_ClipMoveToEntity(edict_t *ent, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int movetype)
+trace_t SV_ClipMoveToEntity(edict_t *ent, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int movetype, int hitsupercontents)
 {
        trace_t trace;
        model_t *model = NULL;
@@ -495,16 +495,17 @@ trace_t SV_ClipMoveToEntity(edict_t *ent, const vec3_t start, const vec3_t mins,
        if (model && model->TraceBox)
        {
                int frame;
+               int hitcontents;
                frame = (int)ent->v->frame;
                frame = bound(0, frame, (model->numframes - 1));
                VectorAdd(starttransformed, maxs, starttransformedmaxs);
                VectorAdd(endtransformed, maxs, endtransformedmaxs);
                VectorAdd(starttransformed, mins, starttransformedmins);
                VectorAdd(endtransformed, mins, endtransformedmins);
-               model->TraceBox(model, frame, &trace, starttransformedmins, starttransformedmaxs, endtransformedmins, endtransformedmaxs, SUPERCONTENTS_SOLID);
+               model->TraceBox(model, frame, &trace, starttransformedmins, starttransformedmaxs, endtransformedmins, endtransformedmaxs, hitsupercontents);
        }
        else
-               Collision_ClipTrace_Box(&trace, ent->v->mins, ent->v->maxs, starttransformed, mins, maxs, endtransformed, SUPERCONTENTS_SOLID, SUPERCONTENTS_SOLID);
+               Collision_ClipTrace_Box(&trace, ent->v->mins, ent->v->maxs, starttransformed, mins, maxs, endtransformed, hitsupercontents, SUPERCONTENTS_SOLID);
        trace.fraction = bound(0, trace.fraction, 1);
        trace.realfraction = bound(0, trace.realfraction, 1);
 
@@ -536,6 +537,7 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const
 {
        vec3_t hullmins, hullmaxs;
        int i;
+       int hitsupercontentsmask;
        int passedictprog;
        qboolean pointtrace;
        edict_t *traceowner, *touch;
@@ -563,8 +565,17 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const
        Con_Printf("move(%f %f %f,%f %f %f)", clipstart[0], clipstart[1], clipstart[2], clipend[0], clipend[1], clipend[2]);
 #endif
 
+       hitsupercontentsmask = SUPERCONTENTS_SOLID;
+       if (passedict)
+       {
+               if (passedict->v->solid == SOLID_SLIDEBOX)
+                       hitsupercontentsmask |= SUPERCONTENTS_PLAYERCLIP;
+               if ((int)passedict->v->flags & FL_MONSTER)
+                       hitsupercontentsmask |= SUPERCONTENTS_MONSTERCLIP;
+       }
+
        // clip to world
-       cliptrace = SV_ClipMoveToEntity(sv.edicts, clipstart, clipmins, clipmaxs, clipend, type);
+       cliptrace = SV_ClipMoveToEntity(sv.edicts, clipstart, clipmins, clipmaxs, clipend, type, hitsupercontentsmask);
        if (cliptrace.startsolid || cliptrace.fraction < 1)
                cliptrace.ent = sv.edicts;
        if (type == MOVE_WORLDONLY)
@@ -654,9 +665,9 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const
 
                // might interact, so do an exact clip
                if ((int)touch->v->flags & FL_MONSTER)
-                       trace = SV_ClipMoveToEntity(touch, clipstart, clipmins2, clipmaxs2, clipend, type);
+                       trace = SV_ClipMoveToEntity(touch, clipstart, clipmins2, clipmaxs2, clipend, type, hitsupercontentsmask);
                else
-                       trace = SV_ClipMoveToEntity(touch, clipstart, clipmins, clipmaxs, clipend, type);
+                       trace = SV_ClipMoveToEntity(touch, clipstart, clipmins, clipmaxs, clipend, type, hitsupercontentsmask);
                // LordHavoc: take the 'best' answers from the new trace and combine with existing data
                if (trace.allsolid)
                        cliptrace.allsolid = true;