]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
added SV_PointContents
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Jul 2003 17:53:04 +0000 (17:53 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Jul 2003 17:53:04 +0000 (17:53 +0000)
moved PointContents and FindNonSolidLocation function pointers into brush from brushq1
added TraceBox function pointer to brush (but no implementations of it yet)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3291 d7cf8633-e32d-0410-b094-e92efae38249

cl_collision.c
model_brush.c
model_shared.h
pr_cmds.c
sv_main.c
sv_move.c
sv_phys.c
world.c
world.h

index dfbc0b805e1bc7ed42f0a1a5767ccf63e1b2e6ad..5b85035f90898719d960f2f7b3da77231ac685c6 100644 (file)
@@ -42,7 +42,10 @@ float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t
        if (hitent)
                *hitent = NULL;
        Mod_CheckLoaded(cl.worldmodel);
-       Collision_ClipTrace(&trace, NULL, cl.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, start, vec3_origin, vec3_origin, end);
+       if (cl.worldmodel && cl.worldmodel->brush.TraceBox)
+               cl.worldmodel->brush.TraceBox(cl.worldmodel, vec3_origin, vec3_origin, &trace, NULL, start, vec3_origin, vec3_origin, end);
+       else
+               Collision_ClipTrace(&trace, NULL, cl.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, start, vec3_origin, vec3_origin, end);
 
        if (impact)
                VectorCopy (trace.endpos, impact);
@@ -71,7 +74,10 @@ float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t
                         || ent->mins[2] > tracemaxs[2] || ent->maxs[2] < tracemins[2])
                                continue;
 
-                       Collision_ClipTrace(&trace, ent, ent->model, ent->origin, ent->angles, ent->mins, ent->maxs, start, vec3_origin, vec3_origin, end);
+                       if (ent->model && ent->model->brush.TraceBox)
+                               ent->model->brush.TraceBox(ent->model, ent->origin, ent->angles, &trace, NULL, start, vec3_origin, vec3_origin, end);
+                       else
+                               Collision_ClipTrace(&trace, ent, ent->model, ent->origin, ent->angles, ent->mins, ent->maxs, start, vec3_origin, vec3_origin, end);
 
                        if (trace.allsolid || trace.startsolid || trace.fraction < maxfrac)
                        {
@@ -93,15 +99,15 @@ float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t
 void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius)
 {
        // FIXME: check multiple brush models
-       if (cl.worldmodel && cl.worldmodel->brushq1.FindNonSolidLocation)
-               cl.worldmodel->brushq1.FindNonSolidLocation(cl.worldmodel, in, out, radius);
+       if (cl.worldmodel && cl.worldmodel->brush.FindNonSolidLocation)
+               cl.worldmodel->brush.FindNonSolidLocation(cl.worldmodel, in, out, radius);
 }
 
 int CL_PointContents(const vec3_t p)
 {
        // FIXME: check multiple brush models
-       if (cl.worldmodel && cl.worldmodel->brushq1.PointContents)
-               return cl.worldmodel->brushq1.PointContents(cl.worldmodel, p);
+       if (cl.worldmodel && cl.worldmodel->brush.PointContents)
+               return cl.worldmodel->brush.PointContents(cl.worldmodel, p);
        return CONTENTS_EMPTY;
 }
 
index a0a3a5b31af808e1eb0eca9d4b66d6ffdb097729..1e170420d0048fa16d8d4a5f9c25d9440b6b3ad6 100644 (file)
@@ -2678,9 +2678,9 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer)
                Host_Error("Mod_Q1BSP_Load: %s has wrong version number(%i should be %i(Quake) or 30(HalfLife))", mod->name, i, BSPVERSION);
        mod->brushq1.ishlbsp = i == 30;
 
-       mod->brushq1.FindNonSolidLocation = Mod_Q1BSP_FindNonSolidLocation;
+       mod->brush.FindNonSolidLocation = Mod_Q1BSP_FindNonSolidLocation;
+       mod->brush.PointContents = Mod_Q1BSP_PointContents;
        mod->brushq1.PointInLeaf = Mod_Q1BSP_PointInLeaf;
