Browse Source

To be consistent, removed the dependency of animation and terrain LOD from viewport pixel size, as the actual size of screen pixels can not be known. Now the LOD only depends on distance and scale.

Lasse Öörni 13 years ago
parent
commit
fa4e6ea827

+ 1 - 1
Engine/Graphics/AnimatedModel.cpp

@@ -1111,7 +1111,7 @@ void AnimatedModel::UpdateAnimation(const FrameInfo& frame)
         // Check for first time update
         if (animationLodTimer_ >= 0.0f)
         {
-            animationLodTimer_ += animationLodBias_ * frame.timeStep_ * frame.viewSize_.y_ * ANIMATION_LOD_BASESCALE;
+            animationLodTimer_ += animationLodBias_ * frame.timeStep_ * ANIMATION_LOD_BASESCALE;
             if (animationLodTimer_ >= animationLodDistance_)
                 animationLodTimer_ = fmodf(animationLodTimer_, animationLodDistance_);
             else

+ 1 - 1
Engine/Graphics/BillboardSet.cpp

@@ -375,7 +375,7 @@ void BillboardSet::UpdateVertexBuffer(const FrameInfo& frame)
     // If using animation LOD, accumulate time and see if it is time to update
     if (animationLodBias_ > 0.0f && lodDistance_ > 0.0f)
     {
-        animationLodTimer_ += animationLodBias_ * frame.timeStep_ * frame.viewSize_.y_ * ANIMATION_LOD_BASESCALE;
+        animationLodTimer_ += animationLodBias_ * frame.timeStep_ * ANIMATION_LOD_BASESCALE;
         if (animationLodTimer_ >= lodDistance_)
             animationLodTimer_ = fmodf(animationLodTimer_, lodDistance_);
         else

+ 1 - 0
Engine/Graphics/Drawable.h

@@ -40,6 +40,7 @@ static const unsigned DEFAULT_SHADOWMASK = M_MAX_UNSIGNED;
 static const unsigned DEFAULT_ZONEMASK = M_MAX_UNSIGNED;
 static const int DRAWABLES_PER_WORK_ITEM = 16;
 static const int MAX_VERTEX_LIGHTS = 4;
+static const float ANIMATION_LOD_BASESCALE = 2500.0f;
 
 class Camera;
 class Geometry;

+ 0 - 2
Engine/Graphics/GraphicsDefs.h

@@ -320,8 +320,6 @@ static const unsigned MASK_INSTANCEMATRIX3 = 0x1000;
 static const unsigned MASK_DEFAULT = 0xffffffff;
 static const unsigned NO_ELEMENT = 0xffffffff;
 
-static const float ANIMATION_LOD_BASESCALE = 2.5f;
-
 static const int MAX_RENDERTARGETS = 4;
 static const int MAX_VERTEX_STREAMS = 4;
 static const int MAX_SKIN_MATRICES = 64;

+ 2 - 2
Engine/Graphics/TerrainPatch.cpp

@@ -40,7 +40,7 @@
 namespace Urho3D
 {
 
-static const float LOD_CONSTANT = 8.0f;
+static const float LOD_CONSTANT = 1.0f / 150.0f;
 
 OBJECTTYPESTATIC(TerrainPatch);
 
@@ -142,7 +142,7 @@ void TerrainPatch::UpdateBatches(const FrameInfo& frame)
     unsigned newLodLevel = 0;
     for (unsigned i = 0; i < lodErrors_.Size(); ++i)
     {
-        if (lodErrors_[i] / lodDistance_ > LOD_CONSTANT / (float)frame.viewSize_.y_)
+        if (lodErrors_[i] / lodDistance_ > LOD_CONSTANT)
             break;
         else
             newLodLevel = i;