cvar_t mod_q3bsp_nolightmaps = {CVAR_SAVE, "mod_q3bsp_nolightmaps", "0", "do not load lightmaps in Q3BSP maps (to save video RAM, but be warned: it looks ugly)"};
cvar_t mod_q3bsp_tracelineofsight_brushes = {0, "mod_q3bsp_tracelineofsight_brushes", "0", "enables culling of entities behind detail brushes, curves, etc"};
cvar_t mod_q1bsp_polygoncollisions = {0, "mod_q1bsp_polygoncollisions", "0", "disables use of precomputed cliphulls and instead collides with polygons (uses Bounding Interval Hierarchy optimizations)"};
-cvar_t mod_collision_bih = {0, "mod_collision_bih", "0", "enables use of generated Bounding Interval Hierarchy tree instead of compiled bsp tree in collision code"};
+cvar_t mod_collision_bih = {0, "mod_collision_bih", "1", "enables use of generated Bounding Interval Hierarchy tree instead of compiled bsp tree in collision code"};
cvar_t mod_recalculatenodeboxes = {0, "mod_recalculatenodeboxes", "1", "enables use of generated node bounding boxes based on BSP tree portal reconstruction, rather than the node boxes supplied by the map compiler"};
static texture_t mod_q1bsp_texture_solid;
strlcpy (out[i].name, in[i].name, sizeof (out[i].name));
out[i].surfaceflags = LittleLong(in[i].surfaceflags);
out[i].supercontents = Mod_Q3BSP_SuperContentsFromNativeContents(loadmodel, LittleLong(in[i].contents));
+ if (cls.state != ca_dedicated)
+ {
+ Mod_LoadTextureFromQ3Shader(out + i, out[i].name, true, true, TEXF_MIPMAP | (r_picmipworld.integer ? TEXF_PICMIP : 0) | TEXF_COMPRESS);
+ // restore the surfaceflags and supercontents
+ out[i].surfaceflags = LittleLong(in[i].surfaceflags);
+ out[i].supercontents = Mod_Q3BSP_SuperContentsFromNativeContents(loadmodel, LittleLong(in[i].contents));
+ }
}
-
- if (cls.state == ca_dedicated)
- return;
-
- for (i = 0;i < count;i++, in++, out++)
- Mod_LoadTextureFromQ3Shader(out, out->name, true, true, TEXF_MIPMAP | (r_picmipworld.integer ? TEXF_PICMIP : 0) | TEXF_COMPRESS);
}
static void Mod_Q3BSP_LoadPlanes(lump_t *l)
break; // we got all of them
if(image_width != size || image_height != size)
{
- for(i = 0; i <= count; ++i)
- Mem_Free(inpixels[i]);
- Host_Error("Mod_Q3BSP_LoadLightmaps: invalid external lightmap size in %s",loadmodel->name);
+ Mem_Free(inpixels[count]);
+ inpixels[count] = NULL;
+ Con_Printf("Mod_Q3BSP_LoadLightmaps: mismatched lightmap size in %s - external lightmap %s/lm_%04d does not match earlier ones\n", loadmodel->name, mapname, count);
+ break;
}
}
}
leaf = model->collision_bih.leafs + (-1-nodenum);
switch(leaf->type)
{
- case BIH_LEAF:
- // brush
+ case BIH_BRUSH:
brush = model->brush.data_brushes[leaf->itemindex].colbrushf;
Collision_TracePointBrushFloat(trace, point, brush);
break;
- case BIH_LEAF + 1:
+ case BIH_COLLISIONTRIANGLE:
// collision triangle - skipped because they have no volume
break;
- case BIH_LEAF + 2:
+ case BIH_RENDERTRIANGLE:
// render triangle - skipped because they have no volume
break;
- default:
- break;
}
}
#endif
switch(leaf->type)
{
- case BIH_LEAF:
- // brush
+ case BIH_BRUSH:
brush = model->brush.data_brushes[leaf->itemindex].colbrushf;
Collision_TraceLineBrushFloat(trace, linestart, lineend, brush, brush);
break;
- case BIH_LEAF + 1:
- // collision triangle
+ case BIH_COLLISIONTRIANGLE:
+ if (!mod_q3bsp_curves_collisions.integer)
+ return;
e = model->brush.data_collisionelement3i + 3*leaf->itemindex;
texture = model->data_textures + leaf->textureindex;
Collision_TraceLineTriangleFloat(trace, linestart, lineend, model->brush.data_collisionvertex3f + e[0] * 3, model->brush.data_collisionvertex3f + e[1] * 3, model->brush.data_collisionvertex3f + e[2] * 3, texture->supercontents, texture->surfaceflags, texture);
break;
- case BIH_LEAF + 2:
- // render triangle
+ case BIH_RENDERTRIANGLE:
e = model->surfmesh.data_element3i + 3*leaf->itemindex;
texture = model->data_textures + leaf->textureindex;
Collision_TraceLineTriangleFloat(trace, linestart, lineend, model->surfmesh.data_vertex3f + e[0] * 3, model->surfmesh.data_vertex3f + e[1] * 3, model->surfmesh.data_vertex3f + e[2] * 3, texture->supercontents, texture->surfaceflags, texture);
break;
- default:
- break;
}
}
#endif
switch(leaf->type)
{
- case BIH_LEAF:
- // brush
+ case BIH_BRUSH:
brush = model->brush.data_brushes[leaf->itemindex].colbrushf;
Collision_TraceBrushBrushFloat(trace, thisbrush_start, thisbrush_end, brush, brush);
break;
- case BIH_LEAF + 1:
- // collision triangle
+ case BIH_COLLISIONTRIANGLE:
+ if (!mod_q3bsp_curves_collisions.integer)
+ return;
e = model->brush.data_collisionelement3i + 3*leaf->itemindex;
texture = model->data_textures + leaf->textureindex;
Collision_TraceBrushTriangleFloat(trace, thisbrush_start, thisbrush_end, model->brush.data_collisionvertex3f + e[0] * 3, model->brush.data_collisionvertex3f + e[1] * 3, model->brush.data_collisionvertex3f + e[2] * 3, texture->supercontents, texture->surfaceflags, texture);
break;
- case BIH_LEAF + 2:
- // render triangle
+ case BIH_RENDERTRIANGLE:
e = model->surfmesh.data_element3i + 3*leaf->itemindex;
texture = model->data_textures + leaf->textureindex;
Collision_TraceBrushTriangleFloat(trace, thisbrush_start, thisbrush_end, model->surfmesh.data_vertex3f + e[0] * 3, model->surfmesh.data_vertex3f + e[1] * 3, model->surfmesh.data_vertex3f + e[2] * 3, texture->supercontents, texture->surfaceflags, texture);
break;
- default:
- break;
}
}
void Mod_CollisionBIH_TracePoint_Mesh(dp_model_t *model, const frameblend_t *frameblend, const skeleton_t *skeleton, trace_t *trace, const vec3_t start, int hitsupercontentsmask)
{
+#if 0
+ // broken - needs to be modified to count front faces and backfaces to figure out if it is in solid
vec3_t end;
int hitsupercontents;
VectorSet(end, start[0], start[1], model->normalmins[2]);
+#endif
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
+#if 0
Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, model->collision_bih.rootnode, start, end, start, end);
hitsupercontents = trace->hitsupercontents;
memset(trace, 0, sizeof(*trace));
trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
trace->startsupercontents = hitsupercontents;
+#endif
}
int Mod_CollisionBIH_PointSuperContents_Mesh(struct model_s *model, int frame, const vec3_t start)
{
+#if 0
+ // broken - needs to be modified to count front faces and backfaces to figure out if it is in solid
trace_t trace;
vec3_t end;
VectorSet(end, start[0], start[1], model->normalmins[2]);
trace.hitsupercontentsmask = 0;
Mod_CollisionBIH_TraceLine_RecursiveBIHNode(&trace, model, model->collision_bih.rootnode, start, end, start, end);
return trace.hitsupercontents;
+#else
+ return 0;
+#endif
}
static void Mod_Q3BSP_TracePoint_RecursiveBSPNode(trace_t *trace, dp_model_t *model, mnode_t *node, const vec3_t point, int markframe)
// walk the tree until we hit a leaf, recursing for any split cases
while (node->plane)
{
+#if 0
+ if (!BoxesOverlap(segmentmins, segmentmaxs, node->mins, node->maxs))
+ return;
+ Mod_Q3BSP_TraceLine_RecursiveBSPNode(trace, model, node->children[0], start, end, startfrac, endfrac, linestart, lineend, markframe, segmentmins, segmentmaxs);
+ node = node->children[1];
+#else
// abort if this part of the bsp tree can not be hit by this trace
// if (!(node->combinedsupercontents & trace->hitsupercontentsmask))
// return;
Mod_Q3BSP_TraceLine_RecursiveBSPNode(trace, model, node->children[endside], mid, end, midfrac, endfrac, linestart, lineend, markframe, segmentmins, segmentmaxs);
return;
}
+#endif
}
// abort if this part of the bsp tree can not be hit by this trace
// if (!(node->combinedsupercontents & trace->hitsupercontentsmask))
nodesegmentmaxs[2] = max(start[2], end[2]) + 1;
// line trace the brushes
leaf = (mleaf_t *)node;
+#if 0
+ if (!BoxesOverlap(segmentmins, segmentmaxs, leaf->mins, leaf->maxs))
+ return;
+#endif
for (i = 0;i < leaf->numleafbrushes;i++)
{
brush = model->brush.data_brushes[leaf->firstleafbrush[i]].colbrushf;
// walk the tree until we hit a leaf, recursing for any split cases
while (node->plane)
{
+#if 0
+ if (!BoxesOverlap(segmentmins, segmentmaxs, node->mins, node->maxs))
+ return;
+ Mod_Q3BSP_TraceBrush_RecursiveBSPNode(trace, model, node->children[0], thisbrush_start, thisbrush_end, markframe, segmentmins, segmentmaxs);
+ node = node->children[1];
+#else
// abort if this part of the bsp tree can not be hit by this trace
// if (!(node->combinedsupercontents & trace->hitsupercontentsmask))
// return;
return; // ERROR: NAN bounding box!
// take whichever side the segment box is on
node = node->children[sides - 1];
+#endif
}
// abort if this part of the bsp tree can not be hit by this trace
// if (!(node->combinedsupercontents & trace->hitsupercontentsmask))
nodesegmentmaxs[2] = min(segmentmaxs[2], node->maxs[2] + 1);
// hit a leaf
leaf = (mleaf_t *)node;
+#if 0
+ if (!BoxesOverlap(segmentmins, segmentmaxs, leaf->mins, leaf->maxs))
+ return;
+#endif
for (i = 0;i < leaf->numleafbrushes;i++)
{
brush = model->brush.data_brushes[leaf->firstleafbrush[i]].colbrushf;
else if (model->brush.submodel)
{
for (i = 0, brush = model->brush.data_brushes + model->firstmodelbrush;i < model->nummodelbrushes;i++, brush++)
- if (brush->colbrushf)
+ if (brush->colbrushf && BoxesOverlap(segmentmins, segmentmaxs, brush->colbrushf->mins, brush->colbrushf->maxs))
Collision_TraceLineBrushFloat(trace, start, end, brush->colbrushf, brush->colbrushf);
if (mod_q3bsp_curves_collisions.integer)
for (i = 0, surface = model->data_surfaces + model->firstmodelsurface;i < model->nummodelsurfaces;i++, surface++)
- if (surface->num_collisiontriangles)
+ if (surface->num_collisiontriangles && BoxesOverlap(segmentmins, segmentmaxs, surface->mins, surface->maxs))
Collision_TraceLineTriangleMeshFloat(trace, start, end, surface->num_collisiontriangles, surface->deprecatedq3data_collisionelement3i, surface->deprecatedq3data_collisionvertex3f, surface->deprecatedq3num_collisionbboxstride, surface->deprecatedq3data_collisionbbox6f, surface->texture->supercontents, surface->texture->surfaceflags, surface->texture, segmentmins, segmentmaxs);
}
else
else if (model->brush.submodel)
{
for (i = 0, brush = model->brush.data_brushes + model->firstmodelbrush;i < model->nummodelbrushes;i++, brush++)
- if (brush->colbrushf)
+ if (brush->colbrushf && BoxesOverlap(segmentmins, segmentmaxs, brush->colbrushf->mins, brush->colbrushf->maxs))
Collision_TraceBrushBrushFloat(trace, &thisbrush_start.brush, &thisbrush_end.brush, brush->colbrushf, brush->colbrushf);
if (mod_q3bsp_curves_collisions.integer)
for (i = 0, surface = model->data_surfaces + model->firstmodelsurface;i < model->nummodelsurfaces;i++, surface++)
- if (surface->num_collisiontriangles)
+ if (surface->num_collisiontriangles && BoxesOverlap(segmentmins, segmentmaxs, surface->mins, surface->maxs))
Collision_TraceBrushTriangleMeshFloat(trace, &thisbrush_start.brush, &thisbrush_end.brush, surface->num_collisiontriangles, surface->deprecatedq3data_collisionelement3i, surface->deprecatedq3data_collisionvertex3f, surface->deprecatedq3num_collisionbboxstride, surface->deprecatedq3data_collisionbbox6f, surface->texture->supercontents, surface->texture->surfaceflags, surface->texture, segmentmins, segmentmaxs);
}
else
{
for (triangleindex = 0, e = renderelement3i + 3*surface->num_firsttriangle;triangleindex < surface->num_triangles;triangleindex++, e += 3)
{
- bihleafs[bihleafindex].type = BIH_LEAF + 2;
+ bihleafs[bihleafindex].type = BIH_RENDERTRIANGLE;
bihleafs[bihleafindex].textureindex = surface->texture - model->data_textures;
bihleafs[bihleafindex].itemindex = triangleindex+surface->num_firsttriangle;
bihleafs[bihleafindex].mins[0] = min(rendervertex3f[3*e[0]+0], min(rendervertex3f[3*e[1]+0], rendervertex3f[3*e[2]+0])) - 1;
{
if (!brush->colbrushf)
continue;
- bihleafs[bihleafindex].type = BIH_LEAF;
+ bihleafs[bihleafindex].type = BIH_BRUSH;
bihleafs[bihleafindex].textureindex = brush->texture - model->data_textures;
bihleafs[bihleafindex].itemindex = brushindex+model->firstmodelbrush;
VectorCopy(brush->colbrushf->mins, bihleafs[bihleafindex].mins);
{
for (triangleindex = 0, e = collisionelement3i + 3*surface->num_firstcollisiontriangle;triangleindex < surface->num_collisiontriangles;triangleindex++, e += 3)
{
- bihleafs[bihleafindex].type = BIH_LEAF + 1;
+ bihleafs[bihleafindex].type = BIH_COLLISIONTRIANGLE;
bihleafs[bihleafindex].textureindex = surface->texture - model->data_textures;
bihleafs[bihleafindex].itemindex = triangleindex+surface->num_firstcollisiontriangle;
bihleafs[bihleafindex].mins[0] = min(collisionvertex3f[3*e[0]+0], min(collisionvertex3f[3*e[1]+0], collisionvertex3f[3*e[2]+0])) - 1;