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