[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16262] branches/apricot/source: Apricot Branch: fix for a change I made to avoid doing where_is_pose
Brecht Van Lommel
brechtvanlommel at pandora.be
Tue Aug 26 19:39:14 CEST 2008
Revision: 16262
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16262
Author: blendix
Date: 2008-08-26 19:38:39 +0200 (Tue, 26 Aug 2008)
Log Message:
-----------
Apricot Branch: fix for a change I made to avoid doing where_is_pose
too often, didn't work correct for multiple objects sharing the same
armature.
Modified Paths:
--------------
branches/apricot/source/blender/blenkernel/intern/action.c
branches/apricot/source/gameengine/Converter/BL_ArmatureObject.cpp
branches/apricot/source/gameengine/Converter/BL_ArmatureObject.h
branches/apricot/source/gameengine/Converter/BL_SkinDeformer.cpp
branches/apricot/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
Modified: branches/apricot/source/blender/blenkernel/intern/action.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/action.c 2008-08-26 17:09:17 UTC (rev 16261)
+++ branches/apricot/source/blender/blenkernel/intern/action.c 2008-08-26 17:38:39 UTC (rev 16262)
@@ -347,6 +347,7 @@
VECCOPY(pchan->loc, chan->loc);
VECCOPY(pchan->size, chan->size);
QUATCOPY(pchan->quat, chan->quat);
+ Mat4CpyMat4(pchan->chan_mat, (float(*)[4])chan->chan_mat);
pchan->flag= chan->flag;
con= chan->constraints.first;
Modified: branches/apricot/source/gameengine/Converter/BL_ArmatureObject.cpp
===================================================================
--- branches/apricot/source/gameengine/Converter/BL_ArmatureObject.cpp 2008-08-26 17:09:17 UTC (rev 16261)
+++ branches/apricot/source/gameengine/Converter/BL_ArmatureObject.cpp 2008-08-26 17:38:39 UTC (rev 16262)
@@ -53,18 +53,19 @@
: KX_GameObject(sgReplicationInfo,callbacks),
m_objArma(armature),
- m_mrdPose(NULL),
m_lastframe(0.0),
m_activeAct(NULL),
m_activePriority(999),
- m_lastapplyframe(0.0),
- m_lastapplypose(NULL)
+ m_lastapplyframe(0.0)
{
m_armature = get_armature(m_objArma);
- m_pose = m_objArma->pose;
+
+ /* we make a copy of blender object's pose, and then always swap it with
+ * the original pose before calling into blender functions, to deal with
+ * replica's or other objects using the same blender object */
+ copy_pose(&m_pose, m_objArma->pose, 1 /* copy_constraint_channels_hack */);
}
-
CValue* BL_ArmatureObject::GetReplica()
{
BL_ArmatureObject* replica = new BL_ArmatureObject(*this);
@@ -80,42 +81,39 @@
{
KX_GameObject::ProcessReplica(replica);
+ replica->m_pose = NULL;
+ copy_pose(&replica->m_pose, m_pose, 1 /* copy_constraint_channels_hack */);
}
BL_ArmatureObject::~BL_ArmatureObject()
{
- if (m_mrdPose)
- free_pose(m_mrdPose);
+ if (m_pose)
+ free_pose(m_pose);
}
-/* note, you can only call this for exisiting Armature objects, and not mix it with other Armatures */
-/* there is only 1 unique Pose per Armature */
-void BL_ArmatureObject::ApplyPose()
+bool BL_ArmatureObject::VerifyPose()
{
- if(m_lastapplyframe == m_lastframe && m_lastapplypose == m_pose)
- return;
-
- if (m_pose) {
- // copy to armature object
- if (m_objArma->pose != m_pose)/* This should never happen but it does - Campbell */
- extract_pose_from_pose(m_objArma->pose, m_pose);
-
- // is this needed anymore?
- //if (!m_mrdPose)
- // copy_pose (&m_mrdPose, m_pose, 0);
- //else
- // extract_pose_from_pose(m_mrdPose, m_pose);
-
+ if(m_lastapplyframe != m_lastframe) {
+ extract_pose_from_pose(m_objArma->pose, m_pose);
where_is_pose(m_objArma);
-
m_lastapplyframe = m_lastframe;
- m_lastapplypose = m_pose;
+ extract_pose_from_pose(m_pose, m_objArma->pose);
+ return false;
}
+ else
+ return true;
}
+void BL_ArmatureObject::ApplyPose()
+{
+ if(VerifyPose())
+ extract_pose_from_pose(m_objArma->pose, m_pose);
+}
+
void BL_ArmatureObject::SetPose(bPose *pose)
{
- m_pose = pose;
+ extract_pose_from_pose(m_pose, pose);
+ m_lastapplyframe = -1.0;
}
bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority, double curtime)
@@ -176,20 +174,16 @@
/* If the caller supplies a null pose, create a new one. */
/* Otherwise, copy the armature's pose channels into the caller-supplied pose */
- // is this needed anymore?
- //if (!m_mrdPose){
- // copy_pose (&m_mrdPose, m_pose, 0);
- //}
-
if (!*pose) {
// must duplicate the constraints too otherwise we have corruption in free_pose_channels()
// because it will free the blender constraints.
// Ideally, blender should rememeber that the constraints were not copied so that
// free_pose_channels() would not free them.
- copy_pose(pose, m_objArma->pose, 1);
+ copy_pose(pose, m_pose, 1);
}
- else
- extract_pose_from_pose(*pose, m_objArma->pose);
+ else {
+ extract_pose_from_pose(*pose, m_pose);
+ }
}
@@ -205,15 +199,16 @@
bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix)
{
- Object* par_arma = m_objArma;
+ bPoseChannel *pchan;
- ApplyPose();
- bPoseChannel *pchan= get_pose_channel(par_arma->pose, bone->name);
+ VerifyPose();
+ pchan = get_pose_channel(m_pose, bone->name);
if(pchan) {
matrix.setValue(&pchan->pose_mat[0][0]);
return true;
}
+
return false;
}
Modified: branches/apricot/source/gameengine/Converter/BL_ArmatureObject.h
===================================================================
--- branches/apricot/source/gameengine/Converter/BL_ArmatureObject.h 2008-08-26 17:09:17 UTC (rev 16261)
+++ branches/apricot/source/gameengine/Converter/BL_ArmatureObject.h 2008-08-26 17:38:39 UTC (rev 16262)
@@ -59,7 +59,10 @@
void GetMRDPose(struct bPose **pose);
void GetPose(struct bPose **pose);
void SetPose (struct bPose *pose);
+
void ApplyPose();
+ bool VerifyPose();
+
bool SetActiveAction(class BL_ActionActuator *act, short priority, double curtime);
struct bArmature * GetArmature() { return m_armature; }
@@ -79,13 +82,11 @@
Object *m_objArma;
struct bArmature *m_armature;
struct bPose *m_pose;
- struct bPose *m_mrdPose;
double m_lastframe;
class BL_ActionActuator *m_activeAct;
short m_activePriority;
double m_lastapplyframe;
- struct bPose *m_lastapplypose;
};
#endif
Modified: branches/apricot/source/gameengine/Converter/BL_SkinDeformer.cpp
===================================================================
--- branches/apricot/source/gameengine/Converter/BL_SkinDeformer.cpp 2008-08-26 17:09:17 UTC (rev 16261)
+++ branches/apricot/source/gameengine/Converter/BL_SkinDeformer.cpp 2008-08-26 17:38:39 UTC (rev 16262)
@@ -171,8 +171,6 @@
/* but it requires the blender object pointer... */
Object* par_arma = m_armobj->GetArmatureObject();
- m_armobj->ApplyPose();
-
/* store verts locally */
VerifyStorage();
@@ -180,6 +178,8 @@
for (int v =0; v<m_bmesh->totvert; v++)
VECCOPY(m_transverts[v], m_bmesh->mvert[v].co);
+ m_armobj->ApplyPose();
+
// save matrix first
Mat4CpyMat4(obmat, m_objMesh->obmat);
// set reference matrix
Modified: branches/apricot/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
===================================================================
--- branches/apricot/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp 2008-08-26 17:09:17 UTC (rev 16261)
+++ branches/apricot/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp 2008-08-26 17:38:39 UTC (rev 16262)
@@ -199,8 +199,8 @@
darray = NULL;
else if(darray->m_vertex.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_VERTEX)
darray = NULL;
-
- break;
+ else
+ break;
}
else
darray = NULL;
More information about the Bf-blender-cvs
mailing list