OpenGL2: Merge bsp surface structs into a single struct, and more cleanup.

This commit is contained in:
SmileTheory 2013-10-15 01:19:16 -07:00
parent 01efe4a538
commit 535d0ea70e
9 changed files with 227 additions and 616 deletions

View file

@ -652,7 +652,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;
@ -767,12 +767,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;
@ -800,7 +800,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];
@ -903,7 +903,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;
@ -1065,7 +1065,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++) {
@ -1086,7 +1086,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++) {
@ -1109,13 +1109,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
@ -1223,11 +1223,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;
@ -1249,11 +1249,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;
@ -1664,13 +1664,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
@ -1695,7 +1695,7 @@ R_StitchAllPatches
*/
void R_StitchAllPatches( void ) {
int i, stitched, numstitches;
srfGridMesh_t *grid1;
srfBspSurface_t *grid1;
numstitches = 0;
do
@ -1703,7 +1703,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;
@ -1728,11 +1728,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;
@ -1890,42 +1890,24 @@ static void R_CreateWorldVBOs(void)
numSurfaces = 0;
for (currSurf = firstSurf; currSurf < lastSurf; currSurf++)
{
surface = *currSurf;
if(*surface->data == SF_FACE)
srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data;
switch (bspSurf->surfaceType)
{
srfSurfaceFace_t *face = (srfSurfaceFace_t *) surface->data;
case SF_FACE:
case SF_GRID:
case SF_TRIANGLES:
if(bspSurf->numVerts)
numVerts += bspSurf->numVerts;
if(face->numVerts)
numVerts += face->numVerts;
if(face->numTriangles)
numTriangles += face->numTriangles;
if(bspSurf->numTriangles)
numTriangles += bspSurf->numTriangles;
numSurfaces++;
}
else if(*surface->data == SF_GRID)
{
srfGridMesh_t *grid = (srfGridMesh_t *) surface->data;
break;
if(grid->numVerts)
numVerts += grid->numVerts;
if(grid->numTriangles)
numTriangles += grid->numTriangles;
numSurfaces++;
}
else if(*surface->data == SF_TRIANGLES)
{
srfTriangles_t *tri = (srfTriangles_t *) surface->data;
if(tri->numVerts)
numVerts += tri->numVerts;
if(tri->numTriangles)
numTriangles += tri->numTriangles;
numSurfaces++;
default:
break;
}
}
@ -1943,93 +1925,42 @@ static void R_CreateWorldVBOs(void)
numTriangles = 0;
for (currSurf = firstSurf; currSurf < lastSurf; currSurf++)
{
surface = *currSurf;
if(*surface->data == SF_FACE)
srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data;
switch (bspSurf->surfaceType)
{
srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data;
case SF_FACE:
case SF_GRID:
case SF_TRIANGLES:
bspSurf->firstIndex = numTriangles * 3;
srf->firstIndex = numTriangles * 3;
if(srf->numTriangles)
if(bspSurf->numTriangles)
{
srfTriangle_t *tri;
srf->minIndex = numVerts + srf->triangles->indexes[0];
srf->maxIndex = numVerts + srf->triangles->indexes[0];
bspSurf->minIndex = numVerts + bspSurf->triangles->indexes[0];
bspSurf->maxIndex = numVerts + bspSurf->triangles->indexes[0];
for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++)
for(i = 0, tri = bspSurf->triangles; i < bspSurf->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]);
bspSurf->minIndex = MIN(bspSurf->minIndex, numVerts + tri->indexes[j]);
bspSurf->maxIndex = MAX(bspSurf->maxIndex, numVerts + tri->indexes[j]);
}
}
numTriangles += srf->numTriangles;
numTriangles += bspSurf->numTriangles;
}
if(srf->numVerts)
numVerts += srf->numVerts;
}
else if(*surface->data == SF_GRID)
{
srfGridMesh_t *srf = (srfGridMesh_t *) surface->data;
if(bspSurf->numVerts)
numVerts += bspSurf->numVerts;
srf->firstIndex = numTriangles * 3;
break;
if(srf->numTriangles)
{
srfTriangle_t *tri;
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++)
{
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_TRIANGLES)
{
srfTriangles_t *srf = (srfTriangles_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];
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;
default:
break;
}
}
@ -2037,54 +1968,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;
srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data;
srf->firstVert = numVerts;
switch (bspSurf->surfaceType)
{
case SF_FACE:
case SF_GRID:
case SF_TRIANGLES:
bspSurf->firstVert = numVerts;
if(srf->numVerts)
if(bspSurf->numVerts)
{
for(i = 0; i < srf->numVerts; i++)
for(i = 0; i < bspSurf->numVerts; i++)
{
CopyVert(&srf->verts[i], &verts[numVerts + i]);
CopyVert(&bspSurf->verts[i], &verts[numVerts + i]);
}
numVerts += srf->numVerts;
}
}
else if(*surface->data == SF_GRID)
{
srfGridMesh_t *srf = (srfGridMesh_t *) surface->data;
srf->firstVert = numVerts;
if(srf->numVerts)
{
for(i = 0; i < srf->numVerts; i++)
{
CopyVert(&srf->verts[i], &verts[numVerts + i]);
numVerts += bspSurf->numVerts;
}
numVerts += srf->numVerts;
}
}
else if(*surface->data == SF_TRIANGLES)
{
srfTriangles_t *srf = (srfTriangles_t *) surface->data;
break;
srf->firstVert = numVerts;
if(srf->numVerts)
{
for(i = 0; i < srf->numVerts; i++)
{
CopyVert(&srf->verts[i], &verts[numVerts + i]);
}
numVerts += srf->numVerts;
}
default:
break;
}
}
@ -2103,36 +2009,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)
switch (bspSurf->surfaceType)
{
srf->vbo = vbo;
srf->ibo = ibo;
}
}
else if(*surface->data == SF_GRID)
case SF_FACE:
case SF_GRID:
case SF_TRIANGLES:
if( bspSurf->numVerts && bspSurf->numTriangles)
{
srfGridMesh_t *srf = (srfGridMesh_t *) surface->data;
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;
}
}
@ -2220,10 +2113,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);
@ -2240,13 +2133,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;
@ -3201,7 +3094,7 @@ void R_MergeLeafSurfaces(void)
int numVerts;
int firstIndex;
srfVBOMesh_t *vboSurf;
srfBspSurface_t *vboSurf;
if (s_worldData.surfacesViewCount[i] != i)
continue;
@ -3212,15 +3105,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:
@ -3235,42 +3122,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:
@ -3300,6 +3166,7 @@ void R_MergeLeafSurfaces(void)
for (j = 0; j < numWorldSurfaces; j++)
{
msurface_t *surf2;
srfBspSurface_t *bspSurf;
if (s_worldData.surfacesViewCount[j] != i)
continue;
@ -3309,54 +3176,19 @@ 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;
*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;
// never happens, but silences a compile warning
@ -3372,7 +3204,7 @@ void R_MergeLeafSurfaces(void)
vboSurf->vbo = vbo;
vboSurf->ibo = ibo;
vboSurf->numIndexes = numTriangles * 3;
vboSurf->numTriangles = numTriangles;
vboSurf->numVerts = numVerts;
vboSurf->firstIndex = firstIndex;
@ -3385,12 +3217,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]);
@ -3452,41 +3280,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)
switch(bspSurf->surfaceType)
{
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)
{
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;
}
}
}

