Blender V2.61 - r43446

rna_key.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): Blender Foundation (2008).
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 #include <stdlib.h>
00029 
00030 #include "RNA_access.h"
00031 #include "RNA_define.h"
00032 
00033 #include "rna_internal.h"
00034 
00035 #include "DNA_ID.h"
00036 #include "DNA_curve_types.h"
00037 #include "DNA_key_types.h"
00038 #include "DNA_lattice_types.h"
00039 #include "DNA_mesh_types.h"
00040 
00041 #ifdef RNA_RUNTIME
00042 
00043 #include <stddef.h>
00044 
00045 #include "DNA_object_types.h"
00046 #include "DNA_scene_types.h"
00047 
00048 #include "BKE_animsys.h"
00049 #include "BKE_depsgraph.h"
00050 #include "BKE_key.h"
00051 #include "BKE_main.h"
00052 
00053 #include "WM_api.h"
00054 #include "WM_types.h"
00055 
00056 static Key *rna_ShapeKey_find_key(ID *id)
00057 {
00058     switch(GS(id->name)) {
00059         case ID_CU: return ((Curve*)id)->key;
00060         case ID_KE: return (Key*)id;
00061         case ID_LT: return ((Lattice*)id)->key;
00062         case ID_ME: return ((Mesh*)id)->key;
00063         case ID_OB: return ob_get_key((Object*)id);
00064         default: return NULL;
00065     }
00066 }
00067 
00068 void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value)
00069 {
00070     KeyBlock *kb= ptr->data;
00071     char oldname[sizeof(kb->name)];
00072     
00073     /* make a copy of the old name first */
00074     BLI_strncpy(oldname, kb->name, sizeof(kb->name));
00075     
00076     /* copy the new name into the name slot */
00077     BLI_strncpy_utf8(kb->name, value, sizeof(kb->name));
00078     
00079     /* make sure the name is truly unique */
00080     if (ptr->id.data) {
00081         Key *key= rna_ShapeKey_find_key(ptr->id.data);
00082         BLI_uniquename(&key->block, kb, "Key", '.', offsetof(KeyBlock, name), sizeof(kb->name));
00083     }
00084     
00085     /* fix all the animation data which may link to this */
00086     BKE_all_animdata_fix_paths_rename("key_blocks", oldname, kb->name);
00087 }
00088 
00089 static void rna_ShapeKey_value_set(PointerRNA *ptr, float value)
00090 {
00091     KeyBlock *data= (KeyBlock*)ptr->data;
00092     CLAMP(value, data->slidermin, data->slidermax);
00093     data->curval= value;
00094 }
00095 
00096 static void rna_ShapeKey_value_range(PointerRNA *ptr, float *min, float *max)
00097 {
00098     KeyBlock *data= (KeyBlock*)ptr->data;
00099 
00100     *min= data->slidermin;
00101     *max= data->slidermax;
00102 }
00103 
00104 /* epsilon for how close one end of shapekey range can get to the other */
00105 #define SHAPEKEY_SLIDER_TOL 0.001f
00106 
00107 static void rna_ShapeKey_slider_min_range(PointerRNA *ptr, float *min, float *max)
00108 {
00109     KeyBlock *data= (KeyBlock*)ptr->data;
00110 
00111     *min= -10.0f;
00112     *max= data->slidermax - SHAPEKEY_SLIDER_TOL;
00113 }
00114 
00115 static void rna_ShapeKey_slider_min_set(PointerRNA *ptr, float value)
00116 {
00117     KeyBlock *data= (KeyBlock*)ptr->data;
00118     float min, max;
00119     
00120     rna_ShapeKey_slider_min_range(ptr, &min, &max);
00121     CLAMP(value, min, max);
00122     data->slidermin = value;
00123 }
00124 
00125 static void rna_ShapeKey_slider_max_range(PointerRNA *ptr, float *min, float *max)
00126 {
00127     KeyBlock *data= (KeyBlock*)ptr->data;
00128 
00129     *min= data->slidermin + SHAPEKEY_SLIDER_TOL;
00130     *max= 10.0f;
00131 }
00132 
00133 static void rna_ShapeKey_slider_max_set(PointerRNA *ptr, float value)
00134 {
00135     KeyBlock *data= (KeyBlock*)ptr->data;
00136     float min, max;
00137     
00138     rna_ShapeKey_slider_max_range(ptr, &min, &max);
00139     CLAMP(value, min, max);
00140     data->slidermax = value;
00141 }
00142 
00143 #undef SHAPEKEY_SLIDER_TOL
00144 
00145 PointerRNA rna_object_shapekey_index_get(ID *id, int value)
00146 {
00147     Key *key= rna_ShapeKey_find_key(id);
00148     KeyBlock *kb= NULL;
00149     PointerRNA ptr;
00150 
00151     if (key && value < key->totkey)
00152         kb = BLI_findlink(&key->block, value);
00153     
00154     RNA_pointer_create(id, &RNA_ShapeKey, kb, &ptr);
00155 
00156     return ptr;
00157 }
00158 
00159 int rna_object_shapekey_index_set(ID *id, PointerRNA value, int current)
00160 {
00161     Key *key= rna_ShapeKey_find_key(id);
00162 
00163     if (key) {
00164         int a = BLI_findindex(&key->block, value.data);
00165         if (a >= 0) return a;
00166     }
00167     
00168     return current;
00169 }
00170 
00171 static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr)
00172 {
00173     KeyBlock *kb= (KeyBlock*)ptr->data;
00174 
00175     return rna_object_shapekey_index_get(ptr->id.data, kb->relative);
00176 }
00177 
00178 static void rna_ShapeKey_relative_key_set(PointerRNA *ptr, PointerRNA value)
00179 {
00180     KeyBlock *kb= (KeyBlock*)ptr->data;
00181 
00182     kb->relative= rna_object_shapekey_index_set(ptr->id.data, value, kb->relative);
00183 }
00184 
00185 static void rna_ShapeKeyPoint_co_get(PointerRNA *ptr, float *values)
00186 {
00187     float *vec= (float*)ptr->data;
00188 
00189     values[0]= vec[0];
00190     values[1]= vec[1];
00191     values[2]= vec[2];
00192 }
00193 
00194 static void rna_ShapeKeyPoint_co_set(PointerRNA *ptr, const float *values)
00195 {
00196     float *vec= (float*)ptr->data;
00197 
00198     vec[0]= values[0];
00199     vec[1]= values[1];
00200     vec[2]= values[2];
00201 }
00202 
00203 static float rna_ShapeKeyCurvePoint_tilt_get(PointerRNA *ptr)
00204 {
00205     float *vec= (float*)ptr->data;
00206     return vec[3];
00207 }
00208 
00209 static void rna_ShapeKeyCurvePoint_tilt_set(PointerRNA *ptr, float value)
00210 {
00211     float *vec= (float*)ptr->data;
00212     vec[3]= value;
00213 }
00214 
00215 static void rna_ShapeKeyBezierPoint_co_get(PointerRNA *ptr, float *values)
00216 {
00217     float *vec= (float*)ptr->data;
00218 
00219     values[0]= vec[0+3];
00220     values[1]= vec[1+3];
00221     values[2]= vec[2+3];
00222 }
00223 
00224 static void rna_ShapeKeyBezierPoint_co_set(PointerRNA *ptr, const float *values)
00225 {
00226     float *vec= (float*)ptr->data;
00227 
00228     vec[0+3]= values[0];
00229     vec[1+3]= values[1];
00230     vec[2+3]= values[2];
00231 }
00232 
00233 static void rna_ShapeKeyBezierPoint_handle_1_co_get(PointerRNA *ptr, float *values)
00234 {
00235     float *vec= (float*)ptr->data;
00236 
00237     values[0]= vec[0];
00238     values[1]= vec[1];
00239     values[2]= vec[2];
00240 }
00241 
00242 static void rna_ShapeKeyBezierPoint_handle_1_co_set(PointerRNA *ptr, const float *values)
00243 {
00244     float *vec= (float*)ptr->data;
00245 
00246     vec[0]= values[0];
00247     vec[1]= values[1];
00248     vec[2]= values[2];
00249 }
00250 
00251 static void rna_ShapeKeyBezierPoint_handle_2_co_get(PointerRNA *ptr, float *values)
00252 {
00253     float *vec= (float*)ptr->data;
00254 
00255     values[0]= vec[6+0];
00256     values[1]= vec[6+1];
00257     values[2]= vec[6+2];
00258 }
00259 
00260 static void rna_ShapeKeyBezierPoint_handle_2_co_set(PointerRNA *ptr, const float *values)
00261 {
00262     float *vec= (float*)ptr->data;
00263 
00264     vec[6+0]= values[0];
00265     vec[6+1]= values[1];
00266     vec[6+2]= values[2];
00267 }
00268 
00269 /*static float rna_ShapeKeyBezierPoint_tilt_get(PointerRNA *ptr)
00270 {
00271     float *vec= (float*)ptr->data;
00272     return vec[10];
00273 }
00274 
00275 static void rna_ShapeKeyBezierPoint_tilt_set(PointerRNA *ptr, float value)
00276 {
00277     float *vec= (float*)ptr->data;
00278     vec[10]= value;
00279 }*/
00280 
00281 static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
00282 {
00283     Key *key= rna_ShapeKey_find_key(ptr->id.data);
00284     KeyBlock *kb= (KeyBlock*)ptr->data;
00285     Curve *cu;
00286     Nurb *nu;
00287     int tot= kb->totelem, size= key->elemsize;
00288     
00289     if(GS(key->from->name) == ID_CU) {
00290         cu= (Curve*)key->from;
00291         nu= cu->nurb.first;
00292         
00293         if(nu->bezt) {
00294             tot /= 3;
00295             size *= 3;
00296         }
00297     }
00298     
00299     rna_iterator_array_begin(iter, (void*)kb->data, size, tot, 0, NULL);
00300 }
00301 
00302 static int rna_ShapeKey_data_length(PointerRNA *ptr)
00303 {
00304     Key *key= rna_ShapeKey_find_key(ptr->id.data);
00305     KeyBlock *kb= (KeyBlock*)ptr->data;
00306     Curve *cu;
00307     Nurb *nu;
00308     int tot= kb->totelem;
00309     
00310     if(GS(key->from->name) == ID_CU) {
00311         cu= (Curve*)key->from;
00312         nu= cu->nurb.first;
00313         
00314         if(nu->bezt)
00315             tot /= 3;
00316     }
00317     
00318     return tot;
00319 }
00320 
00321 static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter)
00322 {
00323     Key *key= rna_ShapeKey_find_key(iter->parent.id.data);
00324     StructRNA *type;
00325     Curve *cu;
00326     Nurb *nu;
00327     
00328     if(GS(key->from->name) == ID_CU) {
00329         cu= (Curve*)key->from;
00330         nu= cu->nurb.first;
00331         
00332         if(nu->bezt)
00333             type= &RNA_ShapeKeyBezierPoint;
00334         else
00335             type= &RNA_ShapeKeyCurvePoint;
00336     }
00337     else
00338         type= &RNA_ShapeKeyPoint;
00339     
00340     return rna_pointer_inherit_refine(&iter->parent, type, rna_iterator_array_get(iter));
00341 }
00342 
00343 static char *rna_ShapeKey_path(PointerRNA *ptr)
00344 {
00345     KeyBlock *kb= (KeyBlock *)ptr->data;
00346     ID *id= ptr->id.data;
00347     
00348     if ((id) && (GS(id->name) != ID_KE))
00349         return BLI_sprintfN("shape_keys.key_blocks[\"%s\"]", kb->name);
00350     else
00351         return BLI_sprintfN("key_blocks[\"%s\"]", kb->name);
00352 }
00353 
00354 static void rna_Key_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
00355 {
00356     Key *key= ptr->id.data;
00357     Object *ob;
00358 
00359     for(ob=bmain->object.first; ob; ob= ob->id.next) {
00360         if(ob_get_key(ob) == key) {
00361             DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
00362             WM_main_add_notifier(NC_OBJECT|ND_MODIFIER, ob);
00363         }
00364     }
00365 }
00366 
00367 static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point)
00368 {
00369     KeyBlock *kb;
00370     
00371     /* sanity checks */
00372     if (ELEM(NULL, key, point))
00373         return NULL;
00374     
00375     /* we'll need to manually search through the keyblocks and check 
00376      * if the point is somewhere in the middle of each block's data
00377      */
00378     for (kb = key->block.first; kb; kb = kb->next) {
00379         if (kb->data) {
00380             float *start = (float *)kb->data;
00381             float *end;
00382             
00383             /* easy cases first */
00384             if ((start == NULL) || (start > point)) {
00385                 /* there's no chance point is in array */
00386                 continue;
00387             }
00388             else if (start == point) {
00389                 /* exact match - point is first in array */
00390                 return kb;
00391             }
00392             
00393             /* determine where end of array is 
00394              *  - elemsize is in bytes, so use char* cast to get array in terms of bytes
00395              */
00396             end = (float *)((char *)start + (key->elemsize * kb->totelem));
00397             
00398             /* if point's address is less than the end, then it is somewhere between start and end, so in array */
00399             if (end > point) {
00400                 /* we've found the owner of the point data */
00401                 return kb;
00402             }
00403         }
00404     }
00405     
00406     return NULL;
00407 }
00408 
00409 static int rna_ShapeKeyPoint_get_index(Key *key, KeyBlock *kb, float *point)
00410 {
00411     /* if we frame the data array and point pointers as char*, then the difference between 
00412      * them will be in bytes. Thus, dividing through by key->elemsize (number of bytes per point)
00413      * gives us the offset of point from start of array.
00414      */
00415     char *start = (char *)kb->data;
00416     char *pt = (char *)point;
00417     
00418     return (int)(pt - start) / key->elemsize;
00419 }
00420 
00421 static char *rna_ShapeKeyPoint_path(PointerRNA *ptr)
00422 {
00423     ID *id = (ID *)ptr->id.data;
00424     Key *key = rna_ShapeKey_find_key(ptr->id.data);
00425     KeyBlock *kb;
00426     float *point = (float *)ptr->data;
00427     
00428     /* if we can get a key block, we can construct a path */
00429     kb = rna_ShapeKeyData_find_keyblock(key, point); 
00430     
00431     if (kb) {
00432         int index = rna_ShapeKeyPoint_get_index(key, kb, point);
00433         
00434         if (GS(id->name) == ID_KE)
00435             return BLI_sprintfN("key_blocks[\"%s\"].data[%d]", kb->name, index);
00436         else
00437             return BLI_sprintfN("shape_keys.key_blocks[\"%s\"].data[%d]", kb->name, index);
00438     }
00439     else
00440         return NULL; // XXX: there's really no way to resolve this...
00441 }
00442 
00443 #else
00444 
00445 static void rna_def_keydata(BlenderRNA *brna)
00446 {
00447     StructRNA *srna;
00448     PropertyRNA *prop;
00449 
00450     srna= RNA_def_struct(brna, "ShapeKeyPoint", NULL);
00451     RNA_def_struct_ui_text(srna, "Shape Key Point", "Point in a shape key");
00452     RNA_def_struct_path_func(srna, "rna_ShapeKeyPoint_path");
00453 
00454     prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
00455     RNA_def_property_array(prop, 3);
00456     RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL);
00457     RNA_def_property_ui_text(prop, "Location", "");
00458     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00459 
00460     srna= RNA_def_struct(brna, "ShapeKeyCurvePoint", NULL);
00461     RNA_def_struct_ui_text(srna, "Shape Key Curve Point", "Point in a shape key for curves");
00462     RNA_def_struct_path_func(srna, "rna_ShapeKeyPoint_path"); /* there's nothing type specific here, so this is fine for now */
00463 
00464     prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
00465     RNA_def_property_array(prop, 3);
00466     RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL);
00467     RNA_def_property_ui_text(prop, "Location", "");
00468     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00469 
00470     prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
00471     RNA_def_property_float_funcs(prop, "rna_ShapeKeyCurvePoint_tilt_get", "rna_ShapeKeyCurvePoint_tilt_set", NULL);
00472     RNA_def_property_ui_text(prop, "Tilt", "");
00473     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00474 
00475     srna= RNA_def_struct(brna, "ShapeKeyBezierPoint", NULL);
00476     RNA_def_struct_ui_text(srna, "Shape Key Bezier Point", "Point in a shape key for Bezier curves");
00477     RNA_def_struct_path_func(srna, "rna_ShapeKeyPoint_path"); /* there's nothing type specific here, so this is fine for now */
00478 
00479     prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
00480     RNA_def_property_array(prop, 3);
00481     RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_co_get", "rna_ShapeKeyBezierPoint_co_set", NULL);
00482     RNA_def_property_ui_text(prop, "Location", "");
00483     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00484 
00485     prop= RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_TRANSLATION);
00486     RNA_def_property_array(prop, 3);
00487     RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_1_co_get", "rna_ShapeKeyBezierPoint_handle_1_co_set", NULL);
00488     RNA_def_property_ui_text(prop, "Handle 1 Location", "");
00489     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00490 
00491     prop= RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION);
00492     RNA_def_property_array(prop, 3);
00493     RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_2_co_get", "rna_ShapeKeyBezierPoint_handle_2_co_set", NULL);
00494     RNA_def_property_ui_text(prop, "Handle 2 Location", "");
00495     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00496 
00497     /* appears to be unused currently
00498     prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
00499     RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_tilt_get", "rna_ShapeKeyBezierPoint_tilt_set", NULL);
00500     RNA_def_property_ui_text(prop, "Tilt", "");
00501     RNA_def_property_update(prop, 0, "rna_Key_update_data"); */
00502 }
00503 
00504 static void rna_def_keyblock(BlenderRNA *brna)
00505 {
00506     StructRNA *srna;
00507     PropertyRNA *prop;
00508 
00509     static EnumPropertyItem prop_keyblock_type_items[] = {
00510         {KEY_LINEAR, "KEY_LINEAR", 0, "Linear", ""},
00511         {KEY_CARDINAL, "KEY_CARDINAL", 0, "Cardinal", ""},
00512         {KEY_BSPLINE, "KEY_BSPLINE", 0, "BSpline", ""},
00513         {0, NULL, 0, NULL, NULL}};
00514 
00515     srna= RNA_def_struct(brna, "ShapeKey", NULL);
00516     RNA_def_struct_ui_text(srna, "Shape Key", "Shape key in a shape keys datablock");
00517     RNA_def_struct_sdna(srna, "KeyBlock");
00518     RNA_def_struct_path_func(srna, "rna_ShapeKey_path");
00519     RNA_def_struct_ui_icon(srna, ICON_SHAPEKEY_DATA);
00520 
00521     prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
00522     RNA_def_property_ui_text(prop, "Name", "Name of Shape Key");
00523     RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ShapeKey_name_set");
00524     RNA_def_struct_name_property(srna, prop);
00525 
00526     /* keys need to be sorted to edit this */
00527     prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
00528     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00529     RNA_def_property_float_sdna(prop, NULL, "pos");
00530     RNA_def_property_ui_text(prop, "Frame", "Frame for absolute keys");
00531     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00532     
00533     /* for now, this is editable directly, as users can set this even if they're not animating them (to test results) */
00534     prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_FACTOR);
00535     RNA_def_property_float_sdna(prop, NULL, "curval");
00536     RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_value_set", "rna_ShapeKey_value_range");
00537     RNA_def_property_ui_range(prop, -10.0f, 10.0f, 10, 3);
00538     RNA_def_property_ui_text(prop, "Value", "Value of shape key at the current frame");
00539     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00540 
00541     prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
00542     RNA_def_property_enum_sdna(prop, NULL, "type");
00543     RNA_def_property_enum_items(prop, prop_keyblock_type_items);
00544     RNA_def_property_ui_text(prop, "Interpolation", "Interpolation type");
00545     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00546 
00547     prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
00548     RNA_def_property_string_sdna(prop, NULL, "vgroup");
00549     RNA_def_property_ui_text(prop, "Vertex Group", "Vertex weight group, to blend with basis shape");
00550     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00551 
00552     prop= RNA_def_property(srna, "relative_key", PROP_POINTER, PROP_NONE);
00553     RNA_def_property_struct_type(prop, "ShapeKey");
00554     RNA_def_property_flag(prop, PROP_EDITABLE);
00555     RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", "rna_ShapeKey_relative_key_set", NULL, NULL);
00556     RNA_def_property_ui_text(prop, "Relative Key", "Shape used as a relative key");
00557     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00558 
00559     prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
00560     RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYBLOCK_MUTE);
00561     RNA_def_property_ui_text(prop, "Mute", "Mute this shape key");
00562     RNA_def_property_ui_icon(prop, ICON_MUTE_IPO_OFF, 1);
00563     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00564 
00565     prop= RNA_def_property(srna, "slider_min", PROP_FLOAT, PROP_NONE);
00566     RNA_def_property_float_sdna(prop, NULL, "slidermin");
00567     RNA_def_property_range(prop, -10.0f, 10.0f);
00568     RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_slider_min_set", "rna_ShapeKey_slider_min_range");
00569     RNA_def_property_ui_text(prop, "Slider Min", "Minimum for slider");
00570 
00571     prop= RNA_def_property(srna, "slider_max", PROP_FLOAT, PROP_NONE);
00572     RNA_def_property_float_sdna(prop, NULL, "slidermax");
00573     RNA_def_property_range(prop, -10.0f, 10.0f);
00574     RNA_def_property_float_default(prop, 1.0f);
00575     RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_slider_max_set", "rna_ShapeKey_slider_max_range");
00576     RNA_def_property_ui_text(prop, "Slider Max", "Maximum for slider");
00577 
00578     prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
00579     RNA_def_property_collection_sdna(prop, NULL, "data", "totelem");
00580     RNA_def_property_struct_type(prop, "UnknownType");
00581     RNA_def_property_ui_text(prop, "Data", "");
00582     RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", NULL, NULL, "rna_ShapeKey_data_get", "rna_ShapeKey_data_length", NULL, NULL, NULL);
00583 }
00584 
00585 static void rna_def_key(BlenderRNA *brna)
00586 {
00587     StructRNA *srna;
00588     PropertyRNA *prop;
00589 
00590     srna= RNA_def_struct(brna, "Key", "ID");
00591     RNA_def_struct_ui_text(srna, "Key", "Shape keys datablock containing different shapes of geometric datablocks");
00592     RNA_def_struct_ui_icon(srna, ICON_SHAPEKEY_DATA);
00593 
00594     prop= RNA_def_property(srna, "reference_key", PROP_POINTER, PROP_NONE);
00595     RNA_def_property_flag(prop, PROP_NEVER_NULL);
00596     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00597     RNA_def_property_pointer_sdna(prop, NULL, "refkey");
00598     RNA_def_property_ui_text(prop, "Reference Key", "");
00599 
00600     prop= RNA_def_property(srna, "key_blocks", PROP_COLLECTION, PROP_NONE);
00601     RNA_def_property_collection_sdna(prop, NULL, "block", NULL);
00602     RNA_def_property_struct_type(prop, "ShapeKey");
00603     RNA_def_property_ui_text(prop, "Key Blocks", "Shape keys");
00604 
00605     rna_def_animdata_common(srna);
00606 
00607     prop= RNA_def_property(srna, "user", PROP_POINTER, PROP_NONE);
00608     RNA_def_property_flag(prop, PROP_NEVER_NULL);
00609     RNA_def_property_pointer_sdna(prop, NULL, "from");
00610     RNA_def_property_ui_text(prop, "User", "Datablock using these shape keys");
00611 
00612     prop= RNA_def_property(srna, "use_relative", PROP_BOOLEAN, PROP_NONE);
00613     RNA_def_property_boolean_sdna(prop, NULL, "type", KEY_RELATIVE);
00614     RNA_def_property_ui_text(prop, "Relative", "Make shape keys relative");
00615     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00616 
00617     prop= RNA_def_property(srna, "slurph", PROP_INT, PROP_UNSIGNED);
00618     RNA_def_property_int_sdna(prop, NULL, "slurph");
00619     RNA_def_property_range(prop, -500, 500);
00620     RNA_def_property_ui_text(prop, "Slurph", "Create a delay (in frames) in applying keypositions, first vertex goes first");
00621     RNA_def_property_update(prop, 0, "rna_Key_update_data");
00622 }
00623 
00624 void RNA_def_key(BlenderRNA *brna)
00625 {
00626     rna_def_key(brna);
00627     rna_def_keyblock(brna);
00628     rna_def_keydata(brna);
00629 }
00630 
00631 #endif
00632