Commit 1aba16d8 authored by cutealien's avatar cutealien

Do no longer re-calculate md2 frames when they don't change (thx @npc for reporting)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5227 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 76fe3727
-------------------------- --------------------------
Changes in 1.9 (not yet released) Changes in 1.9 (not yet released)
- Do no longer re-calculate md2 frames when they don't change (thx @npc for reporting)
- Add multibyteToWString wrapper functions around mbstowcs which work with Irrlicht string class. - Add multibyteToWString wrapper functions around mbstowcs which work with Irrlicht string class.
- Fix: addFileArchive now grab()'s the archive when you pass one in by pointer. - Fix: addFileArchive now grab()'s the archive when you pass one in by pointer.
- Fix: Prevent division by 0 in CGUIScrollBar::setPos - Fix: Prevent division by 0 in CGUIScrollBar::setPos
......
...@@ -219,7 +219,8 @@ static const SMD2AnimationType MD2AnimationTypeList[21] = ...@@ -219,7 +219,8 @@ static const SMD2AnimationType MD2AnimationTypeList[21] =
//! constructor //! constructor
CAnimatedMeshMD2::CAnimatedMeshMD2() CAnimatedMeshMD2::CAnimatedMeshMD2()
: InterpolationBuffer(0), FrameList(0), FrameCount(0), FramesPerSecond((f32)(MD2AnimationTypeList[0].fps << MD2_FRAME_SHIFT)) : InterpolationBuffer(0), InterpolationFirstFrame(-1), InterpolationSecondFrame(-1), InterpolationFrameDiv(0.f)
, FrameList(0), FrameCount(0), FramesPerSecond((f32)(MD2AnimationTypeList[0].fps << MD2_FRAME_SHIFT))
{ {
#ifdef _DEBUG #ifdef _DEBUG
IAnimatedMesh::setDebugName("CAnimatedMeshMD2 IAnimatedMesh"); IAnimatedMesh::setDebugName("CAnimatedMeshMD2 IAnimatedMesh");
...@@ -320,6 +321,12 @@ void CAnimatedMeshMD2::updateInterpolationBuffer(s32 frame, s32 startFrameLoop, ...@@ -320,6 +321,12 @@ void CAnimatedMeshMD2::updateInterpolationBuffer(s32 frame, s32 startFrameLoop,
div = frame * MD2_FRAME_SHIFT_RECIPROCAL; div = frame * MD2_FRAME_SHIFT_RECIPROCAL;
} }
if ( firstFrame != InterpolationFirstFrame || secondFrame != InterpolationSecondFrame || div != InterpolationFrameDiv )
{
InterpolationFirstFrame = firstFrame;
InterpolationSecondFrame = secondFrame;
InterpolationFrameDiv = div;
video::S3DVertex* target = static_cast<video::S3DVertex*>(InterpolationBuffer->getVertices()); video::S3DVertex* target = static_cast<video::S3DVertex*>(InterpolationBuffer->getVertices());
SMD2Vert* first = FrameList[firstFrame].pointer(); SMD2Vert* first = FrameList[firstFrame].pointer();
SMD2Vert* second = FrameList[secondFrame].pointer(); SMD2Vert* second = FrameList[secondFrame].pointer();
...@@ -352,6 +359,7 @@ void CAnimatedMeshMD2::updateInterpolationBuffer(s32 frame, s32 startFrameLoop, ...@@ -352,6 +359,7 @@ void CAnimatedMeshMD2::updateInterpolationBuffer(s32 frame, s32 startFrameLoop,
//update bounding box //update bounding box
InterpolationBuffer->setBoundingBox(BoxList[secondFrame].getInterpolated(BoxList[firstFrame], div)); InterpolationBuffer->setBoundingBox(BoxList[secondFrame].getInterpolated(BoxList[firstFrame], div));
InterpolationBuffer->setDirty(); InterpolationBuffer->setDirty();
}
} }
......
...@@ -102,6 +102,10 @@ namespace scene ...@@ -102,6 +102,10 @@ namespace scene
//! the buffer that contains the most recent animation //! the buffer that contains the most recent animation
SMeshBuffer* InterpolationBuffer; SMeshBuffer* InterpolationBuffer;
//! Frames used to calculate InterpolationBuffer
u32 InterpolationFirstFrame, InterpolationSecondFrame;
f32 InterpolationFrameDiv;
//! named animations //! named animations
struct SAnimationData struct SAnimationData
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment