X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=cl_collision.c;h=713522d331fe7aefbcdec031426a497fca3363a4;hp=6829863048decabbc2bb1045d0eb7d74aac0460b;hb=8b71b1316efa1753420f848c919215e6b46479bb;hpb=ab9e8a37699390a5dc199e4def9cdbaaa59d82cf diff --git a/cl_collision.c b/cl_collision.c index 68298630..713522d3 100644 --- a/cl_collision.c +++ b/cl_collision.c @@ -11,9 +11,9 @@ float CL_SelectTraceLine(const vec3_t start, const vec3_t end, vec3_t impact, ve float maxfrac, maxrealfrac; int n; entity_render_t *ent; - float tracemins[3], tracemaxs[3]; + vec_t tracemins[3], tracemaxs[3]; trace_t trace; - float tempnormal[3], starttransformed[3], endtransformed[3]; + vec_t tempnormal[3], starttransformed[3], endtransformed[3]; #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND vec3_t end; vec_t len = 0; @@ -94,7 +94,7 @@ float CL_SelectTraceLine(const vec3_t start, const vec3_t end, vec3_t impact, ve } } maxfrac = bound(0, maxfrac, 1); - maxrealfrac = bound(0, maxrealfrac, 1); + //maxrealfrac = bound(0, maxrealfrac, 1); //if (maxfrac < 0 || maxfrac > 1) Con_Printf("fraction out of bounds %f %s:%d\n", maxfrac, __FILE__, __LINE__); if (impact) VectorLerp(start, maxfrac, end, impact); @@ -128,6 +128,7 @@ dp_model_t *CL_GetModelByIndex(int modelindex) dp_model_t *CL_GetModelFromEdict(prvm_edict_t *ed) { + prvm_prog_t *prog = CLVM_prog; if (!ed || ed->priv.server->free) return NULL; return CL_GetModelByIndex((int)PRVM_clientedictfloat(ed, modelindex)); @@ -135,6 +136,7 @@ dp_model_t *CL_GetModelFromEdict(prvm_edict_t *ed) void CL_LinkEdict(prvm_edict_t *ent) { + prvm_prog_t *prog = CLVM_prog; vec3_t mins, maxs; if (ent == prog->edicts) @@ -192,11 +194,12 @@ void CL_LinkEdict(prvm_edict_t *ent) VectorCopy(mins, PRVM_clientedictvector(ent, absmin)); VectorCopy(maxs, PRVM_clientedictvector(ent, absmax)); - World_LinkEdict(&cl.world, ent, PRVM_clientedictvector(ent, absmin), PRVM_clientedictvector(ent, absmax)); + World_LinkEdict(&cl.world, ent, mins, maxs); } int CL_GenericHitSuperContentsMask(const prvm_edict_t *passedict) { + prvm_prog_t *prog = CLVM_prog; if (passedict) { int dphitcontentsmask = (int)PRVM_clientedictfloat(passedict, dphitcontentsmask); @@ -227,10 +230,13 @@ CL_Move */ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int hitsupercontentsmask, qboolean hitnetworkbrushmodels, qboolean hitnetworkplayers, int *hitnetworkentity, qboolean hitcsqcentities) { + prvm_prog_t *prog = CLVM_prog; int i, bodysupercontents; int passedictprog; prvm_edict_t *traceowner, *touch; trace_t trace; + // temporary storage because prvm_vec_t may need conversion + vec3_t touchmins, touchmaxs; // bounding box of entire move area vec3_t clipboxmins, clipboxmaxs; // size when clipping against monsters @@ -259,7 +265,7 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int // clip to world Collision_ClipPointToWorld(&cliptrace, cl.worldmodel, clipstart, hitsupercontentsmask); - cliptrace.bmodelstartsolid = cliptrace.startsolid; + cliptrace.worldstartsolid = cliptrace.bmodelstartsolid = cliptrace.startsolid; if (cliptrace.startsolid || cliptrace.fraction < 1) cliptrace.ent = prog ? prog->edicts : NULL; if (type == MOVE_WORLDONLY) @@ -320,7 +326,7 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int vec3_t origin, entmins, entmaxs; matrix4x4_t entmatrix, entinversematrix; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit network players, if we are a nonsolid player if(cl.scores[cl.playerentity-1].frags == -666 || cl.scores[cl.playerentity-1].frags == -616) @@ -339,7 +345,7 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int if (!cl.scores[i-1].name[0]) continue; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit spectators or nonsolid players if(cl.scores[i-1].frags == -666 || cl.scores[i-1].frags == -616) @@ -414,10 +420,12 @@ skipnetworkplayers: else Matrix4x4_CreateTranslate(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2]); Matrix4x4_Invert_Simple(&imatrix, &matrix); + VectorCopy(PRVM_clientedictvector(touch, mins), touchmins); + VectorCopy(PRVM_clientedictvector(touch, maxs), touchmaxs); if ((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER) - Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipstart, hitsupercontentsmask); + Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipstart, hitsupercontentsmask); else - Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask); + Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask); if (cliptrace.realfraction > trace.realfraction && hitnetworkentity) *hitnetworkentity = 0; @@ -439,10 +447,13 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t pEnd, int type, prvm_edict trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, qboolean hitnetworkbrushmodels, qboolean hitnetworkplayers, int *hitnetworkentity, qboolean hitcsqcentities, qboolean hitsurfaces) #endif { + prvm_prog_t *prog = CLVM_prog; int i, bodysupercontents; int passedictprog; prvm_edict_t *traceowner, *touch; trace_t trace; + // temporary storage because prvm_vec_t may need conversion + vec3_t touchmins, touchmaxs; // bounding box of entire move area vec3_t clipboxmins, clipboxmaxs; // size when clipping against monsters @@ -492,7 +503,7 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_ // clip to world Collision_ClipLineToWorld(&cliptrace, cl.worldmodel, clipstart, clipend, hitsupercontentsmask, hitsurfaces); - cliptrace.bmodelstartsolid = cliptrace.startsolid; + cliptrace.worldstartsolid = cliptrace.bmodelstartsolid = cliptrace.startsolid; if (cliptrace.startsolid || cliptrace.fraction < 1) cliptrace.ent = prog ? prog->edicts : NULL; if (type == MOVE_WORLDONLY) @@ -553,7 +564,7 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_ vec3_t origin, entmins, entmaxs; matrix4x4_t entmatrix, entinversematrix; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit network players, if we are a nonsolid player if(cl.scores[cl.playerentity-1].frags == -666 || cl.scores[cl.playerentity-1].frags == -616) @@ -572,7 +583,7 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_ if (!cl.scores[i-1].name[0]) continue; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit spectators or nonsolid players if(cl.scores[i-1].frags == -666 || cl.scores[i-1].frags == -616) @@ -647,10 +658,12 @@ skipnetworkplayers: else Matrix4x4_CreateTranslate(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2]); Matrix4x4_Invert_Simple(&imatrix, &matrix); + VectorCopy(PRVM_clientedictvector(touch, mins), touchmins); + VectorCopy(PRVM_clientedictvector(touch, maxs), touchmaxs); if (type == MOVE_MISSILE && (int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER) - Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask); + Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask); else - Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, hitsurfaces); + Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, hitsurfaces); if (cliptrace.realfraction > trace.realfraction && hitnetworkentity) *hitnetworkentity = 0; @@ -676,12 +689,15 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co 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, qboolean hitnetworkbrushmodels, qboolean hitnetworkplayers, int *hitnetworkentity, qboolean hitcsqcentities) #endif { + prvm_prog_t *prog = CLVM_prog; vec3_t hullmins, hullmaxs; int i, bodysupercontents; int passedictprog; qboolean pointtrace; prvm_edict_t *traceowner, *touch; trace_t trace; + // temporary storage because prvm_vec_t may need conversion + vec3_t touchmins, touchmaxs; // bounding box of entire move area vec3_t clipboxmins, clipboxmaxs; // size of the moving object @@ -755,7 +771,7 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co // clip to world Collision_ClipToWorld(&cliptrace, cl.worldmodel, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask); - cliptrace.bmodelstartsolid = cliptrace.startsolid; + cliptrace.worldstartsolid = cliptrace.bmodelstartsolid = cliptrace.startsolid; if (cliptrace.startsolid || cliptrace.fraction < 1) cliptrace.ent = prog ? prog->edicts : NULL; if (type == MOVE_WORLDONLY) @@ -827,7 +843,7 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co vec3_t origin, entmins, entmaxs; matrix4x4_t entmatrix, entinversematrix; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit network players, if we are a nonsolid player if(cl.scores[cl.playerentity-1].frags == -666 || cl.scores[cl.playerentity-1].frags == -616) @@ -846,7 +862,7 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co if (!cl.scores[i-1].name[0]) continue; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit spectators or nonsolid players if(cl.scores[i-1].frags == -666 || cl.scores[i-1].frags == -616) @@ -921,10 +937,12 @@ skipnetworkplayers: else Matrix4x4_CreateTranslate(&matrix, PRVM_clientedictvector(touch, origin)[0], PRVM_clientedictvector(touch, origin)[1], PRVM_clientedictvector(touch, origin)[2]); Matrix4x4_Invert_Simple(&imatrix, &matrix); + VectorCopy(PRVM_clientedictvector(touch, mins), touchmins); + VectorCopy(PRVM_clientedictvector(touch, maxs), touchmaxs); if ((int)PRVM_clientedictfloat(touch, flags) & FL_MONSTER) - Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask); + Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask); else - Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, PRVM_clientedictvector(touch, mins), PRVM_clientedictvector(touch, maxs), bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask); + Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask); if (cliptrace.realfraction > trace.realfraction && hitnetworkentity) *hitnetworkentity = 0; @@ -950,6 +968,7 @@ trace_t CL_Cache_TraceLineSurfaces(const vec3_t start, const vec3_t pEnd, int ty trace_t CL_Cache_TraceLineSurfaces(const vec3_t start, const vec3_t end, int type, int hitsupercontentsmask) #endif { + prvm_prog_t *prog = CLVM_prog; int i; prvm_edict_t *touch; trace_t trace; @@ -989,7 +1008,7 @@ trace_t CL_Cache_TraceLineSurfaces(const vec3_t start, const vec3_t end, int typ // clip to world Collision_Cache_ClipLineToWorldSurfaces(&cliptrace, cl.worldmodel, clipstart, clipend, hitsupercontentsmask); - cliptrace.bmodelstartsolid = cliptrace.startsolid; + cliptrace.worldstartsolid = cliptrace.bmodelstartsolid = cliptrace.startsolid; if (cliptrace.startsolid || cliptrace.fraction < 1) cliptrace.ent = prog ? prog->edicts : NULL; if (type == MOVE_WORLDONLY)