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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-09-05 00:51:28 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-09-05 00:51:28 +0400
commitcb89decfdcf5e6b2f26376d416633f4ccf0c532d (patch)
treea299a5c8729dd0cb4359d57501fd9e6970141e5d /source/gameengine/Converter/BL_ArmatureObject.cpp
parent2167e5c341f656b2f664b1052d181e8aa32fe698 (diff)
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with scons, make, but not cmake, that seems to have an issue not related to these changes. The changes include: * GLSL support in the viewport and game engine, enable in the game menu in textured draw mode. * Synced and merged part of the duplicated blender and gameengine/ gameplayer drawing code. * Further refactoring of game engine drawing code, especially mesh storage changed a lot. * Optimizations in game engine armatures to avoid recomputations. * A python function to get the framerate estimate in game. * An option take object color into account in materials. * An option to restrict shadow casters to a lamp's layers. * Increase from 10 to 18 texture slots for materials, lamps, word. An extra texture slot shows up once the last slot is used. * Memory limit for undo, not enabled by default yet because it needs the .B.blend to be changed. * Multiple undo for image painting. * An offset for dupligroups, so not all objects in a group have to be at the origin.
Diffstat (limited to 'source/gameengine/Converter/BL_ArmatureObject.cpp')
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp74
1 files changed, 41 insertions, 33 deletions
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index cdfce321713..bf774bf7568 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -53,16 +53,20 @@ BL_ArmatureObject::BL_ArmatureObject(
: KX_GameObject(sgReplicationInfo,callbacks),
m_objArma(armature),
- m_mrdPose(NULL),
m_framePose(NULL),
- m_lastframe(0.),
+ m_lastframe(0.0),
m_activeAct(NULL),
- m_activePriority(999)
+ m_activePriority(999),
+ 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 */
+ m_pose = NULL;
+ copy_pose(&m_pose, m_objArma->pose, 1 /* copy_constraint_channels_hack */);
+}
CValue* BL_ArmatureObject::GetReplica()
{
@@ -79,34 +83,39 @@ void BL_ArmatureObject::ProcessReplica(BL_ArmatureObject *replica)
{
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_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;
+ 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)
@@ -162,6 +171,7 @@ void BL_ArmatureObject::GetPose(bPose **pose)
if (*pose == m_pose)
// no need to copy if the pointers are the same
return;
+
extract_pose_from_pose(*pose, m_pose);
}
}
@@ -171,20 +181,16 @@ void BL_ArmatureObject::GetMRDPose(bPose **pose)
/* 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_pose);
}
- else
- extract_pose_from_pose(*pose, m_objArma->pose);
}
@@ -198,16 +204,18 @@ double BL_ArmatureObject::GetLastFrame()
return m_lastframe;
}
-bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix) const
+bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix)
{
- Object* par_arma = m_objArma;
- where_is_pose(par_arma);
- bPoseChannel *pchan= get_pose_channel(par_arma->pose, bone->name);
+ bPoseChannel *pchan;
+
+ ApplyPose();
+ pchan = get_pose_channel(m_objArma->pose, bone->name);
if(pchan) {
matrix.setValue(&pchan->pose_mat[0][0]);
return true;
}
+
return false;
}