[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38095] branches/soc-2011-pepper/source/ gameengine/Ketsji: BGE Animations: Adding preliminary support for blend shape actions on different layers.

Mitchell Stokes mogurijin at gmail.com
Mon Jul 4 23:19:12 CEST 2011


Revision: 38095
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38095
Author:   moguri
Date:     2011-07-04 21:19:11 +0000 (Mon, 04 Jul 2011)
Log Message:
-----------
BGE Animations: Adding preliminary support for blend shape actions on different layers. This, and shape action blending in general still require more work though.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp	2011-07-04 19:41:33 UTC (rev 38094)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp	2011-07-04 21:19:11 UTC (rev 38095)
@@ -64,6 +64,7 @@
 	m_ipo_flags(0),
 	m_pose(NULL),
 	m_blendpose(NULL),
+	m_blendinpose(NULL),
 	m_sg_contr(NULL),
 	m_ptrrna(NULL),
 	m_done(true),
@@ -95,6 +96,8 @@
 		game_free_pose(m_pose);
 	if (m_blendpose)
 		game_free_pose(m_blendpose);
+	if (m_blendinpose)
+		game_free_pose(m_blendinpose);
 	if (m_sg_contr)
 	{
 		m_obj->GetSGNode()->RemoveSGController(m_sg_contr);
@@ -145,18 +148,15 @@
 	// Setup blendin shapes/poses
 	if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
 	{
-		if (!m_blendpose)
-		{
-			BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
-			obj->GetMRDPose(&m_blendpose);
-		}
+		BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
+		obj->GetMRDPose(&m_blendinpose);
 	}
 	else
 	{
 		BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
 		BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
 		
-		obj->GetShape(m_blendshape);
+		obj->GetShape(m_blendinshape);
 
 		// Now that we have the previous blend shape saved, we can clear out the key to avoid any
 		// further interference.
@@ -244,7 +244,7 @@
 }
 
 
-void BL_Action::BlendShape(Key* key, float srcweight)
+void BL_Action::BlendShape(Key* key, float srcweight, std::vector<float>& blendshape)
 {
 	vector<float>::const_iterator it;
 	float dstweight;
@@ -252,8 +252,8 @@
 	
 	dstweight = 1.0F - srcweight;
 	//printf("Dst: %f\tSrc: %f\n", srcweight, dstweight);
-	for (it=m_blendshape.begin(), kb = (KeyBlock*)key->block.first; 
-		 kb && it != m_blendshape.end(); 
+	for (it=blendshape.begin(), kb = (KeyBlock*)key->block.first; 
+		 kb && it != blendshape.end(); 
 		 kb = (KeyBlock*)kb->next, it++) {
 		//printf("OirgKeys: %f\t%f\n", kb->curval, (*it));
 		kb->curval = kb->curval * dstweight + (*it) * srcweight;
@@ -334,7 +334,7 @@
 			float weight = 1.f - (m_blendframe/m_blendin);
 
 			// Blend the poses
-			game_blend_poses(m_pose, m_blendpose, weight);
+			game_blend_poses(m_pose, m_blendinpose, weight);
 		}
 
 
@@ -376,10 +376,17 @@
 					kb->curval = 0.f;
 
 				// Now blend the shape
-				BlendShape(key, weight);
+				BlendShape(key, weight, m_blendinshape);
 			}
 
-			obj->SetActiveAction(NULL, 0, m_localtime);
+			// Handle layer blending
+			if (m_layer_weight >= 0)
+			{
+				obj->GetShape(m_blendshape);
+				BlendShape(key, m_layer_weight, m_blendshape);
+			}
+
+			obj->SetActiveAction(NULL, 0, curtime);
 		}
 
 

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h	2011-07-04 19:41:33 UTC (rev 38094)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h	2011-07-04 21:19:11 UTC (rev 38095)
@@ -43,10 +43,12 @@
 	struct bAction* m_action;
 	struct bPose* m_pose;
 	struct bPose* m_blendpose;
+	struct bPose* m_blendinpose;
 	struct PointerRNA *m_ptrrna;
 	class SG_Controller *m_sg_contr;
 	class KX_GameObject* m_obj;
 	std::vector<float>	m_blendshape;
+	std::vector<float>	m_blendinshape;
 
 	float m_startframe;
 	float m_endframe;
@@ -74,7 +76,7 @@
 	void InitIPO();
 	void SetLocalTime(float curtime);
 	void IncrementBlending(float curtime);
-	void BlendShape(struct Key* key, float srcweight);
+	void BlendShape(struct Key* key, float srcweight, std::vector<float>& blendshape);
 public:
 	BL_Action(class KX_GameObject* gameobj);
 	~BL_Action();




More information about the Bf-blender-cvs mailing list