Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/WolfireGames/overgrowth.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Graphics/bonetransform.cpp')
-rw-r--r--Source/Graphics/bonetransform.cpp44
1 files changed, 17 insertions, 27 deletions
diff --git a/Source/Graphics/bonetransform.cpp b/Source/Graphics/bonetransform.cpp
index 46a50e49..6f045577 100644
--- a/Source/Graphics/bonetransform.cpp
+++ b/Source/Graphics/bonetransform.cpp
@@ -1,7 +1,7 @@
//-----------------------------------------------------------------------------
// Name: bonetransform.cpp
// Developer: Wolfire Games LLC
-// Description:
+// Description:
// License: Read below
//-----------------------------------------------------------------------------
//
@@ -29,76 +29,66 @@
#include <cmath>
-const BoneTransform& BoneTransform::operator=( const mat4 &other )
-{
+const BoneTransform& BoneTransform::operator=(const mat4& other) {
rotation = QuaternionFromMat4(other);
origin = other.GetTranslationPart();
return (*this);
}
-BoneTransform invert( const BoneTransform& transform )
-{
+BoneTransform invert(const BoneTransform& transform) {
BoneTransform inverted;
inverted.rotation = invert(transform.rotation);
inverted.origin = inverted.rotation * -transform.origin;
return inverted;
}
-BoneTransform operator*( const BoneTransform& a, const BoneTransform& b )
-{
+BoneTransform operator*(const BoneTransform& a, const BoneTransform& b) {
BoneTransform result;
result.rotation = a.rotation * b.rotation;
result.origin = a.rotation * b.origin + a.origin;
- //result = a.GetMat4() * b.GetMat4();
+ // result = a.GetMat4() * b.GetMat4();
return result;
}
-BoneTransform operator*( const quaternion& a, const BoneTransform& b )
-{
+BoneTransform operator*(const quaternion& a, const BoneTransform& b) {
BoneTransform result;
result.rotation = a * b.rotation;
result.origin = a * b.origin;
return result;
}
-vec3 operator*( const BoneTransform& a, const vec3& b )
-{
+vec3 operator*(const BoneTransform& a, const vec3& b) {
vec3 result = a.rotation * b + a.origin;
return result;
}
-BoneTransform mix( const BoneTransform &a, const BoneTransform &b, float alpha )
-{
+BoneTransform mix(const BoneTransform& a, const BoneTransform& b, float alpha) {
BoneTransform result;
result.origin = mix(a.origin, b.origin, alpha);
result.rotation = mix(a.rotation, b.rotation, alpha);
return result;
}
-mat4 BoneTransform::GetMat4() const
-{
+mat4 BoneTransform::GetMat4() const {
mat4 matrix = Mat4FromQuaternion(rotation);
matrix.SetTranslationPart(origin);
return matrix;
}
-BoneTransform::BoneTransform( const mat4 &other )
-{
+BoneTransform::BoneTransform(const mat4& other) {
(*this) = other;
}
-BoneTransform::BoneTransform()
-{}
+BoneTransform::BoneTransform() {}
-BoneTransform ApplyParentRotations(const std::vector<BoneTransform> &matrices,
- int id,
- const std::vector<int> &parents)
-{
+BoneTransform ApplyParentRotations(const std::vector<BoneTransform>& matrices,
+ int id,
+ const std::vector<int>& parents) {
int parent_id = parents[id];
- if(parent_id == -1){
- return matrices[id];
+ if (parent_id == -1) {
+ return matrices[id];
} else {
- return ApplyParentRotations(matrices,parent_id,parents) *
+ return ApplyParentRotations(matrices, parent_id, parents) *
matrices[id];
}
}