Bläddra i källkod

Optimizing the shadow mapping checks

Panagiotis Christopoulos Charitos 10 år sedan
förälder
incheckning
4829cef27b
2 ändrade filer med 9 tillägg och 3 borttagningar
  1. 8 2
      src/renderer/Sm.cpp
  2. 1 1
      testapp/Main.cpp

+ 8 - 2
src/renderer/Sm.cpp

@@ -167,8 +167,9 @@ Bool Sm::skip(SceneNode& light, ShadowmapBase& sm)
 {
 	Timestamp lastUpdate = light.getComponent<MoveComponent>().getTimestamp();
 
+	Bool shouldUpdate = false;
 	Error err = light.iterateComponentsOfType<FrustumComponent>(
-		[&lastUpdate](FrustumComponent& fr)
+		[&](FrustumComponent& fr)
 	{
 		lastUpdate = max(lastUpdate, fr.getTimestamp());
 		VisibilityTestResults& vi = fr.getVisibilityTestResults();
@@ -196,13 +197,18 @@ Bool Sm::skip(SceneNode& light, ShadowmapBase& sm)
 			{
 				lastUpdate = max(lastUpdate, sp->getTimestamp());
 			}
+
+			if(lastUpdate >= sm.m_timestamp)
+			{
+				shouldUpdate = true;
+				break;
+			}
 		}
 
 		return ErrorCode::NONE;
 	});
 	(void)err;
 
-	Bool shouldUpdate = lastUpdate >= sm.m_timestamp;
 	if(shouldUpdate)
 	{
 		sm.m_timestamp = getGlobalTimestamp();

+ 1 - 1
testapp/Main.cpp

@@ -43,7 +43,7 @@ App* app;
 ModelNode* horse;
 PerspectiveCamera* cam;
 
-#define PLAYER 0
+#define PLAYER 1
 #define MOUSE 1
 
 Bool profile = false;