if (r_drawcollisionbrushes.integer < 2)
{
qglPolygonOffset(1.0f, 0);
- if (ent == &cl_entities[0].render && model->brushq3.num_pvsclusters && !r_novis.integer)
- {
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
- pvs = model->brush.GetPVS(model, modelorg);
+ Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ if (ent == &cl_entities[0].render && model->brushq3.num_pvsclusters && !r_novis.integer && (pvs = model->brush.GetPVS(model, modelorg)))
R_Q3BSP_RecursiveWorldNode(ent, model->brushq3.data_nodes, modelorg, pvs, ++markframe);
- }
else
for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
R_Q3BSP_DrawFace(ent, face);
void R_Q3BSP_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz)
{
- int i;
- q3mface_t *face;
- vec3_t modelorg;
- model_t *model;
- qbyte *pvs;
- static int markframe = 0;
- R_Mesh_Matrix(&ent->matrix);
- model = ent->model;
- if (r_drawcollisionbrushes.integer < 2)
- {
- if (ent == &cl_entities[0].render && model->brushq3.num_pvsclusters && !r_novis.integer)
- {
- Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
- pvs = model->brush.GetPVS(model, modelorg);
- R_Q3BSP_RecursiveWorldNode(ent, model->brushq3.data_nodes, modelorg, pvs, ++markframe);
- }
- else
- for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
- R_Q3BSP_DrawFace(ent, face);
- }
- if (r_drawcollisionbrushes.integer >= 1)
- {
- rmeshstate_t m;
- memset(&m, 0, sizeof(m));
- GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
- GL_DepthMask(false);
- GL_DepthTest(true);
- R_Mesh_State_Texture(&m);
- for (i = 0;i < model->brushq3.data_thismodel->numbrushes;i++)
- if (model->brushq3.data_thismodel->firstbrush[i].colbrushf && model->brushq3.data_thismodel->firstbrush[i].colbrushf->numtriangles)
- R_DrawCollisionBrush(model->brushq3.data_thismodel->firstbrush[i].colbrushf);
- }
}
static void gl_surf_start(void)
}
//Returns PVS data for a given point
-//(note: always returns valid data, never NULL)
+//(note: can return NULL)
static qbyte *Mod_Q3BSP_GetPVS(model_t *model, const vec3_t p)
{
q3mnode_t *node;
node = model->brushq3.data_nodes;
while (node->isnode)
node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct(p,node->plane->normal)) < node->plane->dist];
- return model->brushq3.data_pvschains + ((q3mleaf_t *)node)->clusterindex * model->brushq3.num_pvschainlength;
+ if (((q3mleaf_t *)node)->clusterindex >= 0)
+ return model->brushq3.data_pvschains + ((q3mleaf_t *)node)->clusterindex * model->brushq3.num_pvschainlength;
+ else
+ return NULL;
}
static void Mod_Q3BSP_FatPVS_RecursiveBSPNode(model_t *model, const vec3_t org, vec_t radius, qbyte *pvsbuffer, int pvsbytes, q3mnode_t *node)
node = node->children[1];
}
}
- // if this is a leaf, accumulate the pvs bits
- pvs = model->brushq3.data_pvschains + ((q3mleaf_t *)node)->clusterindex * model->brushq3.num_pvschainlength;
- for (i = 0;i < pvsbytes;i++)
- pvsbuffer[i] |= pvs[i];
+ // if this is a leaf with a pvs, accumulate the pvs bits
+ if (((q3mleaf_t *)node)->clusterindex >= 0)
+ {
+ pvs = model->brushq3.data_pvschains + ((q3mleaf_t *)node)->clusterindex * model->brushq3.num_pvschainlength;
+ for (i = 0;i < pvsbytes;i++)
+ pvsbuffer[i] |= pvs[i];
+ }
return;
}