-       mod->brushq1.PointContents = Mod_Q1BSP_PointContents;
        mod->brushq1.LeafPVS = Mod_Q1BSP_LeafPVS;
        mod->brushq1.BuildPVSTextureChains = Mod_Q1BSP_BuildPVSTextureChains;
 
@@ -3548,7 +3548,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l)
                 && out->type != Q3FACETYPE_MESH
                 && out->type != Q3FACETYPE_FLARE)
                {
-                       Con_Printf("Mod_Q3BSP_LoadFaces: face #%i: unknown face type %i\n", i, n);
+                       Con_Printf("Mod_Q3BSP_LoadFaces: face #%i: unknown face type %i\n", i, out->type);
                        out->type = 0; // error
                        continue;
                }
index e9027c9ed844b906343b426f31bd3d2ff0d46020..d3f12f953a68898670a9b3b8a008b78c95249473 100644 (file)
@@ -124,7 +124,10 @@ model_sprite_t;
 
 typedef struct model_brush_s
 {
-       char                    *entities;
+       char *entities;
+       void (*FindNonSolidLocation)(struct model_s *model, const vec3_t in, vec3_t out, vec_t radius);
+       int (*PointContents)(struct model_s *model, const float *p);
+       void (*TraceBox)(struct model_s *model, const vec3_t corigin, const vec3_t cangles, void *trace, const void *cent, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end);
 }
 model_brush_t;
 
@@ -216,18 +219,18 @@ typedef struct model_brushq1_s
        int                             light_scalebit;
        float                   light_ambient;
 
-       void (*FindNonSolidLocation)(struct model_s *model, const vec3_t in, vec3_t out, vec_t radius);
        mleaf_t *(*PointInLeaf)(struct model_s *model, const float *p);
-       int (*PointContents)(struct model_s *model, const float *p);
        qbyte *(*LeafPVS)(struct model_s *model, mleaf_t *leaf);
        void (*BuildPVSTextureChains)(struct model_s *model);
 }
 model_brushq1_t;
 
+/* MSVC can't compile empty structs, so this is commented out for now
 typedef struct model_brushq2_s
 {
 }
 model_brushq2_t;
+*/
 
 typedef struct q3mtexture_s
 {
@@ -464,7 +467,9 @@ typedef struct model_s
        model_sprite_t  sprite;
        model_brush_t   brush;
        model_brushq1_t brushq1;
+       /* MSVC can't handle an empty struct, so this is commented out for now
        model_brushq2_t brushq2;
+       */
        model_brushq3_t brushq3;
 }
 model_t;
