[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38046] branches/soc-2011-pepper/source: BGE Animations: Adding in layer weights to allow for layer blending.

Mitchell Stokes mogurijin at gmail.com
Sun Jul 3 03:59:21 CEST 2011


Revision: 38046
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38046
Author:   moguri
Date:     2011-07-03 01:59:17 +0000 (Sun, 03 Jul 2011)
Log Message:
-----------
BGE Animations: Adding in layer weights to allow for layer blending.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/editors/space_logic/logic_window.c
    branches/soc-2011-pepper/source/blender/makesdna/DNA_actuator_types.h
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_actuator.c
    branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp
    branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.h
    branches/soc-2011-pepper/source/gameengine/Converter/BL_ArmatureObject.cpp
    branches/soc-2011-pepper/source/gameengine/Converter/BL_ArmatureObject.h
    branches/soc-2011-pepper/source/gameengine/Converter/KX_ConvertActuators.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.h
    branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.h

Modified: branches/soc-2011-pepper/source/blender/editors/space_logic/logic_window.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/space_logic/logic_window.c	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/blender/editors/space_logic/logic_window.c	2011-07-03 01:59:17 UTC (rev 38046)
@@ -3713,6 +3713,7 @@
 
 	row= uiLayoutRow(layout, 0);
 	uiItemR(row, ptr, "layer", 0, NULL, ICON_NONE);
+	uiItemR(row, ptr, "layer_weight", 0, NULL, ICON_NONE);
 
 	row= uiLayoutRow(layout, 0);
 	uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE);

Modified: branches/soc-2011-pepper/source/blender/makesdna/DNA_actuator_types.h
===================================================================
--- branches/soc-2011-pepper/source/blender/makesdna/DNA_actuator_types.h	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/blender/makesdna/DNA_actuator_types.h	2011-07-03 01:59:17 UTC (rev 38046)
@@ -59,8 +59,9 @@
 	short	layer;			/* Animation layer */
 	short	end_reset;	/* Ending the actuator (negative pulse) wont reset the the action to its starting frame */
 	short	strideaxis;		/* Displacement axis */
-	short	pad[3];
+	short	pad;
 	float	stridelength;	/* Displacement incurred by cycle */ // not in use
+	float	layer_weight;	/* How much of the previous layer to use for blending. (<0 = disable, 0 = add mode) */
 } bActionActuator;												
 
 typedef struct Sound3D

Modified: branches/soc-2011-pepper/source/blender/makesrna/intern/rna_actuator.c
===================================================================
--- branches/soc-2011-pepper/source/blender/makesrna/intern/rna_actuator.c	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/blender/makesrna/intern/rna_actuator.c	2011-07-03 01:59:17 UTC (rev 38046)
@@ -631,6 +631,11 @@
 	RNA_def_property_ui_text(prop, "Layer", "The animation layer to play the action on");
 	RNA_def_property_update(prop, NC_LOGIC, NULL);
 
+	prop= RNA_def_property(srna, "layer_weight", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_range(prop, 0.0, 1.0);
+	RNA_def_property_ui_text(prop, "Layer Weight", "How much of the previous layer to blend into this one (0 = add mode)");
+	RNA_def_property_update(prop, NC_LOGIC, NULL);
+
 	prop= RNA_def_property(srna, "frame_property", PROP_STRING, PROP_NONE);
 	RNA_def_property_string_sdna(prop, NULL, "frameProp");
 	RNA_def_property_ui_text(prop, "Frame Property", "Assign the action's current frame number to this property");

Modified: branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp	2011-07-03 01:59:17 UTC (rev 38046)
@@ -184,7 +184,7 @@
 	if (!m_is_going && bPositiveEvent)
 	{		
 		m_is_going = true;
-		if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, 0, m_ipo_flags) && m_end_reset)
+		if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, m_layer_weight, m_ipo_flags) && m_end_reset)
 			obj->SetActionFrame(m_layer, m_localtime);
 	}
 	else if (m_is_going && bNegativeEvent)
@@ -203,7 +203,7 @@
 		else if (m_playtype == ACT_ACTION_LOOP_END)
 		{
 			// Convert into a play and let it finish
-			obj->PlayAction(m_action->id.name+2, start, end, m_layer, 0, 0, BL_Action::ACT_MODE_PLAY, 0, m_ipo_flags);
+			obj->PlayAction(m_action->id.name+2, start, end, m_layer, 0, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags);
 			obj->SetActionFrame(m_layer, m_localtime);
 
 			return true;

Modified: branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.h	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.h	2011-07-03 01:59:17 UTC (rev 38046)
@@ -53,6 +53,7 @@
 						short	blendin,
 						short	priority,
 						short	layer,
+						float	layer_weight,
 						short	ipo_flags,
 						short	end_reset,
 						float	stride) 
@@ -72,6 +73,7 @@
 		m_playtype(playtype),
 		m_priority(priority),
 		m_layer(layer),
+		m_layer_weight(layer_weight),
 		m_ipo_flags(ipo_flags),
 		m_end_reset(end_reset),
 		m_is_going(false),
@@ -165,6 +167,7 @@
 	float	m_blendin;
 	float	m_blendstart;
 	float	m_stridelength;
+	float	m_layer_weight;
 	short	m_playtype;
 	short	m_priority;
 	short	m_layer;

