Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_key.c
| Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| # include "DEG_depsgraph.h" | # include "DEG_depsgraph.h" | ||||
| # include "WM_api.h" | # include "WM_api.h" | ||||
| # include "WM_types.h" | # include "WM_types.h" | ||||
| static Key *rna_ShapeKey_find_key(ID *id) | static Key *rna_ShapeKey_find_key(ID *id) | ||||
| { | { | ||||
| switch (GS(id->name)) { | switch (GS(id->name)) { | ||||
| case ID_CU: | case ID_CU_LEGACY: | ||||
| return ((Curve *)id)->key; | return ((Curve *)id)->key; | ||||
| case ID_KE: | case ID_KE: | ||||
| return (Key *)id; | return (Key *)id; | ||||
| case ID_LT: | case ID_LT: | ||||
| return ((Lattice *)id)->key; | return ((Lattice *)id)->key; | ||||
| case ID_ME: | case ID_ME: | ||||
| return ((Mesh *)id)->key; | return ((Mesh *)id)->key; | ||||
| case ID_OB: | case ID_OB: | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | ||||
| { | { | ||||
| Key *key = rna_ShapeKey_find_key(ptr->owner_id); | Key *key = rna_ShapeKey_find_key(ptr->owner_id); | ||||
| KeyBlock *kb = (KeyBlock *)ptr->data; | KeyBlock *kb = (KeyBlock *)ptr->data; | ||||
| int tot = kb->totelem, size = key->elemsize; | int tot = kb->totelem, size = key->elemsize; | ||||
| if (GS(key->from->name) == ID_CU && tot > 0) { | if (GS(key->from->name) == ID_CU_LEGACY && tot > 0) { | ||||
| Curve *cu = (Curve *)key->from; | Curve *cu = (Curve *)key->from; | ||||
| StructRNA *type = NULL; | StructRNA *type = NULL; | ||||
| NurbInfo info = {0}; | NurbInfo info = {0}; | ||||
| /* Check if all sub-curves have the same type. */ | /* Check if all sub-curves have the same type. */ | ||||
| LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { | LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { | ||||
| if (type == NULL) { | if (type == NULL) { | ||||
| type = rna_ShapeKey_curve_point_type(nu); | type = rna_ShapeKey_curve_point_type(nu); | ||||
| Show All 20 Lines | |||||
| } | } | ||||
| static int rna_ShapeKey_data_length(PointerRNA *ptr) | static int rna_ShapeKey_data_length(PointerRNA *ptr) | ||||
| { | { | ||||
| Key *key = rna_ShapeKey_find_key(ptr->owner_id); | Key *key = rna_ShapeKey_find_key(ptr->owner_id); | ||||
| KeyBlock *kb = (KeyBlock *)ptr->data; | KeyBlock *kb = (KeyBlock *)ptr->data; | ||||
| int tot = kb->totelem; | int tot = kb->totelem; | ||||
| if (GS(key->from->name) == ID_CU) { | if (GS(key->from->name) == ID_CU_LEGACY) { | ||||
| tot = rna_ShapeKey_curve_find_index(key, tot); | tot = rna_ShapeKey_curve_find_index(key, tot); | ||||
| } | } | ||||
| return tot; | return tot; | ||||
| } | } | ||||
| static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter) | static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter) | ||||
| { | { | ||||
| Key *key = rna_ShapeKey_find_key(iter->parent.owner_id); | Key *key = rna_ShapeKey_find_key(iter->parent.owner_id); | ||||
| void *ptr = rna_iterator_array_get(iter); | void *ptr = rna_iterator_array_get(iter); | ||||
| StructRNA *type = &RNA_ShapeKeyPoint; | StructRNA *type = &RNA_ShapeKeyPoint; | ||||
| /* If data_begin allocated a mapping array, access it. */ | /* If data_begin allocated a mapping array, access it. */ | ||||
| if (iter->internal.array.free_ptr) { | if (iter->internal.array.free_ptr) { | ||||
| ShapeKeyCurvePoint *point = ptr; | ShapeKeyCurvePoint *point = ptr; | ||||
| return rna_pointer_inherit_refine(&iter->parent, point->type, point->data); | return rna_pointer_inherit_refine(&iter->parent, point->type, point->data); | ||||
| } | } | ||||
| if (GS(key->from->name) == ID_CU) { | if (GS(key->from->name) == ID_CU_LEGACY) { | ||||
| Curve *cu = (Curve *)key->from; | Curve *cu = (Curve *)key->from; | ||||
| type = rna_ShapeKey_curve_point_type(cu->nurb.first); | type = rna_ShapeKey_curve_point_type(cu->nurb.first); | ||||
| } | } | ||||
| return rna_pointer_inherit_refine(&iter->parent, type, ptr); | return rna_pointer_inherit_refine(&iter->parent, type, ptr); | ||||
| } | } | ||||
| int rna_ShapeKey_data_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) | int rna_ShapeKey_data_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) | ||||
| { | { | ||||
| Key *key = rna_ShapeKey_find_key(ptr->owner_id); | Key *key = rna_ShapeKey_find_key(ptr->owner_id); | ||||
| KeyBlock *kb = (KeyBlock *)ptr->data; | KeyBlock *kb = (KeyBlock *)ptr->data; | ||||
| int elemsize = key->elemsize; | int elemsize = key->elemsize; | ||||
| char *databuf = kb->data; | char *databuf = kb->data; | ||||
| memset(r_ptr, 0, sizeof(*r_ptr)); | memset(r_ptr, 0, sizeof(*r_ptr)); | ||||
| if (index < 0) { | if (index < 0) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (GS(key->from->name) == ID_CU) { | if (GS(key->from->name) == ID_CU_LEGACY) { | ||||
| NurbInfo info; | NurbInfo info; | ||||
| rna_ShapeKey_NurbInfo_find_index(key, index, false, &info); | rna_ShapeKey_NurbInfo_find_index(key, index, false, &info); | ||||
| if (info.nu && info.nurb_index < info.nurb_size) { | if (info.nu && info.nurb_index < info.nurb_size) { | ||||
| StructRNA *type = rna_ShapeKey_curve_point_type(info.nu); | StructRNA *type = rna_ShapeKey_curve_point_type(info.nu); | ||||
| *r_ptr = rna_pointer_inherit_refine(ptr, type, databuf + elemsize * info.elem_index); | *r_ptr = rna_pointer_inherit_refine(ptr, type, databuf + elemsize * info.elem_index); | ||||
| return true; | return true; | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||