index 07159201a3d7d19e9b590d1980e7c5ffcdf86c41..f49b2d205729fee951b4daaddcc9142507575fb8 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -1497,7 +1497,7 @@ PF_pointcontents
 */
 void PF_pointcontents (void)
 {
-       G_FLOAT(OFS_RETURN) = sv.worldmodel->brushq1.PointContents(sv.worldmodel, G_VECTOR(OFS_PARM0));
+       G_FLOAT(OFS_RETURN) = SV_PointContents(G_VECTOR(OFS_PARM0));
 }
 
 /*
index e44928158482e1de3f252c0f5f0d40ff35e1f344..74fd70ba600a0c7890d3ca64926085a1901763e7 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -605,7 +605,10 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                testorigin[1] = lhrandom(entmins[1], entmaxs[1]);
                                testorigin[2] = lhrandom(entmins[2], entmaxs[2]);
 
-                               Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
+                               if (sv.worldmodel && sv.worldmodel->brush.TraceBox)
+                                       sv.worldmodel->brush.TraceBox(sv.worldmodel, vec3_origin, vec3_origin, &trace, testeye, vec3_origin, vec3_origin, testorigin);
+                               else
+                                       Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
 
                                if (trace.fraction == 1)
                                        client->visibletime[e] = realtime + 1;
@@ -616,7 +619,10 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                        testorigin[1] = bound(entmins[1], testeye[1], entmaxs[1]);
                                        testorigin[2] = bound(entmins[2], testeye[2], entmaxs[2]);
 
-                                       Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
+                                       if (sv.worldmodel && sv.worldmodel->brush.TraceBox)
+                                               sv.worldmodel->brush.TraceBox(sv.worldmodel, vec3_origin, vec3_origin, &trace, testeye, vec3_origin, vec3_origin, testorigin);
+                                       else
+                                               Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
 
                                        if (trace.fraction == 1)
                                                client->visibletime[e] = realtime + 1;
@@ -982,7 +988,10 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                testorigin[0] = (entmins[0] + entmaxs[0]) * 0.5f;
                                testorigin[1] = (entmins[1] + entmaxs[1]) * 0.5f;
                                testorigin[2] = (entmins[2] + entmaxs[2]) * 0.5f;
-                               Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
+                               if (sv.worldmodel && sv.worldmodel->brush.TraceBox)
+                                       sv.worldmodel->brush.TraceBox(sv.worldmodel, vec3_origin, vec3_origin, &trace, NULL, testeye, vec3_origin, vec3_origin, testorigin);
+                               else
+                                       Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
                                if (trace.fraction == 1)
                                        client->visibletime[e] = realtime + 1;
                                else
@@ -991,7 +1000,10 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                        testorigin[0] = lhrandom(entmins[0], entmaxs[0]);
                                        testorigin[1] = lhrandom(entmins[1], entmaxs[1]);
                                        testorigin[2] = lhrandom(entmins[2], entmaxs[2]);
-                                       Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
+                                       if (sv.worldmodel && sv.worldmodel->brush.TraceBox)
+                                               sv.worldmodel->brush.TraceBox(sv.worldmodel, vec3_origin, vec3_origin, &trace, NULL, testeye, vec3_origin, vec3_origin, testorigin);
+                                       else
+                                               Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
                                        if (trace.fraction == 1)
                                                client->visibletime[e] = realtime + 1;
                                        else
@@ -1002,7 +1014,10 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                                        testorigin[0] = lhrandom(lightmins[0], lightmaxs[0]);
                                                        testorigin[1] = lhrandom(lightmins[1], lightmaxs[1]);
                                                        testorigin[2] = lhrandom(lightmins[2], lightmaxs[2]);
-                                                       Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
+                                                       if (sv.worldmodel && sv.worldmodel->brush.TraceBox)
+                                                               sv.worldmodel->brush.TraceBox(sv.worldmodel, vec3_origin, vec3_origin, &trace, NULL, testeye, vec3_origin, vec3_origin, testorigin);
+                                                       else
+                                                               Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
                                                        if (trace.fraction == 1)
                                                                client->visibletime[e] = realtime + 1;
                                                        else
index 88e4ce6c8f585e7bb56dedc35ce686fb6c1bfe8c..8bb9b75bdc846db41f63bb122521ba944ae36573 100644 (file)
--- a/sv_move.c
+++ b/sv_move.c
@@ -51,7 +51,7 @@ qboolean SV_CheckBottom (edict_t *ent)
                {
                        start[0] = x ? maxs[0] : mins[0];
                        start[1] = y ? maxs[1] : mins[1];
-                       if (sv.worldmodel->brushq1.PointContents(sv.worldmodel, start) != CONTENTS_SOLID)
+                       if (SV_PointContents(start) != CONTENTS_SOLID)
                                goto realcheck;
                }
 
@@ -138,7 +138,7 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
                        if (trace.fraction == 1)
                        {
                                VectorCopy(trace.endpos, traceendpos);
-                               if ( ((int)ent->v->flags & FL_SWIM) && sv.worldmodel->brushq1.PointContents(sv.worldmodel, traceendpos) == CONTENTS_EMPTY )
+                               if (((int)ent->v->flags & FL_SWIM) && SV_PointContents(traceendpos) == CONTENTS_EMPTY )
                                        return false;   // swim monster left water
 
                                VectorCopy (traceendpos, ent->v->origin);
index ad5aa985f7181853696ffd1836b0acee5887610a..76959a5b7a7009aa9a18eaefe15e3cc7342ec2ea 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -854,18 +854,18 @@ qboolean SV_CheckWater (edict_t *ent)
 
        ent->v->waterlevel = 0;
        ent->v->watertype = CONTENTS_EMPTY;
-       cont = sv.worldmodel->brushq1.PointContents(sv.worldmodel, point);
+       cont = SV_PointContents(point);
        if (cont <= CONTENTS_WATER)
        {
                ent->v->watertype = cont;
                ent->v->waterlevel = 1;
                point[2] = ent->v->origin[2] + (ent->v->mins[2] + ent->v->maxs[2])*0.5;
-               cont = sv.worldmodel->brushq1.PointContents(sv.worldmodel, point);
+               cont = SV_PointContents(point);
                if (cont <= CONTENTS_WATER)
                {
                        ent->v->waterlevel = 2;
                        point[2] = ent->v->origin[2] + ent->v->view_ofs[2];
-                       cont = sv.worldmodel->brushq1.PointContents(sv.worldmodel, point);
+                       cont = SV_PointContents(point);
                        if (cont <= CONTENTS_WATER)
                                ent->v->waterlevel = 3;
                }
@@ -1136,7 +1136,7 @@ SV_CheckWaterTransition
 void SV_CheckWaterTransition (edict_t *ent)
 {
        int cont;
-       cont = sv.worldmodel->brushq1.PointContents(sv.worldmodel, ent->v->origin);
+       cont = SV_PointContents(ent->v->origin);
        if (!ent->v->watertype)
        {
                // just spawned here
diff --git a/world.c b/world.c
index 7af2672b7ebda74d312c04da70d75e5b1925ff8d..defb53c3697869bdde78b212dc03aba665e5228a 100644 (file)
--- a/world.c
+++ b/world.c
@@ -479,7 +479,10 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max
                        Host_Error ("SV_ClipMoveToEntity: SOLID_BSP without MOVETYPE_PUSH");
        }
 
-       if (sv_polygoncollisions.integer && (mins[0] != maxs[0] || mins[1] != maxs[1] || mins[2] != maxs[2]))
+       if (model && model->brush.TraceBox)
+               model->brush.TraceBox(model, ent->v->origin, ent->v->angles, &trace, ent, start, mins, maxs, end);
+       // FIXME: these should go away
+       else if (sv_polygoncollisions.integer && (mins[0] != maxs[0] || mins[1] != maxs[1] || mins[2] != maxs[2]))
                Collision_PolygonClipTrace(&trace, ent, model, ent->v->origin, ent->v->angles, ent->v->mins, ent->v->maxs, start, mins, maxs, end);
        else
                Collision_ClipTrace(&trace, ent, model, ent->v->origin, ent->v->angles, ent->v->mins, ent->v->maxs, start, mins, maxs, end);
@@ -704,3 +707,10 @@ trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, e
        return clip.trace;
 }
 
+int SV_PointContents(const vec3_t point)
+{
+       if (sv.worldmodel && sv.worldmodel->brush.PointContents)
+               return sv.worldmodel->brush.PointContents(sv.worldmodel, point);
+       return CONTENTS_SOLID;
+}
+
diff --git a/world.h b/world.h
index eaea6224cf0aaa27c93499ceda2a6f65744bd53f..10419be7650cf3acfafa0f6dae943beb5ad9c7cf 100644 (file)
--- a/world.h
+++ b/world.h
@@ -56,5 +56,7 @@ int SV_TestEntityPosition (edict_t *ent);
 // passedict is explicitly excluded from clipping checks (normally NULL)
 trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, edict_t *passedict);
 
+int SV_PointContents(const vec3_t point);
+
 #endif