diff --git a/engines/grim/costume.cpp b/engines/grim/costume.cpp index 0fb528aaeba..78906ea8192 100644 --- a/engines/grim/costume.cpp +++ b/engines/grim/costume.cpp @@ -33,6 +33,7 @@ #include "engines/grim/model.h" #include "engines/grim/costume/chore.h" +#include "engines/grim/costume/head.h" #include "engines/grim/costume/main_model_component.h" #include "engines/grim/costume/colormap_component.h" #include "engines/grim/costume/keyframe_component.h" @@ -104,7 +105,7 @@ namespace Grim { // along setKey requests to the actual bitmap object. Costume::Costume(const Common::String &fname, const char *data, int len, Costume *prevCost) : - Object() { + Object(), _head(new Head()) { _fname = fname; _lookAtRate = 200; @@ -292,6 +293,7 @@ Costume::~Costume() { delete[] _components; delete[] _chores; } + delete _head; } Component *Costume::loadComponent (tag32 tag, Component *parent, int parentID, const char *name, Component *prevComponent) { @@ -559,13 +561,13 @@ void Costume::animate() { } void Costume::moveHead(bool entering, const Math::Vector3d &lookAt) { - _head.lookAt(entering, lookAt, _lookAtRate, _matrix); + _head->lookAt(entering, lookAt, _lookAtRate, _matrix); } void Costume::setHead(int joint1, int joint2, int joint3, float maxRoll, float maxPitch, float maxYaw) { - _head.setJoints(joint1, joint2, joint3); - _head.loadJoints(getModelNodes()); - _head.setMaxAngles(maxPitch, maxYaw, maxRoll); + _head->setJoints(joint1, joint2, joint3); + _head->loadJoints(getModelNodes()); + _head->setMaxAngles(maxPitch, maxYaw, maxRoll); } void Costume::setLookAtRate(float rate) { @@ -624,7 +626,7 @@ void Costume::saveState(SaveGame *state) const { // FIXME: Decomment this!! // state.writeFloat(_lookAtRate); - _head.saveState(state); + _head->saveState(state); } bool Costume::restoreState(SaveGame *state) { @@ -659,8 +661,8 @@ bool Costume::restoreState(SaveGame *state) { // FIXME: Decomment this!! // _lookAtRate = state->readFloat(); - _head.restoreState(state); - _head.loadJoints(getModelNodes()); + _head->restoreState(state); + _head->loadJoints(getModelNodes()); return true; } diff --git a/engines/grim/costume.h b/engines/grim/costume.h index f3ecdf58c6f..096d0de342f 100644 --- a/engines/grim/costume.h +++ b/engines/grim/costume.h @@ -25,8 +25,9 @@ #include "common/memstream.h" +#include "math/matrix4.h" + #include "engines/grim/object.h" -#include "engines/grim/costume/head.h" namespace Grim { @@ -39,6 +40,7 @@ class TextSplitter; class ModelComponent; class Component; class Chore; +class Head; class Costume : public Object { public: @@ -99,7 +101,7 @@ private: int _numComponents; Component **_components; - Head _head; + Head *_head; ObjectPtr _cmap; int _numChores; diff --git a/engines/grim/costume/head.cpp b/engines/grim/costume/head.cpp index 93151e5f2f8..57ed726055d 100644 --- a/engines/grim/costume/head.cpp +++ b/engines/grim/costume/head.cpp @@ -20,9 +20,9 @@ * */ -#include "engines/grim/costume.h" #include "engines/grim/model.h" #include "engines/grim/grim.h" +#include "engines/grim/costume/head.h" namespace Grim {