mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
OpenGL2: Preallocate grid surfaces like other BSP surfaces.
This commit is contained in:
parent
1cf0b21cda
commit
fe8ac838e2
3 changed files with 65 additions and 88 deletions
|
@ -822,7 +822,7 @@ ParseMesh
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf ) {
|
static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf ) {
|
||||||
srfBspSurface_t *grid;
|
srfBspSurface_t *grid = (srfBspSurface_t *)surf->data;
|
||||||
int i, j;
|
int i, j;
|
||||||
int width, height, numPoints;
|
int width, height, numPoints;
|
||||||
srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE];
|
srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE];
|
||||||
|
@ -903,8 +903,7 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors,
|
||||||
}
|
}
|
||||||
|
|
||||||
// pre-tesseleate
|
// pre-tesseleate
|
||||||
grid = R_SubdividePatchToGrid( width, height, points );
|
R_SubdividePatchToGrid( grid, width, height, points );
|
||||||
surf->data = (surfaceType_t *)grid;
|
|
||||||
|
|
||||||
// copy the level of detail origin, which is the center
|
// copy the level of detail origin, which is the center
|
||||||
// of the group of all curves that must subdivide the same
|
// of the group of all curves that must subdivide the same
|
||||||
|
@ -917,6 +916,12 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors,
|
||||||
VectorScale( bounds[1], 0.5f, grid->lodOrigin );
|
VectorScale( bounds[1], 0.5f, grid->lodOrigin );
|
||||||
VectorSubtract( bounds[0], grid->lodOrigin, tmpVec );
|
VectorSubtract( bounds[0], grid->lodOrigin, tmpVec );
|
||||||
grid->lodRadius = VectorLength( tmpVec );
|
grid->lodRadius = VectorLength( tmpVec );
|
||||||
|
|
||||||
|
surf->cullinfo.type = CULLINFO_BOX | CULLINFO_SPHERE;
|
||||||
|
VectorCopy(grid->cullBounds[0], surf->cullinfo.bounds[0]);
|
||||||
|
VectorCopy(grid->cullBounds[1], surf->cullinfo.bounds[1]);
|
||||||
|
VectorCopy(grid->cullOrigin, surf->cullinfo.localOrigin);
|
||||||
|
surf->cullinfo.radius = grid->cullRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1077,6 +1082,8 @@ static void ParseFlare( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int
|
||||||
flare->color[i] = LittleFloat( ds->lightmapVecs[0][i] );
|
flare->color[i] = LittleFloat( ds->lightmapVecs[0][i] );
|
||||||
flare->normal[i] = LittleFloat( ds->lightmapVecs[2][i] );
|
flare->normal[i] = LittleFloat( ds->lightmapVecs[2][i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
surf->cullinfo = CULLINFO_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1321,7 +1328,7 @@ int R_StitchPatches( int grid1num, int grid2num ) {
|
||||||
// insert column into grid2 right after after column l
|
// insert column into grid2 right after after column l
|
||||||
if (m) row = grid2->height-1;
|
if (m) row = grid2->height-1;
|
||||||
else row = 0;
|
else row = 0;
|
||||||
grid2 = R_GridInsertColumn( grid2, l+1, row,
|
R_GridInsertColumn( grid2, l+1, row,
|
||||||
grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]);
|
grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]);
|
||||||
grid2->lodStitched = qfalse;
|
grid2->lodStitched = qfalse;
|
||||||
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
||||||
|
@ -1365,7 +1372,7 @@ int R_StitchPatches( int grid1num, int grid2num ) {
|
||||||
// insert row into grid2 right after after row l
|
// insert row into grid2 right after after row l
|
||||||
if (m) column = grid2->width-1;
|
if (m) column = grid2->width-1;
|
||||||
else column = 0;
|
else column = 0;
|
||||||
grid2 = R_GridInsertRow( grid2, l+1, column,
|
R_GridInsertRow( grid2, l+1, column,
|
||||||
grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]);
|
grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]);
|
||||||
grid2->lodStitched = qfalse;
|
grid2->lodStitched = qfalse;
|
||||||
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
||||||
|
@ -1418,7 +1425,7 @@ int R_StitchPatches( int grid1num, int grid2num ) {
|
||||||
// insert column into grid2 right after after column l
|
// insert column into grid2 right after after column l
|
||||||
if (m) row = grid2->height-1;
|
if (m) row = grid2->height-1;
|
||||||
else row = 0;
|
else row = 0;
|
||||||
grid2 = R_GridInsertColumn( grid2, l+1, row,
|
R_GridInsertColumn( grid2, l+1, row,
|
||||||
grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]);
|
grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]);
|
||||||
grid2->lodStitched = qfalse;
|
grid2->lodStitched = qfalse;
|
||||||
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
||||||
|
@ -1462,7 +1469,7 @@ int R_StitchPatches( int grid1num, int grid2num ) {
|
||||||
// insert row into grid2 right after after row l
|
// insert row into grid2 right after after row l
|
||||||
if (m) column = grid2->width-1;
|
if (m) column = grid2->width-1;
|
||||||
else column = 0;
|
else column = 0;
|
||||||
grid2 = R_GridInsertRow( grid2, l+1, column,
|
R_GridInsertRow( grid2, l+1, column,
|
||||||
grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]);
|
grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]);
|
||||||
grid2->lodStitched = qfalse;
|
grid2->lodStitched = qfalse;
|
||||||
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
||||||
|
@ -1516,7 +1523,7 @@ int R_StitchPatches( int grid1num, int grid2num ) {
|
||||||
// insert column into grid2 right after after column l
|
// insert column into grid2 right after after column l
|
||||||
if (m) row = grid2->height-1;
|
if (m) row = grid2->height-1;
|
||||||
else row = 0;
|
else row = 0;
|
||||||
grid2 = R_GridInsertColumn( grid2, l+1, row,
|
R_GridInsertColumn( grid2, l+1, row,
|
||||||
grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]);
|
grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]);
|
||||||
grid2->lodStitched = qfalse;
|
grid2->lodStitched = qfalse;
|
||||||
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
||||||
|
@ -1560,7 +1567,7 @@ int R_StitchPatches( int grid1num, int grid2num ) {
|
||||||
// insert row into grid2 right after after row l
|
// insert row into grid2 right after after row l
|
||||||
if (m) column = grid2->width-1;
|
if (m) column = grid2->width-1;
|
||||||
else column = 0;
|
else column = 0;
|
||||||
grid2 = R_GridInsertRow( grid2, l+1, column,
|
R_GridInsertRow( grid2, l+1, column,
|
||||||
grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]);
|
grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]);
|
||||||
if (!grid2)
|
if (!grid2)
|
||||||
break;
|
break;
|
||||||
|
@ -1615,7 +1622,7 @@ int R_StitchPatches( int grid1num, int grid2num ) {
|
||||||
// insert column into grid2 right after after column l
|
// insert column into grid2 right after after column l
|
||||||
if (m) row = grid2->height-1;
|
if (m) row = grid2->height-1;
|
||||||
else row = 0;
|
else row = 0;
|
||||||
grid2 = R_GridInsertColumn( grid2, l+1, row,
|
R_GridInsertColumn( grid2, l+1, row,
|
||||||
grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]);
|
grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]);
|
||||||
grid2->lodStitched = qfalse;
|
grid2->lodStitched = qfalse;
|
||||||
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
||||||
|
@ -1659,7 +1666,7 @@ int R_StitchPatches( int grid1num, int grid2num ) {
|
||||||
// insert row into grid2 right after after row l
|
// insert row into grid2 right after after row l
|
||||||
if (m) column = grid2->width-1;
|
if (m) column = grid2->width-1;
|
||||||
else column = 0;
|
else column = 0;
|
||||||
grid2 = R_GridInsertRow( grid2, l+1, column,
|
R_GridInsertRow( grid2, l+1, column,
|
||||||
grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]);
|
grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]);
|
||||||
grid2->lodStitched = qfalse;
|
grid2->lodStitched = qfalse;
|
||||||
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
s_worldData.surfaces[grid2num].data = (void *) grid2;
|
||||||
|
@ -1749,37 +1756,37 @@ R_MovePatchSurfacesToHunk
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void R_MovePatchSurfacesToHunk(void) {
|
void R_MovePatchSurfacesToHunk(void) {
|
||||||
int i, size;
|
int i;
|
||||||
srfBspSurface_t *grid, *hunkgrid;
|
srfBspSurface_t *grid;
|
||||||
|
|
||||||
for ( i = 0; i < s_worldData.numsurfaces; i++ ) {
|
for ( i = 0; i < s_worldData.numsurfaces; i++ ) {
|
||||||
|
void *copyFrom;
|
||||||
//
|
//
|
||||||
grid = (srfBspSurface_t *) s_worldData.surfaces[i].data;
|
grid = (srfBspSurface_t *) s_worldData.surfaces[i].data;
|
||||||
// if this surface is not a grid
|
// if this surface is not a grid
|
||||||
if ( grid->surfaceType != SF_GRID )
|
if ( grid->surfaceType != SF_GRID )
|
||||||
continue;
|
continue;
|
||||||
//
|
//
|
||||||
size = sizeof(*grid);
|
|
||||||
hunkgrid = ri.Hunk_Alloc(size, h_low);
|
|
||||||
Com_Memcpy(hunkgrid, grid, size);
|
|
||||||
|
|
||||||
hunkgrid->widthLodError = ri.Hunk_Alloc( grid->width * 4, h_low );
|
copyFrom = grid->widthLodError;
|
||||||
Com_Memcpy( hunkgrid->widthLodError, grid->widthLodError, grid->width * 4 );
|
grid->widthLodError = ri.Hunk_Alloc( grid->width * 4, h_low );
|
||||||
|
Com_Memcpy(grid->widthLodError, copyFrom, grid->width * 4);
|
||||||
|
ri.Free(copyFrom);
|
||||||
|
|
||||||
hunkgrid->heightLodError = ri.Hunk_Alloc( grid->height * 4, h_low );
|
copyFrom = grid->heightLodError;
|
||||||
Com_Memcpy( hunkgrid->heightLodError, grid->heightLodError, grid->height * 4 );
|
grid->heightLodError = ri.Hunk_Alloc(grid->height * 4, h_low);
|
||||||
|
Com_Memcpy(grid->heightLodError, copyFrom, grid->height * 4);
|
||||||
|
ri.Free(copyFrom);
|
||||||
|
|
||||||
hunkgrid->numIndexes = grid->numIndexes;
|
copyFrom = grid->indexes;
|
||||||
hunkgrid->indexes = ri.Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low);
|
grid->indexes = ri.Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low);
|
||||||
Com_Memcpy(hunkgrid->indexes, grid->indexes, grid->numIndexes * sizeof(glIndex_t));
|
Com_Memcpy(grid->indexes, copyFrom, grid->numIndexes * sizeof(glIndex_t));
|
||||||
|
ri.Free(copyFrom);
|
||||||
|
|
||||||
hunkgrid->numVerts = grid->numVerts;
|
copyFrom = grid->verts;
|
||||||
hunkgrid->verts = ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low);
|
grid->verts = ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low);
|
||||||
Com_Memcpy(hunkgrid->verts, grid->verts, grid->numVerts * sizeof(srfVert_t));
|
Com_Memcpy(grid->verts, copyFrom, grid->numVerts * sizeof(srfVert_t));
|
||||||
|
ri.Free(copyFrom);
|
||||||
R_FreeSurfaceGridMesh( grid );
|
|
||||||
|
|
||||||
s_worldData.surfaces[i].data = (void *) hunkgrid;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2276,7 +2283,7 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) {
|
||||||
for ( i = 0 ; i < count ; i++, in++, out++ ) {
|
for ( i = 0 ; i < count ; i++, in++, out++ ) {
|
||||||
switch ( LittleLong( in->surfaceType ) ) {
|
switch ( LittleLong( in->surfaceType ) ) {
|
||||||
case MST_PATCH:
|
case MST_PATCH:
|
||||||
// FIXME: do this
|
out->data = ri.Hunk_Alloc( sizeof(srfBspSurface_t), h_low);
|
||||||
break;
|
break;
|
||||||
case MST_TRIANGLE_SOUP:
|
case MST_TRIANGLE_SOUP:
|
||||||
out->data = ri.Hunk_Alloc( sizeof(srfBspSurface_t), h_low);
|
out->data = ri.Hunk_Alloc( sizeof(srfBspSurface_t), h_low);
|
||||||
|
@ -2298,15 +2305,6 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) {
|
||||||
switch ( LittleLong( in->surfaceType ) ) {
|
switch ( LittleLong( in->surfaceType ) ) {
|
||||||
case MST_PATCH:
|
case MST_PATCH:
|
||||||
ParseMesh ( in, dv, hdrVertColors, out );
|
ParseMesh ( in, dv, hdrVertColors, out );
|
||||||
{
|
|
||||||
srfBspSurface_t *surface = (srfBspSurface_t *)out->data;
|
|
||||||
|
|
||||||
out->cullinfo.type = CULLINFO_BOX | CULLINFO_SPHERE;
|
|
||||||
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++;
|
numMeshes++;
|
||||||
break;
|
break;
|
||||||
case MST_TRIANGLE_SOUP:
|
case MST_TRIANGLE_SOUP:
|
||||||
|
@ -2319,9 +2317,6 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) {
|
||||||
break;
|
break;
|
||||||
case MST_FLARE:
|
case MST_FLARE:
|
||||||
ParseFlare( in, dv, out, indexes );
|
ParseFlare( in, dv, out, indexes );
|
||||||
{
|
|
||||||
out->cullinfo.type = CULLINFO_NONE;
|
|
||||||
}
|
|
||||||
numFlares++;
|
numFlares++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -254,14 +254,11 @@ static void MakeMeshTangentVectors(int width, int height, srfVert_t ctrl[MAX_GRI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int MakeMeshIndexes(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE],
|
static int MakeMeshIndexes(int width, int height, glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3])
|
||||||
glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3])
|
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int numIndexes;
|
int numIndexes;
|
||||||
int w, h;
|
int w, h;
|
||||||
srfVert_t *dv;
|
|
||||||
static srfVert_t ctrl2[MAX_GRID_SIZE * MAX_GRID_SIZE];
|
|
||||||
|
|
||||||
h = height - 1;
|
h = height - 1;
|
||||||
w = width - 1;
|
w = width - 1;
|
||||||
|
@ -288,16 +285,6 @@ static int MakeMeshIndexes(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: use more elegant way
|
|
||||||
for(i = 0; i < width; i++)
|
|
||||||
{
|
|
||||||
for(j = 0; j < height; j++)
|
|
||||||
{
|
|
||||||
dv = &ctrl2[j * width + i];
|
|
||||||
*dv = ctrl[j][i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return numIndexes;
|
return numIndexes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,21 +362,17 @@ static void PutPointsOnCurve( srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE],
|
||||||
R_CreateSurfaceGridMesh
|
R_CreateSurfaceGridMesh
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height,
|
void R_CreateSurfaceGridMesh(srfBspSurface_t *grid, int width, int height,
|
||||||
srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], float errorTable[2][MAX_GRID_SIZE],
|
srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], float errorTable[2][MAX_GRID_SIZE],
|
||||||
int numIndexes, glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]) {
|
int numIndexes, glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]) {
|
||||||
int i, j, size;
|
int i, j;
|
||||||
srfVert_t *vert;
|
srfVert_t *vert;
|
||||||
vec3_t tmpVec;
|
vec3_t tmpVec;
|
||||||
srfBspSurface_t *grid;
|
|
||||||
|
|
||||||
// copy the results out to a grid
|
// copy the results out to a grid
|
||||||
size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid );
|
Com_Memset(grid, 0, sizeof(*grid));
|
||||||
|
|
||||||
#ifdef PATCH_STITCHING
|
#ifdef PATCH_STITCHING
|
||||||
grid = /*ri.Hunk_Alloc*/ ri.Malloc( size );
|
|
||||||
Com_Memset(grid, 0, size);
|
|
||||||
|
|
||||||
grid->widthLodError = /*ri.Hunk_Alloc*/ ri.Malloc( width * 4 );
|
grid->widthLodError = /*ri.Hunk_Alloc*/ ri.Malloc( width * 4 );
|
||||||
Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 );
|
Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 );
|
||||||
|
|
||||||
|
@ -403,9 +386,6 @@ srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height,
|
||||||
grid->numVerts = (width * height);
|
grid->numVerts = (width * height);
|
||||||
grid->verts = ri.Malloc(grid->numVerts * sizeof(srfVert_t));
|
grid->verts = ri.Malloc(grid->numVerts * sizeof(srfVert_t));
|
||||||
#else
|
#else
|
||||||
grid = ri.Hunk_Alloc( size );
|
|
||||||
Com_Memset(grid, 0, size);
|
|
||||||
|
|
||||||
grid->widthLodError = ri.Hunk_Alloc( width * 4 );
|
grid->widthLodError = ri.Hunk_Alloc( width * 4 );
|
||||||
Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 );
|
Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 );
|
||||||
|
|
||||||
|
@ -441,7 +421,6 @@ srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height,
|
||||||
VectorCopy( grid->cullOrigin, grid->lodOrigin );
|
VectorCopy( grid->cullOrigin, grid->lodOrigin );
|
||||||
grid->lodRadius = grid->cullRadius;
|
grid->lodRadius = grid->cullRadius;
|
||||||
//
|
//
|
||||||
return grid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -449,12 +428,11 @@ srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height,
|
||||||
R_FreeSurfaceGridMesh
|
R_FreeSurfaceGridMesh
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
void R_FreeSurfaceGridMesh( srfBspSurface_t *grid ) {
|
void R_FreeSurfaceGridMeshData( srfBspSurface_t *grid ) {
|
||||||
ri.Free(grid->widthLodError);
|
ri.Free(grid->widthLodError);
|
||||||
ri.Free(grid->heightLodError);
|
ri.Free(grid->heightLodError);
|
||||||
ri.Free(grid->indexes);
|
ri.Free(grid->indexes);
|
||||||
ri.Free(grid->verts);
|
ri.Free(grid->verts);
|
||||||
ri.Free(grid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -462,7 +440,7 @@ void R_FreeSurfaceGridMesh( srfBspSurface_t *grid ) {
|
||||||
R_SubdividePatchToGrid
|
R_SubdividePatchToGrid
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
srfBspSurface_t *R_SubdividePatchToGrid( int width, int height,
|
void R_SubdividePatchToGrid( srfBspSurface_t *grid, int width, int height,
|
||||||
srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) {
|
srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) {
|
||||||
int i, j, k, l;
|
int i, j, k, l;
|
||||||
srfVert_t_cleared( prev );
|
srfVert_t_cleared( prev );
|
||||||
|
@ -629,7 +607,7 @@ srfBspSurface_t *R_SubdividePatchToGrid( int width, int height,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// calculate indexes
|
// calculate indexes
|
||||||
numIndexes = MakeMeshIndexes(width, height, ctrl, indexes);
|
numIndexes = MakeMeshIndexes(width, height, indexes);
|
||||||
|
|
||||||
// calculate normals
|
// calculate normals
|
||||||
MakeMeshNormals( width, height, ctrl );
|
MakeMeshNormals( width, height, ctrl );
|
||||||
|
@ -637,7 +615,7 @@ srfBspSurface_t *R_SubdividePatchToGrid( int width, int height,
|
||||||
MakeMeshTangentVectors(width, height, ctrl, numIndexes, indexes);
|
MakeMeshTangentVectors(width, height, ctrl, numIndexes, indexes);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numIndexes, indexes);
|
R_CreateSurfaceGridMesh(grid, width, height, ctrl, errorTable, numIndexes, indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -645,7 +623,7 @@ srfBspSurface_t *R_SubdividePatchToGrid( int width, int height,
|
||||||
R_GridInsertColumn
|
R_GridInsertColumn
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
srfBspSurface_t *R_GridInsertColumn( srfBspSurface_t *grid, int column, int row, vec3_t point, float loderror ) {
|
void R_GridInsertColumn( srfBspSurface_t *grid, int column, int row, vec3_t point, float loderror ) {
|
||||||
int i, j;
|
int i, j;
|
||||||
int width, height, oldwidth;
|
int width, height, oldwidth;
|
||||||
srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE];
|
srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE];
|
||||||
|
@ -658,7 +636,7 @@ srfBspSurface_t *R_GridInsertColumn( srfBspSurface_t *grid, int column, int row,
|
||||||
oldwidth = 0;
|
oldwidth = 0;
|
||||||
width = grid->width + 1;
|
width = grid->width + 1;
|
||||||
if (width > MAX_GRID_SIZE)
|
if (width > MAX_GRID_SIZE)
|
||||||
return NULL;
|
return;
|
||||||
height = grid->height;
|
height = grid->height;
|
||||||
for (i = 0; i < width; i++) {
|
for (i = 0; i < width; i++) {
|
||||||
if (i == column) {
|
if (i == column) {
|
||||||
|
@ -684,20 +662,22 @@ srfBspSurface_t *R_GridInsertColumn( srfBspSurface_t *grid, int column, int row,
|
||||||
//PutPointsOnCurve( ctrl, width, height );
|
//PutPointsOnCurve( ctrl, width, height );
|
||||||
|
|
||||||
// calculate indexes
|
// calculate indexes
|
||||||
numIndexes = MakeMeshIndexes(width, height, ctrl, indexes);
|
numIndexes = MakeMeshIndexes(width, height, indexes);
|
||||||
|
|
||||||
// calculate normals
|
// calculate normals
|
||||||
MakeMeshNormals( width, height, ctrl );
|
MakeMeshNormals( width, height, ctrl );
|
||||||
|
#ifdef USE_VERT_TANGENT_SPACE
|
||||||
|
MakeMeshTangentVectors(width, height, ctrl, numIndexes, indexes);
|
||||||
|
#endif
|
||||||
|
|
||||||
VectorCopy(grid->lodOrigin, lodOrigin);
|
VectorCopy(grid->lodOrigin, lodOrigin);
|
||||||
lodRadius = grid->lodRadius;
|
lodRadius = grid->lodRadius;
|
||||||
// free the old grid
|
// free the old grid
|
||||||
R_FreeSurfaceGridMesh(grid);
|
R_FreeSurfaceGridMeshData(grid);
|
||||||
// create a new grid
|
// create a new grid
|
||||||
grid = R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numIndexes, indexes);
|
R_CreateSurfaceGridMesh(grid, width, height, ctrl, errorTable, numIndexes, indexes);
|
||||||
grid->lodRadius = lodRadius;
|
grid->lodRadius = lodRadius;
|
||||||
VectorCopy(lodOrigin, grid->lodOrigin);
|
VectorCopy(lodOrigin, grid->lodOrigin);
|
||||||
return grid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -705,7 +685,7 @@ srfBspSurface_t *R_GridInsertColumn( srfBspSurface_t *grid, int column, int row,
|
||||||
R_GridInsertRow
|
R_GridInsertRow
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
srfBspSurface_t *R_GridInsertRow( srfBspSurface_t *grid, int row, int column, vec3_t point, float loderror ) {
|
void R_GridInsertRow( srfBspSurface_t *grid, int row, int column, vec3_t point, float loderror ) {
|
||||||
int i, j;
|
int i, j;
|
||||||
int width, height, oldheight;
|
int width, height, oldheight;
|
||||||
srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE];
|
srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE];
|
||||||
|
@ -719,7 +699,7 @@ srfBspSurface_t *R_GridInsertRow( srfBspSurface_t *grid, int row, int column, ve
|
||||||
width = grid->width;
|
width = grid->width;
|
||||||
height = grid->height + 1;
|
height = grid->height + 1;
|
||||||
if (height > MAX_GRID_SIZE)
|
if (height > MAX_GRID_SIZE)
|
||||||
return NULL;
|
return;
|
||||||
for (i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
if (i == row) {
|
if (i == row) {
|
||||||
//insert new row
|
//insert new row
|
||||||
|
@ -744,18 +724,20 @@ srfBspSurface_t *R_GridInsertRow( srfBspSurface_t *grid, int row, int column, ve
|
||||||
//PutPointsOnCurve( ctrl, width, height );
|
//PutPointsOnCurve( ctrl, width, height );
|
||||||
|
|
||||||
// calculate indexes
|
// calculate indexes
|
||||||
numIndexes = MakeMeshIndexes(width, height, ctrl, indexes);
|
numIndexes = MakeMeshIndexes(width, height, indexes);
|
||||||
|
|
||||||
// calculate normals
|
// calculate normals
|
||||||
MakeMeshNormals( width, height, ctrl );
|
MakeMeshNormals( width, height, ctrl );
|
||||||
|
#ifdef USE_VERT_TANGENT_SPACE
|
||||||
|
MakeMeshTangentVectors(width, height, ctrl, numIndexes, indexes);
|
||||||
|
#endif
|
||||||
|
|
||||||
VectorCopy(grid->lodOrigin, lodOrigin);
|
VectorCopy(grid->lodOrigin, lodOrigin);
|
||||||
lodRadius = grid->lodRadius;
|
lodRadius = grid->lodRadius;
|
||||||
// free the old grid
|
// free the old grid
|
||||||
R_FreeSurfaceGridMesh(grid);
|
R_FreeSurfaceGridMeshData(grid);
|
||||||
// create a new grid
|
// create a new grid
|
||||||
grid = R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numIndexes, indexes);
|
R_CreateSurfaceGridMesh(grid, width, height, ctrl, errorTable, numIndexes, indexes);
|
||||||
grid->lodRadius = lodRadius;
|
grid->lodRadius = lodRadius;
|
||||||
VectorCopy(lodOrigin, grid->lodOrigin);
|
VectorCopy(lodOrigin, grid->lodOrigin);
|
||||||
return grid;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2152,10 +2152,10 @@ CURVE TESSELATION
|
||||||
|
|
||||||
#define PATCH_STITCHING
|
#define PATCH_STITCHING
|
||||||
|
|
||||||
srfBspSurface_t *R_SubdividePatchToGrid( int width, int height,
|
void R_SubdividePatchToGrid( srfBspSurface_t *grid, int width, int height,
|
||||||
srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] );
|
srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] );
|
||||||
srfBspSurface_t *R_GridInsertColumn( srfBspSurface_t *grid, int column, int row, vec3_t point, float loderror );
|
void 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_GridInsertRow( srfBspSurface_t *grid, int row, int column, vec3_t point, float loderror );
|
||||||
void R_FreeSurfaceGridMesh( srfBspSurface_t *grid );
|
void R_FreeSurfaceGridMesh( srfBspSurface_t *grid );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue