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:
authorCampbell Barton <ideasman42@gmail.com>2010-09-17 20:45:42 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-09-17 20:45:42 +0400
commit62a8be4817ab5b2f4204e1fad902f8bade4d22b3 (patch)
treec1ccdc1bd95a69f5d27abf8b6929e1cf33b22276 /source/blender/makesrna/intern/rna_pose_api.c
parent6717b75ecdd7d9702b280dc3fccccc172e261d38 (diff)
patch [#23840] [Pose]Bone.envelope(point=(0,0,0))
from Dan Eicher (dna) Basically just wraps distfactor_to_bone() and passes the correct head/tail depending on which bone type it's called from. note: renamed envelope() --> evaluate_envelope()
Diffstat (limited to 'source/blender/makesrna/intern/rna_pose_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_pose_api.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_pose_api.c b/source/blender/makesrna/intern/rna_pose_api.c
index 922fa285f84..48e8a1e6940 100644
--- a/source/blender/makesrna/intern/rna_pose_api.c
+++ b/source/blender/makesrna/intern/rna_pose_api.c
@@ -41,8 +41,16 @@
/* #include "DNA_anim_types.h" */
#include "DNA_action_types.h" /* bPose */
+#include "BKE_armature.h"
+static float rna_PoseBone_do_envelope(bPoseChannel *chan, float *vec)
+{
+ Bone *bone = chan->bone;
+
+ float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f;
+ return distfactor_to_bone(vec, chan->pose_head, chan->pose_tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
+}
#else
void RNA_api_pose(StructRNA *srna)
@@ -53,8 +61,16 @@ void RNA_api_pose(StructRNA *srna)
void RNA_api_pose_channel(StructRNA *srna)
{
-// FunctionRNA *func;
-// PropertyRNA *parm;
+ PropertyRNA *parm;
+ FunctionRNA *func;
+
+ func= RNA_def_function(srna, "envelope", "rna_PoseBone_do_envelope");
+ RNA_def_function_ui_description(func, "Calculate bone envelope at given point.");
+ parm= RNA_def_float_vector_xyz(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "Position in 3d space to evaluate", -FLT_MAX, FLT_MAX);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* return value */
+ parm= RNA_def_float(func, "factor", 0, -FLT_MAX, FLT_MAX, "Factor", "Envelope factor", -FLT_MAX, FLT_MAX);
+ RNA_def_function_return(func, parm);
}