diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_object.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 1872 |
1 files changed, 866 insertions, 1006 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 47ab35d3213..19d758a90e7 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -28,26 +28,30 @@ #include <stdlib.h> #include "DNA_action_types.h" +#include "DNA_brush_types.h" +#include "DNA_collection_types.h" #include "DNA_customdata_types.h" -#include "DNA_controller_types.h" -#include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_object_force_types.h" #include "DNA_object_types.h" -#include "DNA_property_types.h" #include "DNA_scene_types.h" #include "DNA_meta_types.h" +#include "DNA_workspace_types.h" +#include "DNA_gpencil_modifier_types.h" +#include "DNA_shader_fx_types.h" #include "BLI_utildefines.h" #include "BLI_listbase.h" #include "BKE_camera.h" +#include "BKE_collection.h" #include "BKE_paint.h" #include "BKE_editlattice.h" #include "BKE_editmesh.h" -#include "BKE_group.h" /* needed for BKE_group_object_exists() */ +#include "BKE_layer.h" #include "BKE_object_deform.h" +#include "BKE_object_facemap.h" #include "RNA_access.h" #include "RNA_define.h" @@ -70,22 +74,55 @@ const EnumPropertyItem rna_enum_object_mode_items[] = { {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""}, - {OB_MODE_GPENCIL, "GPENCIL_EDIT", ICON_GREASEPENCIL, "Edit Strokes", "Edit Grease Pencil Strokes"}, + {OB_MODE_GPENCIL_EDIT, "GPENCIL_EDIT", ICON_EDITMODE_HLT, "Edit Mode", "Edit Grease Pencil Strokes"}, + {OB_MODE_GPENCIL_SCULPT, "GPENCIL_SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", "Sculpt Grease Pencil Strokes"}, + {OB_MODE_GPENCIL_PAINT, "GPENCIL_PAINT", ICON_GREASEPENCIL, "Draw", "Paint Grease Pencil Strokes"}, + {OB_MODE_GPENCIL_WEIGHT, "GPENCIL_WEIGHT", ICON_WPAINT_HLT, "Weight Paint", "Grease Pencil Weight Paint Strokes" }, + {0, NULL, 0, NULL, NULL} +}; + +/* Same as above, but with names that distinguish grease pencil. */ +const EnumPropertyItem rna_enum_workspace_object_mode_items[] = { + {OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""}, + {OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""}, + {OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""}, + {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""}, + {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""}, + {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, + {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, + {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""}, + {OB_MODE_GPENCIL_EDIT, "GPENCIL_EDIT", ICON_EDITMODE_HLT, "Grease Pencil Edit Mode", "Edit Grease Pencil Strokes"}, + {OB_MODE_GPENCIL_SCULPT, "GPENCIL_SCULPT", ICON_SCULPTMODE_HLT, "Grease Pencil Sculpt Mode", "Sculpt Grease Pencil Strokes"}, + {OB_MODE_GPENCIL_PAINT, "GPENCIL_PAINT", ICON_GREASEPENCIL, "Grease Pencil Draw", "Paint Grease Pencil Strokes"}, + {OB_MODE_GPENCIL_WEIGHT, "GPENCIL_WEIGHT", ICON_WPAINT_HLT, "Grease Pencil Weight Paint", "Grease Pencil Weight Paint Strokes" }, {0, NULL, 0, NULL, NULL} }; const EnumPropertyItem rna_enum_object_empty_drawtype_items[] = { - {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""}, - {OB_ARROWS, "ARROWS", 0, "Arrows", ""}, - {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""}, - {OB_CIRCLE, "CIRCLE", 0, "Circle", ""}, - {OB_CUBE, "CUBE", 0, "Cube", ""}, - {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""}, - {OB_EMPTY_CONE, "CONE", 0, "Cone", ""}, - {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""}, + {OB_PLAINAXES, "PLAIN_AXES", ICON_EMPTY_AXIS, "Plain Axes", ""}, + {OB_ARROWS, "ARROWS", ICON_EMPTY_ARROWS, "Arrows", ""}, + {OB_SINGLE_ARROW, "SINGLE_ARROW", ICON_EMPTY_SINGLE_ARROW, "Single Arrow", ""}, + {OB_CIRCLE, "CIRCLE", ICON_MESH_CIRCLE, "Circle", ""}, + {OB_CUBE, "CUBE", ICON_CUBE, "Cube", ""}, + {OB_EMPTY_SPHERE, "SPHERE", ICON_SPHERE, "Sphere", ""}, + {OB_EMPTY_CONE, "CONE", ICON_CONE, "Cone", ""}, + {OB_EMPTY_IMAGE, "IMAGE", ICON_FILE_IMAGE, "Image", ""}, {0, NULL, 0, NULL, NULL} }; +const EnumPropertyItem rna_enum_object_empty_image_depth_items[] = { + {OB_EMPTY_IMAGE_DEPTH_DEFAULT, "DEFAULT", 0, "Default", ""}, + {OB_EMPTY_IMAGE_DEPTH_FRONT, "FRONT", 0, "Front", ""}, + {OB_EMPTY_IMAGE_DEPTH_BACK, "BACK", 0, "Back", ""}, + {0, NULL, 0, NULL, NULL} +}; + +const EnumPropertyItem rna_enum_object_gpencil_type_items[] = { + {GP_EMPTY, "EMPTY", ICON_EMPTY_AXIS, "Blank", "Create an empty grease pencil object"}, + {GP_STROKE, "STROKE", ICON_STROKE, "Stroke", "Create a simple stroke with basic colors"}, + {GP_MONKEY, "MONKEY", ICON_MONKEY, "Monkey", "Construct a Suzanne grease pencil object"}, + {0, NULL, 0, NULL, NULL } +}; static const EnumPropertyItem parent_type_items[] = { {PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"}, @@ -97,28 +134,27 @@ static const EnumPropertyItem parent_type_items[] = { {0, NULL, 0, NULL, NULL} }; -#ifndef RNA_RUNTIME -static const EnumPropertyItem dupli_items[] = { - {0, "NONE", 0, "None", ""}, - {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"}, - {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"}, - {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"}, - {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"}, +#define INSTANCE_ITEMS_SHARED \ + {0, "NONE", 0, "None", ""}, \ + {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make instance of object for every frame"}, \ + {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Instantiate child objects on all vertices"}, \ + {OB_DUPLIFACES, "FACES", 0, "Faces", "Instantiate child objects on all faces"} + +#define INSTANCE_ITEM_COLLECTION \ + {OB_DUPLICOLLECTION, "COLLECTION", 0, "Collection", "Enable collection instancing"} +static const EnumPropertyItem instance_items[] = { + INSTANCE_ITEMS_SHARED, + INSTANCE_ITEM_COLLECTION, {0, NULL, 0, NULL, NULL} }; -#endif - -static const EnumPropertyItem collision_bounds_items[] = { - {OB_BOUND_BOX, "BOX", ICON_MESH_CUBE, "Box", ""}, - {OB_BOUND_SPHERE, "SPHERE", ICON_MESH_UVSPHERE, "Sphere", ""}, - {OB_BOUND_CYLINDER, "CYLINDER", ICON_MESH_CYLINDER, "Cylinder", ""}, - {OB_BOUND_CONE, "CONE", ICON_MESH_CONE, "Cone", ""}, - {OB_BOUND_CONVEX_HULL, "CONVEX_HULL", ICON_MESH_ICOSPHERE, "Convex Hull", ""}, - {OB_BOUND_TRIANGLE_MESH, "TRIANGLE_MESH", ICON_MESH_MONKEY, "Triangle Mesh", ""}, - {OB_BOUND_CAPSULE, "CAPSULE", ICON_MESH_CAPSULE, "Capsule", ""}, - /*{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, */ +#ifdef RNA_RUNTIME +static EnumPropertyItem instance_items_nogroup[] = { + INSTANCE_ITEMS_SHARED, {0, NULL, 0, NULL, NULL} }; +#endif +#undef INSTANCE_ITEMS_SHARED +#undef INSTANCE_ITEM_COLLECTION const EnumPropertyItem rna_enum_metaelem_type_items[] = { {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""}, @@ -144,10 +180,12 @@ const EnumPropertyItem rna_enum_object_type_items[] = { {OB_ARMATURE, "ARMATURE", 0, "Armature", ""}, {OB_LATTICE, "LATTICE", 0, "Lattice", ""}, {OB_EMPTY, "EMPTY", 0, "Empty", ""}, + {OB_GPENCIL, "GPENCIL", 0, "GPencil", ""}, {0, "", 0, NULL, NULL}, {OB_CAMERA, "CAMERA", 0, "Camera", ""}, - {OB_LAMP, "LAMP", 0, "Lamp", ""}, + {OB_LAMP, "LIGHT", 0, "Light", ""}, {OB_SPEAKER, "SPEAKER", 0, "Speaker", ""}, + {OB_LIGHTPROBE, "LIGHT_PROBE", 0, "Probe", ""}, {0, NULL, 0, NULL, NULL} }; @@ -174,25 +212,30 @@ const EnumPropertyItem rna_enum_object_axis_items[] = { #include "DNA_key_types.h" #include "DNA_constraint_types.h" +#include "DNA_gpencil_types.h" +#include "DNA_ID.h" #include "DNA_lattice_types.h" #include "DNA_node_types.h" #include "BKE_armature.h" -#include "BKE_bullet.h" +#include "BKE_brush.h" #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" -#include "BKE_depsgraph.h" #include "BKE_effect.h" #include "BKE_global.h" #include "BKE_key.h" #include "BKE_object.h" #include "BKE_material.h" #include "BKE_mesh.h" +#include "BKE_modifier.h" #include "BKE_particle.h" #include "BKE_scene.h" #include "BKE_deform.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "ED_object.h" #include "ED_particle.h" #include "ED_curve.h" @@ -200,12 +243,12 @@ const EnumPropertyItem rna_enum_object_axis_items[] = { static void rna_Object_internal_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - DAG_id_tag_update(ptr->id.data, OB_RECALC_OB); + DEG_id_tag_update(ptr->id.data, ID_RECALC_TRANSFORM); } static void rna_Object_internal_update_draw(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - DAG_id_tag_update(ptr->id.data, OB_RECALC_OB); + DEG_id_tag_update(ptr->id.data, ID_RECALC_TRANSFORM); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data); } @@ -216,11 +259,29 @@ static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA rna_Object_internal_update(bmain, scene, ptr); } -static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - DAG_id_type_tag(bmain, ID_OB); + Object *ob = ptr->id.data; + BKE_main_collection_sync(bmain); + DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id); } +static void rna_MaterialIndex_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + /* update the material of all brushes not pinned */ + Object *ob = (Object *)ptr->id.data; + if (ob && ob->type == OB_GPENCIL) { + Material *ma = give_current_material(ob, ob->actcol); + if (ma != NULL) { + BKE_brush_update_material(bmain, ma, NULL); + WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL); + } + } +} + + static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) { Object *ob = ptr->id.data; @@ -261,22 +322,24 @@ static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16]) void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data); } -static void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Object_active_shape_update(bContext *C, PointerRNA *ptr) { Object *ob = ptr->id.data; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); - if (scene->obedit == ob) { + if (CTX_data_edit_object(C) == ob) { /* exit/enter editmode to get new shape */ switch (ob->type) { case OB_MESH: EDBM_mesh_load(bmain, ob); EDBM_mesh_make(ob, scene->toolsettings->selectmode, true); - DAG_id_tag_update(ob->data, 0); + DEG_id_tag_update(ob->data, 0); EDBM_mesh_normals_update(((Mesh *)ob->data)->edit_btmesh); BKE_editmesh_tessface_calc(((Mesh *)ob->data)->edit_btmesh); @@ -298,75 +361,11 @@ static void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA static void rna_Object_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - DAG_id_tag_update(ptr->id.data, OB_RECALC_OB); - DAG_relations_tag_update(bmain); + DEG_id_tag_update(ptr->id.data, ID_RECALC_TRANSFORM); + DEG_relations_tag_update(bmain); WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->id.data); } -/* when changing the selection flag the scene needs updating */ -static void rna_Object_select_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) -{ - if (scene) { - Object *ob = (Object *)ptr->id.data; - short mode = (ob->flag & SELECT) ? BA_SELECT : BA_DESELECT; - ED_base_object_select(BKE_scene_base_find(scene, ob), mode); - } -} - -static void rna_Base_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - Base *base = (Base *)ptr->data; - short mode = (base->flag & BA_SELECT) ? BA_SELECT : BA_DESELECT; - ED_base_object_select(base, mode); -} - -static void rna_Object_layer_update__internal(Main *bmain, Scene *scene, Base *base, Object *ob) -{ - /* try to avoid scene sort */ - if (scene == NULL) { - /* pass - unlikely but when running scripts on startup it happens */ - } - else if ((ob->lay & scene->lay) && (base->lay & scene->lay)) { - /* pass */ - } - else if ((ob->lay & scene->lay) == 0 && (base->lay & scene->lay) == 0) { - /* pass */ - } - else { - DAG_relations_tag_update(bmain); - } - - DAG_id_type_tag(bmain, ID_OB); -} - -static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - Object *ob = (Object *)ptr->id.data; - Base *base; - - base = scene ? BKE_scene_base_find(scene, ob) : NULL; - if (!base) - return; - - SWAP(unsigned int, base->lay, ob->lay); - - rna_Object_layer_update__internal(bmain, scene, base, ob); - ob->lay = base->lay; - - WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene); -} - -static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - Base *base = (Base *)ptr->data; - Object *ob = (Object *)base->object; - - rna_Object_layer_update__internal(bmain, scene, base, ob); - ob->lay = base->lay; - - WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene); -} - static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) { Object *ob = (Object *)ptr->data; @@ -381,8 +380,8 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) return; } - BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); - BLI_assert(BKE_id_is_in_gobal_main(id)); + BLI_assert(BKE_id_is_in_global_main(&ob->id)); + BLI_assert(BKE_id_is_in_global_main(id)); if (ob->type == OB_EMPTY) { if (ob->data) { @@ -410,10 +409,12 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) ob->data = id; test_object_materials(G_MAIN, ob, id); - if (GS(id->name) == ID_CU) + if (GS(id->name) == ID_CU) { BKE_curve_type_test(ob); - else if (ob->type == OB_ARMATURE) - BKE_pose_rebuild(ob, ob->data); + } + else if (ob->type == OB_ARMATURE) { + BKE_pose_rebuild(G_MAIN, ob, ob->data, true); + } } } @@ -429,15 +430,30 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) case OB_SURF: return &RNA_Curve; case OB_FONT: return &RNA_Curve; case OB_MBALL: return &RNA_MetaBall; - case OB_LAMP: return &RNA_Lamp; + case OB_LAMP: return &RNA_Light; case OB_CAMERA: return &RNA_Camera; case OB_LATTICE: return &RNA_Lattice; case OB_ARMATURE: return &RNA_Armature; case OB_SPEAKER: return &RNA_Speaker; + case OB_LIGHTPROBE: return &RNA_LightProbe; + case OB_GPENCIL: return &RNA_GreasePencil; default: return &RNA_ID; } } +static bool rna_Object_data_poll(PointerRNA *ptr, const PointerRNA value) +{ + Object *ob = (Object *)ptr->data; + + if (ob->type == OB_GPENCIL) { + /* GP Object - Don't allow using "Annotation" GP datablocks here */ + bGPdata *gpd = value.data; + return (gpd->flag & GP_DATA_ANNOTATIONS) == 0; + } + + return true; +} + static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value) { Object *ob = (Object *)ptr->data; @@ -489,62 +505,59 @@ static const EnumPropertyItem *rna_Object_parent_type_itemf(bContext *UNUSED(C), return item; } -static void rna_Object_empty_draw_type_set(PointerRNA *ptr, int value) +static void rna_Object_empty_display_type_set(PointerRNA *ptr, int value) { Object *ob = (Object *)ptr->data; BKE_object_empty_draw_type_set(ob, value); } -static const EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), bool *r_free) +static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value) { Object *ob = (Object *)ptr->data; - EnumPropertyItem *item = NULL; - int totitem = 0; - if (ob->body_type != OB_BODY_TYPE_CHARACTER) { - RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_TRIANGLE_MESH); - } - RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONVEX_HULL); - - if (ob->body_type != OB_BODY_TYPE_SOFT) { - RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CONE); - RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CYLINDER); - RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_SPHERE); - RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_BOX); - RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CAPSULE); - } - - RNA_enum_item_end(&item, &totitem); - *r_free = true; - - return item; + ED_object_parent(ob, ob->parent, ob->partype, value); } -static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value) +static const EnumPropertyItem *rna_Object_instance_type_itemf( + bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) { Object *ob = (Object *)ptr->data; + const EnumPropertyItem *item; - ED_object_parent(ob, ob->parent, ob->partype, value); + if (ob->type == OB_EMPTY) { + item = instance_items; + } + else { + item = instance_items_nogroup; + } + + return item; } -static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value) +static void rna_Object_dup_collection_set(PointerRNA *ptr, PointerRNA value) { 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, * thus causing a cycle/infinite-recursion leading to crashes on load [#25298] */ - if (BKE_group_object_exists(grp, ob) == 0) { - id_us_min(&ob->dup_group->id); - ob->dup_group = grp; - id_us_plus(&ob->dup_group->id); + if (BKE_collection_has_object_recursive(grp, ob) == 0) { + if (ob->type == OB_EMPTY) { + id_us_min(&ob->dup_group->id); + ob->dup_group = grp; + id_us_plus(&ob->dup_group->id); + } + else { + BKE_report(NULL, RPT_ERROR, + "Only empty objects support group instances"); + } } else { BKE_report(NULL, RPT_ERROR, - "Cannot set dupli-group as object belongs in group being instanced, thus causing a cycle"); + "Cannot set instance-collection as object belongs in group being instanced, thus causing a cycle"); } } @@ -628,6 +641,87 @@ void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result result[0] = '\0'; } +static void rna_FaceMap_name_set(PointerRNA *ptr, const char *value) +{ + Object *ob = (Object *)ptr->id.data; + bFaceMap *fmap = (bFaceMap *)ptr->data; + BLI_strncpy_utf8(fmap->name, value, sizeof(fmap->name)); + BKE_object_facemap_unique_name(ob, fmap); +} + +static int rna_FaceMap_index_get(PointerRNA *ptr) +{ + Object *ob = (Object *)ptr->id.data; + + return BLI_findindex(&ob->fmaps, ptr->data); +} + +static PointerRNA rna_Object_active_face_map_get(PointerRNA *ptr) +{ + Object *ob = (Object *)ptr->id.data; + return rna_pointer_inherit_refine(ptr, &RNA_FaceMap, BLI_findlink(&ob->fmaps, ob->actfmap - 1)); +} + +static int rna_Object_active_face_map_index_get(PointerRNA *ptr) +{ + Object *ob = (Object *)ptr->id.data; + return ob->actfmap - 1; +} + +static void rna_Object_active_face_map_index_set(PointerRNA *ptr, int value) +{ + Object *ob = (Object *)ptr->id.data; + ob->actfmap = value + 1; +} + +static void rna_Object_active_face_map_index_range(PointerRNA *ptr, int *min, int *max, + int *UNUSED(softmin), int *UNUSED(softmax)) +{ + Object *ob = (Object *)ptr->id.data; + + *min = 0; + *max = max_ii(0, BLI_listbase_count(&ob->fmaps) - 1); +} + +void rna_object_BKE_object_facemap_name_index_get(PointerRNA *ptr, char *value, int index) +{ + Object *ob = (Object *)ptr->id.data; + bFaceMap *fmap; + + fmap = BLI_findlink(&ob->fmaps, index - 1); + + if (fmap) BLI_strncpy(value, fmap->name, sizeof(fmap->name)); + else value[0] = '\0'; +} + +int rna_object_BKE_object_facemap_name_index_length(PointerRNA *ptr, int index) +{ + Object *ob = (Object *)ptr->id.data; + bFaceMap *fmap; + + fmap = BLI_findlink(&ob->fmaps, index - 1); + return (fmap) ? strlen(fmap->name) : 0; +} + +void rna_object_BKE_object_facemap_name_index_set(PointerRNA *ptr, const char *value, short *index) +{ + Object *ob = (Object *)ptr->id.data; + *index = BKE_object_facemap_name_index(ob, value) + 1; +} + +void rna_object_fmap_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen) +{ + Object *ob = (Object *)ptr->id.data; + bFaceMap *fmap = BKE_object_facemap_find_name(ob, value); + if (fmap) { + BLI_strncpy(result, value, maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */ + return; + } + + result[0] = '\0'; +} + + void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen) { Object *ob = (Object *)ptr->id.data; @@ -638,10 +732,10 @@ void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *resul if (ob->type == OB_MESH && ob->data) { me = (Mesh *)ob->data; - for (a = 0; a < me->pdata.totlayer; a++) { - layer = &me->pdata.layers[a]; + for (a = 0; a < me->ldata.totlayer; a++) { + layer = &me->ldata.layers[a]; - if (layer->type == CD_MTEXPOLY && STREQ(layer->name, value)) { + if (layer->type == CD_MLOOPUV && STREQ(layer->name, value)) { BLI_strncpy(result, value, maxlen); return; } @@ -715,9 +809,9 @@ static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value) { Object *ob = (Object *)ptr->id.data; - DAG_id_tag_update(value.data, 0); - BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); - BLI_assert(BKE_id_is_in_gobal_main(value.data)); + DEG_id_tag_update(value.data, 0); + BLI_assert(BKE_id_is_in_global_main(&ob->id)); + BLI_assert(BKE_id_is_in_global_main(value.data)); assign_material(G_MAIN, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING); } @@ -757,11 +851,16 @@ static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int val psys_set_current_num(ob, value); } -static void rna_Object_particle_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) { + /* TODO: Disabled for now, because bContext is not available. */ +#if 0 Object *ob = (Object *)ptr->id.data; - - PE_current_changed(bmain, scene, ob); + PE_current_changed(NULL, scene, ob); +#else + (void) scene; + (void) ptr; +#endif } /* rotation - axis-angle */ @@ -874,12 +973,27 @@ static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index) return PROP_EDITABLE; } +static int rna_MaterialSlot_material_editable(PointerRNA *ptr, const char **UNUSED(r_info)) +{ + Object *ob = (Object *)ptr->id.data; + const int index = (Material **)ptr->data - ob->mat; + bool is_editable; + + if ((ob->matbits == NULL) || ob->matbits[index]) { + is_editable = !ID_IS_LINKED(ob); + } + else { + is_editable = ob->data ? !ID_IS_LINKED(ob->data) : false; + } + + return is_editable ? PROP_EDITABLE : 0; +} static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; Material *ma; - int index = (Material **)ptr->data - ob->mat; + const int index = (Material **)ptr->data - ob->mat; ma = give_current_material(ob, index + 1); return rna_pointer_inherit_refine(ptr, &RNA_Material, ma); @@ -890,11 +1004,26 @@ static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value) Object *ob = (Object *)ptr->id.data; int index = (Material **)ptr->data - ob->mat; - BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); - BLI_assert(BKE_id_is_in_gobal_main(value.data)); + BLI_assert(BKE_id_is_in_global_main(&ob->id)); + BLI_assert(BKE_id_is_in_global_main(value.data)); assign_material(G_MAIN, ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING); } +static bool rna_MaterialSlot_material_poll(PointerRNA *ptr, PointerRNA value) +{ + Object *ob = (Object *)ptr->id.data; + Material *ma = (Material *)value.data; + + if (ob->type == OB_GPENCIL) { + /* GP Materials only */ + return (ma->gp_style != NULL); + } + else { + /* Everything except GP materials */ + return (ma->gp_style == NULL); + } +} + static int rna_MaterialSlot_link_get(PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; @@ -952,7 +1081,7 @@ static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr) WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, ptr->id.data); WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } static char *rna_MaterialSlot_path(PointerRNA *ptr) @@ -960,7 +1089,6 @@ static char *rna_MaterialSlot_path(PointerRNA *ptr) Object *ob = (Object *)ptr->id.data; int index = (Material **)ptr->data - ob->mat; - /* from armature... */ return BLI_sprintfN("material_slots[%d]", index); } @@ -969,121 +1097,10 @@ static char *rna_MaterialSlot_path(PointerRNA *ptr) * * logic from check_body_type() * */ -static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr) -{ - Object *ob = (Object *)ptr->id.data; - - /* determine the body_type setting based on flags */ - if (!(ob->gameflag & OB_COLLISION)) { - if (ob->gameflag & OB_OCCLUDER) { - ob->body_type = OB_BODY_TYPE_OCCLUDER; - } - else if (ob->gameflag & OB_NAVMESH) { - ob->body_type = OB_BODY_TYPE_NAVMESH; - } - else { - ob->body_type = OB_BODY_TYPE_NO_COLLISION; - } - } - else if (ob->gameflag & OB_CHARACTER) { - ob->body_type = OB_BODY_TYPE_CHARACTER; - } - else if (ob->gameflag & OB_SENSOR) { - ob->body_type = OB_BODY_TYPE_SENSOR; - } - else if (!(ob->gameflag & OB_DYNAMIC)) { - ob->body_type = OB_BODY_TYPE_STATIC; - } - else if (!(ob->gameflag & (OB_RIGID_BODY | OB_SOFT_BODY))) { - ob->body_type = OB_BODY_TYPE_DYNAMIC; - } - else if (ob->gameflag & OB_RIGID_BODY) { - ob->body_type = OB_BODY_TYPE_RIGID; - } - else { - ob->body_type = OB_BODY_TYPE_SOFT; - /* create the structure here because we display soft body buttons in the main panel */ - if (!ob->bsoft) - ob->bsoft = bsbNew(); - } - return ob->body_type; -} - -static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value) +static char *rna_ObjectDisplay_path(PointerRNA *UNUSED(ptr)) { - Object *ob = (Object *)ptr->id.data; - const int gameflag_prev = ob->gameflag; - ob->body_type = value; - - switch (ob->body_type) { - case OB_BODY_TYPE_SENSOR: - ob->gameflag |= OB_SENSOR | OB_COLLISION; - ob->gameflag &= ~(OB_OCCLUDER | OB_CHARACTER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR | - OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH); - break; - case OB_BODY_TYPE_OCCLUDER: - ob->gameflag |= OB_OCCLUDER; - ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_NAVMESH); - break; - case OB_BODY_TYPE_NAVMESH: - ob->gameflag |= OB_NAVMESH; - ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_DYNAMIC | OB_OCCLUDER); - - if (ob->type == OB_MESH) { - /* could be moved into mesh UI but for now ensure mesh data layer */ - BKE_mesh_ensure_navmesh(ob->data); - } - - break; - case OB_BODY_TYPE_NO_COLLISION: - ob->gameflag &= ~(OB_SENSOR | OB_RIGID_BODY | OB_SOFT_BODY | OB_COLLISION | OB_CHARACTER | OB_OCCLUDER | OB_DYNAMIC | OB_NAVMESH); - break; - case OB_BODY_TYPE_CHARACTER: - ob->gameflag |= OB_COLLISION | OB_CHARACTER; - ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR | - OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH); - /* When we switch to character physics and the collision bounds is set to triangle mesh - * we have to change collision bounds because triangle mesh is not supported by Characters */ - if ((ob->gameflag & OB_BOUNDS) && ob->collision_boundtype == OB_BOUND_TRIANGLE_MESH) { - ob->boundtype = ob->collision_boundtype = OB_BOUND_BOX; - } - break; - case OB_BODY_TYPE_STATIC: - ob->gameflag |= OB_COLLISION; - ob->gameflag &= ~(OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH); - break; - case OB_BODY_TYPE_DYNAMIC: - ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_ACTOR; - ob->gameflag &= ~(OB_RIGID_BODY | OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH); - break; - case OB_BODY_TYPE_RIGID: - ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_RIGID_BODY | OB_ACTOR; - ob->gameflag &= ~(OB_SOFT_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH); - break; - default: - case OB_BODY_TYPE_SOFT: - ob->gameflag |= OB_COLLISION | OB_DYNAMIC | OB_SOFT_BODY | OB_ACTOR; - ob->gameflag &= ~(OB_RIGID_BODY | OB_OCCLUDER | OB_CHARACTER | OB_SENSOR | OB_NAVMESH); - - /* assume triangle mesh, if no bounds chosen for soft body */ - if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype < OB_BOUND_TRIANGLE_MESH)) { - ob->boundtype = OB_BOUND_TRIANGLE_MESH; - } - /* create a BulletSoftBody structure if not already existing */ - if (!ob->bsoft) - ob->bsoft = bsbNew(); - break; - } - - if ((gameflag_prev & OB_NAVMESH) != (ob->gameflag & OB_NAVMESH)) { - if (ob->type == OB_MESH) { - /* this is needed to refresh the derived meshes draw func */ - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); - } - } - - WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data); + return BLI_strdup("display"); } static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr) @@ -1093,160 +1110,6 @@ static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, psys); } -static PointerRNA rna_Object_game_settings_get(PointerRNA *ptr) -{ - return rna_pointer_inherit_refine(ptr, &RNA_GameObjectSettings, ptr->id.data); -} - - -static unsigned int rna_Object_layer_validate__internal(const bool *values, unsigned int lay) -{ - int i, tot = 0; - - /* ensure we always have some layer selected */ - for (i = 0; i < 20; i++) - if (values[i]) - tot++; - - if (tot == 0) - return 0; - - for (i = 0; i < 20; i++) { - if (values[i]) lay |= (1 << i); - else lay &= ~(1 << i); - } - - return lay; -} - -static void rna_Object_layer_set(PointerRNA *ptr, const bool *values) -{ - Object *ob = (Object *)ptr->data; - unsigned int lay; - - lay = rna_Object_layer_validate__internal(values, ob->lay); - if (lay) - ob->lay = lay; -} - -static void rna_Base_layer_set(PointerRNA *ptr, const bool *values) -{ - Base *base = (Base *)ptr->data; - - unsigned int lay; - lay = rna_Object_layer_validate__internal(values, base->lay); - if (lay) - base->lay = lay; - - /* rna_Base_layer_update updates the objects layer */ -} - -static void rna_GameObjectSettings_state_get(PointerRNA *ptr, bool *values) -{ - Object *ob = (Object *)ptr->data; - int i; - int all_states = (ob->scaflag & OB_ALLSTATE) ? 1 : 0; - - memset(values, 0, sizeof(int) * OB_MAX_STATES); - for (i = 0; i < OB_MAX_STATES; i++) { - values[i] = (ob->state & (1 << i)) ? 1 : 0 | all_states; - } -} - -static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const bool *values) -{ - Object *ob = (Object *)ptr->data; - int i, tot = 0; - - /* ensure we always have some state selected */ - for (i = 0; i < OB_MAX_STATES; i++) - if (values[i]) - tot++; - - if (tot == 0) - return; - - for (i = 0; i < OB_MAX_STATES; i++) { - if (values[i]) ob->state |= (1 << i); - else ob->state &= ~(1 << i); - } -} - -static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, bool *values) -{ - Object *ob = (Object *)ptr->data; - bController *cont; - - memset(values, 0, sizeof(int) * OB_MAX_STATES); - for (cont = ob->controllers.first; cont; cont = cont->next) { - int i; - - for (i = 0; i < OB_MAX_STATES; i++) { - if (cont->state_mask & (1 << i)) - values[i] = 1; - } - } -} - -static void rna_GameObjectSettings_col_group_get(PointerRNA *ptr, bool *values) -{ - Object *ob = (Object *)ptr->data; - int i; - - for (i = 0; i < OB_MAX_COL_MASKS; i++) { - values[i] = (ob->col_group & (1 << i)) != 0; - } -} - -static void rna_GameObjectSettings_col_group_set(PointerRNA *ptr, const bool *values) -{ - Object *ob = (Object *)ptr->data; - int i, tot = 0; - - /* ensure we always have some group selected */ - for (i = 0; i < OB_MAX_COL_MASKS; i++) - if (values[i]) - tot++; - - if (tot == 0) - return; - - for (i = 0; i < OB_MAX_COL_MASKS; i++) { - if (values[i]) ob->col_group |= (1 << i); - else ob->col_group &= ~(1 << i); - } -} - -static void rna_GameObjectSettings_col_mask_get(PointerRNA *ptr, bool *values) -{ - Object *ob = (Object *)ptr->data; - int i; - - for (i = 0; i < OB_MAX_COL_MASKS; i++) { - values[i] = (ob->col_mask & (1 << i)) != 0; - } -} - -static void rna_GameObjectSettings_col_mask_set(PointerRNA *ptr, const bool *values) -{ - Object *ob = (Object *)ptr->data; - int i, tot = 0; - - /* ensure we always have some mask selected */ - for (i = 0; i < OB_MAX_COL_MASKS; i++) - if (values[i]) - tot++; - - if (tot == 0) - return; - - for (i = 0; i < OB_MAX_COL_MASKS; i++) { - if (values[i]) ob->col_mask |= (1 << i); - else ob->col_mask &= ~(1 << i); - } -} - - static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) { @@ -1366,6 +1229,56 @@ static void rna_Object_constraints_clear(Object *object, Main *bmain) WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object); } +bool rna_Object_constraints_override_apply( + Main *UNUSED(bmain), + PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *UNUSED(ptr_storage), + PropertyRNA *UNUSED(prop_dst), PropertyRNA *UNUSED(prop_src), PropertyRNA *UNUSED(prop_storage), + const int UNUSED(len_dst), const int UNUSED(len_src), const int UNUSED(len_storage), + PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage), + IDOverrideStaticPropertyOperation *opop) +{ + BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_INSERT_AFTER && + "Unsupported RNA override operation on constraints collection"); + + Object *ob_dst = (Object *)ptr_dst->id.data; + Object *ob_src = (Object *)ptr_src->id.data; + + /* Remember that insertion operations are defined and stored in correct order, which means that + * even if we insert several items in a row, we alays insert first one, then second one, etc. + * So we should always find 'anchor' constraint in both _src *and* _dst> */ + bConstraint *con_anchor = NULL; + if (opop->subitem_local_name && opop->subitem_local_name[0]) { + con_anchor = BLI_findstring(&ob_dst->constraints, opop->subitem_local_name, offsetof(bConstraint, name)); + } + if (con_anchor == NULL && opop->subitem_local_index >= 0) { + con_anchor = BLI_findlink(&ob_dst->constraints, opop->subitem_local_index); + } + /* Otherwise we just insert in first position. */ + + bConstraint *con_src = NULL; + if (opop->subitem_local_name && opop->subitem_local_name[0]) { + con_src = BLI_findstring(&ob_src->constraints, opop->subitem_local_name, offsetof(bConstraint, name)); + } + if (con_src == NULL && opop->subitem_local_index >= 0) { + con_src = BLI_findlink(&ob_src->constraints, opop->subitem_local_index); + } + con_src = con_src ? con_src->next : ob_src->constraints.first; + + BLI_assert(con_src != NULL); + + bConstraint *con_dst = BKE_constraint_duplicate_ex(con_src, 0, true); + + /* This handles NULL anchor as expected by adding at head of list. */ + BLI_insertlinkafter(&ob_dst->constraints, con_anchor, con_dst); + + /* This should actually *not* be needed in typical cases. However, if overridden source was edited, + * we *may* have some new conflicting names. */ + BKE_constraint_unique_name(con_dst, &ob_dst->constraints); + +// printf("%s: We inserted a constraint...\n", __func__); + return true; +} + static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, const char *name, int type) { @@ -1392,6 +1305,112 @@ static void rna_Object_modifier_clear(Object *object, bContext *C) WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object); } +bool rna_Object_modifiers_override_apply( + Main *UNUSED(bmain), + PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *UNUSED(ptr_storage), + PropertyRNA *UNUSED(prop_dst), PropertyRNA *UNUSED(prop_src), PropertyRNA *UNUSED(prop_storage), + const int UNUSED(len_dst), const int UNUSED(len_src), const int UNUSED(len_storage), + PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage), + IDOverrideStaticPropertyOperation *opop) +{ + BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_INSERT_AFTER && + "Unsupported RNA override operation on modifiers collection"); + + Object *ob_dst = (Object *)ptr_dst->id.data; + Object *ob_src = (Object *)ptr_src->id.data; + + /* Remember that insertion operations are defined and stored in correct order, which means that + * even if we insert several items in a row, we alays insert first one, then second one, etc. + * So we should always find 'anchor' constraint in both _src *and* _dst> */ + ModifierData *mod_anchor = NULL; + if (opop->subitem_local_name && opop->subitem_local_name[0]) { + mod_anchor = BLI_findstring(&ob_dst->modifiers, opop->subitem_local_name, offsetof(ModifierData, name)); + } + if (mod_anchor == NULL && opop->subitem_local_index >= 0) { + mod_anchor = BLI_findlink(&ob_dst->modifiers, opop->subitem_local_index); + } + /* Otherwise we just insert in first position. */ + + ModifierData *mod_src = NULL; + if (opop->subitem_local_name && opop->subitem_local_name[0]) { + mod_src = BLI_findstring(&ob_src->modifiers, opop->subitem_local_name, offsetof(ModifierData, name)); + } + if (mod_src == NULL && opop->subitem_local_index >= 0) { + mod_src = BLI_findlink(&ob_src->modifiers, opop->subitem_local_index); + } + mod_src = mod_src ? mod_src->next : ob_src->modifiers.first; + + BLI_assert(mod_src != NULL); + + ModifierData *mod_dst = modifier_new(mod_src->type); + modifier_copyData(mod_src, mod_dst); + + /* This handles NULL anchor as expected by adding at head of list. */ + BLI_insertlinkafter(&ob_dst->modifiers, mod_anchor, mod_dst); + + /* This should actually *not* be needed in typical cases. However, if overridden source was edited, + * we *may* have some new conflicting names. */ + modifier_unique_name(&ob_dst->modifiers, mod_dst); + +// printf("%s: We inserted a modifier...\n", __func__); + 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); +} + +/* shader fx */ +static ShaderFxData *rna_Object_shaderfx_new( + Object *object, bContext *C, ReportList *reports, + const char *name, int type) +{ + return ED_object_shaderfx_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type); +} + +static void rna_Object_shaderfx_remove( + Object *object, bContext *C, ReportList *reports, PointerRNA *gmd_ptr) +{ + ShaderFxData *gmd = gmd_ptr->data; + if (ED_object_shaderfx_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_shaderfx_clear(Object *object, bContext *C) +{ + ED_object_shaderfx_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) { Object *ob = (Object *)ptr->id.data; @@ -1476,6 +1495,69 @@ static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *report return weight; } +static bFaceMap *rna_Object_fmap_new(Object *ob, const char *name) +{ + bFaceMap *fmap = BKE_object_facemap_add_name(ob, name); + + WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); + + return fmap; +} + +static void rna_Object_fmap_remove(Object *ob, ReportList *reports, PointerRNA *fmap_ptr) +{ + bFaceMap *fmap = fmap_ptr->data; + if (BLI_findindex(&ob->fmaps, fmap) == -1) { + BKE_reportf(reports, RPT_ERROR, "FaceMap '%s' not in object '%s'", fmap->name, ob->id.name + 2); + return; + } + + BKE_object_facemap_remove(ob, fmap); + RNA_POINTER_INVALIDATE(fmap_ptr); + + WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); +} + + +static void rna_Object_fmap_clear(Object *ob) +{ + BKE_object_facemap_clear(ob); + + WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); +} + + +static void rna_FaceMap_face_add(ID *id, bFaceMap *fmap, ReportList *reports, int index_len, + int *index) +{ + Object *ob = (Object *)id; + + if (BKE_object_is_in_editmode(ob)) { + BKE_report(reports, RPT_ERROR, "FaceMap.add(): cannot be called while object is in edit mode"); + return; + } + + while (index_len--) + ED_object_facemap_face_add(ob, fmap, *index++); + + WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data); +} + +static void rna_FaceMap_face_remove(ID *id, bFaceMap *fmap, ReportList *reports, int index_len, int *index) +{ + Object *ob = (Object *)id; + + if (BKE_object_is_in_editmode(ob)) { + BKE_report(reports, RPT_ERROR, "FaceMap.add(): cannot be called while object is in edit mode"); + return; + } + + while (index_len--) + ED_object_facemap_face_remove(ob, fmap, *index++); + + WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data); +} + /* generic poll functions */ bool rna_Lattice_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) { @@ -1502,33 +1584,22 @@ bool rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) return ((Object *)value.id.data)->type == OB_CAMERA; } -bool rna_Lamp_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) +bool rna_Light_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) { return ((Object *)value.id.data)->type == OB_LAMP; } -int rna_DupliObject_index_get(PointerRNA *ptr) +bool rna_GPencil_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) { - DupliObject *dob = (DupliObject *)ptr->data; - return dob->persistent_id[0]; + return ((Object *)value.id.data)->type == OB_GPENCIL; } -bool rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr) +int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr) { SculptSession *ss = ((Object *)ptr->id.data)->sculpt; return (ss && ss->bm); } -static void rna_Object_lod_distance_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - Object *ob = (Object *)ptr->id.data; - -#ifdef WITH_GAMEENGINE - BKE_object_lod_sort(ob); -#else - (void)ob; -#endif -} #else static void rna_def_vertex_group(BlenderRNA *brna) @@ -1595,6 +1666,49 @@ static void rna_def_vertex_group(BlenderRNA *brna) RNA_def_function_return(func, parm); } +static void rna_def_face_map(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + FunctionRNA *func; + + srna = RNA_def_struct(brna, "FaceMap", NULL); + RNA_def_struct_sdna(srna, "bFaceMap"); + RNA_def_struct_ui_text(srna, "Face Map", "Group of faces, each face can only be part of one map"); + RNA_def_struct_ui_icon(srna, ICON_MOD_TRIANGULATE); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Name", "Face map name"); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_FaceMap_name_set"); + /* update data because modifiers may use [#24761] */ + RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data"); + + prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); + RNA_def_property_ui_text(prop, "Select", "Face-map selection state (for tools to use)"); + /* important not to use a notifier here, creates a feedback loop! */ + + prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_FaceMap_index_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Index", "Index number of the face map"); + + func = RNA_def_function(srna, "add", "rna_FaceMap_face_add"); + RNA_def_function_ui_description(func, "Add vertices to the group"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + /* TODO, see how array size of 0 works, this shouldnt be used */ + prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0); + RNA_def_parameter_flags(prop, PROP_DYNAMIC, PARM_REQUIRED); + + func = RNA_def_function(srna, "remove", "rna_FaceMap_face_remove"); + RNA_def_function_ui_description(func, "Remove a vertex from the group"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + /* TODO, see how array size of 0 works, this shouldnt be used */ + prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0); + RNA_def_parameter_flags(prop, PROP_DYNAMIC, PARM_REQUIRED); +} + static void rna_def_material_slot(BlenderRNA *brna) { StructRNA *srna; @@ -1614,19 +1728,24 @@ static void rna_def_material_slot(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object"); RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA); - prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Material"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL, NULL); - RNA_def_property_ui_text(prop, "Material", "Material data-block used by this material slot"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update"); - + /* WARNING! Order is crucial for override to work properly here... :/ + * 'link' must come before material pointer, since it defines where (in object or obdata) that one is set! */ prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, link_items); RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update"); + prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Material"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_editable_func(prop, "rna_MaterialSlot_material_editable"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set", NULL, "rna_MaterialSlot_material_poll"); + RNA_def_property_ui_text(prop, "Material", "Material data-block used by this material slot"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update"); + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL); RNA_def_property_ui_text(prop, "Name", "Material slot name"); @@ -1636,313 +1755,6 @@ static void rna_def_material_slot(BlenderRNA *brna) RNA_def_struct_path_func(srna, "rna_MaterialSlot_path"); } -static void rna_def_object_game_settings(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem body_type_items[] = { - {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", "Disable collision for this object"}, - {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", "Stationary object"}, - {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", "Linear physics"}, - {OB_BODY_TYPE_RIGID, "RIGID_BODY", 0, "Rigid Body", "Linear and angular physics"}, - {OB_BODY_TYPE_SOFT, "SOFT_BODY", 0, "Soft Body", "Soft body"}, - {OB_BODY_TYPE_OCCLUDER, "OCCLUDER", 0, "Occluder", "Occluder for optimizing scene rendering"}, - {OB_BODY_TYPE_SENSOR, "SENSOR", 0, "Sensor", - "Collision Sensor, detects static and dynamic objects but not the other " - "collision sensor objects"}, - {OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "Navigation Mesh", "Navigation mesh"}, - {OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character", - "Simple kinematic physics appropriate for game characters"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "GameObjectSettings", NULL); - RNA_def_struct_sdna(srna, "Object"); - RNA_def_struct_nested(brna, srna, "Object"); - RNA_def_struct_ui_text(srna, "Game Object Settings", "Game engine related settings for the object"); - RNA_def_struct_ui_icon(srna, ICON_GAME); - - /* logic */ - - prop = RNA_def_property(srna, "sensors", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "Sensor"); - RNA_def_property_ui_text(prop, "Sensors", "Game engine sensor to detect events"); - - prop = RNA_def_property(srna, "controllers", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "Controller"); - RNA_def_property_ui_text(prop, "Controllers", - "Game engine controllers to process events, connecting sensors to actuators"); - - prop = RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "Actuator"); - RNA_def_property_ui_text(prop, "Actuators", "Game engine actuators to act on events"); - - prop = RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "prop", NULL); - RNA_def_property_struct_type(prop, "GameProperty"); /* rna_property.c */ - RNA_def_property_ui_text(prop, "Properties", "Game engine properties"); - - prop = RNA_def_property(srna, "show_sensors", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSENS); - RNA_def_property_ui_text(prop, "Show Sensors", "Shows sensors for this object in the user interface"); - - prop = RNA_def_property(srna, "show_controllers", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWCONT); - RNA_def_property_ui_text(prop, "Show Controllers", "Shows controllers for this object in the user interface"); - - prop = RNA_def_property(srna, "show_actuators", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWACT); - RNA_def_property_ui_text(prop, "Show Actuators", "Shows actuators for this object in the user interface"); - - /* physics */ - - prop = RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "body_type"); - RNA_def_property_enum_items(prop, body_type_items); - RNA_def_property_enum_default(prop, OB_BODY_TYPE_STATIC); - RNA_def_property_enum_funcs(prop, "rna_GameObjectSettings_physics_type_get", - "rna_GameObjectSettings_physics_type_set", NULL); - RNA_def_property_ui_text(prop, "Physics Type", "Select the type of physical representation"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_record_animation", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_RECORD_ANIMATION); - RNA_def_property_ui_text(prop, "Record Animation", "Record animation objects without physics"); - - prop = RNA_def_property(srna, "use_actor", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ACTOR); - RNA_def_property_ui_text(prop, "Actor", "Object is detected by the Near and Radar sensor"); - - prop = RNA_def_property(srna, "use_ghost", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_GHOST); - RNA_def_property_ui_text(prop, "Ghost", "Object does not react to collisions, like a ghost"); - - prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.01, 10000.0); - RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Mass", "Mass of the object"); - - prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH); - RNA_def_property_float_sdna(prop, NULL, "inertia"); - RNA_def_property_range(prop, 0.01f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.01f, 10.0f, 1, 3); - RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Radius", "Radius of bounding sphere and material physics"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); - - prop = RNA_def_property(srna, "use_sleep", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_COLLISION_RESPONSE); - RNA_def_property_ui_text(prop, "No Sleeping", "Disable auto (de)activation in physics simulation"); - - prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "damping"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_float_default(prop, 0.04f); - RNA_def_property_ui_text(prop, "Damping", "General movement damping"); - - prop = RNA_def_property(srna, "rotation_damping", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "rdamping"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_float_default(prop, 0.1f); - RNA_def_property_ui_text(prop, "Rotation Damping", "General rotation damping"); - - prop = RNA_def_property(srna, "velocity_min", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "min_vel"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Velocity Min", "Clamp velocity to this minimum speed (except when totally still), " - "in distance per second"); - - prop = RNA_def_property(srna, "velocity_max", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "max_vel"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed, " - "in distance per second"); - - prop = RNA_def_property(srna, "angular_velocity_min", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "min_angvel"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Angular Velocity Min", - "Clamp angular velocity to this minimum speed (except when totally still), " - "in angle per second"); - - prop = RNA_def_property(srna, "angular_velocity_max", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "max_angvel"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Angular Velocity Max", "Clamp angular velocity to this maximum speed, " - "in angle per second"); - - /* Character physics */ - prop = RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "step_height"); - RNA_def_property_range(prop, 0.01, 1.0); - RNA_def_property_float_default(prop, 0.15f); - RNA_def_property_ui_text(prop, "Step Height", "Maximum height of steps the character can run over"); - - prop = RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "jump_speed"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_float_default(prop, 10.0f); - RNA_def_property_ui_text(prop, "Jump Force", "Upward velocity applied to the character when jumping"); - - prop = RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fall_speed"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_float_default(prop, 55.0f); - RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall"); - - prop = RNA_def_property(srna, "jump_max", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "max_jumps"); - RNA_def_property_range(prop, 1, CHAR_MAX); - RNA_def_property_ui_range(prop, 1, 10, 1, 1); - RNA_def_property_int_default(prop, 1); - RNA_def_property_ui_text(prop, "Max Jumps", - "The maximum number of jumps the character can make before it hits the ground"); - - /* Collision Masks */ - prop = RNA_def_property(srna, "collision_group", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, NULL, "col_group", 1); - RNA_def_property_array(prop, OB_MAX_COL_MASKS); - RNA_def_property_ui_text(prop, "Collision Group", "The collision group of the object"); - RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_group_get", "rna_GameObjectSettings_col_group_set"); - - prop = RNA_def_property(srna, "collision_mask", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, NULL, "col_mask", 1); - RNA_def_property_array(prop, OB_MAX_COL_MASKS); - RNA_def_property_ui_text(prop, "Collision Mask", "The groups this object can collide with"); - RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_mask_get", "rna_GameObjectSettings_col_mask_set"); - - /* lock position */ - prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_AXIS); - RNA_def_property_ui_text(prop, "Lock X Axis", "Disable simulation of linear motion along the X axis"); - - prop = RNA_def_property(srna, "lock_location_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_AXIS); - RNA_def_property_ui_text(prop, "Lock Y Axis", "Disable simulation of linear motion along the Y axis"); - - prop = RNA_def_property(srna, "lock_location_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_AXIS); - RNA_def_property_ui_text(prop, "Lock Z Axis", "Disable simulation of linear motion along the Z axis"); - - - /* lock rotation */ - prop = RNA_def_property(srna, "lock_rotation_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_ROT_AXIS); - RNA_def_property_ui_text(prop, "Lock X Rotation Axis", "Disable simulation of angular motion along the X axis"); - - prop = RNA_def_property(srna, "lock_rotation_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_ROT_AXIS); - RNA_def_property_ui_text(prop, "Lock Y Rotation Axis", "Disable simulation of angular motion along the Y axis"); - - prop = RNA_def_property(srna, "lock_rotation_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_ROT_AXIS); - RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis"); - - /* is this used anywhere ? */ - prop = RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflag2", OB_NEVER_DO_ACTIVITY_CULLING); - RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular motion along the Z axis"); - - - prop = RNA_def_property(srna, "use_material_physics_fh", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_DO_FH); - RNA_def_property_ui_text(prop, "Use Material Force Field", "React to force field physics settings in materials"); - - prop = RNA_def_property(srna, "use_rotate_from_normal", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ROT_FH); - RNA_def_property_ui_text(prop, "Rotate From Normal", - "Use face normal to rotate object, so that it points away from the surface"); - - prop = RNA_def_property(srna, "form_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "formfactor"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_float_default(prop, 0.4f); - RNA_def_property_ui_text(prop, "Form Factor", "Form factor scales the inertia tensor"); - - prop = RNA_def_property(srna, "use_anisotropic_friction", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ANISOTROPIC_FRICTION); - RNA_def_property_ui_text(prop, "Anisotropic Friction", "Enable anisotropic friction"); - - prop = RNA_def_property(srna, "friction_coefficients", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, NULL, "anisotropicFriction"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Friction Coefficients", - "Relative friction coefficients in the in the X, Y and Z directions, " - "when anisotropic friction is enabled"); - - prop = RNA_def_property(srna, "use_collision_bounds", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_BOUNDS); - RNA_def_property_ui_text(prop, "Use Collision Bounds", "Specify a collision bounds type other than the default"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); - - prop = RNA_def_property(srna, "collision_bounds_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "collision_boundtype"); - RNA_def_property_enum_items(prop, collision_bounds_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_collision_bounds_itemf"); - RNA_def_property_ui_text(prop, "Collision Shape", "Select the collision shape that better fits the object"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); - - prop = RNA_def_property(srna, "use_collision_compound", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_CHILD); - RNA_def_property_ui_text(prop, "Collision Compound", "Add children to form a compound collision object"); - - prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH); - RNA_def_property_float_sdna(prop, NULL, "margin"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_float_default(prop, 0.04f); - RNA_def_property_ui_text(prop, "Collision Margin", - "Extra margin around object for collision detection, small amount required " - "for stability"); - - prop = RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "bsoft"); - RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for Bullet soft body simulation"); - - prop = RNA_def_property(srna, "use_obstacle_create", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_HASOBSTACLE); - RNA_def_property_ui_text(prop, "Create obstacle", "Create representation for obstacle simulation"); - - prop = RNA_def_property(srna, "obstacle_radius", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH); - RNA_def_property_float_sdna(prop, NULL, "obstacleRad"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Obstacle Radius", "Radius of object representation in obstacle simulation"); - - /* state */ - - prop = RNA_def_property(srna, "states_visible", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, NULL, "state", 1); - RNA_def_property_array(prop, OB_MAX_STATES); - RNA_def_property_ui_text(prop, "State", "State determining which controllers are displayed"); - RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_state_get", "rna_GameObjectSettings_state_set"); - - prop = RNA_def_property(srna, "used_states", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_array(prop, OB_MAX_STATES); - RNA_def_property_ui_text(prop, "Used State", "States which are being used by controllers"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_used_state_get", NULL); - - prop = RNA_def_property(srna, "states_initial", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "init_state", 1); - RNA_def_property_array(prop, OB_MAX_STATES); - RNA_def_property_ui_text(prop, "Initial State", "Initial state when the game starts"); - - prop = RNA_def_property(srna, "show_debug_state", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_DEBUGSTATE); - RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine"); - RNA_def_property_ui_icon(prop, ICON_INFO, 0); - - prop = RNA_def_property(srna, "use_all_states", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_ALLSTATE); - RNA_def_property_ui_text(prop, "All", "Set all state bits"); - - prop = RNA_def_property(srna, "show_state_panel", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", OB_SHOWSTATE); - RNA_def_property_ui_text(prop, "States", "Show state panel"); - RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1); -} - static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -2044,6 +1856,88 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop) 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.shaderfxs */ +static void rna_def_object_shaderfxs(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "ObjectShaderFx"); + srna = RNA_def_struct(brna, "ObjectShaderFx", NULL); + RNA_def_struct_sdna(srna, "Object"); + RNA_def_struct_ui_text(srna, "Object Shader Effects", "Collection of object effects"); + + /* add shader_fx */ + func = RNA_def_function(srna, "new", "rna_Object_shaderfx_new"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Add a new shader fx"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the effect"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* shader to add */ + parm = RNA_def_enum(func, "type", rna_enum_object_shaderfx_type_items, 1, "", "Effect type to add"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "shader_fx", "ShaderFx", "", "Newly created effect"); + RNA_def_function_return(func, parm); + + /* remove shader_fx */ + func = RNA_def_function(srna, "remove", "rna_Object_shaderfx_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove an existing effect from the object"); + /* shader to remove */ + parm = RNA_def_pointer(func, "shader_fx", "ShaderFx", "", "Effect 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 shader fx */ + func = RNA_def_function(srna, "clear", "rna_Object_shaderfx_clear"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove all effects from the object"); +} + /* object.particle_systems */ static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop) { @@ -2124,54 +2018,71 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Delete all vertex groups from object"); } - -static void rna_def_object_lodlevel(BlenderRNA *brna) +/* object.face_maps */ +static void rna_def_object_face_maps(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; + PropertyRNA *prop; - srna = RNA_def_struct(brna, "LodLevel", NULL); - RNA_def_struct_sdna(srna, "LodLevel"); - - prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "distance"); - RNA_def_property_range(prop, 0.0, FLT_MAX); - RNA_def_property_ui_text(prop, "Distance", "Distance to begin using this level of detail"); - RNA_def_property_update(prop, NC_OBJECT | ND_LOD, "rna_Object_lod_distance_update"); - - prop = RNA_def_property(srna, "object_hysteresis_percentage", PROP_INT, PROP_PERCENTAGE); - RNA_def_property_int_sdna(prop, NULL, "obhysteresis"); - RNA_def_property_range(prop, 0, 100); - RNA_def_property_ui_range(prop, 0, 100, 10, 1); - RNA_def_property_ui_text(prop, "Hysteresis %", - "Minimum distance change required to transition to the previous level of detail"); - RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL); - - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "source"); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Object", "Object to use for this level of detail"); - RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL); + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "FaceMaps"); + srna = RNA_def_struct(brna, "FaceMaps", NULL); + RNA_def_struct_sdna(srna, "Object"); + RNA_def_struct_ui_text(srna, "Face Maps", "Collection of face maps"); + + prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "FaceMap"); + RNA_def_property_pointer_funcs(prop, "rna_Object_active_face_map_get", + "rna_Object_active_face_map_set", NULL, NULL); + RNA_def_property_ui_text(prop, "Active Face Map", "Face maps of the object"); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data"); + + prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "actfmap"); + RNA_def_property_int_funcs(prop, "rna_Object_active_face_map_index_get", + "rna_Object_active_face_map_index_set", + "rna_Object_active_face_map_index_range"); + RNA_def_property_ui_text(prop, "Active Face Map Index", "Active index in face map array"); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data"); - prop = RNA_def_property(srna, "use_mesh", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", OB_LOD_USE_MESH); - RNA_def_property_ui_text(prop, "Use Mesh", "Use the mesh from this object at this level of detail"); - RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0); - RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL); + /* face maps */ /* add_face_map */ + func = RNA_def_function(srna, "new", "rna_Object_fmap_new"); + RNA_def_function_ui_description(func, "Add face map to object"); + RNA_def_string(func, "name", "Map", 0, "", "face map name"); /* optional */ + parm = RNA_def_pointer(func, "fmap", "FaceMap", "", "New face map"); + RNA_def_function_return(func, parm); - prop = RNA_def_property(srna, "use_material", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", OB_LOD_USE_MAT); - RNA_def_property_ui_text(prop, "Use Material", "Use the material from this object at this level of detail"); - RNA_def_property_ui_icon(prop, ICON_MATERIAL, 0); - RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL); + func = RNA_def_function(srna, "remove", "rna_Object_fmap_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Delete vertex group from object"); + parm = RNA_def_pointer(func, "group", "FaceMap", "", "Face map to remove"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); - prop = RNA_def_property(srna, "use_object_hysteresis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", OB_LOD_USE_HYST); - RNA_def_property_ui_text(prop, "Hysteresis Override", "Override LoD Hysteresis scene setting for this LoD level"); - RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL); + func = RNA_def_function(srna, "clear", "rna_Object_fmap_clear"); + RNA_def_function_ui_description(func, "Delete all vertex groups from object"); } +static void rna_def_object_display(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ObjectDisplay", NULL); + RNA_def_struct_ui_text(srna, "Object Display", "Object display settings for 3d viewport"); + RNA_def_struct_sdna(srna, "ObjectDisplay"); + RNA_def_struct_path_func(srna, "rna_ObjectDisplay_path"); + + prop = RNA_def_property(srna, "show_shadows", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_SHOW_SHADOW); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_ui_text(prop, "Shadow", "Object cast shadows in the 3d viewport"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); +} static void rna_def_object(BlenderRNA *brna) { @@ -2186,20 +2097,20 @@ static void rna_def_object(BlenderRNA *brna) }; static const EnumPropertyItem drawtype_items[] = { - {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Draw the bounds of the object"}, - {OB_WIRE, "WIRE", 0, "Wire", "Draw the object as a wireframe"}, - {OB_SOLID, "SOLID", 0, "Solid", "Draw the object as a solid (if solid drawing is enabled in the viewport)"}, + {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Display the bounds of the object"}, + {OB_WIRE, "WIRE", 0, "Wire", "Display the object as a wireframe"}, + {OB_SOLID, "SOLID", 0, "Solid", "Display the object as a solid (if solid drawing is enabled in the viewport)"}, {OB_TEXTURE, "TEXTURED", 0, "Textured", - "Draw the object with textures (if textures are enabled in the viewport)"}, + "Display the object with textures (if textures are enabled in the viewport)"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem boundtype_items[] = { - {OB_BOUND_BOX, "BOX", 0, "Box", "Draw bounds as box"}, - {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Draw bounds as sphere"}, - {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Draw bounds as cylinder"}, - {OB_BOUND_CONE, "CONE", 0, "Cone", "Draw bounds as cone"}, - {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Draw bounds as capsule"}, + {OB_BOUND_BOX, "BOX", 0, "Box", "Display bounds as box"}, + {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Display bounds as sphere"}, + {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Display bounds as cylinder"}, + {OB_BOUND_CONE, "CONE", 0, "Cone", "Display bounds as cone"}, + {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Display bounds as capsule"}, {0, NULL, 0, NULL, NULL} }; @@ -2231,8 +2142,9 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", "rna_Object_data_poll"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Data", "Object data"); RNA_def_property_update(prop, 0, "rna_Object_internal_update_data"); @@ -2248,26 +2160,6 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Mode", "Object interaction mode"); - prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); - RNA_def_property_array(prop, 20); - RNA_def_property_ui_text(prop, "Layers", "Layers the object is on"); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_layer_set"); - RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_layer_update"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - - prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000); - RNA_def_property_array(prop, 8); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object is on"); - - prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); - RNA_def_property_ui_text(prop, "Select", "Object selection state"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_select_update"); - /* for data access */ prop = RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE); RNA_def_property_multi_array(prop, 2, boundbox_dimsize); @@ -2281,6 +2173,7 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Parent", "Parent Object"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update"); @@ -2310,7 +2203,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "trackflag"); RNA_def_property_enum_items(prop, rna_enum_object_axis_items); RNA_def_property_ui_text(prop, "Track Axis", - "Axis that points in 'forward' direction (applies to DupliFrame when " + "Axis that points in 'forward' direction (applies to InstanceFrame when " "parent 'Follow' is enabled)"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); @@ -2318,7 +2211,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "upflag"); RNA_def_property_enum_items(prop, up_items); RNA_def_property_ui_text(prop, "Up Axis", - "Axis that points in the upward direction (applies to DupliFrame when " + "Axis that points in the upward direction (applies to InstanceFrame when " "parent 'Follow' is enabled)"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); @@ -2326,13 +2219,15 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Proxy", "Library object this proxy object controls"); - 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"); + prop = RNA_def_property(srna, "proxy_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "proxy_group"); + RNA_def_property_ui_text(prop, "Proxy Collection", "Library collection duplicator object this proxy object controls"); /* materials */ prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); RNA_def_property_struct_type(prop, "MaterialSlot"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_NO_PROP_NAME); /* don't dereference pointer! */ 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"); @@ -2340,8 +2235,10 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Material"); RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get", - "rna_Object_active_material_set", NULL, NULL); + "rna_Object_active_material_set", NULL, + "rna_MaterialSlot_material_poll"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_editable_func(prop, "rna_Object_active_material_editable"); RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update"); @@ -2349,15 +2246,17 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "actcol"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set", "rna_Object_active_material_index_range"); RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot"); - RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, NULL); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_MaterialIndex_update"); /* transform */ prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_editable_array_func(prop, "rna_Object_location_editable"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Location", "Location of the object"); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); @@ -2365,6 +2264,7 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "quat"); RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_float_array_default(prop, default_quat); RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions"); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); @@ -2378,12 +2278,14 @@ static void rna_def_object(BlenderRNA *brna) "rna_Object_rotation_axis_angle_set", NULL); RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable"); RNA_def_property_float_array_default(prop, default_axisAngle); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation"); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "rot"); RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers"); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); @@ -2397,6 +2299,7 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_flag(prop, PROP_PROPORTIONAL); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable"); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); RNA_def_property_float_array_default(prop, default_scale); @@ -2501,7 +2404,7 @@ static void rna_def_object(BlenderRNA *brna) "WARNING: Only takes into account 'Object' parenting, so e.g. in case of bone parenting " "you get a matrix relative to the Armature object, not to the actual parent bone"); RNA_def_property_float_funcs(prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL); - RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, NULL); + RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); @@ -2523,22 +2426,33 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); 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_override_funcs(prop, NULL, NULL, "rna_Object_modifiers_override_apply"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_STATIC_INSERTION); rna_def_object_modifiers(brna, prop); + /* Grease Pencil modifiers. */ + prop = RNA_def_property(srna, "grease_pencil_modifiers", PROP_COLLECTION, PROP_NONE); + 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); + + /* Shader FX. */ + prop = RNA_def_property(srna, "shader_effects", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "shader_fx", NULL); + RNA_def_property_struct_type(prop, "ShaderFx"); + RNA_def_property_ui_text(prop, "Shader Effects", "Effects affecting display of object"); + rna_def_object_shaderfxs(brna, prop); + /* constraints */ prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Constraint"); + 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_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_object_constraints(brna, prop); - /* game engine */ - prop = RNA_def_property(srna, "game", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "GameObjectSettings"); - RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Game Settings", "Game engine related settings for the object"); - /* vertex groups */ prop = RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "defbase", NULL); @@ -2546,15 +2460,23 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object"); rna_def_object_vertex_groups(brna, prop); + + /* face maps */ + prop = RNA_def_property(srna, "face_maps", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "fmaps", NULL); + RNA_def_property_struct_type(prop, "FaceMap"); + RNA_def_property_ui_text(prop, "Face Maps", "Maps of faces of the object"); + rna_def_object_face_maps(brna, prop); + /* empty */ - prop = RNA_def_property(srna, "empty_draw_type", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "empty_display_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype"); RNA_def_property_enum_items(prop, rna_enum_object_empty_drawtype_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_Object_empty_draw_type_set", NULL); + RNA_def_property_enum_funcs(prop, NULL, "rna_Object_empty_display_type_set", NULL); RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); - prop = RNA_def_property(srna, "empty_draw_size", PROP_FLOAT, PROP_DISTANCE); + prop = RNA_def_property(srna, "empty_display_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "empty_drawsize"); RNA_def_property_range(prop, 0.0001f, 1000.0f); RNA_def_property_ui_range(prop, 0.01, 100, 1, 2); @@ -2574,6 +2496,26 @@ static void rna_def_object(BlenderRNA *brna) "Parameters defining which layer, pass and frame of the image is displayed"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + prop = RNA_def_property(srna, "empty_image_depth", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_enum_object_empty_image_depth_items); + RNA_def_property_ui_text(prop, "Empty Image Depth", "Determine which other objects will occlude the image"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + + prop = RNA_def_property(srna, "show_empty_image_perspective", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_VISIBLE_PERSPECTIVE); + RNA_def_property_ui_text(prop, "Display in Perspective Mode", "Display image in perspective mode"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + + prop = RNA_def_property(srna, "show_empty_image_orthographic", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_VISIBLE_ORTHOGRAPHIC); + RNA_def_property_ui_text(prop, "Display in Orthographic Mode", "Display image in orthographic mode"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + + prop = RNA_def_property(srna, "show_empty_image_backside", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_VISIBLE_BACKSIDE); + RNA_def_property_ui_text(prop, "Display Back Side", "Display empty image even when viewed from the back"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + /* render */ prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "index"); @@ -2622,24 +2564,35 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies"); /* restrict */ - prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW); - RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_ui_text(prop, "Disable View", "Disable object in the viewport"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT); - RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_ui_text(prop, "Disable Select", "Disable object selection in the viewport"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER); - RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_ui_text(prop, "Disable Render", "Disable object in renders"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); + prop = RNA_def_property(srna, "show_instancer_for_render", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_RENDER); + RNA_def_property_ui_text(prop, "Render Instancer", "Make instancer visible when rendering"); + + prop = RNA_def_property(srna, "show_instancer_for_viewport", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_VIEWPORT); + RNA_def_property_ui_text(prop, "Display Instancer", "Make instancer visible in the viewport"); + /* anim */ rna_def_animdata_common(srna); @@ -2661,148 +2614,139 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Slow Parent Offset", "Delay in the parent relationship"); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); - /* depsgraph hack */ - prop = RNA_def_property(srna, "use_extra_recalc_object", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "depsflag", OB_DEPS_EXTRA_OB_RECALC); - RNA_def_property_ui_text(prop, "Extra Object Update", "Refresh this object again on frame changes, dependency graph hack"); - - prop = RNA_def_property(srna, "use_extra_recalc_data", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "depsflag", OB_DEPS_EXTRA_DATA_RECALC); - RNA_def_property_ui_text(prop, "Extra Data Update", "Refresh this object's data again on frame changes, dependency graph hack"); - - /* duplicates */ - prop = RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE); + /* instancing */ + prop = RNA_def_property(srna, "instance_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag"); - RNA_def_property_enum_items(prop, dupli_items); - RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use"); + RNA_def_property_enum_items(prop, instance_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_instance_type_itemf"); + RNA_def_property_ui_text(prop, "Instance Type", "If not None, object instancing method to use"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update"); - prop = RNA_def_property(srna, "use_dupli_frames_speed", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_instance_frames_speed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED); - RNA_def_property_ui_text(prop, "Dupli Frames Speed", - "Set dupliframes to use the current frame instead of parent curve's evaluation time"); + RNA_def_property_ui_text(prop, "Instance Frames Speed", + "Set frames instancing to use the current frame instead of parent curve's evaluation time"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); - prop = RNA_def_property(srna, "use_dupli_vertices_rotation", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_instance_vertices_rotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT); - RNA_def_property_ui_text(prop, "Dupli Verts Rotation", "Rotate dupli according to vertex normal"); + RNA_def_property_ui_text(prop, "Instance Verts Rotation", "Rotate instance according to vertex normal"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); - prop = RNA_def_property(srna, "use_dupli_faces_scale", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_instance_faces_scale", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE); - RNA_def_property_ui_text(prop, "Dupli Faces Inherit Scale", "Scale dupli based on face size"); + RNA_def_property_ui_text(prop, "Instance Faces Inherit Scale", "Scale instance based on face size"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); - prop = RNA_def_property(srna, "dupli_faces_scale", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "instance_faces_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dupfacesca"); 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, "Instance Faces Scale", "Scale the face instance objects"); 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, "instance_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_pointer_sdna(prop, NULL, "dup_group"); RNA_def_property_flag(prop, PROP_EDITABLE); - 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_pointer_funcs(prop, NULL, "rna_Object_dup_collection_set", NULL, NULL); + RNA_def_property_ui_text(prop, "Instance Collection", "Instance an existing collection"); 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, "instance_frames_start", PROP_INT, PROP_NONE | PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupsta"); 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, "Instance Frames Start", "Start frame for frame instances"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); - prop = RNA_def_property(srna, "dupli_frames_end", PROP_INT, PROP_NONE | PROP_UNIT_TIME); + prop = RNA_def_property(srna, "instance_frames_end", PROP_INT, PROP_NONE | PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupend"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); - RNA_def_property_ui_text(prop, "Dupli Frames End", "End frame for DupliFrames"); + RNA_def_property_ui_text(prop, "Instance Frames End", "End frame for frame instances"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); - prop = RNA_def_property(srna, "dupli_frames_on", PROP_INT, PROP_NONE | PROP_UNIT_TIME); + prop = RNA_def_property(srna, "instance_frames_on", PROP_INT, PROP_NONE | PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupon"); RNA_def_property_range(prop, 1, MAXFRAME); RNA_def_property_ui_range(prop, 1, 1500, 1, -1); - RNA_def_property_ui_text(prop, "Dupli Frames On", "Number of frames to use between DupOff frames"); + RNA_def_property_ui_text(prop, "Instance Frames On", "Number of frames to use between DupOff frames"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); - prop = RNA_def_property(srna, "dupli_frames_off", PROP_INT, PROP_NONE | PROP_UNIT_TIME); + prop = RNA_def_property(srna, "instance_frames_off", PROP_INT, PROP_NONE | PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupoff"); RNA_def_property_range(prop, 0, MAXFRAME); RNA_def_property_ui_range(prop, 0, 1500, 1, -1); - RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes"); + RNA_def_property_ui_text(prop, "Instance Frames Off", "Recurring frames to exclude from the frame instances"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); - prop = RNA_def_property(srna, "dupli_list", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "duplilist", NULL); - RNA_def_property_struct_type(prop, "DupliObject"); - RNA_def_property_ui_text(prop, "Dupli list", "Object duplis"); - - prop = RNA_def_property(srna, "is_duplicator", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "is_instancer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* drawing */ - prop = RNA_def_property(srna, "draw_type", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "display_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dt"); RNA_def_property_enum_items(prop, drawtype_items); - RNA_def_property_ui_text(prop, "Maximum Draw Type", "Maximum draw type to display object with in viewport"); + RNA_def_property_ui_text(prop, "Display As", "How to display object in viewport"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); prop = RNA_def_property(srna, "show_bounds", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWBOUNDOX); - RNA_def_property_ui_text(prop, "Draw Bounds", "Display the object's bounds"); + RNA_def_property_ui_text(prop, "Display Bounds", "Display the object's bounds"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); - prop = RNA_def_property(srna, "draw_bounds_type", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "display_bounds_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "boundtype"); RNA_def_property_enum_items(prop, boundtype_items); - RNA_def_property_ui_text(prop, "Draw Bounds Type", "Object boundary display type"); + RNA_def_property_ui_text(prop, "Display Bounds Type", "Object boundary display type"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWNAME); - RNA_def_property_ui_text(prop, "Draw Name", "Display the object's name"); + RNA_def_property_ui_text(prop, "Display Name", "Display the object's name"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "show_axis", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_AXIS); - RNA_def_property_ui_text(prop, "Draw Axes", "Display the object's origin and axes"); + RNA_def_property_ui_text(prop, "Display Axes", "Display the object's origin and axes"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "show_texture_space", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_TEXSPACE); - RNA_def_property_ui_text(prop, "Draw Texture Space", "Display the object's texture space"); + RNA_def_property_ui_text(prop, "Display Texture Space", "Display the object's texture space"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWWIRE); - RNA_def_property_ui_text(prop, "Draw Wire", "Add the object's wireframe over solid drawing"); + RNA_def_property_ui_text(prop, "Display Wire", "Add the object's wireframe over solid drawing"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "show_all_edges", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAW_ALL_EDGES); - RNA_def_property_ui_text(prop, "Draw All Edges", "Display all edges for mesh objects"); + RNA_def_property_ui_text(prop, "Display All Edges", "Display all edges for mesh objects"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP); - RNA_def_property_ui_text(prop, "Draw Transparent", - "Display material transparency in the object (unsupported for duplicator drawing)"); + RNA_def_property_ui_text(prop, "Display Transparent", + "Display material transparency in the object"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); - prop = RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "show_in_front", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWXRAY); - RNA_def_property_ui_text(prop, "X-Ray", - "Make the object draw in front of others (unsupported for duplicator drawing)"); + RNA_def_property_ui_text(prop, "In Front", + "Make the object draw in front of others"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); /* Grease Pencil */ +#if 1 /* FIXME: Remove this code when all Open-Movie assets have been fixed */ prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "gpd"); RNA_def_property_struct_type(prop, "GreasePencil"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_GPencil_datablocks_obdata_poll"); /* XXX */ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); - RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil data-block"); + RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil data-block (deprecated)"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); +#endif /* pose */ prop = RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE); @@ -2814,6 +2758,7 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "pose"); RNA_def_property_struct_type(prop, "Pose"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures"); /* shape keys */ @@ -2836,6 +2781,7 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "shapenr"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* XXX this is really unpredictable... */ RNA_def_property_int_funcs(prop, "rna_Object_active_shape_key_index_get", "rna_Object_active_shape_key_index_set", "rna_Object_active_shape_key_index_range"); @@ -2848,108 +2794,24 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Dynamic Topology Sculpting", NULL); - /* Levels of Detail */ - prop = RNA_def_property(srna, "lod_levels", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "lodlevels", NULL); - RNA_def_property_struct_type(prop, "LodLevel"); - RNA_def_property_ui_text(prop, "Level of Detail Levels", "A collection of detail levels to automatically switch between"); - RNA_def_property_update(prop, NC_OBJECT | ND_LOD, NULL); - - RNA_api_object(srna); -} - -static void rna_def_dupli_object(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "DupliObject", NULL); - RNA_def_struct_sdna(srna, "DupliObject"); - RNA_def_struct_ui_text(srna, "Object Duplicate", "An object duplicate"); - /* RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); */ - - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "ob"); - /* RNA_def_property_pointer_funcs(prop, "rna_DupliObject_object_get", NULL, NULL, NULL); */ - RNA_def_property_ui_text(prop, "Object", "Object being duplicated"); - - prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); - RNA_def_property_float_sdna(prop, NULL, "mat"); - RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Object Duplicate Matrix", "Object duplicate transformation matrix"); - - prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "no_draw", 0); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Hide", "Don't show dupli object in viewport or render"); - - prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); - RNA_def_property_int_funcs(prop, "rna_DupliObject_index_get", NULL, NULL); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Index", "Index in the lowest-level dupli list"); - - prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Persistent ID", "Persistent identifier for inter-frame matching of objects with motion blur"); - - prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Particle System", "Particle system that this dupli object was instanced from"); - - prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space"); - - prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE); - RNA_def_property_array(prop, 2); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space"); - - prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, dupli_items); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Dupli Type", "Duplicator type that generated this dupli object"); - - prop = RNA_def_property(srna, "random_id", PROP_INT, PROP_UNSIGNED); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Dupli random id", "Random id for this dupli object"); -} - -static void rna_def_object_base(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "ObjectBase", NULL); - RNA_def_struct_sdna(srna, "Base"); - RNA_def_struct_ui_text(srna, "Object Base", "An object instance in a scene"); - RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); + /* Base Settings */ + prop = RNA_def_property(srna, "is_from_instancer", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_FROMDUPLI); + RNA_def_property_ui_text(prop, "Base from Instancer", "Object comes from a instancer"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - RNA_def_property_ui_text(prop, "Object", "Object this base links to"); - - /* same as object layer */ - prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); - RNA_def_property_array(prop, 20); - RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on"); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_layer_update"); - - prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000); - RNA_def_property_array(prop, 8); + prop = RNA_def_property(srna, "is_from_set", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_FROM_SET); + RNA_def_property_ui_text(prop, "Base from Set", "Object comes from a background set"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object base is on"); - prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT); - RNA_def_property_ui_text(prop, "Select", "Object base selection state"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_select_update"); + /* Object Display */ + prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "display"); + RNA_def_property_struct_type(prop, "ObjectDisplay"); + RNA_def_property_ui_text(prop, "Object Display", "Object display settings for 3d viewport"); - RNA_api_object_base(srna); + RNA_api_object(srna); } void RNA_def_object(BlenderRNA *brna) @@ -2957,13 +2819,11 @@ void RNA_def_object(BlenderRNA *brna) rna_def_object(brna); RNA_define_animate_sdna(false); - rna_def_object_game_settings(brna); - rna_def_object_base(brna); rna_def_vertex_group(brna); + rna_def_face_map(brna); rna_def_material_slot(brna); - rna_def_dupli_object(brna); + rna_def_object_display(brna); RNA_define_animate_sdna(true); - rna_def_object_lodlevel(brna); } #endif |