std::ostream& base::operator<<(std::ostream& out, const Transform& t) { if (t.identity()) { out << "T:" << Matrix4(); } else { if (t.isTransRotationOnly()) { out << "r:" << t.getRotation() << " t:" << t.getTranslation(); } else out << "T:" << t.getTransform(); } return out; }
Matrix4 Transform::getTransform() const { if (isIdentity) return Matrix4(); if (isPureTranslationRotation) { Matrix4 tm; if (hasRotation) tm = orient.getQuat4(); if (hasTranslation) tm.setTranslationComponent(trans); return tm; } else return t; }
Transform& Transform::invert() { if (isIdentity) return *this; if (!isPureTranslationRotation) t.invert(); else { if (!hasTranslation) orient.invert(); else { if (!hasRotation) trans = -trans; else { t = getTransform(); t.invert(); isPureTranslationRotation = false; hasTranslation = hasRotation = true; isIdentity = (t.equals(Matrix4(1))); } } } return *this; }