const msurface_t *surf;
rmeshstate_t m;
- // LordHavoc: HalfLife maps have freaky skypolys...
- if (ent->model->brush.ishlbsp)
- return;
// sky rendering transparently would be too difficult
if (ent->flags & RENDER_TRANSPARENT)
return;
R_Sky();
}
+ // LordHavoc: HalfLife maps have freaky skypolys...
+ if (ent->model->brush.ishlbsp)
+ return;
R_Mesh_Matrix(&ent->matrix);
GL_Color(fogcolor[0], fogcolor[1], fogcolor[2], 1);
base = fullbright ? 2.0f : r_ambient.value * (1.0f / 64.0f);
if (surf->flags & SURF_DRAWTURB)
base *= 0.5f;
- if ((surf->flags & SURF_DRAWTURB) && gl_textureshader && r_watershader.value && !fogenabled)
+ if ((surf->flags & SURF_DRAWTURB) && gl_textureshader && r_watershader.value && !fogenabled && fullbright)
{
// NVIDIA Geforce3 distortion texture shader on water
GL_Color(1, 1, 1, currentalpha);
model_t *model = ent->model;
vec3_t lightmins, lightmaxs;
msurface_t *surface;
- int surfacelistindex, j, t;
- const int *e;
- const float *v[3];
+ int surfacelistindex;
if (r_drawcollisionbrushes.integer < 2)
{
lightmins[0] = relativelightorigin[0] - lightradius;
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
surface = model->brushq1.surfaces + surfacelist[surfacelistindex];
- for (j = 0, t = surface->num_firstshadowmeshtriangle, e = model->brush.shadowmesh->element3i + t * 3;j < surface->mesh.num_triangles;j++, t++, e += 3)
- {
- v[0] = model->brush.shadowmesh->vertex3f + e[0] * 3;
- v[1] = model->brush.shadowmesh->vertex3f + e[1] * 3;
- v[2] = model->brush.shadowmesh->vertex3f + e[2] * 3;
- if (PointInfrontOfTriangle(relativelightorigin, v[0], v[1], v[2]) && lightmaxs[0] > min(v[0][0], min(v[1][0], v[2][0])) && lightmins[0] < max(v[0][0], max(v[1][0], v[2][0])) && lightmaxs[1] > min(v[0][1], min(v[1][1], v[2][1])) && lightmins[1] < max(v[0][1], max(v[1][1], v[2][1])) && lightmaxs[2] > min(v[0][2], min(v[1][2], v[2][2])) && lightmins[2] < max(v[0][2], max(v[1][2], v[2][2])))
- shadowmarklist[numshadowmark++] = t;
- }
+ R_Shadow_MarkVolumeFromBox(surface->num_firstshadowmeshtriangle, surface->mesh.num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, relativelightorigin, lightmins, lightmaxs, surface->poly_mins, surface->poly_maxs);
}
R_Shadow_VolumeFromList(model->brush.shadowmesh->numverts, model->brush.shadowmesh->numtriangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, model->brush.shadowmesh->neighbor3i, relativelightorigin, lightradius + model->radius + r_shadow_projectdistance.value, numshadowmark, shadowmarklist);
}
memset(&m, 0, sizeof(m));
m.pointer_vertex = brush->points->v;
R_Mesh_State(&m);
- i = ((int)brush) / sizeof(colbrushf_t);
+ i = (int)(((size_t)brush) / sizeof(colbrushf_t));
GL_Color((i & 31) * (1.0f / 32.0f), ((i >> 5) & 31) * (1.0f / 32.0f), ((i >> 10) & 31) * (1.0f / 32.0f), 0.2f);
GL_LockArrays(0, brush->numpoints);
R_Mesh_Draw(brush->numpoints, brush->numtriangles, brush->elements);
memset(&m, 0, sizeof(m));
m.pointer_vertex = face->data_collisionvertex3f;
R_Mesh_State(&m);
- i = ((int)face) / sizeof(q3msurface_t);
+ i = (int)(((size_t)face) / sizeof(q3msurface_t));
GL_Color((i & 31) * (1.0f / 32.0f), ((i >> 5) & 31) * (1.0f / 32.0f), ((i >> 10) & 31) * (1.0f / 32.0f), 0.2f);
GL_LockArrays(0, face->num_collisionvertices);
R_Mesh_Draw(face->num_collisionvertices, face->num_collisiontriangles, face->data_collisionelement3i);
if (r_surf_surfacevisible[t->facenumlist[i]])
{
face = t->facelist[i];
- if (!R_CullBox(face->mins, face->maxs))
+ if (!R_CullBox(face->mins, face->maxs) && face->num_triangles)
{
if (numfaces >= maxfaces)
{
numfaces = 0;
for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
{
- if ((face->texture->surfaceflags & flagsmask) == flags)
- {
+ if ((face->texture->surfaceflags & flagsmask) == flags && face->num_triangles)
+ {
if (t != face->texture || numfaces >= maxfaces)
{
if (numfaces)
surfaceindex = surface - model->brushq3.data_faces;
if (!CHECKPVSBIT(outsurfacepvs, surfaceindex))
{
- if (BoxesOverlap(lightmins, lightmaxs, surface->mins, surface->maxs) && !(surface->texture->surfaceparms & Q3SURFACEPARM_TRANS) && !(surface->texture->surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NODRAW)))
+ if (BoxesOverlap(lightmins, lightmaxs, surface->mins, surface->maxs) && !(surface->texture->surfaceparms & Q3SURFACEPARM_TRANS) && !(surface->texture->surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NODRAW)) && surface->num_triangles)
{
for (triangleindex = 0, t = surface->num_firstshadowmeshtriangle, e = model->brush.shadowmesh->element3i + t * 3;triangleindex < surface->num_triangles;triangleindex++, t++, e += 3)
{
model_t *model = ent->model;
vec3_t lightmins, lightmaxs;
q3msurface_t *surface;
- int surfacelistindex, j, t;
- const int *e;
- const float *v[3];
+ int surfacelistindex;
if (r_drawcollisionbrushes.integer < 2)
{
lightmins[0] = relativelightorigin[0] - lightradius;
{
surface = model->brushq3.data_faces + surfacelist[surfacelistindex];
// FIXME: check some manner of face->rendermode here?
- if (!(surface->texture->surfaceflags & Q3SURFACEFLAG_NODRAW) && surface->num_triangles && !surface->texture->skin.fog)
- {
- for (j = 0, t = surface->num_firstshadowmeshtriangle, e = model->brush.shadowmesh->element3i + t * 3;j < surface->num_triangles;j++, t++, e += 3)
- {
- v[0] = model->brush.shadowmesh->vertex3f + e[0] * 3;
- v[1] = model->brush.shadowmesh->vertex3f + e[1] * 3;
- v[2] = model->brush.shadowmesh->vertex3f + e[2] * 3;
- if (PointInfrontOfTriangle(relativelightorigin, v[0], v[1], v[2]) && lightmaxs[0] > min(v[0][0], min(v[1][0], v[2][0])) && lightmins[0] < max(v[0][0], max(v[1][0], v[2][0])) && lightmaxs[1] > min(v[0][1], min(v[1][1], v[2][1])) && lightmins[1] < max(v[0][1], max(v[1][1], v[2][1])) && lightmaxs[2] > min(v[0][2], min(v[1][2], v[2][2])) && lightmins[2] < max(v[0][2], max(v[1][2], v[2][2])))
- shadowmarklist[numshadowmark++] = t;
- }
- }
+ if (!(surface->texture->surfaceflags & Q3SURFACEFLAG_NODRAW) && !(surface->texture->surfaceparms & Q3SURFACEPARM_TRANS))
+ R_Shadow_MarkVolumeFromBox(surface->num_firstshadowmeshtriangle, surface->num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, relativelightorigin, lightmins, lightmaxs, surface->mins, surface->maxs);
}
R_Shadow_VolumeFromList(model->brush.shadowmesh->numverts, model->brush.shadowmesh->numtriangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, model->brush.shadowmesh->neighbor3i, relativelightorigin, lightradius + model->radius + r_shadow_projectdistance.value, numshadowmark, shadowmarklist);
}
// if compiling an rtlight, capture the mesh
Mod_ShadowMesh_AddMesh(r_shadow_mempool, r_shadow_compilingrtlight->static_meshchain_light, surface->texture->skin.base, surface->texture->skin.gloss, surface->texture->skin.nmap, surface->data_vertex3f, surface->data_svector3f, surface->data_tvector3f, surface->data_normal3f, surface->data_texcoordtexture2f, surface->num_triangles, surface->data_element3i);
}
- else if ((ent != &cl_entities[0].render || surface->visframe == r_framecount) && !(surface->texture->surfaceflags & Q3SURFACEFLAG_NODRAW) && surface->num_triangles)
+ else if (!(surface->texture->surfaceflags & Q3SURFACEFLAG_NODRAW) && surface->num_triangles)
R_Shadow_RenderLighting(surface->num_vertices, surface->num_triangles, surface->data_element3i, surface->data_vertex3f, surface->data_svector3f, surface->data_tvector3f, surface->data_normal3f, surface->data_texcoordtexture2f, relativelightorigin, relativeeyeorigin, lightcolor, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, surface->texture->skin.base, surface->texture->skin.nmap, surface->texture->skin.gloss, lightcubemap, LIGHTING_DIFFUSE | LIGHTING_SPECULAR);
}
}