Przeglądaj źródła

Fixed comments.
Run all physics examples at 60Hz. This may have the side-effect of making NinjaSnowWar easier, as the AI controller is also run less frequently.

Lasse Öörni 14 lat temu
rodzic
commit
3eecd9cfb4

+ 1 - 1
Bin/Data/Scenes/NinjaSnowWar.xml

@@ -18,7 +18,7 @@
     </component>
     </component>
     <component type="PhysicsWorld" id="16777217">
     <component type="PhysicsWorld" id="16777217">
         <attribute name="Gravity" value="0 -981 0" />
         <attribute name="Gravity" value="0 -981 0" />
-        <attribute name="Physics FPS" value="200" />
+        <attribute name="Physics FPS" value="60" />
         <attribute name="Max Contacts" value="20" />
         <attribute name="Max Contacts" value="20" />
         <attribute name="Bounce Threshold" value="0.1" />
         <attribute name="Bounce Threshold" value="0.1" />
         <attribute name="Network Max Ang Vel." value="100" />
         <attribute name="Network Max Ang Vel." value="100" />

+ 6 - 6
Bin/Data/Scripts/NinjaSnowWar/AIController.as

@@ -1,12 +1,12 @@
-const float initialAggression = 0.0020;
+const float initialAggression = 0.0060;
 const float initialPrediction = 3000;
 const float initialPrediction = 3000;
-const float initialAimSpeed = 5;
-const float deltaAggression = 0.000025;
+const float initialAimSpeed = 15;
+const float deltaAggression = 0.000075;
 const float deltaPrediction = -15;
 const float deltaPrediction = -15;
-const float deltaAimSpeed = 0.15;
-const float maxAggression = 0.01;
+const float deltaAimSpeed = 0.45;
+const float maxAggression = 0.03;
 const float maxPrediction = 2000;
 const float maxPrediction = 2000;
-const float maxAimSpeed = 20;
+const float maxAimSpeed = 60;
 
 
 float aiAggression = initialAggression;
 float aiAggression = initialAggression;
 float aiPrediction = initialPrediction;
 float aiPrediction = initialPrediction;

+ 4 - 1
Bin/Data/Scripts/NinjaSnowWar/Ninja.as

@@ -9,7 +9,7 @@ const float ninjaFriction = 0.5;
 const float ninjaMoveForce = 500000;
 const float ninjaMoveForce = 500000;
 const float ninjaAirMoveForce = 25000;
 const float ninjaAirMoveForce = 25000;
 const float ninjaDampingForce = 1000;
 const float ninjaDampingForce = 1000;
-const float ninjaJumpForce = 9000000;
+const float ninjaJumpForce = 2700000;
 const Vector3 ninjaThrowVelocity(0, 425, 2000);
 const Vector3 ninjaThrowVelocity(0, 425, 2000);
 const Vector3 ninjaThrowPosition(0, 20, 100);
 const Vector3 ninjaThrowPosition(0, 20, 100);
 const float ninjaThrowDelay = 0.1;
 const float ninjaThrowDelay = 0.1;
