From 2654df314f94f72b7ebf6d0cc990f168a0027044 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 23 Mar 2006 11:43:46 +0000 Subject: [PATCH] fix bugs with bbox vs bbox traces (the collision box's planes didn't have correct contents/surfaceflags/texture information) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6173 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_collision.c | 2 +- collision.c | 10 +++++----- collision.h | 2 +- model_brush.c | 22 ++++++++++++++-------- world.c | 2 +- world_cs.c | 2 +- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/cl_collision.c b/cl_collision.c index 038c9249..5e1d1a37 100644 --- a/cl_collision.c +++ b/cl_collision.c @@ -137,7 +137,7 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co Matrix4x4_Transform(&ent->inversematrix, start, starttransformed); Matrix4x4_Transform(&ent->inversematrix, end, endtransformed); - Collision_ClipTrace_Box(&trace, playermins, playermaxs, starttransformed, mins, maxs, endtransformed, hitsupercontentsmask, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY); + Collision_ClipTrace_Box(&trace, playermins, playermaxs, starttransformed, mins, maxs, endtransformed, hitsupercontentsmask, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY, 0, NULL); // LordHavoc: take the 'best' answers from the new trace and combine with existing data if (trace.allsolid) diff --git a/collision.c b/collision.c index 6e27c4bd..25dc46ae 100644 --- a/collision.c +++ b/collision.c @@ -403,7 +403,7 @@ void Collision_CalcPlanesForPolygonBrushFloat(colbrushf_t *brush) brush->planes[3].dist = DotProduct(brush->points[0].v, brush->planes[3].normal); brush->planes[4].dist = DotProduct(brush->points[1].v, brush->planes[4].normal); - if (developer.integer) + if (developer.integer >= 100) { // validation code #if 0 @@ -488,7 +488,7 @@ void Collision_CalcPlanesForPolygonBrushFloat(colbrushf_t *brush) } } - if (developer.integer) + if (developer.integer >= 100) { // validity check - will be disabled later Collision_ValidateBrush(brush); @@ -533,7 +533,7 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush nplane2 -= thatbrush_start->numplanes; startplane = thisbrush_start->planes + nplane2; endplane = thisbrush_end->planes + nplane2; - if (developer.integer) + if (developer.integer >= 100) { // any brush with degenerate planes is not worth handling if (DotProduct(startplane->normal, startplane->normal) < 0.9f || DotProduct(endplane->normal, endplane->normal) < 0.9f) @@ -552,7 +552,7 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush { startplane = thatbrush_start->planes + nplane2; endplane = thatbrush_end->planes + nplane2; - if (developer.integer) + if (developer.integer >= 100) { // any brush with degenerate planes is not worth handling if (DotProduct(startplane->normal, startplane->normal) < 0.9f || DotProduct(endplane->normal, endplane->normal) < 0.9f) @@ -677,7 +677,7 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const endplane = thatbrush_end->planes + nplane; d1 = DotProduct(startplane->normal, linestart) - startplane->dist - collision_startnudge.value; d2 = DotProduct(endplane->normal, lineend) - endplane->dist - collision_endnudge.value; - if (developer.integer) + if (developer.integer >= 100) { // any brush with degenerate planes is not worth handling if (DotProduct(startplane->normal, startplane->normal) < 0.9f || DotProduct(endplane->normal, endplane->normal) < 0.9f) diff --git a/collision.h b/collision.h index d4131e6e..23370c69 100644 --- a/collision.h +++ b/collision.h @@ -56,7 +56,7 @@ typedef struct trace_s trace_t; void Collision_Init(void); -void Collision_ClipTrace_Box(trace_t *trace, const vec3_t cmins, const vec3_t cmaxs, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int hitsupercontentsmask, int boxsupercontents); +void Collision_ClipTrace_Box(trace_t *trace, const vec3_t cmins, const vec3_t cmaxs, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int hitsupercontentsmask, int boxsupercontents, int boxq3surfaceflags, texture_t *boxtexture); typedef struct colpointf_s { diff --git a/model_brush.c b/model_brush.c index 53eb3ff0..a4092e71 100644 --- a/model_brush.c +++ b/model_brush.c @@ -865,7 +865,7 @@ static void Mod_Q1BSP_TraceBox(struct model_s *model, int frame, trace_t *trace, } } -void Collision_ClipTrace_Box(trace_t *trace, const vec3_t cmins, const vec3_t cmaxs, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int hitsupercontentsmask, int boxsupercontents) +void Collision_ClipTrace_Box(trace_t *trace, const vec3_t cmins, const vec3_t cmaxs, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int hitsupercontentsmask, int boxsupercontents, int boxq3surfaceflags, texture_t *boxtexture) { #if 1 colbrushf_t cbox; @@ -890,6 +890,12 @@ void Collision_ClipTrace_Box(trace_t *trace, const vec3_t cmins, const vec3_t cm cbox_planes[3].normal[0] = 0;cbox_planes[3].normal[1] = -1;cbox_planes[3].normal[2] = 0;cbox_planes[3].dist = maxs[1] - cmins[1]; cbox_planes[4].normal[0] = 0;cbox_planes[4].normal[1] = 0;cbox_planes[4].normal[2] = 1;cbox_planes[4].dist = cmaxs[2] - mins[2]; cbox_planes[5].normal[0] = 0;cbox_planes[5].normal[1] = 0;cbox_planes[5].normal[2] = -1;cbox_planes[5].dist = maxs[2] - cmins[2]; + cbox_planes[0].supercontents = boxsupercontents;cbox_planes[0].q3surfaceflags = boxq3surfaceflags;cbox_planes[0].texture = boxtexture; + cbox_planes[1].supercontents = boxsupercontents;cbox_planes[1].q3surfaceflags = boxq3surfaceflags;cbox_planes[1].texture = boxtexture; + cbox_planes[2].supercontents = boxsupercontents;cbox_planes[2].q3surfaceflags = boxq3surfaceflags;cbox_planes[2].texture = boxtexture; + cbox_planes[3].supercontents = boxsupercontents;cbox_planes[3].q3surfaceflags = boxq3surfaceflags;cbox_planes[3].texture = boxtexture; + cbox_planes[4].supercontents = boxsupercontents;cbox_planes[4].q3surfaceflags = boxq3surfaceflags;cbox_planes[4].texture = boxtexture; + cbox_planes[5].supercontents = boxsupercontents;cbox_planes[5].q3surfaceflags = boxq3surfaceflags;cbox_planes[5].texture = boxtexture; memset(trace, 0, sizeof(trace_t)); trace->hitsupercontentsmask = hitsupercontentsmask; trace->fraction = 1; @@ -3398,7 +3404,7 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend) //Mod_Q1BSP_ProcessLightList(); - if (developer.integer) + if (developer.integer >= 10) Con_Printf("Some stats for q1bsp model \"%s\": %i faces, %i nodes, %i leafs, %i visleafs, %i visleafportals\n", loadmodel->name, loadmodel->num_surfaces, loadmodel->brush.num_nodes, loadmodel->brush.num_leafs, mod->brush.num_pvsclusters, loadmodel->brush.num_portals); } @@ -3960,7 +3966,7 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l) if (!COM_ParseToken(&text, true)) break; } - if (developer.integer >= 2) + if (developer.integer >= 100) { Con_Printf("%s %i: ", shadername, passnumber); for (j = 0;j < numparameters;j++) @@ -4005,7 +4011,7 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l) } if (i == 0 && !strcasecmp(com_token, "}")) break; - if (developer.integer >= 2) + if (developer.integer >= 100) { Con_Printf("%s: ", shadername); for (j = 0;j < numparameters;j++) @@ -4500,7 +4506,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) n = LittleLong(in->effectindex); if (n < -1 || n >= loadmodel->brushq3.num_effects) { - if (developer.integer >= 2) + if (developer.integer >= 100) Con_Printf("Mod_Q3BSP_LoadFaces: face #%i (texture \"%s\"): invalid effectindex %i (%i effects)\n", i, out->texture->name, n, loadmodel->brushq3.num_effects); n = -1; } @@ -4587,7 +4593,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) numtriangles = (finalwidth - 1) * (finalheight - 1) * 2; break; case Q3FACETYPE_FLARE: - if (developer.integer >= 2) + if (developer.integer >= 100) Con_Printf("Mod_Q3BSP_LoadFaces: face #%i (texture \"%s\"): Q3FACETYPE_FLARE not supported (yet)\n", i, out->texture->name); // don't render it continue; @@ -4676,7 +4682,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) Q3PatchTesselateFloat(4, sizeof(float[4]), (out->groupmesh->data_lightmapcolor4f + 4 * out->num_firstvertex), patchsize[0], patchsize[1], sizeof(float[4]), originalcolor4f, xtess, ytess); Q3PatchTriangleElements((out->groupmesh->data_element3i + 3 * out->num_firsttriangle), finalwidth, finalheight, out->num_firstvertex); out->num_triangles = Mod_RemoveDegenerateTriangles(out->num_triangles, (out->groupmesh->data_element3i + 3 * out->num_firsttriangle), (out->groupmesh->data_element3i + 3 * out->num_firsttriangle), out->groupmesh->data_vertex3f); - if (developer.integer >= 2) + if (developer.integer >= 100) { if (out->num_triangles < finaltriangles) Con_Printf("Mod_Q3BSP_LoadFaces: %ix%i curve subdivided to %i vertices / %i triangles, %i degenerate triangles removed (leaving %i)\n", patchsize[0], patchsize[1], out->num_vertices, finaltriangles, finaltriangles - out->num_triangles, out->num_triangles); @@ -4719,7 +4725,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) oldnumtriangles = out->num_triangles; oldnumtriangles2 = out->num_collisiontriangles; out->num_collisiontriangles = Mod_RemoveDegenerateTriangles(out->num_collisiontriangles, out->data_collisionelement3i, out->data_collisionelement3i, out->data_collisionvertex3f); - if (developer.integer) + if (developer.integer >= 100) Con_Printf("Mod_Q3BSP_LoadFaces: %ix%i curve became %i:%i vertices / %i:%i triangles (%i:%i degenerate)\n", patchsize[0], patchsize[1], out->num_vertices, out->num_collisionvertices, oldnumtriangles, oldnumtriangles2, oldnumtriangles - out->num_triangles, oldnumtriangles2 - out->num_collisiontriangles); break; default: diff --git a/world.c b/world.c index 70b2099b..427fe1cb 100644 --- a/world.c +++ b/world.c @@ -476,7 +476,7 @@ trace_t SV_ClipMoveToEntity(prvm_edict_t *ent, const vec3_t start, const vec3_t model->TraceBox(model, frame, &trace, starttransformed, mins, maxs, endtransformed, hitsupercontents); } else - Collision_ClipTrace_Box(&trace, ent->fields.server->mins, ent->fields.server->maxs, starttransformed, mins, maxs, endtransformed, hitsupercontents, ent->fields.server->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY); + Collision_ClipTrace_Box(&trace, ent->fields.server->mins, ent->fields.server->maxs, starttransformed, mins, maxs, endtransformed, hitsupercontents, ent->fields.server->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY, 0, NULL); trace.fraction = bound(0, trace.fraction, 1); trace.realfraction = bound(0, trace.realfraction, 1); diff --git a/world_cs.c b/world_cs.c index a90fb266..f6e6e131 100644 --- a/world_cs.c +++ b/world_cs.c @@ -502,7 +502,7 @@ trace_t CSSV_ClipMoveToEntity(prvm_edict_t *ent, const vec3_t start, const vec3_ model->TraceBox(model, frame, &trace, starttransformed, mins, maxs, endtransformed, hitsupercontents); } else - Collision_ClipTrace_Box(&trace, ent->fields.client->mins, ent->fields.client->maxs, starttransformed, mins, maxs, endtransformed, hitsupercontents, ent->fields.client->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY); + Collision_ClipTrace_Box(&trace, ent->fields.client->mins, ent->fields.client->maxs, starttransformed, mins, maxs, endtransformed, hitsupercontents, ent->fields.client->solid == SOLID_CORPSE ? SUPERCONTENTS_CORPSE : SUPERCONTENTS_BODY, 0, NULL); trace.fraction = bound(0, trace.fraction, 1); trace.realfraction = bound(0, trace.realfraction, 1); -- 2.39.2