From: <jww...@us...> - 2010-10-07 00:19:51
|
Revision: 3113 http://quesa.svn.sourceforge.net/quesa/?rev=3113&view=rev Author: jwwalker Date: 2010-10-07 00:19:44 +0000 (Thu, 07 Oct 2010) Log Message: ----------- Correct casting of shadows when using kQ3BackfacingStyleRemoveFront. Modified Paths: -------------- trunk/quesa/Development/Source/Renderers/OpenGL/QOShadowMarker.cpp Modified: trunk/quesa/Development/Source/Renderers/OpenGL/QOShadowMarker.cpp =================================================================== --- trunk/quesa/Development/Source/Renderers/OpenGL/QOShadowMarker.cpp 2010-10-05 23:33:11 UTC (rev 3112) +++ trunk/quesa/Development/Source/Renderers/OpenGL/QOShadowMarker.cpp 2010-10-07 00:19:44 UTC (rev 3113) @@ -217,7 +217,29 @@ +static bool IsFaceVisible( TQ3BackfacingStyle inBackfacing, bool inFrontFace ) +{ + bool isVis = true; + + if (inBackfacing == kQ3BackfacingStyleRemove) + { + if (! inFrontFace) + { + isVis = false; + } + } + else if (inBackfacing == kQ3BackfacingStyleRemoveFront) + { + if (inFrontFace) + { + isVis = false; + } + } + + return isVis; +} + /*! @function MarkShadowOfTriMeshDirectional @abstract Mark the shadow of a TriMesh by a directional light. @@ -278,8 +300,7 @@ TQ3Uns32 e; for (i = 0; i < kNumFaces; ++i) { - if ( (mStyleState.mBackfacing != kQ3BackfacingStyleRemove) || - litFaceFlags[i] ) + if ( IsFaceVisible( mStyleState.mBackfacing, litFaceFlags[i] ) ) { const TQ3TriMeshTriangleData& theFace( inFaces[i] ); @@ -409,8 +430,7 @@ TQ3Uns32 e; for (i = 0; i < kNumFaces; ++i) { - if ( (mStyleState.mBackfacing != kQ3BackfacingStyleRemove) || - litFaceFlags[i] ) + if ( IsFaceVisible( mStyleState.mBackfacing, litFaceFlags[i] ) ) { const TQ3TriMeshTriangleData& theFace( inFaces[i] ); @@ -559,7 +579,7 @@ // If the triangle is away from the light and we are removing backfaces, // then the triangle should be invisible from the light and hence not cast // a shadow. - if ( (towardLight < 0.0f) && (mStyleState.mBackfacing == kQ3BackfacingStyleRemove) ) + if ( ! IsFaceVisible( mStyleState.mBackfacing, towardLight > 0.0f )) { return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |