Skip to content

Commit

Permalink
#5584: MD5 model animation is working again, a renderable surface upd…
Browse files Browse the repository at this point in the history
…ate is queued per each change
  • Loading branch information
codereader committed Jan 16, 2022
1 parent 4336484 commit 5034bb1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
7 changes: 7 additions & 0 deletions radiantcore/model/md5/MD5Model.cpp
Expand Up @@ -384,6 +384,13 @@ void MD5Model::updateAnim(std::size_t time)
{
i->surface->updateToSkeleton(_skeleton);
}

signal_ModelAnimationUpdated().emit();
}

sigc::signal<void>& MD5Model::signal_ModelAnimationUpdated()
{
return _sigModelAnimationUpdated;
}

} // namespace
4 changes: 4 additions & 0 deletions radiantcore/model/md5/MD5Model.h
Expand Up @@ -71,6 +71,8 @@ class MD5Model :
// We need to keep a reference for skin swapping
RenderSystemWeakPtr _renderSystem;

sigc::signal<void> _sigModelAnimationUpdated;

public:
MD5Model();

Expand Down Expand Up @@ -147,6 +149,8 @@ class MD5Model :
*/
static Vector3 parseVector3(parser::DefTokeniser& tok);

sigc::signal<void>& signal_ModelAnimationUpdated();

private:

// Creates a new MD5Surface, adds it to the local list and returns the reference
Expand Down
19 changes: 18 additions & 1 deletion radiantcore/model/md5/MD5ModelNode.cpp
Expand Up @@ -12,7 +12,16 @@ namespace md5
MD5ModelNode::MD5ModelNode(const MD5ModelPtr& model) :
_model(new MD5Model(*model)), // create a copy of the incoming model, we need our own instance
_attachedToShaders(false)
{}
{
_animationUpdateConnection = _model->signal_ModelAnimationUpdated().connect(
sigc::mem_fun(this, &MD5ModelNode::onModelAnimationUpdated)
);
}

MD5ModelNode::~MD5ModelNode()
{
_animationUpdateConnection.disconnect();
}

const model::IModel& MD5ModelNode::getIModel() const
{
Expand Down Expand Up @@ -240,4 +249,12 @@ void MD5ModelNode::onVisibilityChanged(bool isVisibleNow)
}
}

void MD5ModelNode::onModelAnimationUpdated()
{
for (auto& surface : _renderableSurfaces)
{
surface->queueUpdate();
}
}

} // namespace md5
5 changes: 5 additions & 0 deletions radiantcore/model/md5/MD5ModelNode.h
@@ -1,5 +1,6 @@
#pragma once

#include <sigc++/connection.h>
#include "MD5Model.h"
#include "modelskin.h"
#include "itraceable.h"
Expand All @@ -26,8 +27,11 @@ class MD5ModelNode :

bool _attachedToShaders;

sigc::connection _animationUpdateConnection;

public:
MD5ModelNode(const MD5ModelPtr& model);
virtual ~MD5ModelNode();

void onInsertIntoScene(scene::IMapRootNode& root) override;
void onRemoveFromScene(scene::IMapRootNode& root) override;
Expand Down Expand Up @@ -74,6 +78,7 @@ class MD5ModelNode :
void onVisibilityChanged(bool isVisibleNow) override;

private:
void onModelAnimationUpdated();
void attachToShaders();
void detachFromShaders();
#if 0
Expand Down

0 comments on commit 5034bb1

Please sign in to comment.