X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=cl_collision.c;h=2cd3a619a2bf56588225cf492eeeaeea7c7becdc;hb=8dada099c7634cb56a954b76cb96d926ecd4bbd6;hp=56eac0188cffd579ac64ea8e498bcac7d06940f2;hpb=48669036b4be979d997c27227942ed9c430277d5;p=xonotic%2Fdarkplaces.git diff --git a/cl_collision.c b/cl_collision.c index 56eac018..2cd3a619 100644 --- a/cl_collision.c +++ b/cl_collision.c @@ -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,7 +101,7 @@ 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) @@ -124,7 +124,7 @@ void CL_LinkEdict(prvm_edict_t *ent) 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; @@ -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); @@ -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; @@ -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;