Skip to content

Commit

Permalink
Bugfix ofnode orientation with scale (#6093)
Browse files Browse the repository at this point in the history
* Fix getting parent orientation in ofNode::setGlobalOrientation

* More unit test for ofNode::setGlobal~

Fixes first part of #6025.
  • Loading branch information
yusuketomoto authored and arturoc committed Aug 1, 2018
1 parent 26a8247 commit 17c2246
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/openFrameworks/3d/ofNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ void ofNode::setGlobalOrientation(const glm::quat& q) {
if(parent == nullptr) {
setOrientation(q);
} else {
auto invParent = glm::inverse(parent->getGlobalTransformMatrix());
auto m44 = glm::toQuat(invParent) * q;
auto invParent = glm::inverse(parent->getGlobalOrientation());
auto m44 = invParent * q;
setOrientation(m44);
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/math/ofNodeRegressionTests/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ class ofApp: public ofxUnitTestsApp{
ofxTest(aprox_eq(n3.getOrientationQuat(), glm::quat()), "\torientation");
ofxTest(aprox_eq(n3.getScale(), glm::vec3(1,1,1)), "\tscale");
ofxTest(aprox_eq(n3.getGlobalTransformMatrix() * zero, n2.getGlobalTransformMatrix() * zero), "\tmatrices");
n3.setGlobalPosition(n3.getGlobalPosition());
n3.setGlobalOrientation(n3.getGlobalOrientation());
ofxTest(aprox_eq(n3.getPosition(), glm::vec3(0,0,0)), "\tposition");
ofxTest(aprox_eq(n3.getOrientationQuat(), glm::quat()), "\torientation");
ofxTest(aprox_eq(n3.getScale(), glm::vec3(1,1,1)), "\tscale");
ofxTest(aprox_eq(n3.getGlobalTransformMatrix() * zero, n2.getGlobalTransformMatrix() * zero), "\tmatrices");
ofLogNotice() << "end add / clear parent and keep global transform";
}

Expand Down

0 comments on commit 17c2246

Please sign in to comment.