static int dlightdivtable[32768];
-static int R_IntAddDynamicLights (const matrix4x4_t *matrix, msurface_t *surf)
+static int R_IntAddDynamicLights (const matrix4x4_t *matrix, msurface_t *surface)
{
int sdtable[256], lnum, td, maxdist, maxdist2, maxdist3, i, s, t, smax, tmax, smax3, red, green, blue, lit, dist2, impacts, impactt, subtract, k;
unsigned int *bl;
lit = false;
- smax = (surf->extents[0] >> 4) + 1;
- tmax = (surf->extents[1] >> 4) + 1;
+ smax = (surface->extents[0] >> 4) + 1;
+ tmax = (surface->extents[1] >> 4) + 1;
smax3 = smax * 3;
for (lnum = 0, light = r_dlight;lnum < r_numdlights;lnum++, light++)
{
- if (!(surf->dlightbits[lnum >> 5] & (1 << (lnum & 31))))
+ if (!(surface->dlightbits[lnum >> 5] & (1 << (lnum & 31))))
continue; // not lit by this light
Matrix4x4_Transform(matrix, light->origin, local);
- dist = DotProduct (local, surf->plane->normal) - surf->plane->dist;
+ dist = DotProduct (local, surface->plane->normal) - surface->plane->dist;
// for comparisons to minimum acceptable light
// compensate for LIGHTOFFSET
if (dist2 >= maxdist)
continue;
- if (surf->plane->type < 3)
+ if (surface->plane->type < 3)
{
VectorCopy(local, impact);
- impact[surf->plane->type] -= dist;
+ impact[surface->plane->type] -= dist;
}
else
{
- impact[0] = local[0] - surf->plane->normal[0] * dist;
- impact[1] = local[1] - surf->plane->normal[1] * dist;
- impact[2] = local[2] - surf->plane->normal[2] * dist;
+ impact[0] = local[0] - surface->plane->normal[0] * dist;
+ impact[1] = local[1] - surface->plane->normal[1] * dist;
+ impact[2] = local[2] - surface->plane->normal[2] * dist;
}
- impacts = DotProduct (impact, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] - surf->texturemins[0];
- impactt = DotProduct (impact, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] - surf->texturemins[1];
+ impacts = DotProduct (impact, surface->texinfo->vecs[0]) + surface->texinfo->vecs[0][3] - surface->texturemins[0];
+ impactt = DotProduct (impact, surface->texinfo->vecs[1]) + surface->texinfo->vecs[1][3] - surface->texturemins[1];
s = bound(0, impacts, smax * 16) - impacts;
t = bound(0, impactt, tmax * 16) - impactt;
return lit;
}
-static int R_FloatAddDynamicLights (const matrix4x4_t *matrix, msurface_t *surf)
+static int R_FloatAddDynamicLights (const matrix4x4_t *matrix, msurface_t *surface)
{
int lnum, s, t, smax, tmax, smax3, lit, impacts, impactt;
float sdtable[256], *bl, k, dist, dist2, maxdist, maxdist2, maxdist3, td1, td, red, green, blue, impact[3], local[3], subtract;
lit = false;
- smax = (surf->extents[0] >> 4) + 1;
- tmax = (surf->extents[1] >> 4) + 1;
+ smax = (surface->extents[0] >> 4) + 1;
+ tmax = (surface->extents[1] >> 4) + 1;
smax3 = smax * 3;
for (lnum = 0, light = r_dlight;lnum < r_numdlights;lnum++, light++)
{
- if (!(surf->dlightbits[lnum >> 5] & (1 << (lnum & 31))))
+ if (!(surface->dlightbits[lnum >> 5] & (1 << (lnum & 31))))
continue; // not lit by this light
Matrix4x4_Transform(matrix, light->origin, local);
- dist = DotProduct (local, surf->plane->normal) - surf->plane->dist;
+ dist = DotProduct (local, surface->plane->normal) - surface->plane->dist;
// for comparisons to minimum acceptable light
// compensate for LIGHTOFFSET
if (dist2 >= maxdist)
continue;
- if (surf->plane->type < 3)
+ if (surface->plane->type < 3)
{
VectorCopy(local, impact);
- impact[surf->plane->type] -= dist;
+ impact[surface->plane->type] -= dist;
}
else
{
- impact[0] = local[0] - surf->plane->normal[0] * dist;
- impact[1] = local[1] - surf->plane->normal[1] * dist;
- impact[2] = local[2] - surf->plane->normal[2] * dist;
+ impact[0] = local[0] - surface->plane->normal[0] * dist;
+ impact[1] = local[1] - surface->plane->normal[1] * dist;
+ impact[2] = local[2] - surface->plane->normal[2] * dist;
}
- impacts = DotProduct (impact, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] - surf->texturemins[0];
- impactt = DotProduct (impact, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] - surf->texturemins[1];
+ impacts = DotProduct (impact, surface->texinfo->vecs[0]) + surface->texinfo->vecs[0][3] - surface->texturemins[0];
+ impactt = DotProduct (impact, surface->texinfo->vecs[1]) + surface->texinfo->vecs[1][3] - surface->texturemins[1];
td = bound(0, impacts, smax * 16) - impacts;
td1 = bound(0, impactt, tmax * 16) - impactt;
Combine and scale multiple lightmaps into the 8.8 format in blocklights
===============
*/
-static void R_BuildLightMap (const entity_render_t *ent, msurface_t *surf)
+static void R_BuildLightMap (const entity_render_t *ent, msurface_t *surface)
{
if (!r_floatbuildlightmap.integer)
{
qbyte *lightmap, *out, *stain;
// update cached lighting info
- surf->cached_dlight = 0;
+ surface->cached_dlight = 0;
- smax = (surf->extents[0]>>4)+1;
- tmax = (surf->extents[1]>>4)+1;
+ smax = (surface->extents[0]>>4)+1;
+ tmax = (surface->extents[1]>>4)+1;
size = smax*tmax;
size3 = size*3;
- lightmap = surf->samples;
+ lightmap = surface->samples;
// set to full bright if no light data
bl = intblocklights;
// clear to no light
memset(bl, 0, size*3*sizeof(unsigned int));
- if (surf->dlightframe == r_framecount)
+ if (surface->dlightframe == r_framecount)
{
- surf->cached_dlight = R_IntAddDynamicLights(&ent->inversematrix, surf);
- if (surf->cached_dlight)
+ surface->cached_dlight = R_IntAddDynamicLights(&ent->inversematrix, surface);
+ if (surface->cached_dlight)
c_light_polys++;
}
if (lightmap)
{
bl = intblocklights;
- for (maps = 0;maps < MAXLIGHTMAPS && surf->styles[maps] != 255;maps++, lightmap += size3)
- for (scale = d_lightstylevalue[surf->styles[maps]], i = 0;i < size3;i++)
+ for (maps = 0;maps < MAXLIGHTMAPS && surface->styles[maps] != 255;maps++, lightmap += size3)
+ for (scale = d_lightstylevalue[surface->styles[maps]], i = 0;i < size3;i++)
bl[i] += lightmap[i] * scale;
}
}
- stain = surf->stainsamples;
+ stain = surface->stainsamples;
bl = intblocklights;
out = templight;
// the >> 16 shift adjusts down 8 bits to account for the stainmap
// (0 = 0.0, 128 = 1.0, 256 = 2.0)
if (ent->model->brushq1.lightmaprgba)
{
- stride = (surf->lightmaptexturestride - smax) * 4;
+ stride = (surface->lightmaptexturestride - smax) * 4;
for (i = 0;i < tmax;i++, out += stride)
{
for (j = 0;j < smax;j++)
}
else
{
- stride = (surf->lightmaptexturestride - smax) * 3;
+ stride = (surface->lightmaptexturestride - smax) * 3;
for (i = 0;i < tmax;i++, out += stride)
{
for (j = 0;j < smax;j++)
}
}
- R_UpdateTexture(surf->lightmaptexture, templight);
+ R_UpdateTexture(surface->lightmaptexture, templight);
}
else
{
qbyte *lightmap, *out, *stain;
// update cached lighting info
- surf->cached_dlight = 0;
+ surface->cached_dlight = 0;
- smax = (surf->extents[0]>>4)+1;
- tmax = (surf->extents[1]>>4)+1;
+ smax = (surface->extents[0]>>4)+1;
+ tmax = (surface->extents[1]>>4)+1;
size = smax*tmax;
size3 = size*3;
- lightmap = surf->samples;
+ lightmap = surface->samples;
// set to full bright if no light data
bl = floatblocklights;
{
memset(bl, 0, size*3*sizeof(float));
- if (surf->dlightframe == r_framecount)
+ if (surface->dlightframe == r_framecount)
{
- surf->cached_dlight = R_FloatAddDynamicLights(&ent->inversematrix, surf);
- if (surf->cached_dlight)
+ surface->cached_dlight = R_FloatAddDynamicLights(&ent->inversematrix, surface);
+ if (surface->cached_dlight)
c_light_polys++;
}
if (lightmap)
{
bl = floatblocklights;
- for (maps = 0;maps < MAXLIGHTMAPS && surf->styles[maps] != 255;maps++, lightmap += size3)
- for (scale = d_lightstylevalue[surf->styles[maps]], i = 0;i < size3;i++)
+ for (maps = 0;maps < MAXLIGHTMAPS && surface->styles[maps] != 255;maps++, lightmap += size3)
+ for (scale = d_lightstylevalue[surface->styles[maps]], i = 0;i < size3;i++)
bl[i] += lightmap[i] * scale;
}
}
- stain = surf->stainsamples;
+ stain = surface->stainsamples;
bl = floatblocklights;
out = templight;
// this scaling adjusts down 8 bits to account for the stainmap
scale = 1.0f / (1 << 16);
if (ent->model->brushq1.lightmaprgba)
{
- stride = (surf->lightmaptexturestride - smax) * 4;
+ stride = (surface->lightmaptexturestride - smax) * 4;
for (i = 0;i < tmax;i++, out += stride)
{
for (j = 0;j < smax;j++)
}
else
{
- stride = (surf->lightmaptexturestride - smax) * 3;
+ stride = (surface->lightmaptexturestride - smax) * 3;
for (i = 0;i < tmax;i++, out += stride)
{
for (j = 0;j < smax;j++)
}
}
- R_UpdateTexture(surf->lightmaptexture, templight);
+ R_UpdateTexture(surface->lightmaptexture, templight);
}
}
void R_StainNode (mnode_t *node, model_t *model, const vec3_t origin, float radius, const float fcolor[8])
{
float ndist, a, ratio, maxdist, maxdist2, maxdist3, invradius, sdtable[256], td, dist2;
- msurface_t *surf, *endsurf;
+ msurface_t *surface, *endsurface;
int i, s, t, smax, tmax, smax3, impacts, impactt, stained;
qbyte *bl;
vec3_t impact;
impact[2] = origin[2] - node->plane->normal[2] * ndist;
}
- for (surf = model->brushq1.surfaces + node->firstsurface, endsurf = surf + node->numsurfaces;surf < endsurf;surf++)
+ for (surface = model->brushq1.surfaces + node->firstsurface, endsurface = surface + node->numsurfaces;surface < endsurface;surface++)
{
- if (surf->stainsamples)
+ if (surface->stainsamples)
{
- smax = (surf->extents[0] >> 4) + 1;
- tmax = (surf->extents[1] >> 4) + 1;
+ smax = (surface->extents[0] >> 4) + 1;
+ tmax = (surface->extents[1] >> 4) + 1;
- impacts = DotProduct (impact, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] - surf->texturemins[0];
- impactt = DotProduct (impact, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] - surf->texturemins[1];
+ impacts = DotProduct (impact, surface->texinfo->vecs[0]) + surface->texinfo->vecs[0][3] - surface->texturemins[0];
+ impactt = DotProduct (impact, surface->texinfo->vecs[1]) + surface->texinfo->vecs[1][3] - surface->texturemins[1];
s = bound(0, impacts, smax * 16) - impacts;
t = bound(0, impactt, tmax * 16) - impactt;
for (s = 0, i = impacts; s < smax; s++, i -= 16)
sdtable[s] = i * i + dist2;
- bl = surf->stainsamples;
+ bl = surface->stainsamples;
smax3 = smax * 3;
stained = false;
}
// force lightmap upload
if (stained)
- surf->cached_dlight = true;
+ surface->cached_dlight = true;
}
}
static void RSurfShader_Transparent_Callback(const void *calldata1, int calldata2)
{
const entity_render_t *ent = calldata1;
- const msurface_t *surf = ent->model->brushq1.surfaces + calldata2;
+ const msurface_t *surface = ent->model->brushq1.surfaces + calldata2;
rmeshstate_t m;
float currentalpha;
float base, colorscale;
R_Mesh_Matrix(&ent->matrix);
Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
- texture = surf->texinfo->texture;
+ texture = surface->texinfo->texture;
if (texture->animated)
texture = texture->anim_frames[ent->frame != 0][(texture->anim_total[ent->frame != 0] >= 2) ? ((int) (r_refdef.time * 5.0f) % texture->anim_total[ent->frame != 0]) : 0];
currentalpha = ent->alpha;
- if (surf->flags & SURF_WATERALPHA)
+ if (surface->flags & SURF_WATERALPHA)
currentalpha *= r_wateralpha.value;
GL_DepthTest(!(ent->effects & EF_NODEPTHTEST));
GL_DepthMask(!(ent->effects & EF_NODEPTHTEST));
}
- turb = (surf->flags & SURF_DRAWTURB) && r_waterscroll.value;
- fullbright = !(ent->flags & RENDER_LIGHT) || (surf->flags & SURF_DRAWFULLBRIGHT) || !surf->samples;
+ turb = (surface->flags & SURF_DRAWTURB) && r_waterscroll.value;
+ fullbright = !(ent->flags & RENDER_LIGHT) || (surface->flags & SURF_DRAWFULLBRIGHT) || !surface->samples;
base = fullbright ? 2.0f : r_ambient.value * (1.0f / 64.0f);
- if (surf->flags & SURF_DRAWTURB)
+ if (surface->flags & SURF_DRAWTURB)
base *= 0.5f;
- if ((surf->flags & SURF_DRAWTURB) && gl_textureshader && r_watershader.value && !fogenabled && fullbright && ent->colormod[0] == 1 && ent->colormod[1] == 1 && ent->colormod[2] == 1)
+ if ((surface->flags & SURF_DRAWTURB) && gl_textureshader && r_watershader.value && !fogenabled && fullbright && ent->colormod[0] == 1 && ent->colormod[1] == 1 && ent->colormod[2] == 1)
{
// NVIDIA Geforce3 distortion texture shader on water
GL_Color(1, 1, 1, currentalpha);
memset(&m, 0, sizeof(m));
- m.pointer_vertex = surf->mesh.data_vertex3f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
m.tex[0] = R_GetTexture(mod_shared_distorttexture[(int)(r_refdef.time * 16)&63]);
m.tex[1] = R_GetTexture(texture->skin.base);
m.texcombinergb[0] = GL_REPLACE;
m.texcombinergb[1] = GL_REPLACE;
- m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f;
- m.pointer_texcoord[1] = surf->mesh.data_texcoordtexture2f;
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
+ m.pointer_texcoord[1] = surface->mesh.data_texcoordtexture2f;
Matrix4x4_CreateFromQuakeEntity(&m.texmatrix[0], 0, 0, 0, 0, 0, 0, r_watershader.value);
Matrix4x4_CreateTranslate(&m.texmatrix[1], sin(r_refdef.time) * 0.025 * r_waterscroll.value, sin(r_refdef.time * 0.8f) * 0.025 * r_waterscroll.value, 0);
R_Mesh_State(&m);
qglTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, &args[0]);
qglEnable(GL_TEXTURE_SHADER_NV);
- GL_LockArrays(0, surf->mesh.num_vertices);
- R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
qglDisable(GL_TEXTURE_SHADER_NV);
else
{
memset(&m, 0, sizeof(m));
- m.pointer_vertex = surf->mesh.data_vertex3f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
m.pointer_color = varray_color4f;
- m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f;
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
m.tex[0] = R_GetTexture(texture->skin.base);
if (turb)
{
m.texrgbscale[0] = 4;
colorscale *= 0.25f;
}
- R_FillColors(varray_color4f, surf->mesh.num_vertices, base * ent->colormod[0], base * ent->colormod[1], base * ent->colormod[2], currentalpha);
+ R_FillColors(varray_color4f, surface->mesh.num_vertices, base * ent->colormod[0], base * ent->colormod[1], base * ent->colormod[2], currentalpha);
if (!fullbright)
{
- if (surf->dlightframe == r_framecount)
- RSurf_LightSeparate_Vertex3f_Color4f(&ent->inversematrix, surf->dlightbits, surf->mesh.num_vertices, surf->mesh.data_vertex3f, varray_color4f, 1);
- if (surf->samples)
- RSurf_AddLightmapToVertexColors_Color4f(surf->mesh.data_lightmapoffsets, varray_color4f,surf->mesh.num_vertices, surf->samples, ((surf->extents[0]>>4)+1)*((surf->extents[1]>>4)+1)*3, surf->styles);
+ if (surface->dlightframe == r_framecount)
+ RSurf_LightSeparate_Vertex3f_Color4f(&ent->inversematrix, surface->dlightbits, surface->mesh.num_vertices, surface->mesh.data_vertex3f, varray_color4f, 1);
+ if (surface->samples)
+ RSurf_AddLightmapToVertexColors_Color4f(surface->mesh.data_lightmapoffsets, varray_color4f,surface->mesh.num_vertices, surface->samples, ((surface->extents[0]>>4)+1)*((surface->extents[1]>>4)+1)*3, surface->styles);
}
- RSurf_FogColors_Vertex3f_Color4f(surf->mesh.data_vertex3f, varray_color4f, colorscale, surf->mesh.num_vertices, modelorg);
+ RSurf_FogColors_Vertex3f_Color4f(surface->mesh.data_vertex3f, varray_color4f, colorscale, surface->mesh.num_vertices, modelorg);
R_Mesh_State(&m);
- GL_LockArrays(0, surf->mesh.num_vertices);
- R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
if (texture->skin.glow)
{
GL_DepthMask(false);
m.pointer_color = varray_color4f;
m.tex[0] = R_GetTexture(texture->skin.glow);
- m.pointer_vertex = surf->mesh.data_vertex3f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
if (m.tex[0])
{
- m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f;
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
if (turb)
{
// scrolling in texture matrix
}
}
R_Mesh_State(&m);
- RSurf_FoggedColors_Vertex3f_Color4f(surf->mesh.data_vertex3f, varray_color4f, 1, 1, 1, currentalpha, 1, surf->mesh.num_vertices, modelorg);
- GL_LockArrays(0, surf->mesh.num_vertices);
- R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
+ RSurf_FoggedColors_Vertex3f_Color4f(surface->mesh.data_vertex3f, varray_color4f, 1, 1, 1, currentalpha, 1, surface->mesh.num_vertices, modelorg);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
if (fogenabled && rendertype != SURFRENDER_ADD)
GL_DepthMask(false);
m.pointer_color = varray_color4f;
m.tex[0] = R_GetTexture(texture->skin.fog);
- m.pointer_vertex = surf->mesh.data_vertex3f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
if (m.tex[0])
{
- m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f;
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
if (turb)
{
// scrolling in texture matrix
}
}
R_Mesh_State(&m);
- RSurf_FogPassColors_Vertex3f_Color4f(surf->mesh.data_vertex3f, varray_color4f, fogcolor[0], fogcolor[1], fogcolor[2], currentalpha, 1, surf->mesh.num_vertices, modelorg);
- GL_LockArrays(0, surf->mesh.num_vertices);
- R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
+ RSurf_FogPassColors_Vertex3f_Color4f(surface->mesh.data_vertex3f, varray_color4f, fogcolor[0], fogcolor[1], fogcolor[2], currentalpha, 1, surface->mesh.num_vertices, modelorg);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
}
if (CHECKPVSBIT(r_pvsbits, leaf->clusterindex) && !R_CullBox(leaf->mins, leaf->maxs))
{
c_leafs++;
- for (i = 0;i < leaf->numleaffaces;i++)
- r_worldsurfacevisible[leaf->firstleafface[i]] = 1;
+ for (i = 0;i < leaf->numleafsurfaces;i++)
+ r_worldsurfacevisible[leaf->firstleafsurface[i]] = 1;
}
}
}
if (CHECKPVSBIT(r_pvsbits, leaf->clusterindex) && !R_CullBox (leaf->mins, leaf->maxs))
{
c_leafs++;
- if (leaf->numleaffaces)
- for (i = 0, mark = leaf->firstleafface;i < leaf->numleaffaces;i++, mark++)
+ if (leaf->numleafsurfaces)
+ for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
r_worldsurfacevisible[*mark] = true;
}
}
leaf = leafstack[--leafstackpos];
leafvisited[leaf - r_refdef.worldmodel->brush.data_leafs] = 1;
// draw any surfaces bounding this leaf
- if (leaf->numleaffaces)
- for (i = 0, mark = leaf->firstleafface;i < leaf->numleaffaces;i++, mark++)
+ if (leaf->numleafsurfaces)
+ for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
r_worldsurfacevisible[*mark] = true;
// follow portals into other leafs
for (p = leaf->portals;p;p = p->next)
{
model_t *model = ent->model;
vec3_t lightmins, lightmaxs;
- int t, leafindex, leaffaceindex, surfaceindex, triangleindex, outnumclusters = 0, outnumsurfaces = 0;
+ int t, leafindex, leafsurfaceindex, surfaceindex, triangleindex, outnumclusters = 0, outnumsurfaces = 0;
const int *e;
const float *v[3];
msurface_t *surface;
}
if (outsurfacepvs)
{
- for (leaffaceindex = 0;leaffaceindex < leaf->numleaffaces;leaffaceindex++)
+ for (leafsurfaceindex = 0;leafsurfaceindex < leaf->numleafsurfaces;leafsurfaceindex++)
{
- surfaceindex = leaf->firstleafface[leaffaceindex];
+ surfaceindex = leaf->firstleafsurface[leafsurfaceindex];
if (!CHECKPVSBIT(outsurfacepvs, surfaceindex))
{
surface = model->brushq1.surfaces + surfaceindex;
GL_LockArrays(0, 0);
}
-void R_Q3BSP_DrawCollisionFace(entity_render_t *ent, q3msurface_t *face)
+void R_Q3BSP_DrawCollisionFace(entity_render_t *ent, q3msurface_t *surface)
{
int i;
rmeshstate_t m;
- if (!face->mesh.num_collisiontriangles)
+ if (!surface->mesh.num_collisiontriangles)
return;
memset(&m, 0, sizeof(m));
- m.pointer_vertex = face->mesh.data_collisionvertex3f;
+ m.pointer_vertex = surface->mesh.data_collisionvertex3f;
R_Mesh_State(&m);
- i = (int)(((size_t)face) / sizeof(q3msurface_t));
+ i = (int)(((size_t)surface) / 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->mesh.num_collisionvertices);
- R_Mesh_Draw(face->mesh.num_collisionvertices, face->mesh.num_collisiontriangles, face->mesh.data_collisionelement3i);
+ GL_LockArrays(0, surface->mesh.num_collisionvertices);
+ R_Mesh_Draw(surface->mesh.num_collisionvertices, surface->mesh.num_collisiontriangles, surface->mesh.data_collisionelement3i);
GL_LockArrays(0, 0);
}
-void R_Q3BSP_DrawFace_TransparentCallback(const void *voident, int facenumber)
+void R_Q3BSP_DrawFace_TransparentCallback(const void *voident, int surfacenumber)
{
const entity_render_t *ent = voident;
- q3msurface_t *face = ent->model->brushq3.data_faces + facenumber;
+ q3msurface_t *surface = ent->model->brushq3.data_faces + surfacenumber;
rmeshstate_t m;
R_Mesh_Matrix(&ent->matrix);
memset(&m, 0, sizeof(m));
- if ((ent->effects & EF_ADDITIVE) || (face->texture->textureflags & Q3TEXTUREFLAG_ADDITIVE))
+ if ((ent->effects & EF_ADDITIVE) || (surface->texture->textureflags & Q3TEXTUREFLAG_ADDITIVE))
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
else
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GL_DepthMask(false);
GL_DepthTest(!(ent->effects & EF_NODEPTHTEST));
- m.tex[0] = R_GetTexture(face->texture->skin.base);
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
+ m.tex[0] = R_GetTexture(surface->texture->skin.base);
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
// LordHavoc: quake3 was not able to do this; lit transparent surfaces
if (gl_combine.integer)
{
m.texrgbscale[0] = 2;
if (r_textureunits.integer >= 2)
{
- m.tex[1] = R_GetTexture(face->lightmaptexture);
- m.pointer_texcoord[1] = face->mesh.data_texcoordlightmap2f;
+ m.tex[1] = R_GetTexture(surface->lightmaptexture);
+ m.pointer_texcoord[1] = surface->mesh.data_texcoordlightmap2f;
GL_Color(ent->colormod[0], ent->colormod[1], ent->colormod[2], ent->alpha);
}
else
{
if (ent->colormod[0] == 1 && ent->colormod[1] == 1 && ent->colormod[2] == 1 && ent->alpha == 1)
- m.pointer_color = face->mesh.data_lightmapcolor4f;
+ m.pointer_color = surface->mesh.data_lightmapcolor4f;
else
{
int i;
- for (i = 0;i < face->mesh.num_vertices;i++)
+ for (i = 0;i < surface->mesh.num_vertices;i++)
{
- varray_color4f[i*4+0] = face->mesh.data_lightmapcolor4f[i*4+0] * ent->colormod[0];
- varray_color4f[i*4+1] = face->mesh.data_lightmapcolor4f[i*4+1] * ent->colormod[1];
- varray_color4f[i*4+2] = face->mesh.data_lightmapcolor4f[i*4+2] * ent->colormod[2];
- varray_color4f[i*4+3] = face->mesh.data_lightmapcolor4f[i*4+3] * ent->alpha;
+ varray_color4f[i*4+0] = surface->mesh.data_lightmapcolor4f[i*4+0] * ent->colormod[0];
+ varray_color4f[i*4+1] = surface->mesh.data_lightmapcolor4f[i*4+1] * ent->colormod[1];
+ varray_color4f[i*4+2] = surface->mesh.data_lightmapcolor4f[i*4+2] * ent->colormod[2];
+ varray_color4f[i*4+3] = surface->mesh.data_lightmapcolor4f[i*4+3] * ent->alpha;
}
m.pointer_color = varray_color4f;
}
else
{
int i;
- for (i = 0;i < face->mesh.num_vertices;i++)
+ for (i = 0;i < surface->mesh.num_vertices;i++)
{
- varray_color4f[i*4+0] = face->mesh.data_lightmapcolor4f[i*4+0] * ent->colormod[0] * 2.0f;
- varray_color4f[i*4+1] = face->mesh.data_lightmapcolor4f[i*4+1] * ent->colormod[1] * 2.0f;
- varray_color4f[i*4+2] = face->mesh.data_lightmapcolor4f[i*4+2] * ent->colormod[2] * 2.0f;
- varray_color4f[i*4+3] = face->mesh.data_lightmapcolor4f[i*4+3] * ent->alpha;
+ varray_color4f[i*4+0] = surface->mesh.data_lightmapcolor4f[i*4+0] * ent->colormod[0] * 2.0f;
+ varray_color4f[i*4+1] = surface->mesh.data_lightmapcolor4f[i*4+1] * ent->colormod[1] * 2.0f;
+ varray_color4f[i*4+2] = surface->mesh.data_lightmapcolor4f[i*4+2] * ent->colormod[2] * 2.0f;
+ varray_color4f[i*4+3] = surface->mesh.data_lightmapcolor4f[i*4+3] * ent->alpha;
}
m.pointer_color = varray_color4f;
}
- if (face->texture->textureflags & (Q3TEXTUREFLAG_AUTOSPRITE | Q3TEXTUREFLAG_AUTOSPRITE2))
+ if (surface->texture->textureflags & (Q3TEXTUREFLAG_AUTOSPRITE | Q3TEXTUREFLAG_AUTOSPRITE2))
{
int i, j;
float center[3], center2[3], forward[3], right[3], up[3], v[4][3];
matrix4x4_t matrix1, imatrix1;
R_Mesh_Matrix(&r_identitymatrix);
// a single autosprite surface can contain multiple sprites...
- for (j = 0;j < face->mesh.num_vertices - 3;j += 4)
+ for (j = 0;j < surface->mesh.num_vertices - 3;j += 4)
{
VectorClear(center);
for (i = 0;i < 4;i++)
- VectorAdd(center, face->mesh.data_vertex3f + (j+i) * 3, center);
+ VectorAdd(center, surface->mesh.data_vertex3f + (j+i) * 3, center);
VectorScale(center, 0.25f, center);
Matrix4x4_Transform(&ent->matrix, center, center2);
// FIXME: calculate vectors from triangle edges instead of using texture vectors as an easy way out?
- Matrix4x4_FromVectors(&matrix1, face->mesh.data_normal3f + j*3, face->mesh.data_svector3f + j*3, face->mesh.data_tvector3f + j*3, center);
+ Matrix4x4_FromVectors(&matrix1, surface->mesh.data_normal3f + j*3, surface->mesh.data_svector3f + j*3, surface->mesh.data_tvector3f + j*3, center);
Matrix4x4_Invert_Simple(&imatrix1, &matrix1);
for (i = 0;i < 4;i++)
- Matrix4x4_Transform(&imatrix1, face->mesh.data_vertex3f + (j+i)*3, v[i]);
- if (face->texture->textureflags & Q3TEXTUREFLAG_AUTOSPRITE2)
+ Matrix4x4_Transform(&imatrix1, surface->mesh.data_vertex3f + (j+i)*3, v[i]);
+ if (surface->texture->textureflags & Q3TEXTUREFLAG_AUTOSPRITE2)
{
forward[0] = r_vieworigin[0] - center2[0];
forward[1] = r_vieworigin[1] - center2[1];
m.pointer_vertex = varray_vertex3f;
}
else
- m.pointer_vertex = face->mesh.data_vertex3f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- if (face->texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
+ if (surface->texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
qglDisable(GL_CULL_FACE);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
- if (face->texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
+ if (surface->texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
qglEnable(GL_CULL_FACE);
}
-void R_Q3BSP_DrawFaceList(entity_render_t *ent, texture_t *t, int texturenumfaces, q3msurface_t **texturefacelist)
+void R_Q3BSP_DrawFaceList(entity_render_t *ent, texture_t *t, int texturenumsurfaces, q3msurface_t **texturesurfacelist)
{
- int i, texturefaceindex;
+ int i, texturesurfaceindex;
qboolean dolightmap;
qboolean dobase;
qboolean doambient;
qboolean doglow;
qboolean dofog;
rmeshstate_t m;
- if (!texturenumfaces)
+ if (!texturenumsurfaces)
return;
- c_faces += texturenumfaces;
+ c_faces += texturenumsurfaces;
// gl_lightmaps debugging mode skips normal texturing
if (gl_lightmaps.integer)
{
GL_BlendFunc(GL_ONE, GL_ZERO);
qglDisable(GL_CULL_FACE);
memset(&m, 0, sizeof(m));
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.tex[0] = R_GetTexture(face->lightmaptexture);
- m.pointer_texcoord[0] = face->mesh.data_texcoordlightmap2f;
- if (face->lightmaptexture)
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ m.tex[0] = R_GetTexture(surface->lightmaptexture);
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordlightmap2f;
+ if (surface->lightmaptexture)
{
GL_Color(1, 1, 1, 1);
m.pointer_color = NULL;
}
else
- m.pointer_color = face->mesh.data_lightmapcolor4f;
- m.pointer_vertex = face->mesh.data_vertex3f;
+ m.pointer_color = surface->mesh.data_lightmapcolor4f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
qglEnable(GL_CULL_FACE);
// drawing sky transparently would be too difficult
if (t->surfaceparms & Q3SURFACEPARM_SKY)
return;
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- facecenter[0] = (face->mins[0] + face->maxs[0]) * 0.5f;
- facecenter[1] = (face->mins[1] + face->maxs[1]) * 0.5f;
- facecenter[2] = (face->mins[2] + face->maxs[2]) * 0.5f;
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ facecenter[0] = (surface->mins[0] + surface->maxs[0]) * 0.5f;
+ facecenter[1] = (surface->mins[1] + surface->maxs[1]) * 0.5f;
+ facecenter[2] = (surface->mins[2] + surface->maxs[2]) * 0.5f;
Matrix4x4_Transform(&ent->matrix, facecenter, center);
- R_MeshQueue_AddTransparent(center, R_Q3BSP_DrawFace_TransparentCallback, ent, face - ent->model->brushq3.data_faces);
+ R_MeshQueue_AddTransparent(center, R_Q3BSP_DrawFace_TransparentCallback, ent, surface - ent->model->brushq3.data_faces);
}
return;
}
GL_DepthTest(true);
memset(&m, 0, sizeof(m));
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_vertex = face->mesh.data_vertex3f;
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
qglDisable(GL_CULL_FACE);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(t->skin.base);
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_vertex = face->mesh.data_vertex3f;
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
}
GL_BlendFunc(GL_ONE, GL_ZERO);
GL_Color(0, 0, 0, 1);
memset(&m, 0, sizeof(m));
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_vertex = face->mesh.data_vertex3f;
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
}
m.tex[0] = R_GetTexture(t->skin.base);
GL_Color(r_lightmapintensity * ent->colormod[0], r_lightmapintensity * ent->colormod[1], r_lightmapintensity * ent->colormod[2], 1);
m.pointer_color = NULL;
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- if (!face->lightmaptexture)
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ if (!surface->lightmaptexture)
continue;
- m.tex[1] = R_GetTexture(face->lightmaptexture);
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_texcoord[1] = face->mesh.data_texcoordlightmap2f;
+ m.tex[1] = R_GetTexture(surface->lightmaptexture);
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
+ m.pointer_texcoord[1] = surface->mesh.data_texcoordlightmap2f;
m.texrgbscale[1] = 2;
- m.pointer_vertex = face->mesh.data_vertex3f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
if (r_lightmapintensity == 1 && ent->colormod[0] == 1 && ent->colormod[1] == 1 && ent->colormod[2] == 1)
{
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- if (face->lightmaptexture)
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ if (surface->lightmaptexture)
continue;
- m.tex[1] = R_GetTexture(face->lightmaptexture);
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_texcoord[1] = face->mesh.data_texcoordlightmap2f;
+ m.tex[1] = R_GetTexture(surface->lightmaptexture);
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
+ m.pointer_texcoord[1] = surface->mesh.data_texcoordlightmap2f;
m.texrgbscale[1] = 2;
- m.pointer_color = face->mesh.data_lightmapcolor4f;
- m.pointer_vertex = face->mesh.data_vertex3f;
+ m.pointer_color = surface->mesh.data_lightmapcolor4f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
}
else
{
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- if (face->lightmaptexture)
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ if (surface->lightmaptexture)
continue;
- m.tex[1] = R_GetTexture(face->lightmaptexture);
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_texcoord[1] = face->mesh.data_texcoordlightmap2f;
+ m.tex[1] = R_GetTexture(surface->lightmaptexture);
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
+ m.pointer_texcoord[1] = surface->mesh.data_texcoordlightmap2f;
m.texrgbscale[1] = 2;
m.pointer_color = varray_color4f;
- for (i = 0;i < face->mesh.num_vertices;i++)
+ for (i = 0;i < surface->mesh.num_vertices;i++)
{
- varray_color4f[i*4+0] = face->mesh.data_lightmapcolor4f[i*4+0] * ent->colormod[0] * r_lightmapintensity;
- varray_color4f[i*4+1] = face->mesh.data_lightmapcolor4f[i*4+1] * ent->colormod[1] * r_lightmapintensity;
- varray_color4f[i*4+2] = face->mesh.data_lightmapcolor4f[i*4+2] * ent->colormod[2] * r_lightmapintensity;
- varray_color4f[i*4+3] = face->mesh.data_lightmapcolor4f[i*4+3];
+ varray_color4f[i*4+0] = surface->mesh.data_lightmapcolor4f[i*4+0] * ent->colormod[0] * r_lightmapintensity;
+ varray_color4f[i*4+1] = surface->mesh.data_lightmapcolor4f[i*4+1] * ent->colormod[1] * r_lightmapintensity;
+ varray_color4f[i*4+2] = surface->mesh.data_lightmapcolor4f[i*4+2] * ent->colormod[2] * r_lightmapintensity;
+ varray_color4f[i*4+3] = surface->mesh.data_lightmapcolor4f[i*4+3];
}
- m.pointer_vertex = face->mesh.data_vertex3f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
}
GL_DepthTest(true);
GL_BlendFunc(GL_ONE, GL_ZERO);
memset(&m, 0, sizeof(m));
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.tex[0] = R_GetTexture(face->lightmaptexture);
- m.pointer_texcoord[0] = face->mesh.data_texcoordlightmap2f;
- if (face->lightmaptexture)
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ m.tex[0] = R_GetTexture(surface->lightmaptexture);
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordlightmap2f;
+ if (surface->lightmaptexture)
m.pointer_color = NULL;
else
- m.pointer_color = face->mesh.data_lightmapcolor4f;
- m.pointer_vertex = face->mesh.data_vertex3f;
+ m.pointer_color = surface->mesh.data_lightmapcolor4f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
}
GL_Color(r_lightmapintensity * ent->colormod[0], r_lightmapintensity * ent->colormod[1], r_lightmapintensity * ent->colormod[2], 1);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(t->skin.base);
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_vertex = face->mesh.data_vertex3f;
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
}
GL_Color(r_ambient.value * (1.0f / 128.0f) * ent->colormod[0], r_ambient.value * (1.0f / 128.0f) * ent->colormod[1], r_ambient.value * (1.0f / 128.0f) * ent->colormod[2], 1);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(t->skin.base);
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_vertex = face->mesh.data_vertex3f;
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
}
GL_Color(1, 1, 1, 1);
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(t->skin.glow);
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_vertex = face->mesh.data_vertex3f;
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
}
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(t->skin.fog);
m.pointer_color = varray_color4f;
- for (texturefaceindex = 0;texturefaceindex < texturenumfaces;texturefaceindex++)
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
- q3msurface_t *face = texturefacelist[texturefaceindex];
+ q3msurface_t *surface = texturesurfacelist[texturesurfaceindex];
if (m.tex[0])
- m.pointer_texcoord[0] = face->mesh.data_texcoordtexture2f;
- m.pointer_vertex = face->mesh.data_vertex3f;
+ m.pointer_texcoord[0] = surface->mesh.data_texcoordtexture2f;
+ m.pointer_vertex = surface->mesh.data_vertex3f;
R_Mesh_State(&m);
- RSurf_FogPassColors_Vertex3f_Color4f(face->mesh.data_vertex3f, varray_color4f, fogcolor[0], fogcolor[1], fogcolor[2], 1, 1, face->mesh.num_vertices, modelorg);
- GL_LockArrays(0, face->mesh.num_vertices);
- R_Mesh_Draw(face->mesh.num_vertices, face->mesh.num_triangles, face->mesh.data_element3i);
+ RSurf_FogPassColors_Vertex3f_Color4f(surface->mesh.data_vertex3f, varray_color4f, fogcolor[0], fogcolor[1], fogcolor[2], 1, 1, surface->mesh.num_vertices, modelorg);
+ GL_LockArrays(0, surface->mesh.num_vertices);
+ R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
GL_LockArrays(0, 0);
}
}
void R_Q3BSP_DrawFaces(entity_render_t *ent, int skyfaces)
{
int i, j, f, flagsmask, flags;
- q3msurface_t *face;
+ q3msurface_t *surface;
model_t *model = ent->model;
texture_t *t;
const int maxfaces = 1024;
- int numfaces = 0;
- q3msurface_t *facelist[1024];
+ int numsurfaces = 0;
+ q3msurface_t *surfacelist[1024];
R_Mesh_Matrix(&ent->matrix);
flagsmask = Q3SURFACEFLAG_NODRAW | Q3SURFACEFLAG_SKY;
if (skyfaces)
flags = 0;
t = NULL;
f = 0;
- numfaces = 0;
+ numsurfaces = 0;
for (i = 0, j = model->firstmodelsurface;i < model->nummodelsurfaces;i++, j++)
{
if (ent != r_refdef.worldentity || r_worldsurfacevisible[j])
{
- face = model->brushq3.data_faces + j;
- if (t != face->texture)
+ surface = model->brushq3.data_faces + j;
+ if (t != surface->texture)
{
- if (numfaces)
+ if (numsurfaces)
{
- R_Q3BSP_DrawFaceList(ent, t, numfaces, facelist);
- numfaces = 0;
+ R_Q3BSP_DrawFaceList(ent, t, numsurfaces, surfacelist);
+ numsurfaces = 0;
}
- t = face->texture;
+ t = surface->texture;
f = t->surfaceflags & flagsmask;
}
if (f == flags)
{
- if (!face->mesh.num_triangles)
+ if (!surface->mesh.num_triangles)
continue;
- facelist[numfaces++] = face;
- if (numfaces >= maxfaces)
+ surfacelist[numsurfaces++] = surface;
+ if (numsurfaces >= maxfaces)
{
- R_Q3BSP_DrawFaceList(ent, t, numfaces, facelist);
- numfaces = 0;
+ R_Q3BSP_DrawFaceList(ent, t, numsurfaces, surfacelist);
+ numsurfaces = 0;
}
}
}
}
- if (numfaces)
- R_Q3BSP_DrawFaceList(ent, t, numfaces, facelist);
+ if (numsurfaces)
+ R_Q3BSP_DrawFaceList(ent, t, numsurfaces, surfacelist);
}
void R_Q3BSP_DrawSky(entity_render_t *ent)
{
int i;
model_t *model = ent->model;
- q3msurface_t *face;
+ q3msurface_t *surface;
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
GL_DepthMask(false);
GL_DepthTest(true);
for (i = 0;i < model->brushq3.data_models[model->brush.submodel].numbrushes;i++)
if (model->brushq3.data_models[model->brush.submodel].firstbrush[i].colbrushf && model->brushq3.data_models[model->brush.submodel].firstbrush[i].colbrushf->numtriangles)
R_DrawCollisionBrush(model->brushq3.data_models[model->brush.submodel].firstbrush[i].colbrushf);
- for (i = 0, face = model->brushq3.data_models[model->brush.submodel].firstface;i < model->brushq3.data_models[model->brush.submodel].numfaces;i++, face++)
- if (face->mesh.num_collisiontriangles)
- R_Q3BSP_DrawCollisionFace(ent, face);
+ for (i = 0, surface = model->brushq3.data_models[model->brush.submodel].firstsurface;i < model->brushq3.data_models[model->brush.submodel].numsurfaces;i++, surface++)
+ if (surface->mesh.num_collisiontriangles)
+ R_Q3BSP_DrawCollisionFace(ent, surface);
qglPolygonOffset(0, 0);
}
}
{
model_t *model = ent->model;
vec3_t lightmins, lightmaxs;
- int t, leafindex, leaffaceindex, surfaceindex, triangleindex, outnumclusters = 0, outnumsurfaces = 0;
+ int t, leafindex, leafsurfaceindex, surfaceindex, triangleindex, outnumclusters = 0, outnumsurfaces = 0;
const int *e;
const float *v[3];
q3msurface_t *surface;
}
if (outsurfacepvs)
{
- for (leaffaceindex = 0;leaffaceindex < leaf->numleaffaces;leaffaceindex++)
+ for (leafsurfaceindex = 0;leafsurfaceindex < leaf->numleafsurfaces;leafsurfaceindex++)
{
- surfaceindex = leaf->firstleafface[leaffaceindex];
+ surfaceindex = leaf->firstleafsurface[leafsurfaceindex];
surface = model->brushq3.data_faces + surfaceindex;
if (!CHECKPVSBIT(outsurfacepvs, surfaceindex))
{
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
surface = model->brushq3.data_faces + surfacelist[surfacelistindex];
- // FIXME: check some manner of face->rendermode here?
+ // FIXME: check some manner of surface->rendermode here?
if (!(surface->texture->surfaceflags & Q3SURFACEFLAG_NODRAW) && !(surface->texture->surfaceparms & (Q3SURFACEPARM_SKY | Q3SURFACEPARM_TRANS)) && !(surface->texture->textureflags & Q3TEXTUREFLAG_TWOSIDED))
R_Shadow_MarkVolumeFromBox(surface->num_firstshadowmeshtriangle, surface->mesh.num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, relativelightorigin, lightmins, lightmaxs, surface->mins, surface->maxs);
}
#endif
static void Mod_Q1BSP_FindNonSolidLocation_r_Leaf(findnonsolidlocationinfo_t *info, mleaf_t *leaf)
{
- int i, surfnum, k, *tri, *mark;
+ int i, surfacenum, k, *tri, *mark;
float dist, f, vert[3][3], edge[3][3], facenormal[3], edgenormal[3][3], point[3];
#if 0
float surfnormal[3];
#endif
- msurface_t *surf;
- for (surfnum = 0, mark = leaf->firstleafface;surfnum < leaf->numleaffaces;surfnum++, mark++)
+ msurface_t *surface;
+ for (surfacenum = 0, mark = leaf->firstleafsurface;surfacenum < leaf->numleafsurfaces;surfacenum++, mark++)
{
- surf = info->model->brushq1.surfaces + *mark;
- if (surf->flags & SURF_SOLIDCLIP)
+ surface = info->model->brushq1.surfaces + *mark;
+ if (surface->flags & SURF_SOLIDCLIP)
{
#if 0
- VectorCopy(surf->plane->normal, surfnormal);
- if (surf->flags & SURF_PLANEBACK)
+ VectorCopy(surface->plane->normal, surfnormal);
+ if (surface->flags & SURF_PLANEBACK)
VectorNegate(surfnormal, surfnormal);
#endif
- for (k = 0;k < surf->mesh.num_triangles;k++)
+ for (k = 0;k < surface->mesh.num_triangles;k++)
{
- tri = surf->mesh.data_element3i + k * 3;
- VectorCopy((surf->mesh.data_vertex3f + tri[0] * 3), vert[0]);
- VectorCopy((surf->mesh.data_vertex3f + tri[1] * 3), vert[1]);
- VectorCopy((surf->mesh.data_vertex3f + tri[2] * 3), vert[2]);
+ tri = surface->mesh.data_element3i + k * 3;
+ VectorCopy((surface->mesh.data_vertex3f + tri[0] * 3), vert[0]);
+ VectorCopy((surface->mesh.data_vertex3f + tri[1] * 3), vert[1]);
+ VectorCopy((surface->mesh.data_vertex3f + tri[2] * 3), vert[2]);
VectorSubtract(vert[1], vert[0], edge[0]);
VectorSubtract(vert[2], vert[1], edge[1]);
CrossProduct(edge[1], edge[0], facenormal);
}
else
{
- if (((mleaf_t *)node)->numleaffaces)
+ if (((mleaf_t *)node)->numleafsurfaces)
Mod_Q1BSP_FindNonSolidLocation_r_Leaf(info, (mleaf_t *)node);
}
}
if (node->numsurfaces)
{
int i, ds, dt;
- msurface_t *surf;
+ msurface_t *surface;
- surf = r_refdef.worldmodel->brushq1.surfaces + node->firstsurface;
- for (i = 0;i < node->numsurfaces;i++, surf++)
+ surface = r_refdef.worldmodel->brushq1.surfaces + node->firstsurface;
+ for (i = 0;i < node->numsurfaces;i++, surface++)
{
- if (!(surf->flags & SURF_LIGHTMAP) || !surf->samples)
+ if (!(surface->flags & SURF_LIGHTMAP) || !surface->samples)
continue; // no lightmaps
- ds = (int) (x * surf->texinfo->vecs[0][0] + y * surf->texinfo->vecs[0][1] + mid * surf->texinfo->vecs[0][2] + surf->texinfo->vecs[0][3]) - surf->texturemins[0];
- dt = (int) (x * surf->texinfo->vecs[1][0] + y * surf->texinfo->vecs[1][1] + mid * surf->texinfo->vecs[1][2] + surf->texinfo->vecs[1][3]) - surf->texturemins[1];
+ ds = (int) (x * surface->texinfo->vecs[0][0] + y * surface->texinfo->vecs[0][1] + mid * surface->texinfo->vecs[0][2] + surface->texinfo->vecs[0][3]) - surface->texturemins[0];
+ dt = (int) (x * surface->texinfo->vecs[1][0] + y * surface->texinfo->vecs[1][1] + mid * surface->texinfo->vecs[1][2] + surface->texinfo->vecs[1][3]) - surface->texturemins[1];
- if (ds >= 0 && ds < surf->extents[0] && dt >= 0 && dt < surf->extents[1])
+ if (ds >= 0 && ds < surface->extents[0] && dt >= 0 && dt < surface->extents[1])
{
qbyte *lightmap;
int lmwidth, lmheight, maps, line3, size3, dsfrac = ds & 15, dtfrac = dt & 15, scale = 0, r00 = 0, g00 = 0, b00 = 0, r01 = 0, g01 = 0, b01 = 0, r10 = 0, g10 = 0, b10 = 0, r11 = 0, g11 = 0, b11 = 0;
- lmwidth = ((surf->extents[0]>>4)+1);
- lmheight = ((surf->extents[1]>>4)+1);
+ lmwidth = ((surface->extents[0]>>4)+1);
+ lmheight = ((surface->extents[1]>>4)+1);
line3 = lmwidth * 3; // LordHavoc: *3 for colored lighting
size3 = lmwidth * lmheight * 3; // LordHavoc: *3 for colored lighting
- lightmap = surf->samples + ((dt>>4) * lmwidth + (ds>>4))*3; // LordHavoc: *3 for colored lighting
+ lightmap = surface->samples + ((dt>>4) * lmwidth + (ds>>4))*3; // LordHavoc: *3 for colored lighting
- for (maps = 0;maps < MAXLIGHTMAPS && surf->styles[maps] != 255;maps++)
+ for (maps = 0;maps < MAXLIGHTMAPS && surface->styles[maps] != 255;maps++)
{
- scale = d_lightstylevalue[surf->styles[maps]];
+ scale = d_lightstylevalue[surface->styles[maps]];
r00 += lightmap[ 0] * scale;g00 += lightmap[ 1] * scale;b00 += lightmap[ 2] * scale;
r01 += lightmap[ 3] * scale;g01 += lightmap[ 4] * scale;b01 += lightmap[ 5] * scale;
r10 += lightmap[line3+0] * scale;g10 += lightmap[line3+1] * scale;b10 += lightmap[line3+2] * scale;
//Breaks a polygon up along axial 64 unit
//boundaries so that turbulent and sky warps
//can be done reasonably.
-static void Mod_Q1BSP_GenerateWarpMesh(msurface_t *surf)
+static void Mod_Q1BSP_GenerateWarpMesh(msurface_t *surface)
{
int i, j;
surfvertex_t *v;
subdivpolytriangles = 0;
subdivpolyverts = 0;
- SubdividePolygon(surf->mesh.num_vertices, surf->mesh.data_vertex3f);
+ SubdividePolygon(surface->mesh.num_vertices, surface->mesh.data_vertex3f);
if (subdivpolytriangles < 1)
Host_Error("Mod_Q1BSP_GenerateWarpMesh: no triangles?\n");
- surf->mesh = mesh = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t) + subdivpolytriangles * sizeof(int[3]) + subdivpolyverts * sizeof(surfvertex_t));
+ surface->mesh = mesh = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t) + subdivpolytriangles * sizeof(int[3]) + subdivpolyverts * sizeof(surfvertex_t));
mesh->num_vertices = subdivpolyverts;
mesh->num_triangles = subdivpolytriangles;
mesh->vertex = (surfvertex_t *)(mesh + 1);
for (i = 0, v = mesh->vertex;i < subdivpolyverts;i++, v++)
{
VectorCopy(subdivpolyvert[i], v->v);
- v->st[0] = DotProduct(v->v, surf->texinfo->vecs[0]);
- v->st[1] = DotProduct(v->v, surf->texinfo->vecs[1]);
+ v->st[0] = DotProduct(v->v, surface->texinfo->vecs[0]);
+ v->st[1] = DotProduct(v->v, surface->texinfo->vecs[1]);
}
}
#endif
static void Mod_Q1BSP_LoadFaces(lump_t *l)
{
dface_t *in;
- msurface_t *surf;
- int i, j, count, surfnum, planenum, smax, tmax, ssize, tsize, firstedge, numedges, totalverts, totaltris;
+ msurface_t *surface;
+ int i, j, count, surfacenum, planenum, smax, tmax, ssize, tsize, firstedge, numedges, totalverts, totaltris;
float texmins[2], texmaxs[2], val;
in = (void *)(mod_base + l->fileofs);
totalverts = 0;
totaltris = 0;
- for (surfnum = 0, in = (void *)(mod_base + l->fileofs);surfnum < count;surfnum++, in++)
+ for (surfacenum = 0, in = (void *)(mod_base + l->fileofs);surfacenum < count;surfacenum++, in++)
{
numedges = LittleShort(in->numedges);
totalverts += numedges;
totalverts = 0;
totaltris = 0;
- for (surfnum = 0, in = (void *)(mod_base + l->fileofs), surf = loadmodel->brushq1.surfaces;surfnum < count;surfnum++, in++, surf++)
+ for (surfacenum = 0, in = (void *)(mod_base + l->fileofs), surface = loadmodel->brushq1.surfaces;surfacenum < count;surfacenum++, in++, surface++)
{
- surf->number = surfnum;
+ surface->number = surfacenum;
// FIXME: validate edges, texinfo, etc?
firstedge = LittleLong(in->firstedge);
numedges = LittleShort(in->numedges);
i = LittleShort(in->texinfo);
if ((unsigned int) i >= (unsigned int) loadmodel->brushq1.numtexinfo)
Host_Error("Mod_Q1BSP_LoadFaces: invalid texinfo index %i(model has %i texinfos)\n", i, loadmodel->brushq1.numtexinfo);
- surf->texinfo = loadmodel->brushq1.texinfo + i;
- surf->flags = surf->texinfo->texture->flags;
+ surface->texinfo = loadmodel->brushq1.texinfo + i;
+ surface->flags = surface->texinfo->texture->flags;
planenum = LittleShort(in->planenum);
if ((unsigned int) planenum >= (unsigned int) loadmodel->brush.num_planes)
Host_Error("Mod_Q1BSP_LoadFaces: invalid plane index %i (model has %i planes)\n", planenum, loadmodel->brush.num_planes);
if (LittleShort(in->side))
- surf->flags |= SURF_PLANEBACK;
-
- surf->plane = loadmodel->brush.data_planes + planenum;
-
- surf->mesh.num_vertices = numedges;
- surf->mesh.num_triangles = numedges - 2;
- surf->mesh.data_vertex3f = loadmodel->meshlist[0]->data_vertex3f + totalverts * 3;
- surf->mesh.data_texcoordtexture2f = loadmodel->meshlist[0]->data_texcoordtexture2f + totalverts * 2;
- surf->mesh.data_texcoordlightmap2f = loadmodel->meshlist[0]->data_texcoordlightmap2f + totalverts * 2;
- surf->mesh.data_texcoorddetail2f = loadmodel->meshlist[0]->data_texcoorddetail2f + totalverts * 2;
- surf->mesh.data_svector3f = loadmodel->meshlist[0]->data_svector3f + totalverts * 3;
- surf->mesh.data_tvector3f = loadmodel->meshlist[0]->data_tvector3f + totalverts * 3;
- surf->mesh.data_normal3f = loadmodel->meshlist[0]->data_normal3f + totalverts * 3;
- surf->mesh.data_lightmapoffsets = loadmodel->meshlist[0]->data_lightmapoffsets + totalverts;
- surf->mesh.data_element3i = loadmodel->meshlist[0]->data_element3i + totaltris * 3;
- surf->mesh.data_neighbor3i = loadmodel->meshlist[0]->data_neighbor3i + totaltris * 3;
+ surface->flags |= SURF_PLANEBACK;
+
+ surface->plane = loadmodel->brush.data_planes + planenum;
+
+ surface->mesh.num_vertices = numedges;
+ surface->mesh.num_triangles = numedges - 2;
+ surface->mesh.data_vertex3f = loadmodel->meshlist[0]->data_vertex3f + totalverts * 3;
+ surface->mesh.data_texcoordtexture2f = loadmodel->meshlist[0]->data_texcoordtexture2f + totalverts * 2;
+ surface->mesh.data_texcoordlightmap2f = loadmodel->meshlist[0]->data_texcoordlightmap2f + totalverts * 2;
+ surface->mesh.data_texcoorddetail2f = loadmodel->meshlist[0]->data_texcoorddetail2f + totalverts * 2;
+ surface->mesh.data_svector3f = loadmodel->meshlist[0]->data_svector3f + totalverts * 3;
+ surface->mesh.data_tvector3f = loadmodel->meshlist[0]->data_tvector3f + totalverts * 3;
+ surface->mesh.data_normal3f = loadmodel->meshlist[0]->data_normal3f + totalverts * 3;
+ surface->mesh.data_lightmapoffsets = loadmodel->meshlist[0]->data_lightmapoffsets + totalverts;
+ surface->mesh.data_element3i = loadmodel->meshlist[0]->data_element3i + totaltris * 3;
+ surface->mesh.data_neighbor3i = loadmodel->meshlist[0]->data_neighbor3i + totaltris * 3;
totalverts += numedges;
totaltris += numedges - 2;
// convert edges back to a normal polygon
- for (i = 0;i < surf->mesh.num_vertices;i++)
+ for (i = 0;i < surface->mesh.num_vertices;i++)
{
int lindex = loadmodel->brushq1.surfedges[firstedge + i];
float s, t;
if (lindex > 0)
- VectorCopy(loadmodel->brushq1.vertexes[loadmodel->brushq1.edges[lindex].v[0]].position, surf->mesh.data_vertex3f + i * 3);
+ VectorCopy(loadmodel->brushq1.vertexes[loadmodel->brushq1.edges[lindex].v[0]].position, surface->mesh.data_vertex3f + i * 3);
else
- VectorCopy(loadmodel->brushq1.vertexes[loadmodel->brushq1.edges[-lindex].v[1]].position, surf->mesh.data_vertex3f + i * 3);
- s = DotProduct((surf->mesh.data_vertex3f + i * 3), surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3];
- t = DotProduct((surf->mesh.data_vertex3f + i * 3), surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3];
- surf->mesh.data_texcoordtexture2f[i * 2 + 0] = s / surf->texinfo->texture->width;
- surf->mesh.data_texcoordtexture2f[i * 2 + 1] = t / surf->texinfo->texture->height;
- surf->mesh.data_texcoorddetail2f[i * 2 + 0] = s * (1.0f / 16.0f);
- surf->mesh.data_texcoorddetail2f[i * 2 + 1] = t * (1.0f / 16.0f);
- surf->mesh.data_texcoordlightmap2f[i * 2 + 0] = 0;
- surf->mesh.data_texcoordlightmap2f[i * 2 + 1] = 0;
- surf->mesh.data_lightmapoffsets[i] = 0;
+ VectorCopy(loadmodel->brushq1.vertexes[loadmodel->brushq1.edges[-lindex].v[1]].position, surface->mesh.data_vertex3f + i * 3);
+ s = DotProduct((surface->mesh.data_vertex3f + i * 3), surface->texinfo->vecs[0]) + surface->texinfo->vecs[0][3];
+ t = DotProduct((surface->mesh.data_vertex3f + i * 3), surface->texinfo->vecs[1]) + surface->texinfo->vecs[1][3];
+ surface->mesh.data_texcoordtexture2f[i * 2 + 0] = s / surface->texinfo->texture->width;
+ surface->mesh.data_texcoordtexture2f[i * 2 + 1] = t / surface->texinfo->texture->height;
+ surface->mesh.data_texcoorddetail2f[i * 2 + 0] = s * (1.0f / 16.0f);
+ surface->mesh.data_texcoorddetail2f[i * 2 + 1] = t * (1.0f / 16.0f);
+ surface->mesh.data_texcoordlightmap2f[i * 2 + 0] = 0;
+ surface->mesh.data_texcoordlightmap2f[i * 2 + 1] = 0;
+ surface->mesh.data_lightmapoffsets[i] = 0;
}
- for (i = 0;i < surf->mesh.num_triangles;i++)
+ for (i = 0;i < surface->mesh.num_triangles;i++)
{
- surf->mesh.data_element3i[i * 3 + 0] = 0;
- surf->mesh.data_element3i[i * 3 + 1] = i + 1;
- surf->mesh.data_element3i[i * 3 + 2] = i + 2;
+ surface->mesh.data_element3i[i * 3 + 0] = 0;
+ surface->mesh.data_element3i[i * 3 + 1] = i + 1;
+ surface->mesh.data_element3i[i * 3 + 2] = i + 2;
}
// compile additional data about the surface geometry
- Mod_BuildTriangleNeighbors(surf->mesh.data_neighbor3i, surf->mesh.data_element3i, surf->mesh.num_triangles);
- Mod_BuildTextureVectorsAndNormals(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_vertex3f, surf->mesh.data_texcoordtexture2f, surf->mesh.data_element3i, surf->mesh.data_svector3f, surf->mesh.data_tvector3f, surf->mesh.data_normal3f);
- BoxFromPoints(surf->mins, surf->maxs, surf->mesh.num_vertices, surf->mesh.data_vertex3f);
+ Mod_BuildTriangleNeighbors(surface->mesh.data_neighbor3i, surface->mesh.data_element3i, surface->mesh.num_triangles);
+ Mod_BuildTextureVectorsAndNormals(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_vertex3f, surface->mesh.data_texcoordtexture2f, surface->mesh.data_element3i, surface->mesh.data_svector3f, surface->mesh.data_tvector3f, surface->mesh.data_normal3f);
+ BoxFromPoints(surface->mins, surface->maxs, surface->mesh.num_vertices, surface->mesh.data_vertex3f);
// generate surface extents information
- texmins[0] = texmaxs[0] = DotProduct(surf->mesh.data_vertex3f, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3];
- texmins[1] = texmaxs[1] = DotProduct(surf->mesh.data_vertex3f, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3];
- for (i = 1;i < surf->mesh.num_vertices;i++)
+ texmins[0] = texmaxs[0] = DotProduct(surface->mesh.data_vertex3f, surface->texinfo->vecs[0]) + surface->texinfo->vecs[0][3];
+ texmins[1] = texmaxs[1] = DotProduct(surface->mesh.data_vertex3f, surface->texinfo->vecs[1]) + surface->texinfo->vecs[1][3];
+ for (i = 1;i < surface->mesh.num_vertices;i++)
{
for (j = 0;j < 2;j++)
{
- val = DotProduct(surf->mesh.data_vertex3f + i * 3, surf->texinfo->vecs[j]) + surf->texinfo->vecs[j][3];
+ val = DotProduct(surface->mesh.data_vertex3f + i * 3, surface->texinfo->vecs[j]) + surface->texinfo->vecs[j][3];
texmins[j] = min(texmins[j], val);
texmaxs[j] = max(texmaxs[j], val);
}
}
for (i = 0;i < 2;i++)
{
- surf->texturemins[i] = (int) floor(texmins[i] / 16.0) * 16;
- surf->extents[i] = (int) ceil(texmaxs[i] / 16.0) * 16 - surf->texturemins[i];
+ surface->texturemins[i] = (int) floor(texmins[i] / 16.0) * 16;
+ surface->extents[i] = (int) ceil(texmaxs[i] / 16.0) * 16 - surface->texturemins[i];
}
- smax = surf->extents[0] >> 4;
- tmax = surf->extents[1] >> 4;
- ssize = (surf->extents[0] >> 4) + 1;
- tsize = (surf->extents[1] >> 4) + 1;
+ smax = surface->extents[0] >> 4;
+ tmax = surface->extents[1] >> 4;
+ ssize = (surface->extents[0] >> 4) + 1;
+ tsize = (surface->extents[1] >> 4) + 1;
// lighting info
for (i = 0;i < MAXLIGHTMAPS;i++)
- surf->styles[i] = in->styles[i];
+ surface->styles[i] = in->styles[i];
// force lightmap upload on first time seeing the surface
- surf->cached_dlight = true;
- surf->lightmaptexturestride = 0;
- surf->lightmaptexture = NULL;
+ surface->cached_dlight = true;
+ surface->lightmaptexturestride = 0;
+ surface->lightmaptexture = NULL;
i = LittleLong(in->lightofs);
if (i == -1)
- surf->samples = NULL;
+ surface->samples = NULL;
else if (loadmodel->brush.ishlbsp) // LordHavoc: HalfLife map (bsp version 30)
- surf->samples = loadmodel->brushq1.lightdata + i;
+ surface->samples = loadmodel->brushq1.lightdata + i;
else // LordHavoc: white lighting (bsp version 29)
- surf->samples = loadmodel->brushq1.lightdata + (i * 3);
+ surface->samples = loadmodel->brushq1.lightdata + (i * 3);
- if (surf->texinfo->texture->flags & SURF_LIGHTMAP)
+ if (surface->texinfo->texture->flags & SURF_LIGHTMAP)
{
if (ssize > 256 || tsize > 256)
Host_Error("Bad surface extents");
// stainmap for permanent marks on walls
- surf->stainsamples = Mem_Alloc(loadmodel->mempool, ssize * tsize * 3);
+ surface->stainsamples = Mem_Alloc(loadmodel->mempool, ssize * tsize * 3);
// clear to white
- memset(surf->stainsamples, 255, ssize * tsize * 3);
+ memset(surface->stainsamples, 255, ssize * tsize * 3);
}
- if (surf->texinfo->texture->flags & SURF_LIGHTMAP)
+ if (surface->texinfo->texture->flags & SURF_LIGHTMAP)
{
int i, iu, iv;
float u, v, ubase, vbase, uscale, vscale;
if (r_miplightmaps.integer)
{
- surf->lightmaptexturestride = ssize;
- surf->lightmaptexture = R_LoadTexture2D(loadmodel->texturepool, NULL, surf->lightmaptexturestride, tsize, NULL, loadmodel->brushq1.lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, TEXF_MIPMAP | TEXF_FORCELINEAR | TEXF_PRECACHE, NULL);
+ surface->lightmaptexturestride = ssize;
+ surface->lightmaptexture = R_LoadTexture2D(loadmodel->texturepool, NULL, surface->lightmaptexturestride, tsize, NULL, loadmodel->brushq1.lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, TEXF_MIPMAP | TEXF_FORCELINEAR | TEXF_PRECACHE, NULL);
}
else
{
- surf->lightmaptexturestride = R_CompatibleFragmentWidth(ssize, loadmodel->brushq1.lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, 0);
- surf->lightmaptexture = R_LoadTexture2D(loadmodel->texturepool, NULL, surf->lightmaptexturestride, tsize, NULL, loadmodel->brushq1.lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, TEXF_FRAGMENT | TEXF_FORCELINEAR | TEXF_PRECACHE, NULL);
+ surface->lightmaptexturestride = R_CompatibleFragmentWidth(ssize, loadmodel->brushq1.lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, 0);
+ surface->lightmaptexture = R_LoadTexture2D(loadmodel->texturepool, NULL, surface->lightmaptexturestride, tsize, NULL, loadmodel->brushq1.lightmaprgba ? TEXTYPE_RGBA : TEXTYPE_RGB, TEXF_FRAGMENT | TEXF_FORCELINEAR | TEXF_PRECACHE, NULL);
}
- R_FragmentLocation(surf->lightmaptexture, NULL, NULL, &ubase, &vbase, &uscale, &vscale);
+ R_FragmentLocation(surface->lightmaptexture, NULL, NULL, &ubase, &vbase, &uscale, &vscale);
uscale = (uscale - ubase) / ssize;
vscale = (vscale - vbase) / tsize;
- for (i = 0;i < surf->mesh.num_vertices;i++)
+ for (i = 0;i < surface->mesh.num_vertices;i++)
{
- u = ((DotProduct((surf->mesh.data_vertex3f + i * 3), surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3]) + 8 - surf->texturemins[0]) * (1.0 / 16.0);
- v = ((DotProduct((surf->mesh.data_vertex3f + i * 3), surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3]) + 8 - surf->texturemins[1]) * (1.0 / 16.0);
- surf->mesh.data_texcoordlightmap2f[i * 2 + 0] = u * uscale + ubase;
- surf->mesh.data_texcoordlightmap2f[i * 2 + 1] = v * vscale + vbase;
+ u = ((DotProduct((surface->mesh.data_vertex3f + i * 3), surface->texinfo->vecs[0]) + surface->texinfo->vecs[0][3]) + 8 - surface->texturemins[0]) * (1.0 / 16.0);
+ v = ((DotProduct((surface->mesh.data_vertex3f + i * 3), surface->texinfo->vecs[1]) + surface->texinfo->vecs[1][3]) + 8 - surface->texturemins[1]) * (1.0 / 16.0);
+ surface->mesh.data_texcoordlightmap2f[i * 2 + 0] = u * uscale + ubase;
+ surface->mesh.data_texcoordlightmap2f[i * 2 + 1] = v * vscale + vbase;
// LordHavoc: calc lightmap data offset for vertex lighting to use
iu = (int) u;
iv = (int) v;
- surf->mesh.data_lightmapoffsets[i] = (bound(0, iv, tmax) * ssize + bound(0, iu, smax)) * 3;
+ surface->mesh.data_lightmapoffsets[i] = (bound(0, iv, tmax) * ssize + bound(0, iu, smax)) * 3;
}
}
}
out->contents = LittleLong(in->contents);
- out->firstleafface = loadmodel->brush.data_leaffaces + LittleShort(in->firstmarksurface);
- out->numleaffaces = LittleShort(in->nummarksurfaces);
- if (out->firstleafface < 0 || LittleShort(in->firstmarksurface) + out->numleaffaces > loadmodel->brush.num_leaffaces)
+ out->firstleafsurface = loadmodel->brush.data_leafsurfaces + LittleShort(in->firstmarksurface);
+ out->numleafsurfaces = LittleShort(in->nummarksurfaces);
+ if (out->firstleafsurface < 0 || LittleShort(in->firstmarksurface) + out->numleafsurfaces > loadmodel->brush.num_leafsurfaces)
{
- Con_Printf("Mod_Q1BSP_LoadLeafs: invalid leafface range %i:%i outside range %i:%i\n", out->firstleafface, out->firstleafface + out->numleaffaces, 0, loadmodel->brush.num_leaffaces);
- out->firstleafface = NULL;
- out->numleaffaces = 0;
+ Con_Printf("Mod_Q1BSP_LoadLeafs: invalid leafsurface range %i:%i outside range %i:%i\n", out->firstleafsurface, out->firstleafsurface + out->numleafsurfaces, 0, loadmodel->brush.num_leafsurfaces);
+ out->firstleafsurface = NULL;
+ out->numleafsurfaces = 0;
}
out->clusterindex = i - 1;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Host_Error("Mod_Q1BSP_LoadLeaffaces: funny lump size in %s",loadmodel->name);
- loadmodel->brush.num_leaffaces = l->filelen / sizeof(*in);
- loadmodel->brush.data_leaffaces = Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_leaffaces * sizeof(int));
+ loadmodel->brush.num_leafsurfaces = l->filelen / sizeof(*in);
+ loadmodel->brush.data_leafsurfaces = Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_leafsurfaces * sizeof(int));
- for (i = 0;i < loadmodel->brush.num_leaffaces;i++)
+ for (i = 0;i < loadmodel->brush.num_leafsurfaces;i++)
{
j = (unsigned) LittleShort(in[i]);
if (j >= loadmodel->brushq1.numsurfaces)
Host_Error("Mod_Q1BSP_LoadLeaffaces: bad surface number");
- loadmodel->brush.data_leaffaces[i] = j;
+ loadmodel->brush.data_leafsurfaces[i] = j;
}
}
static void Mod_Q1BSP_BuildLightmapUpdateChains(mempool_t *mempool, model_t *model)
{
int i, j, stylecounts[256], totalcount, remapstyles[256];
- msurface_t *surf;
+ msurface_t *surface;
memset(stylecounts, 0, sizeof(stylecounts));
for (i = 0;i < model->nummodelsurfaces;i++)
{
- surf = model->brushq1.surfaces + model->firstmodelsurface + i;
+ surface = model->brushq1.surfaces + model->firstmodelsurface + i;
for (j = 0;j < MAXLIGHTMAPS;j++)
- stylecounts[surf->styles[j]]++;
+ stylecounts[surface->styles[j]]++;
}
totalcount = 0;
model->brushq1.light_styles = 0;
}
for (i = 0;i < model->nummodelsurfaces;i++)
{
- surf = model->brushq1.surfaces + model->firstmodelsurface + i;
+ surface = model->brushq1.surfaces + model->firstmodelsurface + i;
for (j = 0;j < MAXLIGHTMAPS;j++)
- if (surf->styles[j] != 255)
- *model->brushq1.light_styleupdatechains[remapstyles[surf->styles[j]]]++ = surf;
+ if (surface->styles[j] != 255)
+ *model->brushq1.light_styleupdatechains[remapstyles[surface->styles[j]]]++ = surface;
}
j = 0;
for (i = 0;i < model->brushq1.light_styles;i++)
leaf = (mleaf_t *)node;
if ((pvs == NULL || CHECKPVSBIT(pvs, leaf->clusterindex)))
{
- int leaffacenum;
- msurface_t *surf;
+ int leafsurfacenum;
+ msurface_t *surface;
if (maxleafs && *numleafs < maxleafs)
leaflist[(*numleafs)++] = leaf;
if (maxsurfaces)
{
- for (leaffacenum = 0;leaffacenum < leaf->numleaffaces;leaffacenum++)
+ for (leafsurfacenum = 0;leafsurfacenum < leaf->numleafsurfaces;leafsurfacenum++)
{
- surf = model->brushq1.surfaces + leaf->firstleafface[leaffacenum];
- if (surf->shadowmark != shadowmarkcount)
+ surface = model->brushq1.surfaces + leaf->firstleafsurface[leafsurfacenum];
+ if (surface->shadowmark != shadowmarkcount)
{
- surf->shadowmark = shadowmarkcount;
- if (BoxesOverlap(mins, maxs, surf->mins, surf->maxs) && ((surf->flags & SURF_PLANEBACK) ? PlaneDiff(point, surf->plane) < 0 : PlaneDiff(point, surf->plane) > 0) && *numsurfaces < maxsurfaces)
- surfacelist[(*numsurfaces)++] = surf;
+ surface->shadowmark = shadowmarkcount;
+ if (BoxesOverlap(mins, maxs, surface->mins, surface->maxs) && ((surface->flags & SURF_PLANEBACK) ? PlaneDiff(point, surface->plane) < 0 : PlaneDiff(point, surface->plane) > 0) && *numsurfaces < maxsurfaces)
+ surfacelist[(*numsurfaces)++] = surface;
}
}
}
dmodel_t *bm;
mempool_t *mainmempool;
float dist, modelyawradius, modelradius, *vec;
- msurface_t *surf;
+ msurface_t *surface;
int numshadowmeshtriangles;
mod->type = mod_brushq1;
// make a single combined shadow mesh to allow optimized shadow volume creation
numshadowmeshtriangles = 0;
- for (j = 0, surf = loadmodel->brushq1.surfaces;j < loadmodel->brushq1.numsurfaces;j++, surf++)
+ for (j = 0, surface = loadmodel->brushq1.surfaces;j < loadmodel->brushq1.numsurfaces;j++, surface++)
{
- surf->num_firstshadowmeshtriangle = numshadowmeshtriangles;
- numshadowmeshtriangles += surf->mesh.num_triangles;
+ surface->num_firstshadowmeshtriangle = numshadowmeshtriangles;
+ numshadowmeshtriangles += surface->mesh.num_triangles;
}
loadmodel->brush.shadowmesh = Mod_ShadowMesh_Begin(loadmodel->mempool, numshadowmeshtriangles * 3, numshadowmeshtriangles, NULL, NULL, NULL, false, false, true);
- for (j = 0, surf = loadmodel->brushq1.surfaces;j < loadmodel->brushq1.numsurfaces;j++, surf++)
- Mod_ShadowMesh_AddMesh(loadmodel->mempool, loadmodel->brush.shadowmesh, NULL, NULL, NULL, surf->mesh.data_vertex3f, NULL, NULL, NULL, NULL, surf->mesh.num_triangles, surf->mesh.data_element3i);
+ for (j = 0, surface = loadmodel->brushq1.surfaces;j < loadmodel->brushq1.numsurfaces;j++, surface++)
+ Mod_ShadowMesh_AddMesh(loadmodel->mempool, loadmodel->brush.shadowmesh, NULL, NULL, NULL, surface->mesh.data_vertex3f, NULL, NULL, NULL, NULL, surface->mesh.num_triangles, surface->mesh.data_element3i);
loadmodel->brush.shadowmesh = Mod_ShadowMesh_Finish(loadmodel->mempool, loadmodel->brush.shadowmesh, false, true);
Mod_BuildTriangleNeighbors(loadmodel->brush.shadowmesh->neighbor3i, loadmodel->brush.shadowmesh->element3i, loadmodel->brush.shadowmesh->numtriangles);
mod->normalmaxs[0] = mod->normalmaxs[1] = mod->normalmaxs[2] = -1000000000.0f;
modelyawradius = 0;
modelradius = 0;
- for (j = 0, surf = &mod->brushq1.surfaces[mod->firstmodelsurface];j < mod->nummodelsurfaces;j++, surf++)
+ for (j = 0, surface = &mod->brushq1.surfaces[mod->firstmodelsurface];j < mod->nummodelsurfaces;j++, surface++)
{
// we only need to have a drawsky function if it is used(usually only on world model)
- if (surf->texinfo->texture->flags & SURF_DRAWSKY)
+ if (surface->texinfo->texture->flags & SURF_DRAWSKY)
mod->DrawSky = R_Q1BSP_DrawSky;
// LordHavoc: submodels always clip, even if water
if (mod->brush.numsubmodels - 1)
- surf->flags |= SURF_SOLIDCLIP;
+ surface->flags |= SURF_SOLIDCLIP;
// calculate bounding shapes
- for (k = 0, vec = surf->mesh.data_vertex3f;k < surf->mesh.num_vertices;k++, vec += 3)
+ for (k = 0, vec = surface->mesh.data_vertex3f;k < surface->mesh.num_vertices;k++, vec += 3)
{
if (mod->normalmins[0] > vec[0]) mod->normalmins[0] = vec[0];
if (mod->normalmins[1] > vec[1]) mod->normalmins[1] = vec[1];
c = LittleLong(in->numfaces);
if (n < 0 || n + c > loadmodel->brushq3.num_faces)
Host_Error("Mod_Q3BSP_LoadModels: invalid face range %i : %i (%i faces)\n", n, n + c, loadmodel->brushq3.num_faces);
- out->firstface = loadmodel->brushq3.data_faces + n;
- out->numfaces = c;
+ out->firstsurface = loadmodel->brushq3.data_faces + n;
+ out->numsurfaces = c;
n = LittleLong(in->firstbrush);
c = LittleLong(in->numbrushes);
if (n < 0 || n + c > loadmodel->brushq3.num_brushes)
count = l->filelen / sizeof(*in);
out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
- loadmodel->brush.data_leaffaces = out;
- loadmodel->brush.num_leaffaces = count;
+ loadmodel->brush.data_leafsurfaces = out;
+ loadmodel->brush.num_leafsurfaces = count;
for (i = 0;i < count;i++, in++, out++)
{
}
n = LittleLong(in->firstleafface);
c = LittleLong(in->numleaffaces);
- if (n < 0 || n + c > loadmodel->brush.num_leaffaces)
- Host_Error("Mod_Q3BSP_LoadLeafs: invalid leafface range %i : %i (%i leaffaces)\n", n, n + c, loadmodel->brush.num_leaffaces);
- out->firstleafface = loadmodel->brush.data_leaffaces + n;
- out->numleaffaces = c;
+ if (n < 0 || n + c > loadmodel->brush.num_leafsurfaces)
+ Host_Error("Mod_Q3BSP_LoadLeafs: invalid leafsurface range %i : %i (%i leafsurfaces)\n", n, n + c, loadmodel->brush.num_leafsurfaces);
+ out->firstleafsurface = loadmodel->brush.data_leafsurfaces + n;
+ out->numleafsurfaces = c;
n = LittleLong(in->firstleafbrush);
c = LittleLong(in->numleafbrushes);
if (n < 0 || n + c > loadmodel->brush.num_leafbrushes)
int i, startside, endside;
float dist1, dist2, midfrac, mid[3], nodesegmentmins[3], nodesegmentmaxs[3];
mleaf_t *leaf;
- q3msurface_t *face;
+ q3msurface_t *surface;
colbrushf_t *brush;
if (startfrac > trace->realfraction)
return;
if (mod_q3bsp_curves_collisions.integer && !VectorCompare(start, end))
{
// line trace the curves
- for (i = 0;i < leaf->numleaffaces;i++)
+ for (i = 0;i < leaf->numleafsurfaces;i++)
{
- face = model->brushq3.data_faces + leaf->firstleafface[i];
- if (face->mesh.num_collisiontriangles && face->collisionmarkframe != markframe && BoxesOverlap(nodesegmentmins, nodesegmentmaxs, face->mins, face->maxs))
+ surface = model->brushq3.data_faces + leaf->firstleafsurface[i];
+ if (surface->mesh.num_collisiontriangles && surface->collisionmarkframe != markframe && BoxesOverlap(nodesegmentmins, nodesegmentmaxs, surface->mins, surface->maxs))
{
- face->collisionmarkframe = markframe;
- Collision_TraceLineTriangleMeshFloat(trace, linestart, lineend, face->mesh.num_collisiontriangles, face->mesh.data_collisionelement3i, face->mesh.data_collisionvertex3f, face->texture->supercontents, segmentmins, segmentmaxs);
+ surface->collisionmarkframe = markframe;
+ Collision_TraceLineTriangleMeshFloat(trace, linestart, lineend, surface->mesh.num_collisiontriangles, surface->mesh.data_collisionelement3i, surface->mesh.data_collisionvertex3f, surface->texture->supercontents, segmentmins, segmentmaxs);
if (startfrac > trace->realfraction)
return;
}
float nodesegmentmins[3], nodesegmentmaxs[3];
mleaf_t *leaf;
colbrushf_t *brush;
- q3msurface_t *face;
+ q3msurface_t *surface;
/*
// find which nodes the line is in and recurse for them
while (node->plane)
}
if (mod_q3bsp_curves_collisions.integer)
{
- for (i = 0;i < leaf->numleaffaces;i++)
+ for (i = 0;i < leaf->numleafsurfaces;i++)
{
- face = model->brushq3.data_faces + leaf->firstleafface[i];
- if (face->mesh.num_collisiontriangles && face->collisionmarkframe != markframe && BoxesOverlap(nodesegmentmins, nodesegmentmaxs, face->mins, face->maxs))
+ surface = model->brushq3.data_faces + leaf->firstleafsurface[i];
+ if (surface->mesh.num_collisiontriangles && surface->collisionmarkframe != markframe && BoxesOverlap(nodesegmentmins, nodesegmentmaxs, surface->mins, surface->maxs))
{
- face->collisionmarkframe = markframe;
- Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, face->mesh.num_collisiontriangles, face->mesh.data_collisionelement3i, face->mesh.data_collisionvertex3f, face->texture->supercontents, segmentmins, segmentmaxs);
+ surface->collisionmarkframe = markframe;
+ Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, surface->mesh.num_collisiontriangles, surface->mesh.data_collisionelement3i, surface->mesh.data_collisionvertex3f, surface->texture->supercontents, segmentmins, segmentmaxs);
}
}
}
colbrushf_t *thisbrush_start, *thisbrush_end;
matrix4x4_t startmatrix, endmatrix;
static int markframe = 0;
- q3msurface_t *face;
+ q3msurface_t *surface;
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
trace->realfraction = 1;
Collision_TraceLineBrushFloat(trace, boxstartmins, boxendmins, model->brushq3.data_models[model->brush.submodel].firstbrush[i].colbrushf, model->brushq3.data_models[model->brush.submodel].firstbrush[i].colbrushf);
if (mod_q3bsp_curves_collisions.integer)
{
- for (i = 0;i < model->brushq3.data_models[model->brush.submodel].numfaces;i++)
+ for (i = 0;i < model->brushq3.data_models[model->brush.submodel].numsurfaces;i++)
{
- face = model->brushq3.data_models[model->brush.submodel].firstface + i;
- if (face->mesh.num_collisiontriangles)
- Collision_TraceLineTriangleMeshFloat(trace, boxstartmins, boxendmins, face->mesh.num_collisiontriangles, face->mesh.data_collisionelement3i, face->mesh.data_collisionvertex3f, face->texture->supercontents, segmentmins, segmentmaxs);
+ surface = model->brushq3.data_models[model->brush.submodel].firstsurface + i;
+ if (surface->mesh.num_collisiontriangles)
+ Collision_TraceLineTriangleMeshFloat(trace, boxstartmins, boxendmins, surface->mesh.num_collisiontriangles, surface->mesh.data_collisionelement3i, surface->mesh.data_collisionvertex3f, surface->texture->supercontents, segmentmins, segmentmaxs);
}
}
}
Collision_TraceBrushBrushFloat(trace, thisbrush_start, thisbrush_end, model->brushq3.data_models[model->brush.submodel].firstbrush[i].colbrushf, model->brushq3.data_models[model->brush.submodel].firstbrush[i].colbrushf);
if (mod_q3bsp_curves_collisions.integer)
{
- for (i = 0;i < model->brushq3.data_models[model->brush.submodel].numfaces;i++)
+ for (i = 0;i < model->brushq3.data_models[model->brush.submodel].numsurfaces;i++)
{
- face = model->brushq3.data_models[model->brush.submodel].firstface + i;
- if (face->mesh.num_collisiontriangles)
- Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, face->mesh.num_collisiontriangles, face->mesh.data_collisionelement3i, face->mesh.data_collisionvertex3f, face->texture->supercontents, segmentmins, segmentmaxs);
+ surface = model->brushq3.data_models[model->brush.submodel].firstsurface + i;
+ if (surface->mesh.num_collisiontriangles)
+ Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, surface->mesh.num_collisiontriangles, surface->mesh.data_collisionelement3i, surface->mesh.data_collisionvertex3f, surface->texture->supercontents, segmentmins, segmentmaxs);
}
}
}
int i, j, numshadowmeshtriangles;
q3dheader_t *header;
float corner[3], yawradius, modelradius;
- q3msurface_t *face;
+ q3msurface_t *surface;
mod->type = mod_brushq3;
mod->numframes = 2; // although alternate textures are not supported it is annoying to complain about no such frame 1
// make a single combined shadow mesh to allow optimized shadow volume creation
numshadowmeshtriangles = 0;
- for (j = 0, face = loadmodel->brushq3.data_faces;j < loadmodel->brushq3.num_faces;j++, face++)
+ for (j = 0, surface = loadmodel->brushq3.data_faces;j < loadmodel->brushq3.num_faces;j++, surface++)
{
- face->num_firstshadowmeshtriangle = numshadowmeshtriangles;
- numshadowmeshtriangles += face->mesh.num_triangles;
+ surface->num_firstshadowmeshtriangle = numshadowmeshtriangles;
+ numshadowmeshtriangles += surface->mesh.num_triangles;
}
loadmodel->brush.shadowmesh = Mod_ShadowMesh_Begin(loadmodel->mempool, numshadowmeshtriangles * 3, numshadowmeshtriangles, NULL, NULL, NULL, false, false, true);
- for (j = 0, face = loadmodel->brushq3.data_faces;j < loadmodel->brushq3.num_faces;j++, face++)
- Mod_ShadowMesh_AddMesh(loadmodel->mempool, loadmodel->brush.shadowmesh, NULL, NULL, NULL, face->mesh.data_vertex3f, NULL, NULL, NULL, NULL, face->mesh.num_triangles, face->mesh.data_element3i);
+ for (j = 0, surface = loadmodel->brushq3.data_faces;j < loadmodel->brushq3.num_faces;j++, surface++)
+ Mod_ShadowMesh_AddMesh(loadmodel->mempool, loadmodel->brush.shadowmesh, NULL, NULL, NULL, surface->mesh.data_vertex3f, NULL, NULL, NULL, NULL, surface->mesh.num_triangles, surface->mesh.data_element3i);
loadmodel->brush.shadowmesh = Mod_ShadowMesh_Finish(loadmodel->mempool, loadmodel->brush.shadowmesh, false, true);
Mod_BuildTriangleNeighbors(loadmodel->brush.shadowmesh->neighbor3i, loadmodel->brush.shadowmesh->element3i, loadmodel->brush.shadowmesh->numtriangles);
mod->brush.submodel = i;
// make the model surface list (used by shadowing/lighting)
- mod->nummodelsurfaces = mod->brushq3.data_models[i].numfaces;
+ mod->nummodelsurfaces = mod->brushq3.data_models[i].numsurfaces;
mod->surfacelist = Mem_Alloc(loadmodel->mempool, mod->nummodelsurfaces * sizeof(*mod->surfacelist));
for (j = 0;j < mod->nummodelsurfaces;j++)
- mod->surfacelist[j] = (mod->brushq3.data_models[i].firstface - mod->brushq3.data_faces) + j;
+ mod->surfacelist[j] = (mod->brushq3.data_models[i].firstsurface - mod->brushq3.data_faces) + j;
VectorCopy(mod->brushq3.data_models[i].mins, mod->normalmins);
VectorCopy(mod->brushq3.data_models[i].maxs, mod->normalmaxs);
mod->radius = modelradius;
mod->radius2 = modelradius * modelradius;
- for (j = 0;j < mod->brushq3.data_models[i].numfaces;j++)
- if (mod->brushq3.data_models[i].firstface[j].texture->surfaceflags & Q3SURFACEFLAG_SKY)
+ for (j = 0;j < mod->brushq3.data_models[i].numsurfaces;j++)
+ if (mod->brushq3.data_models[i].firstsurface[j].texture->surfaceflags & Q3SURFACEFLAG_SKY)
break;
- if (j < mod->brushq3.data_models[i].numfaces)
+ if (j < mod->brushq3.data_models[i].numsurfaces)
mod->DrawSky = R_Q3BSP_DrawSky;
}
}
// common
int clusterindex; // -1 is not in pvs, >= 0 is pvs bit number
int areaindex; // q3bsp
- int numleaffaces;
- int *firstleafface;
+ int numleafsurfaces;
+ int *firstleafsurface;
int numleafbrushes; // q3bsp
int *firstleafbrush; // q3bsp
qbyte ambient_sound_level[NUM_AMBIENTS]; // q1bsp
{
vec3_t mins;
vec3_t maxs;
- int numfaces;
- struct q3msurface_s *firstface;
+ int numsurfaces;
+ struct q3msurface_s *firstsurface;
int numbrushes;
struct q3mbrush_s *firstbrush;
}
static void mod_newmap(void)
{
- msurface_t *surf;
- int i, surfnum, ssize, tsize;
+ msurface_t *surface;
+ int i, surfacenum, ssize, tsize;
if (!cl_stainmaps_clearonload.integer)
return;
- for (i=0; i<MAX_MOD_KNOWN; i++)
+ for (i = 0;i < MAX_MOD_KNOWN;i++)
{
if (mod_known[i].name[0] && mod_known[i].type == mod_brushq1)
{
- for (surfnum=0, surf=mod_known[i].brushq1.surfaces; surfnum<mod_known[i].brushq1.numsurfaces;surfnum++, surf++)
+ for (surfacenum = 0, surface = mod_known[i].brushq1.surfaces;surfacenum < mod_known[i].brushq1.numsurfaces;surfacenum++, surface++)
{
- if (surf->texinfo->texture->flags & SURF_LIGHTMAP)
+ if (surface->texinfo->texture->flags & SURF_LIGHTMAP)
{
- ssize = (surf->extents[0] >> 4) + 1;
- tsize = (surf->extents[1] >> 4) + 1;
+ ssize = (surface->extents[0] >> 4) + 1;
+ tsize = (surface->extents[1] >> 4) + 1;
if (ssize > 256 || tsize > 256)
Host_Error("Bad surface extents");
- if (surf->stainsamples)
- memset(surf->stainsamples, 255, ssize * tsize * 3);
+ if (surface->stainsamples)
+ memset(surface->stainsamples, 255, ssize * tsize * 3);
- surf->cached_dlight = true;
+ surface->cached_dlight = true;
}
}
}
int num_leafbrushes;
int *data_leafbrushes;
- int num_leaffaces;
- int *data_leaffaces;
+ int num_leafsurfaces;
+ int *data_leafsurfaces;
int num_portals;
mportal_t *data_portals;
}
portalrecursioninfo_t;
-void Portal_RecursiveFlow_ExactLeafFaces(portalrecursioninfo_t *info, int *mark, int numleaffaces, int firstclipplane, int numclipplanes)
+void Portal_RecursiveFlow_ExactLeafFaces(portalrecursioninfo_t *info, int *mark, int numleafsurfaces, int firstclipplane, int numclipplanes)
{
int i, j, *elements;
vec3_t trimins, trimaxs;
- msurface_t *surf;
- for (i = 0;i < numleaffaces;i++, mark++)
+ msurface_t *surface;
+ for (i = 0;i < numleafsurfaces;i++, mark++)
{
if (!info->surfacemark[*mark])
{
// FIXME? this assumes q1bsp polygon surfaces
- surf = info->model->brushq1.surfaces + *mark;
- if (surf->mesh.num_vertices)
+ surface = info->model->brushq1.surfaces + *mark;
+ if (surface->mesh.num_vertices)
{
- if (surf->flags & SURF_PLANEBACK)
+ if (surface->flags & SURF_PLANEBACK)
{
- if (DotProduct(info->eye, surf->plane->normal) > surf->plane->dist)
+ if (DotProduct(info->eye, surface->plane->normal) > surface->plane->dist)
continue;
}
else
{
- if (DotProduct(info->eye, surf->plane->normal) < surf->plane->dist)
+ if (DotProduct(info->eye, surface->plane->normal) < surface->plane->dist)
continue;
}
- if (Portal_PortalThroughPortalPlanes(&portalplanes[firstclipplane], numclipplanes, surf->mesh.data_vertex3f, surf->mesh.num_vertices, &portaltemppoints2[0][0], 256) < 3)
+ if (Portal_PortalThroughPortalPlanes(&portalplanes[firstclipplane], numclipplanes, surface->mesh.data_vertex3f, surface->mesh.num_vertices, &portaltemppoints2[0][0], 256) < 3)
continue;
}
else
{
- for (j = 0, elements = surf->mesh.data_element3i;j < surf->mesh.num_triangles;j++, elements += 3)
+ for (j = 0, elements = surface->mesh.data_element3i;j < surface->mesh.num_triangles;j++, elements += 3)
{
- VectorCopy((surf->mesh.data_vertex3f + elements[0] * 3), trianglepoints[0]);
- VectorCopy((surf->mesh.data_vertex3f + elements[1] * 3), trianglepoints[1]);
- VectorCopy((surf->mesh.data_vertex3f + elements[2] * 3), trianglepoints[2]);
+ VectorCopy((surface->mesh.data_vertex3f + elements[0] * 3), trianglepoints[0]);
+ VectorCopy((surface->mesh.data_vertex3f + elements[1] * 3), trianglepoints[1]);
+ VectorCopy((surface->mesh.data_vertex3f + elements[2] * 3), trianglepoints[2]);
if (PointInfrontOfTriangle(info->eye, trianglepoints[0], trianglepoints[1], trianglepoints[2]))
{
trimins[0] = min(trianglepoints[0][0], min(trianglepoints[1][0], trianglepoints[2][0]));
break;
}
}
- if (j == surf->mesh.num_triangles)
+ if (j == surface->mesh.num_triangles)
continue;
}
info->surfacemark[*mark] = true;
info->leafmark[leaf - info->model->brush.data_leafs] = true;
// mark surfaces in leaf that can be seen through portal
- if (leaf->numleaffaces && info->surfacemark)
+ if (leaf->numleafsurfaces && info->surfacemark)
{
if (info->exact)
- Portal_RecursiveFlow_ExactLeafFaces(info, leaf->firstleafface, leaf->numleaffaces, firstclipplane, numclipplanes);
+ Portal_RecursiveFlow_ExactLeafFaces(info, leaf->firstleafsurface, leaf->numleafsurfaces, firstclipplane, numclipplanes);
else
- for (i = 0;i < leaf->numleaffaces;i++)
- info->surfacemark[leaf->firstleafface[i]] = true;
+ for (i = 0;i < leaf->numleafsurfaces;i++)
+ info->surfacemark[leaf->firstleafsurface[i]] = true;
}
// follow portals into other leafs
MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
}
-static void clippointtosurface(msurface_t *surf, vec3_t p, vec3_t out)
+static void clippointtosurface(msurface_t *surface, vec3_t p, vec3_t out)
{
int i, j;
vec3_t v1, clipplanenormal, normal;
vec_t clipplanedist, clipdist;
VectorCopy(p, out);
- if (surf->flags & SURF_PLANEBACK)
- VectorNegate(surf->plane->normal, normal);
+ if (surface->flags & SURF_PLANEBACK)
+ VectorNegate(surface->plane->normal, normal);
else
- VectorCopy(surf->plane->normal, normal);
- for (i = 0, j = surf->mesh.num_vertices - 1;i < surf->mesh.num_vertices;j = i, i++)
+ VectorCopy(surface->plane->normal, normal);
+ for (i = 0, j = surface->mesh.num_vertices - 1;i < surface->mesh.num_vertices;j = i, i++)
{
- VectorSubtract(&surf->mesh.data_vertex3f[j * 3], &surf->mesh.data_vertex3f[i * 3], v1);
+ VectorSubtract(&surface->mesh.data_vertex3f[j * 3], &surface->mesh.data_vertex3f[i * 3], v1);
VectorNormalizeFast(v1);
CrossProduct(v1, normal, clipplanenormal);
- clipplanedist = DotProduct(&surf->mesh.data_vertex3f[i * 3], clipplanenormal);
+ clipplanedist = DotProduct(&surface->mesh.data_vertex3f[i * 3], clipplanenormal);
clipdist = DotProduct(out, clipplanenormal) - clipplanedist;
if (clipdist > 0)
{
}
}
-static msurface_t *getsurface(edict_t *ed, int surfnum)
+static msurface_t *getsurface(edict_t *ed, int surfacenum)
{
int modelindex;
model_t *model;
if (modelindex < 1 || modelindex >= MAX_MODELS)
return NULL;
model = sv.models[modelindex];
- if (surfnum < 0 || surfnum >= model->nummodelsurfaces)
+ if (surfacenum < 0 || surfacenum >= model->nummodelsurfaces)
return NULL;
- return model->brushq1.surfaces + surfnum + model->firstmodelsurface;
+ return model->brushq1.surfaces + surfacenum + model->firstmodelsurface;
}
//PF_getsurfacenumpoints, // #434 float(entity e, float s) getsurfacenumpoints = #434;
void PF_getsurfacenumpoints(void)
{
- msurface_t *surf;
+ msurface_t *surface;
// return 0 if no such surface
- if (!(surf = getsurface(G_EDICT(OFS_PARM0), G_FLOAT(OFS_PARM1))))
+ if (!(surface = getsurface(G_EDICT(OFS_PARM0), G_FLOAT(OFS_PARM1))))
{
G_FLOAT(OFS_RETURN) = 0;
return;
}
- G_FLOAT(OFS_RETURN) = surf->mesh.num_vertices;
+ G_FLOAT(OFS_RETURN) = surface->mesh.num_vertices;
}
//PF_getsurfacepoint, // #435 vector(entity e, float s, float n) getsurfacepoint = #435;
void PF_getsurfacepoint(void)
{
edict_t *ed;
- msurface_t *surf;
+ msurface_t *surface;
int pointnum;
VectorClear(G_VECTOR(OFS_RETURN));
ed = G_EDICT(OFS_PARM0);
if (!ed || ed->e->free)
return;
- if (!(surf = getsurface(ed, G_FLOAT(OFS_PARM1))))
+ if (!(surface = getsurface(ed, G_FLOAT(OFS_PARM1))))
return;
pointnum = G_FLOAT(OFS_PARM2);
- if (pointnum < 0 || pointnum >= surf->mesh.num_vertices)
+ if (pointnum < 0 || pointnum >= surface->mesh.num_vertices)
return;
// FIXME: implement rotation/scaling
- VectorAdd(&surf->mesh.data_vertex3f[pointnum * 3], ed->v->origin, G_VECTOR(OFS_RETURN));
+ VectorAdd(&surface->mesh.data_vertex3f[pointnum * 3], ed->v->origin, G_VECTOR(OFS_RETURN));
}
//PF_getsurfacenormal, // #436 vector(entity e, float s) getsurfacenormal = #436;
void PF_getsurfacenormal(void)
{
- msurface_t *surf;
+ msurface_t *surface;
VectorClear(G_VECTOR(OFS_RETURN));
- if (!(surf = getsurface(G_EDICT(OFS_PARM0), G_FLOAT(OFS_PARM1))))
+ if (!(surface = getsurface(G_EDICT(OFS_PARM0), G_FLOAT(OFS_PARM1))))
return;
// FIXME: implement rotation/scaling
- if (surf->flags & SURF_PLANEBACK)
- VectorNegate(surf->plane->normal, G_VECTOR(OFS_RETURN));
+ if (surface->flags & SURF_PLANEBACK)
+ VectorNegate(surface->plane->normal, G_VECTOR(OFS_RETURN));
else
- VectorCopy(surf->plane->normal, G_VECTOR(OFS_RETURN));
+ VectorCopy(surface->plane->normal, G_VECTOR(OFS_RETURN));
}
//PF_getsurfacetexture, // #437 string(entity e, float s) getsurfacetexture = #437;
void PF_getsurfacetexture(void)
{
- msurface_t *surf;
+ msurface_t *surface;
G_INT(OFS_RETURN) = 0;
- if (!(surf = getsurface(G_EDICT(OFS_PARM0), G_FLOAT(OFS_PARM1))))
+ if (!(surface = getsurface(G_EDICT(OFS_PARM0), G_FLOAT(OFS_PARM1))))
return;
- G_INT(OFS_RETURN) = PR_SetString(surf->texinfo->texture->name);
+ G_INT(OFS_RETURN) = PR_SetString(surface->texinfo->texture->name);
}
//PF_getsurfacenearpoint, // #438 float(entity e, vector p) getsurfacenearpoint = #438;
void PF_getsurfacenearpoint(void)
{
- int surfnum, best, modelindex;
+ int surfacenum, best, modelindex;
vec3_t clipped, p;
vec_t dist, bestdist;
edict_t *ed;
model_t *model;
- msurface_t *surf;
+ msurface_t *surface;
vec_t *point;
G_FLOAT(OFS_RETURN) = -1;
ed = G_EDICT(OFS_PARM0);
VectorSubtract(point, ed->v->origin, p);
best = -1;
bestdist = 1000000000;
- for (surfnum = 0;surfnum < model->nummodelsurfaces;surfnum++)
+ for (surfacenum = 0;surfacenum < model->nummodelsurfaces;surfacenum++)
{
- surf = model->brushq1.surfaces + surfnum + model->firstmodelsurface;
- dist = PlaneDiff(p, surf->plane);
+ surface = model->brushq1.surfaces + surfacenum + model->firstmodelsurface;
+ dist = PlaneDiff(p, surface->plane);
dist = dist * dist;
if (dist < bestdist)
{
- clippointtosurface(surf, p, clipped);
+ clippointtosurface(surface, p, clipped);
VectorSubtract(clipped, p, clipped);
dist += DotProduct(clipped, clipped);
if (dist < bestdist)
{
- best = surfnum;
+ best = surfacenum;
bestdist = dist;
}
}
void PF_getsurfaceclippedpoint(void)
{
edict_t *ed;
- msurface_t *surf;
+ msurface_t *surface;
vec3_t p, out;
VectorClear(G_VECTOR(OFS_RETURN));
ed = G_EDICT(OFS_PARM0);
if (!ed || ed->e->free)
return;
- if (!(surf = getsurface(ed, G_FLOAT(OFS_PARM1))))
+ if (!(surface = getsurface(ed, G_FLOAT(OFS_PARM1))))
return;
// FIXME: implement rotation/scaling
VectorSubtract(G_VECTOR(OFS_PARM2), ed->v->origin, p);
- clippointtosurface(surf, p, out);
+ clippointtosurface(surface, p, out);
// FIXME: implement rotation/scaling
VectorAdd(out, ed->v->origin, G_VECTOR(OFS_RETURN));
}
// check if leaf is visible according to pvs
leaf = (mleaf_t *)node;
i = leaf->clusterindex;
- if (leaf->numleaffaces && (i >= pvsbits || CHECKPVSBIT(pvs, i)))
+ if (leaf->numleafsurfaces && (i >= pvsbits || CHECKPVSBIT(pvs, i)))
{
int d, impacts, impactt;
float sdist, maxdist, dist2, impact[3];
- msurface_t *surf;
+ msurface_t *surface;
// mark the polygons
maxdist = light->rtlight.lightmap_cullradius2;
- for (i = 0;i < leaf->numleaffaces;i++)
+ for (i = 0;i < leaf->numleafsurfaces;i++)
{
- if (ent == r_refdef.worldentity && !r_worldsurfacevisible[leaf->firstleafface[i]])
+ if (ent == r_refdef.worldentity && !r_worldsurfacevisible[leaf->firstleafsurface[i]])
continue;
- surf = ent->model->brushq1.surfaces + leaf->firstleafface[i];
- dist = sdist = PlaneDiff(lightorigin, surf->plane);
- if (surf->flags & SURF_PLANEBACK)
+ surface = ent->model->brushq1.surfaces + leaf->firstleafsurface[i];
+ dist = sdist = PlaneDiff(lightorigin, surface->plane);
+ if (surface->flags & SURF_PLANEBACK)
dist = -dist;
- if (dist < -0.25f && !(surf->flags & SURF_LIGHTBOTHSIDES))
+ if (dist < -0.25f && !(surface->flags & SURF_LIGHTBOTHSIDES))
continue;
dist2 = dist * dist;
continue;
VectorCopy(lightorigin, impact);
- if (surf->plane->type >= 3)
- VectorMA(impact, -sdist, surf->plane->normal, impact);
+ if (surface->plane->type >= 3)
+ VectorMA(impact, -sdist, surface->plane->normal, impact);
else
- impact[surf->plane->type] -= sdist;
+ impact[surface->plane->type] -= sdist;
- impacts = DotProduct (impact, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] - surf->texturemins[0];
+ impacts = DotProduct (impact, surface->texinfo->vecs[0]) + surface->texinfo->vecs[0][3] - surface->texturemins[0];
- d = bound(0, impacts, surf->extents[0] + 16) - impacts;
+ d = bound(0, impacts, surface->extents[0] + 16) - impacts;
dist2 += d * d;
if (dist2 > maxdist)
continue;
- impactt = DotProduct (impact, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] - surf->texturemins[1];
+ impactt = DotProduct (impact, surface->texinfo->vecs[1]) + surface->texinfo->vecs[1][3] - surface->texturemins[1];
- d = bound(0, impactt, surf->extents[1] + 16) - impactt;
+ d = bound(0, impactt, surface->extents[1] + 16) - impactt;
dist2 += d * d;
if (dist2 > maxdist)
continue;
- if (surf->dlightframe != r_framecount) // not dynamic until now
+ if (surface->dlightframe != r_framecount) // not dynamic until now
{
- surf->dlightbits[0] = surf->dlightbits[1] = surf->dlightbits[2] = surf->dlightbits[3] = surf->dlightbits[4] = surf->dlightbits[5] = surf->dlightbits[6] = surf->dlightbits[7] = 0;
- surf->dlightframe = r_framecount;
- surf->cached_dlight = true;
+ surface->dlightbits[0] = surface->dlightbits[1] = surface->dlightbits[2] = surface->dlightbits[3] = surface->dlightbits[4] = surface->dlightbits[5] = surface->dlightbits[6] = surface->dlightbits[7] = 0;
+ surface->dlightframe = r_framecount;
+ surface->cached_dlight = true;
}
- surf->dlightbits[bitindex] |= bit;
+ surface->dlightbits[bitindex] |= bit;
}
}
}