Permalink
Browse files

GRIM: Only compute the world transform matrices for the joint node an…

…d its parents, not for every node of the character.
  • Loading branch information...
1 parent 8530edd commit 4fb4e0c32085130721e2ffe490e3dfe32a7da9bd @Akz- Akz- committed Apr 8, 2012
@@ -41,10 +41,12 @@ void Head::Joint::orientTowards(bool entering, const Math::Vector3d &point, floa
float pitchStep = step / 3.0f;
float rollStep = step / 3.0f;
- // Make sure we have up-to-date world transform matrices computed for every bone node of this character.
+ // Make sure we have up-to-date world transform matrices computed for the joint nodes of this character.
+ _node->_needsUpdate = true;
ModelNode *p = _node;
while (p->_parent) {
p = p->_parent;
+ p->_needsUpdate = true;
}
p->setMatrix(matrix);
p->update();
@@ -71,6 +71,8 @@ class Head {
float _maxPitch;
float _maxYaw;
+ ModelNode *_rootNode;
+
// Specifies the three head joint bones of this character.
// These joint bones are animated by the moveHead function to make
// the characters face different directions.
@@ -646,9 +646,11 @@ void Lua_V1::GetActorNodeLocation() {
ModelNode *allNodes = actor->getCurrentCostume()->getModelNodes();
ModelNode *node = allNodes + nodeId;
+ node->_needsUpdate = true;
ModelNode *root = node;
while (root->_parent) {
root = root->_parent;
+ root->_needsUpdate = true;
}
Math::Matrix4 matrix;
View
@@ -709,7 +709,7 @@ void ModelNode::update() {
if (!_initialized)
return;
- if (_hierVisible) {
+ if (_hierVisible && _needsUpdate) {
Math::Vector3d animPos = _pos + _animPos;
Math::Angle animPitch = _pitch + _animPitch;
Math::Angle animYaw = _yaw + _animYaw;
@@ -731,6 +731,8 @@ void ModelNode::update() {
_child->setMatrix(_matrix);
_child->update();
}
+
+ _needsUpdate = false;
}
if (_sibling) {
View
@@ -143,7 +143,7 @@ class Mesh {
class ModelNode {
public:
- ModelNode() : _initialized(false) { }
+ ModelNode() : _initialized(false), _needsUpdate(true) { }
~ModelNode();
void loadBinary(Common::SeekableReadStream *data, ModelNode *hierNodes, const Model::Geoset *g);
void draw() const;
@@ -181,6 +181,7 @@ class ModelNode {
Math::Angle _animPitch, _animYaw, _animRoll;
bool _meshVisible, _hierVisible;
bool _initialized;
+ bool _needsUpdate;
Math::Matrix4 _matrix;
Math::Matrix4 _localMatrix;
Math::Matrix4 _pivotMatrix;

0 comments on commit 4fb4e0c

Please sign in to comment.