aboutsummaryrefslogtreecommitdiff
path: root/mp/src/utils/vrad/vraddisps.cpp
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-07-17 18:26:59 -0700
committerJoe Ludwig <[email protected]>2013-07-17 18:26:59 -0700
commite16ea21dc8a710237ade8413207f58d403c616a3 (patch)
tree85dcfbda9881e4e022dedafefbc2727e2fd2aa59 /mp/src/utils/vrad/vraddisps.cpp
parentMerge pull request #36 from AnAkIn1/fogplayerparams_fix (diff)
downloadsource-sdk-2013-e16ea21dc8a710237ade8413207f58d403c616a3.tar.xz
source-sdk-2013-e16ea21dc8a710237ade8413207f58d403c616a3.zip
* Added support for building shaders in your mod
* Added nav mesh support * fixed many warnings and misc bugs * Fixed the create*projects scripts in mp * Added a bunch of stuff to .gitignore
Diffstat (limited to 'mp/src/utils/vrad/vraddisps.cpp')
-rw-r--r--mp/src/utils/vrad/vraddisps.cpp44
1 files changed, 10 insertions, 34 deletions
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;
}