View file

@ -25,14 +25,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] ) {
*/
@ -329,8 +329,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++)
{
@ -341,8 +339,6 @@ static int MakeMeshTriangles(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE
}
}
R_CalcSurfaceTrianglePlanes(numTriangles, triangles, ctrl2);
return numTriangles;
}
@ -420,13 +416,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 );
@ -468,23 +464,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;
}
@ -494,7 +490,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);
@ -507,7 +503,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 );
@ -690,7 +686,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];
@ -750,7 +746,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];

View file

@ -94,12 +94,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;
}
}
}

View file

@ -1028,13 +1028,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;
@ -1043,9 +1040,30 @@ typedef struct srfGridMesh_s
int pshadowBits;
// culling information
vec3_t meshBounds[2];
vec3_t localOrigin;
float meshRadius;
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;
// BSP VBO offsets
int firstVert;
int firstIndex;
glIndex_t minIndex;
glIndex_t maxIndex;
// static render data
VBO_t *vbo;
IBO_t *ibo;
// SF_GRID specific variables after here
// lod information, which may be different
// than the culling information to allow for
@ -1059,85 +1077,7 @@ typedef struct srfGridMesh_s
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];
// triangle definitions
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;
} 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;
// 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;
} srfTriangles_t;
} srfBspSurface_t;
// inter-quake-model
typedef struct {
@ -1174,33 +1114,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;
@ -2054,8 +1967,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
@ -2350,11 +2261,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 );
/*
============================================================
@ -2501,13 +2412,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 );
@ -2517,19 +2422,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 );
/*
=============================================================

View file

@ -492,99 +492,6 @@ qboolean R_CalcTangentVectors(srfVert_t * dv[3])
#endif
/*
=================
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
@ -1365,7 +1272,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;
@ -1377,10 +1284,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];

View file

@ -268,7 +268,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;
@ -327,7 +327,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
@ -407,10 +407,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;
}
@ -419,7 +419,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
@ -435,7 +435,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++)
{

View file

@ -562,8 +562,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);

View file

@ -522,7 +522,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 ) )
{
@ -1247,7 +1247,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 ) )
{
@ -1296,7 +1296,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;
@ -1574,9 +1574,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 );
}

View file

@ -208,16 +208,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 {
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 ) {
@ -292,16 +294,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 {
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 ) {