[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44615] trunk/blender: option for the Armature Actuator to change the influence of a bone constraint .
Dalai Felinto
dfelinto at gmail.com
Sat Mar 3 03:47:11 CET 2012
Revision: 44615
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44615
Author: dfelinto
Date: 2012-03-03 02:47:01 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
option for the Armature Actuator to change the influence of a bone constraint.
Also adds DampedTrackTo to the list of supported constraints in the BGE
Test file:
http://www.pasteall.org/blend/11715
Patch developed as part of a project to NF-UBC Nereus Program.
Development time 'sponsored' by the project.
www.nereusprogram.org
Modified Paths:
--------------
trunk/blender/doc/python_api/rst/bge.types.rst
trunk/blender/source/blender/blenkernel/intern/sca.c
trunk/blender/source/blender/editors/space_logic/logic_window.c
trunk/blender/source/blender/makesdna/DNA_actuator_types.h
trunk/blender/source/blender/makesrna/intern/rna_actuator.c
trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.cpp
trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.h
trunk/blender/source/gameengine/Converter/BL_ArmatureConstraint.h
trunk/blender/source/gameengine/Converter/BL_ArmatureObject.cpp
trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp
Modified: trunk/blender/doc/python_api/rst/bge.types.rst
===================================================================
--- trunk/blender/doc/python_api/rst/bge.types.rst 2012-03-03 01:43:44 UTC (rev 44614)
+++ trunk/blender/doc/python_api/rst/bge.types.rst 2012-03-03 02:47:01 UTC (rev 44615)
@@ -4518,10 +4518,16 @@
.. data:: KX_ACT_ARMATURE_SETWEIGHT
- Change weight of (only for IK constraint).
+ Change weight of constraint (IK only).
:value: 4
+ .. data:: KX_ACT_ARMATURE_SETINFLUENCE
+
+ Change influence of constraint.
+
+ :value: 5
+
.. attribute:: type
The type of action that the actuator executes when it is active.
@@ -4566,6 +4572,12 @@
A weight of 0 disables a constraint while still updating constraint runtime values (see :class:`BL_ArmatureConstraint`)
+ .. attribute:: influence
+
+ The influence this actuator will set on the constraint it controls.
+
+ :type: float.
+
.. class:: KX_ArmatureSensor(SCA_ISensor)
Armature sensor detect conditions on armatures.
Modified: trunk/blender/source/blender/blenkernel/intern/sca.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sca.c 2012-03-03 01:43:44 UTC (rev 44614)
+++ trunk/blender/source/blender/blenkernel/intern/sca.c 2012-03-03 02:47:01 UTC (rev 44615)
@@ -395,6 +395,7 @@
bRandomActuator *ra;
bSoundActuator *sa;
bSteeringActuator *sta;
+ bArmatureActuator *arma;
if(act->data) MEM_freeN(act->data);
act->data= NULL;
@@ -468,6 +469,8 @@
break;
case ACT_ARMATURE:
act->data = MEM_callocN(sizeof( bArmatureActuator ), "armature act");
+ arma = act->data;
+ arma->influence = 1.f;
break;
case ACT_STEERING:
act->data = MEM_callocN(sizeof( bSteeringActuator), "steering act");
Modified: trunk/blender/source/blender/editors/space_logic/logic_window.c
===================================================================
--- trunk/blender/source/blender/editors/space_logic/logic_window.c 2012-03-03 01:43:44 UTC (rev 44614)
+++ trunk/blender/source/blender/editors/space_logic/logic_window.c 2012-03-03 02:47:01 UTC (rev 44615)
@@ -3806,6 +3806,16 @@
uiItemR(layout, ptr, "weight", 0, NULL, ICON_NONE);
break;
+ case ACT_ARM_SETINFLUENCE:
+ if (ob->pose) {
+ uiItemPointerR(layout, ptr, "bone", &pose_ptr, "bones", NULL, ICON_BONE_DATA);
+
+ if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, aa->posechannel, &pchan_ptr))
+ uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE);
+ }
+
+ uiItemR(layout, ptr, "influence", 0, NULL, ICON_NONE);
+ break;
}
}
Modified: trunk/blender/source/blender/makesdna/DNA_actuator_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_actuator_types.h 2012-03-03 01:43:44 UTC (rev 44614)
+++ trunk/blender/source/blender/makesdna/DNA_actuator_types.h 2012-03-03 02:47:01 UTC (rev 44615)
@@ -224,6 +224,8 @@
char constraint[64]; /* MAX_NAME */
int type; /* 0=run, 1=enable, 2=disable, 3=set target, 4=set weight */
float weight;
+ float influence;
+ float pad;
struct Object *target;
struct Object *subtarget;
} bArmatureActuator;
@@ -511,8 +513,9 @@
#define ACT_ARM_DISABLE 2
#define ACT_ARM_SETTARGET 3
#define ACT_ARM_SETWEIGHT 4
-/* update this define if more type are addedd */
-#define ACT_ARM_MAXTYPE 4
+#define ACT_ARM_SETINFLUENCE 5
+/* update this define if more types are added */
+#define ACT_ARM_MAXTYPE 5
/* stateactuator->type */
#define ACT_STATE_SET 0
Modified: trunk/blender/source/blender/makesrna/intern/rna_actuator.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_actuator.c 2012-03-03 01:43:44 UTC (rev 44614)
+++ trunk/blender/source/blender/makesrna/intern/rna_actuator.c 2012-03-03 02:47:01 UTC (rev 44615)
@@ -1887,6 +1887,7 @@
{ACT_ARM_DISABLE, "DISABLE", 0, "Disable", ""},
{ACT_ARM_SETTARGET, "SETTARGET", 0, "Set Target", ""},
{ACT_ARM_SETWEIGHT, "SETWEIGHT", 0, "Set Weight", ""},
+ {ACT_ARM_SETINFLUENCE, "SETINFLUENCE", 0, "Set Influence", ""},
{0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "ArmatureActuator", "Actuator");
@@ -1927,6 +1928,12 @@
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_text(prop, "Weight", "Weight of this constraint");
RNA_def_property_update(prop, NC_LOGIC, NULL);
+
+ prop= RNA_def_property(srna, "influence", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "influence");
+ RNA_def_property_range(prop, 0.0, 1.0);
+ RNA_def_property_ui_text(prop, "Influence", "Influence of this constraint");
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
}
static void rna_def_steering_actuator(BlenderRNA *brna)
Modified: trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.cpp 2012-03-03 01:43:44 UTC (rev 44614)
+++ trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.cpp 2012-03-03 02:47:01 UTC (rev 44615)
@@ -53,7 +53,8 @@
const char *constraintname,
KX_GameObject* targetobj,
KX_GameObject* subtargetobj,
- float weight) :
+ float weight,
+ float influence) :
SCA_IActuator(obj, KX_ACT_ARMATURE),
m_constraint(NULL),
m_gametarget(targetobj),
@@ -61,6 +62,7 @@
m_posechannel(posechannel),
m_constraintname(constraintname),
m_weight(weight),
+ m_influence(influence),
m_type(type)
{
if (m_gametarget)
@@ -173,6 +175,10 @@
if (m_constraint)
m_constraint->SetWeight(m_weight);
break;
+ case ACT_ARM_SETINFLUENCE:
+ if (m_constraint)
+ m_constraint->SetInfluence(m_influence);
+ break;
}
}
return result;
@@ -216,6 +222,7 @@
KX_PYATTRIBUTE_RW_FUNCTION("target", BL_ArmatureActuator, pyattr_get_object, pyattr_set_object),
KX_PYATTRIBUTE_RW_FUNCTION("subtarget", BL_ArmatureActuator, pyattr_get_object, pyattr_set_object),
KX_PYATTRIBUTE_FLOAT_RW("weight",0.0f,1.0f,BL_ArmatureActuator,m_weight),
+ KX_PYATTRIBUTE_FLOAT_RW("influence",0.0f,1.0f,BL_ArmatureActuator,m_influence),
KX_PYATTRIBUTE_INT_RW("type",0,ACT_ARM_MAXTYPE,false,BL_ArmatureActuator,m_type),
{ NULL } //Sentinel
};
Modified: trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.h 2012-03-03 01:43:44 UTC (rev 44614)
+++ trunk/blender/source/gameengine/Converter/BL_ArmatureActuator.h 2012-03-03 02:47:01 UTC (rev 44615)
@@ -54,7 +54,8 @@
const char *constraintname,
KX_GameObject* targetobj,
KX_GameObject* subtargetobj,
- float weight);
+ float weight,
+ float influence);
virtual ~BL_ArmatureActuator();
@@ -88,6 +89,7 @@
STR_String m_posechannel;
STR_String m_constraintname;
float m_weight;
+ float m_influence;
int m_type;
};
Modified: trunk/blender/source/gameengine/Converter/BL_ArmatureConstraint.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ArmatureConstraint.h 2012-03-03 01:43:44 UTC (rev 44614)
+++ trunk/blender/source/gameengine/Converter/BL_ArmatureConstraint.h 2012-03-03 02:47:01 UTC (rev 44615)
@@ -104,6 +104,11 @@
con->weight = weight;
}
}
+ void SetInfluence(float influence)
+ {
+ if (m_constraint)
+ m_constraint->enforce = influence;
+ }
void SetTarget(KX_GameObject* target);
void SetSubtarget(KX_GameObject* subtarget);
Modified: trunk/blender/source/gameengine/Converter/BL_ArmatureObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ArmatureObject.cpp 2012-03-03 01:43:44 UTC (rev 44614)
+++ trunk/blender/source/gameengine/Converter/BL_ArmatureObject.cpp 2012-03-03 02:47:01 UTC (rev 44615)
@@ -287,6 +287,7 @@
// which constraint should we support?
switch (pcon->type) {
case CONSTRAINT_TYPE_TRACKTO:
+ case CONSTRAINT_TYPE_DAMPTRACK:
case CONSTRAINT_TYPE_KINEMATIC:
case CONSTRAINT_TYPE_ROTLIKE:
case CONSTRAINT_TYPE_LOCLIKE:
Modified: trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp 2012-03-03 01:43:44 UTC (rev 44614)
+++ trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp 2012-03-03 02:47:01 UTC (rev 44615)
@@ -1060,7 +1060,7 @@
bArmatureActuator* armAct = (bArmatureActuator*) bact->data;
KX_GameObject *tmpgob = converter->FindGameObject(armAct->target);
KX_GameObject *subgob = converter->FindGameObject(armAct->subtarget);
- BL_ArmatureActuator* tmparmact = new BL_ArmatureActuator(gameobj, armAct->type, armAct->posechannel, armAct->constraint, tmpgob, subgob, armAct->weight);
+ BL_ArmatureActuator* tmparmact = new BL_ArmatureActuator(gameobj, armAct->type, armAct->posechannel, armAct->constraint, tmpgob, subgob, armAct->weight, armAct->influence);
baseact = tmparmact;
break;
}
More information about the Bf-blender-cvs
mailing list