Sfoglia il codice sorgente

Fixed AnimatedModel's animation possibly not updating when loading the scene.
Added light's shadow intensity & shadow fade distance parameters to the NinjaSnowWar scene.

Lasse Öörni 15 anni fa
parent
commit
16aa868d4f

+ 1 - 1
Bin/Data/TestLevel.xml

@@ -17,7 +17,7 @@
             <render castshadows="true" occluder="false" visible="true" />
             <render castshadows="true" occluder="false" visible="true" />
             <lod drawdistance="0" shadowdistance="0" viewmask="-1" lightmask="-1" fadedistance="0" detail="0" shadowdetail="0" />
             <lod drawdistance="0" shadowdistance="0" viewmask="-1" lightmask="-1" fadedistance="0" detail="0" shadowdetail="0" />
             <light type="directional" direction="-0.57735 -0.57735 0.57735" color="1 1 1 1" specular="0" range="0" fov="30" aspectratio="1" />
             <light type="directional" direction="-0.57735 -0.57735 0.57735" color="1 1 1 1" specular="0" range="0" fov="30" aspectratio="1" />
-            <shadows resolution="1" nearfarratio="0.002" />
+            <shadows fadedistance="0" intensity="0" resolution="1" nearfarratio="0.002" />
             <shadowbias constant="0.00025" slopescaled="0.001" />
             <shadowbias constant="0.00025" slopescaled="0.001" />
             <shadowcascade lambda="0.5" maxrange="5000" faderange="0.2" splits="2" />
             <shadowcascade lambda="0.5" maxrange="5000" faderange="0.2" splits="2" />
             <shadowfocus enable="true" nonuniform="true" zoomout="true" quantize="50" minview="900" />
             <shadowfocus enable="true" nonuniform="true" zoomout="true" quantize="50" minview="900" />

+ 12 - 6
Engine/Renderer/AnimatedModel.cpp

@@ -51,10 +51,10 @@ static bool compareAnimationOrder(AnimationState* lhs, AnimationState* rhs)
 
 
 AnimatedModel::AnimatedModel(Octant* octant, const std::string& name) :
 AnimatedModel::AnimatedModel(Octant* octant, const std::string& name) :
     StaticModel(NODE_ANIMATEDMODEL, octant, name),
     StaticModel(NODE_ANIMATEDMODEL, octant, name),
-    mAnimationLodDistance(0.0f),
     mAnimationLodFrameNumber(M_MAX_UNSIGNED),
     mAnimationLodFrameNumber(M_MAX_UNSIGNED),
     mAnimationLodBias(1.0f),
     mAnimationLodBias(1.0f),
-    mAnimationLodTimer(0.0f),
+    mAnimationLodTimer(-1.0f),
+    mAnimationLodDistance(0.0f),
     mAnimationDirty(true),
     mAnimationDirty(true),
     mAnimationOrderDirty(true),
     mAnimationOrderDirty(true),
     mMorphsDirty(true),
     mMorphsDirty(true),
@@ -1093,11 +1093,17 @@ void AnimatedModel::updateAnimation(const FrameInfo& frame)
     // If using animation LOD, accumulate time and see if it is time to update
     // If using animation LOD, accumulate time and see if it is time to update
     if ((mAnimationLodBias > 0.0f) && (mAnimationLodDistance > 0.0f))
     if ((mAnimationLodBias > 0.0f) && (mAnimationLodDistance > 0.0f))
     {
     {
-        mAnimationLodTimer += mAnimationLodBias * frame.mTimeStep * ANIMATION_LOD_BASESCALE;
-        if (mAnimationLodTimer >= mAnimationLodDistance)
-            mAnimationLodTimer = fmodf(mAnimationLodTimer, mAnimationLodDistance);
+        // Check for first time update
+        if (mAnimationLodTimer >= 0.0f)
+        {
+            mAnimationLodTimer += mAnimationLodBias * frame.mTimeStep * ANIMATION_LOD_BASESCALE;
+            if (mAnimationLodTimer >= mAnimationLodDistance)
+                mAnimationLodTimer = fmodf(mAnimationLodTimer, mAnimationLodDistance);
+            else
+                return;
+        }
         else
         else
-            return;
+            mAnimationLodTimer = 0.0f;
     }
     }
     
     
     PROFILE(AnimatedModel_UpdateAnimation);
     PROFILE(AnimatedModel_UpdateAnimation);

+ 4 - 5
Engine/Renderer/AnimatedModel.h

@@ -143,11 +143,6 @@ protected:
     //! Update world-space bounding box
     //! Update world-space bounding box
     virtual void onWorldBoundingBoxUpdate(BoundingBox& worldBoundingBox);
     virtual void onWorldBoundingBoxUpdate(BoundingBox& worldBoundingBox);
     
     
-    //! Animation LOD distance, the minimum of all LOD view distances last frame
-    float mAnimationLodDistance;
-    //! The frame number animation LOD distance was last calculated on
-    unsigned mAnimationLodFrameNumber;
-    
 private:
 private:
     //! Mark animation and skinning to require an update
     //! Mark animation and skinning to require an update
     void markAnimationDirty();
     void markAnimationDirty();
@@ -188,10 +183,14 @@ private:
     std::vector<std::vector<Matrix4x3> > mGeometrySkinMatrices;
     std::vector<std::vector<Matrix4x3> > mGeometrySkinMatrices;
     //! Subgeometry skinning matrix pointers, if more bones than skinning shader can manage
     //! Subgeometry skinning matrix pointers, if more bones than skinning shader can manage
     std::vector<std::vector<Matrix4x3*> > mGeometrySkinMatrixPtrs;
     std::vector<std::vector<Matrix4x3*> > mGeometrySkinMatrixPtrs;
+    //! The frame number animation LOD distance was last calculated on
+    unsigned mAnimationLodFrameNumber;
     //! Animation LOD bias
     //! Animation LOD bias
     float mAnimationLodBias;
     float mAnimationLodBias;
     //! Animation LOD timer
     //! Animation LOD timer
     float mAnimationLodTimer;
     float mAnimationLodTimer;
+    //! Animation LOD distance, the minimum of all LOD view distances last frame
+    float mAnimationLodDistance;
     //! Animation dirty flag
     //! Animation dirty flag
     bool mAnimationDirty;
     bool mAnimationDirty;
     //! Animation order dirty flag
     //! Animation order dirty flag