diff options
Diffstat (limited to 'mp/src/utils')
| -rw-r--r-- | mp/src/utils/vrad/lightmap.cpp | 5 | ||||
| -rw-r--r-- | mp/src/utils/vrad/trace.cpp | 11 | ||||
| -rw-r--r-- | mp/src/utils/vrad/vrad_dispcoll.cpp | 4 | ||||
| -rw-r--r-- | mp/src/utils/vrad/vraddisps.cpp | 44 |
4 files changed, 25 insertions, 39 deletions
diff --git a/mp/src/utils/vrad/lightmap.cpp b/mp/src/utils/vrad/lightmap.cpp index b6f8c1f7..bc3d254e 100644 --- a/mp/src/utils/vrad/lightmap.cpp +++ b/mp/src/utils/vrad/lightmap.cpp @@ -661,8 +661,9 @@ bool BuildFacesamples( lightinfo_t *pLightInfo, facelight_t *pFaceLight ) pTex->lightmapVecsLuxelsPerWorldUnits[1] ) ) );
// allocate a large number of samples for creation -- get copied later!
- char sampleData[sizeof(sample_t)*SINGLE_BRUSH_MAP*2];
- sample_t *samples = (sample_t*)sampleData; // use a char array to speed up the debug version.
+ CUtlVector<sample_t> sampleData;
+ sampleData.SetCount( SINGLE_BRUSH_MAP * 2 );
+ sample_t *samples = sampleData.Base();
sample_t *pSamples = samples;
// lightmap space winding
diff --git a/mp/src/utils/vrad/trace.cpp b/mp/src/utils/vrad/trace.cpp index f049fc40..8069dbe7 100644 --- a/mp/src/utils/vrad/trace.cpp +++ b/mp/src/utils/vrad/trace.cpp @@ -622,14 +622,23 @@ void AddBrushesForRayTrace( void ) for ( int j = 0; j < face->numedges; j++ )
{
+ if ( j >= MAX_POINTS_ON_WINDING )
+ Error( "***** ERROR! MAX_POINTS_ON_WINDING reached!" );
+
+ if ( face->firstedge + j >= ARRAYSIZE( dsurfedges ) )
+ Error( "***** ERROR! face->firstedge + j >= ARRAYSIZE( dsurfedges )!" );
+
int surfEdge = dsurfedges[face->firstedge + j];
- short v;
+ unsigned short v;
if (surfEdge < 0)
v = dedges[-surfEdge].v[1];
else
v = dedges[surfEdge].v[0];
+ if ( v >= ARRAYSIZE( dvertexes ) )
+ Error( "***** ERROR! v(%u) >= ARRAYSIZE( dvertexes(%d) )!", ( unsigned int )v, ARRAYSIZE( dvertexes ) );
+
dvertex_t *dv = &dvertexes[v];
points[j] = dv->point;
}
diff --git a/mp/src/utils/vrad/vrad_dispcoll.cpp b/mp/src/utils/vrad/vrad_dispcoll.cpp index df69a4ac..7e788d07 100644 --- a/mp/src/utils/vrad/vrad_dispcoll.cpp +++ b/mp/src/utils/vrad/vrad_dispcoll.cpp @@ -665,8 +665,8 @@ void CVRADDispColl::CreateChildPatchesSub( int iParentPatch ) // Split along the longest edge.
Vector vecEdges[3];
vecEdges[0] = pParentPatch->winding->p[1] - pParentPatch->winding->p[0];
- vecEdges[1] = pParentPatch->winding->p[2] - pParentPatch->winding->p[0];
- vecEdges[2] = pParentPatch->winding->p[2] - pParentPatch->winding->p[1];
+ vecEdges[1] = pParentPatch->winding->p[2] - pParentPatch->winding->p[1];
+ vecEdges[2] = pParentPatch->winding->p[0] - pParentPatch->winding->p[2];
// Find the longest edge.
float flEdgeLength = 0.0f;
diff --git a/mp/src/utils/vrad/vraddisps.cpp b/mp/src/utils/vrad/vraddisps.cpp index 1e8d2606..0bbafd40 100644 --- a/mp/src/utils/vrad/vraddisps.cpp +++ b/mp/src/utils/vrad/vraddisps.cpp @@ -1135,7 +1135,7 @@ void AddPatchLightToRadial( Vector const &patchOrigin, Vector const &patchNormal if( bNeighborBump )
{
float flScale = patchNormal.Dot( normals[0] );
- flScale = clamp( flScale, 0.0f, flScale );
+ flScale = max( 0.0f, flScale );
float flBumpInfluence = influence * flScale;
for( int ndxBump = 0; ndxBump < ( NUM_BUMP_VECTS+1 ); ndxBump++ )
@@ -1148,7 +1148,7 @@ void AddPatchLightToRadial( Vector const &patchOrigin, Vector const &patchNormal else
{
float flScale = patchNormal.Dot( normals[0] );
- flScale = clamp( flScale, 0.0f, flScale );
+ flScale = max( 0.0f, flScale );
float flBumpInfluence = influence * flScale * 0.05f;
for( int ndxBump = 0; ndxBump < ( NUM_BUMP_VECTS+1 ); ndxBump++ )
@@ -1162,7 +1162,7 @@ void AddPatchLightToRadial( Vector const &patchOrigin, Vector const &patchNormal else
{
float flScale = patchNormal.Dot( luxelNormal );
- flScale = clamp( flScale, 0.0f, flScale );
+ flScale = max( 0.0f, flScale );
influence *= flScale;
pRadial->light[0][ndxRadial].AddWeighted( pPatchLight[0], influence );
@@ -1580,21 +1580,13 @@ bool CVRadDispMgr::BuildDispSamples( lightinfo_t *pLightInfo, facelight_t *pFace //
int ndxU, ndxV;
- // NOTE: These allocations are necessary to avoid stack overflow
- // FIXME: Solve with storing global per-thread temp buffers if there's
- // a performance problem with this solution...
- bool bTempAllocationNecessary = ((height + 1) * (width + 1)) > SINGLE_BRUSH_MAP;
+ CUtlVector<sample_t> samples;
+ samples.SetCount( SINGLEMAP );
+ sample_t *pSamples = samples.Base();
- Vector worldPointBuffer[SINGLE_BRUSH_MAP];
- sample_t sampleBuffer[SINGLE_BRUSH_MAP*2];
-
- Vector *pWorldPoints = worldPointBuffer;
- sample_t *pSamples = sampleBuffer;
- if (bTempAllocationNecessary)
- {
- pWorldPoints = new Vector[ SINGLEMAP ];
- pSamples = new sample_t[ SINGLEMAP ];
- }
+ CUtlVector<Vector> worldPoints;
+ worldPoints.SetCount( SINGLEMAP );
+ Vector *pWorldPoints = worldPoints.Base();
for( ndxV = 0; ndxV < ( height + 1 ); ndxV++ )
{
@@ -1607,7 +1599,6 @@ bool CVRadDispMgr::BuildDispSamples( lightinfo_t *pLightInfo, facelight_t *pFace }
}
-
for( ndxV = 0; ndxV < height; ndxV++ )
{
for( ndxU = 0; ndxU < width; ndxU++ )
@@ -1660,7 +1651,7 @@ bool CVRadDispMgr::BuildDispSamples( lightinfo_t *pLightInfo, facelight_t *pFace pFaceLight->numsamples = width * height;
pFaceLight->sample = ( sample_t* )calloc( pFaceLight->numsamples, sizeof( *pFaceLight->sample ) );
if( !pFaceLight->sample )
- goto buildDispSamplesError;
+ return false;
memcpy( pFaceLight->sample, pSamples, pFaceLight->numsamples * sizeof( *pFaceLight->sample ) );
@@ -1669,23 +1660,8 @@ bool CVRadDispMgr::BuildDispSamples( lightinfo_t *pLightInfo, facelight_t *pFace {
Msg( "BuildDispSamples: WARNING - no samples %d\n", pLightInfo->face - g_pFaces );
}
-
- if (bTempAllocationNecessary)
- {
- delete[] pWorldPoints;
- delete[] pSamples;
- }
return true;
-
-buildDispSamplesError:
- if (bTempAllocationNecessary)
- {
- delete[] pWorldPoints;
- delete[] pSamples;
- }
-
- return false;
}
|