diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index d5d4527148..1a6b152a30 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -59,7 +59,7 @@ void Actor::Reset() m_bTextureWrapping = false; m_BlendMode = BLEND_NORMAL; m_bClearZBuffer = false; - m_bZTest = false; + m_ZTestMode = ZTEST_OFF; m_bZWrite = false; m_CullMode = CULL_NONE; } @@ -228,7 +228,7 @@ void Actor::SetRenderStates() DISPLAY->SetTextureWrapping( m_bTextureWrapping ); DISPLAY->SetBlendMode( m_BlendMode ); DISPLAY->SetZWrite( m_bZWrite ); - DISPLAY->SetZTest( m_bZTest ); + DISPLAY->SetZTestMode( m_ZTestMode ); if( m_bClearZBuffer ) DISPLAY->ClearZBuffer(); DISPLAY->SetCullMode( m_CullMode ); @@ -730,6 +730,7 @@ void Actor::HandleCommand( const ParsedCommand &command ) else if( sName=="blend" ) SetBlendMode( sParam(1) ); else if( sName=="zbuffer" ) SetUseZBuffer( bParam(1) ); else if( sName=="ztest" ) SetZTest( bParam(1) ); + else if( sName=="ztestmode" ) SetZTestMode( sParam(1) ); else if( sName=="zwrite" ) SetZWrite( bParam(1) ); else if( sName=="clearzbuffer" ) SetClearZBuffer( bParam(1) ); else if( sName=="backfacecull" ) SetCullMode( bParam(1) ? CULL_BACK : CULL_NONE ); @@ -884,6 +885,20 @@ void Actor::SetCullMode( CString s ) else ASSERT(0); } +void Actor::SetZTestMode( CString s ) +{ + s.MakeLower(); + + // for metrics backward compatibility + if (s=="1") SetZTestMode( ZTEST_WRITE_ON_PASS ); + else if(s=="0") SetZTestMode( ZTEST_OFF ); + + else if(s=="off") SetZTestMode( ZTEST_OFF ); + else if(s=="writeonpass") SetZTestMode( ZTEST_WRITE_ON_PASS ); + else if(s=="writeonfail") SetZTestMode( ZTEST_WRITE_ON_FAIL ); + else ASSERT(0); +} + void Actor::CopyTweening( const Actor &from ) { m_current = from.m_current; diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 5000dbca88..1237d01593 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -297,8 +297,10 @@ public: void SetBlendMode( CString ); void SetTextureWrapping( bool b ) { m_bTextureWrapping = b; } void SetClearZBuffer( bool b ) { m_bClearZBuffer = b; } - void SetUseZBuffer( bool b ) { SetZTest(b); SetZWrite(b); } - virtual void SetZTest( bool b ) { m_bZTest = b; } + void SetUseZBuffer( bool b ) { SetZTestMode(b?ZTEST_WRITE_ON_PASS:ZTEST_OFF); SetZWrite(b); } + virtual void SetZTestMode( ZTestMode mode ) { m_ZTestMode = mode; } + virtual void SetZTestMode( CString ); + void SetZTest( bool b ) { SetZTestMode(b?ZTEST_WRITE_ON_PASS:ZTEST_OFF); } virtual void SetZWrite( bool b ) { m_bZWrite = b; } virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; } virtual void SetCullMode( CString ); @@ -387,10 +389,11 @@ protected: // // render states // - bool m_bTextureWrapping; + bool m_bTextureWrapping; BlendMode m_BlendMode; - bool m_bClearZBuffer; - bool m_bZTest, m_bZWrite; + bool m_bClearZBuffer; + ZTestMode m_ZTestMode; + bool m_bZWrite; CullMode m_CullMode; }; diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index ee86ed9bf6..77313ea7f7 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -103,7 +103,7 @@ void ActorFrame::Update( float fDeltaTime ) } PropagateActorFrameCommand( SetDiffuse, RageColor ) -PropagateActorFrameCommand( SetZTest, bool ) +PropagateActorFrameCommand( SetZTestMode, ZTestMode ) PropagateActorFrameCommand( SetZWrite, bool ) PropagateActorFrameCommand( HurryTweening, float ) diff --git a/stepmania/src/ActorFrame.h b/stepmania/src/ActorFrame.h index 8284f81942..d0dfeff187 100644 --- a/stepmania/src/ActorFrame.h +++ b/stepmania/src/ActorFrame.h @@ -35,7 +35,7 @@ public: virtual void SetDiffuse( RageColor c ); virtual void SetDiffuseAlpha( float f ); - virtual void SetZTest( bool b ); + virtual void SetZTestMode( ZTestMode mode ); virtual void SetZWrite( bool b ); virtual void FinishTweening(); virtual void HurryTweening( float factor ); diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 88e5edd47c..ebc691e8c5 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -195,7 +195,8 @@ public: virtual bool IsZTestEnabled() const = 0; virtual bool IsZWriteEnabled() const = 0; virtual void SetZWrite( bool b ) = 0; - virtual void SetZTest( bool b ) = 0; + void SetZTest( bool b ) { SetZTestMode(b?ZTEST_WRITE_ON_PASS:ZTEST_OFF); } + virtual void SetZTestMode( ZTestMode mode ) = 0; virtual void ClearZBuffer() = 0; void SetZBuffer( bool b ) { SetZWrite(b); SetZTest(b); } // shortcut diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index dcc9ae7201..a09f6341d6 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -1045,10 +1045,17 @@ void RageDisplay_D3D::SetZWrite( bool b ) g_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, b ); } -void RageDisplay_D3D::SetZTest( bool b ) +void RageDisplay_D3D::SetZTestMode( ZTestMode mode ) { g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); - g_pd3dDevice->SetRenderState( D3DRS_ZFUNC, b ? D3DCMP_LESSEQUAL : D3DCMP_ALWAYS ); + DWORD dw; + switch( mode ) + { + case ZTEST_OFF: dw = D3DCMP_ALWAYS; break; + case ZTEST_WRITE_ON_PASS: dw = D3DCMP_LESSEQUAL; break; + case ZTEST_WRITE_ON_FAIL: dw = D3DCMP_GREATER; break; + default: ASSERT( 0 ); + } } void RageDisplay_D3D::ClearZBuffer() diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index 516f6c0bcc..ef60c807f4 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -54,6 +54,7 @@ public: bool IsZTestEnabled() const; void SetZWrite( bool b ); void SetZTest( bool b ); + void SetZTestMode( ZTestMode mode ); void ClearZBuffer(); void SetCullMode( CullMode mode ); void SetAlphaTest( bool b ); diff --git a/stepmania/src/RageDisplay_Null.h b/stepmania/src/RageDisplay_Null.h index 84da350bab..6639efb4d8 100644 --- a/stepmania/src/RageDisplay_Null.h +++ b/stepmania/src/RageDisplay_Null.h @@ -41,7 +41,7 @@ public: bool IsZWriteEnabled() const { return false; } bool IsZTestEnabled() const { return false; } void SetZWrite( bool b ) { } - void SetZTest( bool b ) { } + void SetZTestMode( ZTestMode mode ) { } void ClearZBuffer() { } void SetCullMode( CullMode mode ) { } void SetAlphaTest( bool b ) { } diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 4f7fca354e..da03bc7b0a 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -1480,13 +1480,16 @@ void RageDisplay_OGL::SetZWrite( bool b ) glDepthMask( b ); } -void RageDisplay_OGL::SetZTest( bool b ) +void RageDisplay_OGL::SetZTestMode( ZTestMode mode ) { glEnable( GL_DEPTH_TEST ); - if( b ) - glDepthFunc( GL_LEQUAL ); - else - glDepthFunc( GL_ALWAYS ); + switch( mode ) + { + case ZTEST_OFF: glDepthFunc( GL_ALWAYS ); break; + case ZTEST_WRITE_ON_PASS: glDepthFunc( GL_LEQUAL ); break; + case ZTEST_WRITE_ON_FAIL: glDepthFunc( GL_GREATER ); break; + default: ASSERT( 0 ); + } } void RageDisplay_OGL::SetTextureWrapping( bool b ) diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index c2f8d8a20d..a2e458c877 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -43,6 +43,7 @@ public: bool IsZTestEnabled() const; void SetZWrite( bool b ); void SetZTest( bool b ); + void SetZTestMode( ZTestMode mode ); void ClearZBuffer(); void SetCullMode( CullMode mode ); void SetAlphaTest( bool b ); diff --git a/stepmania/src/RageTypes.h b/stepmania/src/RageTypes.h index ec5a14ca11..8d95fbdf92 100644 --- a/stepmania/src/RageTypes.h +++ b/stepmania/src/RageTypes.h @@ -8,6 +8,7 @@ enum GlowMode { GLOW_BRIGHTEN, GLOW_WHITEN }; enum BlendMode { BLEND_NORMAL, BLEND_ADD, BLEND_NO_EFFECT, BLEND_INVALID }; enum CullMode { CULL_BACK, CULL_FRONT, CULL_NONE }; +enum ZTestMode { ZTEST_OFF, ZTEST_WRITE_ON_PASS, ZTEST_WRITE_ON_FAIL }; struct RageVector2