diff options
-rw-r--r-- | release/scripts/io/import_anim_bvh.py | 3 | ||||
-rw-r--r-- | release/scripts/io/import_scene_3ds.py | 4 | ||||
-rw-r--r-- | release/scripts/io/import_scene_obj.py | 3 | ||||
-rw-r--r-- | release/scripts/op/add_mesh_torus.py | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_action.c | 59 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_fcurve.c | 96 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 21 | ||||
-rw-r--r-- | source/blender/nodes/intern/SHD_nodes/SHD_material.c | 11 |
8 files changed, 188 insertions, 14 deletions
diff --git a/release/scripts/io/import_anim_bvh.py b/release/scripts/io/import_anim_bvh.py index 364bd6e96ee..044daf39a47 100644 --- a/release/scripts/io/import_anim_bvh.py +++ b/release/scripts/io/import_anim_bvh.py @@ -609,7 +609,8 @@ class BvhImporter(bpy.types.Operator): return {'RUNNING_MODAL'} -menu_func = lambda self, context: self.layout.operator(BvhImporter.bl_idname, text="Motion Capture (.bvh)") +def menu_func(self, context): + self.layout.operator(BvhImporter.bl_idname, text="Motion Capture (.bvh)") def register(): diff --git a/release/scripts/io/import_scene_3ds.py b/release/scripts/io/import_scene_3ds.py index d1dbdc62563..19bb734028b 100644 --- a/release/scripts/io/import_scene_3ds.py +++ b/release/scripts/io/import_scene_3ds.py @@ -1030,8 +1030,8 @@ class IMPORT_OT_autodesk_3ds(bpy.types.Operator): return {'RUNNING_MODAL'} -menu_func = lambda self, context: self.layout.operator(IMPORT_OT_autodesk_3ds.bl_idname, text="3D Studio (.3ds)") - +def menu_func(self, context): + self.layout.operator(IMPORT_OT_autodesk_3ds.bl_idname, text="3D Studio (.3ds)") def register(): bpy.types.register(IMPORT_OT_autodesk_3ds) diff --git a/release/scripts/io/import_scene_obj.py b/release/scripts/io/import_scene_obj.py index 467aa5194b7..1b627543e90 100644 --- a/release/scripts/io/import_scene_obj.py +++ b/release/scripts/io/import_scene_obj.py @@ -1621,7 +1621,8 @@ class IMPORT_OT_obj(bpy.types.Operator): return {'RUNNING_MODAL'} -menu_func = lambda self, context: self.layout.operator(IMPORT_OT_obj.bl_idname, text="Wavefront (.obj)") +def menu_func(self, context): + self.layout.operator(IMPORT_OT_obj.bl_idname, text="Wavefront (.obj)") def register(): diff --git a/release/scripts/op/add_mesh_torus.py b/release/scripts/op/add_mesh_torus.py index 825b23c49e1..601cc712dda 100644 --- a/release/scripts/op/add_mesh_torus.py +++ b/release/scripts/op/add_mesh_torus.py @@ -154,9 +154,8 @@ class AddTorus(bpy.types.Operator): return {'FINISHED'} -# Add to the menu -menu_func = (lambda self, context: self.layout.operator(AddTorus.bl_idname, - text="Torus", icon='MESH_DONUT')) +def menu_func(self, context): + self.layout.operator(AddTorus.bl_idname, text="Torus", icon='MESH_DONUT') def register(): diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 2f0f9f40b85..c1a74f21fa2 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -54,6 +54,35 @@ static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter) iter->valid= (internal->link != NULL); } +static bActionGroup *rna_Action_groups_add(bAction *act, char *name) +{ + bActionGroup *agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup"); + strncpy(agrp->name, name, sizeof(agrp->name)); + BLI_addtail(&act->groups, agrp); + BLI_uniquename(&act->groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name)); + return agrp; +} + +static void rna_Action_groups_remove(bAction *act, ReportList *reports, bActionGroup *agrp) +{ + FCurve *fcu; + + if(!BLI_remlink_safe(&act->groups, agrp)) { + BKE_reportf(reports, RPT_ERROR, "ActionGroup '%s' not found in action '%s'", agrp->name, act->id.name); + return; + } + + for(fcu= act->curves.first; fcu; fcu= fcu->next) { + if(fcu->grp==agrp) + fcu->grp= NULL; + } + + /* XXX, can these be added to drivers??? */ + + MEM_freeN(agrp); /* XXX, invalidate PyObject */ +} + + #else static void rna_def_dopesheet(BlenderRNA *brna) @@ -244,6 +273,35 @@ static void rna_def_action_group(BlenderRNA *brna) RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); } +/* fcurve.keyframe_points */ +static void rna_def_action_groups(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "ActionGroups"); + srna= RNA_def_struct(brna, "ActionGroups", NULL); + RNA_def_struct_sdna(srna, "bAction"); + RNA_def_struct_ui_text(srna, "Action Points", "Collection of action groups"); + + func= RNA_def_function(srna, "add", "rna_Action_groups_add"); + RNA_def_function_ui_description(func, "Add a keyframe to the curve."); + parm= RNA_def_string(func, "name", "Group", 0, "", "New name for the action group."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + parm= RNA_def_pointer(func, "action_group", "ActionGroup", "", "Newly created action group"); + RNA_def_function_return(func, parm); + + + func= RNA_def_function(srna, "remove", "rna_Action_groups_remove"); + RNA_def_function_ui_description(func, "Remove action group."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm= RNA_def_pointer(func, "action_group", "ActionGroup", "", "Action group to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); +} + static void rna_def_action(BlenderRNA *brna) { StructRNA *srna; @@ -263,6 +321,7 @@ static void rna_def_action(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "groups", NULL); RNA_def_property_struct_type(prop, "ActionGroup"); RNA_def_property_ui_text(prop, "Groups", "Convenient groupings of F-Curves"); + rna_def_action_groups(brna, prop); prop= RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "markers", NULL); diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index a237edc330a..c29ac0a0c2b 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -40,6 +40,9 @@ #include "WM_types.h" +#include "ED_keyframing.h" +#include "ED_keyframes_edit.h" + EnumPropertyItem fmodifier_type_items[] = { {FMODIFIER_TYPE_NULL, "NULL", 0, "Invalid", ""}, {FMODIFIER_TYPE_GENERATOR, "GENERATOR", 0, "Generator", ""}, @@ -460,6 +463,53 @@ static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, fl *max= MAXFRAMEF; } +static BezTriple *rna_FKeyframe_points_add(FCurve *fcu, float frame, float value, int do_replace, int do_needed, int do_fast) +{ + int index; + int flag= 0; + + if(do_replace) flag |= INSERTKEY_REPLACE; + if(do_needed) flag |= INSERTKEY_NEEDED; + if(do_fast) flag |= INSERTKEY_FAST; + + + index= insert_vert_fcurve(fcu, frame, value, flag); + return index >= 0 ? fcu->bezt + index : NULL; +} + +static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTriple *bezt, int do_fast) +{ + int index= (int)(bezt - fcu->bezt); + if (index < 0 || index >= fcu->totvert) { + BKE_report(reports, RPT_ERROR, "bezier not in fcurve."); + return; + } + + delete_fcurve_key(fcu, index, !do_fast); +} + +static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value) +{ + FCurve *fcu= ptr->data; + + if(value.data && (ptr->id.data != value.id.data)) { + return; /* id's differ, cant do this, should raise an error */ + } + if(fcu->grp == value.data) { + return; /* nothing to do */ + } + + if(fcu->grp) { + BLI_remlink(&fcu->grp->channels, fcu); + } + + fcu->grp= value.data; + + if(fcu->grp) { + BLI_addtail(&fcu->grp->channels, fcu); + } +} + #else static void rna_def_fmodifier_generator(BlenderRNA *brna) @@ -1143,7 +1193,6 @@ static void rna_def_fkeyframe(BlenderRNA *brna) RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); } - static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop) { /* add modifiers */ @@ -1188,6 +1237,43 @@ static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_flag(parm, PROP_REQUIRED); } +/* fcurve.keyframe_points */ +static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "FCurveKeyframePoints"); + srna= RNA_def_struct(brna, "FCurveKeyframePoints", NULL); + RNA_def_struct_sdna(srna, "FCurve"); + RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points"); + + func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add"); + RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve."); + parm= RNA_def_float(func, "frame", 0.0f, -FLT_MAX, FLT_MAX, "", "X Value of this keyframe point", -FLT_MAX, FLT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "", "Y Value of this keyframe point", -FLT_MAX, FLT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* optional */ + parm= RNA_def_boolean(func, "replace", 0, "Replace", "Replace existing keyframes"); + parm= RNA_def_boolean(func, "needed", 0, "Needed", "Only adds keyframes that are needed"); + parm= RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time"); + + parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe"); + RNA_def_function_return(func, parm); + + + func= RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove"); + RNA_def_function_ui_description(func, "Remove keyframe from an fcurve."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + /* optional */ + parm= RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe removal to avoid recalculating the curve each time"); +} + static void rna_def_fcurve(BlenderRNA *brna) { StructRNA *srna; @@ -1221,10 +1307,11 @@ static void rna_def_fcurve(BlenderRNA *brna) prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "grp"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX this is not editable for now, since editing this will easily break the visible hierarchy + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Group", "Action Group that this F-Curve belongs to"); - RNA_def_property_update(prop, NC_ANIMATION|ND_FCURVES_ORDER, NULL); - + RNA_def_property_pointer_funcs(prop, NULL, "rna_FCurve_group_set", NULL); + RNA_def_property_update(prop, NC_ANIMATION, NULL); + /* Path + Array Index */ prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, "rna_FCurve_RnaPath_get", "rna_FCurve_RnaPath_length", "rna_FCurve_RnaPath_set"); @@ -1282,6 +1369,7 @@ static void rna_def_fcurve(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "bezt", "totvert"); RNA_def_property_struct_type(prop, "Keyframe"); RNA_def_property_ui_text(prop, "Keyframes", "User-editable keyframes"); + rna_def_fcurve_keyframe_points(brna, prop); prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "FModifier"); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index ff67597a78b..39694b5b64a 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -531,6 +531,18 @@ PointerRNA rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key) return rptr; } +static void rna_PoseChannel_matrix_local_get(PointerRNA *ptr, float *values) +{ + bPoseChannel *pchan= (bPoseChannel*)ptr->data; + pchan_to_mat4(pchan, (float (*)[4])values); +} + +static void rna_PoseChannel_matrix_local_set(PointerRNA *ptr, const float *values) +{ + bPoseChannel *pchan= (bPoseChannel*)ptr->data; + pchan_apply_mat4(pchan, (float (*)[4])values); +} + #else static void rna_def_bone_group(BlenderRNA *brna) @@ -764,12 +776,17 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); /* transform matrices - should be read-only since these are set directly by AnimSys evaluation */ - prop= RNA_def_property(srna, "channel_matrix", PROP_FLOAT, PROP_MATRIX); + prop= RNA_def_property(srna, "matrix_channel", PROP_FLOAT, PROP_MATRIX); RNA_def_property_float_sdna(prop, NULL, "chan_mat"); RNA_def_property_array(prop, 16); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Channel Matrix", "4x4 matrix, before constraints"); - + + prop= RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_array(prop, 16); + RNA_def_property_ui_text(prop, "Local Matrix", "Matrix representing the parent relative location, scale and rotation. Provides an alternative access to these properties."); + RNA_def_property_float_funcs(prop, "rna_PoseChannel_matrix_local_get", "rna_PoseChannel_matrix_local_set", NULL); + prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); RNA_def_property_float_sdna(prop, NULL, "pose_mat"); RNA_def_property_array(prop, 16); diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_material.c b/source/blender/nodes/intern/SHD_nodes/SHD_material.c index d216ddf565a..3182fca8272 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_material.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_material.c @@ -173,8 +173,17 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, } /* copy passes, now just active node */ - if(node->flag & NODE_ACTIVE_ID) + if(node->flag & NODE_ACTIVE_ID) { + float combined[4], alpha; + + copy_v4_v4(combined, shcd->shr->combined); + alpha= shcd->shr->alpha; + *(shcd->shr)= shrnode; + + copy_v4_v4(shcd->shr->combined, combined); + shcd->shr->alpha= alpha; + } } } |