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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-12-04 03:07:47 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-12-04 03:07:47 +0300
commit8fc5d6e7de5d2b16a664fd4d31e788a98361b607 (patch)
treefe778b26539360484ebc856062ff9bac6e90b553 /source/blender/makesrna/intern/rna_key.c
parent853f2b0647ac0f969f545b800901f29f5a22dbc4 (diff)
RNA
* Remove some unnecessary defining of struct types for pointers. * Review of DNA_key_types.h and added Key for Mesh and Curve.
Diffstat (limited to 'source/blender/makesrna/intern/rna_key.c')
-rw-r--r--source/blender/makesrna/intern/rna_key.c116
1 files changed, 71 insertions, 45 deletions
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index 19cca60d5a4..ef3b1f5fb82 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -29,9 +29,39 @@
#include "rna_internal.h"
+#include "DNA_ID.h"
+#include "DNA_curve_types.h"
#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_mesh_types.h"
#ifdef RNA_RUNTIME
+
+static Key *rna_ShapeKey_find_key(ID *id)
+{
+ switch(GS(id->name)) {
+ case ID_CU: return ((Curve*)id)->key;
+ case ID_KE: return (Key*)id;
+ case ID_LT: return ((Lattice*)id)->key;
+ case ID_ME: return ((Mesh*)id)->key;
+ default: return NULL;
+ }
+}
+
+static void *rna_ShapeKey_relative_key_get(PointerRNA *ptr)
+{
+ Key *key= rna_ShapeKey_find_key(ptr->id.data);
+ KeyBlock *kb= (KeyBlock*)ptr->data, *kbrel;
+ int a;
+
+ if(key && kb->relative < key->totkey)
+ for(a=0, kbrel=key->block.first; kbrel; kbrel=kbrel->next, a++)
+ if(a == kb->relative)
+ return kbrel;
+
+ return NULL;
+}
+
#else
void RNA_def_keyblock(BlenderRNA *brna)
@@ -45,49 +75,52 @@ void RNA_def_keyblock(BlenderRNA *brna)
{KEY_BSPLINE, "KEY_BSPLINE", "BSpline", ""},
{0, NULL, NULL, NULL}};
- srna= RNA_def_struct(brna, "KeyBlock", NULL, "KeyBlock");
+ srna= RNA_def_struct(brna, "ShapeKey", NULL, "Shape Key");
+ RNA_def_struct_sdna(srna, "KeyBlock");
- prop= RNA_def_property(srna, "current_pos", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Name", "");
+ RNA_def_struct_name_property(srna, prop);
+
+ /* the current value isn't easily editable this way, it's linked to an IPO.
+ prop= RNA_def_property(srna, "current_position", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pos");
- RNA_def_property_ui_text(prop, "CurrentPosition", "Current Position.");
+ RNA_def_property_ui_text(prop, "Current Position", "");
- prop= RNA_def_property(srna, "current_val", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "current_value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "curval");
- RNA_def_property_ui_text(prop, "CurrentValue", "Current Value.");
+ RNA_def_property_ui_text(prop, "Current Value", "");*/
- prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, prop_keyblock_type_items);
- RNA_def_property_ui_text(prop, "Type", "");
-
- prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Name", "Current Shape Key name.");
- RNA_def_property_string_maxlength(prop, 32);
+ RNA_def_property_ui_text(prop, "Interpolation", "Interpolation type.");
prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "vgroup");
- RNA_def_property_ui_text(prop, "Vertex Group", "");
- RNA_def_property_string_maxlength(prop, 32);
+ RNA_def_property_ui_text(prop, "Vertex Group", "Vertex weight group, to blend with basis shape.");
- /* XXX couldn't quite figure this one out: shape key number, channel code? */
- prop= RNA_def_property(srna, "channel", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "adrcode");
+ prop= RNA_def_property(srna, "relative_key", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
- RNA_def_property_ui_text(prop, "Channel", "");
+ RNA_def_property_struct_type(prop, "ShapeKey");
+ RNA_def_property_ui_text(prop, "Relative Key", "Shape used as a relative key.");
+ RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", NULL, NULL);
- prop= RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "relative", 1);
- RNA_def_property_ui_text(prop, "Relative", "Makes Shape Keys relative.");
+ prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYBLOCK_MUTE);
+ RNA_def_property_ui_text(prop, "Mute", "Mute this shape key.");
- prop= RNA_def_property(srna, "slidermin", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "slider_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "slidermin");
- RNA_def_property_ui_text(prop, "SliderMin", "Minimum for Slider.");
+ RNA_def_property_range(prop, -10.0f, 10.0f);
+ RNA_def_property_ui_text(prop, "Slider Min", "Minimum for slider.");
- prop= RNA_def_property(srna, "slidermax", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "slider_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "slidermax");
- RNA_def_property_ui_text(prop, "SliderMax", "Maximum for Slider.");
+ RNA_def_property_range(prop, -10.0f, 10.0f);
+ RNA_def_property_ui_text(prop, "Slider Max", "Maximum for slider.");
+ /* KeyBlock.data has to be wrapped still */
}
void RNA_def_key(BlenderRNA *brna)
@@ -99,36 +132,29 @@ void RNA_def_key(BlenderRNA *brna)
srna= RNA_def_struct(brna, "Key", "ID", "Key");
- prop= RNA_def_property(srna, "refkey", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "KeyBlock");
+ prop= RNA_def_property(srna, "reference_key", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_pointer_sdna(prop, NULL, "refkey");
RNA_def_property_ui_text(prop, "Reference Key", "");
- prop= RNA_def_property(srna, "keyblocks", PROP_COLLECTION, PROP_NONE);
+ prop= RNA_def_property(srna, "shape_keys", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "block", NULL);
- RNA_def_property_struct_type(prop, "KeyBlock");
- RNA_def_property_ui_text(prop, "KeyBlocks", "Key Blocks.");
+ RNA_def_property_struct_type(prop, "ShapeKey");
+ RNA_def_property_ui_text(prop, "Shape Keys", "");
- prop= RNA_def_property(srna, "num_keyblocks", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "totkey");
- RNA_def_property_ui_text(prop, "NumKeyBlocks", "Number of KeyBlocks.");
-
- prop= RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Ipo");
- RNA_def_property_ui_text(prop, "Ipo", "");
+ rna_def_ipo_common(srna);
prop= RNA_def_property(srna, "from", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "ID");
- RNA_def_property_ui_text(prop, "From", "");
+ RNA_def_property_ui_text(prop, "From", "Datablock using these shape keys.");
prop= RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "type", 1);
- RNA_def_property_ui_text(prop, "Relative", "");
+ RNA_def_property_boolean_sdna(prop, NULL, "type", KEY_RELATIVE);
+ RNA_def_property_ui_text(prop, "Relative", "Makes shape keys relative.");
- prop= RNA_def_property(srna, "slurph", PROP_INT, PROP_NONE);
+ prop= RNA_def_property(srna, "slurph", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "slurph");
- RNA_def_property_ui_text(prop, "Slurph", "");
-
-
+ RNA_def_property_range(prop, -500, 500);
+ RNA_def_property_ui_text(prop, "Slurph", "Creates a delay in amount of frames in applying keypositions, first vertex goes first.");
}
#endif