Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_object.c
| Show All 31 Lines | |||||
| #include "DNA_group_types.h" | #include "DNA_group_types.h" | ||||
| #include "DNA_material_types.h" | #include "DNA_material_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_object_force_types.h" | #include "DNA_object_force_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #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 "DNA_gpencil_modifier_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_collection.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_editlattice.h" | #include "BKE_editlattice.h" | ||||
| ▲ Show 20 Lines • Show All 1,213 Lines • ▼ Show 20 Lines | bool rna_Object_modifiers_override_apply( | ||||
| /* This should actually *not* be needed in typical cases. However, if overridden source was edited, | /* This should actually *not* be needed in typical cases. However, if overridden source was edited, | ||||
| * we *may* have some new conflicting names. */ | * we *may* have some new conflicting names. */ | ||||
| modifier_unique_name(&ob_dst->modifiers, mod_dst); | modifier_unique_name(&ob_dst->modifiers, mod_dst); | ||||
| // printf("%s: We inserted a modifier...\n", __func__); | // printf("%s: We inserted a modifier...\n", __func__); | ||||
| return true; | return true; | ||||
| } | } | ||||
| static GpencilModifierData *rna_Object_greasepencil_modifier_new( | |||||
| Object *object, bContext *C, ReportList *reports, | |||||
| const char *name, int type) | |||||
| { | |||||
| return ED_object_gpencil_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type); | |||||
| } | |||||
| static void rna_Object_greasepencil_modifier_remove( | |||||
| Object *object, bContext *C, ReportList *reports, PointerRNA *gmd_ptr) | |||||
| { | |||||
| GpencilModifierData *gmd = gmd_ptr->data; | |||||
| if (ED_object_gpencil_modifier_remove(reports, CTX_data_main(C), object, gmd) == false) { | |||||
| /* error is already set */ | |||||
| return; | |||||
| } | |||||
| RNA_POINTER_INVALIDATE(gmd_ptr); | |||||
| WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object); | |||||
| } | |||||
| static void rna_Object_greasepencil_modifier_clear(Object *object, bContext *C) | |||||
| { | |||||
| ED_object_gpencil_modifier_clear(CTX_data_main(C), object); | |||||
| WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object); | |||||
| } | |||||
| static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) | static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) | ||||
| { | { | ||||
| Object *ob = (Object *)ptr->id.data; | Object *ob = (Object *)ptr->id.data; | ||||
| BoundBox *bb = BKE_object_boundbox_get(ob); | BoundBox *bb = BKE_object_boundbox_get(ob); | ||||
| if (bb) { | if (bb) { | ||||
| memcpy(values, bb->vec, sizeof(bb->vec)); | memcpy(values, bb->vec, sizeof(bb->vec)); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 429 Lines • ▼ Show 20 Lines | #endif | ||||
| RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); | RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); | ||||
| /* clear all modifiers */ | /* clear all modifiers */ | ||||
| func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear"); | func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear"); | ||||
| RNA_def_function_flag(func, FUNC_USE_CONTEXT); | RNA_def_function_flag(func, FUNC_USE_CONTEXT); | ||||
| RNA_def_function_ui_description(func, "Remove all modifiers from the object"); | RNA_def_function_ui_description(func, "Remove all modifiers from the object"); | ||||
| } | } | ||||
| /* object.grease_pencil_modifiers */ | |||||
| static void rna_def_object_grease_pencil_modifiers(BlenderRNA *brna, PropertyRNA *cprop) | |||||
| { | |||||
| StructRNA *srna; | |||||
| FunctionRNA *func; | |||||
| PropertyRNA *parm; | |||||
| RNA_def_property_srna(cprop, "ObjectGpencilModifiers"); | |||||
| srna = RNA_def_struct(brna, "ObjectGpencilModifiers", NULL); | |||||
| RNA_def_struct_sdna(srna, "Object"); | |||||
| RNA_def_struct_ui_text(srna, "Object Grease Pencil Modifiers", "Collection of object grease pencil modifiers"); | |||||
| /* add greasepencil modifier */ | |||||
| func = RNA_def_function(srna, "new", "rna_Object_greasepencil_modifier_new"); | |||||
| RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); | |||||
| RNA_def_function_ui_description(func, "Add a new greasepencil_modifier"); | |||||
| parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the greasepencil_modifier"); | |||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | |||||
| /* greasepencil_modifier to add */ | |||||
| parm = RNA_def_enum(func, "type", rna_enum_object_greasepencil_modifier_type_items, 1, "", "Modifier type to add"); | |||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | |||||
| /* return type */ | |||||
| parm = RNA_def_pointer(func, "greasepencil_modifier", "GpencilModifier", "", "Newly created modifier"); | |||||
| RNA_def_function_return(func, parm); | |||||
| /* remove greasepencil_modifier */ | |||||
| func = RNA_def_function(srna, "remove", "rna_Object_greasepencil_modifier_remove"); | |||||
| RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); | |||||
| RNA_def_function_ui_description(func, "Remove an existing greasepencil_modifier from the object"); | |||||
| /* greasepencil_modifier to remove */ | |||||
| parm = RNA_def_pointer(func, "greasepencil_modifier", "GpencilModifier", "", "Modifier to remove"); | |||||
| RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); | |||||
| RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); | |||||
| /* clear all greasepencil modifiers */ | |||||
| func = RNA_def_function(srna, "clear", "rna_Object_greasepencil_modifier_clear"); | |||||
| RNA_def_function_flag(func, FUNC_USE_CONTEXT); | |||||
| RNA_def_function_ui_description(func, "Remove all grease pencil modifiers from the object"); | |||||
| } | |||||
| /* object.particle_systems */ | /* object.particle_systems */ | ||||
| static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop) | static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| /* FunctionRNA *func; */ | /* FunctionRNA *func; */ | ||||
| ▲ Show 20 Lines • Show All 480 Lines • ▼ Show 20 Lines | #endif | ||||
| /* modifiers */ | /* modifiers */ | ||||
| prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_struct_type(prop, "Modifier"); | RNA_def_property_struct_type(prop, "Modifier"); | ||||
| RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object"); | RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object"); | ||||
| RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_modifiers_override_apply"); | RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_modifiers_override_apply"); | ||||
| RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_STATIC_INSERTION); | RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_STATIC_INSERTION); | ||||
| rna_def_object_modifiers(brna, prop); | rna_def_object_modifiers(brna, prop); | ||||
| /* Grease Pencil modifiers. */ | |||||
| prop = RNA_def_property(srna, "grease_pencil_modifiers", PROP_COLLECTION, PROP_NONE); | |||||
aligorith: IMO, this is not great from a UX standpoint (e.g. drivers, bpy, etc.), but it will probably… | |||||
| RNA_def_property_collection_sdna(prop, NULL, "greasepencil_modifiers", NULL); | |||||
| RNA_def_property_struct_type(prop, "GpencilModifier"); | |||||
| RNA_def_property_ui_text(prop, "Grease Pencil Modifiers", "Modifiers affecting the data of the grease pencil object"); | |||||
| rna_def_object_grease_pencil_modifiers(brna, prop); | |||||
| /* constraints */ | /* constraints */ | ||||
| prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_struct_type(prop, "Constraint"); | RNA_def_property_struct_type(prop, "Constraint"); | ||||
| RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_STATIC_INSERTION); | RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_STATIC_INSERTION); | ||||
| RNA_def_property_ui_text(prop, "Constraints", "Constraints affecting the transformation of the object"); | RNA_def_property_ui_text(prop, "Constraints", "Constraints affecting the transformation of the object"); | ||||
| RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_constraints_override_apply"); | RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_constraints_override_apply"); | ||||
| /* RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "constraints__add", "constraints__remove"); */ | /* RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "constraints__add", "constraints__remove"); */ | ||||
| rna_def_object_constraints(brna, prop); | rna_def_object_constraints(brna, prop); | ||||
| ▲ Show 20 Lines • Show All 339 Lines • Show Last 20 Lines | |||||
IMO, this is not great from a UX standpoint (e.g. drivers, bpy, etc.), but it will probably have to do.
Ideally, we could have the "object.modifiers" property redirect to the correct underlying listbase/types based on "ob.type", but, that also complicates code here.