@@ -221,6 +221,9 @@ class Ninja : GameObject
         if ((controls.IsPressed(CTRL_FIRE, prevControls)) && (throwTime <= 0))
         if ((controls.IsPressed(CTRL_FIRE, prevControls)) && (throwTime <= 0))
         {
         {
             Vector3 projectileVel = GetAim() * ninjaThrowVelocity;
             Vector3 projectileVel = GetAim() * ninjaThrowVelocity;
+            // Hack: clamp projectile downward velocity to limit tunnelling when snowball is thrown almost directly down
+            if (projectileVel.y < -1000.0)
+                projectileVel.y = -1000.0;
 
 
             controller.Play("Models/Ninja_Attack1.ani", LAYER_ATTACK, false, 0.0);
             controller.Play("Models/Ninja_Attack1.ani", LAYER_ATTACK, false, 0.0);
             controller.SetTime("Models/Ninja_Attack1.ani", 0.0); // Always play from beginning
             controller.SetTime("Models/Ninja_Attack1.ani", 0.0); // Always play from beginning

+ 1 - 1
Bin/Data/Scripts/TestScene.as

@@ -96,7 +96,7 @@ void InitScene()
     testScene.CreateComponent("DebugRenderer");
     testScene.CreateComponent("DebugRenderer");
 
 
     world.gravity = Vector3(0.0, -9.81, 0.0);
     world.gravity = Vector3(0.0, -9.81, 0.0);
-    world.fps = 100;
+    world.fps = 60;
     world.linearRestThreshold = 0.1;
     world.linearRestThreshold = 0.1;
     world.angularRestThreshold = 0.1;
     world.angularRestThreshold = 0.1;
     world.contactSurfaceLayer = 0.001;
     world.contactSurfaceLayer = 0.001;

+ 1 - 1
Bin/Data/Scripts/TestSceneOld.as

@@ -60,7 +60,7 @@ void InitScene()
 
 
     // Set the physics world parameters
     // Set the physics world parameters
     world.gravity = Vector3(0, -9.81, 0);
     world.gravity = Vector3(0, -9.81, 0);
-    world.fps = 100;
+    world.fps = 60;
     world.linearRestThreshold = 0.1;
     world.linearRestThreshold = 0.1;
     world.angularRestThreshold = 0.1;
     world.angularRestThreshold = 0.1;
     world.contactSurfaceLayer = 0.001;
     world.contactSurfaceLayer = 0.001;

+ 14 - 24
Engine/Graphics/View.cpp

@@ -1016,17 +1016,16 @@ void View::RenderBatchesForward()
     graphics_->SetViewport(viewRect_);
     graphics_->SetViewport(viewRect_);
     graphics_->Clear(CLEAR_DEPTH | CLEAR_STENCIL);
     graphics_->Clear(CLEAR_DEPTH | CLEAR_STENCIL);
     
     
+    // Render opaque object unlit base pass
     if (!baseQueue_.IsEmpty())
     if (!baseQueue_.IsEmpty())
     {
     {
-        // Render opaque object unlit base pass
         PROFILE(RenderBase);
         PROFILE(RenderBase);
-        
         baseQueue_.Draw(graphics_, renderer_);
         baseQueue_.Draw(graphics_, renderer_);
     }
     }
     
     
+    // Render shadow maps + opaque objects' additive lighting
     if (!lightQueues_.Empty())
     if (!lightQueues_.Empty())
     {
     {
-        // Render shadow maps + opaque objects' additive lighting
         PROFILE(RenderLights);
         PROFILE(RenderLights);
         
         
         for (List<LightBatchQueue>::Iterator i = lightQueues_.Begin(); i != lightQueues_.End(); ++i)
         for (List<LightBatchQueue>::Iterator i = lightQueues_.Begin(); i != lightQueues_.End(); ++i)
@@ -1060,27 +1059,24 @@ void View::RenderBatchesForward()
     graphics_->ClearParameterSource(PSP_MATDIFFCOLOR);
     graphics_->ClearParameterSource(PSP_MATDIFFCOLOR);
     DrawFullscreenQuad(camera_, false);
     DrawFullscreenQuad(camera_, false);
     
     
+    // Render pre-alpha custom pass
     if (!preAlphaQueue_.IsEmpty())
     if (!preAlphaQueue_.IsEmpty())
     {
     {
-        // Render pre-alpha custom pass
         PROFILE(RenderPreAlpha);
         PROFILE(RenderPreAlpha);
-        
         preAlphaQueue_.Draw(graphics_, renderer_);
         preAlphaQueue_.Draw(graphics_, renderer_);
     }
     }
     
     
+    // Render transparent objects (both base passes & additive lighting)
     if (!alphaQueue_.IsEmpty())
     if (!alphaQueue_.IsEmpty())
     {
     {
-        // Render transparent objects (both base passes & additive lighting)
         PROFILE(RenderAlpha);
         PROFILE(RenderAlpha);
-        
         alphaQueue_.Draw(graphics_, renderer_, true);
         alphaQueue_.Draw(graphics_, renderer_, true);
     }
     }
     
     
+    // Render post-alpha custom pass
     if (!postAlphaQueue_.IsEmpty())
     if (!postAlphaQueue_.IsEmpty())
     {
     {
-        // Render pre-alpha custom pass
         PROFILE(RenderPostAlpha);
         PROFILE(RenderPostAlpha);
-        
         postAlphaQueue_.Draw(graphics_, renderer_);
         postAlphaQueue_.Draw(graphics_, renderer_);
     }
     }
     
     
@@ -1132,18 +1128,18 @@ void View::RenderBatchesDeferred()
     graphics_->SetViewport(viewRect_);
     graphics_->SetViewport(viewRect_);
     graphics_->Clear(CLEAR_DEPTH | CLEAR_STENCIL);
     graphics_->Clear(CLEAR_DEPTH | CLEAR_STENCIL);
     
     
+    // Render G-buffer batches
     if (!gbufferQueue_.IsEmpty())
     if (!gbufferQueue_.IsEmpty())
     {
     {
-        // Render G-buffer batches
         PROFILE(RenderGBuffer);
         PROFILE(RenderGBuffer);
-        
         gbufferQueue_.Draw(graphics_, renderer_, false, true);
         gbufferQueue_.Draw(graphics_, renderer_, false, true);
     }
     }
     
     
+    // Clear the light accumulation buffer (light pre-pass only.) However, skip the clear if the first light is a directional
+    // light with full mask
     RenderSurface* lightRenderTarget = renderMode_ == RENDER_PREPASS ? albedoBuffer->GetRenderSurface() : renderTarget;
     RenderSurface* lightRenderTarget = renderMode_ == RENDER_PREPASS ? albedoBuffer->GetRenderSurface() : renderTarget;
     if (renderMode_ == RENDER_PREPASS)
     if (renderMode_ == RENDER_PREPASS)
     {
     {
-        // Clear the light accumulation buffer. However, skip the clear if the first light is a directional light with full mask
         bool optimizeLightBuffer = !hasZeroLightMask_ && !lightQueues_.Empty() && lightQueues_.Front().light_->GetLightType() ==
         bool optimizeLightBuffer = !hasZeroLightMask_ && !lightQueues_.Empty() && lightQueues_.Front().light_->GetLightType() ==
             LIGHT_DIRECTIONAL && (lightQueues_.Front().light_->GetLightMask() & 0xff) == 0xff;
             LIGHT_DIRECTIONAL && (lightQueues_.Front().light_->GetLightMask() & 0xff) == 0xff;
         
         
@@ -1161,9 +1157,9 @@ void View::RenderBatchesDeferred()
         graphics_->ResetRenderTarget(3);
         graphics_->ResetRenderTarget(3);
     }
     }
     
     
+    // Render shadow maps + light volumes
     if (!lightQueues_.Empty())
     if (!lightQueues_.Empty())
     {
     {
-        // Render shadow maps + light volumes
         PROFILE(RenderLights);
         PROFILE(RenderLights);
         
         
         for (List<LightBatchQueue>::Iterator i = lightQueues_.Begin(); i != lightQueues_.End(); ++i)
         for (List<LightBatchQueue>::Iterator i = lightQueues_.Begin(); i != lightQueues_.End(); ++i)
@@ -1214,40 +1210,34 @@ void View::RenderBatchesDeferred()
     graphics_->ClearParameterSource(PSP_MATDIFFCOLOR);
     graphics_->ClearParameterSource(PSP_MATDIFFCOLOR);
     DrawFullscreenQuad(camera_, false);
     DrawFullscreenQuad(camera_, false);
     
     
+    // Render opaque objects with deferred lighting result (light pre-pass only)
     if (!baseQueue_.IsEmpty())
     if (!baseQueue_.IsEmpty())
     {
     {
-        // Render opaque objects with deferred lighting result
         PROFILE(RenderBase);
         PROFILE(RenderBase);
         
         
-        if (renderMode_ == RENDER_PREPASS)
-            graphics_->SetTexture(TU_LIGHTBUFFER, albedoBuffer);
-        
+        graphics_->SetTexture(TU_LIGHTBUFFER, renderMode_ == RENDER_PREPASS ? albedoBuffer : 0);
         baseQueue_.Draw(graphics_, renderer_);
         baseQueue_.Draw(graphics_, renderer_);
-        
         graphics_->SetTexture(TU_LIGHTBUFFER, 0);
         graphics_->SetTexture(TU_LIGHTBUFFER, 0);
     }
     }
     
     
+    // Render pre-alpha custom pass
     if (!preAlphaQueue_.IsEmpty())
     if (!preAlphaQueue_.IsEmpty())
     {
     {
-        // Render pre-alpha custom pass
         PROFILE(RenderPreAlpha);
         PROFILE(RenderPreAlpha);
-        
         preAlphaQueue_.Draw(graphics_, renderer_);
         preAlphaQueue_.Draw(graphics_, renderer_);
     }
     }
     
     
+    // Render transparent objects (both base passes & additive lighting)
     if (!alphaQueue_.IsEmpty())
     if (!alphaQueue_.IsEmpty())
     {
     {
-        // Render transparent objects (both base passes & additive lighting)
         PROFILE(RenderAlpha);
         PROFILE(RenderAlpha);
-        
         alphaQueue_.Draw(graphics_, renderer_, true);
         alphaQueue_.Draw(graphics_, renderer_, true);
     }
     }
     
     
+    // Render post-alpha custom pass
     if (!postAlphaQueue_.IsEmpty())
     if (!postAlphaQueue_.IsEmpty())
     {
     {
-        // Render pre-alpha custom pass
         PROFILE(RenderPostAlpha);
         PROFILE(RenderPostAlpha);
-        
         postAlphaQueue_.Draw(graphics_, renderer_);
         postAlphaQueue_.Draw(graphics_, renderer_);
     }
     }
 }
 }