Modified: branches/soc-2011-pepper/source/gameengine/Converter/BL_ArmatureObject.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Converter/BL_ArmatureObject.cpp	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/gameengine/Converter/BL_ArmatureObject.cpp	2011-07-03 01:59:17 UTC (rev 38046)
@@ -137,13 +137,14 @@
 
 
 /* Only allowed for Poses with identical channels */
-void game_blend_poses(bPose *dst, bPose *src, float srcweight, short mode)
+void game_blend_poses(bPose *dst, bPose *src, float srcweight/*, short mode*/)
 {	
 	bPoseChannel *dchan;
 	const bPoseChannel *schan;
 	bConstraint *dcon, *scon;
 	float dstweight;
 	int i;
+	short mode = ACTSTRIPMODE_BLEND;
 
 	switch (mode){
 	case ACTSTRIPMODE_BLEND:

Modified: branches/soc-2011-pepper/source/gameengine/Converter/BL_ArmatureObject.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Converter/BL_ArmatureObject.h	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/gameengine/Converter/BL_ArmatureObject.h	2011-07-03 01:59:17 UTC (rev 38046)
@@ -145,7 +145,7 @@
 };
 
 /* Pose function specific to the game engine */
-void game_blend_poses(struct bPose *dst, struct bPose *src, float srcweight, short mode); /* was blend_poses */
+void game_blend_poses(struct bPose *dst, struct bPose *src, float srcweight/*, short mode*/); /* was blend_poses */
 //void extract_pose_from_pose(struct bPose *pose, const struct bPose *src);
 void game_copy_pose(struct bPose **dst, struct bPose *src, int copy_con);
 void game_free_pose(struct bPose *pose);

Modified: branches/soc-2011-pepper/source/gameengine/Converter/KX_ConvertActuators.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Converter/KX_ConvertActuators.cpp	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/gameengine/Converter/KX_ConvertActuators.cpp	2011-07-03 01:59:17 UTC (rev 38046)
@@ -220,6 +220,7 @@
 					actact->blendin,
 					actact->priority,
 					actact->layer,
+					actact->layer_weight,
 					ipo_flags,
 					actact->end_reset,
 					actact->stridelength

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp	2011-07-03 01:59:17 UTC (rev 38046)
@@ -46,7 +46,6 @@
 #include "BKE_action.h"
 #include "RNA_access.h"
 #include "RNA_define.h"
-#include "DNA_nla_types.h"
 }
 
 BL_Action::BL_Action(class KX_GameObject* gameobj)
@@ -111,7 +110,7 @@
 					short priority,
 					float blendin,
 					short play_mode,
-					short blend_mode,
+					float layer_weight,
 					short ipo_flags,
 					float playback_speed)
 {
@@ -173,11 +172,11 @@
 	m_endframe = end;
 	m_blendin = blendin;
 	m_playmode = play_mode;
-	m_blendmode = blend_mode;
 	m_endtime = 0.f;
 	m_blendframe = 0.f;
 	m_blendstart = 0.f;
 	m_speed = playback_speed;
+	m_layer_weight = layer_weight;
 	
 	m_done = false;
 
@@ -335,15 +334,15 @@
 			float weight = 1.f - (m_blendframe/m_blendin);
 
 			// Blend the poses
-			game_blend_poses(m_pose, m_blendpose, weight, ACTSTRIPMODE_BLEND);
+			game_blend_poses(m_pose, m_blendpose, weight);
 		}
 
 
 		// Handle layer blending
-		if (m_blendmode != ACT_BLEND_NONE)
+		if (m_layer_weight >= 0)
 		{
 			obj->GetMRDPose(&m_blendpose);
-			game_blend_poses(m_pose, m_blendpose, 1.f, ACTSTRIPMODE_ADD);
+			game_blend_poses(m_pose, m_blendpose, m_layer_weight);
 		}
 
 		obj->SetPose(m_pose);

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h	2011-07-03 01:59:17 UTC (rev 38046)
@@ -58,12 +58,13 @@
 	float m_blendframe;
 	float m_blendstart;
 
+	float m_layer_weight;
+
 	float m_speed;
 
 	short m_priority;
 
 	short m_playmode;
-	short m_blendmode;
 
 	short m_ipo_flags;
 
@@ -84,7 +85,7 @@
 			short priority,
 			float blendin,
 			short play_mode,
-			short blend_mode,
+			float layer_weight,
 			short ipo_flags,
 			float playback_speed);
 	void Stop();
@@ -107,13 +108,6 @@
 
 	enum
 	{
-		ACT_BLEND_NONE = 0,
-		ACT_BLEND_MIX,
-		ACT_BLEND_MAX,
-	};
-
-	enum
-	{
 		ACT_IPOFLAG_FORCE = 1,
 		ACT_IPOFLAG_LOCAL = 2,
 		ACT_IPOFLAG_ADD = 4,

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.cpp	2011-07-02 18:24:05 UTC (rev 38045)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.cpp	2011-07-03 01:59:17 UTC (rev 38046)
@@ -63,14 +63,14 @@
 								short priority,
 								float blendin,
 								short play_mode,
-								short blend_mode,
+								float layer_weight,
 								short ipo_flags,
 								float playback_speed)
 {
 	// Disable layer blending on the first layer
-	if (layer == 0) blend_mode = BL_Action::ACT_BLEND_NONE;
+	if (layer == 0) layer_weight = -1.f;
 
-	return m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
+	return m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, layer_weight, ipo_flags, playback_speed);
 }
 
 void BL_ActionManager::StopAction(short layer)


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list