]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_collision.c
Add a third masterextra and default it to dpm.dpmaster.org
[xonotic/darkplaces.git] / cl_collision.c
index eb7a4dd923517688357fb72500d0ff00cd11124f..97303e7a92a9775678e2b5b5c7eefaaeba384cb2 100644 (file)
@@ -83,7 +83,7 @@ void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius)
                cl.worldmodel->brush.FindNonSolidLocation(cl.worldmodel, in, out, radius);
 }
 
-dp_model_t *CL_GetModelByIndex(int modelindex)
+model_t *CL_GetModelByIndex(int modelindex)
 {
        if(!modelindex)
                return NULL;
@@ -101,10 +101,10 @@ dp_model_t *CL_GetModelByIndex(int modelindex)
        return NULL;
 }
 
-dp_model_t *CL_GetModelFromEdict(prvm_edict_t *ed)
+model_t *CL_GetModelFromEdict(prvm_edict_t *ed)
 {
        prvm_prog_t *prog = CLVM_prog;
-       if (!ed || ed->priv.server->free)
+       if (!ed || ed->free)
                return NULL;
        return CL_GetModelByIndex((int)PRVM_clientedictfloat(ed, modelindex));
 }
@@ -117,14 +117,14 @@ void CL_LinkEdict(prvm_edict_t *ent)
        if (ent == prog->edicts)
                return;         // don't add the world
 
