Revision: 24880
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24880
Author: aligorith
Date: 2009-11-25 13:00:31 +0100 (Wed, 25 Nov 2009)
Log Message:
-----------
AnimSys - Transform Locks + RNA:
The Animation System now respects the Transform Locks too (i.e. lock
x-location, etc.) when writing settings. This means that it is no longer
necessary to set up "constant drivers" to make sure some values don't get
accidentally animated.
Internally, added a new callback for properties in RNA, which is responsible
for checking if the item at some array-index is editable. This needs to be
manually called for each place which uses rna to set settings for arrays (see
the code changes in anim_sys.c for changes how to do this; the same thing needs
to be done in the UI code too, and probably in py-api too)
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/anim_sys.c
trunk/blender/source/blender/makesrna/RNA_access.h
trunk/blender/source/blender/makesrna/RNA_define.h
trunk/blender/source/blender/makesrna/intern/makesrna.c
trunk/blender/source/blender/makesrna/intern/rna_access.c
trunk/blender/source/blender/makesrna/intern/rna_define.c
trunk/blender/source/blender/makesrna/intern/rna_internal_types.h
trunk/blender/source/blender/makesrna/intern/rna_object.c
trunk/blender/source/blender/makesrna/intern/rna_pose.c
Modified: trunk/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim_sys.c 2009-11-25
11:59:57 UTC (rev 24879)
+++ trunk/blender/source/blender/blenkernel/intern/anim_sys.c 2009-11-25
12:00:31 UTC (rev 24880)
@@ -697,20 +697,26 @@
switch (RNA_property_type(prop))
{
case PROP_BOOLEAN:
- if (RNA_property_array_length(&new_ptr,
prop))
-
RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value);
+ if (RNA_property_array_length(&new_ptr,
prop)) {
+ if
(RNA_property_editable_index(&new_ptr, prop, array_index))
+
RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value);
+ }
else
RNA_property_boolean_set(&new_ptr, prop, (int)value);
break;
case PROP_INT:
- if (RNA_property_array_length(&new_ptr,
prop))
-
RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value);
+ if (RNA_property_array_length(&new_ptr,
prop)){
+ if
(RNA_property_editable_index(&new_ptr, prop, array_index))
+
RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value);
+ }
else
RNA_property_int_set(&new_ptr,
prop, (int)value);
break;
case PROP_FLOAT:
- if (RNA_property_array_length(&new_ptr,
prop))
-
RNA_property_float_set_index(&new_ptr, prop, array_index, value);
+ if (RNA_property_array_length(&new_ptr,
prop)) {
+ if
(RNA_property_editable_index(&new_ptr, prop, array_index))
+
RNA_property_float_set_index(&new_ptr, prop, array_index, value);
+ }
else
RNA_property_float_set(&new_ptr, prop, value);
break;
@@ -1434,20 +1440,26 @@
switch (RNA_property_type(prop))
{
case PROP_BOOLEAN:
- if (RNA_property_array_length(ptr, prop))
- RNA_property_boolean_set_index(ptr,
prop, array_index, (int)value);
+ if (RNA_property_array_length(ptr, prop)) {
+ if (RNA_property_editable_index(ptr,
prop, array_index))
+
RNA_property_boolean_set_index(ptr, prop, array_index, (int)value);
+ }
else
RNA_property_boolean_set(ptr, prop,
(int)value);
break;
case PROP_INT:
- if (RNA_property_array_length(ptr, prop))
- RNA_property_int_set_index(ptr, prop,
array_index, (int)value);
+ if (RNA_property_array_length(ptr, prop)) {
+ if (RNA_property_editable_index(ptr,
prop, array_index))
+ RNA_property_int_set_index(ptr,
prop, array_index, (int)value);
+ }
else
RNA_property_int_set(ptr, prop,
(int)value);
break;
case PROP_FLOAT:
- if (RNA_property_array_length(ptr, prop))
- RNA_property_float_set_index(ptr, prop,
array_index, value);
+ if (RNA_property_array_length(ptr, prop)) {
+ if (RNA_property_editable_index(ptr,
prop, array_index))
+
RNA_property_float_set_index(ptr, prop, array_index, value);
+ }
else
RNA_property_float_set(ptr, prop,
value);
break;
Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h 2009-11-25 11:59:57 UTC
(rev 24879)
+++ trunk/blender/source/blender/makesrna/RNA_access.h 2009-11-25 12:00:31 UTC
(rev 24880)
@@ -640,6 +640,7 @@
StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop);
int RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop);
+int RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index);
int RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop);
int RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop);
Modified: trunk/blender/source/blender/makesrna/RNA_define.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_define.h 2009-11-25 11:59:57 UTC
(rev 24879)
+++ trunk/blender/source/blender/makesrna/RNA_define.h 2009-11-25 12:00:31 UTC
(rev 24880)
@@ -155,6 +155,7 @@
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char
*updatefunc);
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable);
+void RNA_def_property_editable_array_func(PropertyRNA *prop, const char
*editable);
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char
*getlength);
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const
char *set);
Modified: trunk/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/makesrna.c 2009-11-25
11:59:57 UTC (rev 24879)
+++ trunk/blender/source/blender/makesrna/intern/makesrna.c 2009-11-25
12:00:31 UTC (rev 24880)
@@ -1763,7 +1763,7 @@
rna_print_c_string(f, prop->description); fprintf(f, ",\n\t");
fprintf(f, "%d,\n", prop->icon);
fprintf(f, "\t%s, %s|%s, %s, %d, {%d, %d, %d}, %d,\n",
rna_property_typename(prop->type), rna_property_subtypename(prop->subtype),
rna_property_subtype_unit(prop->subtype), rna_function_string(prop->getlength),
prop->arraydimension, prop->arraylength[0], prop->arraylength[1],
prop->arraylength[2], prop->totarraylength);
- fprintf(f, "\t%s, %d, %s,\n", rna_function_string(prop->update),
prop->noteflag, rna_function_string(prop->editable));
+ fprintf(f, "\t%s, %d, %s, %s,\n", rna_function_string(prop->update),
prop->noteflag, rna_function_string(prop->editable),
rna_function_string(prop->itemeditable));
if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop);
else fprintf(f, "\t0, 0");
Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c 2009-11-25
11:59:57 UTC (rev 24879)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c 2009-11-25
12:00:31 UTC (rev 24880)
@@ -982,6 +982,26 @@
return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag &
PROP_LIB_EXCEPTION));
}
+/* same as RNA_property_editable(), except this checks individual items in an
array */
+int RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index)
+{
+ ID *id;
+ int flag;
+
+ prop= rna_ensure_property(prop);
+
+ /* if there is no function to do this for a given index,
+ * just resort to doing this on the whole array
+ */
+ if (prop->itemeditable == NULL)
+ return RNA_property_editable(ptr, prop);
+
+ flag= prop->itemeditable(ptr, index);
+ id= ptr->id.data;
+
+ return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag &
PROP_LIB_EXCEPTION));
+}
+
int RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop)
{
int flag;
Modified: trunk/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_define.c 2009-11-25
11:59:57 UTC (rev 24879)
+++ trunk/blender/source/blender/makesrna/intern/rna_define.c 2009-11-25
12:00:31 UTC (rev 24880)
@@ -1732,6 +1732,16 @@
if(editable) prop->editable= (EditableFunc)editable;
}
+void RNA_def_property_editable_array_func(PropertyRNA *prop, const char
*editable)
+{
+ if(!DefRNA.preprocess) {
+ fprintf(stderr, "RNA_def_property_editable_array_func: only
during preprocessing.\n");
+ return;
+ }
+
+ if(editable) prop->itemeditable= (ItemEditableFunc)editable;
+}
+
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
{
if(!DefRNA.preprocess) {
Modified: trunk/blender/source/blender/makesrna/intern/rna_internal_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_internal_types.h
2009-11-25 11:59:57 UTC (rev 24879)
+++ trunk/blender/source/blender/makesrna/intern/rna_internal_types.h
2009-11-25 12:00:31 UTC (rev 24880)
@@ -55,6 +55,7 @@
typedef void (*UpdateFunc)(struct bContext *C, struct PointerRNA *ptr);
typedef int (*EditableFunc)(struct PointerRNA *ptr);
+typedef int (*ItemEditableFunc)(struct PointerRNA *ptr, int index);
typedef struct IDProperty* (*IDPropertiesFunc)(struct PointerRNA *ptr, int
create);
typedef struct StructRNA *(*StructRefineFunc)(struct PointerRNA *ptr);
typedef char *(*StructPathFunc)(struct PointerRNA *ptr);
@@ -152,8 +153,10 @@
UpdateFunc update;
int noteflag;
- /* callback for testing if editable/evaluated */
+ /* callback for testing if editable */
EditableFunc editable;
+ /* callback for testing if array-item editable (if applicable) */
+ ItemEditableFunc itemeditable;
/* raw access */
int rawoffset;
Modified: trunk/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object.c 2009-11-25
11:59:57 UTC (rev 24879)
+++ trunk/blender/source/blender/makesrna/intern/rna_object.c 2009-11-25
12:00:31 UTC (rev 24880)
@@ -577,7 +577,72 @@
}
}
+static int rna_Object_location_editable(PointerRNA *ptr, int index)
+{
+ Object *ob= (Object *)ptr->data;
+
+ /* only if the axis in question is locked, not editable... */
+ if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX))
+ return 0;
+ else if ((index == 1) && (ob->protectflag & OB_LOCK_LOCY))
+ return 0;
+ else if ((index == 2) && (ob->protectflag & OB_LOCK_LOCZ))
+ return 0;
+ else
+ return PROP_EDITABLE;
+}
+static int rna_Object_scale_editable(PointerRNA *ptr, int index)
+{
+ Object *ob= (Object *)ptr->data;
+
+ /* only if the axis in question is locked, not editable... */
+ if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX))
+ return 0;
+ else if ((index == 1) && (ob->protectflag & OB_LOCK_SCALEY))
+ return 0;
+ else if ((index == 2) && (ob->protectflag & OB_LOCK_SCALEZ))
+ return 0;
+ else
+ return PROP_EDITABLE;
+}
+
+static int rna_Object_rotation_euler_editable(PointerRNA *ptr, int index)
+{
+ Object *ob= (Object *)ptr->data;
+
+ /* only if the axis in question is locked, not editable... */
+ if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX))
+ return 0;
+ else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTY))
+ return 0;
+ else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTZ))
+ return 0;
+ else
+ return PROP_EDITABLE;
+}
+
+static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
+{
+ Object *ob= (Object *)ptr->data;
+
+ /* only consider locks if locking components individually... */
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs