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
path: root/source
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
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')
-rw-r--r--source/blender/makesrna/intern/rna_armature.c2
-rw-r--r--source/blender/makesrna/intern/rna_armature_api.c22
-rw-r--r--source/blender/makesrna/intern/rna_internal.h1
-rw-r--r--source/blender/makesrna/intern/rna_pose_api.c20
4 files changed, 42 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 7d036982007..d42cf625898 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -581,6 +581,8 @@ static void rna_def_bone(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "arm_head");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Armature-Relative Head", "Location of head end of the bone relative to armature");
+
+ RNA_api_bone(srna);
}
static void rna_def_edit_bone(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_armature_api.c b/source/blender/makesrna/intern/rna_armature_api.c
index cd78bd6e578..4e161e5b22e 100644
--- a/source/blender/makesrna/intern/rna_armature_api.c
+++ b/source/blender/makesrna/intern/rna_armature_api.c
@@ -36,7 +36,7 @@
#include <stddef.h>
#include "BLI_blenlib.h"
-
+#include "BKE_armature.h"
void rna_EditBone_align_roll(EditBone *ebo, float *no)
{
@@ -48,6 +48,12 @@ void rna_EditBone_align_roll(EditBone *ebo, float *no)
}
}
+float rna_Bone_do_envelope(Bone *bone, float *vec)
+{
+ float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f;
+ return distfactor_to_bone(vec, bone->head, bone->tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
+}
+
#else
void RNA_api_armature_edit_bone(StructRNA *srna)
@@ -61,4 +67,18 @@ void RNA_api_armature_edit_bone(StructRNA *srna)
RNA_def_property_flag(parm, PROP_REQUIRED);
}
+void RNA_api_bone(StructRNA *srna)
+{
+ PropertyRNA *parm;
+ FunctionRNA *func;
+
+ func= RNA_def_function(srna, "evaluate_envelope", "rna_Bone_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);
+}
+
#endif
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 401f9de92d4..07103564d46 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -224,6 +224,7 @@ char *rna_TextureSlot_path(struct PointerRNA *ptr);
void RNA_api_action(StructRNA *srna);
void RNA_api_armature_edit_bone(StructRNA *srna);
+void RNA_api_bone(StructRNA *srna);
void RNA_api_drivers(StructRNA *srna);
void RNA_api_image(struct StructRNA *srna);
void RNA_api_operator(struct StructRNA *srna);
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);
}