summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSmileTheory <SmileTheory@gmail.com>2013-10-15 01:19:16 -0700
committerTim Angus <tim@ngus.net>2014-06-17 17:43:35 +0100
commitbfd5a88d22160a94dfc0df380e01ed8319283e62 (patch)
treeaff95be51dc52273bf09fb225d007036a10ffb6c
parent9b532f128d0b1481074c1602c00b9f4d850a9b44 (diff)
OpenGL2: Merge bsp surface structs into a single struct, and more cleanup.
-rw-r--r--src/renderergl2/tr_bsp.c447
-rw-r--r--src/renderergl2/tr_curve.c36
-rw-r--r--src/renderergl2/tr_light.c17
-rw-r--r--src/renderergl2/tr_local.h158
-rw-r--r--src/renderergl2/tr_main.c99
-rw-r--r--src/renderergl2/tr_marks.c12
-rw-r--r--src/renderergl2/tr_model.c2
-rw-r--r--src/renderergl2/tr_surface.c10
-rw-r--r--src/renderergl2/tr_world.c44
9 files changed, 218 insertions, 607 deletions
diff --git a/src/renderergl2/tr_bsp.c b/src/renderergl2/tr_bsp.c
index eed6e3ec..5196cbd2 100644
--- a/src/renderergl2/tr_bsp.c
+++ b/src/renderergl2/tr_bsp.c
@@ -653,7 +653,7 @@ ParseFace
*/
static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) {
int i, j;
- srfSurfaceFace_t *cv;
+ srfBspSurface_t *cv;
srfTriangle_t *tri;
int numVerts, numTriangles, badTriangles;
int realLightmapNum;
@@ -768,12 +768,12 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors,
// take the plane information from the lightmap vector
for ( i = 0 ; i < 3 ; i++ ) {
- cv->plane.normal[i] = LittleFloat( ds->lightmapVecs[2][i] );
+ cv->cullPlane.normal[i] = LittleFloat( ds->lightmapVecs[2][i] );
}
- cv->plane.dist = DotProduct( cv->verts[0].xyz, cv->plane.normal );
- SetPlaneSignbits( &cv->plane );
- cv->plane.type = PlaneTypeForNormal( cv->plane.normal );
- surf->cullinfo.plane = cv->plane;
+ cv->cullPlane.dist = DotProduct( cv->verts[0].xyz, cv->cullPlane.normal );
+ SetPlaneSignbits( &cv->cullPlane );
+ cv->cullPlane.type = PlaneTypeForNormal( cv->cullPlane.normal );
+ surf->cullinfo.plane = cv->cullPlane;
surf->data = (surfaceType_t *)cv;
@@ -801,7 +801,7 @@ ParseMesh
===============
*/
static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf ) {
- srfGridMesh_t *grid;
+ srfBspSurface_t *grid;
int i, j;
int width, height, numPoints;
srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE];
@@ -904,7 +904,7 @@ ParseTriSurf
===============
*/
static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) {
- srfTriangles_t *cv;
+ srfBspSurface_t *cv;
srfTriangle_t *tri;
int i, j;
int numVerts, numTriangles, badTriangles;
@@ -1066,7 +1066,7 @@ R_MergedWidthPoints
returns true if there are grid points merged on a width edge
=================
*/
-int R_MergedWidthPoints(srfGridMesh_t *grid, int offset) {
+int R_MergedWidthPoints(srfBspSurface_t *grid, int offset) {
int i, j;
for (i = 1; i < grid->width-1; i++) {
@@ -1087,7 +1087,7 @@ R_MergedHeightPoints
returns true if there are grid points merged on a height edge
=================
*/
-int R_MergedHeightPoints(srfGridMesh_t *grid, int offset) {
+int R_MergedHeightPoints(srfBspSurface_t *grid, int offset) {
int i, j;
for (i = 1; i < grid->height-1; i++) {
@@ -1110,13 +1110,13 @@ NOTE: never sync LoD through grid edges with merged points!
FIXME: write generalized version that also avoids cracks between a patch and one that meets half way?
=================
*/
-void R_FixSharedVertexLodError_r( int start, srfGridMesh_t *grid1 ) {
+void R_FixSharedVertexLodError_r( int start, srfBspSurface_t *grid1 ) {
int j, k, l, m, n, offset1, offset2, touch;
- srfGridMesh_t *grid2;
+ srfBspSurface_t *grid2;
for ( j = start; j < s_worldData.numsurfaces; j++ ) {
//
- grid2 = (srfGridMesh_t *) s_worldData.surfaces[j].data;
+ grid2 = (srfBspSurface_t *) s_worldData.surfaces[j].data;
// if this surface is not a grid
if ( grid2->surfaceType != SF_GRID ) continue;
// if the LOD errors are already fixed for this patch
@@ -1224,11 +1224,11 @@ If this is not the case this function will still do its job but won't fix the hi
*/
void R_FixSharedVertexLodError( void ) {
int i;
- srfGridMesh_t *grid1;
+ srfBspSurface_t *grid1;
for ( i = 0; i < s_worldData.numsurfaces; i++ ) {
//
- grid1 = (srfGridMesh_t *) s_worldData.surfaces[i].data;
+ grid1 = (srfBspSurface_t *) s_worldData.surfaces[i].data;
// if this surface is not a grid
if ( grid1->surfaceType != SF_GRID )
continue;
@@ -1250,11 +1250,11 @@ R_StitchPatches
*/
int R_StitchPatches( int grid1num, int grid2num ) {
float *v1, *v2;
- srfGridMesh_t *grid1, *grid2;
+ srfBspSurface_t *grid1, *grid2;
int k, l, m, n, offset1, offset2, row, column;
- grid1 = (srfGridMesh_t *) s_worldData.surfaces[grid1num].data;
- grid2 = (srfGridMesh_t *) s_worldData.surfaces[grid2num].data;
+ grid1 = (srfBspSurface_t *) s_worldData.surfaces[grid1num].data;
+ grid2 = (srfBspSurface_t *) s_worldData.surfaces[grid2num].data;
for (n = 0; n < 2; n++) {
//
if (n) offset1 = (grid1->height-1) * grid1->width;
@@ -1665,13 +1665,13 @@ might still appear at that side.
*/
int R_TryStitchingPatch( int grid1num ) {
int j, numstitches;
- srfGridMesh_t *grid1, *grid2;
+ srfBspSurface_t *grid1, *grid2;
numstitches = 0;
- grid1 = (srfGridMesh_t *) s_worldData.surfaces[grid1num].data;
+ grid1 = (srfBspSurface_t *) s_worldData.surfaces[grid1num].data;
for ( j = 0; j < s_worldData.numsurfaces; j++ ) {
//
- grid2 = (srfGridMesh_t *) s_worldData.surfaces[j].data;
+ grid2 = (srfBspSurface_t *) s_worldData.surfaces[j].data;
// if this surface is not a grid
if ( grid2->surfaceType != SF_GRID ) continue;
// grids in the same LOD group should have the exact same lod radius
@@ -1696,7 +1696,7 @@ R_StitchAllPatches
*/
void R_StitchAllPatches( void ) {
int i, stitched, numstitches;
- srfGridMesh_t *grid1;
+ srfBspSurface_t *grid1;
numstitches = 0;
do
@@ -1704,7 +1704,7 @@ void R_StitchAllPatches( void ) {
stitched = qfalse;
for ( i = 0; i < s_worldData.numsurfaces; i++ ) {
//
- grid1 = (srfGridMesh_t *) s_worldData.surfaces[i].data;
+ grid1 = (srfBspSurface_t *) s_worldData.surfaces[i].data;
// if this surface is not a grid
if ( grid1->surfaceType != SF_GRID )
continue;
@@ -1729,11 +1729,11 @@ R_MovePatchSurfacesToHunk
*/
void R_MovePatchSurfacesToHunk(void) {
int i, size;
- srfGridMesh_t *grid, *hunkgrid;
+ srfBspSurface_t *grid, *hunkgrid;
for ( i = 0; i < s_worldData.numsurfaces; i++ ) {
//
- grid = (srfGridMesh_t *) s_worldData.surfaces[i].data;
+ grid = (srfBspSurface_t *) s_worldData.surfaces[i].data;
// if this surface is not a grid
if ( grid->surfaceType != SF_GRID )
continue;
@@ -1891,42 +1891,24 @@ static void R_CreateWorldVBOs(void)
numSurfaces = 0;
for (currSurf = firstSurf; currSurf < lastSurf; currSurf++)
{
- surface = *currSurf;
- if(*surface->data == SF_FACE)
- {
- srfSurfaceFace_t *face = (srfSurfaceFace_t *) surface->data;
-
- if(face->numVerts)
- numVerts += face->numVerts;
-
- if(face->numTriangles)
- numTriangles += face->numTriangles;
-
- numSurfaces++;
- }
- else if(*surface->data == SF_GRID)
- {
- srfGridMesh_t *grid = (srfGridMesh_t *) surface->data;
-
- if(grid->numVerts)
- numVerts += grid->numVerts;
-
- if(grid->numTriangles)
- numTriangles += grid->numTriangles;
+ srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data;
- numSurfaces++;
- }
- else if(*surface->data == SF_TRIANGLES)
+ switch (bspSurf->surfaceType)
{
- srfTriangles_t *tri = (srfTriangles_t *) surface->data;
+ case SF_FACE:
+ case SF_GRID:
+ case SF_TRIANGLES:
+ if(bspSurf->numVerts)
+ numVerts += bspSurf->numVerts;
- if(tri->numVerts)
- numVerts += tri->numVerts;
+ if(bspSurf->numTriangles)
+ numTriangles += bspSurf->numTriangles;
- if(tri->numTriangles)
- numTriangles += tri->numTriangles;
+ numSurfaces++;
+ break;
- numSurfaces++;
+ default:
+ break;
}
}
@@ -1944,93 +1926,42 @@ static void R_CreateWorldVBOs(void)
numTriangles = 0;
for (currSurf = firstSurf; currSurf < lastSurf; currSurf++)
{
- surface = *currSurf;
- if(*surface->data == SF_FACE)
- {
- srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data;
-
- srf->firstIndex = numTriangles * 3;
-
- if(srf->numTriangles)
- {
- srfTriangle_t *tri;
-
- srf->minIndex = numVerts + srf->triangles->indexes[0];
- srf->maxIndex = numVerts + srf->triangles->indexes[0];
+ srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data;
- for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++)
- {
- for(j = 0; j < 3; j++)
- {
- triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j];
- srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]);
- srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]);
- }
- }
-
- numTriangles += srf->numTriangles;
- }
-
- if(srf->numVerts)
- numVerts += srf->numVerts;
- }
- else if(*surface->data == SF_GRID)
+ switch (bspSurf->surfaceType)
{
- srfGridMesh_t *srf = (srfGridMesh_t *) surface->data;
-
- srf->firstIndex = numTriangles * 3;
-
- if(srf->numTriangles)
- {
- srfTriangle_t *tri;
-
- srf->minIndex = numVerts + srf->triangles->indexes[0];
- srf->maxIndex = numVerts + srf->triangles->indexes[0];
+ case SF_FACE:
+ case SF_GRID:
+ case SF_TRIANGLES:
+ bspSurf->firstIndex = numTriangles * 3;
- for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++)
+ if(bspSurf->numTriangles)
{
- for(j = 0; j < 3; j++)
- {
- triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j];
- srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]);
- srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]);
- }
- }
-
- numTriangles += srf->numTriangles;
- }
+ srfTriangle_t *tri;
- if(srf->numVerts)
- numVerts += srf->numVerts;
- }
- else if(*surface->data == SF_TRIANGLES)
- {
- srfTriangles_t *srf = (srfTriangles_t *) surface->data;
-
- srf->firstIndex = numTriangles * 3;
-
- if(srf->numTriangles)
- {
- srfTriangle_t *tri;
+ bspSurf->minIndex = numVerts + bspSurf->triangles->indexes[0];
+ bspSurf->maxIndex = numVerts + bspSurf->triangles->indexes[0];
- srf->minIndex = numVerts + srf->triangles->indexes[0];
- srf->maxIndex = numVerts + srf->triangles->indexes[0];
-
- for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++)
- {
- for(j = 0; j < 3; j++)
+ for(i = 0, tri = bspSurf->triangles; i < bspSurf->numTriangles; i++, tri++)
{
- triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j];
- srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]);
- srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]);
+ for(j = 0; j < 3; j++)
+ {
+ triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j];
+ bspSurf->minIndex = MIN(bspSurf->minIndex, numVerts + tri->indexes[j]);
+ bspSurf->maxIndex = MAX(bspSurf->maxIndex, numVerts + tri->indexes[j]);
+ }
}
+
+ numTriangles += bspSurf->numTriangles;
}
- numTriangles += srf->numTriangles;
- }
+ if(bspSurf->numVerts)
+ numVerts += bspSurf->numVerts;
+
+ break;
- if(srf->numVerts)
- numVerts += srf->numVerts;
+ default:
+ break;
}
}
@@ -2038,54 +1969,29 @@ static void R_CreateWorldVBOs(void)
numVerts = 0;
for (currSurf = firstSurf; currSurf < lastSurf; currSurf++)
{
- surface = *currSurf;
- if(*surface->data == SF_FACE)
- {
- srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data;
-
- srf->firstVert = numVerts;
+ srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data;
- if(srf->numVerts)
- {
- for(i = 0; i < srf->numVerts; i++)
- {
- CopyVert(&srf->verts[i], &verts[numVerts + i]);
- }
-
- numVerts += srf->numVerts;
- }
- }
- else if(*surface->data == SF_GRID)
+ switch (bspSurf->surfaceType)
{
- srfGridMesh_t *srf = (srfGridMesh_t *) surface->data;
-
- srf->firstVert = numVerts;
+ case SF_FACE:
+ case SF_GRID:
+ case SF_TRIANGLES:
+ bspSurf->firstVert = numVerts;
- if(srf->numVerts)
- {
- for(i = 0; i < srf->numVerts; i++)
+ if(bspSurf->numVerts)
{
- CopyVert(&srf->verts[i], &verts[numVerts + i]);
- }
-
- numVerts += srf->numVerts;
- }
- }
- else if(*surface->data == SF_TRIANGLES)
- {
- srfTriangles_t *srf = (srfTriangles_t *) surface->data;
-
- srf->firstVert = numVerts;
+ for(i = 0; i < bspSurf->numVerts; i++)
+ {
+ CopyVert(&bspSurf->verts[i], &verts[numVerts + i]);
+ }
- if(srf->numVerts)
- {
- for(i = 0; i < srf->numVerts; i++)
- {
- CopyVert(&srf->verts[i], &verts[numVerts + i]);
+ numVerts += bspSurf->numVerts;
}
- numVerts += srf->numVerts;
- }
+ break;
+
+ default:
+ break;
}
}
@@ -2104,36 +2010,23 @@ static void R_CreateWorldVBOs(void)
// point triangle surfaces to VBO
for (currSurf = firstSurf; currSurf < lastSurf; currSurf++)
{
- surface = *currSurf;
- if(*surface->data == SF_FACE)
- {
- srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data;
+ srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data;
- if( srf->numVerts && srf->numTriangles)
- {
- srf->vbo = vbo;
- srf->ibo = ibo;
- }
- }
- else if(*surface->data == SF_GRID)
+ switch (bspSurf->surfaceType)
{
- srfGridMesh_t *srf = (srfGridMesh_t *) surface->data;
+ case SF_FACE:
+ case SF_GRID:
+ case SF_TRIANGLES:
+ if( bspSurf->numVerts && bspSurf->numTriangles)
+ {
+ bspSurf->vbo = vbo;
+ bspSurf->ibo = ibo;
+ }
- if( srf->numVerts && srf->numTriangles)
- {
- srf->vbo = vbo;
- srf->ibo = ibo;
- }
- }
- else if(*surface->data == SF_TRIANGLES)
- {
- srfTriangles_t *srf = (srfTriangles_t *) surface->data;
+ break;
- if( srf->numVerts && srf->numTriangles)
- {
- srf->vbo = vbo;
- srf->ibo = ibo;
- }
+ default:
+ break;
}
}
@@ -2221,10 +2114,10 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) {
// FIXME: do this
break;
case MST_TRIANGLE_SOUP:
- out->data = ri.Hunk_Alloc( sizeof(srfTriangles_t), h_low);
+ out->data = ri.Hunk_Alloc( sizeof(srfBspSurface_t), h_low);
break;
case MST_PLANAR:
- out->data = ri.Hunk_Alloc( sizeof(srfSurfaceFace_t), h_low);
+ out->data = ri.Hunk_Alloc( sizeof(srfBspSurface_t), h_low);
break;
case MST_FLARE:
out->data = ri.Hunk_Alloc( sizeof(srfFlare_t), h_low);
@@ -2241,13 +2134,13 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) {
case MST_PATCH:
ParseMesh ( in, dv, hdrVertColors, out );
{
- srfGridMesh_t *surface = (srfGridMesh_t *)out->data;
+ srfBspSurface_t *surface = (srfBspSurface_t *)out->data;
out->cullinfo.type = CULLINFO_BOX | CULLINFO_SPHERE;
- VectorCopy(surface->meshBounds[0], out->cullinfo.bounds[0]);
- VectorCopy(surface->meshBounds[1], out->cullinfo.bounds[1]);
- VectorCopy(surface->localOrigin, out->cullinfo.localOrigin);
- out->cullinfo.radius = surface->meshRadius;
+ VectorCopy(surface->cullBounds[0], out->cullinfo.bounds[0]);
+ VectorCopy(surface->cullBounds[1], out->cullinfo.bounds[1]);
+ VectorCopy(surface->cullOrigin, out->cullinfo.localOrigin);
+ out->cullinfo.radius = surface->cullRadius;
}
numMeshes++;
break;
@@ -3202,7 +3095,7 @@ void R_MergeLeafSurfaces(void)
int numVerts;
int firstIndex;
- srfVBOMesh_t *vboSurf;
+ srfBspSurface_t *vboSurf;
if (s_worldData.surfacesViewCount[i] != i)
continue;
@@ -3213,15 +3106,9 @@ void R_MergeLeafSurfaces(void)
switch(*surf1->data)
{
case SF_FACE:
- vbo = ((srfSurfaceFace_t *)(surf1->data))->vbo;
- break;
-
case SF_GRID:
- vbo = ((srfGridMesh_t *)(surf1->data))->vbo;
- break;
-
case SF_TRIANGLES:
- vbo = ((srfTriangles_t *)(surf1->data))->vbo;
+ vbo = ((srfBspSurface_t *)(surf1->data))->vbo;
break;
default:
@@ -3236,42 +3123,21 @@ void R_MergeLeafSurfaces(void)
for (j = 0; j < numWorldSurfaces; j++)
{
msurface_t *surf2;
+ srfBspSurface_t *bspSurf;
if (s_worldData.surfacesViewCount[j] != i)
continue;
surf2 = s_worldData.surfaces + j;
- switch(*surf2->data)
+ bspSurf = (srfBspSurface_t *) surf2->data;
+ switch(bspSurf->surfaceType)
{
case SF_FACE:
- {
- srfSurfaceFace_t *face;
-
- face = (srfSurfaceFace_t *) surf2->data;
- numTriangles += face->numTriangles;
- numVerts += face->numVerts;
- }
- break;
-
case SF_GRID:
- {
- srfGridMesh_t *grid;
-
- grid = (srfGridMesh_t *) surf2->data;
- numTriangles += grid->numTriangles;
- numVerts += grid->numVerts;
- }
- break;
-
case SF_TRIANGLES:
- {
- srfTriangles_t *tris;
-
- tris = (srfTriangles_t *) surf2->data;
- numTriangles += tris->numTriangles;
- numVerts += tris->numVerts;
- }
+ numTriangles += bspSurf->numTriangles;
+ numVerts += bspSurf->numVerts;
break;
default:
@@ -3301,6 +3167,7 @@ void R_MergeLeafSurfaces(void)
for (j = 0; j < numWorldSurfaces; j++)
{
msurface_t *surf2;
+ srfBspSurface_t *bspSurf;
if (s_worldData.surfacesViewCount[j] != i)
continue;
@@ -3310,53 +3177,18 @@ void R_MergeLeafSurfaces(void)
AddPointToBounds(surf2->cullinfo.bounds[0], bounds[0], bounds[1]);
AddPointToBounds(surf2->cullinfo.bounds[1], bounds[0], bounds[1]);
- switch(*surf2->data)
+ bspSurf = (srfBspSurface_t *) surf2->data;
+ switch(bspSurf->surfaceType)
{
case SF_FACE:
- {
- srfSurfaceFace_t *face;
-
- face = (srfSurfaceFace_t *) surf2->data;
-
- for (k = 0; k < face->numTriangles; k++)
- {
- *outIboIndexes++ = face->triangles[k].indexes[0] + face->firstVert;
- *outIboIndexes++ = face->triangles[k].indexes[1] + face->firstVert;
- *outIboIndexes++ = face->triangles[k].indexes[2] + face->firstVert;
- numIboIndexes += 3;
- }
- }
- break;
-
case SF_GRID:
- {
- srfGridMesh_t *grid;
-
- grid = (srfGridMesh_t *) surf2->data;
-
- for (k = 0; k < grid->numTriangles; k++)
- {
- *outIboIndexes++ = grid->triangles[k].indexes[0] + grid->firstVert;
- *outIboIndexes++ = grid->triangles[k].indexes[1] + grid->firstVert;
- *outIboIndexes++ = grid->triangles[k].indexes[2] + grid->firstVert;
- numIboIndexes += 3;
- }
- }
- break;
-
case SF_TRIANGLES:
+ for (k = 0; k < bspSurf->numTriangles; k++)
{
- srfTriangles_t *tris;
-
- tris = (srfTriangles_t *) surf2->data;
-
- for (k = 0; k < tris->numTriangles; k++)
- {
- *outIboIndexes++ = tris->triangles[k].indexes[0] + tris->firstVert;
- *outIboIndexes++ = tris->triangles[k].indexes[1] + tris->firstVert;
- *outIboIndexes++ = tris->triangles[k].indexes[2] + tris->firstVert;
- numIboIndexes += 3;
- }
+ *outIboIndexes++ = bspSurf->triangles[k].indexes[0] + bspSurf->firstVert;
+ *outIboIndexes++ = bspSurf->triangles[k].indexes[1] + bspSurf->firstVert;
+ *outIboIndexes++ = bspSurf->triangles[k].indexes[2] + bspSurf->firstVert;
+ numIboIndexes += 3;
}
break;
@@ -3373,7 +3205,7 @@ void R_MergeLeafSurfaces(void)
vboSurf->vbo = vbo;
vboSurf->ibo = ibo;
- vboSurf->numIndexes = numTriangles * 3;
+ vboSurf->numTriangles = numTriangles;
vboSurf->numVerts = numVerts;
vboSurf->firstIndex = firstIndex;
@@ -3386,12 +3218,8 @@ void R_MergeLeafSurfaces(void)
vboSurf->maxIndex = MAX(vboSurf->maxIndex, *(iboIndexes + firstIndex + j));
}
- vboSurf->shader = surf1->shader;
- vboSurf->fogIndex = surf1->fogIndex;
- vboSurf->cubemapIndex = surf1->cubemapIndex;
-
- VectorCopy(bounds[0], vboSurf->bounds[0]);
- VectorCopy(bounds[1], vboSurf->bounds[1]);
+ VectorCopy(bounds[0], vboSurf->cullBounds[0]);
+ VectorCopy(bounds[1], vboSurf->cullBounds[1]);
VectorCopy(bounds[0], mergedSurf->cullinfo.bounds[0]);
VectorCopy(bounds[1], mergedSurf->cullinfo.bounds[1]);
@@ -3453,41 +3281,20 @@ void R_CalcVertexLightDirs( void )
for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces /* s_worldData.numWorldSurfaces */; k++, surface++)
{
- if(*surface->data == SF_FACE)
- {
- srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data;
+ srfBspSurface_t *bspSurf = (srfBspSurface_t *) surface->data;
- if(srf->numVerts)
- {
- for(i = 0; i < srf->numVerts; i++)
- {
- R_LightDirForPoint( srf->verts[i].xyz, srf->verts[i].lightdir, srf->verts[i].normal, &s_worldData );
- }
- }
- }
- else if(*surface->data == SF_GRID)
+ switch(bspSurf->surfaceType)
{
- srfGridMesh_t *srf = (srfGridMesh_t *) surface->data;
+ case SF_FACE:
+ case SF_GRID:
+ case SF_TRIANGLES:
+ for(i = 0; i < bspSurf->numVerts; i++)
+ R_LightDirForPoint( bspSurf->verts[i].xyz, bspSurf->verts[i].lightdir, bspSurf->verts[i].normal, &s_worldData );
- if(srf->numVerts)
- {
- for(i = 0; i < srf->numVerts; i++)
- {
- R_LightDirForPoint( srf->verts[i].xyz, srf->verts[i].lightdir, srf->verts[i].normal, &s_worldData );
- }
- }
- }
- else if(*surface->data == SF_TRIANGLES)
- {
- srfTriangles_t *srf = (srfTriangles_t *) surface->data;
+ break;
- if(srf->numVerts)
- {
- for(i = 0; i < srf->numVerts; i++)
- {
- R_LightDirForPoint( srf->verts[i].xyz, srf->verts[i].lightdir, srf->verts[i].normal, &s_worldData );
- }
- }
+ default:
+ break;
}
}
}
diff --git a/src/renderergl2/tr_curve.c b/src/renderergl2/tr_curve.c
index 6fe000f1..104e706a 100644
--- a/src/renderergl2/tr_curve.c
+++ b/src/renderergl2/tr_curve.c
@@ -26,14 +26,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/*
This file does all of the processing necessary to turn a raw grid of points
-read from the map file into a srfGridMesh_t ready for rendering.
+read from the map file into a srfBspSurface_t ready for rendering.
The level of detail solution is direction independent, based only on subdivided
distance from the true curve.
Only a single entry point:
-srfGridMesh_t *R_SubdividePatchToGrid( int width, int height,
+srfBspSurface_t *R_SubdividePatchToGrid( int width, int height,
srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) {
*/
@@ -330,8 +330,6 @@ static int MakeMeshTriangles(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE
}
}
- R_CalcSurfaceTriangleNeighbors(numTriangles, triangles);
-
// FIXME: use more elegant way
for(i = 0; i < width; i++)
{
@@ -342,8 +340,6 @@ static int MakeMeshTriangles(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE
}
}
- R_CalcSurfaceTrianglePlanes(numTriangles, triangles, ctrl2);
-
return numTriangles;
}
@@ -421,13 +417,13 @@ static void PutPointsOnCurve( srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE],
R_CreateSurfaceGridMesh
=================
*/
-srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height,
+srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height,
srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], float errorTable[2][MAX_GRID_SIZE],
int numTriangles, srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]) {
int i, j, size;
srfVert_t *vert;
vec3_t tmpVec;
- srfGridMesh_t *grid;
+ srfBspSurface_t *grid;
// copy the results out to a grid
size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid );
@@ -469,23 +465,23 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height,
grid->width = width;
grid->height = height;
grid->surfaceType = SF_GRID;
- ClearBounds( grid->meshBounds[0], grid->meshBounds[1] );
+ ClearBounds( grid->cullBounds[0], grid->cullBounds[1] );
for ( i = 0 ; i < width ; i++ ) {
for ( j = 0 ; j < height ; j++ ) {
vert = &grid->verts[j*width+i];
*vert = ctrl[j][i];
- AddPointToBounds( vert->xyz, grid->meshBounds[0], grid->meshBounds[1] );
+ AddPointToBounds( vert->xyz, grid->cullBounds[0], grid->cullBounds[1] );
}
}
// compute local origin and bounds
- VectorAdd( grid->meshBounds[0], grid->meshBounds[1], grid->localOrigin );
- VectorScale( grid->localOrigin, 0.5f, grid->localOrigin );
- VectorSubtract( grid->meshBounds[0], grid->localOrigin, tmpVec );
- grid->meshRadius = VectorLength( tmpVec );
+ VectorAdd( grid->cullBounds[0], grid->cullBounds[1], grid->cullOrigin );
+ VectorScale( grid->cullOrigin, 0.5f, grid->cullOrigin );
+ VectorSubtract( grid->cullBounds[0], grid->cullOrigin, tmpVec );
+ grid->cullRadius = VectorLength( tmpVec );
- VectorCopy( grid->localOrigin, grid->lodOrigin );
- grid->lodRadius = grid->meshRadius;
+ VectorCopy( grid->cullOrigin, grid->lodOrigin );
+ grid->lodRadius = grid->cullRadius;
//
return grid;
}
@@ -495,7 +491,7 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height,
R_FreeSurfaceGridMesh
=================
*/
-void R_FreeSurfaceGridMesh( srfGridMesh_t *grid ) {
+void R_FreeSurfaceGridMesh( srfBspSurface_t *grid ) {
ri.Free(grid->widthLodError);
ri.Free(grid->heightLodError);
ri.Free(grid->triangles);
@@ -508,7 +504,7 @@ void R_FreeSurfaceGridMesh( srfGridMesh_t *grid ) {
R_SubdividePatchToGrid
=================
*/
-srfGridMesh_t *R_SubdividePatchToGrid( int width, int height,
+srfBspSurface_t *R_SubdividePatchToGrid( int width, int height,
srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) {
int i, j, k, l;
srfVert_t_cleared( prev );
@@ -691,7 +687,7 @@ srfGridMesh_t *R_SubdividePatchToGrid( int width, int height,
R_GridInsertColumn
===============
*/
-srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec3_t point, float loderror ) {
+srfBspSurface_t *R_GridInsertColumn( srfBspSurface_t *grid, int column, int row, vec3_t point, float loderror ) {
int i, j;
int width, height, oldwidth;
srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE];
@@ -751,7 +747,7 @@ srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec
R_GridInsertRow
===============
*/
-srfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t point, float loderror ) {
+srfBspSurface_t *R_GridInsertRow( srfBspSurface_t *grid, int row, int column, vec3_t point, float loderror ) {
int i, j;
int width, height, oldheight;
srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE];
diff --git a/src/renderergl2/tr_light.c b/src/renderergl2/tr_light.c
index 01ce46d2..4d54bff2 100644
--- a/src/renderergl2/tr_light.c
+++ b/src/renderergl2/tr_light.c
@@ -95,12 +95,17 @@ void R_DlightBmodel( bmodel_t *bmodel ) {
for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) {
surf = tr.world->surfaces + bmodel->firstSurface + i;
- if ( *surf->data == SF_FACE ) {
- ((srfSurfaceFace_t *)surf->data)->dlightBits = mask;
- } else if ( *surf->data == SF_GRID ) {
- ((srfGridMesh_t *)surf->data)->dlightBits = mask;
- } else if ( *surf->data == SF_TRIANGLES ) {
- ((srfTriangles_t *)surf->data)->dlightBits = mask;
+ switch(*surf->data)
+ {
+ case SF_FACE:
+ case SF_GRID:
+ case SF_TRIANGLES:
+ case SF_VBO_MESH:
+ ((srfBspSurface_t *)surf->data)->dlightBits = mask;
+ break;
+
+ default:
+ break;
}
}
}
diff --git a/src/renderergl2/tr_local.h b/src/renderergl2/tr_local.h
index ab99e354..08334fa3 100644
--- a/src/renderergl2/tr_local.h
+++ b/src/renderergl2/tr_local.h
@@ -1029,13 +1029,10 @@ typedef struct
{
int indexes[3];
int neighbors[3];
- vec4_t plane;
- qboolean facingLight;
- qboolean degenerated;
} srfTriangle_t;
-
-typedef struct srfGridMesh_s
+// srfBspSurface_t covers SF_GRID, SF_TRIANGLES, SF_POLY, and SF_VBO_MESH
+typedef struct srfBspSurface_s
{
surfaceType_t surfaceType;
@@ -1044,57 +1041,16 @@ typedef struct srfGridMesh_s
int pshadowBits;
// culling information
- vec3_t meshBounds[2];
- vec3_t localOrigin;
- float meshRadius;
-
- // lod information, which may be different
- // than the culling information to allow for
- // groups of curves that LOD as a unit
- vec3_t lodOrigin;
- float lodRadius;
- int lodFixed;
- int lodStitched;
-
- // vertexes
- int width, height;
- float *widthLodError;
- float *heightLodError;
-
- int numTriangles;
- srfTriangle_t *triangles;
-
- int numVerts;
- srfVert_t *verts;
-
- // BSP VBO offsets
- int firstVert;
- int firstIndex;
- glIndex_t minIndex;
- glIndex_t maxIndex;
-
- // static render data
- VBO_t *vbo; // points to bsp model VBO
- IBO_t *ibo;
-} srfGridMesh_t;
-
-
-typedef struct
-{
- surfaceType_t surfaceType;
-
- // dynamic lighting information
- int dlightBits;
- int pshadowBits;
-
- // culling information
- cplane_t plane;
-// vec3_t bounds[2];
+ vec3_t cullBounds[2];
+ vec3_t cullOrigin;
+ float cullRadius;
+ cplane_t cullPlane;
// triangle definitions
int numTriangles;
srfTriangle_t *triangles;
+ // vertexes
int numVerts;
srfVert_t *verts;
@@ -1105,40 +1061,24 @@ typedef struct
glIndex_t maxIndex;
// static render data
- VBO_t *vbo; // points to bsp model VBO
+ VBO_t *vbo;
IBO_t *ibo;
-} srfSurfaceFace_t;
-
-
-// misc_models in maps are turned into direct geometry by xmap
-typedef struct
-{
- surfaceType_t surfaceType;
-
- // dynamic lighting information
- int dlightBits;
- int pshadowBits;
-
- // culling information
-// vec3_t bounds[2];
-
- // triangle definitions
- int numTriangles;
- srfTriangle_t *triangles;
-
- int numVerts;
- srfVert_t *verts;
+
+ // SF_GRID specific variables after here
- // BSP VBO offsets
- int firstVert;
- int firstIndex;
- glIndex_t minIndex;
- glIndex_t maxIndex;
+ // lod information, which may be different
+ // than the culling information to allow for
+ // groups of curves that LOD as a unit
+ vec3_t lodOrigin;
+ float lodRadius;
+ int lodFixed;
+ int lodStitched;
- // static render data
- VBO_t *vbo; // points to bsp model VBO
- IBO_t *ibo;
-} srfTriangles_t;
+ // vertexes
+ int width, height;
+ float *widthLodError;
+ float *heightLodError;
+} srfBspSurface_t;
// inter-quake-model
typedef struct {
@@ -1175,33 +1115,6 @@ typedef struct srfIQModel_s {
int first_triangle, num_triangles;
} srfIQModel_t;
-typedef struct srfVBOMesh_s
-{
- surfaceType_t surfaceType;
-
- struct shader_s *shader; // FIXME move this to somewhere else
- int fogIndex;
- int cubemapIndex;
-
- // dynamic lighting information
- int dlightBits;
- int pshadowBits;
-
- // culling information
- vec3_t bounds[2];
-
- // backEnd stats
- int numIndexes;
- int numVerts;
- int firstIndex;
- glIndex_t minIndex;
- glIndex_t maxIndex;
-
- // static render data
- VBO_t *vbo;
- IBO_t *ibo;
-} srfVBOMesh_t;
-
typedef struct srfVBOMDVMesh_s
{
surfaceType_t surfaceType;
@@ -2057,8 +1970,6 @@ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader,
void R_CalcTangentSpace(vec3_t tangent, vec3_t bitangent, vec3_t normal,
const vec3_t v0, const vec3_t v1, const vec3_t v2, const vec2_t t0, const vec2_t t1, const vec2_t t2);
qboolean R_CalcTangentVectors(srfVert_t * dv[3]);
-void R_CalcSurfaceTriangleNeighbors(int numTriangles, srfTriangle_t * triangles);
-void R_CalcSurfaceTrianglePlanes(int numTriangles, srfTriangle_t * triangles, srfVert_t * verts);
#define CULL_IN 0 // completely unclipped
#define CULL_CLIP 1 // clipped by one or more planes
@@ -2353,11 +2264,11 @@ CURVE TESSELATION
#define PATCH_STITCHING
-srfGridMesh_t *R_SubdividePatchToGrid( int width, int height,
+srfBspSurface_t *R_SubdividePatchToGrid( int width, int height,
srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] );
-srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec3_t point, float loderror );
-srfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t point, float loderror );
-void R_FreeSurfaceGridMesh( srfGridMesh_t *grid );
+srfBspSurface_t *R_GridInsertColumn( srfBspSurface_t *grid, int column, int row, vec3_t point, float loderror );
+srfBspSurface_t *R_GridInsertRow( srfBspSurface_t *grid, int row, int column, vec3_t point, float loderror );
+void R_FreeSurfaceGridMesh( srfBspSurface_t *grid );
/*
============================================================
@@ -2504,13 +2415,7 @@ void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t
void RB_DeformTessGeometry( void );
-void RB_CalcEnvironmentTexCoords( float *dstTexCoords );
void RB_CalcFogTexCoords( float *dstTexCoords );
-void RB_CalcScrollTexCoords( const float scroll[2], float *dstTexCoords );
-void RB_CalcRotateTexCoords( float rotSpeed, float *dstTexCoords );
-void RB_CalcScaleTexCoords( const float scale[2], float *dstTexCoords );
-void RB_CalcTurbulentTexCoords( const waveForm_t *wf, float *dstTexCoords );
-void RB_CalcTransformTexCoords( const texModInfo_t *tmi, float *dstTexCoords );
void RB_CalcScaleTexMatrix( const float scale[2], float *matrix );
void RB_CalcScrollTexMatrix( const float scrollSpeed[2], float *matrix );
@@ -2520,19 +2425,8 @@ void RB_CalcTransformTexMatrix( const texModInfo_t *tmi, float *matrix );
void RB_CalcStretchTexMatrix( const waveForm_t *wf, float *matrix );
void RB_CalcModulateColorsByFog( unsigned char *dstColors );
-void RB_CalcModulateAlphasByFog( unsigned char *dstColors );
-void RB_CalcModulateRGBAsByFog( unsigned char *dstColors );
-void RB_CalcWaveAlpha( const waveForm_t *wf, unsigned char *dstColors );
float RB_CalcWaveAlphaSingle( const waveForm_t *wf );
-void RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors );
float RB_CalcWaveColorSingle( const waveForm_t *wf );
-void RB_CalcAlphaFromEntity( unsigned char *dstColors );
-void RB_CalcAlphaFromOneMinusEntity( unsigned char *dstColors );
-void RB_CalcStretchTexCoords( const waveForm_t *wf, float *texCoords );
-void RB_CalcColorFromEntity( unsigned char *dstColors );
-void RB_CalcColorFromOneMinusEntity( unsigned char *dstColors );
-void RB_CalcSpecularAlpha( unsigned char *alphas );
-void RB_CalcDiffuseColor( unsigned char *colors );
/*
=============================================================
diff --git a/src/renderergl2/tr_main.c b/src/renderergl2/tr_main.c
index e10be3a1..b0362a88 100644
--- a/src/renderergl2/tr_main.c
+++ b/src/renderergl2/tr_main.c
@@ -495,99 +495,6 @@ qboolean R_CalcTangentVectors(srfVert_t * dv[3])
/*
=================
-R_FindSurfaceTriangleWithEdge
-
-Recoded from Q2E
-=================
-*/
-static int R_FindSurfaceTriangleWithEdge(int numTriangles, srfTriangle_t * triangles, int start, int end, int ignore)
-{
- srfTriangle_t *tri;
- int count, match;
- int i;
-
- count = 0;
- match = -1;
-
- for(i = 0, tri = triangles; i < numTriangles; i++, tri++)
- {
- if((tri->indexes[0] == start && tri->indexes[1] == end) ||
- (tri->indexes[1] == start && tri->indexes[2] == end) || (tri->indexes[2] == start && tri->indexes[0] == end))
- {
- if(i != ignore)
- {
- match = i;
- }
-
- count++;
- }
- else if((tri->indexes[1] == start && tri->indexes[0] == end) ||
- (tri->indexes[2] == start && tri->indexes[1] == end) || (tri->indexes[0] == start && tri->indexes[2] == end))
- {
- count++;
- }
- }
-
- // detect edges shared by three triangles and make them seams
- if(count > 2)
- {
- match = -1;
- }
-
- return match;
-}
-
-
-/*
-=================
-R_CalcSurfaceTriangleNeighbors
-
-Recoded from Q2E
-=================
-*/
-void R_CalcSurfaceTriangleNeighbors(int numTriangles, srfTriangle_t * triangles)
-{
- int i;
- srfTriangle_t *tri;
-
- for(i = 0, tri = triangles; i < numTriangles; i++, tri++)
- {
- tri->neighbors[0] = R_FindSurfaceTriangleWithEdge(numTriangles, triangles, tri->indexes[1], tri->indexes[0], i);
- tri->neighbors[1] = R_FindSurfaceTriangleWithEdge(numTriangles, triangles, tri->indexes[2], tri->indexes[1], i);
- tri->neighbors[2] = R_FindSurfaceTriangleWithEdge(numTriangles, triangles, tri->indexes[0], tri->indexes[2], i);
- }
-}
-
-/*
-=================
-R_CalcSurfaceTrianglePlanes
-=================
-*/
-void R_CalcSurfaceTrianglePlanes(int numTriangles, srfTriangle_t * triangles, srfVert_t * verts)
-{
- int i;
- srfTriangle_t *tri;
-
- for(i = 0, tri = triangles; i < numTriangles; i++, tri++)
- {
- float *v1, *v2, *v3;
- vec3_t d1, d2;
-
- v1 = verts[tri->indexes[0]].xyz;
- v2 = verts[tri->indexes[1]].xyz;
- v3 = verts[tri->indexes[2]].xyz;
-
- VectorSubtract(v2, v1, d1);
- VectorSubtract(v3, v1, d2);
-
- CrossProduct(d2, d1, tri->plane);
- tri->plane[3] = DotProduct(tri->plane, v1);
- }
-}
-
-
-/*
-=================
R_CullLocalBox
Returns CULL_IN, CULL_CLIP, or CULL_OUT
@@ -1366,7 +1273,7 @@ R_PlaneForSurface
=============
*/
void R_PlaneForSurface (surfaceType_t *surfType, cplane_t *plane) {
- srfTriangles_t *tri;
+ srfBspSurface_t *tri;
srfPoly_t *poly;
srfVert_t *v1, *v2, *v3;
vec4_t plane4;
@@ -1378,10 +1285,10 @@ void R_PlaneForSurface (surfaceType_t *surfType, cplane_t *plane) {
}
switch (*surfType) {
case SF_FACE:
- *plane = ((srfSurfaceFace_t *)surfType)->plane;
+ *plane = ((srfBspSurface_t *)surfType)->cullPlane;
return;
case SF_TRIANGLES:
- tri = (srfTriangles_t *)surfType;
+ tri = (srfBspSurface_t *)surfType;
v1 = tri->verts + tri->triangles[0].indexes[0];
v2 = tri->verts + tri->triangles[0].indexes[1];
v3 = tri->verts + tri->triangles[0].indexes[2];
diff --git a/src/renderergl2/tr_marks.c b/src/renderergl2/tr_marks.c
index bf6980e9..3fe41d1c 100644
--- a/src/renderergl2/tr_marks.c
+++ b/src/renderergl2/tr_marks.c
@@ -269,7 +269,7 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio
vec3_t clipPoints[2][MAX_VERTS_ON_POLY];
int numClipPoints;
float *v;
- srfGridMesh_t *cv;
+ srfBspSurface_t *cv;
srfTriangle_t *tri;
srfVert_t *dv;
vec3_t normal;
@@ -328,7 +328,7 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio
if (*surfaces[i] == SF_GRID) {
- cv = (srfGridMesh_t *) surfaces[i];
+ cv = (srfBspSurface_t *) surfaces[i];
for ( m = 0 ; m < cv->height - 1 ; m++ ) {
for ( n = 0 ; n < cv->width - 1 ; n++ ) {
// We triangulate the grid and chop all triangles within
@@ -408,10 +408,10 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio
}
else if (*surfaces[i] == SF_FACE) {
- srfSurfaceFace_t *surf = ( srfSurfaceFace_t * ) surfaces[i];
+ srfBspSurface_t *surf = ( srfBspSurface_t * ) surfaces[i];
// check the normal of this face
- if (DotProduct(surf->plane.normal, projectionDir) > -0.5) {
+ if (DotProduct(surf->cullPlane.normal, projectionDir) > -0.5) {
continue;
}
@@ -420,7 +420,7 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio
for(j = 0; j < 3; j++)
{
v = surf->verts[tri->indexes[j]].xyz;
- VectorMA(v, MARKER_OFFSET, surf->plane.normal, clipPoints[0][j]);
+ VectorMA(v, MARKER_OFFSET, surf->cullPlane.normal, clipPoints[0][j]);
}
// add the fragments of this face
@@ -436,7 +436,7 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio
}
else if(*surfaces[i] == SF_TRIANGLES && r_marksOnTriangleMeshes->integer) {
- srfTriangles_t *surf = (srfTriangles_t *) surfaces[i];
+ srfBspSurface_t *surf = (srfBspSurface_t *) surfaces[i];
for(k = 0, tri = surf->triangles; k < surf->numTriangles; k++, tri++)
{
diff --git a/src/renderergl2/tr_model.c b/src/renderergl2/tr_model.c
index f0bf8b31..34aff630 100644
--- a/src/renderergl2/tr_model.c
+++ b/src/renderergl2/tr_model.c
@@ -563,8 +563,6 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize,
tri->indexes[2] = LittleLong(md3Tri->indexes[2]);
}
- R_CalcSurfaceTriangleNeighbors(surf->numTriangles, surf->triangles);
-
// swap all the XyzNormals
surf->numVerts = md3Surf->numVerts;
surf->verts = v = ri.Hunk_Alloc(sizeof(*v) * (md3Surf->numVerts * md3Surf->numFrames), h_low);
diff --git a/src/renderergl2/tr_surface.c b/src/renderergl2/tr_surface.c
index 32760c4b..563c75c1 100644
--- a/src/renderergl2/tr_surface.c
+++ b/src/renderergl2/tr_surface.c
@@ -523,7 +523,7 @@ static qboolean RB_SurfaceVbo(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndex
RB_SurfaceTriangles
=============
*/
-static void RB_SurfaceTriangles( srfTriangles_t *srf ) {
+static void RB_SurfaceTriangles( srfBspSurface_t *srf ) {
if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3,
srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) )
{
@@ -1248,7 +1248,7 @@ static void RB_SurfaceMesh(mdvSurface_t *surface) {
RB_SurfaceFace
==============
*/
-static void RB_SurfaceFace( srfSurfaceFace_t *srf ) {
+static void RB_SurfaceFace( srfBspSurface_t *srf ) {
if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3,
srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) )
{
@@ -1297,7 +1297,7 @@ RB_SurfaceGrid
Just copy the grid of points and triangulate
=============
*/
-static void RB_SurfaceGrid( srfGridMesh_t *srf ) {
+static void RB_SurfaceGrid( srfBspSurface_t *srf ) {
int i, j;
float *xyz;
float *texCoords, *lightCoords;
@@ -1575,9 +1575,9 @@ static void RB_SurfaceFlare(srfFlare_t *surf)
RB_AddFlare(surf, tess.fogNum, surf->origin, surf->color, surf->normal);
}
-static void RB_SurfaceVBOMesh(srfVBOMesh_t * srf)
+static void RB_SurfaceVBOMesh(srfBspSurface_t * srf)
{
- RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex,
+ RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex,
srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qfalse );
}
diff --git a/src/renderergl2/tr_world.c b/src/renderergl2/tr_world.c
index 5d35cded..1a25d26a 100644
--- a/src/renderergl2/tr_world.c
+++ b/src/renderergl2/tr_world.c
@@ -209,16 +209,18 @@ static int R_DlightSurface( msurface_t *surf, int dlightBits ) {
}
}
- if ( *surf->data == SF_FACE ) {
- ((srfSurfaceFace_t *)surf->data)->dlightBits = dlightBits;
- } else if ( *surf->data == SF_GRID ) {
- ((srfGridMesh_t *)surf->data)->dlightBits = dlightBits;
- } else if ( *surf->data == SF_TRIANGLES ) {
- ((srfTriangles_t *)surf->data)->dlightBits = dlightBits;
- } else if ( *surf->data == SF_VBO_MESH ) {
- ((srfVBOMesh_t *)surf->data)->dlightBits = dlightBits;
- } else {
- dlightBits = 0;
+ switch(*surf->data)
+ {
+ case SF_FACE:
+ case SF_GRID:
+ case SF_TRIANGLES:
+ case SF_VBO_MESH:
+ ((srfBspSurface_t *)surf->data)->dlightBits = dlightBits;
+ break;
+
+ default:
+ dlightBits = 0;
+ break;
}
if ( dlightBits ) {
@@ -293,16 +295,18 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) {
}
}
- if ( *surf->data == SF_FACE ) {
- ((srfSurfaceFace_t *)surf->data)->pshadowBits = pshadowBits;
- } else if ( *surf->data == SF_GRID ) {
- ((srfGridMesh_t *)surf->data)->pshadowBits = pshadowBits;
- } else if ( *surf->data == SF_TRIANGLES ) {
- ((srfTriangles_t *)surf->data)->pshadowBits = pshadowBits;
- } else if ( *surf->data == SF_VBO_MESH ) {
- ((srfVBOMesh_t *)surf->data)->pshadowBits = pshadowBits;
- } else {
- pshadowBits = 0;
+ switch(*surf->data)
+ {
+ case SF_FACE:
+ case SF_GRID:
+ case SF_TRIANGLES:
+ case SF_VBO_MESH:
+ ((srfBspSurface_t *)surf->data)->pshadowBits = pshadowBits;
+ break;
+
+ default:
+ pshadowBits = 0;
+ break;
}
if ( pshadowBits ) {