Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_object.c
| Show All 36 Lines | |||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_meta_types.h" | #include "DNA_meta_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BKE_camera.h" | #include "BKE_camera.h" | ||||
| #include "BKE_collection.h" | |||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_editlattice.h" | #include "BKE_editlattice.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_group.h" /* needed for BKE_group_object_exists() */ | |||||
| #include "BKE_object_deform.h" | #include "BKE_object_deform.h" | ||||
| #include "BKE_object_facemap.h" | #include "BKE_object_facemap.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "RNA_enum_types.h" | #include "RNA_enum_types.h" | ||||
| #include "rna_internal.h" | #include "rna_internal.h" | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| }; | }; | ||||
| #define DUPLI_ITEMS_SHARED \ | #define DUPLI_ITEMS_SHARED \ | ||||
| {0, "NONE", 0, "None", ""}, \ | {0, "NONE", 0, "None", ""}, \ | ||||
| {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"}, \ | {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"}, \ | ||||
| {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"}, \ | {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"}, \ | ||||
| {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"} | {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"} | ||||
| #define DUPLI_ITEM_GROUP \ | #define DUPLI_ITEM_COLLECTION \ | ||||
| {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"} | {OB_DUPLICOLLECTION, "COLLECTION", 0, "Collection", "Enable collection instancing"} | ||||
| static const EnumPropertyItem dupli_items[] = { | static const EnumPropertyItem dupli_items[] = { | ||||
| DUPLI_ITEMS_SHARED, | DUPLI_ITEMS_SHARED, | ||||
| DUPLI_ITEM_GROUP, | DUPLI_ITEM_COLLECTION, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| #ifdef RNA_RUNTIME | #ifdef RNA_RUNTIME | ||||
| static EnumPropertyItem dupli_items_nogroup[] = { | static EnumPropertyItem dupli_items_nogroup[] = { | ||||
| DUPLI_ITEMS_SHARED, | DUPLI_ITEMS_SHARED, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| #endif | #endif | ||||
| #undef DUPLI_ITEMS_SHARED | #undef DUPLI_ITEMS_SHARED | ||||
| #undef DUPLI_ITEM_GROUP | #undef DUPLI_ITEM_COLLECTION | ||||
| const EnumPropertyItem rna_enum_metaelem_type_items[] = { | const EnumPropertyItem rna_enum_metaelem_type_items[] = { | ||||
| {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""}, | {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""}, | ||||
| {MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""}, | {MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""}, | ||||
| {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""}, | {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""}, | ||||
| {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, /* NOTE: typo at original definition! */ | {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, /* NOTE: typo at original definition! */ | ||||
| {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""}, | {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""}, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| ▲ Show 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | static const EnumPropertyItem *rna_Object_dupli_type_itemf( | ||||
| } | } | ||||
| return item; | return item; | ||||
| } | } | ||||
| static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value) | static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value) | ||||
| { | { | ||||
| Object *ob = (Object *)ptr->data; | Object *ob = (Object *)ptr->data; | ||||
| Group *grp = (Group *)value.data; | Collection *grp = (Collection *)value.data; | ||||
| /* must not let this be set if the object belongs in this group already, | /* must not let this be set if the object belongs in this group already, | ||||
| * thus causing a cycle/infinite-recursion leading to crashes on load [#25298] | * thus causing a cycle/infinite-recursion leading to crashes on load [#25298] | ||||
| */ | */ | ||||
| if (BKE_group_object_exists(grp, ob) == 0) { | if (BKE_collection_has_object_recursive(grp, ob) == 0) { | ||||
| if (ob->type == OB_EMPTY) { | if (ob->type == OB_EMPTY) { | ||||
| id_us_min(&ob->dup_group->id); | id_us_min(&ob->dup_group->id); | ||||
| ob->dup_group = grp; | ob->dup_group = grp; | ||||
| id_us_plus(&ob->dup_group->id); | id_us_plus(&ob->dup_group->id); | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_report(NULL, RPT_ERROR, | BKE_report(NULL, RPT_ERROR, | ||||
| "Only empty objects support group instances"); | "Only empty objects support group instances"); | ||||
| ▲ Show 20 Lines • Show All 1,483 Lines • ▼ Show 20 Lines | RNA_def_property_ui_text(prop, "Up Axis", | ||||
| "parent 'Follow' is enabled)"); | "parent 'Follow' is enabled)"); | ||||
| RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); | RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); | ||||
| /* proxy */ | /* proxy */ | ||||
| prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls"); | RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls"); | ||||
| prop = RNA_def_property(srna, "proxy_group", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "proxy_group", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_ui_text(prop, "Proxy Group", "Library group duplicator object this proxy object controls"); | RNA_def_property_ui_text(prop, "Proxy Collection", "Library collection duplicator object this proxy object controls"); | ||||
| /* materials */ | /* materials */ | ||||
| prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); | RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); | ||||
| RNA_def_property_struct_type(prop, "MaterialSlot"); | RNA_def_property_struct_type(prop, "MaterialSlot"); | ||||
| /* don't dereference pointer! */ | /* don't dereference pointer! */ | ||||
| RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", NULL, NULL, NULL, NULL); | RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", NULL, NULL, NULL, NULL); | ||||
| RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object"); | RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object"); | ||||
| ▲ Show 20 Lines • Show All 358 Lines • ▼ Show 20 Lines | /* RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "constraints__add", "constraints__remove"); */ | ||||
| prop = RNA_def_property(srna, "dupli_faces_scale", PROP_FLOAT, PROP_NONE); | prop = RNA_def_property(srna, "dupli_faces_scale", PROP_FLOAT, PROP_NONE); | ||||
| RNA_def_property_float_sdna(prop, NULL, "dupfacesca"); | RNA_def_property_float_sdna(prop, NULL, "dupfacesca"); | ||||
| RNA_def_property_range(prop, 0.001f, 10000.0f); | RNA_def_property_range(prop, 0.001f, 10000.0f); | ||||
| RNA_def_property_ui_text(prop, "Dupli Faces Scale", "Scale the DupliFace objects"); | RNA_def_property_ui_text(prop, "Dupli Faces Scale", "Scale the DupliFace objects"); | ||||
| RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); | RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); | ||||
| prop = RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_struct_type(prop, "Collection"); | |||||
| RNA_def_property_pointer_sdna(prop, NULL, "dup_group"); | RNA_def_property_pointer_sdna(prop, NULL, "dup_group"); | ||||
| RNA_def_property_flag(prop, PROP_EDITABLE); | RNA_def_property_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_group_set", NULL, NULL); | RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_group_set", NULL, NULL); | ||||
| RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group"); | RNA_def_property_ui_text(prop, "Dupli Collection", "Instance an existing collection"); | ||||
| RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update"); | RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update"); | ||||
| prop = RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE | PROP_UNIT_TIME); | prop = RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE | PROP_UNIT_TIME); | ||||
| RNA_def_property_int_sdna(prop, NULL, "dupsta"); | RNA_def_property_int_sdna(prop, NULL, "dupsta"); | ||||
| RNA_def_property_range(prop, MINAFRAME, MAXFRAME); | RNA_def_property_range(prop, MINAFRAME, MAXFRAME); | ||||
| RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames"); | RNA_def_property_ui_text(prop, "Dupli Frames Start", "Start frame for DupliFrames"); | ||||
| RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); | RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); | ||||
| ▲ Show 20 Lines • Show All 225 Lines • Show Last 20 Lines | |||||