X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=chase.c;h=be915bcf84057d905944fbc8f5a6ae8069338d70;hb=eef4de5c2e8ee6dbc76c96e7f42ff8ac0c506889;hp=e383ab61656b65b3a9146fcd00f5702fd14234a9;hpb=ff5947f97081e10c4ce112d4d51c2d1fa14ebba8;p=xonotic%2Fdarkplaces.git diff --git a/chase.c b/chase.c index e383ab61..be915bcf 100644 --- a/chase.c +++ b/chase.c @@ -20,10 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // chase.c -- chase camera code #include "quakedef.h" +#include "cl_collision.h" -cvar_t chase_back = {CVAR_SAVE, "chase_back", "48"}; -cvar_t chase_up = {CVAR_SAVE, "chase_up", "48"}; -cvar_t chase_active = {CVAR_SAVE, "chase_active", "0"}; +cvar_t chase_back = {CVAR_SAVE, "chase_back", "48"}; +cvar_t chase_up = {CVAR_SAVE, "chase_up", "24"}; +cvar_t chase_active = {CVAR_SAVE, "chase_active", "0"}; void Chase_Init (void) { @@ -38,131 +39,6 @@ void Chase_Reset (void) // start position 12 units behind head } -int traceline_endcontents; - -static entity_render_t *traceline_entity[MAX_EDICTS]; -static int traceline_entities; - -// builds list of entities for TraceLine to check later -void TraceLine_ScanForBModels(void) -{ - int i; - entity_render_t *ent; - model_t *model; - traceline_entities = 0; - for (i = 1;i < MAX_EDICTS;i++) - { - ent = &cl_entities[i].render; - model = ent->model; - // look for embedded brush models only - if (model && model->name[0] == '*') - { - // this does nothing for * models currently... - //Mod_CheckLoaded(model); - if (model->type == mod_brush) - { - traceline_entity[traceline_entities++] = ent; - if (ent->angles[0] || ent->angles[2]) - { - // pitch or roll - VectorAdd(ent->origin, model->rotatedmins, ent->mins); - VectorAdd(ent->origin, model->rotatedmaxs, ent->maxs); - } - else if (ent->angles[1]) - { - // yaw - VectorAdd(ent->origin, model->yawmins, ent->mins); - VectorAdd(ent->origin, model->yawmaxs, ent->maxs); - } - else - { - VectorAdd(ent->origin, model->normalmins, ent->mins); - VectorAdd(ent->origin, model->normalmaxs, ent->maxs); - } - } - } - } -} - -float TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels) -{ - float maxfrac; - trace_t trace; - -// FIXME: broken, fix it -// if (impact == NULL && normal == NULL && contents == 0) -// return SV_TestLine (cl.worldmodel->hulls, 0, start, end); - - Mod_CheckLoaded(cl.worldmodel); - memset (&trace, 0, sizeof(trace)); - VectorCopy (end, trace.endpos); - trace.fraction = 1; - trace.startcontents = contents; - VectorCopy(start, RecursiveHullCheckInfo.start); - VectorSubtract(end, start, RecursiveHullCheckInfo.dist); - RecursiveHullCheckInfo.hull = cl.worldmodel->hulls; - RecursiveHullCheckInfo.trace = &trace; - SV_RecursiveHullCheck (0, 0, 1, start, end); - if (impact) - VectorCopy (trace.endpos, impact); - if (normal) - VectorCopy (trace.plane.normal, normal); - traceline_endcontents = trace.endcontents; - maxfrac = trace.fraction; - - if (hitbmodels && traceline_entities) - { - int n; - entity_render_t *ent; - vec3_t start2, end2, tracemins, tracemaxs; - tracemins[0] = min(start[0], end[0]); - tracemaxs[0] = max(start[0], end[0]); - tracemins[1] = min(start[1], end[1]); - tracemaxs[1] = max(start[1], end[1]); - tracemins[2] = min(start[2], end[2]); - tracemaxs[2] = max(start[2], end[2]); - - // look for embedded bmodels - for (n = 0;n < traceline_entities;n++) - { - ent = traceline_entity[n]; - if (ent->mins[0] > tracemaxs[0] || ent->maxs[0] < tracemins[0] - || ent->mins[1] > tracemaxs[1] || ent->maxs[1] < tracemins[1] - || ent->mins[2] > tracemaxs[2] || ent->maxs[2] < tracemins[2]) - continue; - - softwaretransformforentity(ent); - softwareuntransform(start, start2); - softwareuntransform(end, end2); - - memset (&trace, 0, sizeof(trace)); - VectorCopy (end2, trace.endpos); - trace.fraction = 1; - trace.startcontents = contents; - VectorCopy(start2, RecursiveHullCheckInfo.start); - VectorSubtract(end2, start2, RecursiveHullCheckInfo.dist); - RecursiveHullCheckInfo.hull = ent->model->hulls; - RecursiveHullCheckInfo.trace = &trace; - SV_RecursiveHullCheck (ent->model->hulls->firstclipnode, 0, 1, start2, end2); - - if (trace.allsolid || trace.startsolid || trace.fraction < maxfrac) - { - maxfrac = trace.fraction; - if (impact) - { - softwaretransform(trace.endpos, impact); - } - if (normal) - { - softwaretransformdirection(trace.plane.normal, normal); - } - traceline_endcontents = trace.endcontents; - } - } - } - return maxfrac; -} - void Chase_Update (void) { vec3_t forward, stop, chase_dest, normal; @@ -178,7 +54,7 @@ void Chase_Update (void) chase_dest[1] = r_refdef.vieworg[1] + forward[1] * dist; chase_dest[2] = r_refdef.vieworg[2] + forward[2] * dist + chase_up.value; - TraceLine (r_refdef.vieworg, chase_dest, stop, normal, 0, true); + CL_TraceLine (r_refdef.vieworg, chase_dest, stop, normal, 0, true, NULL); chase_dest[0] = stop[0] + forward[0] * 8 + normal[0] * 4; chase_dest[1] = stop[1] + forward[1] * 8 + normal[1] * 4; chase_dest[2] = stop[2] + forward[2] * 8 + normal[2] * 4;