-       if (ent->priv.server->free)
+       if (ent->free)
                return;
 
        // set the abs box
 
        if (PRVM_clientedictfloat(ent, solid) == SOLID_BSP)
        {
-               dp_model_t *model = CL_GetModelByIndex( (int)PRVM_clientedictfloat(ent, modelindex) );
+               model_t *model = CL_GetModelByIndex( (int)PRVM_clientedictfloat(ent, modelindex) );
                if (model == NULL)
                {
                        Con_Printf("edict %i: SOLID_BSP with invalid modelindex!\n", PRVM_NUM_FOR_EDICT(ent));
@@ -203,7 +203,7 @@ int CL_GenericHitSuperContentsMask(const prvm_edict_t *passedict)
 CL_Move
 ==================
 */
-trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, qboolean hitnetworkbrushmodels, qboolean hitnetworkplayers, int *hitnetworkentity, qboolean hitcsqcentities)
+trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities)
 {
        prvm_prog_t *prog = CLVM_prog;
        int i, bodysupercontents;
@@ -223,10 +223,11 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int
        // matrices to transform into/out of other entity's space
        matrix4x4_t matrix, imatrix;
        // model of other entity
-       dp_model_t *model;
+       model_t *model;
        // list of entities to test for collisions
        int numtouchedicts;
        static prvm_edict_t *touchedicts[MAX_EDICTS];
+       int clipgroup;
 
        if (hitnetworkentity)
                *hitnetworkentity = 0;
@@ -248,7 +249,7 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int
 
        if (type == MOVE_MISSILE)
        {
-               // LordHavoc: modified this, was = -15, now -= 15
+               // LadyHavoc: modified this, was = -15, now -= 15
                for (i = 0;i < 3;i++)
                {
                        clipmins2[i] -= 15;
@@ -266,8 +267,8 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int
        // debug override to test against everything
        if (sv_debugmove.integer)
        {
-               clipboxmins[0] = clipboxmins[1] = clipboxmins[2] = -999999999;
-               clipboxmaxs[0] = clipboxmaxs[1] = clipboxmaxs[2] =  999999999;
+               clipboxmins[0] = clipboxmins[1] = clipboxmins[2] = (vec_t)-999999999;
+               clipboxmaxs[0] = clipboxmaxs[1] = clipboxmaxs[2] =  (vec_t)999999999;
        }
 
        // if the passedict is world, make it NULL (to avoid two checks each time)
@@ -280,6 +281,8 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int
        // precalculate passedict's owner edict pointer for comparisons
        traceowner = passedict ? PRVM_PROG_TO_EDICT(PRVM_clientedictedict(passedict, owner)) : NULL;
 
+       clipgroup = passedict ? (int)PRVM_clientedictfloat(passedict, clipgroup) : 0;
+
        // collide against network entities
        if (hitnetworkbrushmodels)
        {
@@ -381,6 +384,9 @@ skipnetworkplayers:
                        // don't clip owner against owned entities
                        if (passedictprog == PRVM_clientedictedict(touch, owner))
                                continue;
+                       // don't clip against any entities in the same clipgroup (DP_RM_CLIPGROUP)
+                       if (clipgroup && clipgroup == (int)PRVM_clientedictfloat(touch, clipgroup))
+                               continue;
                        // don't clip points against points (they can't collide)
                        if (VectorCompare(PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs)) && (type != MOVE_MISSILE || !((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)))
                                continue;
@@ -418,7 +424,7 @@ finished:
 CL_TraceLine
 ==================
 */
-trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qboolean hitnetworkbrushmodels, qboolean hitnetworkplayers, int *hitnetworkentity, qboolean hitcsqcentities, qboolean hitsurfaces)
+trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities, qbool hitsurfaces)
 {
        prvm_prog_t *prog = CLVM_prog;
        int i, bodysupercontents;
@@ -438,10 +444,11 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
        // matrices to transform into/out of other entity's space
        matrix4x4_t matrix, imatrix;
        // model of other entity
-       dp_model_t *model;
+       model_t *model;
        // list of entities to test for collisions
        int numtouchedicts;
        static prvm_edict_t *touchedicts[MAX_EDICTS];
+       int clipgroup;
        if (VectorCompare(start, end))
                return CL_TracePoint(start, type, passedict, hitsupercontentsmask, skipsupercontentsmask, skipmaterialflagsmask, hitnetworkbrushmodels, hitnetworkplayers, hitnetworkentity, hitcsqcentities);
 
@@ -466,7 +473,7 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
 
        if (type == MOVE_MISSILE)
        {
-               // LordHavoc: modified this, was = -15, now -= 15
+               // LadyHavoc: modified this, was = -15, now -= 15
                for (i = 0;i < 3;i++)
                {
                        clipmins2[i] -= 15;
@@ -484,8 +491,8 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
        // debug override to test against everything
        if (sv_debugmove.integer)
        {
-               clipboxmins[0] = clipboxmins[1] = clipboxmins[2] = -999999999;
-               clipboxmaxs[0] = clipboxmaxs[1] = clipboxmaxs[2] =  999999999;
+               clipboxmins[0] = clipboxmins[1] = clipboxmins[2] = (vec_t)-999999999;
+               clipboxmaxs[0] = clipboxmaxs[1] = clipboxmaxs[2] =  (vec_t)999999999;
        }
 
        // if the passedict is world, make it NULL (to avoid two checks each time)
@@ -498,6 +505,8 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
        // precalculate passedict's owner edict pointer for comparisons
        traceowner = passedict ? PRVM_PROG_TO_EDICT(PRVM_clientedictedict(passedict, owner)) : NULL;
 
+       clipgroup = passedict ? (int)PRVM_clientedictfloat(passedict, clipgroup) : 0;
+
        // collide against network entities
        if (hitnetworkbrushmodels)
        {
@@ -599,6 +608,9 @@ skipnetworkplayers:
                        // don't clip owner against owned entities
                        if (passedictprog == PRVM_clientedictedict(touch, owner))
                                continue;
+                       // don't clip against any entities in the same clipgroup (DP_RM_CLIPGROUP)
+                       if (clipgroup && clipgroup == (int)PRVM_clientedictfloat(touch, clipgroup))
+                               continue;
                        // don't clip points against points (they can't collide)
                        if (VectorCompare(PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs)) && (type != MOVE_MISSILE || !((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)))
                                continue;
@@ -636,13 +648,13 @@ finished:
 CL_Move
 ==================
 */
-trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qboolean hitnetworkbrushmodels, qboolean hitnetworkplayers, int *hitnetworkentity, qboolean hitcsqcentities)
+trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities)
 {
        prvm_prog_t *prog = CLVM_prog;
        vec3_t hullmins, hullmaxs;
        int i, bodysupercontents;
        int passedictprog;
-       qboolean pointtrace;
+       qbool pointtrace;
        prvm_edict_t *traceowner, *touch;
        trace_t trace;
        // temporary storage because prvm_vec_t may need conversion
@@ -660,10 +672,11 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
        // matrices to transform into/out of other entity's space
        matrix4x4_t matrix, imatrix;
        // model of other entity
-       dp_model_t *model;
+       model_t *model;
        // list of entities to test for collisions
        int numtouchedicts;
        static prvm_edict_t *touchedicts[MAX_EDICTS];
+       int clipgroup;
        if (VectorCompare(mins, maxs))
        {
                vec3_t shiftstart, shiftend;
@@ -700,7 +713,7 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
 
        if (type == MOVE_MISSILE)
        {
-               // LordHavoc: modified this, was = -15, now -= 15
+               // LadyHavoc: modified this, was = -15, now -= 15
                for (i = 0;i < 3;i++)
                {
                        clipmins2[i] -= 15;
@@ -727,8 +740,8 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
        // debug override to test against everything
        if (sv_debugmove.integer)
        {
-               clipboxmins[0] = clipboxmins[1] = clipboxmins[2] = -999999999;
-               clipboxmaxs[0] = clipboxmaxs[1] = clipboxmaxs[2] =  999999999;
+               clipboxmins[0] = clipboxmins[1] = clipboxmins[2] = (vec_t)-999999999;
+               clipboxmaxs[0] = clipboxmaxs[1] = clipboxmaxs[2] =  (vec_t)999999999;
        }
 
        // if the passedict is world, make it NULL (to avoid two checks each time)
@@ -743,6 +756,8 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
        // precalculate passedict's owner edict pointer for comparisons
        traceowner = passedict ? PRVM_PROG_TO_EDICT(PRVM_clientedictedict(passedict, owner)) : NULL;
 
+       clipgroup = passedict ? (int)PRVM_clientedictfloat(passedict, clipgroup) : 0;
+
        // collide against network entities
        if (hitnetworkbrushmodels)
        {
@@ -844,6 +859,9 @@ skipnetworkplayers:
                        // don't clip owner against owned entities
                        if (passedictprog == PRVM_clientedictedict(touch, owner))
                                continue;
+                       // don't clip against any entities in the same clipgroup (DP_RM_CLIPGROUP)
+                       if (clipgroup && clipgroup == (int)PRVM_clientedictfloat(touch, clipgroup))
+                               continue;
                        // don't clip points against points (they can't collide)
                        if (pointtrace && VectorCompare(PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs)) && (type != MOVE_MISSILE || !((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER)))
                                continue;
@@ -896,7 +914,7 @@ trace_t CL_Cache_TraceLineSurfaces(const vec3_t start, const vec3_t end, int typ
        // matrices to transform into/out of other entity's space
        matrix4x4_t matrix, imatrix;
        // model of other entity
-       dp_model_t *model;
+       model_t *model;
        // list of entities to test for collisions
        int numtouchedicts;
        static prvm_edict_t *touchedicts[MAX_EDICTS];
@@ -960,7 +978,7 @@ trace_t CL_Cache_TraceLineSurfaces(const vec3_t start, const vec3_t end, int typ
                if (!model)
                        continue;
                // animated models are not suitable for caching
-               if ((touch->priv.server->frameblend && (touch->priv.server->frameblend[0].lerp != 1.0 || touch->priv.server->frameblend[0].subframe != 0)) || touch->priv.server->skeleton.relativetransforms)
+               if ((&touch->priv.server->frameblend[0] && (touch->priv.server->frameblend[0].lerp != 1.0 || touch->priv.server->frameblend[0].subframe != 0)) || touch->priv.server->skeleton.relativetransforms)
                        continue;
                if (type == MOVE_NOMONSTERS && PRVM_clientedictfloat(touch, solid) != SOLID_BSP)
                        continue;