[Bf-blender-cvs] [51810ed] soc-2014-bge: gameengine scenegraph: whitespace and comment cleanup - KX_BoneParentRelation
Ines Almeida
noreply at git.blender.org
Sat Jul 19 03:41:59 CEST 2014
Commit: 51810ed3a3148166d22ce704e38615dd5a34ee43
Author: Ines Almeida
Date: Sat Jul 19 01:41:22 2014 +0100
https://developer.blender.org/rB51810ed3a3148166d22ce704e38615dd5a34ee43
gameengine scenegraph: whitespace and comment cleanup - KX_BoneParentRelation
===================================================================
M source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
M source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h
===================================================================
diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
index 19b9d13..d7487a4 100644
--- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
+++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
@@ -38,44 +38,24 @@
#include "BL_ArmatureObject.h"
-/**
- * Implementation of classes defined in KX_SG_BoneParentNodeRelationship.h
- */
-
-/**
- * first of all KX_SG_BoneParentRelation
- */
-
- KX_BoneParentRelation *
-KX_BoneParentRelation::
-New(Bone* bone
-) {
+KX_BoneParentRelation* KX_BoneParentRelation::New(Bone* bone)
+{
return new KX_BoneParentRelation(bone);
}
- bool
-KX_BoneParentRelation::
-UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
-) {
+bool KX_BoneParentRelation::UpdateChildCoordinates(SG_Spatial * child, const SG_Spatial * parent, bool& parentUpdated)
+{
MT_assert(child != NULL);
-
+
// This way of accessing child coordinates is a bit cumbersome
// be nice to have non constant reference access to these values.
+ const MT_Vector3 & child_l_scale = child->GetLocalScale();
+ const MT_Point3 & child_l_pos = child->GetLocalPosition();
+ const MT_Matrix3x3 & child_l_orientation = child->GetLocalOrientation();
- const MT_Vector3 & child_scale = child->GetLocalScale();
- const MT_Point3 & child_pos = child->GetLocalPosition();
- const MT_Matrix3x3 & child_rotation = child->GetLocalOrientation();
- // we don't know if the armature has been updated or not, assume yes
- parentUpdated = true;
-
- // the childs world locations which we will update.
-
MT_Vector3 child_w_scale;
MT_Point3 child_w_pos;
- MT_Matrix3x3 child_w_rotation;
+ MT_Matrix3x3 child_w_orientation;
bool valid_parent_transform = false;
@@ -88,68 +68,62 @@ UpdateChildCoordinates(
if (armature->GetBoneMatrix(m_bone, parent_matrix))
{
// Get the child's transform, and the bone matrix.
- MT_Matrix4x4 child_transform (
- MT_Transform(child_pos + MT_Vector3(0.0, armature->GetBoneLength(m_bone), 0.0),
- child_rotation.scaled(
- child_scale[0],
- child_scale[1],
- child_scale[2])));
-
- // The child's world transform is parent * child
- parent_matrix = parent->GetWorldTransform() * parent_matrix;
- child_transform = parent_matrix * child_transform;
+ MT_Matrix4x4 child_transform (
+ MT_Transform(
+ child_l_pos + MT_Vector3(0.0, armature->GetBoneLength(m_bone), 0.0),
+ child_l_orientation.scaled(child_l_scale[0], child_l_scale[1], child_l_scale[2])));
+
+ parent_matrix = parent->GetWorldTransform() * parent_matrix; //the bone is relative to the armature
+ child_transform = parent_matrix * child_transform; // The child's world transform is parent * child
// Recompute the child transform components from the transform.
child_w_scale.setValue(
MT_Vector3(child_transform[0][0], child_transform[0][1], child_transform[0][2]).length(),
MT_Vector3(child_transform[1][0], child_transform[1][1], child_transform[1][2]).length(),
MT_Vector3(child_transform[2][0], child_transform[2][1], child_transform[2][2]).length());
- child_w_rotation.setValue(child_transform[0][0], child_transform[0][1], child_transform[0][2],
+ child_w_orientation.setValue(
+ child_transform[0][0], child_transform[0][1], child_transform[0][2],
child_transform[1][0], child_transform[1][1], child_transform[1][2],
child_transform[2][0], child_transform[2][1], child_transform[2][2]);
- child_w_rotation.scale(1.0/child_w_scale[0], 1.0/child_w_scale[1], 1.0/child_w_scale[2]);
-
+ child_w_orientation.scale(1.0/child_w_scale[0], 1.0/child_w_scale[1], 1.0/child_w_scale[2]);
child_w_pos = MT_Point3(child_transform[0][3], child_transform[1][3], child_transform[2][3]);
-
+
valid_parent_transform = true;
}
}
- }
-
+ }
+
if (valid_parent_transform)
{
child->SetWorldScale(child_w_scale);
child->SetWorldPosition(child_w_pos);
- child->SetWorldOrientation(child_w_rotation);
+ child->SetWorldOrientation(child_w_orientation);
}
else {
+ /* the parent is null or not an armature */
child->SetWorldFromLocalTransform();
}
+
+ parentUpdated = true; //this variable is going to be used to update the children of this child
child->ClearModified();
// this node must always be updated, so reschedule it for next time
child->ActivateRecheduleUpdateCallback();
return valid_parent_transform;
}
- SG_ParentRelation *
-KX_BoneParentRelation::
-NewCopy(
-) {
- KX_BoneParentRelation* bone_parent = new KX_BoneParentRelation(m_bone);
- return bone_parent;
+SG_ParentRelation* KX_BoneParentRelation::NewCopy()
+{
+ return new KX_BoneParentRelation(m_bone);
}
-KX_BoneParentRelation::
-~KX_BoneParentRelation(
-) {
+KX_BoneParentRelation::~KX_BoneParentRelation()
+{
//nothing to do
}
-KX_BoneParentRelation::
-KX_BoneParentRelation(Bone* bone
-)
-: m_bone(bone)
+KX_BoneParentRelation::KX_BoneParentRelation(Bone* bone)
+ : m_bone(bone)
{
// nothing to do
}
diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h
index 6f4fd48..9c983e6 100644
--- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h
+++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h
@@ -39,53 +39,33 @@
struct Bone;
/**
- * Bone parent relationship parents a child SG_Spatial frame to a
- * bone in an armature object.
+ * Bone parent relationship parents a child SG_Spatial frame to a bone in an armature object.
*/
class KX_BoneParentRelation : public SG_ParentRelation
{
public :
/**
- * Allocate and construct a new KX_SG_BoneParentRelation
- * on the heap.
- *
- * bone is the bone id to use. Currently it is a pointer
- * to a Blender struct Bone - this should be fixed if
+ * Allocate and construct a new KX_SG_BoneParentRelation on the heap.
*/
-
- static
- KX_BoneParentRelation *
- New(Bone* bone
- );
+ static KX_BoneParentRelation* New(Bone* bone);
/**
- * Updates the childs world coordinates relative to the parent's
- * world coordinates.
- *
+ * Updates the child's world coordinates based upon the local ones and relative to the parent's world coordinates.
* Parent should be a BL_ArmatureObject.
*/
- bool
- UpdateChildCoordinates(
- SG_Spatial * child,
- const SG_Spatial * parent,
- bool& parentUpdated
- );
+ bool UpdateChildCoordinates(SG_Spatial *child, const SG_Spatial *parent, bool &parentUpdated);
/**
* Create a copy of this relationship
*/
- SG_ParentRelation *
- NewCopy(
- );
+ SG_ParentRelation* NewCopy();
- ~KX_BoneParentRelation(
- );
+ ~KX_BoneParentRelation();
private :
Bone* m_bone;
- KX_BoneParentRelation(Bone* bone
- );
+ KX_BoneParentRelation(Bone* bone);
#ifdef WITH_CXX_GUARDEDALLOC
@@ -93,4 +73,4 @@ private :
#endif
};
-#endif
+#endif /* __KX_SG_BONEPARENTNODERELATIONSHIP_H__ */
More information about the Bf-blender-cvs
mailing list