X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=cl_collision.c;h=57b6b4b5b667c42d5894140a87e8ec34b73306e9;hb=ceef40ca3c9282f8fc7d44e54998923257889bfb;hp=f4744885794fd2a0a141d7cff21d3c0f83605766;hpb=4e402f83fc7aa1989f298c38847661bdf6d7883d;p=xonotic%2Fdarkplaces.git diff --git a/cl_collision.c b/cl_collision.c index f4744885..57b6b4b5 100644 --- a/cl_collision.c +++ b/cl_collision.c @@ -18,12 +18,12 @@ float CL_SelectTraceLine(const vec3_t start, const vec3_t end, vec3_t impact, ve vec3_t end; vec_t len = 0; - if(!VectorCompare(start, pEnd)) + if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0) { // TRICK: make the trace 1 qu longer! VectorSubtract(pEnd, start, end); len = VectorNormalizeLength(end); - VectorAdd(pEnd, end, end); + VectorMA(pEnd, collision_endposnudge.value, end, end); } else VectorCopy(pEnd, end); @@ -72,8 +72,8 @@ float CL_SelectTraceLine(const vec3_t start, const vec3_t end, vec3_t impact, ve Matrix4x4_Transform(&ent->inversematrix, end, endtransformed); Collision_ClipTrace_Box(&trace, ent->model->normalmins, ent->model->normalmaxs, starttransformed, vec3_origin, vec3_origin, endtransformed, SUPERCONTENTS_SOLID, SUPERCONTENTS_SOLID, 0, NULL); #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND - if(!VectorCompare(start, pEnd)) - Collision_ShortenTrace(&trace, len / (len + 1), pEnd); + if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0) + Collision_ShortenTrace(&trace, len / (len + collision_endposnudge.value), pEnd); #endif if (maxrealfrac < trace.realfraction) continue; @@ -157,8 +157,8 @@ void CL_LinkEdict(prvm_edict_t *ent) if( model != NULL ) { - if (!model->TraceBox && developer.integer >= 1) - Con_Printf("edict %i: SOLID_BSP with non-collidable model\n", PRVM_NUM_FOR_EDICT(ent)); + if (!model->TraceBox) + Con_DPrintf("edict %i: SOLID_BSP with non-collidable model\n", PRVM_NUM_FOR_EDICT(ent)); if (ent->fields.client->angles[0] || ent->fields.client->angles[2] || ent->fields.client->avelocity[0] || ent->fields.client->avelocity[2]) { @@ -246,7 +246,7 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int dp_model_t *model; // list of entities to test for collisions int numtouchedicts; - prvm_edict_t *touchedicts[MAX_EDICTS]; + static prvm_edict_t *touchedicts[MAX_EDICTS]; if (hitnetworkentity) *hitnetworkentity = 0; @@ -321,7 +321,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) + if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) { // 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) @@ -340,7 +340,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) + if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) { // don't hit spectators or nonsolid players if(cl.scores[i-1].frags == -666 || cl.scores[i-1].frags == -616) @@ -435,9 +435,9 @@ CL_TraceLine ================== */ #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND -trace_t CL_TraceLine(const vec3_t start, const vec3_t pEnd, int type, prvm_edict_t *passedict, int hitsupercontentsmask, qboolean hitnetworkbrushmodels, qboolean hitnetworkplayers, int *hitnetworkentity, qboolean hitcsqcentities) +trace_t CL_TraceLine(const vec3_t start, const vec3_t pEnd, int type, prvm_edict_t *passedict, int hitsupercontentsmask, qboolean hitnetworkbrushmodels, qboolean hitnetworkplayers, int *hitnetworkentity, qboolean hitcsqcentities, qboolean hitsurfaces) #else -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) +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 { int i, bodysupercontents; @@ -458,24 +458,27 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_ dp_model_t *model; // list of entities to test for collisions int numtouchedicts; - prvm_edict_t *touchedicts[MAX_EDICTS]; + static prvm_edict_t *touchedicts[MAX_EDICTS]; #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND vec3_t end; vec_t len = 0; - if(!VectorCompare(start, pEnd)) + if (VectorCompare(start, pEnd)) + return CL_TracePoint(start, type, passedict, hitsupercontentsmask, hitnetworkbrushmodels, hitnetworkplayers, hitnetworkentity, hitcsqcentities); + + if(collision_endposnudge.value > 0) { // TRICK: make the trace 1 qu longer! VectorSubtract(pEnd, start, end); len = VectorNormalizeLength(end); - VectorAdd(pEnd, end, end); + VectorMA(pEnd, collision_endposnudge.value, end, end); } else VectorCopy(pEnd, end); -#endif - +#else if (VectorCompare(start, end)) return CL_TracePoint(start, type, passedict, hitsupercontentsmask, hitnetworkbrushmodels, hitnetworkplayers, hitnetworkentity, hitcsqcentities); +#endif if (hitnetworkentity) *hitnetworkentity = 0; @@ -489,7 +492,7 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_ #endif // clip to world - Collision_ClipLineToWorld(&cliptrace, cl.worldmodel, clipstart, clipend, hitsupercontentsmask); + Collision_ClipLineToWorld(&cliptrace, cl.worldmodel, clipstart, clipend, hitsupercontentsmask, hitsurfaces); cliptrace.bmodelstartsolid = cliptrace.startsolid; if (cliptrace.startsolid || cliptrace.fraction < 1) cliptrace.ent = prog ? prog->edicts : NULL; @@ -538,7 +541,7 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_ entity_render_t *ent = &cl.entities[cl.brushmodel_entities[i]].render; if (!BoxesOverlap(clipboxmins, clipboxmaxs, ent->mins, ent->maxs)) continue; - Collision_ClipLineToGenericEntity(&trace, ent->model, ent->frameblend, ent->skeleton, vec3_origin, vec3_origin, 0, &ent->matrix, &ent->inversematrix, start, end, hitsupercontentsmask); + Collision_ClipLineToGenericEntity(&trace, ent->model, ent->frameblend, ent->skeleton, vec3_origin, vec3_origin, 0, &ent->matrix, &ent->inversematrix, start, end, hitsupercontentsmask, hitsurfaces); if (cliptrace.realfraction > trace.realfraction && hitnetworkentity) *hitnetworkentity = cl.brushmodel_entities[i]; Collision_CombineTraces(&cliptrace, &trace, NULL, true); @@ -551,7 +554,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) + if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) { // 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) @@ -570,7 +573,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) + if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) { // don't hit spectators or nonsolid players if(cl.scores[i-1].frags == -666 || cl.scores[i-1].frags == -616) @@ -584,7 +587,7 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_ continue; Matrix4x4_CreateTranslate(&entmatrix, origin[0], origin[1], origin[2]); Matrix4x4_CreateTranslate(&entinversematrix, -origin[0], -origin[1], -origin[2]); - Collision_ClipLineToGenericEntity(&trace, NULL, NULL, NULL, cl.playerstandmins, cl.playerstandmaxs, SUPERCONTENTS_BODY, &entmatrix, &entinversematrix, start, end, hitsupercontentsmask); + Collision_ClipLineToGenericEntity(&trace, NULL, NULL, NULL, cl.playerstandmins, cl.playerstandmaxs, SUPERCONTENTS_BODY, &entmatrix, &entinversematrix, start, end, hitsupercontentsmask, hitsurfaces); if (cliptrace.realfraction > trace.realfraction && hitnetworkentity) *hitnetworkentity = i; Collision_CombineTraces(&cliptrace, &trace, NULL, false); @@ -648,7 +651,7 @@ skipnetworkplayers: if (type == MOVE_MISSILE && (int)touch->fields.client->flags & FL_MONSTER) Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins2, clipmaxs2, clipend, hitsupercontentsmask); else - Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask); + Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touch->fields.client->mins, touch->fields.client->maxs, bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, hitsurfaces); if (cliptrace.realfraction > trace.realfraction && hitnetworkentity) *hitnetworkentity = 0; @@ -657,8 +660,8 @@ skipnetworkplayers: finished: #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND - if(!VectorCompare(start, pEnd)) - Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd); + if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0) + Collision_ShortenTrace(&cliptrace, len / (len + collision_endposnudge.value), pEnd); #endif return cliptrace; } @@ -696,22 +699,34 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co dp_model_t *model; // list of entities to test for collisions int numtouchedicts; - prvm_edict_t *touchedicts[MAX_EDICTS]; + static prvm_edict_t *touchedicts[MAX_EDICTS]; #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND vec3_t end; vec_t len = 0; - if(!VectorCompare(start, pEnd)) + if (VectorCompare(mins, maxs)) + { + vec3_t shiftstart, shiftend; + VectorAdd(start, mins, shiftstart); + VectorAdd(pEnd, mins, shiftend); + if (VectorCompare(start, pEnd)) + trace = CL_TracePoint(shiftstart, type, passedict, hitsupercontentsmask, hitnetworkbrushmodels, hitnetworkplayers, hitnetworkentity, hitcsqcentities); + else + trace = CL_TraceLine(shiftstart, shiftend, type, passedict, hitsupercontentsmask, hitnetworkbrushmodels, hitnetworkplayers, hitnetworkentity, hitcsqcentities, false); + VectorSubtract(trace.endpos, mins, trace.endpos); + return trace; + } + + if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0) { // TRICK: make the trace 1 qu longer! VectorSubtract(pEnd, start, end); len = VectorNormalizeLength(end); - VectorAdd(pEnd, end, end); + VectorMA(pEnd, collision_endposnudge.value, end, end); } else VectorCopy(pEnd, end); -#endif - +#else if (VectorCompare(mins, maxs)) { vec3_t shiftstart, shiftend; @@ -724,6 +739,7 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co VectorSubtract(trace.endpos, mins, trace.endpos); return trace; } +#endif if (hitnetworkentity) *hitnetworkentity = 0; @@ -812,7 +828,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) + if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) { // 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) @@ -831,7 +847,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) + if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) { // don't hit spectators or nonsolid players if(cl.scores[i-1].frags == -666 || cl.scores[i-1].frags == -616) @@ -918,8 +934,8 @@ skipnetworkplayers: finished: #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND - if(!VectorCompare(start, pEnd)) - Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd); + if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0) + Collision_ShortenTrace(&cliptrace, len / (len + collision_endposnudge.value), pEnd); #endif return cliptrace; }