summaryrefslogtreecommitdiff
path: root/src/content_cao.cpp
diff options
context:
space:
mode:
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>2015-02-21 23:38:53 +0200
committerest31 <MTest31@outlook.com>2015-06-22 01:53:38 +0200
commit660fa516bfe774c77947c47a97154d6f069f414d (patch)
tree60cbb826cfda9f08bd747aab3f087a75aec1df4c /src/content_cao.cpp
parent622918d8a86ab2bb8a6ef1211b9a2ed1ad4c9b96 (diff)
downloadminetest-660fa516bfe774c77947c47a97154d6f069f414d.tar.gz
minetest-660fa516bfe774c77947c47a97154d6f069f414d.tar.bz2
minetest-660fa516bfe774c77947c47a97154d6f069f414d.zip
Fix some issues with animations, and allow non-looped animations to be defined
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r--src/content_cao.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index 01be1422c..d38cb892a 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -565,6 +565,7 @@ GenericCAO::GenericCAO(IGameDef *gamedef, ClientEnvironment *env):
m_animation_range(v2s32(0,0)),
m_animation_speed(15),
m_animation_blend(0),
+ m_animation_loop(true),
m_bone_position(std::map<std::string, core::vector2d<v3f> >()),
m_attachment_bone(""),
m_attachment_position(v3f(0,0,0)),
@@ -1465,9 +1466,18 @@ void GenericCAO::updateAnimation()
{
if(m_animated_meshnode == NULL)
return;
- m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
- m_animated_meshnode->setAnimationSpeed(m_animation_speed);
+
+ if (m_animated_meshnode->getStartFrame() != m_animation_range.X ||
+ m_animated_meshnode->getEndFrame() != m_animation_range.Y)
+ m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
+ if (m_animated_meshnode->getAnimationSpeed() != m_animation_speed)
+ m_animated_meshnode->setAnimationSpeed(m_animation_speed);
m_animated_meshnode->setTransitionTime(m_animation_blend);
+// Requires Irrlicht 1.8 or greater
+#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR > 1
+ if (m_animated_meshnode->getLoopMode() != m_animation_loop)
+ m_animated_meshnode->setLoopMode(m_animation_loop);
+#endif
}
void GenericCAO::updateBonePosition()
@@ -1633,6 +1643,8 @@ void GenericCAO::processMessage(const std::string &data)
m_animation_range = v2s32((s32)range.X, (s32)range.Y);
m_animation_speed = readF1000(is);
m_animation_blend = readF1000(is);
+ // these are sent inverted so we get true when the server sends nothing
+ m_animation_loop = !readU8(is);
updateAnimation();
} else {
LocalPlayer *player = m_env->getLocalPlayer();
@@ -1641,6 +1653,8 @@ void GenericCAO::processMessage(const std::string &data)
m_animation_range = v2s32((s32)range.X, (s32)range.Y);
m_animation_speed = readF1000(is);
m_animation_blend = readF1000(is);
+ // these are sent inverted so we get true when the server sends nothing
+ m_animation_loop = !readU8(is);
}
// update animation only if local animations present
// and received animation is unknown (except idle animation)