diff options
Diffstat (limited to 'source/blender/makesrna/intern')
92 files changed, 19005 insertions, 15325 deletions
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 5e7438ce4ee..a795b4c6cae 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -32,7 +32,6 @@ endif() set(DEFSRC rna_ID.c rna_action.c - rna_actuator.c rna_animation.c rna_animviz.c rna_armature.c @@ -41,21 +40,23 @@ set(DEFSRC rna_cachefile.c rna_camera.c rna_cloth.c + rna_collection.c rna_color.c rna_constraint.c rna_context.c - rna_controller.c rna_curve.c rna_depsgraph.c rna_dynamicpaint.c rna_fcurve.c rna_fluidsim.c rna_gpencil.c - rna_group.c + rna_gpencil_modifier.c rna_image.c rna_key.c rna_lamp.c rna_lattice.c + rna_layer.c + rna_lightprobe.c rna_linestyle.c rna_main.c rna_mask.c @@ -72,15 +73,14 @@ set(DEFSRC rna_palette.c rna_particle.c rna_pose.c - rna_property.c rna_render.c rna_rigidbody.c rna_rna.c rna_scene.c rna_screen.c rna_sculpt_paint.c - rna_sensor.c rna_sequencer.c + rna_shader_fx.c rna_smoke.c rna_sound.c rna_space.c @@ -94,16 +94,16 @@ set(DEFSRC rna_userdef.c rna_vfont.c rna_wm.c + rna_wm_gizmo.c + rna_workspace.c rna_world.c ) set(APISRC rna_action_api.c - rna_actuator_api.c rna_animation_api.c rna_armature_api.c rna_camera_api.c - rna_controller_api.c rna_curve_api.c rna_fcurve_api.c rna_image_api.c @@ -116,7 +116,6 @@ set(APISRC rna_object_api.c rna_pose_api.c rna_scene_api.c - rna_sensor_api.c rna_sequencer_api.c rna_sound_api.c rna_space_api.c @@ -124,6 +123,8 @@ set(APISRC rna_ui_api.c rna_vfont_api.c rna_wm_api.c + rna_wm_gizmo_api.c + rna_workspace_api.c ) string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}") @@ -188,10 +189,6 @@ if(WITH_PYTHON) ) endif() -if(WITH_GAMEENGINE) - add_definitions(-DWITH_GAMEENGINE) -endif() - if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() @@ -220,12 +217,8 @@ if(WITH_IMAGE_HDR) add_definitions(-DWITH_HDR) endif() -if(WITH_IMAGE_FRAMESERVER) - add_definitions(-DWITH_FRAMESERVER) -endif() - if(WITH_AUDASPACE) - add_definitions(${AUDASPACE_DEFINITIONS}) + add_definitions(-DWITH_AUDASPACE) list(APPEND INC_SYS ${AUDASPACE_C_INCLUDE_DIRS} @@ -312,6 +305,10 @@ if(WITH_OPENSUBDIV) add_definitions(-DWITH_OPENSUBDIV) endif() +if(WITH_OPENSUBDIV_MODIFIER) + add_definitions(-DWITH_OPENSUBDIV_MODIFIER) +endif() + if(WITH_OPENVDB) add_definitions(-DWITH_OPENVDB) @@ -334,6 +331,7 @@ blender_include_dirs( ../../bmesh ../../blentranslation ../../depsgraph + ../../draw ../../gpu ../../imbuf ../../ikplugin diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 4b58e13d994..fbdb8abd3b0 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -906,7 +906,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr } else { PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop; - StructRNA *type = rna_find_struct((const char *)pprop->type); + StructRNA *type = (pprop->type) ? rna_find_struct((const char *)pprop->type) : NULL; if (type && (type->flag & STRUCT_ID)) { fprintf(f, " if (value.data)\n"); fprintf(f, " id_lib_extern((ID *)value.data);\n\n"); @@ -2482,12 +2482,24 @@ static void rna_auto_types(void) for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { /* DNA name for Screen is patched in 2.5, we do the reverse here .. */ - if (ds->dnaname && STREQ(ds->dnaname, "Screen")) - ds->dnaname = "bScreen"; + if (ds->dnaname) { + if (STREQ(ds->dnaname, "Screen")) + ds->dnaname = "bScreen"; + if (STREQ(ds->dnaname, "Group")) + ds->dnaname = "Collection"; + if (STREQ(ds->dnaname, "GroupObject")) + ds->dnaname = "CollectionObject"; + } for (dp = ds->cont.properties.first; dp; dp = dp->next) { - if (dp->dnastructname && STREQ(dp->dnastructname, "Screen")) - dp->dnastructname = "bScreen"; + if (dp->dnastructname) { + if (STREQ(dp->dnastructname, "Screen")) + dp->dnastructname = "bScreen"; + if (STREQ(dp->dnastructname, "Group")) + dp->dnastructname = "Collection"; + if (STREQ(dp->dnastructname, "GroupObject")) + dp->dnastructname = "CollectionObject"; + } if (dp->dnatype) { if (dp->prop->type == PROP_POINTER) { @@ -2654,7 +2666,7 @@ static void rna_generate_property_prototypes(BlenderRNA *UNUSED(brna), StructRNA fprintf(f, "\n"); for (prop = srna->cont.properties.first; prop; prop = prop->next) - fprintf(f, "%s%s rna_%s_%s;\n", (prop->flag & PROP_EXPORT) ? "" : "", rna_property_structname(prop->type), + fprintf(f, "%s rna_%s_%s;\n", rna_property_structname(prop->type), srna->identifier, prop->identifier); fprintf(f, "\n"); } @@ -3023,12 +3035,33 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr } break; } + case PROP_POINTER: + { + PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop; + + /* XXX This systematically enforces that flag on ID pointers... we'll probably have to revisit. :/ */ + StructRNA *type = rna_find_struct((const char *)pprop->type); + if (type && (type->flag & STRUCT_ID)) { + prop->flag |= PROP_PTR_NO_OWNERSHIP; + } + break; + } + case PROP_COLLECTION: + { + CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop; + + /* XXX This systematically enforces that flag on ID pointers... we'll probably have to revisit. :/ */ + StructRNA *type = rna_find_struct((const char *)cprop->item_type); + if (type && (type->flag & STRUCT_ID)) { + prop->flag |= PROP_PTR_NO_OWNERSHIP; + } + break; + } default: break; } - fprintf(f, "%s%s rna_%s%s_%s = {\n", - (prop->flag & PROP_EXPORT) ? "" : "", + fprintf(f, "%s rna_%s%s_%s = {\n", rna_property_structname(prop->type), srna->identifier, strnest, prop->identifier); @@ -3038,7 +3071,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr else fprintf(f, "NULL,\n"); fprintf(f, "\t%d, ", prop->magic); rna_print_c_string(f, prop->identifier); - fprintf(f, ", %d, %d, %d, %d, ", prop->flag, prop->flag_parameter, prop->flag_internal, prop->tags); + fprintf(f, ", %d, %d, %d, %d, %d, ", prop->flag, prop->flag_override, prop->flag_parameter, prop->flag_internal, prop->tags); rna_print_c_string(f, prop->name); fprintf(f, ",\n\t"); rna_print_c_string(f, prop->description); fprintf(f, ",\n\t"); fprintf(f, "%d, ", prop->icon); @@ -3053,12 +3086,15 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr prop->arraylength[1], prop->arraylength[2], prop->totarraylength); - fprintf(f, "\t%s%s, %d, %s, %s,\n", + fprintf(f, "\t%s%s, %d, %s, %s, %s, %s, %s,\n", (prop->flag & PROP_CONTEXT_UPDATE) ? "(UpdateFunc)" : "", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable), - rna_function_string(prop->itemeditable)); + rna_function_string(prop->itemeditable), + rna_function_string(prop->override_diff), + rna_function_string(prop->override_store), + rna_function_string(prop->override_apply)); if (prop->flag_internal & PROP_INTERN_RAW_ACCESS) rna_set_raw_offset(f, srna, prop); else fprintf(f, "\t0, -1"); @@ -3353,49 +3389,49 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_action.c", "rna_action_api.c", RNA_def_action}, {"rna_animation.c", "rna_animation_api.c", RNA_def_animation}, {"rna_animviz.c", NULL, RNA_def_animviz}, - {"rna_actuator.c", "rna_actuator_api.c", RNA_def_actuator}, {"rna_armature.c", "rna_armature_api.c", RNA_def_armature}, {"rna_boid.c", NULL, RNA_def_boid}, {"rna_brush.c", NULL, RNA_def_brush}, {"rna_cachefile.c", NULL, RNA_def_cachefile}, {"rna_camera.c", "rna_camera_api.c", RNA_def_camera}, {"rna_cloth.c", NULL, RNA_def_cloth}, + {"rna_collection.c", NULL, RNA_def_collections}, {"rna_color.c", NULL, RNA_def_color}, {"rna_constraint.c", NULL, RNA_def_constraint}, {"rna_context.c", NULL, RNA_def_context}, - {"rna_controller.c", "rna_controller_api.c", RNA_def_controller}, {"rna_curve.c", "rna_curve_api.c", RNA_def_curve}, - {"rna_depsgraph.c", NULL, RNA_def_depsgraph}, {"rna_dynamicpaint.c", NULL, RNA_def_dynamic_paint}, {"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve}, {"rna_fluidsim.c", NULL, RNA_def_fluidsim}, {"rna_gpencil.c", NULL, RNA_def_gpencil}, - {"rna_group.c", NULL, RNA_def_group}, {"rna_image.c", "rna_image_api.c", RNA_def_image}, {"rna_key.c", NULL, RNA_def_key}, - {"rna_lamp.c", NULL, RNA_def_lamp}, + {"rna_lamp.c", NULL, RNA_def_light}, {"rna_lattice.c", "rna_lattice_api.c", RNA_def_lattice}, + {"rna_layer.c", NULL, RNA_def_view_layer}, {"rna_linestyle.c", NULL, RNA_def_linestyle}, {"rna_main.c", "rna_main_api.c", RNA_def_main}, {"rna_material.c", "rna_material_api.c", RNA_def_material}, {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh}, {"rna_meta.c", "rna_meta_api.c", RNA_def_meta}, {"rna_modifier.c", NULL, RNA_def_modifier}, + {"rna_gpencil_modifier.c", NULL, RNA_def_greasepencil_modifier}, + {"rna_shader_fx.c", NULL, RNA_def_shader_fx }, {"rna_nla.c", NULL, RNA_def_nla}, {"rna_nodetree.c", NULL, RNA_def_nodetree}, {"rna_object.c", "rna_object_api.c", RNA_def_object}, {"rna_object_force.c", NULL, RNA_def_object_force}, + {"rna_depsgraph.c", NULL, RNA_def_depsgraph}, {"rna_packedfile.c", NULL, RNA_def_packedfile}, {"rna_palette.c", NULL, RNA_def_palette}, {"rna_particle.c", NULL, RNA_def_particle}, {"rna_pose.c", "rna_pose_api.c", RNA_def_pose}, - {"rna_property.c", NULL, RNA_def_gameproperty}, + {"rna_lightprobe.c", NULL, RNA_def_lightprobe}, {"rna_render.c", NULL, RNA_def_render}, {"rna_rigidbody.c", NULL, RNA_def_rigidbody}, {"rna_scene.c", "rna_scene_api.c", RNA_def_scene}, {"rna_screen.c", NULL, RNA_def_screen}, {"rna_sculpt_paint.c", NULL, RNA_def_sculpt_paint}, - {"rna_sensor.c", "rna_sensor_api.c", RNA_def_sensor}, {"rna_sequencer.c", "rna_sequencer_api.c", RNA_def_sequencer}, {"rna_smoke.c", NULL, RNA_def_smoke}, {"rna_space.c", "rna_space_api.c", RNA_def_space}, @@ -3408,6 +3444,8 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_userdef.c", NULL, RNA_def_userdef}, {"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont}, {"rna_wm.c", "rna_wm_api.c", RNA_def_wm}, + {"rna_wm_gizmo.c", "rna_wm_gizmo_api.c", RNA_def_wm_gizmo}, + {"rna_workspace.c", "rna_workspace_api.c", RNA_def_workspace}, {"rna_world.c", NULL, RNA_def_world}, {"rna_movieclip.c", NULL, RNA_def_movieclip}, {"rna_tracking.c", NULL, RNA_def_tracking}, @@ -3725,7 +3763,7 @@ static const char *cpp_classes = "" " COLLECTION_PROPERTY_LENGTH_##has_length(sname, identifier) \\\n" " COLLECTION_PROPERTY_LOOKUP_INT_##has_lookup_int(sname, identifier) \\\n" " COLLECTION_PROPERTY_LOOKUP_STRING_##has_lookup_string(sname, identifier) \\\n" -" Collection<sname, type, sname##_##identifier##_begin, \\\n" +" CollectionRef<sname, type, sname##_##identifier##_begin, \\\n" " sname##_##identifier##_next, sname##_##identifier##_end, \\\n" " sname##_##identifier##_length_wrap, \\\n" " sname##_##identifier##_lookup_int_wrap, sname##_##identifier##_lookup_string_wrap, collection_funcs> identifier;\n" @@ -3738,6 +3776,9 @@ static const char *cpp_classes = "" " operator void*() { return ptr.data; }\n" " operator bool() { return ptr.data != NULL; }\n" "\n" +" bool operator==(const Pointer &other) { return ptr.data == other.ptr.data; }\n" +" bool operator!=(const Pointer &other) { return ptr.data != other.ptr.data; }\n" +"\n" " PointerRNA ptr;\n" "};\n" "\n" @@ -3819,9 +3860,9 @@ static const char *cpp_classes = "" "template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend,\n" " TLengthFunc Tlength, TLookupIntFunc Tlookup_int, TLookupStringFunc Tlookup_string,\n" " typename Tcollection_funcs>\n" -"class Collection : public Tcollection_funcs {\n" +"class CollectionRef : public Tcollection_funcs {\n" "public:\n" -" Collection(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n" +" CollectionRef(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n" "\n" " void begin(CollectionIterator<T, Tbegin, Tnext, Tend>& iter)\n" " { iter.begin(ptr); }\n" diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index bebf232b3b9..eeb9713b1d4 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -36,6 +36,7 @@ #include "BLI_math_base.h" #include "BKE_icons.h" +#include "BKE_library.h" #include "BKE_object.h" #include "RNA_access.h" @@ -58,10 +59,10 @@ const EnumPropertyItem rna_enum_id_type_items[] = { {ID_CU, "CURVE", ICON_CURVE_DATA, "Curve", ""}, {ID_VF, "FONT", ICON_FONT_DATA, "Font", ""}, {ID_GD, "GREASEPENCIL", ICON_GREASEPENCIL, "Grease Pencil", ""}, - {ID_GR, "GROUP", ICON_GROUP, "Group", ""}, + {ID_GR, "COLLECTION", ICON_GROUP, "Collection", ""}, {ID_IM, "IMAGE", ICON_IMAGE_DATA, "Image", ""}, {ID_KE, "KEY", ICON_SHAPEKEY_DATA, "Key", ""}, - {ID_LA, "LAMP", ICON_LAMP_DATA, "Lamp", ""}, + {ID_LA, "LIGHT", ICON_LIGHT_DATA, "Light", ""}, {ID_LI, "LIBRARY", ICON_LIBRARY_DATA_DIRECT, "Library", ""}, {ID_LS, "LINESTYLE", ICON_LINE_DATA, "Line Style", ""}, {ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattice", ""}, @@ -75,14 +76,15 @@ const EnumPropertyItem rna_enum_id_type_items[] = { {ID_PC, "PAINTCURVE", ICON_CURVE_BEZCURVE, "Paint Curve", ""}, {ID_PAL, "PALETTE", ICON_COLOR, "Palette", ""}, {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""}, + {ID_LP, "LIGHT_PROBE", ICON_LIGHTPROBE_CUBEMAP, "Light Probe", ""}, {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""}, - {ID_SCR, "SCREEN", ICON_SPLITSCREEN, "Screen", ""}, - {ID_SO, "SOUND", ICON_PLAY_AUDIO, "Sound", ""}, + {ID_SO, "SOUND", ICON_SOUND, "Sound", ""}, {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""}, {ID_TXT, "TEXT", ICON_TEXT, "Text", ""}, {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""}, - {ID_WM, "WINDOWMANAGER", ICON_FULLSCREEN, "Window Manager", ""}, + {ID_WM, "WINDOWMANAGER", ICON_WINDOW, "Window Manager", ""}, {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""}, + {ID_WS, "WORKSPACE", ICON_WORKSPACE, "Workspace", ""}, {0, NULL, 0, NULL, NULL} }; @@ -94,16 +96,44 @@ const EnumPropertyItem rna_enum_id_type_items[] = { #include "BKE_font.h" #include "BKE_idprop.h" -#include "BKE_library.h" #include "BKE_library_query.h" +#include "BKE_library_override.h" #include "BKE_library_remap.h" #include "BKE_animsys.h" #include "BKE_material.h" -#include "BKE_depsgraph.h" #include "BKE_global.h" /* XXX, remove me */ +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" + #include "WM_api.h" +void rna_ID_override_static_property_operation_refname_get(PointerRNA *ptr, char *value) +{ + IDOverrideStaticPropertyOperation *opop = ptr->data; + strcpy(value, (opop->subitem_reference_name == NULL) ? "" : opop->subitem_reference_name); +} + +int rna_ID_override_static_property_operation_refname_length(PointerRNA *ptr) +{ + IDOverrideStaticPropertyOperation *opop = ptr->data; + return (opop->subitem_reference_name == NULL) ? 0 : strlen(opop->subitem_reference_name); +} + +void rna_ID_override_static_property_operation_locname_get(PointerRNA *ptr, char *value) +{ + IDOverrideStaticPropertyOperation *opop = ptr->data; + strcpy(value, (opop->subitem_local_name == NULL) ? "" : opop->subitem_local_name); +} + +int rna_ID_override_static_property_operation_locname_length(PointerRNA *ptr) +{ + IDOverrideStaticPropertyOperation *opop = ptr->data; + return (opop->subitem_local_name == NULL) ? 0 : strlen(opop->subitem_local_name); +} + + /* name functions that ignore the first two ID characters */ void rna_ID_name_get(PointerRNA *ptr, char *value) { @@ -138,6 +168,34 @@ static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info)) return PROP_EDITABLE; } +void rna_ID_name_full_get(PointerRNA *ptr, char *value) +{ + ID *id = (ID *)ptr->data; + BKE_id_full_name_get(value, id); +} + +int rna_ID_name_full_length(PointerRNA *ptr) +{ + ID *id = (ID *)ptr->data; + char name[MAX_ID_FULL_NAME]; + BKE_id_full_name_get(name, id); + return strlen(name); +} + +static int rna_ID_is_evaluated_get(PointerRNA *ptr) +{ + ID *id = (ID *)ptr->data; + + return (DEG_get_original_id(id) != id); +} + +static PointerRNA rna_ID_original_get(PointerRNA *ptr) +{ + ID *id = (ID *)ptr->data; + + return rna_pointer_inherit_refine(ptr, &RNA_ID, DEG_get_original_id(id)); +} + short RNA_type_to_ID_code(const StructRNA *type) { const StructRNA *base_type = RNA_struct_base_child_of(type, &RNA_ID); @@ -151,10 +209,10 @@ short RNA_type_to_ID_code(const StructRNA *type) if (base_type == &RNA_Camera) return ID_CA; if (base_type == &RNA_Curve) return ID_CU; if (base_type == &RNA_GreasePencil) return ID_GD; - if (base_type == &RNA_Group) return ID_GR; + if (base_type == &RNA_Collection) return ID_GR; if (base_type == &RNA_Image) return ID_IM; if (base_type == &RNA_Key) return ID_KE; - if (base_type == &RNA_Lamp) return ID_LA; + if (base_type == &RNA_Light) return ID_LA; if (base_type == &RNA_Library) return ID_LI; if (base_type == &RNA_FreestyleLineStyle) return ID_LS; if (base_type == &RNA_Lattice) return ID_LT; @@ -168,6 +226,7 @@ short RNA_type_to_ID_code(const StructRNA *type) if (base_type == &RNA_ParticleSettings) return ID_PA; if (base_type == &RNA_Palette) return ID_PAL; if (base_type == &RNA_PaintCurve) return ID_PC; + if (base_type == &RNA_LightProbe) return ID_LP; if (base_type == &RNA_Scene) return ID_SCE; if (base_type == &RNA_Screen) return ID_SCR; if (base_type == &RNA_Sound) return ID_SO; @@ -175,6 +234,7 @@ short RNA_type_to_ID_code(const StructRNA *type) if (base_type == &RNA_Texture) return ID_TE; if (base_type == &RNA_Text) return ID_TXT; if (base_type == &RNA_VectorFont) return ID_VF; + if (base_type == &RNA_WorkSpace) return ID_WS; if (base_type == &RNA_World) return ID_WO; if (base_type == &RNA_WindowManager) return ID_WM; @@ -193,10 +253,10 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_CF: return &RNA_CacheFile; case ID_CU: return &RNA_Curve; case ID_GD: return &RNA_GreasePencil; - case ID_GR: return &RNA_Group; + case ID_GR: return &RNA_Collection; case ID_IM: return &RNA_Image; case ID_KE: return &RNA_Key; - case ID_LA: return &RNA_Lamp; + case ID_LA: return &RNA_Light; case ID_LI: return &RNA_Library; case ID_LS: return &RNA_FreestyleLineStyle; case ID_LT: return &RNA_Lattice; @@ -210,6 +270,7 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_PA: return &RNA_ParticleSettings; case ID_PAL: return &RNA_Palette; case ID_PC: return &RNA_PaintCurve; + case ID_LP: return &RNA_LightProbe; case ID_SCE: return &RNA_Scene; case ID_SCR: return &RNA_Screen; case ID_SO: return &RNA_Sound; @@ -219,6 +280,7 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_VF: return &RNA_VectorFont; case ID_WM: return &RNA_WindowManager; case ID_WO: return &RNA_World; + case ID_WS: return &RNA_WorkSpace; /* deprecated */ case ID_IP: break; @@ -305,6 +367,15 @@ static ID *rna_ID_copy(ID *id, Main *bmain) return NULL; } +static ID *rna_ID_override_create(ID *id, Main *bmain) +{ + if (!BKE_override_static_is_enabled() || id->lib == NULL) { + return NULL; + } + + return BKE_override_static_create_from_id(bmain, id); +} + static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) { /* XXX, new function for this! */ @@ -343,7 +414,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) } } - DAG_id_tag_update(id, flag); + DEG_id_tag_update(id, flag); } static void rna_ID_user_clear(ID *id) @@ -379,14 +450,14 @@ static struct ID *rna_ID_make_local(struct ID *self, Main *bmain, bool clear_pro static AnimData *rna_ID_animation_data_create(ID *id, Main *bmain) { AnimData *adt = BKE_animdata_add_id(id); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); return adt; } static void rna_ID_animation_data_free(ID *id, Main *bmain) { BKE_animdata_free(id, true); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } #ifdef WITH_PYTHON @@ -455,7 +526,7 @@ static Material *rna_IDMaterials_pop_id( return NULL; } - DAG_id_tag_update(id, OB_RECALC_DATA); + DEG_id_tag_update(id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_DRAW, id); WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id); @@ -466,7 +537,7 @@ static void rna_IDMaterials_clear_id(ID *id, Main *bmain, bool remove_material_s { BKE_material_clear_id(bmain, id, remove_material_slot); - DAG_id_tag_update(id, OB_RECALC_DATA); + DEG_id_tag_update(id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_DRAW, id); WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id); } @@ -783,52 +854,52 @@ static void rna_def_ID_properties(BlenderRNA *brna) /* IDP_STRING */ prop = RNA_def_property(srna, "string", PROP_STRING, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); /* IDP_INT */ prop = RNA_def_property(srna, "int", PROP_INT, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); prop = RNA_def_property(srna, "int_array", PROP_INT, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 1); /* IDP_FLOAT */ prop = RNA_def_property(srna, "float", PROP_FLOAT, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); prop = RNA_def_property(srna, "float_array", PROP_FLOAT, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 1); /* IDP_DOUBLE */ prop = RNA_def_property(srna, "double", PROP_FLOAT, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); prop = RNA_def_property(srna, "double_array", PROP_FLOAT, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 1); /* IDP_GROUP */ prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "PropertyGroup"); prop = RNA_def_property(srna, "collection", PROP_COLLECTION, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_struct_type(prop, "PropertyGroup"); prop = RNA_def_property(srna, "idp_array", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "PropertyGroup"); RNA_def_property_collection_funcs(prop, "rna_IDPArray_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_IDPArray_length", NULL, NULL, NULL); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); /* never tested, maybe its useful to have this? */ #if 0 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting"); RNA_def_struct_name_property(srna, prop); @@ -836,7 +907,7 @@ static void rna_def_ID_properties(BlenderRNA *brna) /* IDP_ID */ prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY | PROP_NEVER_UNLINK); + RNA_def_property_flag(prop, PROP_IDPROPERTY | PROP_NEVER_UNLINK); RNA_def_property_struct_type(prop, "ID"); @@ -854,7 +925,7 @@ static void rna_def_ID_properties(BlenderRNA *brna) * however this isn't prefect because it overrides how python would set the name * when we only really want this so RNA_def_struct_name_property() is set to something useful */ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_flag(prop, PROP_EXPORT | PROP_IDPROPERTY); + RNA_def_property_flag(prop, PROP_IDPROPERTY); /*RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting"); RNA_def_struct_name_property(srna, prop); @@ -965,6 +1036,107 @@ static void rna_def_image_preview(BlenderRNA *brna) RNA_def_function_ui_description(func, "Reload the preview from its source path"); } +static void rna_def_ID_override_static_property_operation(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static const EnumPropertyItem static_override_property_operation_items[] = { + {IDOVERRIDESTATIC_OP_NOOP, "NOOP", 0, "No-Op", "Does nothing, prevents adding actual overrides (NOT USED)"}, + {IDOVERRIDESTATIC_OP_REPLACE, "REPLACE", 0, "Replace", "Replace value of reference by overriding one"}, + {IDOVERRIDESTATIC_OP_ADD, "DIFF_ADD", 0, "Differential", + "Stores and apply difference between reference and local value (NOT USED)"}, + {IDOVERRIDESTATIC_OP_SUBTRACT, "DIFF_SUB", 0, "Differential", + "Stores and apply difference between reference and local value (NOT USED)"}, + {IDOVERRIDESTATIC_OP_MULTIPLY, "FACT_MULTIPLY", 0, "Factor", + "Stores and apply multiplication factor between reference and local value (NOT USED)"}, + {IDOVERRIDESTATIC_OP_INSERT_AFTER, "INSERT_AFTER", 0, "Insert After", + "Insert a new item into collection after the one referenced in subitem_reference_name or _index"}, + {IDOVERRIDESTATIC_OP_INSERT_BEFORE, "INSERT_BEFORE", 0, "Insert Before", + "Insert a new item into collection after the one referenced in subitem_reference_name or _index (NOT USED)"}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem static_override_property_flag_items[] = { + {IDOVERRIDESTATIC_FLAG_MANDATORY, "MANDATORY", 0, "Mandatory", + "For templates, prevents the user from removing pre-defined operation (NOT USED)"}, + {IDOVERRIDESTATIC_FLAG_LOCKED, "LOCKED", 0, "Locked", + "Prevents the user from modifying that override operation (NOT USED)"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "IDOverrideStaticPropertyOperation", NULL); + RNA_def_struct_ui_text(srna, "ID Static Override Property Operation", + "Description of an override operation over an overridden property"); + + prop = RNA_def_enum(srna, "operation", static_override_property_operation_items, IDOVERRIDESTATIC_OP_REPLACE, + "Operation", "What override operation is performed"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + + prop = RNA_def_enum(srna, "flag", static_override_property_flag_items, 0, + "Flags", "Optional flags (NOT USED)"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + + prop = RNA_def_string(srna, "subitem_reference_name", NULL, INT_MAX, "Subitem Reference Name", + "Used to handle insertions into collection"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + RNA_def_property_string_funcs(prop, "rna_ID_override_static_property_operation_refname_get", + "rna_ID_override_static_property_operation_refname_length", NULL); + + prop = RNA_def_string(srna, "subitem_local_name", NULL, INT_MAX, "Subitem Local Name", + "Used to handle insertions into collection"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + RNA_def_property_string_funcs(prop, "rna_ID_override_static_property_operation_locname_get", + "rna_ID_override_static_property_operation_locname_length", NULL); + + prop = RNA_def_int(srna, "subitem_reference_index", -1, -1, INT_MAX, "Subitem Reference Index", + "Used to handle insertions into collection", -1, INT_MAX); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + + prop = RNA_def_int(srna, "subitem_local_index", -1, -1, INT_MAX, "Subitem Local Index", + "Used to handle insertions into collection", -1, INT_MAX); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ +} + +static void rna_def_ID_override_static_property(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "IDOverrideStaticProperty", NULL); + RNA_def_struct_ui_text(srna, "ID Static Override Property", "Description of an overridden property"); + + /* String pointer, we *should* add get/set/etc. But NULL rna_path would be a nasty bug anyway... */ + prop = RNA_def_string(srna, "rna_path", NULL, INT_MAX, "RNA Path", + "RNA path leading to that property, from owning ID"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ + + RNA_def_collection(srna, "operations", "IDOverrideStaticPropertyOperation", "Operations", + "List of overriding operations for a property"); + + rna_def_ID_override_static_property_operation(brna); +} + +static void rna_def_ID_override_static(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "IDOverrideStatic", NULL); + RNA_def_struct_ui_text(srna, "ID Static Override", "Struct gathering all data needed by statically overridden IDs"); + + RNA_def_pointer(srna, "reference", "ID", "Reference ID", "Linked ID used as reference by this override"); + + prop = RNA_def_boolean(srna, "auto_generate", true, "Auto Generate Override", + "Automatically generate overriding operations by detecting changes in properties"); + RNA_def_property_boolean_sdna(prop, NULL, "flag", STATICOVERRIDE_AUTO); + + RNA_def_collection(srna, "properties", "IDOverrideStaticProperty", "Properties", + "List of overridden properties"); + + rna_def_ID_override_static_property(brna); +} + static void rna_def_ID(BlenderRNA *brna) { StructRNA *srna; @@ -994,6 +1166,25 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_property_update(prop, NC_ID | NA_RENAME, NULL); RNA_def_struct_name_property(srna, prop); + prop = RNA_def_property(srna, "name_full", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Full Name", "Unique data-block ID name, including library one is any"); + RNA_def_property_string_funcs(prop, "rna_ID_name_full_get", "rna_ID_name_full_length", NULL); + RNA_def_property_string_maxlength(prop, MAX_ID_FULL_NAME); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop = RNA_def_property(srna, "is_evaluated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Is Evaluated", + "Whether this ID is runtime-only, evaluated data-block, or actual data from .blend file"); + RNA_def_property_boolean_funcs(prop, "rna_ID_is_evaluated_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop = RNA_def_property(srna, "original", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ID"); + RNA_def_property_ui_text(prop, "Original ID", + "Actual data-block from .blend file (Main database) that generated that evaluated one"); + RNA_def_property_pointer_funcs(prop, "rna_ID_original_get", NULL, NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_PTR_NO_OWNERSHIP); + prop = RNA_def_property(srna, "users", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "us"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -1002,6 +1193,7 @@ static void rna_def_ID(BlenderRNA *brna) prop = RNA_def_property(srna, "use_fake_user", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_FAKEUSER); RNA_def_property_ui_text(prop, "Fake User", "Save this data-block even if it has no users"); + RNA_def_property_ui_icon(prop, ICON_FAKE_USER_OFF, true); RNA_def_property_boolean_funcs(prop, NULL, "rna_ID_fake_user_set"); prop = RNA_def_property(srna, "tag", PROP_BOOLEAN, PROP_NONE); @@ -1011,16 +1203,6 @@ static void rna_def_ID(BlenderRNA *brna) "Tools can use this to tag data for their own purposes " "(initial state is undefined)"); - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "recalc", ID_RECALC); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Is Updated", "Data-block is tagged for recalculation"); - - prop = RNA_def_property(srna, "is_updated_data", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "recalc", ID_RECALC_DATA); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Is Updated Data", "Data-block data is tagged for recalculation"); - prop = RNA_def_property(srna, "is_library_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "tag", LIB_TAG_INDIRECT); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -1031,6 +1213,9 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Library", "Library file the data-block is linked from"); + prop = RNA_def_pointer(srna, "override_static", "IDOverrideStatic", "Static Override", "Static override data"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + prop = RNA_def_pointer(srna, "preview", "ImagePreview", "Preview", "Preview image and icon of this data-block (None if not supported for this type of data)"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -1043,6 +1228,12 @@ static void rna_def_ID(BlenderRNA *brna) parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "override_create", "rna_ID_override_create"); + RNA_def_function_ui_description(func, "Create an overridden local copy of this linked data-block (not supported for all data-blocks)"); + RNA_def_function_flag(func, FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "id", "ID", "", "New overridden local copy of the ID"); + RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear"); RNA_def_function_ui_description(func, "Clear the user count of a data-block so its not saved, " "on reload the data will be removed"); @@ -1147,6 +1338,7 @@ void RNA_def_ID(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Any Type", "RNA type used for pointers to any possible data"); rna_def_ID(brna); + rna_def_ID_override_static(brna); rna_def_image_preview(brna); rna_def_ID_properties(brna); rna_def_ID_materials(brna); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 51293340a6c..f52e13ba1c9 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -34,6 +34,8 @@ #include "DNA_ID.h" #include "DNA_scene_types.h" +#include "DNA_constraint_types.h" +#include "DNA_modifier_types.h" #include "DNA_windowmanager_types.h" #include "BLI_blenlib.h" @@ -42,6 +44,10 @@ #include "BLI_ghash.h" #include "BLI_math.h" +#ifdef DEBUG_OVERRIDE_TIMEIT +# include "PIL_time_utildefines.h" +#endif + #include "BLF_api.h" #include "BLT_translation.h" @@ -50,19 +56,21 @@ #include "BKE_idcode.h" #include "BKE_idprop.h" #include "BKE_fcurve.h" -#include "BKE_library.h" +#include "BKE_library_override.h" #include "BKE_main.h" #include "BKE_report.h" +#include "DEG_depsgraph.h" + #include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" #include "WM_api.h" +#include "WM_message.h" /* flush updates */ #include "DNA_object_types.h" -#include "BKE_depsgraph.h" #include "WM_types.h" #include "rna_internal.h" @@ -431,7 +439,7 @@ static PropertyRNA *arraytypemap[IDP_NUMTYPES] = { (PropertyRNA *)&rna_PropertyGroupItem_double_array }; -IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr) +static void *rna_idproperty_check_ex(PropertyRNA **prop, PointerRNA *ptr, const bool return_rnaprop) { /* This is quite a hack, but avoids some complexity in the API. we * pass IDProperty structs as PropertyRNA pointers to the outside. @@ -453,8 +461,9 @@ IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr) return idprop; } - else - return NULL; + else { + return return_rnaprop ? *prop : NULL; + } } { @@ -469,6 +478,19 @@ IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr) } } +/* This function only returns an IDProperty, + * or NULL (in case IDProp could not be found, or prop is a real RNA property). */ +IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr) +{ + return rna_idproperty_check_ex(prop, ptr, false); +} + +/* This function always return the valid, real data pointer, be it a regular RNA property one, or an IDProperty one. */ +PropertyRNA *rna_ensure_property_realdata(PropertyRNA **prop, PointerRNA *ptr) +{ + return rna_idproperty_check_ex(prop, ptr, true); +} + static PropertyRNA *rna_ensure_property(PropertyRNA *prop) { /* the quick version if we don't need the idproperty */ @@ -597,7 +619,7 @@ StructRNA *RNA_struct_base(StructRNA *type) /** * Use to find the subtype directly below a base-type. * - * So if type were `RNA_SpotLamp`, `RNA_struct_base_of(type, &RNA_ID)` would return `&RNA_Lamp`. + * So if type were `RNA_SpotLIght`, `RNA_struct_base_of(type, &RNA_ID)` would return `&RNA_Light`. */ const StructRNA *RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type) { @@ -982,6 +1004,11 @@ int RNA_property_flag(PropertyRNA *prop) return rna_ensure_property(prop)->flag; } +int RNA_property_override_flag(PropertyRNA *prop) +{ + return rna_ensure_property(prop)->flag_override; +} + /** * Get the tags set for \a prop as int bitfield. * \note Doesn't perform any validity check on the set bits. #RNA_def_property_tags does this @@ -1637,6 +1664,21 @@ int RNA_enum_from_identifier(const EnumPropertyItem *item, const char *identifie return -1; } +/** + * Take care using this with translated enums, + * prefer #RNA_enum_from_identifier where possible. + */ +int RNA_enum_from_name(const EnumPropertyItem *item, const char *name) +{ + int i = 0; + for (; item->identifier; item++, i++) { + if (item->identifier[0] && STREQ(item->name, name)) { + return i; + } + } + return -1; +} + int RNA_enum_from_value(const EnumPropertyItem *item, const int value) { int i = 0; @@ -1819,7 +1861,8 @@ bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop) return ((flag & PROP_EDITABLE) && (flag & PROP_REGISTER) == 0 && - (!id || !ID_IS_LINKED(id) || (prop->flag & PROP_LIB_EXCEPTION))); + (!id || ((!ID_IS_LINKED(id) || (prop->flag & PROP_LIB_EXCEPTION)) && + (!id->override_static || RNA_property_overridable_get(ptr, prop))))); } /** @@ -1845,11 +1888,19 @@ bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char * } /* property from linked data-block */ - if (id && ID_IS_LINKED(id) && (prop->flag & PROP_LIB_EXCEPTION) == 0) { - if (!(*r_info)[0]) { - *r_info = N_("Can't edit this property from a linked data-block"); + if (id) { + if (ID_IS_LINKED(id) && (prop->flag & PROP_LIB_EXCEPTION) == 0) { + if (!(*r_info)[0]) { + *r_info = N_("Can't edit this property from a linked data-block."); + } + return false; + } + if (id->override_static != NULL && !RNA_property_overridable_get(ptr, prop)) { + if (!(*r_info)[0]) { + *r_info = N_("Can't edit this property from an override data-block."); + } + return false; } - return false; } return ((flag & PROP_EDITABLE) && (flag & PROP_REGISTER) == 0); @@ -1923,6 +1974,70 @@ bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop) return false; } +/** \note Does not take into account editable status, this has to be checked separately + * (using RNA_property_edtiable_flag() usually). */ +bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop) +{ + if (prop->magic == RNA_MAGIC) { + /* Special handling for insertions of constraints or modifiers... */ + /* TODO Note We may want to add a more generic system to RNA (like a special property in struct of items) + * if we get more overrideable collections, for now we can live with those special-cases handling I think. */ + if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) { + bConstraint *con = ptr->data; + if (con->flag & CONSTRAINT_STATICOVERRIDE_LOCAL) { + return true; + } + } + else if (RNA_struct_is_a(ptr->type, &RNA_Modifier)) { + ModifierData *mod = ptr->data; + if (mod->flag & eModifierFlag_StaticOverride_Local) { + return true; + } + } + /* If this is a RNA-defined property (real or 'virtual' IDProp), we want to use RNA prop flag. */ + return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON) && (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_STATIC); + } + else { + /* If this is a real 'pure' IDProp (aka custom property), we want to use the IDProp flag. */ + return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON) && (((IDProperty *)prop)->flag & IDP_FLAG_OVERRIDABLE_STATIC); + } +} + +/* Should only be used for custom properties */ +bool RNA_property_overridable_static_set(PointerRNA *UNUSED(ptr), PropertyRNA *prop, const bool is_overridable) +{ + /* Only works for pure custom properties IDProps. */ + if (prop->magic != RNA_MAGIC) { + IDProperty *idprop = (IDProperty *)prop; + + idprop->flag = is_overridable ? (idprop->flag | IDP_FLAG_OVERRIDABLE_STATIC) : + (idprop->flag & ~IDP_FLAG_OVERRIDABLE_STATIC); + return true; + } + + return false; +} + + +bool RNA_property_overridden(PointerRNA *ptr, PropertyRNA *prop) +{ + char *rna_path = RNA_path_from_ID_to_property(ptr, prop); + ID *id = ptr->id.data; + + if (rna_path == NULL || id == NULL || id->override_static == NULL) { + return false; + } + + return (BKE_override_static_property_find(id->override_static, rna_path) != NULL); +} + +bool RNA_property_comparable(PointerRNA *UNUSED(ptr), PropertyRNA *prop) +{ + prop = rna_ensure_property(prop); + + return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON); +} + /* this function is to check if its possible to create a valid path from the ID * its slow so don't call in a loop */ bool RNA_property_path_from_ID_check(PointerRNA *ptr, PropertyRNA *prop) @@ -1957,7 +2072,7 @@ static void rna_property_update(bContext *C, Main *bmain, Scene *scene, PointerR * parts of the code that need it still, so we have this exception */ if (prop->flag & PROP_CONTEXT_UPDATE) { if (C) { - if (prop->flag & PROP_CONTEXT_PROPERTY_UPDATE) { + if ((prop->flag & PROP_CONTEXT_PROPERTY_UPDATE) == PROP_CONTEXT_PROPERTY_UPDATE) { ((ContextPropUpdateFunc)prop->update)(C, ptr, prop); } else { @@ -1968,14 +2083,35 @@ static void rna_property_update(bContext *C, Main *bmain, Scene *scene, PointerR else prop->update(bmain, scene, ptr); } - if (prop->noteflag) + +#if 0 + /* TODO(campbell): Should eventually be replaced entirely by message bus (below) + * for now keep since COW, bugs are hard to track when we have other missing updates. */ + if (prop->noteflag) { WM_main_add_notifier(prop->noteflag, ptr->id.data); + } +#endif + + /* if C is NULL, we're updating from animation. + * avoid slow-down from f-curves by not publishing (for now). */ + if (C != NULL) { + struct wmMsgBus *mbus = CTX_wm_message_bus(C); + /* we could add NULL check, for now don't */ + WM_msg_publish_rna(mbus, ptr, prop); + } + if (ptr->id.data != NULL) { + const short id_type = GS(((ID *)ptr->id.data)->name); + if (ID_TYPE_IS_COW(id_type)) { + DEG_id_tag_update(ptr->id.data, DEG_TAG_COPY_ON_WRITE); + } + } + /* End message bus. */ } if (!is_rna || (prop->flag & PROP_IDPROPERTY)) { /* WARNING! This is so property drivers update the display! * not especially nice */ - DAG_id_tag_update(ptr->id.data, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + DEG_id_tag_update(ptr->id.data, OB_RECALC_OB | OB_RECALC_DATA); WM_main_add_notifier(NC_WINDOW, NULL); /* Not nice as well, but the only way to make sure material preview * is updated with custom nodes. @@ -4502,17 +4638,42 @@ static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, Prope return true; } +/** + * Generic rna path parser. + * + * \note All parameters besides \a ptr and \a path are optional. + * + * \param ptr The root of given RNA path. + * \param path The RNA path. + * \param r_ptr The final RNA data holding the last property in \a path. + * \param r_prop The final property of \a r_ptr, from \a path. + * \param r_index The final index in the \a r_prop, if defined by \a path. + * \param r_item_ptr Only valid for Pointer and Collection, return the actual value of the pointer, + * or of the collection item. Mutually exclusive with \a eval_pointer option. + * \param r_elements A list of \a PropertyElemRNA items + * (pairs of \a PointerRNA, \a PropertyRNA that represent the whole given \a path). + * \param eval_pointer If \a true, and \a path leads to a Pointer property, or an item in a Collection property, + * \a r_ptr will be set to the value of that property, and \a r_prop will be NULL. + * Mutually exclusive with \a r_item_ptr. + * \return \a true on success, \a false if the path is somehow invalid. + */ static bool rna_path_parse(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index, - ListBase *r_elements, + PointerRNA *r_item_ptr, ListBase *r_elements, const bool eval_pointer) { + BLI_assert(r_item_ptr == NULL || !eval_pointer); PropertyRNA *prop; - PointerRNA curptr; + PointerRNA curptr, nextptr; PropertyElemRNA *prop_elem = NULL; int index = -1; char fixedbuf[256]; int type; + const bool do_item_ptr = r_item_ptr != NULL && !eval_pointer; + + if (do_item_ptr) { + RNA_POINTER_INVALIDATE(&nextptr); + } prop = NULL; curptr = *ptr; @@ -4521,20 +4682,26 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path, return false; while (*path) { + if (do_item_ptr) { + RNA_POINTER_INVALIDATE(&nextptr); + } + int use_id_prop = (*path == '[') ? 1 : 0; char *token; /* custom property lookup ? * C.object["someprop"] */ - if (!curptr.data) + if (!curptr.data) { return false; + } /* look up property name in current struct */ token = rna_path_token(&path, fixedbuf, sizeof(fixedbuf), use_id_prop); - if (!token) + if (!token) { return false; + } prop = NULL; if (use_id_prop) { /* look up property name in current struct */ @@ -4546,11 +4713,13 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path, prop = RNA_struct_find_property(&curptr, token); } - if (token != fixedbuf) + if (token != fixedbuf) { MEM_freeN(token); + } - if (!prop) + if (!prop) { return false; + } if (r_elements) { prop_elem = MEM_mallocN(sizeof(PropertyElemRNA), __func__); @@ -4570,9 +4739,11 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path, /* resolve pointer if further path elements follow * or explicitly requested */ - if (eval_pointer || *path) { - PointerRNA nextptr = RNA_property_pointer_get(&curptr, prop); + if (do_item_ptr || eval_pointer || *path != '\0') { + nextptr = RNA_property_pointer_get(&curptr, prop); + } + if (eval_pointer || *path != '\0') { curptr = nextptr; prop = NULL; /* now we have a PointerRNA, the prop is our parent so forget it */ index = -1; @@ -4582,17 +4753,18 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path, case PROP_COLLECTION: { /* Resolve pointer if further path elements follow. * Note that if path is empty, rna_path_parse_collection_key will do nothing anyway, - * so eval_pointer is of no use here (esp. as in this case, we want to keep found prop, - * erasing it breaks operators - e.g. bpy.types.Operator.bl_rna.foobar errors...). + * so do_item_ptr is of no use in that case. */ if (*path) { - PointerRNA nextptr; - if (!rna_path_parse_collection_key(&path, &curptr, prop, &nextptr)) + if (!rna_path_parse_collection_key(&path, &curptr, prop, &nextptr)) { return false; + } - curptr = nextptr; - prop = NULL; /* now we have a PointerRNA, the prop is our parent so forget it */ - index = -1; + if (eval_pointer || *path != '\0') { + curptr = nextptr; + prop = NULL; /* now we have a PointerRNA, the prop is our parent so forget it */ + index = -1; + } } break; } @@ -4610,12 +4782,18 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path, } } - if (r_ptr) + if (r_ptr) { *r_ptr = curptr; - if (r_prop) + } + if (r_prop) { *r_prop = prop; - if (r_index) + } + if (r_index) { *r_index = index; + } + if (r_item_ptr && do_item_ptr) { + *r_item_ptr = nextptr; + } if (prop_elem && (prop_elem->ptr.data != curptr.data || prop_elem->prop != prop || prop_elem->index != index)) { prop_elem = MEM_mallocN(sizeof(PropertyElemRNA), __func__); @@ -4636,7 +4814,7 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path, */ bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop) { - if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, NULL, true)) + if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, NULL, NULL, true)) return false; return r_ptr->data != NULL; @@ -4650,7 +4828,7 @@ bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prop */ bool RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index) { - if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, true)) + if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, true)) return false; return r_ptr->data != NULL; @@ -4665,8 +4843,9 @@ bool RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, */ bool RNA_path_resolve_property(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop) { - if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, NULL, false)) + if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, NULL, NULL, false)) { return false; + } return r_ptr->data != NULL && *r_prop != NULL; } @@ -4681,13 +4860,51 @@ bool RNA_path_resolve_property(PointerRNA *ptr, const char *path, PointerRNA *r_ */ bool RNA_path_resolve_property_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index) { - if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, false)) + if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, false)) return false; return r_ptr->data != NULL && *r_prop != NULL; } /** + * Resolve the given RNA Path to find both the pointer AND property indicated by fully resolving the path, + * and get the value of the Pointer property (or item of the collection). + * + * This is a convenience method to avoid logic errors and ugly syntax, it combines both \a RNA_path_resolve and + * \a RNA_path_resolve_property in a single call. + * \note Assumes all pointers provided are valid. + * \param r_item_pointer The final Pointer or Collection item value. You must check for its validity before use! + * \return True only if both a valid pointer and property are found after resolving the path + */ +bool RNA_path_resolve_property_and_item_pointer( + PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, PointerRNA *r_item_ptr) +{ + if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, r_item_ptr, NULL, false)) { + return false; + } + + return r_ptr->data != NULL && *r_prop != NULL; +} + +/** + * Resolve the given RNA Path to find both the pointer AND property (as well as the array index) + * indicated by fully resolving the path, and get the value of the Pointer property (or item of the collection). + * + * This is a convenience method to avoid logic errors and ugly syntax, it combines both \a RNA_path_resolve_full and + * \a RNA_path_resolve_property_full in a single call. + * \note Assumes all pointers provided are valid. + * \param r_item_pointer The final Pointer or Collection item value. You must check for its validity before use! + * \return True only if both a valid pointer and property are found after resolving the path + */ +bool RNA_path_resolve_property_and_item_pointer_full( + PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index, PointerRNA *r_item_ptr) +{ + if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, r_item_ptr, NULL, false)) + return false; + + return r_ptr->data != NULL && *r_prop != NULL; +} +/** * Resolve the given RNA Path into a linked list of PropertyElemRNA's. * * To be used when complex operations over path are needed, like e.g. get relative paths, to avoid too much @@ -4698,7 +4915,7 @@ bool RNA_path_resolve_property_full(PointerRNA *ptr, const char *path, PointerRN */ bool RNA_path_resolve_elements(PointerRNA *ptr, const char *path, ListBase *r_elements) { - return rna_path_parse(ptr, path, NULL, NULL, NULL, r_elements, false); + return rna_path_parse(ptr, path, NULL, NULL, NULL, NULL, r_elements, false); } char *RNA_path_append(const char *path, PointerRNA *UNUSED(ptr), PropertyRNA *prop, int intkey, const char *strkey) @@ -7010,120 +7227,54 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index) } } -bool RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, int index) +static bool rna_property_override_operation_apply( + Main *bmain, + PointerRNA *ptr_local, PointerRNA *ptr_override, PointerRNA *ptr_storage, + PropertyRNA *prop_local, PropertyRNA *prop_override, PropertyRNA *prop_storage, + PointerRNA *ptr_item_local, PointerRNA *ptr_item_override, PointerRNA *ptr_item_storage, + IDOverrideStaticPropertyOperation *opop); + +bool RNA_property_copy(Main *bmain, PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, int index) { - int len, fromlen; - PropertyRNA *fromprop = prop; + if (!RNA_property_editable(ptr, prop)) { + return false; + } - if (prop->magic != RNA_MAGIC) { - /* In case of IDProperty, we have to find the *real* idprop of ptr, - * since prop in this case is just a fake wrapper around actual IDProp data, and not a 'real' PropertyRNA. */ - prop = (PropertyRNA *)rna_idproperty_find(ptr, ((IDProperty *)fromprop)->name); + PropertyRNA *prop_dst = prop; + PropertyRNA *prop_src = prop; - /* its possible the custom-prop doesn't exist on this data-block */ - if (prop == NULL) { - return false; - } + /* Ensure we get real property data, be it an actual RNA property, or an IDProperty in disguise. */ + prop_dst = rna_ensure_property_realdata(&prop_dst, ptr); + prop_src = rna_ensure_property_realdata(&prop_src, fromptr); - /* Even though currently we now prop will always be the 'fromprop', this might not be the case in the future. */ - if (prop == fromprop) { - fromprop = (PropertyRNA *)rna_idproperty_find(fromptr, ((IDProperty *)prop)->name); - } + /* IDprops: destination may not exist, if source does and is set, try to create it. */ + /* Note: this is sort of quick hack/bandage to fix the issue, we need to rethink how IDProps are handled + * in 'diff' RNA code completely, imho... */ + if (prop_src != NULL && prop_dst == NULL && RNA_property_is_set(fromptr, prop)) { + BLI_assert(prop_src->magic != RNA_MAGIC); + IDProperty *idp_dst = RNA_struct_idprops(ptr, true); + IDProperty *prop_idp_dst = IDP_CopyProperty((IDProperty *)prop_src); + IDP_AddToGroup(idp_dst, prop_idp_dst); + rna_idproperty_touch(prop_idp_dst); + /* Nothing else to do here... */ + return true; } - /* get the length of the array to work with */ - len = RNA_property_array_length(ptr, prop); - fromlen = RNA_property_array_length(fromptr, fromprop); - - if (len != fromlen) + if (ELEM(NULL, prop_dst, prop_src)) { return false; - - /* get and set the default values as appropriate for the various types */ - switch (RNA_property_type(prop)) { - case PROP_BOOLEAN: - if (len) { - if (index == -1) { - bool *tmparray = MEM_callocN(sizeof(bool) * len, "copy - boolean"); - - RNA_property_boolean_get_array(fromptr, fromprop, tmparray); - RNA_property_boolean_set_array(ptr, prop, tmparray); - - MEM_freeN(tmparray); - } - else { - int value = RNA_property_boolean_get_index(fromptr, fromprop, index); - RNA_property_boolean_set_index(ptr, prop, index, value); - } - } - else { - int value = RNA_property_boolean_get(fromptr, fromprop); - RNA_property_boolean_set(ptr, prop, value); - } - return true; - case PROP_INT: - if (len) { - if (index == -1) { - int *tmparray = MEM_callocN(sizeof(int) * len, "copy - int"); - - RNA_property_int_get_array(fromptr, fromprop, tmparray); - RNA_property_int_set_array(ptr, prop, tmparray); - - MEM_freeN(tmparray); - } - else { - int value = RNA_property_int_get_index(fromptr, fromprop, index); - RNA_property_int_set_index(ptr, prop, index, value); - } - } - else { - int value = RNA_property_int_get(fromptr, fromprop); - RNA_property_int_set(ptr, prop, value); - } - return true; - case PROP_FLOAT: - if (len) { - if (index == -1) { - float *tmparray = MEM_callocN(sizeof(float) * len, "copy - float"); - - RNA_property_float_get_array(fromptr, fromprop, tmparray); - RNA_property_float_set_array(ptr, prop, tmparray); - - MEM_freeN(tmparray); - } - else { - float value = RNA_property_float_get_index(fromptr, fromprop, index); - RNA_property_float_set_index(ptr, prop, index, value); - } - } - else { - float value = RNA_property_float_get(fromptr, fromprop); - RNA_property_float_set(ptr, prop, value); - } - return true; - case PROP_ENUM: - { - int value = RNA_property_enum_get(fromptr, fromprop); - RNA_property_enum_set(ptr, prop, value); - return true; - } - case PROP_POINTER: - { - PointerRNA value = RNA_property_pointer_get(fromptr, fromprop); - RNA_property_pointer_set(ptr, prop, value); - return true; - } - case PROP_STRING: - { - char *value = RNA_property_string_get_alloc(fromptr, fromprop, NULL, 0, NULL); - RNA_property_string_set(ptr, prop, value); - MEM_freeN(value); - return true; - } - default: - return false; } - return false; + IDOverrideStaticPropertyOperation opop = { + .operation = IDOVERRIDESTATIC_OP_REPLACE, + .subitem_reference_index = index, + .subitem_local_index = index + }; + return rna_property_override_operation_apply( + bmain, + ptr, fromptr, NULL, + prop_dst, prop_src, NULL, + NULL, NULL, NULL, + &opop); } /* use RNA_warning macro which includes __func__ suffix */ @@ -7148,177 +7299,725 @@ void _RNA_warning(const char *format, ...) #endif } -bool RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop, eRNAEqualsMode mode) +static int rna_property_override_diff( + Main *bmain, + PointerRNA *ptr_a, PointerRNA *ptr_b, PropertyRNA *prop, PropertyRNA *prop_a, PropertyRNA *prop_b, const char *rna_path, + eRNACompareMode mode, IDOverrideStatic *override, const int flags, eRNAOverrideMatchResult *r_report_flags); + +bool RNA_property_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, PropertyRNA *prop, eRNACompareMode mode) +{ + BLI_assert(ELEM(mode, RNA_EQ_STRICT, RNA_EQ_UNSET_MATCH_ANY, RNA_EQ_UNSET_MATCH_NONE)); + + return (rna_property_override_diff(bmain, ptr_a, ptr_b, prop, NULL, NULL, NULL, mode, NULL, 0, NULL) == 0); +} + +bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACompareMode mode) +{ + CollectionPropertyIterator iter; + PropertyRNA *iterprop; + bool equals = true; + + if (ptr_a == NULL && ptr_b == NULL) + return true; + else if (ptr_a == NULL || ptr_b == NULL) + return false; + else if (ptr_a->type != ptr_b->type) + return false; + + iterprop = RNA_struct_iterator_property(ptr_a->type); + + RNA_property_collection_begin(ptr_a, iterprop, &iter); + for (; iter.valid; RNA_property_collection_next(&iter)) { + PropertyRNA *prop = iter.ptr.data; + + if (!RNA_property_equals(bmain, ptr_a, ptr_b, prop, mode)) { + equals = false; + break; + } + } + RNA_property_collection_end(&iter); + + return equals; +} + +/* Low-level functions, also used by non-override RNA API like copy or equality check. */ + +/** Generic RNA property diff function. + * + * \note about \a prop and \a prop_a/prop_b parameters: the former is exptected to be an 'un-resolved' one, + * while the two laters are expected to be fully resolved ones (i.e. to be the IDProps when they should be, etc.). + * When \a prop is given, \a prop_a and \a prop_b should always be NULL, and vice-versa. + * This is necessary, because we cannot perform 'set/unset' checks on resolved properties + * (unset IDProps would merely be NULL then). + * + * \note When there is no equality, but we cannot determine an order (greater than/lesser than), we return 1. + */ +static int rna_property_override_diff( + Main *bmain, + PointerRNA *ptr_a, PointerRNA *ptr_b, PropertyRNA *prop, PropertyRNA *prop_a, PropertyRNA *prop_b, + const char *rna_path, eRNACompareMode mode, + IDOverrideStatic *override, const int flags, eRNAOverrideMatchResult *r_report_flags) { - int len, fromlen; + if (prop != NULL) { + BLI_assert(prop_a == NULL && prop_b == NULL); + prop_a = prop; + prop_b = prop; + } + + if (ELEM(NULL, prop_a, prop_b)) { + return (prop_a == prop_b) ? 0 : 1; + } + + if (!RNA_property_comparable(ptr_a, prop_a) || !RNA_property_comparable(ptr_b, prop_b)) { + return 0; + } if (mode == RNA_EQ_UNSET_MATCH_ANY) { /* uninitialized properties are assumed to match anything */ - if (!RNA_property_is_set(a, prop) || !RNA_property_is_set(b, prop)) - return true; + if (!RNA_property_is_set(ptr_a, prop_a) || !RNA_property_is_set(ptr_b, prop_b)) { + return 0; + } } else if (mode == RNA_EQ_UNSET_MATCH_NONE) { /* unset properties never match set properties */ - if (RNA_property_is_set(a, prop) != RNA_property_is_set(b, prop)) - return false; + if (RNA_property_is_set(ptr_a, prop_a) != RNA_property_is_set(ptr_b, prop_b)) { + return 1; + } + } + + if (prop != NULL) { + /* Ensure we get real property data, be it an actual RNA property, or an IDProperty in disguise. */ + prop_a = rna_ensure_property_realdata(&prop_a, ptr_a); + prop_b = rna_ensure_property_realdata(&prop_b, ptr_b); + + if (ELEM(NULL, prop_a, prop_b)) { + return (prop_a == prop_b) ? 0 : 1; + } + } + + /* Check if we are working with arrays. */ + const bool is_array_a = RNA_property_array_check(prop_a); + const bool is_array_b = RNA_property_array_check(prop_b); + + if (is_array_a != is_array_b) { + /* Should probably never happen actually... */ + BLI_assert(0); + return is_array_a ? 1 : -1; + } + + /* Get the length of the array to work with. */ + const int len_a = RNA_property_array_length(ptr_a, prop_a); + const int len_b = RNA_property_array_length(ptr_b, prop_b); + + if (len_a != len_b) { + /* Do not handle override in that case, we do not support insertion/deletion from arrays for now. */ + return len_a > len_b ? 1 : -1; + } + + if (is_array_a && len_a == 0) { + /* Empty arrays, will happen in some case with dynamic ones. */ + return 0; + } + + RNAPropOverrideDiff override_diff = NULL; + /* Special case for IDProps, we use default callback then. */ + if (prop_a->magic != RNA_MAGIC) { + override_diff = rna_property_override_diff_default; + if (prop_b->magic == RNA_MAGIC && prop_b->override_diff != override_diff) { + override_diff = NULL; + } + } + else if (prop_b->magic != RNA_MAGIC) { + override_diff = rna_property_override_diff_default; + if (prop_a->override_diff != override_diff) { + override_diff = NULL; + } + } + else if (prop_a->override_diff == prop_b->override_diff) { + override_diff = prop_a->override_diff; + } + + if (override_diff == NULL) { +#ifndef NDEBUG + printf("'%s' gives unmatching or NULL RNA diff callbacks, should not happen (%d vs. %d).\n", + rna_path ? rna_path : (prop_a->magic != RNA_MAGIC ? ((IDProperty *)prop_a)->name : prop_a->identifier), + prop_a->magic == RNA_MAGIC, prop_b->magic == RNA_MAGIC); +#endif + BLI_assert(0); + return 1; + } + + bool override_changed = false; + int diff_flags = flags; + if (!RNA_property_overridable_get(ptr_a, prop_a)) { + diff_flags &= ~RNA_OVERRIDE_COMPARE_CREATE; + } + const int diff = override_diff( + bmain, + ptr_a, ptr_b, prop_a, prop_b, len_a, len_b, + mode, override, rna_path, diff_flags, &override_changed); + if (override_changed && r_report_flags) { + *r_report_flags |= RNA_OVERRIDE_MATCH_RESULT_CREATED; + } + + return diff; +} + +/* Modify local data-block to make it ready for override application (only needed for diff operations, where we use + * the local data-block's data as second operand). */ +static bool rna_property_override_operation_store( + Main *bmain, + PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, + PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *prop_storage, + IDOverrideStaticProperty *op) +{ + int len_local, len_reference, len_storage = 0; + bool changed = false; + + if (ptr_storage == NULL) { + return changed; + } + + /* get the length of the array to work with */ + len_local = RNA_property_array_length(ptr_local, prop_local); + len_reference = RNA_property_array_length(ptr_reference, prop_reference); + if (prop_storage) { + len_storage = RNA_property_array_length(ptr_storage, prop_storage); + } + + if (len_local != len_reference || len_local != len_storage) { + /* Do not handle override in that case, we do not support insertion/deletion from arrays for now. */ + return changed; + } + + BLI_assert(prop_local->override_store == prop_reference->override_store && + (!ptr_storage || prop_local->override_store == prop_storage->override_store) && + prop_local->override_store != NULL); + + for (IDOverrideStaticPropertyOperation *opop = op->operations.first; opop; opop = opop->next) { + /* Only needed for diff operations. */ + if (!ELEM(opop->operation, IDOVERRIDESTATIC_OP_ADD, IDOVERRIDESTATIC_OP_SUBTRACT, IDOVERRIDESTATIC_OP_MULTIPLY)) { + continue; + } + + if (prop_local->override_store( + bmain, + ptr_local, ptr_reference, ptr_storage, + prop_local, prop_reference, prop_storage, + len_local, len_reference, len_storage, + opop)) + { + changed = true; + } + } + + return changed; +} + +static bool rna_property_override_operation_apply( + Main *bmain, + PointerRNA *ptr_local, PointerRNA *ptr_override, PointerRNA *ptr_storage, + PropertyRNA *prop_local, PropertyRNA *prop_override, PropertyRNA *prop_storage, + PointerRNA *ptr_item_local, PointerRNA *ptr_item_override, PointerRNA *ptr_item_storage, + IDOverrideStaticPropertyOperation *opop) +{ + int len_local, len_reference, len_storage = 0; + + const short override_op = opop->operation; + + if (override_op == IDOVERRIDESTATIC_OP_NOOP) { + return true; + } + + if (ELEM(override_op, IDOVERRIDESTATIC_OP_ADD, IDOVERRIDESTATIC_OP_SUBTRACT, IDOVERRIDESTATIC_OP_MULTIPLY) && !ptr_storage) { + /* We cannot apply 'diff' override operations without some reference storage. + * This should typically only happen at read time of .blend file... */ + return false; + } + + if (ELEM(override_op, IDOVERRIDESTATIC_OP_ADD, IDOVERRIDESTATIC_OP_SUBTRACT, IDOVERRIDESTATIC_OP_MULTIPLY) && !prop_storage) { + /* We cannot apply 'diff' override operations without some reference storage. + * This should typically only happen at read time of .blend file... */ + return false; + } + + RNAPropOverrideApply override_apply = NULL; + /* Special case for IDProps, we use default callback then. */ + if (prop_local->magic != RNA_MAGIC) { + override_apply = rna_property_override_apply_default; + if (prop_override->magic == RNA_MAGIC && prop_override->override_apply != override_apply) { + override_apply = NULL; + } + } + else if (prop_override->magic != RNA_MAGIC) { + override_apply = rna_property_override_apply_default; + if (prop_local->override_apply != override_apply) { + override_apply = NULL; + } + } + else if (prop_local->override_apply == prop_override->override_apply) { + override_apply = prop_local->override_apply; + } + + if (ptr_storage && prop_storage->magic == RNA_MAGIC && prop_storage->override_apply != override_apply) { + override_apply = NULL; + } + + if (override_apply == NULL) { +#ifndef NDEBUG + printf("'%s' gives unmatching or NULL RNA copy callbacks, should not happen (%d vs. %d).\n", + prop_local->magic != RNA_MAGIC ? ((IDProperty *)prop_local)->name : prop_local->identifier, + prop_local->magic == RNA_MAGIC, prop_override->magic == RNA_MAGIC); +#endif + BLI_assert(0); + return false; } /* get the length of the array to work with */ - len = RNA_property_array_length(a, prop); - fromlen = RNA_property_array_length(b, prop); + len_local = RNA_property_array_length(ptr_local, prop_local); + len_reference = RNA_property_array_length(ptr_override, prop_override); + if (ptr_storage) { + len_storage = RNA_property_array_length(ptr_storage, prop_storage); + } - if (len != fromlen) + if (len_local != len_reference || (ptr_storage && len_local != len_storage)) { + /* Do not handle override in that case, we do not support insertion/deletion from arrays for now. */ return false; + } /* get and set the default values as appropriate for the various types */ - switch (RNA_property_type(prop)) { - case PROP_BOOLEAN: - { - if (len) { - bool fixed_a[16], fixed_b[16]; - bool *array_a, *array_b; - bool equals; + return override_apply( + bmain, + ptr_local, ptr_override, ptr_storage, + prop_local, prop_override, prop_storage, + len_local, len_reference, len_storage, + ptr_item_local, ptr_item_override, ptr_item_storage, + opop); +} - array_a = (len > 16) ? MEM_mallocN(sizeof(bool) * len, "RNA equals") : fixed_a; - array_b = (len > 16) ? MEM_mallocN(sizeof(bool) * len, "RNA equals") : fixed_b; +/** + * Check whether reference and local overridden data match (are the same), + * with respect to given restrictive sets of properties. + * If requested, will generate needed new property overrides, and/or restore values from reference. + * + * \param r_report_flags If given, will be set with flags matching actions taken by the function on \a ptr_local. + * + * \return True if _resulting_ \a ptr_local does match \a ptr_reference. + */ +bool RNA_struct_override_matches( + Main *bmain, + PointerRNA *ptr_local, PointerRNA *ptr_reference, const char *root_path, + IDOverrideStatic *override, const eRNAOverrideMatch flags, + eRNAOverrideMatchResult *r_report_flags) +{ + CollectionPropertyIterator iter; + PropertyRNA *iterprop; + bool matching = true; + + BLI_assert(ptr_local->type == ptr_reference->type); + BLI_assert(ptr_local->id.data && ptr_reference->id.data); + + const bool ignore_non_overridable = (flags & RNA_OVERRIDE_COMPARE_IGNORE_NON_OVERRIDABLE) != 0; + const bool ignore_overridden = (flags & RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN) != 0; + const bool do_create = (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0; + const bool do_restore = (flags & RNA_OVERRIDE_COMPARE_RESTORE) != 0; + +//#define DEBUG_OVERRIDE_TIMEIT +#ifdef DEBUG_OVERRIDE_TIMEIT + static float _sum_time_global = 0.0f; + static float _num_time_global = 0.0f; + double _timeit_time_global; + static float _sum_time_diffing = 0.0f; + static float _delta_time_diffing = 0.0f; + static int _num_delta_time_diffing = 0.0f; + static float _num_time_diffing = 0.0f; + double _timeit_time_diffing; + + if (!root_path) { + _delta_time_diffing = 0.0f; + _num_delta_time_diffing = 0; + _timeit_time_global = PIL_check_seconds_timer(); + } +#endif + + iterprop = RNA_struct_iterator_property(ptr_local->type); - RNA_property_boolean_get_array(a, prop, array_a); - RNA_property_boolean_get_array(b, prop, array_b); + for (RNA_property_collection_begin(ptr_local, iterprop, &iter); iter.valid; RNA_property_collection_next(&iter)) { + PropertyRNA *prop_local = iter.ptr.data; + PropertyRNA *prop_reference = iter.ptr.data; + + /* Ensure we get real property data, be it an actual RNA property, or an IDProperty in disguise. */ + prop_local = rna_ensure_property_realdata(&prop_local, ptr_local); + prop_reference = rna_ensure_property_realdata(&prop_reference, ptr_reference); + + if (ELEM(NULL, prop_local, prop_reference)) { + continue; + } - equals = memcmp(array_a, array_b, sizeof(bool) * len) == 0; + if (ignore_non_overridable && !RNA_property_overridable_get(ptr_local, prop_local)) { + continue; + } - if (array_a != fixed_a) MEM_freeN(array_a); - if (array_b != fixed_b) MEM_freeN(array_b); +#if 0 /* This actually makes things slower, since it has to check for animation paths etc! */ + if (RNA_property_animated(ptr_local, prop_local)) { + /* We cannot do anything here really, animation is some kind of dynamic overrides that has + * precedence over static one... */ + continue; + } +#endif - return equals; +#define RNA_PATH_BUFFSIZE 8192 +#define RNA_PATH_PRINTF(_str, ...) \ + if (BLI_snprintf(rna_path, RNA_PATH_BUFFSIZE, \ + (_str), __VA_ARGS__) >= RNA_PATH_BUFFSIZE) \ + { rna_path = BLI_sprintfN((_str), __VA_ARGS__); }(void)0 +#define RNA_PATH_FREE \ + if (rna_path != rna_path_buffer) MEM_freeN(rna_path) + + char rna_path_buffer[RNA_PATH_BUFFSIZE]; + char *rna_path = rna_path_buffer; + + /* XXX TODO this will have to be refined to handle collections insertions, and array items */ + if (root_path) { + /* Inlined building, much much more efficient. */ + if (prop_local->magic == RNA_MAGIC) { + RNA_PATH_PRINTF("%s.%s", root_path, RNA_property_identifier(prop_local)); } else { - int value = RNA_property_boolean_get(a, prop); - return value == RNA_property_boolean_get(b, prop); + RNA_PATH_PRINTF("%s[\"%s\"]", root_path, RNA_property_identifier(prop_local)); } } + else { + /* This is rather slow, but is not much called, so not really worth optimizing. */ + rna_path = RNA_path_from_ID_to_property(ptr_local, prop_local); + } + if (rna_path == NULL) { + continue; + } - case PROP_INT: - { - if (len) { - int fixed_a[16], fixed_b[16]; - int *array_a, *array_b; - bool equals; +// printf("Override Checking %s\n", rna_path); - array_a = (len > 16) ? MEM_mallocN(sizeof(int) * len, "RNA equals") : fixed_a; - array_b = (len > 16) ? MEM_mallocN(sizeof(int) * len, "RNA equals") : fixed_b; + if (ignore_overridden && BKE_override_static_property_find(override, rna_path) != NULL) { + RNA_PATH_FREE; + continue; + } - RNA_property_int_get_array(a, prop, array_a); - RNA_property_int_get_array(b, prop, array_b); +#ifdef DEBUG_OVERRIDE_TIMEIT + if (!root_path) { + _timeit_time_diffing = PIL_check_seconds_timer(); + } +#endif - equals = memcmp(array_a, array_b, sizeof(int) * len) == 0; + eRNAOverrideMatchResult report_flags = 0; + const int diff = rna_property_override_diff( + bmain, + ptr_local, ptr_reference, NULL, prop_local, prop_reference, rna_path, + RNA_EQ_STRICT, override, flags, &report_flags); - if (array_a != fixed_a) MEM_freeN(array_a); - if (array_b != fixed_b) MEM_freeN(array_b); +#ifdef DEBUG_OVERRIDE_TIMEIT + if (!root_path) { + const float _delta_time = (float)(PIL_check_seconds_timer() - _timeit_time_diffing); + _delta_time_diffing += _delta_time; + _num_delta_time_diffing++; + } +#endif - return equals; + matching = matching && diff == 0; + if (r_report_flags) { + *r_report_flags |= report_flags; + } + + if (diff != 0) { + /* XXX TODO: refine this for per-item overriding of arrays... */ + IDOverrideStaticProperty *op = BKE_override_static_property_find(override, rna_path); + IDOverrideStaticPropertyOperation *opop = op ? op->operations.first : NULL; + + if (do_restore && (report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) == 0) { + /* We are allowed to restore to reference's values. */ + if (ELEM(NULL, op, opop) || opop->operation == IDOVERRIDESTATIC_OP_NOOP) { + /* We should restore that property to its reference value */ + if (RNA_property_editable(ptr_local, prop_local)) { + IDOverrideStaticPropertyOperation opop_tmp = { + .operation = IDOVERRIDESTATIC_OP_REPLACE, + .subitem_reference_index = -1, + .subitem_local_index = -1 + }; + rna_property_override_operation_apply( + bmain, + ptr_local, ptr_reference, NULL, + prop_local, prop_reference, NULL, + NULL, NULL, NULL, + &opop_tmp); + if (r_report_flags) { + *r_report_flags |= RNA_OVERRIDE_MATCH_RESULT_RESTORED; + } + } + else { + /* Too noisy for now, this triggers on runtime props like transform matrices etc. */ + /* BLI_assert(!"We have differences between reference and overriding data on non-editable property."); */ + matching = false; + } + } } - else { - int value = RNA_property_int_get(a, prop); - return value == RNA_property_int_get(b, prop); + else if ((report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) == 0 && ELEM(NULL, op, opop)) { + /* This property is not overridden, and differs from reference, so we have no match. */ + matching = false; + if (!(do_create || do_restore)) { + /* Since we have no 'changing' action allowed, we can break here. */ + MEM_SAFE_FREE(rna_path); + break; + } } } - case PROP_FLOAT: - { - if (len) { - float fixed_a[16], fixed_b[16]; - float *array_a, *array_b; - bool equals; + RNA_PATH_FREE; - array_a = (len > 16) ? MEM_mallocN(sizeof(float) * len, "RNA equals") : fixed_a; - array_b = (len > 16) ? MEM_mallocN(sizeof(float) * len, "RNA equals") : fixed_b; +#undef RNA_PATH_BUFFSIZE +#undef RNA_PATH_PRINTF +#undef RNA_PATH_FREE + } + RNA_property_collection_end(&iter); + +#ifdef DEBUG_OVERRIDE_TIMEIT + if (!root_path) { + const float _delta_time = (float)(PIL_check_seconds_timer() - _timeit_time_global); + _sum_time_global += _delta_time; + _num_time_global++; + _sum_time_diffing += _delta_time_diffing; + _num_time_diffing++; + printf("ID: %s\n", ((ID *)ptr_local->id.data)->name); + printf("time end (%s): %.6f\n", __func__, _delta_time); + printf("time averaged (%s): %.6f (total: %.6f, in %d runs)\n", __func__, + (_sum_time_global / _num_time_global), _sum_time_global, (int)_num_time_global); + printf("diffing time end (%s): %.6f (in %d runs)\n", __func__, _delta_time_diffing, _num_delta_time_diffing); + printf("diffing time averaged (%s): %.6f (total: %.6f, in %d runs)\n", __func__, + (_sum_time_diffing / _num_time_diffing), _sum_time_diffing, (int)_num_time_diffing); + } +#endif - RNA_property_float_get_array(a, prop, array_a); - RNA_property_float_get_array(b, prop, array_b); + return matching; +} - equals = memcmp(array_a, array_b, sizeof(float) * len) == 0; - if (array_a != fixed_a) MEM_freeN(array_a); - if (array_b != fixed_b) MEM_freeN(array_b); +/** Store needed second operands into \a storage data-block for differential override operations. */ +bool RNA_struct_override_store( + Main *bmain, + PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, IDOverrideStatic *override) +{ + bool changed = false; - return equals; +#ifdef DEBUG_OVERRIDE_TIMEIT + TIMEIT_START_AVERAGED(RNA_struct_override_store); +#endif + for (IDOverrideStaticProperty *op = override->properties.first; op; op = op->next) { + /* Simplified for now! */ + PointerRNA data_reference, data_local; + PropertyRNA *prop_reference, *prop_local; + + if (RNA_path_resolve_property(ptr_local, op->rna_path, &data_local, &prop_local) && + RNA_path_resolve_property(ptr_reference, op->rna_path, &data_reference, &prop_reference)) + { + PointerRNA data_storage; + PropertyRNA *prop_storage = NULL; + + /* It is totally OK if this does not success, only a subset of override operations actually need storage. */ + if (ptr_storage && (ptr_storage->id.data != NULL)) { + RNA_path_resolve_property(ptr_storage, op->rna_path, &data_storage, &prop_storage); } - else { - float value = RNA_property_float_get(a, prop); - return value == RNA_property_float_get(b, prop); + + if (rna_property_override_operation_store( + bmain, + &data_local, &data_reference, &data_storage, + prop_reference, prop_local, prop_storage, + op)) + { + changed = true; } } + } +#ifdef DEBUG_OVERRIDE_TIMEIT + TIMEIT_END_AVERAGED(RNA_struct_override_store); +#endif - case PROP_ENUM: - { - int value = RNA_property_enum_get(a, prop); - return value == RNA_property_enum_get(b, prop); - } + return changed; +} - case PROP_STRING: +static void rna_property_override_apply_ex( + Main *bmain, + PointerRNA *ptr_local, PointerRNA *ptr_override, PointerRNA *ptr_storage, + PropertyRNA *prop_local, PropertyRNA *prop_override, PropertyRNA *prop_storage, + PointerRNA *ptr_item_local, PointerRNA *ptr_item_override, PointerRNA *ptr_item_storage, + IDOverrideStaticProperty *op, const bool do_insert) +{ + for (IDOverrideStaticPropertyOperation *opop = op->operations.first; opop; opop = opop->next) { + if (!do_insert != !ELEM(opop->operation, IDOVERRIDESTATIC_OP_INSERT_AFTER, IDOVERRIDESTATIC_OP_INSERT_BEFORE)) { + if (!do_insert) { + printf("Skipping insert override operations in first pass (%s)!\n", op->rna_path); + } + continue; + } + if (!rna_property_override_operation_apply( + bmain, + ptr_local, ptr_override, ptr_storage, + prop_local, prop_override, prop_storage, + ptr_item_local, ptr_item_override, ptr_item_storage, + opop)) { - char fixed_a[128], fixed_b[128]; - int len_a, len_b; - char *value_a = RNA_property_string_get_alloc(a, prop, fixed_a, sizeof(fixed_a), &len_a); - char *value_b = RNA_property_string_get_alloc(b, prop, fixed_b, sizeof(fixed_b), &len_b); - bool equals = STREQ(value_a, value_b); + /* TODO No assert here, would be much much better to just report as warning, + * failing override applications will probably be fairly common! */ + BLI_assert(0); + } + } +} - if (value_a != fixed_a) MEM_freeN(value_a); - if (value_b != fixed_b) MEM_freeN(value_b); +/** Apply given \a override operations on \a ptr_local, using \a ptr_override + * (and \a ptr_storage form differential ops) as source. */ +void RNA_struct_override_apply( + Main *bmain, + PointerRNA *ptr_local, PointerRNA *ptr_override, PointerRNA *ptr_storage, IDOverrideStatic *override) +{ +#ifdef DEBUG_OVERRIDE_TIMEIT + TIMEIT_START_AVERAGED(RNA_struct_override_apply); +#endif + /* Note: Applying insert operations in a separate pass is mandatory. + * We could optimize this later, but for now, as inneficient as it is, don't think this is a critical point. + */ + bool do_insert = false; + for (int i = 0; i < 2; i++, do_insert = true) { + for (IDOverrideStaticProperty *op = override->properties.first; op; op = op->next) { + /* Simplified for now! */ + PointerRNA data_override, data_local; + PointerRNA data_item_override, data_item_local; + PropertyRNA *prop_override, *prop_local; + + if (RNA_path_resolve_property_and_item_pointer( + ptr_local, op->rna_path, &data_local, &prop_local, &data_item_local) && + RNA_path_resolve_property_and_item_pointer( + ptr_override, op->rna_path, &data_override, &prop_override, &data_item_override)) + { + PointerRNA data_storage, data_item_storage; + PropertyRNA *prop_storage = NULL; - return equals; - } + /* It is totally OK if this does not success, only a subset of override operations actually need storage. */ + if (ptr_storage && (ptr_storage->id.data != NULL)) { + RNA_path_resolve_property_and_item_pointer( + ptr_storage, op->rna_path, &data_storage, &prop_storage, &data_item_storage); + } - case PROP_POINTER: - { - if (!STREQ(RNA_property_identifier(prop), "rna_type")) { - PointerRNA propptr_a = RNA_property_pointer_get(a, prop); - PointerRNA propptr_b = RNA_property_pointer_get(b, prop); - return RNA_struct_equals(&propptr_a, &propptr_b, mode); + rna_property_override_apply_ex( + bmain, + &data_local, &data_override, prop_storage ? &data_storage : NULL, + prop_local, prop_override, prop_storage, + &data_item_local, &data_item_override, prop_storage ? &data_item_storage : NULL, + op, do_insert); } - break; +#ifndef NDEBUG + else { + printf("Failed to apply static override operation to '%s.%s' " + "(could not resolve some properties, local: %d, override: %d)\n", + ((ID *)ptr_override->id.data)->name, op->rna_path, + RNA_path_resolve_property(ptr_local, op->rna_path, &data_local, &prop_local), + RNA_path_resolve_property(ptr_override, op->rna_path, &data_override, &prop_override)); + } +#endif } + } +#ifdef DEBUG_OVERRIDE_TIMEIT + TIMEIT_END_AVERAGED(RNA_struct_override_apply); +#endif +} - default: - break; +IDOverrideStaticProperty *RNA_property_override_property_find(PointerRNA *ptr, PropertyRNA *prop) +{ + ID *id = ptr->id.data; + + if (!id || !id->override_static) { + return NULL; } - return true; + char *rna_path = RNA_path_from_ID_to_property(ptr, prop); + if (rna_path) { + IDOverrideStaticProperty *op = BKE_override_static_property_find(id->override_static, rna_path); + MEM_freeN(rna_path); + return op; + } + return NULL; } -bool RNA_struct_equals(PointerRNA *a, PointerRNA *b, eRNAEqualsMode mode) +IDOverrideStaticProperty *RNA_property_override_property_get(PointerRNA *ptr, PropertyRNA *prop, bool *r_created) { - CollectionPropertyIterator iter; -// CollectionPropertyRNA *citerprop; /* UNUSED */ - PropertyRNA *iterprop; - bool equals = true; + ID *id = ptr->id.data; - if (a == NULL && b == NULL) - return true; - else if (a == NULL || b == NULL) - return false; - else if (a->type != b->type) - return false; + if (!id || !id->override_static) { + return NULL; + } - iterprop = RNA_struct_iterator_property(a->type); -// citerprop = (CollectionPropertyRNA *)rna_ensure_property(iterprop); /* UNUSED */ + char *rna_path = RNA_path_from_ID_to_property(ptr, prop); + if (rna_path) { + IDOverrideStaticProperty *op = BKE_override_static_property_get(id->override_static, rna_path, r_created); + MEM_freeN(rna_path); + return op; + } + return NULL; +} - RNA_property_collection_begin(a, iterprop, &iter); - for (; iter.valid; RNA_property_collection_next(&iter)) { - PropertyRNA *prop = iter.ptr.data; +IDOverrideStaticPropertyOperation *RNA_property_override_property_operation_find( + PointerRNA *ptr, PropertyRNA *prop, const int index, const bool strict, bool *r_strict) +{ + IDOverrideStaticProperty *op = RNA_property_override_property_find(ptr, prop); - if (!RNA_property_equals(a, b, prop, mode)) { - equals = false; - break; + if (!op) { + return NULL; + } + + return BKE_override_static_property_operation_find(op, NULL, NULL, index, index, strict, r_strict); +} + +IDOverrideStaticPropertyOperation *RNA_property_override_property_operation_get( + PointerRNA *ptr, PropertyRNA *prop, const short operation, const int index, + const bool strict, bool *r_strict, bool *r_created) +{ + IDOverrideStaticProperty *op = RNA_property_override_property_get(ptr, prop, NULL); + + if (!op) { + return NULL; + } + + return BKE_override_static_property_operation_get(op, operation, NULL, NULL, index, index, strict, r_strict, r_created); +} + +eRNAOverrideStatus RNA_property_static_override_status(PointerRNA *ptr, PropertyRNA *prop, const int index) +{ + int override_status = 0; + + if (!BKE_override_static_is_enabled()) { + return override_status; + } + + if (!ptr || !prop || !ptr->id.data || !((ID *)ptr->id.data)->override_static) { + return override_status; + } + + if (RNA_property_overridable_get(ptr, prop) && RNA_property_editable_flag(ptr, prop)) { + override_status |= RNA_OVERRIDE_STATUS_OVERRIDABLE; + } + + IDOverrideStaticPropertyOperation *opop = RNA_property_override_property_operation_find(ptr, prop, index, false, NULL); + if (opop != NULL) { + override_status |= RNA_OVERRIDE_STATUS_OVERRIDDEN; + if (opop->flag & IDOVERRIDESTATIC_FLAG_MANDATORY) { + override_status |= RNA_OVERRIDE_STATUS_MANDATORY; + } + if (opop->flag & IDOVERRIDESTATIC_FLAG_LOCKED) { + override_status |= RNA_OVERRIDE_STATUS_LOCKED; } } - RNA_property_collection_end(&iter); - return equals; + return override_status; } + bool RNA_path_resolved_create( PointerRNA *ptr, struct PropertyRNA *prop, const int prop_index, @@ -7337,3 +8036,22 @@ bool RNA_path_resolved_create( return false; } } + +static char rna_struct_state_owner[64]; +void RNA_struct_state_owner_set(const char *name) +{ + if (name) { + BLI_strncpy(rna_struct_state_owner, name, sizeof(rna_struct_state_owner)); + } + else { + rna_struct_state_owner[0] = '\0'; + } +} + +const char *RNA_struct_state_owner_get(void) +{ + if (rna_struct_state_owner[0]) { + return rna_struct_state_owner; + } + return NULL; +} diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 675ed42a6d2..8728f0634da 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -102,7 +102,7 @@ static void rna_Action_groups_remove(bAction *act, ReportList *reports, PointerR RNA_POINTER_INVALIDATE(agrp_ptr); } -static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const char *data_path, +static FCurve *rna_Action_fcurve_new(bAction *act, Main *bmain, ReportList *reports, const char *data_path, int index, const char *group) { if (group && group[0] == '\0') group = NULL; @@ -113,12 +113,12 @@ static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const ch } /* annoying, check if this exists */ - if (verify_fcurve(act, group, NULL, data_path, index, 0)) { + if (verify_fcurve(bmain, act, group, NULL, data_path, index, 0)) { BKE_reportf(reports, RPT_ERROR, "F-Curve '%s[%d]' already exists in action '%s'", data_path, index, act->id.name + 2); return NULL; } - return verify_fcurve(act, group, NULL, data_path, index, 1); + return verify_fcurve(bmain, act, group, NULL, data_path, index, 1); } static FCurve *rna_Action_fcurve_find(bAction *act, ReportList *reports, const char *data_path, int index) @@ -322,49 +322,30 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_only_errors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLY_ERRORS); RNA_def_property_ui_text(prop, "Show Errors", "Only include F-Curves and drivers that are disabled or have errors"); - RNA_def_property_ui_icon(prop, ICON_HELP, 0); /* XXX: this doesn't quite fit */ + RNA_def_property_ui_icon(prop, ICON_ERROR, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - /* Object Group Filtering Settings */ - prop = RNA_def_property(srna, "show_only_group_objects", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYOBGROUP); - RNA_def_property_ui_text(prop, "Only Objects in Group", - "Only include channels from objects in the specified group"); - RNA_def_property_ui_icon(prop, ICON_GROUP, 0); - RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - - prop = RNA_def_property(srna, "filter_group", PROP_POINTER, PROP_NONE); + /* Object Collection Filtering Settings */ + prop = RNA_def_property(srna, "filter_collection", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "filter_grp"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Filtering Group", "Group that included object should be a member of"); + RNA_def_property_ui_text(prop, "Filtering Collection", "Collection that included object should be a member of"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* FCurve Display Name Search Settings */ - prop = RNA_def_property(srna, "show_only_matching_fcurves", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_BY_FCU_NAME); - RNA_def_property_ui_text(prop, "Only Matching F-Curves", - "Only include F-Curves with names containing search text"); - RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0); - RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - prop = RNA_def_property(srna, "filter_fcurve_name", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "searchstr"); RNA_def_property_ui_text(prop, "F-Curve Name Filter", "F-Curve live filtering string"); + RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0); RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* NLA Name Search Settings (Shared with FCurve setting, but with different labels) */ - prop = RNA_def_property(srna, "use_filter_text", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_BY_FCU_NAME); - RNA_def_property_ui_text(prop, "Only Matching Channels", - "Only include channels with names containing search text"); - RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0); - RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - prop = RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "searchstr"); RNA_def_property_ui_text(prop, "Name Filter", "Live filtering string"); RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); + RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* Multi-word fuzzy search option for name/text filters */ @@ -402,7 +383,7 @@ static void rna_def_dopesheet(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOOBJ); RNA_def_property_ui_text(prop, "Display Transforms", "Include visualization of object-level animation data (mostly transforms)"); - RNA_def_property_ui_icon(prop, ICON_MANIPUL, 0); /* XXX? */ + RNA_def_property_ui_icon(prop, ICON_ORIENTATION_GLOBAL, 0); /* XXX? */ RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_shapekeys", PROP_BOOLEAN, PROP_NONE); @@ -421,19 +402,19 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_meshes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMESH); RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of mesh related animation data"); - RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_MESH, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_lattices", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAT); RNA_def_property_ui_text(prop, "Display Lattices", "Include visualization of lattice related animation data"); - RNA_def_property_ui_icon(prop, ICON_LATTICE_DATA, 0); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LATTICE, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCAM); RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of camera related animation data"); - RNA_def_property_ui_icon(prop, ICON_CAMERA_DATA, 0); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_CAMERA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_materials", PROP_BOOLEAN, PROP_NONE); @@ -442,10 +423,10 @@ static void rna_def_dopesheet(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_MATERIAL_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "show_lights", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAM); - RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of lamp related animation data"); - RNA_def_property_ui_icon(prop, ICON_LAMP_DATA, 0); + RNA_def_property_ui_text(prop, "Display Light", "Include visualization of light related animation data"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LIGHT, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_linestyles", PROP_BOOLEAN, PROP_NONE); @@ -487,13 +468,13 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_metaballs", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMBA); RNA_def_property_ui_text(prop, "Display Metaball", "Include visualization of metaball related animation data"); - RNA_def_property_ui_icon(prop, ICON_META_DATA, 0); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_META, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOARM); RNA_def_property_ui_text(prop, "Display Armature", "Include visualization of armature related animation data"); - RNA_def_property_ui_icon(prop, ICON_ARMATURE_DATA, 0); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_ARMATURE, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_nodes", PROP_BOOLEAN, PROP_NONE); @@ -505,13 +486,13 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSPK); RNA_def_property_ui_text(prop, "Display Speaker", "Include visualization of speaker related animation data"); - RNA_def_property_ui_icon(prop, ICON_SPEAKER, 0); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_SPEAKER, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_gpencil", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOGPENCIL); RNA_def_property_ui_text(prop, "Display Grease Pencil", "Include visualization of Grease Pencil related animation data and frames"); - RNA_def_property_ui_icon(prop, ICON_GREASEPENCIL, 0); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_GREASEPENCIL, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* GPencil Mode Settings */ @@ -617,7 +598,7 @@ static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop) /* Action.fcurves.new(...) */ func = RNA_def_function(srna, "new", "rna_Action_fcurve_new"); RNA_def_function_ui_description(func, "Add an F-Curve to the action"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_MAIN); parm = RNA_def_string(func, "data_path", NULL, 0, "Data Path", "F-Curve data path to use"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX); diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c deleted file mode 100644 index 6f0ff9aa556..00000000000 --- a/source/blender/makesrna/intern/rna_actuator.c +++ /dev/null @@ -1,2220 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Blender Foundation (2008). - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/makesrna/intern/rna_actuator.c - * \ingroup RNA - */ - - -#include <stdlib.h> - -#include "DNA_constraint_types.h" -#include "DNA_object_types.h" -#include "DNA_actuator_types.h" -#include "DNA_scene_types.h" /* for MAXFRAME */ - -#include "BLI_math.h" -#include "BLI_string_utils.h" -#include "BLI_utildefines.h" - -#include "BLT_translation.h" - -#include "RNA_define.h" -#include "RNA_access.h" -#include "RNA_enum_types.h" - -#include "rna_internal.h" - -#include "WM_types.h" - -/* Always keep in alphabetical order */ -static const EnumPropertyItem actuator_type_items[] = { - {ACT_ACTION, "ACTION", 0, "Action", ""}, - {ACT_ARMATURE, "ARMATURE", 0, "Armature", ""}, - {ACT_CAMERA, "CAMERA", 0, "Camera", ""}, - {ACT_CONSTRAINT, "CONSTRAINT", 0, "Constraint", ""}, - {ACT_EDIT_OBJECT, "EDIT_OBJECT", 0, "Edit Object", ""}, - {ACT_2DFILTER, "FILTER_2D", 0, "Filter 2D", ""}, - {ACT_GAME, "GAME", 0, "Game", ""}, - {ACT_MESSAGE, "MESSAGE", 0, "Message", ""}, - {ACT_OBJECT, "MOTION", 0, "Motion", ""}, - {ACT_MOUSE, "MOUSE", 0, "Mouse", ""}, - {ACT_PARENT, "PARENT", 0, "Parent", ""}, - {ACT_PROPERTY, "PROPERTY", 0, "Property", ""}, - {ACT_RANDOM, "RANDOM", 0, "Random", ""}, - {ACT_SCENE, "SCENE", 0, "Scene", ""}, - {ACT_SOUND, "SOUND", 0, "Sound", ""}, - {ACT_STATE, "STATE", 0, "State", ""}, - {ACT_STEERING, "STEERING", 0, "Steering", ""}, - {ACT_VISIBILITY, "VISIBILITY", 0, "Visibility", ""}, - {0, NULL, 0, NULL, NULL} -}; - -#ifdef RNA_RUNTIME - -#include "BKE_sca.h" - -static StructRNA *rna_Actuator_refine(struct PointerRNA *ptr) -{ - bActuator *actuator = (bActuator *)ptr->data; - - switch (actuator->type) { - case ACT_ACTION: - return &RNA_ActionActuator; - case ACT_OBJECT: - return &RNA_ObjectActuator; - case ACT_CAMERA: - return &RNA_CameraActuator; - case ACT_SOUND: - return &RNA_SoundActuator; - case ACT_PROPERTY: - return &RNA_PropertyActuator; - case ACT_CONSTRAINT: - return &RNA_ConstraintActuator; - case ACT_EDIT_OBJECT: - return &RNA_EditObjectActuator; - case ACT_SCENE: - return &RNA_SceneActuator; - case ACT_RANDOM: - return &RNA_RandomActuator; - case ACT_MESSAGE: - return &RNA_MessageActuator; - case ACT_GAME: - return &RNA_GameActuator; - case ACT_VISIBILITY: - return &RNA_VisibilityActuator; - case ACT_2DFILTER: - return &RNA_Filter2DActuator; - case ACT_PARENT: - return &RNA_ParentActuator; - case ACT_STATE: - return &RNA_StateActuator; - case ACT_ARMATURE: - return &RNA_ArmatureActuator; - case ACT_STEERING: - return &RNA_SteeringActuator; - case ACT_MOUSE: - return &RNA_MouseActuator; - default: - return &RNA_Actuator; - } -} - -static void rna_Actuator_name_set(PointerRNA *ptr, const char *value) -{ - Object *ob = ptr->id.data; - bActuator *act = ptr->data; - BLI_strncpy_utf8(act->name, value, sizeof(act->name)); - BLI_uniquename(&ob->actuators, act, DATA_("Actuator"), '.', offsetof(bActuator, name), sizeof(act->name)); -} - -static void rna_Actuator_type_set(struct PointerRNA *ptr, int value) -{ - bActuator *act = (bActuator *)ptr->data; - - if (value != act->type) { - act->type = value; - init_actuator(act); - } -} - -static void rna_ConstraintActuator_type_set(struct PointerRNA *ptr, int value) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - - if (value != ca->type) { - ca->type = value; - switch (ca->type) { - case ACT_CONST_TYPE_ORI: - /* negative axis not supported in the orientation mode */ - if (ELEM(ca->mode, ACT_CONST_DIRNX, ACT_CONST_DIRNY, ACT_CONST_DIRNZ)) - ca->mode = ACT_CONST_NONE; - break; - - case ACT_CONST_TYPE_LOC: - case ACT_CONST_TYPE_DIST: - case ACT_CONST_TYPE_FH: - default: - break; - } - } -} - -static float rna_ConstraintActuator_limitmin_get(struct PointerRNA *ptr) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->flag & ACT_CONST_LOCX) fp = ca->minloc; - else if (ca->flag & ACT_CONST_LOCY) fp = ca->minloc + 1; - else if (ca->flag & ACT_CONST_LOCZ) fp = ca->minloc + 2; - else if (ca->flag & ACT_CONST_ROTX) fp = ca->minrot; - else if (ca->flag & ACT_CONST_ROTY) fp = ca->minrot + 1; - else fp = ca->minrot + 2; - - return *fp; -} - -static void rna_ConstraintActuator_limitmin_set(struct PointerRNA *ptr, float value) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->flag & ACT_CONST_LOCX) fp = ca->minloc; - else if (ca->flag & ACT_CONST_LOCY) fp = ca->minloc + 1; - else if (ca->flag & ACT_CONST_LOCZ) fp = ca->minloc + 2; - else if (ca->flag & ACT_CONST_ROTX) fp = ca->minrot; - else if (ca->flag & ACT_CONST_ROTY) fp = ca->minrot + 1; - else fp = ca->minrot + 2; - - *fp = value; -} - -static float rna_ConstraintActuator_limitmax_get(struct PointerRNA *ptr) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->flag & ACT_CONST_LOCX) fp = ca->maxloc; - else if (ca->flag & ACT_CONST_LOCY) fp = ca->maxloc + 1; - else if (ca->flag & ACT_CONST_LOCZ) fp = ca->maxloc + 2; - else if (ca->flag & ACT_CONST_ROTX) fp = ca->maxrot; - else if (ca->flag & ACT_CONST_ROTY) fp = ca->maxrot + 1; - else fp = ca->maxrot + 2; - - return *fp; -} - -static void rna_ConstraintActuator_limitmax_set(struct PointerRNA *ptr, float value) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->flag & ACT_CONST_LOCX) fp = ca->maxloc; - else if (ca->flag & ACT_CONST_LOCY) fp = ca->maxloc + 1; - else if (ca->flag & ACT_CONST_LOCZ) fp = ca->maxloc + 2; - else if (ca->flag & ACT_CONST_ROTX) fp = ca->maxrot; - else if (ca->flag & ACT_CONST_ROTY) fp = ca->maxrot + 1; - else fp = ca->maxrot + 2; - - *fp = value; -} - -static float rna_ConstraintActuator_distance_get(struct PointerRNA *ptr) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->minloc; - else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->minloc + 1; - else fp = ca->minloc + 2; - - return *fp; -} - -static void rna_ConstraintActuator_distance_set(struct PointerRNA *ptr, float value) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->minloc; - else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->minloc + 1; - else fp = ca->minloc + 2; - - *fp = value; -} - -static float rna_ConstraintActuator_range_get(struct PointerRNA *ptr) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->maxloc; - else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->maxloc + 1; - else fp = ca->maxloc + 2; - - return *fp; -} - -static void rna_ConstraintActuator_range_set(struct PointerRNA *ptr, float value) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->maxloc; - else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->maxloc + 1; - else fp = ca->maxloc + 2; - - *fp = value; -} - -static float rna_ConstraintActuator_fhheight_get(struct PointerRNA *ptr) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->minloc; - else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->minloc + 1; - else fp = ca->minloc + 2; - - return *fp; -} - -static void rna_ConstraintActuator_fhheight_set(struct PointerRNA *ptr, float value) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->minloc; - else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->minloc + 1; - else fp = ca->minloc + 2; - - *fp = value; -} - -static float rna_ConstraintActuator_spring_get(struct PointerRNA *ptr) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->maxloc; - else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->maxloc + 1; - else fp = ca->maxloc + 2; - - return *fp; -} - -static void rna_ConstraintActuator_spring_set(struct PointerRNA *ptr, float value) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - float *fp; - - if (ca->mode & (ACT_CONST_DIRPX | ACT_CONST_DIRNX)) fp = ca->maxloc; - else if (ca->mode & (ACT_CONST_DIRPY | ACT_CONST_DIRNY)) fp = ca->maxloc + 1; - else fp = ca->maxloc + 2; - - *fp = value; -} -/* ConstraintActuator uses the same property for Material and Property. - * Therefore we need to clear the property when "use_material_detect" mode changes */ -static void rna_Actuator_constraint_detect_material_set(struct PointerRNA *ptr, bool value) -{ - bActuator *act = (bActuator *)ptr->data; - bConstraintActuator *ca = act->data; - - short old_value = (ca->flag & ACT_CONST_MATERIAL) ? 1 : 0; - - if (old_value != value) { - ca->flag ^= ACT_CONST_MATERIAL; - ca->matprop[0] = '\0'; - } -} - -static void rna_ActionActuator_add_set(struct PointerRNA *ptr, bool value) -{ - bActuator *act = (bActuator *)ptr->data; - bActionActuator *aa = act->data; - - if (value) { - aa->flag &= ~ACT_IPOFORCE; - aa->flag |= ACT_IPOADD; - } - else { - aa->flag &= ~ACT_IPOADD; - } -} - -static void rna_ActionActuator_force_set(struct PointerRNA *ptr, bool value) -{ - bActuator *act = (bActuator *)ptr->data; - bActionActuator *aa = act->data; - - if (value) { - aa->flag &= ~ACT_IPOADD; - aa->flag |= ACT_IPOFORCE; - } - else { - aa->flag &= ~ACT_IPOFORCE; - } -} - -static void rna_ObjectActuator_type_set(struct PointerRNA *ptr, int value) -{ - bActuator *act = (bActuator *)ptr->data; - bObjectActuator *oa = act->data; - if (value != oa->type) { - oa->type = value; - switch (oa->type) { - case ACT_OBJECT_NORMAL: - memset(oa, 0, sizeof(bObjectActuator)); - oa->flag = ACT_FORCE_LOCAL | ACT_TORQUE_LOCAL | ACT_DLOC_LOCAL | ACT_DROT_LOCAL; - oa->type = ACT_OBJECT_NORMAL; - break; - - case ACT_OBJECT_SERVO: - memset(oa, 0, sizeof(bObjectActuator)); - oa->flag = ACT_LIN_VEL_LOCAL; - oa->type = ACT_OBJECT_SERVO; - oa->forcerot[0] = 30.0f; - oa->forcerot[1] = 0.5f; - oa->forcerot[2] = 0.0f; - break; - - case ACT_OBJECT_CHARACTER: - memset(oa, 0, sizeof(bObjectActuator)); - oa->flag = ACT_DLOC_LOCAL | ACT_DROT_LOCAL; - oa->type = ACT_OBJECT_CHARACTER; - break; - } - } -} - -static void rna_ObjectActuator_integralcoefficient_set(struct PointerRNA *ptr, float value) -{ - bActuator *act = (bActuator *)ptr->data; - bObjectActuator *oa = act->data; - - oa->forcerot[1] = value; - oa->forcerot[0] = 60.0f * oa->forcerot[1]; -} - -static void rna_StateActuator_state_set(PointerRNA *ptr, const bool *values) -{ - bActuator *act = (bActuator *)ptr->data; - bStateActuator *sa = act->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]) sa->mask |= (1 << i); - else sa->mask &= ~(1 << i); - } -} - -/* Always keep in alphabetical order */ -const EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) -{ - EnumPropertyItem *item = NULL; - Object *ob = NULL; - int totitem = 0; - - if (ptr->type == &RNA_Actuator || RNA_struct_is_a(ptr->type, &RNA_Actuator)) { - ob = (Object *)ptr->id.data; - } - else { - /* can't use ob from ptr->id.data because that enum is also used by operators */ - ob = CTX_data_active_object(C); - } - - if (ob != NULL) { - if (ob->type == OB_ARMATURE) { - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ARMATURE); - } - } - - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ACTION); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CAMERA); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CONSTRAINT); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_EDIT_OBJECT); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_2DFILTER); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_GAME); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_MESSAGE); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_MOUSE); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_OBJECT); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PARENT); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PROPERTY); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_RANDOM); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SCENE); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_STEERING); - - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SOUND); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_STATE); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_VISIBILITY); - - RNA_enum_item_end(&item, &totitem); - *r_free = true; - - return item; -} - -static void rna_Actuator_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - bActuator *act = (bActuator *)ptr->data; - bArmatureActuator *aa = act->data; - Object *ob = (Object *)ptr->id.data; - - char *posechannel = aa->posechannel; - char *constraint = aa->constraint; - - /* check that bone exist in the active object */ - if (ob->type == OB_ARMATURE && ob->pose) { - bPoseChannel *pchan; - bPose *pose = ob->pose; - for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - if (STREQ(pchan->name, posechannel)) { - /* found it, now look for constraint channel */ - bConstraint *con; - for (con = pchan->constraints.first; con; con = con->next) { - if (STREQ(con->name, constraint)) { - /* found it, all ok */ - return; - } - } - /* didn't find constraint, make empty */ - constraint[0] = 0; - return; - } - } - } - /* didn't find any */ - posechannel[0] = 0; - constraint[0] = 0; -} - -static void rna_SteeringActuator_navmesh_set(PointerRNA *ptr, PointerRNA value) -{ - bActuator *act = (bActuator *)ptr->data; - bSteeringActuator *sa = (bSteeringActuator *) act->data; - - Object *obj = value.data; - if (obj && obj->body_type == OB_BODY_TYPE_NAVMESH) - sa->navmesh = obj; - else - sa->navmesh = NULL; -} - -/* note: the following set functions exists only to avoid id refcounting */ -static void rna_Actuator_editobject_mesh_set(PointerRNA *ptr, PointerRNA value) -{ - bActuator *act = (bActuator *)ptr->data; - bEditObjectActuator *eoa = (bEditObjectActuator *) act->data; - - eoa->me = value.data; -} - -#else - -static void rna_def_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "Actuator", NULL); - RNA_def_struct_ui_text(srna, "Actuator", "Actuator to apply actions in the game engine"); - RNA_def_struct_sdna(srna, "bActuator"); - RNA_def_struct_refine_func(srna, "rna_Actuator_refine"); - - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Name", ""); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Actuator_name_set"); - RNA_def_struct_name_property(srna, prop); - - prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_enum_items(prop, actuator_type_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_Actuator_type_set", "rna_Actuator_type_itemf"); - RNA_def_property_ui_text(prop, "Type", ""); - - prop = RNA_def_property(srna, "pin", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_PIN); - RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller"); - RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SHOW); - RNA_def_property_ui_text(prop, "Expanded", "Set actuator expanded in the user interface"); - RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); - - prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_DEACTIVATE); - RNA_def_property_ui_text(prop, "Active", "Set the active state of the actuator"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - RNA_api_actuator(srna); -} - -static void rna_def_action_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_ACTION_PLAY, "PLAY", 0, "Play", ""}, - {ACT_ACTION_PINGPONG, "PINGPONG", 0, "Ping Pong", ""}, - {ACT_ACTION_FLIPPER, "FLIPPER", 0, "Flipper", ""}, - {ACT_ACTION_LOOP_STOP, "LOOPSTOP", 0, "Loop Stop", ""}, - {ACT_ACTION_LOOP_END, "LOOPEND", 0, "Loop End", ""}, - {ACT_ACTION_FROM_PROP, "PROPERTY", 0, "Property", ""}, -#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR - {ACT_ACTION_MOTION, "MOTION", 0, "Displacement", ""}, -#endif - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_blend_items[] = { - {ACT_ACTION_BLEND, "BLEND", 0, "Blend", ""}, - {ACT_ACTION_ADD, "ADD", 0, "Add", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "ActionActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Action Actuator", "Actuator to control the object movement"); - RNA_def_struct_sdna_from(srna, "bActionActuator", "data"); - - prop = RNA_def_property(srna, "play_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Action Type", "Action playback type"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "act"); - RNA_def_property_struct_type(prop, "Action"); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); - RNA_def_property_ui_text(prop, "Action", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_continue_last_frame", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "end_reset", 1); - RNA_def_property_ui_text(prop, "Continue", - "Restore last frame when switching on/off, otherwise play from the start each time"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Property", "Use this property to define the Action position"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sta"); - RNA_def_property_ui_range(prop, 0.0, MAXFRAME, 100, 2); - RNA_def_property_ui_text(prop, "Start Frame", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "end"); - RNA_def_property_ui_range(prop, 0.0, MAXFRAME, 100, 2); - RNA_def_property_ui_text(prop, "End Frame", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "frame_blend_in", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "blendin"); - RNA_def_property_range(prop, 0, 32767); - RNA_def_property_ui_text(prop, "Blendin", "Number of frames of motion blending"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "priority", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 0, 100); - RNA_def_property_ui_text(prop, "Priority", - "Execution priority - lower numbers will override actions with higher numbers " - "(with 2 or more actions at once, the overriding channels must be lower in the stack)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "layer", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 0, 32766); /* This should match BL_ActionManager::MAX_ACTION_LAYERS - 1 */ - RNA_def_property_ui_text(prop, "Layer", "The animation layer to play the action on"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "layer_weight", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Layer Weight", - "How much of the previous layer to blend into this one"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "frame_property", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "frameProp"); - RNA_def_property_ui_text(prop, "Frame Property", "Assign the action's current frame number to this property"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* booleans */ - prop = RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOADD); - RNA_def_property_boolean_funcs(prop, NULL, "rna_ActionActuator_add_set"); - RNA_def_property_ui_text(prop, "Add", - "Action is added to the current loc/rot/scale in global or local coordinate according to " - "Local flag"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_force", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOFORCE); - RNA_def_property_boolean_funcs(prop, NULL, "rna_ActionActuator_force_set"); - RNA_def_property_ui_text(prop, "Force", - "Apply Action as a global or local force depending on the local option " - "(dynamic objects only)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_local", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOLOCAL); - RNA_def_property_ui_text(prop, "L", "Let the Action act in local coordinates, used in Force and Add mode"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "apply_to_children", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOCHILD); - RNA_def_property_ui_text(prop, "Child", "Update Action on all children Objects as well"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "blend_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "blend_mode"); - RNA_def_property_enum_items(prop, prop_blend_items); - RNA_def_property_ui_text(prop, "Blend Mode", "How this layer is blended with previous layers"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - -#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR - prop = RNA_def_property(srna, "stride_length", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "stridelength"); - RNA_def_property_range(prop, 0.0, 2500.0); - RNA_def_property_ui_text(prop, "Cycle", "Distance covered by a single cycle of the action"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -#endif -} - -static void rna_def_object_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_OBJECT_NORMAL, "OBJECT_NORMAL", 0, "Simple Motion", ""}, - {ACT_OBJECT_SERVO, "OBJECT_SERVO", 0, "Servo Control", ""}, - {ACT_OBJECT_CHARACTER, "OBJECT_CHARACTER", 0, "Character Motion", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "ObjectActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Motion Actuator", "Actuator to control the object movement"); - RNA_def_struct_sdna_from(srna, "bObjectActuator", "data"); - - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_ObjectActuator_type_set", NULL); - RNA_def_property_ui_text(prop, "Motion Type", "Specify the motion system"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "reference_object", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_sdna(prop, NULL, "reference"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Reference Object", - "Reference object for velocity calculation, leave empty for world reference"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "damping", PROP_INT, PROP_NONE); - RNA_def_property_ui_range(prop, 0, 1000, 1, 1); - RNA_def_property_ui_text(prop, "Damping Frames", "Number of frames to reach the target velocity"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "proportional_coefficient", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "forcerot[0]"); - RNA_def_property_ui_range(prop, 0.0, 200.0, 10, 2); - RNA_def_property_ui_text(prop, "Proportional Coefficient", "Typical value is 60x integral coefficient"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "integral_coefficient", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "forcerot[1]"); - RNA_def_property_ui_range(prop, 0.0, 3.0, 10, 2); - RNA_def_property_float_funcs(prop, NULL, "rna_ObjectActuator_integralcoefficient_set", NULL); - RNA_def_property_ui_text(prop, "Integral Coefficient", - "Low value (0.01) for slow response, high value (0.5) for fast response"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "derivate_coefficient", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "forcerot[2]"); - RNA_def_property_ui_range(prop, -100.0, 100.0, 10, 2); - RNA_def_property_ui_text(prop, "Derivate Coefficient", "Not required, high values can cause instability"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* Servo Limit */ - prop = RNA_def_property(srna, "force_max_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dloc[0]"); - RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2); - RNA_def_property_ui_text(prop, "Max", "Upper limit for X force"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "force_min_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "drot[0]"); - RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2); - RNA_def_property_ui_text(prop, "Min", "Lower limit for X force"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "force_max_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dloc[1]"); - RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2); - RNA_def_property_ui_text(prop, "Max", "Upper limit for Y force"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "force_min_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "drot[1]"); - RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2); - RNA_def_property_ui_text(prop, "Min", "Lower limit for Y force"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "force_max_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dloc[2]"); - RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2); - RNA_def_property_ui_text(prop, "Max", "Upper limit for Z force"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "force_min_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "drot[2]"); - RNA_def_property_ui_range(prop, -100.0, 100.0, 1, 2); - RNA_def_property_ui_text(prop, "Min", "Lower limit for Z force"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* floats 3 Arrays*/ - prop = RNA_def_property(srna, "offset_location", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, NULL, "dloc"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2); - RNA_def_property_ui_text(prop, "Loc", "Location"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "offset_rotation", PROP_FLOAT, PROP_EULER); - RNA_def_property_float_sdna(prop, NULL, "drot"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2); - RNA_def_property_ui_text(prop, "Rot", "Rotation"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "force", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, NULL, "forceloc"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2); - RNA_def_property_ui_text(prop, "Force", "Force"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "torque", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, NULL, "forcerot"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2); - RNA_def_property_ui_text(prop, "Torque", "Torque"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "linear_velocity", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, NULL, "linearvelocity"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2); - RNA_def_property_ui_text(prop, "Linear Velocity", - "Linear velocity (in Servo mode it sets the target relative linear velocity, it will be " - "achieved by automatic application of force - Null velocity is a valid target)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, NULL, "angularvelocity"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2); - RNA_def_property_ui_text(prop, "Angular Velocity", "Angular velocity"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* booleans */ - prop = RNA_def_property(srna, "use_local_location", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_DLOC_LOCAL); - RNA_def_property_ui_text(prop, "L", "Location is defined in local coordinates"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_local_rotation", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_DROT_LOCAL); - RNA_def_property_ui_text(prop, "L", "Rotation is defined in local coordinates"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_local_force", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_FORCE_LOCAL); - RNA_def_property_ui_text(prop, "L", "Force is defined in local coordinates"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_local_torque", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_TORQUE_LOCAL); - RNA_def_property_ui_text(prop, "L", "Torque is defined in local coordinates"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_local_linear_velocity", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_LIN_VEL_LOCAL); - RNA_def_property_ui_text(prop, "L", "Velocity is defined in local coordinates"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_local_angular_velocity", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_ANG_VEL_LOCAL); - RNA_def_property_ui_text(prop, "L", "Angular velocity is defined in local coordinates"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_add_linear_velocity", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_ADD_LIN_VEL); - RNA_def_property_ui_text(prop, "Add", "Toggles between ADD and SET linV"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_add_character_location", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_ADD_CHAR_LOC); - RNA_def_property_ui_text(prop, "Add", "Toggle between ADD and SET character location"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_servo_limit_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SERVO_LIMIT_X); - RNA_def_property_ui_text(prop, "X", "Set limit to force along the X axis"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_servo_limit_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SERVO_LIMIT_Y); - RNA_def_property_ui_text(prop, "Y", "Set limit to force along the Y axis"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_servo_limit_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SERVO_LIMIT_Z); - RNA_def_property_ui_text(prop, "Z", "Set limit to force along the Z axis"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_character_jump", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CHAR_JUMP); - RNA_def_property_ui_text(prop, "Jump", "Make the character jump using the settings in the physics properties"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_camera_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_axis_items[] = { - {OB_POSX, "POS_X", 0, "+X", "Camera tries to get behind the X axis"}, - {OB_POSY, "POS_Y", 0, "+Y", "Camera tries to get behind the Y axis"}, - {OB_NEGX, "NEG_X", 0, "-X", "Camera tries to get behind the -X axis"}, - {OB_NEGY, "NEG_Y", 0, "-Y", "Camera tries to get behind the -Y axis"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "CameraActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Camera Actuator", ""); - RNA_def_struct_sdna_from(srna, "bCameraActuator", "data"); - - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_sdna(prop, NULL, "ob"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Camera Object", "Look at this Object"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* floats */ - prop = RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_range(prop, 0.0, 20.0, 1, 2); - RNA_def_property_ui_text(prop, "Height", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_range(prop, 0.0, 20.0, 1, 2); - RNA_def_property_ui_text(prop, "Min", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_range(prop, 0.0, 20.0, 1, 2); - RNA_def_property_ui_text(prop, "Max", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "damping"); - RNA_def_property_range(prop, 0, 10.0); - RNA_def_property_ui_range(prop, 0, 5.0, 1, 2); - RNA_def_property_ui_text(prop, "Damping", "Strength of the constraint that drives the camera behind the target"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* +x/+y/-x/-y */ - prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "axis"); - RNA_def_property_enum_items(prop, prop_axis_items); - RNA_def_property_ui_text(prop, "Axis", "Axis the Camera will try to get behind"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_sound_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_SND_PLAY_STOP_SOUND, "PLAYSTOP", 0, "Play Stop", ""}, - {ACT_SND_PLAY_END_SOUND, "PLAYEND", 0, "Play End", ""}, - {ACT_SND_LOOP_STOP_SOUND, "LOOPSTOP", 0, "Loop Stop", ""}, - {ACT_SND_LOOP_END_SOUND, "LOOPEND", 0, "Loop End", ""}, - {ACT_SND_LOOP_BIDIRECTIONAL_SOUND, "LOOPBIDIRECTIONAL", 0, "Loop Bidirectional", ""}, - {ACT_SND_LOOP_BIDIRECTIONAL_STOP_SOUND, "LOOPBIDIRECTIONALSTOP", 0, "Loop Bidirectional Stop", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "SoundActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Sound Actuator", "Actuator to handle sound"); - RNA_def_struct_sdna_from(srna, "bSoundActuator", "data"); - - prop = RNA_def_property(srna, "sound", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Sound"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_struct_ui_text(srna, "Sound", "Sound file"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Play Mode", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "volume", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2); - RNA_def_property_range(prop, 0.0, 2.0); - RNA_def_property_ui_text(prop, "Volume", "Initial volume of the sound"); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SOUND); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_range(prop, -12.0, 12.0, 1, 2); - RNA_def_property_ui_text(prop, "Pitch", "Pitch of the sound"); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SOUND); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* floats - 3D Parameters */ - prop = RNA_def_property(srna, "gain_3d_min", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sound3D.min_gain"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2); - RNA_def_property_ui_text(prop, "Minimum Gain", "The minimum gain of the sound, no matter how far it is away"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "gain_3d_max", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sound3D.max_gain"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2); - RNA_def_property_ui_text(prop, "Maximum Gain", "The maximum gain of the sound, no matter how near it is"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "distance_3d_reference", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sound3D.reference_distance"); - RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 1, 2); - RNA_def_property_ui_text(prop, "Reference Distance", "The distance where the sound has a gain of 1.0"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "distance_3d_max", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sound3D.max_distance"); - RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 1, 2); - RNA_def_property_ui_text(prop, "Maximum Distance", "The maximum distance at which you can hear the sound"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "rolloff_factor_3d", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sound3D.rolloff_factor"); - RNA_def_property_ui_range(prop, 0.0, 5.0, 1, 2); - RNA_def_property_ui_text(prop, "Rolloff", "The influence factor on volume depending on distance"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "cone_outer_gain_3d", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sound3D.cone_outer_gain"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2); - RNA_def_property_ui_text(prop, "Cone Outer Gain", - "The gain outside the outer cone (the gain in the outer cone will be interpolated " - "between this value and the normal gain in the inner cone)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "cone_outer_angle_3d", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "sound3D.cone_outer_angle"); - RNA_def_property_ui_range(prop, 0.0, DEG2RADF(360.0f), 1, 2); - RNA_def_property_ui_text(prop, "Cone Outer Angle", "The angle of the outer cone"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "cone_inner_angle_3d", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "sound3D.cone_inner_angle"); - RNA_def_property_ui_range(prop, 0.0, DEG2RADF(360.0f), 1, 2); - RNA_def_property_ui_text(prop, "Cone Inner Angle", "The angle of the inner cone"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* booleans */ - prop = RNA_def_property(srna, "use_sound_3d", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SND_3D_SOUND); - RNA_def_property_ui_text(prop, "3D Sound", "Enable/Disable 3D Sound"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_property_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_PROP_ASSIGN, "ASSIGN", 0, "Assign", ""}, - {ACT_PROP_ADD, "ADD", 0, "Add", ""}, - {ACT_PROP_COPY, "COPY", 0, "Copy", ""}, - {ACT_PROP_TOGGLE, "TOGGLE", 0, "Toggle", "For bool/int/float/timer properties only"}, - {ACT_PROP_LEVEL, "LEVEL", 0, "Level", "For bool/int/float/timer properties only"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "PropertyActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Property Actuator", "Actuator to handle properties"); - RNA_def_struct_sdna_from(srna, "bPropertyActuator", "data"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Mode", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Property", "The name of the property"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "value", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Value", "The name of the property or the value to use (use \"\" around strings)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* Copy Mode */ - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_sdna(prop, NULL, "ob"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Object", "Copy from this Object"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /*XXX add even magic'er property lookup (need to look for the property list of the target object) */ - prop = RNA_def_property(srna, "object_property", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "value"); - RNA_def_property_ui_text(prop, "Property Name", "Copy this property"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_constraint_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_CONST_TYPE_LOC, "LOC", 0, "Location Constraint", ""}, - {ACT_CONST_TYPE_DIST, "DIST", 0, "Distance Constraint", ""}, - {ACT_CONST_TYPE_ORI, "ORI", 0, "Orientation Constraint", ""}, - {ACT_CONST_TYPE_FH, "FH", 0, "Force Field Constraint", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_limit_items[] = { - {ACT_CONST_NONE, "NONE", 0, "None", ""}, - {ACT_CONST_LOCX, "LOCX", 0, "Loc X", ""}, - {ACT_CONST_LOCY, "LOCY", 0, "Loc Y", ""}, - {ACT_CONST_LOCZ, "LOCZ", 0, "Loc Z", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_direction_items[] = { - {ACT_CONST_NONE, "NONE", 0, "None", ""}, - {ACT_CONST_DIRPX, "DIRPX", 0, "X axis", ""}, - {ACT_CONST_DIRPY, "DIRPY", 0, "Y axis", ""}, - {ACT_CONST_DIRPZ, "DIRPZ", 0, "Z axis", ""}, - {ACT_CONST_DIRNX, "DIRNX", 0, "-X axis", ""}, - {ACT_CONST_DIRNY, "DIRNY", 0, "-Y axis", ""}, - {ACT_CONST_DIRNZ, "DIRNZ", 0, "-Z axis", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_direction_pos_items[] = { - {ACT_CONST_NONE, "NONE", 0, "None", ""}, - {ACT_CONST_DIRPX, "DIRPX", 0, "X axis", ""}, - {ACT_CONST_DIRPY, "DIRPY", 0, "Y axis", ""}, - {ACT_CONST_DIRPZ, "DIRPZ", 0, "Z axis", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "ConstraintActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Constraint Actuator", "Actuator to handle Constraints"); - RNA_def_struct_sdna_from(srna, "bConstraintActuator", "data"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_ConstraintActuator_type_set", NULL); - RNA_def_property_ui_text(prop, "Constraints Mode", "The type of the constraint"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "limit", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, prop_limit_items); - RNA_def_property_ui_text(prop, "Limit", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, prop_direction_items); - RNA_def_property_ui_text(prop, "Direction", "Direction of the ray"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "direction_axis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, prop_direction_items); - RNA_def_property_ui_text(prop, "Direction", "Select the axis to be aligned along the reference direction"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_CONST_TYPE_LOC */ - prop = RNA_def_property(srna, "limit_min", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_limitmin_get", - "rna_ConstraintActuator_limitmin_set", NULL); - RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Min", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "limit_max", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_limitmax_get", - "rna_ConstraintActuator_limitmax_set", NULL); - RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Max", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "damping", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "damp"); - RNA_def_property_ui_range(prop, 0, 100, 1, 1); - RNA_def_property_ui_text(prop, "Damping", "Damping factor: time constant (in frame) of low pass filter"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_CONST_TYPE_DIST */ - prop = RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_range_get", "rna_ConstraintActuator_range_set", NULL); - RNA_def_property_ui_range(prop, 0.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Range", "Maximum length of ray"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_distance_get", - "rna_ConstraintActuator_distance_set", NULL); - RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Distance", "Keep this distance to target"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /*XXX to use a pointer or add a material lookup */ - prop = RNA_def_property(srna, "material", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "matprop"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Material", "Ray detects only Objects with this material"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /*XXX add magic property lookup */ - prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "matprop"); - RNA_def_property_ui_text(prop, "Property", "Ray detects only Objects with this property"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "time", PROP_INT, PROP_NONE); - RNA_def_property_ui_range(prop, 0, 1000, 1, 2); - RNA_def_property_ui_text(prop, "Time", "Maximum activation time in frame, 0 for unlimited"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "damping_rotation", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "rotdamp"); - RNA_def_property_ui_range(prop, 0, 100, 1, 1); - RNA_def_property_ui_text(prop, "RotDamp", "Use a different damping for orientation"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_CONST_TYPE_ORI */ - prop = RNA_def_property(srna, "direction_axis_pos", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, prop_direction_pos_items); - RNA_def_property_ui_text(prop, "Direction", "Select the axis to be aligned along the reference direction"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "rotation_max", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, NULL, "maxrot"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_range(prop, -2000.0, 2000.0, 10, 2); - RNA_def_property_ui_text(prop, "Reference Direction", "Reference Direction"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "angle_min", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "minloc[0]"); - RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f)); - RNA_def_property_ui_text(prop, "Min Angle", - "Minimum angle to maintain with target direction " - "(no correction is done if angle with target direction is between min and max)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "angle_max", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "maxloc[0]"); - RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f)); - RNA_def_property_ui_text(prop, "Max Angle", - "Maximum angle allowed with target direction " - "(no correction is done if angle with target direction is between min and max)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_CONST_TYPE_FH */ - prop = RNA_def_property(srna, "fh_height", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_fhheight_get", - "rna_ConstraintActuator_fhheight_set", NULL); - RNA_def_property_ui_range(prop, 0.01, 2000.0, 10, 2); - RNA_def_property_ui_text(prop, "Distance", "Height of the force field area"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "fh_force", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_spring_get", "rna_ConstraintActuator_spring_set", NULL); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 2); - RNA_def_property_ui_text(prop, "Force", "Spring force within the force field area"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "fh_damping", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxrot[0]"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 2); - RNA_def_property_ui_text(prop, "Damping", "Damping factor of the force field spring"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* booleans */ - prop = RNA_def_property(srna, "use_force_distance", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_DISTANCE); - RNA_def_property_ui_text(prop, "Force Distance", "Force distance of object to point of impact of ray"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_local", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_LOCAL); - RNA_def_property_ui_text(prop, "L", "Set ray along object's axis or global axis"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_NORMAL); - RNA_def_property_ui_text(prop, "N", - "Set object axis along (local axis) or parallel (global axis) to the normal at " - "hit position"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_persistent", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_PERMANENT); - RNA_def_property_ui_text(prop, "PER", "Persistent actuator: stays active even if ray does not reach target"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /*XXX to use an enum instead of a flag if possible */ - prop = RNA_def_property(srna, "use_material_detect", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_MATERIAL); - RNA_def_property_ui_text(prop, "M/P", "Detect material instead of property"); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Actuator_constraint_detect_material_set"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_fh_paralel_axis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_DOROTFH); - RNA_def_property_ui_text(prop, "Rot Fh", "Keep object axis parallel to normal"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_fh_normal", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_NORMAL); - RNA_def_property_ui_text(prop, "N", "Add a horizontal spring force on slopes"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_edit_object_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_dyn_items[] = { - {ACT_EDOB_RESTORE_DYN, "RESTOREDYN", 0, "Restore Dynamics", ""}, - {ACT_EDOB_SUSPEND_DYN, "SUSPENDDYN", 0, "Suspend Dynamics", ""}, - {ACT_EDOB_ENABLE_RB, "ENABLERIGIDBODY", 0, "Enable Rigid Body", ""}, - {ACT_EDOB_DISABLE_RB, "DISABLERIGIDBODY", 0, "Disable Rigid Body", ""}, - {ACT_EDOB_SET_MASS, "SETMASS", 0, "Set Mass", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_EDOB_ADD_OBJECT, "ADDOBJECT", 0, "Add Object", ""}, - {ACT_EDOB_END_OBJECT, "ENDOBJECT", 0, "End Object", ""}, - {ACT_EDOB_REPLACE_MESH, "REPLACEMESH", 0, "Replace Mesh", ""}, - {ACT_EDOB_TRACK_TO, "TRACKTO", 0, "Track to", ""}, - {ACT_EDOB_DYNAMICS, "DYNAMICS", 0, "Dynamics", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_track_axis_items[] = { - {ACT_TRACK_TRAXIS_X, "TRACKAXISX", 0, "X axis", ""}, - {ACT_TRACK_TRAXIS_Y, "TRACKAXISY", 0, "Y axis", ""}, - {ACT_TRACK_TRAXIS_Z, "TRACKAXISZ", 0, "Z axis", ""}, - {ACT_TRACK_TRAXIS_NEGX, "TRACKAXISNEGX", 0, "-X axis", ""}, - {ACT_TRACK_TRAXIS_NEGY, "TRACKAXISNEGY", 0, "-Y axis", ""}, - {ACT_TRACK_TRAXIS_NEGZ, "TRACKAXISNEGZ", 0, "-Z axis", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_up_axis_items[] = { - {ACT_TRACK_UP_X, "UPAXISX", 0, "X axis", ""}, - {ACT_TRACK_UP_Y, "UPAXISY", 0, "Y axis", ""}, - {ACT_TRACK_UP_Z, "UPAXISZ", 0, "Z axis", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "EditObjectActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Edit Object Actuator", "Actuator used to edit objects"); - RNA_def_struct_sdna_from(srna, "bEditObjectActuator", "data"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Edit Object", "The mode of the actuator"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "dynamic_operation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "dyn_operation"); - RNA_def_property_enum_items(prop, prop_dyn_items); - RNA_def_property_ui_text(prop, "Dynamic Operation", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "upflag"); - RNA_def_property_enum_items(prop, prop_up_axis_items); - RNA_def_property_ui_text(prop, "Up Axis", "The axis that points upward"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "trackflag"); - RNA_def_property_enum_items(prop, prop_track_axis_items); - RNA_def_property_ui_text(prop, "Track Axis", "The axis that points to the target object"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_sdna(prop, NULL, "ob"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Object", "Add this Object and all its children (can't be on a visible layer)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "track_object", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_sdna(prop, NULL, "ob"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Object", "Track to this Object"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "mesh", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Mesh"); - RNA_def_property_pointer_sdna(prop, NULL, "me"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Mesh", - "Replace the existing, when left blank 'Phys' will remake the existing physics mesh"); - /* note: custom set function is ONLY to avoid rna setting a user for this. */ - RNA_def_property_pointer_funcs(prop, NULL, "rna_Actuator_editobject_mesh_set", NULL, NULL); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "time", PROP_INT, PROP_NONE); - RNA_def_property_ui_range(prop, 0, 2000, 1, 1); - RNA_def_property_ui_text(prop, "Time", "Duration the new Object lives or the track takes"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_range(prop, 0, 10000, 1, 2); - RNA_def_property_ui_text(prop, "Mass", "The mass of the object"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* floats 3 Arrays*/ - prop = RNA_def_property(srna, "linear_velocity", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, NULL, "linVelocity"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_range(prop, -100.0, 100.0, 10, 2); - RNA_def_property_ui_text(prop, "Linear Velocity", "Velocity upon creation"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, NULL, "angVelocity"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2); - RNA_def_property_ui_text(prop, "Angular Velocity", "Angular velocity upon creation"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* booleans */ - prop = RNA_def_property(srna, "use_local_linear_velocity", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "localflag", ACT_EDOB_LOCAL_LINV); - RNA_def_property_ui_text(prop, "L", "Apply the transformation locally"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_local_angular_velocity", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "localflag", ACT_EDOB_LOCAL_ANGV); - RNA_def_property_ui_text(prop, "L", "Apply the rotation locally"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_replace_display_mesh", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_EDOB_REPLACE_MESH_NOGFX); - RNA_def_property_ui_text(prop, "Gfx", "Replace the display mesh"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_replace_physics_mesh", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_EDOB_REPLACE_MESH_PHYS); - RNA_def_property_ui_text(prop, "Phys", - "Replace the physics mesh (triangle bounds only - compound shapes not supported)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_3d_tracking", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_TRACK_3D); - RNA_def_property_ui_text(prop, "3D", "Enable 3D tracking"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_scene_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_SCENE_RESTART, "RESTART", 0, "Restart", ""}, - {ACT_SCENE_SET, "SET", 0, "Set Scene", ""}, - {ACT_SCENE_CAMERA, "CAMERA", 0, "Set Camera", ""}, - {ACT_SCENE_ADD_FRONT, "ADDFRONT", 0, "Add Overlay Scene", ""}, - {ACT_SCENE_ADD_BACK, "ADDBACK", 0, "Add Background Scene", ""}, - {ACT_SCENE_REMOVE, "REMOVE", 0, "Remove Scene", ""}, - {ACT_SCENE_SUSPEND, "SUSPEND", 0, "Suspend Scene", ""}, - {ACT_SCENE_RESUME, "RESUME", 0, "Resume Scene", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "SceneActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Scene Actuator", ""); - RNA_def_struct_sdna_from(srna, "bSceneActuator", "data"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Mode", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Camera Object", "Set this Camera (leave empty to refer to self object)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Scene"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Scene", "Scene to be added/removed/paused/resumed"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_random_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_distribution_items[] = { - {ACT_RANDOM_BOOL_CONST, "BOOL_CONSTANT", 0, "Bool Constant", ""}, - {ACT_RANDOM_BOOL_UNIFORM, "BOOL_UNIFORM", 0, "Bool Uniform", ""}, - {ACT_RANDOM_BOOL_BERNOUILLI, "BOOL_BERNOUILLI", 0, "Bool Bernoulli", ""}, - {ACT_RANDOM_INT_CONST, "INT_CONSTANT", 0, "Int Constant", ""}, - {ACT_RANDOM_INT_UNIFORM, "INT_UNIFORM", 0, "Int Uniform", ""}, - {ACT_RANDOM_INT_POISSON, "INT_POISSON", 0, "Int Poisson", ""}, - {ACT_RANDOM_FLOAT_CONST, "FLOAT_CONSTANT", 0, "Float Constant", ""}, - {ACT_RANDOM_FLOAT_UNIFORM, "FLOAT_UNIFORM", 0, "Float Uniform", ""}, - {ACT_RANDOM_FLOAT_NORMAL, "FLOAT_NORMAL", 0, "Float Normal", ""}, - {ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL, "FLOAT_NEGATIVE_EXPONENTIAL", 0, "Float Neg. Exp.", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "RandomActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Random Actuator", ""); - RNA_def_struct_sdna_from(srna, "bRandomActuator", "data"); - - prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE); - RNA_def_property_ui_range(prop, 0, 1000, 1, 1); - RNA_def_property_range(prop, 0, MAXFRAME); - RNA_def_property_ui_text(prop, "Seed", - "Initial seed of the random generator, use Python for more freedom " - "(choose 0 for not random)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "propname"); - RNA_def_property_ui_text(prop, "Property", "Assign the random value to this property"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "distribution", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_distribution_items); - RNA_def_property_ui_text(prop, "Distribution", "Choose the type of distribution"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* arguments for the distribution */ - /* int_arg_1, int_arg_2, float_arg_1, float_arg_2 */ - - /* ACT_RANDOM_BOOL_CONST */ - prop = RNA_def_property(srna, "use_always_true", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "int_arg_1", 1); - RNA_def_property_ui_text(prop, "Always True", "Always false or always true"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_RANDOM_BOOL_UNIFORM */ - /* label => "Choose between true and false, 50% chance each" */ - - /* ACT_RANDOM_BOOL_BERNOUILLI */ - prop = RNA_def_property(srna, "chance", PROP_FLOAT, PROP_PERCENTAGE); - RNA_def_property_float_sdna(prop, NULL, "float_arg_1"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Chance", "Pick a number between 0 and 1, success if it's below this value"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_RANDOM_INT_CONST */ - prop = RNA_def_property(srna, "int_value", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "int_arg_1"); - RNA_def_property_ui_range(prop, -1000, 1000, 1, 1); - RNA_def_property_ui_text(prop, "Value", "Always return this number"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_RANDOM_INT_UNIFORM */ - prop = RNA_def_property(srna, "int_min", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "int_arg_1"); - RNA_def_property_range(prop, -1000, 1000); - RNA_def_property_ui_text(prop, "Min", "Choose a number from a range: lower boundary of the range"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "int_max", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "int_arg_2"); - RNA_def_property_range(prop, -1000, 1000); - RNA_def_property_ui_text(prop, "Max", "Choose a number from a range: upper boundary of the range"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_RANDOM_INT_POISSON */ - prop = RNA_def_property(srna, "int_mean", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "float_arg_1"); - RNA_def_property_range(prop, 0.01, 100.0); - RNA_def_property_ui_text(prop, "Mean", "Expected mean value of the distribution"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_RANDOM_FLOAT_CONST */ - prop = RNA_def_property(srna, "float_value", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "float_arg_1"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Value", "Always return this number"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_RANDOM_FLOAT_UNIFORM */ - prop = RNA_def_property(srna, "float_min", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "float_arg_1"); - RNA_def_property_range(prop, -1000.0, 1000.0); - RNA_def_property_ui_text(prop, "Min", "Choose a number from a range: lower boundary of the range"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "float_max", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "float_arg_2"); - RNA_def_property_range(prop, -1000.0, 1000.0); - RNA_def_property_ui_text(prop, "Max", "Choose a number from a range: upper boundary of the range"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_RANDOM_FLOAT_NORMAL */ - prop = RNA_def_property(srna, "float_mean", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "float_arg_1"); - RNA_def_property_range(prop, -1000.0, 1000.0); - RNA_def_property_ui_text(prop, "Mean", "A normal distribution: mean of the distribution"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "standard_derivation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "float_arg_2"); - RNA_def_property_range(prop, -1000.0, 1000.0); - RNA_def_property_ui_text(prop, "SD", "A normal distribution: standard deviation of the distribution"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL */ - prop = RNA_def_property(srna, "half_life_time", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "float_arg_1"); - RNA_def_property_range(prop, -1000.0, 1000.0); - RNA_def_property_ui_text(prop, "Half-Life Time", "Negative exponential dropoff"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_message_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_body_type_items[] = { - {ACT_MESG_MESG, "TEXT", 0, "Text", ""}, - {ACT_MESG_PROP, "PROPERTY", 0, "Property", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "MessageActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Message Actuator", ""); - RNA_def_struct_sdna_from(srna, "bMessageActuator", "data"); - - prop = RNA_def_property(srna, "to_property", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "toPropName"); - RNA_def_property_ui_text(prop, "To", - "Optional, send message to objects with this name only, or empty to broadcast"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "subject", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Subject", "Optional, message subject (this is what can be filtered on)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "body_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "bodyType"); - RNA_def_property_enum_items(prop, prop_body_type_items); - RNA_def_property_ui_text(prop, "Body", "Toggle message type: either Text or a PropertyName"); - - /* ACT_MESG_MESG */ - prop = RNA_def_property(srna, "body_message", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "body"); - RNA_def_property_ui_text(prop, "Body", "Optional, message body Text"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_MESG_PROP */ - prop = RNA_def_property(srna, "body_property", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "body"); - RNA_def_property_ui_text(prop, "Prop Name", "The message body will be set by the Property Value"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_game_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { -/* {ACT_GAME_LOAD, "LOAD", 0, "Load Game", ""}, */ -/* {ACT_GAME_START, "START", 0, "Start Loaded Game", ""}, */ -/* keeping the load/start hacky for compatibility with 2.49 */ -/* ideally we could use ACT_GAME_START again and do a do_version() */ - - {ACT_GAME_LOAD, "START", 0, "Start Game From File", ""}, - {ACT_GAME_RESTART, "RESTART", 0, "Restart Game", ""}, - {ACT_GAME_QUIT, "QUIT", 0, "Quit Game", ""}, - {ACT_GAME_SAVECFG, "SAVECFG", 0, "Save bge.logic.globalDict", ""}, - {ACT_GAME_LOADCFG, "LOADCFG", 0, "Load bge.logic.globalDict", ""}, - {ACT_GAME_SCREENSHOT, "SCREENSHOT", 0, "Screenshot", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "GameActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Game Actuator", ""); - RNA_def_struct_sdna_from(srna, "bGameActuator", "data"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Game", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* ACT_GAME_LOAD */ - prop = RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); - RNA_def_property_ui_text(prop, "File", - "The file to use, depending on the mode (e.g. the blend file to load or a destination " - "for saving a screenshot) - use the \"//\" prefix for a relative path"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - /*XXX to do: an operator that calls file_browse with relative_path on and blender filtering active */ -} - -static void rna_def_visibility_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "VisibilityActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Visibility Actuator", "Actuator to set visibility and occlusion of the object"); - RNA_def_struct_sdna_from(srna, "bVisibilityActuator", "data"); - - prop = RNA_def_property(srna, "use_visible", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_VISIBILITY_INVISIBLE); - RNA_def_property_ui_text(prop, "Visible", - "Set the objects visible (initialized from the object render restriction toggle in " - "physics button)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_occlusion", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_VISIBILITY_OCCLUSION); - RNA_def_property_ui_text(prop, "Occlusion", - "Set the object to occlude objects behind it (initialized from the object type in " - "physics button)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "apply_to_children", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_VISIBILITY_RECURSIVE); - RNA_def_property_ui_text(prop, "Children", - "Set all the children of this object to the same visibility/occlusion recursively"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_twodfilter_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_2DFILTER_ENABLED, "ENABLE", 0, "Enable Filter", ""}, - {ACT_2DFILTER_DISABLED, "DISABLE", 0, "Disable Filter", ""}, - {ACT_2DFILTER_NOFILTER, "REMOVE", 0, "Remove Filter", ""}, - {ACT_2DFILTER_MOTIONBLUR, "MOTIONBLUR", 0, "Motion Blur", ""}, - {ACT_2DFILTER_BLUR, "BLUR", 0, "Blur", ""}, - {ACT_2DFILTER_SHARPEN, "SHARPEN", 0, "Sharpen", ""}, - {ACT_2DFILTER_DILATION, "DILATION", 0, "Dilation", ""}, - {ACT_2DFILTER_EROSION, "EROSION", 0, "Erosion", ""}, - {ACT_2DFILTER_LAPLACIAN, "LAPLACIAN", 0, "Laplacian", ""}, - {ACT_2DFILTER_SOBEL, "SOBEL", 0, "Sobel", ""}, - {ACT_2DFILTER_PREWITT, "PREWITT", 0, "Prewitt", ""}, - {ACT_2DFILTER_GRAYSCALE, "GRAYSCALE", 0, "Gray Scale", ""}, - {ACT_2DFILTER_SEPIA, "SEPIA", 0, "Sepia", ""}, - {ACT_2DFILTER_INVERT, "INVERT", 0, "Invert", ""}, - {ACT_2DFILTER_CUSTOMFILTER, "CUSTOMFILTER", 0, "Custom Filter", ""}, -/* {ACT_2DFILTER_NUMBER_OF_FILTERS, "", 0, "Do not use it. Sentinel", ""}, */ - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "Filter2DActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Filter 2D Actuator", "Actuator to apply screen graphic effects"); - RNA_def_struct_sdna_from(srna, "bTwoDFilterActuator", "data"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Filter 2D Type", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "glsl_shader", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "text"); - RNA_def_property_struct_type(prop, "Text"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Script", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "filter_pass", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "int_arg"); - RNA_def_property_ui_text(prop, "Pass Number", "Set filter order"); - RNA_def_property_range(prop, 0, 99); /*MAX_RENDER_PASS-1 */ - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "motion_blur_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "float_arg"); - RNA_def_property_ui_text(prop, "Value", "Motion blur factor"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* booleans */ - prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", 1); - RNA_def_property_ui_text(prop, "Enable", "Enable/Disable Motion Blur"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_parent_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_PARENT_SET, "SETPARENT", 0, "Set Parent", ""}, - {ACT_PARENT_REMOVE, "REMOVEPARENT", 0, "Remove Parent", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "ParentActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Parent Actuator", ""); - RNA_def_struct_sdna_from(srna, "bParentActuator", "data"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Scene", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_sdna(prop, NULL, "ob"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Parent Object", "Set this object as parent"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* booleans */ - prop = RNA_def_property(srna, "use_compound", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_PARENT_COMPOUND); - RNA_def_property_ui_text(prop, "Compound", - "Add this object shape to the parent shape " - "(only if the parent shape is already compound)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_ghost", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ACT_PARENT_GHOST); - RNA_def_property_ui_text(prop, "Ghost", "Make this object ghost while parented"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_state_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_STATE_SET, "SET", 0, "Set State", ""}, - {ACT_STATE_ADD, "ADD", 0, "Add State", ""}, - {ACT_STATE_REMOVE, "REMOVE", 0, "Remove State", ""}, - {ACT_STATE_CHANGE, "CHANGE", 0, "Change State", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "StateActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "State Actuator", "Actuator to handle states"); - RNA_def_struct_sdna_from(srna, "bStateActuator", "data"); - - prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Operation", "Select the bit operation on object state mask"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "states", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, NULL, "mask", 1); - RNA_def_property_array(prop, OB_MAX_STATES); - RNA_def_property_ui_text(prop, "State", ""); - RNA_def_property_boolean_funcs(prop, NULL, "rna_StateActuator_state_set"); -} - -static void rna_def_armature_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_ARM_RUN, "RUN", 0, "Run Armature", ""}, - {ACT_ARM_ENABLE, "ENABLE", 0, "Enable", ""}, - {ACT_ARM_DISABLE, "DISABLE", 0, "Disable", ""}, - {ACT_ARM_SETTARGET, "SETTARGET", 0, "Set Target", ""}, - {ACT_ARM_SETWEIGHT, "SETWEIGHT", 0, "Set Weight", ""}, - {ACT_ARM_SETINFLUENCE, "SETINFLUENCE", 0, "Set Influence", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "ArmatureActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Armature Actuator", ""); - RNA_def_struct_sdna_from(srna, "bArmatureActuator", "data"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Constraint Type", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "bone", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "posechannel"); - RNA_def_property_ui_text(prop, "Bone", "Bone on which the constraint is defined"); - RNA_def_property_update(prop, NC_LOGIC, "rna_Actuator_Armature_update"); - - prop = RNA_def_property(srna, "constraint", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "constraint"); - RNA_def_property_ui_text(prop, "Constraint", "Name of the constraint to control"); - RNA_def_property_update(prop, NC_LOGIC, "rna_Actuator_Armature_update"); - - prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Target", "Set this object as the target of the constraint"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "secondary_target", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "subtarget"); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Secondary Target", - "Set this object as the secondary target of the constraint " - "(only IK polar target at the moment)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "weight"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Weight", "Weight of this constraint"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "influence"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Influence", "Influence of this constraint"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_steering_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_STEERING_SEEK, "SEEK", 0, "Seek", ""}, - {ACT_STEERING_FLEE, "FLEE", 0, "Flee", ""}, - {ACT_STEERING_PATHFOLLOWING, "PATHFOLLOWING", 0, "Path following", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem facingaxis_items[] = { - {1, "X", 0, "X", ""}, - {2, "Y", 0, "Y", ""}, - {3, "Z", 0, "Z", ""}, - {4, "NEG_X", 0, "-X", ""}, - {5, "NEG_Y", 0, "-Y", ""}, - {6, "NEG_Z", 0, "-Z", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "SteeringActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Steering Actuator", ""); - RNA_def_struct_sdna_from(srna, "bSteeringActuator", "data"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Behavior", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "velocity"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Velocity", "Velocity magnitude"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "acceleration", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "acceleration"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Acceleration", "Max acceleration"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "turn_speed", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "turnspeed"); - RNA_def_property_range(prop, 0.0, 720.0); - RNA_def_property_ui_text(prop, "Turn Speed", "Max turn speed"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dist"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Dist", "Relax distance"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_sdna(prop, NULL, "target"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Target Object", "Target object"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "self_terminated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_SELFTERMINATED); - RNA_def_property_ui_text(prop, "Self Terminated", "Terminate when target is reached"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_visualization", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_ENABLEVISUALIZATION); - RNA_def_property_ui_text(prop, "Visualize", "Enable debug visualization for 'Path following'"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "update_period", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "updateTime"); - RNA_def_property_ui_range(prop, -1, 100000, 1, 1); - RNA_def_property_ui_text(prop, "Update period", "Path update period"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "navmesh", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_sdna(prop, NULL, "navmesh"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Navigation Mesh Object", "Navigation mesh"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_SteeringActuator_navmesh_set", NULL, NULL); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "facing", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_AUTOMATICFACING); - RNA_def_property_ui_text(prop, "Facing", "Enable automatic facing"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "facing_axis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "facingaxis"); - RNA_def_property_enum_items(prop, facingaxis_items); - RNA_def_property_ui_text(prop, "Axis", "Axis for automatic facing"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "normal_up", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_NORMALUP); - RNA_def_property_ui_text(prop, "N", "Use normal of the navmesh to set \"UP\" vector"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "lock_z_velocity", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_STEERING_LOCKZVEL); - RNA_def_property_ui_text(prop, "Lock Z velocity", "Disable simulation of linear motion along Z axis"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -static void rna_def_mouse_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_type_items[] = { - {ACT_MOUSE_VISIBILITY, "VISIBILITY", 0, "Visibility", ""}, - {ACT_MOUSE_LOOK, "LOOK", 0, "Look", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_object_axis_items[] = { - {ACT_MOUSE_OBJECT_AXIS_X, "OBJECT_AXIS_X", 0, "X Axis", ""}, - {ACT_MOUSE_OBJECT_AXIS_Y, "OBJECT_AXIS_Y", 0, "Y Axis", ""}, - {ACT_MOUSE_OBJECT_AXIS_Z, "OBJECT_AXIS_Z", 0, "Z Axis", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "MouseActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Mouse Actuator", ""); - RNA_def_struct_sdna_from(srna, "bMouseActuator", "data"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Mode", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* Visibility */ - prop = RNA_def_property(srna, "visible", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_VISIBLE); - RNA_def_property_ui_text(prop, "Visible", "Make mouse cursor visible"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* Mouse Look */ - prop = RNA_def_property(srna, "use_axis_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_USE_AXIS_X); - RNA_def_property_ui_text(prop, "Use X Axis", "Calculate mouse movement on the X axis"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_axis_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_USE_AXIS_Y); - RNA_def_property_ui_text(prop, "Use Y Axis", "Calculate mouse movement on the Y axis"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "reset_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_RESET_X); - RNA_def_property_ui_text(prop, "Reset", - "Reset the cursor's X position to the center of the screen space after calculating"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "reset_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_RESET_Y); - RNA_def_property_ui_text(prop, "Reset", - "Reset the cursor's Y position to the center of the screen space after calculating"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "local_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_LOCAL_X); - RNA_def_property_ui_text(prop, "Local", "Apply rotation locally"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "local_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_MOUSE_LOCAL_Y); - RNA_def_property_ui_text(prop, "Local", "Apply rotation locally"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "threshold_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "threshold[0]"); - RNA_def_property_ui_range(prop, 0, 0.5, 1, 3); - RNA_def_property_ui_text(prop, "Threshold", "Amount of X motion before mouse movement will register"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "threshold_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "threshold[1]"); - RNA_def_property_ui_range(prop, 0, 0.5, 1, 3); - RNA_def_property_ui_text(prop, "Threshold", "Amount of Y motion before mouse movement will register"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "object_axis_x", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "object_axis[0]"); - RNA_def_property_enum_items(prop, prop_object_axis_items); - RNA_def_property_ui_text(prop, "Object Axis", "Local object axis mouse movement in the X direction will apply to"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "object_axis_y", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "object_axis[1]"); - RNA_def_property_enum_items(prop, prop_object_axis_items); - RNA_def_property_ui_text(prop, "Object Axis", "Local object axis mouse movement in the Y direction will apply to"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "sensitivity_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sensitivity[0]"); - RNA_def_property_ui_range(prop, -100.0, 100.0, 0.2, 3); - RNA_def_property_ui_text(prop, "Sensitivity", "Sensitivity of the X axis"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "sensitivity_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sensitivity[1]"); - RNA_def_property_ui_range(prop, -100.0, 100.0, 0.2, 3); - RNA_def_property_ui_text(prop, "Sensitivity", "Sensitivity of the Y axis"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "limit_x[0]"); - RNA_def_property_ui_range(prop, DEG2RADF(-3600.0f), 0.0, 9, 3); - RNA_def_property_ui_text(prop, "Min", "Maximum negative rotation allowed by X mouse movement (0 for infinite)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "limit_x[1]"); - RNA_def_property_ui_range(prop, 0.0, DEG2RADF(3600.0f), 9, 3); - RNA_def_property_ui_text(prop, "Max", "Maximum positive rotation allowed by X mouse movement (0 for infinite)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "limit_y[0]"); - RNA_def_property_ui_range(prop, DEG2RADF(-3600.0f), 0.0, 9, 3); - RNA_def_property_ui_text(prop, "Min", "Maximum negative rotation allowed by Y mouse movement (0 for infinite)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "limit_y[1]"); - RNA_def_property_ui_range(prop, 0.0, DEG2RADF(3600.0f), 9, 3); - RNA_def_property_ui_text(prop, "Max", "Maximum positive rotation allowed by Y mouse movement (0 for infinite)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -void RNA_def_actuator(BlenderRNA *brna) -{ - rna_def_actuator(brna); - - rna_def_action_actuator(brna); - rna_def_object_actuator(brna); - rna_def_camera_actuator(brna); - rna_def_sound_actuator(brna); - rna_def_property_actuator(brna); - rna_def_constraint_actuator(brna); - rna_def_edit_object_actuator(brna); - rna_def_scene_actuator(brna); - rna_def_random_actuator(brna); - rna_def_message_actuator(brna); - rna_def_game_actuator(brna); - rna_def_visibility_actuator(brna); - rna_def_twodfilter_actuator(brna); - rna_def_parent_actuator(brna); - rna_def_state_actuator(brna); - rna_def_armature_actuator(brna); - rna_def_steering_actuator(brna); - rna_def_mouse_actuator(brna); -} - -#endif diff --git a/source/blender/makesrna/intern/rna_actuator_api.c b/source/blender/makesrna/intern/rna_actuator_api.c deleted file mode 100644 index 0047d7257cb..00000000000 --- a/source/blender/makesrna/intern/rna_actuator_api.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2010 Blender Foundation. - * All rights reserved. - * - * - * Contributor(s): - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/makesrna/intern/rna_actuator_api.c - * \ingroup RNA - */ - - -#include <stdlib.h> -#include <stdio.h> - -#include "WM_types.h" -#include "RNA_define.h" - -#include "rna_internal.h" /* own include */ - -#ifdef RNA_RUNTIME - -#include "BKE_sca.h" -#include "DNA_controller_types.h" -#include "DNA_actuator_types.h" - -static void rna_Actuator_link(bActuator *act, bController *cont) -{ - link_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks, sizeof(bActuator *)); -} - -static void rna_Actuator_unlink(bActuator *act, bController *cont) -{ - unlink_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks); -} - -#else - -void RNA_api_actuator(StructRNA *srna) -{ - FunctionRNA *func; - PropertyRNA *parm; - - func = RNA_def_function(srna, "link", "rna_Actuator_link"); - RNA_def_function_ui_description(func, "Link the actuator to a controller"); - parm = RNA_def_pointer(func, "controller", "Controller", "", "Controller to link to"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_property_update(parm, NC_LOGIC, NULL); - - func = RNA_def_function(srna, "unlink", "rna_Actuator_unlink"); - RNA_def_function_ui_description(func, "Unlink the actuator from a controller"); - parm = RNA_def_pointer(func, "controller", "Controller", "", "Controller to unlink from"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_property_update(parm, NC_LOGIC, NULL); -} - -#endif diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 6f1445d31ef..43a89df0ed0 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -73,10 +73,11 @@ const EnumPropertyItem rna_enum_keying_flag_items[] = { #include "BLI_math_base.h" #include "BKE_animsys.h" -#include "BKE_depsgraph.h" #include "BKE_fcurve.h" #include "BKE_nla.h" +#include "DEG_depsgraph.h" + #include "DNA_object_types.h" #include "WM_api.h" @@ -84,11 +85,13 @@ const EnumPropertyItem rna_enum_keying_flag_items[] = { static void rna_AnimData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { ID *id = ptr->id.data; + AnimData *adt = ptr->data; /* tag for refresh so that scheduled updates (e.g. action changed) will * get computed and reflected in the scene [#34869] */ - DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA); + adt->recalc |= ADT_RECALC_ANIM; + DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } static int rna_AnimData_action_editable(PointerRNA *ptr, const char **UNUSED(r_info)) @@ -105,17 +108,9 @@ static int rna_AnimData_action_editable(PointerRNA *ptr, const char **UNUSED(r_i static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value) { ID *ownerId = (ID *)ptr->id.data; - AnimData *adt; /* set action */ BKE_animdata_set_action(NULL, ownerId, value.data); - - /* force action to get evaluated [#34869] */ - adt = BKE_animdata_from_id(ownerId); - if (adt) { - adt->recalc |= ADT_RECALC_ANIM; - DAG_id_tag_update(ownerId, OB_RECALC_TIME); - } } static void rna_AnimData_tweakmode_set(PointerRNA *ptr, const bool value) @@ -535,7 +530,7 @@ static void rna_NlaTrack_remove(AnimData *adt, bContext *C, ReportList *reports, return; } - BKE_nlatrack_free(&adt->nla_tracks, track); + BKE_nlatrack_free(&adt->nla_tracks, track, true); RNA_POINTER_INVALIDATE(track_ptr); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL); @@ -584,6 +579,36 @@ static FCurve *rna_Driver_find(AnimData *adt, ReportList *reports, const char *d return list_find_fcurve(&adt->drivers, data_path, index); } +bool rna_AnimaData_override_apply( + Main *UNUSED(bmain), + PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, + PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *UNUSED(prop_storage), + const int len_dst, const int len_src, const int len_storage, + PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage), + IDOverrideStaticPropertyOperation *opop) +{ + BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0); + BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_REPLACE && "Unsupported RNA override operation on animdata pointer"); + UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop); + + /* AnimData is a special case, since you cannot edit/replace it, it's either existent or not. */ + AnimData *adt_dst = RNA_property_pointer_get(ptr_dst, prop_dst).data; + AnimData *adt_src = RNA_property_pointer_get(ptr_src, prop_src).data; + + if (adt_dst == NULL && adt_src != NULL) { + /* Copy anim data from reference into final local ID. */ + BKE_animdata_copy_id(NULL, ptr_dst->id.data, ptr_src->id.data, 0); + return true; + } + else if (adt_dst != NULL && adt_src == NULL) { + /* Override has cleared/removed anim data from its reference. */ + BKE_animdata_free(ptr_dst->id.data, true); + return true; + } + + return false; +} + #else /* helper function for Keying Set -> keying settings */ @@ -998,6 +1023,8 @@ void rna_def_animdata_common(StructRNA *srna) prop = RNA_def_property(srna, "animation_data", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "adt"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_override_funcs(prop, NULL, NULL, "rna_AnimaData_override_apply"); RNA_def_property_ui_text(prop, "Animation Data", "Animation data for this data-block"); } @@ -1022,6 +1049,7 @@ static void rna_def_animdata(BlenderRNA *brna) prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); /* this flag as well as the dynamic test must be defined for this to be editable... */ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_pointer_funcs(prop, NULL, "rna_AnimData_action_set", NULL, "rna_Action_id_poll"); RNA_def_property_editable_func(prop, "rna_AnimData_action_editable"); RNA_def_property_ui_text(prop, "Action", "Active Action for this data-block"); @@ -1033,14 +1061,14 @@ static void rna_def_animdata(BlenderRNA *brna) RNA_def_property_enum_items(prop, rna_enum_nla_mode_extend_items); RNA_def_property_ui_text(prop, "Action Extrapolation", "Action to take for gaps past the Active Action's range (when evaluating with NLA)"); - RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); + RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, "rna_AnimData_update"); prop = RNA_def_property(srna, "action_blend_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "act_blendmode"); RNA_def_property_enum_items(prop, rna_enum_nla_mode_blend_items); RNA_def_property_ui_text(prop, "Action Blending", "Method used for combining Active Action's result with result of NLA stack"); - RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */ + RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, "rna_AnimData_update"); /* this will do? */ prop = RNA_def_property(srna, "action_influence", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "act_influence"); @@ -1048,12 +1076,13 @@ static void rna_def_animdata(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Action Influence", "Amount the Active Action contributes to the result of the NLA stack"); - RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */ + RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, "rna_AnimData_update"); /* this will do? */ /* Drivers */ prop = RNA_def_property(srna, "drivers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "drivers", NULL); RNA_def_property_struct_type(prop, "FCurve"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Drivers", "The Drivers/Expressions for this data-block"); rna_api_animdata_drivers(brna, prop); diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 6c728ac50e5..ea39b1f46eb 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -43,8 +43,8 @@ #ifdef RNA_RUNTIME +#include "BKE_action.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_main.h" @@ -52,15 +52,27 @@ #include "ED_armature.h" #include "BKE_armature.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + static void rna_Armature_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { ID *id = ptr->id.data; - DAG_id_tag_update(id, 0); + DEG_id_tag_update(id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, id); /*WM_main_add_notifier(NC_OBJECT|ND_POSE, NULL); */ } +static void rna_Armature_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + ID *id = ptr->id.data; + + DEG_relations_tag_update(bmain); + + DEG_id_tag_update(id, 0); + WM_main_add_notifier(NC_GEOM | ND_DATA, id); +} static void rna_Armature_act_bone_set(PointerRNA *ptr, PointerRNA value) { @@ -140,6 +152,7 @@ static void rna_Armature_update_layers(Main *bmain, Scene *UNUSED(scene), Pointe ob->pose->proxy_layer = arm->layer; } + DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); WM_main_add_notifier(NC_GEOM | ND_DATA, arm); } @@ -147,6 +160,7 @@ static void rna_Armature_redraw_data(Main *UNUSED(bmain), Scene *UNUSED(scene), { ID *id = ptr->id.data; + DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE); WM_main_add_notifier(NC_GEOM | ND_DATA, id); } @@ -166,24 +180,30 @@ static void rna_Bone_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po { ID *id = ptr->id.data; - /* special updates for cases where rigs try to hook into armature drawing stuff - * e.g. Mask Modifier - 'Armature' option + /* 1) special updates for cases where rigs try to hook into armature drawing stuff + * e.g. Mask Modifier - 'Armature' option + * 2) tag armature for copy-on-write, so that selection status (set by addons) + * will update properly, like standard tools do already */ if (id) { if (GS(id->name) == ID_AR) { bArmature *arm = (bArmature *)id; if (arm->flag & ARM_HAS_VIZ_DEPS) { - DAG_id_tag_update(id, OB_RECALC_DATA); + DEG_id_tag_update(id, OB_RECALC_DATA); } + + DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE); } else if (GS(id->name) == ID_OB) { Object *ob = (Object *)id; bArmature *arm = (bArmature *)ob->data; if (arm->flag & ARM_HAS_VIZ_DEPS) { - DAG_id_tag_update(id, OB_RECALC_DATA); + DEG_id_tag_update(id, OB_RECALC_DATA); } + + DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE); } } @@ -238,6 +258,18 @@ static IDProperty *rna_EditBone_idprops(PointerRNA *ptr, bool create) return ebone->prop; } +/* Update the layers_used variable after bones are moved between layer + * NOTE: Used to be done in drawing code in 2.7, but that won't work with + * Copy-on-Write, as drawing uses evaluated copies. + */ +static void rna_Armature_layer_used_refresh(bArmature *arm, ListBase *bones) +{ + for (Bone *bone = bones->first; bone; bone = bone->next) { + arm->layer_used |= bone->layer; + rna_Armature_layer_used_refresh(arm, &bone->childbase); + } +} + static void rna_bone_layer_set(int *layer, const bool *values) { int i, tot = 0; @@ -258,8 +290,13 @@ static void rna_bone_layer_set(int *layer, const bool *values) static void rna_Bone_layer_set(PointerRNA *ptr, const bool *values) { + bArmature *arm = (bArmature *)ptr->id.data; Bone *bone = (Bone *)ptr->data; + rna_bone_layer_set(&bone->layer, values); + + arm->layer_used = 0; + rna_Armature_layer_used_refresh(arm, &arm->bonebase); } static void rna_Armature_layer_set(PointerRNA *ptr, const bool *values) @@ -413,6 +450,82 @@ static void rna_EditBone_matrix_set(PointerRNA *ptr, const float *values) ED_armature_ebone_from_mat4(ebone, (float(*)[4])values); } +static void rna_Bone_bbone_handle_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bArmature *arm = (bArmature *)ptr->id.data; + Bone *bone = (Bone *)ptr->data; + + /* Update all users of this armature after changing B-Bone handles. */ + for (Object *obt = bmain->object.first; obt; obt = obt->id.next) { + if (obt->data == arm && obt->pose) { + bPoseChannel *pchan = BKE_pose_channel_find_name(obt->pose, bone->name); + + if (pchan && pchan->bone == bone) { + BKE_pchan_rebuild_bbone_handles(obt->pose, pchan); + DEG_id_tag_update(&obt->id, DEG_TAG_COPY_ON_WRITE); + } + } + } + + rna_Armature_dependency_update(bmain, scene, ptr); +} + +static PointerRNA rna_EditBone_bbone_prev_get(PointerRNA *ptr) +{ + EditBone *data = (EditBone *)(ptr->data); + return rna_pointer_inherit_refine(ptr, &RNA_EditBone, data->bbone_prev); +} + +static void rna_EditBone_bbone_prev_set(PointerRNA *ptr, PointerRNA value) +{ + EditBone *ebone = (EditBone *)(ptr->data); + EditBone *hbone = (EditBone *)value.data; + + /* Within the same armature? */ + if (hbone == NULL || value.id.data == ptr->id.data) { + ebone->bbone_prev = hbone; + } +} + +static void rna_Bone_bbone_prev_set(PointerRNA *ptr, PointerRNA value) +{ + Bone *bone = (Bone *)ptr->data; + Bone *hbone = (Bone *)value.data; + + /* Within the same armature? */ + if (hbone == NULL || value.id.data == ptr->id.data) { + bone->bbone_prev = hbone; + } +} + +static PointerRNA rna_EditBone_bbone_next_get(PointerRNA *ptr) +{ + EditBone *data = (EditBone *)(ptr->data); + return rna_pointer_inherit_refine(ptr, &RNA_EditBone, data->bbone_next); +} + +static void rna_EditBone_bbone_next_set(PointerRNA *ptr, PointerRNA value) +{ + EditBone *ebone = (EditBone *)(ptr->data); + EditBone *hbone = (EditBone *)value.data; + + /* Within the same armature? */ + if (hbone == NULL || value.id.data == ptr->id.data) { + ebone->bbone_next = hbone; + } +} + +static void rna_Bone_bbone_next_set(PointerRNA *ptr, PointerRNA value) +{ + Bone *bone = (Bone *)ptr->data; + Bone *hbone = (Bone *)value.data; + + /* Within the same armature? */ + if (hbone == NULL || value.id.data == ptr->id.data) { + bone->bbone_next = hbone; + } +} + static void rna_Armature_editbone_transform_update(Main *bmain, Scene *scene, PointerRNA *ptr) { bArmature *arm = (bArmature *)ptr->id.data; @@ -581,6 +694,14 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone) static void rna_def_bone_common(StructRNA *srna, int editbone) { + static const EnumPropertyItem prop_bbone_handle_type[] = { + {BBONE_HANDLE_AUTO, "AUTO", 0, "Automatic", "Use connected parent and children to compute the handle"}, + {BBONE_HANDLE_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Use the position of the specified bone to compute the handle"}, + {BBONE_HANDLE_RELATIVE, "RELATIVE", 0, "Relative", "Use the offset of the specified bone from rest pose to compute the handle"}, + {BBONE_HANDLE_TANGENT, "TANGENT", 0, "Tangent", "Use the orientation of the specified bone to compute the handle, ignoring the location"}, + {0, NULL, 0, NULL, NULL} + }; + PropertyRNA *prop; /* strings */ @@ -641,7 +762,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_DRAWWIRE); - RNA_def_property_ui_text(prop, "Draw Wire", + RNA_def_property_ui_text(prop, "Display Wire", "Bone is always drawn as Wireframe regardless of viewport draw mode " "(useful for non-obstructive custom bone shapes)"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); @@ -696,7 +817,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) RNA_def_property_int_sdna(prop, NULL, "segments"); RNA_def_property_range(prop, 1, 32); RNA_def_property_ui_text(prop, "B-Bone Segments", "Number of subdivisions of bone (for B-Bones only)"); - RNA_def_property_update(prop, 0, "rna_Armature_update_data"); + RNA_def_property_update(prop, 0, "rna_Armature_dependency_update"); prop = RNA_def_property(srna, "bbone_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xwidth"); @@ -709,6 +830,50 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_ui_text(prop, "B-Bone Display Z Width", "B-Bone Z size"); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); + + prop = RNA_def_property(srna, "bbone_handle_type_start", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "bbone_prev_type"); + RNA_def_property_enum_items(prop, prop_bbone_handle_type); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "B-Bone Start Handle Type", "Selects how the start handle of the B-Bone is computed"); + RNA_def_property_update(prop, 0, "rna_Armature_dependency_update"); + + prop = RNA_def_property(srna, "bbone_custom_handle_start", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "bbone_prev"); + RNA_def_property_struct_type(prop, editbone ? "EditBone" : "Bone"); + if (editbone) { + RNA_def_property_pointer_funcs(prop, "rna_EditBone_bbone_prev_get", "rna_EditBone_bbone_prev_set", NULL, NULL); + RNA_def_property_update(prop, 0, "rna_Armature_dependency_update"); + } + else { + RNA_def_property_pointer_funcs(prop, NULL, "rna_Bone_bbone_prev_set", NULL, NULL); + RNA_def_property_update(prop, 0, "rna_Bone_bbone_handle_update"); + } + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_PTR_NO_OWNERSHIP); + RNA_def_property_ui_text(prop, "B-Bone Start Handle", + "Bone that serves as the start handle for the B-Bone curve"); + + prop = RNA_def_property(srna, "bbone_handle_type_end", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "bbone_next_type"); + RNA_def_property_enum_items(prop, prop_bbone_handle_type); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "B-Bone End Handle Type", "Selects how the end handle of the B-Bone is computed"); + RNA_def_property_update(prop, 0, "rna_Armature_dependency_update"); + + prop = RNA_def_property(srna, "bbone_custom_handle_end", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "bbone_next"); + RNA_def_property_struct_type(prop, editbone ? "EditBone" : "Bone"); + if (editbone) { + RNA_def_property_pointer_funcs(prop, "rna_EditBone_bbone_next_get", "rna_EditBone_bbone_next_set", NULL, NULL); + RNA_def_property_update(prop, 0, "rna_Armature_dependency_update"); + } + else { + RNA_def_property_pointer_funcs(prop, NULL, "rna_Bone_bbone_next_set", NULL, NULL); + RNA_def_property_update(prop, 0, "rna_Bone_bbone_handle_update"); + } + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_PTR_NO_OWNERSHIP); + RNA_def_property_ui_text(prop, "B-Bone End Handle", + "Bone that serves as the end handle for the B-Bone curve"); } /* err... bones should not be directly edited (only editbones should be...) */ @@ -728,6 +893,7 @@ static void rna_def_bone(BlenderRNA *brna) prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Bone"); RNA_def_property_pointer_sdna(prop, NULL, "parent"); + RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP); RNA_def_property_ui_text(prop, "Parent", "Parent bone (in same Armature)"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); @@ -735,6 +901,7 @@ static void rna_def_bone(BlenderRNA *brna) prop = RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "childbase", NULL); RNA_def_property_struct_type(prop, "Bone"); + RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP); RNA_def_property_ui_text(prop, "Children", "Bones which are children of this bone"); rna_def_bone_common(srna, 0); @@ -989,11 +1156,6 @@ static void rna_def_armature(BlenderRNA *brna) {ARM_WIRE, "WIRE", 0, "Wire", "Display bones as thin wires, showing subdivision and B-Splines"}, {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem prop_vdeformer[] = { - {ARM_VDEF_BLENDER, "BLENDER", 0, "Blender", "Use Blender's armature vertex deformation"}, - {ARM_VDEF_BGE_CPU, "BGE_CPU", 0, "BGE", "Use vertex deformation code optimized for the BGE"}, - {0, NULL, 0, NULL, NULL} - }; static const EnumPropertyItem prop_ghost_type_items[] = { {ARM_GHOST_CUR, "CURRENT_FRAME", 0, "Around Frame", "Display Ghosts of poses within a fixed number of frames around the current frame"}, @@ -1044,17 +1206,10 @@ static void rna_def_armature(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Armature_update_data"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); - 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, "drawtype"); RNA_def_property_enum_items(prop, prop_drawtype_items); - RNA_def_property_ui_text(prop, "Draw Type", ""); - RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); - - prop = RNA_def_property(srna, "deform_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "gevertdeformer"); - RNA_def_property_enum_items(prop, prop_vdeformer); - RNA_def_property_ui_text(prop, "Vertex Deformer", "Vertex Deformer Method (Game Engine only)"); + RNA_def_property_ui_text(prop, "Display Type Type", ""); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); @@ -1089,13 +1244,13 @@ static void rna_def_armature(BlenderRNA *brna) /* flag */ prop = RNA_def_property(srna, "show_axes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWAXES); - RNA_def_property_ui_text(prop, "Draw Axes", "Draw bone axes"); + RNA_def_property_ui_text(prop, "Display Axes", "Display bone axes"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); prop = RNA_def_property(srna, "show_names", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWNAMES); - RNA_def_property_ui_text(prop, "Draw Names", "Draw bone names"); + RNA_def_property_ui_text(prop, "Display Names", "Display bone names"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); @@ -1118,18 +1273,18 @@ static void rna_def_armature(BlenderRNA *brna) prop = RNA_def_property(srna, "show_bone_custom_shapes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ARM_NO_CUSTOM); - RNA_def_property_ui_text(prop, "Draw Custom Bone Shapes", "Draw bones with their custom shapes"); + RNA_def_property_ui_text(prop, "Display Custom Bone Shapes", "Display bones with their custom shapes"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_COL_CUSTOM); - RNA_def_property_ui_text(prop, "Draw Bone Group Colors", "Draw bone group colors"); + RNA_def_property_ui_text(prop, "Display Bone Group Colors", "Display bone group colors"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); /* XXX deprecated ....... old animviz for armatures only */ prop = RNA_def_property(srna, "show_only_ghost_selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_GHOST_ONLYSEL); - RNA_def_property_ui_text(prop, "Draw Ghosts on Selected Bones Only", ""); + RNA_def_property_ui_text(prop, "Display Ghosts on Selected Bones Only", ""); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); /* XXX deprecated ....... old animviz for armatures only */ diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c index 8b0623a867c..413cb10422a 100644 --- a/source/blender/makesrna/intern/rna_boid.c +++ b/source/blender/makesrna/intern/rna_boid.c @@ -87,9 +87,11 @@ static const EnumPropertyItem boidruleset_type_items[] = { #include "BLI_math_base.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_particle.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + static void rna_Boids_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { if (ptr->type == &RNA_ParticleSystem) { @@ -97,10 +99,10 @@ static void rna_Boids_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN psys->recalc = PSYS_RECALC_RESET; - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); } else - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA | PSYS_RECALC_RESET); + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA | PSYS_RECALC_RESET); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); } @@ -111,12 +113,12 @@ static void rna_Boids_reset_deps(Main *bmain, Scene *UNUSED(scene), PointerRNA * psys->recalc = PSYS_RECALC_RESET; - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); } else - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA | PSYS_RECALC_RESET); + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA | PSYS_RECALC_RESET); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); } diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index dfc93581e6a..150ad998dea 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -31,6 +31,8 @@ #include "DNA_texture_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" +#include "DNA_workspace_types.h" +#include "DNA_gpencil_types.h" #include "BLI_math.h" @@ -44,8 +46,8 @@ #include "WM_types.h" static const EnumPropertyItem prop_direction_items[] = { - {0, "ADD", 0, "Add", "Add effect of brush"}, - {BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"}, + {0, "ADD", ICON_ADD, "Add", "Add effect of brush"}, + {BRUSH_DIR_IN, "SUBTRACT", ICON_REMOVE, "Subtract", "Subtract effect of brush"}, {0, NULL, 0, NULL, NULL} }; @@ -85,30 +87,19 @@ const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = { {0, NULL, 0, NULL, NULL} }; - const EnumPropertyItem rna_enum_brush_vertex_tool_items[] = { - {PAINT_BLEND_MIX, "MIX", ICON_BRUSH_MIX, "Mix", "Use mix blending mode while painting"}, - {PAINT_BLEND_ADD, "ADD", ICON_BRUSH_ADD, "Add", "Use add blending mode while painting"}, - {PAINT_BLEND_SUB, "SUB", ICON_BRUSH_SUBTRACT, "Subtract", "Use subtract blending mode while painting"}, - {PAINT_BLEND_MUL, "MUL", ICON_BRUSH_MULTIPLY, "Multiply", "Use multiply blending mode while painting"}, - {PAINT_BLEND_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"}, - {PAINT_BLEND_LIGHTEN, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"}, - {PAINT_BLEND_DARKEN, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"}, - {PAINT_BLEND_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", "Use average blending mode while painting"}, - {PAINT_BLEND_SMEAR, "SMEAR", ICON_BRUSH_BLUR, "Smear", "Use smear blending mode while painting"}, - {PAINT_BLEND_COLORDODGE, "COLORDODGE", ICON_BRUSH_BLUR, "Color Dodge", "Use color dodge blending mode while painting" }, - {PAINT_BLEND_DIFFERENCE, "DIFFERENCE", ICON_BRUSH_BLUR, "Difference", "Use difference blending mode while painting"}, - {PAINT_BLEND_SCREEN, "SCREEN", ICON_BRUSH_BLUR, "Screen", "Use screen blending mode while painting"}, - {PAINT_BLEND_HARDLIGHT, "HARDLIGHT", ICON_BRUSH_BLUR, "Hardlight", "Use hardlight blending mode while painting"}, - {PAINT_BLEND_OVERLAY, "OVERLAY", ICON_BRUSH_BLUR, "Overlay", "Use overlay blending mode while painting"}, - {PAINT_BLEND_SOFTLIGHT, "SOFTLIGHT", ICON_BRUSH_BLUR, "Softlight", "Use softlight blending mode while painting"}, - {PAINT_BLEND_EXCLUSION, "EXCLUSION", ICON_BRUSH_BLUR, "Exclusion", "Use exclusion blending mode while painting"}, - {PAINT_BLEND_LUMINOCITY, "LUMINOCITY", ICON_BRUSH_BLUR, "Luminocity", "Use luminocity blending mode while painting"}, - {PAINT_BLEND_SATURATION, "SATURATION", ICON_BRUSH_BLUR, "Saturation", "Use saturation blending mode while painting"}, - {PAINT_BLEND_HUE, "HUE", ICON_BRUSH_BLUR, "Hue", "Use hue blending mode while painting"}, - {PAINT_BLEND_ALPHA_SUB, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting"}, - {PAINT_BLEND_ALPHA_ADD, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"}, + {VPAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_MIX, "Draw", ""}, + {VPAINT_TOOL_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", ""}, + {VPAINT_TOOL_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", ""}, + {VPAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_BLUR, "Smear", ""}, + {0, NULL, 0, NULL, NULL} +}; +const EnumPropertyItem rna_enum_brush_weight_tool_items[] = { + {WPAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_MIX, "Draw", ""}, + {WPAINT_TOOL_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", ""}, + {WPAINT_TOOL_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", ""}, + {WPAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_BLUR, "Smear", ""}, {0, NULL, 0, NULL, NULL} }; @@ -122,6 +113,44 @@ const EnumPropertyItem rna_enum_brush_image_tool_items[] = { {0, NULL, 0, NULL, NULL} }; +const EnumPropertyItem rna_enum_brush_gpencil_types_items[] = { + {GPAINT_TOOL_DRAW, "DRAW", ICON_GP_STROKE, "Draw", "The brush is of type used for drawing strokes"}, + {GPAINT_TOOL_FILL, "FILL", ICON_COLOR, "Fill", "The brush is of type used for filling areas"}, + {GPAINT_TOOL_ERASE, "ERASE", ICON_PANEL_CLOSE, "Erase", "The brush is used for erasing strokes"}, + {0, NULL, 0, NULL, NULL} +}; + +#ifndef RNA_RUNTIME +static EnumPropertyItem rna_enum_gpencil_brush_eraser_modes_items[] = { + { GP_BRUSH_ERASER_SOFT, "SOFT", 0, "Soft", "Use soft eraser" }, + { GP_BRUSH_ERASER_HARD, "HARD", 0, "Hard", "Use hard eraser" }, + { GP_BRUSH_ERASER_STROKE, "STROKE", 0, "Stroke", "Use stroke eraser" }, + { 0, NULL, 0, NULL, NULL } +}; + +static EnumPropertyItem rna_enum_gpencil_fill_draw_modes_items[] = { + { GP_FILL_DMODE_STROKE, "STROKE", 0, "Strokes", "Use visible strokes as fill boundary limits" }, + { GP_FILL_DMODE_CONTROL, "CONTROL", 0, "Control", "Use internal control lines as fill boundary limits" }, + { GP_FILL_DMODE_BOTH, "BOTH", 0, "Both", "Use visible strokes and control lines as fill boundary limits" }, + { 0, NULL, 0, NULL, NULL } +}; + +static EnumPropertyItem rna_enum_gpencil_brush_icons_items[] = { + { GP_BRUSH_ICON_PENCIL, "PENCIL", ICON_GPBRUSH_PENCIL, "Pencil", "" }, + { GP_BRUSH_ICON_PEN, "PEN", ICON_GPBRUSH_PEN, "Pen", "" }, + { GP_BRUSH_ICON_INK, "INK", ICON_GPBRUSH_INK, "Ink", "" }, + { GP_BRUSH_ICON_INKNOISE, "INKNOISE", ICON_GPBRUSH_INKNOISE, "Ink Noise", "" }, + { GP_BRUSH_ICON_BLOCK, "BLOCK", ICON_GPBRUSH_BLOCK, "Block", "" }, + { GP_BRUSH_ICON_MARKER, "MARKER", ICON_GPBRUSH_MARKER, "Marker", "" }, + { GP_BRUSH_ICON_FILL, "FILL", ICON_GPBRUSH_FILL, "Fill", "" }, + { GP_BRUSH_ICON_ERASE_SOFT, "SOFT", ICON_GPBRUSH_ERASE_SOFT, "Eraser Soft", "" }, + { GP_BRUSH_ICON_ERASE_HARD, "HARD", ICON_GPBRUSH_ERASE_HARD, "Eraser Hard", "" }, + { GP_BRUSH_ICON_ERASE_STROKE, "STROKE", ICON_GPBRUSH_ERASE_STROKE, "Eraser Stroke", "" }, + { 0, NULL, 0, NULL, NULL } +}; +#endif + + #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" @@ -131,6 +160,7 @@ const EnumPropertyItem rna_enum_brush_image_tool_items[] = { #include "BKE_colorband.h" #include "BKE_brush.h" #include "BKE_icons.h" +#include "BKE_gpencil.h" #include "BKE_paint.h" #include "WM_api.h" @@ -349,7 +379,7 @@ static PointerRNA rna_Brush_capabilities_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_BrushCapabilities, ptr->id.data); } -static void rna_Brush_reset_icon(Brush *br, const char *UNUSED(type)) +static void rna_Brush_reset_icon(Brush *br) { ID *id = &br->id; @@ -371,44 +401,61 @@ static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR /*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */ } -static void rna_Brush_main_tex_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Brush_material_update(bContext *C, PointerRNA *ptr) { - Brush *br = (Brush *)ptr->data; - BKE_paint_invalidate_overlay_tex(scene, br->mtex.tex); - rna_Brush_update(bmain, scene, ptr); -} + Main *bmain = CTX_data_main(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); + Brush *br = (Brush *)ptr->id.data; + int index; + + /* set material slot to same material */ + if ((ob) && (ob->type == OB_GPENCIL) && (br->gpencil_settings != NULL)) { + BrushGpencilSettings *gpencil_settings = br->gpencil_settings; + if (gpencil_settings->material != NULL) { + + index = BKE_gpencil_get_material_index(ob, gpencil_settings->material); + if ((index > 0) && (ob->actcol != index)) { + ob->actcol = index; + /* update other brushes to keep all synchro */ + BKE_brush_update_material(bmain, gpencil_settings->material, br); + } -static void rna_Brush_secondary_tex_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - Brush *br = (Brush *)ptr->data; - BKE_paint_invalidate_overlay_tex(scene, br->mask_mtex.tex); - rna_Brush_update(bmain, scene, ptr); + } + WM_main_add_notifier(NC_SPACE | ND_SPACE_PROPERTIES, NULL); + } } -static void rna_Brush_size_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Brush_main_tex_update(bContext *C, PointerRNA *ptr) { - BKE_paint_invalidate_overlay_all(); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Brush *br = (Brush *)ptr->data; + BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mtex.tex); rna_Brush_update(bmain, scene, ptr); } -static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Brush_secondary_tex_update(bContext *C, PointerRNA *ptr) { + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); Brush *br = (Brush *)ptr->data; - rna_Brush_reset_icon(br, "sculpt"); + BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mask_mtex.tex); rna_Brush_update(bmain, scene, ptr); } -static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Brush_size_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Brush *br = (Brush *)ptr->data; - rna_Brush_reset_icon(br, "vertex_paint"); + BKE_paint_invalidate_overlay_all(); rna_Brush_update(bmain, scene, ptr); } -static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Brush_update_and_reset_icon(Main *bmain, Scene *scene, PointerRNA *ptr) { - Brush *br = (Brush *)ptr->data; - rna_Brush_reset_icon(br, "image_paint"); + Brush *br = ptr->data; + rna_Brush_reset_icon(br); rna_Brush_update(bmain, scene, ptr); } @@ -436,14 +483,17 @@ static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); } -static void rna_TextureSlot_brush_angle_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_TextureSlot_brush_angle_update(bContext *C, PointerRNA *ptr) { + Scene *scene = CTX_data_scene(C); MTex *mtex = ptr->data; /* skip invalidation of overlay for stencil mode */ - if (mtex->mapping != MTEX_MAP_MODE_STENCIL) - BKE_paint_invalidate_overlay_tex(scene, mtex->tex); + if (mtex->mapping != MTEX_MAP_MODE_STENCIL) { + ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex); + } - rna_TextureSlot_update(bmain, scene, ptr); + rna_TextureSlot_update(C, ptr); } static void rna_Brush_set_size(PointerRNA *ptr, int value) @@ -487,39 +537,39 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA /* sculpt mode */ static const EnumPropertyItem prop_flatten_contrast_items[] = { - {0, "FLATTEN", 0, "Flatten", "Add effect of brush"}, - {BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"}, + {BRUSH_DIR_IN, "CONTRAST", ICON_ADD, "Contrast", "Subtract effect of brush"}, + {0, "FLATTEN", ICON_REMOVE, "Flatten", "Add effect of brush"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem prop_fill_deepen_items[] = { - {0, "FILL", 0, "Fill", "Add effect of brush"}, - {BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of brush"}, + {0, "FILL", ICON_ADD, "Fill", "Add effect of brush"}, + {BRUSH_DIR_IN, "DEEPEN", ICON_REMOVE, "Deepen", "Subtract effect of brush"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem prop_scrape_peaks_items[] = { - {0, "SCRAPE", 0, "Scrape", "Add effect of brush"}, - {BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"}, + {0, "SCRAPE", ICON_ADD, "Scrape", "Add effect of brush"}, + {BRUSH_DIR_IN, "PEAKS", ICON_REMOVE, "Peaks", "Subtract effect of brush"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem prop_pinch_magnify_items[] = { - {0, "PINCH", 0, "Pinch", "Add effect of brush"}, - {BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"}, + {BRUSH_DIR_IN, "MAGNIFY", ICON_ADD, "Magnify", "Subtract effect of brush"}, + {0, "PINCH", ICON_REMOVE, "Pinch", "Add effect of brush"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem prop_inflate_deflate_items[] = { - {0, "INFLATE", 0, "Inflate", "Add effect of brush"}, - {BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"}, + {0, "INFLATE", ICON_ADD, "Inflate", "Add effect of brush"}, + {BRUSH_DIR_IN, "DEFLATE", ICON_REMOVE, "Deflate", "Subtract effect of brush"}, {0, NULL, 0, NULL, NULL} }; /* texture paint mode */ static const EnumPropertyItem prop_soften_sharpen_items[] = { - {0, "SOFTEN", 0, "Soften", "Blur effect of brush"}, - {BRUSH_DIR_IN, "SHARPEN", 0, "Sharpen", "Sharpen effect of brush"}, + {BRUSH_DIR_IN, "SHARPEN", ICON_ADD, "Sharpen", "Sharpen effect of brush"}, + {0, "SOFTEN", ICON_REMOVE, "Soften", "Blur effect of brush"}, {0, NULL, 0, NULL, NULL} }; @@ -606,6 +656,63 @@ static const EnumPropertyItem *rna_Brush_stroke_itemf(bContext *C, PointerRNA *U return brush_stroke_method_items; } } + +/* Grease Pencil Drawing Brushes Settings */ +static char *rna_BrushGpencilSettings_path(PointerRNA *UNUSED(ptr)) +{ + return BLI_strdup("tool_settings.gpencil_paint.brush.gpencil_settings"); +} + +static void rna_BrushGpencilSettings_default_eraser_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) +{ + ToolSettings *ts = scene->toolsettings; + Paint *paint = &ts->gp_paint->paint; + Brush *brush_cur = paint->brush; + + /* disable default eraser in all brushes */ + for (Brush *brush = bmain->brush.first; brush; brush = brush->id.next) { + if ((brush != brush_cur) && + (brush->ob_mode == OB_MODE_GPENCIL_PAINT) && + (brush->gpencil_tool == GPAINT_TOOL_ERASE)) + { + brush->gpencil_settings->flag &= ~GP_BRUSH_DEFAULT_ERASER; + } + } +} + +static void rna_BrushGpencilSettings_eraser_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +{ + ToolSettings *ts = scene->toolsettings; + Paint *paint = &ts->gp_paint->paint; + Brush *brush = paint->brush; + + /* set eraser icon */ + if ((brush) && (brush->gpencil_tool == GPAINT_TOOL_ERASE)) { + switch (brush->gpencil_settings->eraser_mode) { + case GP_BRUSH_ERASER_SOFT: + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_SOFT; + break; + case GP_BRUSH_ERASER_HARD: + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_HARD; + break; + case GP_BRUSH_ERASER_STROKE: + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_STROKE; + break; + default: + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_SOFT; + break; + } + } +} + +static bool rna_BrushGpencilSettings_material_poll(PointerRNA *UNUSED(ptr), PointerRNA value) +{ + Material *ma = (Material *)value.data; + + /* GP materials only */ + return (ma->gp_style != NULL); +} + #else static void rna_def_brush_texture_slot(BlenderRNA *brna) @@ -657,39 +764,46 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "rot"); RNA_def_property_range(prop, 0, M_PI * 2); RNA_def_property_ui_text(prop, "Angle", "Brush texture rotation"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_angle_update"); prop = RNA_def_property(srna, "map_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); RNA_def_property_enum_items(prop, prop_map_mode_items); RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "tex_paint_map_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); RNA_def_property_enum_items(prop, prop_tex_paint_map_mode_items); RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "mask_map_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); RNA_def_property_enum_items(prop, prop_mask_paint_map_mode_items); RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "use_rake", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "brush_angle_mode", MTEX_ANGLE_RAKE); RNA_def_property_ui_text(prop, "Rake", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "use_random", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "brush_angle_mode", MTEX_ANGLE_RANDOM); RNA_def_property_ui_text(prop, "Random", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "random_angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_range(prop, 0, M_PI * 2); RNA_def_property_ui_text(prop, "Random Angle", "Brush texture random angle"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); TEXTURE_CAPABILITY(has_texture_angle_source, "Has Texture Angle Source"); @@ -793,6 +907,325 @@ static void rna_def_image_paint_capabilities(BlenderRNA *brna) #undef IMAPAINT_TOOL_CAPABILITY } +static void rna_def_gpencil_options(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "BrushGpencilSettings", NULL); + RNA_def_struct_sdna(srna, "BrushGpencilSettings"); + RNA_def_struct_path_func(srna, "rna_BrushGpencilSettings_path"); + RNA_def_struct_ui_text(srna, "Grease Pencil Brush Settings", "Settings for grease pencil brush"); + + /* Sensitivity factor for new strokes */ + prop = RNA_def_property(srna, "pen_sensitivity_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "draw_sensitivity"); + RNA_def_property_range(prop, 0.1f, 3.0f); + RNA_def_property_ui_text(prop, "Sensitivity", "Pressure sensitivity factor for new strokes"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Strength factor for new strokes */ + prop = RNA_def_property(srna, "pen_strength", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "draw_strength"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3); + RNA_def_property_ui_text(prop, "Strength", "Color strength for new strokes (affect alpha factor of color)"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Jitter factor for new strokes */ + prop = RNA_def_property(srna, "pen_jitter", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "draw_jitter"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Jitter", "Jitter factor for new strokes"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Randomnes factor for pressure */ + prop = RNA_def_property(srna, "random_pressure", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "draw_random_press"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Pressure Randomness", "Randomness factor for pressure in new strokes"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Randomnes factor for strength */ + prop = RNA_def_property(srna, "random_strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "draw_random_strength"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Strength Randomness", "Randomness factor strength in new strokes"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Randomnes factor for subdivision */ + prop = RNA_def_property(srna, "random_subdiv", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "draw_random_sub"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Random Subdivision", "Randomness factor for new strokes after subdivision"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Angle when brush is full size */ + prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "draw_angle"); + RNA_def_property_range(prop, -M_PI_2, M_PI_2); + RNA_def_property_ui_text(prop, "Angle", + "Direction of the stroke at which brush gives maximal thickness " + "(0° for horizontal)"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Factor to change brush size depending of angle */ + prop = RNA_def_property(srna, "angle_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "draw_angle_factor"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Angle Factor", + "Reduce brush thickness by this factor when stroke is perpendicular to 'Angle' direction"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Smoothing factor for new strokes */ + prop = RNA_def_property(srna, "pen_smooth_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "draw_smoothfac"); + RNA_def_property_range(prop, 0.0, 2.0f); + RNA_def_property_ui_text(prop, "Smooth", + "Amount of smoothing to apply after finish newly created strokes, to reduce jitter/noise"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Iterations of the Smoothing factor */ + prop = RNA_def_property(srna, "pen_smooth_steps", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "draw_smoothlvl"); + RNA_def_property_range(prop, 1, 3); + RNA_def_property_ui_text(prop, "Iterations", + "Number of times to smooth newly created strokes"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Thickness smoothing factor for new strokes */ + prop = RNA_def_property(srna, "pen_thick_smooth_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "thick_smoothfac"); + RNA_def_property_range(prop, 0.0, 2.0f); + RNA_def_property_ui_text(prop, "Smooth Thickness", + "Amount of thickness smoothing to apply after finish newly created strokes, to reduce jitter/noise"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Thickness iterations of the Smoothing factor */ + prop = RNA_def_property(srna, "pen_thick_smooth_steps", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "thick_smoothlvl"); + RNA_def_property_range(prop, 1, 3); + RNA_def_property_ui_text(prop, "Iterations Thickness", + "Number of times to smooth thickness for newly created strokes"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Subdivision level for new strokes */ + prop = RNA_def_property(srna, "pen_subdivision_steps", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "draw_subdivide"); + RNA_def_property_range(prop, 0, 3); + RNA_def_property_ui_text(prop, "Subdivision Steps", + "Number of times to subdivide newly created strokes, for less jagged strokes"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Curves for pressure */ + prop = RNA_def_property(srna, "curve_sensitivity", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "curve_sensitivity"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Curve Sensitivity", "Curve used for the sensitivity"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + prop = RNA_def_property(srna, "curve_strength", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "curve_strength"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Curve Strength", "Curve used for the strength"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + prop = RNA_def_property(srna, "curve_jitter", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "curve_jitter"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Curve Jitter", "Curve used for the jitter effect"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* fill threshold for transparence */ + prop = RNA_def_property(srna, "fill_threshold", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fill_threshold"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Threshold", + "Threshold to consider color transparent for filling"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* fill leak size */ + prop = RNA_def_property(srna, "fill_leak", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "fill_leak"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Leak Size", + "Size in pixels to consider the leak closed"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* fill simplify steps */ + prop = RNA_def_property(srna, "fill_simplify_level", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "fill_simplylvl"); + RNA_def_property_range(prop, 0, 10); + RNA_def_property_ui_text(prop, "Simplify", + "Number of simplify steps (large values reduce fill accuracy)"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + prop = RNA_def_property(srna, "uv_random", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "uv_random"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "UV Random", "Random factor for autogenerated UV rotation"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + prop = RNA_def_property(srna, "input_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "input_samples"); + RNA_def_property_range(prop, 0, GP_MAX_INPUT_SAMPLES); + RNA_def_property_ui_text(prop, "Input Samples", "Generate intermediate points for very fast mouse movements. Set to 0 to disable"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* active smooth factor while drawing */ + prop = RNA_def_property(srna, "active_smooth_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "active_smooth"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Active Smooth", + "Amount of smoothing while drawing "); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + prop = RNA_def_property(srna, "eraser_strength_factor", PROP_FLOAT, PROP_PERCENTAGE); + RNA_def_property_float_sdna(prop, NULL, "era_strength_f"); + RNA_def_property_range(prop, 0.0, 100.0); + RNA_def_property_ui_range(prop, 0.0, 100.0, 10, 1); + RNA_def_property_ui_text(prop, "Affect Stroke Strength", + "Amount of erasing for strength "); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + prop = RNA_def_property(srna, "eraser_thickness_factor", PROP_FLOAT, PROP_PERCENTAGE); + RNA_def_property_float_sdna(prop, NULL, "era_thickness_f"); + RNA_def_property_range(prop, 0.0, 100.0); + RNA_def_property_ui_range(prop, 0.0, 100.0, 10, 1); + RNA_def_property_ui_text(prop, "Affect Stroke Thickness", + "Amount of erasing for thickness "); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* brush standard icon */ + prop = RNA_def_property(srna, "gp_icon", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "icon_id"); + RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_icons_items); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_ui_text(prop, "Grease Pencil Icon", ""); + + /* Flags */ + prop = RNA_def_property(srna, "use_pressure", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_PRESSURE); + RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); + RNA_def_property_ui_text(prop, "Use Pressure", "Use tablet pressure"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + prop = RNA_def_property(srna, "use_strength_pressure", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_STENGTH_PRESSURE); + RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); + RNA_def_property_ui_text(prop, "Use Pressure Strength", "Use tablet pressure for color strength"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + prop = RNA_def_property(srna, "use_jitter_pressure", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_JITTER_PRESSURE); + RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); + RNA_def_property_ui_text(prop, "Use Pressure Jitter", "Use tablet pressure for jitter"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + prop = RNA_def_property(srna, "use_settings_stabilizer", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_STABILIZE_MOUSE); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_ui_text(prop, "Use Stabilizer", + "Draw lines with a delay to allow smooth strokes. Press Shift key to override while drawing"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "use_cursor", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_ENABLE_CURSOR); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_ui_text(prop, "Enable Cursor", "Enable cursor on screen"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "eraser_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "eraser_mode"); + RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_eraser_modes_items); + RNA_def_property_ui_text(prop, "Mode", "Eraser Mode"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_BrushGpencilSettings_eraser_mode_update"); + + prop = RNA_def_property(srna, "fill_draw_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "fill_draw_mode"); + RNA_def_property_enum_items(prop, rna_enum_gpencil_fill_draw_modes_items); + RNA_def_property_ui_text(prop, "Mode", "Mode to draw boundary limits"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + /* Material */ + prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Material"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_BrushGpencilSettings_material_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK | PROP_CONTEXT_UPDATE); + RNA_def_property_ui_text(prop, "Material", "Material used for strokes drawn using this brush"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_Brush_material_update"); + + prop = RNA_def_property(srna, "show_fill_boundary", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_FILL_SHOW_HELPLINES); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_ui_text(prop, "Show Lines", "Show help lines for filling to see boundaries"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "show_fill", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_BRUSH_FILL_HIDE); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_ui_text(prop, "Show Fill", "Show transparent lines to use as boundary for filling"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "use_default_eraser", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_DEFAULT_ERASER); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); + RNA_def_property_ui_text(prop, "Default Eraser", "Use this brush when enable eraser with fast switch key"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_BrushGpencilSettings_default_eraser_update"); + + prop = RNA_def_property(srna, "use_settings_postprocess", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_GROUP_SETTINGS); + RNA_def_property_ui_text(prop, "Use Post-Process Settings", "Additional post processing options for new strokes"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "use_settings_random", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_GROUP_RANDOM); + RNA_def_property_ui_text(prop, "Random Settings", "Random brush settings"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "use_material_pin", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_MATERIAL_PINNED); + RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); + RNA_def_property_ui_text(prop, "Pin Material", "Keep material assigned to brush"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "show_lasso", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_BRUSH_DISSABLE_LASSO); + RNA_def_property_ui_text(prop, "Show Lasso", "Do not draw fill color while drawing the stroke"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); +} + static void rna_def_brush(BlenderRNA *brna) { StructRNA *srna; @@ -800,29 +1233,35 @@ static void rna_def_brush(BlenderRNA *brna) static const EnumPropertyItem prop_blend_items[] = { {IMB_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting"}, - {IMB_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting"}, - {IMB_BLEND_SUB, "SUB", 0, "Subtract", "Use subtract blending mode while painting"}, - {IMB_BLEND_MUL, "MUL", 0, "Multiply", "Use multiply blending mode while painting"}, - {IMB_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting"}, + {0, "", ICON_NONE, NULL, NULL}, {IMB_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting"}, - {IMB_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting"}, - {IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"}, - {IMB_BLEND_OVERLAY, "OVERLAY", 0, "Overlay", "Use overlay blending mode while painting"}, - {IMB_BLEND_HARDLIGHT, "HARDLIGHT", 0, "Hard light", "Use hard light blending mode while painting"}, + {IMB_BLEND_MUL, "MUL", 0, "Multiply", "Use multiply blending mode while painting"}, {IMB_BLEND_COLORBURN, "COLORBURN", 0, "Color burn", "Use color burn blending mode while painting"}, {IMB_BLEND_LINEARBURN, "LINEARBURN", 0, "Linear burn", "Use linear burn blending mode while painting"}, - {IMB_BLEND_COLORDODGE, "COLORDODGE", 0, "Color dodge", "Use color dodge blending mode while painting"}, + {0, "", ICON_NONE, NULL, NULL}, + {IMB_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting"}, {IMB_BLEND_SCREEN, "SCREEN", 0, "Screen", "Use screen blending mode while painting"}, + {IMB_BLEND_COLORDODGE, "COLORDODGE", 0, "Color dodge", "Use color dodge blending mode while painting"}, + {IMB_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting"}, + {0, "", ICON_NONE, NULL, NULL}, + {IMB_BLEND_OVERLAY, "OVERLAY", 0, "Overlay", "Use overlay blending mode while painting"}, {IMB_BLEND_SOFTLIGHT, "SOFTLIGHT", 0, "Soft light", "Use softlight blending mode while painting"}, - {IMB_BLEND_PINLIGHT, "PINLIGHT", 0, "Pin light", "Use pinlight blending mode while painting"}, + {IMB_BLEND_HARDLIGHT, "HARDLIGHT", 0, "Hard light", "Use hard light blending mode while painting"}, {IMB_BLEND_VIVIDLIGHT, "VIVIDLIGHT", 0, "Vivid light", "Use vividlight blending mode while painting"}, {IMB_BLEND_LINEARLIGHT, "LINEARLIGHT", 0, "Linear light", "Use linearlight blending mode while painting"}, + {IMB_BLEND_PINLIGHT, "PINLIGHT", 0, "Pin light", "Use pinlight blending mode while painting"}, + {0, "", ICON_NONE, NULL, NULL}, {IMB_BLEND_DIFFERENCE, "DIFFERENCE", 0, "Difference", "Use difference blending mode while painting"}, {IMB_BLEND_EXCLUSION, "EXCLUSION", 0, "Exclusion", "Use exclusion blending mode while painting"}, + {IMB_BLEND_SUB, "SUB", 0, "Subtract", "Use subtract blending mode while painting"}, + {0, "", ICON_NONE, NULL, NULL}, {IMB_BLEND_HUE, "HUE", 0, "Hue", "Use hue blending mode while painting"}, {IMB_BLEND_SATURATION, "SATURATION", 0, "Saturation", "Use saturation blending mode while painting"}, - {IMB_BLEND_LUMINOSITY, "LUMINOSITY", 0, "Luminosity", "Use luminosity blending mode while painting"}, {IMB_BLEND_COLOR, "COLOR", 0, "Color", "Use color blending mode while painting"}, + {IMB_BLEND_LUMINOSITY, "LUMINOSITY", 0, "Luminosity", "Use luminosity blending mode while painting"}, + {0, "", ICON_NONE, NULL, NULL}, + {IMB_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting"}, + {IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"}, {0, NULL, 0, NULL, NULL} }; @@ -877,22 +1316,42 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + + /** + * Begin per-mode tool properties. + * + * keep in sync with #BKE_paint_get_tool_prop_id_from_paintmode + */ prop = RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, rna_enum_brush_sculpt_tool_items); RNA_def_property_ui_text(prop, "Sculpt Tool", ""); - RNA_def_property_update(prop, 0, "rna_Brush_sculpt_tool_update"); + RNA_def_property_update(prop, 0, "rna_Brush_update_and_reset_icon"); prop = RNA_def_property(srna, "vertex_tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "vertexpaint_tool"); RNA_def_property_enum_items(prop, rna_enum_brush_vertex_tool_items); - RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode"); - RNA_def_property_update(prop, 0, "rna_Brush_vertex_tool_update"); + RNA_def_property_ui_text(prop, "Vertex Paint Tool", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update_and_reset_icon"); + + prop = RNA_def_property(srna, "weight_tool", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "weightpaint_tool"); + RNA_def_property_enum_items(prop, rna_enum_brush_weight_tool_items); + RNA_def_property_ui_text(prop, "Weight Paint Tool", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update_and_reset_icon"); prop = RNA_def_property(srna, "image_tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "imagepaint_tool"); RNA_def_property_enum_items(prop, rna_enum_brush_image_tool_items); RNA_def_property_ui_text(prop, "Image Paint Tool", ""); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_update_and_reset_icon"); + + prop = RNA_def_property(srna, "gpencil_tool", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "gpencil_tool"); + RNA_def_property_enum_items(prop, rna_enum_brush_gpencil_types_items); + RNA_def_property_ui_text(prop, "Type", "Category of the brush"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + /** End per mode tool properties. */ + prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); @@ -1357,6 +1816,10 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_TEXTURE_PAINT); RNA_def_property_ui_text(prop, "Use Texture", "Use this brush in texture paint mode"); + prop = RNA_def_property(srna, "use_paint_grease_pencil", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_GPENCIL_PAINT); + RNA_def_property_ui_text(prop, "Use Sculpt", "Use this brush in grease pencil drawing mode"); + /* texture */ prop = RNA_def_property(srna, "texture_slot", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "BrushTextureSlot"); @@ -1366,7 +1829,7 @@ static void rna_def_brush(BlenderRNA *brna) prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "mtex.tex"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Texture", ""); RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_main_tex_update"); @@ -1378,7 +1841,7 @@ static void rna_def_brush(BlenderRNA *brna) prop = RNA_def_property(srna, "mask_texture", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "mask_mtex.tex"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Mask Texture", ""); RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_secondary_tex_update"); @@ -1459,6 +1922,13 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ImapaintToolCapabilities"); RNA_def_property_pointer_funcs(prop, "rna_Imapaint_tool_capabilities_get", NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Image Painting Capabilities", "Brush's capabilities in image paint mode"); + + prop = RNA_def_property(srna, "gpencil_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "BrushGpencilSettings"); + RNA_def_property_pointer_sdna(prop, NULL, "gpencil_settings"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Gpencil Settings", ""); + } /** @@ -1527,6 +1997,7 @@ void RNA_def_brush(BlenderRNA *brna) rna_def_brush_capabilities(brna); rna_def_sculpt_capabilities(brna); rna_def_image_paint_capabilities(brna); + rna_def_gpencil_options(brna); rna_def_brush_texture_slot(brna); rna_def_operator_stroke_element(brna); } diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c index 73928d377f1..dd76e2409db 100644 --- a/source/blender/makesrna/intern/rna_cachefile.c +++ b/source/blender/makesrna/intern/rna_cachefile.c @@ -23,6 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/makesrna/intern/rna_cachefile.c + * \ingroup RNA + */ + #include "DNA_cachefile_types.h" #include "DNA_scene_types.h" @@ -37,7 +41,6 @@ #include "BLI_string.h" #include "BKE_cachefile.h" -#include "BKE_depsgraph.h" #include "DEG_depsgraph.h" @@ -52,7 +55,7 @@ static void rna_CacheFile_update(Main *bmain, Scene *scene, PointerRNA *ptr) { CacheFile *cache_file = (CacheFile *)ptr->data; - DAG_id_tag_update(&cache_file->id, 0); + DEG_id_tag_update(&cache_file->id, 0); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); UNUSED_VARS(bmain, scene); @@ -63,7 +66,7 @@ static void rna_CacheFile_update_handle(Main *bmain, Scene *scene, PointerRNA *p CacheFile *cache_file = ptr->data; if ((cache_file->flag & CACHEFILE_DIRTY) != 0) { - BKE_cachefile_clean(scene, cache_file); + BKE_cachefile_clean(bmain, cache_file); BLI_freelistN(&cache_file->object_paths); cache_file->flag &= ~CACHEFILE_DIRTY; } diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 981ae75e7c5..60c68bc7214 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -30,20 +30,22 @@ #include "BLI_math.h" +#include "RNA_access.h" #include "RNA_define.h" #include "rna_internal.h" +#include "WM_api.h" #include "WM_types.h" #ifdef RNA_RUNTIME #include "BKE_camera.h" -#include "BKE_depsgraph.h" #include "BKE_object.h" #include "BKE_sequencer.h" -#include "WM_api.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" static float rna_Camera_angle_get(PointerRNA *ptr) { @@ -87,14 +89,43 @@ static void rna_Camera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointer { Camera *camera = (Camera *)ptr->id.data; - DAG_id_tag_update(&camera->id, 0); + DEG_id_tag_update(&camera->id, 0); } static void rna_Camera_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Camera *camera = (Camera *)ptr->id.data; - DAG_relations_tag_update(bmain); - DAG_id_tag_update(&camera->id, 0); + DEG_relations_tag_update(bmain); + DEG_id_tag_update(&camera->id, 0); +} + +static CameraBGImage *rna_Camera_background_images_new(Camera *cam) +{ + CameraBGImage *bgpic = BKE_camera_background_image_new(cam); + + WM_main_add_notifier(NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, cam); + + return bgpic; +} + +static void rna_Camera_background_images_remove(Camera *cam, ReportList *reports, PointerRNA *bgpic_ptr) +{ + CameraBGImage *bgpic = bgpic_ptr->data; + if (BLI_findindex(&cam->bg_images, bgpic) == -1) { + BKE_report(reports, RPT_ERROR, "Background image cannot be removed"); + } + + BKE_camera_background_image_remove(cam, bgpic); + RNA_POINTER_INVALIDATE(bgpic_ptr); + + WM_main_add_notifier(NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, cam); +} + +static void rna_Camera_background_images_clear(Camera *cam) +{ + BKE_camera_background_image_clear(cam); + + WM_main_add_notifier(NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, cam); } static void rna_Camera_dof_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) @@ -107,6 +138,161 @@ static void rna_Camera_dof_update(Main *UNUSED(bmain), Scene *scene, PointerRNA #else +static void rna_def_camera_background_image(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static const EnumPropertyItem bgpic_source_items[] = { + {CAM_BGIMG_SOURCE_IMAGE, "IMAGE", 0, "Image", ""}, + {CAM_BGIMG_SOURCE_MOVIE, "MOVIE_CLIP", 0, "Movie Clip", ""}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem bgpic_camera_frame_items[] = { + {0, "STRETCH", 0, "Stretch", ""}, + {CAM_BGIMG_FLAG_CAMERA_ASPECT, "FIT", 0, "Fit", ""}, + {CAM_BGIMG_FLAG_CAMERA_ASPECT | CAM_BGIMG_FLAG_CAMERA_CROP, "CROP", 0, "Crop", ""}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem bgpic_display_depth_items[] = { + {0, "BACK", 0, "Back", ""}, + {CAM_BGIMG_FLAG_FOREGROUND, "FRONT", 0, "Front", ""}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "CameraBackgroundImage", NULL); + RNA_def_struct_sdna(srna, "CameraBGImage"); + RNA_def_struct_ui_text(srna, "Background Image", "Image and settings for display in the 3D View background"); + + prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "source"); + RNA_def_property_enum_items(prop, bgpic_source_items); + RNA_def_property_ui_text(prop, "Background Source", "Data source used for background"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "ima"); + RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "clip"); + RNA_def_property_ui_text(prop, "MovieClip", "Movie clip displayed and edited in this space"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "iuser"); + RNA_def_property_ui_text(prop, "Image User", + "Parameters defining which layer, pass and frame of the image is displayed"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "clip_user", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "MovieClipUser"); + RNA_def_property_pointer_sdna(prop, NULL, "cuser"); + RNA_def_property_ui_text(prop, "Clip User", "Parameters defining which frame of the movie clip is displayed"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "offset"); + RNA_def_property_ui_text(prop, "Offset", ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "scale"); + RNA_def_property_ui_text(prop, "Scale", "Scale the background image"); + RNA_def_property_range(prop, 0.0, FLT_MAX); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "rotation"); + RNA_def_property_ui_text(prop, "Rotation", "Rotation for the background image (ortho view only)"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "use_flip_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_BGIMG_FLAG_FLIP_X); + RNA_def_property_ui_text(prop, "Flip Horizontally", "Flip the background image horizontally"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "use_flip_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_BGIMG_FLAG_FLIP_Y); + RNA_def_property_ui_text(prop, "Flip Vertically", "Flip the background image vertically"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "alpha"); + RNA_def_property_ui_text(prop, "Alpha", "Image opacity to blend the image against the background color"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_BGIMG_FLAG_EXPANDED); + RNA_def_property_ui_text(prop, "Show Expanded", "Show the expanded in the user interface"); + RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); + + prop = RNA_def_property(srna, "use_camera_clip", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_BGIMG_FLAG_CAMERACLIP); + RNA_def_property_ui_text(prop, "Camera Clip", "Use movie clip from active scene camera"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_background_image", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CAM_BGIMG_FLAG_DISABLED); + RNA_def_property_ui_text(prop, "Show Background Image", "Show this image as background"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_on_foreground", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_BGIMG_FLAG_FOREGROUND); + RNA_def_property_ui_text(prop, "Show On Foreground", "Show this image in front of objects in viewport"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + /* expose 1 flag as a enum of 2 items */ + prop = RNA_def_property(srna, "display_depth", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, bgpic_display_depth_items); + RNA_def_property_ui_text(prop, "Depth", "Display under or over everything"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + /* expose 2 flags as a enum of 3 items */ + prop = RNA_def_property(srna, "frame_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, bgpic_camera_frame_items); + RNA_def_property_ui_text(prop, "Frame Method", "How the image fits in the camera frame"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); +} + + +static void rna_def_camera_background_images(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "CameraBackgroundImages"); + srna = RNA_def_struct(brna, "CameraBackgroundImages", NULL); + RNA_def_struct_sdna(srna, "Camera"); + RNA_def_struct_ui_text(srna, "Background Images", "Collection of background images"); + + func = RNA_def_function(srna, "new", "rna_Camera_background_images_new"); + RNA_def_function_ui_description(func, "Add new background image"); + parm = RNA_def_pointer(func, "image", "CameraBackgroundImage", "", "Image displayed as viewport background"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Camera_background_images_remove"); + RNA_def_function_ui_description(func, "Remove background image"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "image", "CameraBackgroundImage", "", "Image displayed as viewport background"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + + func = RNA_def_function(srna, "clear", "rna_Camera_background_images_clear"); + RNA_def_function_ui_description(func, "Remove all background images"); +} + static void rna_def_camera_stereo_data(BlenderRNA *brna) { StructRNA *srna; @@ -192,7 +378,7 @@ void RNA_def_camera(BlenderRNA *brna) {CAM_PANO, "PANO", 0, "Panoramic", ""}, {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem prop_draw_type_extra_items[] = { + static const EnumPropertyItem prop_display_type_extra_items[] = { {CAM_DTX_CENTER, "CENTER", 0, "Center", ""}, {CAM_DTX_CENTER_DIAG, "CENTER_DIAGONAL", 0, "Center Diagonal", ""}, {CAM_DTX_THIRDS, "THIRDS", 0, "Thirds", ""}, @@ -227,9 +413,9 @@ void RNA_def_camera(BlenderRNA *brna) prop = RNA_def_property(srna, "show_guide", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dtx"); - RNA_def_property_enum_items(prop, prop_draw_type_extra_items); + RNA_def_property_enum_items(prop, prop_display_type_extra_items); RNA_def_property_flag(prop, PROP_ENUM_FLAG); - RNA_def_property_ui_text(prop, "Composition Guides", "Draw overlay"); + RNA_def_property_ui_text(prop, "Composition Guides", "Display overlay"); RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL); prop = RNA_def_property(srna, "sensor_fit", PROP_ENUM, PROP_NONE); @@ -242,6 +428,7 @@ void RNA_def_camera(BlenderRNA *brna) prop = RNA_def_property(srna, "passepartout_alpha", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "passepartalpha"); + RNA_def_property_float_default(prop, 0.5f); RNA_def_property_ui_text(prop, "Passepartout Alpha", "Opacity (alpha) of the darkened overlay in Camera view"); RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL); @@ -268,6 +455,7 @@ void RNA_def_camera(BlenderRNA *brna) prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipsta"); + RNA_def_property_float_default(prop, 0.1f); RNA_def_property_range(prop, 1e-6f, FLT_MAX); RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3); RNA_def_property_ui_text(prop, "Clip Start", "Camera near clipping distance"); @@ -275,6 +463,7 @@ void RNA_def_camera(BlenderRNA *brna) prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipend"); + RNA_def_property_float_default(prop, 1000.0f); RNA_def_property_range(prop, 1e-6f, FLT_MAX); RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3); RNA_def_property_ui_text(prop, "Clip End", "Camera far clipping distance"); @@ -282,6 +471,7 @@ void RNA_def_camera(BlenderRNA *brna) prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_DISTANCE_CAMERA); RNA_def_property_float_sdna(prop, NULL, "lens"); + RNA_def_property_float_default(prop, 50.0f); RNA_def_property_range(prop, 1.0f, FLT_MAX); RNA_def_property_ui_range(prop, 1.0f, 5000.0f, 1, 2); RNA_def_property_ui_text(prop, "Focal Length", "Perspective Camera lens value in millimeters"); @@ -289,6 +479,7 @@ void RNA_def_camera(BlenderRNA *brna) prop = RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_DISTANCE_CAMERA); RNA_def_property_float_sdna(prop, NULL, "sensor_x"); + RNA_def_property_float_default(prop, 36.0f); RNA_def_property_range(prop, 1.0f, FLT_MAX); RNA_def_property_ui_range(prop, 1.0f, 100.f, 1, 2); RNA_def_property_ui_text(prop, "Sensor Width", "Horizontal size of the image sensor area in millimeters"); @@ -296,6 +487,7 @@ void RNA_def_camera(BlenderRNA *brna) prop = RNA_def_property(srna, "sensor_height", PROP_FLOAT, PROP_DISTANCE_CAMERA); RNA_def_property_float_sdna(prop, NULL, "sensor_y"); + RNA_def_property_float_default(prop, 34.0f); RNA_def_property_range(prop, 1.0f, FLT_MAX); RNA_def_property_ui_range(prop, 1.0f, 100.f, 1, 2); RNA_def_property_ui_text(prop, "Sensor Height", "Vertical size of the image sensor area in millimeters"); @@ -303,16 +495,18 @@ void RNA_def_camera(BlenderRNA *brna) prop = RNA_def_property(srna, "ortho_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ortho_scale"); + RNA_def_property_float_default(prop, 6.0f); RNA_def_property_range(prop, FLT_MIN, FLT_MAX); RNA_def_property_ui_range(prop, 0.001f, 10000.0f, 10, 3); RNA_def_property_ui_text(prop, "Orthographic Scale", "Orthographic Camera scale (similar to zoom)"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update"); - prop = RNA_def_property(srna, "draw_size", PROP_FLOAT, PROP_DISTANCE); + prop = RNA_def_property(srna, "display_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "drawsize"); + RNA_def_property_float_default(prop, 1.0f); RNA_def_property_range(prop, 0.01f, 1000.0f); RNA_def_property_ui_range(prop, 0.01, 100, 1, 2); - RNA_def_property_ui_text(prop, "Draw Size", "Apparent size of the Camera object in the 3D View"); + RNA_def_property_ui_text(prop, "Display Size", "Apparent size of the Camera object in the 3D View"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "shift_x", PROP_FLOAT, PROP_NONE); @@ -346,16 +540,17 @@ void RNA_def_camera(BlenderRNA *brna) /* flag */ prop = RNA_def_property(srna, "show_limits", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOWLIMITS); - RNA_def_property_ui_text(prop, "Show Limits", "Draw the clipping range and focus point on the camera"); + RNA_def_property_ui_text(prop, "Show Limits", "Display the clipping range and focus point on the camera"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "show_mist", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOWMIST); - RNA_def_property_ui_text(prop, "Show Mist", "Draw a line from the Camera to indicate the mist area"); + RNA_def_property_ui_text(prop, "Show Mist", "Display a line from the Camera to indicate the mist area"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "show_passepartout", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOWPASSEPARTOUT); + RNA_def_property_boolean_default(prop, true); RNA_def_property_ui_text(prop, "Show Passepartout", "Show a darkened overlay outside the image area in Camera view"); RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL); @@ -381,6 +576,12 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Sensor Size", "Show sensor size (film gate) in Camera view"); RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL); + prop = RNA_def_property(srna, "show_background_images", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOW_BG_IMAGE); + RNA_def_property_ui_text(prop, "Display Background Images", + "Display reference images behind objects in the 3D View"); + RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL); + prop = RNA_def_property(srna, "lens_unit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, prop_lens_unit_items); @@ -399,8 +600,17 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_ui_text(prop, "GPU Depth Of Field", ""); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + prop = RNA_def_property(srna, "background_images", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "bg_images", NULL); + RNA_def_property_struct_type(prop, "CameraBackgroundImage"); + RNA_def_property_ui_text(prop, "Background Images", "List of background images"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + rna_def_animdata_common(srna); + rna_def_camera_background_image(brna); + rna_def_camera_background_images(brna, prop); + /* Nested Data */ RNA_define_animate_sdna(true); diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index ef2241e269b..c178f0b7389 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -31,6 +31,8 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_math_base.h" + #include "RNA_define.h" #include "rna_internal.h" @@ -46,19 +48,20 @@ #ifdef RNA_RUNTIME #include "BKE_context.h" -#include "BKE_depsgraph.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" static void rna_cloth_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } static void rna_cloth_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); rna_cloth_update(bmain, scene, ptr); } @@ -70,7 +73,7 @@ static void rna_cloth_pinning_changed(Main *UNUSED(bmain), Scene *UNUSED(scene), cloth_free_modifier(clmd); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } @@ -96,26 +99,70 @@ static void rna_ClothSettings_max_bend_set(struct PointerRNA *ptr, float value) settings->max_bend = value; } -static void rna_ClothSettings_structural_set(struct PointerRNA *ptr, float value) +static void rna_ClothSettings_tension_set(struct PointerRNA *ptr, float value) +{ + ClothSimSettings *settings = (ClothSimSettings *)ptr->data; + + settings->tension = value; + + /* check for max clipping */ + if (value > settings->max_tension) + settings->max_tension = value; +} + +static void rna_ClothSettings_max_tension_set(struct PointerRNA *ptr, float value) +{ + ClothSimSettings *settings = (ClothSimSettings *)ptr->data; + + /* check for clipping */ + if (value < settings->tension) + value = settings->tension; + + settings->max_tension = value; +} + +static void rna_ClothSettings_compression_set(struct PointerRNA *ptr, float value) +{ + ClothSimSettings *settings = (ClothSimSettings *)ptr->data; + + settings->compression = value; + + /* check for max clipping */ + if (value > settings->max_compression) + settings->max_compression = value; +} + +static void rna_ClothSettings_max_compression_set(struct PointerRNA *ptr, float value) +{ + ClothSimSettings *settings = (ClothSimSettings *)ptr->data; + + /* check for clipping */ + if (value < settings->compression) + value = settings->compression; + + settings->max_compression = value; +} + +static void rna_ClothSettings_shear_set(struct PointerRNA *ptr, float value) { ClothSimSettings *settings = (ClothSimSettings *)ptr->data; - settings->structural = value; + settings->shear = value; /* check for max clipping */ - if (value > settings->max_struct) - settings->max_struct = value; + if (value > settings->max_shear) + settings->max_shear = value; } -static void rna_ClothSettings_max_struct_set(struct PointerRNA *ptr, float value) +static void rna_ClothSettings_max_shear_set(struct PointerRNA *ptr, float value) { ClothSimSettings *settings = (ClothSimSettings *)ptr->data; /* check for clipping */ - if (value < settings->structural) - value = settings->structural; + if (value < settings->shear) + value = settings->shear; - settings->max_struct = value; + settings->max_shear = value; } static void rna_ClothSettings_max_sewing_set(struct PointerRNA *ptr, float value) @@ -129,6 +176,28 @@ static void rna_ClothSettings_max_sewing_set(struct PointerRNA *ptr, float value settings->max_sewing = value; } +static void rna_ClothSettings_shrink_min_set(struct PointerRNA *ptr, float value) +{ + ClothSimSettings *settings = (ClothSimSettings *)ptr->data; + + settings->shrink_min = value; + + /* check for max clipping */ + if (value > settings->shrink_max) + settings->shrink_max = value; +} + +static void rna_ClothSettings_shrink_max_set(struct PointerRNA *ptr, float value) +{ + ClothSimSettings *settings = (ClothSimSettings *)ptr->data; + + /* check for clipping */ + if (value < settings->shrink_min) + value = settings->shrink_min; + + settings->shrink_max = value; +} + static void rna_ClothSettings_mass_vgroup_get(PointerRNA *ptr, char *value) { ClothSimSettings *sim = (ClothSimSettings *)ptr->data; @@ -183,6 +252,24 @@ static void rna_ClothSettings_struct_vgroup_set(PointerRNA *ptr, const char *val rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_struct); } +static void rna_ClothSettings_shear_vgroup_get(PointerRNA *ptr, char *value) +{ + ClothSimSettings *sim = (ClothSimSettings *)ptr->data; + rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_shear); +} + +static int rna_ClothSettings_shear_vgroup_length(PointerRNA *ptr) +{ + ClothSimSettings *sim = (ClothSimSettings *)ptr->data; + return rna_object_vgroup_name_index_length(ptr, sim->vgroup_shear); +} + +static void rna_ClothSettings_shear_vgroup_set(PointerRNA *ptr, const char *value) +{ + ClothSimSettings *sim = (ClothSimSettings *)ptr->data; + rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_shear); +} + static void rna_ClothSettings_bend_vgroup_get(PointerRNA *ptr, char *value) { ClothSimSettings *sim = (ClothSimSettings *)ptr->data; @@ -349,6 +436,12 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static const EnumPropertyItem prop_bending_model_items[] = { + {CLOTH_BENDING_ANGULAR, "ANGULAR", 0, "Angular", "Cloth model with angular bending springs"}, + {CLOTH_BENDING_LINEAR, "LINEAR", 0, "Linear", "Cloth model with linear bending springs (legacy)"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "ClothSettings", NULL); RNA_def_struct_ui_text(srna, "Cloth Settings", "Cloth simulation settings for an object"); RNA_def_struct_sdna(srna, "ClothSimSettings"); @@ -441,20 +534,6 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Air Damping", "Air has normally some thickness which slows falling things down"); RNA_def_property_update(prop, 0, "rna_cloth_update"); - prop = RNA_def_property(srna, "vel_damping", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "vel_damping"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Velocity Damping", - "Damp velocity to help cloth reach the resting position faster " - "(1.0 = no damping, 0.0 = fully dampened)"); - RNA_def_property_update(prop, 0, "rna_cloth_update"); - - prop = RNA_def_property(srna, "use_pin_cloth", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_GOAL); - RNA_def_property_ui_text(prop, "Pin Cloth", "Enable pinning of cloth vertices to other objects/positions"); - RNA_def_property_update(prop, 0, "rna_cloth_pinning_changed"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - prop = RNA_def_property(srna, "pin_stiffness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "goalspring"); RNA_def_property_range(prop, 0.0f, 50.0); @@ -485,12 +564,14 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "shrink_min", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shrink_min"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Shrink Factor Min", "Min amount to shrink cloth by"); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shrink_min_set", NULL); + RNA_def_property_ui_text(prop, "Shrink Factor", "Factor by which to shrink cloth"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "shrink_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shrink_max"); RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shrink_max_set", NULL); RNA_def_property_ui_text(prop, "Shrink Factor Max", "Max amount to shrink cloth by"); RNA_def_property_update(prop, 0, "rna_cloth_update"); @@ -502,33 +583,64 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_cloth_update"); /* springs */ + prop = RNA_def_property(srna, "tension_damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "tension_damp"); + RNA_def_property_range(prop, 0.0f, 50.0f); + RNA_def_property_ui_text(prop, "Tension Spring Damping", "Amount of damping in stretching behavior"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); - prop = RNA_def_property(srna, "use_stiffness_scale", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_SCALING); - RNA_def_property_ui_text(prop, "Stiffness Scaling", - "If enabled, stiffness can be scaled along a weight painted vertex group"); + prop = RNA_def_property(srna, "compression_damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "compression_damp"); + RNA_def_property_range(prop, 0.0f, 50.0f); + RNA_def_property_ui_text(prop, "Compression Spring Damping", "Amount of damping in compression behavior"); RNA_def_property_update(prop, 0, "rna_cloth_update"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - prop = RNA_def_property(srna, "spring_damping", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "Cdis"); + prop = RNA_def_property(srna, "shear_damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "shear_damp"); RNA_def_property_range(prop, 0.0f, 50.0f); - RNA_def_property_ui_text(prop, "Spring Damping", - "Damping of cloth velocity (higher = more smooth, less jiggling)"); + RNA_def_property_ui_text(prop, "Shear Spring Damping", "Amount of damping in shearing behavior"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); + + prop = RNA_def_property(srna, "tension_stiffness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "tension"); + RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_tension_set", NULL); + RNA_def_property_ui_text(prop, "Tension Stiffness", "How much the material resists stretching"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); + + prop = RNA_def_property(srna, "tension_stiffness_max", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "max_tension"); + RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_tension_set", NULL); + RNA_def_property_ui_text(prop, "Tension Stiffness Maximum", "Maximum tension stiffness value"); RNA_def_property_update(prop, 0, "rna_cloth_update"); - prop = RNA_def_property(srna, "structural_stiffness", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "structural"); + prop = RNA_def_property(srna, "compression_stiffness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "compression"); RNA_def_property_range(prop, 0.0f, 10000.0f); - RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_structural_set", NULL); - RNA_def_property_ui_text(prop, "Structural Stiffness", "Overall stiffness of structure"); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_compression_set", NULL); + RNA_def_property_ui_text(prop, "Compression Stiffness", "How much the material resists compression"); RNA_def_property_update(prop, 0, "rna_cloth_update"); - prop = RNA_def_property(srna, "structural_stiffness_max", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "max_struct"); + prop = RNA_def_property(srna, "compression_stiffness_max", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "max_compression"); RNA_def_property_range(prop, 0.0f, 10000.0f); - RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_struct_set", NULL); - RNA_def_property_ui_text(prop, "Structural Stiffness Maximum", "Maximum structural stiffness value"); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_compression_set", NULL); + RNA_def_property_ui_text(prop, "Compression Stiffness Maximum", "Maximum compression stiffness value"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); + + prop = RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "shear"); + RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shear_set", NULL); + RNA_def_property_ui_text(prop, "Shear Stiffness", "How much the material resists shearing"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); + + prop = RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "max_shear"); + RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_shear_set", NULL); + RNA_def_property_ui_text(prop, "Shear Stiffness Maximum", "Maximum shear scaling value"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "sewing_force_max", PROP_FLOAT, PROP_NONE); @@ -546,12 +658,19 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) "Vertex group for fine control over structural stiffness"); RNA_def_property_update(prop, 0, "rna_cloth_update"); + prop = RNA_def_property(srna, "vertex_group_shear_stiffness", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_ClothSettings_shear_vgroup_get", + "rna_ClothSettings_shear_vgroup_length", + "rna_ClothSettings_shear_vgroup_set"); + RNA_def_property_ui_text(prop, "Shear Stiffness Vertex Group", + "Vertex group for fine control over shear stiffness"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); + prop = RNA_def_property(srna, "bending_stiffness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bending"); RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_bending_set", NULL); - RNA_def_property_ui_text(prop, "Bending Stiffness", - "Wrinkle coefficient (higher = less smaller but more big wrinkles)"); + RNA_def_property_ui_text(prop, "Bending Stiffness", "How much the material resists bending"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "bending_stiffness_max", PROP_FLOAT, PROP_NONE); @@ -564,8 +683,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "bending_damping", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bending_damping"); RNA_def_property_range(prop, 0.0f, 1000.0f); - RNA_def_property_ui_text(prop, "Bending Spring Damping", - "Damping of bending motion"); + RNA_def_property_ui_text(prop, "Bending Spring Damping", "Amount of damping in bending behavior"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "use_sewing_springs", PROP_BOOLEAN, PROP_NONE); @@ -600,24 +718,17 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_cloth_update"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + prop = RNA_def_property(srna, "bending_model", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "bending_model"); + RNA_def_property_enum_items(prop, prop_bending_model_items); + RNA_def_property_ui_text(prop, "Bending Model", "Physical model for simulating bending forces"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + /* unused */ /* unused still */ #if 0 - prop = RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "shear"); - RNA_def_property_range(prop, 0.0f, 1000.0f); - RNA_def_property_ui_text(prop, "Shear Stiffness", "Shear spring stiffness"); -#endif - /* unused still */ -#if 0 - prop = RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "max_shear"); - RNA_def_property_range(prop, 0.0f, upperLimitf); - RNA_def_property_ui_text(prop, "Shear Stiffness Maximum", "Maximum shear scaling value"); -#endif - /* unused still */ -#if 0 prop = RNA_def_property(srna, "effector_force_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "eff_force_scale"); RNA_def_property_range(prop, 0.0f, 100.0f); @@ -663,26 +774,11 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Enable Collision", "Enable collisions with other objects"); RNA_def_property_update(prop, 0, "rna_cloth_update"); - prop = RNA_def_property(srna, "repel_force", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "repel_force"); - RNA_def_property_range(prop, 0.0f, 20.0f); - RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Repulsion Force", "Repulsion force to apply on cloth when close to colliding"); - RNA_def_property_update(prop, 0, "rna_cloth_update"); - - prop = RNA_def_property(srna, "distance_repel", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "distance_repel"); - RNA_def_property_range(prop, 0.001f, 10.0f); - RNA_def_property_float_default(prop, 0.005f); - RNA_def_property_ui_text(prop, "Repulsion Distance", - "Maximum distance to apply repulsion force, must be greater than minimum distance"); - RNA_def_property_update(prop, 0, "rna_cloth_update"); - prop = RNA_def_property(srna, "distance_min", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "epsilon"); RNA_def_property_range(prop, 0.001f, 1.0f); RNA_def_property_ui_text(prop, "Minimum Distance", - "Minimum distance between collision objects before collision response takes in"); + "Minimum distance between collision objects before collision response takes effect"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE); @@ -705,6 +801,12 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna) "How many collision iterations should be done. (higher is better quality but slower)"); RNA_def_property_update(prop, 0, "rna_cloth_update"); + prop = RNA_def_property(srna, "impulse_clamp", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "clamp"); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_ui_text(prop, "Impulse Clamping", "Clamp collision impulses to avoid instability (0.0 to disable clamping)"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); + /* self collision */ prop = RNA_def_property(srna, "use_self_collision", PROP_BOOLEAN, PROP_NONE); @@ -714,22 +816,13 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "self_distance_min", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "selfepsilon"); - RNA_def_property_range(prop, 0.5f, 1.0f); - RNA_def_property_ui_text(prop, "Self Minimum Distance", "0.5 means no distance at all, 1.0 is maximum distance"); + RNA_def_property_range(prop, 0.001f, 0.1f); + RNA_def_property_ui_text(prop, "Self Minimum Distance", "Minimum distance between cloth faces before collision response takes effect"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "self_friction", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 80.0f); - RNA_def_property_ui_text(prop, "Self Friction", "Friction/damping with self contact"); - RNA_def_property_update(prop, 0, "rna_cloth_update"); - - prop = RNA_def_property(srna, "self_collision_quality", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "self_loop_count"); - RNA_def_property_range(prop, 1, SHRT_MAX); - RNA_def_property_ui_range(prop, 1, 10, 1, -1); - RNA_def_property_ui_text(prop, "Self Collision Quality", - "How many self collision iterations should be done " - "(higher is better quality but slower)"); + RNA_def_property_ui_text(prop, "Self Friction", "Friction with self contact"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); @@ -743,6 +836,12 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Selfcollision Vertex Group", "Vertex group to define vertices which are not used during self collisions"); RNA_def_property_update(prop, 0, "rna_cloth_update"); + + prop = RNA_def_property(srna, "self_impulse_clamp", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "self_clamp"); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_ui_text(prop, "Impulse Clamping", "Clamp collision impulses to avoid instability (0.0 to disable clamping)"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); } void RNA_def_cloth(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c new file mode 100644 index 00000000000..2279dc6880d --- /dev/null +++ b/source/blender/makesrna/intern/rna_collection.c @@ -0,0 +1,380 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_collection.c + * \ingroup RNA + */ + +#include <stdlib.h> + +#include "DNA_collection_types.h" + +#include "BLI_utildefines.h" + +#include "RNA_define.h" + +#include "rna_internal.h" + +#include "WM_types.h" + +#ifdef RNA_RUNTIME + +#include "DNA_scene_types.h" +#include "DNA_object_types.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + +#include "BKE_collection.h" +#include "BKE_global.h" +#include "BKE_layer.h" + +#include "WM_api.h" + +#include "RNA_access.h" + +static void rna_Collection_all_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Collection *collection = (Collection *)ptr->data; + ListBase collection_objects = BKE_collection_object_cache_get(collection); + rna_iterator_listbase_begin(iter, &collection_objects, NULL); +} + +static PointerRNA rna_Collection_all_objects_get(CollectionPropertyIterator *iter) +{ + ListBaseIterator *internal = &iter->internal.listbase; + + /* we are actually iterating a ObjectBase list, so override get */ + Base *base = (Base *)internal->link; + return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, base->object); +} + +static void rna_Collection_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Collection *collection = (Collection *)ptr->data; + rna_iterator_listbase_begin(iter, &collection->gobject, NULL); +} + +static PointerRNA rna_Collection_objects_get(CollectionPropertyIterator *iter) +{ + ListBaseIterator *internal = &iter->internal.listbase; + + /* we are actually iterating a ObjectBase list, so override get */ + CollectionObject *cob = (CollectionObject *)internal->link; + return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, cob->ob); +} + +static void rna_Collection_objects_link(Collection *collection, Main *bmain, ReportList *reports, Object *object) +{ + if (!BKE_collection_object_add(bmain, collection, object)) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' already in collection '%s'", object->id.name + 2, collection->id.name + 2); + return; + } + + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id); +} + +static void rna_Collection_objects_unlink(Collection *collection, Main *bmain, ReportList *reports, Object *object) +{ + if (!BKE_collection_object_remove(bmain, collection, object, false)) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in collection '%s'", object->id.name + 2, collection->id.name + 2); + return; + } + + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id); +} + +static bool rna_Collection_objects_override_apply( + Main *bmain, + PointerRNA *ptr_dst, PointerRNA *UNUSED(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 *ptr_item_dst, PointerRNA *ptr_item_src, PointerRNA *UNUSED(ptr_item_storage), + IDOverrideStaticPropertyOperation *opop) +{ + (void)opop; + BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_REPLACE && + "Unsupported RNA override operation on collections' objects"); + + Collection *coll_dst = ptr_dst->id.data; + + if (ptr_item_dst->type == NULL || ptr_item_src->type == NULL) { + BLI_assert(0 && "invalid source or destination object."); + return false; + } + + Object *ob_dst = ptr_item_dst->data; + Object *ob_src = ptr_item_src->data; + + CollectionObject *cob_dst = BLI_findptr(&coll_dst->gobject, ob_dst, offsetof(CollectionObject, ob)); + + if (cob_dst == NULL) { + BLI_assert(0 && "Could not find destination object in destination collection!"); + return false; + } + + /* XXX TODO We most certainly rather want to have a 'swap object pointer in collection' util in BKE_collection... + * This is only temp auick dirty test! */ + id_us_min(&cob_dst->ob->id); + cob_dst->ob = ob_src; + id_us_plus(&cob_dst->ob->id); + + if (BKE_collection_is_in_scene(coll_dst)) { + BKE_main_collection_sync(bmain); + } + + return true; +} + + + + +static void rna_Collection_children_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Collection *collection = (Collection *)ptr->data; + rna_iterator_listbase_begin(iter, &collection->children, NULL); +} + +static PointerRNA rna_Collection_children_get(CollectionPropertyIterator *iter) +{ + ListBaseIterator *internal = &iter->internal.listbase; + + /* we are actually iterating a CollectionBase list, so override get */ + CollectionChild *child = (CollectionChild *)internal->link; + return rna_pointer_inherit_refine(&iter->parent, &RNA_Collection, child->collection); +} + +static void rna_Collection_children_link(Collection *collection, Main *bmain, ReportList *reports, Collection *child) +{ + if (!BKE_collection_child_add(bmain, collection, child)) { + BKE_reportf(reports, RPT_ERROR, "Collection '%s' already in collection '%s'", child->id.name + 2, collection->id.name + 2); + return; + } + + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, &child->id); +} + +static void rna_Collection_children_unlink(Collection *collection, Main *bmain, ReportList *reports, Collection *child) +{ + if (!BKE_collection_child_remove(bmain, collection, child)) { + BKE_reportf(reports, RPT_ERROR, "Collection '%s' not in collection '%s'", child->id.name + 2, collection->id.name + 2); + return; + } + + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, &child->id); +} + +static bool rna_Collection_children_override_apply( + Main *bmain, + PointerRNA *ptr_dst, PointerRNA *UNUSED(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 *ptr_item_dst, PointerRNA *ptr_item_src, PointerRNA *UNUSED(ptr_item_storage), + IDOverrideStaticPropertyOperation *opop) +{ + (void)opop; + BLI_assert(opop->operation == IDOVERRIDESTATIC_OP_REPLACE && + "Unsupported RNA override operation on collections' objects"); + + Collection *coll_dst = ptr_dst->id.data; + + if (ptr_item_dst->type == NULL || ptr_item_src->type == NULL) { + BLI_assert(0 && "invalid source or destination sub-collection."); + return false; + } + + Collection *subcoll_dst = ptr_item_dst->data; + Collection *subcoll_src = ptr_item_src->data; + + CollectionChild *collchild_dst = BLI_findptr(&coll_dst->children, subcoll_dst, offsetof(CollectionChild, collection)); + + if (collchild_dst == NULL) { + BLI_assert(0 && "Could not find destination sub-collection in destination collection!"); + return false; + } + + /* XXX TODO We most certainly rather want to have a 'swap object pointer in collection' util in BKE_collection... + * This is only temp auick dirty test! */ + id_us_min(&collchild_dst->collection->id); + collchild_dst->collection = subcoll_src; + id_us_plus(&collchild_dst->collection->id); + + BKE_collection_object_cache_free(coll_dst); + BKE_main_collection_sync(bmain); + + return true; +} + + + + +static void rna_Collection_flag_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Collection *collection = (Collection *)ptr->data; + BKE_collection_object_cache_free(collection); + BKE_main_collection_sync(bmain); + + DEG_id_tag_update(&collection->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene); +} + +#else + +/* collection.objects */ +static void rna_def_collection_objects(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "CollectionObjects"); + srna = RNA_def_struct(brna, "CollectionObjects", NULL); + RNA_def_struct_sdna(srna, "Collection"); + RNA_def_struct_ui_text(srna, "Collection Objects", "Collection of collection objects"); + + /* add object */ + func = RNA_def_function(srna, "link", "rna_Collection_objects_link"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_MAIN); + RNA_def_function_ui_description(func, "Add this object to a collection"); + parm = RNA_def_pointer(func, "object", "Object", "", "Object to add"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* remove object */ + func = RNA_def_function(srna, "unlink", "rna_Collection_objects_unlink"); + RNA_def_function_ui_description(func, "Remove this object from a collection"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); +} + +/* collection.children */ +static void rna_def_collection_children(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "CollectionChildren"); + srna = RNA_def_struct(brna, "CollectionChildren", NULL); + RNA_def_struct_sdna(srna, "Collection"); + RNA_def_struct_ui_text(srna, "Collection Children", "Collection of child collections"); + + /* add child */ + func = RNA_def_function(srna, "link", "rna_Collection_children_link"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_MAIN); + RNA_def_function_ui_description(func, "Add this collection as child of this collection"); + parm = RNA_def_pointer(func, "child", "Collection", "", "Collection to add"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* remove child */ + func = RNA_def_function(srna, "unlink", "rna_Collection_children_unlink"); + RNA_def_function_ui_description(func, "Remove this child collection from a collection"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "child", "Collection", "", "Collection to remove"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); +} + + +void RNA_def_collections(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "Collection", "ID"); + RNA_def_struct_sdna(srna, "Group"); /* it is actually Collection but for 2.8 the dna is patched! */ + RNA_def_struct_ui_text(srna, "Collection", "Collection of Object data-blocks"); + RNA_def_struct_ui_icon(srna, ICON_GROUP); + /* this is done on save/load in readfile.c, removed if no objects are in the collection and not in a scene */ + RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT); + + prop = RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_float_sdna(prop, NULL, "dupli_ofs"); + RNA_def_property_ui_text(prop, "Dupli Offset", "Offset from the origin to use when instancing"); + RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + + prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Collection_objects_override_apply"); + RNA_def_property_ui_text(prop, "Objects", "Objects that are directly in this collection"); + RNA_def_property_collection_funcs(prop, "rna_Collection_objects_begin", + "rna_iterator_listbase_next", + "rna_iterator_listbase_end", + "rna_Collection_objects_get", + NULL, NULL, NULL, NULL); + rna_def_collection_objects(brna, prop); + + prop = RNA_def_property(srna, "all_objects", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_ui_text(prop, "All Objects", "Objects that are in this collection and its child collections"); + RNA_def_property_collection_funcs(prop, "rna_Collection_all_objects_begin", + "rna_iterator_listbase_next", + "rna_iterator_listbase_end", + "rna_Collection_all_objects_get", + NULL, NULL, NULL, NULL); + + prop = RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Collection"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Collection_children_override_apply"); + RNA_def_property_ui_text(prop, "Children", "Collections that are immediate children of this collection"); + RNA_def_property_collection_funcs(prop, "rna_Collection_children_begin", + "rna_iterator_listbase_next", + "rna_iterator_listbase_end", + "rna_Collection_children_get", + NULL, NULL, NULL, NULL); + rna_def_collection_children(brna, prop); + + /* Flags */ + prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_SELECT); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1); + RNA_def_property_ui_text(prop, "Disable Select", "Disable collection for viewport selection"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update"); + + prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_VIEW); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1); + RNA_def_property_ui_text(prop, "Disable Viewport", "Disable collection in viewport"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update"); + + prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_RENDER); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1); + RNA_def_property_ui_text(prop, "Disable Render", "Disable collection in renders"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update"); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index aa1164068d8..3cf959eaee1 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -54,13 +54,14 @@ #include "BKE_colorband.h" #include "BKE_colortools.h" -#include "BKE_depsgraph.h" #include "BKE_image.h" #include "BKE_movieclip.h" #include "BKE_node.h" #include "BKE_sequencer.h" #include "BKE_linestyle.h" +#include "DEG_depsgraph.h" + #include "ED_node.h" #include "IMB_colormanagement.h" @@ -113,6 +114,12 @@ static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *value curvemapping_set_black_white(cumap, NULL, NULL); } +static void rna_CurveMapping_tone_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ + WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); +} + static void rna_CurveMapping_clipminx_range(PointerRNA *ptr, float *min, float *max, float *UNUSED(softmin), float *UNUSED(softmax)) { @@ -159,17 +166,6 @@ static char *rna_ColorRamp_path(PointerRNA *ptr) ID *id = ptr->id.data; switch (GS(id->name)) { - case ID_MA: /* material has 2 cases - diffuse and specular */ - { - Material *ma = (Material *)id; - - if (ptr->data == ma->ramp_col) - path = BLI_strdup("diffuse_ramp"); - else if (ptr->data == ma->ramp_spec) - path = BLI_strdup("specular_ramp"); - break; - } - case ID_NT: { bNodeTree *ntree = (bNodeTree *)id; @@ -244,22 +240,6 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr) ID *id = ptr->id.data; switch (GS(id->name)) { - case ID_MA: /* 2 cases for material - diffuse and spec */ - { - Material *ma = (Material *)id; - - /* try diffuse first */ - if (ma->ramp_col) { - RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_col, &ramp_ptr); - COLRAMP_GETPATH; - } - /* try specular if not diffuse */ - if (!path && ma->ramp_spec) { - RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_spec, &ramp_ptr); - COLRAMP_GETPATH; - } - break; - } case ID_NT: { bNodeTree *ntree = (bNodeTree *)id; @@ -315,7 +295,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA * { Material *ma = ptr->id.data; - DAG_id_tag_update(&ma->id, 0); + DEG_id_tag_update(&ma->id, 0); WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma); break; } @@ -335,7 +315,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA * { Tex *tex = ptr->id.data; - DAG_id_tag_update(&tex->id, 0); + DEG_id_tag_update(&tex->id, 0); WM_main_add_notifier(NC_TEXTURE, tex); break; } @@ -350,7 +330,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA * { ParticleSettings *part = ptr->id.data; - DAG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO); + DEG_id_tag_update(&part->id, OB_RECALC_DATA | PSYS_RECALC_REDO); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, part); } default: @@ -446,7 +426,7 @@ static void rna_ColorManagedDisplaySettings_display_device_update(Main *UNUSED(b IMB_colormanagement_validate_settings(&scene->display_settings, &scene->view_settings); - DAG_id_tag_update(id, 0); + DEG_id_tag_update(id, 0); WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); } } @@ -581,7 +561,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain, Scene if (GS(id->name) == ID_IM) { Image *ima = (Image *) id; - DAG_id_tag_update(&ima->id, 0); + DEG_id_tag_update(&ima->id, 0); BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE); @@ -664,7 +644,7 @@ static void rna_ColorManagement_update(Main *UNUSED(bmain), Scene *UNUSED(scene) return; if (GS(id->name) == ID_SCE) { - DAG_id_tag_update(id, 0); + DEG_id_tag_update(id, 0); WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); } } @@ -783,11 +763,24 @@ static void rna_def_curvemapping(BlenderRNA *brna) PropertyRNA *prop; FunctionRNA *func; + static const EnumPropertyItem tone_items[] = { + {CURVE_TONE_STANDARD, "STANDARD", 0, "Standard", ""}, + {CURVE_TONE_FILMLIKE, "FILMLIKE", 0, "Film like", ""}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "CurveMapping", NULL); RNA_def_struct_ui_text(srna, "CurveMapping", "Curve mapping to map color, vector and scalar values to other values using " "a user defined curve"); + prop = RNA_def_property(srna, "tone", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "tone"); + RNA_def_property_enum_items(prop, tone_items); + RNA_def_property_ui_text(prop, "Tone", "Tone of the curve"); + RNA_def_property_update(prop, 0, "rna_CurveMapping_tone_update"); + + prop = RNA_def_property(srna, "use_clip", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CUMA_DO_CLIP); RNA_def_property_ui_text(prop, "Clip", "Force the curve view to fit a defined boundary"); @@ -1012,7 +1005,7 @@ static void rna_def_histogram(BlenderRNA *brna) prop = RNA_def_property(srna, "show_line", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", HISTO_FLAG_LINE); RNA_def_property_ui_text(prop, "Show Line", "Display lines rather than filled shapes"); - RNA_def_property_ui_icon(prop, ICON_IPO, 0); + RNA_def_property_ui_icon(prop, ICON_GRAPH, 0); } static void rna_def_scopes(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 4b563bf6659..d7fd0aae917 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -27,6 +27,9 @@ #include <stdlib.h> #include "BLI_math.h" +#include "BLI_listbase.h" + +#include "MEM_guardedalloc.h" #include "BLT_translation.h" @@ -48,64 +51,66 @@ /* please keep the names in sync with constraint.c */ const EnumPropertyItem rna_enum_constraint_type_items[] = { {0, "", 0, N_("Motion Tracking"), ""}, - {CONSTRAINT_TYPE_CAMERASOLVER, "CAMERA_SOLVER", ICON_CONSTRAINT_DATA, "Camera Solver", ""}, - {CONSTRAINT_TYPE_FOLLOWTRACK, "FOLLOW_TRACK", ICON_CONSTRAINT_DATA, "Follow Track", ""}, - {CONSTRAINT_TYPE_OBJECTSOLVER, "OBJECT_SOLVER", ICON_CONSTRAINT_DATA, "Object Solver", ""}, + {CONSTRAINT_TYPE_CAMERASOLVER, "CAMERA_SOLVER", ICON_CONSTRAINT, "Camera Solver", ""}, + {CONSTRAINT_TYPE_FOLLOWTRACK, "FOLLOW_TRACK", ICON_CONSTRAINT, "Follow Track", ""}, + {CONSTRAINT_TYPE_OBJECTSOLVER, "OBJECT_SOLVER", ICON_CONSTRAINT, "Object Solver", ""}, {0, "", 0, N_("Transform"), ""}, - {CONSTRAINT_TYPE_LOCLIKE, "COPY_LOCATION", ICON_CONSTRAINT_DATA, "Copy Location", + {CONSTRAINT_TYPE_LOCLIKE, "COPY_LOCATION", ICON_CONSTRAINT, "Copy Location", "Copy the location of a target (with an optional offset), so that they move together"}, - {CONSTRAINT_TYPE_ROTLIKE, "COPY_ROTATION", ICON_CONSTRAINT_DATA, "Copy Rotation", + {CONSTRAINT_TYPE_ROTLIKE, "COPY_ROTATION", ICON_CONSTRAINT, "Copy Rotation", "Copy the rotation of a target (with an optional offset), so that they rotate together"}, - {CONSTRAINT_TYPE_SIZELIKE, "COPY_SCALE", ICON_CONSTRAINT_DATA, "Copy Scale", + {CONSTRAINT_TYPE_SIZELIKE, "COPY_SCALE", ICON_CONSTRAINT, "Copy Scale", "Copy the scale factors of a target (with an optional offset), so that they are scaled by the same amount"}, - {CONSTRAINT_TYPE_TRANSLIKE, "COPY_TRANSFORMS", ICON_CONSTRAINT_DATA, "Copy Transforms", + {CONSTRAINT_TYPE_TRANSLIKE, "COPY_TRANSFORMS", ICON_CONSTRAINT, "Copy Transforms", "Copy all the transformations of a target, so that they move together"}, - {CONSTRAINT_TYPE_DISTLIMIT, "LIMIT_DISTANCE", ICON_CONSTRAINT_DATA, "Limit Distance", + {CONSTRAINT_TYPE_DISTLIMIT, "LIMIT_DISTANCE", ICON_CONSTRAINT, "Limit Distance", "Restrict movements to within a certain distance of a target (at the time of constraint evaluation only)"}, - {CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", ICON_CONSTRAINT_DATA, "Limit Location", + {CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", ICON_CONSTRAINT, "Limit Location", "Restrict movement along each axis within given ranges"}, - {CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", ICON_CONSTRAINT_DATA, "Limit Rotation", + {CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", ICON_CONSTRAINT, "Limit Rotation", "Restrict rotation along each axis within given ranges"}, - {CONSTRAINT_TYPE_SIZELIMIT, "LIMIT_SCALE", ICON_CONSTRAINT_DATA, "Limit Scale", + {CONSTRAINT_TYPE_SIZELIMIT, "LIMIT_SCALE", ICON_CONSTRAINT, "Limit Scale", "Restrict scaling along each axis with given ranges"}, - {CONSTRAINT_TYPE_SAMEVOL, "MAINTAIN_VOLUME", ICON_CONSTRAINT_DATA, "Maintain Volume", + {CONSTRAINT_TYPE_SAMEVOL, "MAINTAIN_VOLUME", ICON_CONSTRAINT, "Maintain Volume", "Compensate for scaling one axis by applying suitable scaling to the other two axes"}, - {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", ICON_CONSTRAINT_DATA, "Transformation", + {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", ICON_CONSTRAINT, "Transformation", "Use one transform property from target to control another (or same) property on owner"}, - {CONSTRAINT_TYPE_TRANSFORM_CACHE, "TRANSFORM_CACHE", ICON_CONSTRAINT_DATA, "Transform Cache", + {CONSTRAINT_TYPE_TRANSFORM_CACHE, "TRANSFORM_CACHE", ICON_CONSTRAINT, "Transform Cache", "Look up the transformation matrix from an external file"}, {0, "", 0, N_("Tracking"), ""}, - {CONSTRAINT_TYPE_CLAMPTO, "CLAMP_TO", ICON_CONSTRAINT_DATA, "Clamp To", + {CONSTRAINT_TYPE_CLAMPTO, "CLAMP_TO", ICON_CONSTRAINT, "Clamp To", "Restrict movements to lie along a curve by remapping location along curve's longest axis"}, - {CONSTRAINT_TYPE_DAMPTRACK, "DAMPED_TRACK", ICON_CONSTRAINT_DATA, "Damped Track", + {CONSTRAINT_TYPE_DAMPTRACK, "DAMPED_TRACK", ICON_CONSTRAINT, "Damped Track", "Point towards a target by performing the smallest rotation necessary"}, - {CONSTRAINT_TYPE_KINEMATIC, "IK", ICON_CONSTRAINT_DATA, "Inverse Kinematics", + {CONSTRAINT_TYPE_KINEMATIC, "IK", ICON_CONSTRAINT, "Inverse Kinematics", "Control a chain of bones by specifying the endpoint target (Bones only)"}, - {CONSTRAINT_TYPE_LOCKTRACK, "LOCKED_TRACK", ICON_CONSTRAINT_DATA, "Locked Track", + {CONSTRAINT_TYPE_LOCKTRACK, "LOCKED_TRACK", ICON_CONSTRAINT, "Locked Track", "Rotate around the specified ('locked') axis to point towards a target"}, - {CONSTRAINT_TYPE_SPLINEIK, "SPLINE_IK", ICON_CONSTRAINT_DATA, "Spline IK", + {CONSTRAINT_TYPE_SPLINEIK, "SPLINE_IK", ICON_CONSTRAINT, "Spline IK", "Align chain of bones along a curve (Bones only)"}, - {CONSTRAINT_TYPE_STRETCHTO, "STRETCH_TO", ICON_CONSTRAINT_DATA, "Stretch To", + {CONSTRAINT_TYPE_STRETCHTO, "STRETCH_TO", ICON_CONSTRAINT, "Stretch To", "Stretch along Y-Axis to point towards a target"}, - {CONSTRAINT_TYPE_TRACKTO, "TRACK_TO", ICON_CONSTRAINT_DATA, "Track To", + {CONSTRAINT_TYPE_TRACKTO, "TRACK_TO", ICON_CONSTRAINT, "Track To", "Legacy tracking constraint prone to twisting artifacts"}, {0, "", 0, N_("Relationship"), ""}, - {CONSTRAINT_TYPE_ACTION, "ACTION", ICON_CONSTRAINT_DATA, "Action", + {CONSTRAINT_TYPE_ACTION, "ACTION", ICON_CONSTRAINT, "Action", "Use transform property of target to look up pose for owner from an Action"}, - {CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", ICON_CONSTRAINT_DATA, "Child Of", + {CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", ICON_CONSTRAINT, "Child Of", "Make target the 'detachable' parent of owner"}, - {CONSTRAINT_TYPE_MINMAX, "FLOOR", ICON_CONSTRAINT_DATA, "Floor", + {CONSTRAINT_TYPE_MINMAX, "FLOOR", ICON_CONSTRAINT, "Floor", "Use position (and optionally rotation) of target to define a 'wall' or 'floor' that the owner can not cross"}, - {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOW_PATH", ICON_CONSTRAINT_DATA, "Follow Path", + {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOW_PATH", ICON_CONSTRAINT, "Follow Path", "Use to animate an object/bone following a path"}, - {CONSTRAINT_TYPE_PIVOT, "PIVOT", ICON_CONSTRAINT_DATA, "Pivot", + {CONSTRAINT_TYPE_PIVOT, "PIVOT", ICON_CONSTRAINT, "Pivot", "Change pivot point for transforms (buggy)"}, - {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", ICON_CONSTRAINT_DATA, "Rigid Body Joint", - "Use to define a Rigid Body Constraint (for Game Engine use only)"}, + /* {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", ICON_CONSTRAINT_DATA, "Rigid Body Joint", + "Use to define a Rigid Body Constraint (for Game Engine use only)"}, */ /* {CONSTRAINT_TYPE_PYTHON, "SCRIPT", ICON_CONSTRAINT_DATA, "Script", "Custom constraint(s) written in Python (Not yet implemented)"}, */ - {CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", ICON_CONSTRAINT_DATA, "Shrinkwrap", + {CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", ICON_CONSTRAINT, "Shrinkwrap", "Restrict movements to surface of target mesh"}, + {CONSTRAINT_TYPE_ARMATURE, "ARMATURE", ICON_CONSTRAINT, "Armature", + "Apply weight-blended transformation from multiple bones like the Armature modifier"}, {0, NULL, 0, NULL, NULL} }; @@ -138,6 +143,16 @@ static const EnumPropertyItem owner_space_pchan_items[] = { {0, NULL, 0, NULL, NULL} }; +static const EnumPropertyItem track_axis_items[] = { + {TRACK_X, "TRACK_X", 0, "X", ""}, + {TRACK_Y, "TRACK_Y", 0, "Y", ""}, + {TRACK_Z, "TRACK_Z", 0, "Z", ""}, + {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""}, + {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""}, + {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME static const EnumPropertyItem space_object_items[] = { @@ -154,7 +169,6 @@ static const EnumPropertyItem space_object_items[] = { #include "BKE_action.h" #include "BKE_constraint.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #ifdef WITH_ALEMBIC # include "ABC_alembic.h" @@ -183,6 +197,8 @@ static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr) return &RNA_MaintainVolumeConstraint; case CONSTRAINT_TYPE_PYTHON: return &RNA_PythonConstraint; + case CONSTRAINT_TYPE_ARMATURE: + return &RNA_ArmatureConstraint; case CONSTRAINT_TYPE_ACTION: return &RNA_ActionConstraint; case CONSTRAINT_TYPE_LOCKTRACK: @@ -191,8 +207,6 @@ static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr) return &RNA_StretchToConstraint; case CONSTRAINT_TYPE_MINMAX: return &RNA_FloorConstraint; - case CONSTRAINT_TYPE_RIGIDBODYJOINT: - return &RNA_RigidBodyJointConstraint; case CONSTRAINT_TYPE_CLAMPTO: return &RNA_ClampToConstraint; case CONSTRAINT_TYPE_TRANSFORM: @@ -228,6 +242,17 @@ static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr) } } +static void rna_ConstraintTargetBone_target_set(PointerRNA *ptr, PointerRNA value) +{ + bConstraintTarget *tgt = (bConstraintTarget *)ptr->data; + Object *ob = value.data; + + if (!ob || ob->type == OB_ARMATURE) { + id_lib_extern((ID *)ob); + tgt->tar = ob; + } +} + static void rna_Constraint_name_set(PointerRNA *ptr, const char *value) { bConstraint *con = ptr->data; @@ -253,10 +278,8 @@ static void rna_Constraint_name_set(PointerRNA *ptr, const char *value) BKE_animdata_fix_paths_rename_all(NULL, "constraints", oldname, con->name); } -static char *rna_Constraint_path(PointerRNA *ptr) +static char *rna_Constraint_do_compute_path(Object *ob, bConstraint *con) { - Object *ob = ptr->id.data; - bConstraint *con = ptr->data; bPoseChannel *pchan; ListBase *lb = get_constraint_lb(ob, con, &pchan); @@ -278,6 +301,55 @@ static char *rna_Constraint_path(PointerRNA *ptr) } } +static char *rna_Constraint_path(PointerRNA *ptr) +{ + Object *ob = ptr->id.data; + bConstraint *con = ptr->data; + + return rna_Constraint_do_compute_path(ob, con); +} + +static bConstraint *rna_constraint_from_target(PointerRNA *ptr) +{ + Object *ob = ptr->id.data; + bConstraintTarget *tgt = ptr->data; + + return BKE_constraint_find_from_target(ob, tgt); +} + +static char *rna_ConstraintTarget_path(PointerRNA *ptr) +{ + Object *ob = ptr->id.data; + bConstraintTarget *tgt = ptr->data; + bConstraint *con = rna_constraint_from_target(ptr); + int index = -1; + + if (con != NULL) { + if (con->type == CONSTRAINT_TYPE_ARMATURE) { + bArmatureConstraint *acon = con->data; + index = BLI_findindex(&acon->targets, tgt); + } + else if (con->type == CONSTRAINT_TYPE_PYTHON) { + bPythonConstraint *pcon = con->data; + index = BLI_findindex(&pcon->targets, tgt); + } + } + + if (index >= 0) { + char *con_path = rna_Constraint_do_compute_path(ob, con); + char *result = BLI_sprintfN("%s.targets[%d]", con_path, index); + + MEM_freeN(con_path); + return result; + } + else { + printf("%s: internal error, constraint '%s' of object '%s' does not contain the target\n", + __func__, con->name, ob->id.name); + } + + return NULL; +} + static void rna_Constraint_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { ED_object_constraint_tag_update(bmain, ptr->id.data, ptr->data); @@ -288,6 +360,16 @@ static void rna_Constraint_dependency_update(Main *bmain, Scene *UNUSED(scene), ED_object_constraint_dependency_tag_update(bmain, ptr->id.data, ptr->data); } +static void rna_ConstraintTarget_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + ED_object_constraint_tag_update(bmain, ptr->id.data, rna_constraint_from_target(ptr)); +} + +static void rna_ConstraintTarget_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + ED_object_constraint_dependency_tag_update(bmain, ptr->id.data, rna_constraint_from_target(ptr)); +} + static void rna_Constraint_influence_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Object *ob = ptr->id.data; @@ -316,8 +398,9 @@ static void rna_Constraint_ik_type_set(struct PointerRNA *ptr, int value) } } -static const EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) +static const EnumPropertyItem *rna_Constraint_owner_space_itemf( + bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) { Object *ob = (Object *)ptr->id.data; bConstraint *con = (bConstraint *)ptr->data; @@ -328,8 +411,9 @@ static const EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *UNUSED return space_object_items; } -static const EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) +static const EnumPropertyItem *rna_Constraint_target_space_itemf( + bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) { bConstraint *con = (bConstraint *)ptr->data; const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); @@ -353,6 +437,43 @@ static const EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *UNUSE return space_object_items; } +static bConstraintTarget *rna_ArmatureConstraint_target_new(ID *id, bConstraint *con, Main *bmain) +{ + bArmatureConstraint *acon = con->data; + bConstraintTarget *tgt = MEM_callocN(sizeof(bConstraintTarget), "Constraint Target"); + + tgt->weight = 1.0f; + BLI_addtail(&acon->targets, tgt); + + ED_object_constraint_dependency_tag_update(bmain, (Object *)id, con); + return tgt; +} + +static void rna_ArmatureConstraint_target_remove( + ID *id, bConstraint *con, Main *bmain, ReportList *reports, PointerRNA *target_ptr) +{ + bArmatureConstraint *acon = con->data; + bConstraintTarget *tgt = target_ptr->data; + + if (BLI_findindex(&acon->targets, tgt) < 0) { + BKE_reportf(reports, RPT_ERROR, "Target is not in the constraint target list"); + return; + } + + BLI_freelinkN(&acon->targets, tgt); + + ED_object_constraint_dependency_tag_update(bmain, (Object *)id, con); +} + +static void rna_ArmatureConstraint_target_clear(ID *id, bConstraint *con, Main *bmain) +{ + bArmatureConstraint *acon = con->data; + + BLI_freelistN(&acon->targets); + + ED_object_constraint_dependency_tag_update(bmain, (Object *)id, con); +} + static void rna_ActionConstraint_minmax_range(PointerRNA *ptr, float *min, float *max, float *UNUSED(softmin), float *UNUSED(softmax)) { @@ -399,6 +520,20 @@ static void rna_SplineIKConstraint_joint_bindings_set(PointerRNA *ptr, const flo memcpy(ikData->points, values, ikData->numpoints * sizeof(float)); } +static int rna_ShrinkwrapConstraint_face_cull_get(PointerRNA *ptr) +{ + bConstraint *con = (bConstraint *)ptr->data; + bShrinkwrapConstraint *swc = (bShrinkwrapConstraint *)con->data; + return swc->flag & CON_SHRINKWRAP_PROJECT_CULL_MASK; +} + +static void rna_ShrinkwrapConstraint_face_cull_set(struct PointerRNA *ptr, int value) +{ + bConstraint *con = (bConstraint *)ptr->data; + bShrinkwrapConstraint *swc = (bShrinkwrapConstraint *)con->data; + swc->flag = (swc->flag & ~CON_SHRINKWRAP_PROJECT_CULL_MASK) | value; +} + static bool rna_Constraint_cameraObject_poll(PointerRNA *ptr, PointerRNA value) { Object *ob = (Object *)value.data; @@ -520,7 +655,7 @@ static void rna_def_constraint_headtail_common(StructRNA *srna) prop = RNA_def_property(srna, "use_bbone_shape", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, "bConstraint", "flag", CONSTRAINT_BBONE_SHAPE); RNA_def_property_ui_text(prop, "Follow B-Bone", "Follow shape of B-Bone segments when calculating Head/Tail position"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); } static void rna_def_constraint_target_common(StructRNA *srna) @@ -531,6 +666,7 @@ static void rna_def_constraint_target_common(StructRNA *srna) RNA_def_property_pointer_sdna(prop, NULL, "tar"); RNA_def_property_ui_text(prop, "Target", "Target object"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); @@ -542,16 +678,58 @@ static void rna_def_constraint_target_common(StructRNA *srna) static void rna_def_constrainttarget(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; srna = RNA_def_struct(brna, "ConstraintTarget", NULL); RNA_def_struct_ui_text(srna, "Constraint Target", "Target object for multi-target constraints"); + RNA_def_struct_path_func(srna, "rna_ConstraintTarget_path"); RNA_def_struct_sdna(srna, "bConstraintTarget"); - rna_def_constraint_target_common(srna); + prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "tar"); + RNA_def_property_ui_text(prop, "Target", "Target object"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_ConstraintTarget_dependency_update"); + + prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "subtarget"); + RNA_def_property_ui_text(prop, "Sub-Target", "Armature bone, mesh or lattice vertex group, ..."); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_ConstraintTarget_dependency_update"); /* space, flag and type still to do */ } +static void rna_def_constrainttarget_bone(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ConstraintTargetBone", NULL); + RNA_def_struct_ui_text(srna, "Constraint Target Bone", "Target bone for multi-target constraints"); + RNA_def_struct_path_func(srna, "rna_ConstraintTarget_path"); + RNA_def_struct_sdna(srna, "bConstraintTarget"); + + prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "tar"); + RNA_def_property_ui_text(prop, "Target", "Target armature"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ConstraintTargetBone_target_set", NULL, "rna_Armature_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_ConstraintTarget_dependency_update"); + + prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "subtarget"); + RNA_def_property_ui_text(prop, "Sub-Target", "Target armature bone"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_ConstraintTarget_dependency_update"); + + prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "weight"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Blend Weight", "Blending weight of this bone"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_ConstraintTarget_update"); +} + static void rna_def_constraint_childof(BlenderRNA *brna) { StructRNA *srna; @@ -651,6 +829,70 @@ static void rna_def_constraint_python(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Script Error", "The linked Python script has thrown an error"); } + +static void rna_def_constraint_armature_deform_targets(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "ArmatureConstraintTargets"); + srna = RNA_def_struct(brna, "ArmatureConstraintTargets", NULL); + RNA_def_struct_sdna(srna, "bConstraint"); + RNA_def_struct_ui_text(srna, "Armature Deform Constraint Targets", "Collection of target bones and weights"); + + func = RNA_def_function(srna, "new", "rna_ArmatureConstraint_target_new"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + RNA_def_function_ui_description(func, "Add a new target to the constraint"); + parm = RNA_def_pointer(func, "target", "ConstraintTargetBone", "", "New target bone"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_ArmatureConstraint_target_remove"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Delete target from the constraint"); + parm = RNA_def_pointer(func, "target", "ConstraintTargetBone", "", "Target to remove"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + + func = RNA_def_function(srna, "clear", "rna_ArmatureConstraint_target_clear"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + RNA_def_function_ui_description(func, "Delete all targets from object"); +} + +static void rna_def_constraint_armature_deform(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ArmatureConstraint", "Constraint"); + RNA_def_struct_ui_text(srna, "Armature Constraint", "Applies transformations done by the Armature modifier"); + RNA_def_struct_sdna_from(srna, "bArmatureConstraint", "data"); + + prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "targets", NULL); + RNA_def_property_struct_type(prop, "ConstraintTargetBone"); + RNA_def_property_ui_text(prop, "Targets", "Target Bones"); + rna_def_constraint_armature_deform_targets(brna, prop); + + prop = RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_ARMATURE_QUATERNION); + RNA_def_property_ui_text(prop, "Preserve Volume", "Deform rotation interpolation with quaternions"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_ARMATURE_ENVELOPE); + RNA_def_property_ui_text(prop, "Use Envelopes", + "Multiply weights by envelope for all bones, instead of acting like Vertex Group based blending. " + "The specified weights are still used, and only the listed bones are considered"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "use_current_location", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_ARMATURE_CUR_LOCATION); + RNA_def_property_ui_text(prop, "Use Current Location", + "Use the current bone location for envelopes and choosing B-Bone segments instead of rest position"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); +} + static void rna_def_constraint_kinematic(BlenderRNA *brna) { StructRNA *srna; @@ -683,6 +925,7 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "poletar"); RNA_def_property_ui_text(prop, "Pole Target", "Object for pole rotation"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "pole_subtarget", PROP_STRING, PROP_NONE); @@ -795,16 +1038,6 @@ static void rna_def_constraint_track_to(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem track_items[] = { - {TRACK_X, "TRACK_X", 0, "X", ""}, - {TRACK_Y, "TRACK_Y", 0, "Y", ""}, - {TRACK_Z, "TRACK_Z", 0, "Z", ""}, - {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""}, - {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""}, - {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem up_items[] = { {TRACK_X, "UP_X", 0, "X", ""}, {TRACK_Y, "UP_Y", 0, "Y", ""}, @@ -823,7 +1056,7 @@ static void rna_def_constraint_track_to(BlenderRNA *brna) prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "reserved1"); - RNA_def_property_enum_items(prop, track_items); + RNA_def_property_enum_items(prop, track_axis_items); RNA_def_property_ui_text(prop, "Track Axis", "Axis that points to the target object"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); @@ -964,7 +1197,12 @@ static void rna_def_constraint_size_like(BlenderRNA *brna) prop = RNA_def_property(srna, "use_offset", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_OFFSET); - RNA_def_property_ui_text(prop, "Offset", "Add original scale into copied scale"); + RNA_def_property_ui_text(prop, "Offset", "Combine original scale with copied scale"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "use_add", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIZELIKE_MULTIPLY); + RNA_def_property_ui_text(prop, "Additive", "Use addition instead of multiplication to combine scale (2.7 compatibility)"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); } @@ -1091,6 +1329,7 @@ static void rna_def_constraint_action(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Action_id_poll"); RNA_def_property_ui_text(prop, "Action", "The constraining action"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); prop = RNA_def_property(srna, "use_bone_object_action", PROP_BOOLEAN, PROP_NONE); @@ -1132,16 +1371,6 @@ static void rna_def_constraint_locked_track(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem locktrack_items[] = { - {TRACK_X, "TRACK_X", 0, "X", ""}, - {TRACK_Y, "TRACK_Y", 0, "Y", ""}, - {TRACK_Z, "TRACK_Z", 0, "Z", ""}, - {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""}, - {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""}, - {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem lock_items[] = { {TRACK_X, "LOCK_X", 0, "X", ""}, {TRACK_Y, "LOCK_Y", 0, "Y", ""}, @@ -1161,7 +1390,7 @@ static void rna_def_constraint_locked_track(BlenderRNA *brna) prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "trackflag"); - RNA_def_property_enum_items(prop, locktrack_items); + RNA_def_property_enum_items(prop, track_axis_items); RNA_def_property_ui_text(prop, "Track Axis", "Axis that points to the target object"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); @@ -1203,6 +1432,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll"); RNA_def_property_ui_text(prop, "Target", "Target Curve object"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TIME); @@ -1324,178 +1554,6 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); } -static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem pivot_items[] = { - {CONSTRAINT_RB_BALL, "BALL", 0, "Ball", "Allow rotations around all axes"}, - {CONSTRAINT_RB_HINGE, "HINGE", 0, "Hinge", "Work in one plane, allow rotations around one axis only"}, - {CONSTRAINT_RB_CONETWIST, "CONE_TWIST", 0, "Cone Twist", - "Allow rotations around all axes with limits for the cone and twist axes"}, - {CONSTRAINT_RB_GENERIC6DOF, "GENERIC_6_DOF", 0, "Generic 6 DoF", - "No constraints by default, limits can be set individually"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "RigidBodyJointConstraint", "Constraint"); - RNA_def_struct_ui_text(srna, "Rigid Body Joint Constraint", "For use with the Game Engine"); - RNA_def_struct_sdna_from(srna, "bRigidBodyJointConstraint", "data"); - - prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_ui_text(prop, "Target", "Target Object"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); - - prop = RNA_def_property(srna, "child", PROP_POINTER, PROP_NONE); - RNA_def_property_ui_text(prop, "Child Object", "Child object"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); - - prop = RNA_def_property(srna, "pivot_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, pivot_items); - RNA_def_property_ui_text(prop, "Pivot Type", ""); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "pivX"); - RNA_def_property_range(prop, -1000.0, 1000.f); - RNA_def_property_ui_text(prop, "Pivot X", "Offset pivot on X"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "pivY"); - RNA_def_property_range(prop, -1000.0, 1000.f); - RNA_def_property_ui_text(prop, "Pivot Y", "Offset pivot on Y"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "pivot_z", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "pivZ"); - RNA_def_property_range(prop, -1000.0, 1000.f); - RNA_def_property_ui_text(prop, "Pivot Z", "Offset pivot on Z"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "axX"); - RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); - RNA_def_property_ui_text(prop, "Axis X", "Rotate pivot on X axis"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "axY"); - RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); - RNA_def_property_ui_text(prop, "Axis Y", "Rotate pivot on Y axis"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "axZ"); - RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); - RNA_def_property_ui_text(prop, "Axis Z", "Rotate pivot on Z axis"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "use_linked_collision", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE_LINKED_COLLISION); - RNA_def_property_ui_text(prop, "Disable Linked Collision", "Disable collision between linked bodies"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "show_pivot", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DRAW_PIVOT); - RNA_def_property_ui_text(prop, "Draw Pivot", "Display the pivot point and rotation in 3D view"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - - /* Limits */ - /* Limit Min/Max */ - prop = RNA_def_property(srna, "limit_min_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minLimit[0]"); - RNA_def_property_ui_text(prop, "Minimum Limit X", ""); - - prop = RNA_def_property(srna, "limit_min_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minLimit[1]"); - RNA_def_property_ui_text(prop, "Minimum Limit Y", ""); - - prop = RNA_def_property(srna, "limit_min_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minLimit[2]"); - RNA_def_property_ui_text(prop, "Minimum Limit Z", ""); - - prop = RNA_def_property(srna, "limit_max_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxLimit[0]"); - RNA_def_property_ui_text(prop, "Maximum Limit X", ""); - - prop = RNA_def_property(srna, "limit_max_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxLimit[1]"); - RNA_def_property_ui_text(prop, "Maximum Limit Y", ""); - - prop = RNA_def_property(srna, "limit_max_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxLimit[2]"); - RNA_def_property_ui_text(prop, "Maximum Limit Z", ""); - - /* Limit Min/Max for angle */ - prop = RNA_def_property(srna, "limit_angle_min_x", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "minLimit[3]"); - RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); - RNA_def_property_ui_text(prop, "Minimum Angular Limit X", ""); - - prop = RNA_def_property(srna, "limit_angle_min_y", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "minLimit[4]"); - RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); - RNA_def_property_ui_text(prop, "Minimum Angular Limit Y", ""); - - prop = RNA_def_property(srna, "limit_angle_min_z", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "minLimit[5]"); - RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); - RNA_def_property_ui_text(prop, "Minimum Angular Limit Z", ""); - - prop = RNA_def_property(srna, "limit_angle_max_x", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "maxLimit[3]"); - RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); - RNA_def_property_ui_text(prop, "Maximum Angular Limit X", ""); - - prop = RNA_def_property(srna, "limit_angle_max_y", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "maxLimit[4]"); - RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); - RNA_def_property_ui_text(prop, "Maximum Angular Limit Y", ""); - - prop = RNA_def_property(srna, "limit_angle_max_z", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "maxLimit[5]"); - RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); - RNA_def_property_ui_text(prop, "Maximum Angular Limit Z", ""); - - /* Limit Booleans */ - prop = RNA_def_property(srna, "use_limit_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", 1); - RNA_def_property_ui_text(prop, "Limit X", "Use minimum/maximum X limit"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "use_limit_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", 2); - RNA_def_property_ui_text(prop, "Limit Y", "Use minimum/maximum y limit"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "use_limit_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", 4); - RNA_def_property_ui_text(prop, "Limit Z", "Use minimum/maximum z limit"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "use_angular_limit_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", 8); - RNA_def_property_ui_text(prop, "Angular X Limit", "Use minimum/maximum X angular limit"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "use_angular_limit_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", 16); - RNA_def_property_ui_text(prop, "Angular Y Limit", "Use minimum/maximum Y angular limit"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); - - prop = RNA_def_property(srna, "use_angular_limit_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", 32); - RNA_def_property_ui_text(prop, "Angular Z Limit", "Use minimum/maximum Z angular limit"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); -} - static void rna_def_constraint_clamp_to(BlenderRNA *brna) { StructRNA *srna; @@ -1519,6 +1577,7 @@ static void rna_def_constraint_clamp_to(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll"); RNA_def_property_ui_text(prop, "Target", "Target Object (Curves only)"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "main_axis", PROP_ENUM, PROP_NONE); @@ -2078,6 +2137,16 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) "Shrink the location to the nearest target surface along a given axis"}, {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", 0, "Nearest Vertex", "Shrink the location to the nearest target vertex"}, + {MOD_SHRINKWRAP_TARGET_PROJECT, "TARGET_PROJECT", 0, "Target Normal Project", + "Shrink the location to the nearest target surface " + "along the interpolated vertex normals of the target"}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem shrink_face_cull_items[] = { + {0, "OFF", 0, "Off", "No culling"}, + {CON_SHRINKWRAP_PROJECT_CULL_FRONTFACE, "FRONT", 0, "Front", "No projection when in front of the face"}, + {CON_SHRINKWRAP_PROJECT_CULL_BACKFACE, "BACK", 0, "Back", "No projection when behind the face"}, {0, NULL, 0, NULL, NULL} }; @@ -2090,13 +2159,20 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll"); RNA_def_property_ui_text(prop, "Target", "Target Mesh object"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "shrinkwrap_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "shrinkType"); RNA_def_property_enum_items(prop, type_items); RNA_def_property_ui_text(prop, "Shrinkwrap Type", "Select type of shrinkwrap algorithm for target position"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); + + prop = RNA_def_property(srna, "wrap_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "shrinkMode"); + RNA_def_property_enum_items(prop, rna_enum_modifier_shrinkwrap_mode_items); + RNA_def_property_ui_text(prop, "Snap Mode", "Select how to constrain the object to the target surface"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); @@ -2123,6 +2199,36 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0.0f, 100.0f, 10, 3); RNA_def_property_ui_text(prop, "Project Distance", "Limit the distance used for projection (zero disables)"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "use_project_opposite", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CON_SHRINKWRAP_PROJECT_OPPOSITE); + RNA_def_property_ui_text(prop, "Project Opposite", "Project in both specified and opposite directions"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "cull_face", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, shrink_face_cull_items); + RNA_def_property_enum_funcs(prop, "rna_ShrinkwrapConstraint_face_cull_get", + "rna_ShrinkwrapConstraint_face_cull_set", NULL); + RNA_def_property_ui_text(prop, "Face Cull", + "Stop vertices from projecting to a face on the target when facing towards/away"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "use_invert_cull", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CON_SHRINKWRAP_PROJECT_INVERT_CULL); + RNA_def_property_ui_text(prop, "Invert Cull", "When projecting in the opposite direction invert the face cull mode"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "use_track_normal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CON_SHRINKWRAP_TRACK_NORMAL); + RNA_def_property_ui_text(prop, "Align Axis To Normal", "Align the specified axis to the surface normal"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); + + prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "trackAxis"); + RNA_def_property_enum_items(prop, track_axis_items); + RNA_def_property_ui_text(prop, "Track Axis", "Axis that is aligned to the normal"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_damped_track(BlenderRNA *brna) @@ -2130,16 +2236,6 @@ static void rna_def_constraint_damped_track(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem damptrack_items[] = { - {TRACK_X, "TRACK_X", 0, "X", ""}, - {TRACK_Y, "TRACK_Y", 0, "Y", ""}, - {TRACK_Z, "TRACK_Z", 0, "Z", ""}, - {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""}, - {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""}, - {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "DampedTrackConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Damped Track Constraint", "Point toward target by taking the shortest rotation path"); @@ -2152,7 +2248,7 @@ rna_def_constraint_headtail_common(srna); prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "trackflag"); - RNA_def_property_enum_items(prop, damptrack_items); + RNA_def_property_enum_items(prop, track_axis_items); RNA_def_property_ui_text(prop, "Track Axis", "Axis that points to the target object"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); } @@ -2183,6 +2279,7 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll"); RNA_def_property_ui_text(prop, "Target", "Curve that controls this relationship"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "chain_count", PROP_INT, PROP_NONE); @@ -2301,6 +2398,7 @@ static void rna_def_constraint_pivot(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "tar"); RNA_def_property_ui_text(prop, "Target", "Target Object, defining the position of the pivot when defined"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); @@ -2351,6 +2449,7 @@ static void rna_def_constraint_follow_track(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "clip"); RNA_def_property_ui_text(prop, "Movie Clip", "Movie Clip to get tracking data from"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); /* track */ @@ -2383,6 +2482,7 @@ static void rna_def_constraint_follow_track(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Camera", "Camera to which motion is parented (if empty active scene camera is used)"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_followTrack_camera_set", NULL, "rna_Constraint_cameraObject_poll"); @@ -2393,6 +2493,7 @@ static void rna_def_constraint_follow_track(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Depth Object", "Object used to define depth in camera space by projecting onto surface of this object"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_followTrack_depthObject_set", NULL, "rna_Constraint_followTrack_depthObject_poll"); @@ -2425,6 +2526,7 @@ static void rna_def_constraint_camera_solver(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "clip"); RNA_def_property_ui_text(prop, "Movie Clip", "Movie Clip to get tracking data from"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); /* use default clip */ @@ -2448,6 +2550,7 @@ static void rna_def_constraint_object_solver(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "clip"); RNA_def_property_ui_text(prop, "Movie Clip", "Movie Clip to get tracking data from"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); /* use default clip */ @@ -2468,6 +2571,7 @@ static void rna_def_constraint_object_solver(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Camera", "Camera to which motion is parented (if empty active scene camera is used)"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_objectSolver_camera_set", NULL, "rna_Constraint_cameraObject_poll"); @@ -2487,6 +2591,7 @@ static void rna_def_constraint_transform_cache(BlenderRNA *brna) RNA_def_property_struct_type(prop, "CacheFile"); RNA_def_property_ui_text(prop, "Cache File", ""); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, 0, "rna_Constraint_dependency_update"); prop = RNA_def_property(srna, "object_path", PROP_STRING, PROP_NONE); @@ -2536,10 +2641,12 @@ void RNA_def_constraint(BlenderRNA *brna) /* flags */ prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_OFF); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Disable", "Enable/Disable Constraint"); prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_EXPAND); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Expanded", "Constraint's panel is expanded in UI"); RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); @@ -2581,9 +2688,11 @@ void RNA_def_constraint(BlenderRNA *brna) /* pointers */ rna_def_constrainttarget(brna); + rna_def_constrainttarget_bone(brna); rna_def_constraint_childof(brna); rna_def_constraint_python(brna); + rna_def_constraint_armature_deform(brna); rna_def_constraint_stretch_to(brna); rna_def_constraint_follow_path(brna); rna_def_constraint_locked_track(brna); @@ -2596,7 +2705,6 @@ void RNA_def_constraint(BlenderRNA *brna) rna_def_constraint_minmax(brna); rna_def_constraint_track_to(brna); rna_def_constraint_kinematic(brna); - rna_def_constraint_rigid_body_joint(brna); rna_def_constraint_clamp_to(brna); rna_def_constraint_distance_limit(brna); rna_def_constraint_size_limit(brna); diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 04b531740ed..618cefe13e5 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -34,11 +34,36 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "rna_internal.h" /* own include */ +const EnumPropertyItem rna_enum_context_mode_items[] = { + {CTX_MODE_EDIT_MESH, "EDIT_MESH", 0, "Mesh Edit", ""}, + {CTX_MODE_EDIT_CURVE, "EDIT_CURVE", 0, "Curve Edit", ""}, + {CTX_MODE_EDIT_SURFACE, "EDIT_SURFACE", 0, "Surface Edit", ""}, + {CTX_MODE_EDIT_TEXT, "EDIT_TEXT", 0, "Edit Edit", ""}, + {CTX_MODE_EDIT_ARMATURE, "EDIT_ARMATURE", 0, "Armature Edit", ""}, /* PARSKEL reuse will give issues */ + {CTX_MODE_EDIT_METABALL, "EDIT_METABALL", 0, "Metaball Edit", ""}, + {CTX_MODE_EDIT_LATTICE, "EDIT_LATTICE", 0, "Lattice Edit", ""}, + {CTX_MODE_POSE, "POSE", 0, "Pose ", ""}, + {CTX_MODE_SCULPT, "SCULPT", 0, "Sculpt", ""}, + {CTX_MODE_PAINT_WEIGHT, "PAINT_WEIGHT", 0, "Weight Paint", ""}, + {CTX_MODE_PAINT_VERTEX, "PAINT_VERTEX", 0, "Vertex Paint", ""}, + {CTX_MODE_PAINT_TEXTURE, "PAINT_TEXTURE", 0, "Texture Paint", ""}, + {CTX_MODE_PARTICLE, "PARTICLE", 0, "Particle", ""}, + {CTX_MODE_OBJECT, "OBJECT", 0, "Object", ""}, + {CTX_MODE_GPENCIL_PAINT, "GPENCIL_PAINT", 0, "Grease Pencil Paint", "" }, + {CTX_MODE_GPENCIL_EDIT, "GPENCIL_EDIT", 0, "Grease Pencil Edit", "" }, + {CTX_MODE_GPENCIL_SCULPT, "GPENCIL_SCULPT", 0, "Grease Pencil Sculpt", "" }, + {CTX_MODE_GPENCIL_WEIGHT, "GPENCIL_WEIGHT", 0, "Grease Pencil Weight Paint", "" }, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME +#include "RE_engine.h" + static PointerRNA rna_Context_manager_get(PointerRNA *ptr) { bContext *C = (bContext *)ptr->data; @@ -51,6 +76,12 @@ static PointerRNA rna_Context_window_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_Window, CTX_wm_window(C)); } +static PointerRNA rna_Context_workspace_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_WorkSpace, CTX_wm_workspace(C)); +} + static PointerRNA rna_Context_screen_get(PointerRNA *ptr) { bContext *C = (bContext *)ptr->data; @@ -95,18 +126,69 @@ static PointerRNA rna_Context_region_data_get(PointerRNA *ptr) return PointerRNA_NULL; } +static PointerRNA rna_Context_gizmo_group_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + PointerRNA newptr; + RNA_pointer_create(NULL, &RNA_GizmoGroup, CTX_wm_gizmo_group(C), &newptr); + return newptr; +} + static PointerRNA rna_Context_main_get(PointerRNA *ptr) { bContext *C = (bContext *)ptr->data; return rna_pointer_inherit_refine(ptr, &RNA_BlendData, CTX_data_main(C)); } +static PointerRNA rna_Context_depsgraph_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_Depsgraph, CTX_data_depsgraph(C)); +} + static PointerRNA rna_Context_scene_get(PointerRNA *ptr) { bContext *C = (bContext *)ptr->data; return rna_pointer_inherit_refine(ptr, &RNA_Scene, CTX_data_scene(C)); } +static PointerRNA rna_Context_view_layer_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + Scene *scene = CTX_data_scene(C); + PointerRNA scene_ptr; + + RNA_id_pointer_create(&scene->id, &scene_ptr); + return rna_pointer_inherit_refine(&scene_ptr, &RNA_ViewLayer, CTX_data_view_layer(C)); +} + +static void rna_Context_engine_get(PointerRNA *ptr, char *value) + { + bContext *C = (bContext *)ptr->data; + RenderEngineType *engine_type = CTX_data_engine_type(C); + strcpy(value, engine_type->idname); +} + +static int rna_Context_engine_length(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + RenderEngineType *engine_type = CTX_data_engine_type(C); + return strlen(engine_type->idname); +} + +static PointerRNA rna_Context_collection_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_Collection, CTX_data_collection(C)); +} + +static PointerRNA rna_Context_layer_collection_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + ptr->id.data = CTX_data_scene(C); + return rna_pointer_inherit_refine(ptr, &RNA_LayerCollection, CTX_data_layer_collection(C)); +} + static PointerRNA rna_Context_tool_settings_get(PointerRNA *ptr) { bContext *C = (bContext *)ptr->data; @@ -134,24 +216,6 @@ void RNA_def_context(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem mode_items[] = { - {CTX_MODE_EDIT_MESH, "EDIT_MESH", 0, "Mesh Edit", ""}, - {CTX_MODE_EDIT_CURVE, "EDIT_CURVE", 0, "Curve Edit", ""}, - {CTX_MODE_EDIT_SURFACE, "EDIT_SURFACE", 0, "Surface Edit", ""}, - {CTX_MODE_EDIT_TEXT, "EDIT_TEXT", 0, "Edit Edit", ""}, - {CTX_MODE_EDIT_ARMATURE, "EDIT_ARMATURE", 0, "Armature Edit", ""}, /* PARSKEL reuse will give issues */ - {CTX_MODE_EDIT_METABALL, "EDIT_METABALL", 0, "Metaball Edit", ""}, - {CTX_MODE_EDIT_LATTICE, "EDIT_LATTICE", 0, "Lattice Edit", ""}, - {CTX_MODE_POSE, "POSE", 0, "Pose ", ""}, - {CTX_MODE_SCULPT, "SCULPT", 0, "Sculpt", ""}, - {CTX_MODE_PAINT_WEIGHT, "PAINT_WEIGHT", 0, "Weight Paint", ""}, - {CTX_MODE_PAINT_VERTEX, "PAINT_VERTEX", 0, "Vertex Paint", ""}, - {CTX_MODE_PAINT_TEXTURE, "PAINT_TEXTURE", 0, "Texture Paint", ""}, - {CTX_MODE_PARTICLE, "PARTICLE", 0, "Particle", ""}, - {CTX_MODE_OBJECT, "OBJECT", 0, "Object", ""}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "Context", NULL); RNA_def_struct_ui_text(srna, "Context", "Current windowmanager and data context"); RNA_def_struct_sdna(srna, "bContext"); @@ -167,6 +231,11 @@ void RNA_def_context(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Window"); RNA_def_property_pointer_funcs(prop, "rna_Context_window_get", NULL, NULL, NULL); + prop = RNA_def_property(srna, "workspace", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "WorkSpace"); + RNA_def_property_pointer_funcs(prop, "rna_Context_workspace_get", NULL, NULL, NULL); + prop = RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Screen"); @@ -192,17 +261,46 @@ void RNA_def_context(BlenderRNA *brna) RNA_def_property_struct_type(prop, "RegionView3D"); RNA_def_property_pointer_funcs(prop, "rna_Context_region_data_get", NULL, NULL, NULL); + prop = RNA_def_property(srna, "gizmo_group", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "GizmoGroup"); + RNA_def_property_pointer_funcs(prop, "rna_Context_gizmo_group_get", NULL, NULL, NULL); + /* Data */ prop = RNA_def_property(srna, "blend_data", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "BlendData"); RNA_def_property_pointer_funcs(prop, "rna_Context_main_get", NULL, NULL, NULL); + prop = RNA_def_property(srna, "depsgraph", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "Depsgraph"); + RNA_def_property_pointer_funcs(prop, "rna_Context_depsgraph_get", NULL, NULL, NULL); + prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Scene"); RNA_def_property_pointer_funcs(prop, "rna_Context_scene_get", NULL, NULL, NULL); + prop = RNA_def_property(srna, "view_layer", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "ViewLayer"); + RNA_def_property_pointer_funcs(prop, "rna_Context_view_layer_get", NULL, NULL, NULL); + + prop = RNA_def_property(srna, "engine", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs(prop, "rna_Context_engine_get", "rna_Context_engine_length", NULL); + + prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "Collection"); + RNA_def_property_pointer_funcs(prop, "rna_Context_collection_get", NULL, NULL, NULL); + + prop = RNA_def_property(srna, "layer_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "LayerCollection"); + RNA_def_property_pointer_funcs(prop, "rna_Context_layer_collection_get", NULL, NULL, NULL); + prop = RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "ToolSettings"); @@ -214,7 +312,7 @@ void RNA_def_context(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_Context_user_preferences_get", NULL, NULL, NULL); prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_enum_items(prop, rna_enum_context_mode_items); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_funcs(prop, "rna_Context_mode_get", NULL, NULL); } diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c deleted file mode 100644 index 606f482c92e..00000000000 --- a/source/blender/makesrna/intern/rna_controller.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Blender Foundation (2008). - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/makesrna/intern/rna_controller.c - * \ingroup RNA - */ - -#include <stdlib.h> - -#include "DNA_object_types.h" -#include "DNA_controller_types.h" - -#include "BLI_string_utils.h" -#include "BLI_utildefines.h" - -#include "BLT_translation.h" - -#include "RNA_define.h" -#include "RNA_enum_types.h" - -#include "rna_internal.h" - -#include "WM_types.h" - -const EnumPropertyItem rna_enum_controller_type_items[] = { - {CONT_LOGIC_AND, "LOGIC_AND", 0, "And", "Logic And"}, - {CONT_LOGIC_OR, "LOGIC_OR", 0, "Or", "Logic Or"}, - {CONT_LOGIC_NAND, "LOGIC_NAND", 0, "Nand", "Logic Nand"}, - {CONT_LOGIC_NOR, "LOGIC_NOR", 0, "Nor", "Logic Nor"}, - {CONT_LOGIC_XOR, "LOGIC_XOR", 0, "Xor", "Logic Xor"}, - {CONT_LOGIC_XNOR, "LOGIC_XNOR", 0, "Xnor", "Logic Xnor"}, - {CONT_EXPRESSION, "EXPRESSION", 0, "Expression", ""}, - {CONT_PYTHON, "PYTHON", 0, "Python", ""}, - {0, NULL, 0, NULL, NULL} -}; - -#ifdef RNA_RUNTIME - -#include "BKE_sca.h" -#include "DNA_actuator_types.h" - -static StructRNA *rna_Controller_refine(struct PointerRNA *ptr) -{ - bController *controller = (bController *)ptr->data; - - switch (controller->type) { - case CONT_LOGIC_AND: - return &RNA_AndController; - case CONT_LOGIC_OR: - return &RNA_OrController; - case CONT_LOGIC_NAND: - return &RNA_NandController; - case CONT_LOGIC_NOR: - return &RNA_NorController; - case CONT_LOGIC_XOR: - return &RNA_XorController; - case CONT_LOGIC_XNOR: - return &RNA_XnorController; - case CONT_EXPRESSION: - return &RNA_ExpressionController; - case CONT_PYTHON: - return &RNA_PythonController; - default: - return &RNA_Controller; - } -} - -static void rna_Constroller_name_set(PointerRNA *ptr, const char *value) -{ - Object *ob = ptr->id.data; - bController *cont = ptr->data; - BLI_strncpy_utf8(cont->name, value, sizeof(cont->name)); - BLI_uniquename(&ob->controllers, cont, DATA_("Controller"), '.', offsetof(bController, name), sizeof(cont->name)); -} - -static void rna_Controller_type_set(struct PointerRNA *ptr, int value) -{ - bController *cont = (bController *)ptr->data; - - if (value != cont->type) { - cont->type = value; - init_controller(cont); - } -} - -static void rna_Controller_mode_set(struct PointerRNA *ptr, int value) -{ - bController *cont = (bController *)ptr->data; - bPythonCont *pycon = (bPythonCont *)cont->data; - - /* if mode changed and previous mode were Script */ - if (value != pycon->mode && pycon->mode == CONT_PY_SCRIPT) { - /* clear script to avoid it to get linked with the controller */ - pycon->text = NULL; - } - pycon->mode = value; -} - -static int rna_Controller_state_number_get(struct PointerRNA *ptr) -{ - bController *cont = (bController *)ptr->data; - int bit; - - for (bit = 0; bit < 32; bit++) { - if (cont->state_mask & (1u << bit)) - return bit + 1; - } - return 0; -} - -static void rna_Controller_state_number_set(struct PointerRNA *ptr, const int value) -{ - bController *cont = (bController *)ptr->data; - if (value < 1 || value > OB_MAX_STATES) - return; - - cont->state_mask = (1 << (value - 1)); -} - -static void rna_Controller_actuators_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - bController *cont = (bController *)ptr->data; - rna_iterator_array_begin(iter, cont->links, sizeof(bActuator *), (int)cont->totlinks, 0, NULL); -} - -static int rna_Controller_actuators_length(PointerRNA *ptr) -{ - bController *cont = (bController *)ptr->data; - return (int) cont->totlinks; -} - -#if 0 /* editable is set to false, comment for now. */ -static void rna_Controller_state_get(PointerRNA *ptr, int *values) -{ - bController *cont = (bController *)ptr->data; - int i; - - memset(values, 0, sizeof(int) * OB_MAX_STATES); - for (i = 0; i < OB_MAX_STATES; i++) - values[i] = (cont->state_mask & (1 << i)); -} - -static void rna_Controller_state_set(PointerRNA *ptr, const bool *values) -{ - bController *cont = (bController *)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; - - /* only works for one state at once */ - if (tot > 1) - return; - - for (i = 0; i < OB_MAX_STATES; i++) { - if (values[i]) cont->state_mask |= (1 << i); - else cont->state_mask &= ~(1 << i); - } -} -#endif - -#else - -void RNA_def_controller(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem python_controller_modes[] = { - {CONT_PY_SCRIPT, "SCRIPT", 0, "Script", ""}, - {CONT_PY_MODULE, "MODULE", 0, "Module", ""}, - {0, NULL, 0, NULL, NULL} - }; - - /* Controller */ - srna = RNA_def_struct(brna, "Controller", NULL); - RNA_def_struct_sdna(srna, "bController"); - RNA_def_struct_refine_func(srna, "rna_Controller_refine"); - RNA_def_struct_ui_text(srna, "Controller", - "Game engine logic brick to process events, connecting sensors to actuators"); - - RNA_api_controller(srna); - - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Name", ""); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Constroller_name_set"); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_enum_funcs(prop, NULL, "rna_Controller_type_set", NULL); - RNA_def_property_enum_items(prop, rna_enum_controller_type_items); - RNA_def_property_ui_text(prop, "Type", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_SHOW); - RNA_def_property_ui_text(prop, "Expanded", "Set controller expanded in the user interface"); - RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONT_DEACTIVATE); - RNA_def_property_ui_text(prop, "Active", "Set the active state of the controller"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_priority", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_PRIO); - RNA_def_property_ui_text(prop, "Priority", - "Mark controller for execution before all non-marked controllers " - "(good for startup scripts)"); - RNA_def_property_ui_icon(prop, ICON_BOOKMARKS, 1); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "actuators", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "links", NULL); - RNA_def_property_struct_type(prop, "Actuator"); - RNA_def_property_ui_text(prop, "Actuators", "The list containing the actuators connected to the controller"); - RNA_def_property_collection_funcs(prop, "rna_Controller_actuators_begin", "rna_iterator_array_next", - "rna_iterator_array_end", "rna_iterator_array_dereference_get", - "rna_Controller_actuators_length", NULL, NULL, NULL); - - /* State */ - - /* array of OB_MAX_STATES */ - /*prop = RNA_def_property(srna, "states", PROP_BOOLEAN, PROP_LAYER_MEMBER); */ - /*RNA_def_property_array(prop, OB_MAX_STATES); */ - /*RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ - /*RNA_def_property_ui_text(prop, "", "Set Controller state index (1 to 30)"); */ - /*RNA_def_property_boolean_funcs(prop, "rna_Controller_state_get", "rna_Controller_state_set"); */ - /*RNA_def_property_update(prop, NC_LOGIC, NULL); */ - - /* number of the state */ - prop = RNA_def_property(srna, "states", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "state_mask"); - RNA_def_property_range(prop, 1, OB_MAX_STATES); - RNA_def_property_ui_text(prop, "", "Set Controller state index (1 to 30)"); - RNA_def_property_int_funcs(prop, "rna_Controller_state_number_get", "rna_Controller_state_number_set", NULL); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* Expression Controller */ - srna = RNA_def_struct(brna, "ExpressionController", "Controller"); - RNA_def_struct_sdna_from(srna, "bExpressionCont", "data"); - RNA_def_struct_ui_text(srna, "Expression Controller", - "Controller passing on events based on the evaluation of an expression"); - - prop = RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "str"); - RNA_def_property_ui_text(prop, "Expression", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* Python Controller */ - srna = RNA_def_struct(brna, "PythonController", "Controller"); - RNA_def_struct_sdna_from(srna, "bPythonCont", "data"); - RNA_def_struct_ui_text(srna, "Python Controller", "Controller executing a python script"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, python_controller_modes); - RNA_def_property_enum_funcs(prop, NULL, "rna_Controller_mode_set", NULL); - RNA_def_property_ui_text(prop, "Execution Method", "Python script type (textblock or module - faster)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Text"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Text", "Text data-block with the python script"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "module", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Module", - "Module name and function to run, e.g. \"someModule.main\" " - "(internal texts and external python files can be used)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "use_debug", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_PY_DEBUG); - RNA_def_property_ui_text(prop, "D", - "Continuously reload the module from disk for editing external modules " - "without restarting"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* Other Controllers */ - srna = RNA_def_struct(brna, "AndController", "Controller"); - RNA_def_struct_ui_text(srna, "And Controller", "Controller passing on events based on a logical AND operation"); - - srna = RNA_def_struct(brna, "OrController", "Controller"); - RNA_def_struct_ui_text(srna, "Or Controller", "Controller passing on events based on a logical OR operation"); - - srna = RNA_def_struct(brna, "NorController", "Controller"); - RNA_def_struct_ui_text(srna, "Nor Controller", "Controller passing on events based on a logical NOR operation"); - - srna = RNA_def_struct(brna, "NandController", "Controller"); - RNA_def_struct_ui_text(srna, "Nand Controller", "Controller passing on events based on a logical NAND operation"); - - srna = RNA_def_struct(brna, "XorController", "Controller"); - RNA_def_struct_ui_text(srna, "Xor Controller", "Controller passing on events based on a logical XOR operation"); - - srna = RNA_def_struct(brna, "XnorController", "Controller"); - RNA_def_struct_ui_text(srna, "Xnor Controller", "Controller passing on events based on a logical XNOR operation"); -} - -#endif diff --git a/source/blender/makesrna/intern/rna_controller_api.c b/source/blender/makesrna/intern/rna_controller_api.c deleted file mode 100644 index c36d678e064..00000000000 --- a/source/blender/makesrna/intern/rna_controller_api.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2010 Blender Foundation. - * All rights reserved. - * - * - * Contributor(s): - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/makesrna/intern/rna_controller_api.c - * \ingroup RNA - */ - - -#include <stdlib.h> -#include <stdio.h> - -#include "WM_types.h" -#include "RNA_define.h" - -#include "rna_internal.h" /* own include */ - -#ifdef RNA_RUNTIME - -#include "BKE_sca.h" -#include "DNA_sensor_types.h" -#include "DNA_controller_types.h" -#include "DNA_actuator_types.h" - -static void rna_Controller_link(bController *cont, bSensor *sens, bActuator *act) -{ - if (sens) - link_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks, sizeof(bController *)); - if (act) - link_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks, sizeof(bActuator *)); -} - -static void rna_Controller_unlink(bController *cont, bSensor *sens, bActuator *act) -{ - if (sens) - unlink_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks); - if (act) - unlink_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks); -} - -#else - -void RNA_api_controller(StructRNA *srna) -{ - FunctionRNA *func; - PropertyRNA *parm; - - func = RNA_def_function(srna, "link", "rna_Controller_link"); - RNA_def_function_ui_description(func, "Link the controller with a sensor/actuator"); - parm = RNA_def_pointer(func, "sensor", "Sensor", "", "Sensor to link the controller to"); - RNA_def_property_update(parm, NC_LOGIC, NULL); - parm = RNA_def_pointer(func, "actuator", "Actuator", "", "Actuator to link the controller to"); - RNA_def_property_update(parm, NC_LOGIC, NULL); - - func = RNA_def_function(srna, "unlink", "rna_Controller_unlink"); - RNA_def_function_ui_description(func, "Unlink the controller from a sensor/actuator"); - parm = RNA_def_pointer(func, "sensor", "Sensor", "", "Sensor to unlink the controller from"); - RNA_def_property_update(parm, NC_LOGIC, NULL); - parm = RNA_def_pointer(func, "actuator", "Actuator", "", "Actuator to unlink the controller from"); - RNA_def_property_update(parm, NC_LOGIC, NULL); -} - -#endif diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 233303ef613..e9671754288 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -57,11 +57,11 @@ static const EnumPropertyItem beztriple_handle_type_items[] = { #endif const EnumPropertyItem rna_enum_keyframe_handle_type_items[] = { - {HD_FREE, "FREE", 0, "Free", ""}, - {HD_VECT, "VECTOR", 0, "Vector", ""}, - {HD_ALIGN, "ALIGNED", 0, "Aligned", ""}, - {HD_AUTO, "AUTO", 0, "Automatic", ""}, - {HD_AUTO_ANIM, "AUTO_CLAMPED", 0, "Auto Clamped", "Auto handles clamped to not overshoot"}, + {HD_FREE, "FREE", ICON_HANDLETYPE_FREE_VEC, "Free", "Completely independent manually set handle"}, + {HD_ALIGN, "ALIGNED", ICON_HANDLETYPE_ALIGNED_VEC, "Aligned", "Manually set handle with rotation locked together with its pair"}, + {HD_VECT, "VECTOR", ICON_HANDLETYPE_VECTOR_VEC, "Vector", "Automatic handles that create straight lines"}, + {HD_AUTO, "AUTO", ICON_HANDLETYPE_AUTO_VEC, "Automatic", "Automatic handles that create smooth curves"}, + {HD_AUTO_ANIM, "AUTO_CLAMPED", ICON_HANDLETYPE_AUTO_CLAMP_VEC, "Auto Clamped", "Automatic handles that create smooth curves which only change direction at keyframes"}, {0, NULL, 0, NULL, NULL} }; @@ -124,9 +124,11 @@ static const EnumPropertyItem curve2d_fill_mode_items[] = { #include "DNA_object_types.h" #include "BKE_curve.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "WM_api.h" #include "MEM_guardedalloc.h" @@ -338,7 +340,7 @@ static void rna_BPoint_array_begin(CollectionPropertyIterator *iter, PointerRNA static void rna_Curve_update_data_id(Main *UNUSED(bmain), Scene *UNUSED(scene), ID *id) { - DAG_id_tag_update(id, 0); + DEG_id_tag_update(id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, id); } @@ -349,7 +351,7 @@ static void rna_Curve_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Curve_update_deps(Main *bmain, Scene *scene, PointerRNA *ptr) { - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); rna_Curve_update_data(bmain, scene, ptr); } @@ -638,7 +640,7 @@ static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, PointerRNA * BKE_nurb_free(nu); RNA_POINTER_INVALIDATE(nu_ptr); - DAG_id_tag_update(&cu->id, OB_RECALC_DATA); + DEG_id_tag_update(&cu->id, OB_RECALC_DATA); WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); } @@ -648,7 +650,7 @@ static void rna_Curve_spline_clear(Curve *cu) BKE_nurbList_free(nurbs); - DAG_id_tag_update(&cu->id, OB_RECALC_DATA); + DEG_id_tag_update(&cu->id, OB_RECALC_DATA); WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); } @@ -954,19 +956,21 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna) PropertyRNA *prop; static const EnumPropertyItem prop_align_items[] = { - {CU_ALIGN_X_LEFT, "LEFT", 0, "Left", "Align text to the left"}, - {CU_ALIGN_X_MIDDLE, "CENTER", 0, "Center", "Center text"}, - {CU_ALIGN_X_RIGHT, "RIGHT", 0, "Right", "Align text to the right"}, - {CU_ALIGN_X_JUSTIFY, "JUSTIFY", 0, "Justify", "Align to the left and the right"}, - {CU_ALIGN_X_FLUSH, "FLUSH", 0, "Flush", "Align to the left and the right, with equal character spacing"}, + {CU_ALIGN_X_LEFT, "LEFT", ICON_ALIGN_LEFT, "Left", "Align text to the left"}, + {CU_ALIGN_X_MIDDLE, "CENTER", ICON_ALIGN_CENTER, "Center", "Center text"}, + {CU_ALIGN_X_RIGHT, "RIGHT", ICON_ALIGN_RIGHT, "Right", "Align text to the right"}, + {CU_ALIGN_X_JUSTIFY, "JUSTIFY", ICON_ALIGN_JUSTIFY, "Justify", "Align to the left and the right"}, + {CU_ALIGN_X_FLUSH, "FLUSH", ICON_ALIGN_FLUSH, "Flush", "Align to the left and the right, with equal character spacing"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem prop_align_y_items[] = { - {CU_ALIGN_Y_TOP_BASELINE, "TOP_BASELINE", 0, "Top Base-Line", "Align to top but use the base-line of the text"}, - {CU_ALIGN_Y_TOP, "TOP", 0, "Top", "Align text to the top"}, - {CU_ALIGN_Y_CENTER, "CENTER", 0, "Center", "Align text to the middle"}, - {CU_ALIGN_Y_BOTTOM, "BOTTOM", 0, "Bottom", "Align text to the bottom"}, + {CU_ALIGN_Y_TOP_BASELINE, "TOP_BASELINE", ICON_ALIGN_TOP, "Top Base-Line", "Align to top but use the base-line of the text"}, + {CU_ALIGN_Y_TOP, "TOP", ICON_ALIGN_TOP, "Top", "Align text to the top"}, + {CU_ALIGN_Y_CENTER, "CENTER", ICON_ALIGN_MIDDLE, "Center", "Align text to the middle"}, + {CU_ALIGN_Y_BOTTOM, "BOTTOM", ICON_ALIGN_BOTTOM, "Bottom", "Align text to the bottom"}, + {CU_ALIGN_Y_BOTTOM_BASELINE, "BOTTOM_BASELINE", ICON_ALIGN_BOTTOM, "Bottom Base-Line", + "Align text to the bottom but use the base-line of the text"}, {0, NULL, 0, NULL, NULL} }; @@ -1175,16 +1179,19 @@ static void rna_def_charinfo(BlenderRNA *brna) prop = RNA_def_property(srna, "use_bold", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_BOLD); RNA_def_property_ui_text(prop, "Bold", ""); + RNA_def_property_ui_icon(prop, ICON_BOLD, 0); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop = RNA_def_property(srna, "use_italic", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_ITALIC); RNA_def_property_ui_text(prop, "Italic", ""); + RNA_def_property_ui_icon(prop, ICON_ITALIC, 0); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop = RNA_def_property(srna, "use_underline", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_UNDERLINE); RNA_def_property_ui_text(prop, "Underline", ""); + RNA_def_property_ui_icon(prop, ICON_UNDERLINE, 0); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* probably there is no reason to expose this */ @@ -1198,6 +1205,7 @@ static void rna_def_charinfo(BlenderRNA *brna) prop = RNA_def_property(srna, "use_small_caps", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_SMALLCAPS); RNA_def_property_ui_text(prop, "Small Caps", ""); + RNA_def_property_ui_icon(prop, ICON_SMALL_CAPS, 0); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED); @@ -1240,7 +1248,7 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop) /*PropertyRNA *prop; */ FunctionRNA *func; - /*PropertyRNA *parm; */ + PropertyRNA *parm; RNA_def_property_srna(cprop, "SplinePoints"); srna = RNA_def_struct(brna, "SplinePoints", NULL); @@ -1250,7 +1258,8 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "rna_Curve_spline_points_add"); RNA_def_function_ui_description(func, "Add a number of points to this spline"); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS); - RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + parm = RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); #if 0 func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); @@ -1268,7 +1277,7 @@ static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop) /*PropertyRNA *prop; */ FunctionRNA *func; - /*PropertyRNA *parm; */ + PropertyRNA *parm; RNA_def_property_srna(cprop, "SplineBezierPoints"); srna = RNA_def_struct(brna, "SplineBezierPoints", NULL); @@ -1278,7 +1287,8 @@ static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add"); RNA_def_function_ui_description(func, "Add a number of points to this spline"); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS); - RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + parm = RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); #if 0 func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); @@ -1379,16 +1389,6 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Splines", "Collection of splines in this curve data object"); rna_def_curve_splines(brna, prop); - prop = RNA_def_property(srna, "show_handles", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", CU_HIDE_HANDLES); - RNA_def_property_ui_text(prop, "Draw Handles", "Display Bezier handles in editmode"); - RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL); - - prop = RNA_def_property(srna, "show_normal_face", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", CU_HIDE_NORMALS); - RNA_def_property_ui_text(prop, "Draw Normals", "Display 3D curve normals in editmode"); - RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL); - rna_def_path(brna, srna); /* Number values */ diff --git a/source/blender/makesrna/intern/rna_curve_api.c b/source/blender/makesrna/intern/rna_curve_api.c index d83a843c5c1..4e870d64f1c 100644 --- a/source/blender/makesrna/intern/rna_curve_api.c +++ b/source/blender/makesrna/intern/rna_curve_api.c @@ -47,8 +47,14 @@ static void rna_Curve_transform(Curve *cu, float *mat, bool shape_keys) { BKE_curve_transform(cu, (float (*)[4])mat, shape_keys, true); - DAG_id_tag_update(&cu->id, 0); + DEG_id_tag_update(&cu->id, 0); } + +static void rna_Curve_update_gpu_tag(Curve *cu) +{ + BKE_curve_batch_cache_dirty_tag(cu, BKE_CURVE_BATCH_DIRTY_ALL); +} + static float rna_Nurb_calc_length(Nurb *nu, int resolution_u) { return BKE_nurb_calc_length(nu, resolution_u); @@ -72,6 +78,8 @@ void RNA_api_curve(StructRNA *srna) "has had invalid indices corrected (to default 0)"); parm = RNA_def_boolean(func, "result", 0, "Result", ""); RNA_def_function_return(func, parm); + + RNA_def_function(srna, "update_gpu_tag", "rna_Curve_update_gpu_tag"); } void RNA_api_curve_nurb(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 697e23a414a..6724315f376 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1165,7 +1165,8 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier case PROP_STRING: { StringPropertyRNA *sprop = (StringPropertyRNA *)prop; - + /* By default don't allow NULL string args, callers may clear. */ + RNA_def_property_flag(prop, PROP_NEVER_NULL); sprop->defaultvalue = ""; break; } @@ -1270,6 +1271,14 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier #endif } + /* Override handling. */ + if (DefRNA.preprocess) { + prop->override_diff = (RNAPropOverrideDiff)"rna_property_override_diff_default"; + prop->override_store = (RNAPropOverrideStore)"rna_property_override_store_default"; + prop->override_apply = (RNAPropOverrideApply)"rna_property_override_apply_default"; + } + /* TODO: do we want that for runtime-defined stuff too? I’d say no, but... maybe yes :/ */ + rna_addtail(&cont->properties, prop); return prop; @@ -1285,6 +1294,16 @@ void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag) prop->flag &= ~flag; } +void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag) +{ + prop->flag_override |= flag; +} + +void RNA_def_property_override_clear_flag(PropertyRNA *prop, PropertyOverrideFlag flag) +{ + prop->flag_override &= ~flag; +} + /** * Add the property-tags passed as \a tags to \a prop (if valid). * @@ -1408,11 +1427,13 @@ void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *d prop->description = description; } -void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, bool consecutive) +void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive) { prop->icon = icon; - if (consecutive) + if (consecutive != 0) prop->flag |= PROP_ICONS_CONSECUTIVE; + if (consecutive < 0) + prop->flag |= PROP_ICONS_REVERSE; } /** @@ -1860,7 +1881,7 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *stru return dp; } else { - fprintf(stderr, "%s: \"%s.%s\" (identifier \"%s\") not found.\n", + fprintf(stderr, "%s: \"%s.%s\" (identifier \"%s\") not found. Struct must be in DNA.\n", __func__, structname, propname, prop->identifier); DefRNA.error = 1; return NULL; @@ -2222,6 +2243,29 @@ void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editabl if (editable) prop->itemeditable = (ItemEditableFunc)editable; } +/** + * Set custom callbacks for override operations handling. + * + * \note \a diff callback will also be used by RNA comparison/equality functions. + */ +void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, const char *apply) +{ + if (!DefRNA.preprocess) { + fprintf(stderr, "%s: only during preprocessing.\n", __func__); + return; + } + + if (diff) { + prop->override_diff = (RNAPropOverrideDiff)diff; + } + if (store) { + prop->override_store = (RNAPropOverrideStore)store; + } + if (apply) { + prop->override_apply = (RNAPropOverrideApply)apply; + } +} + void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func) { if (!DefRNA.preprocess) { @@ -2241,7 +2285,7 @@ void RNA_def_property_update_runtime(PropertyRNA *prop, const void *func) void RNA_def_property_poll_runtime(PropertyRNA *prop, const void *func) { if (prop->type == PROP_POINTER) { - ((PointerPropertyRNA *)prop)->poll = func; + ((PointerPropertyRNA *)prop)->poll = (void *)func; } else { fprintf(stderr, "%s: %s is not a Pointer Property.\n", __func__, prop->identifier); diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c index c6b18d8d387..7bfd3f679d8 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.c +++ b/source/blender/makesrna/intern/rna_depsgraph.c @@ -34,16 +34,173 @@ #include "rna_internal.h" -#include "DEG_depsgraph.h" +#include "DNA_object_types.h" -#include "BKE_depsgraph.h" +#include "DEG_depsgraph.h" #define STATS_MAX_SIZE 16384 #ifdef RNA_RUNTIME +#include "BLI_iterator.h" +#include "BLI_math.h" + +#include "BKE_anim.h" + #include "DEG_depsgraph_build.h" #include "DEG_depsgraph_debug.h" +#include "DEG_depsgraph_query.h" + +#include "MEM_guardedalloc.h" + +/* **************** Object Instance **************** */ + +static PointerRNA rna_DepsgraphObjectInstance_object_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_Object, iterator->current); +} + +static int rna_DepsgraphObjectInstance_is_instance_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; + return (deg_iter->dupli_object_current != NULL); +} + +static PointerRNA rna_DepsgraphObjectInstance_instance_object_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; + Object *instance_object = NULL; + if (deg_iter->dupli_object_current != NULL) { + instance_object = deg_iter->dupli_object_current->ob; + } + return rna_pointer_inherit_refine(ptr, &RNA_Object, instance_object); +} + +static PointerRNA rna_DepsgraphObjectInstance_parent_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; + Object *dupli_parent = NULL; + if (deg_iter->dupli_object_current != NULL) { + dupli_parent = deg_iter->dupli_parent; + } + return rna_pointer_inherit_refine(ptr, &RNA_Object, dupli_parent); +} + +static PointerRNA rna_DepsgraphObjectInstance_particle_system_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; + struct ParticleSystem *particle_system = NULL; + if (deg_iter->dupli_object_current != NULL) { + particle_system = deg_iter->dupli_object_current->particle_system; + } + return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, particle_system); +} + +static void rna_DepsgraphObjectInstance_persistent_id_get(PointerRNA *ptr, int *persistent_id) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; + if (deg_iter->dupli_object_current != NULL) { + memcpy(persistent_id, deg_iter->dupli_object_current->persistent_id, + sizeof(deg_iter->dupli_object_current->persistent_id)); + } + else { + memset(persistent_id, 0, sizeof(deg_iter->dupli_object_current->persistent_id)); + } +} + +static unsigned int rna_DepsgraphObjectInstance_random_id_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; + if (deg_iter->dupli_object_current != NULL) { + return deg_iter->dupli_object_current->random_id; + } + else { + return 0; + } +} + +static void rna_DepsgraphObjectInstance_matrix_world_get(PointerRNA *ptr, float *mat) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; + if (deg_iter->dupli_object_current != NULL) { + copy_m4_m4((float(*)[4])mat, deg_iter->dupli_object_current->mat); + } + else { + unit_m4((float(*)[4])mat); + } +} + +static void rna_DepsgraphObjectInstance_orco_get(PointerRNA *ptr, float *orco) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; + if (deg_iter->dupli_object_current != NULL) { + copy_v3_v3(orco, deg_iter->dupli_object_current->orco); + } + else { + zero_v3(orco); + } +} + +static void rna_DepsgraphObjectInstance_uv_get(PointerRNA *ptr, float *uv) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data; + if (deg_iter->dupli_object_current != NULL) { + copy_v2_v2(uv, deg_iter->dupli_object_current->uv); + } + else { + zero_v2(uv); + } +} + +/* ******************** Sorted ***************** */ + +static int rna_Depsgraph_mode_get(PointerRNA *ptr) +{ + Depsgraph *depsgraph = ptr->data; + return DEG_get_mode(depsgraph); +} + +/* ******************** Updates ***************** */ + +static PointerRNA rna_DepsgraphUpdate_id_get(PointerRNA *ptr) +{ + return rna_pointer_inherit_refine(ptr, &RNA_ID, ptr->data); +} + +static bool rna_DepsgraphUpdate_is_dirty_transform_get(PointerRNA *ptr) +{ + ID *id = ptr->data; + return ((id->recalc & ID_RECALC_TRANSFORM) == 0); +} + +static bool rna_DepsgraphUpdate_is_dirty_geometry_get(PointerRNA *ptr) +{ + ID *id = ptr->data; + if (id->recalc & ID_RECALC_GEOMETRY) { + return false; + } + if (GS(id->name) != ID_OB) { + return true; + } + Object *object = (Object *)id; + ID *data = object->data; + if (data == NULL) { + return true; + } + return ((data->recalc & ID_RECALC_ALL) == 0); +} + +/* **************** Depsgraph **************** */ static void rna_Depsgraph_debug_relations_graphviz(Depsgraph *depsgraph, const char *filename) @@ -79,20 +236,295 @@ static void rna_Depsgraph_debug_stats(Depsgraph *depsgraph, char *result) DEG_stats_simple(depsgraph, &outer, &ops, &rels); BLI_snprintf(result, STATS_MAX_SIZE, "Approx %lu Operations, %lu Relations, %lu Outer Nodes", - ops, rels, outer); + ops, rels, outer); +} + +/* Iteration over objects, simple version */ + +static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__); + DEGObjectIterData *data = MEM_callocN(sizeof(DEGObjectIterData), __func__); + + data->graph = (Depsgraph *)ptr->data; + data->flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | + DEG_ITER_OBJECT_FLAG_VISIBLE | + DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET; + + ((BLI_Iterator *)iter->internal.custom)->valid = true; + DEG_iterator_objects_begin(iter->internal.custom, data); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static void rna_Depsgraph_objects_next(CollectionPropertyIterator *iter) +{ + DEG_iterator_objects_next(iter->internal.custom); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static void rna_Depsgraph_objects_end(CollectionPropertyIterator *iter) +{ + DEG_iterator_objects_end(iter->internal.custom); + MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data); + MEM_freeN(iter->internal.custom); +} + +static PointerRNA rna_Depsgraph_objects_get(CollectionPropertyIterator *iter) +{ + Object *ob = ((BLI_Iterator *)iter->internal.custom)->current; + return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ob); +} + +/* Iteration over objects, extended version + * + * Contains extra information about duplicator and persistent ID. + */ + +static void rna_Depsgraph_object_instances_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__); + DEGObjectIterData *data = MEM_callocN(sizeof(DEGObjectIterData), __func__); + + data->graph = (Depsgraph *)ptr->data; + data->flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | + DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | + DEG_ITER_OBJECT_FLAG_VISIBLE | + DEG_ITER_OBJECT_FLAG_DUPLI; + + ((BLI_Iterator *)iter->internal.custom)->valid = true; + DEG_iterator_objects_begin(iter->internal.custom, data); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static void rna_Depsgraph_object_instances_next(CollectionPropertyIterator *iter) +{ + DEG_iterator_objects_next(iter->internal.custom); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static void rna_Depsgraph_object_instances_end(CollectionPropertyIterator *iter) +{ + DEG_iterator_objects_end(iter->internal.custom); + MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data); + MEM_freeN(iter->internal.custom); +} + +static PointerRNA rna_Depsgraph_object_instances_get(CollectionPropertyIterator *iter) +{ + BLI_Iterator *iterator = (BLI_Iterator *)iter->internal.custom; + return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphObjectInstance, iterator); +} + +/* Iteration over evaluated IDs */ + +static void rna_Depsgraph_ids_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__); + DEGIDIterData *data = MEM_callocN(sizeof(DEGIDIterData), __func__); + + data->graph = (Depsgraph *)ptr->data; + + ((BLI_Iterator *)iter->internal.custom)->valid = true; + DEG_iterator_ids_begin(iter->internal.custom, data); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static void rna_Depsgraph_ids_next(CollectionPropertyIterator *iter) +{ + DEG_iterator_ids_next(iter->internal.custom); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static void rna_Depsgraph_ids_end(CollectionPropertyIterator *iter) +{ + DEG_iterator_ids_end(iter->internal.custom); + MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data); + MEM_freeN(iter->internal.custom); +} + +static PointerRNA rna_Depsgraph_ids_get(CollectionPropertyIterator *iter) +{ + ID *id = ((BLI_Iterator *)iter->internal.custom)->current; + return rna_pointer_inherit_refine(&iter->parent, &RNA_ID, id); +} + +static void rna_Depsgraph_updates_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__); + DEGIDIterData *data = MEM_callocN(sizeof(DEGIDIterData), __func__); + + data->graph = (Depsgraph *)ptr->data; + data->only_updated = true; + + ((BLI_Iterator *)iter->internal.custom)->valid = true; + DEG_iterator_ids_begin(iter->internal.custom, data); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static PointerRNA rna_Depsgraph_updates_get(CollectionPropertyIterator *iter) +{ + ID *id = ((BLI_Iterator *)iter->internal.custom)->current; + return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphUpdate, id); +} + +static ID *rna_Depsgraph_id_eval_get(Depsgraph *depsgraph, ID *id_orig) +{ + return DEG_get_evaluated_id(depsgraph, id_orig); +} + +static bool rna_Depsgraph_id_type_updated(Depsgraph *depsgraph, int id_type) +{ + return DEG_id_type_updated(depsgraph, id_type); +} + +static PointerRNA rna_Depsgraph_scene_get(PointerRNA *ptr) +{ + Depsgraph *depsgraph = (Depsgraph *)ptr->data; + Scene *scene = DEG_get_input_scene(depsgraph); + return rna_pointer_inherit_refine(ptr, &RNA_Scene, scene); +} + +static PointerRNA rna_Depsgraph_view_layer_get(PointerRNA *ptr) +{ + Depsgraph *depsgraph = (Depsgraph *)ptr->data; + ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph); + return rna_pointer_inherit_refine(ptr, &RNA_ViewLayer, view_layer); +} + +static PointerRNA rna_Depsgraph_scene_eval_get(PointerRNA *ptr) +{ + Depsgraph *depsgraph = (Depsgraph *)ptr->data; + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + return rna_pointer_inherit_refine(ptr, &RNA_Scene, scene_eval); +} + +static PointerRNA rna_Depsgraph_view_layer_eval_get(PointerRNA *ptr) +{ + Depsgraph *depsgraph = (Depsgraph *)ptr->data; + ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); + return rna_pointer_inherit_refine(ptr, &RNA_ViewLayer, view_layer_eval); } #else +static void rna_def_depsgraph_instance(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "DepsgraphObjectInstance", NULL); + RNA_def_struct_ui_text(srna, "Dependency Graph Object Instance", + "Extended information about dependency graph object iterator " + "(WARNING: all data here is *evaluated* one, not original .blend IDs...)"); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_ui_text(prop, "Object", "Evaluated object the iterator points to"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_object_get", NULL, NULL, NULL); + + prop = RNA_def_property(srna, "is_instance", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Is Instance", "Denotes whether the object is coming from dupli-list"); + RNA_def_property_boolean_funcs(prop, "rna_DepsgraphObjectInstance_is_instance_get", NULL); + + prop = RNA_def_property(srna, "instance_object", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_ui_text(prop, "Instance Object", "Evaluated object which is being instanced by this iterator"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_instance_object_get", NULL, NULL, NULL); + + prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_ui_text(prop, "Parent", "Evaluated parent object of the duplication list"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_parent_get", NULL, NULL, NULL); + + prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ParticleSystem"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Particle System", "Evaluated particle system that this object was instanced from"); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_particle_system_get", NULL, NULL, NULL); + + prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Persistent ID", + "Persistent identifier for inter-frame matching of objects with motion blur"); + RNA_def_property_array(prop, 2 * MAX_DUPLI_RECUR); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_DepsgraphObjectInstance_persistent_id_get", NULL, NULL); + + 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"); + RNA_def_property_int_funcs(prop, "rna_DepsgraphObjectInstance_random_id_get", NULL, NULL); + + prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Generated Matrix", "Generated transform matrix in world space"); + RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_matrix_world_get", NULL, NULL); + + prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space"); + RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_orco_get", NULL, NULL); + + prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space"); + RNA_def_property_array(prop, 2); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_uv_get", NULL, NULL); +} + +static void rna_def_depsgraph_update(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "DepsgraphUpdate", NULL); + RNA_def_struct_ui_text(srna, "Dependency Graph Update", + "Information about ID that was updated"); + + prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ID"); + RNA_def_property_ui_text(prop, "ID", "Updated datablock"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphUpdate_id_get", NULL, NULL, NULL); + + prop = RNA_def_property(srna, "is_dirty_transform", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Transform", "Object transformation is not updated"); + RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_dirty_transform_get", NULL); + + prop = RNA_def_property(srna, "is_dirty_geometry", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Geometry", "Object geometry is not updated"); + RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_dirty_geometry_get", NULL); +} + static void rna_def_depsgraph(BlenderRNA *brna) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; + + static EnumPropertyItem enum_depsgraph_mode_items[] = { + {DAG_EVAL_VIEWPORT, "VIEWPORT", 0, "Viewport", "Viewport non-rendered mode"}, + {DAG_EVAL_RENDER, "RENDER", 0, "Render", "Render"}, + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "Depsgraph", NULL); RNA_def_struct_ui_text(srna, "Dependency Graph", ""); + prop = RNA_def_enum(srna, "mode", enum_depsgraph_mode_items, 0, "Mode", "Evaluation mode"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_funcs(prop, "rna_Depsgraph_mode_get", NULL, NULL); + + /* Debug helpers. */ + func = RNA_def_function(srna, "debug_relations_graphviz", "rna_Depsgraph_debug_relations_graphviz"); parm = RNA_def_string_file_path(func, "filename", NULL, FILE_MAX, "File Name", "File in which to store graphviz debug output"); @@ -114,10 +546,94 @@ static void rna_def_depsgraph(BlenderRNA *brna) parm = RNA_def_string(func, "result", NULL, STATS_MAX_SIZE, "result", ""); RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); /* needed for string return value */ RNA_def_function_output(func, parm); + + /* Queries for original datablockls (the ones depsgraph is built for). */ + + prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Scene"); + RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_scene_get", NULL, NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Scene", "Original scene dependency graph is built for"); + + prop = RNA_def_property(srna, "view_layer", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ViewLayer"); + RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_view_layer_get", NULL, NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "View Layer", "Original view layer dependency graph is built for"); + + /* Queries for evaluated datablockls (the ones depsgraph is evaluating). */ + + func = RNA_def_function(srna, "id_eval_get", "rna_Depsgraph_id_eval_get"); + parm = RNA_def_pointer(func, "id", "ID", "", "Original ID to get evaluated complementary part for"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "id_eval", "ID", "", "Evaluated ID for the given original one"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "id_type_updated", "rna_Depsgraph_id_type_updated"); + parm = RNA_def_enum(func, "id_type", rna_enum_id_type_items, 0, "ID Type", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_boolean(func, "updated", false, "Updated", "True if any datablock with this type was added, updated or removed"); + RNA_def_function_return(func, parm); + + prop = RNA_def_property(srna, "scene_eval", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Scene"); + RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_scene_eval_get", NULL, NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Scene", "Original scene dependency graph is built for"); + + prop = RNA_def_property(srna, "view_layer_eval", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ViewLayer"); + RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_view_layer_eval_get", NULL, NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "View Layer", "Original view layer dependency graph is built for"); + + /* Iterators. */ + + prop = RNA_def_property(srna, "ids", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "ID"); + RNA_def_property_collection_funcs(prop, + "rna_Depsgraph_ids_begin", + "rna_Depsgraph_ids_next", + "rna_Depsgraph_ids_end", + "rna_Depsgraph_ids_get", + NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "IDs", "All evaluated datablocks"); + + prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_collection_funcs(prop, + "rna_Depsgraph_objects_begin", + "rna_Depsgraph_objects_next", + "rna_Depsgraph_objects_end", + "rna_Depsgraph_objects_get", + NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Objects", "Evaluated objects in the dependency graph"); + + prop = RNA_def_property(srna, "object_instances", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "DepsgraphObjectInstance"); + RNA_def_property_collection_funcs(prop, + "rna_Depsgraph_object_instances_begin", + "rna_Depsgraph_object_instances_next", + "rna_Depsgraph_object_instances_end", + "rna_Depsgraph_object_instances_get", + NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Object Instances", "All object instances to display or render"); + + prop = RNA_def_property(srna, "updates", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "DepsgraphUpdate"); + RNA_def_property_collection_funcs(prop, + "rna_Depsgraph_updates_begin", + "rna_Depsgraph_ids_next", + "rna_Depsgraph_ids_end", + "rna_Depsgraph_updates_get", + NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Updates", "Updates to datablocks"); } void RNA_def_depsgraph(BlenderRNA *brna) { + rna_def_depsgraph_instance(brna); + rna_def_depsgraph_update(brna); rna_def_depsgraph(brna); } diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c index c82c95e5a4b..209860e26c6 100644 --- a/source/blender/makesrna/intern/rna_dynamicpaint.c +++ b/source/blender/makesrna/intern/rna_dynamicpaint.c @@ -55,9 +55,10 @@ const EnumPropertyItem rna_enum_prop_dynamicpaint_type_items[] = { #ifdef RNA_RUNTIME #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_particle.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" static char *rna_DynamicPaintCanvasSettings_path(PointerRNA *ptr) { @@ -98,7 +99,7 @@ static char *rna_DynamicPaintSurface_path(PointerRNA *ptr) static void rna_DynamicPaint_redoModifier(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, OB_RECALC_DATA); } static void rna_DynamicPaintSurfaces_updateFrames(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -160,7 +161,7 @@ static void rna_DynamicPaintSurfaces_changeFormat(Main *bmain, Scene *scene, Poi static void rna_DynamicPaint_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr) { rna_DynamicPaintSurface_reset(bmain, scene, ptr); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } static PointerRNA rna_PaintSurface_active_get(PointerRNA *ptr) @@ -424,9 +425,9 @@ static void rna_def_canvas_surface(BlenderRNA *brna) RNA_def_struct_name_property(srna, prop); prop = RNA_def_property(srna, "brush_group", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Group"); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Brush Group", "Only use brush objects from this group"); + RNA_def_property_ui_text(prop, "Brush Collection", "Only use brush objects from this collection"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_reset_dependency"); @@ -824,18 +825,6 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Paint Alpha", "Paint alpha"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier"); - prop = RNA_def_property(srna, "use_material", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_USE_MATERIAL); - RNA_def_property_ui_text(prop, "Use object material", "Use object material to define color and influence"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier"); - - prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "mat"); - RNA_def_property_ui_text(prop, "Material", - "Material to use (if not defined, material linked to the mesh is used)"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier"); - prop = RNA_def_property(srna, "use_absolute_alpha", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ABS_ALPHA); RNA_def_property_ui_text(prop, "Absolute Alpha", diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 9dbc9a62aa4..7b714bef186 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -72,11 +72,11 @@ const EnumPropertyItem rna_enum_fmodifier_type_items[] = { }; const EnumPropertyItem rna_enum_beztriple_keyframe_type_items[] = { - {BEZT_KEYTYPE_KEYFRAME, "KEYFRAME", VICO_KEYTYPE_KEYFRAME_VEC, "Keyframe", "Normal keyframe - e.g. for key poses"}, - {BEZT_KEYTYPE_BREAKDOWN, "BREAKDOWN", VICO_KEYTYPE_BREAKDOWN_VEC, "Breakdown", "A breakdown pose - e.g. for transitions between key poses"}, - {BEZT_KEYTYPE_MOVEHOLD, "MOVING_HOLD", VICO_KEYTYPE_MOVING_HOLD_VEC, "Moving Hold", "A keyframe that is part of a moving hold"}, - {BEZT_KEYTYPE_EXTREME, "EXTREME", VICO_KEYTYPE_EXTREME_VEC, "Extreme", "An 'extreme' pose, or some other purpose as needed"}, - {BEZT_KEYTYPE_JITTER, "JITTER", VICO_KEYTYPE_JITTER_VEC, "Jitter", "A filler or baked keyframe for keying on ones, or some other purpose as needed"}, + {BEZT_KEYTYPE_KEYFRAME, "KEYFRAME", ICON_KEYTYPE_KEYFRAME_VEC, "Keyframe", "Normal keyframe - e.g. for key poses"}, + {BEZT_KEYTYPE_BREAKDOWN, "BREAKDOWN", ICON_KEYTYPE_BREAKDOWN_VEC, "Breakdown", "A breakdown pose - e.g. for transitions between key poses"}, + {BEZT_KEYTYPE_MOVEHOLD, "MOVING_HOLD", ICON_KEYTYPE_MOVING_HOLD_VEC, "Moving Hold", "A keyframe that is part of a moving hold"}, + {BEZT_KEYTYPE_EXTREME, "EXTREME", ICON_KEYTYPE_EXTREME_VEC, "Extreme", "An 'extreme' pose, or some other purpose as needed"}, + {BEZT_KEYTYPE_JITTER, "JITTER", ICON_KEYTYPE_JITTER_VEC, "Jitter", "A filler or baked keyframe for keying on ones, or some other purpose as needed"}, {0, NULL, 0, NULL, NULL} }; @@ -127,9 +127,18 @@ static StructRNA *rna_FModifierType_refine(struct PointerRNA *ptr) /* ****************************** */ #include "BKE_fcurve.h" -#include "BKE_depsgraph.h" #include "BKE_animsys.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + +static bool rna_ChannelDriver_is_simple_expression_get(PointerRNA *ptr) +{ + ChannelDriver *driver = ptr->data; + + return BKE_driver_has_simple_expression(driver); +} + static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) { ID *id = ptr->id.data; @@ -138,8 +147,8 @@ static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA driver->flag &= ~DRIVER_FLAG_INVALID; /* TODO: this really needs an update guard... */ - DAG_relations_tag_update(bmain); - DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA); + DEG_relations_tag_update(bmain); + DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA); WM_main_add_notifier(NC_SCENE | ND_FRAME, scene); } @@ -149,7 +158,7 @@ static void rna_ChannelDriver_update_expr(Main *bmain, Scene *scene, PointerRNA ChannelDriver *driver = ptr->data; /* tag driver as needing to be recompiled */ - driver->flag |= DRIVER_FLAG_RECOMPILE; + BKE_driver_invalidate_expression(driver, true, false); /* update_data() clears invalid flag and schedules for updates */ rna_ChannelDriver_update_data(bmain, scene, ptr); @@ -182,8 +191,7 @@ static void rna_DriverTarget_update_name(Main *bmain, Scene *scene, PointerRNA * ChannelDriver *driver = ptr->data; rna_DriverTarget_update_data(bmain, scene, ptr); - driver->flag |= DRIVER_FLAG_RENAMEVAR; - + BKE_driver_invalidate_expression(driver, false, true); } /* ----------- */ @@ -479,6 +487,18 @@ static void rna_FCurve_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), Po rna_FCurve_update_data_ex((FCurve *)ptr->data); } +/* RNA update callback for F-Curves to indicate that there are copy-on-write tagging/flushing needed + * (e.g. for properties that affect how animation gets evaluated) + */ +static void rna_FCurve_update_eval(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + IdAdtTemplate *iat = (IdAdtTemplate *)ptr->id.data; + if (iat && iat->adt && iat->adt->action) { + /* action is separate datablock, needs separate tag */ + DEG_id_tag_update(&iat->adt->action->id, DEG_TAG_COPY_ON_WRITE); + } +} + static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr) { @@ -588,10 +608,22 @@ static void rna_FModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin ID *id = ptr->id.data; FModifier *fcm = (FModifier *)ptr->data; AnimData *adt = BKE_animdata_from_id(id); - DAG_id_tag_update(id, (GS(id->name) == ID_OB) ? OB_RECALC_OB : OB_RECALC_DATA); + + DEG_id_tag_update(id, (GS(id->name) == ID_OB) ? OB_RECALC_OB : OB_RECALC_DATA); + + /* tag datablock for time update so that animation is recalculated, + * as FModifiers affect how animation plays... + */ + DEG_id_tag_update(id, DEG_TAG_TIME); if (adt != NULL) { adt->recalc |= ADT_RECALC_ANIM; + + if (adt->action != NULL) { + /* action is separate datablock, needs separate tag */ + DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE); + } } + if (fcm->curve && fcm->type == FMODIFIER_TYPE_CYCLES) { calchandles_fcurve(fcm->curve); } @@ -1367,7 +1399,7 @@ static void rna_def_fmodifier(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_MUTED); RNA_def_property_ui_text(prop, "Muted", "F-Curve Modifier will not be evaluated"); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update"); - RNA_def_property_ui_icon(prop, ICON_MUTE_IPO_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_CHECKBOX_DEHLT, 1); prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -1471,6 +1503,7 @@ static void rna_def_drivertarget(BlenderRNA *brna) prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable"); /* note: custom set function is ONLY to avoid rna setting a user for this. */ RNA_def_property_pointer_funcs(prop, NULL, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", NULL); @@ -1521,10 +1554,10 @@ static void rna_def_drivervar(BlenderRNA *brna) static const EnumPropertyItem prop_type_items[] = { {DVAR_TYPE_SINGLE_PROP, "SINGLE_PROP", ICON_RNA, "Single Property", "Use the value from some RNA property (Default)"}, - {DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", ICON_MANIPUL, "Transform Channel", + {DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", ICON_DRIVER_TRANSFORM, "Transform Channel", "Final transformation value of object or bone"}, - {DVAR_TYPE_ROT_DIFF, "ROTATION_DIFF", ICON_PARTICLE_TIP, "Rotational Difference", "Use the angle between two bones"}, /* XXX: Icon... */ - {DVAR_TYPE_LOC_DIFF, "LOC_DIFF", ICON_FULLSCREEN_ENTER, "Distance", "Distance between two bones or objects"}, /* XXX: Icon... */ + {DVAR_TYPE_ROT_DIFF, "ROTATION_DIFF", ICON_DRIVER_ROTATIONAL_DIFFERENCE, "Rotational Difference", "Use the angle between two bones"}, + {DVAR_TYPE_LOC_DIFF, "LOC_DIFF", ICON_DRIVER_DISTANCE, "Distance", "Distance between two bones or objects"}, {0, NULL, 0, NULL, NULL} }; @@ -1555,6 +1588,7 @@ static void rna_def_drivervar(BlenderRNA *brna) prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "targets", "num_targets"); RNA_def_property_struct_type(prop, "DriverTarget"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable"); /* Name Validity Flags */ @@ -1631,15 +1665,11 @@ static void rna_def_channeldriver(BlenderRNA *brna) prop = RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "variables", NULL); RNA_def_property_struct_type(prop, "DriverVariable"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver"); rna_def_channeldriver_variables(brna, prop); /* Settings */ - prop = RNA_def_property(srna, "show_debug_info", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_SHOWDEBUG); - RNA_def_property_ui_text(prop, "Show Debug Info", - "Show intermediate values for the driver calculations to allow debugging of drivers"); - prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_USE_SELF); RNA_def_property_ui_text(prop, "Use Self", @@ -1651,6 +1681,10 @@ static void rna_def_channeldriver(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", DRIVER_FLAG_INVALID); RNA_def_property_ui_text(prop, "Invalid", "Driver could not be evaluated in past, so should be skipped"); + prop = RNA_def_property(srna, "is_simple_expression", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_ChannelDriver_is_simple_expression_get", NULL); + RNA_def_property_ui_text(prop, "Simple Expression", "The scripted expression can be evaluated without using the full python interpreter"); /* Functions */ RNA_api_drivers(srna); @@ -1860,7 +1894,8 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "rna_FKeyframe_points_add"); RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve"); - RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + parm = RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); func = RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove"); RNA_def_function_ui_description(func, "Remove keyframe from an F-Curve"); @@ -1915,6 +1950,7 @@ static void rna_def_fcurve(BlenderRNA *brna) /* Pointers */ prop = RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)"); @@ -1966,7 +2002,7 @@ static void rna_def_fcurve(BlenderRNA *brna) prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_MUTED); RNA_def_property_ui_text(prop, "Muted", "F-Curve is not evaluated"); - RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, "rna_FCurve_update_eval"); prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_VISIBLE); diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 54d89ec81ab..23d9155fccd 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -46,7 +46,6 @@ #include "DNA_scene_types.h" #include "DNA_particle_types.h" -#include "BKE_depsgraph.h" #include "BKE_fluidsim.h" #include "BKE_global.h" #include "BKE_main.h" @@ -54,6 +53,8 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" +#include "DEG_depsgraph.h" + static StructRNA *rna_FluidSettings_refine(struct PointerRNA *ptr) { FluidsimSettings *fss = (FluidsimSettings *)ptr->data; @@ -82,7 +83,7 @@ static void rna_fluid_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR { Object *ob = ptr->id.data; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 625ef7db2dc..806133c71c2 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -26,8 +26,13 @@ #include <stdlib.h> +#include "BLI_math.h" + +#include "DNA_meshdata_types.h" #include "DNA_gpencil_types.h" #include "DNA_scene_types.h" +#include "DNA_brush_types.h" +#include "DNA_object_types.h" #include "MEM_guardedalloc.h" @@ -38,12 +43,11 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "rna_internal.h" #include "WM_types.h" -#include "DNA_object_types.h" -#include "ED_gpencil.h" /* parent type */ static const EnumPropertyItem parent_type_items[] = { @@ -53,31 +57,92 @@ static const EnumPropertyItem parent_type_items[] = { {0, NULL, 0, NULL, NULL} }; +#ifndef RNA_RUNTIME +static EnumPropertyItem rna_enum_gpencil_xraymodes_items[] = { + { GP_XRAY_FRONT, "FRONT", 0, "Front", "Draw all strokes in front" }, + { GP_XRAY_3DSPACE, "3DSPACE", 0, "3D Space", "Draw strokes relative to other objects in 3D space" }, + { GP_XRAY_BACK, "BACK", 0, "Back", "Draw all strokes last" }, + { 0, NULL, 0, NULL, NULL } +}; + +static EnumPropertyItem rna_enum_gpencil_onion_modes_items[] = { + { GP_ONION_MODE_ABSOLUTE, "ABSOLUTE", 0, "Frames", "Frames in absolute range of the scene frame" }, + { GP_ONION_MODE_RELATIVE, "RELATIVE", 0, "Keyframes", "Frames in relative range of the Grease Pencil keyframes" }, + { GP_ONION_MODE_SELECTED, "SELECTED", 0, "Selected", "Only selected keyframes" }, + { 0, NULL, 0, NULL, NULL } +}; + +const EnumPropertyItem rna_enum_gplayer_move_type_items[] = { + { -1, "UP", 0, "Up", ""}, + { 1, "DOWN", 0, "Down", ""}, + { 0, NULL, 0, NULL, NULL} +}; + +#endif #ifdef RNA_RUNTIME -#include "BLI_math.h" +#include "BLI_ghash.h" #include "WM_api.h" +#include "BKE_action.h" #include "BKE_animsys.h" #include "BKE_gpencil.h" -#include "BKE_action.h" +#include "BKE_icons.h" +#include "DEG_depsgraph.h" -static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) + +static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } -static void rna_GPencil_editmode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +static void rna_GPencil_autolock(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bGPdata *gpd = (bGPdata *)ptr->id.data; + bGPDlayer *gpl = NULL; + + if (gpd->flag & GP_DATA_AUTOLOCK_LAYERS) { + bGPDlayer *layer = BKE_gpencil_layer_getactive(gpd); + + /* Lock all other layers */ + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { + /* unlock active layer */ + if (gpl == layer) { + gpl->flag &= ~GP_LAYER_LOCKED; + } + else { + gpl->flag |= GP_LAYER_LOCKED; + } + } + } + else { + /* If disable is better unlock all layers by default or it looks there is + * a problem in the UI because the user expects all layers will be unlocked + */ + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { + gpl->flag &= ~GP_LAYER_LOCKED; + } + } + + /* standard update */ + rna_GPencil_update(bmain, scene, ptr); +} + +static void rna_GPencil_editmode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { + bGPdata *gpd = (bGPdata *)ptr->id.data; + DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA); + /* Notify all places where GPencil data lives that the editing state is different */ WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); WM_main_add_notifier(NC_SCENE | ND_MODE | NC_MOVIECLIP, NULL); } -static void rna_GPencil_onion_skinning_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void UNUSED_FUNCTION(rna_GPencil_onion_skinning_update)(Main *bmain, Scene *scene, PointerRNA *ptr) { bGPdata *gpd = (bGPdata *)ptr->id.data; bGPDlayer *gpl; @@ -87,7 +152,7 @@ static void rna_GPencil_onion_skinning_update(Main *bmain, Scene *scene, Pointer * stays in sync with the status of the actual layers */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { - if (gpl->flag & GP_LAYER_ONIONSKIN) { + if (gpl->onion_flag & GP_LAYER_ONIONSKIN) { enabled = true; } } @@ -102,16 +167,22 @@ static void rna_GPencil_onion_skinning_update(Main *bmain, Scene *scene, Pointer rna_GPencil_update(bmain, scene, ptr); } -static void rna_GPencil_stroke_colorname_update(Main *bmain, Scene *scene, PointerRNA *ptr) + +/* Poll Callback to filter GP Datablocks to only show those for Annotations */ +bool rna_GPencil_datablocks_annotations_poll(PointerRNA *UNUSED(ptr), const PointerRNA value) { - bGPDstroke *gps = (bGPDstroke *)ptr->data; - gps->flag |= GP_STROKE_RECALC_COLOR; - gps->palcolor = NULL; + bGPdata *gpd = value.data; + return (gpd->flag & GP_DATA_ANNOTATIONS) != 0; +} - /* Now do standard updates... */ - rna_GPencil_update(bmain, scene, ptr); +/* Poll Callback to filter GP Datablocks to only show those for GP Objects */ +bool rna_GPencil_datablocks_obdata_poll(PointerRNA *UNUSED(ptr), const PointerRNA value) +{ + bGPdata *gpd = value.data; + return (gpd->flag & GP_DATA_ANNOTATIONS) == 0; } + static char *rna_GPencilLayer_path(PointerRNA *ptr) { bGPDlayer *gpl = (bGPDlayer *)ptr->data; @@ -133,36 +204,6 @@ static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr, const char ** return PROP_EDITABLE; } -static void rna_GPencilLayer_line_width_range(PointerRNA *ptr, int *min, int *max, - int *softmin, int *softmax) -{ - bGPDlayer *gpl = ptr->data; - - /* The restrictions on max width here are due to OpenGL on Windows not supporting - * any widths greater than 10 (for driver-drawn) strokes/points. - * - * Although most of our 2D strokes also don't suffer from this restriction, - * it's relatively hard to test for that. So, for now, only volumetric strokes - * get to be larger... - */ - - /* From GP v2 this value is used to increase or decrease the thickness of the stroke */ - if (gpl->flag & GP_LAYER_VOLUMETRIC) { - *min = -300; - *max = 300; - - *softmin = -100; - *softmax = 100; - } - else { - *min = -10; - *max = 10; - - *softmin = -10; - *softmax = 10; - } -} - /* set parent */ static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char *substr) { @@ -202,21 +243,6 @@ static void rna_GPencilLayer_parent_set(PointerRNA *ptr, PointerRNA value) set_parent(gpl, par, gpl->partype, gpl->parsubstr); } else { - /* keep strokes in the same place, so apply current transformation */ - if (gpl->parent != NULL) { - bGPDspoint *pt; - int i; - float diff_mat[4][4]; - /* calculate difference matrix */ - ED_gpencil_parent_location(gpl, diff_mat); - for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { - for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { - for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - mul_m4_v3(diff_mat, &pt->x); - } - } - } - } /* clear parent */ gpl->parent = NULL; } @@ -306,6 +332,15 @@ static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value) { bGPdata *gpd = ptr->id.data; + /* Don't allow setting active layer to NULL if layers exist + * as this breaks various tools. Tools should be used instead + * if it's necessary to remove layers + */ + if (value.data == NULL) { + printf("%s: Setting active layer to None is not allowed\n", __func__); + return; + } + if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */ bGPDlayer *gl; @@ -336,6 +371,10 @@ static void rna_GPencil_active_layer_index_set(PointerRNA *ptr, int value) bGPDlayer *gpl = BLI_findlink(&gpd->layers, value); BKE_gpencil_layer_setactive(gpd, gpl); + + /* Now do standard updates... */ + DEG_id_tag_update(&gpd->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } static void rna_GPencil_active_layer_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) @@ -349,6 +388,36 @@ static void rna_GPencil_active_layer_index_range(PointerRNA *ptr, int *min, int *softmax = *max; } +static const EnumPropertyItem *rna_GPencil_active_layer_itemf( + bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) +{ + bGPdata *gpd = (bGPdata *)ptr->id.data; + bGPDlayer *gpl; + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + int i = 0; + + if (ELEM(NULL, C, gpd)) { + return DummyRNA_NULL_items; + } + + /* Existing layers */ + for (gpl = gpd->layers.first, i = 0; gpl; gpl = gpl->next, i++) { + item_tmp.identifier = gpl->info; + item_tmp.name = gpl->info; + item_tmp.value = i; + + item_tmp.icon = BKE_icon_gplayer_color_ensure(gpl); + + RNA_enum_item_add(&item, &totitem, &item_tmp); + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) { bGPdata *gpd = ptr->id.data; @@ -366,31 +435,6 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) BKE_animdata_fix_paths_rename_all(&gpd->id, "layers", oldname, gpl->info); } -static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const bool value) -{ - bGPdata *gpd = ptr->id.data; - bGPDlayer *gpl; - - /* set new value */ - if (value) { - /* enable on active layer (it's the one that's most likely to be of interest right now) */ - gpl = BKE_gpencil_layer_getactive(gpd); - if (gpl) { - gpl->flag |= GP_LAYER_ONIONSKIN; - } - - gpd->flag |= GP_DATA_SHOW_ONIONSKINS; - } - else { - /* disable on all layers - allowa quickly turning them all off, without having to check */ - for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { - gpl->flag &= ~GP_LAYER_ONIONSKIN; - } - - gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS; - } -} - static bGPDstroke *rna_GPencil_stroke_point_find_stroke(const bGPdata *gpd, const bGPDspoint *pt, bGPDlayer **r_gpl, bGPDframe **r_gpf) { bGPDlayer *gpl; @@ -454,14 +498,21 @@ static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count, float pr stroke->points = MEM_recallocN_id(stroke->points, sizeof(bGPDspoint) * (stroke->totpoints + count), "gp_stroke_points"); + stroke->dvert = MEM_recallocN_id(stroke->dvert, + sizeof(MDeformVert) * (stroke->totpoints + count), + "gp_stroke_weight"); /* init the pressure and strength values so that old scripts won't need to * be modified to give these initial values... */ for (int i = 0; i < count; i++) { bGPDspoint *pt = stroke->points + (stroke->totpoints + i); + MDeformVert *dvert = stroke->dvert + (stroke->totpoints + i); pt->pressure = pressure; pt->strength = strength; + + dvert->totweight = 0; + dvert->dw = NULL; } stroke->totpoints += count; @@ -471,6 +522,7 @@ static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count, float pr static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports, int index) { bGPDspoint *pt_tmp = stroke->points; + MDeformVert *pt_dvert = stroke->dvert; /* python style negative indexing */ if (index < 0) { @@ -485,27 +537,37 @@ static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports stroke->totpoints--; stroke->points = MEM_callocN(sizeof(bGPDspoint) * stroke->totpoints, "gp_stroke_points"); + if (pt_dvert != NULL) { + stroke->dvert = MEM_callocN(sizeof(MDeformVert) * stroke->totpoints, "gp_stroke_weights"); + } - if (index > 0) + if (index > 0) { memcpy(stroke->points, pt_tmp, sizeof(bGPDspoint) * index); + /* verify weight data is available */ + if (pt_dvert != NULL) { + memcpy(stroke->dvert, pt_dvert, sizeof(MDeformVert) * index); + } + } - if (index < stroke->totpoints) + if (index < stroke->totpoints) { memcpy(&stroke->points[index], &pt_tmp[index + 1], sizeof(bGPDspoint) * (stroke->totpoints - index)); + if (pt_dvert != NULL) { + memcpy(&stroke->dvert[index], &pt_dvert[index + 1], sizeof(MDeformVert) * (stroke->totpoints - index)); + } + } /* free temp buffer */ MEM_freeN(pt_tmp); + if (pt_dvert != NULL) { + MEM_freeN(pt_dvert); + } WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } -static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame, const char *colorname) +static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame) { bGPDstroke *stroke = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); - if (colorname) { - BLI_strncpy(stroke->colorname, colorname, sizeof(stroke->colorname)); - } - stroke->palcolor = NULL; - stroke->flag |= GP_STROKE_RECALC_COLOR; BLI_addtail(&frame->strokes, stroke); return stroke; @@ -614,279 +676,62 @@ static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, PointerR WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } -static void rna_GPencil_frame_clear(bGPDframe *frame) +static void rna_GPencil_layer_move(bGPdata *gpd, ReportList *reports, PointerRNA *layer_ptr, int type) { - BKE_gpencil_free_strokes(frame); - - WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); -} - -static void rna_GPencil_layer_clear(bGPDlayer *layer) -{ - BKE_gpencil_free_frames(layer); - - WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); -} - -static void rna_GPencil_clear(bGPdata *gpd) -{ - BKE_gpencil_free_layers(&gpd->layers); - - WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); -} - -/* Palettes */ -static bGPDpalette *rna_GPencil_palette_new(bGPdata *gpd, const char *name, bool setactive) -{ - bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, name, setactive != 0); - - WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - - return palette; -} - -static void rna_GPencil_palette_remove(bGPdata *gpd, ReportList *reports, PointerRNA *palette_ptr) -{ - bGPDpalette *palette = palette_ptr->data; - if (BLI_findindex(&gpd->palettes, palette) == -1) { - BKE_report(reports, RPT_ERROR, "Palette not found in grease pencil data"); + bGPDlayer *gpl = layer_ptr->data; + if (BLI_findindex(&gpd->layers, gpl) == -1) { + BKE_report(reports, RPT_ERROR, "Layer not found in grease pencil data"); return; } - BKE_gpencil_palette_delete(gpd, palette); - RNA_POINTER_INVALIDATE(palette_ptr); - - WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); -} - -static PointerRNA rna_GPencil_active_palette_get(PointerRNA *ptr) -{ - bGPdata *gpd = ptr->id.data; - - if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */ - bGPDpalette *palette; - - for (palette = gpd->palettes.first; palette; palette = palette->next) { - if (palette->flag & PL_PALETTE_ACTIVE) { - break; - } - } - - if (palette) { - return rna_pointer_inherit_refine(ptr, &RNA_GPencilPalette, palette); - } - } - - return rna_pointer_inherit_refine(ptr, NULL, NULL); -} - -static void rna_GPencil_active_palette_set(PointerRNA *ptr, PointerRNA value) -{ - bGPdata *gpd = ptr->id.data; - - if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */ - bGPDpalette *palette; + BLI_assert(ELEM(type, -1, 0, 1)); /* we use value below */ - for (palette = gpd->palettes.first; palette; palette = palette->next) { - if (palette == value.data) { - palette->flag |= PL_PALETTE_ACTIVE; - } - else { - palette->flag &= ~PL_PALETTE_ACTIVE; - } - } - /* force color recalc */ - BKE_gpencil_palette_change_strokes(gpd); + const int direction = type * -1; - WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); + if (BLI_listbase_link_move(&gpd->layers, gpl, direction)) { + DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA); } -} - -static int rna_GPencilPalette_index_get(PointerRNA *ptr) -{ - bGPdata *gpd = (bGPdata *)ptr->id.data; - bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); - - return BLI_findindex(&gpd->palettes, palette); -} - -static void rna_GPencilPalette_index_set(PointerRNA *ptr, int value) -{ - bGPdata *gpd = (bGPdata *)ptr->id.data; - bGPDpalette *palette = BLI_findlink(&gpd->palettes, value); - BKE_gpencil_palette_setactive(gpd, palette); WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } -static void rna_GPencilPalette_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) -{ - bGPdata *gpd = (bGPdata *)ptr->id.data; - - *min = 0; - *max = max_ii(0, BLI_listbase_count(&gpd->palettes) - 1); - - *softmin = *min; - *softmax = *max; -} - -/* Palette colors */ -static bGPDpalettecolor *rna_GPencilPalette_color_new(bGPDpalette *palette) -{ - bGPDpalettecolor *color = BKE_gpencil_palettecolor_addnew(palette, DATA_("Color"), true); - - return color; -} - -static void rna_GPencilPalette_color_remove(bGPDpalette *palette, ReportList *reports, PointerRNA *color_ptr) +static void rna_GPencil_frame_clear(bGPDframe *frame) { - bGPDpalettecolor *color = color_ptr->data; - - if (BLI_findindex(&palette->colors, color) == -1) { - BKE_reportf(reports, RPT_ERROR, "Palette '%s' does not contain color given", palette->info + 2); - return; - } - - BKE_gpencil_palettecolor_delete(palette, color); - RNA_POINTER_INVALIDATE(color_ptr); + BKE_gpencil_free_strokes(frame); WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } -static PointerRNA rna_GPencilPalette_active_color_get(PointerRNA *ptr) -{ - bGPDpalette *palette = (bGPDpalette *)ptr->data; - bGPDpalettecolor *color; - - for (color = palette->colors.first; color; color = color->next) { - if (color->flag & PC_COLOR_ACTIVE) { - break; - } - } - - if (color) { - return rna_pointer_inherit_refine(ptr, &RNA_GPencilPaletteColor, color); - } - - return rna_pointer_inherit_refine(ptr, NULL, NULL); -} - -static void rna_GPencilPalette_active_color_set(PointerRNA *ptr, PointerRNA value) -{ - bGPDpalette *palette = (bGPDpalette *)ptr->data; - bGPDpalettecolor *color = value.data; - - BKE_gpencil_palettecolor_setactive(palette, color); -} - -static void rna_GPencilPalette_info_set(PointerRNA *ptr, const char *value) -{ - bGPdata *gpd = ptr->id.data; - bGPDpalette *palette = ptr->data; - - char oldname[64] = ""; - BLI_strncpy(oldname, palette->info, sizeof(oldname)); - - /* copy the new name into the name slot */ - BLI_strncpy_utf8(palette->info, value, sizeof(palette->info)); - - BLI_uniquename(&gpd->palettes, palette, DATA_("GP_Palette"), '.', offsetof(bGPDpalette, info), - sizeof(palette->info)); - /* now fix animation paths */ - BKE_animdata_fix_paths_rename_all(&gpd->id, "palettes", oldname, palette->info); -} - -static char *rna_GPencilPalette_path(PointerRNA *ptr) -{ - bGPDpalette *palette = ptr->data; - char name_esc[sizeof(palette->info) * 2]; - - BLI_strescape(name_esc, palette->info, sizeof(name_esc)); - - return BLI_sprintfN("palettes[\"%s\"]", name_esc); -} - -static char *rna_GPencilPalette_color_path(PointerRNA *ptr) +static void rna_GPencil_layer_clear(bGPDlayer *layer) { - bGPdata *gpd = ptr->id.data; - bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); - bGPDpalettecolor *palcolor = ptr->data; - - char name_palette[sizeof(palette->info) * 2]; - char name_color[sizeof(palcolor->info) * 2]; - - BLI_strescape(name_palette, palette->info, sizeof(name_palette)); - BLI_strescape(name_color, palcolor->info, sizeof(name_color)); + BKE_gpencil_free_frames(layer); - return BLI_sprintfN("palettes[\"%s\"].colors[\"%s\"]", name_palette, name_color); + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } -static void rna_GPencilPaletteColor_info_set(PointerRNA *ptr, const char *value) +static void rna_GPencil_clear(bGPdata *gpd) { - bGPdata *gpd = ptr->id.data; - bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); - bGPDpalettecolor *palcolor = ptr->data; - - char oldname[64] = ""; - BLI_strncpy(oldname, palcolor->info, sizeof(oldname)); - - /* copy the new name into the name slot */ - BLI_strncpy_utf8(palcolor->info, value, sizeof(palcolor->info)); - BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info), - sizeof(palcolor->info)); - - /* rename all strokes */ - BKE_gpencil_palettecolor_changename(gpd, oldname, palcolor->info); + BKE_gpencil_free_layers(&gpd->layers); - /* now fix animation paths */ - BKE_animdata_fix_paths_rename_all(&gpd->id, "colors", oldname, palcolor->info); + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } -static void rna_GPencilStrokeColor_info_set(PointerRNA *ptr, const char *value) +static void rna_GpencilVertex_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { bGPDstroke *gps = ptr->data; - /* copy the new name into the name slot */ - BLI_strncpy_utf8(gps->colorname, value, sizeof(gps->colorname)); -} - + if (gps->dvert) { + MDeformVert *dvert = gps->dvert; -static bool rna_GPencilPaletteColor_is_stroke_visible_get(PointerRNA *ptr) -{ - bGPDpalettecolor *pcolor = (bGPDpalettecolor *)ptr->data; - return (pcolor->color[3] > GPENCIL_ALPHA_OPACITY_THRESH); -} - -static bool rna_GPencilPaletteColor_is_fill_visible_get(PointerRNA *ptr) -{ - bGPDpalettecolor *pcolor = (bGPDpalettecolor *)ptr->data; - return (pcolor->fill[3] > GPENCIL_ALPHA_OPACITY_THRESH); -} - -static int rna_GPencilPaletteColor_index_get(PointerRNA *ptr) -{ - bGPDpalette *palette = (bGPDpalette *)ptr->data; - bGPDpalettecolor *pcolor = BKE_gpencil_palettecolor_getactive(palette); - - return BLI_findindex(&palette->colors, pcolor); -} - -static void rna_GPencilPaletteColor_index_set(PointerRNA *ptr, int value) -{ - bGPDpalette *palette = (bGPDpalette *)ptr->data; - bGPDpalettecolor *pcolor = BLI_findlink(&palette->colors, value); - BKE_gpencil_palettecolor_setactive(palette, pcolor); + rna_iterator_array_begin(iter, (void *)dvert->dw, sizeof(MDeformWeight), dvert->totweight, 0, NULL); + } + else + rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL); } -static void rna_GPencilPaletteColor_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) +static char *rna_GreasePencilGrid_path(PointerRNA *UNUSED(ptr)) { - bGPDpalette *palette = (bGPDpalette *)ptr->data; - - *min = 0; - *max = max_ii(0, BLI_listbase_count(&palette->colors) - 1); - - *softmin = *min; - *softmax = *max; + return BLI_sprintfN("grid"); } #else @@ -918,17 +763,31 @@ static void rna_def_gpencil_stroke_point(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Strength", "Color intensity (alpha factor)"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + prop = RNA_def_property(srna, "uv_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "uv_fac"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "UV Factor", "Internal UV factor"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "uv_rotation", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "uv_rot"); + RNA_def_property_range(prop, 0.0f, M_PI * 2); + RNA_def_property_ui_text(prop, "UV Rotation", "Internal UV factor for dot mode"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SPOINT_SELECT); RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_stroke_point_select_set"); RNA_def_property_ui_text(prop, "Select", "Point is selected for viewport editing"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + } static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; + PropertyRNA *parm; RNA_def_property_srna(cprop, "GPencilStrokePoints"); srna = RNA_def_struct(brna, "GPencilStrokePoints", NULL); @@ -937,7 +796,8 @@ static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cpr func = RNA_def_function(srna, "add", "rna_GPencil_stroke_point_add"); RNA_def_function_ui_description(func, "Add a new grease pencil stroke point"); - RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the stroke", 0, INT_MAX); + parm = RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the stroke", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); RNA_def_float(func, "pressure", 1.0f, 0.0f, 1.0f, "Pressure", "Pressure for newly created points", 0.0f, 1.0f); RNA_def_float(func, "strength", 1.0f, 0.0f, 1.0f, "Strength", "Color intensity (alpha factor) for newly created points", 0.0f, 1.0f); @@ -955,7 +815,7 @@ static void rna_def_gpencil_triangle(BlenderRNA *brna) srna = RNA_def_struct(brna, "GPencilTriangle", NULL); RNA_def_struct_sdna(srna, "bGPDtriangle"); - RNA_def_struct_ui_text(srna, "Triangle", "Triangulation data for HQ fill"); + RNA_def_struct_ui_text(srna, "Triangle", "Triangulation data for Grease Pencil fills"); /* point v1 */ prop = RNA_def_property(srna, "v1", PROP_INT, PROP_NONE); @@ -974,6 +834,51 @@ static void rna_def_gpencil_triangle(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "verts[2]"); RNA_def_property_ui_text(prop, "v3", "Third triangle vertex index"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + /* texture coord for point v1 */ + prop = RNA_def_property(srna, "uv1", PROP_FLOAT, PROP_COORDS); + RNA_def_property_float_sdna(prop, NULL, "uv[0]"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "uv1", "First triangle vertex texture coordinates"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + /* texture coord for point v2 */ + prop = RNA_def_property(srna, "uv2", PROP_FLOAT, PROP_COORDS); + RNA_def_property_float_sdna(prop, NULL, "uv[1]"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "uv2", "Second triangle vertex texture coordinates"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + /* texture coord for point v3 */ + prop = RNA_def_property(srna, "uv3", PROP_FLOAT, PROP_COORDS); + RNA_def_property_float_sdna(prop, NULL, "uv[2]"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "uv3", "Third triangle vertex texture coordinates"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); +} + +static void rna_def_gpencil_mvert_group(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "GpencilVertexGroupElement", NULL); + RNA_def_struct_sdna(srna, "MDeformWeight"); + RNA_def_struct_ui_text(srna, "Vertex Group Element", "Weight value of a vertex in a vertex group"); + RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX); + + /* we can't point to actual group, it is in the object and so + * there is no unique group to point to, hence the index */ + prop = RNA_def_property(srna, "group", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "def_nr"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Group Index", ""); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Weight", "Vertex Weight"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); } static void rna_def_gpencil_stroke(BlenderRNA *brna) @@ -981,7 +886,7 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem stroke_draw_mode_items[] = { + static const EnumPropertyItem stroke_display_mode_items[] = { {0, "SCREEN", 0, "Screen", "Stroke is in screen-space"}, {GP_STROKE_3DSPACE, "3DSPACE", 0, "3D Space", "Stroke is in 3D-space"}, {GP_STROKE_2DSPACE, "2DSPACE", 0, "2D Space", "Stroke is in 2D-space"}, @@ -1000,24 +905,30 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Stroke Points", "Stroke data points"); rna_def_gpencil_stroke_points_api(brna, prop); + /* vertex groups */ + prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_funcs(prop, "rna_GpencilVertex_groups_begin", "rna_iterator_array_next", + "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL); + RNA_def_property_struct_type(prop, "GpencilVertexGroupElement"); + RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this vertex is member of"); + /* Triangles */ prop = RNA_def_property(srna, "triangles", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "triangles", "tot_triangles"); RNA_def_property_struct_type(prop, "GPencilTriangle"); RNA_def_property_ui_text(prop, "Triangles", "Triangulation data for HQ fill"); - /* Color */ - prop = RNA_def_property(srna, "color", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "GPencilPaletteColor"); - RNA_def_property_pointer_sdna(prop, NULL, "palcolor"); - RNA_def_property_ui_text(prop, "Palette Color", "Color from palette used in Stroke"); - RNA_def_property_update(prop, 0, "rna_GPencil_update"); + /* Material Index */ + prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "mat_nr"); + RNA_def_property_ui_text(prop, "Material Index", "Index of material used in this stroke"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* Settings */ - prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, stroke_draw_mode_items); - RNA_def_property_ui_text(prop, "Draw Mode", ""); + RNA_def_property_enum_items(prop, stroke_display_mode_items); + RNA_def_property_ui_text(prop, "Draw Mode", "Coordinate space that stroke is in"); RNA_def_property_update(prop, 0, "rna_GPencil_update"); prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); @@ -1026,22 +937,23 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Select", "Stroke is selected for viewport editing"); RNA_def_property_update(prop, 0, "rna_GPencil_update"); - /* Color Name */ - prop = RNA_def_property(srna, "colorname", PROP_STRING, PROP_NONE); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilStrokeColor_info_set"); - RNA_def_property_ui_text(prop, "Color Name", "Palette color name"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_colorname_update"); - /* Cyclic: Draw a line from end to start point */ prop = RNA_def_property(srna, "draw_cyclic", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_CYCLIC); RNA_def_property_ui_text(prop, "Cyclic", "Enable cyclic drawing, closing the stroke"); RNA_def_property_update(prop, 0, "rna_GPencil_update"); + /* No fill: The stroke never must fill area and must use fill color as stroke color (this is a special flag for fill brush) */ + prop = RNA_def_property(srna, "is_nofill_stroke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_NOFILL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "No Fill", "Special stroke to use as boundary for filling areas"); + RNA_def_property_update(prop, 0, "rna_GPencil_update"); + /* Line Thickness */ prop = RNA_def_property(srna, "line_width", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "thickness"); - RNA_def_property_range(prop, 1, 300); + RNA_def_property_range(prop, 1, 1000); RNA_def_property_ui_range(prop, 1, 10, 1, 0); RNA_def_property_ui_text(prop, "Thickness", "Thickness of stroke (in pixels)"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); @@ -1062,7 +974,6 @@ static void rna_def_gpencil_strokes_api(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_GPencil_stroke_new"); RNA_def_function_ui_description(func, "Add a new grease pencil stroke"); - parm = RNA_def_string(func, "colorname", 0, MAX_NAME, "Color", "Name of the color"); parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "", "The newly created stroke"); RNA_def_function_return(func, parm); @@ -1183,20 +1094,30 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_editable_func(prop, "rna_GPencilLayer_active_frame_editable"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - /* Draw Style */ - // TODO: replace these with a "draw type" combo (i.e. strokes only, filled strokes, strokes + fills, volumetric)? - prop = RNA_def_property(srna, "use_volumetric_strokes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_VOLUMETRIC); - RNA_def_property_ui_text(prop, "Volumetric Strokes", - "Draw strokes as a series of circular blobs, resulting in a volumetric effect"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* Layer Opacity */ prop = RNA_def_property(srna, "opacity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "opacity"); RNA_def_property_range(prop, 0.0, 1.0f); RNA_def_property_ui_text(prop, "Opacity", "Layer Opacity"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + /* Stroke Drawing Color (Annotations) */ + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Color", "Color for all strokes in this layer"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + /* Line Thickness (Annotations) */ + prop = RNA_def_property(srna, "thickness", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "thickness"); + RNA_def_property_range(prop, 1, 10); + RNA_def_property_ui_text(prop, "Thickness", "Thickness of annotation strokes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + /* Tint Color */ prop = RNA_def_property(srna, "tint_color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "tintcolor"); @@ -1212,66 +1133,36 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Tint Factor", "Factor of tinting color"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - /* Line Thickness change */ + /* Line Thickness Change */ prop = RNA_def_property(srna, "line_change", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "thickness"); - //RNA_def_property_range(prop, 1, 10); /* 10 px limit comes from Windows OpenGL limits for natively-drawn strokes */ - RNA_def_property_int_funcs(prop, NULL, NULL, "rna_GPencilLayer_line_width_range"); - RNA_def_property_ui_text(prop, "Thickness", "Thickness change to apply to current strokes (in pixels)"); + RNA_def_property_int_sdna(prop, NULL, "line_change"); + RNA_def_property_range(prop, -300, 300); + RNA_def_property_ui_range(prop, -100, 100, 1.0, 1); + RNA_def_property_ui_text(prop, "Thickness Change", "Thickness change to apply to current strokes (in pixels)"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* Onion-Skinning */ prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ONIONSKIN); - RNA_def_property_ui_text(prop, "Onion Skinning", "Ghost frames on either side of frame"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_onion_skinning_update"); - - prop = RNA_def_property(srna, "ghost_before_range", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "gstep"); - RNA_def_property_range(prop, -1, 120); - RNA_def_property_ui_text(prop, "Frames Before", - "Maximum number of frames to show before current frame " - "(0 = show only the previous sketch, -1 = don't show any frames before current)"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "gstep_next"); - RNA_def_property_range(prop, -1, 120); - RNA_def_property_ui_text(prop, "Frames After", - "Maximum number of frames to show after current frame " - "(0 = show only the next sketch, -1 = don't show any frames after current)"); + RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_LAYER_ONIONSKIN); + RNA_def_property_ui_text(prop, "Onion Skinning", "Display onion skins before and after the current frame"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - prop = RNA_def_property(srna, "use_ghost_custom_colors", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_GHOST_PREVCOL | GP_LAYER_GHOST_NEXTCOL); - RNA_def_property_ui_text(prop, "Use Custom Ghost Colors", "Use custom colors for ghost frames"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - prop = RNA_def_property(srna, "before_color", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "gcolor_prev"); - RNA_def_property_array(prop, 3); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - prop = RNA_def_property(srna, "after_color", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "gcolor_next"); - RNA_def_property_array(prop, 3); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - prop = RNA_def_property(srna, "use_ghosts_always", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_GHOST_ALWAYS); - RNA_def_property_ui_text(prop, "Always Show Ghosts", - "Ghosts are shown in renders and animation playback. Useful for special effects (e.g. motion blur)"); + /* pass index for compositing and modifiers */ + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Layer Index\" pass"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + prop = RNA_def_property(srna, "viewlayer_render", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "viewlayername"); + RNA_def_property_ui_text(prop, "ViewLayer", + "Only include Layer in this View Layer render output (leave blank to include always)"); /* Flags */ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1); RNA_def_property_ui_text(prop, "Hide", "Set layer Visibility"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); @@ -1287,16 +1178,14 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Frame Locked", "Lock current frame displayed by layer"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - /* Unlock colors */ - prop = RNA_def_property(srna, "unlock_color", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_UNLOCK_COLOR); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_COLOR_OFF, 1); - RNA_def_property_ui_text(prop, "Unlock Color", - "Unprotect selected colors from further editing and/or frame changes"); + prop = RNA_def_property(srna, "lock_material", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_UNLOCK_COLOR); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Lock Material", "Disable Material editing"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - /* expose as layers.active */ + /* exposed as layers.active */ #if 0 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ACTIVE); @@ -1310,16 +1199,15 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the Dope Sheet"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, "rna_GPencil_update"); - /* XXX keep this option? */ prop = RNA_def_property(srna, "show_points", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_DRAWDEBUG); RNA_def_property_ui_text(prop, "Show Points", "Draw the points which make up the strokes (for debugging purposes)"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - /* X-Ray */ - prop = RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE); + /* In Front */ + prop = RNA_def_property(srna, "show_in_front", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_NO_XRAY); - RNA_def_property_ui_text(prop, "X Ray", "Make the layer draw in front of objects"); + RNA_def_property_ui_text(prop, "In Front", "Make the layer draw in front of objects"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* Parent object */ @@ -1391,6 +1279,15 @@ static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + func = RNA_def_function(srna, "move", "rna_GPencil_layer_move"); + RNA_def_function_ui_description(func, "Move a grease pencil layer in the layer stack"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The layer to move"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + parm = RNA_def_enum(func, "type", rna_enum_gplayer_move_type_items, 1, "", "Direction of movement"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "GPencilLayer"); RNA_def_property_pointer_funcs(prop, "rna_GPencil_active_layer_get", "rna_GPencil_active_layer_set", NULL, NULL); @@ -1399,215 +1296,69 @@ static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL); prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, - "rna_GPencil_active_layer_index_get", - "rna_GPencil_active_layer_index_set", - "rna_GPencil_active_layer_index_range"); + RNA_def_property_int_funcs( + prop, + "rna_GPencil_active_layer_index_get", + "rna_GPencil_active_layer_index_set", + "rna_GPencil_active_layer_index_range"); RNA_def_property_ui_text(prop, "Active Layer Index", "Index of active grease pencil layer"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL); + + /* Active Layer - As an enum (for selecting active layer for annotations) */ + prop = RNA_def_property(srna, "active_note", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_funcs( + prop, + "rna_GPencil_active_layer_index_get", + "rna_GPencil_active_layer_index_set", + "rna_GPencil_active_layer_itemf"); + RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); /* purely dynamic, as it maps to user-data */ + RNA_def_property_ui_text(prop, "Active Note", "Note/Layer to add annotation strokes to"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); } -static void rna_def_gpencil_palettecolor(BlenderRNA *brna) +static void rna_def_gpencil_grid(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "GPencilPaletteColor", NULL); - RNA_def_struct_sdna(srna, "bGPDpalettecolor"); - RNA_def_struct_ui_text(srna, "Grease Pencil Palette color", "Collection of related colors"); - RNA_def_struct_path_func(srna, "rna_GPencilPalette_color_path"); + static const float default_grid_color[] = { 0.5f, 0.5f, 0.5f }; - /* Stroke Drawing Color */ - prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "color"); - RNA_def_property_array(prop, 3); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Color", "Color for strokes"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + srna = RNA_def_struct(brna, "GreasePencilGrid", NULL); + RNA_def_struct_sdna(srna, "bGPgrid"); + RNA_def_struct_nested(brna, srna, "GreasePencil"); - prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "color[3]"); - RNA_def_property_range(prop, 0.0, 1.0f); - RNA_def_property_ui_text(prop, "Opacity", "Color Opacity"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + RNA_def_struct_path_func(srna, "rna_GreasePencilGrid_path"); + RNA_def_struct_ui_text(srna, "Grid and Canvas Settings", + "Settings for grid and canvas in 3D viewport"); - /* Name */ - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "info"); - RNA_def_property_ui_text(prop, "Name", "Color name"); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilPaletteColor_info_set"); - RNA_def_struct_name_property(srna, prop); + prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "scale"); + RNA_def_property_range(prop, 0.01f, FLT_MAX); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Grid Scale", "Grid scale"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - /* Fill Drawing Color */ - prop = RNA_def_property(srna, "fill_color", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "fill"); + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "color"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region bounded by each stroke"); + RNA_def_property_float_array_default(prop, default_grid_color); + RNA_def_property_ui_text(prop, "Grid Color", "Color for grid lines"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - /* Fill alpha */ - prop = RNA_def_property(srna, "fill_alpha", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fill[3]"); - RNA_def_property_range(prop, 0.0, 1.0f); - RNA_def_property_ui_text(prop, "Fill Opacity", "Opacity for filling region bounded by each stroke"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - /* Flags */ - prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_HIDE); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); - RNA_def_property_ui_text(prop, "Hide", "Set color Visibility"); + prop = RNA_def_property(srna, "lines", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "lines"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_int_default(prop, GP_DEFAULT_GRID_LINES); + RNA_def_property_ui_text(prop, "Grid Subdivisions", "Number of subdivisions in each side of symmetry line"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_LOCKED); - RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); - RNA_def_property_ui_text(prop, "Locked", "Protect color from further editing and/or frame changes"); + prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "offset"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Offset", "Offset of the canvas"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - prop = RNA_def_property(srna, "ghost", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_ONIONSKIN); - RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0); - RNA_def_property_ui_text(prop, "Show in Ghosts", "Display strokes using this color when showing onion skins"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - /* Draw Style */ - prop = RNA_def_property(srna, "use_volumetric_strokes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_VOLUMETRIC); - RNA_def_property_ui_text(prop, "Volumetric Strokes", "Draw strokes as a series of circular blobs, resulting in " - "a volumetric effect"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - /* Use High quality fill */ - prop = RNA_def_property(srna, "use_hq_fill", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PC_COLOR_HQ_FILL); - RNA_def_property_ui_text(prop, "High Quality Fill", "Fill strokes using high quality to avoid glitches " - "(slower fps during animation play)"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - /* Read-only state props (for simpler UI code) */ - prop = RNA_def_property(srna, "is_stroke_visible", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_GPencilPaletteColor_is_stroke_visible_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Is Stroke Visible", "True when opacity of stroke is set high enough to be visible"); - - prop = RNA_def_property(srna, "is_fill_visible", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_GPencilPaletteColor_is_fill_visible_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Is Fill Visible", "True when opacity of fill is set high enough to be visible"); -} - -/* palette colors api */ -static void rna_def_gpencil_palettecolors_api(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - PropertyRNA *prop; - - FunctionRNA *func; - PropertyRNA *parm; - - RNA_def_property_srna(cprop, "GPencilPaletteColors"); - srna = RNA_def_struct(brna, "GPencilPaletteColors", NULL); - RNA_def_struct_sdna(srna, "bGPDpalette"); - RNA_def_struct_ui_text(srna, "Palette colors", "Collection of palette colors"); - - func = RNA_def_function(srna, "new", "rna_GPencilPalette_color_new"); - RNA_def_function_ui_description(func, "Add a new color to the palette"); - parm = RNA_def_pointer(func, "color", "GPencilPaletteColor", "", "The newly created color"); - RNA_def_function_return(func, parm); - - func = RNA_def_function(srna, "remove", "rna_GPencilPalette_color_remove"); - RNA_def_function_ui_description(func, "Remove a color from the palette"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "color", "GPencilPaletteColor", "", "The color to remove"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); - RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); - - prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "GPencilPaletteColor"); - RNA_def_property_pointer_funcs(prop, "rna_GPencilPalette_active_color_get", "rna_GPencilPalette_active_color_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Active Palette Color", "Current active color"); - - prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, - "rna_GPencilPaletteColor_index_get", - "rna_GPencilPaletteColor_index_set", - "rna_GPencilPaletteColor_index_range"); - RNA_def_property_ui_text(prop, "Active color Index", "Index of active palette color"); -} - -static void rna_def_gpencil_palette(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GPencilPalette", NULL); - RNA_def_struct_sdna(srna, "bGPDpalette"); - RNA_def_struct_ui_text(srna, "Grease Pencil Palette", "Collection of related palettes"); - RNA_def_struct_path_func(srna, "rna_GPencilPalette_path"); - RNA_def_struct_ui_icon(srna, ICON_COLOR); - - /* Name */ - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "info"); - RNA_def_property_ui_text(prop, "Name", "Palette name"); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilPalette_info_set"); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - /* Colors */ - prop = RNA_def_property(srna, "colors", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "colors", NULL); - RNA_def_property_struct_type(prop, "GPencilPaletteColor"); - RNA_def_property_ui_text(prop, "Colors", "Colors of the palette"); - rna_def_gpencil_palettecolors_api(brna, prop); - -} - -static void rna_def_gpencil_palettes_api(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - PropertyRNA *prop; - - FunctionRNA *func; - PropertyRNA *parm; - - RNA_def_property_srna(cprop, "GreasePencilPalettes"); - srna = RNA_def_struct(brna, "GreasePencilPalettes", NULL); - RNA_def_struct_sdna(srna, "bGPdata"); - RNA_def_struct_ui_text(srna, "Grease Pencil Palettes", "Collection of grease pencil palettes"); - - func = RNA_def_function(srna, "new", "rna_GPencil_palette_new"); - RNA_def_function_ui_description(func, "Add a new grease pencil palette"); - parm = RNA_def_string(func, "name", "GPencilPalette", MAX_NAME, "Name", "Name of the palette"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_boolean(func, "set_active", true, "Set Active", "Activate the newly created palette"); - parm = RNA_def_pointer(func, "palette", "GPencilPalette", "", "The newly created palette"); - RNA_def_function_return(func, parm); - - func = RNA_def_function(srna, "remove", "rna_GPencil_palette_remove"); - RNA_def_function_ui_description(func, "Remove a grease pencil palette"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "palette", "GPencilPalette", "", "The palette to remove"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); - RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); - - prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "GPencilPalette"); - RNA_def_property_pointer_funcs(prop, "rna_GPencil_active_palette_get", "rna_GPencil_active_palette_set", - NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Active Palette", "Current active palette"); - - prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, - "rna_GPencilPalette_index_get", - "rna_GPencilPalette_index_set", - "rna_GPencilPalette_index_range"); - RNA_def_property_ui_text(prop, "Active Palette Index", "Index of active palette"); } static void rna_def_gpencil_data(BlenderRNA *brna) @@ -1616,6 +1367,10 @@ static void rna_def_gpencil_data(BlenderRNA *brna) PropertyRNA *prop; FunctionRNA *func; + static float default_1[4] = { 0.6f, 0.6f, 0.6f, 0.5f }; + static float onion_dft1[3] = { 0.145098f, 0.419608f, 0.137255f }; /* green */ + static float onion_dft2[3] = { 0.125490f, 0.082353f, 0.529412f }; /* blue */ + srna = RNA_def_struct(brna, "GreasePencil", "ID"); RNA_def_struct_sdna(srna, "bGPdata"); RNA_def_struct_ui_text(srna, "Grease Pencil", "Freehand annotation sketchbook"); @@ -1628,28 +1383,52 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Layers", ""); rna_def_gpencil_layers_api(brna, prop); - /* Palettes */ - prop = RNA_def_property(srna, "palettes", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "palettes", NULL); - RNA_def_property_struct_type(prop, "GPencilPalette"); - RNA_def_property_ui_text(prop, "Palettes", ""); - rna_def_gpencil_palettes_api(brna, prop); - /* Animation Data */ rna_def_animdata_common(srna); + /* materials */ + prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); + RNA_def_property_struct_type(prop, "Material"); + RNA_def_property_ui_text(prop, "Materials", ""); + RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */ + RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int"); + + /* xray modes */ + prop = RNA_def_property(srna, "xray_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "xray_mode"); + RNA_def_property_enum_items(prop, rna_enum_gpencil_xraymodes_items); + RNA_def_property_ui_text(prop, "Xray", ""); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* Flags */ prop = RNA_def_property(srna, "use_stroke_edit_mode", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_EDITMODE); RNA_def_property_ui_text(prop, "Stroke Edit Mode", "Edit Grease Pencil strokes instead of viewport data"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update"); + prop = RNA_def_property(srna, "is_stroke_paint_mode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_PAINTMODE); + RNA_def_property_ui_text(prop, "Stroke Paint Mode", "Draw Grease Pencil strokes on click/drag"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update"); + + prop = RNA_def_property(srna, "is_stroke_sculpt_mode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_SCULPTMODE); + RNA_def_property_ui_text(prop, "Stroke Sculpt Mode", "Sculpt Grease Pencil strokes instead of viewport data"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update"); + + prop = RNA_def_property(srna, "is_stroke_weight_mode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_WEIGHTMODE); + RNA_def_property_ui_text(prop, "Stroke Weight Paint Mode", "Grease Pencil weight paint"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_editmode_update"); + prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_SHOW_ONIONSKINS); - RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_use_onion_skinning_set"); - RNA_def_property_ui_text(prop, "Onion Skins", - "Show ghosts of the frames before and after the current frame, toggle to enable on active layer or disable all"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + RNA_def_property_ui_text(prop, "Onion Skins", "Show ghosts of the keyframes before and after the current frame"); + RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update"); prop = RNA_def_property(srna, "show_stroke_direction", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_SHOW_DIRECTION); @@ -1657,9 +1436,137 @@ static void rna_def_gpencil_data(BlenderRNA *brna) "and smaller red dot (end) points"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + prop = RNA_def_property(srna, "show_constant_thickness", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_KEEPTHICKNESS); + RNA_def_property_ui_text(prop, "Keep Thickness", "Maintain the thickness of the stroke when the viewport zoom changes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "pixel_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pixfactor"); + RNA_def_property_range(prop, 0.1f, 30.0f); + RNA_def_property_ui_range(prop, 0.1f, 30.0f, 1, 2); + RNA_def_property_ui_text(prop, "Scale", "Scale conversion factor for pixel size (use larger values for thicker lines)"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "use_multiedit", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_MULTIEDIT); + RNA_def_property_ui_text(prop, "MultiFrame", "Edit strokes from multiple grease pencil keyframes at the same time (keyframes must be selected to be included)"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "use_force_fill_recalc", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_FORCE_RECALC); + RNA_def_property_ui_text(prop, "Force Fill Update", "Force recalc of fill data after use deformation modifiers (reduce FPS)"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "use_adaptative_uv", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_UV_ADAPTATIVE); + RNA_def_property_ui_text(prop, "Adaptative UV", "Automatic UVs are calculated depending of the stroke size"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "use_autolock_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_AUTOLOCK_LAYERS); + RNA_def_property_ui_text(prop, "Autolock Layers", + "Lock automatically all layers except active one to avoid accidental changes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_autolock"); + + prop = RNA_def_property(srna, "edit_line_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "line_color"); + RNA_def_property_array(prop, 4); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_array_default(prop, default_1); + RNA_def_property_ui_text(prop, "Edit Line Color", "Color for editing line"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + /* onion skinning */ + prop = RNA_def_property(srna, "ghost_before_range", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "gstep"); + RNA_def_property_range(prop, 0, 120); + RNA_def_property_int_default(prop, 1); + RNA_def_property_ui_text(prop, "Frames Before", + "Maximum number of frames to show before current frame " + "(0 = don't show any frames before current)"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "gstep_next"); + RNA_def_property_range(prop, 0, 120); + RNA_def_property_int_default(prop, 1); + RNA_def_property_ui_text(prop, "Frames After", + "Maximum number of frames to show after current frame " + "(0 = don't show any frames after current)"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "use_ghost_custom_colors", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_GHOST_PREVCOL | GP_ONION_GHOST_NEXTCOL); + RNA_def_property_ui_text(prop, "Use Custom Ghost Colors", "Use custom colors for ghost frames"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "before_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gcolor_prev"); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_array_default(prop, onion_dft1); + RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame"); + RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "after_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gcolor_next"); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_array_default(prop, onion_dft2); + RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame"); + RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "use_ghosts_always", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_GHOST_ALWAYS); + RNA_def_property_ui_text(prop, "Always Show Ghosts", + "Ghosts are shown in renders and animation playback. Useful for special effects (e.g. motion blur)"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "onion_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "onion_mode"); + RNA_def_property_enum_items(prop, rna_enum_gpencil_onion_modes_items); + RNA_def_property_ui_text(prop, "Mode", "Mode to display frames"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "use_onion_fade", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_FADE); + RNA_def_property_ui_text(prop, "Fade", + "Display onion keyframes with a fade in color transparency"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "use_onion_loop", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_LOOP); + RNA_def_property_ui_text(prop, "Loop", + "Display first onion keyframes using next frame color to show indication of loop start frame"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "onion_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "onion_factor"); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_range(prop, 0.0, 1.0f); + RNA_def_property_ui_text(prop, "Onion Opacity", "Change fade opacity of displayed onion frames"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "zdepth_offset", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "zdepth_offset"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 5); + RNA_def_property_ui_text(prop, "Surface Offset", + "Offset amount when drawing in surface mode"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + /* Nested Structs */ + prop = RNA_def_property(srna, "grid", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "GreasePencilGrid"); + RNA_def_property_ui_text(prop, "Grid Settings", "Settings for grid and canvas in the 3D viewport"); + + rna_def_gpencil_grid(brna); + /* API Functions */ func = RNA_def_function(srna, "clear", "rna_GPencil_clear"); - RNA_def_function_ui_description(func, "Remove all the grease pencil data"); + RNA_def_function_ui_description(func, "Remove all the Grease Pencil data"); } /* --- */ @@ -1670,12 +1577,12 @@ void RNA_def_gpencil(BlenderRNA *brna) rna_def_gpencil_layer(brna); rna_def_gpencil_frame(brna); - rna_def_gpencil_triangle(brna); + rna_def_gpencil_stroke(brna); rna_def_gpencil_stroke_point(brna); + rna_def_gpencil_triangle(brna); - rna_def_gpencil_palette(brna); - rna_def_gpencil_palettecolor(brna); + rna_def_gpencil_mvert_group(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c new file mode 100644 index 00000000000..dc13f099e11 --- /dev/null +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -0,0 +1,1652 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_gpencil_modifier.c + * \ingroup RNA + */ + + +#include <float.h> +#include <limits.h> +#include <stdlib.h> + +#include "DNA_armature_types.h" +#include "DNA_cachefile_types.h" +#include "DNA_mesh_types.h" +#include "DNA_gpencil_modifier_types.h" +#include "DNA_object_types.h" +#include "DNA_object_force_types.h" +#include "DNA_scene_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "BLT_translation.h" + +#include "BKE_animsys.h" +#include "BKE_data_transfer.h" +#include "BKE_dynamicpaint.h" +#include "BKE_effect.h" +#include "BKE_mesh_mapping.h" +#include "BKE_mesh_remap.h" +#include "BKE_multires.h" +#include "BKE_smoke.h" /* For smokeModifier_free & smokeModifier_createType */ + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "rna_internal.h" + +#include "WM_api.h" +#include "WM_types.h" + +const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = { + {0, "", 0, N_("Generate"), "" }, + {eGpencilModifierType_Array, "GP_ARRAY", ICON_MOD_ARRAY, "Array", "Create array of duplicate instances"}, + {eGpencilModifierType_Build, "GP_BUILD", ICON_MOD_BUILD, "Build", "Create duplication of strokes"}, + {eGpencilModifierType_Mirror, "GP_MIRROR", ICON_MOD_MIRROR, "Mirror", "Duplicate strokes like a mirror"}, + {eGpencilModifierType_Simplify, "GP_SIMPLIFY", ICON_MOD_SIMPLIFY, "Simplify", "Simplify stroke reducing number of points"}, + {eGpencilModifierType_Subdiv, "GP_SUBDIV", ICON_MOD_SUBSURF, "Subdivide", "Subdivide stroke adding more control points"}, + {0, "", 0, N_("Deform"), "" }, + {eGpencilModifierType_Armature, "GP_ARMATURE", ICON_MOD_ARMATURE, "Armature", "Deform stroke points using armature object"}, + {eGpencilModifierType_Hook, "GP_HOOK", ICON_HOOK, "Hook", "Deform stroke points using objects"}, + {eGpencilModifierType_Lattice, "GP_LATTICE", ICON_MOD_LATTICE, "Lattice", "Deform strokes using lattice"}, + {eGpencilModifierType_Noise, "GP_NOISE", ICON_MOD_NOISE, "Noise", "Add noise to strokes"}, + {eGpencilModifierType_Offset, "GP_OFFSET", ICON_MOD_OFFSET, "Offset", "Change stroke location, rotation or scale"}, + {eGpencilModifierType_Smooth, "GP_SMOOTH", ICON_MOD_SMOOTH, "Smooth", "Smooth stroke"}, + {eGpencilModifierType_Thick, "GP_THICK", ICON_MOD_THICKNESS, "Thickness", "Change stroke thickness"}, + {eGpencilModifierType_Time, "GP_TIME", ICON_MOD_TIME, "Time Offset", "Offset keyframes"}, + {0, "", 0, N_("Color"), "" }, + {eGpencilModifierType_Color, "GP_COLOR", ICON_MOD_HUE_SATURATION, "Hue/Saturation", "Apply changes to stroke colors"}, + {eGpencilModifierType_Opacity, "GP_OPACITY", ICON_MOD_OPACITY, "Opacity", "Opacity of the strokes"}, + {eGpencilModifierType_Tint, "GP_TINT", ICON_MOD_TINT, "Tint", "Tint strokes with new color"}, + {0, NULL, 0, NULL, NULL} +}; + +#ifndef RNA_RUNTIME +static const EnumPropertyItem modifier_modify_color_items[] = { + { GP_MODIFY_COLOR_BOTH, "BOTH", 0, "Both", "Modify fill and stroke colors" }, + { GP_MODIFY_COLOR_STROKE, "STROKE", 0, "Stroke", "Modify stroke color only" }, + { GP_MODIFY_COLOR_FILL, "FILL", 0, "Fill", "Modify fill color only" }, + { 0, NULL, 0, NULL, NULL } +}; + +static const EnumPropertyItem modifier_gphook_falloff_items[] = { + { eGPHook_Falloff_None, "NONE", 0, "No Falloff", "" }, + { eGPHook_Falloff_Curve, "CURVE", 0, "Curve", "" }, + { eGPHook_Falloff_Smooth, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", "" }, + { eGPHook_Falloff_Sphere, "SPHERE", ICON_SPHERECURVE, "Sphere", "" }, + { eGPHook_Falloff_Root, "ROOT", ICON_ROOTCURVE, "Root", "" }, + { eGPHook_Falloff_InvSquare, "INVERSE_SQUARE", ICON_ROOTCURVE, "Inverse Square", "" }, + { eGPHook_Falloff_Sharp, "SHARP", ICON_SHARPCURVE, "Sharp", "" }, + { eGPHook_Falloff_Linear, "LINEAR", ICON_LINCURVE, "Linear", "" }, + { eGPHook_Falloff_Const, "CONSTANT", ICON_NOCURVE, "Constant", "" }, + { 0, NULL, 0, NULL, NULL } +}; + +static const EnumPropertyItem rna_enum_time_mode_items[] = { + { GP_TIME_MODE_NORMAL, "NORMAL", 0, "Normal", "Apply offset in normal animation direction" }, + { GP_TIME_MODE_REVERSE, "REVERSE", 0, "Reverse", "Apply offset in reverse animation direction" }, + { GP_TIME_MODE_FIX, "FIX", 0, "Fixed Frame", "Keep frame and do not change with time" }, + { 0, NULL, 0, NULL, NULL } +}; + +#endif + +#ifdef RNA_RUNTIME + +#include "DNA_particle_types.h" +#include "DNA_curve_types.h" +#include "DNA_smoke_types.h" + +#include "BKE_cachefile.h" +#include "BKE_context.h" +#include "BKE_gpencil_modifier.h" +#include "BKE_object.h" +#include "BKE_gpencil.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + +static StructRNA *rna_GpencilModifier_refine(struct PointerRNA *ptr) +{ + GpencilModifierData *md = (GpencilModifierData *)ptr->data; + + switch ((GpencilModifierType)md->type) { + case eGpencilModifierType_Noise: + return &RNA_NoiseGpencilModifier; + case eGpencilModifierType_Subdiv: + return &RNA_SubdivGpencilModifier; + case eGpencilModifierType_Simplify: + return &RNA_SimplifyGpencilModifier; + case eGpencilModifierType_Thick: + return &RNA_ThickGpencilModifier; + case eGpencilModifierType_Tint: + return &RNA_TintGpencilModifier; + case eGpencilModifierType_Time: + return &RNA_TimeGpencilModifier; + case eGpencilModifierType_Color: + return &RNA_ColorGpencilModifier; + case eGpencilModifierType_Array: + return &RNA_ArrayGpencilModifier; + case eGpencilModifierType_Build: + return &RNA_BuildGpencilModifier; + case eGpencilModifierType_Opacity: + return &RNA_OpacityGpencilModifier; + case eGpencilModifierType_Lattice: + return &RNA_LatticeGpencilModifier; + case eGpencilModifierType_Mirror: + return &RNA_MirrorGpencilModifier; + case eGpencilModifierType_Smooth: + return &RNA_SmoothGpencilModifier; + case eGpencilModifierType_Hook: + return &RNA_HookGpencilModifier; + case eGpencilModifierType_Offset: + return &RNA_OffsetGpencilModifier; + case eGpencilModifierType_Armature: + return &RNA_ArmatureGpencilModifier; + /* Default */ + case eGpencilModifierType_None: + case NUM_GREASEPENCIL_MODIFIER_TYPES: + return &RNA_GpencilModifier; + } + + return &RNA_GpencilModifier; +} + +static void rna_GpencilModifier_name_set(PointerRNA *ptr, const char *value) +{ + GpencilModifierData *gmd = ptr->data; + char oldname[sizeof(gmd->name)]; + + /* make a copy of the old name first */ + BLI_strncpy(oldname, gmd->name, sizeof(gmd->name)); + + /* copy the new name into the name slot */ + BLI_strncpy_utf8(gmd->name, value, sizeof(gmd->name)); + + /* make sure the name is truly unique */ + if (ptr->id.data) { + Object *ob = ptr->id.data; + BKE_gpencil_modifier_unique_name(&ob->greasepencil_modifiers, gmd); + } + + /* fix all the animation data which may link to this */ + BKE_animdata_fix_paths_rename_all(NULL, "grease_pencil_modifiers", oldname, gmd->name); +} + +static char *rna_GpencilModifier_path(PointerRNA *ptr) +{ + GpencilModifierData *gmd = ptr->data; + char name_esc[sizeof(gmd->name) * 2]; + + BLI_strescape(name_esc, gmd->name, sizeof(name_esc)); + return BLI_sprintfN("grease_pencil_modifiers[\"%s\"]", name_esc); +} + +static void rna_GpencilModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->id.data); +} + +static void rna_GpencilModifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + rna_GpencilModifier_update(bmain, scene, ptr); + DEG_relations_tag_update(bmain); +} + +/* Vertex Groups */ + +#define RNA_GP_MOD_VGROUP_NAME_SET(_type, _prop) \ +static void rna_##_type##GpencilModifier_##_prop##_set(PointerRNA *ptr, const char *value) \ +{ \ + _type##GpencilModifierData *tmd = (_type##GpencilModifierData *)ptr->data; \ + rna_object_vgroup_name_set(ptr, value, tmd->_prop, sizeof(tmd->_prop)); \ +} + +RNA_GP_MOD_VGROUP_NAME_SET(Noise, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Thick, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Opacity, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Lattice, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Smooth, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Hook, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Offset, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Armature, vgname); + +#undef RNA_GP_MOD_VGROUP_NAME_SET + +/* Objects */ + +static void greasepencil_modifier_object_set(Object *self, Object **ob_p, int type, PointerRNA value) +{ + Object *ob = value.data; + + if (!self || ob != self) { + if (!ob || type == OB_EMPTY || ob->type == type) { + id_lib_extern((ID *)ob); + *ob_p = ob; + } + } +} + +#define RNA_GP_MOD_OBJECT_SET(_type, _prop, _obtype) \ +static void rna_##_type##GpencilModifier_##_prop##_set(PointerRNA *ptr, PointerRNA value) \ +{ \ + _type##GpencilModifierData *tmd = (_type##GpencilModifierData *)ptr->data; \ + greasepencil_modifier_object_set(ptr->id.data, &tmd->_prop, _obtype, value); \ +} + +RNA_GP_MOD_OBJECT_SET(Armature, object, OB_ARMATURE); +RNA_GP_MOD_OBJECT_SET(Lattice, object, OB_LATTICE); +RNA_GP_MOD_OBJECT_SET(Mirror, object, OB_EMPTY); + +#undef RNA_GP_MOD_OBJECT_SET + +static void rna_HookGpencilModifier_object_set(PointerRNA *ptr, PointerRNA value) +{ + HookGpencilModifierData *hmd = ptr->data; + Object *ob = (Object *)value.data; + + hmd->object = ob; + id_lib_extern((ID *)ob); + BKE_object_modifier_gpencil_hook_reset(ob, hmd); +} + +static void rna_TimeModifier_start_frame_set(PointerRNA *ptr, int value) +{ + TimeGpencilModifierData *tmd = ptr->data; + CLAMP(value, MINFRAME, MAXFRAME); + tmd->sfra = value; + + if (tmd->sfra >= tmd->efra) { + tmd->efra = MIN2(tmd->sfra, MAXFRAME); + } +} + +static void rna_TimeModifier_end_frame_set(PointerRNA *ptr, int value) +{ + TimeGpencilModifierData *tmd = ptr->data; + CLAMP(value, MINFRAME, MAXFRAME); + tmd->efra = value; + + if (tmd->sfra >= tmd->efra) { + tmd->sfra = MAX2(tmd->efra, MINFRAME); + } +} + +#else + +static void rna_def_modifier_gpencilnoise(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "NoiseGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Noise Modifier", "Noise effect modifier"); + RNA_def_struct_sdna(srna, "NoiseGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_NOISE); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NoiseGpencilModifier_vgname_set"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "factor"); + RNA_def_property_range(prop, 0, 30.0); + RNA_def_property_ui_text(prop, "Factor", "Amount of noise to apply"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "random", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_USE_RANDOM); + RNA_def_property_ui_text(prop, "Random", "Use random values"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_edit_position", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_MOD_LOCATION); + RNA_def_property_ui_text(prop, "Affect Position", "The modifier affects the position of the point"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_edit_strength", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_MOD_STRENGTH); + RNA_def_property_ui_text(prop, "Affect Strength", "The modifier affects the color strength of the point"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_edit_thickness", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_MOD_THICKNESS); + RNA_def_property_ui_text(prop, "Affect Thickness", "The modifier affects the thickness of the point"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_edit_uv", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_MOD_UV); + RNA_def_property_ui_text(prop, "Affect UV", "The modifier affects the UV rotation factor of the point"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "full_stroke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_FULL_STROKE); + RNA_def_property_ui_text(prop, "Full Stroke", "The noise moves the stroke as a whole, not point by point"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "move_extreme", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_MOVE_EXTREME); + RNA_def_property_ui_text(prop, "Move Extremes", "The noise moves the stroke extreme points"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "step", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "step"); + RNA_def_property_range(prop, 1, 100); + RNA_def_property_ui_text(prop, "Step", "Number of frames before recalculate random values again"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Inverse VertexGroup", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilsmooth(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "SmoothGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Smooth Modifier", "Smooth effect modifier"); + RNA_def_struct_sdna(srna, "SmoothGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SMOOTH); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SmoothGpencilModifier_vgname_set"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "factor"); + RNA_def_property_range(prop, 0, 2); + RNA_def_property_ui_text(prop, "Factor", "Amount of smooth to apply"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_edit_position", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SMOOTH_MOD_LOCATION); + RNA_def_property_ui_text(prop, "Affect Position", "The modifier affects the position of the point"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_edit_strength", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SMOOTH_MOD_STRENGTH); + RNA_def_property_ui_text(prop, "Affect Strength", "The modifier affects the color strength of the point"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_edit_thickness", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SMOOTH_MOD_THICKNESS); + RNA_def_property_ui_text(prop, "Affect Thickness", "The modifier affects the thickness of the point"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_edit_uv", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SMOOTH_MOD_UV); + RNA_def_property_ui_text(prop, "Affect UV", "The modifier affects the UV rotation factor of the point"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "step", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "step"); + RNA_def_property_range(prop, 1, 10); + RNA_def_property_ui_text(prop, "Step", "Number of times to apply smooth (high numbers can reduce fps)"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SMOOTH_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SMOOTH_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SMOOTH_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Inverse VertexGroup", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SMOOTH_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilsubdiv(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "SubdivGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Subdivision Modifier", "Subdivide Stroke modifier"); + RNA_def_struct_sdna(srna, "SubdivGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SUBSURF); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "level", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "level"); + RNA_def_property_range(prop, 0, 5); + RNA_def_property_ui_text(prop, "Level", "Number of subdivisions"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "simple", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SUBDIV_SIMPLE); + RNA_def_property_ui_text(prop, "Simple", "The modifier only add control points"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SUBDIV_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SUBDIV_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SUBDIV_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilsimplify(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_gpencil_simplify_mode_items[] = { + { GP_SIMPLIFY_FIXED, "FIXED", ICON_IPO_CONSTANT, "Fixed", + "Delete alternative vertices in the stroke, except extrems" }, + { GP_SIMPLIFY_ADAPTATIVE, "ADAPTATIVE", ICON_IPO_EASE_IN_OUT, "Adaptative", + "Use a RDP algorithm to simplify" }, + { 0, NULL, 0, NULL, NULL } + }; + + srna = RNA_def_struct(brna, "SimplifyGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Simplify Modifier", "Simplify Stroke modifier"); + RNA_def_struct_sdna(srna, "SimplifyGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SIMPLIFY); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "factor"); + RNA_def_property_range(prop, 0, 100.0); + RNA_def_property_ui_range(prop, 0, 100.0, 1.0f, 3); + RNA_def_property_ui_text(prop, "Factor", "Factor of Simplify"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SIMPLIFY_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SIMPLIFY_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SIMPLIFY_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + /* Mode */ + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_gpencil_simplify_mode_items); + RNA_def_property_ui_text(prop, "Mode", "How simplify the stroke"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "step", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "step"); + RNA_def_property_range(prop, 1, 50); + RNA_def_property_ui_text(prop, "Iterations", "Number of times to apply simplify"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilthick(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ThickGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Thick Modifier", "Subdivide and Smooth Stroke modifier"); + RNA_def_struct_sdna(srna, "ThickGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_THICKNESS); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ThickGpencilModifier_vgname_set"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "thickness", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "thickness"); + RNA_def_property_range(prop, -100, 500); + RNA_def_property_ui_text(prop, "Thickness", "Factor of thickness change"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_THICK_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_THICK_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_THICK_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Inverse VertexGroup", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_THICK_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_custom_curve", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_THICK_CUSTOM_CURVE); + RNA_def_property_ui_text(prop, "Custom Curve", "Use a custom curve to define thickness changes"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "normalize_thickness", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_THICK_NORMALIZE); + RNA_def_property_ui_text(prop, "Normalize", "Normalize the full stroke to modifier thickness"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "curve_thickness"); + RNA_def_property_ui_text(prop, "Curve", "Custom Thickness Curve"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpenciloffset(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "OffsetGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Offset Modifier", "Offset Stroke modifier"); + RNA_def_struct_sdna(srna, "OffsetGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_OFFSET); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_OffsetGpencilModifier_vgname_set"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OFFSET_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OFFSET_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OFFSET_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Inverse VertexGroup", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OFFSET_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_float_sdna(prop, NULL, "loc"); + RNA_def_property_ui_text(prop, "Location", "Values for change location"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER); + RNA_def_property_float_sdna(prop, NULL, "rot"); + RNA_def_property_ui_text(prop, "Rotation", "Values for changes in rotation"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "scale"); + RNA_def_property_ui_text(prop, "Scale", "Values for changes in scale"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpenciltint(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "TintGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Tint Modifier", "Tint Stroke Color modifier"); + RNA_def_struct_sdna(srna, "TintGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_COLOR); + + prop = RNA_def_property(srna, "modify_color", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, modifier_modify_color_items); /* share the enum */ + RNA_def_property_ui_text(prop, "Mode", "Set what colors of the stroke are affected"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_float_sdna(prop, NULL, "rgb"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Color", "Color used for tinting"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "factor"); + RNA_def_property_ui_range(prop, 0, 2.0, 0.1, 3); + RNA_def_property_ui_text(prop, "Factor", "Factor for mixing color"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "create_materials", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TINT_CREATE_COLORS); + RNA_def_property_ui_text(prop, "Create Materials", "When apply modifier, create new material"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TINT_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TINT_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TINT_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpenciltime(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "TimeGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Time Offset Modifier", "Time offset modifier"); + RNA_def_struct_sdna(srna, "TimeGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_TIME); + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, rna_enum_time_mode_items); + RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TIME_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TIME_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "offset", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "offset"); + RNA_def_property_range(prop, -INT_MAX, INT_MAX); + RNA_def_property_ui_text(prop, "Frame Offset", + "Number of frames to offset original keyframe number or frame to fix"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "frame_scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "frame_scale"); + RNA_def_property_range(prop, 0.001f, 100.0f); + RNA_def_property_ui_text(prop, "Frame Scale", "Evaluation time in seconds"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "sfra"); + RNA_def_property_int_funcs(prop, NULL, "rna_TimeModifier_start_frame_set", NULL); + RNA_def_property_range(prop, MINFRAME, MAXFRAME); + RNA_def_property_int_default(prop, 1); + RNA_def_property_ui_text(prop, "Start Frame", "First frame of the range"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "efra"); + RNA_def_property_int_funcs(prop, NULL, "rna_TimeModifier_end_frame_set", NULL); + RNA_def_property_range(prop, MINFRAME, MAXFRAME); + RNA_def_property_int_default(prop, 250); + RNA_def_property_ui_text(prop, "End Frame", "Final frame of the range"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_keep_loop", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TIME_KEEP_LOOP); + RNA_def_property_ui_text(prop, "Keep Loop", + "Retiming end frames and move to start of animation to keep loop"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_custom_frame_range", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TIME_CUSTOM_RANGE); + RNA_def_property_ui_text(prop, "Custom Range", + "Define a custom range of frames to use in modifier"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilcolor(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ColorGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Hue/Saturation Modifier", "Change Hue/Saturation modifier"); + RNA_def_struct_sdna(srna, "ColorGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_TINT); + + prop = RNA_def_property(srna, "modify_color", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, modifier_modify_color_items); /* share the enum */ + RNA_def_property_ui_text(prop, "Mode", "Set what colors of the stroke are affected"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "hue", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0, 2.0); + RNA_def_property_ui_range(prop, 0.0, 2.0, 0.1, 3); + RNA_def_property_float_sdna(prop, NULL, "hsv[0]"); + RNA_def_property_ui_text(prop, "Hue", "Color Hue"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "saturation", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0, 2.0); + RNA_def_property_ui_range(prop, 0.0, 2.0, 0.1, 3); + RNA_def_property_float_sdna(prop, NULL, "hsv[1]"); + RNA_def_property_ui_text(prop, "Saturation", "Color Saturation"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0, 2.0); + RNA_def_property_ui_range(prop, 0.0, 2.0, 0.1, 3); + RNA_def_property_float_sdna(prop, NULL, "hsv[2]"); + RNA_def_property_ui_text(prop, "Value", "Color Value"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "create_materials", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_COLOR_CREATE_COLORS); + RNA_def_property_ui_text(prop, "Create Materials", "When apply modifier, create new material"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_COLOR_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_COLOR_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_COLOR_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilopacity(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "OpacityGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Opacity Modifier", "Opacity of Strokes modifier"); + RNA_def_struct_sdna(srna, "OpacityGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_OPACITY); + + prop = RNA_def_property(srna, "modify_color", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, modifier_modify_color_items); /* share the enum */ + RNA_def_property_ui_text(prop, "Mode", "Set what colors of the stroke are affected"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_OpacityGpencilModifier_vgname_set"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "factor"); + RNA_def_property_ui_range(prop, 0, 2.0, 0.1, 3); + RNA_def_property_ui_text(prop, "Factor", "Factor of Opacity"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "create_materials", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OPACITY_CREATE_COLORS); + RNA_def_property_ui_text(prop, "Create Materials", "When apply modifier, create new material"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OPACITY_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OPACITY_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OPACITY_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Inverse VertexGroup", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OPACITY_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilinstance(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ArrayGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Instance Modifier", "Create grid of duplicate instances"); + RNA_def_struct_sdna(srna, "ArrayGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_ARRAY); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "count", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_ui_range(prop, 1, 50, 1, -1); + RNA_def_property_ui_text(prop, "Count", "Number of items"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + /* Offset parameters */ + prop = RNA_def_property(srna, "offset_object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "object"); + RNA_def_property_ui_text(prop, "Object Offset", + "Use the location and rotation of another object to determine the distance and " + "rotational change between arrayed items"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_float_sdna(prop, NULL, "offset"); + RNA_def_property_ui_text(prop, "Offset", "Value for the distance between items"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "shift", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_float_sdna(prop, NULL, "shift"); + RNA_def_property_ui_text(prop, "Shift", "Shiftness value"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER); + RNA_def_property_float_sdna(prop, NULL, "rot"); + RNA_def_property_ui_text(prop, "Rotation", "Value for changes in rotation"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "scale"); + RNA_def_property_ui_text(prop, "Scale", "Value for changes in scale"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "random_rot", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_RANDOM_ROT); + RNA_def_property_ui_text(prop, "Random Rotation", "Use random factors for rotation"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "rot_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "rnd_rot"); + RNA_def_property_ui_text(prop, "Rotation Factor", "Random factor for rotation"); + RNA_def_property_range(prop, -10.0, 10.0); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "random_scale", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_RANDOM_SIZE); + RNA_def_property_ui_text(prop, "Random Scale", "Use random factors for scale"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "scale_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "rnd_size"); + RNA_def_property_ui_text(prop, "Scale Factor", "Random factor for scale"); + RNA_def_property_range(prop, -10.0, 10.0); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "replace_material", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "mat_rpl"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Material", "Index of the material used for generated strokes (0 keep original material)"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "keep_on_top", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_KEEP_ONTOP); + RNA_def_property_ui_text(prop, "Keep On Top", + "Keep the original stroke in front of new instances (only affect by layer)"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilbuild(BlenderRNA *brna) +{ + static EnumPropertyItem prop_gpencil_build_mode_items[] = { + {GP_BUILD_MODE_SEQUENTIAL, "SEQUENTIAL", ICON_PARTICLE_POINT, "Sequential", + "Strokes appear/disappear one after the other, but only a single one changes at a time"}, + {GP_BUILD_MODE_CONCURRENT, "CONCURRENT", ICON_PARTICLE_TIP, "Concurrent", + "Multiple strokes appear/disappear at once"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem prop_gpencil_build_transition_items[] = { + {GP_BUILD_TRANSITION_GROW, "GROW", 0, "Grow", + "Show points in the order they occur in each stroke " + "(e.g. for animating lines being drawn)"}, + {GP_BUILD_TRANSITION_SHRINK, "SHRINK", 0, "Shrink", + "Hide points from the end of each stroke to the start " + "(e.g. for animating lines being erased)"}, + {GP_BUILD_TRANSITION_FADE, "FADE", 0, "Fade", + "Hide points in the order they occur in each stroke " + "(e.g. for animating ink fading or vanishing after getting drawn)"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem prop_gpencil_build_time_align_items[] = { + {GP_BUILD_TIMEALIGN_START, "START", 0, "Align Start", + "All strokes start at same time (i.e. short strokes finish earlier)"}, + {GP_BUILD_TIMEALIGN_END, "END", 0, "Align End", + "All strokes end at same time (i.e. short strokes start later)"}, + {0, NULL, 0, NULL, NULL} + }; + + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "BuildGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Build Modifier", "Animate strokes appearing and disappearing"); + RNA_def_struct_sdna(srna, "BuildGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_BUILD); + + /* Mode */ + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_gpencil_build_mode_items); + RNA_def_property_ui_text(prop, "Mode", "How many strokes are being animated at a time"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + /* Direction */ + prop = RNA_def_property(srna, "transition", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_gpencil_build_transition_items); + RNA_def_property_ui_text(prop, "Transition", "How are strokes animated (i.e. are they appearing or disappearing)"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + + /* Transition Onset Delay + Length */ + prop = RNA_def_property(srna, "start_delay", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "start_delay"); + RNA_def_property_ui_text(prop, "Start Delay", "Number of frames after each GP keyframe before the modifier has any effect"); + RNA_def_property_range(prop, 0, MAXFRAMEF); + RNA_def_property_ui_range(prop, 0, 200, 1, -1); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "length"); + RNA_def_property_ui_text(prop, "Length", + "Maximum number of frames that the build effect can run for " + "(unless another GP keyframe occurs before this time has elapsed)"); + RNA_def_property_range(prop, 1, MAXFRAMEF); + RNA_def_property_ui_range(prop, 1, 1000, 1, -1); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + + /* Concurrent Mode Settings */ + prop = RNA_def_property(srna, "concurrent_time_alignment", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "time_alignment"); + RNA_def_property_enum_items(prop, prop_gpencil_build_time_align_items); + RNA_def_property_ui_text(prop, "Time Alignment", "When should strokes start to appear/disappear"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + + + /* Time Limits */ + prop = RNA_def_property(srna, "use_restrict_frame_range", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BUILD_RESTRICT_TIME); + RNA_def_property_ui_text(prop, "Restrict Frame Range", "Only modify strokes during the specified frame range"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "start_frame"); + RNA_def_property_ui_text(prop, "Start Frame", "Start Frame (when Restrict Frame Range is enabled)"); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "end_frame"); + RNA_def_property_ui_text(prop, "End Frame", "End Frame (when Restrict Frame Range is enabled)"); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + + /* Filters - Layer */ + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BUILD_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BUILD_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencillattice(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LatticeGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Lattice Modifier", "Change stroke using lattice to deform modifier"); + RNA_def_struct_sdna(srna, "LatticeGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_LATTICE); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LatticeGpencilModifier_vgname_set"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LATTICE_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LATTICE_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LATTICE_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Inverse VertexGroup", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LATTICE_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Lattice object to deform with"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_LatticeGpencilModifier_object_set", NULL, "rna_Lattice_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_range(prop, 0, 1, 10, 2); + RNA_def_property_ui_text(prop, "Strength", "Strength of modifier effect"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilmirror(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "MirrorGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Mirror Modifier", "Change stroke using lattice to deform modifier"); + RNA_def_struct_sdna(srna, "MirrorGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_MIRROR); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_MIRROR_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_MIRROR_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_MIRROR_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Object used as center"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_MirrorGpencilModifier_object_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "clip", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_MIRROR_CLIPPING); + RNA_def_property_ui_text(prop, "Clip", "Clip points"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "x_axis", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_MIRROR_AXIS_X); + RNA_def_property_ui_text(prop, "X", "Mirror this axis"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "y_axis", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_MIRROR_AXIS_Y); + RNA_def_property_ui_text(prop, "Y", "Mirror this axis"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "z_axis", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_MIRROR_AXIS_Z); + RNA_def_property_ui_text(prop, "Z", "Mirror this axis"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilhook(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "HookGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Hook Modifier", "Hook modifier to modify the location of stroke points"); + RNA_def_struct_sdna(srna, "HookGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_HOOK); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Parent Object for hook, also recalculates and clears offset"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_pointer_funcs(prop, NULL, "rna_HookGpencilModifier_object_set", NULL, NULL); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "subtarget"); + RNA_def_property_ui_text(prop, "Sub-Target", + "Name of Parent Bone for hook (if applicable), also recalculates and clears offset"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_HookGpencilModifier_vgname_set"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_HOOK_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_HOOK_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_HOOK_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Inverse VertexGroup", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_HOOK_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "force"); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_text(prop, "Strength", "Relative force of the hook"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, modifier_gphook_falloff_items); /* share the enum */ + RNA_def_property_ui_text(prop, "Falloff Type", ""); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "falloff"); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_range(prop, 0, 100, 100, 2); + RNA_def_property_ui_text(prop, "Radius", "If not zero, the distance from the hook where influence ends"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "curfalloff"); + RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "center", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "cent"); + RNA_def_property_ui_text(prop, "Hook Center", ""); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "matrix_inverse", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_float_sdna(prop, NULL, "parentinv"); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Matrix", "Reverse the transformation between this object and its target"); + RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_falloff_uniform", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_HOOK_UNIFORM_SPACE); + RNA_def_property_ui_text(prop, "Uniform Falloff", "Compensate for non-uniform object scale"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + +static void rna_def_modifier_gpencilarmature(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ArmatureGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Armature Modifier", "Change stroke using armature to deform modifier"); + RNA_def_struct_sdna(srna, "ArmatureGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_ARMATURE); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Armature object to deform with"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArmatureGpencilModifier_object_set", NULL, "rna_Armature_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE); + RNA_def_property_ui_text(prop, "Use Bone Envelopes", "Bind Bone envelopes to armature modifier"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "use_vertex_groups", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP); + RNA_def_property_ui_text(prop, "Use Vertex Groups", "Bind vertex groups to armature modifier"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION); + RNA_def_property_ui_text(prop, "Preserve Volume", "Deform rotation interpolation with quaternions"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + +#if 0 /* GPXX keep disabled now */ + prop = RNA_def_property(srna, "use_multi_modifier", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "multi", 0); + RNA_def_property_ui_text(prop, "Multi Modifier", + "Use same input as previous modifier, and mix results using overall vgroup"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); +#endif + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_ui_text(prop, "Vertex Group", + "Name of Vertex Group which determines influence of modifier per point"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ArmatureGpencilModifier_vgname_set"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); +} + +void RNA_def_greasepencil_modifier(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + /* data */ + srna = RNA_def_struct(brna, "GpencilModifier", NULL); + RNA_def_struct_ui_text(srna, "GpencilModifier", "Modifier affecting the grease pencil object"); + RNA_def_struct_refine_func(srna, "rna_GpencilModifier_refine"); + RNA_def_struct_path_func(srna, "rna_GpencilModifier_path"); + RNA_def_struct_sdna(srna, "GpencilModifierData"); + + /* strings */ + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GpencilModifier_name_set"); + RNA_def_property_ui_text(prop, "Name", "Modifier name"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER | NA_RENAME, NULL); + RNA_def_struct_name_property(srna, prop); + + /* enums */ + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, rna_enum_object_greasepencil_modifier_type_items); + RNA_def_property_ui_text(prop, "Type", ""); + + /* flags */ + prop = RNA_def_property(srna, "show_viewport", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", eGpencilModifierMode_Realtime); + RNA_def_property_ui_text(prop, "Realtime", "Display modifier in viewport"); + RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_ON, 1); + + prop = RNA_def_property(srna, "show_render", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", eGpencilModifierMode_Render); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_ui_text(prop, "Render", "Use modifier during render"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_ON, 1); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL); + + prop = RNA_def_property(srna, "show_in_editmode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", eGpencilModifierMode_Editmode); + RNA_def_property_ui_text(prop, "Edit Mode", "Display modifier in Edit mode"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0); + + prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", eGpencilModifierMode_Expanded); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface"); + RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); + + /* types */ + rna_def_modifier_gpencilnoise(brna); + rna_def_modifier_gpencilsmooth(brna); + rna_def_modifier_gpencilsubdiv(brna); + rna_def_modifier_gpencilsimplify(brna); + rna_def_modifier_gpencilthick(brna); + rna_def_modifier_gpenciloffset(brna); + rna_def_modifier_gpenciltint(brna); + rna_def_modifier_gpenciltime(brna); + rna_def_modifier_gpencilcolor(brna); + rna_def_modifier_gpencilinstance(brna); + rna_def_modifier_gpencilbuild(brna); + rna_def_modifier_gpencilopacity(brna); + rna_def_modifier_gpencillattice(brna); + rna_def_modifier_gpencilmirror(brna); + rna_def_modifier_gpencilhook(brna); + rna_def_modifier_gpencilarmature(brna); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c deleted file mode 100644 index 87e35ca4102..00000000000 --- a/source/blender/makesrna/intern/rna_group.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Campbell Barton - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/makesrna/intern/rna_group.c - * \ingroup RNA - */ - -#include <stdlib.h> - -#include "DNA_group_types.h" - -#include "BLI_utildefines.h" - -#include "RNA_define.h" - -#include "rna_internal.h" - -#include "WM_types.h" - -#ifdef RNA_RUNTIME - -#include "DNA_scene_types.h" -#include "DNA_object_types.h" - -#include "BKE_group.h" - -#include "WM_api.h" - -static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter) -{ - ListBaseIterator *internal = &iter->internal.listbase; - - /* we are actually iterating a GroupObject list, so override get */ - return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((GroupObject *)internal->link)->ob); -} - -static void rna_Group_objects_link(Group *group, bContext *C, ReportList *reports, Object *object) -{ - if (!BKE_group_object_add(group, object, CTX_data_scene(C), NULL)) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' already in group '%s'", object->id.name + 2, group->id.name + 2); - return; - } - - WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id); -} - -static void rna_Group_objects_unlink(Group *group, bContext *C, ReportList *reports, Object *object) -{ - Main *bmain = CTX_data_main(C); - if (!BKE_group_object_unlink(bmain, group, object, CTX_data_scene(C), NULL)) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' not in group '%s'", object->id.name + 2, group->id.name + 2); - return; - } - - WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id); -} - -#else - -/* group.objects */ -static void rna_def_group_objects(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; -/* PropertyRNA *prop; */ - - FunctionRNA *func; - PropertyRNA *parm; - - RNA_def_property_srna(cprop, "GroupObjects"); - srna = RNA_def_struct(brna, "GroupObjects", NULL); - RNA_def_struct_sdna(srna, "Group"); - RNA_def_struct_ui_text(srna, "Group Objects", "Collection of group objects"); - - /* add object */ - func = RNA_def_function(srna, "link", "rna_Group_objects_link"); - RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Add this object to a group"); - /* object to add */ - parm = RNA_def_pointer(func, "object", "Object", "", "Object to add"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - - /* remove object */ - func = RNA_def_function(srna, "unlink", "rna_Group_objects_unlink"); - RNA_def_function_ui_description(func, "Remove this object to a group"); - RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); - /* object to remove */ - parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); -} - - -void RNA_def_group(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "Group", "ID"); - RNA_def_struct_ui_text(srna, "Group", "Group of Object data-blocks"); - RNA_def_struct_ui_icon(srna, ICON_GROUP); - /* this is done on save/load in readfile.c, removed if no objects are in the group */ - RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT); - - prop = RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_TRANSLATION); - RNA_def_property_float_sdna(prop, NULL, "dupli_ofs"); - RNA_def_property_ui_text(prop, "Dupli Offset", "Offset from the origin to use when instancing as DupliGroup"); - RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, RNA_TRANSLATION_PREC_DEFAULT); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); - - prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER); - RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); - RNA_def_property_array(prop, 20); - RNA_def_property_ui_text(prop, "Dupli Layers", "Layers visible when this group is instanced as a dupli"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); - - prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "gobject", NULL); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_ui_text(prop, "Objects", "A collection of this groups objects"); - RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_Group_objects_get", NULL, NULL, NULL, NULL); - - rna_def_group_objects(brna, prop); - -} - -#endif diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 018a4765cd0..d4535af52db 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -33,9 +33,10 @@ #include "BLI_math_base.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_image.h" +#include "DEG_depsgraph.h" + #include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -66,23 +67,11 @@ static const EnumPropertyItem image_source_items[] = { #include "BKE_global.h" #include "GPU_draw.h" +#include "GPU_texture.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" -static void rna_Image_animated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - Image *ima = (Image *)ptr->data; - int nr; - - if (ima->flag & IMA_TWINANIM) { - nr = ima->xrep * ima->yrep; - if (ima->twsta >= nr) ima->twsta = 1; - if (ima->twend >= nr) ima->twend = nr - 1; - if (ima->twsta > ima->twend) ima->twsta = 1; - } -} - static bool rna_Image_is_stereo_3d_get(PointerRNA *ptr) { return BKE_image_is_stereo((Image *)ptr->data); @@ -106,29 +95,8 @@ static void rna_Image_source_set(PointerRNA *ptr, int value) ima->source = value; BLI_assert(BKE_id_is_in_gobal_main(&ima->id)); BKE_image_signal(G_MAIN, ima, NULL, IMA_SIGNAL_SRC_CHANGE); - DAG_id_tag_update(&ima->id, 0); - } -} - -static void rna_Image_fields_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) -{ - Image *ima = ptr->id.data; - ImBuf *ibuf; - void *lock; - - ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); - - if (ibuf) { - short nr = 0; - - if (!(ima->flag & IMA_FIELDS) && (ibuf->flags & IB_fields)) nr = 1; - if ((ima->flag & IMA_FIELDS) && !(ibuf->flags & IB_fields)) nr = 1; - - if (nr) - BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE); + DEG_id_tag_update(&ima->id, 0); } - - BKE_image_release_ibuf(ima, ibuf, lock); } static void rna_Image_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) @@ -136,7 +104,7 @@ static void rna_Image_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRN Image *ima = ptr->id.data; BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD); WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id); - DAG_id_tag_update(&ima->id, 0); + DEG_id_tag_update(&ima->id, 0); } static void rna_Image_generated_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) @@ -149,7 +117,7 @@ static void rna_Image_colormanage_update(Main *bmain, Scene *UNUSED(scene), Poin { Image *ima = ptr->id.data; BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE); - DAG_id_tag_update(&ima->id, 0); + DEG_id_tag_update(&ima->id, 0); WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id); WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id); } @@ -175,11 +143,11 @@ static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA * { ImageUser *iuser = ptr->data; - BKE_image_user_frame_calc(iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(iuser, scene->r.cfra); if (ptr->id.data) { /* Update material or texture for render preview. */ - DAG_id_tag_update(ptr->id.data, 0); + DEG_id_tag_update(ptr->id.data, 0); } } @@ -311,6 +279,13 @@ static void rna_Image_resolution_set(PointerRNA *ptr, const float *values) BKE_image_release_ibuf(im, ibuf, lock); } +static int rna_Image_bindcode_get(PointerRNA *ptr) +{ + Image *ima = (Image *)ptr->data; + GPUTexture *tex = ima->gputexture[TEXTARGET_TEXTURE_2D]; + return (tex) ? GPU_texture_opengl_bindcode(tex) : 0; +} + static int rna_Image_depth_get(PointerRNA *ptr) { Image *im = (Image *)ptr->data; @@ -467,16 +442,19 @@ static PointerRNA rna_Image_packed_file_get(PointerRNA *ptr) } } -static void rna_Image_render_slots_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_RenderSlot_clear(ID *id, RenderSlot *slot, ImageUser *iuser) { - Image *image = (Image *)ptr->id.data; - rna_iterator_array_begin(iter, (void *)image->render_slots, sizeof(RenderSlot), IMA_MAX_RENDER_SLOT, 0, NULL); + Image *image = (Image *) id; + int index = BLI_findindex(&image->renderslots, slot); + BKE_image_clear_renderslot(image, iuser, index); + + WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, image); } static PointerRNA rna_render_slots_active_get(PointerRNA *ptr) { Image *image = (Image *)ptr->id.data; - RenderSlot *render_slot = &image->render_slots[image->render_slot]; + RenderSlot *render_slot = BKE_image_get_renderslot(image, image->render_slot); return rna_pointer_inherit_refine(ptr, &RNA_RenderSlot, render_slot); } @@ -485,9 +463,9 @@ static void rna_render_slots_active_set(PointerRNA *ptr, PointerRNA value) { Image *image = (Image *)ptr->id.data; if (value.id.data == image) { - RenderSlot *render_slot = (RenderSlot *)value.data; - int index = render_slot - image->render_slots; - image->render_slot = CLAMPIS(index, 0, IMA_MAX_RENDER_SLOT - 1); + RenderSlot *slot = (RenderSlot *)value.data; + int index = BLI_findindex(&image->renderslots, slot); + if (index != -1) image->render_slot = index; } } @@ -500,8 +478,17 @@ static int rna_render_slots_active_index_get(PointerRNA *ptr) static void rna_render_slots_active_index_set(PointerRNA *ptr, int value) { Image *image = (Image *)ptr->id.data; + int num_slots = BLI_listbase_count(&image->renderslots); image->render_slot = value; - CLAMP(image->render_slot, 0, IMA_MAX_RENDER_SLOT - 1); + CLAMP(image->render_slot, 0, num_slots - 1); +} + +static void rna_render_slots_active_index_range(PointerRNA *ptr, int *min, int *max, + int *UNUSED(softmin), int *UNUSED(softmax)) +{ + Image *image = (Image *)ptr->id.data; + *min = 0; + *max = max_ii(0, BLI_listbase_count(&image->renderslots) - 1); } #else @@ -554,13 +541,6 @@ static void rna_def_imageuser(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_ImageUser_update"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - prop = RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "fie_ima"); - RNA_def_property_range(prop, 1, 200); - RNA_def_property_ui_text(prop, "Fields per Frame", "Number of fields per rendered frame (2 fields is 1 image)"); - RNA_def_property_update(prop, 0, "rna_ImageUser_update"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - prop = RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "layer"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */ @@ -601,7 +581,9 @@ static void rna_def_image_packed_files(BlenderRNA *brna) static void rna_def_render_slot(BlenderRNA *brna) { StructRNA *srna; - PropertyRNA *prop; + PropertyRNA *prop, *parm; + FunctionRNA *func; + srna = RNA_def_struct(brna, "RenderSlot", NULL); RNA_def_struct_ui_text(srna, "Render Slot", "Parameters defining the render slot"); @@ -609,32 +591,45 @@ static void rna_def_render_slot(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Name", "Render slot name"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); + + func = RNA_def_function(srna, "clear", "rna_RenderSlot_clear"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Clear the render slot"); + parm = RNA_def_pointer(func, "iuser", "ImageUser", "ImageUser", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } -static void rna_def_render_slots(BlenderRNA *brna) +static void rna_def_render_slots(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; - PropertyRNA *prop; + FunctionRNA *func; + PropertyRNA *prop, *parm; + RNA_def_property_srna(cprop, "RenderSlots"); srna = RNA_def_struct(brna, "RenderSlots", NULL); - RNA_def_struct_sdna(srna, "RenderSlot"); - RNA_def_struct_ui_text(srna, "Render Slots", "Collection of the render slots"); + RNA_def_struct_sdna(srna, "Image"); + RNA_def_struct_ui_text(srna, "Render Layers", "Collection of render layers"); + + prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "render_slot"); + RNA_def_property_int_funcs(prop, "rna_render_slots_active_index_get", + "rna_render_slots_active_index_set", + "rna_render_slots_active_index_range"); + RNA_def_property_ui_text(prop, "Active", "Active render slot of the image"); + RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "RenderSlot"); RNA_def_property_pointer_funcs(prop, "rna_render_slots_active_get", "rna_render_slots_active_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active", "Active render slot of the image"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE); - RNA_def_property_int_funcs(prop, "rna_render_slots_active_index_get", - "rna_render_slots_active_index_set", - NULL); - RNA_def_property_range(prop, 0, IMA_MAX_RENDER_SLOT); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Active Index", "Index of an active render slot of the image"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); + func = RNA_def_function(srna, "new", "BKE_image_add_renderslot"); + RNA_def_function_ui_description(func, "Add a render slot to the image"); + parm = RNA_def_string(func, "name", NULL, 0, "Name", "New name for the render slot"); + parm = RNA_def_pointer(func, "result", "RenderSlot", "", "Newly created render layer"); + RNA_def_function_return(func, parm); } static void rna_def_image(BlenderRNA *brna) @@ -649,16 +644,6 @@ static void rna_def_image(BlenderRNA *brna) {IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""}, {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem prop_mapping_items[] = { - {0, "UV", 0, "UV Coordinates", "Use UV coordinates for mapping the image"}, - {IMA_REFLECT, "REFLECTION", 0, "Reflection", "Use reflection mapping for mapping the image"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem prop_field_order_items[] = { - {0, "EVEN", 0, "Upper First", "Upper field first"}, - {IMA_STD_FIELD, "ODD", 0, "Lower First", "Lower field first"}, - {0, NULL, 0, NULL, NULL} - }; static const EnumPropertyItem alpha_mode_items[] = { {IMA_ALPHA_STRAIGHT, "STRAIGHT", 0, "Straight", "Transparent RGB and alpha pixels are unmodified"}, {IMA_ALPHA_PREMUL, "PREMUL", 0, "Premultiplied", "Transparent RGB pixels are multiplied by the alpha channel"}, @@ -670,6 +655,7 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA); prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update"); @@ -708,51 +694,44 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Packed Files", "Collection of packed images"); - prop = RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, prop_field_order_items); - RNA_def_property_ui_text(prop, "Field Order", "Order of video fields (select which lines are displayed first)"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - - /* booleans */ - prop = RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS); - RNA_def_property_ui_text(prop, "Fields", "Use fields of the image"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_fields_update"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - - prop = RNA_def_property(srna, "use_view_as_render", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_VIEW_AS_RENDER); RNA_def_property_ui_text(prop, "View as Render", "Apply render part of display transformation when displaying this image on the screen"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMA_IGNORE_ALPHA); RNA_def_property_ui_text(prop, "Use Alpha", "Use the alpha channel information from the image or make image fully opaque"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_colormanage_update"); prop = RNA_def_property(srna, "use_deinterlace", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DEINTERLACE); RNA_def_property_ui_text(prop, "Deinterlace", "Deinterlace movie file on load"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update"); prop = RNA_def_property(srna, "use_multiview", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_USE_VIEWS); RNA_def_property_ui_text(prop, "Use Multi-View", "Use Multiple Views (when available)"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_views_format_update"); prop = RNA_def_property(srna, "is_stereo_3d", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_boolean_funcs(prop, "rna_Image_is_stereo_3d_get", NULL); RNA_def_property_ui_text(prop, "Stereo 3D", "Image has left and right views"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "is_multiview", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_boolean_funcs(prop, "rna_Image_is_multiview_get", NULL); RNA_def_property_ui_text(prop, "Multiple Views", "Image has more than one view"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Dirty", "Image has changed and is not saved"); @@ -794,14 +773,8 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - /* realtime properties */ - prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, prop_mapping_items); - RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_float_sdna(prop, NULL, "aspx"); RNA_def_property_array(prop, 2); RNA_def_property_range(prop, 0.1f, FLT_MAX); @@ -809,69 +782,17 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this image, does not affect rendering"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - prop = RNA_def_property(srna, "use_animation", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TWINANIM); - RNA_def_property_ui_text(prop, "Animated", "Use as animated texture in the game engine"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update"); - - prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "twsta"); - RNA_def_property_range(prop, 0, 255); - RNA_def_property_ui_text(prop, "Animation Start", "Start frame of an animated texture"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update"); - - prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "twend"); - RNA_def_property_range(prop, 0, 255); - RNA_def_property_ui_text(prop, "Animation End", "End frame of an animated texture"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update"); - - prop = RNA_def_property(srna, "fps", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "animspeed"); - RNA_def_property_range(prop, 1, 100); - RNA_def_property_ui_text(prop, "Animation Speed", "Speed of the animation in frames per second"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - - prop = RNA_def_property(srna, "use_tiles", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TILES); - RNA_def_property_ui_text(prop, "Tiles", - "Use of tilemode for faces (default shift-LMB to pick the tile for selected faces)"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - - prop = RNA_def_property(srna, "tiles_x", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "xrep"); - RNA_def_property_range(prop, 1, 16); - RNA_def_property_ui_text(prop, "Tiles X", "Degree of repetition in the X direction"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - - prop = RNA_def_property(srna, "tiles_y", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "yrep"); - RNA_def_property_range(prop, 1, 16); - RNA_def_property_ui_text(prop, "Tiles Y", "Degree of repetition in the Y direction"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - - prop = RNA_def_property(srna, "use_clamp_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_U); - RNA_def_property_ui_text(prop, "Clamp X", "Disable texture repeating horizontally"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - - prop = RNA_def_property(srna, "use_clamp_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_V); - RNA_def_property_ui_text(prop, "Clamp Y", "Disable texture repeating vertically"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - prop = RNA_def_property(srna, "bindcode", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "bindcode"); + RNA_def_property_int_funcs(prop, "rna_Image_bindcode_get", NULL, NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bindcode", "OpenGL bindcode"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); prop = RNA_def_property(srna, "render_slots", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "RenderSlot"); + RNA_def_property_collection_sdna(prop, NULL, "renderslots", NULL); RNA_def_property_ui_text(prop, "Render Slots", "Render slots of the image"); - RNA_def_property_collection_funcs(prop, "rna_Image_render_slots_begin", "rna_iterator_array_next", - "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL); - RNA_def_property_srna(prop, "RenderSlots"); + rna_def_render_slots(brna, prop); /* * Image.has_data and Image.depth are temporary, @@ -894,6 +815,7 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_float_vector(srna, "resolution", 2, NULL, 0, 0, "Resolution", "X/Y pixels per meter", 0, 0); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_float_funcs(prop, "rna_Image_resolution_get", "rna_Image_resolution_set", NULL); prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_UNSIGNED); @@ -928,12 +850,14 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings"); prop = RNA_def_property(srna, "alpha_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_enum_items(prop, alpha_mode_items); RNA_def_property_ui_text(prop, "Alpha Mode", "Representation of alpha information in the RGBA pixels"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_colormanage_update"); /* multiview */ prop = RNA_def_property(srna, "views_format", PROP_ENUM, PROP_NONE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_enum_sdna(prop, NULL, "views_format"); RNA_def_property_enum_items(prop, rna_enum_views_format_items); RNA_def_property_ui_text(prop, "Views Format", "Mode to load image views"); @@ -951,7 +875,6 @@ static void rna_def_image(BlenderRNA *brna) void RNA_def_image(BlenderRNA *brna) { rna_def_render_slot(brna); - rna_def_render_slots(brna); rna_def_image(brna); rna_def_imageuser(brna); rna_def_image_packed_files(brna); diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index dc625ca8d9a..d6b7cabc335 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -56,9 +56,6 @@ #include "IMB_imbuf.h" #include "IMB_colormanagement.h" -#include "GPU_draw.h" -#include "GPU_debug.h" - #include "DNA_image_types.h" #include "DNA_scene_types.h" @@ -225,18 +222,18 @@ static void rna_Image_scale(Image *image, ReportList *reports, int width, int he static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int filter, int mag) { - ImBuf *ibuf; - unsigned int *bind = &image->bindcode[TEXTARGET_TEXTURE_2D]; + GPUTexture *tex = image->gputexture[TEXTARGET_TEXTURE_2D]; int error = GL_NO_ERROR; - ImageUser iuser = {NULL}; - void *lock; - if (*bind) + if (tex) return error; + + ImageUser iuser = {NULL}; iuser.framenr = frame; iuser.ok = true; - ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock); + void *lock; + ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock); /* clean glError buffer */ while (glGetError() != GL_NO_ERROR) {} @@ -247,17 +244,22 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int f return (int)GL_INVALID_OPERATION; } - GPU_create_gl_tex(bind, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D, + unsigned int bindcode = 0; + GPU_create_gl_tex(&bindcode, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D, (filter != GL_NEAREST && filter != GL_LINEAR), false, image); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)filter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLint)mag); + /* TODO(merwin): validate input (dimensions, filter, mag) before calling OpenGL + * instead of trusting input & testing for error after */ error = glGetError(); if (error) { - glDeleteTextures(1, (GLuint *)bind); - image->bindcode[TEXTARGET_TEXTURE_2D] = 0; + glDeleteTextures(1, (GLuint *)&bindcode); + } + else { + image->gputexture[TEXTARGET_TEXTURE_2D] = GPU_texture_from_bindcode(GL_TEXTURE_2D, bindcode); } BKE_image_release_ibuf(image, ibuf, lock); @@ -267,12 +269,11 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int f static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame, int filter, int mag) { - unsigned int *bind = &image->bindcode[TEXTARGET_TEXTURE_2D]; int error = GL_NO_ERROR; BKE_image_tag_time(image); - if (*bind == 0) + if (image->gputexture[TEXTARGET_TEXTURE_2D] == NULL) error = rna_Image_gl_load(image, reports, frame, filter, mag); return error; diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index c3ccdc6f446..155c030587d 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -35,13 +35,19 @@ #define RNA_MAGIC ((int)~0) +struct Depsgraph; +struct FreestyleSettings; struct ID; +struct IDOverrideStatic; +struct IDOverrideStaticProperty; +struct IDOverrideStaticPropertyOperation; struct IDProperty; struct Main; struct Mesh; struct Object; struct ReportList; struct SDNA; +struct ViewLayer; /* Data structures used during define */ @@ -136,6 +142,7 @@ void RNA_def_brush(struct BlenderRNA *brna); void RNA_def_cachefile(struct BlenderRNA *brna); void RNA_def_camera(struct BlenderRNA *brna); void RNA_def_cloth(struct BlenderRNA *brna); +void RNA_def_collections(struct BlenderRNA *brna); void RNA_def_color(struct BlenderRNA *brna); void RNA_def_constraint(struct BlenderRNA *brna); void RNA_def_context(struct BlenderRNA *brna); @@ -145,12 +152,12 @@ void RNA_def_depsgraph(struct BlenderRNA *brna); void RNA_def_dynamic_paint(struct BlenderRNA *brna); void RNA_def_fluidsim(struct BlenderRNA *brna); void RNA_def_fcurve(struct BlenderRNA *brna); -void RNA_def_gameproperty(struct BlenderRNA *brna); void RNA_def_gpencil(struct BlenderRNA *brna); -void RNA_def_group(struct BlenderRNA *brna); +void RNA_def_greasepencil_modifier(struct BlenderRNA *brna); +void RNA_def_shader_fx(struct BlenderRNA *brna); void RNA_def_image(struct BlenderRNA *brna); void RNA_def_key(struct BlenderRNA *brna); -void RNA_def_lamp(struct BlenderRNA *brna); +void RNA_def_light(struct BlenderRNA *brna); void RNA_def_lattice(struct BlenderRNA *brna); void RNA_def_linestyle(struct BlenderRNA *brna); void RNA_def_main(struct BlenderRNA *brna); @@ -166,10 +173,12 @@ void RNA_def_packedfile(struct BlenderRNA *brna); void RNA_def_palette(struct BlenderRNA *brna); void RNA_def_particle(struct BlenderRNA *brna); void RNA_def_pose(struct BlenderRNA *brna); +void RNA_def_lightprobe(struct BlenderRNA *brna); void RNA_def_render(struct BlenderRNA *brna); void RNA_def_rigidbody(struct BlenderRNA *brna); void RNA_def_rna(struct BlenderRNA *brna); void RNA_def_scene(struct BlenderRNA *brna); +void RNA_def_view_layer(struct BlenderRNA *brna); void RNA_def_screen(struct BlenderRNA *brna); void RNA_def_sculpt_paint(struct BlenderRNA *brna); void RNA_def_sensor(struct BlenderRNA *brna); @@ -186,6 +195,8 @@ void RNA_def_ui(struct BlenderRNA *brna); void RNA_def_userdef(struct BlenderRNA *brna); void RNA_def_vfont(struct BlenderRNA *brna); void RNA_def_wm(struct BlenderRNA *brna); +void RNA_def_wm_gizmo(struct BlenderRNA *brna); +void RNA_def_workspace(struct BlenderRNA *brna); void RNA_def_world(struct BlenderRNA *brna); void RNA_def_movieclip(struct BlenderRNA *brna); void RNA_def_tracking(struct BlenderRNA *brna); @@ -195,6 +206,14 @@ void RNA_def_mask(struct BlenderRNA *brna); void rna_def_animdata_common(struct StructRNA *srna); +bool rna_AnimaData_override_apply( + struct Main *bmain, + struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage, + struct PropertyRNA *prop_local, struct PropertyRNA *prop_reference, struct PropertyRNA *prop_storage, + const int len_local, const int len_reference, const int len_storage, + struct PointerRNA *ptr_item_local, struct PointerRNA *ptr_item_reference, struct PointerRNA *ptr_item_storage, + struct IDOverrideStaticPropertyOperation *opop); + void rna_def_animviz_common(struct StructRNA *srna); void rna_def_motionpath_common(struct StructRNA *srna); @@ -205,7 +224,7 @@ void rna_def_mtex_common(struct BlenderRNA *brna, struct StructRNA *srna, const const char *activeset, const char *activeeditable, const char *structname, const char *structname_slots, const char *update, const char *update_index); void rna_def_texpaint_slots(struct BlenderRNA *brna, struct StructRNA *srna); -void rna_def_render_layer_common(struct StructRNA *srna, int scene); +void rna_def_view_layer_common(struct StructRNA *srna, int scene); void rna_def_actionbone_group_common(struct StructRNA *srna, int update_flag, const char *update_cb); void rna_ActionGroup_colorset_set(struct PointerRNA *ptr, int value); @@ -234,16 +253,40 @@ void rna_object_vcollayer_name_set(struct PointerRNA *ptr, const char *value, ch PointerRNA rna_object_shapekey_index_get(struct ID *id, int value); int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current); +/* ViewLayer related functions defined in rna_scene.c but required in rna_layer.c */ +void rna_def_freestyle_settings(struct BlenderRNA *brna); +struct PointerRNA rna_FreestyleLineSet_linestyle_get(struct PointerRNA *ptr); +void rna_FreestyleLineSet_linestyle_set(struct PointerRNA *ptr, struct PointerRNA value); +struct FreestyleLineSet *rna_FreestyleSettings_lineset_add( + struct ID *id, struct FreestyleSettings *config, struct Main *bmain, const char *name); +void rna_FreestyleSettings_lineset_remove( + struct ID *id, struct FreestyleSettings *config, struct ReportList *reports, struct PointerRNA *lineset_ptr); +struct PointerRNA rna_FreestyleSettings_active_lineset_get(struct PointerRNA *ptr); +void rna_FreestyleSettings_active_lineset_index_range( + struct PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax); +int rna_FreestyleSettings_active_lineset_index_get(struct PointerRNA *ptr); +void rna_FreestyleSettings_active_lineset_index_set(struct PointerRNA *ptr, int value); +struct FreestyleModuleConfig *rna_FreestyleSettings_module_add(struct ID *id, struct FreestyleSettings *config); +void rna_FreestyleSettings_module_remove( + struct ID *id, struct FreestyleSettings *config, struct ReportList *reports, struct PointerRNA *module_ptr); + +void rna_Scene_use_view_map_cache_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); +void rna_Scene_glsl_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); +void rna_Scene_freestyle_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); +void rna_ViewLayer_name_set(struct PointerRNA *ptr, const char *value); +void rna_ViewLayer_pass_update(struct Main *bmain, struct Scene *activescene, struct PointerRNA *ptr); + /* named internal so as not to conflict with obj.update() rna func */ void rna_Object_internal_update_data(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); void rna_Mesh_update_draw(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); -void rna_TextureSlot_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); +void rna_TextureSlot_update(struct bContext *C, struct PointerRNA *ptr); /* basic poll functions for object types */ bool rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value); bool rna_Camera_object_poll(struct PointerRNA *ptr, struct PointerRNA value); bool rna_Curve_object_poll(struct PointerRNA *ptr, struct PointerRNA value); -bool rna_Lamp_object_poll(struct PointerRNA *ptr, struct PointerRNA value); +bool rna_GPencil_object_poll(struct PointerRNA *ptr, struct PointerRNA value); +bool rna_Light_object_poll(struct PointerRNA *ptr, struct PointerRNA value); bool rna_Lattice_object_poll(struct PointerRNA *ptr, struct PointerRNA value); bool rna_Mesh_object_poll(struct PointerRNA *ptr, struct PointerRNA value); @@ -251,6 +294,10 @@ bool rna_Mesh_object_poll(struct PointerRNA *ptr, struct PointerRNA value); bool rna_Action_id_poll(struct PointerRNA *ptr, struct PointerRNA value); bool rna_Action_actedit_assign_poll(struct PointerRNA *ptr, struct PointerRNA value); +/* Grease Pencil datablock polling functions - for filtering GP Object vs Annotation datablocks */ +bool rna_GPencil_datablocks_annotations_poll(struct PointerRNA *ptr, const struct PointerRNA value); +bool rna_GPencil_datablocks_obdata_poll(struct PointerRNA *ptr, const struct PointerRNA value); + char *rna_TextureSlot_path(struct PointerRNA *ptr); char *rna_Node_ImageUser_path(struct PointerRNA *ptr); @@ -269,6 +316,8 @@ void RNA_api_image(struct StructRNA *srna); void RNA_api_lattice(struct StructRNA *srna); void RNA_api_operator(struct StructRNA *srna); void RNA_api_macro(struct StructRNA *srna); +void RNA_api_gizmo(struct StructRNA *srna); +void RNA_api_gizmogroup(struct StructRNA *srna); void RNA_api_keyconfig(struct StructRNA *srna); void RNA_api_keyconfigs(struct StructRNA *srna); void RNA_api_keyingset(struct StructRNA *srna); @@ -281,7 +330,7 @@ void RNA_api_material(StructRNA *srna); void RNA_api_mesh(struct StructRNA *srna); void RNA_api_meta(struct StructRNA *srna); void RNA_api_object(struct StructRNA *srna); -void RNA_api_object_base(struct StructRNA *srna); +void RNA_api_object_base_legacy(struct StructRNA *srna); void RNA_api_pose(struct StructRNA *srna); void RNA_api_pose_channel(struct StructRNA *srna); void RNA_api_scene(struct StructRNA *srna); @@ -303,6 +352,8 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop); void RNA_api_sequence_elements(BlenderRNA *brna, PropertyRNA *cprop); void RNA_api_sound(struct StructRNA *srna); void RNA_api_vfont(struct StructRNA *srna); +void RNA_api_workspace(struct StructRNA *srna); +void RNA_api_workspace_tool(struct StructRNA *srna); /* main collection functions */ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop); @@ -311,7 +362,7 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop); -void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_lights(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop); @@ -323,7 +374,7 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop); -void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_collections(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop); @@ -337,6 +388,8 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_cachefiles(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_paintcurves(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop); /* ID Properties */ @@ -358,6 +411,38 @@ extern StructRNA RNA_PropertyGroup; #endif struct IDProperty *rna_idproperty_check(struct PropertyRNA **prop, struct PointerRNA *ptr); +struct PropertyRNA *rna_ensure_property_realdata(struct PropertyRNA **prop, struct PointerRNA *ptr); + +/* Override default callbacks. */ +/* Default override callbacks for all types. */ +/* TODO: Maybe at some point we'll want to write that in direct RNA-generated code instead + * (like we do for default get/set/etc.)? + * Not obvious though, those are fairly more complicated than basic SDNA access. + */ +int rna_property_override_diff_default( + struct Main *bmain, + struct PointerRNA *ptr_a, struct PointerRNA *ptr_b, + struct PropertyRNA *prop_a, struct PropertyRNA *prop_b, + const int len_a, const int len_b, + const int mode, + struct IDOverrideStatic *override, const char *rna_path, + const int flags, bool *r_override_changed); + +bool rna_property_override_store_default( + struct Main *bmain, + struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage, + struct PropertyRNA *prop_local, struct PropertyRNA *prop_reference, struct PropertyRNA *prop_storage, + const int len_local, const int len_reference, const int len_storage, + struct IDOverrideStaticPropertyOperation *opop); + +bool rna_property_override_apply_default( + struct Main *bmain, + struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, + struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage, + const int len_dst, const int len_src, const int len_storage, + struct PointerRNA *ptr_item_dst, struct PointerRNA *ptr_item_src, struct PointerRNA *ptr_item_storage, + struct IDOverrideStaticPropertyOperation *opop); + /* Builtin Property Callbacks */ @@ -404,8 +489,8 @@ PointerRNA rna_pointer_inherit_refine(struct PointerRNA *ptr, struct StructRNA * int rna_parameter_size(struct PropertyRNA *parm); struct Mesh *rna_Main_meshes_new_from_object( - struct Main *bmain, struct ReportList *reports, struct Scene *sce, - struct Object *ob, bool apply_modifiers, int settings, bool calc_tessface, bool calc_undeformed); + struct Main *bmain, struct ReportList *reports, struct Depsgraph *depsgraph, + struct Object *ob, bool apply_modifiers, bool calc_undeformed); /* XXX, these should not need to be defined here~! */ struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct bContext *C, struct ReportList *reports); diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index f9929cec7b1..f03752968c9 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -40,20 +40,14 @@ struct PointerRNA; struct FunctionRNA; struct CollectionPropertyIterator; struct bContext; +struct IDOverrideStatic; +struct IDOverrideStaticProperty; +struct IDOverrideStaticPropertyOperation; struct IDProperty; struct GHash; struct Main; struct Scene; -#ifdef UNIT_TEST -#define RNA_MAX_ARRAY_LENGTH 64 -#else -#define RNA_MAX_ARRAY_LENGTH 32 -#endif - -#define RNA_MAX_ARRAY_DIMENSION 3 - - /* store local properties here */ #define RNA_IDP_UI "_RNA_UI" @@ -126,6 +120,58 @@ typedef void (*PropStringSetFuncEx)(struct PointerRNA *ptr, struct PropertyRNA * typedef int (*PropEnumGetFuncEx)(struct PointerRNA *ptr, struct PropertyRNA *prop); typedef void (*PropEnumSetFuncEx)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value); +/* Handling override operations, and also comparison. */ + +/** + * If \a override is NULL, merely do comparison between prop_a from ptr_a and prop_b from ptr_b, + * following comparison mode given. + * If \a override and \a rna_path are not NULL, it will add a new override operation for overridable properties + * that differ and have not yet been overridden (and set accordingly \a r_override_changed if given). + * + * \note Given PropertyRNA are final (in case of IDProps...). + * \note In non-array cases, \a len values are 0. + * \note \a override, \a rna_path and \a r_override_changed may be NULL pointers. + */ +typedef int (*RNAPropOverrideDiff)( + struct Main *bmain, + struct PointerRNA *ptr_a, struct PointerRNA *ptr_b, + struct PropertyRNA *prop_a, struct PropertyRNA *prop_b, + const int len_a, const int len_b, + const int mode, + struct IDOverrideStatic *override, const char *rna_path, + const int flags, bool *r_override_changed); + +/** + * Only used for differential override (add, sub, etc.). + * Store into storage the value needed to transform reference's value into local's value. + * + * \note Given PropertyRNA are final (in case of IDProps...). + * \note In non-array cases, \a len values are 0. + * \note Might change given override operation (e.g. change 'add' one into 'sub'), in case computed storage value + * is out of range (or even change it to basic 'set' operation if nothing else works). + */ +typedef bool (*RNAPropOverrideStore)( + struct Main *bmain, + struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, struct PointerRNA *ptr_storage, + struct PropertyRNA *prop_local, struct PropertyRNA *prop_reference, struct PropertyRNA *prop_storage, + const int len_local, const int len_reference, const int len_storage, + struct IDOverrideStaticPropertyOperation *opop); + +/** + * Apply given override operation from src to dst (using value from storage as second operand + * for differential operations). + * + * \note Given PropertyRNA are final (in case of IDProps...). + * \note In non-array cases, \a len values are 0. + */ +typedef bool (*RNAPropOverrideApply)( + struct Main *bmain, + struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, + struct PropertyRNA *prop_dst, struct PropertyRNA *prop_src, struct PropertyRNA *prop_storage, + const int len_dst, const int len_src, const int len_storage, + struct PointerRNA *ptr_item_dst, struct PointerRNA *ptr_item_src, struct PointerRNA *ptr_item_storage, + struct IDOverrideStaticPropertyOperation *opop); + /* Container - generic abstracted container of RNA properties */ typedef struct ContainerRNA { void *next, *prev; @@ -164,6 +210,8 @@ struct PropertyRNA { const char *identifier; /* various options */ int flag; + /* various override options */ + int flag_override; /* Function parameters flags. */ short flag_parameter; /* Internal ("private") flags. */ @@ -203,6 +251,11 @@ struct PropertyRNA { /* callback for testing if array-item editable (if applicable) */ ItemEditableFunc itemeditable; + /* Override handling callbacks (diff is also used for comparison). */ + RNAPropOverrideDiff override_diff; + RNAPropOverrideStore override_store; + RNAPropOverrideApply override_apply; + /* raw access */ int rawoffset; RawPropertyType rawtype; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 9a22742e7b9..a8d6246e169 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -51,10 +51,11 @@ #include "DNA_object_types.h" #include "BKE_animsys.h" -#include "BKE_depsgraph.h" #include "BKE_key.h" #include "BKE_main.h" +#include "DEG_depsgraph.h" + #include "WM_api.h" #include "WM_types.h" @@ -486,7 +487,7 @@ static void rna_Key_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *p for (ob = bmain->object.first; ob; ob = ob->id.next) { if (BKE_key_from_object(ob) == key) { - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } } @@ -712,7 +713,7 @@ static void rna_def_keyblock(BlenderRNA *brna) prop = RNA_def_property(srna, "relative_key", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ShapeKey"); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL | PROP_PTR_NO_OWNERSHIP); RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", "rna_ShapeKey_relative_key_set", NULL, NULL); RNA_def_property_ui_text(prop, "Relative Key", "Shape used as a relative key"); @@ -721,7 +722,7 @@ static void rna_def_keyblock(BlenderRNA *brna) prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYBLOCK_MUTE); RNA_def_property_ui_text(prop, "Mute", "Mute this shape key"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1); RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop = RNA_def_property(srna, "slider_min", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 1e1ae2e8183..126c5e82206 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -45,15 +45,16 @@ #include "MEM_guardedalloc.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_texture.h" +#include "DEG_depsgraph.h" + #include "ED_node.h" #include "WM_api.h" #include "WM_types.h" -static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value) +static void rna_Light_buffer_size_set(PointerRNA *ptr, int value) { Lamp *la = (Lamp *)ptr->data; @@ -62,111 +63,55 @@ static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value) la->bufsize &= (~15); /* round to multiple of 16 */ } -static PointerRNA rna_Lamp_sky_settings_get(PointerRNA *ptr) -{ - return rna_pointer_inherit_refine(ptr, &RNA_LampSkySettings, ptr->id.data); -} - -static void rna_Lamp_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - Lamp *la = (Lamp *)ptr->data; - rna_iterator_array_begin(iter, (void *)la->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL); -} - -static PointerRNA rna_Lamp_active_texture_get(PointerRNA *ptr) -{ - Lamp *la = (Lamp *)ptr->data; - Tex *tex; - - tex = give_current_lamp_texture(la); - return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex); -} - -static void rna_Lamp_active_texture_set(PointerRNA *ptr, PointerRNA value) -{ - Lamp *la = (Lamp *)ptr->data; - - set_current_lamp_texture(la, value.data); -} - -static bool rna_use_shadow_get(PointerRNA *ptr) -{ - Lamp *la = (Lamp *)ptr->data; - - if (la->type == LA_SPOT) { - return (la->mode & (LA_SHAD_BUF | LA_SHAD_RAY)) != 0; - } - else { - return (la->mode & LA_SHAD_RAY) != 0; - } -} - -static void rna_use_shadow_set(PointerRNA *ptr, bool value) -{ - Lamp *la = (Lamp *)ptr->data; - la->mode &= ~(LA_SHAD_BUF | LA_SHAD_RAY); - if (value) { - la->mode |= LA_SHAD_RAY; - } -} - -static StructRNA *rna_Lamp_refine(struct PointerRNA *ptr) +static StructRNA *rna_Light_refine(struct PointerRNA *ptr) { Lamp *la = (Lamp *)ptr->data; switch (la->type) { case LA_LOCAL: - return &RNA_PointLamp; + return &RNA_PointLight; case LA_SUN: - return &RNA_SunLamp; + return &RNA_SunLight; case LA_SPOT: - return &RNA_SpotLamp; + return &RNA_SpotLight; case LA_HEMI: - return &RNA_HemiLamp; + return &RNA_HemiLight; case LA_AREA: - return &RNA_AreaLamp; + return &RNA_AreaLight; default: - return &RNA_Lamp; + return &RNA_Light; } } -static void rna_Lamp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Light_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Lamp *la = ptr->id.data; - DAG_id_tag_update(&la->id, 0); + DEG_id_tag_update(&la->id, 0); WM_main_add_notifier(NC_LAMP | ND_LIGHTING, la); } -static void rna_Lamp_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Light_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Lamp *la = ptr->id.data; - DAG_id_tag_update(&la->id, 0); + DEG_id_tag_update(&la->id, 0); WM_main_add_notifier(NC_LAMP | ND_LIGHTING_DRAW, la); } -static void rna_Lamp_sky_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - Lamp *la = ptr->id.data; - - DAG_id_tag_update(&la->id, 0); - WM_main_add_notifier(NC_LAMP | ND_SKY, la); -} - -static void rna_Lamp_use_nodes_update(bContext *C, PointerRNA *ptr) +static void rna_Light_use_nodes_update(bContext *C, PointerRNA *ptr) { Lamp *la = (Lamp *)ptr->data; if (la->use_nodes && la->nodetree == NULL) ED_node_shader_default(C, &la->id); - rna_Lamp_update(CTX_data_main(C), CTX_data_scene(C), ptr); + rna_Light_update(CTX_data_main(C), CTX_data_scene(C), ptr); } #else -/* Don't define icons here, so they don't show up in the Lamp UI (properties Editor) - DingTo */ -const EnumPropertyItem rna_enum_lamp_type_items[] = { +/* Don't define icons here, so they don't show up in the Light UI (properties Editor) - DingTo */ +const EnumPropertyItem rna_enum_light_type_items[] = { {LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source"}, {LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source"}, {LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source"}, @@ -175,182 +120,23 @@ const EnumPropertyItem rna_enum_lamp_type_items[] = { {0, NULL, 0, NULL, NULL} }; -static void rna_def_lamp_mtex(BlenderRNA *brna) +static void rna_def_light(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + static float default_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - static const EnumPropertyItem prop_texture_coordinates_items[] = { - {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates"}, - {TEXCO_VIEW, "VIEW", 0, "View", "Use view coordinates for the texture coordinates"}, - {TEXCO_OBJECT, "OBJECT", 0, "Object", "Use linked object's coordinates for texture coordinates"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "LampTextureSlot", "TextureSlot"); - RNA_def_struct_sdna(srna, "MTex"); - RNA_def_struct_ui_text(srna, "Lamp Texture Slot", "Texture slot for textures in a Lamp data-block"); - - prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "texco"); - RNA_def_property_enum_items(prop, prop_texture_coordinates_items); - RNA_def_property_ui_text(prop, "Texture Coordinates", ""); - - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - 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 mapping with Object texture coordinates"); - - prop = RNA_def_property(srna, "use_map_color", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_COL); - RNA_def_property_ui_text(prop, "Color", "Let the texture affect the basic color of the lamp"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "use_map_shadow", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_SHAD); - RNA_def_property_ui_text(prop, "Shadow", "Let the texture affect the shadow color of the lamp"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Color Factor", "Amount texture affects color values"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "shadow_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "shadowfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Shadow Factor", "Amount texture affects shadow"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); -} - -static void rna_def_lamp_sky_settings(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_skycolorspace_items[] = { - {0, "SMPTE", 0, "SMPTE", ""}, - {1, "REC709", 0, "REC709", ""}, - {2, "CIE", 0, "CIE", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "LampSkySettings", NULL); + srna = RNA_def_struct(brna, "Light", "ID"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_nested(brna, srna, "SunLamp"); - RNA_def_struct_ui_text(srna, "Lamp Sky Settings", "Sky related settings for a sun lamp"); - - prop = RNA_def_property(srna, "sky_color_space", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "sky_colorspace"); - RNA_def_property_enum_items(prop, prop_skycolorspace_items); - RNA_def_property_ui_text(prop, "Sky Color Space", "Color space to use for internal XYZ->RGB color conversion"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "sky_blend_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "skyblendtype"); - RNA_def_property_enum_items(prop, rna_enum_ramp_blend_items); - RNA_def_property_ui_text(prop, "Sky Blend Mode", "Blend mode for combining sun sky with world sky"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - /* Number values */ - - prop = RNA_def_property(srna, "horizon_brightness", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 20.0f); - RNA_def_property_ui_text(prop, "Horizon Brightness", "Horizon brightness"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "spread", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 10.0f); - RNA_def_property_ui_text(prop, "Horizon Spread", "Horizon Spread"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "sun_brightness", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 10.0f); - RNA_def_property_ui_text(prop, "Sun Brightness", "Sun brightness"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "sun_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 10.0f); - RNA_def_property_ui_text(prop, "Sun Size", "Sun size"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "backscattered_light", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, -1.0f, 1.0f); - RNA_def_property_ui_text(prop, "Backscattered Light", "Backscattered light"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "sun_intensity", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 10.0f); - RNA_def_property_ui_text(prop, "Sun Intensity", "Sun intensity"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "atmosphere_turbidity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "atm_turbidity"); - RNA_def_property_range(prop, 1.0f, 30.0f); - RNA_def_property_ui_range(prop, 2.0f, 10.0f, 1, 2); - RNA_def_property_ui_text(prop, "Atmosphere Turbidity", "Sky turbidity"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "atmosphere_inscattering", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "atm_inscattering_factor"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Atmosphere Inscatter", "Scatter contribution factor"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "atmosphere_extinction", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "atm_extinction_factor"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Atmosphere Extinction", "Extinction scattering contribution factor"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "atmosphere_distance_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "atm_distance_factor"); - RNA_def_property_range(prop, 0.0f, 500.0f); - RNA_def_property_ui_text(prop, "Atmosphere Distance Factor", - "Multiplier to convert blender units to physical distance"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "sky_blend", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "skyblendfac"); - RNA_def_property_range(prop, 0.0f, 2.0f); - RNA_def_property_ui_text(prop, "Sky Blend", "Blend factor with sky"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "sky_exposure", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 20.0f); - RNA_def_property_ui_text(prop, "Sky Exposure", "Strength of sky shading exponential exposure correction"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - /* boolean */ - - prop = RNA_def_property(srna, "use_sky", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "sun_effect_type", LA_SUN_EFFECT_SKY); - RNA_def_property_ui_text(prop, "Sky", "Apply sun effect on sky"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); - - prop = RNA_def_property(srna, "use_atmosphere", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "sun_effect_type", LA_SUN_EFFECT_AP); - RNA_def_property_ui_text(prop, "Atmosphere", "Apply sun effect on atmosphere"); - RNA_def_property_update(prop, 0, "rna_Lamp_sky_update"); -} - -static void rna_def_lamp(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "Lamp", "ID"); - RNA_def_struct_refine_func(srna, "rna_Lamp_refine"); - RNA_def_struct_ui_text(srna, "Lamp", "Lamp data-block for lighting a scene"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_DATA); + RNA_def_struct_refine_func(srna, "rna_Light_refine"); + RNA_def_struct_ui_text(srna, "Light", "Light data-block for lighting a scene"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_DATA); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, rna_enum_lamp_type_items); - RNA_def_property_ui_text(prop, "Type", "Type of Lamp"); + RNA_def_property_enum_items(prop, rna_enum_light_type_items); + RNA_def_property_ui_text(prop, "Type", "Type of Light"); RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_LAMP); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); @@ -358,61 +144,46 @@ static void rna_def_lamp(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0, 1000, 1, 3); RNA_def_property_ui_text(prop, "Distance", "Falloff distance - the light is at half the original intensity at this point"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_default(prop, 10.0f); RNA_def_property_ui_range(prop, 0, 10, 1, 3); - RNA_def_property_ui_text(prop, "Energy", "Amount of light that the lamp emits"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_ui_text(prop, "Energy", "Amount of light emitted"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "r"); RNA_def_property_array(prop, 3); + RNA_def_property_float_array_default(prop, default_color); RNA_def_property_ui_text(prop, "Color", "Light color"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); - - prop = RNA_def_property(srna, "use_own_layer", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER); - RNA_def_property_ui_text(prop, "Layer", "Illuminate objects only on the same layers the lamp is on"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "use_negative", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_NEG); - RNA_def_property_ui_text(prop, "Negative", "Cast negative light"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); - prop = RNA_def_property(srna, "use_specular", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_SPEC); - RNA_def_property_ui_text(prop, "Specular", "Create specular highlights"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "use_diffuse", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_DIFF); - RNA_def_property_ui_text(prop, "Diffuse", "Do diffuse shading"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "spec_fac"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_range(prop, 0.0f, 9999.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2); + RNA_def_property_ui_text(prop, "Specular Factor", "Specular reflection multiplier"); + RNA_def_property_update(prop, 0, "rna_Light_update"); /* nodes */ prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); - RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based lamps"); + RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based lights"); prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); - RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the lamp"); - RNA_def_property_update(prop, 0, "rna_Lamp_use_nodes_update"); + RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the light"); + RNA_def_property_update(prop, 0, "rna_Light_use_nodes_update"); /* common */ rna_def_animdata_common(srna); - - /* textures */ - rna_def_mtex_common(brna, srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get", - "rna_Lamp_active_texture_set", NULL, "LampTextureSlot", "LampTextureSlots", - "rna_Lamp_draw_update", "rna_Lamp_draw_update"); } -static void rna_def_lamp_falloff(StructRNA *srna) +static void rna_def_light_falloff(StructRNA *srna) { PropertyRNA *prop; @@ -429,124 +200,54 @@ static void rna_def_lamp_falloff(StructRNA *srna) prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_fallofftype_items); RNA_def_property_ui_text(prop, "Falloff Type", "Intensity Decay with distance"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curfalloff"); - RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "use_sphere", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SPHERE); - RNA_def_property_ui_text(prop, "Sphere", "Set light intensity to zero beyond lamp distance"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_ui_text(prop, "Falloff Curve", "Custom light falloff curve"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "linear_attenuation", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "att1"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Linear Attenuation", "Linear distance attenuation"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "quadratic_attenuation", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "att2"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Quadratic Attenuation", "Quadratic distance attenuation"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "constant_coefficient", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "coeff_const"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Constant Coefficient", "Constant distance attenuation coefficient"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "linear_coefficient", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "coeff_lin"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Linear Coefficient", "Linear distance attenuation coefficient"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "quadratic_coefficient", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "coeff_quad"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Quadratic Coefficient", "Quadratic distance attenuation coefficient"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); } -static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area) +static void rna_def_light_shadow(StructRNA *srna, int sun) { PropertyRNA *prop; - static const EnumPropertyItem prop_shadow_items[] = { - {0, "NOSHADOW", 0, "No Shadow", ""}, - {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_spot_shadow_items[] = { - {0, "NOSHADOW", 0, "No Shadow", ""}, - {LA_SHAD_BUF, "BUFFER_SHADOW", 0, "Buffer Shadow", "Let spotlight produce shadows using shadow buffer"}, - {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_ray_sampling_method_items[] = { - {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""}, - {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_spot_ray_sampling_method_items[] = { - {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""}, - {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""}, - {LA_SAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_shadbuftype_items[] = { - {LA_SHADBUF_REGULAR, "REGULAR", 0, "Classical", "Classic shadow buffer"}, - {LA_SHADBUF_HALFWAY, "HALFWAY", 0, "Classic-Halfway", - "Regular buffer, averaging the closest and 2nd closest Z value to reducing " - "bias artifacts"}, - {LA_SHADBUF_IRREGULAR, "IRREGULAR", 0, "Irregular", - "Irregular buffer produces sharp shadow always, but it doesn't show up for raytracing"}, - {LA_SHADBUF_DEEP, "DEEP", 0, "Deep", - "Deep shadow buffer supports transparency and better filtering, at the cost of " - "more memory usage and processing time"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_shadbuffiltertype_items[] = { - {LA_SHADBUF_BOX, "BOX", 0, "Box", "Apply the Box filter to shadow buffer samples"}, - {LA_SHADBUF_TENT, "TENT", 0, "Tent", "Apply the Tent Filter to shadow buffer samples"}, - {LA_SHADBUF_GAUSS, "GAUSS", 0, "Gauss", "Apply the Gauss filter to shadow buffer samples"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_numbuffer_items[] = { - {1, "BUFFERS_1", 0, "1", "Only one buffer rendered"}, - {4, "BUFFERS_4", 0, "4", "Render 4 buffers for better AA, this quadruples memory usage"}, - {9, "BUFFERS_9", 0, "9", "Render 9 buffers for better AA, this uses nine times more memory"}, - {0, NULL, 0, NULL, NULL} - }; - - /* GE only */ - static const EnumPropertyItem prop_ge_shadowbuffer_type_items[] = { - {LA_SHADMAP_SIMPLE, "SIMPLE", 0, "Simple", "Simple shadow maps"}, - {LA_SHADMAP_VARIANCE, "VARIANCE", 0, "Variance", "Variance shadow maps"}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_use_shadow_get", "rna_use_shadow_set"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); - - prop = RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, (spot) ? prop_spot_shadow_items : prop_shadow_items); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHADOW); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "shadow_buffer_size", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "bufsize"); @@ -554,158 +255,157 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area) RNA_def_property_ui_text(prop, "Shadow Buffer Size", "Resolution of the shadow buffer, higher values give crisper shadows " "but use more memory"); - RNA_def_property_int_funcs(prop, NULL, "rna_Lamp_buffer_size_set", NULL); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "shadow_filter_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "filtertype"); - RNA_def_property_enum_items(prop, prop_shadbuffiltertype_items); - RNA_def_property_ui_text(prop, "Shadow Filter Type", "Type of shadow filter (Buffer Shadows)"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "shadow_sample_buffers", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "buffers"); - RNA_def_property_enum_items(prop, prop_numbuffer_items); - RNA_def_property_ui_text(prop, "Shadow Sample Buffers", - "Number of shadow buffers to render for better AA, this increases memory usage"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_int_funcs(prop, NULL, "rna_Light_buffer_size_set", NULL); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipsta"); + RNA_def_property_float_default(prop, 0.5f); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Clip Start", "Shadow map clip start, below which objects will not generate shadows"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipend"); + RNA_def_property_float_default(prop, 40.0f); RNA_def_property_range(prop, 0.0f, 9999.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Clip End", "Shadow map clip end, beyond which objects will not generate shadows"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bias"); - RNA_def_property_range(prop, 0.001f, 5.0f); - RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Shadow buffer sampling bias"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_range(prop, 0.001f, 9999.0f); + RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3); + RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Bias for reducing self shadowing"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_buffer_bleed_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bleedbias"); RNA_def_property_range(prop, 0.f, 1.f); RNA_def_property_ui_text(prop, "Shadow Buffer Bleed Bias", "Bias for reducing light-bleed on variance shadow maps"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); + + prop = RNA_def_property(srna, "shadow_buffer_exp", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "bleedexp"); + RNA_def_property_float_default(prop, 2.5f); + RNA_def_property_range(prop, 1.0f, 9999.0f); + RNA_def_property_ui_text(prop, "Shadow Buffer Exponent", "Bias for reducing light-bleed on exponential shadow maps"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_buffer_soft", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "soft"); + RNA_def_property_float_default(prop, 3.0f); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Shadow Buffer Soft", "Size of shadow buffer sampling area"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_buffer_samples", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "samp"); RNA_def_property_range(prop, 1, 16); RNA_def_property_ui_text(prop, "Samples", "Number of shadow buffer samples"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "shadow_buffer_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "buftype"); - RNA_def_property_enum_items(prop, prop_shadbuftype_items); - RNA_def_property_ui_text(prop, "Shadow Buffer Type", "Type of shadow buffer"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "ge_shadow_buffer_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "shadowmap_type"); - RNA_def_property_enum_items(prop, prop_ge_shadowbuffer_type_items); - RNA_def_property_ui_text(prop, "Shadow Map Type", "The shadow mapping algorithm used"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - - prop = RNA_def_property(srna, "use_auto_clip_start", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bufflag", LA_SHADBUF_AUTO_START); - RNA_def_property_ui_text(prop, "Autoclip Start", - "Automatic calculation of clipping-start, based on visible vertices"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); - - prop = RNA_def_property(srna, "use_auto_clip_end", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bufflag", LA_SHADBUF_AUTO_END); - RNA_def_property_ui_text(prop, "Autoclip End", "Automatic calculation of clipping-end, based on visible vertices"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); - - prop = RNA_def_property(srna, "compression_threshold", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "compressthresh"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Compress", "Deep shadow map compression threshold"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "shdwr"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows cast by the lamp"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "use_only_shadow", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_ONLYSHADOW); - RNA_def_property_ui_text(prop, "Only Shadow", "Cast shadows only, without illuminating objects"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "shadow_ray_sample_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "ray_samp_method"); - RNA_def_property_enum_items(prop, (area) ? prop_spot_ray_sampling_method_items : prop_ray_sampling_method_items); - RNA_def_property_ui_text(prop, "Shadow Ray Sampling Method", - "Method for generating shadow samples: Adaptive QMC is fastest, " - "Constant QMC is less noisy but slower"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, (area) ? "shadow_ray_samples_x" : "shadow_ray_samples", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "ray_samp"); - RNA_def_property_range(prop, 1, 64); - RNA_def_property_ui_text(prop, (area) ? "Shadow Ray Samples" : "Shadow Ray Samples X", - "Number of samples taken extra (samples x samples)"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - if (area) { - prop = RNA_def_property(srna, "shadow_ray_samples_y", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "ray_sampy"); - RNA_def_property_range(prop, 1, 64); - RNA_def_property_ui_text(prop, "Shadow Ray Samples Y", - "Number of samples taken extra (samples x samples)"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - } - - prop = RNA_def_property(srna, "shadow_adaptive_threshold", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "adapt_thresh"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Shadow Adaptive Threshold", "Threshold for Adaptive Sampling (Raytraced shadows)"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows cast by the light"); + RNA_def_property_update(prop, 0, "rna_Light_update"); prop = RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "area_size"); + RNA_def_property_float_default(prop, 0.25f); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows)"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_update"); + + /* Eevee */ + prop = RNA_def_property(srna, "use_contact_shadow", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHAD_CONTACT); + RNA_def_property_ui_text(prop, "Contact Shadow", "Use screen space raytracing to have correct shadowing " + "near occluder, or for small features that does not appear " + "in shadow maps"); + RNA_def_property_update(prop, 0, "rna_Light_update"); + + prop = RNA_def_property(srna, "contact_shadow_distance", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "contact_dist"); + RNA_def_property_float_default(prop, 0.2f); + RNA_def_property_range(prop, 0.0f, 9999.0f); + RNA_def_property_ui_text(prop, "Contact Shadow Distance", "World space distance in which to search for " + "screen space occluder"); + RNA_def_property_update(prop, 0, "rna_Light_update"); + + prop = RNA_def_property(srna, "contact_shadow_bias", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "contact_bias"); + RNA_def_property_float_default(prop, 0.03f); + RNA_def_property_range(prop, 0.001f, 9999.0f); + RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3); + RNA_def_property_ui_text(prop, "Contact Shadow Bias", "Bias to avoid self shadowing"); + RNA_def_property_update(prop, 0, "rna_Light_update"); + + prop = RNA_def_property(srna, "contact_shadow_soft_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "contact_spread"); + RNA_def_property_float_default(prop, 0.2f); + RNA_def_property_range(prop, 0.0f, 9999.0f); + RNA_def_property_ui_text(prop, "Contact Shadow Soft", "Control how soft the contact shadows will be"); + RNA_def_property_update(prop, 0, "rna_Light_update"); - prop = RNA_def_property(srna, "use_shadow_layer", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER_SHADOW); - RNA_def_property_ui_text(prop, "Shadow Layer", "Objects on the same layers only cast shadows"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + prop = RNA_def_property(srna, "contact_shadow_thickness", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "contact_thickness"); + RNA_def_property_float_default(prop, 0.2f); + RNA_def_property_range(prop, 0.0f, 9999.0f); + RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); + RNA_def_property_ui_text(prop, "Contact Shadow Thickness", "Pixel thickness used to detect occlusion"); + RNA_def_property_update(prop, 0, "rna_Light_update"); + + if (sun) { + prop = RNA_def_property(srna, "shadow_cascade_max_distance", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "cascade_max_dist"); + RNA_def_property_float_default(prop, 1000.0f); + RNA_def_property_range(prop, 0.0f, 9999.0f); + RNA_def_property_ui_text(prop, "Cascade Max Distance", "End distance of the cascaded shadow map (only in perspective view)"); + RNA_def_property_update(prop, 0, "rna_Light_update"); + + prop = RNA_def_property(srna, "shadow_cascade_count", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "cascade_count"); + RNA_def_property_int_default(prop, 4); + RNA_def_property_range(prop, 1, 4); + RNA_def_property_ui_text(prop, "Cascade Count", "Number of texture used by the cascaded shadow map"); + RNA_def_property_update(prop, 0, "rna_Light_update"); + + prop = RNA_def_property(srna, "shadow_cascade_exponent", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "cascade_exponent"); + RNA_def_property_float_default(prop, 0.8f); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Exponential Distribution", "Higher value increase resolution towards the viewpoint"); + RNA_def_property_update(prop, 0, "rna_Light_update"); + + prop = RNA_def_property(srna, "shadow_cascade_fade", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "cascade_fade"); + RNA_def_property_float_default(prop, 0.1f); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Cascade Fade", "How smooth is the transition between each cascade"); + RNA_def_property_update(prop, 0, "rna_Light_update"); + } } -static void rna_def_point_lamp(BlenderRNA *brna) +static void rna_def_point_light(BlenderRNA *brna) { StructRNA *srna; - srna = RNA_def_struct(brna, "PointLamp", "Lamp"); + srna = RNA_def_struct(brna, "PointLight", "Light"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_ui_text(srna, "Point Lamp", "Omnidirectional point lamp"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_POINT); + RNA_def_struct_ui_text(srna, "Point Light", "Omnidirectional point Light"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_POINT); - rna_def_lamp_falloff(srna); - rna_def_lamp_shadow(srna, 0, 0); + rna_def_light_falloff(srna); + rna_def_light_shadow(srna, 0); } -static void rna_def_area_lamp(BlenderRNA *brna) +static void rna_def_area_light(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -713,167 +413,112 @@ static void rna_def_area_lamp(BlenderRNA *brna) static const EnumPropertyItem prop_areashape_items[] = { {LA_AREA_SQUARE, "SQUARE", 0, "Square", ""}, {LA_AREA_RECT, "RECTANGLE", 0, "Rectangle", ""}, + {LA_AREA_DISK, "DISK", 0, "Disk", ""}, + {LA_AREA_ELLIPSE, "ELLIPSE", 0, "Ellipse", ""}, {0, NULL, 0, NULL, NULL} }; - srna = RNA_def_struct(brna, "AreaLamp", "Lamp"); + srna = RNA_def_struct(brna, "AreaLight", "Light"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_ui_text(srna, "Area Lamp", "Directional area lamp"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_AREA); - - rna_def_lamp_shadow(srna, 0, 1); + RNA_def_struct_ui_text(srna, "Area Light", "Directional area Light"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_AREA); - prop = RNA_def_property(srna, "use_umbra", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_UMBRA); - RNA_def_property_ui_text(prop, "Umbra", "Emphasize parts that are fully shadowed (Constant Jittered sampling)"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "use_dither", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_DITHER); - RNA_def_property_ui_text(prop, "Dither", "Use 2x2 dithering for sampling (Constant Jittered sampling)"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "use_jitter", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_JITTER); - RNA_def_property_ui_text(prop, "Jitter", "Use noise for sampling (Constant Jittered sampling)"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + rna_def_light_shadow(srna, 0); + rna_def_light_falloff(srna); prop = RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "area_shape"); RNA_def_property_enum_items(prop, prop_areashape_items); - RNA_def_property_ui_text(prop, "Shape", "Shape of the area lamp"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_ui_text(prop, "Shape", "Shape of the area Light"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "area_size"); + RNA_def_property_float_default(prop, 0.25f); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); - RNA_def_property_ui_text(prop, "Size", "Size of the area of the area Lamp, X direction size for Rectangle shapes"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_ui_text(prop, "Size", "Size of the area of the area light, X direction size for rectangle shapes"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_float_sdna(prop, NULL, "area_sizey"); + RNA_def_property_float_default(prop, 0.25f); + RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Size Y", - "Size of the area of the area Lamp in the Y direction for Rectangle shapes"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); - - prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "k"); - RNA_def_property_ui_range(prop, 0.001, 2.0, 0.1, 3); - RNA_def_property_ui_text(prop, "Gamma", "Light gamma correction value"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + "Size of the area of the area light in the Y direction for rectangle shapes"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); } -static void rna_def_spot_lamp(BlenderRNA *brna) +static void rna_def_spot_light(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "SpotLamp", "Lamp"); + srna = RNA_def_struct(brna, "SpotLight", "Light"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_ui_text(srna, "Spot Lamp", "Directional cone lamp"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_SPOT); + RNA_def_struct_ui_text(srna, "Spot Light", "Directional cone Light"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_SPOT); - rna_def_lamp_falloff(srna); - rna_def_lamp_shadow(srna, 1, 0); + rna_def_light_falloff(srna); + rna_def_light_shadow(srna, 0); prop = RNA_def_property(srna, "use_square", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SQUARE); RNA_def_property_ui_text(prop, "Square", "Cast a square spot light shape"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); - - prop = RNA_def_property(srna, "use_halo", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_HALO); - RNA_def_property_ui_text(prop, "Halo", "Render spotlight with a volumetric halo"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "halo_intensity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "haint"); - RNA_def_property_ui_range(prop, 0, 5.0, 0.1, 3); - RNA_def_property_ui_text(prop, "Halo Intensity", "Brightness of the spotlight's halo cone"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); - - prop = RNA_def_property(srna, "halo_step", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "shadhalostep"); - RNA_def_property_range(prop, 0, 12); - RNA_def_property_ui_text(prop, "Halo Step", "Volumetric halo sampling frequency"); - RNA_def_property_update(prop, 0, "rna_Lamp_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "spot_blend", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "spotblend"); + RNA_def_property_float_default(prop, 0.15f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Spot Blend", "The softness of the spotlight edge"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "spotsize"); + RNA_def_property_float_default(prop, DEG2RADF(45.0f)); RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(180.0f)); RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); prop = RNA_def_property(srna, "show_cone", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHOW_CONE); RNA_def_property_ui_text(prop, "Show Cone", "Draw transparent cone in 3D view to visualize which objects are contained in it"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_property_update(prop, 0, "rna_Light_draw_update"); } -static void rna_def_sun_lamp(BlenderRNA *brna) +static void rna_def_sun_light(BlenderRNA *brna) { StructRNA *srna; - PropertyRNA *prop; - srna = RNA_def_struct(brna, "SunLamp", "Lamp"); + srna = RNA_def_struct(brna, "SunLight", "Light"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_ui_text(srna, "Sun Lamp", "Constant direction parallel ray lamp"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_SUN); - - rna_def_lamp_shadow(srna, 0, 0); - - /* sky */ - prop = RNA_def_property(srna, "sky", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "LampSkySettings"); - RNA_def_property_pointer_funcs(prop, "rna_Lamp_sky_settings_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Sky Settings", "Sky related settings for sun lamps"); - - rna_def_lamp_sky_settings(brna); - - /* BGE Only */ - prop = RNA_def_property(srna, "shadow_frustum_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "shadow_frustum_size"); - RNA_def_property_ui_range(prop, 0.001, 100.0, 2, 1); - RNA_def_property_ui_text(prop, "Frustum Size", "Size of the frustum used for creating the shadow map"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); - - prop = RNA_def_property(srna, "show_shadow_box", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SHOW_SHADOW_BOX); - RNA_def_property_ui_text(prop, "Show Shadow Box", - "Draw a box in 3D view to visualize which objects are contained in it"); - RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); + RNA_def_struct_ui_text(srna, "Sun Light", "Constant direction parallel ray Light"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_SUN); + + rna_def_light_shadow(srna, 1); } -static void rna_def_hemi_lamp(BlenderRNA *brna) +static void rna_def_hemi_light(BlenderRNA *brna) { StructRNA *srna; - srna = RNA_def_struct(brna, "HemiLamp", "Lamp"); + srna = RNA_def_struct(brna, "HemiLight", "Light"); RNA_def_struct_sdna(srna, "Lamp"); - RNA_def_struct_ui_text(srna, "Hemi Lamp", "180 degree constant lamp"); - RNA_def_struct_ui_icon(srna, ICON_LAMP_HEMI); + RNA_def_struct_ui_text(srna, "Hemi Light", "180 degree constant Light"); + RNA_def_struct_ui_icon(srna, ICON_LIGHT_HEMI); } -void RNA_def_lamp(BlenderRNA *brna) +void RNA_def_light(BlenderRNA *brna) { - rna_def_lamp(brna); - rna_def_point_lamp(brna); - rna_def_area_lamp(brna); - rna_def_spot_lamp(brna); - rna_def_sun_lamp(brna); - rna_def_hemi_lamp(brna); - rna_def_lamp_mtex(brna); + rna_def_light(brna); + rna_def_point_light(brna); + rna_def_area_light(brna); + rna_def_spot_light(brna); + rna_def_sun_light(brna); + rna_def_hemi_light(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 782ca0d76b3..cc6a46123db 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -43,11 +43,12 @@ #include "DNA_scene_types.h" #include "BLI_string.h" -#include "BKE_depsgraph.h" #include "BKE_lattice.h" #include "BKE_main.h" #include "BKE_deform.h" +#include "DEG_depsgraph.h" + #include "WM_api.h" #include "WM_types.h" #include "ED_lattice.h" @@ -97,7 +98,7 @@ static void rna_Lattice_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), P { ID *id = ptr->id.data; - DAG_id_tag_update(id, 0); + DEG_id_tag_update(id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, id); } @@ -119,7 +120,7 @@ static void rna_Lattice_update_data_editlatt(Main *UNUSED(bmain), Scene *UNUSED( BLI_strncpy(lt_em->vgroup, lt->vgroup, sizeof(lt_em->vgroup)); } - DAG_id_tag_update(id, 0); + DEG_id_tag_update(id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, id); } diff --git a/source/blender/makesrna/intern/rna_lattice_api.c b/source/blender/makesrna/intern/rna_lattice_api.c index ee1a94f2ecb..405b7922a0a 100644 --- a/source/blender/makesrna/intern/rna_lattice_api.c +++ b/source/blender/makesrna/intern/rna_lattice_api.c @@ -45,8 +45,14 @@ static void rna_Lattice_transform(Lattice *lt, float *mat, bool shape_keys) { BKE_lattice_transform(lt, (float (*)[4])mat, shape_keys); - DAG_id_tag_update(<->id, 0); + DEG_id_tag_update(<->id, 0); } + +static void rna_Lattice_update_gpu_tag(Lattice *lt) +{ + BKE_lattice_batch_cache_dirty_tag(lt, BKE_LATTICE_BATCH_DIRTY_ALL); +} + #else void RNA_api_lattice(StructRNA *srna) @@ -59,6 +65,8 @@ void RNA_api_lattice(StructRNA *srna) parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); RNA_def_boolean(func, "shape_keys", 0, "", "Transform Shape Keys"); + + RNA_def_function(srna, "update_gpu_tag", "rna_Lattice_update_gpu_tag"); } #endif diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c new file mode 100644 index 00000000000..693d7a06a79 --- /dev/null +++ b/source/blender/makesrna/intern/rna_layer.c @@ -0,0 +1,402 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Foundation. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_layer.c + * \ingroup RNA + */ + +#include "DNA_scene_types.h" +#include "DNA_layer_types.h" +#include "DNA_view3d_types.h" + +#include "BLI_math.h" +#include "BLI_string_utils.h" + +#include "BLT_translation.h" + +#include "ED_object.h" +#include "ED_render.h" + +#include "RE_engine.h" + +#include "DRW_engine.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "RNA_define.h" + +#include "rna_internal.h" + +#ifdef RNA_RUNTIME + +#ifdef WITH_PYTHON +# include "BPY_extern.h" +#endif + +#include "DNA_collection_types.h" +#include "DNA_object_types.h" + +#include "RNA_access.h" + +#include "BKE_idprop.h" +#include "BKE_layer.h" +#include "BKE_node.h" +#include "BKE_scene.h" +#include "BKE_mesh.h" + +#include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" + +/***********************************/ + + +static PointerRNA rna_ViewLayer_active_layer_collection_get(PointerRNA *ptr) +{ + ViewLayer *view_layer = (ViewLayer *)ptr->data; + LayerCollection *lc = view_layer->active_collection; + return rna_pointer_inherit_refine(ptr, &RNA_LayerCollection, lc); +} + +static void rna_ViewLayer_active_layer_collection_set(PointerRNA *ptr, PointerRNA value) +{ + ViewLayer *view_layer = (ViewLayer *)ptr->data; + LayerCollection *lc = (LayerCollection *)value.data; + const int index = BKE_layer_collection_findindex(view_layer, lc); + if (index != -1) { + BKE_layer_collection_activate(view_layer, lc); + } +} + +static PointerRNA rna_LayerObjects_active_object_get(PointerRNA *ptr) +{ + ViewLayer *view_layer = (ViewLayer *)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_Object, view_layer->basact ? view_layer->basact->object : NULL); +} + +static void rna_LayerObjects_active_object_set(PointerRNA *ptr, PointerRNA value) +{ + ViewLayer *view_layer = (ViewLayer *)ptr->data; + if (value.data) + view_layer->basact = BKE_view_layer_base_find(view_layer, (Object *)value.data); + else + view_layer->basact = NULL; +} + +static char *rna_ViewLayer_path(PointerRNA *ptr) +{ + ViewLayer *srl = (ViewLayer *)ptr->data; + char name_esc[sizeof(srl->name) * 2]; + + BLI_strescape(name_esc, srl->name, sizeof(name_esc)); + return BLI_sprintfN("view_layers[\"%s\"]", name_esc); +} + +static IDProperty *rna_ViewLayer_idprops(PointerRNA *ptr, bool create) +{ + ViewLayer *view_layer = (ViewLayer *)ptr->data; + + if (create && !view_layer->id_properties) { + IDPropertyTemplate val = {0}; + view_layer->id_properties = IDP_New(IDP_GROUP, &val, "ViewLayer ID properties"); + } + + return view_layer->id_properties; +} + +static void rna_ViewLayer_update_render_passes(ID *id) +{ + Scene *scene = (Scene *)id; + if (scene->nodetree) + ntreeCompositUpdateRLayers(scene->nodetree); +} + +static PointerRNA rna_ViewLayer_objects_get(CollectionPropertyIterator *iter) +{ + ListBaseIterator *internal = &iter->internal.listbase; + + /* we are actually iterating a ObjectBase list */ + Base *base = (Base *)internal->link; + return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, base->object); +} + +static int rna_ViewLayer_objects_selected_skip(CollectionPropertyIterator *iter, void *UNUSED(data)) +{ + ListBaseIterator *internal = &iter->internal.listbase; + Base *base = (Base *)internal->link; + + if ((base->flag & BASE_SELECTED) != 0) { + return 0; + } + + return 1; +}; + +static PointerRNA rna_ViewLayer_depsgraph_get(PointerRNA *ptr) +{ + ID *id = ptr->id.data; + if (GS(id->name) == ID_SCE) { + Scene *scene = (Scene *)id; + ViewLayer *view_layer = (ViewLayer *)ptr->data; + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false); + return rna_pointer_inherit_refine(ptr, &RNA_Depsgraph, depsgraph); + } + return PointerRNA_NULL; +} + +static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + ViewLayer *view_layer = (ViewLayer *)ptr->data; + rna_iterator_listbase_begin(iter, &view_layer->object_bases, rna_ViewLayer_objects_selected_skip); +} + +static void rna_ViewLayer_update_tagged(ID *id_ptr, ViewLayer *view_layer, Main *bmain) +{ +#ifdef WITH_PYTHON + /* Allow drivers to be evaluated */ + BPy_BEGIN_ALLOW_THREADS; +#endif + + Scene *scene = (Scene *)id_ptr; + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); + BKE_scene_graph_update_tagged(depsgraph, bmain); + +#ifdef WITH_PYTHON + BPy_END_ALLOW_THREADS; +#endif +} + +static void rna_ObjectBase_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + Base *base = (Base *)ptr->data; + short mode = (base->flag & BASE_SELECTED) ? BA_SELECT : BA_DESELECT; + ED_object_base_select(base, mode); +} + +static void rna_LayerCollection_name_get(struct PointerRNA *ptr, char *value) +{ + ID *id = (ID *)((LayerCollection *)ptr->data)->collection; + BLI_strncpy(value, id->name + 2, sizeof(id->name) - 2); +} + +int rna_LayerCollection_name_length(PointerRNA *ptr) +{ + ID *id = (ID *)((LayerCollection *)ptr->data)->collection; + return strlen(id->name + 2); +} + +static void rna_LayerCollection_use_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + Scene *scene = (Scene *)ptr->id.data; + LayerCollection *lc = (LayerCollection *)ptr->data; + ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc); + + BKE_layer_collection_sync(scene, view_layer); + + DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE); + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL); +} + +#else + +static void rna_def_layer_collection(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LayerCollection", NULL); + RNA_def_struct_ui_text(srna, "Layer Collection", "Layer collection"); + RNA_def_struct_ui_icon(srna, ICON_GROUP); + + prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_ANIMATABLE); + RNA_def_property_struct_type(prop, "Collection"); + RNA_def_property_ui_text(prop, "Collection", "Collection this layer collection is wrapping"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "collection->id.name"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Name", "Name of this view layer (same as its collection one)"); + RNA_def_property_string_funcs(prop, "rna_LayerCollection_name_get", "rna_LayerCollection_name_length", NULL); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "layer_collections", NULL); + RNA_def_property_struct_type(prop, "LayerCollection"); + RNA_def_property_ui_text(prop, "Children", "Child layer collections"); + + prop = RNA_def_property(srna, "exclude", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_EXCLUDE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Exclude", "Exclude collection from view layer"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_use_update"); + + prop = RNA_def_property(srna, "holdout", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_HOLDOUT); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Holdout", "Mask out objects in collection from view layer"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_use_update"); + + prop = RNA_def_property(srna, "indirect_only", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_INDIRECT_ONLY); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Indirect Only", + "Objects in collection only contribute indirectly (through shadows and reflections) " + "in the view layer"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_use_update"); +} + +static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "LayerObjects"); + srna = RNA_def_struct(brna, "LayerObjects", NULL); + RNA_def_struct_sdna(srna, "ViewLayer"); + RNA_def_struct_ui_text(srna, "Layer Objects", "Collections of objects"); + + prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_funcs(prop, "rna_LayerObjects_active_object_get", + "rna_LayerObjects_active_object_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); + RNA_def_property_ui_text(prop, "Active Object", "Active object for this layer"); + /* Could call: ED_object_base_activate(C, rl->basact); + * but would be a bad level call and it seems the notifier is enough */ + RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL); + + prop = RNA_def_property(srna, "selected", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_collection_funcs(prop, "rna_LayerObjects_selected_begin", "rna_iterator_listbase_next", + "rna_iterator_listbase_end", "rna_ViewLayer_objects_get", + NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Selected Objects", "All the selected objects of this layer"); +} + +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 render layer"); + 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, "object"); + RNA_def_property_ui_text(prop, "Object", "Object this base links to"); + + prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BASE_SELECTED); + RNA_def_property_ui_text(prop, "Select", "Object base selection state"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ObjectBase_select_update"); +} + +void RNA_def_view_layer(BlenderRNA *brna) +{ + FunctionRNA *func; + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ViewLayer", NULL); + RNA_def_struct_ui_text(srna, "View Layer", "View layer"); + RNA_def_struct_ui_icon(srna, ICON_RENDER_RESULT); + RNA_def_struct_path_func(srna, "rna_ViewLayer_path"); + RNA_def_struct_idprops_func(srna, "rna_ViewLayer_idprops"); + + rna_def_view_layer_common(srna, 1); + + func = RNA_def_function(srna, "update_render_passes", "rna_ViewLayer_update_render_passes"); + RNA_def_function_ui_description(func, "Requery the enabled render passes from the render engine"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_NO_SELF); + + prop = RNA_def_property(srna, "layer_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "LayerCollection"); + RNA_def_property_pointer_sdna(prop, NULL, "layer_collections.first"); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_ui_text(prop, "Layer Collection", + "Root of collections hierarchy of this view layer," + "its 'collection' pointer property is the same as the scene's master collection"); + + prop = RNA_def_property(srna, "active_layer_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "LayerCollection"); + RNA_def_property_pointer_funcs(prop, "rna_ViewLayer_active_layer_collection_get", + "rna_ViewLayer_active_layer_collection_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_ui_text(prop, "Active Layer Collection", + "Active layer collection in this view layer's hierarchy"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL); + + prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_ViewLayer_objects_get", NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Objects", "All the objects in this layer"); + rna_def_layer_objects(brna, prop); + + /* layer options */ + prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", VIEW_LAYER_RENDER); + RNA_def_property_ui_text(prop, "Enabled", "Disable or enable the render layer"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL); + + prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", VIEW_LAYER_FREESTYLE); + RNA_def_property_ui_text(prop, "Freestyle", "Render stylized strokes in this Layer"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL); + + /* Freestyle */ + rna_def_freestyle_settings(brna); + + prop = RNA_def_property(srna, "freestyle_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "freestyle_config"); + RNA_def_property_struct_type(prop, "FreestyleSettings"); + RNA_def_property_ui_text(prop, "Freestyle Settings", ""); + + /* debug update routine */ + func = RNA_def_function(srna, "update", "rna_ViewLayer_update_tagged"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + RNA_def_function_ui_description(func, + "Update data tagged to be updated from previous access to data or operators"); + + /* Dependency Graph */ + prop = RNA_def_property(srna, "depsgraph", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Depsgraph"); + RNA_def_property_ui_text(prop, "Dependency Graph", "Dependencies in the scene data"); + RNA_def_property_pointer_funcs(prop, "rna_ViewLayer_depsgraph_get", NULL, NULL, NULL); + + /* Nested Data */ + /* *** Non-Animated *** */ + RNA_define_animate_sdna(false); + rna_def_layer_collection(brna); + rna_def_object_base(brna); + RNA_define_animate_sdna(true); + /* *** Animated *** */ +} + +#endif diff --git a/source/blender/makesrna/intern/rna_lightprobe.c b/source/blender/makesrna/intern/rna_lightprobe.c new file mode 100644 index 00000000000..85df1c5ba72 --- /dev/null +++ b/source/blender/makesrna/intern/rna_lightprobe.c @@ -0,0 +1,231 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Foundation. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_lightprobe.c + * \ingroup RNA + */ + +#include <stdlib.h> + +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "rna_internal.h" + +#include "DNA_lightprobe_types.h" + +#include "WM_types.h" + +#ifdef RNA_RUNTIME + +#include "MEM_guardedalloc.h" + +#include "BKE_main.h" +#include "DEG_depsgraph.h" + +#include "DNA_collection_types.h" +#include "DNA_object_types.h" + +#include "WM_api.h" + +static void rna_LightProbe_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); +} + +#else + +static EnumPropertyItem parallax_type_items[] = { + {LIGHTPROBE_SHAPE_ELIPSOID, "ELIPSOID", ICON_NONE, "Sphere", ""}, + {LIGHTPROBE_SHAPE_BOX, "BOX", ICON_NONE, "Box", ""}, + {0, NULL, 0, NULL, NULL} +}; + +static EnumPropertyItem lightprobe_type_items[] = { + {LIGHTPROBE_TYPE_CUBE, "CUBEMAP", ICON_LIGHTPROBE_CUBEMAP, "Reflection Cubemap", "Capture reflections"}, + {LIGHTPROBE_TYPE_PLANAR, "PLANAR", ICON_LIGHTPROBE_PLANAR, "Reflection Plane", ""}, + {LIGHTPROBE_TYPE_GRID, "GRID", ICON_LIGHTPROBE_GRID, "Irradiance Volume", "Volume used for precomputing indirect lighting"}, + {0, NULL, 0, NULL, NULL} +}; + +static void rna_def_lightprobe(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LightProbe", "ID"); + RNA_def_struct_ui_text(srna, "LightProbe", "Light Probe data-block for lighting capture objects"); + RNA_def_struct_ui_icon(srna, ICON_LIGHTPROBE_CUBEMAP); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, lightprobe_type_items); + RNA_def_property_ui_text(prop, "Type", "Type of light probe"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "clipsta"); + RNA_def_property_float_default(prop, 0.8f); + RNA_def_property_range(prop, 1e-6f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3); + RNA_def_property_ui_text(prop, "Clip Start", + "Probe clip start, below which objects will not appear in reflections"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); + + prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "clipend"); + RNA_def_property_float_default(prop, 40.0f); + RNA_def_property_range(prop, 1e-6f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3); + RNA_def_property_ui_text(prop, "Clip End", + "Probe clip end, beyond which objects will not appear in reflections"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); + + prop = RNA_def_property(srna, "show_clip", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LIGHTPROBE_FLAG_SHOW_CLIP_DIST); + RNA_def_property_ui_text(prop, "Clipping", "Show the clipping distances in the 3D view"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "influence_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "attenuation_type"); + RNA_def_property_enum_items(prop, parallax_type_items); + RNA_def_property_ui_text(prop, "Type", "Type of influence volume"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "show_influence", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LIGHTPROBE_FLAG_SHOW_INFLUENCE); + RNA_def_property_ui_text(prop, "Influence", "Show the influence volume in the 3D view"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "influence_distance", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "distinf"); + RNA_def_property_float_default(prop, 2.5f); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_text(prop, "Influence Distance", "Influence distance of the probe"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.2f); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Falloff", "Control how fast the probe influence decreases"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "use_custom_parallax", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LIGHTPROBE_FLAG_CUSTOM_PARALLAX); + RNA_def_property_ui_text(prop, "Use Custom Parallax", "Enable custom settings for the parallax correction volume"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "show_parallax", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LIGHTPROBE_FLAG_SHOW_PARALLAX); + RNA_def_property_ui_text(prop, "Parallax", "Show the parallax correction volume in the 3D view"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "parallax_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, parallax_type_items); + RNA_def_property_ui_text(prop, "Type", "Type of parallax volume"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "parallax_distance", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "distpar"); + RNA_def_property_float_default(prop, 2.5f); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_text(prop, "Parallax Radius", "Lowest corner of the parallax bounding box"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + /* irradiance grid */ + prop = RNA_def_property(srna, "grid_resolution_x", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 1, 256); + RNA_def_property_int_default(prop, 4); + RNA_def_property_ui_text(prop, "Resolution X", "Number of sample along the x axis of the volume"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); + + prop = RNA_def_property(srna, "grid_resolution_y", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 1, 256); + RNA_def_property_int_default(prop, 4); + RNA_def_property_ui_text(prop, "Resolution Y", "Number of sample along the y axis of the volume"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); + + prop = RNA_def_property(srna, "grid_resolution_z", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 1, 256); + RNA_def_property_int_default(prop, 4); + RNA_def_property_ui_text(prop, "Resolution Z", "Number of sample along the z axis of the volume"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); + + prop = RNA_def_property(srna, "visibility_buffer_bias", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vis_bias"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_range(prop, 0.001f, 9999.0f); + RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3); + RNA_def_property_ui_text(prop, "Visibility Bias", "Bias for reducing self shadowing"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "visibility_bleed_bias", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vis_bleedbias"); + RNA_def_property_float_default(prop, 0.0f); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Visibility Bleed Bias", "Bias for reducing light-bleed on variance shadow maps"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "visibility_blur", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vis_blur"); + RNA_def_property_float_default(prop, 0.2f); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Visibility Blur", "Filter size of the visibilty blur"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); + + prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "intensity"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 3.0f, 1.0, 3); + RNA_def_property_ui_text(prop, "Intensity", "Modify the intensity of the lighting captured by this probe"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); + + prop = RNA_def_property(srna, "visibility_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Collection"); + RNA_def_property_pointer_sdna(prop, NULL, "visibility_grp"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Visibility Collection", "Restrict objects visible for this probe"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); + + prop = RNA_def_property(srna, "invert_visibility_collection", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LIGHTPROBE_FLAG_INVERT_GROUP); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Invert Collection", "Invert visibility collection"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc"); + + /* Data preview */ + prop = RNA_def_property(srna, "show_data", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LIGHTPROBE_FLAG_SHOW_DATA); + RNA_def_property_ui_text(prop, "Show Data", "Show captured lighting data into the 3D view for debugging purpose"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + /* common */ + rna_def_animdata_common(srna); +} + + +void RNA_def_lightprobe(BlenderRNA *brna) +{ + rna_def_lightprobe(brna); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c index b50102079a9..5cee2fb90cb 100644 --- a/source/blender/makesrna/intern/rna_linestyle.c +++ b/source/blender/makesrna/intern/rna_linestyle.c @@ -101,7 +101,8 @@ const EnumPropertyItem rna_enum_linestyle_geometry_modifier_type_items[] = { #include "BKE_linestyle.h" #include "BKE_texture.h" -#include "BKE_depsgraph.h" + +#include "DEG_depsgraph.h" #include "ED_node.h" @@ -323,7 +324,7 @@ static void rna_LineStyle_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin { FreestyleLineStyle *linestyle = ptr->id.data; - DAG_id_tag_update(&linestyle->id, 0); + DEG_id_tag_update(&linestyle->id, 0); WM_main_add_notifier(NC_LINESTYLE, linestyle); } @@ -347,7 +348,7 @@ static LineStyleModifier *rna_LineStyle_color_modifier_add(FreestyleLineStyle *l return NULL; } - DAG_id_tag_update(&linestyle->id, 0); + DEG_id_tag_update(&linestyle->id, 0); WM_main_add_notifier(NC_LINESTYLE, linestyle); return modifier; @@ -365,7 +366,7 @@ static void rna_LineStyle_color_modifier_remove(FreestyleLineStyle *linestyle, R RNA_POINTER_INVALIDATE(modifier_ptr); - DAG_id_tag_update(&linestyle->id, 0); + DEG_id_tag_update(&linestyle->id, 0); WM_main_add_notifier(NC_LINESTYLE, linestyle); } @@ -379,7 +380,7 @@ static LineStyleModifier *rna_LineStyle_alpha_modifier_add(FreestyleLineStyle *l return NULL; } - DAG_id_tag_update(&linestyle->id, 0); + DEG_id_tag_update(&linestyle->id, 0); WM_main_add_notifier(NC_LINESTYLE, linestyle); return modifier; @@ -397,7 +398,7 @@ static void rna_LineStyle_alpha_modifier_remove(FreestyleLineStyle *linestyle, R RNA_POINTER_INVALIDATE(modifier_ptr); - DAG_id_tag_update(&linestyle->id, 0); + DEG_id_tag_update(&linestyle->id, 0); WM_main_add_notifier(NC_LINESTYLE, linestyle); } @@ -411,7 +412,7 @@ static LineStyleModifier *rna_LineStyle_thickness_modifier_add(FreestyleLineStyl return NULL; } - DAG_id_tag_update(&linestyle->id, 0); + DEG_id_tag_update(&linestyle->id, 0); WM_main_add_notifier(NC_LINESTYLE, linestyle); return modifier; @@ -429,7 +430,7 @@ static void rna_LineStyle_thickness_modifier_remove(FreestyleLineStyle *linestyl RNA_POINTER_INVALIDATE(modifier_ptr); - DAG_id_tag_update(&linestyle->id, 0); + DEG_id_tag_update(&linestyle->id, 0); WM_main_add_notifier(NC_LINESTYLE, linestyle); } @@ -443,7 +444,7 @@ static LineStyleModifier *rna_LineStyle_geometry_modifier_add(FreestyleLineStyle return NULL; } - DAG_id_tag_update(&linestyle->id, 0); + DEG_id_tag_update(&linestyle->id, 0); WM_main_add_notifier(NC_LINESTYLE, linestyle); return modifier; @@ -461,7 +462,7 @@ static void rna_LineStyle_geometry_modifier_remove(FreestyleLineStyle *linestyle RNA_POINTER_INVALIDATE(modifier_ptr); - DAG_id_tag_update(&linestyle->id, 0); + DEG_id_tag_update(&linestyle->id, 0); WM_main_add_notifier(NC_LINESTYLE, linestyle); } diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 5d7088c952b..4f145d1f48d 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -31,6 +31,7 @@ #include "BLI_path_util.h" #include "RNA_define.h" +#include "RNA_access.h" #include "rna_internal.h" @@ -107,7 +108,7 @@ static void rna_Main_object_begin(CollectionPropertyIterator *iter, PointerRNA * rna_iterator_listbase_begin(iter, &bmain->object, NULL); } -static void rna_Main_lamp_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Main_light_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Main *bmain = (Main *)ptr->data; rna_iterator_listbase_begin(iter, &bmain->lamp, NULL); @@ -209,10 +210,10 @@ static void rna_Main_sound_begin(CollectionPropertyIterator *iter, PointerRNA *p rna_iterator_listbase_begin(iter, &bmain->sound, NULL); } -static void rna_Main_group_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Main_collection_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Main *bmain = (Main *)ptr->data; - rna_iterator_listbase_begin(iter, &bmain->group, NULL); + rna_iterator_listbase_begin(iter, &bmain->collection, NULL); } static void rna_Main_armature_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) @@ -293,6 +294,251 @@ static void rna_Main_paintcurves_begin(CollectionPropertyIterator *iter, Pointer rna_iterator_listbase_begin(iter, &bmain->paintcurves, NULL); } +static void rna_Main_workspaces_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Main *bmain = (Main *)ptr->data; + rna_iterator_listbase_begin(iter, &bmain->workspaces, NULL); +} + +static void rna_Main_lightprobes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Main *bmain = (Main *)ptr->data; + rna_iterator_listbase_begin(iter, &bmain->lightprobe, NULL); +} + +static int rna_ID_lookup_string(ListBase *lb, const char *key, PointerRNA *r_ptr) +{ + ID *id; + for (id = lb->first; id != NULL; id = id->next) { + if (STREQ(id->name + 2, key)) { + break; + } + else if (strstr(key, id->name + 2) != NULL) { + char full_name_ui[MAX_ID_FULL_NAME_UI]; + BKE_id_full_name_ui_prefix_get(full_name_ui, id); + /* Second check skips the three 'UI keycode letters' prefix. */ + if (STREQ(full_name_ui, key) || STREQ(full_name_ui + 3, key)) { + break; + } + } + } + if (id != NULL) { + RNA_id_pointer_create(id, r_ptr); + return true; + } + return false; +} + +int rna_Main_camera_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->camera, key, r_ptr); +} + +int rna_Main_scene_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->scene, key, r_ptr); +} + +int rna_Main_object_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->object, key, r_ptr); +} + +int rna_Main_mat_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->mat, key, r_ptr); +} + +int rna_Main_nodetree_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->nodetree, key, r_ptr); +} + +int rna_Main_mesh_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->mesh, key, r_ptr); +} + +int rna_Main_light_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->lamp, key, r_ptr); +} + +int rna_Main_library_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->library, key, r_ptr); +} + +int rna_Main_screen_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->screen, key, r_ptr); +} + +int rna_Main_wm_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->wm, key, r_ptr); +} + +int rna_Main_image_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->image, key, r_ptr); +} + +int rna_Main_latt_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->latt, key, r_ptr); +} + +int rna_Main_curve_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->curve, key, r_ptr); +} + +int rna_Main_mball_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->mball, key, r_ptr); +} + +int rna_Main_font_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->vfont, key, r_ptr); +} + +int rna_Main_tex_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->tex, key, r_ptr); +} + +int rna_Main_brush_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->brush, key, r_ptr); +} + +int rna_Main_world_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->world, key, r_ptr); +} + +int rna_Main_collection_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->collection, key, r_ptr); +} + +int rna_Main_key_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->key, key, r_ptr); +} + +int rna_Main_text_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->text, key, r_ptr); +} + +int rna_Main_speaker_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->speaker, key, r_ptr); +} + +int rna_Main_sound_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->sound, key, r_ptr); +} + +int rna_Main_armature_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->armature, key, r_ptr); +} + +int rna_Main_action_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->action, key, r_ptr); +} + +int rna_Main_particle_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->particle, key, r_ptr); +} + +int rna_Main_palette_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->palettes, key, r_ptr); +} + +int rna_Main_gpencil_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->gpencil, key, r_ptr); +} + +int rna_Main_movieclip_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->movieclip, key, r_ptr); +} + +int rna_Main_mask_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->mask, key, r_ptr); +} + +int rna_Main_linestyle_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->linestyle, key, r_ptr); +} + +int rna_Main_cachefile_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->cachefiles, key, r_ptr); +} + +int rna_Main_paintcurve_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->paintcurves, key, r_ptr); +} + +int rna_Main_workspace_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->workspaces, key, r_ptr); +} + +int rna_Main_lightprobe_lookup_string(PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr) +{ + Main *bmain = ptr->data; + return rna_ID_lookup_string(&bmain->lightprobe, key, r_ptr); +} + static void rna_Main_version_get(PointerRNA *ptr, int *value) { Main *bmain = (Main *)ptr->data; @@ -325,6 +571,7 @@ typedef struct MainCollectionDef { const char *name; const char *description; CollectionDefFunc *func; + const char *lookup_string; } MainCollectionDef; void RNA_def_main(BlenderRNA *brna) @@ -335,39 +582,41 @@ void RNA_def_main(BlenderRNA *brna) /* plural must match idtypes in readblenentry.c */ MainCollectionDef lists[] = { - {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera data-blocks", RNA_def_main_cameras}, - {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene data-blocks", RNA_def_main_scenes}, - {"objects", "Object", "rna_Main_object_begin", "Objects", "Object data-blocks", RNA_def_main_objects}, - {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material data-blocks", RNA_def_main_materials}, - {"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group data-blocks", RNA_def_main_node_groups}, - {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh data-blocks", RNA_def_main_meshes}, - {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp data-blocks", RNA_def_main_lamps}, - {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library data-blocks", RNA_def_main_libraries}, - {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen data-blocks", RNA_def_main_screens}, - {"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager data-blocks", RNA_def_main_window_managers}, - {"images", "Image", "rna_Main_image_begin", "Images", "Image data-blocks", RNA_def_main_images}, - {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice data-blocks", RNA_def_main_lattices}, - {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve data-blocks", RNA_def_main_curves}, - {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball data-blocks", RNA_def_main_metaballs}, - {"fonts", "VectorFont", "rna_Main_font_begin", "Vector Fonts", "Vector font data-blocks", RNA_def_main_fonts}, - {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture data-blocks", RNA_def_main_textures}, - {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush data-blocks", RNA_def_main_brushes}, - {"worlds", "World", "rna_Main_world_begin", "Worlds", "World data-blocks", RNA_def_main_worlds}, - {"groups", "Group", "rna_Main_group_begin", "Groups", "Group data-blocks", RNA_def_main_groups}, - {"shape_keys", "Key", "rna_Main_key_begin", "Shape Keys", "Shape Key data-blocks", NULL}, - {"texts", "Text", "rna_Main_text_begin", "Texts", "Text data-blocks", RNA_def_main_texts}, - {"speakers", "Speaker", "rna_Main_speaker_begin", "Speakers", "Speaker data-blocks", RNA_def_main_speakers}, - {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound data-blocks", RNA_def_main_sounds}, - {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature data-blocks", RNA_def_main_armatures}, - {"actions", "Action", "rna_Main_action_begin", "Actions", "Action data-blocks", RNA_def_main_actions}, - {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle data-blocks", RNA_def_main_particles}, - {"palettes", "Palette", "rna_Main_palettes_begin", "Palettes", "Palette data-blocks", RNA_def_main_palettes}, - {"grease_pencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil data-blocks", RNA_def_main_gpencil}, - {"movieclips", "MovieClip", "rna_Main_movieclips_begin", "Movie Clips", "Movie Clip data-blocks", RNA_def_main_movieclips}, - {"masks", "Mask", "rna_Main_masks_begin", "Masks", "Masks data-blocks", RNA_def_main_masks}, - {"linestyles", "FreestyleLineStyle", "rna_Main_linestyle_begin", "Line Styles", "Line Style data-blocks", RNA_def_main_linestyles}, - {"cache_files", "CacheFile", "rna_Main_cachefiles_begin", "Cache Files", "Cache Files data-blocks", RNA_def_main_cachefiles}, - {"paint_curves", "PaintCurve", "rna_Main_paintcurves_begin", "Paint Curves", "Paint Curves data-blocks", RNA_def_main_paintcurves}, + {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera data-blocks", RNA_def_main_cameras, "rna_Main_camera_lookup_string"}, + {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene data-blocks", RNA_def_main_scenes, "rna_Main_scene_lookup_string"}, + {"objects", "Object", "rna_Main_object_begin", "Objects", "Object data-blocks", RNA_def_main_objects, "rna_Main_object_lookup_string"}, + {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material data-blocks", RNA_def_main_materials, "rna_Main_mat_lookup_string"}, + {"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group data-blocks", RNA_def_main_node_groups, "rna_Main_nodetree_lookup_string"}, + {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh data-blocks", RNA_def_main_meshes, "rna_Main_mesh_lookup_string"}, + {"lights", "Light", "rna_Main_light_begin", "Lights", "Light data-blocks", RNA_def_main_lights, "rna_Main_light_lookup_string"}, + {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library data-blocks", RNA_def_main_libraries, "rna_Main_library_lookup_string"}, + {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen data-blocks", RNA_def_main_screens, "rna_Main_screen_lookup_string"}, + {"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager data-blocks", RNA_def_main_window_managers, "rna_Main_wm_lookup_string"}, + {"images", "Image", "rna_Main_image_begin", "Images", "Image data-blocks", RNA_def_main_images, "rna_Main_image_lookup_string"}, + {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice data-blocks", RNA_def_main_lattices, "rna_Main_latt_lookup_string"}, + {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve data-blocks", RNA_def_main_curves, "rna_Main_curve_lookup_string"}, + {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball data-blocks", RNA_def_main_metaballs, "rna_Main_mball_lookup_string"}, + {"fonts", "VectorFont", "rna_Main_font_begin", "Vector Fonts", "Vector font data-blocks", RNA_def_main_fonts, "rna_Main_font_lookup_string"}, + {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture data-blocks", RNA_def_main_textures, "rna_Main_tex_lookup_string"}, + {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush data-blocks", RNA_def_main_brushes, "rna_Main_brush_lookup_string"}, + {"worlds", "World", "rna_Main_world_begin", "Worlds", "World data-blocks", RNA_def_main_worlds, "rna_Main_world_lookup_string"}, + {"collections", "Collection", "rna_Main_collection_begin", "Collections", "Collection data-blocks", RNA_def_main_collections, "rna_Main_collection_lookup_string"}, + {"shape_keys", "Key", "rna_Main_key_begin", "Shape Keys", "Shape Key data-blocks", NULL, "rna_Main_key_lookup_string"}, + {"texts", "Text", "rna_Main_text_begin", "Texts", "Text data-blocks", RNA_def_main_texts, "rna_Main_text_lookup_string"}, + {"speakers", "Speaker", "rna_Main_speaker_begin", "Speakers", "Speaker data-blocks", RNA_def_main_speakers, "rna_Main_speaker_lookup_string"}, + {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound data-blocks", RNA_def_main_sounds, "rna_Main_sound_lookup_string"}, + {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature data-blocks", RNA_def_main_armatures, "rna_Main_armature_lookup_string"}, + {"actions", "Action", "rna_Main_action_begin", "Actions", "Action data-blocks", RNA_def_main_actions, "rna_Main_action_lookup_string"}, + {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle data-blocks", RNA_def_main_particles, "rna_Main_particle_lookup_string"}, + {"palettes", "Palette", "rna_Main_palettes_begin", "Palettes", "Palette data-blocks", RNA_def_main_palettes, "rna_Main_palette_lookup_string"}, + {"grease_pencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil data-blocks", RNA_def_main_gpencil, "rna_Main_gpencil_lookup_string"}, + {"movieclips", "MovieClip", "rna_Main_movieclips_begin", "Movie Clips", "Movie Clip data-blocks", RNA_def_main_movieclips, "rna_Main_movieclip_lookup_string"}, + {"masks", "Mask", "rna_Main_masks_begin", "Masks", "Masks data-blocks", RNA_def_main_masks, "rna_Main_mask_lookup_string"}, + {"linestyles", "FreestyleLineStyle", "rna_Main_linestyle_begin", "Line Styles", "Line Style data-blocks", RNA_def_main_linestyles, "rna_Main_linestyle_lookup_string"}, + {"cache_files", "CacheFile", "rna_Main_cachefiles_begin", "Cache Files", "Cache Files data-blocks", RNA_def_main_cachefiles, "rna_Main_cachefile_lookup_string"}, + {"paint_curves", "PaintCurve", "rna_Main_paintcurves_begin", "Paint Curves", "Paint Curves data-blocks", RNA_def_main_paintcurves, "rna_Main_paintcurve_lookup_string"}, + {"workspaces", "WorkSpace", "rna_Main_workspaces_begin", "Workspaces", "Workspace data-blocks", RNA_def_main_workspaces, "rna_Main_workspace_lookup_string"}, + {"lightprobes", "LightProbe", "rna_Main_lightprobes_begin", "LightProbes", "LightProbe data-blocks", RNA_def_main_lightprobes, "rna_Main_lightprobe_lookup_string"}, {NULL, NULL, NULL, NULL, NULL, NULL} }; @@ -409,7 +658,7 @@ void RNA_def_main(BlenderRNA *brna) RNA_def_property_struct_type(prop, lists[i].type); RNA_def_property_collection_funcs(prop, lists[i].iter_begin, "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", - NULL, NULL, NULL, NULL); + NULL, NULL, lists[i].lookup_string, NULL); RNA_def_property_ui_text(prop, lists[i].name, lists[i].description); /* collection functions */ diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index f2249eb397d..c6094dc2dc3 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -49,41 +49,42 @@ #ifdef RNA_RUNTIME -#include "BKE_main.h" +#include "BKE_action.h" +#include "BKE_armature.h" +#include "BKE_brush.h" #include "BKE_camera.h" +#include "BKE_collection.h" #include "BKE_curve.h" -#include "BKE_DerivedMesh.h" #include "BKE_displist.h" -#include "BKE_mesh.h" -#include "BKE_armature.h" -#include "BKE_lamp.h" -#include "BKE_library.h" -#include "BKE_library_remap.h" -#include "BKE_object.h" -#include "BKE_material.h" +#include "BKE_font.h" +#include "BKE_gpencil.h" #include "BKE_icons.h" #include "BKE_idcode.h" #include "BKE_image.h" -#include "BKE_texture.h" -#include "BKE_scene.h" -#include "BKE_sound.h" -#include "BKE_text.h" -#include "BKE_action.h" -#include "BKE_group.h" -#include "BKE_brush.h" +#include "BKE_lamp.h" #include "BKE_lattice.h" +#include "BKE_library_remap.h" +#include "BKE_lightprobe.h" +#include "BKE_linestyle.h" +#include "BKE_mask.h" +#include "BKE_material.h" #include "BKE_mball.h" -#include "BKE_world.h" -#include "BKE_particle.h" -#include "BKE_paint.h" -#include "BKE_font.h" +#include "BKE_mesh.h" +#include "BKE_movieclip.h" #include "BKE_node.h" -#include "BKE_depsgraph.h" +#include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_particle.h" +#include "BKE_scene.h" +#include "BKE_sound.h" #include "BKE_speaker.h" -#include "BKE_movieclip.h" -#include "BKE_mask.h" -#include "BKE_gpencil.h" -#include "BKE_linestyle.h" +#include "BKE_text.h" +#include "BKE_texture.h" +#include "BKE_workspace.h" +#include "BKE_world.h" + +#include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -93,9 +94,10 @@ #include "DNA_mesh_types.h" #include "DNA_speaker_types.h" #include "DNA_sound_types.h" +#include "DNA_lightprobe_types.h" #include "DNA_text_types.h" #include "DNA_texture_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_brush_types.h" #include "DNA_lattice_types.h" #include "DNA_meta_types.h" @@ -115,6 +117,8 @@ # include "BPY_extern.h" #endif +#include "WM_api.h" + static void rna_idname_validate(const char *name, char *r_name) { @@ -171,14 +175,15 @@ static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports (scene_new = scene->id.next)) { if (do_unlink) { - bScreen *sc = CTX_wm_screen(C); - if (sc->scene == scene) { + wmWindow *win = CTX_wm_window(C); + + if (WM_window_get_active_scene(win) == scene) { #ifdef WITH_PYTHON BPy_BEGIN_ALLOW_THREADS; #endif - ED_screen_set_scene(C, sc, scene_new); + WM_window_set_active_scene(bmain, C, win, scene_new); #ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; @@ -224,6 +229,9 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char case ID_LT: type = OB_LATTICE; break; + case ID_GD: + type = OB_GPENCIL; + break; case ID_AR: type = OB_ARMATURE; break; @@ -242,7 +250,6 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char } ob = BKE_object_add_only_object(bmain, type, safe_name); - id_us_min(&ob->id); ob->data = data; test_object_materials(bmain, ob, ob->data); @@ -260,6 +267,13 @@ static Material *rna_Main_materials_new(Main *bmain, const char *name) return (Material *)id; } +static void rna_Main_materials_gpencil_data(Main *UNUSED(bmain), PointerRNA *id_ptr) +{ + ID *id = id_ptr->data; + Material *ma = (Material *)id; + BKE_material_init_gpencil_settings(ma); +} + static const EnumPropertyItem *rna_Main_nodetree_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { return rna_node_tree_type_itemf(NULL, NULL, r_free); @@ -292,11 +306,12 @@ static Mesh *rna_Main_meshes_new(Main *bmain, const char *name) } /* copied from Mesh_getFromObject and adapted to RNA interface */ -/* settings: 1 - preview, 2 - render */ Mesh *rna_Main_meshes_new_from_object( - Main *bmain, ReportList *reports, Scene *sce, - Object *ob, bool apply_modifiers, int settings, bool calc_tessface, bool calc_undeformed) + Main *bmain, ReportList *reports, Depsgraph *depsgraph, + Object *ob, bool apply_modifiers, bool calc_undeformed) { + Scene *sce = DEG_get_evaluated_scene(depsgraph); + switch (ob->type) { case OB_FONT: case OB_CURVE: @@ -309,10 +324,10 @@ Mesh *rna_Main_meshes_new_from_object( return NULL; } - return BKE_mesh_new_from_object(bmain, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed); + return BKE_mesh_new_from_object(depsgraph, bmain, sce, ob, apply_modifiers, calc_undeformed); } -static Lamp *rna_Main_lamps_new(Main *bmain, const char *name, int type) +static Lamp *rna_Main_lights_new(Main *bmain, const char *name, int type) { char safe_name[MAX_ID_NAME - 2]; rna_idname_validate(name, safe_name); @@ -426,6 +441,14 @@ static Brush *rna_Main_brushes_new(Main *bmain, const char *name, int mode) return brush; } +static void rna_Main_brush_gpencil_data(Main *UNUSED(bmain), PointerRNA *id_ptr) +{ + ID *id = id_ptr->data; + Brush *brush = (Brush *)id; + BKE_brush_init_gpencil_settings(brush); +} + + static World *rna_Main_worlds_new(Main *bmain, const char *name) { char safe_name[MAX_ID_NAME - 2]; @@ -436,12 +459,12 @@ static World *rna_Main_worlds_new(Main *bmain, const char *name) return world; } -static Group *rna_Main_groups_new(Main *bmain, const char *name) +static Collection *rna_Main_collections_new(Main *bmain, const char *name) { char safe_name[MAX_ID_NAME - 2]; rna_idname_validate(name, safe_name); - return BKE_group_add(bmain, safe_name); + return BKE_collection_add(bmain, NULL, safe_name); } static Speaker *rna_Main_speakers_new(Main *bmain, const char *name) @@ -545,7 +568,7 @@ static MovieClip *rna_Main_movieclip_load(Main *bmain, ReportList *reports, cons } if (clip != NULL) { - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } else { BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath, @@ -574,14 +597,21 @@ static FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char *name return linestyle; } -/* tag and is_updated functions, all the same */ +static LightProbe *rna_Main_lightprobe_new(Main *bmain, const char *name) +{ + char safe_name[MAX_ID_NAME - 2]; + rna_idname_validate(name, safe_name); + + LightProbe *probe = BKE_lightprobe_add(bmain, safe_name); + id_us_min(&probe->id); + return probe; +} + +/* tag functions, all the same */ #define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \ static void rna_Main_##_func_name##_tag(Main *bmain, bool value) { \ BKE_main_id_tag_listbase(&bmain->_listbase_name, LIB_TAG_DOIT, value); \ } \ - static bool rna_Main_##_func_name##_is_updated_get(PointerRNA *ptr) { \ - return DAG_id_type_tagged(ptr->data, _id_type) != 0; \ - } RNA_MAIN_ID_TAG_FUNCS_DEF(cameras, camera, ID_CA) RNA_MAIN_ID_TAG_FUNCS_DEF(scenes, scene, ID_SCE) @@ -589,7 +619,7 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(objects, object, ID_OB) RNA_MAIN_ID_TAG_FUNCS_DEF(materials, mat, ID_MA) RNA_MAIN_ID_TAG_FUNCS_DEF(node_groups, nodetree, ID_NT) RNA_MAIN_ID_TAG_FUNCS_DEF(meshes, mesh, ID_ME) -RNA_MAIN_ID_TAG_FUNCS_DEF(lamps, lamp, ID_LA) +RNA_MAIN_ID_TAG_FUNCS_DEF(lights, lamp, ID_LA) RNA_MAIN_ID_TAG_FUNCS_DEF(libraries, library, ID_LI) RNA_MAIN_ID_TAG_FUNCS_DEF(screens, screen, ID_SCR) RNA_MAIN_ID_TAG_FUNCS_DEF(window_managers, wm, ID_WM) @@ -601,7 +631,7 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(fonts, vfont, ID_VF) RNA_MAIN_ID_TAG_FUNCS_DEF(textures, tex, ID_TE) RNA_MAIN_ID_TAG_FUNCS_DEF(brushes, brush, ID_BR) RNA_MAIN_ID_TAG_FUNCS_DEF(worlds, world, ID_WO) -RNA_MAIN_ID_TAG_FUNCS_DEF(groups, group, ID_GR) +RNA_MAIN_ID_TAG_FUNCS_DEF(collections, collection, ID_GR) //RNA_MAIN_ID_TAG_FUNCS_DEF(shape_keys, key, ID_KE) RNA_MAIN_ID_TAG_FUNCS_DEF(texts, text, ID_TXT) RNA_MAIN_ID_TAG_FUNCS_DEF(speakers, speaker, ID_SPK) @@ -616,6 +646,8 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(masks, mask, ID_MSK) RNA_MAIN_ID_TAG_FUNCS_DEF(linestyle, linestyle, ID_LS) RNA_MAIN_ID_TAG_FUNCS_DEF(cachefiles, cachefiles, ID_CF) RNA_MAIN_ID_TAG_FUNCS_DEF(paintcurves, paintcurves, ID_PC) +RNA_MAIN_ID_TAG_FUNCS_DEF(workspaces, workspaces, ID_WS) +RNA_MAIN_ID_TAG_FUNCS_DEF(lightprobes, lightprobe, ID_LP) #undef RNA_MAIN_ID_TAG_FUNCS_DEF @@ -643,7 +675,6 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataCameras"); srna = RNA_def_struct(brna, "BlendDataCameras", NULL); @@ -675,10 +706,6 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_cameras_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_cameras_is_updated_get", NULL); } void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) @@ -686,7 +713,6 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataScenes"); srna = RNA_def_struct(brna, "BlendDataScenes", NULL); @@ -712,10 +738,6 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_scenes_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_scenes_is_updated_get", NULL); } void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) @@ -723,7 +745,6 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataObjects"); srna = RNA_def_struct(brna, "BlendDataObjects", NULL); @@ -757,10 +778,6 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_objects_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_objects_is_updated_get", NULL); } void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) @@ -768,7 +785,6 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataMaterials"); srna = RNA_def_struct(brna, "BlendDataMaterials", NULL); @@ -783,6 +799,11 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_pointer(func, "material", "Material", "", "New material data-block"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "create_gpencil_data", "rna_Main_materials_gpencil_data"); + RNA_def_function_ui_description(func, "Add grease pencil material settings"); + parm = RNA_def_pointer(func, "material", "Material", "", "Material"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a material from the current blendfile"); @@ -798,17 +819,12 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_materials_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_materials_is_updated_get", NULL); } void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; static const EnumPropertyItem dummy_items[] = { {0, "DUMMY", 0, "", ""}, @@ -846,23 +862,12 @@ void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_node_groups_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_node_groups_is_updated_get", NULL); } void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; - - static const EnumPropertyItem mesh_type_items[] = { - {eModifierMode_Realtime, "PREVIEW", 0, "Preview", "Apply modifier preview settings"}, - {eModifierMode_Render, "RENDER", 0, "Render", "Apply modifier render settings"}, - {0, NULL, 0, NULL, NULL} - }; RNA_def_property_srna(cprop, "BlendDataMeshes"); srna = RNA_def_struct(brna, "BlendDataMeshes", NULL); @@ -880,15 +885,12 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new_from_object", "rna_Main_meshes_new_from_object"); RNA_def_function_ui_description(func, "Add a new mesh created from object with modifiers applied"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers"); + parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "Dependency Graph", "Evaluated dependency graph within which to evaluate modifiers"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_pointer(func, "object", "Object", "", "Object to create mesh from"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_boolean(func, "calc_tessface", true, "Calculate Tessellation", "Calculate tessellation faces"); RNA_def_boolean(func, "calc_undeformed", false, "Calculate Undeformed", "Calculate undeformed vertex coordinates"); parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export"); @@ -911,54 +913,46 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_meshes_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_meshes_is_updated_get", NULL); } -void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) + +void RNA_def_main_lights(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; - RNA_def_property_srna(cprop, "BlendDataLamps"); - srna = RNA_def_struct(brna, "BlendDataLamps", NULL); + RNA_def_property_srna(cprop, "BlendDataLights"); + srna = RNA_def_struct(brna, "BlendDataLights", NULL); RNA_def_struct_sdna(srna, "Main"); - RNA_def_struct_ui_text(srna, "Main Lamps", "Collection of lamps"); + RNA_def_struct_ui_text(srna, "Main Lights", "Collection of lights"); - func = RNA_def_function(srna, "new", "rna_Main_lamps_new"); - RNA_def_function_ui_description(func, "Add a new lamp to the main database"); - parm = RNA_def_string(func, "name", "Lamp", 0, "", "New name for the data-block"); + func = RNA_def_function(srna, "new", "rna_Main_lights_new"); + RNA_def_function_ui_description(func, "Add a new light to the main database"); + parm = RNA_def_string(func, "name", "Light", 0, "", "New name for the data-block"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_enum(func, "type", rna_enum_lamp_type_items, 0, "Type", "The type of texture to add"); + parm = RNA_def_enum(func, "type", rna_enum_light_type_items, 0, "Type", "The type of texture to add"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "lamp", "Lamp", "", "New lamp data-block"); + parm = RNA_def_pointer(func, "light", "Light", "", "New light data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile"); - parm = RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove"); + RNA_def_function_ui_description(func, "Remove a light from the current blendfile"); + parm = RNA_def_pointer(func, "light", "Light", "", "Light to remove"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); RNA_def_boolean(func, "do_unlink", true, "", - "Unlink all usages of this lamp before deleting it " - "(WARNING: will also delete objects instancing that lamp data)"); + "Unlink all usages of this Light before deleting it " + "(WARNING: will also delete objects instancing that light data)"); RNA_def_boolean(func, "do_id_user", true, "", - "Decrement user counter of all datablocks used by this lamp data"); + "Decrement user counter of all datablocks used by this light data"); RNA_def_boolean(func, "do_ui_user", true, "", - "Make sure interface does not reference this lamp data"); + "Make sure interface does not reference this light data"); - func = RNA_def_function(srna, "tag", "rna_Main_lamps_tag"); + func = RNA_def_function(srna, "tag", "rna_Main_lights_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_lamps_is_updated_get", NULL); } void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop) @@ -966,7 +960,6 @@ void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataLibraries"); srna = RNA_def_struct(brna, "BlendDataLibraries", NULL); @@ -976,10 +969,6 @@ void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_libraries_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_libraries_is_updated_get", NULL); } void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop) @@ -987,7 +976,6 @@ void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataScreens"); srna = RNA_def_struct(brna, "BlendDataScreens", NULL); @@ -997,10 +985,6 @@ void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_screens_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_screens_is_updated_get", NULL); } void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop) @@ -1008,7 +992,6 @@ void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataWindowManagers"); srna = RNA_def_struct(brna, "BlendDataWindowManagers", NULL); @@ -1018,17 +1001,12 @@ void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_window_managers_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_window_managers_is_updated_get", NULL); } void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataImages"); srna = RNA_def_struct(brna, "BlendDataImages", NULL); @@ -1075,10 +1053,6 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_images_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_images_is_updated_get", NULL); } void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) @@ -1086,7 +1060,6 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataLattices"); srna = RNA_def_struct(brna, "BlendDataLattices", NULL); @@ -1118,17 +1091,12 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_lattices_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_lattices_is_updated_get", NULL); } void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataCurves"); srna = RNA_def_struct(brna, "BlendDataCurves", NULL); @@ -1162,17 +1130,12 @@ void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_curves_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_curves_is_updated_get", NULL); } void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataMetaBalls"); srna = RNA_def_struct(brna, "BlendDataMetaBalls", NULL); @@ -1204,17 +1167,12 @@ void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_metaballs_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_metaballs_is_updated_get", NULL); } void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataFonts"); srna = RNA_def_struct(brna, "BlendDataFonts", NULL); @@ -1246,22 +1204,17 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_fonts_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_fonts_is_updated_get", NULL); } void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataTextures"); srna = RNA_def_struct(brna, "BlendDataTextures", NULL); RNA_def_struct_sdna(srna, "Main"); - RNA_def_struct_ui_text(srna, "Main Textures", "Collection of groups"); + RNA_def_struct_ui_text(srna, "Main Textures", "Collection of textures"); func = RNA_def_function(srna, "new", "rna_Main_textures_new"); RNA_def_function_ui_description(func, "Add a new texture to the main database"); @@ -1288,17 +1241,12 @@ void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_textures_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_textures_is_updated_get", NULL); } void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataBrushes"); srna = RNA_def_struct(brna, "BlendDataBrushes", NULL); @@ -1330,9 +1278,10 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_brushes_is_updated_get", NULL); + func = RNA_def_function(srna, "create_gpencil_data", "rna_Main_brush_gpencil_data"); + RNA_def_function_ui_description(func, "Add grease pencil brush settings"); + parm = RNA_def_pointer(func, "brush", "Brush", "", "Brush"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); } void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) @@ -1340,7 +1289,6 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataWorlds"); srna = RNA_def_struct(brna, "BlendDataWorlds", NULL); @@ -1370,51 +1318,42 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_worlds_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_worlds_is_updated_get", NULL); } -void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) +void RNA_def_main_collections(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; - RNA_def_property_srna(cprop, "BlendDataGroups"); - srna = RNA_def_struct(brna, "BlendDataGroups", NULL); + RNA_def_property_srna(cprop, "BlendDataCollections"); + srna = RNA_def_struct(brna, "BlendDataCollections", NULL); RNA_def_struct_sdna(srna, "Main"); - RNA_def_struct_ui_text(srna, "Main Groups", "Collection of groups"); + RNA_def_struct_ui_text(srna, "Main Collections", "Collection of collections"); - func = RNA_def_function(srna, "new", "rna_Main_groups_new"); - RNA_def_function_ui_description(func, "Add a new group to the main database"); - parm = RNA_def_string(func, "name", "Group", 0, "", "New name for the data-block"); + func = RNA_def_function(srna, "new", "rna_Main_collections_new"); + RNA_def_function_ui_description(func, "Add a new collection to the main database"); + parm = RNA_def_string(func, "name", "Collection", 0, "", "New name for the data-block"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "group", "Group", "", "New group data-block"); + parm = RNA_def_pointer(func, "collection", "Collection", "", "New collection data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); - RNA_def_function_ui_description(func, "Remove a group from the current blendfile"); + RNA_def_function_ui_description(func, "Remove a collection from the current blendfile"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "group", "Group", "", "Group to remove"); + parm = RNA_def_pointer(func, "collection", "Collection", "", "Collection to remove"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); - RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this group before deleting it"); + RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this collection before deleting it"); RNA_def_boolean(func, "do_id_user", true, "", - "Decrement user counter of all datablocks used by this group"); + "Decrement user counter of all datablocks used by this collection"); RNA_def_boolean(func, "do_ui_user", true, "", - "Make sure interface does not reference this group"); + "Make sure interface does not reference this collection"); - func = RNA_def_function(srna, "tag", "rna_Main_groups_tag"); + func = RNA_def_function(srna, "tag", "rna_Main_collections_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_groups_is_updated_get", NULL); } void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop) @@ -1422,7 +1361,6 @@ void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataSpeakers"); srna = RNA_def_struct(brna, "BlendDataSpeakers", NULL); @@ -1454,10 +1392,6 @@ void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_speakers_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_speakers_is_updated_get", NULL); } void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) @@ -1465,7 +1399,6 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataTexts"); srna = RNA_def_struct(brna, "BlendDataTexts", NULL); @@ -1506,10 +1439,6 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_texts_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_texts_is_updated_get", NULL); } void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop) @@ -1517,7 +1446,6 @@ void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataSounds"); srna = RNA_def_struct(brna, "BlendDataSounds", NULL); @@ -1549,10 +1477,6 @@ void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_sounds_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_sounds_is_updated_get", NULL); } void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) @@ -1560,7 +1484,6 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataArmatures"); srna = RNA_def_struct(brna, "BlendDataArmatures", NULL); @@ -1592,17 +1515,12 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_armatures_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_armatures_is_updated_get", NULL); } void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataActions"); srna = RNA_def_struct(brna, "BlendDataActions", NULL); @@ -1632,17 +1550,12 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_actions_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_actions_is_updated_get", NULL); } void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataParticles"); srna = RNA_def_struct(brna, "BlendDataParticles", NULL); @@ -1672,17 +1585,13 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_particles_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_particles_is_updated_get", NULL); } + void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataPalettes"); srna = RNA_def_struct(brna, "BlendDataPalettes", NULL); @@ -1712,17 +1621,12 @@ void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_palettes_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_palettes_is_updated_get", NULL); } void RNA_def_main_cachefiles(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataCacheFiles"); srna = RNA_def_struct(brna, "BlendDataCacheFiles", NULL); @@ -1732,17 +1636,12 @@ void RNA_def_main_cachefiles(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_cachefiles_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_cachefiles_is_updated_get", NULL); } void RNA_def_main_paintcurves(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataPaintCurves"); srna = RNA_def_struct(brna, "BlendDataPaintCurves", NULL); @@ -1752,17 +1651,12 @@ void RNA_def_main_paintcurves(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "tag", "rna_Main_paintcurves_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_paintcurves_is_updated_get", NULL); } void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataGreasePencils"); srna = RNA_def_struct(brna, "BlendDataGreasePencils", NULL); @@ -1792,10 +1686,6 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) "Decrement user counter of all datablocks used by this grease pencil"); RNA_def_boolean(func, "do_ui_user", true, "", "Make sure interface does not reference this grease pencil"); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_gpencil_is_updated_get", NULL); } void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop) @@ -1803,7 +1693,6 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataMovieClips"); srna = RNA_def_struct(brna, "BlendDataMovieClips", NULL); @@ -1839,10 +1728,6 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop) /* return type */ parm = RNA_def_pointer(func, "clip", "MovieClip", "", "New movie clip data-block"); RNA_def_function_return(func, parm); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_movieclips_is_updated_get", NULL); } void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) @@ -1850,7 +1735,6 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataMasks"); srna = RNA_def_struct(brna, "BlendDataMasks", NULL); @@ -1882,10 +1766,6 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) "Decrement user counter of all datablocks used by this mask"); RNA_def_boolean(func, "do_ui_user", true, "", "Make sure interface does not reference this mask"); - - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_masks_is_updated_get", NULL); } void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) @@ -1893,7 +1773,6 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataLineStyles"); srna = RNA_def_struct(brna, "BlendDataLineStyles", NULL); @@ -1923,10 +1802,60 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) "Decrement user counter of all datablocks used by this line style"); RNA_def_boolean(func, "do_ui_user", true, "", "Make sure interface does not reference this line style"); +} + +void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "BlendDataWorkSpaces"); + srna = RNA_def_struct(brna, "BlendDataWorkSpaces", NULL); + RNA_def_struct_sdna(srna, "Main"); + RNA_def_struct_ui_text(srna, "Main Workspaces", "Collection of workspaces"); + + func = RNA_def_function(srna, "tag", "rna_Main_workspaces_tag"); + parm = RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); +} + +void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; - prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_boolean_funcs(prop, "rna_Main_linestyle_is_updated_get", NULL); + RNA_def_property_srna(cprop, "BlendDataProbes"); + srna = RNA_def_struct(brna, "BlendDataProbes", NULL); + RNA_def_struct_sdna(srna, "Main"); + RNA_def_struct_ui_text(srna, "Main Light Probes", "Collection of light probes"); + + func = RNA_def_function(srna, "new", "rna_Main_lightprobe_new"); + RNA_def_function_ui_description(func, "Add a new probe to the main database"); + parm = RNA_def_string(func, "name", "Probe", 0, "", "New name for the data-block"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "lightprobe", "LightProbe", "", "New light probe data-block"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a probe from the current blendfile"); + parm = RNA_def_pointer(func, "lightprobe", "LightProbe", "", "Probe to remove"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + RNA_def_boolean(func, "do_unlink", true, "", + "Unlink all usages of this probe before deleting it " + "(WARNING: will also delete objects instancing that light probe data)"); + RNA_def_boolean(func, "do_id_user", true, "", + "Decrement user counter of all datablocks used by this light probe"); + RNA_def_boolean(func, "do_ui_user", true, "", + "Make sure interface does not reference this light probe"); + + func = RNA_def_function(srna, "tag", "rna_Main_lightprobes_tag"); + parm = RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } #endif diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index c266e0e7f31..2cd427fbbd8 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -56,9 +56,10 @@ #include "DNA_movieclip_types.h" -#include "BKE_depsgraph.h" #include "BKE_mask.h" +#include "DEG_depsgraph.h" + #include "RNA_access.h" #include "WM_api.h" @@ -68,7 +69,7 @@ static void rna_Mask_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin Mask *mask = ptr->id.data; WM_main_add_notifier(NC_MASK | ND_DATA, mask); - DAG_id_tag_update( &mask->id, 0); + DEG_id_tag_update( &mask->id, 0); } static void rna_Mask_update_parent(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -448,7 +449,7 @@ static void rna_MaskLayer_spline_remove(ID *id, MaskLayer *mask_layer, ReportLis RNA_POINTER_INVALIDATE(spline_ptr); - DAG_id_tag_update(&mask->id, OB_RECALC_DATA); + DEG_id_tag_update(&mask->id, OB_RECALC_DATA); } static void rna_Mask_start_frame_set(PointerRNA *ptr, int value) @@ -522,7 +523,7 @@ static void rna_MaskSpline_points_add(ID *id, MaskSpline *spline, int count) } WM_main_add_notifier(NC_MASK | ND_DATA, mask); - DAG_id_tag_update(&mask->id, 0); + DEG_id_tag_update(&mask->id, 0); } static void rna_MaskSpline_point_remove(ID *id, MaskSpline *spline, ReportList *reports, PointerRNA *point_ptr) @@ -582,7 +583,7 @@ static void rna_MaskSpline_point_remove(ID *id, MaskSpline *spline, ReportList * BKE_mask_layer_shape_changed_remove(layer, BKE_mask_layer_shape_spline_to_index(layer, spline) + point_index, 1); WM_main_add_notifier(NC_MASK | ND_DATA, mask); - DAG_id_tag_update(&mask->id, 0); + DEG_id_tag_update(&mask->id, 0); RNA_POINTER_INVALIDATE(point_ptr); } @@ -810,7 +811,8 @@ static void rna_def_maskSplinePoints(BlenderRNA *brna) func = RNA_def_function(srna, "add", "rna_MaskSpline_points_add"); RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a number of point to this spline"); - RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + parm = RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); /* Remove the point */ func = RNA_def_function(srna, "remove", "rna_MaskSpline_point_remove"); @@ -931,19 +933,19 @@ static void rna_def_mask_layer(BlenderRNA *brna) prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", MASK_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_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1); RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL); prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", MASK_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_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1); RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL); prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", MASK_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_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1); RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL); /* select (for dopesheet)*/ diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 5bd12d727ed..7a3d45c7a62 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -38,41 +38,30 @@ #include "WM_api.h" #include "WM_types.h" -static const EnumPropertyItem prop_texture_coordinates_items[] = { - {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates"}, - {TEXCO_OBJECT, "OBJECT", 0, "Object", "Use linked object's coordinates for texture coordinates"}, - {TEXCO_UV, "UV", 0, "UV", "Use UV coordinates for texture coordinates"}, - {TEXCO_ORCO, "ORCO", 0, "Generated", "Use the original undeformed coordinates of the object"}, - {TEXCO_STRAND, "STRAND", 0, "Strand / Particle", - "Use normalized strand texture coordinate (1D) or particle age (X) and trail position (Y)"}, - {TEXCO_WINDOW, "WINDOW", 0, "Window", "Use screen coordinates as texture coordinates"}, - {TEXCO_NORM, "NORMAL", 0, "Normal", "Use normal vector as texture coordinates"}, - {TEXCO_REFL, "REFLECTION", 0, "Reflection", "Use reflection vector as texture coordinates"}, - {TEXCO_STRESS, "STRESS", 0, "Stress", - "Use the difference of edge lengths compared to original coordinates of the mesh"}, - {TEXCO_TANGENT, "TANGENT", 0, "Tangent", "Use the optional tangent vector as texture coordinates"}, - {0, NULL, 0, NULL, NULL} -}; - const EnumPropertyItem rna_enum_ramp_blend_items[] = { {MA_RAMP_BLEND, "MIX", 0, "Mix", ""}, - {MA_RAMP_ADD, "ADD", 0, "Add", ""}, - {MA_RAMP_MULT, "MULTIPLY", 0, "Multiply", ""}, - {MA_RAMP_SUB, "SUBTRACT", 0, "Subtract", ""}, - {MA_RAMP_SCREEN, "SCREEN", 0, "Screen", ""}, - {MA_RAMP_DIV, "DIVIDE", 0, "Divide", ""}, - {MA_RAMP_DIFF, "DIFFERENCE", 0, "Difference", ""}, + {0, "", ICON_NONE, NULL, NULL}, {MA_RAMP_DARK, "DARKEN", 0, "Darken", ""}, + {MA_RAMP_MULT, "MULTIPLY", 0, "Multiply", ""}, + {MA_RAMP_BURN, "BURN", 0, "Burn", ""}, + {0, "", ICON_NONE, NULL, NULL}, {MA_RAMP_LIGHT, "LIGHTEN", 0, "Lighten", ""}, - {MA_RAMP_OVERLAY, "OVERLAY", 0, "Overlay", ""}, + {MA_RAMP_SCREEN, "SCREEN", 0, "Screen", ""}, {MA_RAMP_DODGE, "DODGE", 0, "Dodge", ""}, - {MA_RAMP_BURN, "BURN", 0, "Burn", ""}, + {MA_RAMP_ADD, "ADD", 0, "Add", ""}, + {0, "", ICON_NONE, NULL, NULL}, + {MA_RAMP_OVERLAY, "OVERLAY", 0, "Overlay", ""}, + {MA_RAMP_SOFT, "SOFT_LIGHT", 0, "Soft Light", ""}, + {MA_RAMP_LINEAR, "LINEAR_LIGHT", 0, "Linear Light", ""}, + {0, "", ICON_NONE, NULL, NULL}, + {MA_RAMP_DIFF, "DIFFERENCE", 0, "Difference", ""}, + {MA_RAMP_SUB, "SUBTRACT", 0, "Subtract", ""}, + {MA_RAMP_DIV, "DIVIDE", 0, "Divide", ""}, + {0, "", ICON_NONE, NULL, NULL}, {MA_RAMP_HUE, "HUE", 0, "Hue", ""}, {MA_RAMP_SAT, "SATURATION", 0, "Saturation", ""}, - {MA_RAMP_VAL, "VALUE", 0, "Value", ""}, {MA_RAMP_COLOR, "COLOR", 0, "Color", ""}, - {MA_RAMP_SOFT, "SOFT_LIGHT", 0, "Soft Light", ""}, - {MA_RAMP_LINEAR, "LINEAR_LIGHT", 0, "Linear Light", ""}, + {MA_RAMP_VAL, "VALUE", 0, "Value", ""}, {0, NULL, 0, NULL, NULL} }; @@ -87,22 +76,28 @@ const EnumPropertyItem rna_enum_ramp_blend_items[] = { #include "BKE_colorband.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" +#include "BKE_gpencil.h" #include "BKE_material.h" #include "BKE_texture.h" #include "BKE_node.h" #include "BKE_paint.h" +#include "BKE_scene.h" +#include "BKE_workspace.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" #include "ED_node.h" #include "ED_image.h" -#include "BKE_scene.h" +#include "ED_screen.h" +#include "ED_gpencil.h" static void rna_Material_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Material *ma = ptr->id.data; - DAG_id_tag_update(&ma->id, 0); + DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE); WM_main_add_notifier(NC_MATERIAL | ND_SHADING, ma); } @@ -116,58 +111,28 @@ static void rna_Material_update_previews(Main *UNUSED(bmain), Scene *UNUSED(scen WM_main_add_notifier(NC_MATERIAL | ND_SHADING_PREVIEW, ma); } -static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_MaterialGpencil_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Material *ma = ptr->id.data; - DAG_id_tag_update(&ma->id, 0); - WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma); -} - -static PointerRNA rna_Material_mirror_get(PointerRNA *ptr) -{ - return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceMirror, ptr->id.data); -} - -static PointerRNA rna_Material_transp_get(PointerRNA *ptr) -{ - return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceTransparency, ptr->id.data); -} - -static PointerRNA rna_Material_halo_get(PointerRNA *ptr) -{ - return rna_pointer_inherit_refine(ptr, &RNA_MaterialHalo, ptr->id.data); + rna_Material_update(bmain, scene, ptr); + WM_main_add_notifier(NC_GPENCIL | ND_DATA, ma); } -static PointerRNA rna_Material_sss_get(PointerRNA *ptr) +static void rna_MaterialGpencil_nopreview_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - return rna_pointer_inherit_refine(ptr, &RNA_MaterialSubsurfaceScattering, ptr->id.data); -} - -static PointerRNA rna_Material_strand_get(PointerRNA *ptr) -{ - return rna_pointer_inherit_refine(ptr, &RNA_MaterialStrand, ptr->id.data); -} + Material *ma = ptr->id.data; -static PointerRNA rna_Material_physics_get(PointerRNA *ptr) -{ - return rna_pointer_inherit_refine(ptr, &RNA_MaterialPhysics, ptr->id.data); + rna_Material_update(bmain, scene, ptr); + WM_main_add_notifier(NC_GPENCIL | ND_DATA, ma); } -static void rna_Material_type_set(PointerRNA *ptr, int value) +static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - Material *ma = (Material *)ptr->data; - - if (ma->material_type == MA_TYPE_HALO && value != MA_TYPE_HALO) - ma->mode &= ~(MA_STAR | MA_HALO_XALPHA | MA_ZINV | MA_ENV); - - ma->material_type = value; -} + Material *ma = ptr->id.data; -static void rna_Material_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - Material *ma = (Material *)ptr->data; - rna_iterator_array_begin(iter, (void *)ma->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL); + DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE); + WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma); } static void rna_Material_texpaint_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) @@ -199,181 +164,47 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s if (ma->texpaintslot) { Image *image = ma->texpaintslot[ma->paint_active_slot].ima; for (sc = bmain->screen.first; sc; sc = sc->id.next) { + wmWindow *win = ED_screen_window_find(sc, bmain->wm.first); + if (win == NULL) { + continue; + } + + Object *obedit = NULL; + { + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + } + ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; - - if (!sima->pin) - ED_space_image_set(bmain, sima, scene, scene->obedit, image); + if (!sima->pin) { + ED_space_image_set(bmain, sima, scene, obedit, image); + } } } } } } - DAG_id_tag_update(&ma->id, 0); + DEG_id_tag_update(&ma->id, 0); WM_main_add_notifier(NC_MATERIAL | ND_SHADING, ma); } -static PointerRNA rna_Material_active_texture_get(PointerRNA *ptr) -{ - Material *ma = (Material *)ptr->data; - Tex *tex; - - tex = give_current_material_texture(ma); - return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex); -} - -static void rna_Material_active_texture_set(PointerRNA *ptr, PointerRNA value) -{ - Material *ma = (Material *)ptr->data; - - set_current_material_texture(ma, value.data); -} - -static int rna_Material_active_texture_editable(PointerRNA *ptr, const char **UNUSED(r_info)) -{ - Material *ma = (Material *)ptr->id.data; - - return has_current_material_texture(ma) ? PROP_EDITABLE : 0; -} - -static PointerRNA rna_Material_active_node_material_get(PointerRNA *ptr) -{ - Material *ma = give_node_material((Material *)ptr->data); - return rna_pointer_inherit_refine(ptr, &RNA_Material, ma); -} - -static void rna_Material_active_node_material_set(PointerRNA *ptr, PointerRNA value) -{ - Material *ma = (Material *)ptr->data; - Material *ma_act = value.data; - - nodeSetActiveID(ma->nodetree, ID_MA, &ma_act->id); -} - -static void rna_MaterialStrand_start_size_range(PointerRNA *ptr, float *min, float *max, - float *UNUSED(softmin), float *UNUSED(softmax)) -{ - Material *ma = (Material *)ptr->id.data; - - if (ma->mode & MA_STR_B_UNITS) { - *min = 0.0001f; - *max = 2.0f; - } - else { - *min = 0.25f; - *max = 20.0f; - } -} - -static void rna_MaterialStrand_end_size_range(PointerRNA *ptr, float *min, float *max, - float *UNUSED(softmin), float *UNUSED(softmax)) -{ - Material *ma = (Material *)ptr->id.data; - - if (ma->mode & MA_STR_B_UNITS) { - *min = 0.0001f; - *max = 1.0f; - } - else { - *min = 0.25f; - *max = 10.0f; - } -} - -static bool rna_MaterialTextureSlot_use_get(PointerRNA *ptr) -{ - Material *ma = (Material *)ptr->id.data; - MTex *mtex = (MTex *)ptr->data; - int a; - - for (a = 0; a < MAX_MTEX; a++) - if (ma->mtex[a] == mtex) - return (ma->septex & (1 << a)) == 0; - - return 0; -} - -static void rna_MaterialTextureSlot_use_set(PointerRNA *ptr, bool value) -{ - Material *ma = (Material *)ptr->id.data; - MTex *mtex = (MTex *)ptr->data; - int a; - - for (a = 0; a < MAX_MTEX; a++) { - if (ma->mtex[a] == mtex) { - if (value) - ma->septex &= ~(1 << a); - else - ma->septex |= (1 << a); - } - } -} - -static void rna_Material_use_diffuse_ramp_set(PointerRNA *ptr, bool value) -{ - Material *ma = (Material *)ptr->data; - - if (value) ma->mode |= MA_RAMP_COL; - else ma->mode &= ~MA_RAMP_COL; - - if ((ma->mode & MA_RAMP_COL) && ma->ramp_col == NULL) - ma->ramp_col = BKE_colorband_add(false); -} - -static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, bool value) -{ - Material *ma = (Material *)ptr->data; - - if (value) ma->mode |= MA_RAMP_SPEC; - else ma->mode &= ~MA_RAMP_SPEC; - - if ((ma->mode & MA_RAMP_SPEC) && ma->ramp_spec == NULL) - ma->ramp_spec = BKE_colorband_add(false); -} - static void rna_Material_use_nodes_update(bContext *C, PointerRNA *ptr) { Material *ma = (Material *)ptr->data; + Main *bmain = CTX_data_main(C); if (ma->use_nodes && ma->nodetree == NULL) ED_node_shader_default(C, &ma->id); - rna_Material_draw_update(CTX_data_main(C), CTX_data_scene(C), ptr); -} - -static const EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), bool *r_free) -{ - Material *ma = (Material *)ptr->id.data; - EnumPropertyItem *item = NULL; - int totitem = 0; - - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_GLOB); - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_OBJECT); - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_ORCO); - - if (ma->material_type == MA_TYPE_VOLUME) { - /* pass */ - } - else if (ELEM(ma->material_type, MA_TYPE_SURFACE, MA_TYPE_HALO, MA_TYPE_WIRE)) { - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_UV); - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STRAND); - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_WINDOW); - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_NORM); - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_REFL); - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STRESS); - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_TANGENT); - } - - RNA_enum_item_end(&item, &totitem); - *r_free = true; - - return item; + DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE); + DEG_relations_tag_update(bmain); + rna_Material_draw_update(bmain, CTX_data_scene(C), ptr); } MTex *rna_mtex_texture_slots_add(ID *self_id, struct bContext *C, ReportList *reports) @@ -428,7 +259,7 @@ void rna_mtex_texture_slots_clear(ID *self_id, struct bContext *C, ReportList *r id_us_min((ID *)mtex_ar[index]->tex); MEM_freeN(mtex_ar[index]); mtex_ar[index] = NULL; - DAG_id_tag_update(self_id, 0); + DEG_id_tag_update(self_id, 0); } /* for redraw only */ @@ -462,470 +293,65 @@ static void rna_TexPaintSlot_uv_layer_set(PointerRNA *ptr, const char *value) } } - -#else - -static void rna_def_material_mtex(BlenderRNA *brna) +static bool rna_is_grease_pencil_get(PointerRNA *ptr) { - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_mapping_items[] = { - {MTEX_FLAT, "FLAT", 0, "Flat", "Map X and Y coordinates directly"}, - {MTEX_CUBE, "CUBE", 0, "Cube", "Map using the normal vector"}, - {MTEX_TUBE, "TUBE", 0, "Tube", "Map with Z as central axis"}, - {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_x_mapping_items[] = { - {0, "NONE", 0, "None", ""}, - {1, "X", 0, "X", ""}, - {2, "Y", 0, "Y", ""}, - {3, "Z", 0, "Z", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_y_mapping_items[] = { - {0, "NONE", 0, "None", ""}, - {1, "X", 0, "X", ""}, - {2, "Y", 0, "Y", ""}, - {3, "Z", 0, "Z", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_z_mapping_items[] = { - {0, "NONE", 0, "None", ""}, - {1, "X", 0, "X", ""}, - {2, "Y", 0, "Y", ""}, - {3, "Z", 0, "Z", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_normal_map_space_items[] = { - {MTEX_NSPACE_CAMERA, "CAMERA", 0, "Camera", ""}, - {MTEX_NSPACE_WORLD, "WORLD", 0, "World", ""}, - {MTEX_NSPACE_OBJECT, "OBJECT", 0, "Object", ""}, - {MTEX_NSPACE_TANGENT, "TANGENT", 0, "Tangent", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_bump_method_items[] = { - {0, "BUMP_ORIGINAL", 0, "Original", ""}, - {MTEX_COMPAT_BUMP, "BUMP_COMPATIBLE", 0, "Compatible", ""}, - {MTEX_3TAP_BUMP, "BUMP_LOW_QUALITY", 0, "Low Quality", "Use 3 tap filtering"}, - {MTEX_5TAP_BUMP, "BUMP_MEDIUM_QUALITY", 0, "Medium Quality", "Use 5 tap filtering"}, - {MTEX_BICUBIC_BUMP, "BUMP_BEST_QUALITY", 0, - "Best Quality", "Use bicubic filtering (requires OpenGL 3.0+, it will fall back on " - "medium setting for other systems)"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_bump_space_items[] = { - {0, "BUMP_VIEWSPACE", 0, "ViewSpace", ""}, - {MTEX_BUMP_OBJECTSPACE, "BUMP_OBJECTSPACE", 0, "ObjectSpace", ""}, - {MTEX_BUMP_TEXTURESPACE, "BUMP_TEXTURESPACE", 0, "TextureSpace", ""}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "MaterialTextureSlot", "TextureSlot"); - RNA_def_struct_sdna(srna, "MTex"); - RNA_def_struct_ui_text(srna, "Material Texture Slot", "Texture slot for textures in a Material data-block"); - - prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "texco"); - RNA_def_property_enum_items(prop, prop_texture_coordinates_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Material_texture_coordinates_itemf"); - RNA_def_property_ui_text(prop, "Texture Coordinates", ""); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - 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 mapping with Object texture coordinates"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "uvname"); - RNA_def_property_ui_text(prop, "UV Map", "UV map to use for mapping with UV texture coordinates"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_from_dupli", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_DUPLI_MAPTO); - RNA_def_property_ui_text(prop, "From Dupli", - "Dupli's instanced from verts, faces or particles, inherit texture coordinate " - "from their parent"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_to_bounds", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_MAPTO_BOUNDS); - RNA_def_property_ui_text(prop, "Map to Bounds", - "Map coordinates in object bounds"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_from_original", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_OB_DUPLI_ORIG); - RNA_def_property_ui_text(prop, "From Original", - "Dupli's derive their object coordinates from the original object's transformation"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_color_diffuse", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COL); - RNA_def_property_ui_text(prop, "Diffuse Color", "The texture affects basic color of the material"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_normal", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_NORM); - RNA_def_property_ui_text(prop, "Normal", "The texture affects the rendered normal"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_color_spec", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COLSPEC); - RNA_def_property_ui_text(prop, "Specular Color", "The texture affects the specularity color"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_mirror", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COLMIR); - RNA_def_property_ui_text(prop, "Mirror", "The texture affects the mirror color"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_diffuse", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REF); - RNA_def_property_ui_text(prop, "Diffuse", "The texture affects the value of diffuse reflectivity"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_specular", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_SPEC); - RNA_def_property_ui_text(prop, "Specular", "The texture affects the value of specular reflectivity"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_ambient", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_AMB); - RNA_def_property_ui_text(prop, "Ambient", "The texture affects the value of ambient"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_hardness", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_HAR); - RNA_def_property_ui_text(prop, "Hardness", "The texture affects the hardness value"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_raymir", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_RAYMIRR); - RNA_def_property_ui_text(prop, "Ray-Mirror", "The texture affects the ray-mirror value"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_alpha", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_ALPHA); - RNA_def_property_ui_text(prop, "Alpha", "The texture affects the alpha value"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_emit", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMIT); - RNA_def_property_ui_text(prop, "Emit", "The texture affects the emit value"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_translucency", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_TRANSLU); - RNA_def_property_ui_text(prop, "Translucency", "The texture affects the translucency value"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_displacement", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_DISPLACE); - RNA_def_property_ui_text(prop, "Displacement", "Let the texture displace the surface"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_warp", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_WARP); - RNA_def_property_ui_text(prop, "Warp", "Let the texture warp texture coordinates of next channels"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "projx"); - RNA_def_property_enum_items(prop, prop_x_mapping_items); - RNA_def_property_ui_text(prop, "X Mapping", ""); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "projy"); - RNA_def_property_enum_items(prop, prop_y_mapping_items); - RNA_def_property_ui_text(prop, "Y Mapping", ""); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "projz"); - RNA_def_property_enum_items(prop, prop_z_mapping_items); - RNA_def_property_ui_text(prop, "Z Mapping", ""); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_mapping_items); - RNA_def_property_ui_text(prop, "Mapping", ""); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "normal_map_space", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "normapspace"); - RNA_def_property_enum_items(prop, prop_normal_map_space_items); - RNA_def_property_ui_text(prop, "Normal Map Space", "Set space of normal map image"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "norfac"); - RNA_def_property_ui_range(prop, -5, 5, 10, 3); - RNA_def_property_ui_text(prop, "Normal Factor", "Amount texture affects normal values"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "displacement_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dispfac"); - RNA_def_property_ui_range(prop, -1, 1, 10, 3); - RNA_def_property_ui_text(prop, "Displacement Factor", "Amount texture displaces the surface"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "warp_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "warpfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Warp Factor", "Amount texture affects texture coordinates of next channels"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "specular_color_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colspecfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Specular Color Factor", "Amount texture affects specular color"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_color_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Diffuse Color Factor", "Amount texture affects diffuse color"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "mirror_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "mirrfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Mirror Factor", "Amount texture affects mirror color"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "alpha_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "alphafac"); - RNA_def_property_ui_range(prop, -1, 1, 10, 3); - RNA_def_property_ui_text(prop, "Alpha Factor", "Amount texture affects alpha"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "difffac"); - RNA_def_property_ui_range(prop, -1, 1, 10, 3); - RNA_def_property_ui_text(prop, "Diffuse Factor", "Amount texture affects diffuse reflectivity"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "specfac"); - RNA_def_property_ui_range(prop, -1, 1, 10, 3); - RNA_def_property_ui_text(prop, "Specular Factor", "Amount texture affects specular reflectivity"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "emit_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "emitfac"); - RNA_def_property_ui_range(prop, -1, 1, 10, 3); - RNA_def_property_ui_text(prop, "Emit Factor", "Amount texture affects emission"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "hardness_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "hardfac"); - RNA_def_property_ui_range(prop, -1, 1, 10, 3); - RNA_def_property_ui_text(prop, "Hardness Factor", "Amount texture affects hardness"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "raymir_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "raymirrfac"); - RNA_def_property_ui_range(prop, -1, 1, 10, 3); - RNA_def_property_ui_text(prop, "Ray Mirror Factor", "Amount texture affects ray mirror"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "translucency_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "translfac"); - RNA_def_property_ui_range(prop, -1, 1, 10, 3); - RNA_def_property_ui_text(prop, "Translucency Factor", "Amount texture affects translucency"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "ambient_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ambfac"); - RNA_def_property_ui_range(prop, -1, 1, 10, 3); - RNA_def_property_ui_text(prop, "Ambient Factor", "Amount texture affects ambient"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - /* volume material */ - prop = RNA_def_property(srna, "use_map_color_emission", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMISSION_COL); - RNA_def_property_ui_text(prop, "Emission Color", "The texture affects the color of emission"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_color_reflection", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REFLECTION_COL); - RNA_def_property_ui_text(prop, "Reflection Color", "The texture affects the color of scattered light"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_color_transmission", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_TRANSMISSION_COL); - RNA_def_property_ui_text(prop, "Transmission Color", - "The texture affects the result color after other light has been scattered/absorbed"); - RNA_def_property_update(prop, NC_TEXTURE, NULL); - - prop = RNA_def_property(srna, "use_map_density", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_DENSITY); - RNA_def_property_ui_text(prop, "Density", "The texture affects the volume's density"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_emission", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMISSION); - RNA_def_property_ui_text(prop, "Emission", "The texture affects the volume's emission"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_scatter", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_SCATTERING); - RNA_def_property_ui_text(prop, "Scattering", "The texture affects the volume's scattering"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_map_reflect", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REFLECTION); - RNA_def_property_ui_text(prop, "Reflection", "The texture affects the reflected light's brightness"); - RNA_def_property_update(prop, NC_TEXTURE, NULL); - - prop = RNA_def_property(srna, "emission_color_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colemitfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Emission Color Factor", "Amount texture affects emission color"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "reflection_color_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colreflfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Reflection Color Factor", "Amount texture affects color of out-scattered light"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "transmission_color_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "coltransfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Transmission Color Factor", - "Amount texture affects result color after light has been scattered/absorbed"); - RNA_def_property_update(prop, NC_TEXTURE, NULL); - - prop = RNA_def_property(srna, "density_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "densfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Density Factor", "Amount texture affects density"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "emission_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "emitfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Emission Factor", "Amount texture affects emission"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "scattering_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "scatterfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Scattering Factor", "Amount texture affects scattering"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "reflection_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "reflfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Reflection Factor", "Amount texture affects brightness of out-scattered light"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - /* end volume material */ - - prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_MaterialTextureSlot_use_get", "rna_MaterialTextureSlot_use_set"); - RNA_def_property_ui_text(prop, "Enabled", "Enable this material texture slot"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "bump_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "texflag"); - RNA_def_property_enum_items(prop, prop_bump_method_items); - RNA_def_property_ui_text(prop, "Bump Method", "Method to use for bump mapping"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + Material *ma = (Material *)ptr->data; + if (ma->gp_style != NULL) + return true; - prop = RNA_def_property(srna, "bump_objectspace", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "texflag"); - RNA_def_property_enum_items(prop, prop_bump_space_items); - RNA_def_property_ui_text(prop, "Bump Space", "Space to apply bump mapping in"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + return false; } -static void rna_def_material_gamesettings(BlenderRNA *brna) +static void rna_gpcolordata_uv_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_alpha_blend_items[] = { - {GEMAT_SOLID, "OPAQUE", 0, "Opaque", "Render color of textured face as color"}, - {GEMAT_ADD, "ADD", 0, "Add", "Render face transparent and add color of face"}, - {GEMAT_CLIP, "CLIP", 0, "Alpha Clip", "Use the image alpha values clipped with no blending (binary alpha)"}, - {GEMAT_ALPHA, "ALPHA", 0, "Alpha Blend", - "Render polygon transparent, depending on alpha channel of the texture"}, - {GEMAT_ALPHA_SORT, "ALPHA_SORT", 0, "Alpha Sort", - "Sort faces for correct alpha drawing (slow, use Alpha Clip instead when possible)"}, - {GEMAT_ALPHA_TO_COVERAGE, "ALPHA_ANTIALIASING", 0, "Alpha Anti-Aliasing", - "Use textures alpha as anti-aliasing mask, requires multi-sample OpenGL display"}, - {0, NULL, 0, NULL, NULL} - }; + /* update all uv strokes of this color */ + Material *ma = ptr->id.data; + ED_gpencil_update_color_uv(bmain, ma); - static const EnumPropertyItem prop_face_orientation_items[] = { - {GEMAT_NORMAL, "NORMAL", 0, "Normal", "No transformation"}, - {GEMAT_HALO, "HALO", 0, "Halo", "Screen aligned billboard"}, - {GEMAT_BILLBOARD, "BILLBOARD", 0, "Billboard", "Billboard with Z-axis constraint"}, - {GEMAT_SHADOW, "SHADOW", 0, "Shadow", "Faces are used for shadow"}, - {0, NULL, 0, NULL, NULL} - }; + rna_MaterialGpencil_update(bmain, scene, ptr); +} - srna = RNA_def_struct(brna, "MaterialGameSettings", NULL); - RNA_def_struct_sdna(srna, "GameSettings"); - RNA_def_struct_nested(brna, srna, "Material"); - RNA_def_struct_ui_text(srna, "Material Game Settings", "Game Engine settings for a Material data-block"); +static char *rna_GpencilColorData_path(PointerRNA *UNUSED(ptr)) +{ + return BLI_sprintfN("grease_pencil"); +} - prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_BACKCULL); /* use bitflags */ - RNA_def_property_ui_text(prop, "Backface Culling", "Hide Back of the face in Game Engine "); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); +static int rna_GpencilColorData_is_stroke_visible_get(PointerRNA *ptr) +{ + MaterialGPencilStyle *pcolor = ptr->data; + return (pcolor->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH); +} - prop = RNA_def_property(srna, "text", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_TEXT); /* use bitflags */ - RNA_def_property_ui_text(prop, "Text", "Use material as text in Game Engine "); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); +static int rna_GpencilColorData_is_fill_visible_get(PointerRNA *ptr) +{ + MaterialGPencilStyle *pcolor = (MaterialGPencilStyle *)ptr->data; + return ((pcolor->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (pcolor->fill_style > 0)); +} - prop = RNA_def_property(srna, "invisible", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_INVISIBLE); /* use bitflags */ - RNA_def_property_ui_text(prop, "Invisible", "Make face invisible"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); +static void rna_GpencilColorData_stroke_image_set(PointerRNA *ptr, PointerRNA value) +{ + MaterialGPencilStyle *pcolor = ptr->data; + ID *id = value.data; - prop = RNA_def_property(srna, "alpha_blend", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "alpha_blend"); - RNA_def_property_enum_items(prop, prop_alpha_blend_items); - RNA_def_property_ui_text(prop, "Blend Mode", "Blend Mode for Transparent Faces"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); + id_us_plus(id); + pcolor->sima = (struct Image *)id; +} - prop = RNA_def_property(srna, "face_orientation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_face_orientation_items); - RNA_def_property_ui_text(prop, "Face Orientations", "Especial face orientation options"); +static void rna_GpencilColorData_fill_image_set(PointerRNA *ptr, PointerRNA value) +{ + MaterialGPencilStyle *pcolor = (MaterialGPencilStyle *)ptr->data; + ID *id = value.data; - prop = RNA_def_property(srna, "physics", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GEMAT_NOPHYSICS); /* use bitflags */ - RNA_def_property_ui_text(prop, "Physics", "Use physics properties of materials "); + id_us_plus(id); + pcolor->ima = (struct Image *)id; } -static void rna_def_material_colors(StructRNA *srna) +#else + +static void rna_def_material_display(StructRNA *srna) { PropertyRNA *prop; - static const EnumPropertyItem prop_ramp_input_items[] = { - {MA_RAMP_IN_SHADER, "SHADER", 0, "Shader", ""}, - {MA_RAMP_IN_ENERGY, "ENERGY", 0, "Energy", ""}, - {MA_RAMP_IN_NOR, "NORMAL", 0, "Normal", ""}, - {MA_RAMP_IN_RESULT, "RESULT", 0, "Result", ""}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "r"); RNA_def_property_array(prop, 3); @@ -938,82 +364,24 @@ static void rna_def_material_colors(StructRNA *srna) RNA_def_property_ui_text(prop, "Specular Color", "Specular color of the material"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "mirror_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "mirr"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Mirror Color", "Mirror color of the material"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Alpha", "Alpha transparency of the material"); + prop = RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "roughness"); + RNA_def_property_float_default(prop, 0.25f); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_text(prop, "Roughness", "Roughness of the material"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "specular_alpha", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "spectra"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Specular Alpha", "Alpha transparency for specular areas"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - /* Color bands */ - prop = RNA_def_property(srna, "use_diffuse_ramp", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAMP_COL); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_diffuse_ramp_set"); - RNA_def_property_ui_text(prop, "Use Diffuse Ramp", "Toggle diffuse ramp operations"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_ramp", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "ramp_col"); - RNA_def_property_struct_type(prop, "ColorRamp"); - RNA_def_property_ui_text(prop, "Diffuse Ramp", "Color ramp used to affect diffuse shading"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_specular_ramp", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAMP_SPEC); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_specular_ramp_set"); - RNA_def_property_ui_text(prop, "Use Specular Ramp", "Toggle specular ramp operations"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "specular_ramp", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "ramp_spec"); - RNA_def_property_struct_type(prop, "ColorRamp"); - RNA_def_property_ui_text(prop, "Specular Ramp", "Color ramp used to affect specular shading"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_ramp_blend", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "rampblend_col"); - RNA_def_property_enum_items(prop, rna_enum_ramp_blend_items); - RNA_def_property_ui_text(prop, "Diffuse Ramp Blend", "Blending method of the ramp and the diffuse color"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "specular_ramp_blend", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "rampblend_spec"); - RNA_def_property_enum_items(prop, rna_enum_ramp_blend_items); - RNA_def_property_ui_text(prop, "Specular Ramp Blend", "Blending method of the ramp and the specular color"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_ramp_input", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "rampin_col"); - RNA_def_property_enum_items(prop, prop_ramp_input_items); - RNA_def_property_ui_text(prop, "Diffuse Ramp Input", "How the ramp maps on the surface"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "specular_ramp_input", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "rampin_spec"); - RNA_def_property_enum_items(prop, prop_ramp_input_items); - RNA_def_property_ui_text(prop, "Specular Ramp Input", "How the ramp maps on the surface"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_ramp_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "rampfac_col"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Diffuse Ramp Factor", "Blending factor (also uses alpha in Colorband)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "spec"); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_text(prop, "Specular", "How intense (bright) the specular reflection is"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "specular_ramp_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "rampfac_spec"); + prop = RNA_def_property(srna, "metallic", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "metallic"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Specular Ramp Factor", "Blending factor (also uses alpha in Colorband)"); + RNA_def_property_ui_text(prop, "Metallic", "Amount of mirror reflection for raytrace"); RNA_def_property_update(prop, 0, "rna_Material_update"); /* Freestyle line color */ @@ -1031,768 +399,259 @@ static void rna_def_material_colors(StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Material_update"); } -static void rna_def_material_diffuse(StructRNA *srna) -{ - PropertyRNA *prop; - - static const EnumPropertyItem prop_diff_shader_items[] = { - {MA_DIFF_LAMBERT, "LAMBERT", 0, "Lambert", "Use a Lambertian shader"}, - {MA_DIFF_ORENNAYAR, "OREN_NAYAR", 0, "Oren-Nayar", "Use an Oren-Nayar shader"}, - {MA_DIFF_TOON, "TOON", 0, "Toon", "Use a toon shader"}, - {MA_DIFF_MINNAERT, "MINNAERT", 0, "Minnaert", "Use a Minnaert shader"}, - {MA_DIFF_FRESNEL, "FRESNEL", 0, "Fresnel", "Use a Fresnel shader"}, - {0, NULL, 0, NULL, NULL} - }; - - prop = RNA_def_property(srna, "diffuse_shader", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "diff_shader"); - RNA_def_property_enum_items(prop, prop_diff_shader_items); - RNA_def_property_ui_text(prop, "Diffuse Shader Model", ""); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_intensity", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "ref"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Diffuse Intensity", "Amount of diffuse reflection"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - - prop = RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 3.14f); - RNA_def_property_ui_text(prop, "Roughness", "Oren-Nayar Roughness"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_toon_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "param[0]"); - RNA_def_property_range(prop, 0.0f, 3.14f); - RNA_def_property_ui_text(prop, "Diffuse Toon Size", "Size of diffuse toon area"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_toon_smooth", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "param[1]"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Diffuse Toon Smooth", "Smoothness of diffuse toon area"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_fresnel", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "param[1]"); - RNA_def_property_range(prop, 0.0f, 5.0f); - RNA_def_property_ui_text(prop, "Diffuse Fresnel", "Power of Fresnel"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "diffuse_fresnel_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "param[0]"); - RNA_def_property_range(prop, 0.0f, 5.0f); - RNA_def_property_ui_text(prop, "Diffuse Fresnel Factor", "Blending factor of Fresnel"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "darkness", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 2.0f); - RNA_def_property_ui_text(prop, "Darkness", "Minnaert darkness"); - RNA_def_property_update(prop, 0, "rna_Material_update"); -} - -static void rna_def_material_raymirror(BlenderRNA *brna) +static void rna_def_material_greasepencil(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem prop_fadeto_mir_items[] = { - {MA_RAYMIR_FADETOSKY, "FADE_TO_SKY", 0, "Sky", ""}, - {MA_RAYMIR_FADETOMAT, "FADE_TO_MATERIAL", 0, "Material", ""}, - {0, NULL, 0, NULL, NULL} + /* mode type styles */ + static EnumPropertyItem gpcolordata_mode_types_items[] = { + { GP_STYLE_MODE_LINE, "LINE", 0, "Line", "Draw strokes using a continuous line" }, + { GP_STYLE_MODE_DOTS, "DOTS", 0, "Dots", "Draw strokes using separated dots" }, + { GP_STYLE_MODE_BOX, "BOX", 0, "Boxes", "Draw strokes using separated rectangle boxes" }, + { 0, NULL, 0, NULL, NULL } }; - srna = RNA_def_struct(brna, "MaterialRaytraceMirror", NULL); - RNA_def_struct_sdna(srna, "Material"); - RNA_def_struct_nested(brna, srna, "Material"); - RNA_def_struct_ui_text(srna, "Material Raytrace Mirror", "Raytraced reflection settings for a Material data-block"); - - prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAYMIRROR); /* use bitflags */ - RNA_def_property_ui_text(prop, "Enabled", "Enable raytraced reflections"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "reflect_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "ray_mirror"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Reflectivity", "Amount of mirror reflection for raytrace"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "fresnel", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fresnel_mir"); - RNA_def_property_range(prop, 0.0f, 5.0f); - RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for mirror reflection"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "fresnel_mir_i"); - RNA_def_property_range(prop, 0.0f, 5.0f); - RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "gloss_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "gloss_mir"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Gloss Amount", - "The shininess of the reflection (values < 1.0 give diffuse, blurry reflections)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "gloss_anisotropic", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "aniso_gloss_mir"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Gloss Anisotropy", - "The shape of the reflection, from 0.0 (circular) to 1.0 " - "(fully stretched along the tangent"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "gloss_samples", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "samp_gloss_mir"); - RNA_def_property_range(prop, 0, 1024); - RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry reflections"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_mir"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Gloss Threshold", - "Threshold for adaptive sampling (if a sample contributes less than " - "this amount [as a percentage], sampling is stopped)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "ray_depth"); - RNA_def_property_ui_range(prop, 0, 100, 1, 3); - RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-reflections"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "dist_mir"); - RNA_def_property_range(prop, 0.0f, 10000.0f); - RNA_def_property_ui_text(prop, "Maximum Distance", - "Maximum distance of reflected rays (reflections further than this " - "range fade to sky color or material color)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "fade_to", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "fadeto_mir"); - RNA_def_property_enum_items(prop, prop_fadeto_mir_items); - RNA_def_property_ui_text(prop, "Fade-out Color", - "The color that rays with no intersection within the Max Distance take " - "(material color can be best for indoor scenes, sky color for outdoor)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); -} - -static void rna_def_material_raytra(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "MaterialRaytraceTransparency", NULL); - RNA_def_struct_sdna(srna, "Material"); - RNA_def_struct_nested(brna, srna, "Material"); - RNA_def_struct_ui_text(srna, "Material Raytrace Transparency", - "Raytraced refraction settings for a Material data-block"); - - prop = RNA_def_property(srna, "ior", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ang"); - RNA_def_property_range(prop, 0.25f, 4.0f); - RNA_def_property_ui_text(prop, "IOR", "Angular index of refraction for raytraced refraction"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "fresnel", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fresnel_tra"); - RNA_def_property_range(prop, 0.0f, 5.0f); - RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for transparency (Ray or ZTransp)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "fresnel_tra_i"); - RNA_def_property_range(prop, 1.0f, 5.0f); - RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "gloss_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "gloss_tra"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Gloss Amount", - "The clarity of the refraction. Values < 1.0 give diffuse, blurry refractions"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "gloss_samples", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "samp_gloss_tra"); - RNA_def_property_range(prop, 0, 1024); - RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry refractions"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_tra"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Gloss Threshold", - "Threshold for adaptive sampling. If a sample contributes less than " - "this amount (as a percentage), sampling is stopped"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "ray_depth_tra"); - RNA_def_property_ui_range(prop, 0, 100, 1, 3); - RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-refractions"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "filter", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "filter"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Filter", - "Amount to blend in the material's diffuse color in raytraced " - "transparency (simulating absorption)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "depth_max", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "tx_limit"); - RNA_def_property_range(prop, 0.0f, 100.0f); - RNA_def_property_ui_text(prop, "Limit", - "Maximum depth for light to travel through the transparent material " - "before becoming fully filtered (0.0 is disabled)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "tx_falloff"); - RNA_def_property_range(prop, 0.1f, 10.0f); - RNA_def_property_ui_text(prop, "Falloff", "Falloff power for transmissivity filter effect (1.0 is linear)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); -} - -static void rna_def_material_volume(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_lighting_items[] = { - {MA_VOL_SHADE_SHADELESS, "SHADELESS", 0, "Shadeless", "Do not calculate lighting and shadows"}, - {MA_VOL_SHADE_SHADOWED, "SHADOWED", 0, "Shadowed", ""}, - {MA_VOL_SHADE_SHADED, "SHADED", 0, "Shaded", ""}, - {MA_VOL_SHADE_MULTIPLE, "MULTIPLE_SCATTERING", 0, "Multiple Scattering", ""}, - {MA_VOL_SHADE_SHADEDPLUSMULTIPLE, "SHADED_PLUS_MULTIPLE_SCATTERING", 0, "Shaded + Multiple Scattering", ""}, - {0, NULL, 0, NULL, NULL} + /* stroke styles */ + static EnumPropertyItem stroke_style_items[] = { + { GP_STYLE_STROKE_STYLE_SOLID, "SOLID", 0, "Solid", "Draw strokes with solid color" }, + { GP_STYLE_STROKE_STYLE_TEXTURE, "TEXTURE", 0, "Texture", "Draw strokes using texture" }, + { 0, NULL, 0, NULL, NULL } }; - static const EnumPropertyItem prop_stepsize_items[] = { - {MA_VOL_STEP_RANDOMIZED, "RANDOMIZED", 0, "Randomized", ""}, - {MA_VOL_STEP_CONSTANT, "CONSTANT", 0, "Constant", ""}, - /*{MA_VOL_STEP_ADAPTIVE, "ADAPTIVE", 0, "Adaptive", ""}, */ - {0, NULL, 0, NULL, NULL} + /* fill styles */ + static EnumPropertyItem fill_style_items[] = { + { GP_STYLE_FILL_STYLE_SOLID, "SOLID", 0, "Solid", "Fill area with solid color" }, + { GP_STYLE_FILL_STYLE_GRADIENT, "GRADIENT", 0, "Gradient", "Fill area with gradient color" }, + { GP_STYLE_FILL_STYLE_CHESSBOARD, "CHESSBOARD", 0, "Checker Board", "Fill area with chessboard pattern" }, + { GP_STYLE_FILL_STYLE_TEXTURE, "TEXTURE", 0, "Texture", "Fill area with image texture" }, + { 0, NULL, 0, NULL, NULL } }; - srna = RNA_def_struct(brna, "MaterialVolume", NULL); - RNA_def_struct_sdna(srna, "VolumeSettings"); - RNA_def_struct_nested(brna, srna, "Material"); - RNA_def_struct_ui_text(srna, "Material Volume", "Volume rendering settings for a Material data-block"); - - prop = RNA_def_property(srna, "step_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "stepsize_type"); - RNA_def_property_enum_items(prop, prop_stepsize_items); - RNA_def_property_ui_text(prop, "Step Calculation", "Method of calculating the steps through the volume"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "stepsize"); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.001f, 1.0f, 1, 3); - RNA_def_property_ui_text(prop, "Step Size", "Distance between subsequent volume depth samples"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "light_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "shade_type"); - RNA_def_property_enum_items(prop, prop_lighting_items); - RNA_def_property_ui_text(prop, "Lighting Mode", - "Method of shading, attenuating, and scattering light through the volume"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_external_shadows", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shadeflag", MA_VOL_RECV_EXT_SHADOW); /* use bitflags */ - RNA_def_property_ui_text(prop, "External Shadows", "Receive shadows from sources outside the volume (temporary)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_light_cache", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shadeflag", MA_VOL_PRECACHESHADING); /* use bitflags */ - RNA_def_property_ui_text(prop, "Light Cache", - "Pre-calculate the shading information into a voxel grid, " - "speeds up shading at slightly less accuracy"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "cache_resolution", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "precache_resolution"); - RNA_def_property_range(prop, 1, 1024); - RNA_def_property_ui_text(prop, "Resolution", - "Resolution of the voxel grid, low resolutions are faster, " - "high resolutions use more memory"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "ms_diffusion", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ms_diff"); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_text(prop, "Diffusion", "Diffusion factor, the strength of the blurring effect"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + static EnumPropertyItem fill_gradient_items[] = { + { GP_STYLE_GRADIENT_LINEAR, "LINEAR", 0, "Linear", "Fill area with gradient color" }, + { GP_STYLE_GRADIENT_RADIAL, "RADIAL", 0, "Radial", "Fill area with radial gradient" }, + { 0, NULL, 0, NULL, NULL } + }; - prop = RNA_def_property(srna, "ms_spread", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ms_spread"); - RNA_def_property_range(prop, 0, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3); - RNA_def_property_ui_text(prop, "Spread", "Proportional distance over which the light is diffused"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + srna = RNA_def_struct(brna, "MaterialGPencilStyle", NULL); + RNA_def_struct_sdna(srna, "MaterialGPencilStyle"); + RNA_def_struct_ui_text(srna, "Grease Pencil Color", ""); + RNA_def_struct_path_func(srna, "rna_GpencilColorData_path"); - prop = RNA_def_property(srna, "ms_intensity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ms_intensity"); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_text(prop, "Intensity", "Multiplier for multiple scattered light energy"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_float_sdna(prop, NULL, "stroke_rgba"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Color", ""); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); - prop = RNA_def_property(srna, "depth_threshold", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "depth_cutoff"); + /* Fill Drawing Color */ + prop = RNA_def_property(srna, "fill_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "fill_rgba"); + RNA_def_property_array(prop, 4); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Depth Cutoff", - "Stop ray marching early if transmission drops below this luminance - " - "higher values give speedups in dense volumes at the expense of accuracy"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region bounded by each stroke"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); - prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "density"); + /* Secondary Drawing Color */ + prop = RNA_def_property(srna, "mix_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "mix_rgba"); + RNA_def_property_array(prop, 4); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Density", "The base density of the volume"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "density_scale", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "density_scale"); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); - RNA_def_property_ui_text(prop, "Density Scale", "Multiplier for the material's density"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "scattering", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "scattering"); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); - RNA_def_property_ui_text(prop, "Scattering", - "Amount of light that gets scattered out by the volume - " - "the more out-scattering, the shallower the light will penetrate"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "transmission_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "transmission_col"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Transmission Color", - "Result color of the volume, after other light has been scattered/absorbed"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - - prop = RNA_def_property(srna, "reflection_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "reflection_col"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Reflection Color", - "Color of light scattered out of the volume (does not affect transmission)"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - - prop = RNA_def_property(srna, "reflection", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "reflection"); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3); - RNA_def_property_ui_text(prop, "Reflection", - "Multiplier to make out-scattered light brighter or darker (non-physically correct)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "emission_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "emission_col"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Emission Color", "Color of emitted light"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - - prop = RNA_def_property(srna, "emission", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "emission"); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); - RNA_def_property_ui_text(prop, "Emission", "Amount of light that gets emitted by the volume"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + RNA_def_property_ui_text(prop, "Mix Color", "Color for mixing with primary filling color"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); - prop = RNA_def_property(srna, "asymmetry", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "asymmetry"); - RNA_def_property_range(prop, -1.0f, 1.0f); - RNA_def_property_ui_text(prop, "Asymmetry", - "Back scattering (-1.0) to Forward scattering (1.0) and the range in between"); - RNA_def_property_update(prop, 0, "rna_Material_update"); -} - - -static void rna_def_material_halo(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "MaterialHalo", NULL); - RNA_def_struct_sdna(srna, "Material"); - RNA_def_struct_nested(brna, srna, "Material"); - RNA_def_struct_ui_text(srna, "Material Halo", "Halo particle effect settings for a Material data-block"); - - prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "hasize"); - RNA_def_property_range(prop, 0.0f, 100.0f); - RNA_def_property_ui_text(prop, "Size", "Dimension of the halo"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "hardness", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "har"); - RNA_def_property_range(prop, 0, 127); - RNA_def_property_ui_text(prop, "Hardness", "Hardness of the halo"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "add", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "add"); + /* Mix factor */ + prop = RNA_def_property(srna, "mix_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "mix_factor"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Add", "Strength of the add effect"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "ring_count", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "ringc"); - RNA_def_property_range(prop, 0, 24); - RNA_def_property_ui_text(prop, "Rings", "Number of rings rendered over the halo"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "line_count", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "linec"); - RNA_def_property_range(prop, 0, 250); - RNA_def_property_ui_text(prop, "Line Number", "Number of star shaped lines rendered over the halo"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "star_tip_count", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "starc"); - RNA_def_property_range(prop, 3, 50); - RNA_def_property_ui_text(prop, "Star Tips", "Number of points on the star shaped halo"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "seed1"); - RNA_def_property_range(prop, 0, 255); - RNA_def_property_ui_text(prop, "Seed", "Randomize ring dimension and line location"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_flare_mode", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_FLARE); /* use bitflags */ - RNA_def_property_ui_text(prop, "Flare", "Render halo as a lens flare"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "flare_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "flaresize"); - RNA_def_property_range(prop, 0.1f, 25.0f); - RNA_def_property_ui_text(prop, "Flare Size", "Factor by which the flare is larger than the halo"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "flare_subflare_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "subsize"); - RNA_def_property_range(prop, 0.1f, 25.0f); - RNA_def_property_ui_text(prop, "Flare Subsize", "Dimension of the sub-flares, dots and circles"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "flare_boost", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "flareboost"); - RNA_def_property_range(prop, 0.1f, 10.0f); - RNA_def_property_ui_text(prop, "Flare Boost", "Give the flare extra strength"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "flare_seed", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "seed2"); - RNA_def_property_range(prop, 0, 255); - RNA_def_property_ui_text(prop, "Flare Seed", "Offset in the flare seed table"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "flare_subflare_count", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "flarec"); - RNA_def_property_range(prop, 1, 32); - RNA_def_property_ui_text(prop, "Flares Sub", "Number of sub-flares"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_ring", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_RINGS); - RNA_def_property_ui_text(prop, "Rings", "Render rings over halo"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_lines", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_LINES); - RNA_def_property_ui_text(prop, "Lines", "Render star shaped lines over halo"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_star", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STAR); - RNA_def_property_ui_text(prop, "Star", "Render halo as a star"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALOTEX); - RNA_def_property_ui_text(prop, "Texture", "Give halo a texture"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_vertex_normal", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALOPUNO); - RNA_def_property_ui_text(prop, "Vertex Normal", "Use the vertex normal to specify the dimension of the halo"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_extreme_alpha", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_XALPHA); - RNA_def_property_ui_text(prop, "Extreme Alpha", "Use extreme alpha"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_shaded", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_SHADE); - RNA_def_property_ui_text(prop, "Shaded", "Let halo receive light and shadows from external objects"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_soft", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_SOFT); - RNA_def_property_ui_text(prop, "Soft", "Soften the edges of halos at intersections with other geometry"); - RNA_def_property_update(prop, 0, "rna_Material_update"); -} - -static void rna_def_material_sss(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "MaterialSubsurfaceScattering", NULL); - RNA_def_struct_sdna(srna, "Material"); - RNA_def_struct_nested(brna, srna, "Material"); - RNA_def_struct_ui_text(srna, "Material Subsurface Scattering", - "Diffuse subsurface scattering settings for a Material data-block"); - - prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_COLOR | PROP_UNIT_LENGTH); - RNA_def_property_float_sdna(prop, NULL, "sss_radius"); - RNA_def_property_range(prop, 0.001, FLT_MAX); - RNA_def_property_ui_range(prop, 0.001, 10000, 1, 3); - RNA_def_property_ui_text(prop, "Radius", "Mean red/green/blue scattering path length"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "sss_col"); - RNA_def_property_ui_text(prop, "Color", "Scattering color"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "error_threshold", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sss_error"); - RNA_def_property_ui_range(prop, 0.0001, 10, 1, 3); - RNA_def_property_ui_text(prop, "Error Tolerance", "Error tolerance (low values are slower and higher quality)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sss_scale"); - RNA_def_property_ui_range(prop, 0.001, 1000, 1, 3); - RNA_def_property_ui_text(prop, "Scale", "Object scale factor"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "ior", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sss_ior"); - RNA_def_property_ui_range(prop, 0.1, 2, 1, 3); - RNA_def_property_ui_text(prop, "IOR", "Index of refraction (higher values are denser)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "sss_colfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Color Factor", "Blend factor for SSS colors"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "texture_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "sss_texfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Texture Factor", "Texture scattering blend factor"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "front", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sss_front"); - RNA_def_property_range(prop, 0, 2); - RNA_def_property_ui_text(prop, "Front", "Front scattering weight"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sss_back"); - RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Back", "Back scattering weight"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "sss_flag", MA_DIFF_SSS); - RNA_def_property_ui_text(prop, "Enabled", "Enable diffuse subsurface scattering effects in a material"); - RNA_def_property_update(prop, 0, "rna_Material_update"); -} - -static void rna_def_material_specularity(StructRNA *srna) -{ - PropertyRNA *prop; - - static const EnumPropertyItem prop_specular_shader_items[] = { - {MA_SPEC_COOKTORR, "COOKTORR", 0, "CookTorr", "Use a Cook-Torrance shader"}, - {MA_SPEC_PHONG, "PHONG", 0, "Phong", "Use a Phong shader"}, - {MA_SPEC_BLINN, "BLINN", 0, "Blinn", "Use a Blinn shader"}, - {MA_SPEC_TOON, "TOON", 0, "Toon", "Use a toon shader"}, - {MA_SPEC_WARDISO, "WARDISO", 0, "WardIso", "Use a Ward anisotropic shader"}, - {0, NULL, 0, NULL, NULL} - }; - - prop = RNA_def_property(srna, "specular_shader", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "spec_shader"); - RNA_def_property_enum_items(prop, prop_specular_shader_items); - RNA_def_property_ui_text(prop, "Specular Shader Model", ""); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "spec"); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Specular Intensity", "How intense (bright) the specular reflection is"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - - /* NOTE: "har", "param", etc are used for multiple purposes depending on - * settings. This should be fixed in DNA once, for RNA we just expose them - * multiple times, which may give somewhat strange changes in the outliner, - * but in the UI they are never visible at the same time. */ - - prop = RNA_def_property(srna, "specular_hardness", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "har"); - RNA_def_property_range(prop, 1, 511); - RNA_def_property_ui_text(prop, "Specular Hardness", "How hard (sharp) the specular reflection is"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - - prop = RNA_def_property(srna, "specular_ior", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "refrac"); - RNA_def_property_range(prop, 1, 10); - RNA_def_property_ui_text(prop, "Specular IOR", "Specular index of refraction"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "specular_toon_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "param[2]"); - RNA_def_property_range(prop, 0.0f, 1.53f); - RNA_def_property_ui_text(prop, "Specular Toon Size", "Size of specular toon area"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "specular_toon_smooth", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "param[3]"); + RNA_def_property_ui_text(prop, "Mix", "Mix Adjustment Factor"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* Scale factor for uv coordinates */ + prop = RNA_def_property(srna, "pattern_scale", PROP_FLOAT, PROP_COORDS); + RNA_def_property_float_sdna(prop, NULL, "gradient_scale"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Scale", "Scale Factor for UV coordinates"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* Shift factor to move pattern filling in 2d space */ + prop = RNA_def_property(srna, "pattern_shift", PROP_FLOAT, PROP_COORDS); + RNA_def_property_float_sdna(prop, NULL, "gradient_shift"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Shift", "Shift filling pattern in 2d space"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* Gradient angle */ + prop = RNA_def_property(srna, "pattern_angle", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "gradient_angle"); + RNA_def_property_ui_text(prop, "Angle", "Pattern Orientation Angle"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* Gradient radius */ + prop = RNA_def_property(srna, "pattern_radius", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "gradient_radius"); + RNA_def_property_range(prop, 0.0001f, 10.0f); + RNA_def_property_ui_text(prop, "Radius", "Pattern Radius"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* Box size */ + prop = RNA_def_property(srna, "pattern_gridsize", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pattern_gridsize"); + RNA_def_property_range(prop, 0.0001f, 10.0f); + RNA_def_property_ui_text(prop, "Size", "Box Size"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* Texture angle */ + prop = RNA_def_property(srna, "texture_angle", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "texture_angle"); + RNA_def_property_ui_text(prop, "Angle", "Texture Orientation Angle"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* Scale factor for texture */ + prop = RNA_def_property(srna, "texture_scale", PROP_FLOAT, PROP_COORDS); + RNA_def_property_float_sdna(prop, NULL, "texture_scale"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Scale", "Scale Factor for Texture"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* Shift factor to move texture in 2d space */ + prop = RNA_def_property(srna, "texture_offset", PROP_FLOAT, PROP_COORDS); + RNA_def_property_float_sdna(prop, NULL, "texture_offset"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Offset", "Shift Texture in 2d Space"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* Texture opacity size */ + prop = RNA_def_property(srna, "texture_opacity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "texture_opacity"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Specular Toon Smooth", "Smoothness of specular toon area"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "specular_slope", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "rms"); - RNA_def_property_range(prop, 0, 0.4); - RNA_def_property_ui_text(prop, "Specular Slope", "The standard deviation of surface slope"); - RNA_def_property_update(prop, 0, "rna_Material_update"); -} - -static void rna_def_material_strand(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "MaterialStrand", NULL); - RNA_def_struct_sdna(srna, "Material"); - RNA_def_struct_nested(brna, srna, "Material"); - RNA_def_struct_ui_text(srna, "Material Strand", "Strand settings for a Material data-block"); + RNA_def_property_ui_text(prop, "Opacity", "Texture Opacity"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* texture pixsize factor (used for UV along the stroke) */ + prop = RNA_def_property(srna, "pixel_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "texture_pixsize"); + RNA_def_property_range(prop, 1, 5000); + RNA_def_property_ui_text(prop, "UV Factor", "Texture Pixel Size factor along the stroke"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_gpcolordata_uv_update"); + + /* Flags */ + prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_COLOR_HIDE); + RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1); + RNA_def_property_ui_text(prop, "Hide", "Set color Visibility"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_nopreview_update"); + + prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_COLOR_LOCKED); + RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); + RNA_def_property_ui_text(prop, "Locked", "Protect color from further editing and/or frame changes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_nopreview_update"); + + prop = RNA_def_property(srna, "ghost", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_COLOR_ONIONSKIN); + RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0); + RNA_def_property_ui_text(prop, "Show in Ghosts", "Display strokes using this color when showing onion skins"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_nopreview_update"); + + prop = RNA_def_property(srna, "texture_clamp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_COLOR_TEX_CLAMP); + RNA_def_property_ui_text(prop, "Clamp", "Do not repeat texture and clamp to one instance only"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + prop = RNA_def_property(srna, "texture_mix", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_COLOR_TEX_MIX); + RNA_def_property_ui_text(prop, "Mix Texture", "Mix texture image with filling colors"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + prop = RNA_def_property(srna, "flip", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_COLOR_FLIP_FILL); + RNA_def_property_ui_text(prop, "Flip", "Flip filling colors"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + prop = RNA_def_property(srna, "use_stroke_pattern", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_STROKE_PATTERN); + RNA_def_property_ui_text(prop, "Pattern", "Use Stroke Texture as a pattern to apply color"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + prop = RNA_def_property(srna, "use_fill_pattern", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_FILL_PATTERN); + RNA_def_property_ui_text(prop, "Pattern", "Use Fill Texture as a pattern to apply color"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + prop = RNA_def_property(srna, "show_stroke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_STROKE_SHOW); + RNA_def_property_ui_text(prop, "Show Stroke", "Show stroke lines of this material"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + prop = RNA_def_property(srna, "show_fill", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_FILL_SHOW); + RNA_def_property_ui_text(prop, "Show Fill", "Show stroke fills of this material"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* pass index for future compositing and editing tools */ + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "index"); + RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Color Index\" pass"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_nopreview_update"); - prop = RNA_def_property(srna, "use_tangent_shading", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_STR); - RNA_def_property_ui_text(prop, "Tangent Shading", "Use direction of strands as normal for tangent-shading"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + /* mode type */ + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, gpcolordata_mode_types_items); + RNA_def_property_ui_text(prop, "Mode Type", "Select draw mode for stroke"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* stroke style */ + prop = RNA_def_property(srna, "stroke_style", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "stroke_style"); + RNA_def_property_enum_items(prop, stroke_style_items); + RNA_def_property_ui_text(prop, "Stroke Style", "Select style used to draw strokes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* stroke image texture */ + prop = RNA_def_property(srna, "stroke_image", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "sima"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_GpencilColorData_stroke_image_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Image", ""); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* fill style */ + prop = RNA_def_property(srna, "fill_style", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "fill_style"); + RNA_def_property_enum_items(prop, fill_style_items); + RNA_def_property_ui_text(prop, "Fill Style", "Select style used to fill strokes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* gradient type */ + prop = RNA_def_property(srna, "gradient_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "gradient_type"); + RNA_def_property_enum_items(prop, fill_gradient_items); + RNA_def_property_ui_text(prop, "Gradient Type", "Select type of gradient used to fill strokes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + + /* fill image texture */ + prop = RNA_def_property(srna, "fill_image", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "ima"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_GpencilColorData_fill_image_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Image", ""); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); - /* this flag is only set when rendering, not to be edited manually */ - prop = RNA_def_property(srna, "use_surface_diffuse", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_SURFDIFF); + /* Read-only state props (for simpler UI code) */ + prop = RNA_def_property(srna, "is_stroke_visible", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_GpencilColorData_is_stroke_visible_get", NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Surface Diffuse", "Make diffuse shading more similar to shading the surface"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "blend_distance", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "strand_surfnor"); - RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Blend Distance", "Worldspace distance over which to blend in the surface normal"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_blender_units", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_B_UNITS); - RNA_def_property_ui_text(prop, "Blender Units", "Use Blender units for widths instead of pixels"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "root_size", PROP_FLOAT, PROP_UNSIGNED); - RNA_def_property_float_sdna(prop, NULL, "strand_sta"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_start_size_range"); - RNA_def_property_ui_range(prop, 0, 10.0f, 10, 5); - RNA_def_property_ui_text(prop, "Root Size", "Start size of strands in pixels or Blender units"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "tip_size", PROP_FLOAT, PROP_UNSIGNED); - RNA_def_property_float_sdna(prop, NULL, "strand_end"); - RNA_def_property_ui_range(prop, 0, 10.0f, 10, 5); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_end_size_range"); - RNA_def_property_ui_text(prop, "Tip Size", "End size of strands in pixels or Blender units"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "size_min", PROP_FLOAT, PROP_UNSIGNED); - RNA_def_property_float_sdna(prop, NULL, "strand_min"); - RNA_def_property_range(prop, 0.001, 10); - RNA_def_property_ui_text(prop, "Minimum Size", "Minimum size of strands in pixels"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "shape", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "strand_ease"); - RNA_def_property_range(prop, -0.9, 0.9); - RNA_def_property_ui_text(prop, "Shape", "Positive values make strands rounder, negative ones make strands spiky"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "width_fade", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "strand_widthfade"); - RNA_def_property_range(prop, 0, 2); - RNA_def_property_ui_text(prop, "Width Fade", "Transparency along the width of the strand"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "strand_uvname"); - RNA_def_property_ui_text(prop, "UV Map", "Name of UV map to override"); - RNA_def_property_update(prop, 0, "rna_Material_update"); -} + RNA_def_property_ui_text(prop, "Is Stroke Visible", "True when opacity of stroke is set high enough to be visible"); -static void rna_def_material_physics(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "MaterialPhysics", NULL); - RNA_def_struct_sdna(srna, "Material"); - RNA_def_struct_nested(brna, srna, "Material"); - RNA_def_struct_ui_text(srna, "Material Physics", "Physics settings for a Material data-block"); - - prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "friction"); - RNA_def_property_range(prop, 0, 100); - RNA_def_property_ui_text(prop, "Friction", "Coulomb friction coefficient, when inside the physics distance area"); - - prop = RNA_def_property(srna, "elasticity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "reflect"); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Elasticity", "Elasticity of collisions"); - - /* FH/Force Field Settings */ - prop = RNA_def_property(srna, "use_fh_normal", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "dynamode", MA_FH_NOR); - RNA_def_property_ui_text(prop, "Align to Normal", - "Align dynamic game objects along the surface normal, " - "when inside the physics distance area"); - - prop = RNA_def_property(srna, "fh_force", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fh"); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 2); - RNA_def_property_ui_text(prop, "Force", "Upward spring force, when inside the physics distance area"); - - prop = RNA_def_property(srna, "fh_distance", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fhdist"); - RNA_def_property_range(prop, 0, 20); - RNA_def_property_ui_text(prop, "Distance", "Distance of the physics area"); + prop = RNA_def_property(srna, "is_fill_visible", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_GpencilColorData_is_fill_visible_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Is Fill Visible", "True when opacity of fill is set high enough to be visible"); - prop = RNA_def_property(srna, "fh_damping", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "xyfrict"); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Damping", "Damping of the spring force, when inside the physics distance area"); } void RNA_def_material(BlenderRNA *brna) @@ -1800,20 +659,6 @@ void RNA_def_material(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem prop_type_items[] = { - {MA_TYPE_SURFACE, "SURFACE", 0, "Surface", "Render object as a surface"}, - {MA_TYPE_WIRE, "WIRE", 0, "Wire", "Render the edges of faces as wires (not supported in raytracing)"}, - {MA_TYPE_VOLUME, "VOLUME", 0, "Volume", "Render object as a volume"}, - {MA_TYPE_HALO, "HALO", 0, "Halo", "Render object as halo particles"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem transparency_items[] = { - {0, "MASK", 0, "Mask", "Mask the background"}, - {MA_ZTRANSP, "Z_TRANSPARENCY", 0, "Z Transparency", "Use alpha buffer for transparent faces"}, - {MA_RAYTRANSP, "RAYTRACE", 0, "Raytrace", "Use raytracing for transparent refraction rendering"}, - {0, NULL, 0, NULL, NULL} - }; - /* Render Preview Types */ static const EnumPropertyItem preview_type_items[] = { {MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Flat XY plane"}, @@ -1825,11 +670,21 @@ void RNA_def_material(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem prop_shadows_only_items[] = { - {MA_SO_OLD, "SHADOW_ONLY_OLD", 0, "Shadow and Distance", "Old shadow only method"}, - {MA_SO_SHADOW, "SHADOW_ONLY", 0, "Shadow Only", "Improved shadow only method"}, - {MA_SO_SHADED, "SHADOW_ONLY_SHADED", 0, "Shadow and Shading", - "Improved shadow only method which also renders lightless areas as shadows"}, + static EnumPropertyItem prop_eevee_blend_items[] = { + {MA_BM_SOLID, "OPAQUE", 0, "Opaque", "Render surface without transparency"}, + {MA_BM_ADD, "ADD", 0, "Additive", "Render surface and blend the result with additive blending"}, + {MA_BM_MULTIPLY, "MULTIPLY", 0, "Multiply", "Render surface and blend the result with multiplicative blending"}, + {MA_BM_CLIP, "CLIP", 0, "Alpha Clip", "Use the alpha threshold to clip the visibility (binary visibility)"}, + {MA_BM_HASHED, "HASHED", 0, "Alpha Hashed", "Use noise to dither the binary visibility (works well with multi-samples)"}, + {MA_BM_BLEND, "BLEND", 0, "Alpha Blend", "Render polygon transparent, depending on alpha channel of the texture"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem prop_eevee_blend_shadow_items[] = { + {MA_BS_NONE, "NONE", 0, "None", "Material will cast no shadow"}, + {MA_BS_SOLID, "OPAQUE", 0, "Opaque", "Material will cast shadows without transparency"}, + {MA_BS_CLIP, "CLIP", 0, "Clip", "Use the alpha threshold to clip the visibility (binary visibility)"}, + {MA_BS_HASHED, "HASHED", 0, "Hashed", "Use noise to dither the binary visibility and use filtering to reduce the noise"}, {0, NULL, 0, NULL, NULL} }; @@ -1838,284 +693,58 @@ void RNA_def_material(BlenderRNA *brna) "Material data-block to define the appearance of geometric objects for rendering"); RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA); - prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "material_type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Type", "Material type defining how the object is rendered"); - RNA_def_property_enum_funcs(prop, NULL, "rna_Material_type_set", NULL); + /* Blending (only Eevee for now) */ + prop = RNA_def_property(srna, "blend_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_eevee_blend_items); + RNA_def_property_ui_text(prop, "Blend Mode", "Blend Mode for Transparent Faces"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "use_transparency", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRANSP); - RNA_def_property_ui_text(prop, "Transparency", "Render material as transparent"); + prop = RNA_def_property(srna, "transparent_shadow_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "blend_shadow"); + RNA_def_property_enum_items(prop, prop_eevee_blend_shadow_items); + RNA_def_property_ui_text(prop, "Transparent Shadow", "Shadow method for transparent material"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "transparency_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, transparency_items); - RNA_def_property_ui_text(prop, "Transparency Method", "Method to use for rendering transparency"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - /* For Preview Render */ - prop = RNA_def_property(srna, "preview_render_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "pr_type"); - RNA_def_property_enum_items(prop, preview_type_items); - RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render"); - RNA_def_property_update(prop, 0, "rna_Material_update_previews"); - - prop = RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "amb"); + prop = RNA_def_property(srna, "alpha_threshold", PROP_FLOAT, PROP_FACTOR); RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Ambient", "Amount of global ambient color the material receives"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "emit", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0, FLT_MAX); - RNA_def_property_ui_range(prop, 0, 2.0f, 1, 2); - RNA_def_property_ui_text(prop, "Emit", "Amount of light to emit"); + RNA_def_property_ui_text(prop, "Clip Threshold", "A pixel is rendered only if its alpha value is above this threshold"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "translucency", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Translucency", "Amount of diffuse shading on the back side"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "show_transparent_backside", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "blend_flag", MA_BL_HIDE_BACKSIDE); + RNA_def_property_ui_text(prop, "Show Backside", "Limit transparency to a single layer " + "(avoids transparency sorting problems)"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "use_cubic", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_CUBIC); - RNA_def_property_ui_text(prop, "Cubic Interpolation", - "Use cubic interpolation for diffuse values, for smoother transitions"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "use_screen_refraction", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "blend_flag", MA_BL_SS_REFRACTION); + RNA_def_property_ui_text(prop, "Screen Space Refraction", "Use raytraced screen space refractions"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "use_object_color", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_OBCOLOR); - RNA_def_property_ui_text(prop, "Object Color", "Modulate the result with a per-object color"); + prop = RNA_def_property(srna, "use_sss_translucency", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "blend_flag", MA_BL_TRANSLUCENCY); + RNA_def_property_ui_text(prop, "Subsurface Translucency", "Add translucency effect to subsurface"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "shadow_ray_bias", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sbias"); - RNA_def_property_range(prop, 0, 0.25); - RNA_def_property_ui_text(prop, "Shadow Ray Bias", - "Shadow raytracing bias to prevent terminator problems on shadow boundary"); - - prop = RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "lbias"); - RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Factor to multiply shadow buffer bias with (0 is ignore)"); - - prop = RNA_def_property(srna, "shadow_cast_alpha", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "shad_alpha"); - RNA_def_property_range(prop, 0.001, 1); - RNA_def_property_ui_text(prop, "Shadow Casting Alpha", - "Shadow casting alpha, in use for Irregular and Deep shadow buffer"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "refraction_depth", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "refract_depth"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_text(prop, "Refraction Depth", "Approximate the thickness of the object to compute two refraction " + "event (0 is disabled)"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "light_group", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "group"); - RNA_def_property_struct_type(prop, "Group"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Light Group", "Limit lighting to lamps in this Group"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + /* For Preview Render */ + prop = RNA_def_property(srna, "preview_render_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "pr_type"); + RNA_def_property_enum_items(prop, preview_type_items); + RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render"); + RNA_def_property_update(prop, 0, "rna_Material_update_previews"); prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "index"); RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Material Index\" render pass"); RNA_def_property_update(prop, NC_OBJECT, "rna_Material_update"); - /* flags */ - - prop = RNA_def_property(srna, "use_light_group_exclusive", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_GROUP_NOLAY); - RNA_def_property_ui_text(prop, "Light Group Exclusive", - "Material uses the light group exclusively - these lamps are excluded " - "from other scene lighting"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_light_group_local", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_GROUP_LOCAL); - RNA_def_property_ui_text(prop, "Light Group Local", "When linked in, material uses local light group with the same name"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRACEBLE); - RNA_def_property_ui_text(prop, "Traceable", - "Include this material and geometry that uses it in raytracing calculations"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_shadows", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADOW); - RNA_def_property_ui_text(prop, "Shadows", "Allow this material to receive shadows"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_shadeless", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHLESS); - RNA_def_property_ui_text(prop, "Shadeless", "Make this material insensitive to light or shadow"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - - prop = RNA_def_property(srna, "use_vertex_color_light", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_VERTEXCOL); - RNA_def_property_ui_text(prop, "Vertex Color Light", "Add vertex colors as additional lighting"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_vertex_color_paint", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_VERTEXCOLP); - RNA_def_property_ui_text(prop, "Vertex Color Paint", - "Replace object base color with vertex colors (multiply with " - "'texture face' face assigned textures)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "invert_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ZINV); - RNA_def_property_ui_text(prop, "Invert Z Depth", - "Render material's faces with an inverted Z buffer (scanline only)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "offset_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "zoffs"); - RNA_def_property_ui_text(prop, "Z Offset", "Give faces an artificial offset in the Z buffer for Z transparency"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_sky", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ENV); - RNA_def_property_ui_text(prop, "Sky", - "Render this material with zero alpha, with sky background in place (scanline only)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_only_shadow", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ONLYSHADOW); - RNA_def_property_ui_text(prop, "Only Shadow", - "Render shadows as the material's alpha value, making the material " - "transparent except for shadowed areas"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "shadow_only_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "shadowonly_flag"); - RNA_def_property_enum_items(prop, prop_shadows_only_items); - RNA_def_property_ui_text(prop, "Shadow Type", "How to draw shadows"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_face_texture", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FACETEXTURE); - RNA_def_property_ui_text(prop, "Face Textures", - "Replace the object's base color with color from UV map image textures"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_face_texture_alpha", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FACETEXTURE_ALPHA); - RNA_def_property_ui_text(prop, "Face Textures Alpha", - "Replace the object's base alpha value with alpha from UV map image textures"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_cast_shadows", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode2", MA_CASTSHADOW); - RNA_def_property_ui_text(prop, "Cast Shadows", - "Allow this material to cast shadows"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_cast_shadows_only", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ONLYCAST); - RNA_def_property_ui_text(prop, "Cast Shadows Only", - "Make objects with this material appear invisible (not rendered), only casting shadows"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_mist", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", MA_NOMIST); - RNA_def_property_ui_text(prop, "Use Mist", "Use mist with this material (in world settings)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_transparent_shadows", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADOW_TRA); - RNA_def_property_ui_text(prop, "Receive Transparent Shadows", - "Allow this object to receive transparent shadows cast through other objects"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_ray_shadow_bias", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAYBIAS); - RNA_def_property_ui_text(prop, "Ray Shadow Bias", - "Prevent raytraced shadow errors on surfaces with smooth shaded normals " - "(terminator problem)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_full_oversampling", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FULL_OSA); - RNA_def_property_ui_text(prop, "Full Oversampling", - "Force this material to render full shading/textures for all anti-aliasing samples"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_cast_buffer_shadows", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADBUF); - RNA_def_property_ui_text(prop, "Cast Buffer Shadows", - "Allow this material to cast shadows from shadow buffer lamps"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_cast_approximate", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_APPROX_OCCLUSION); - RNA_def_property_ui_text(prop, "Cast Approximate", - "Allow this material to cast shadows when using approximate ambient occlusion"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_tangent_shading", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_V); - RNA_def_property_ui_text(prop, "Tangent Shading", - "Use the material's tangent vector instead of the normal for shading " - "- for anisotropic shading effects"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - prop = RNA_def_property(srna, "use_uv_project", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapflag", MA_MAPFLAG_UVPROJECT); - RNA_def_property_ui_text(prop, "UV Project", - "Use to ensure UV interpolation is correct for camera projections (use with UV project modifier)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); - - /* nested structs */ - prop = RNA_def_property(srna, "raytrace_mirror", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "MaterialRaytraceMirror"); - RNA_def_property_pointer_funcs(prop, "rna_Material_mirror_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Raytrace Mirror", "Raytraced reflection settings for the material"); - - prop = RNA_def_property(srna, "raytrace_transparency", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "MaterialRaytraceTransparency"); - RNA_def_property_pointer_funcs(prop, "rna_Material_transp_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Raytrace Transparency", "Raytraced transparency settings for the material"); - - prop = RNA_def_property(srna, "volume", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "vol"); - RNA_def_property_struct_type(prop, "MaterialVolume"); - RNA_def_property_ui_text(prop, "Volume", "Volume settings for the material"); - - prop = RNA_def_property(srna, "halo", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "MaterialHalo"); - RNA_def_property_pointer_funcs(prop, "rna_Material_halo_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Halo", "Halo settings for the material"); - - prop = RNA_def_property(srna, "subsurface_scattering", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "MaterialSubsurfaceScattering"); - RNA_def_property_pointer_funcs(prop, "rna_Material_sss_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Subsurface Scattering", "Subsurface scattering settings for the material"); - - prop = RNA_def_property(srna, "strand", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "MaterialStrand"); - RNA_def_property_pointer_funcs(prop, "rna_Material_strand_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Strand", "Strand settings for the material"); - - prop = RNA_def_property(srna, "physics", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "MaterialPhysics"); - RNA_def_property_pointer_funcs(prop, "rna_Material_physics_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Physics", "Game physics settings"); - - /* game settings */ - prop = RNA_def_property(srna, "game_settings", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "game"); - RNA_def_property_struct_type(prop, "MaterialGameSettings"); - RNA_def_property_ui_text(prop, "Game Settings", "Game material settings"); - /* nodetree */ prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); @@ -2128,43 +757,24 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material"); RNA_def_property_update(prop, 0, "rna_Material_use_nodes_update"); - prop = RNA_def_property(srna, "active_node_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_Material_active_node_material_get", - "rna_Material_active_node_material_set", NULL, NULL); - RNA_def_property_ui_text(prop, "Material", "Active node material"); - RNA_def_property_update(prop, NC_MATERIAL, NULL); - /* common */ rna_def_animdata_common(srna); - rna_def_mtex_common(brna, srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get", - "rna_Material_active_texture_set", "rna_Material_active_texture_editable", - "MaterialTextureSlot", "MaterialTextureSlots", "rna_Material_update", "rna_Material_update"); - rna_def_texpaint_slots(brna, srna); - /* only material has this one */ - prop = RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "septex", 1); - RNA_def_property_array(prop, 18); - RNA_def_property_ui_text(prop, "Use Textures", "Enable/Disable each texture"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + rna_def_material_display(srna); + + /* grease pencil */ + prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "gp_style"); + RNA_def_property_ui_text(prop, "Grease Pencil Settings", "Grease pencil color settings for material"); + + prop = RNA_def_property(srna, "is_grease_pencil", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_is_grease_pencil_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Is Grease Pencil", "True if this material has grease pencil data"); + + rna_def_material_greasepencil(brna); - rna_def_material_colors(srna); - rna_def_material_diffuse(srna); - rna_def_material_specularity(srna); - - /* nested structs */ - rna_def_material_raymirror(brna); - rna_def_material_raytra(brna); - rna_def_material_volume(brna); - rna_def_material_halo(brna); - rna_def_material_sss(brna); - rna_def_material_mtex(brna); - rna_def_material_strand(brna); - rna_def_material_physics(brna); - rna_def_material_gamesettings(brna); RNA_api_material(srna); } @@ -2249,9 +859,10 @@ static void rna_def_tex_slot(BlenderRNA *brna) RNA_def_property_ui_text(prop, "UV Map", "Name of UV map"); RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Material_update"); - prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "valid", 1); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Index", "Index of MTex slot in the material"); + RNA_def_property_ui_text(prop, "Valid", "Slot has a valid image and UV map"); } diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index c97cf2923f2..40690731b76 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -68,11 +68,13 @@ const EnumPropertyItem rna_enum_mesh_delimit_mode_items[] = { #include "BLI_math.h" #include "BKE_customdata.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_report.h" +#include "DEG_depsgraph.h" + #include "ED_mesh.h" /* XXX Bad level call */ #include "WM_api.h" @@ -138,12 +140,6 @@ static CustomData *rna_mesh_ldata(PointerRNA *ptr) return rna_mesh_ldata_helper(me); } -static CustomData *rna_mesh_fdata(PointerRNA *ptr) -{ - Mesh *me = rna_mesh(ptr); - return rna_mesh_fdata_helper(me); -} - /* -------------------------------------------------------------------- */ /* Generic CustomData Layer Functions */ @@ -186,22 +182,14 @@ static void rna_MeshEdgeLayer_name_set(PointerRNA *ptr, const char *value) rna_cd_layer_name_set(rna_mesh_edata(ptr), (CustomDataLayer *)ptr->data, value); } #endif -#if 0 static void rna_MeshPolyLayer_name_set(PointerRNA *ptr, const char *value) { rna_cd_layer_name_set(rna_mesh_pdata(ptr), (CustomDataLayer *)ptr->data, value); } -#endif static void rna_MeshLoopLayer_name_set(PointerRNA *ptr, const char *value) { rna_cd_layer_name_set(rna_mesh_ldata(ptr), (CustomDataLayer *)ptr->data, value); } -#if 0 -static void rna_MeshTessfaceLayer_name_set(PointerRNA *ptr, const char *value) -{ - rna_cd_layer_name_set(rna_mesh_fdata(ptr), (CustomDataLayer *)ptr->data, value); -} -#endif /* only for layers shared between types */ static void rna_MeshAnyLayer_name_set(PointerRNA *ptr, const char *value) { @@ -224,20 +212,25 @@ static void rna_Mesh_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin /* cheating way for importers to avoid slow updates */ if (id->us > 0) { - DAG_id_tag_update(id, 0); + DEG_id_tag_update(id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, id); } } -static void rna_Mesh_update_data_edit_color(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerRNA *ptr) { - Mesh *me = rna_mesh(ptr); + BKE_mesh_batch_cache_dirty_tag(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_ALL); + rna_Mesh_update_data(bmain, scene, ptr); - if (me->edit_btmesh) { - BKE_editmesh_color_free(me->edit_btmesh); - } } + +static void rna_Mesh_update_data_edit_active_color(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + BKE_mesh_batch_cache_dirty_tag(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_ALL); + + rna_Mesh_update_data(bmain, scene, ptr); +} static void rna_Mesh_update_select(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { ID *id = ptr->id.data; @@ -263,6 +256,9 @@ static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr) if ((me->editflag & ME_EDIT_PAINT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_FACE_SEL)) { me->editflag &= ~ME_EDIT_PAINT_FACE_SEL; } + + BKE_mesh_batch_cache_dirty_tag(me, BKE_MESH_BATCH_DIRTY_ALL); + rna_Mesh_update_draw(bmain, scene, ptr); } @@ -272,6 +268,9 @@ static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr) if ((me->editflag & ME_EDIT_PAINT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_FACE_SEL)) { me->editflag &= ~ME_EDIT_PAINT_VERT_SEL; } + + BKE_mesh_batch_cache_dirty_tag(me, BKE_MESH_BATCH_DIRTY_ALL); + rna_Mesh_update_draw(bmain, scene, ptr); } @@ -425,232 +424,57 @@ static void rna_MeshPolygon_flip(ID *id, MPoly *mp) BKE_mesh_polygon_flip(mp, me->mloop, &me->ldata); BKE_mesh_tessface_clear(me); + BKE_mesh_runtime_clear_geometry(me); } -static void rna_MeshTessFace_normal_get(PointerRNA *ptr, float *values) +static void rna_MeshLoopTriangle_verts_get(PointerRNA *ptr, int *values) { Mesh *me = rna_mesh(ptr); - MFace *mface = (MFace *)ptr->data; - - if (mface->v4) - normal_quad_v3(values, me->mvert[mface->v1].co, me->mvert[mface->v2].co, - me->mvert[mface->v3].co, me->mvert[mface->v4].co); - else - normal_tri_v3(values, me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co); + MLoopTri *lt = (MLoopTri *)ptr->data; + values[0] = me->mloop[lt->tri[0]].v; + values[1] = me->mloop[lt->tri[1]].v; + values[2] = me->mloop[lt->tri[2]].v; } -static void rna_MeshTessFace_split_normals_get(PointerRNA *ptr, float *values) -{ - Mesh *me = rna_mesh(ptr); - MFace *mface = (MFace *)ptr->data; - const short (*vec)[4][3] = CustomData_get(&me->fdata, (int)(mface - me->mface), CD_TESSLOOPNORMAL); - int i = 4; - - if (!vec) { - while (i--) zero_v3(&values[i * 3]); - } - else { - while (i--) normal_short_to_float_v3(&values[i * 3], (const short *)(*vec)[i]); - } -} -static float rna_MeshTessFace_area_get(PointerRNA *ptr) +static void rna_MeshLoopTriangle_normal_get(PointerRNA *ptr, float *values) { Mesh *me = rna_mesh(ptr); - MFace *mface = (MFace *)ptr->data; + MLoopTri *lt = (MLoopTri *)ptr->data; + unsigned int v1 = me->mloop[lt->tri[0]].v; + unsigned int v2 = me->mloop[lt->tri[1]].v; + unsigned int v3 = me->mloop[lt->tri[2]].v; - if (mface->v4) - return area_quad_v3(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co, - me->mvert[mface->v4].co); - else - return area_tri_v3(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co); -} - -static void rna_MeshTextureFace_uv1_get(PointerRNA *ptr, float *values) -{ - MTFace *mtface = (MTFace *)ptr->data; - - values[0] = mtface->uv[0][0]; - values[1] = mtface->uv[0][1]; + normal_tri_v3(values, me->mvert[v1].co, me->mvert[v2].co, me->mvert[v3].co); } -static void rna_MeshTextureFace_uv1_set(PointerRNA *ptr, const float *values) -{ - MTFace *mtface = (MTFace *)ptr->data; - - mtface->uv[0][0] = values[0]; - mtface->uv[0][1] = values[1]; -} - -static void rna_MeshTextureFace_uv2_get(PointerRNA *ptr, float *values) -{ - MTFace *mtface = (MTFace *)ptr->data; - - values[0] = mtface->uv[1][0]; - values[1] = mtface->uv[1][1]; -} - -static void rna_MeshTextureFace_uv2_set(PointerRNA *ptr, const float *values) -{ - MTFace *mtface = (MTFace *)ptr->data; - - mtface->uv[1][0] = values[0]; - mtface->uv[1][1] = values[1]; -} - -static void rna_MeshTextureFace_uv3_get(PointerRNA *ptr, float *values) -{ - MTFace *mtface = (MTFace *)ptr->data; - - values[0] = mtface->uv[2][0]; - values[1] = mtface->uv[2][1]; -} - -static void rna_MeshTextureFace_uv3_set(PointerRNA *ptr, const float *values) -{ - MTFace *mtface = (MTFace *)ptr->data; - - mtface->uv[2][0] = values[0]; - mtface->uv[2][1] = values[1]; -} - -static void rna_MeshTextureFace_uv4_get(PointerRNA *ptr, float *values) -{ - MTFace *mtface = (MTFace *)ptr->data; - - values[0] = mtface->uv[3][0]; - values[1] = mtface->uv[3][1]; -} - -static void rna_MeshTextureFace_uv4_set(PointerRNA *ptr, const float *values) -{ - MTFace *mtface = (MTFace *)ptr->data; - - mtface->uv[3][0] = values[0]; - mtface->uv[3][1] = values[1]; -} - -static int rna_CustomDataData_numverts(PointerRNA *ptr, int type) +static void rna_MeshLoopTriangle_split_normals_get(PointerRNA *ptr, float *values) { Mesh *me = rna_mesh(ptr); - CustomData *fdata = rna_mesh_fdata(ptr); - CustomDataLayer *cdl; - int a, b; + const float (*lnors)[3] = CustomData_get_layer(&me->ldata, CD_NORMAL); - for (cdl = fdata->layers, a = 0; a < fdata->totlayer; cdl++, a++) { - if (cdl->type == type) { - b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type); - if (b >= 0 && b < me->totface) { - return (me->mface[b].v4 ? 4 : 3); - } - } + if (!lnors) { + zero_v3(values + 0); + zero_v3(values + 3); + zero_v3(values + 6); + } + else { + MLoopTri *lt = (MLoopTri *)ptr->data; + copy_v3_v3(values + 0, lnors[lt->tri[0]]); + copy_v3_v3(values + 3, lnors[lt->tri[1]]); + copy_v3_v3(values + 6, lnors[lt->tri[2]]); } - - return 0; -} - -static int rna_MeshTextureFace_uv_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) -{ - length[0] = rna_CustomDataData_numverts(ptr, CD_MTFACE); - length[1] = 2; - return length[0] * length[1]; -} - -static void rna_MeshTextureFace_uv_get(PointerRNA *ptr, float *values) -{ - MTFace *mtface = (MTFace *)ptr->data; - int totvert = rna_CustomDataData_numverts(ptr, CD_MTFACE); - - memcpy(values, mtface->uv, totvert * 2 * sizeof(float)); -} - -static void rna_MeshTextureFace_uv_set(PointerRNA *ptr, const float *values) -{ - MTFace *mtface = (MTFace *)ptr->data; - int totvert = rna_CustomDataData_numverts(ptr, CD_MTFACE); - - memcpy(mtface->uv, values, totvert * 2 * sizeof(float)); -} - -/* notice red and blue are swapped */ -static void rna_MeshColor_color1_get(PointerRNA *ptr, float *values) -{ - MCol *mcol = (MCol *)ptr->data; - - values[3] = mcol[0].a / 255.0f; - values[2] = mcol[0].r / 255.0f; - values[1] = mcol[0].g / 255.0f; - values[0] = mcol[0].b / 255.0f; -} - -static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values) -{ - MCol *mcol = (MCol *)ptr->data; - - mcol[0].a = round_fl_to_uchar_clamp(values[3] * 255.0f); - mcol[0].r = round_fl_to_uchar_clamp(values[2] * 255.0f); - mcol[0].g = round_fl_to_uchar_clamp(values[1] * 255.0f); - mcol[0].b = round_fl_to_uchar_clamp(values[0] * 255.0f); -} - -static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values) -{ - MCol *mcol = (MCol *)ptr->data; - - values[3] = mcol[1].a / 255.0f; - values[2] = mcol[1].r / 255.0f; - values[1] = mcol[1].g / 255.0f; - values[0] = mcol[1].b / 255.0f; -} - -static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values) -{ - MCol *mcol = (MCol *)ptr->data; - - mcol[1].a = round_fl_to_uchar_clamp(values[3] * 255.0f); - mcol[1].r = round_fl_to_uchar_clamp(values[2] * 255.0f); - mcol[1].g = round_fl_to_uchar_clamp(values[1] * 255.0f); - mcol[1].b = round_fl_to_uchar_clamp(values[0] * 255.0f); -} - -static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values) -{ - MCol *mcol = (MCol *)ptr->data; - - values[3] = mcol[2].a / 255.0f; - values[2] = mcol[2].r / 255.0f; - values[1] = mcol[2].g / 255.0f; - values[0] = mcol[2].b / 255.0f; -} - -static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values) -{ - MCol *mcol = (MCol *)ptr->data; - - mcol[2].a = round_fl_to_uchar_clamp(values[3] * 255.0f); - mcol[2].r = round_fl_to_uchar_clamp(values[2] * 255.0f); - mcol[2].g = round_fl_to_uchar_clamp(values[1] * 255.0f); - mcol[2].b = round_fl_to_uchar_clamp(values[0] * 255.0f); -} - -static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values) -{ - MCol *mcol = (MCol *)ptr->data; - - values[3] = mcol[3].a / 255.0f; - values[2] = mcol[3].r / 255.0f; - values[1] = mcol[3].g / 255.0f; - values[0] = mcol[3].b / 255.0f; } -static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values) +static float rna_MeshLoopTriangle_area_get(PointerRNA *ptr) { - MCol *mcol = (MCol *)ptr->data; + Mesh *me = rna_mesh(ptr); + MLoopTri *lt = (MLoopTri *)ptr->data; + unsigned int v1 = me->mloop[lt->tri[0]].v; + unsigned int v2 = me->mloop[lt->tri[1]].v; + unsigned int v3 = me->mloop[lt->tri[2]].v; - mcol[3].a = round_fl_to_uchar_clamp(values[3] * 255.0f); - mcol[3].r = round_fl_to_uchar_clamp(values[2] * 255.0f); - mcol[3].g = round_fl_to_uchar_clamp(values[1] * 255.0f); - mcol[3].b = round_fl_to_uchar_clamp(values[0] * 255.0f); + return area_tri_v3(me->mvert[v1].co, me->mvert[v2].co, me->mvert[v3].co); } static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values) @@ -758,13 +582,6 @@ static void rna_CustomDataLayer_active_set(PointerRNA *ptr, CustomData *data, in if (render) CustomData_set_layer_render(data, type, n); else CustomData_set_layer_active(data, type, n); - /* sync loop layer */ - if (type == CD_MTEXPOLY) { - CustomData *ldata = rna_mesh_ldata(ptr); - if (render) CustomData_set_layer_render(ldata, CD_MLOOPUV, n); - else CustomData_set_layer_active(ldata, CD_MLOOPUV, n); - } - BKE_mesh_update_customdata_pointers(me, true); } @@ -869,147 +686,38 @@ static int rna_MeshUVLoopLayer_data_length(PointerRNA *ptr) return (me->edit_btmesh) ? 0 : me->totloop; } -/* face uv_textures */ - -DEFINE_CUSTOMDATA_LAYER_COLLECTION(tessface_uv_texture, fdata, CD_MTFACE) -DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(tessface_uv_texture, fdata, CD_MTFACE, active, MeshTextureFaceLayer) -DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(tessface_uv_texture, fdata, CD_MTFACE, clone, MeshTextureFaceLayer) -DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(tessface_uv_texture, fdata, CD_MTFACE, stencil, MeshTextureFaceLayer) -DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(tessface_uv_texture, fdata, CD_MTFACE, render, MeshTextureFaceLayer) - -static void rna_MeshTextureFaceLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - Mesh *me = rna_mesh(ptr); - CustomDataLayer *layer = (CustomDataLayer *)ptr->data; - rna_iterator_array_begin(iter, layer->data, sizeof(MTFace), (me->edit_btmesh) ? 0 : me->totface, 0, NULL); -} - -static int rna_MeshTextureFaceLayer_data_length(PointerRNA *ptr) +static bool rna_MeshUVLoopLayer_active_render_get(PointerRNA *ptr) { - Mesh *me = rna_mesh(ptr); - return (me->edit_btmesh) ? 0 : me->totface; + return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV, 1); } -static bool rna_MeshTextureFaceLayer_active_render_get(PointerRNA *ptr) +static bool rna_MeshUVLoopLayer_active_get(PointerRNA *ptr) { - return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE, 1); + return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV, 0); } -static bool rna_MeshTextureFaceLayer_active_get(PointerRNA *ptr) +static bool rna_MeshUVLoopLayer_clone_get(PointerRNA *ptr) { - return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE, 0); + return rna_CustomDataLayer_clone_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV); } -static bool rna_MeshTextureFaceLayer_clone_get(PointerRNA *ptr) +static void rna_MeshUVLoopLayer_active_render_set(PointerRNA *ptr, bool value) { - return rna_CustomDataLayer_clone_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE); + rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV, 1); } -static void rna_MeshTextureFaceLayer_active_render_set(PointerRNA *ptr, bool value) +static void rna_MeshUVLoopLayer_active_set(PointerRNA *ptr, bool value) { - rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MTFACE, 1); + rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV, 0); } -static void rna_MeshTextureFaceLayer_active_set(PointerRNA *ptr, int value) +static void rna_MeshUVLoopLayer_clone_set(PointerRNA *ptr, bool value) { - rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MTFACE, 0); -} - -static void rna_MeshTextureFaceLayer_clone_set(PointerRNA *ptr, int value) -{ - rna_CustomDataLayer_clone_set(ptr, rna_mesh_fdata(ptr), value, CD_MTFACE); -} - -/* poly uv_textures */ - -DEFINE_CUSTOMDATA_LAYER_COLLECTION(uv_texture, pdata, CD_MTEXPOLY) -DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(uv_texture, pdata, CD_MTEXPOLY, active, MeshTexturePolyLayer) -DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(uv_texture, pdata, CD_MTEXPOLY, clone, MeshTexturePolyLayer) -DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(uv_texture, pdata, CD_MTEXPOLY, stencil, MeshTexturePolyLayer) -DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(uv_texture, pdata, CD_MTEXPOLY, render, MeshTexturePolyLayer) - -static void rna_MeshTexturePolyLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - Mesh *me = rna_mesh(ptr); - CustomDataLayer *layer = (CustomDataLayer *)ptr->data; - rna_iterator_array_begin(iter, layer->data, sizeof(MTexPoly), (me->edit_btmesh) ? 0 : me->totpoly, 0, NULL); -} - -static int rna_MeshTexturePolyLayer_data_length(PointerRNA *ptr) -{ - Mesh *me = rna_mesh(ptr); - return (me->edit_btmesh) ? 0 : me->totpoly; -} - -static bool rna_MeshTexturePolyLayer_active_render_get(PointerRNA *ptr) -{ - return rna_CustomDataLayer_active_get(ptr, rna_mesh_pdata(ptr), CD_MTEXPOLY, 1); -} - -static bool rna_MeshTexturePolyLayer_active_get(PointerRNA *ptr) -{ - return rna_CustomDataLayer_active_get(ptr, rna_mesh_pdata(ptr), CD_MTEXPOLY, 0); -} - -static bool rna_MeshTexturePolyLayer_clone_get(PointerRNA *ptr) -{ - return rna_CustomDataLayer_clone_get(ptr, rna_mesh_pdata(ptr), CD_MTEXPOLY); -} - -static void rna_MeshTexturePolyLayer_active_render_set(PointerRNA *ptr, bool value) -{ - rna_CustomDataLayer_active_set(ptr, rna_mesh_pdata(ptr), value, CD_MTEXPOLY, 1); -} - -static void rna_MeshTexturePolyLayer_active_set(PointerRNA *ptr, int value) -{ - rna_CustomDataLayer_active_set(ptr, rna_mesh_pdata(ptr), value, CD_MTEXPOLY, 0); -} - -static void rna_MeshTexturePolyLayer_clone_set(PointerRNA *ptr, bool value) -{ - rna_CustomDataLayer_clone_set(ptr, rna_mesh_pdata(ptr), value, CD_MTEXPOLY); + rna_CustomDataLayer_clone_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV); } /* vertex_color_layers */ -DEFINE_CUSTOMDATA_LAYER_COLLECTION(tessface_vertex_color, fdata, CD_MCOL) -DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(tessface_vertex_color, fdata, CD_MCOL, active, MeshColorLayer) -DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(tessface_vertex_color, fdata, CD_MCOL, render, MeshColorLayer) - -static void rna_MeshColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - Mesh *me = rna_mesh(ptr); - CustomDataLayer *layer = (CustomDataLayer *)ptr->data; - rna_iterator_array_begin(iter, layer->data, sizeof(MCol) * 4, me->totface, 0, NULL); -} - -static int rna_MeshColorLayer_data_length(PointerRNA *ptr) -{ - Mesh *me = rna_mesh(ptr); - return me->totface; -} - -static bool rna_MeshColorLayer_active_render_get(PointerRNA *ptr) -{ - return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MCOL, 1); -} - -static bool rna_MeshColorLayer_active_get(PointerRNA *ptr) -{ - return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MCOL, 0); -} - -static void rna_MeshColorLayer_active_render_set(PointerRNA *ptr, bool value) -{ - rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MCOL, 1); -} - -static void rna_MeshColorLayer_active_set(PointerRNA *ptr, int value) -{ - rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MCOL, 0); -} - DEFINE_CUSTOMDATA_LAYER_COLLECTION(vertex_color, ldata, CD_MLOOPCOL) DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(vertex_color, ldata, CD_MLOOPCOL, active, MeshLoopColorLayer) DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(vertex_color, ldata, CD_MLOOPCOL, render, MeshLoopColorLayer) @@ -1194,66 +902,75 @@ static int rna_MeshPaintMaskLayer_data_length(PointerRNA *ptr) /* End paint mask */ -static void rna_TexturePoly_image_set(PointerRNA *ptr, PointerRNA value) -{ - MTexPoly *tf = (MTexPoly *)ptr->data; - ID *id = value.data; +/* Face maps */ - if (id) { - /* special exception here, individual faces don't count - * as reference, but we do ensure the refcount is not zero */ - if (id->us == 0) - id_us_plus(id); - else - id_lib_extern(id); - } +DEFINE_CUSTOMDATA_LAYER_COLLECTION(face_map, pdata, CD_FACEMAP) +DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(face_map, pdata, CD_FACEMAP, active, MeshFaceMapLayer) - tf->tpage = (struct Image *)id; +static char *rna_MeshFaceMapLayer_path(PointerRNA *ptr) +{ + CustomDataLayer *cdl = ptr->data; + char name_esc[sizeof(cdl->name) * 2]; + BLI_strescape(name_esc, cdl->name, sizeof(name_esc)); + return BLI_sprintfN("face_maps[\"%s\"]", name_esc); } -/* while this is supposed to be readonly, - * keep it to support importers that only make tessfaces */ -static void rna_TextureFace_image_set(PointerRNA *ptr, PointerRNA value) +static void rna_MeshFaceMapLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - MTFace *tf = (MTFace *)ptr->data; - ID *id = value.data; - - if (id) { - /* special exception here, individual faces don't count - * as reference, but we do ensure the refcount is not zero */ - if (id->us == 0) - id_us_plus(id); - else - id_lib_extern(id); - } + Mesh *me = rna_mesh(ptr); + CustomDataLayer *layer = (CustomDataLayer *)ptr->data; + rna_iterator_array_begin(iter, layer->data, sizeof(int), me->totpoly, 0, NULL); +} - tf->tpage = (struct Image *)id; +static int rna_MeshFaceMapLayer_data_length(PointerRNA *ptr) +{ + Mesh *me = rna_mesh(ptr); + return me->totpoly; } -static int rna_MeshTessFace_verts_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) +static PointerRNA rna_Mesh_face_map_new(struct Mesh *me, ReportList *reports, const char *name) { - MFace *face = (MFace *)ptr->data; + if (BKE_mesh_ensure_facemap_customdata(me) == false) { + BKE_report(reports, RPT_ERROR, "Currently only single face-map layers are supported"); + return PointerRNA_NULL; + } - if (face) - length[0] = (face->v4) ? 4 : 3; - else - length[0] = 4; /* XXX rna_raw_access wants the length of a dummy face. this needs fixing. - Campbell */ + CustomData *pdata = rna_mesh_pdata_helper(me); - return length[0]; -} + int index = CustomData_get_layer_index(pdata, CD_FACEMAP); + BLI_assert(index != -1); + CustomDataLayer *cdl = &pdata->layers[index]; + rna_cd_layer_name_set(pdata, cdl, name); -static void rna_MeshTessFace_verts_get(PointerRNA *ptr, int *values) -{ - MFace *face = (MFace *)ptr->data; - memcpy(values, &face->v1, (face->v4 ? 4 : 3) * sizeof(int)); + PointerRNA ptr; + RNA_pointer_create(&me->id, &RNA_MeshFaceMapLayer, cdl, &ptr); + return ptr; } -static void rna_MeshTessFace_verts_set(PointerRNA *ptr, const int *values) +static void rna_Mesh_face_map_remove(struct Mesh *me, ReportList *reports, struct CustomDataLayer *layer) { - MFace *face = (MFace *)ptr->data; - memcpy(&face->v1, values, (face->v4 ? 4 : 3) * sizeof(int)); + /* just for sanity check */ + { + CustomData *pdata = rna_mesh_pdata_helper(me); + int index = CustomData_get_layer_index(pdata, CD_FACEMAP); + if (index != -1) { + CustomDataLayer *layer_test = &pdata->layers[index]; + if (layer != layer_test) { + /* don't show name, its likely freed memory */ + BKE_report(reports, RPT_ERROR, "FaceMap not in mesh"); + return; + } + } + } + + if (BKE_mesh_clear_facemap_customdata(me) == false) { + BKE_reportf(reports, RPT_ERROR, "Error removing face-map"); + } } +/* End face maps */ + + /* poly.vertices - this is faked loop access for convenience */ static int rna_MeshPoly_vertices_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) { @@ -1308,11 +1025,25 @@ static int rna_MeshEdge_index_get(PointerRNA *ptr) return (int)(edge - me->medge); } -static int rna_MeshTessFace_index_get(PointerRNA *ptr) +static int rna_MeshLoopTriangle_index_get(PointerRNA *ptr) { Mesh *me = rna_mesh(ptr); - MFace *face = (MFace *)ptr->data; - return (int)(face - me->mface); + MLoopTri *ltri = (MLoopTri *)ptr->data; + return (int)(ltri - me->runtime.looptris.array); +} + +static int rna_MeshLoopTriangle_material_index_get(PointerRNA *ptr) +{ + Mesh *me = rna_mesh(ptr); + MLoopTri *ltri = (MLoopTri *)ptr->data; + return me->mpoly[ltri->poly].mat_nr; +} + +static bool rna_MeshLoopTriangle_use_smooth_get(PointerRNA *ptr) +{ + Mesh *me = rna_mesh(ptr); + MLoopTri *ltri = (MLoopTri *)ptr->data; + return me->mpoly[ltri->poly].flag & ME_SMOOTH; } static int rna_MeshPolygon_index_get(PointerRNA *ptr) @@ -1351,9 +1082,9 @@ static char *rna_MeshPolygon_path(PointerRNA *ptr) return BLI_sprintfN("polygons[%d]", (int)((MPoly *)ptr->data - rna_mesh(ptr)->mpoly)); } -static char *rna_MeshTessFace_path(PointerRNA *ptr) +static char *rna_MeshLoopTriangle_path(PointerRNA *ptr) { - return BLI_sprintfN("tessfaces[%d]", (int)((MFace *)ptr->data - rna_mesh(ptr)->mface)); + return BLI_sprintfN("loop_triangles[%d]", (int)((MLoopTri *)ptr->data - rna_mesh(ptr)->runtime.looptris.array)); } static char *rna_MeshEdge_path(PointerRNA *ptr) @@ -1372,22 +1103,6 @@ static char *rna_MeshVertex_path(PointerRNA *ptr) return BLI_sprintfN("vertices[%d]", (int)((MVert *)ptr->data - rna_mesh(ptr)->mvert)); } -static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr) -{ - CustomDataLayer *cdl = ptr->data; - char name_esc[sizeof(cdl->name) * 2]; - BLI_strescape(name_esc, cdl->name, sizeof(name_esc)); - return BLI_sprintfN("tessface_uv_textures[\"%s\"]", name_esc); -} - -static char *rna_MeshTexturePolyLayer_path(PointerRNA *ptr) -{ - CustomDataLayer *cdl = ptr->data; - char name_esc[sizeof(cdl->name) * 2]; - BLI_strescape(name_esc, cdl->name, sizeof(name_esc)); - return BLI_sprintfN("uv_textures[\"%s\"]", name_esc); -} - static char *rna_VertCustomData_data_path(PointerRNA *ptr, const char *collection, int type) { CustomDataLayer *cdl; @@ -1451,51 +1166,11 @@ static char *rna_LoopCustomData_data_path(PointerRNA *ptr, const char *collectio return NULL; } -static char *rna_FaceCustomData_data_path(PointerRNA *ptr, const char *collection, int type) -{ - CustomDataLayer *cdl; - Mesh *me = rna_mesh(ptr); - CustomData *fdata = rna_mesh_fdata(ptr); - int a, b, totloop = (me->edit_btmesh) ? 0 : me->totloop; - - for (cdl = fdata->layers, a = 0; a < fdata->totlayer; cdl++, a++) { - if (cdl->type == type) { - b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type); - if (b >= 0 && b < totloop) { - char name_esc[sizeof(cdl->name) * 2]; - BLI_strescape(name_esc, cdl->name, sizeof(name_esc)); - return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, name_esc, b); - } - } - } - - return NULL; -} - - static char *rna_MeshUVLoop_path(PointerRNA *ptr) { return rna_LoopCustomData_data_path(ptr, "uv_layers", CD_MLOOPUV); } -static char *rna_MeshTextureFace_path(PointerRNA *ptr) -{ - return rna_FaceCustomData_data_path(ptr, "tessface_uv_textures", CD_MTFACE); -} - -static char *rna_MeshTexturePoly_path(PointerRNA *ptr) -{ - return rna_PolyCustomData_data_path(ptr, "uv_textures", CD_MTEXPOLY); -} - -static char *rna_MeshColorLayer_path(PointerRNA *ptr) -{ - CustomDataLayer *cdl = ptr->data; - char name_esc[sizeof(cdl->name) * 2]; - BLI_strescape(name_esc, cdl->name, sizeof(name_esc)); - return BLI_sprintfN("tessface_vertex_colors[\"%s\"]", name_esc); -} - static char *rna_MeshLoopColorLayer_path(PointerRNA *ptr) { CustomDataLayer *cdl = ptr->data; @@ -1675,6 +1350,12 @@ void rna_MeshStringProperty_s_set(PointerRNA *ptr, const char *value) MStringProperty *ms = (MStringProperty *)ptr->data; BLI_strncpy(ms->s, value, sizeof(ms->s)); } + +static char *rna_MeshFaceMap_path(PointerRNA *ptr) +{ + return rna_PolyCustomData_data_path(ptr, "face_maps", CD_FACEMAP); +} + /***************************************/ static int rna_Mesh_tot_vert_get(PointerRNA *ptr) @@ -1716,34 +1397,6 @@ static void rna_Mesh_vertex_color_remove(struct Mesh *me, ReportList *reports, C } } -static PointerRNA rna_Mesh_tessface_vertex_color_new(struct Mesh *me, ReportList *reports, const char *name) -{ - PointerRNA ptr; - CustomData *fdata; - CustomDataLayer *cdl = NULL; - int index; - - if (me->edit_btmesh) { - BKE_report(reports, RPT_ERROR, "Cannot add tessface colors in edit mode"); - return PointerRNA_NULL; - } - - if (me->mpoly) { - BKE_report(reports, RPT_ERROR, "Cannot add tessface colors when MPoly's exist"); - return PointerRNA_NULL; - } - - index = ED_mesh_color_add(me, name, false); - - if (index != -1) { - fdata = rna_mesh_fdata_helper(me); - cdl = &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MCOL, index)]; - } - - RNA_pointer_create(&me->id, &RNA_MeshColorLayer, cdl, &ptr); - return ptr; -} - #define DEFINE_CUSTOMDATA_PROPERTY_API(elemname, datatype, cd_prop_type, cdata, countvar, layertype) \ static PointerRNA rna_Mesh_##elemname##_##datatype##_property_new(struct Mesh *me, const char *name) \ { \ @@ -1768,61 +1421,29 @@ DEFINE_CUSTOMDATA_PROPERTY_API(polygon, int, CD_PROP_INT, pdata, totpoly, MeshPo DEFINE_CUSTOMDATA_PROPERTY_API(polygon, string, CD_PROP_STR, pdata, totpoly, MeshPolygonStringPropertyLayer) #undef DEFINE_CUSTOMDATA_PROPERTY_API -static PointerRNA rna_Mesh_uv_texture_new(struct Mesh *me, const char *name) +static PointerRNA rna_Mesh_uv_layers_new(struct Mesh *me, const char *name) { PointerRNA ptr; - CustomData *pdata; + CustomData *ldata; CustomDataLayer *cdl = NULL; int index = ED_mesh_uv_texture_add(me, name, false); if (index != -1) { - pdata = rna_mesh_pdata_helper(me); - cdl = &pdata->layers[CustomData_get_layer_index_n(pdata, CD_MTEXPOLY, index)]; + ldata = rna_mesh_ldata_helper(me); + cdl = &ldata->layers[CustomData_get_layer_index_n(ldata, CD_MLOOPUV, index)]; } - RNA_pointer_create(&me->id, &RNA_MeshTexturePolyLayer, cdl, &ptr); + RNA_pointer_create(&me->id, &RNA_MeshUVLoopLayer, cdl, &ptr); return ptr; } -static void rna_Mesh_uv_texture_layers_remove(struct Mesh *me, ReportList *reports, CustomDataLayer *layer) +static void rna_Mesh_uv_layers_remove(struct Mesh *me, ReportList *reports, CustomDataLayer *layer) { if (ED_mesh_uv_texture_remove_named(me, layer->name) == false) { BKE_reportf(reports, RPT_ERROR, "Texture layer '%s' not found", layer->name); } } -/* while this is supposed to be readonly, - * keep it to support importers that only make tessfaces */ - -static PointerRNA rna_Mesh_tessface_uv_texture_new(struct Mesh *me, ReportList *reports, const char *name) -{ - PointerRNA ptr; - CustomData *fdata; - CustomDataLayer *cdl = NULL; - int index; - - if (me->edit_btmesh) { - BKE_report(reports, RPT_ERROR, "Cannot add tessface uv's in edit mode"); - return PointerRNA_NULL; - } - - if (me->mpoly) { - BKE_report(reports, RPT_ERROR, "Cannot add tessface uv's when MPoly's exist"); - return PointerRNA_NULL; - } - - index = ED_mesh_uv_texture_add(me, name, false); - - if (index != -1) { - fdata = rna_mesh_fdata_helper(me); - cdl = &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MTFACE, index)]; - } - - RNA_pointer_create(&me->id, &RNA_MeshTextureFaceLayer, cdl, &ptr); - return ptr; -} - - static bool rna_Mesh_is_editmode_get(PointerRNA *ptr) { Mesh *me = rna_mesh(ptr); @@ -1835,38 +1456,18 @@ static void UNUSED_FUNCTION(rna_mesh_unused)(void) /* unused functions made by macros */ (void)rna_Mesh_skin_vertice_index_range; (void)rna_Mesh_vertex_paint_mask_index_range; - (void)rna_Mesh_tessface_uv_texture_active_set; - (void)rna_Mesh_tessface_uv_texture_clone_get; - (void)rna_Mesh_tessface_uv_texture_clone_index_get; - (void)rna_Mesh_tessface_uv_texture_clone_index_set; - (void)rna_Mesh_tessface_uv_texture_clone_set; - (void)rna_Mesh_tessface_uv_texture_index_range; - (void)rna_Mesh_tessface_uv_texture_render_get; - (void)rna_Mesh_tessface_uv_texture_render_index_get; - (void)rna_Mesh_tessface_uv_texture_render_index_set; - (void)rna_Mesh_tessface_uv_texture_render_set; - (void)rna_Mesh_tessface_uv_texture_stencil_get; - (void)rna_Mesh_tessface_uv_texture_stencil_index_get; - (void)rna_Mesh_tessface_uv_texture_stencil_index_set; - (void)rna_Mesh_tessface_uv_texture_stencil_set; - (void)rna_Mesh_tessface_vertex_color_active_set; - (void)rna_Mesh_tessface_vertex_color_index_range; - (void)rna_Mesh_tessface_vertex_color_render_get; - (void)rna_Mesh_tessface_vertex_color_render_index_get; - (void)rna_Mesh_tessface_vertex_color_render_index_set; - (void)rna_Mesh_tessface_vertex_color_render_set; (void)rna_Mesh_uv_layer_render_get; (void)rna_Mesh_uv_layer_render_index_get; (void)rna_Mesh_uv_layer_render_index_set; (void)rna_Mesh_uv_layer_render_set; - (void)rna_Mesh_uv_texture_render_get; - (void)rna_Mesh_uv_texture_render_index_get; - (void)rna_Mesh_uv_texture_render_index_set; - (void)rna_Mesh_uv_texture_render_set; (void)rna_Mesh_vertex_color_render_get; (void)rna_Mesh_vertex_color_render_index_get; (void)rna_Mesh_vertex_color_render_index_set; (void)rna_Mesh_vertex_color_render_set; + (void)rna_Mesh_face_map_index_range; + (void)rna_Mesh_face_map_active_index_set; + (void)rna_Mesh_face_map_active_index_get; + (void)rna_Mesh_face_map_active_set; /* end unused function block */ } @@ -1894,7 +1495,7 @@ static void rna_def_mvert_group(BlenderRNA *brna) prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Weight", "Vertex Weight"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_weight"); } static void rna_def_mvert(BlenderRNA *brna) @@ -2016,83 +1617,70 @@ static void rna_def_medge(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Index", "Index of this edge"); } -static void rna_def_mface(BlenderRNA *brna) +static void rna_def_mlooptri(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - const int splitnor_dim[] = {4, 3}; + const int splitnor_dim[] = {3, 3}; - srna = RNA_def_struct(brna, "MeshTessFace", NULL); - RNA_def_struct_sdna(srna, "MFace"); - RNA_def_struct_ui_text(srna, "Mesh TessFace", "TessFace in a Mesh data-block"); - RNA_def_struct_path_func(srna, "rna_MeshTessFace_path"); + srna = RNA_def_struct(brna, "MeshLoopTriangle", NULL); + RNA_def_struct_sdna(srna, "MLoopTri"); + RNA_def_struct_ui_text(srna, "Mesh Loop Triangle", "Tessellated triangle in a Mesh data-block"); + RNA_def_struct_path_func(srna, "rna_MeshLoopTriangle_path"); RNA_def_struct_ui_icon(srna, ICON_FACESEL); - /* XXX allows creating invalid meshes */ prop = RNA_def_property(srna, "vertices", PROP_INT, PROP_UNSIGNED); - RNA_def_property_array(prop, 4); - RNA_def_property_flag(prop, PROP_DYNAMIC); - RNA_def_property_dynamic_array_funcs(prop, "rna_MeshTessFace_verts_get_length"); - RNA_def_property_int_funcs(prop, "rna_MeshTessFace_verts_get", "rna_MeshTessFace_verts_set", NULL); - RNA_def_property_ui_text(prop, "Vertices", "Vertex indices"); - - /* leaving this fixed size array for foreach_set used in import scripts */ - prop = RNA_def_property(srna, "vertices_raw", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "v1"); - RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Vertices", "Fixed size vertex indices array"); - - prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "mat_nr"); - RNA_def_property_ui_text(prop, "Material Index", ""); -#if 0 - RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MeshPoly_material_index_range"); /* reuse for tessface is ok */ -#endif - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FACE_SEL); - RNA_def_property_ui_text(prop, "Select", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); + RNA_def_property_array(prop, 3); + RNA_def_property_int_funcs(prop, "rna_MeshLoopTriangle_verts_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Vertices", "Indices of triangle vertices"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE); - RNA_def_property_ui_text(prop, "Hide", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); + prop = RNA_def_property(srna, "loops", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "tri"); + RNA_def_property_ui_text(prop, "Loops", "Indices of mesh loops that make up the triangle"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SMOOTH); - RNA_def_property_ui_text(prop, "Smooth", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + prop = RNA_def_property(srna, "polygon_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "poly"); + RNA_def_property_ui_text(prop, "Polygon", "Index of mesh polygon that the triangle is a part of"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_float_funcs(prop, "rna_MeshTessFace_normal_get", NULL, NULL); - RNA_def_property_ui_text(prop, "Face Normal", "Local space unit length normal vector for this face"); + RNA_def_property_float_funcs(prop, "rna_MeshLoopTriangle_normal_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Triangle Normal", "Local space unit length normal vector for this triangle"); prop = RNA_def_property(srna, "split_normals", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_multi_array(prop, 2, splitnor_dim); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_float_funcs(prop, "rna_MeshTessFace_split_normals_get", NULL, NULL); + RNA_def_property_float_funcs(prop, "rna_MeshLoopTriangle_split_normals_get", NULL, NULL); RNA_def_property_ui_text(prop, "Split Normals", - "Local space unit length split normals vectors of the vertices of this face " - "(must be computed beforehand using calc_normals_split or calc_tangents, " - "and then calc_tessface)"); + "Local space unit length split normals vectors of the vertices of this triangle " + "(must be computed beforehand using calc_normals_split or calc_tangents)"); prop = RNA_def_property(srna, "area", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_float_funcs(prop, "rna_MeshTessFace_area_get", NULL, NULL); - RNA_def_property_ui_text(prop, "Face Area", "Read only area of this face"); + RNA_def_property_float_funcs(prop, "rna_MeshLoopTriangle_area_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Triangle Area", "Area of this triangle"); 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_MeshTessFace_index_get", NULL, NULL); - RNA_def_property_ui_text(prop, "Index", "Index of this face"); -} + RNA_def_property_int_funcs(prop, "rna_MeshLoopTriangle_index_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Index", "Index of this loop triangle"); + prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_MeshLoopTriangle_material_index_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Material Index", ""); + + prop = RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_MeshLoopTriangle_use_smooth_get", NULL); + RNA_def_property_ui_text(prop, "Smooth", ""); +} static void rna_def_mloop(BlenderRNA *brna) { @@ -2264,282 +1852,42 @@ static void rna_def_mloopuv(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", "Name of UV map"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - srna = RNA_def_struct(brna, "MeshUVLoop", NULL); - RNA_def_struct_sdna(srna, "MLoopUV"); - RNA_def_struct_path_func(srna, "rna_MeshUVLoop_path"); - - prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_XYZ); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "pin_uv", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", MLOOPUV_PINNED); - RNA_def_property_ui_text(prop, "UV Pinned", ""); - - prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", MLOOPUV_VERTSEL); - RNA_def_property_ui_text(prop, "UV Select", ""); - - prop = RNA_def_property(srna, "select_edge", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", MLOOPUV_EDGESEL); - RNA_def_property_ui_text(prop, "UV Edge Select", ""); -} - -static void rna_def_mtface(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - const int uv_dim[] = {4, 2}; - - srna = RNA_def_struct(brna, "MeshTextureFaceLayer", NULL); - RNA_def_struct_ui_text(srna, "Mesh UV Map", "UV map with assigned image textures in a Mesh data-block"); - RNA_def_struct_sdna(srna, "CustomDataLayer"); - RNA_def_struct_path_func(srna, "rna_MeshTextureFaceLayer_path"); - RNA_def_struct_ui_icon(srna, ICON_GROUP_UVS); - - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshUVLayer_name_set"); - RNA_def_property_ui_text(prop, "Name", "Name of UV map"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_active_get", "rna_MeshTextureFaceLayer_active_set"); - RNA_def_property_ui_text(prop, "Active", "Set the map as active for display and editing"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0); - RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_active_render_get", - "rna_MeshTextureFaceLayer_active_render_set"); - RNA_def_property_ui_text(prop, "Active Render", "Set the map as active for rendering"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "active_clone", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "active_clone", 0); - RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_clone_get", "rna_MeshTextureFaceLayer_clone_set"); - RNA_def_property_ui_text(prop, "Active Clone", "Set the map as active for cloning"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "MeshTextureFace"); - RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next", - "rna_iterator_array_end", "rna_iterator_array_get", - "rna_MeshTextureFaceLayer_data_length", NULL, NULL, NULL); - - srna = RNA_def_struct(brna, "MeshTextureFace", NULL); - RNA_def_struct_sdna(srna, "MTFace"); - RNA_def_struct_ui_text(srna, "Mesh UV Map Face", "UV map and image texture for a face"); - RNA_def_struct_path_func(srna, "rna_MeshTextureFace_path"); - RNA_def_struct_ui_icon(srna, ICON_FACESEL_HLT); - - prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "tpage"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_TextureFace_image_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Image", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - /* these are for editing only, access at loops now */ -#if 0 - prop = RNA_def_property(srna, "select_uv", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", TF_SEL1); - RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "UV Selected", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); - - prop = RNA_def_property(srna, "pin_uv", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "unwrap", TF_PIN1); - RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "UV Pinned", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); -#endif - - prop = RNA_def_property(srna, "uv1", PROP_FLOAT, PROP_XYZ); - RNA_def_property_array(prop, 2); - RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv1_get", "rna_MeshTextureFace_uv1_set", NULL); - RNA_def_property_ui_text(prop, "UV 1", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "uv2", PROP_FLOAT, PROP_XYZ); - RNA_def_property_array(prop, 2); - RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv2_get", "rna_MeshTextureFace_uv2_set", NULL); - RNA_def_property_ui_text(prop, "UV 2", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "uv3", PROP_FLOAT, PROP_XYZ); - RNA_def_property_array(prop, 2); - RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv3_get", "rna_MeshTextureFace_uv3_set", NULL); - RNA_def_property_ui_text(prop, "UV 3", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "uv4", PROP_FLOAT, PROP_XYZ); - RNA_def_property_array(prop, 2); - RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv4_get", "rna_MeshTextureFace_uv4_set", NULL); - RNA_def_property_ui_text(prop, "UV 4", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE); - RNA_def_property_multi_array(prop, 2, uv_dim); - RNA_def_property_flag(prop, PROP_DYNAMIC); - RNA_def_property_dynamic_array_funcs(prop, "rna_MeshTextureFace_uv_get_length"); - RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv_get", "rna_MeshTextureFace_uv_set", NULL); - RNA_def_property_ui_text(prop, "UV", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "uv_raw", PROP_FLOAT, PROP_NONE); - RNA_def_property_multi_array(prop, 2, uv_dim); - RNA_def_property_float_sdna(prop, NULL, "uv"); - RNA_def_property_ui_text(prop, "UV Raw", "Fixed size UV coordinates array"); - -} - -static void rna_def_mtexpoly(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; -#if 0 /* BMESH_TODO: needed later when do another todo */ - int uv_dim[] = {4, 2}; -#endif - - srna = RNA_def_struct(brna, "MeshTexturePolyLayer", NULL); - RNA_def_struct_ui_text(srna, "Mesh UV Map", "UV map with assigned image textures in a Mesh data-block"); - RNA_def_struct_sdna(srna, "CustomDataLayer"); - RNA_def_struct_path_func(srna, "rna_MeshTexturePolyLayer_path"); - RNA_def_struct_ui_icon(srna, ICON_GROUP_UVS); - - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshUVLayer_name_set"); - RNA_def_property_ui_text(prop, "Name", "Name of UV map"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_MeshTexturePolyLayer_active_get", "rna_MeshTexturePolyLayer_active_set"); + RNA_def_property_boolean_funcs(prop, "rna_MeshUVLoopLayer_active_get", "rna_MeshUVLoopLayer_active_set"); RNA_def_property_ui_text(prop, "Active", "Set the map as active for display and editing"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0); - RNA_def_property_boolean_funcs(prop, "rna_MeshTexturePolyLayer_active_render_get", - "rna_MeshTexturePolyLayer_active_render_set"); + RNA_def_property_boolean_funcs(prop, "rna_MeshUVLoopLayer_active_render_get", + "rna_MeshUVLoopLayer_active_render_set"); RNA_def_property_ui_text(prop, "Active Render", "Set the map as active for rendering"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop = RNA_def_property(srna, "active_clone", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "active_clone", 0); - RNA_def_property_boolean_funcs(prop, "rna_MeshTexturePolyLayer_clone_get", "rna_MeshTexturePolyLayer_clone_set"); + RNA_def_property_boolean_funcs(prop, "rna_MeshUVLoopLayer_clone_get", "rna_MeshUVLoopLayer_clone_set"); RNA_def_property_ui_text(prop, "Active Clone", "Set the map as active for cloning"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "MeshTexturePoly"); - RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshTexturePolyLayer_data_begin", "rna_iterator_array_next", - "rna_iterator_array_end", "rna_iterator_array_get", - "rna_MeshTexturePolyLayer_data_length", NULL, NULL, NULL); - - srna = RNA_def_struct(brna, "MeshTexturePoly", NULL); - RNA_def_struct_sdna(srna, "MTexPoly"); - RNA_def_struct_ui_text(srna, "Mesh UV Map Face", "UV map and image texture for a face"); - RNA_def_struct_path_func(srna, "rna_MeshTexturePoly_path"); - RNA_def_struct_ui_icon(srna, ICON_FACESEL_HLT); + srna = RNA_def_struct(brna, "MeshUVLoop", NULL); + RNA_def_struct_sdna(srna, "MLoopUV"); + RNA_def_struct_path_func(srna, "rna_MeshUVLoop_path"); - prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "tpage"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_TexturePoly_image_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Image", ""); + prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_XYZ); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); -#if 0 /* moved to MeshUVLoopLayer */ - prop = RNA_def_property(srna, "select_uv", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", TF_SEL1); - RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "UV Selected", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); - prop = RNA_def_property(srna, "pin_uv", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "unwrap", TF_PIN1); - RNA_def_property_array(prop, 4); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MLOOPUV_PINNED); RNA_def_property_ui_text(prop, "UV Pinned", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); - - prop = RNA_def_property(srna, "uv_raw", PROP_FLOAT, PROP_NONE); - RNA_def_property_multi_array(prop, 2, uv_dim); - RNA_def_property_float_sdna(prop, NULL, "uv"); - RNA_def_property_ui_text(prop, "UV", "Fixed size UV coordinates array"); -#endif -} - -static void rna_def_mcol(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "MeshColorLayer", NULL); - RNA_def_struct_ui_text(srna, "Mesh Vertex Color Layer", "Layer of vertex colors in a Mesh data-block"); - RNA_def_struct_sdna(srna, "CustomDataLayer"); - RNA_def_struct_path_func(srna, "rna_MeshColorLayer_path"); - RNA_def_struct_ui_icon(srna, ICON_GROUP_VCOL); - - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_string_funcs(prop, NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Name", "Name of Vertex color layer"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_MeshColorLayer_active_get", "rna_MeshColorLayer_active_set"); - RNA_def_property_ui_text(prop, "Active", "Sets the layer as active for display and editing"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0); - RNA_def_property_boolean_funcs(prop, "rna_MeshColorLayer_active_render_get", - "rna_MeshColorLayer_active_render_set"); - RNA_def_property_ui_text(prop, "Active Render", "Sets the layer as active for rendering"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "MeshColor"); - RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next", - "rna_iterator_array_end", "rna_iterator_array_get", - "rna_MeshColorLayer_data_length", NULL, NULL, NULL); - - srna = RNA_def_struct(brna, "MeshColor", NULL); - RNA_def_struct_sdna(srna, "MCol"); - RNA_def_struct_ui_text(srna, "Mesh Vertex Color", "Vertex colors for a face in a Mesh"); - RNA_def_struct_path_func(srna, "rna_MeshColor_path"); - - prop = RNA_def_property(srna, "color1", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 4); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_float_funcs(prop, "rna_MeshColor_color1_get", "rna_MeshColor_color1_set", NULL); - RNA_def_property_ui_text(prop, "Color 1", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "color2", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 4); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_float_funcs(prop, "rna_MeshColor_color2_get", "rna_MeshColor_color2_set", NULL); - RNA_def_property_ui_text(prop, "Color 2", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "color3", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 4); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_float_funcs(prop, "rna_MeshColor_color3_get", "rna_MeshColor_color3_set", NULL); - RNA_def_property_ui_text(prop, "Color 3", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MLOOPUV_VERTSEL); + RNA_def_property_ui_text(prop, "UV Select", ""); - prop = RNA_def_property(srna, "color4", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 4); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_float_funcs(prop, "rna_MeshColor_color4_get", "rna_MeshColor_color4_set", NULL); - RNA_def_property_ui_text(prop, "Color 4", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + prop = RNA_def_property(srna, "select_edge", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MLOOPUV_EDGESEL); + RNA_def_property_ui_text(prop, "UV Edge Select", ""); } static void rna_def_mloopcol(BlenderRNA *brna) @@ -2754,7 +2102,7 @@ static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop) /* PropertyRNA *prop; */ FunctionRNA *func; -/* PropertyRNA *parm; */ + PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshVertices"); srna = RNA_def_struct(brna, "MeshVertices", NULL); @@ -2763,7 +2111,8 @@ static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "ED_mesh_vertices_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX); + parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); #if 0 /* BMESH_TODO Remove until BMesh merge */ func = RNA_def_function(srna, "remove", "ED_mesh_vertices_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); @@ -2778,7 +2127,7 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop) /* PropertyRNA *prop; */ FunctionRNA *func; -/* PropertyRNA *parm; */ + PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshEdges"); srna = RNA_def_struct(brna, "MeshEdges", NULL); @@ -2787,7 +2136,8 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "ED_mesh_edges_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to add", 0, INT_MAX); + parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to add", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); #if 0 /* BMESH_TODO Remove until BMesh merge */ func = RNA_def_function(srna, "remove", "ED_mesh_edges_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); @@ -2795,32 +2145,15 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop) #endif } -/* mesh.faces */ -static void rna_def_mesh_tessfaces(BlenderRNA *brna, PropertyRNA *cprop) +/* mesh.loop_triangles */ +static void rna_def_mesh_looptris(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; - PropertyRNA *prop; - FunctionRNA *func; -/* PropertyRNA *parm; */ - - RNA_def_property_srna(cprop, "MeshTessFaces"); - srna = RNA_def_struct(brna, "MeshTessFaces", NULL); + RNA_def_property_srna(cprop, "MeshLoopTriangle"); + srna = RNA_def_struct(brna, "MeshLoopTriangles", NULL); RNA_def_struct_sdna(srna, "Mesh"); - RNA_def_struct_ui_text(srna, "Mesh Faces", "Collection of mesh faces"); - - prop = RNA_def_property(srna, "active", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "act_face"); - RNA_def_property_ui_text(prop, "Active Face", "The active face for this mesh"); - - func = RNA_def_function(srna, "add", "ED_mesh_tessfaces_add"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to add", 0, INT_MAX); -#if 0 /* BMESH_TODO Remove until BMesh merge */ - func = RNA_def_function(srna, "remove", "ED_mesh_faces_remove"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to remove", 0, INT_MAX); -#endif + RNA_def_struct_ui_text(srna, "Mesh Loop Triangles", "Tessellation of mesh polygons into triangles"); } /* mesh.loops */ @@ -2831,7 +2164,7 @@ static void rna_def_mesh_loops(BlenderRNA *brna, PropertyRNA *cprop) /*PropertyRNA *prop;*/ FunctionRNA *func; - /*PropertyRNA *parm;*/ + PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshLoops"); srna = RNA_def_struct(brna, "MeshLoops", NULL); @@ -2840,7 +2173,8 @@ static void rna_def_mesh_loops(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "ED_mesh_loops_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of loops to add", 0, INT_MAX); + parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of loops to add", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } /* mesh.polygons */ @@ -2851,7 +2185,7 @@ static void rna_def_mesh_polygons(BlenderRNA *brna, PropertyRNA *cprop) PropertyRNA *prop; FunctionRNA *func; - /* PropertyRNA *parm; */ + PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshPolygons"); srna = RNA_def_struct(brna, "MeshPolygons", NULL); @@ -2864,47 +2198,11 @@ static void rna_def_mesh_polygons(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "ED_mesh_polys_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of polygons to add", 0, INT_MAX); + parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of polygons to add", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } -/* mesh.vertex_colors */ -static void rna_def_tessface_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - PropertyRNA *prop; - - FunctionRNA *func; - PropertyRNA *parm; - - RNA_def_property_srna(cprop, "VertexColors"); - srna = RNA_def_struct(brna, "VertexColors", NULL); - RNA_def_struct_sdna(srna, "Mesh"); - RNA_def_struct_ui_text(srna, "Vertex Colors", "Collection of vertex colors"); - - /* eventually deprecate this */ - func = RNA_def_function(srna, "new", "rna_Mesh_tessface_vertex_color_new"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh"); - RNA_def_string(func, "name", "Col", 0, "", "Vertex color name"); - parm = RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer"); - RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); - RNA_def_function_return(func, parm); - - prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "MeshColorLayer"); - RNA_def_property_pointer_funcs(prop, "rna_Mesh_tessface_vertex_color_active_get", - "rna_Mesh_tessface_vertex_color_active_set", NULL, NULL); - RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, "rna_Mesh_tessface_vertex_color_active_index_get", - "rna_Mesh_tessface_vertex_color_active_index_set", "rna_Mesh_vertex_color_index_range"); - RNA_def_property_ui_text(prop, "Active Vertex Color Index", "Active vertex color index"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); -} - static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -2938,13 +2236,13 @@ static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop) "rna_Mesh_vertex_color_active_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color"); prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_funcs(prop, "rna_Mesh_vertex_color_active_index_get", "rna_Mesh_vertex_color_active_index_set", "rna_Mesh_vertex_color_index_range"); RNA_def_property_ui_text(prop, "Active Vertex Color Index", "Active vertex color index"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color"); } static void rna_def_uv_layers(BlenderRNA *brna, PropertyRNA *cprop) @@ -2952,14 +2250,27 @@ static void rna_def_uv_layers(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; PropertyRNA *prop; - /* FunctionRNA *func; */ - /* PropertyRNA *parm; */ + FunctionRNA *func; + PropertyRNA *parm; RNA_def_property_srna(cprop, "UVLoopLayers"); srna = RNA_def_struct(brna, "UVLoopLayers", NULL); RNA_def_struct_sdna(srna, "Mesh"); RNA_def_struct_ui_text(srna, "UV Loop Layers", "Collection of uv loop layers"); + func = RNA_def_function(srna, "new", "rna_Mesh_uv_layers_new"); + RNA_def_function_ui_description(func, "Add a UV map layer to Mesh"); + RNA_def_string(func, "name", "UVMap", 0, "", "UV map name"); + parm = RNA_def_pointer(func, "layer", "MeshUVLoopLayer", "", "The newly created layer"); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Mesh_uv_layers_remove"); + RNA_def_function_ui_description(func, "Remove a vertex color layer"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "layer", "MeshUVLoopLayer", "", "The layer to remove"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "MeshUVLoopLayer"); RNA_def_property_pointer_funcs(prop, "rna_Mesh_uv_layer_active_get", @@ -3101,86 +2412,6 @@ static void rna_def_polygon_string_layers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); } -/* mesh.tessface_uv_layers */ -static void rna_def_tessface_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - PropertyRNA *prop; - - FunctionRNA *func; - PropertyRNA *parm; - - RNA_def_property_srna(cprop, "TessfaceUVTextures"); - srna = RNA_def_struct(brna, "TessfaceUVTextures", NULL); - RNA_def_struct_sdna(srna, "Mesh"); - RNA_def_struct_ui_text(srna, "UV Maps", "Collection of UV maps for tessellated faces"); - - /* eventually deprecate this */ - func = RNA_def_function(srna, "new", "rna_Mesh_tessface_uv_texture_new"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Add a UV tessface-texture layer to Mesh (only for meshes with no polygons)"); - RNA_def_string(func, "name", "UVMap", 0, "", "UV map name"); - parm = RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The newly created layer"); - RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); - RNA_def_function_return(func, parm); - - - prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); - RNA_def_property_pointer_funcs(prop, "rna_Mesh_tessface_uv_texture_active_get", - "rna_Mesh_tessface_uv_texture_active_set", NULL, NULL); - RNA_def_property_ui_text(prop, "Active UV Map", "Active UV Map"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, "rna_Mesh_tessface_uv_texture_active_index_get", - "rna_Mesh_tessface_uv_texture_active_index_set", "rna_Mesh_uv_texture_index_range"); - RNA_def_property_ui_text(prop, "Active UV Map Index", "Active UV Map index"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); -} - - -static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - PropertyRNA *prop; - - FunctionRNA *func; - PropertyRNA *parm; - - RNA_def_property_srna(cprop, "UVTextures"); - srna = RNA_def_struct(brna, "UVTextures", NULL); - RNA_def_struct_sdna(srna, "Mesh"); - RNA_def_struct_ui_text(srna, "UV Maps", "Collection of UV maps"); - - func = RNA_def_function(srna, "new", "rna_Mesh_uv_texture_new"); - RNA_def_function_ui_description(func, "Add a UV map layer to Mesh"); - RNA_def_string(func, "name", "UVMap", 0, "", "UV map name"); - parm = RNA_def_pointer(func, "layer", "MeshTexturePolyLayer", "", "The newly created layer"); - RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); - RNA_def_function_return(func, parm); - - func = RNA_def_function(srna, "remove", "rna_Mesh_uv_texture_layers_remove"); - RNA_def_function_ui_description(func, "Remove a vertex color layer"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "layer", "MeshTexturePolyLayer", "", "The layer to remove"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - - prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "MeshTexturePolyLayer"); - RNA_def_property_pointer_funcs(prop, "rna_Mesh_uv_texture_active_get", - "rna_Mesh_uv_texture_active_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); - RNA_def_property_ui_text(prop, "Active UV Map", "Active UV Map"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, "rna_Mesh_uv_texture_active_index_get", - "rna_Mesh_uv_texture_active_index_set", "rna_Mesh_uv_texture_index_range"); - RNA_def_property_ui_text(prop, "Active UV Map Index", "Active UV Map index"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); -} - static void rna_def_skin_vertices(BlenderRNA *brna, PropertyRNA *UNUSED(cprop)) { StructRNA *srna; @@ -3261,6 +2492,79 @@ static void rna_def_paint_mask(BlenderRNA *brna, PropertyRNA *UNUSED(cprop)) RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); } +static void rna_def_face_map(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "MeshFaceMapLayer", NULL); + RNA_def_struct_ui_text(srna, "Mesh Face Map Layer", "Per-face map index"); + RNA_def_struct_sdna(srna, "CustomDataLayer"); + RNA_def_struct_path_func(srna, "rna_MeshFaceMapLayer_path"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshPolyLayer_name_set"); + RNA_def_property_ui_text(prop, "Name", "Name of face-map layer"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "MeshFaceMap"); + RNA_def_property_ui_text(prop, "Data", ""); + RNA_def_property_collection_funcs(prop, "rna_MeshFaceMapLayer_data_begin", "rna_iterator_array_next", + "rna_iterator_array_end", "rna_iterator_array_get", + "rna_MeshFaceMapLayer_data_length", NULL, NULL, NULL); + + /* FaceMap struct */ + srna = RNA_def_struct(brna, "MeshFaceMap", NULL); + RNA_def_struct_sdna(srna, "MIntProperty"); + RNA_def_struct_ui_text(srna, "Int Property", ""); + RNA_def_struct_path_func(srna, "rna_MeshFaceMap_path"); + + prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "i"); + RNA_def_property_ui_text(prop, "Value", ""); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); +} + +static void rna_def_face_maps(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "MeshFaceMapLayers"); + srna = RNA_def_struct(brna, "MeshFaceMapLayers", NULL); + RNA_def_struct_ui_text(srna, "Mesh Face Map Layer", "Per-face map index"); + RNA_def_struct_sdna(srna, "Mesh"); + RNA_def_struct_ui_text(srna, "Mesh FaceMaps", "Collection of mesh face-maps"); + + /* add this since we only ever have one layer anyway, don't bother with active_index */ + prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "MeshFaceMapLayer"); + RNA_def_property_pointer_funcs(prop, "rna_Mesh_face_map_active_get", + NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Active FaceMap Layer", ""); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + FunctionRNA *func; + PropertyRNA *parm; + + func = RNA_def_function(srna, "new", "rna_Mesh_face_map_new"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Add a float property layer to Mesh"); + RNA_def_string(func, "name", "Face Map", 0, "", "Face map name"); + parm = RNA_def_pointer(func, "layer", "MeshFaceMapLayer", "", "The newly created layer"); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Mesh_face_map_remove"); + RNA_def_function_ui_description(func, "Remove a face map layer"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "layer", "MeshFaceMapLayer", "", "The layer to remove"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); +} + static void rna_def_mesh(BlenderRNA *brna) { StructRNA *srna; @@ -3282,12 +2586,6 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Edges", "Edges of the mesh"); rna_def_mesh_edges(brna, prop); - prop = RNA_def_property(srna, "tessfaces", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "mface", "totface"); - RNA_def_property_struct_type(prop, "MeshTessFace"); - RNA_def_property_ui_text(prop, "TessFaces", "Tessellated faces of the mesh (derived from polygons)"); - rna_def_mesh_tessfaces(brna, prop); - prop = RNA_def_property(srna, "loops", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "mloop", "totloop"); RNA_def_property_struct_type(prop, "MeshLoop"); @@ -3300,6 +2598,12 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Polygons", "Polygons of the mesh"); rna_def_mesh_polygons(brna, prop); + prop = RNA_def_property(srna, "loop_triangles", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "runtime.looptris.array", "runtime.looptris.len"); + RNA_def_property_struct_type(prop, "MeshLoopTriangle"); + RNA_def_property_ui_text(prop, "Loop Triangles", "Tessellation of mesh polygons into triangles"); + rna_def_mesh_looptris(brna, prop); + /* TODO, should this be allowed to be its self? */ prop = RNA_def_property(srna, "texture_mesh", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "texcomesh"); @@ -3340,62 +2644,6 @@ static void rna_def_mesh(BlenderRNA *brna) "rna_Mesh_uv_layer_stencil_index_set", "rna_Mesh_uv_layer_index_range"); RNA_def_property_ui_text(prop, "Mask UV loop layer Index", "Mask UV loop layer index"); - /* Tessellated face UV maps - used by renderers */ - prop = RNA_def_property(srna, "tessface_uv_textures", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_tessface_uv_textures_begin", NULL, NULL, NULL, - "rna_Mesh_tessface_uv_textures_length", NULL, NULL, NULL); - RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); - RNA_def_property_ui_text(prop, "Tessellated Face UV Maps", - "All UV maps for tessellated faces (read-only, for use by renderers)"); - rna_def_tessface_uv_textures(brna, prop); - - /* UV maps */ - prop = RNA_def_property(srna, "uv_textures", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "pdata.layers", "pdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_textures_begin", NULL, NULL, NULL, - "rna_Mesh_uv_textures_length", NULL, NULL, NULL); - RNA_def_property_struct_type(prop, "MeshTexturePolyLayer"); - RNA_def_property_ui_text(prop, "UV Maps", "All UV maps"); - rna_def_uv_textures(brna, prop); - - prop = RNA_def_property(srna, "uv_texture_clone", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "MeshTexturePolyLayer"); - RNA_def_property_pointer_funcs(prop, "rna_Mesh_uv_texture_clone_get", - "rna_Mesh_uv_texture_clone_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Clone UV Map", "UV map to be used as cloning source"); - - prop = RNA_def_property(srna, "uv_texture_clone_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, "rna_Mesh_uv_texture_clone_index_get", - "rna_Mesh_uv_texture_clone_index_set", "rna_Mesh_uv_texture_index_range"); - RNA_def_property_ui_text(prop, "Clone UV Map Index", "Clone UV map index"); - - prop = RNA_def_property(srna, "uv_texture_stencil", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "MeshTexturePolyLayer"); - RNA_def_property_pointer_funcs(prop, "rna_Mesh_uv_texture_stencil_get", - "rna_Mesh_uv_texture_stencil_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Mask UV Map", "UV map to mask the painted area"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - prop = RNA_def_property(srna, "uv_texture_stencil_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, "rna_Mesh_uv_texture_stencil_index_get", - "rna_Mesh_uv_texture_stencil_index_set", "rna_Mesh_uv_texture_index_range"); - RNA_def_property_ui_text(prop, "Mask UV Map Index", "Mask UV map index"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - - /* Tessellated face colors - used by renderers */ - - prop = RNA_def_property(srna, "tessface_vertex_colors", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_tessface_vertex_colors_begin", NULL, NULL, NULL, - "rna_Mesh_tessface_vertex_colors_length", NULL, NULL, NULL); - RNA_def_property_struct_type(prop, "MeshColorLayer"); - RNA_def_property_ui_text(prop, "Tessellated Face Colors", - "All tessellated face colors (read-only, for use by renderers)"); - rna_def_tessface_vertex_colors(brna, prop); - /* Vertex colors */ prop = RNA_def_property(srna, "vertex_colors", PROP_COLLECTION, PROP_NONE); @@ -3455,6 +2703,15 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_ui_text(prop, "String Property Layers", ""); rna_def_polygon_string_layers(brna, prop); + /* face-maps */ + prop = RNA_def_property(srna, "face_maps", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "pdata.layers", "pdata.totlayer"); + RNA_def_property_collection_funcs(prop, "rna_Mesh_face_maps_begin", NULL, NULL, NULL, + "rna_Mesh_face_maps_length", NULL, NULL, NULL); + RNA_def_property_struct_type(prop, "MeshFaceMapLayer"); + RNA_def_property_ui_text(prop, "FaceMap", ""); + rna_def_face_maps(brna, prop); + /* Skin vertices */ prop = RNA_def_property(srna, "skin_vertices", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer"); @@ -3538,109 +2795,11 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); #endif - /* Mesh Draw Options for Edit Mode*/ - - prop = RNA_def_property(srna, "show_edges", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEDGES); - RNA_def_property_ui_text(prop, "Draw Edges", - "Display selected edges using highlights in the 3D view and UV editor"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_faces", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWFACES); - RNA_def_property_ui_text(prop, "Draw Faces", "Display all faces as shades in the 3D view and UV editor"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_normal_face", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWNORMALS); - RNA_def_property_ui_text(prop, "Draw Normals", "Display face normals as lines"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_normal_loop", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_LNORMALS); - RNA_def_property_ui_text(prop, "Draw Split Normals", "Display vertex-per-face normals as lines"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_normal_vertex", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_VNORMALS); - RNA_def_property_ui_text(prop, "Draw Vertex Normals", "Display vertex normals as lines"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_weight", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEIGHT); - RNA_def_property_ui_text(prop, "Show Weights", "Draw weights in editmode"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_color"); /* needs to rebuild 'dm' */ - - prop = RNA_def_property(srna, "show_edge_crease", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWCREASES); - RNA_def_property_ui_text(prop, "Draw Creases", "Display creases created for Subdivision Surface modifier"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_edge_bevel_weight", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWBWEIGHTS); - RNA_def_property_ui_text(prop, "Draw Bevel Weights", "Display weights created for the Bevel modifier"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_edge_seams", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWSEAMS); - RNA_def_property_ui_text(prop, "Draw Seams", "Display UV unwrapping seams"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_edge_sharp", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWSHARP); - RNA_def_property_ui_text(prop, "Draw Sharp", "Display sharp edges, used with the Edge Split modifier"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_freestyle_edge_marks", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FREESTYLE_EDGE); - RNA_def_property_ui_text(prop, "Draw Freestyle Edge Marks", "Display Freestyle edge marks, used with the Freestyle renderer"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_freestyle_face_marks", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FREESTYLE_FACE); - RNA_def_property_ui_text(prop, "Draw Freestyle Face Marks", "Display Freestyle face marks, used with the Freestyle renderer"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_statvis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_STATVIS); - RNA_def_property_ui_text(prop, "Stat Vis", "Display statistical information about the mesh"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_color"); - - prop = RNA_def_property(srna, "show_extra_edge_length", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_EDGELEN); - RNA_def_property_ui_text(prop, "Edge Length", - "Display selected edge lengths, using global values when set in the transform panel"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_extra_edge_angle", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_EDGEANG); - RNA_def_property_ui_text(prop, "Edge Angle", - "Display selected edge angle, using global values when set in the transform panel"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_extra_face_angle", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_FACEANG); - RNA_def_property_ui_text(prop, "Face Angles", - "Display the angles in the selected edges, " - "using global values when set in the transform panel"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_extra_face_area", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_FACEAREA); - RNA_def_property_ui_text(prop, "Face Area", - "Display the area of selected faces, " - "using global values when set in the transform panel"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - - prop = RNA_def_property(srna, "show_extra_indices", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_INDICES); - RNA_def_property_ui_text(prop, "Indices", "Display the index numbers of selected vertices, edges, and faces"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - /* editflag */ prop = RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_X); RNA_def_property_ui_text(prop, "X Mirror", "X Axis mirror editing"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); #if 0 prop = RNA_def_property(srna, "use_mirror_y", PROP_BOOLEAN, PROP_NONE); @@ -3661,7 +2820,7 @@ static void rna_def_mesh(BlenderRNA *brna) prop = RNA_def_property(srna, "use_paint_mask", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_PAINT_FACE_SEL); RNA_def_property_ui_text(prop, "Paint Mask", "Face selection masking for painting"); - RNA_def_property_ui_icon(prop, ICON_FACESEL_HLT, 0); + RNA_def_property_ui_icon(prop, ICON_FACESEL, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Mesh_update_facemask"); prop = RNA_def_property(srna, "use_paint_mask_vertex", PROP_BOOLEAN, PROP_NONE); @@ -3720,15 +2879,13 @@ void RNA_def_mesh(BlenderRNA *brna) rna_def_mvert(brna); rna_def_mvert_group(brna); rna_def_medge(brna); - rna_def_mface(brna); + rna_def_mlooptri(brna); rna_def_mloop(brna); rna_def_mpolygon(brna); rna_def_mloopuv(brna); - rna_def_mtface(brna); - rna_def_mtexpoly(brna); - rna_def_mcol(brna); rna_def_mloopcol(brna); rna_def_mproperties(brna); + rna_def_face_map(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index 579898cce44..a08555794d8 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -48,7 +48,9 @@ #include "DNA_mesh_types.h" #include "BKE_mesh.h" +#include "BKE_mesh_tangent.h" #include "BKE_mesh_mapping.h" +#include "BKE_mesh_runtime.h" #include "ED_mesh.h" static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, struct Mesh *mesh2) @@ -92,7 +94,7 @@ static void rna_Mesh_calc_tangents(Mesh *mesh, ReportList *reports, const char * BKE_mesh_calc_normals_split(mesh); } - BKE_mesh_loop_tangents(mesh, uvmap, r_looptangents, reports); + BKE_mesh_calc_loop_tangent_single(mesh, uvmap, r_looptangents, reports); } static void rna_Mesh_free_tangents(Mesh *mesh) @@ -100,9 +102,9 @@ static void rna_Mesh_free_tangents(Mesh *mesh) CustomData_free_layers(&mesh->ldata, CD_MLOOPTANGENT, mesh->totloop); } -static void rna_Mesh_calc_tessface(Mesh *mesh, bool free_mpoly) +static void rna_Mesh_calc_looptri(Mesh *mesh) { - ED_mesh_calc_tessface(mesh, free_mpoly != 0); + BKE_mesh_runtime_looptri_ensure(mesh); } static void rna_Mesh_calc_smooth_groups(Mesh *mesh, bool use_bitflags, int *r_poly_group_len, @@ -172,7 +174,7 @@ static void rna_Mesh_normals_split_custom_set(Mesh *mesh, ReportList *reports, i rna_Mesh_normals_split_custom_do(mesh, loopnors, false); - DAG_id_tag_update(&mesh->id, 0); + DEG_id_tag_update(&mesh->id, 0); } static void rna_Mesh_normals_split_custom_set_from_vertices( @@ -190,14 +192,14 @@ static void rna_Mesh_normals_split_custom_set_from_vertices( rna_Mesh_normals_split_custom_do(mesh, vertnors, true); - DAG_id_tag_update(&mesh->id, 0); + DEG_id_tag_update(&mesh->id, 0); } static void rna_Mesh_transform(Mesh *mesh, float *mat, bool shape_keys) { BKE_mesh_transform(mesh, (float (*)[4])mat, shape_keys); - DAG_id_tag_update(&mesh->id, 0); + DEG_id_tag_update(&mesh->id, 0); } static void rna_Mesh_flip_normals(Mesh *mesh) @@ -205,8 +207,9 @@ static void rna_Mesh_flip_normals(Mesh *mesh) BKE_mesh_polygons_flip(mesh->mpoly, mesh->mloop, &mesh->ldata, mesh->totpoly); BKE_mesh_tessface_clear(mesh); BKE_mesh_calc_normals(mesh); + BKE_mesh_runtime_clear_geometry(mesh); - DAG_id_tag_update(&mesh->id, 0); + DEG_id_tag_update(&mesh->id, 0); } static void rna_Mesh_split_faces(Mesh *mesh, bool free_loop_normals) @@ -214,6 +217,12 @@ static void rna_Mesh_split_faces(Mesh *mesh, bool free_loop_normals) BKE_mesh_split_faces(mesh, free_loop_normals != 0); } +static void rna_Mesh_update_gpu_tag(Mesh *mesh) +{ + BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL); +} + + #else void RNA_api_mesh(StructRNA *srna) @@ -262,12 +271,8 @@ void RNA_api_mesh(StructRNA *srna) func = RNA_def_function(srna, "free_tangents", "rna_Mesh_free_tangents"); RNA_def_function_ui_description(func, "Free tangents"); - func = RNA_def_function(srna, "calc_tessface", "rna_Mesh_calc_tessface"); - RNA_def_function_ui_description(func, "Calculate face tessellation (supports editmode too)"); - RNA_def_boolean(func, "free_mpoly", 0, "Free MPoly", "Free data used by polygons and loops. " - "WARNING: This destructive operation removes regular faces, " - "only used on temporary mesh data-blocks to reduce memory footprint of render " - "engines and export scripts"); + func = RNA_def_function(srna, "calc_loop_triangles", "rna_Mesh_calc_looptri"); + RNA_def_function_ui_description(func, "Calculate loop triangle tessellation (supports editmode too)"); func = RNA_def_function(srna, "calc_smooth_groups", "rna_Mesh_calc_smooth_groups"); RNA_def_function_ui_description(func, "Calculate smooth groups from sharp edges"); @@ -301,9 +306,12 @@ void RNA_api_mesh(StructRNA *srna) func = RNA_def_function(srna, "update", "ED_mesh_update"); RNA_def_boolean(func, "calc_edges", 0, "Calculate Edges", "Force recalculation of edges"); - RNA_def_boolean(func, "calc_tessface", 0, "Calculate Tessellation", "Force recalculation of tessellation faces"); + RNA_def_boolean(func, "calc_edges_loose", 0, "Calculate Loose Edges", "Calculate the loose state of each edge"); + RNA_def_boolean(func, "calc_loop_triangles", 0, "Calculate Triangules", "Force recalculation of triangle tessellation"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function(srna, "update_gpu_tag", "rna_Mesh_update_gpu_tag"); + func = RNA_def_function(srna, "unit_test_compare", "rna_Mesh_unit_test_compare"); RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to compare to"); /* return value */ diff --git a/source/blender/makesrna/intern/rna_mesh_utils.h b/source/blender/makesrna/intern/rna_mesh_utils.h index 2bcce9d2a00..b16a7254a86 100644 --- a/source/blender/makesrna/intern/rna_mesh_utils.h +++ b/source/blender/makesrna/intern/rna_mesh_utils.h @@ -101,12 +101,6 @@ for (layer = data->layers + layer_index, a = 0; layer_index + a < data->totlayer; layer++, a++) { \ if (value.data == layer) { \ CustomData_set_layer_##active_type(data, layer_type, a); \ - \ - /* keep loops in sync */ \ - if (layer_type == CD_MTEXPOLY) { \ - CustomData *ldata = rna_mesh_ldata_helper(me); \ - CustomData_set_layer_##active_type(ldata, CD_MLOOPUV, a); \ - } \ BKE_mesh_update_customdata_pointers(me, true); \ return; \ } \ @@ -131,11 +125,6 @@ CustomData *data = rna_mesh_##customdata_type(ptr); \ if (data) { \ CustomData_set_layer_##active_type(data, layer_type, value); \ - /* keep loops in sync */ \ - if (layer_type == CD_MTEXPOLY) { \ - CustomData *ldata = rna_mesh_ldata_helper(me); \ - CustomData_set_layer_##active_type(ldata, CD_MLOOPUV, value); \ - } \ BKE_mesh_update_customdata_pointers(me, true); \ } \ } diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 7025e05d56c..af674cd2763 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -47,8 +47,10 @@ #include "DNA_object_types.h" #include "BKE_mball.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" +#include "BKE_scene.h" + +#include "DEG_depsgraph.h" #include "WM_types.h" #include "WM_api.h" @@ -101,9 +103,9 @@ static void rna_MetaBall_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) if (mb->id.us > 0) { for (ob = bmain->object.first; ob; ob = ob->id.next) if (ob->data == mb) - BKE_mball_properties_copy(bmain, bmain->eval_ctx, scene, ob); + BKE_mball_properties_copy(scene, ob); - DAG_id_tag_update(&mb->id, 0); + DEG_id_tag_update(&mb->id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, mb); } } @@ -121,7 +123,7 @@ static MetaElem *rna_MetaBall_elements_new(MetaBall *mb, int type) /* cheating way for importers to avoid slow updates */ if (mb->id.us > 0) { - DAG_id_tag_update(&mb->id, 0); + DEG_id_tag_update(&mb->id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, &mb->id); } @@ -142,7 +144,7 @@ static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, Poin /* cheating way for importers to avoid slow updates */ if (mb->id.us > 0) { - DAG_id_tag_update(&mb->id, 0); + DEG_id_tag_update(&mb->id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, &mb->id); } } @@ -153,7 +155,7 @@ static void rna_MetaBall_elements_clear(MetaBall *mb) /* cheating way for importers to avoid slow updates */ if (mb->id.us > 0) { - DAG_id_tag_update(&mb->id, 0); + DEG_id_tag_update(&mb->id, 0); WM_main_add_notifier(NC_GEOM | ND_DATA, &mb->id); } } diff --git a/source/blender/makesrna/intern/rna_meta_api.c b/source/blender/makesrna/intern/rna_meta_api.c index 4c3fa787b94..e747a849c12 100644 --- a/source/blender/makesrna/intern/rna_meta_api.c +++ b/source/blender/makesrna/intern/rna_meta_api.c @@ -47,7 +47,12 @@ static void rna_Meta_transform(struct MetaBall *mb, float *mat) { BKE_mball_transform(mb, (float (*)[4])mat, true); - DAG_id_tag_update(&mb->id, 0); + DEG_id_tag_update(&mb->id, 0); +} + +static void rna_Mball_update_gpu_tag(MetaBall *mb) +{ + BKE_mball_batch_cache_dirty_tag(mb, BKE_MBALL_BATCH_DIRTY_ALL); } #else @@ -60,6 +65,8 @@ void RNA_api_meta(StructRNA *srna) RNA_def_function_ui_description(func, "Transform meta elements by a matrix"); parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + RNA_def_function(srna, "update_gpu_tag", "rna_Mball_update_gpu_tag"); } #endif diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index f9b848744d6..b633dd907ae 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -45,12 +45,12 @@ #include "BKE_animsys.h" #include "BKE_data_transfer.h" -#include "BKE_DerivedMesh.h" #include "BKE_dynamicpaint.h" #include "BKE_effect.h" #include "BKE_mesh_mapping.h" #include "BKE_mesh_remap.h" #include "BKE_multires.h" +#include "BKE_ocean.h" #include "BKE_smoke.h" /* For smokeModifier_free & smokeModifier_createType */ #include "RNA_access.h" @@ -68,6 +68,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { {eModifierType_MeshCache, "MESH_CACHE", ICON_MOD_MESHDEFORM, "Mesh Cache", ""}, {eModifierType_MeshSequenceCache, "MESH_SEQUENCE_CACHE", ICON_MOD_MESHDEFORM, "Mesh Sequence Cache", ""}, {eModifierType_NormalEdit, "NORMAL_EDIT", ICON_MOD_NORMALEDIT, "Normal Edit", ""}, + {eModifierType_WeightedNormal, "WEIGHTED_NORMAL", ICON_MOD_NORMALEDIT, "Weighted Normal", ""}, {eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV Project", ""}, {eModifierType_UVWarp, "UV_WARP", ICON_MOD_UVPROJECT, "UV Warp", ""}, {eModifierType_WeightVGEdit, "VERTEX_WEIGHT_EDIT", ICON_MOD_VERTEX_WEIGHT, "Vertex Weight Edit", ""}, @@ -94,17 +95,17 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { {0, "", 0, N_("Deform"), ""}, {eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""}, {eModifierType_Cast, "CAST", ICON_MOD_CAST, "Cast", ""}, - {eModifierType_CorrectiveSmooth, "CORRECTIVE_SMOOTH", ICON_MOD_SMOOTH, "Corrective Smooth", ""}, {eModifierType_Curve, "CURVE", ICON_MOD_CURVE, "Curve", ""}, {eModifierType_Displace, "DISPLACE", ICON_MOD_DISPLACE, "Displace", ""}, {eModifierType_Hook, "HOOK", ICON_HOOK, "Hook", ""}, - {eModifierType_LaplacianSmooth, "LAPLACIANSMOOTH", ICON_MOD_SMOOTH, "Laplacian Smooth", ""}, {eModifierType_LaplacianDeform, "LAPLACIANDEFORM", ICON_MOD_MESHDEFORM, "Laplacian Deform", ""}, {eModifierType_Lattice, "LATTICE", ICON_MOD_LATTICE, "Lattice", ""}, {eModifierType_MeshDeform, "MESH_DEFORM", ICON_MOD_MESHDEFORM, "Mesh Deform", ""}, {eModifierType_Shrinkwrap, "SHRINKWRAP", ICON_MOD_SHRINKWRAP, "Shrinkwrap", ""}, {eModifierType_SimpleDeform, "SIMPLE_DEFORM", ICON_MOD_SIMPLEDEFORM, "Simple Deform", ""}, {eModifierType_Smooth, "SMOOTH", ICON_MOD_SMOOTH, "Smooth", ""}, + {eModifierType_CorrectiveSmooth, "CORRECTIVE_SMOOTH", ICON_MOD_SMOOTH, "Smooth Corrective", ""}, + {eModifierType_LaplacianSmooth, "LAPLACIANSMOOTH", ICON_MOD_SMOOTH, "Smooth Laplacian", ""}, {eModifierType_SurfaceDeform, "SURFACE_DEFORM", ICON_MOD_MESHDEFORM, "Surface Deform", ""}, {eModifierType_Warp, "WARP", ICON_MOD_WARP, "Warp", ""}, {eModifierType_Wave, "WAVE", ICON_MOD_WAVE, "Wave", ""}, @@ -115,11 +116,11 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { {eModifierType_Explode, "EXPLODE", ICON_MOD_EXPLODE, "Explode", ""}, {eModifierType_Fluidsim, "FLUID_SIMULATION", ICON_MOD_FLUIDSIM, "Fluid Simulation", ""}, {eModifierType_Ocean, "OCEAN", ICON_MOD_OCEAN, "Ocean", ""}, - {eModifierType_ParticleInstance, "PARTICLE_INSTANCE", ICON_MOD_PARTICLES, "Particle Instance", ""}, + {eModifierType_ParticleInstance, "PARTICLE_INSTANCE", ICON_MOD_PARTICLE_INSTANCE, "Particle Instance", ""}, {eModifierType_ParticleSystem, "PARTICLE_SYSTEM", ICON_MOD_PARTICLES, "Particle System", ""}, {eModifierType_Smoke, "SMOKE", ICON_MOD_SMOKE, "Smoke", ""}, {eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""}, - {eModifierType_Surface, "SURFACE", ICON_MOD_PHYSICS, "Surface", ""}, + {eModifierType_Surface, "SURFACE", ICON_MODIFIER, "Surface", ""}, {0, NULL, 0, NULL, NULL} }; @@ -139,6 +140,24 @@ const EnumPropertyItem rna_enum_modifier_triangulate_ngon_method_items[] = { {0, NULL, 0, NULL, NULL} }; +const EnumPropertyItem rna_enum_modifier_shrinkwrap_mode_items[] = { + {MOD_SHRINKWRAP_ON_SURFACE, "ON_SURFACE", 0, "On Surface", + "The point is constrained to the surface of the target object, " + "with distance offset towards the original point location"}, + {MOD_SHRINKWRAP_INSIDE, "INSIDE", 0, "Inside", + "The point is constrained to be inside the target object"}, + {MOD_SHRINKWRAP_OUTSIDE, "OUTSIDE", 0, "Outside", + "The point is constrained to be outside the target object"}, + {MOD_SHRINKWRAP_OUTSIDE_SURFACE, "OUTSIDE_SURFACE", 0, "Outside Surface", + "The point is constrained to the surface of the target object, " + "with distance offset always to the outside, towards or away from the original location"}, + {MOD_SHRINKWRAP_ABOVE_SURFACE, "ABOVE_SURFACE", 0, "Above Surface", + "The point is constrained to the surface of the target object, " + "with distance offset applied exactly along the target normal"}, + {0, NULL, 0, NULL, NULL} +}; + + #ifndef RNA_RUNTIME /* use eWarp_Falloff_*** & eHook_Falloff_***, they're in sync */ static const EnumPropertyItem modifier_warp_falloff_items[] = { @@ -286,12 +305,14 @@ const EnumPropertyItem rna_enum_axis_flag_xyz_items[] = { #include "BKE_cachefile.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" -#include "BKE_library.h" +#include "BKE_mesh_runtime.h" #include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_particle.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #ifdef WITH_ALEMBIC # include "ABC_alembic.h" #endif @@ -411,6 +432,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr) return &RNA_MeshSequenceCacheModifier; case eModifierType_SurfaceDeform: return &RNA_SurfaceDeformModifier; + case eModifierType_WeightedNormal: + return &RNA_WeightedNormalModifier; /* Default */ case eModifierType_None: case eModifierType_ShapeKey: @@ -453,14 +476,14 @@ static char *rna_Modifier_path(PointerRNA *ptr) static void rna_Modifier_update(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, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->id.data); } static void rna_Modifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) { rna_Modifier_update(bmain, scene, ptr); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } /* Vertex Groups */ @@ -501,6 +524,7 @@ RNA_MOD_VGROUP_NAME_SET(WeightVGMix, defgrp_name_b); RNA_MOD_VGROUP_NAME_SET(WeightVGMix, mask_defgrp_name); RNA_MOD_VGROUP_NAME_SET(WeightVGProximity, defgrp_name); RNA_MOD_VGROUP_NAME_SET(WeightVGProximity, mask_defgrp_name); +RNA_MOD_VGROUP_NAME_SET(WeightedNormal, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Wireframe, defgrp_name); static void rna_ExplodeModifier_vgroup_get(PointerRNA *ptr, char *value) @@ -689,15 +713,13 @@ static int rna_MultiresModifier_filepath_length(PointerRNA *ptr) static int rna_ShrinkwrapModifier_face_cull_get(PointerRNA *ptr) { ShrinkwrapModifierData *swm = (ShrinkwrapModifierData *)ptr->data; - return swm->shrinkOpts & (MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE | MOD_SHRINKWRAP_CULL_TARGET_BACKFACE); + return swm->shrinkOpts & MOD_SHRINKWRAP_CULL_TARGET_MASK; } static void rna_ShrinkwrapModifier_face_cull_set(struct PointerRNA *ptr, int value) { ShrinkwrapModifierData *swm = (ShrinkwrapModifierData *)ptr->data; - - swm->shrinkOpts = - (swm->shrinkOpts & ~(MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE | MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) | value; + swm->shrinkOpts = (swm->shrinkOpts & ~MOD_SHRINKWRAP_CULL_TARGET_MASK) | value; } static bool rna_MeshDeformModifier_is_bound_get(PointerRNA *ptr) @@ -714,7 +736,7 @@ static PointerRNA rna_SoftBodyModifier_settings_get(PointerRNA *ptr) static PointerRNA rna_SoftBodyModifier_point_cache_get(PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; - return rna_pointer_inherit_refine(ptr, &RNA_PointCache, ob->soft->pointcache); + return rna_pointer_inherit_refine(ptr, &RNA_PointCache, ob->soft->shared->pointcache); } static PointerRNA rna_CollisionModifier_settings_get(PointerRNA *ptr) @@ -737,8 +759,7 @@ static void rna_OceanModifier_init_update(Main *bmain, Scene *scene, PointerRNA { OceanModifierData *omd = (OceanModifierData *)ptr->data; - omd->refresh |= MOD_OCEAN_REFRESH_RESET | MOD_OCEAN_REFRESH_CLEAR_CACHE; - + BKE_ocean_free_modifier_cache(omd); rna_Modifier_update(bmain, scene, ptr); } @@ -752,8 +773,7 @@ static void rna_OceanModifier_ocean_chop_set(PointerRNA *ptr, float value) if ((old_value == 0.0f && value > 0.0f) || (old_value > 0.0f && value == 0.0f)) { - omd->refresh |= MOD_OCEAN_REFRESH_RESET; - omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE; + BKE_ocean_free_modifier_cache(omd); } } @@ -775,11 +795,11 @@ static void rna_CurveModifier_dependency_update(Main *bmain, Scene *scene, Point { CurveModifierData *cmd = (CurveModifierData *)ptr->data; rna_Modifier_update(bmain, scene, ptr); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); if (cmd->object != NULL) { Curve *curve = cmd->object->data; if ((curve->flag & CU_PATH) == 0) { - DAG_id_tag_update(&curve->id, OB_RECALC_DATA); + DEG_id_tag_update(&curve->id, OB_RECALC_DATA); } } } @@ -788,11 +808,11 @@ static void rna_ArrayModifier_dependency_update(Main *bmain, Scene *scene, Point { ArrayModifierData *amd = (ArrayModifierData *)ptr->data; rna_Modifier_update(bmain, scene, ptr); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); if (amd->curve_ob != NULL) { Curve *curve = amd->curve_ob->data; if ((curve->flag & CU_PATH) == 0) { - DAG_id_tag_update(&curve->id, OB_RECALC_DATA); + DEG_id_tag_update(&curve->id, OB_RECALC_DATA); } } } @@ -815,7 +835,7 @@ static void rna_DataTransferModifier_use_data_update(Main *bmain, Scene *scene, dtmd->data_types &= ~DT_TYPE_POLY_ALL; } - rna_Modifier_update(bmain, scene, ptr); + rna_Modifier_dependency_update(bmain, scene, ptr); } static void rna_DataTransferModifier_data_types_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -836,7 +856,7 @@ static void rna_DataTransferModifier_data_types_update(Main *bmain, Scene *scene dtmd->flags |= MOD_DATATRANSFER_USE_POLY; } - rna_Modifier_update(bmain, scene, ptr); + rna_Modifier_dependency_update(bmain, scene, ptr); } static void rna_DataTransferModifier_verts_data_types_set(struct PointerRNA *ptr, int value) @@ -881,6 +901,9 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( return rna_enum_dt_layers_select_src_items; } + Depsgraph *depsgraph = CTX_data_depsgraph(C); + Scene *scene = CTX_data_scene(C); + /* No active here! */ RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC); @@ -914,22 +937,18 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( Object *ob_src = dtmd->ob_source; if (ob_src) { - DerivedMesh *dm_src; - CustomData *pdata; + Mesh *me_eval; int num_data, i; - dm_src = object_get_derived_final(ob_src, false); - if (dm_src != NULL) { - pdata = dm_src->getPolyDataLayout(dm_src); - num_data = CustomData_number_of_layers(pdata, CD_MTEXPOLY); + me_eval = mesh_get_eval_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPUV); + num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV); - RNA_enum_item_add_separator(&item, &totitem); + RNA_enum_item_add_separator(&item, &totitem); - for (i = 0; i < num_data; i++) { - tmp_item.value = i; - tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(pdata, CD_MTEXPOLY, i); - RNA_enum_item_add(&item, &totitem, &tmp_item); - } + for (i = 0; i < num_data; i++) { + tmp_item.value = i; + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(&me_eval->ldata, CD_MLOOPUV, i); + RNA_enum_item_add(&item, &totitem, &tmp_item); } } } @@ -937,22 +956,18 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( Object *ob_src = dtmd->ob_source; if (ob_src) { - DerivedMesh *dm_src; - CustomData *ldata; + Mesh *me_eval; int num_data, i; - dm_src = object_get_derived_final(ob_src, false); - if (dm_src != NULL) { - ldata = dm_src->getLoopDataLayout(dm_src); - num_data = CustomData_number_of_layers(ldata, CD_MLOOPCOL); + me_eval = mesh_get_eval_final(depsgraph, scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL); + num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL); - RNA_enum_item_add_separator(&item, &totitem); + RNA_enum_item_add_separator(&item, &totitem); - for (i = 0; i < num_data; i++) { - tmp_item.value = i; - tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(ldata, CD_MLOOPCOL, i); - RNA_enum_item_add(&item, &totitem, &tmp_item); - } + for (i = 0; i < num_data; i++) { + tmp_item.value = i; + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(&me_eval->ldata, CD_MLOOPCOL, i); + RNA_enum_item_add(&item, &totitem, &tmp_item); } } } @@ -1006,18 +1021,18 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_dst_itemf( if (ob_dst && ob_dst->data) { Mesh *me_dst; - CustomData *pdata; + CustomData *ldata; int num_data, i; me_dst = ob_dst->data; - pdata = &me_dst->pdata; - num_data = CustomData_number_of_layers(pdata, CD_MTEXPOLY); + ldata = &me_dst->ldata; + num_data = CustomData_number_of_layers(ldata, CD_MLOOPUV); RNA_enum_item_add_separator(&item, &totitem); for (i = 0; i < num_data; i++) { tmp_item.value = i; - tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(pdata, CD_MTEXPOLY, i); + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(ldata, CD_MLOOPUV, i); RNA_enum_item_add(&item, &totitem, &tmp_item); } } @@ -1176,15 +1191,53 @@ static void rna_ParticleInstanceModifier_particle_system_set(PointerRNA *ptr, co #else +/* NOTE: *MUST* return subdivision_type property. */ static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[]) { static const EnumPropertyItem prop_subdivision_type_items[] = { - {0, "CATMULL_CLARK", 0, "Catmull-Clark", ""}, - {1, "SIMPLE", 0, "Simple", ""}, + {SUBSURF_TYPE_CATMULL_CLARK, "CATMULL_CLARK", 0, "Catmull-Clark", ""}, + {SUBSURF_TYPE_SIMPLE, "SIMPLE", 0, "Simple", ""}, {0, NULL, 0, NULL, NULL} }; - PropertyRNA *prop = RNA_def_property(srna, "subdivision_type", PROP_ENUM, PROP_NONE); + static const EnumPropertyItem prop_uv_smooth_items[] = { + {SUBSURF_UV_SMOOTH_NONE, "NONE", 0, + "Sharp", "UVs are not smoothed, boundaries are kept sharp"}, + {SUBSURF_UV_SMOOTH_PRESERVE_CORNERS, "PRESERVE_CORNERS", 0, + "Smooth, keep corners", "UVs are smoothed, corners on discontinuous boundary are kept sharp"}, +#if 0 + {SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_AND_JUNCTIONS, "PRESERVE_CORNERS_AND_JUNCTIONS", 0, + "Smooth, keep corners+junctions", "UVs are smoothed, corners on discontinuous boundary and " + "junctions of 3 or more regions are kept sharp"}, + {SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE, "PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE", 0, + "Smooth, keep corners+junctions+concave", "UVs are smoothed, corners on discontinuous boundary, " + "junctions of 3 or more regions and darts and concave corners are kept sharp"}, + {SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES, "PRESERVE_BOUNDARIES", 0, + "Smooth, keep corners", "UVs are smoothed, boundaries are kept sharp"}, + {SUBSURF_UV_SMOOTH_ALL, "PRESERVE_BOUNDARIES", 0, + "Smooth all", "UVs and boundaries are smoothed"}, +#endif + {0, NULL, 0, NULL, NULL} + }; + + PropertyRNA *prop; + + prop = RNA_def_property(srna, "uv_smooth", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "uv_smooth"); + RNA_def_property_enum_items(prop, prop_uv_smooth_items); + RNA_def_property_ui_text(prop, "UV Smooth", "Controls how smoothing is applied to UVs"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + +#ifdef WITH_OPENSUBDIV_MODIFIER + prop = RNA_def_property(srna, "quality", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "quality"); + RNA_def_property_range(prop, 1, 10); + RNA_def_property_ui_range(prop, 1, 6, 1, -1); + RNA_def_property_ui_text(prop, "Quality", "Accuracy of vertex positions, lower value is faster but less precise"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +#endif + + prop = RNA_def_property(srna, "subdivision_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, type); RNA_def_property_enum_items(prop, prop_subdivision_type_items); RNA_def_property_ui_text(prop, "Subdivision Type", "Select type of subdivision algorithm"); @@ -1223,18 +1276,6 @@ static void rna_def_modifier_subsurf(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", eSubsurfModifierFlag_ControlEdges); RNA_def_property_ui_text(prop, "Optimal Display", "Skip drawing/rendering of interior subdivided edges"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_subsurf_uv", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", eSubsurfModifierFlag_SubsurfUv); - RNA_def_property_ui_text(prop, "Subdivide UVs", "Use subsurf to subdivide UVs"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - -#ifdef WITH_OPENSUBDIV - prop = RNA_def_property(srna, "use_opensubdiv", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "use_opensubdiv", 1); - RNA_def_property_ui_text(prop, "Use OpenSubdiv", "Use OpenSubdiv for the subdivisions (viewport only)"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); -#endif } static void rna_def_modifier_generic_map_info(StructRNA *srna) @@ -1312,7 +1353,7 @@ static void rna_def_modifier_warp(BlenderRNA *brna) prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curfalloff"); - RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve"); + RNA_def_property_ui_text(prop, "Falloff Curve", "Custom falloff curve"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_volume_preserve", PROP_BOOLEAN, PROP_NONE); @@ -1380,11 +1421,6 @@ static void rna_def_modifier_multires(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", eMultiresModifierFlag_ControlEdges); RNA_def_property_ui_text(prop, "Optimal Display", "Skip drawing/rendering of interior subdivided edges"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_subsurf_uv", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", eMultiresModifierFlag_PlainUv); - RNA_def_property_ui_text(prop, "Subdivide UVs", "Use subsurf to subdivide UVs"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_lattice(BlenderRNA *brna) @@ -1835,6 +1871,7 @@ static void rna_def_modifier_armature(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Object", "Armature object to deform with"); RNA_def_property_pointer_funcs(prop, NULL, "rna_ArmatureModifier_object_set", NULL, "rna_Armature_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); prop = RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE); @@ -1902,7 +1939,7 @@ static void rna_def_modifier_hook(BlenderRNA *brna) prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curfalloff"); - RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve"); + RNA_def_property_ui_text(prop, "Falloff Curve", "Custom falloff curve"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "center", PROP_FLOAT, PROP_NONE); @@ -2264,11 +2301,6 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Projectors", ""); - prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); - RNA_def_property_ui_text(prop, "Image", ""); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - prop = RNA_def_property(srna, "aspect_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "aspectx"); RNA_def_property_flag(prop, PROP_PROPORTIONAL); @@ -2301,11 +2333,6 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Vertical Scale", ""); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - prop = RNA_def_property(srna, "use_image_override", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_UVPROJECT_OVERRIDEIMAGE); - RNA_def_property_ui_text(prop, "Override Image", "Override faces' current images with the given image"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - srna = RNA_def_struct(brna, "UVProjector", NULL); RNA_def_struct_ui_text(srna, "UVProjector", "UV projector used by the UV project modifier"); @@ -3014,6 +3041,14 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem prop_harden_normals_items[] = { + { MOD_BEVEL_HN_NONE, "HN_NONE", 0, "Off", "Do not use Harden Normals" }, + { MOD_BEVEL_HN_FACE, "HN_FACE", 0, "Face Area", "Use faces as weight" }, + { MOD_BEVEL_HN_ADJ, "HN_ADJ", 0, "Vertex average", "Use adjacent vertices as weight" }, + { MOD_BEVEL_FIX_SHA, "FIX_SHA", 0, "Fix shading", "Fix normal shading continuity" }, + { 0, NULL, 0, NULL, NULL }, + }; + srna = RNA_def_struct(brna, "BevelModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Bevel Modifier", "Bevel modifier to make edges and vertices more rounded"); RNA_def_struct_sdna(srna, "BevelModifierData"); @@ -3090,6 +3125,33 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", MOD_BEVEL_EVEN_WIDTHS); RNA_def_property_ui_text(prop, "Loop Slide", "Prefer sliding along edges to having even widths"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "mark_seam", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "edge_flags", MOD_BEVEL_MARK_SEAM); + RNA_def_property_ui_text(prop, "Mark Seams", "Mark Seams along beveled edges"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "mark_sharp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "edge_flags", MOD_BEVEL_MARK_SHARP); + RNA_def_property_ui_text(prop, "Mark Sharp", "Mark beveled edges as sharp"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "hnmode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_harden_normals_items); + RNA_def_property_ui_text(prop, "Normal Mode", "Weighting mode for Harden Normals"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "hn_strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_range(prop, 0, 1, 1, 2); + RNA_def_property_ui_text(prop, "Normal Strength", "Strength of calculated normal"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "set_wn_strength", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_BEVEL_SET_WN_STR); + RNA_def_property_ui_text(prop, "Face Strength", "Set face strength of beveled faces for use in WN Modifier"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) @@ -3104,6 +3166,9 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) "Shrink the mesh to the nearest target surface along a given axis"}, {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", 0, "Nearest Vertex", "Shrink the mesh to the nearest target vertex"}, + {MOD_SHRINKWRAP_TARGET_PROJECT, "TARGET_PROJECT", 0, "Target Normal Project", + "Shrink the mesh to the nearest target surface " + "along the interpolated vertex normals of the target"}, {0, NULL, 0, NULL, NULL} }; @@ -3124,7 +3189,13 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "shrinkType"); RNA_def_property_enum_items(prop, shrink_type_items); RNA_def_property_ui_text(prop, "Mode", ""); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); + RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + + prop = RNA_def_property(srna, "wrap_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "shrinkMode"); + RNA_def_property_enum_items(prop, rna_enum_modifier_shrinkwrap_mode_items); + RNA_def_property_ui_text(prop, "Snap Mode", "Select how vertices are constrained to the target surface"); + RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); prop = RNA_def_property(srna, "cull_face", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "shrinkOpts"); @@ -3202,9 +3273,9 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Positive", "Allow vertices to move in the positive direction of axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - prop = RNA_def_property(srna, "use_keep_above_surface", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shrinkOpts", MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE); - RNA_def_property_ui_text(prop, "Keep Above Surface", ""); + prop = RNA_def_property(srna, "use_invert_cull", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shrinkOpts", MOD_SHRINKWRAP_INVERT_CULL_TARGET); + RNA_def_property_ui_text(prop, "Invert Cull", "When projecting in the negative direction invert the face cull mode"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); @@ -4897,6 +4968,68 @@ static void rna_def_modifier_surfacedeform(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); } +static void rna_def_modifier_weightednormal(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_weighting_mode_items[] = { + {MOD_WEIGHTEDNORMAL_MODE_FACE, "FACE_AREA", 0, "Face Area", "Generate face area weighted normals"}, + {MOD_WEIGHTEDNORMAL_MODE_ANGLE, "CORNER_ANGLE", 0, "Corner Angle", "Generate corner angle weighted normals"}, + {MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE, "FACE_AREA_WITH_ANGLE", 0, "Face Area And Angle", + "Generated normals weighted by both face area and angle"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "WeightedNormalModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "WeightedNormal Modifier", ""); + RNA_def_struct_sdna(srna, "WeightedNormalModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_NORMALEDIT); + + prop = RNA_def_property(srna, "weight", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 1, 100); + RNA_def_property_ui_range(prop, 1, 100, 1, -1); + RNA_def_property_ui_text(prop, "Weight", + "Corrective factor applied to faces' weights, 50 is neutral, " + "lower values increase weight of weak faces, " + "higher values increase weight of strong faces"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_weighting_mode_items); + RNA_def_property_ui_text(prop, "Weighting Mode", "Weighted vertex normal mode to use"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "thresh", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0, 10); + RNA_def_property_ui_range(prop, 0, 10, 1, 2); + RNA_def_property_ui_text(prop, "Threshold", "Threshold value for different weights to be considered equal"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "keep_sharp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WEIGHTEDNORMAL_KEEP_SHARP); + RNA_def_property_ui_text(prop, "Keep Sharp", + "Keep sharp edges as computed for default split normals, " + "instead of setting a single weighted normal for each vertex"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modifying the selected areas"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeightedNormalModifier_defgrp_name_set"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WEIGHTEDNORMAL_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "face_influence", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WEIGHTEDNORMAL_FACE_INFLUENCE); + RNA_def_property_ui_text(prop, "Face Influence", "Use influence of face for weighting"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +} + void RNA_def_modifier(BlenderRNA *brna) { StructRNA *srna; @@ -4928,13 +5061,15 @@ void RNA_def_modifier(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Realtime); RNA_def_property_ui_text(prop, "Realtime", "Display modifier in viewport"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 0); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_ON, 1); prop = RNA_def_property(srna, "show_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Render); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Render", "Use modifier during render"); - RNA_def_property_ui_icon(prop, ICON_SCENE, 0); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_ON, 1); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL); prop = RNA_def_property(srna, "show_in_editmode", PROP_BOOLEAN, PROP_NONE); @@ -4951,6 +5086,7 @@ void RNA_def_modifier(BlenderRNA *brna) prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Expanded); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface"); RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); @@ -5015,6 +5151,7 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_normaledit(brna); rna_def_modifier_meshseqcache(brna); rna_def_modifier_surfacedeform(brna); + rna_def_modifier_weightednormal(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c index 3639c8547ba..aedaeccc0b6 100644 --- a/source/blender/makesrna/intern/rna_movieclip.c +++ b/source/blender/makesrna/intern/rna_movieclip.c @@ -49,7 +49,7 @@ #ifdef RNA_RUNTIME -#include "BKE_depsgraph.h" +#include "DEG_depsgraph.h" #include "ED_clip.h" @@ -61,7 +61,7 @@ static void rna_MovieClip_reload_update(Main *bmain, Scene *UNUSED(scene), Point MovieClip *clip = (MovieClip *)ptr->id.data; BKE_movieclip_reload(bmain, clip); - DAG_id_tag_update(&clip->id, 0); + DEG_id_tag_update(&clip->id, 0); } static void rna_MovieClip_size_get(PointerRNA *ptr, int *values) @@ -230,11 +230,11 @@ static void rna_def_moviecliUser(BlenderRNA *brna) PropertyRNA *prop; static const EnumPropertyItem clip_render_size_items[] = { - {MCLIP_PROXY_RENDER_SIZE_25, "PROXY_25", 0, "Proxy size 25%", ""}, - {MCLIP_PROXY_RENDER_SIZE_50, "PROXY_50", 0, "Proxy size 50%", ""}, - {MCLIP_PROXY_RENDER_SIZE_75, "PROXY_75", 0, "Proxy size 75%", ""}, - {MCLIP_PROXY_RENDER_SIZE_100, "PROXY_100", 0, "Proxy size 100%", ""}, - {MCLIP_PROXY_RENDER_SIZE_FULL, "FULL", 0, "No proxy, full render", ""}, + {MCLIP_PROXY_RENDER_SIZE_25, "PROXY_25", 0, "25%", ""}, + {MCLIP_PROXY_RENDER_SIZE_50, "PROXY_50", 0, "50%", ""}, + {MCLIP_PROXY_RENDER_SIZE_75, "PROXY_75", 0, "75%", ""}, + {MCLIP_PROXY_RENDER_SIZE_100, "PROXY_100", 0, "100%", ""}, + {MCLIP_PROXY_RENDER_SIZE_FULL, "FULL", 0, "None, full render", ""}, {0, NULL, 0, NULL, NULL} }; @@ -251,7 +251,7 @@ static void rna_def_moviecliUser(BlenderRNA *brna) prop = RNA_def_property(srna, "proxy_render_size", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "render_size"); RNA_def_property_enum_items(prop, clip_render_size_items); - RNA_def_property_ui_text(prop, "Proxy render size", + RNA_def_property_ui_text(prop, "Proxy Render Size", "Draw preview using full resolution or different proxy resolutions"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClipUser_proxy_render_settings_update"); @@ -338,6 +338,7 @@ static void rna_def_movieclip(BlenderRNA *brna) 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_annotations_poll"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this movie clip"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 09b194d0e1b..48be6421f36 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -50,7 +50,6 @@ /* needed for some of the validation stuff... */ #include "BKE_animsys.h" -#include "BKE_depsgraph.h" #include "BKE_fcurve.h" #include "BKE_nla.h" @@ -384,7 +383,7 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo if (BKE_nlastrips_add_strip(&track->strips, strip) == 0) { BKE_report(reports, RPT_ERROR, "Unable to add strip (the track does not have any space to accommodate this new strip)"); - BKE_nlastrip_free(NULL, strip); + BKE_nlastrip_free(NULL, strip, true); return NULL; } @@ -425,7 +424,7 @@ static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *report return; } - BKE_nlastrip_free(&track->strips, strip); + BKE_nlastrip_free(&track->strips, strip, true); RNA_POINTER_INVALIDATE(strip_ptr); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 68f0272c035..42abf76901c 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -43,7 +43,6 @@ #include "DNA_texture_types.h" #include "BKE_animsys.h" -#include "BKE_main.h" #include "BKE_node.h" #include "BKE_image.h" #include "BKE_texture.h" @@ -66,6 +65,9 @@ #include "NOD_composite.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + const EnumPropertyItem rna_enum_node_socket_in_out_items[] = { { SOCK_IN, "IN", 0, "Input", "" }, { SOCK_OUT, "OUT", 0, "Output", "" }, @@ -110,41 +112,35 @@ static const EnumPropertyItem node_chunksize_items[] = { }; #endif -#define DEF_ICON_BLANK_SKIP -#define DEF_ICON(name) {ICON_##name, (#name), 0, (#name), ""}, -#define DEF_VICO(name) -const EnumPropertyItem rna_enum_node_icon_items[] = { -#include "UI_icons.h" - {0, NULL, 0, NULL, NULL}}; -#undef DEF_ICON_BLANK_SKIP -#undef DEF_ICON -#undef DEF_VICO - const EnumPropertyItem rna_enum_node_math_items[] = { {NODE_MATH_ADD, "ADD", 0, "Add", ""}, {NODE_MATH_SUB, "SUBTRACT", 0, "Subtract", ""}, {NODE_MATH_MUL, "MULTIPLY", 0, "Multiply", ""}, {NODE_MATH_DIVIDE, "DIVIDE", 0, "Divide", ""}, - {NODE_MATH_SIN, "SINE", 0, "Sine", ""}, - {NODE_MATH_COS, "COSINE", 0, "Cosine", ""}, - {NODE_MATH_TAN, "TANGENT", 0, "Tangent", ""}, - {NODE_MATH_ASIN, "ARCSINE", 0, "Arcsine", ""}, - {NODE_MATH_ACOS, "ARCCOSINE", 0, "Arccosine", ""}, - {NODE_MATH_ATAN, "ARCTANGENT", 0, "Arctangent", ""}, + {0, "", ICON_NONE, NULL, NULL}, {NODE_MATH_POW, "POWER", 0, "Power", ""}, {NODE_MATH_LOG, "LOGARITHM", 0, "Logarithm", ""}, + {NODE_MATH_SQRT, "SQRT", 0, "Square Root", ""}, + {NODE_MATH_ABS, "ABSOLUTE", 0, "Absolute", ""}, + {0, "", ICON_NONE, NULL, NULL}, {NODE_MATH_MIN, "MINIMUM", 0, "Minimum", ""}, {NODE_MATH_MAX, "MAXIMUM", 0, "Maximum", ""}, - {NODE_MATH_ROUND, "ROUND", 0, "Round", ""}, {NODE_MATH_LESS, "LESS_THAN", 0, "Less Than", ""}, {NODE_MATH_GREATER, "GREATER_THAN", 0, "Greater Than", ""}, - {NODE_MATH_MOD, "MODULO", 0, "Modulo", ""}, - {NODE_MATH_ABS, "ABSOLUTE", 0, "Absolute", ""}, - {NODE_MATH_ATAN2, "ARCTAN2", 0, "Arctan2", ""}, + {0, "", ICON_NONE, NULL, NULL}, + {NODE_MATH_ROUND, "ROUND", 0, "Round", ""}, {NODE_MATH_FLOOR, "FLOOR", 0, "Floor", ""}, {NODE_MATH_CEIL, "CEIL", 0, "Ceil", ""}, {NODE_MATH_FRACT, "FRACT", 0, "Fract", ""}, - {NODE_MATH_SQRT, "SQRT", 0, "Square Root", ""}, + {NODE_MATH_MOD, "MODULO", 0, "Modulo", ""}, + {0, "", ICON_NONE, NULL, NULL}, + {NODE_MATH_SIN, "SINE", 0, "Sine", ""}, + {NODE_MATH_COS, "COSINE", 0, "Cosine", ""}, + {NODE_MATH_TAN, "TANGENT", 0, "Tangent", ""}, + {NODE_MATH_ASIN, "ARCSINE", 0, "Arcsine", ""}, + {NODE_MATH_ACOS, "ARCCOSINE", 0, "Arccosine", ""}, + {NODE_MATH_ATAN, "ARCTANGENT", 0, "Arctangent", ""}, + {NODE_MATH_ATAN2, "ARCTAN2", 0, "Arctan2", ""}, {0, NULL, 0, NULL, NULL} }; @@ -176,6 +172,14 @@ static const EnumPropertyItem node_sampler_type_items[] = { {2, "BICUBIC", 0, "Bicubic", ""}, {0, NULL, 0, NULL, NULL} }; + + +static const EnumPropertyItem prop_shader_output_target_items[] = { + {SHD_OUTPUT_ALL, "ALL", 0, "All", "Use shaders for all renderers and viewports, unless there exists a more specific output"}, + {SHD_OUTPUT_EEVEE, "EEVEE", 0, "Eevee", "Use shaders for Eevee renderer"}, + {SHD_OUTPUT_CYCLES, "CYCLES", 0, "Cycles", "Use shaders for Cycles renderer"}, + {0, NULL, 0, NULL, NULL} +}; #endif #ifdef RNA_RUNTIME @@ -185,13 +189,14 @@ static const EnumPropertyItem node_sampler_type_items[] = { #include "BKE_context.h" #include "BKE_idprop.h" -#include "BKE_library.h" #include "BKE_global.h" #include "ED_node.h" #include "ED_render.h" +#include "GPU_material.h" + #include "NOD_common.h" #include "NOD_socket.h" @@ -539,7 +544,7 @@ static bool rna_NodeTree_poll(const bContext *C, bNodeTreeType *ntreetype) ParameterList list; FunctionRNA *func; void *ret; - int visible; + bool visible; RNA_pointer_create(NULL, ntreetype->ext.srna, NULL, &ptr); /* dummy */ func = &rna_NodeTree_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ @@ -2323,14 +2328,6 @@ static void rna_NodeSocketStandard_value_update(struct bContext *C, PointerRNA * /* fall back to searching node in the tree */ nodeFindNode(ntree, sock, &node, NULL); } - - if (node) { - nodeSynchronizeID(node, true); - - /* extra update for sockets that get synced to material */ - if (node->id && ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) - WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, node->id); - } } @@ -2486,17 +2483,6 @@ static void rna_Node_tex_image_update(Main *bmain, Scene *UNUSED(scene), Pointer WM_main_add_notifier(NC_IMAGE, NULL); } -static void rna_Node_material_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) -{ - bNodeTree *ntree = (bNodeTree *)ptr->id.data; - bNode *node = (bNode *)ptr->data; - - if (node->id) - nodeSetActive(ntree, node); - - ED_node_tag_update_nodetree(bmain, ntree, node); -} - static void rna_NodeGroup_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { bNodeTree *ntree = (bNodeTree *)ptr->id.data; @@ -2758,7 +2744,7 @@ static const EnumPropertyItem *rna_Node_image_view_itemf(bContext *UNUSED(C), Po return item; } -static const EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *UNUSED(C), PointerRNA *ptr, +static const EnumPropertyItem *rna_Node_view_layer_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { bNode *node = (bNode *)ptr->data; @@ -2771,7 +2757,7 @@ static const EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *UNUSED(C), P return DummyRNA_NULL_items; } - rl = sce->r.layers.first; + rl = sce->view_layers.first; item = renderresult_layers_add_enum(rl); *r_free = true; @@ -2779,7 +2765,7 @@ static const EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *UNUSED(C), P return item; } -static void rna_Node_scene_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Node_view_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) { rna_Node_update(bmain, scene, ptr); if (scene->nodetree != NULL) { @@ -3176,12 +3162,12 @@ static int point_density_vertex_color_source_from_shader(NodeShaderTexPointDensi } void rna_ShaderNodePointDensity_density_cache(bNode *self, - Scene *scene, - int settings) + Depsgraph *depsgraph) { NodeShaderTexPointDensity *shader_point_density = self->storage; PointDensity *pd = &shader_point_density->pd; - if (scene == NULL) { + + if (depsgraph == NULL) { return; } @@ -3213,14 +3199,11 @@ void rna_ShaderNodePointDensity_density_cache(bNode *self, shader_point_density->cached_resolution = shader_point_density->resolution; /* Single-threaded sampling of the voxel domain. */ - RE_point_density_cache(scene, - pd, - settings == 1); + RE_point_density_cache(depsgraph, pd); } void rna_ShaderNodePointDensity_density_calc(bNode *self, - Scene *scene, - int settings, + Depsgraph *depsgraph, int *length, float **values) { @@ -3228,7 +3211,7 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self, PointDensity *pd = &shader_point_density->pd; const int resolution = shader_point_density->cached_resolution; - if (scene == NULL) { + if (depsgraph == NULL) { *length = 0; return; } @@ -3241,10 +3224,7 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self, } /* Single-threaded sampling of the voxel domain. */ - RE_point_density_sample(scene, pd, - resolution, - settings == 1, - *values); + RE_point_density_sample(depsgraph, pd, resolution, *values); /* We're done, time to clean up. */ BKE_texture_pointdensity_free_data(pd); @@ -3253,19 +3233,20 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self, } void rna_ShaderNodePointDensity_density_minmax(bNode *self, - Scene *scene, - int settings, + Depsgraph *depsgraph, float r_min[3], float r_max[3]) { NodeShaderTexPointDensity *shader_point_density = self->storage; PointDensity *pd = &shader_point_density->pd; - if (scene == NULL) { + + if (depsgraph == NULL) { zero_v3(r_min); zero_v3(r_max); return; } - RE_point_density_minmax(scene, pd, settings == 1, r_min, r_max); + + RE_point_density_minmax(depsgraph, pd, r_min, r_max); } #else @@ -3280,7 +3261,7 @@ static const EnumPropertyItem prop_image_view_items[] = { {0, NULL, 0, NULL, NULL} }; -static const EnumPropertyItem prop_scene_layer_items[] = { +static const EnumPropertyItem prop_view_layer_items[] = { { 0, "PLACEHOLDER", 0, "Placeholder", ""}, {0, NULL, 0, NULL, NULL} }; @@ -3599,6 +3580,12 @@ static void def_sh_output(StructRNA *srna) RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_DO_OUTPUT); RNA_def_property_ui_text(prop, "Active Output", "True if this node is used as the active output"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "target", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, prop_shader_output_target_items); + RNA_def_property_ui_text(prop, "Target", "Which renderer and viewport shading types to use the shaders for"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_sh_output_linestyle(StructRNA *srna) @@ -3607,33 +3594,6 @@ static void def_sh_output_linestyle(StructRNA *srna) def_mix_rgb(srna); } -static void def_sh_material(StructRNA *srna) -{ - PropertyRNA *prop; - - prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "id"); - RNA_def_property_struct_type(prop, "Material"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Material", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_material_update"); - - prop = RNA_def_property(srna, "use_diffuse", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_DIFF); - RNA_def_property_ui_text(prop, "Diffuse", "Material Node outputs Diffuse"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "use_specular", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_SPEC); - RNA_def_property_ui_text(prop, "Specular", "Material Node outputs Specular"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "invert_normal", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_NEG); - RNA_def_property_ui_text(prop, "Invert Normal", "Material Node uses inverted normal"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); -} - static void def_sh_mapping(StructRNA *srna) { static const EnumPropertyItem prop_vect_type_items[] = { @@ -3696,36 +3656,6 @@ static void def_sh_mapping(StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Mapping_Node_update"); } -static void def_sh_geometry(StructRNA *srna) -{ - PropertyRNA *prop; - - RNA_def_struct_sdna_from(srna, "NodeGeometry", "storage"); - - prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "uvname"); - RNA_def_property_ui_text(prop, "UV Map", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "color_layer", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "colname"); - RNA_def_property_ui_text(prop, "Vertex Color Layer", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); -} - -static void def_sh_lamp(StructRNA *srna) -{ - PropertyRNA *prop; - - prop = RNA_def_property(srna, "lamp_object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "id"); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); - RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Lamp_object_poll"); - RNA_def_property_ui_text(prop, "Lamp Object", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); -} - static void def_sh_attribute(StructRNA *srna) { PropertyRNA *prop; @@ -4229,13 +4159,6 @@ static void def_sh_tex_pointdensity(StructRNA *srna) {0, NULL, 0, NULL, NULL} }; - /* TODO(sergey): Use some mnemonic names for the hardcoded values here. */ - static const EnumPropertyItem calc_mode_items[] = { - {0, "VIEWPORT", 0, "Viewport", "Canculate density using viewport settings"}, - {1, "RENDER", 0, "Render", "Canculate duplis using render settings"}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Object"); @@ -4297,13 +4220,11 @@ static void def_sh_tex_pointdensity(StructRNA *srna) func = RNA_def_function(srna, "cache_point_density", "rna_ShaderNodePointDensity_density_cache"); RNA_def_function_ui_description(func, "Cache point density data for later calculation"); - RNA_def_pointer(func, "scene", "Scene", "", ""); - RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); + RNA_def_pointer(func, "depsgraph", "Depsgraph", "", ""); func = RNA_def_function(srna, "calc_point_density", "rna_ShaderNodePointDensity_density_calc"); RNA_def_function_ui_description(func, "Calculate point density"); - RNA_def_pointer(func, "scene", "Scene", "", ""); - RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); + RNA_def_pointer(func, "depsgraph", "Depsgraph", "", ""); /* TODO, See how array size of 0 works, this shouldnt be used. */ parm = RNA_def_float_array(func, "rgba_values", 1, NULL, 0, 0, "", "RGBA Values", 0, 0); RNA_def_parameter_flags(parm, PROP_DYNAMIC, 0); @@ -4311,8 +4232,7 @@ static void def_sh_tex_pointdensity(StructRNA *srna) func = RNA_def_function(srna, "calc_point_density_minmax", "rna_ShaderNodePointDensity_density_minmax"); RNA_def_function_ui_description(func, "Calculate point density"); - RNA_def_pointer(func, "scene", "Scene", "", ""); - RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); + RNA_def_pointer(func, "depsgraph", "Depsgraph", "", ""); parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_COORDS); RNA_def_property_array(parm, 3); RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); @@ -5056,15 +4976,15 @@ static void def_cmp_render_layers(StructRNA *srna) RNA_def_property_struct_type(prop, "Scene"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Scene", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_scene_layer_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_view_layer_update"); prop = RNA_def_property(srna, "layer", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, prop_scene_layer_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_scene_layer_itemf"); + RNA_def_property_enum_items(prop, prop_view_layer_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_view_layer_itemf"); RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); RNA_def_property_ui_text(prop, "Layer", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_scene_layer_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_view_layer_update"); } static void rna_def_cmp_output_file_slot_file(BlenderRNA *brna) @@ -7176,7 +7096,7 @@ static void rna_def_node_socket(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Node Socket", "Input or output socket of a node"); RNA_def_struct_sdna(srna, "bNodeSocket"); RNA_def_struct_refine_func(srna, "rna_NodeSocket_refine"); - RNA_def_struct_ui_icon(srna, ICON_PLUG); + RNA_def_struct_ui_icon(srna, ICON_PLUGIN); RNA_def_struct_path_func(srna, "rna_NodeSocket_path"); RNA_def_struct_register_funcs(srna, "rna_NodeSocket_register", "rna_NodeSocket_unregister", NULL); RNA_def_struct_idprops_func(srna, "rna_NodeSocket_idprops"); @@ -7937,12 +7857,6 @@ static void rna_def_node(BlenderRNA *brna) {NODE_CUSTOM, "CUSTOM", 0, "Custom", "Custom Node"}, {0, NULL, 0, NULL, NULL}}; - static const EnumPropertyItem node_shading_compatibilities[] = { - {NODE_OLD_SHADING, "OLD_SHADING", 0, "Old Shading", "Old shading system compatibility"}, - {NODE_NEW_SHADING, "NEW_SHADING", 0, "New Shading", "New shading system compatibility"}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "Node", NULL); RNA_def_struct_ui_text(srna, "Node", "Node in a node tree"); RNA_def_struct_sdna(srna, "bNode"); @@ -8082,12 +7996,6 @@ static void rna_def_node(BlenderRNA *brna) parm = RNA_def_boolean(func, "result", false, "Result", ""); RNA_def_function_return(func, parm); - prop = RNA_def_property(srna, "shading_compatibility", PROP_ENUM, PROP_NONE); - RNA_def_property_flag(prop, PROP_ENUM_FLAG); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_enum_sdna(prop, NULL, "typeinfo->compatibility"); - RNA_def_property_enum_items(prop, node_shading_compatibilities); - /* registration */ prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "typeinfo->idname"); @@ -8105,7 +8013,7 @@ static void rna_def_node(BlenderRNA *brna) prop = RNA_def_property(srna, "bl_icon", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "typeinfo->ui_icon"); - RNA_def_property_enum_items(prop, rna_enum_node_icon_items); + RNA_def_property_enum_items(prop, rna_enum_icon_items); RNA_def_property_enum_default(prop, ICON_NODE); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); RNA_def_property_ui_text(prop, "Icon", "The node icon"); @@ -8436,6 +8344,7 @@ static void rna_def_nodetree(BlenderRNA *brna) 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_annotations_poll"); 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_update(prop, NC_NODE, NULL); @@ -8492,7 +8401,7 @@ static void rna_def_nodetree(BlenderRNA *brna) prop = RNA_def_property(srna, "bl_icon", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "typeinfo->ui_icon"); - RNA_def_property_enum_items(prop, rna_enum_node_icon_items); + RNA_def_property_enum_items(prop, rna_enum_icon_items); RNA_def_property_enum_default(prop, ICON_NODETREE); RNA_def_property_flag(prop, PROP_REGISTER); RNA_def_property_ui_text(prop, "Icon", "The node tree icon"); @@ -8572,12 +8481,21 @@ static void rna_def_composite_nodetree(BlenderRNA *brna) static void rna_def_shader_nodetree(BlenderRNA *brna) { StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; srna = RNA_def_struct(brna, "ShaderNodeTree", "NodeTree"); RNA_def_struct_ui_text(srna, "Shader Node Tree", "Node tree consisting of linked nodes used for materials (and other shading data-blocks)"); RNA_def_struct_sdna(srna, "bNodeTree"); RNA_def_struct_ui_icon(srna, ICON_MATERIAL); + + func = RNA_def_function(srna, "get_output_node", "ntreeShaderOutputNode"); + RNA_def_function_ui_description(func, "Return active shader output node for the specified target"); + parm = RNA_def_enum(func, "target", prop_shader_output_target_items, SHD_OUTPUT_ALL, "Target", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "node", "ShaderNode", "Node", ""); + RNA_def_function_return(func, parm); } static void rna_def_texture_nodetree(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 4094552d9bc..ff2466d1b39 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,7 +74,27 @@ 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} }; @@ -86,6 +110,19 @@ const EnumPropertyItem rna_enum_object_empty_drawtype_items[] = { {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_GP_EMPTY, "Blank", "Create an empty grease pencil object"}, + {GP_STROKE, "STROKE", ICON_GP_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 +#define DUPLI_ITEMS_SHARED \ + {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"} + +#define DUPLI_ITEM_COLLECTION \ + {OB_DUPLICOLLECTION, "COLLECTION", 0, "Collection", "Enable collection instancing"} 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"}, + DUPLI_ITEMS_SHARED, + DUPLI_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 dupli_items_nogroup[] = { + DUPLI_ITEMS_SHARED, {0, NULL, 0, NULL, NULL} }; +#endif +#undef DUPLI_ITEMS_SHARED +#undef DUPLI_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, OB_RECALC_OB); } 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, OB_RECALC_OB); 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, DEG_TAG_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, OB_RECALC_DATA); 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, OB_RECALC_OB); + 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; @@ -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,58 +505,55 @@ 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_dupli_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 = dupli_items; + } + else { + item = dupli_items_nogroup; + } + + return item; } static void rna_Object_dup_group_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, @@ -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,7 +809,7 @@ static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value) { Object *ob = (Object *)ptr->id.data; - DAG_id_tag_update(value.data, 0); + DEG_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)); 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); @@ -895,6 +1009,21 @@ static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value) 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"); @@ -2327,12 +2220,13 @@ static void rna_def_object(BlenderRNA *brna) 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"); + 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 +2234,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 +2245,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 +2263,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 +2277,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 +2298,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); @@ -2523,22 +2425,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 +2459,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 +2495,21 @@ 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); + /* render */ prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "index"); @@ -2622,24 +2558,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_duplicator_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 Duplicator", "Make duplicator visible when rendering"); + + prop = RNA_def_property(srna, "show_duplicator_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 Duplicator", "Make duplicator visible in the viewport"); + /* anim */ rna_def_animdata_common(srna); @@ -2661,19 +2608,11 @@ 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); RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag"); RNA_def_property_enum_items(prop, dupli_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_dupli_type_itemf"); RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update"); @@ -2700,10 +2639,11 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update"); prop = RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_pointer_sdna(prop, NULL, "dup_group"); RNA_def_property_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_ui_text(prop, "Dupli 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); @@ -2732,77 +2672,75 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes"); 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); 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 +2752,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 +2775,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 +2788,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_duplicator", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_FROMDUPLI); + RNA_def_property_ui_text(prop, "Base from Duplicator", "Object comes from a duplicator"); + 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 +2813,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 diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 6218de2469d..c34534614f4 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -40,10 +40,13 @@ #include "RNA_define.h" #include "DNA_constraint_types.h" +#include "DNA_layer_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" -#include "BKE_depsgraph.h" +#include "BKE_layer.h" + +#include "DEG_depsgraph.h" #include "rna_internal.h" /* own include */ @@ -65,7 +68,6 @@ static const EnumPropertyItem space_items[] = { #include "BKE_anim.h" #include "BKE_bvhutils.h" -#include "BKE_cdderivedmesh.h" #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_customdata.h" @@ -86,9 +88,85 @@ static const EnumPropertyItem space_items[] = { #include "DNA_scene_types.h" #include "DNA_view3d_types.h" +#include "DEG_depsgraph_query.h" + #include "MEM_guardedalloc.h" -#include "DEG_depsgraph.h" +static void rna_Object_select_set( + Object *ob, bContext *C, ReportList *reports, + bool select, ViewLayer *view_layer) +{ + if (view_layer == NULL) { + view_layer = CTX_data_view_layer(C); + } + Base *base = BKE_view_layer_base_find(view_layer, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); + return; + } + + if (select) { + BKE_view_layer_base_select(base); + } + else { + base->flag &= ~BASE_SELECTED; + } + + Scene *scene = CTX_data_scene(C); + DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE); + WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene); +} + +static bool rna_Object_select_get(Object *ob, bContext *C, ReportList *reports) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + Base *base = BKE_view_layer_base_find(view_layer, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); + return false; + } + + return ((base->flag & BASE_SELECTED) != 0); +} + +static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + Base *base = BKE_view_layer_base_find(view_layer, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); + return false; + } + + return ((base->flag & BASE_VISIBLE) != 0); +} + +static bool rna_Object_holdout_get(Object *ob, ReportList *reports, ViewLayer *view_layer) +{ + Base *base = BKE_view_layer_base_find(view_layer, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); + return false; + } + + return ((base->flag & BASE_HOLDOUT) != 0); +} + +static bool rna_Object_indirect_only_get(Object *ob, ReportList *reports, ViewLayer *view_layer) +{ + Base *base = BKE_view_layer_base_find(view_layer, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); + return false; + } + + return ((base->flag & BASE_INDIRECT_ONLY) != 0); +} /* Convert a given matrix from a space to another (using the object and/or a bone as reference). */ static void rna_Object_mat_convert_space(Object *ob, ReportList *reports, bPoseChannel *pchan, @@ -116,13 +194,14 @@ static void rna_Object_mat_convert_space(Object *ob, ReportList *reports, bPoseC } static void rna_Object_calc_matrix_camera( - Object *ob, float mat_ret[16], int width, int height, float scalex, float scaley) + Object *ob, Depsgraph *depsgraph, float mat_ret[16], int width, int height, float scalex, float scaley) { + const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); CameraParams params; /* setup parameters */ BKE_camera_params_init(¶ms); - BKE_camera_params_from_object(¶ms, ob); + BKE_camera_params_from_object(¶ms, ob_eval); /* compute matrix, viewplane, .. */ BKE_camera_params_compute_viewplane(¶ms, width, height, scalex, scaley); @@ -132,97 +211,20 @@ static void rna_Object_calc_matrix_camera( } static void rna_Object_camera_fit_coords( - Object *ob, Scene *scene, int num_cos, float *cos, float co_ret[3], float *scale_ret) + Object *ob, Depsgraph *depsgraph, int num_cos, float *cos, float co_ret[3], float *scale_ret) { - BKE_camera_view_frame_fit_to_coords(scene, (const float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret); + BKE_camera_view_frame_fit_to_coords(depsgraph, (const float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret); } /* copied from Mesh_getFromObject and adapted to RNA interface */ /* settings: 0 - preview, 1 - render */ static Mesh *rna_Object_to_mesh( - Object *ob, Main *bmain, ReportList *reports, Scene *sce, - bool apply_modifiers, int settings, bool calc_tessface, bool calc_undeformed) + Object *ob, bContext *C, ReportList *reports, Depsgraph *depsgraph, + bool apply_modifiers, bool calc_undeformed) { - return rna_Main_meshes_new_from_object(bmain, reports, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed); -} - -/* mostly a copy from convertblender.c */ -static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int enable) -{ - /* ugly function, but we need to set particle systems to their render - * settings before calling object_duplilist, to get render level duplis */ - Group *group; - GroupObject *go; - ParticleSystem *psys; - DerivedMesh *dm; - float mat[4][4]; - - unit_m4(mat); - - if (level >= MAX_DUPLI_RECUR) - return; - - if (ob->transflag & OB_DUPLIPARTS) { - for (psys = ob->particlesystem.first; psys; psys = psys->next) { - if (ELEM(psys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { - if (enable) - psys_render_set(ob, psys, mat, mat, 1, 1, 0.f); - else - psys_render_restore(ob, psys); - } - } - - if (enable) { - /* this is to make sure we get render level duplis in groups: - * the derivedmesh must be created before init_render_mesh, - * since object_duplilist does dupliparticles before that */ - dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL); - dm->release(dm); - - for (psys = ob->particlesystem.first; psys; psys = psys->next) - psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated; - } - } - - if (ob->dup_group == NULL) return; - group = ob->dup_group; - - for (go = group->gobject.first; go; go = go->next) - dupli_render_particle_set(scene, go->ob, level + 1, enable); -} -/* When no longer needed, duplilist should be freed with Object.free_duplilist */ -static void rna_Object_create_duplilist(Object *ob, Main *bmain, ReportList *reports, Scene *sce, int settings) -{ - bool for_render = (settings == DAG_EVAL_RENDER); - EvaluationContext eval_ctx; - DEG_evaluation_context_init(&eval_ctx, settings); - - if (!(ob->transflag & OB_DUPLI)) { - BKE_report(reports, RPT_ERROR, "Object does not have duplis"); - return; - } - - /* free duplilist if a user forgets to */ - if (ob->duplilist) { - BKE_report(reports, RPT_WARNING, "Object.dupli_list has not been freed"); - - free_object_duplilist(ob->duplilist); - ob->duplilist = NULL; - } - if (for_render) - dupli_render_particle_set(sce, ob, 0, 1); - ob->duplilist = object_duplilist(bmain, &eval_ctx, sce, ob); - if (for_render) - dupli_render_particle_set(sce, ob, 0, 0); - /* ob->duplilist should now be freed with Object.free_duplilist */ -} + Main *bmain = CTX_data_main(C); -static void rna_Object_free_duplilist(Object *ob) -{ - if (ob->duplilist) { - free_object_duplilist(ob->duplilist); - ob->duplilist = NULL; - } + return rna_Main_meshes_new_from_object(bmain, reports, depsgraph, ob, apply_modifiers, calc_undeformed); } static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports, @@ -262,17 +264,12 @@ static void rna_Object_shape_key_remove( return; } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); RNA_POINTER_INVALIDATE(kb_ptr); } -static bool rna_Object_is_visible(Object *ob, Scene *sce) -{ - return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay); -} - #if 0 static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int *indices, int totindex, float weight, int assignmode) @@ -311,9 +308,9 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int #endif /* don't call inside a loop */ -static int dm_looptri_to_poly_index(DerivedMesh *dm, const MLoopTri *lt) +static int mesh_looptri_to_poly_index(Mesh *me_eval, const MLoopTri *lt) { - const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); + const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX); return index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly; } @@ -324,7 +321,7 @@ static void rna_Object_ray_cast( { bool success = false; - if (ob->derivedFinal == NULL) { + if (ob->runtime.mesh_eval == NULL) { BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for ray casting", ob->id.name + 2); return; } @@ -339,7 +336,7 @@ static void rna_Object_ray_cast( BVHTreeFromMesh treeData = {NULL}; /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ - bvhtree_from_mesh_get(&treeData, ob->derivedFinal, BVHTREE_FROM_LOOPTRI, 4); + BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4); /* may fail if the mesh has no faces, in that case the ray-cast misses */ if (treeData.tree != NULL) { @@ -356,7 +353,7 @@ static void rna_Object_ray_cast( copy_v3_v3(r_location, hit.co); copy_v3_v3(r_normal, hit.no); - *r_index = dm_looptri_to_poly_index(ob->derivedFinal, &treeData.looptri[hit.index]); + *r_index = mesh_looptri_to_poly_index(ob->runtime.mesh_eval, &treeData.looptri[hit.index]); } } @@ -378,14 +375,14 @@ static void rna_Object_closest_point_on_mesh( { BVHTreeFromMesh treeData = {NULL}; - if (ob->derivedFinal == NULL) { + if (ob->runtime.mesh_eval == NULL) { BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for finding nearest point", ob->id.name + 2); return; } /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ - bvhtree_from_mesh_get(&treeData, ob->derivedFinal, BVHTREE_FROM_LOOPTRI, 4); + BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4); if (treeData.tree == NULL) { BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for finding nearest point", @@ -403,7 +400,7 @@ static void rna_Object_closest_point_on_mesh( copy_v3_v3(r_location, nearest.co); copy_v3_v3(r_normal, nearest.no); - *r_index = dm_looptri_to_poly_index(ob->derivedFinal, &treeData.looptri[nearest.index]); + *r_index = mesh_looptri_to_poly_index(ob->runtime.mesh_eval, &treeData.looptri[nearest.index]); goto finally; } @@ -419,13 +416,6 @@ finally: free_bvhtree_from_mesh(&treeData); } -/* ObjectBase */ - -static void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d) -{ - base->lay = base->object->lay = v3d->lay; -} - static bool rna_Object_is_modified(Object *ob, Scene *scene, int settings) { return BKE_object_is_modified(scene, ob) & settings; @@ -437,10 +427,12 @@ static bool rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings } #ifndef NDEBUG -void rna_Object_dm_info(struct Object *ob, int type, char *result) + +#include "BKE_mesh_runtime.h" + +void rna_Object_me_eval_info(struct Object *ob, int type, char *result) { - DerivedMesh *dm = NULL; - bool dm_release = false; + Mesh *me_eval = NULL; char *ret = NULL; result[0] = '\0'; @@ -448,24 +440,19 @@ void rna_Object_dm_info(struct Object *ob, int type, char *result) switch (type) { case 0: if (ob->type == OB_MESH) { - dm = CDDM_from_mesh(ob->data); - ret = DM_debug_info(dm); - dm_release = true; + me_eval = ob->data; } break; case 1: - dm = ob->derivedDeform; + me_eval = ob->runtime.mesh_deform_eval; break; case 2: - dm = ob->derivedFinal; + me_eval = ob->runtime.mesh_eval; break; } - if (dm) { - ret = DM_debug_info(dm); - if (dm_release) { - dm->release(dm); - } + if (me_eval) { + ret = BKE_mesh_runtime_debug_info(me_eval); if (ret) { strcpy(result, ret); MEM_freeN(ret); @@ -476,6 +463,7 @@ void rna_Object_dm_info(struct Object *ob, int type, char *result) static bool rna_Object_update_from_editmode(Object *ob, Main *bmain) { + /* fail gracefully if we aren't in edit-mode. */ return ED_object_editmode_load(bmain, ob); } #else /* RNA_RUNTIME */ @@ -491,13 +479,6 @@ void RNA_api_object(StructRNA *srna) {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem dupli_eval_mode_items[] = { - {DAG_EVAL_VIEWPORT, "VIEWPORT", 0, "Viewport", "Generate duplis using viewport settings"}, - {DAG_EVAL_PREVIEW, "PREVIEW", 0, "Preview", "Generate duplis using preview settings"}, - {DAG_EVAL_RENDER, "RENDER", 0, "Render", "Generate duplis using render settings"}, - {0, NULL, 0, NULL, NULL} - }; - #ifndef NDEBUG static const EnumPropertyItem mesh_dm_info_items[] = { {0, "SOURCE", 0, "Source", "Source mesh"}, @@ -507,6 +488,42 @@ void RNA_api_object(StructRNA *srna) }; #endif + /* Special wrapper to access the base selection value */ + func = RNA_def_function(srna, "select_set", "rna_Object_select_set"); + RNA_def_function_ui_description(func, "Select the object (for the active view layer)"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + parm = RNA_def_boolean(func, "state", 0, "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Operate on this view layer instead of the context"); + + func = RNA_def_function(srna, "select_get", "rna_Object_select_get"); + RNA_def_function_ui_description(func, "Get the object selection for the active view layer"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + parm = RNA_def_boolean(func, "result", 0, "", "Object selected"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "visible_get", "rna_Object_visible_get"); + RNA_def_function_ui_description(func, "Get the object visibility for the active view layer"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + parm = RNA_def_boolean(func, "result", 0, "", "Object visible"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "holdout_get", "rna_Object_holdout_get"); + RNA_def_function_ui_description(func, "Test if object is masked in the view layer"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_boolean(func, "result", 0, "", "Object holdout"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "indirect_only_get", "rna_Object_indirect_only_get"); + RNA_def_function_ui_description(func, "Test if object is set to contribute only indirectly (through shadows and reflections) in the view layer"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_boolean(func, "result", 0, "", "Object indirect only"); + RNA_def_function_return(func, parm); + /* Matrix space conversion */ func = RNA_def_function(srna, "convert_space", "rna_Object_mat_convert_space"); RNA_def_function_ui_description(func, "Convert (transform) the given matrix from one space to another"); @@ -529,7 +546,10 @@ void RNA_api_object(StructRNA *srna) /* Camera-related operations */ func = RNA_def_function(srna, "calc_matrix_camera", "rna_Object_calc_matrix_camera"); RNA_def_function_ui_description(func, "Generate the camera projection matrix of this object " - "(mostly useful for Camera and Lamp types)"); + "(mostly useful for Camera and Light types)"); + parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", + "Depsgraph to get evaluated data from"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_property(func, "result", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(parm, "", "The camera projection matrix"); @@ -542,7 +562,8 @@ void RNA_api_object(StructRNA *srna) func = RNA_def_function(srna, "camera_fit_coords", "rna_Object_camera_fit_coords"); RNA_def_function_ui_description(func, "Compute the coordinate (and scale for ortho cameras) " "given object should be to 'see' all given coordinates"); - parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to get render size information from, if available"); + parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", + "Depsgraph to get evaluated data from"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_float_array(func, "coordinates", 1, NULL, -FLT_MAX, FLT_MAX, "", "Coordinates to fit in", -FLT_MAX, FLT_MAX); @@ -558,32 +579,16 @@ void RNA_api_object(StructRNA *srna) /* mesh */ func = RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh"); RNA_def_function_ui_description(func, "Create a Mesh data-block with modifiers applied"); - RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT); + parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "Dependency Graph", "Evaluated dependency graph within which to evaluate modifiers"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_boolean(func, "calc_tessface", true, "Calculate Tessellation", "Calculate tessellation faces"); RNA_def_boolean(func, "calc_undeformed", false, "Calculate Undeformed", "Calculate undeformed vertex coordinates"); parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export"); RNA_def_function_return(func, parm); - /* duplis */ - func = RNA_def_function(srna, "dupli_list_create", "rna_Object_create_duplilist"); - RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Create a list of dupli objects for this object, needs to " - "be freed manually with free_dupli_list to restore the " - "objects real matrix and layers"); - parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate duplis"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - RNA_def_enum(func, "settings", dupli_eval_mode_items, 0, "", "Generate texture coordinates for rendering"); - - func = RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist"); - RNA_def_function_ui_description(func, "Free the list of dupli objects"); - /* Armature */ func = RNA_def_function(srna, "find_armature", "modifiers_isDeformedByArmature"); RNA_def_function_ui_description(func, "Find armature influencing this object as a parent or via a modifier"); @@ -661,12 +666,6 @@ void RNA_api_object(StructRNA *srna) RNA_def_function_output(func, parm); /* View */ - func = RNA_def_function(srna, "is_visible", "rna_Object_is_visible"); - RNA_def_function_ui_description(func, "Determine if object is visible in a given scene"); - parm = RNA_def_pointer(func, "scene", "Scene", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_boolean(func, "result", 0, "", "Object visibility"); - RNA_def_function_return(func, parm); /* utility function for checking if the object is modified */ func = RNA_def_function(srna, "is_modified", "rna_Object_is_modified"); @@ -689,7 +688,7 @@ void RNA_api_object(StructRNA *srna) #ifndef NDEBUG /* mesh */ - func = RNA_def_function(srna, "dm_info", "rna_Object_dm_info"); + func = RNA_def_function(srna, "dm_info", "rna_Object_me_eval_info"); RNA_def_function_ui_description(func, "Returns a string for derived mesh data"); parm = RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply"); @@ -710,17 +709,4 @@ void RNA_api_object(StructRNA *srna) RNA_def_function_ui_description(func, "Release memory used by caches associated with this object. Intended to be used by render engines only"); } - -void RNA_api_object_base(StructRNA *srna) -{ - FunctionRNA *func; - PropertyRNA *parm; - - func = RNA_def_function(srna, "layers_from_view", "rna_ObjectBase_layers_from_view"); - RNA_def_function_ui_description(func, - "Sets the object layers from a 3D View (use when adding an object in local view)"); - parm = RNA_def_pointer(func, "view", "SpaceView3D", "", ""); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); -} - #endif /* RNA_RUNTIME */ diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index c5d66581ca3..e1090a3ded5 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -42,10 +42,11 @@ #include "WM_types.h" static const EnumPropertyItem effector_shape_items[] = { - {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""}, - {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""}, - {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Surface", ""}, - {PFIELD_SHAPE_POINTS, "POINTS", 0, "Every Point", ""}, + {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"}, + {PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"}, + {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", "Field originates from the local XY plane of the object"}, + {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Surface", "Field originates from the surface of the object"}, + {PFIELD_SHAPE_POINTS, "POINTS", 0, "Every Point", "Field originates from all of the vertices of the object"}, {0, NULL, 0, NULL, NULL} }; @@ -56,15 +57,17 @@ static const EnumPropertyItem effector_shape_items[] = { /* type specific return values only used from functions */ static const EnumPropertyItem curve_shape_items[] = { - {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""}, - {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""}, - {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Curve", ""}, + {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"}, + {PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"}, + {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", "Field originates from the local XY plane of the object"}, + {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Curve", "Field originates from the curve itself"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem empty_shape_items[] = { - {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""}, - {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""}, + {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"}, + {PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"}, + {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", "Field originates from the local XY plane of the object"}, {0, NULL, 0, NULL, NULL} }; @@ -94,78 +97,59 @@ static const EnumPropertyItem empty_vortex_shape_items[] = { #include "DNA_modifier_types.h" #include "DNA_texture_types.h" +#include "BKE_collection.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" -#include "BKE_global.h" -#include "BKE_library.h" #include "BKE_modifier.h" #include "BKE_pointcache.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "ED_object.h" -static void rna_Cache_change(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; PointCache *cache = (PointCache *)ptr->data; - PTCacheID *pid = NULL; - ListBase pidlist; if (!ob) return; cache->flag |= PTCACHE_OUTDATED; - BKE_ptcache_ids_from_object(bmain, &pidlist, ob, NULL, 0); - - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache); - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) - break; - } + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); - if (pid) { + if (pid.cache) { /* Just make sure this wasn't changed. */ - if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) + if (pid.type == PTCACHE_TYPE_SMOKE_DOMAIN) cache->step = 1; - BKE_ptcache_update_info(pid); + BKE_ptcache_update_info(&pid); } - - BLI_freelistN(&pidlist); } -static void rna_Cache_toggle_disk_cache(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Cache_toggle_disk_cache(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; PointCache *cache = (PointCache *)ptr->data; - PTCacheID *pid = NULL; - ListBase pidlist; if (!ob) return; - BKE_ptcache_ids_from_object(bmain, &pidlist, ob, NULL, 0); - - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) - break; - } + PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache); /* smoke can only use disk cache */ - if (pid && pid->type != PTCACHE_TYPE_SMOKE_DOMAIN) - BKE_ptcache_toggle_disk_cache(pid); + if (pid.cache && pid.type != PTCACHE_TYPE_SMOKE_DOMAIN) + BKE_ptcache_toggle_disk_cache(&pid); else cache->flag ^= PTCACHE_DISK_CACHE; - - BLI_freelistN(&pidlist); } -static void rna_Cache_idname_change(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; PointCache *cache = (PointCache *)ptr->data; - PTCacheID *pid = NULL, *pid2 = NULL; - ListBase pidlist; bool use_new_name = true; if (!ob) @@ -173,23 +157,22 @@ static void rna_Cache_idname_change(Main *bmain, Scene *UNUSED(scene), PointerRN /* TODO: check for proper characters */ - BKE_ptcache_ids_from_object(bmain, &pidlist, ob, NULL, 0); - if (cache->flag & PTCACHE_EXTERNAL) { - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) - break; - } - - if (!pid) - return; + PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache); - BKE_ptcache_load_external(pid); + if (pid.cache) { + BKE_ptcache_load_external(&pid); + } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_POINTCACHE, ob); } else { + PTCacheID *pid = NULL, *pid2 = NULL; + ListBase pidlist; + + BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) pid2 = pid; @@ -215,9 +198,9 @@ static void rna_Cache_idname_change(Main *bmain, Scene *UNUSED(scene), PointerRN BLI_strncpy(cache->prev_name, cache->name, sizeof(cache->prev_name)); } - } - BLI_freelistN(&pidlist); + BLI_freelistN(&pidlist); + } } static void rna_Cache_list_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) @@ -238,45 +221,27 @@ static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, { Object *ob = ptr->id.data; PointCache *cache = ptr->data; - PTCacheID *pid; - ListBase pidlist; - - BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); - BKE_ptcache_ids_from_object(G_MAIN, &pidlist, ob, NULL, 0); + PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache); *min = 0; *max = 0; - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) { - *max = max_ii(0, BLI_listbase_count(pid->ptcaches) - 1); - break; - } + if (pid.cache) { + *max = max_ii(0, BLI_listbase_count(pid.ptcaches) - 1); } - - BLI_freelistN(&pidlist); } static int rna_Cache_active_point_cache_index_get(PointerRNA *ptr) { Object *ob = ptr->id.data; PointCache *cache = ptr->data; - PTCacheID *pid; - ListBase pidlist; + PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache); int num = 0; - BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); - BKE_ptcache_ids_from_object(G_MAIN, &pidlist, ob, NULL, 0); - - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) { - num = BLI_findindex(pid->ptcaches, cache); - break; - } + if (pid.cache) { + num = BLI_findindex(pid.ptcaches, cache); } - BLI_freelistN(&pidlist); - return num; } @@ -284,20 +249,11 @@ static void rna_Cache_active_point_cache_index_set(struct PointerRNA *ptr, int v { Object *ob = ptr->id.data; PointCache *cache = ptr->data; - PTCacheID *pid; - ListBase pidlist; - - BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); - BKE_ptcache_ids_from_object(G_MAIN, &pidlist, ob, NULL, 0); + PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache); - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) { - *(pid->cache_ptr) = BLI_findlink(pid->ptcaches, value); - break; - } + if (pid.cache) { + *(pid.cache_ptr) = BLI_findlink(pid.ptcaches, value); } - - BLI_freelistN(&pidlist); } static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max, @@ -305,23 +261,14 @@ static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max, { Object *ob = ptr->id.data; PointCache *cache = ptr->data; - PTCacheID *pid; - ListBase pidlist; + PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache); *min = 1; *max = 20; - BLI_assert(BKE_id_is_in_gobal_main(&ob->id)); - BKE_ptcache_ids_from_object(G_MAIN, &pidlist, ob, NULL, 0); - - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) { - *max = pid->max_step; - break; - } + if (pid.cache) { + *max = pid.max_step; } - - BLI_freelistN(&pidlist); } static char *rna_CollisionSettings_path(PointerRNA *UNUSED(ptr)) @@ -505,7 +452,7 @@ static void rna_FieldSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scene), part->pd2->tex = NULL; } - DAG_id_tag_update(&part->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME | PSYS_RECALC_RESET); + DEG_id_tag_update(&part->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME | PSYS_RECALC_RESET); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } @@ -517,7 +464,7 @@ static void rna_FieldSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scene), ob->pd->tex = NULL; } - DAG_id_tag_update(&ob->id, OB_RECALC_OB); + DEG_id_tag_update(&ob->id, OB_RECALC_OB); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); } } @@ -553,7 +500,7 @@ static void rna_FieldSettings_type_set(PointerRNA *ptr, int value) static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) { if (particle_id_check(ptr)) { - DAG_id_tag_update((ID *)ptr->id.data, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME | PSYS_RECALC_RESET); + DEG_id_tag_update((ID *)ptr->id.data, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME | PSYS_RECALC_RESET); } else { Object *ob = (Object *)ptr->id.data; @@ -569,12 +516,12 @@ static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, Point rna_FieldSettings_shape_update(bmain, scene, ptr); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); if (ob->type == OB_CURVE && ob->pd->forcefield == PFIELD_GUIDE) - DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); else - DAG_id_tag_update(&ob->id, OB_RECALC_OB); + DEG_id_tag_update(&ob->id, OB_RECALC_OB); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); } @@ -611,23 +558,23 @@ static void rna_EffectorWeight_update(Main *UNUSED(bmain), Scene *UNUSED(scene), if (id && GS(id->name) == ID_SCE) { Scene *scene = (Scene *)id; - Base *base; - - for (base = scene->base.first; base; base = base->next) { - BKE_ptcache_object_reset(scene, base->object, PTCACHE_RESET_DEPSGRAPH); + FOREACH_SCENE_OBJECT_BEGIN(scene, ob) + { + BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH); } + FOREACH_SCENE_OBJECT_END; } else { - DAG_id_tag_update(id, OB_RECALC_DATA | PSYS_RECALC_RESET); + DEG_id_tag_update(id, OB_RECALC_DATA | PSYS_RECALC_RESET); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } } static void rna_EffectorWeight_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); - DAG_id_tag_update((ID *)ptr->id.data, OB_RECALC_DATA | PSYS_RECALC_RESET); + DEG_id_tag_update((ID *)ptr->id.data, OB_RECALC_DATA | PSYS_RECALC_RESET); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } @@ -724,7 +671,7 @@ static void rna_CollisionSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scen { Object *ob = (Object *)ptr->id.data; - DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); } @@ -732,13 +679,13 @@ static void rna_softbody_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point { Object *ob = (Object *)ptr->id.data; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } static void rna_softbody_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); rna_softbody_update(bmain, scene, ptr); } @@ -1011,6 +958,22 @@ static void rna_def_collision(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Absorption", "How much of effector force gets lost during collision with this object (in percent)"); RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); + + prop = RNA_def_property(srna, "cloth_friction", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pdef_cfrict"); + RNA_def_property_range(prop, 0.0f, 80.0f); + RNA_def_property_ui_text(prop, "Friction", "Friction for cloth collisions"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); + + prop = RNA_def_property(srna, "use_culling", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_CLOTH_USE_CULLING); + RNA_def_property_ui_text(prop, "Single Sided", "Cloth collision acts with respect to the collider normals (improves penetration recovery)"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); + + prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_CLOTH_USE_NORMAL); + RNA_def_property_ui_text(prop, "Override Normals", "Cloth collision impulses act in the direction of the collider normals (more reliable in some cases)"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); } static void rna_def_effector_weight(BlenderRNA *brna) @@ -1032,8 +995,9 @@ static void rna_def_effector_weight(BlenderRNA *brna) /* General */ prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Effector Group", "Limit effectors to this Group"); + RNA_def_property_ui_text(prop, "Effector Collection", "Limit effectors to this collection"); RNA_def_property_update(prop, 0, "rna_EffectorWeight_dependency_update"); prop = RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_NONE); @@ -1515,78 +1479,6 @@ static void rna_def_field(BlenderRNA *brna) /* falloff_power, use_max_distance, maximum_distance */ } -static void rna_def_game_softbody(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GameSoftBodySettings", NULL); - RNA_def_struct_sdna(srna, "BulletSoftBody"); - RNA_def_struct_ui_text(srna, "Game Soft Body Settings", - "Soft body simulation settings for an object in the game engine"); - - /* Floats */ - - prop = RNA_def_property(srna, "linear_stiffness", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "linStiff"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Linear Stiffness", "Linear stiffness of the soft body links"); - - prop = RNA_def_property(srna, "dynamic_friction", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "kDF"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Friction", "Dynamic Friction"); - - prop = RNA_def_property(srna, "shape_threshold", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "kMT"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Threshold", "Shape matching threshold"); - - prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "margin"); - RNA_def_property_range(prop, 0.01f, 1.0f); - RNA_def_property_ui_text(prop, "Margin", - "Collision margin for soft body. Small value makes the algorithm unstable"); - - prop = RNA_def_property(srna, "weld_threshold", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "welding"); - RNA_def_property_range(prop, 0.0f, 0.01f); - RNA_def_property_ui_text(prop, "Welding", - "Welding threshold: distance between nearby vertices to be considered equal " - "=> set to 0.0 to disable welding test and speed up scene loading " - "(ok if the mesh has no duplicates)"); - - /* Integers */ - - prop = RNA_def_property(srna, "location_iterations", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "piterations"); - RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Position Iterations", "Position solver iterations"); - - prop = RNA_def_property(srna, "cluster_iterations", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "numclusteriterations"); - RNA_def_property_range(prop, 1, 128); - RNA_def_property_ui_text(prop, "Cluster Iterations", "Number of cluster iterations"); - - /* Booleans */ - - prop = RNA_def_property(srna, "use_shape_match", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_BSB_SHAPE_MATCHING); - RNA_def_property_ui_text(prop, "Shape Match", "Enable soft body shape matching goal"); - - prop = RNA_def_property(srna, "use_bending_constraints", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_BSB_BENDING_CONSTRAINTS); - RNA_def_property_ui_text(prop, "Bending Const", "Enable bending constraints"); - - prop = RNA_def_property(srna, "use_cluster_rigid_to_softbody", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "collisionflags", OB_BSB_COL_CL_RS); - RNA_def_property_ui_text(prop, "Rigid to Soft Body", "Enable cluster collision between soft and rigid body"); - - prop = RNA_def_property(srna, "use_cluster_soft_to_softbody", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "collisionflags", OB_BSB_COL_CL_SS); - RNA_def_property_ui_text(prop, "Soft to Soft Body", "Enable cluster collision between soft and soft body"); -} - static void rna_def_softbody(BlenderRNA *brna) { StructRNA *srna; @@ -1710,7 +1602,7 @@ static void rna_def_softbody(BlenderRNA *brna) prop = RNA_def_property(srna, "spring_length", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "springpreload"); RNA_def_property_range(prop, 0.0f, 200.0f); - RNA_def_property_ui_text(prop, "SL", "Alter spring length to shrink/blow up (unit %) 0 to disable"); + RNA_def_property_ui_text(prop, "view_layer", "Alter spring length to shrink/blow up (unit %) 0 to disable"); RNA_def_property_update(prop, 0, "rna_softbody_update"); prop = RNA_def_property(srna, "aero", PROP_INT, PROP_NONE); @@ -1890,8 +1782,9 @@ static void rna_def_softbody(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_softbody_update"); prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Collision Group", "Limit colliders to this Group"); + RNA_def_property_ui_text(prop, "Collision Collection", "Limit colliders to this collection"); RNA_def_property_update(prop, 0, "rna_softbody_dependency_update"); prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE); @@ -1907,7 +1800,6 @@ void RNA_def_object_force(BlenderRNA *brna) rna_def_collision(brna); rna_def_effector_weight(brna); rna_def_field(brna); - rna_def_game_softbody(brna); rna_def_softbody(brna); } diff --git a/source/blender/makesrna/intern/rna_palette.c b/source/blender/makesrna/intern/rna_palette.c index 4d6b94bf709..547cac9f38d 100644 --- a/source/blender/makesrna/intern/rna_palette.c +++ b/source/blender/makesrna/intern/rna_palette.c @@ -39,7 +39,6 @@ #include "BKE_paint.h" #include "BKE_report.h" - static PaletteColor *rna_Palette_color_new(Palette *palette) { PaletteColor *color = BKE_palette_color_add(palette); @@ -139,6 +138,7 @@ static void rna_def_palettecolor(BlenderRNA *brna) prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_float_sdna(prop, NULL, "rgb"); + RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Color", ""); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); @@ -153,6 +153,7 @@ static void rna_def_palettecolor(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "value"); RNA_def_property_ui_text(prop, "Weight", ""); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + } static void rna_def_palette(BlenderRNA *brna) @@ -167,6 +168,7 @@ static void rna_def_palette(BlenderRNA *brna) prop = RNA_def_property(srna, "colors", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "PaletteColor"); rna_def_palettecolors(brna, prop); + } void RNA_def_palette(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 05fd0ee740e..1abba3979f0 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -32,6 +32,7 @@ #include <limits.h> #include "DNA_material_types.h" +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_cloth_types.h" @@ -45,6 +46,8 @@ #include "RNA_define.h" #include "RNA_enum_types.h" +#include "BKE_mesh.h" + #include "BLI_string_utils.h" #include "BLT_translation.h" @@ -112,7 +115,7 @@ static const EnumPropertyItem part_ren_as_items[] = { {PART_DRAW_LINE, "LINE", 0, "Line", ""}, {PART_DRAW_PATH, "PATH", 0, "Path", ""}, {PART_DRAW_OB, "OBJECT", 0, "Object", ""}, - {PART_DRAW_GR, "GROUP", 0, "Group", ""}, + {PART_DRAW_GR, "COLLECTION", 0, "Collection", ""}, {PART_DRAW_BB, "BILLBOARD", 0, "Billboard", ""}, {0, NULL, 0, NULL, NULL} }; @@ -122,7 +125,7 @@ static const EnumPropertyItem part_hair_ren_as_items[] = { {PART_DRAW_NOT, "NONE", 0, "None", ""}, {PART_DRAW_PATH, "PATH", 0, "Path", ""}, {PART_DRAW_OB, "OBJECT", 0, "Object", ""}, - {PART_DRAW_GR, "GROUP", 0, "Group", ""}, + {PART_DRAW_GR, "COLLECTION", 0, "Collection", ""}, {0, NULL, 0, NULL, NULL} }; #endif @@ -136,9 +139,6 @@ static const EnumPropertyItem part_hair_ren_as_items[] = { #include "BKE_cloth.h" #include "BKE_colortools.h" #include "BKE_deform.h" -#include "BKE_depsgraph.h" -#include "BKE_DerivedMesh.h" -#include "BKE_cdderivedmesh.h" #include "BKE_effect.h" #include "BKE_material.h" #include "BKE_modifier.h" @@ -146,6 +146,9 @@ static const EnumPropertyItem part_hair_ren_as_items[] = { #include "BKE_pointcache.h" #include "BKE_texture.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + /* use for object space hair get/set */ static void rna_ParticleHairKey_location_object_info(PointerRNA *ptr, ParticleSystemModifierData **psmd_pt, ParticleData **pa_pt) @@ -178,7 +181,7 @@ static void rna_ParticleHairKey_location_object_info(PointerRNA *ptr, ParticleSy for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_ParticleSystem) { psmd = (ParticleSystemModifierData *) md; - if (psmd && psmd->dm_final && psmd->psys) { + if (psmd && psmd->mesh_final && psmd->psys) { psys = psmd->psys; for (i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) { /* hairkeys are stored sequentially in memory, so we can @@ -205,15 +208,15 @@ static void rna_ParticleHairKey_location_object_get(PointerRNA *ptr, float *valu rna_ParticleHairKey_location_object_info(ptr, &psmd, &pa); if (pa) { - DerivedMesh *hairdm = (psmd->psys->flag & PSYS_HAIR_DYNAMICS) ? psmd->psys->hair_out_dm : NULL; + Mesh *hair_mesh = (psmd->psys->flag & PSYS_HAIR_DYNAMICS) ? psmd->psys->hair_out_mesh : NULL; - if (hairdm) { - MVert *mvert = CDDM_get_vert(hairdm, pa->hair_index + (hkey - pa->hair)); + if (hair_mesh) { + MVert *mvert = &hair_mesh->mvert[pa->hair_index + (hkey - pa->hair)]; copy_v3_v3(values, mvert->co); } else { float hairmat[4][4]; - psys_mat_hair_to_object(ob, psmd->dm_final, psmd->psys->part->from, pa, hairmat); + psys_mat_hair_to_object(ob, psmd->mesh_final, psmd->psys->part->from, pa, hairmat); copy_v3_v3(values, hkey->co); mul_m4_v3(hairmat, values); } @@ -233,17 +236,17 @@ static void rna_ParticleHairKey_location_object_set(PointerRNA *ptr, const float rna_ParticleHairKey_location_object_info(ptr, &psmd, &pa); if (pa) { - DerivedMesh *hairdm = (psmd->psys->flag & PSYS_HAIR_DYNAMICS) ? psmd->psys->hair_out_dm : NULL; + Mesh *hair_mesh = (psmd->psys->flag & PSYS_HAIR_DYNAMICS) ? psmd->psys->hair_out_mesh : NULL; - if (hairdm) { - MVert *mvert = CDDM_get_vert(hairdm, pa->hair_index + (hkey - pa->hair)); + if (hair_mesh) { + MVert *mvert = &hair_mesh->mvert[pa->hair_index + (hkey - pa->hair)]; copy_v3_v3(mvert->co, values); } else { float hairmat[4][4]; float imat[4][4]; - psys_mat_hair_to_object(ob, psmd->dm_final, psmd->psys->part->from, pa, hairmat); + psys_mat_hair_to_object(ob, psmd->mesh_final, psmd->psys->part->from, pa, hairmat); invert_m4_m4(imat, hairmat); copy_v3_v3(hkey->co, values); mul_m4_v3(imat, hkey->co); @@ -258,15 +261,15 @@ static void rna_ParticleHairKey_co_object(HairKey *hairkey, Object *object, Part float n_co[3]) { - DerivedMesh *hairdm = (modifier->psys->flag & PSYS_HAIR_DYNAMICS) ? modifier->psys->hair_out_dm : NULL; + Mesh *hair_mesh = (modifier->psys->flag & PSYS_HAIR_DYNAMICS) ? modifier->psys->hair_out_mesh : NULL; if (particle) { - if (hairdm) { - MVert *mvert = CDDM_get_vert(hairdm, particle->hair_index + (hairkey - particle->hair)); + if (hair_mesh) { + MVert *mvert = &hair_mesh->mvert[particle->hair_index + (hairkey - particle->hair)]; copy_v3_v3(n_co, mvert->co); } else { float hairmat[4][4]; - psys_mat_hair_to_object(object, modifier->dm_final, modifier->psys->part->from, particle, hairmat); + psys_mat_hair_to_object(object, modifier->mesh_final, modifier->psys->part->from, particle, hairmat); copy_v3_v3(n_co, hairkey->co); mul_m4_v3(hairmat, n_co); } @@ -285,14 +288,14 @@ static void rna_Particle_uv_on_emitter(ParticleData *particle, ReportList *repor int num = particle->num_dmcache; int from = modifier->psys->part->from; - if (!CustomData_has_layer(&modifier->dm_final->loopData, CD_MLOOPUV)) { + if (!CustomData_has_layer(&modifier->mesh_final->ldata, CD_MLOOPUV)) { BKE_report(reports, RPT_ERROR, "Mesh has no UV data"); return; } - DM_ensure_tessface(modifier->dm_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ + BKE_mesh_tessface_ensure(modifier->mesh_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ if (num == DMCACHE_NOTFOUND) - if (particle->num < modifier->dm_final->getNumTessFaces(modifier->dm_final)) + if (particle->num < modifier->mesh_final->totface) num = particle->num; /* get uvco */ @@ -302,8 +305,8 @@ static void rna_Particle_uv_on_emitter(ParticleData *particle, ReportList *repor MFace *mface; MTFace *mtface; - mface = modifier->dm_final->getTessFaceData(modifier->dm_final, num, CD_MFACE); - mtface = (MTFace *)CustomData_get_layer_n(&modifier->dm_final->faceData, CD_MTFACE, 0); + mface = modifier->mesh_final->mface; + mtface = modifier->mesh_final->mtface; if (mface && mtface) { mtface += num; @@ -324,27 +327,18 @@ static void rna_ParticleSystem_co_hair(ParticleSystem *particlesystem, Object *o ParticleData *pars = NULL; ParticleCacheKey *cache = NULL; int totchild = 0; - int path_nbr = 0; int totpart; int max_k = 0; - int step_nbr = 0; if (particlesystem == NULL) return; part = particlesystem->part; pars = particlesystem->particles; + totpart = particlesystem->totcached; + totchild = particlesystem->totchildcache; - if (particlesystem->renderdata) { - step_nbr = part->ren_step; - totchild = particlesystem->totchild; - } - else { - step_nbr = part->draw_step; - totchild = (int)((float)particlesystem->totchild * (float)(part->disp) / 100.0f); - } - - if (part == NULL || pars == NULL || !psys_check_enabled(object, particlesystem, particlesystem->renderdata != NULL)) + if (part == NULL || pars == NULL) return; if (part->ren_as == PART_DRAW_OB || part->ren_as == PART_DRAW_GR || part->ren_as == PART_DRAW_NOT) @@ -354,47 +348,28 @@ static void rna_ParticleSystem_co_hair(ParticleSystem *particlesystem, Object *o if (part->type == PART_HAIR && !particlesystem->childcache) totchild = 0; - totpart = particlesystem->totpart; - - if (particle_no >= totpart + totchild) - return; - - if (part->ren_as == PART_DRAW_PATH && particlesystem->pathcache) - path_nbr = 1 << step_nbr; - if (part->kink == PART_KINK_SPIRAL) - path_nbr += part->kink_extra_steps; - if (particle_no < totpart) { + cache = particlesystem->pathcache[particle_no]; + max_k = (int)cache->segments; + } + else if (particle_no < totpart + totchild) { + cache = particlesystem->childcache[particle_no - totpart]; - if (path_nbr) { - cache = particlesystem->pathcache[particle_no]; + if (cache->segments < 0) + max_k = 0; + else max_k = (int)cache->segments; - } - } else { - - if (path_nbr) { - cache = particlesystem->childcache[particle_no - totpart]; - - if (cache->segments < 0) - max_k = 0; - else - max_k = (int)cache->segments; - } + return; } - /*strands key loop data stored in cache + step->co*/ - if (path_nbr) { - if (step >= 0 && step <= path_nbr) { - if (step <= max_k) { - copy_v3_v3(n_co, (cache + step)->co); - mul_m4_v3(particlesystem->imat, n_co); - mul_m4_v3(object->obmat, n_co); - } - } + /* Strands key loop data stored in cache + step->co. */ + if (step >= 0 && step <= max_k) { + copy_v3_v3(n_co, (cache + step)->co); + mul_m4_v3(particlesystem->imat, n_co); + mul_m4_v3(object->obmat, n_co); } - } @@ -450,9 +425,9 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys int totvert; int num = -1; - DM_ensure_tessface(modifier->dm_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ - totface = modifier->dm_final->getNumTessFaces(modifier->dm_final); - totvert = modifier->dm_final->getNumVerts(modifier->dm_final); + BKE_mesh_tessface_ensure(modifier->mesh_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ + totface = modifier->mesh_final->totface; + totvert = modifier->mesh_final->totvert; /* 1. check that everything is ok & updated */ if (!particlesystem || !totface) { @@ -460,20 +435,13 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys } part = particlesystem->part; - - if (particlesystem->renderdata) { - totchild = particlesystem->totchild; - } - else { - totchild = (int)((float)particlesystem->totchild * (float)(part->disp) / 100.0f); - } + totpart = particlesystem->totcached; + totchild = particlesystem->totchildcache; /* can happen for disconnected/global hair */ if (part->type == PART_HAIR && !particlesystem->childcache) totchild = 0; - totpart = particlesystem->totpart; - if (particle_no >= totpart + totchild) return num; @@ -489,7 +457,7 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys } else if (part->from == PART_FROM_VERT) { if (num != DMCACHE_NOTFOUND && num < totvert) { - MFace *mface = modifier->dm_final->getTessFaceDataArray(modifier->dm_final, CD_MFACE); + MFace *mface = modifier->mesh_final->mface; *r_fuv = &particle->fuv; @@ -531,7 +499,7 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys } else if (part->from == PART_FROM_VERT) { if (num != DMCACHE_NOTFOUND && num < totvert) { - MFace *mface = modifier->dm_final->getTessFaceDataArray(modifier->dm_final, CD_MFACE); + MFace *mface = modifier->mesh_final->mface; *r_fuv = &parent->fuv; @@ -555,7 +523,7 @@ static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem, Rep ParticleSystemModifierData *modifier, ParticleData *particle, int particle_no, int uv_no, float r_uv[2]) { - if (!CustomData_has_layer(&modifier->dm_final->loopData, CD_MLOOPUV)) { + if (!CustomData_has_layer(&modifier->mesh_final->ldata, CD_MLOOPUV)) { BKE_report(reports, RPT_ERROR, "Mesh has no UV data"); zero_v2(r_uv); return; @@ -572,8 +540,8 @@ static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem, Rep zero_v2(r_uv); } else { - MFace *mface = modifier->dm_final->getTessFaceData(modifier->dm_final, num, CD_MFACE); - MTFace *mtface = (MTFace *)CustomData_get_layer_n(&modifier->dm_final->faceData, CD_MTFACE, uv_no); + MFace *mface = &modifier->mesh_final->mface[num]; + MTFace *mtface = (MTFace *)CustomData_get_layer_n(&modifier->mesh_final->fdata, CD_MTFACE, uv_no); psys_interpolate_uvs(&mtface[num], mface->v4, *fuv, r_uv); } @@ -584,7 +552,7 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, R ParticleSystemModifierData *modifier, ParticleData *particle, int particle_no, int vcol_no, float r_mcol[3]) { - if (!CustomData_has_layer(&modifier->dm_final->loopData, CD_MLOOPCOL)) { + if (!CustomData_has_layer(&modifier->mesh_final->ldata, CD_MLOOPCOL)) { BKE_report(reports, RPT_ERROR, "Mesh has no VCol data"); zero_v3(r_mcol); return; @@ -601,8 +569,8 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, R zero_v3(r_mcol); } else { - MFace *mface = modifier->dm_final->getTessFaceData(modifier->dm_final, num, CD_MFACE); - MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->dm_final->faceData, CD_MCOL, vcol_no); + MFace *mface = &modifier->mesh_final->mface[num]; + MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->mesh_final->fdata, CD_MCOL, vcol_no); MCol mcol; psys_interpolate_mcol(&mc[num * 4], mface->v4, *fuv, &mcol); @@ -613,42 +581,18 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, R } } -static void rna_ParticleSystem_set_resolution( - ParticleSystem *particlesystem, Main *bmain, Scene *scene, Object *object, int resolution) -{ - if (resolution == eModifierMode_Render) { - ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem); - float mat[4][4]; - - unit_m4(mat); - - psys_render_set(object, particlesystem, mat, mat, 1, 1, 0.f); - psmd->flag &= ~eParticleSystemFlag_psys_updated; - particle_system_update(bmain, scene, object, particlesystem, true); - } - else { - ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem); - - if (particlesystem->renderdata) { - psys_render_restore(object, particlesystem); - } - - psmd->flag &= ~eParticleSystemFlag_psys_updated; - particle_system_update(bmain, scene, object, particlesystem, false); - } -} - static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr, short flag) { if (ptr->type == &RNA_ParticleSystem) { + Object *ob = ptr->id.data; ParticleSystem *psys = (ParticleSystem *)ptr->data; psys->recalc = flag; - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } else - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA | flag); + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA | flag); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); } @@ -659,10 +603,18 @@ static void rna_Particle_redo(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Particle_redo_dependency(Main *bmain, Scene *scene, PointerRNA *ptr) { - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); rna_Particle_redo(bmain, scene, ptr); } +static void rna_Particle_redo_count(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + ParticleSettings *part = (ParticleSettings *)ptr->data; + DEG_relations_tag_update(bmain); + psys_check_group_weights(part); + particle_recalc(bmain, scene, ptr, PSYS_RECALC_REDO); +} + static void rna_Particle_reset(Main *bmain, Scene *scene, PointerRNA *ptr) { particle_recalc(bmain, scene, ptr, PSYS_RECALC_RESET); @@ -670,14 +622,27 @@ static void rna_Particle_reset(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Particle_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr) { - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); rna_Particle_reset(bmain, scene, ptr); } -static void rna_Particle_change_type(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Particle_change_type(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - particle_recalc(bmain, scene, ptr, PSYS_RECALC_RESET | PSYS_RECALC_TYPE); - DAG_relations_tag_update(bmain); + ParticleSettings *part = ptr->id.data; + + /* Iterating over all object is slow, but no better solution exists at the moment. */ + for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { + for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) { + if (psys->part == part) { + psys_changed_type(ob, psys); + psys->recalc |= PSYS_RECALC_RESET; + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + } + } + } + + WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); + DEG_relations_tag_update(bmain); } static void rna_Particle_change_physics_type(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -716,7 +681,7 @@ static void rna_Particle_cloth_update(Main *UNUSED(bmain), Scene *UNUSED(scene), { Object *ob = (Object *)ptr->id.data; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } @@ -761,8 +726,8 @@ static void rna_Particle_target_reset(Main *bmain, Scene *UNUSED(scene), Pointer psys->recalc = PSYS_RECALC_RESET; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - DAG_relations_tag_update(bmain); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_relations_tag_update(bmain); } WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); @@ -777,7 +742,7 @@ static void rna_Particle_target_redo(Main *UNUSED(bmain), Scene *UNUSED(scene), psys->recalc = PSYS_RECALC_REDO; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); } } @@ -790,7 +755,7 @@ static void rna_Particle_hair_dynamics_update(Main *bmain, Scene *scene, Pointer if (psys && !psys->clmd) { psys->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth); psys->clmd->sim_parms->goalspring = 0.0f; - psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL | CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS; + psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS; psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF; rna_Particle_redo(bmain, scene, ptr); } @@ -798,9 +763,10 @@ static void rna_Particle_hair_dynamics_update(Main *bmain, Scene *scene, Pointer WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - DAG_relations_tag_update(bmain); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_relations_tag_update(bmain); } + static PointerRNA rna_particle_settings_get(PointerRNA *ptr) { ParticleSystem *psys = (ParticleSystem *)ptr->data; @@ -811,6 +777,7 @@ static PointerRNA rna_particle_settings_get(PointerRNA *ptr) static void rna_particle_settings_set(PointerRNA *ptr, PointerRNA value) { + Object *ob = ptr->id.data; ParticleSystem *psys = (ParticleSystem *)ptr->data; int old_type = 0; @@ -825,8 +792,9 @@ static void rna_particle_settings_set(PointerRNA *ptr, PointerRNA value) if (psys->part) { id_us_plus(&psys->part->id); psys_check_boid_data(psys); - if (old_type != psys->part->type) - psys->recalc |= PSYS_RECALC_TYPE; + if (old_type != psys->part->type) { + psys_changed_type(ob, psys); + } } } static void rna_Particle_abspathtime_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -1164,6 +1132,9 @@ static void rna_ParticleDupliWeight_active_index_set(struct PointerRNA *ptr, int static void rna_ParticleDupliWeight_name_get(PointerRNA *ptr, char *str) { + ParticleSettings *part = (ParticleSettings *)ptr->id.data; + psys_find_group_weights(part); + ParticleDupliWeight *dw = ptr->data; if (dw->ob) @@ -2333,11 +2304,6 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Size", "Show particle size"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); - prop = RNA_def_property(srna, "use_render_emitter", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_EMITTER); - RNA_def_property_ui_text(prop, "Emitter", "Render emitter Object also"); - RNA_def_property_update(prop, 0, "rna_Particle_redo"); - prop = RNA_def_property(srna, "show_health", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_HEALTH); RNA_def_property_ui_text(prop, "Health", "Draw boid health"); @@ -2365,8 +2331,8 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "use_group_count", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_COUNT_GR); - RNA_def_property_ui_text(prop, "Use Count", "Use object multiple times in the same group"); - RNA_def_property_update(prop, 0, "rna_Particle_redo"); + RNA_def_property_ui_text(prop, "Use Count", "Use object multiple times in the same collection"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_count"); prop = RNA_def_property(srna, "use_global_dupli", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_GLOBAL_OB); @@ -2405,7 +2371,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Strand Render", "Use the strand primitive for rendering"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); - prop = RNA_def_property(srna, "draw_method", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "display_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "draw_as"); RNA_def_property_enum_items(prop, part_draw_as_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_draw_as_itemf"); @@ -2419,16 +2385,17 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Particle Rendering", "How particles are rendered"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); - prop = RNA_def_property(srna, "draw_color", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "display_color", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "draw_col"); RNA_def_property_enum_items(prop, draw_col_items); RNA_def_property_ui_text(prop, "Draw Color", "Draw additional particle data as a color"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); - prop = RNA_def_property(srna, "draw_size", PROP_INT, PROP_PIXEL); + prop = RNA_def_property(srna, "display_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "draw_size"); RNA_def_property_range(prop, 0, 1000); RNA_def_property_ui_range(prop, 0, 100, 1, -1); - RNA_def_property_ui_text(prop, "Draw Size", "Size of particles on viewport in pixels (0=default)"); + RNA_def_property_ui_text(prop, "Draw Size", "Size of particles on viewport in BU"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); prop = RNA_def_property(srna, "child_type", PROP_ENUM, PROP_NONE); @@ -2437,7 +2404,8 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Children From", "Create child particles"); RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); - prop = RNA_def_property(srna, "draw_step", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "display_step", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "draw_step"); RNA_def_property_range(prop, 0, 10); RNA_def_property_ui_range(prop, 0, 7, 1, -1); RNA_def_property_ui_text(prop, "Steps", "How many steps paths are drawn with (power of 2)"); @@ -2477,7 +2445,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0, 50); RNA_def_property_ui_text(prop, "Pixel", "How many pixels path has to cover to make another render segment"); - prop = RNA_def_property(srna, "draw_percentage", PROP_INT, PROP_PERCENTAGE); + prop = RNA_def_property(srna, "display_percentage", PROP_INT, PROP_PERCENTAGE); RNA_def_property_int_sdna(prop, NULL, "disp"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Display", "Percentage of particles to display in 3D view"); @@ -2586,33 +2554,6 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Billboard Velocity Tail", "Scale billboards by velocity"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); - /* simplification */ - prop = RNA_def_property(srna, "use_simplify", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", PART_SIMPLIFY_ENABLE); - RNA_def_property_ui_text(prop, "Child Simplification", - "Remove child strands as the object becomes smaller on the screen"); - - prop = RNA_def_property(srna, "use_simplify_viewport", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", PART_SIMPLIFY_VIEWPORT); - RNA_def_property_ui_text(prop, "Viewport", ""); - - prop = RNA_def_property(srna, "simplify_refsize", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "simplify_refsize"); - RNA_def_property_range(prop, 1, SHRT_MAX); - RNA_def_property_ui_text(prop, "Reference Size", "Reference size in pixels, after which simplification begins"); - - prop = RNA_def_property(srna, "simplify_rate", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Rate", "Speed of simplification"); - - prop = RNA_def_property(srna, "simplify_transition", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Transition", "Transition period for fading out strands"); - - prop = RNA_def_property(srna, "simplify_viewport", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 0.999f); - RNA_def_property_ui_text(prop, "Rate", "Speed of Simplification"); - /* general values */ prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "sta"); /*optional if prop names are the same */ @@ -2840,8 +2781,9 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Particle_reset"); prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Collision Group", "Limit colliders to this Group"); + RNA_def_property_ui_text(prop, "Collision Collection", "Limit colliders to this collection"); RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency"); /* global physical properties */ @@ -3153,10 +3095,10 @@ static void rna_def_particle_settings(BlenderRNA *brna) /* draw objects & groups */ prop = RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "dup_group"); - RNA_def_property_struct_type(prop, "Group"); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Dupli Group", "Show Objects in this Group in place of particles"); - RNA_def_property_update(prop, 0, "rna_Particle_redo"); + RNA_def_property_ui_text(prop, "Dupli Collection", "Show Objects in this collection in place of particles"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_count"); prop = RNA_def_property(srna, "dupli_weights", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "dupliweights", NULL); @@ -3239,6 +3181,38 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Twist Curve", "Curve defining twist"); RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + + /* hair shape */ + prop = RNA_def_property(srna, "use_close_tip", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shape_flag", PART_SHAPE_CLOSE_TIP); + RNA_def_property_ui_text(prop, "Close Tip", "Set tip radius to zero"); + RNA_def_property_update(prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */ + + prop = RNA_def_property(srna, "shape", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, -1.0f, 1.0f); + RNA_def_property_ui_text(prop, "Shape", "Strand shape parameter"); + RNA_def_property_update(prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */ + + prop = RNA_def_property(srna, "root_radius", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "rad_root"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2); + RNA_def_property_ui_text(prop, "Root", "Strand width at the root"); + RNA_def_property_update(prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */ + + prop = RNA_def_property(srna, "tip_radius", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "rad_tip"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2); + RNA_def_property_ui_text(prop, "Tip", "Strand width at the tip"); + RNA_def_property_update(prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */ + + prop = RNA_def_property(srna, "radius_scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "rad_scale"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2); + RNA_def_property_ui_text(prop, "Scaling", "Multiplier of radius properties"); + RNA_def_property_update(prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */ } static void rna_def_particle_target(BlenderRNA *brna) @@ -3309,12 +3283,6 @@ static void rna_def_particle_system(BlenderRNA *brna) FunctionRNA *func; PropertyRNA *parm; - static const EnumPropertyItem resolution_items[] = { - {eModifierMode_Realtime, "PREVIEW", 0, "Preview", "Apply modifier preview settings"}, - {eModifierMode_Render, "RENDER", 0, "Render", "Apply modifier render settings"}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "ParticleSystem", NULL); RNA_def_struct_ui_text(srna, "Particle System", "Particle system in an object"); RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA); @@ -3338,11 +3306,13 @@ static void rna_def_particle_system(BlenderRNA *brna) prop = RNA_def_property(srna, "particles", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "particles", "totpart"); RNA_def_property_struct_type(prop, "Particle"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); RNA_def_property_ui_text(prop, "Particles", "Particles generated by the particle system"); prop = RNA_def_property(srna, "child_particles", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "child", "totchild"); RNA_def_property_struct_type(prop, "ChildParticle"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); RNA_def_property_ui_text(prop, "Child Particles", "Child particles generated by the particle system"); prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED); @@ -3625,14 +3595,6 @@ static void rna_def_particle_system(BlenderRNA *brna) RNA_def_struct_path_func(srna, "rna_ParticleSystem_path"); - /* set viewport or render resolution */ - func = RNA_def_function(srna, "set_resolution", "rna_ParticleSystem_set_resolution"); - RNA_def_function_ui_description(func, "Set the resolution to use for the number of particles"); - RNA_def_function_flag(func, FUNC_USE_MAIN); - RNA_def_pointer(func, "scene", "Scene", "", "Scene"); - RNA_def_pointer(func, "object", "Object", "", "Object"); - RNA_def_enum(func, "resolution", resolution_items, 0, "", "Resolution settings to apply"); - /* extract cached hair location data */ func = RNA_def_function(srna, "co_hair", "rna_ParticleSystem_co_hair"); RNA_def_function_ui_description(func, "Obtain cache hair data"); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index e06aab8c4cc..61a63bc939f 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -68,26 +68,26 @@ const EnumPropertyItem rna_enum_posebone_rotmode_items[] = { /* Bone and Group Color Sets */ const EnumPropertyItem rna_enum_color_sets_items[] = { {0, "DEFAULT", 0, "Default Colors", ""}, - {1, "THEME01", VICO_COLORSET_01_VEC, "01 - Theme Color Set", ""}, - {2, "THEME02", VICO_COLORSET_02_VEC, "02 - Theme Color Set", ""}, - {3, "THEME03", VICO_COLORSET_03_VEC, "03 - Theme Color Set", ""}, - {4, "THEME04", VICO_COLORSET_04_VEC, "04 - Theme Color Set", ""}, - {5, "THEME05", VICO_COLORSET_05_VEC, "05 - Theme Color Set", ""}, - {6, "THEME06", VICO_COLORSET_06_VEC, "06 - Theme Color Set", ""}, - {7, "THEME07", VICO_COLORSET_07_VEC, "07 - Theme Color Set", ""}, - {8, "THEME08", VICO_COLORSET_08_VEC, "08 - Theme Color Set", ""}, - {9, "THEME09", VICO_COLORSET_09_VEC, "09 - Theme Color Set", ""}, - {10, "THEME10", VICO_COLORSET_10_VEC, "10 - Theme Color Set", ""}, - {11, "THEME11", VICO_COLORSET_11_VEC, "11 - Theme Color Set", ""}, - {12, "THEME12", VICO_COLORSET_12_VEC, "12 - Theme Color Set", ""}, - {13, "THEME13", VICO_COLORSET_13_VEC, "13 - Theme Color Set", ""}, - {14, "THEME14", VICO_COLORSET_14_VEC, "14 - Theme Color Set", ""}, - {15, "THEME15", VICO_COLORSET_15_VEC, "15 - Theme Color Set", ""}, - {16, "THEME16", VICO_COLORSET_16_VEC, "16 - Theme Color Set", ""}, - {17, "THEME17", VICO_COLORSET_17_VEC, "17 - Theme Color Set", ""}, - {18, "THEME18", VICO_COLORSET_18_VEC, "18 - Theme Color Set", ""}, - {19, "THEME19", VICO_COLORSET_19_VEC, "19 - Theme Color Set", ""}, - {20, "THEME20", VICO_COLORSET_20_VEC, "20 - Theme Color Set", ""}, + {1, "THEME01", ICON_COLORSET_01_VEC, "01 - Theme Color Set", ""}, + {2, "THEME02", ICON_COLORSET_02_VEC, "02 - Theme Color Set", ""}, + {3, "THEME03", ICON_COLORSET_03_VEC, "03 - Theme Color Set", ""}, + {4, "THEME04", ICON_COLORSET_04_VEC, "04 - Theme Color Set", ""}, + {5, "THEME05", ICON_COLORSET_05_VEC, "05 - Theme Color Set", ""}, + {6, "THEME06", ICON_COLORSET_06_VEC, "06 - Theme Color Set", ""}, + {7, "THEME07", ICON_COLORSET_07_VEC, "07 - Theme Color Set", ""}, + {8, "THEME08", ICON_COLORSET_08_VEC, "08 - Theme Color Set", ""}, + {9, "THEME09", ICON_COLORSET_09_VEC, "09 - Theme Color Set", ""}, + {10, "THEME10", ICON_COLORSET_10_VEC, "10 - Theme Color Set", ""}, + {11, "THEME11", ICON_COLORSET_11_VEC, "11 - Theme Color Set", ""}, + {12, "THEME12", ICON_COLORSET_12_VEC, "12 - Theme Color Set", ""}, + {13, "THEME13", ICON_COLORSET_13_VEC, "13 - Theme Color Set", ""}, + {14, "THEME14", ICON_COLORSET_14_VEC, "14 - Theme Color Set", ""}, + {15, "THEME15", ICON_COLORSET_15_VEC, "15 - Theme Color Set", ""}, + {16, "THEME16", ICON_COLORSET_16_VEC, "16 - Theme Color Set", ""}, + {17, "THEME17", ICON_COLORSET_17_VEC, "17 - Theme Color Set", ""}, + {18, "THEME18", ICON_COLORSET_18_VEC, "18 - Theme Color Set", ""}, + {19, "THEME19", ICON_COLORSET_19_VEC, "19 - Theme Color Set", ""}, + {20, "THEME20", ICON_COLORSET_20_VEC, "20 - Theme Color Set", ""}, {-1, "CUSTOM", 0, "Custom Color Set", ""}, {0, NULL, 0, NULL, NULL} }; @@ -106,10 +106,12 @@ const EnumPropertyItem rna_enum_color_sets_items[] = { #include "BKE_context.h" #include "BKE_constraint.h" -#include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_idprop.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "ED_object.h" #include "ED_armature.h" @@ -121,7 +123,16 @@ static void rna_Pose_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN { /* XXX when to use this? ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); */ - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + WM_main_add_notifier(NC_OBJECT | ND_POSE, ptr->id.data); +} + +static void rna_Pose_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + DEG_relations_tag_update(bmain); + + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + WM_main_add_notifier(NC_OBJECT | ND_POSE, ptr->id.data); } static void rna_Pose_IK_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -129,7 +140,9 @@ static void rna_Pose_IK_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe /* XXX when to use this? ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); */ Object *ob = ptr->id.data; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_OBJECT | ND_POSE, ptr->id.data); + BIK_clear_data(ob->pose); } @@ -234,13 +247,13 @@ static void rna_Pose_ik_solver_update(Main *bmain, Scene *UNUSED(scene), Pointer bPose *pose = ptr->data; BKE_pose_tag_recalc(bmain, pose); /* checks & sorts pose channels */ - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); BKE_pose_update_constraint_flags(pose); object_test_constraints(bmain, ob); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); } /* rotation - axis-angle */ @@ -352,7 +365,7 @@ static void rna_Itasc_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR itasc->maxvel = 100.f; BIK_update_param(ob->pose); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } static void rna_Itasc_update_rebuild(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -564,6 +577,56 @@ static void rna_PoseChannel_constraints_remove( } } +bool rna_PoseChannel_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"); + + bPoseChannel *pchan_dst = (bPoseChannel *)ptr_dst->data; + bPoseChannel *pchan_src = (bPoseChannel *)ptr_src->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(&pchan_dst->constraints, opop->subitem_local_name, offsetof(bConstraint, name)); + } + if (con_anchor == NULL && opop->subitem_local_index >= 0) { + con_anchor = BLI_findlink(&pchan_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(&pchan_src->constraints, opop->subitem_local_name, offsetof(bConstraint, name)); + } + if (con_src == NULL && opop->subitem_local_index >= 0) { + con_src = BLI_findlink(&pchan_src->constraints, opop->subitem_local_index); + } + con_src = con_src ? con_src->next : pchan_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(&pchan_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, &pchan_dst->constraints); + +// printf("%s: We inserted a constraint...\n", __func__); + return true; +} + static int rna_PoseChannel_proxy_editable(PointerRNA *ptr, const char **r_info) { Object *ob = (Object *)ptr->id.data; @@ -675,11 +738,30 @@ static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values) Object *ob = (Object *)ptr->id.data; float tmat[4][4]; - BKE_armature_mat_pose_to_bone_ex(ob, pchan, (float (*)[4])values, tmat); + BKE_armature_mat_pose_to_bone_ex(NULL, ob, pchan, (float (*)[4])values, tmat); BKE_pchan_apply_mat4(pchan, tmat, false); /* no compat for predictable result */ } +static bPoseChannel *rna_PoseChannel_ensure_own_pchan(Object *ob, Object *ref_ob, bPoseChannel *ref_pchan) +{ + if (ref_ob != ob) { + /* We are trying to set a pchan from another object! Forbidden, try to find by name, or abort. */ + if (ref_pchan != NULL) { + ref_pchan = BKE_pose_channel_find_name(ob->pose, ref_pchan->name); + } + } + return ref_pchan; +} + +static void rna_PoseChannel_custom_shape_transform_set(PointerRNA *ptr, PointerRNA value) +{ + bPoseChannel *pchan = (bPoseChannel *)ptr->data; + Object *ob = (Object *)ptr->id.data; + + pchan->custom_tx = rna_PoseChannel_ensure_own_pchan(ob, value.id.data, value.data); +} + #else /* common properties for Action/Bone Groups - related to color */ @@ -807,7 +889,9 @@ static void rna_def_pose_channel(BlenderRNA *brna) /* Bone 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 that act on this PoseChannel"); + RNA_def_property_override_funcs(prop, NULL, NULL, "rna_PoseChannel_constraints_override_apply"); rna_def_pose_channel_constraints(brna, prop); @@ -825,22 +909,26 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop = RNA_def_property(srna, "bone", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "Bone"); + RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bone", "Bone associated with this PoseBone"); prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "PoseBone"); + RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Parent", "Parent of this pose bone"); prop = RNA_def_property(srna, "child", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "PoseBone"); + RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Child", "Child of this pose bone"); /* Transformation settings */ prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_location_editable"); RNA_def_property_ui_text(prop, "Location", ""); RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); @@ -849,6 +937,7 @@ static void rna_def_pose_channel(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_PoseChannel_scale_editable"); RNA_def_property_float_array_default(prop, default_scale); RNA_def_property_ui_text(prop, "Scale", ""); @@ -856,6 +945,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "quat"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable"); RNA_def_property_float_array_default(prop, default_quat); RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions"); @@ -865,6 +955,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) * having a single one is better for Keyframing and other property-management situations... */ prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_array(prop, 4); RNA_def_property_float_funcs(prop, "rna_PoseChannel_rotation_axis_angle_get", "rna_PoseChannel_rotation_axis_angle_set", NULL); @@ -875,6 +966,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "eul"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_euler_editable"); RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); @@ -892,45 +984,23 @@ static void rna_def_pose_channel(BlenderRNA *brna) rna_def_bone_curved_common(srna, true); /* Custom BBone next/prev sources */ - prop = RNA_def_property(srna, "use_bbone_custom_handles", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bboneflag", PCHAN_BBONE_CUSTOM_HANDLES); - RNA_def_property_ui_text(prop, "Use Custom Handle References", - "Use custom reference bones as handles for B-Bones instead of next/previous bones, " - "leave these blank to use only B-Bone offset properties to control the shape"); - RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); - RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); - prop = RNA_def_property(srna, "bbone_custom_handle_start", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "bbone_prev"); RNA_def_property_struct_type(prop, "PoseBone"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP); + RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); RNA_def_property_ui_text(prop, "B-Bone Start Handle", "Bone that serves as the start handle for the B-Bone curve"); - RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); - RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); - - prop = RNA_def_property(srna, "use_bbone_relative_start_handle", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bboneflag", PCHAN_BBONE_CUSTOM_START_REL); - RNA_def_property_ui_text(prop, "Relative B-Bone Start Handle", - "Treat custom start handle position as a relative value"); - RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); - RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); + RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_dependency_update"); prop = RNA_def_property(srna, "bbone_custom_handle_end", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "bbone_next"); RNA_def_property_struct_type(prop, "PoseBone"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP); + RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); RNA_def_property_ui_text(prop, "B-Bone End Handle", "Bone that serves as the end handle for the B-Bone curve"); - RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); - RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); - - prop = RNA_def_property(srna, "use_bbone_relative_end_handle", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bboneflag", PCHAN_BBONE_CUSTOM_END_REL); - RNA_def_property_ui_text(prop, "Relative B-Bone End Handle", - "Treat custom end handle position as a relative value"); - RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); - RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); + RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_dependency_update"); /* transform matrices - should be read-only since these are set directly by AnimSys evaluation */ prop = RNA_def_property(srna, "matrix_channel", PROP_FLOAT, PROP_MATRIX); @@ -1136,10 +1206,12 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop = RNA_def_property(srna, "custom_shape_transform", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "custom_tx"); RNA_def_property_struct_type(prop, "PoseBone"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_PTR_NO_OWNERSHIP); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Custom Shape Transform", "Bone that defines the display transform of this custom shape"); RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_PoseChannel_custom_shape_transform_set", NULL, NULL); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); /* bone groups */ @@ -1401,6 +1473,7 @@ static void rna_def_pose(BlenderRNA *brna) prop = RNA_def_property(srna, "bones", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "chanbase", NULL); RNA_def_property_struct_type(prop, "PoseBone"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Pose Bones", "Individual pose bones for the armature"); /* can be removed, only for fast lookup */ RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, "rna_PoseBones_lookup_string", NULL); diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c deleted file mode 100644 index 9a79aa4023c..00000000000 --- a/source/blender/makesrna/intern/rna_property.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Blender Foundation (2008). - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/makesrna/intern/rna_property.c - * \ingroup RNA - */ - - -#include <stdlib.h> - -#include "DNA_property_types.h" -#include "DNA_object_types.h" - -#include "BLI_path_util.h" -#include "BLI_string_utils.h" - -#include "BLT_translation.h" - -#include "RNA_define.h" -#include "RNA_enum_types.h" - -#include "rna_internal.h" - - -#include "WM_types.h" - -const EnumPropertyItem rna_enum_gameproperty_type_items[] = { - {GPROP_BOOL, "BOOL", 0, "Boolean", "Boolean Property"}, - {GPROP_INT, "INT", 0, "Integer", "Integer Property"}, - {GPROP_FLOAT, "FLOAT", 0, "Float", "Floating-Point Property"}, - {GPROP_STRING, "STRING", 0, "String", "String Property"}, - {GPROP_TIME, "TIMER", 0, "Timer", "Timer Property"}, - {0, NULL, 0, NULL, NULL} -}; - - -#ifdef RNA_RUNTIME - -#include "BKE_property.h" - -static StructRNA *rna_GameProperty_refine(struct PointerRNA *ptr) -{ - bProperty *property = (bProperty *)ptr->data; - - switch (property->type) { - case GPROP_BOOL: - return &RNA_GameBooleanProperty; - case GPROP_INT: - return &RNA_GameIntProperty; - case GPROP_FLOAT: - return &RNA_GameFloatProperty; - case GPROP_STRING: - return &RNA_GameStringProperty; - case GPROP_TIME: - return &RNA_GameTimerProperty; - default: - return &RNA_GameProperty; - } -} - -/* for both float and timer */ -static float rna_GameFloatProperty_value_get(PointerRNA *ptr) -{ - bProperty *prop = (bProperty *)(ptr->data); - return *(float *)(&prop->data); -} - -static void rna_GameFloatProperty_value_set(PointerRNA *ptr, float value) -{ - bProperty *prop = (bProperty *)(ptr->data); - CLAMP(value, -10000.0f, 10000.0f); - *(float *)(&prop->data) = value; -} - -static void rna_GameProperty_type_set(PointerRNA *ptr, int value) -{ - bProperty *prop = (bProperty *)(ptr->data); - - if (prop->type != value) { - prop->type = value; - BKE_bproperty_init(prop); - } -} - -static void rna_GameProperty_name_set(PointerRNA *ptr, const char *value) -{ - Object *ob = ptr->id.data; - bProperty *prop = ptr->data; - BLI_strncpy_utf8(prop->name, value, sizeof(prop->name)); - - BLI_uniquename(&ob->prop, prop, DATA_("Property"), '.', offsetof(bProperty, name), sizeof(prop->name)); -} - - -#else - -void RNA_def_gameproperty(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - /* Base Struct for GameProperty */ - srna = RNA_def_struct(brna, "GameProperty", NULL); - RNA_def_struct_ui_text(srna, "Game Property", "Game engine user defined object property"); - RNA_def_struct_sdna(srna, "bProperty"); - RNA_def_struct_refine_func(srna, "rna_GameProperty_refine"); - - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Name", "Available as GameObject attributes in the game engine's python API"); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GameProperty_name_set"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, rna_enum_gameproperty_type_items); - RNA_def_property_ui_text(prop, "Type", ""); - RNA_def_property_enum_funcs(prop, NULL, "rna_GameProperty_type_set", NULL); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_debug", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PROP_DEBUG); - RNA_def_property_ui_text(prop, "Debug", "Print debug information for this property"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* GameBooleanProperty */ - srna = RNA_def_struct(brna, "GameBooleanProperty", "GameProperty"); - RNA_def_struct_ui_text(srna, "Game Boolean Property", "Game engine user defined Boolean property"); - RNA_def_struct_sdna(srna, "bProperty"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "data", 1); - RNA_def_property_ui_text(prop, "Value", "Property value"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* GameIntProperty */ - srna = RNA_def_struct(brna, "GameIntProperty", "GameProperty"); - RNA_def_struct_ui_text(srna, "Game Integer Property", "Game engine user defined integer number property"); - RNA_def_struct_sdna(srna, "bProperty"); - - prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "data"); - RNA_def_property_ui_text(prop, "Value", "Property value"); - RNA_def_property_range(prop, -10000, 10000); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* GameFloatProperty */ - srna = RNA_def_struct(brna, "GameFloatProperty", "GameProperty"); - RNA_def_struct_ui_text(srna, "Game Float Property", "Game engine user defined floating point number property"); - RNA_def_struct_sdna(srna, "bProperty"); - - prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE); - /* RNA_def_property_float_sdna(prop, NULL, "data"); */ - RNA_def_property_ui_text(prop, "Value", "Property value"); - RNA_def_property_range(prop, -10000, 10000); - RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* GameTimerProperty */ - srna = RNA_def_struct(brna, "GameTimerProperty", "GameProperty"); - RNA_def_struct_ui_text(srna, "Game Timer Property", "Game engine user defined timer property"); - RNA_def_struct_sdna(srna, "bProperty"); - - prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE); - /* RNA_def_property_float_sdna(prop, NULL, "data"); */ - RNA_def_property_ui_text(prop, "Value", "Property value"); - RNA_def_property_range(prop, -10000, 10000); - RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* GameStringProperty */ - srna = RNA_def_struct(brna, "GameStringProperty", "GameProperty"); - RNA_def_struct_ui_text(srna, "Game String Property", "Game engine user defined text string property"); - RNA_def_struct_sdna(srna, "bProperty"); - - prop = RNA_def_property(srna, "value", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "poin"); - RNA_def_property_string_maxlength(prop, MAX_PROPSTRING); - RNA_def_property_ui_text(prop, "Value", "Property value"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - -#endif diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index b516accbf1e..1e9f68c577b 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -33,6 +33,8 @@ #include "BLI_utildefines.h" #include "BLI_path_util.h" +#include "DEG_depsgraph.h" + #include "BKE_scene.h" #include "BKE_image.h" @@ -54,7 +56,7 @@ const EnumPropertyItem rna_enum_render_pass_type_items[] = { {SCE_PASS_DIFFUSE, "DIFFUSE", 0, "Diffuse", ""}, {SCE_PASS_SPEC, "SPECULAR", 0, "Specular", ""}, {SCE_PASS_SHADOW, "SHADOW", 0, "Shadow", ""}, - {SCE_PASS_AO, "AO", 0, "AO", ""}, + {SCE_PASS_AO, "AO", 0, "Ambient Occlusion", ""}, {SCE_PASS_REFLECT, "REFLECTION", 0, "Reflection", ""}, {SCE_PASS_NORMAL, "NORMAL", 0, "Normal", ""}, {SCE_PASS_VECTOR, "VECTOR", 0, "Vector", ""}, @@ -85,7 +87,7 @@ const EnumPropertyItem rna_enum_render_pass_type_items[] = { const EnumPropertyItem rna_enum_bake_pass_type_items[] = { {SCE_PASS_COMBINED, "COMBINED", 0, "Combined", ""}, - {SCE_PASS_AO, "AO", 0, "AO", ""}, + {SCE_PASS_AO, "AO", 0, "Ambient Occlusion", ""}, {SCE_PASS_SHADOW, "SHADOW", 0, "Shadow", ""}, {SCE_PASS_NORMAL, "NORMAL", 0, "Normal", ""}, {SCE_PASS_UV, "UV", 0, "UV", ""}, @@ -111,6 +113,8 @@ const EnumPropertyItem rna_enum_bake_pass_type_items[] = { #include "IMB_colormanagement.h" #include "GPU_extensions.h" +#include "DEG_depsgraph_query.h" + /* RenderEngine Callbacks */ static void engine_tag_redraw(RenderEngine *engine) @@ -146,7 +150,7 @@ static void engine_unbind_display_space_shader(RenderEngine *UNUSED(engine)) IMB_colormanagement_finish_glsl_draw(); } -static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene) +static void engine_update(RenderEngine *engine, Main *bmain, Depsgraph *depsgraph) { extern FunctionRNA rna_RenderEngine_update_func; PointerRNA ptr; @@ -158,13 +162,13 @@ static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene) RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "data", &bmain); - RNA_parameter_set_lookup(&list, "scene", &scene); + RNA_parameter_set_lookup(&list, "depsgraph", &depsgraph); engine->type->ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } -static void engine_render(RenderEngine *engine, struct Scene *scene) +static void engine_render(RenderEngine *engine, Depsgraph *depsgraph) { extern FunctionRNA rna_RenderEngine_render_func; PointerRNA ptr; @@ -175,13 +179,13 @@ static void engine_render(RenderEngine *engine, struct Scene *scene) func = &rna_RenderEngine_render_func; RNA_parameter_list_create(&list, &ptr, func); - RNA_parameter_set_lookup(&list, "scene", &scene); + RNA_parameter_set_lookup(&list, "depsgraph", &depsgraph); engine->type->ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } -static void engine_bake(RenderEngine *engine, struct Scene *scene, +static void engine_bake(RenderEngine *engine, struct Depsgraph *depsgraph, struct Object *object, const int pass_type, const int pass_filter, const int object_id, const struct BakePixel *pixel_array, const int num_pixels, const int depth, void *result) @@ -195,7 +199,7 @@ static void engine_bake(RenderEngine *engine, struct Scene *scene, func = &rna_RenderEngine_bake_func; RNA_parameter_list_create(&list, &ptr, func); - RNA_parameter_set_lookup(&list, "scene", &scene); + RNA_parameter_set_lookup(&list, "depsgraph", &depsgraph); RNA_parameter_set_lookup(&list, "object", &object); RNA_parameter_set_lookup(&list, "pass_type", &pass_type); RNA_parameter_set_lookup(&list, "pass_filter", &pass_filter); @@ -261,7 +265,7 @@ static void engine_update_script_node(RenderEngine *engine, struct bNodeTree *nt RNA_parameter_list_free(&list); } -static void engine_update_render_passes(RenderEngine *engine, struct Scene *scene, struct SceneRenderLayer *srl) +static void engine_update_render_passes(RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer) { extern FunctionRNA rna_RenderEngine_update_render_passes_func; PointerRNA ptr; @@ -273,7 +277,7 @@ static void engine_update_render_passes(RenderEngine *engine, struct Scene *scen RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "scene", &scene); - RNA_parameter_set_lookup(&list, "renderlayer", &srl); + RNA_parameter_set_lookup(&list, "renderlayer", &view_layer); engine->type->ext.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); @@ -303,7 +307,7 @@ static StructRNA *rna_RenderEngine_register( RenderEngineType *et, dummyet = {NULL}; RenderEngine dummyengine = {NULL}; PointerRNA dummyptr; - int have_function[7]; + int have_function[8]; /* setup dummy engine & engine type to store static properties in */ dummyengine.type = &dummyet; @@ -347,7 +351,7 @@ static StructRNA *rna_RenderEngine_register( et->update_script_node = (have_function[5]) ? engine_update_script_node : NULL; et->update_render_passes = (have_function[6]) ? engine_update_render_passes : NULL; - BLI_addtail(&R_engines, et); + RE_engines_register(et); return et->ext.srna; } @@ -381,10 +385,11 @@ static PointerRNA rna_RenderEngine_render_get(PointerRNA *ptr) static PointerRNA rna_RenderEngine_camera_override_get(PointerRNA *ptr) { RenderEngine *engine = (RenderEngine *)ptr->data; - + /* TODO(sergey): Shouldn't engine point to an evaluated datablocks already? */ if (engine->re) { Object *cam = RE_GetCamera(engine->re); - return rna_pointer_inherit_refine(ptr, &RNA_Object, cam); + Object *cam_eval = DEG_get_evaluated_object(engine->depsgraph, cam); + return rna_pointer_inherit_refine(ptr, &RNA_Object, cam_eval); } else { return rna_pointer_inherit_refine(ptr, &RNA_Object, engine->camera_override); @@ -482,17 +487,18 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_function_ui_description(func, "Export scene data for render"); RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); RNA_def_pointer(func, "data", "BlendData", "", ""); - RNA_def_pointer(func, "scene", "Scene", "", ""); + RNA_def_pointer(func, "depsgraph", "Depsgraph", "", ""); func = RNA_def_function(srna, "render", NULL); RNA_def_function_ui_description(func, "Render scene into an image"); RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); - RNA_def_pointer(func, "scene", "Scene", "", ""); + parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); func = RNA_def_function(srna, "bake", NULL); RNA_def_function_ui_description(func, "Bake passes"); RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); - parm = RNA_def_pointer(func, "scene", "Scene", "", ""); + parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_pointer(func, "object", "Object", "", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -530,6 +536,12 @@ static void rna_def_render_engine(BlenderRNA *brna) parm = RNA_def_pointer(func, "node", "Node", "", ""); RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); + func = RNA_def_function(srna, "update_render_passes", NULL); + RNA_def_function_ui_description(func, "Update the render passes that will be generated"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + parm = RNA_def_pointer(func, "scene", "Scene", "", ""); + parm = RNA_def_pointer(func, "renderlayer", "ViewLayer", "", ""); + /* tag for redraw */ func = RNA_def_function(srna, "tag_redraw", "engine_tag_redraw"); RNA_def_function_ui_description(func, "Request redraw for viewport rendering"); @@ -538,12 +550,6 @@ static void rna_def_render_engine(BlenderRNA *brna) func = RNA_def_function(srna, "tag_update", "engine_tag_update"); RNA_def_function_ui_description(func, "Request update call for viewport rendering"); - func = RNA_def_function(srna, "update_render_passes", NULL); - RNA_def_function_ui_description(func, "Update the render passes that will be generated"); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); - parm = RNA_def_pointer(func, "scene", "Scene", "", ""); - parm = RNA_def_pointer(func, "renderlayer", "SceneRenderLayer", "", ""); - func = RNA_def_function(srna, "begin_result", "RE_engine_begin_result"); RNA_def_function_ui_description(func, "Create render result to write linear floating point render layers and passes"); parm = RNA_def_int(func, "x", 0, 0, INT_MAX, "X", "", 0, INT_MAX); @@ -719,17 +725,17 @@ static void rna_def_render_engine(BlenderRNA *brna) func = RNA_def_function(srna, "register_pass", "RE_engine_register_pass"); RNA_def_function_ui_description(func, "Register a render pass that will be part of the render with the current settings"); - prop = RNA_def_pointer(func, "scene", "Scene", "", ""); + parm = RNA_def_pointer(func, "scene", "Scene", "", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - prop = RNA_def_pointer(func, "srl", "SceneRenderLayer", "", ""); + parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - prop = RNA_def_string(func, "name", NULL, MAX_NAME, "Name", ""); + parm = RNA_def_string(func, "name", NULL, MAX_NAME, "Name", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - prop = RNA_def_int(func, "channels", 1, 1, 8, "Channels", "", 1, 4); + parm = RNA_def_int(func, "channels", 1, 1, 8, "Channels", "", 1, 4); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - prop = RNA_def_string(func, "chanid", NULL, 8, "Channel IDs", ""); + parm = RNA_def_string(func, "chanid", NULL, 8, "Channel IDs", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - prop = RNA_def_enum(func, "type", render_pass_type_items, SOCK_FLOAT, "Type", ""); + parm = RNA_def_enum(func, "type", render_pass_type_items, SOCK_FLOAT, "Type", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); /* registration */ @@ -902,7 +908,7 @@ static void rna_def_render_layer(BlenderRNA *brna) RNA_define_verify_sdna(0); - rna_def_render_layer_common(srna, 0); + rna_def_view_layer_common(srna, 0); prop = RNA_def_property(srna, "passes", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "RenderPass"); diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c index 5b86ec6b10d..4a36e2d00b7 100644 --- a/source/blender/makesrna/intern/rna_rigidbody.c +++ b/source/blender/makesrna/intern/rna_rigidbody.c @@ -33,7 +33,7 @@ #include "rna_internal.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_object_types.h" #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" @@ -97,7 +97,6 @@ static const EnumPropertyItem rigidbody_mesh_source_items[] = { # include "RBI_api.h" #endif -#include "BKE_depsgraph.h" #include "BKE_rigidbody.h" #include "WM_api.h" @@ -131,8 +130,8 @@ static void rna_RigidBodyWorld_num_solver_iterations_set(PointerRNA *ptr, int va rbw->num_solver_iterations = value; #ifdef WITH_BULLET - if (rbw->physics_world) { - RB_dworld_set_solver_iterations(rbw->physics_world, value); + if (rbw->shared->physics_world) { + RB_dworld_set_solver_iterations(rbw->shared->physics_world, value); } #endif } @@ -144,8 +143,8 @@ static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, bool value) RB_FLAG_SET(rbw->flag, value, RBW_FLAG_USE_SPLIT_IMPULSE); #ifdef WITH_BULLET - if (rbw->physics_world) { - RB_dworld_set_split_impulse(rbw->physics_world, value); + if (rbw->shared->physics_world) { + RB_dworld_set_split_impulse(rbw->shared->physics_world, value); } #endif } @@ -174,7 +173,7 @@ static void rna_RigidBodyOb_shape_reset(Main *UNUSED(bmain), Scene *scene, Point RigidBodyOb *rbo = (RigidBodyOb *)ptr->data; BKE_rigidbody_cache_reset(rbw); - if (rbo->physics_shape) + if (rbo->shared->physics_shape) rbo->flag |= RBO_FLAG_NEEDS_RESHAPE; } @@ -208,9 +207,9 @@ static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, bool value) #ifdef WITH_BULLET /* update kinematic state if necessary - only needed for active bodies */ - if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { - RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo)); - RB_body_set_kinematic_state(rbo->physics_object, !value); + if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { + RB_body_set_mass(rbo->shared->physics_object, RBO_GET_MASS(rbo)); + RB_body_set_kinematic_state(rbo->shared->physics_object, !value); rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; } #endif @@ -224,8 +223,8 @@ static void rna_RigidBodyOb_mass_set(PointerRNA *ptr, float value) #ifdef WITH_BULLET /* only active bodies need mass update */ - if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { - RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo)); + if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { + RB_body_set_mass(rbo->shared->physics_object, RBO_GET_MASS(rbo)); } #endif } @@ -237,8 +236,8 @@ static void rna_RigidBodyOb_friction_set(PointerRNA *ptr, float value) rbo->friction = value; #ifdef WITH_BULLET - if (rbo->physics_object) { - RB_body_set_friction(rbo->physics_object, value); + if (rbo->shared->physics_object) { + RB_body_set_friction(rbo->shared->physics_object, value); } #endif } @@ -249,8 +248,8 @@ static void rna_RigidBodyOb_restitution_set(PointerRNA *ptr, float value) rbo->restitution = value; #ifdef WITH_BULLET - if (rbo->physics_object) { - RB_body_set_restitution(rbo->physics_object, value); + if (rbo->shared->physics_object) { + RB_body_set_restitution(rbo->shared->physics_object, value); } #endif } @@ -262,8 +261,8 @@ static void rna_RigidBodyOb_collision_margin_set(PointerRNA *ptr, float value) rbo->margin = value; #ifdef WITH_BULLET - if (rbo->physics_shape) { - RB_shape_set_margin(rbo->physics_shape, RBO_GET_MARGIN(rbo)); + if (rbo->shared->physics_shape) { + RB_shape_set_margin(rbo->shared->physics_shape, RBO_GET_MARGIN(rbo)); } #endif } @@ -290,9 +289,9 @@ static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, bool value) #ifdef WITH_BULLET /* update kinematic state if necessary */ - if (rbo->physics_object) { - RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo)); - RB_body_set_kinematic_state(rbo->physics_object, value); + if (rbo->shared->physics_object) { + RB_body_set_mass(rbo->shared->physics_object, RBO_GET_MASS(rbo)); + RB_body_set_kinematic_state(rbo->shared->physics_object, value); rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; } #endif @@ -306,8 +305,8 @@ static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, bool value) #ifdef WITH_BULLET /* update activation state if necessary - only active bodies can be deactivated */ - if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { - RB_body_set_activation_state(rbo->physics_object, value); + if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { + RB_body_set_activation_state(rbo->shared->physics_object, value); } #endif } @@ -320,8 +319,8 @@ static void rna_RigidBodyOb_linear_sleepThresh_set(PointerRNA *ptr, float value) #ifdef WITH_BULLET /* only active bodies need sleep threshold update */ - if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { - RB_body_set_linear_sleep_thresh(rbo->physics_object, value); + if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { + RB_body_set_linear_sleep_thresh(rbo->shared->physics_object, value); } #endif } @@ -334,8 +333,8 @@ static void rna_RigidBodyOb_angular_sleepThresh_set(PointerRNA *ptr, float value #ifdef WITH_BULLET /* only active bodies need sleep threshold update */ - if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { - RB_body_set_angular_sleep_thresh(rbo->physics_object, value); + if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { + RB_body_set_angular_sleep_thresh(rbo->shared->physics_object, value); } #endif } @@ -348,8 +347,8 @@ static void rna_RigidBodyOb_linear_damping_set(PointerRNA *ptr, float value) #ifdef WITH_BULLET /* only active bodies need damping update */ - if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { - RB_body_set_linear_damping(rbo->physics_object, value); + if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { + RB_body_set_linear_damping(rbo->shared->physics_object, value); } #endif } @@ -362,8 +361,8 @@ static void rna_RigidBodyOb_angular_damping_set(PointerRNA *ptr, float value) #ifdef WITH_BULLET /* only active bodies need damping update */ - if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { - RB_body_set_angular_damping(rbo->physics_object, value); + if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) { + RB_body_set_angular_damping(rbo->shared->physics_object, value); } #endif } @@ -729,8 +728,8 @@ static void rna_RigidBodyWorld_convex_sweep_test( #ifdef WITH_BULLET RigidBodyOb *rob = object->rigidbody_object; - if (rbw->physics_world != NULL && rob->physics_object != NULL) { - RB_world_convex_sweep_test(rbw->physics_world, rob->physics_object, ray_start, ray_end, + if (rbw->shared->physics_world != NULL && rob->shared->physics_object != NULL) { + RB_world_convex_sweep_test(rbw->shared->physics_world, rob->shared->physics_object, ray_start, ray_end, r_location, r_hitpoint, r_normal, r_hit); if (*r_hit == -2) { BKE_report(reports, RPT_ERROR, @@ -746,6 +745,13 @@ static void rna_RigidBodyWorld_convex_sweep_test( #endif } +static PointerRNA rna_RigidBodyWorld_PointCache_get(PointerRNA *ptr) +{ + RigidBodyWorld *rbw = ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_PointCache, rbw->shared->pointcache); +} + + #else static void rna_def_rigidbody_world(BlenderRNA *brna) @@ -763,15 +769,15 @@ static void rna_def_rigidbody_world(BlenderRNA *brna) /* groups */ prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Group"); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); - RNA_def_property_ui_text(prop, "Group", "Group containing objects participating in this simulation"); + RNA_def_property_ui_text(prop, "Collection", "Collection containing objects participating in this simulation"); RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset"); prop = RNA_def_property(srna, "constraints", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Group"); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); - RNA_def_property_ui_text(prop, "Constraints", "Group containing rigid body constraint objects"); + RNA_def_property_ui_text(prop, "Constraints", "Collection containing rigid body constraint objects"); RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset"); /* booleans */ @@ -824,7 +830,7 @@ static void rna_def_rigidbody_world(BlenderRNA *brna) /* cache */ prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "pointcache"); + RNA_def_property_pointer_funcs(prop, "rna_RigidBodyWorld_PointCache_get", NULL, NULL, NULL); RNA_def_property_struct_type(prop, "PointCache"); RNA_def_property_ui_text(prop, "Point Cache", ""); @@ -1022,7 +1028,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "col_groups", 1); RNA_def_property_array(prop, 20); RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_collision_groups_set"); - RNA_def_property_ui_text(prop, "Collision Groups", "Collision Groups Rigid Body belongs to"); + RNA_def_property_ui_text(prop, "Collision Collections", "Collision collections rigid body belongs to"); RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); } diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index b8a9e9f92cd..cb2ef85d713 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -131,6 +131,9 @@ const EnumPropertyItem rna_enum_property_unit_items[] = { #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" #include "BLI_ghash.h" +#include "BLI_string.h" + +#include "BKE_library_override.h" /* Struct */ @@ -589,6 +592,13 @@ static bool rna_Property_animatable_get(PointerRNA *ptr) return (prop->flag & PROP_ANIMATABLE) != 0; } +static bool rna_Property_overridable_get(PointerRNA *ptr) +{ + PropertyRNA *prop = (PropertyRNA *)ptr->data; + + return (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_STATIC) != 0; +} + static bool rna_Property_use_output_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; @@ -1107,6 +1117,1131 @@ static int rna_BlenderRNA_structs_lookup_string(PointerRNA *ptr, const char *key return false; } +/* Default override (and compare) callbacks. */ + +/* Ensures it makes sense to go inside the pointers to compare their content + * (if they are IDs, or have different names or RNA type, then this would be meaningless). */ +static bool rna_property_override_diff_propptr_validate_diffing( + PointerRNA *propptr_a, PointerRNA *propptr_b, const bool no_prop_name, + bool *r_is_id, bool *r_is_null, bool *r_is_type_diff, + char **r_propname_a, char *propname_a_buff, size_t propname_a_buff_size, + char **r_propname_b, char *propname_b_buff, size_t propname_b_buff_size) +{ + BLI_assert(propptr_a != NULL); + + bool is_valid_for_diffing = true; + const bool do_force_name = !no_prop_name && r_propname_a != NULL; + + if (do_force_name) { + BLI_assert(r_propname_a != NULL); + BLI_assert(r_propname_b != NULL); + } + + *r_is_id = *r_is_null = *r_is_type_diff = false; + + /* Beware, PointerRNA_NULL has no type and is considered a 'blank page'! */ + if (propptr_a->type == NULL) { + if (propptr_b == NULL || propptr_b->type == NULL) { + *r_is_null = true; + } + else { + *r_is_id = RNA_struct_is_ID(propptr_b->type); + *r_is_null = true; + *r_is_type_diff = true; + } + is_valid_for_diffing = false; + } + else { + *r_is_id = RNA_struct_is_ID(propptr_a->type); + *r_is_null = *r_is_type_diff = (ELEM(NULL, propptr_b, propptr_b->type)); + is_valid_for_diffing = !(*r_is_id || *r_is_null); + } + + if (propptr_b == NULL || propptr_a->type != propptr_b->type) { + *r_is_type_diff = true; + is_valid_for_diffing = false; +// printf("%s: different pointer RNA types\n", rna_path ? rna_path : "<UNKNOWN>"); + } + + /* We do a generic quick first comparison checking for "name" and/or "type" properties. + * We assume that is any of those are false, then we are not handling the same data. + * This helps a lot in static override case, especially to detect inserted items in collections. */ + if (!no_prop_name && (is_valid_for_diffing || do_force_name)) { + PropertyRNA *nameprop_a = RNA_struct_name_property(propptr_a->type); + PropertyRNA *nameprop_b = (propptr_b != NULL) ? RNA_struct_name_property(propptr_b->type) : NULL; + + int propname_a_len = 0, propname_b_len = 0; + char *propname_a = NULL; + char *propname_b = NULL; + char buff_a[4096]; + char buff_b[4096]; + if (nameprop_a != NULL) { + if (r_propname_a == NULL && propname_a_buff == NULL) { + propname_a_buff = buff_a; + propname_a_buff_size = sizeof(buff_a); + } + + propname_a = RNA_property_string_get_alloc( + propptr_a, nameprop_a, propname_a_buff, propname_a_buff_size, &propname_a_len); +// printf("propname_a = %s\n", propname_a ? propname_a : "<NONE>"); + + if (r_propname_a != NULL) { + *r_propname_a = propname_a; + } + } +// else printf("item of type %s a has no name property!\n", propptr_a->type->name); + if (nameprop_b != NULL) { + if (r_propname_b == NULL && propname_b_buff == NULL) { + propname_b_buff = buff_b; + propname_b_buff_size = sizeof(buff_b); + } + + propname_b = RNA_property_string_get_alloc( + propptr_b, nameprop_b, propname_b_buff, propname_b_buff_size, &propname_b_len); + + if (r_propname_b != NULL) { + *r_propname_b = propname_b; + } + } + if (propname_a != NULL && propname_b != NULL) { + if (propname_a_len != propname_b_len || + propname_a[0] != propname_b[0] || + !STREQ(propname_a, propname_b)) + { + is_valid_for_diffing = false; +// printf("%s: different names\n", rna_path ? rna_path : "<UNKNOWN>"); + } + } + } + + if (*r_is_id) { + BLI_assert(propptr_a->data == propptr_a->id.data && propptr_b->data == propptr_b->id.data); + } + + return is_valid_for_diffing; +} + +/* Used for both Pointer and Collection properties. */ +static int rna_property_override_diff_propptr( + Main *bmain, + PointerRNA *propptr_a, PointerRNA *propptr_b, + eRNACompareMode mode, const bool no_ownership, const bool no_prop_name, + IDOverrideStatic *override, const char *rna_path, const int flags, bool *r_override_changed) +{ + const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 && rna_path != NULL; + + bool is_id = false; + bool is_null = false; + bool is_type_diff = false; + /* If false, it means that the whole data itself is different, so no point in going inside of it at all! */ + bool is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing( + propptr_a, propptr_b, no_prop_name, &is_id, &is_null, &is_type_diff, + NULL, NULL, 0, NULL, NULL, 0); + + if (is_id) { + BLI_assert(no_ownership); /* For now, once we deal with nodetrees we'll want to get rid of that one. */ + } + + if (override) { + if (no_ownership /* || is_id */ || is_null || is_type_diff || !is_valid_for_diffing) { + /* In case this pointer prop does not own its data (or one is NULL), do not compare structs! + * This is a quite safe path to infinite loop, among other nasty issues. + * Instead, just compare pointers themselves. */ + const int comp = (propptr_a->data != propptr_b->data); + + if (do_create && comp != 0) { + bool created = false; + IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created); + + if (op != NULL && created) { /* If not yet overridden... */ + BKE_override_static_property_operation_get( + op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + if (r_override_changed) { + *r_override_changed = created; + } + } + } + + return comp; + } + else { + eRNAOverrideMatchResult report_flags = 0; + const bool match = RNA_struct_override_matches( + bmain, propptr_a, propptr_b, rna_path, override, flags, &report_flags); + if (r_override_changed && (report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) != 0) { + *r_override_changed = true; + } + return !match; + } + } + else { + /* We could also use is_diff_pointer, but then we potentially lose the gt/lt info - + * and don't think performances are critical here for now anyway... */ + return !RNA_struct_equals(bmain, propptr_a, propptr_b, mode); + } +} + + + +#define RNA_PROPERTY_GET_SINGLE(_typename, _ptr, _prop, _index) \ + (is_array ? RNA_property_##_typename##_get_index((_ptr), (_prop), (_index)) : \ + RNA_property_##_typename##_get((_ptr), (_prop))) +#define RNA_PROPERTY_SET_SINGLE(_typename, _ptr, _prop, _index, _value) \ + (is_array ? RNA_property_##_typename##_set_index((_ptr), (_prop), (_index), (_value)) : \ + RNA_property_##_typename##_set((_ptr), (_prop), (_value))) + +int rna_property_override_diff_default( + Main *bmain, + PointerRNA *ptr_a, PointerRNA *ptr_b, + PropertyRNA *prop_a, PropertyRNA *prop_b, + const int len_a, const int len_b, + const int mode, + IDOverrideStatic *override, const char *rna_path, + const int flags, bool *r_override_changed) +{ + BLI_assert(len_a == len_b); + + /* Note: at this point, we are sure that when len_a is zero, we are not handling an (empty) array. */ + + const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 && rna_path != NULL; + + switch (RNA_property_type(prop_a)) { + case PROP_BOOLEAN: + { + if (len_a) { + bool array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY]; + bool *array_a, *array_b; + + array_a = (len_a > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(bool) * len_a, "RNA equals") : array_stack_a; + array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(bool) * len_b, "RNA equals") : array_stack_b; + + RNA_property_boolean_get_array(ptr_a, prop_a, array_a); + RNA_property_boolean_get_array(ptr_b, prop_b, array_b); + + const int comp = memcmp(array_a, array_b, sizeof(bool) * len_a); + + if (do_create && comp != 0) { + /* XXX TODO this will have to be refined to handle array items */ + bool created = false; + IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created); + + if (op != NULL && created) { + BKE_override_static_property_operation_get( + op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + if (r_override_changed) { + *r_override_changed = created; + } + } + else { + /* Already overridden prop, we'll have to check arrays items etc. */ + } + } + + if (array_a != array_stack_a) MEM_freeN(array_a); + if (array_b != array_stack_b) MEM_freeN(array_b); + + return comp; + } + else { + const bool value_a = RNA_property_boolean_get(ptr_a, prop_a); + const bool value_b = RNA_property_boolean_get(ptr_b, prop_b); + const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0; + + if (do_create && comp != 0) { + bool created = false; + IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created); + + if (op != NULL && created) { /* If not yet overridden... */ + BKE_override_static_property_operation_get( + op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + if (r_override_changed) { + *r_override_changed = created; + } + } + } + + return comp; + } + } + + case PROP_INT: + { + if (len_a) { + int array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY]; + int *array_a, *array_b; + + array_a = (len_a > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(int) * len_a, "RNA equals") : array_stack_a; + array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(int) * len_b, "RNA equals") : array_stack_b; + + RNA_property_int_get_array(ptr_a, prop_a, array_a); + RNA_property_int_get_array(ptr_b, prop_b, array_b); + + const int comp = memcmp(array_a, array_b, sizeof(int) * len_a); + + if (do_create && comp != 0) { + /* XXX TODO this will have to be refined to handle array items */ + bool created = false; + IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created); + + if (op != NULL && created) { + BKE_override_static_property_operation_get( + op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + if (r_override_changed) { + *r_override_changed = created; + } + } + else { + /* Already overridden prop, we'll have to check arrays items etc. */ + } + } + + if (array_a != array_stack_a) MEM_freeN(array_a); + if (array_b != array_stack_b) MEM_freeN(array_b); + + return comp; + } + else { + const int value_a = RNA_property_int_get(ptr_a, prop_a); + const int value_b = RNA_property_int_get(ptr_b, prop_b); + const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0; + + if (do_create && comp != 0) { + bool created = false; + IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created); + + if (op != NULL && created) { /* If not yet overridden... */ + BKE_override_static_property_operation_get( + op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + if (r_override_changed) { + *r_override_changed = created; + } + } + } + + return comp; + } + } + + case PROP_FLOAT: + { + if (len_a) { + float array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY]; + float *array_a, *array_b; + + array_a = (len_a > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(float) * len_a, "RNA equals") : array_stack_a; + array_b = (len_b > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(float) * len_b, "RNA equals") : array_stack_b; + + RNA_property_float_get_array(ptr_a, prop_a, array_a); + RNA_property_float_get_array(ptr_b, prop_b, array_b); + + const int comp = memcmp(array_a, array_b, sizeof(float) * len_a); + + if (do_create && comp != 0) { + /* XXX TODO this will have to be refined to handle array items */ + bool created = false; + IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created); + + if (op != NULL && created) { + BKE_override_static_property_operation_get( + op, IDOVERRIDESTATIC_OP_REPLACE, + NULL, NULL, -1, -1, true, NULL, NULL); + if (r_override_changed) { + *r_override_changed = created; + } + } + else { + /* Already overridden prop, we'll have to check arrays items etc. */ + } + } + + if (array_a != array_stack_a) MEM_freeN(array_a); + if (array_b != array_stack_b) MEM_freeN(array_b); + + return comp; + } + else { + const float value_a = RNA_property_float_get(ptr_a, prop_a); + const float value_b = RNA_property_float_get(ptr_b, prop_b); + const int comp = (value_a < value_b) ? -1 : (value_a > value_b) ? 1 : 0; + + if (do_create && comp != 0) { + bool created = false; + IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created); + + if (op != NULL && created) { /* If not yet overridden... */ + BKE_override_static_property_operation_get( + op, IDOVERRIDESTATIC_OP_REPLACE, + NULL, NULL, -1, -1, true, NULL, NULL); + if (r_override_changed) { + *r_override_changed = created; + } + } + } + + return comp ; + } + } + + case PROP_ENUM: + { + const int value_a = RNA_property_enum_get(ptr_a, prop_a); + const int value_b = RNA_property_enum_get(ptr_b, prop_b); + const int comp = value_a != value_b; + + if (do_create && comp != 0) { + bool created = false; + IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created); + + if (op != NULL && created) { /* If not yet overridden... */ + BKE_override_static_property_operation_get( + op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + if (r_override_changed) { + *r_override_changed = created; + } + } + } + + return comp; + } + + case PROP_STRING: + { + char fixed_a[4096], fixed_b[4096]; + int len_str_a, len_str_b; + char *value_a = RNA_property_string_get_alloc(ptr_a, prop_a, fixed_a, sizeof(fixed_a), &len_str_a); + char *value_b = RNA_property_string_get_alloc(ptr_b, prop_b, fixed_b, sizeof(fixed_b), &len_str_b); + /* TODO we could do a check on length too, but then we would not have a 'real' string comparison... + * Maybe behind a eRNAOverrideMatch flag? */ +// const int comp = len_str_a < len_str_b ? -1 : len_str_a > len_str_b ? 1 : strcmp(value_a, value_b); + const int comp = strcmp(value_a, value_b); + + if (do_create && comp != 0) { + bool created = false; + IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created); + + if (op != NULL && created) { /* If not yet overridden... */ + BKE_override_static_property_operation_get( + op, IDOVERRIDESTATIC_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + if (r_override_changed) { + *r_override_changed = created; + } + } + } + + if (value_a != fixed_a) MEM_freeN(value_a); + if (value_b != fixed_b) MEM_freeN(value_b); + + return comp; + } + + case PROP_POINTER: + { + if (STREQ(RNA_property_identifier(prop_a), "rna_type")) { + /* Dummy 'pass' answer, this is a meta-data and must be ignored... */ + return 0; + } + else { + PointerRNA propptr_a = RNA_property_pointer_get(ptr_a, prop_a); + PointerRNA propptr_b = RNA_property_pointer_get(ptr_b, prop_b); + const bool no_ownership = (RNA_property_flag(prop_a) & PROP_PTR_NO_OWNERSHIP) != 0; + const bool no_prop_name = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_NO_PROP_NAME) != 0; + return rna_property_override_diff_propptr( + bmain, + &propptr_a, &propptr_b, mode, no_ownership, no_prop_name, + override, rna_path, flags, r_override_changed); + } + break; + } + + case PROP_COLLECTION: + { + /* Note: we assume we only insert in ptr_a (i.e. we can only get new items in ptr_a), + * and that we never remove anything. */ + const bool use_insertion = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_STATIC_INSERTION) && do_create; + const bool no_prop_name = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_NO_PROP_NAME) != 0; + bool equals = true; + bool abort = false; + bool is_first_insert = true; + int idx_a = 0; + int idx_b = 0; + +#define RNA_PATH_BUFFSIZE 8192 + + char extended_rna_path_buffer[RNA_PATH_BUFFSIZE]; + char *extended_rna_path = extended_rna_path_buffer; + +#define RNA_PATH_PRINTF(_str, ...) \ + if (BLI_snprintf(extended_rna_path_buffer, RNA_PATH_BUFFSIZE, \ + (_str), __VA_ARGS__) >= RNA_PATH_BUFFSIZE - 1) \ + { extended_rna_path = BLI_sprintfN((_str), __VA_ARGS__); }(void)0 +#define RNA_PATH_FREE() \ + if (extended_rna_path != extended_rna_path_buffer) MEM_freeN(extended_rna_path) + + CollectionPropertyIterator iter_a, iter_b; + RNA_property_collection_begin(ptr_a, prop_a, &iter_a); + RNA_property_collection_begin(ptr_b, prop_b, &iter_b); + + char buff_a[4096]; + char buff_prev_a[4096] = {0}; + char buff_b[4096]; + char *propname_a = NULL; + char *prev_propname_a = buff_prev_a; + char *propname_b = NULL; + + for (; iter_a.valid && !abort; ) { + bool is_valid_for_diffing; + bool is_valid_for_insertion; + do { + bool is_id = false, is_null = false, is_type_diff = false; + + is_valid_for_insertion = use_insertion; + + /* If false, it means that the whole data itself is different, so no point in going inside of it at all! */ + if (iter_b.valid) { + is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing( + &iter_a.ptr, &iter_b.ptr, no_prop_name, + &is_id, &is_null, &is_type_diff, + &propname_a, buff_a, sizeof(buff_a), + &propname_b, buff_b, sizeof(buff_b)); + } + else { + is_valid_for_diffing = false; + if (is_valid_for_insertion) { + /* We still need propname from 'a' item... */ + rna_property_override_diff_propptr_validate_diffing( + &iter_a.ptr, NULL, no_prop_name, + &is_id, &is_null, &is_type_diff, + &propname_a, buff_a, sizeof(buff_a), + &propname_b, buff_b, sizeof(buff_b)); + } + } + + /* We do not support insertion of IDs for now, neither handle NULL pointers. */ + if (is_id || is_valid_for_diffing) { + is_valid_for_insertion = false; + } + +#if 0 + if (rna_path) { + printf("Checking %s, %s [%d] vs %s [%d]; is_id: %d, diffing: %d; " + "insert: %d (could be used: %d, do_create: %d)\n", + rna_path, propname_a ? propname_a : "", idx_a, propname_b ? propname_b : "", idx_b, + is_id, is_valid_for_diffing, is_valid_for_insertion, + (RNA_property_override_flag(prop_a) & PROPOVERRIDE_STATIC_INSERTION) != 0, do_create); + } +#endif + + if (!(is_id || is_valid_for_diffing || is_valid_for_insertion)) { + /* Differences we cannot handle, we can break here + * (we do not support replacing ID pointers in collections e.g.). */ + equals = false; + abort = true; + break; + } + + /* There may be a propname defined in some cases, while no actual name set + * (e.g. happens with point cache), in that case too we want to fall back to index. + * Note that we do not need the RNA path for insertion operations. */ + if (is_id || is_valid_for_diffing) { + if ((propname_a != NULL && propname_a[0] != '\0') && + (propname_b != NULL && propname_b[0] != '\0')) + { + if (rna_path) { + /* In case of name, either it is valid for diffing, and _a and _b are identical, + * or it is valid for insertion, and we need to use _a. */ + char esc_item_name[RNA_PATH_BUFFSIZE]; + BLI_strescape(esc_item_name, propname_a, RNA_PATH_BUFFSIZE); + RNA_PATH_PRINTF("%s[\"%s\"]", rna_path, esc_item_name); + } + } + else { /* Based on index... */ + if (rna_path) { + /* In case of indices, we need _a one for insertion, but _b ones for in-depth diffing. + * Insertion always happen once all 'replace' operations have been done, + * otherwise local and reference paths for those would have to be different! */ + RNA_PATH_PRINTF("%s[%d]", rna_path, is_valid_for_insertion ? idx_a : idx_b); + } + } + } + + /* Collections do not support replacement of their data (since they do not support removing), + * only in *some* cases, insertion. + * We also assume then that _a data is the one where things are inserted. */ + if (is_valid_for_insertion && use_insertion) { + bool created; + IDOverrideStaticProperty *op = BKE_override_static_property_get(override, rna_path, &created); + + if (is_first_insert) { + /* We need to clean up all possible existing insertion operations, otherwise we'd end up + * with a mess of ops everytime something changes. */ + for (IDOverrideStaticPropertyOperation *opop = op->operations.first; + opop != NULL;) + { + IDOverrideStaticPropertyOperation *opop_next = opop->next; + if (ELEM(opop->operation, + IDOVERRIDESTATIC_OP_INSERT_AFTER, IDOVERRIDESTATIC_OP_INSERT_BEFORE)) + { + BKE_override_static_property_operation_delete(op, opop); + } + opop = opop_next; + } + is_first_insert = false; + } + + BKE_override_static_property_operation_get( + op, IDOVERRIDESTATIC_OP_INSERT_AFTER, + NULL, prev_propname_a, -1, idx_a - 1, true, NULL, NULL); +// printf("%s: Adding insertion op override after '%s'/%d\n", rna_path, prev_propname_a, idx_a - 1); + } + else if (is_id || is_valid_for_diffing) { + if (equals || do_create) { + const bool no_ownership = (RNA_property_flag(prop_a) & PROP_PTR_NO_OWNERSHIP) != 0; + const int eq = rna_property_override_diff_propptr( + bmain, + &iter_a.ptr, &iter_b.ptr, mode, no_ownership, no_prop_name, + override, extended_rna_path, flags, r_override_changed); + equals = equals && eq; + } + } + + if (prev_propname_a != buff_prev_a) { + MEM_freeN(prev_propname_a); + prev_propname_a = buff_prev_a; + } + prev_propname_a[0] = '\0'; + if (propname_a != NULL && + BLI_strncpy_rlen(prev_propname_a, propname_a, sizeof(buff_prev_a)) >= sizeof(buff_prev_a) - 1) + { + prev_propname_a = BLI_strdup(propname_a); + } + if (propname_a != buff_a) { + MEM_SAFE_FREE(propname_a); + propname_a = buff_a; + } + propname_a[0] = '\0'; + if (propname_b != buff_b) { + MEM_SAFE_FREE(propname_b); + propname_b = buff_b; + } + propname_b[0] = '\0'; + RNA_PATH_FREE(); + + if (!do_create && !equals) { + abort = true; /* Early out in case we do not want to loop over whole collection. */ + break; + } + + if (!(use_insertion && !(is_id || is_valid_for_diffing))) { + break; + } + + if (iter_a.valid) { + RNA_property_collection_next(&iter_a); + idx_a++; + } + } while (iter_a.valid); + + if (iter_a.valid) { + RNA_property_collection_next(&iter_a); + idx_a++; + } + if (iter_b.valid) { + RNA_property_collection_next(&iter_b); + idx_b++; + } + +#undef RNA_PATH_BUFFSIZE +#undef RNA_PATH_PRINTF +#undef RNA_PATH_FREE + } + + equals = equals && !(iter_a.valid || iter_b.valid) && !abort; /* Not same number of items in both collections... */ + RNA_property_collection_end(&iter_a); + RNA_property_collection_end(&iter_b); + + return (equals == false); + } + + default: + break; + } + + return 0; +} + +bool rna_property_override_store_default( + Main *UNUSED(bmain), + PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, + PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *prop_storage, + const int len_local, const int len_reference, const int len_storage, + IDOverrideStaticPropertyOperation *opop) +{ + BLI_assert(len_local == len_reference && (!ptr_storage || len_local == len_storage)); + UNUSED_VARS_NDEBUG(len_reference, len_storage); + + bool changed = false; + const bool is_array = len_local > 0; + const int index = is_array ? opop->subitem_reference_index : 0; + + if (!ELEM(opop->operation, IDOVERRIDESTATIC_OP_ADD, IDOVERRIDESTATIC_OP_SUBTRACT, IDOVERRIDESTATIC_OP_MULTIPLY)) { + return changed; + } + + /* XXX TODO About range limits. + * Ideally, it would be great to get rid of RNA range in that specific case. + * However, this won't be that easy and will add yet another layer of complexity in generated code, + * not to mention that we could most likely *not* bypass custom setters anyway. + * So for now, if needed second operand value is not in valid range, we simply fall back + * to a mere REPLACE operation. + * Time will say whether this is acceptable limitation or not. */ + switch (RNA_property_type(prop_local)) { + case PROP_BOOLEAN: + /* TODO support boolean ops? Really doubt this would ever be useful though... */ + BLI_assert(0 && "Boolean properties support no override diff operation"); + break; + case PROP_INT: + { + int prop_min, prop_max; + RNA_property_int_range(ptr_local, prop_local, &prop_min, &prop_max); + + if (is_array && index == -1) { + int array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY]; + int *array_a, *array_b; + + array_a = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_local, __func__) : array_stack_a; + RNA_property_int_get_array(ptr_reference, prop_reference, array_a); + + switch (opop->operation) { + case IDOVERRIDESTATIC_OP_ADD: + case IDOVERRIDESTATIC_OP_SUBTRACT: + { + const int fac = opop->operation == IDOVERRIDESTATIC_OP_ADD ? 1 : -1; + const int other_op = opop->operation == IDOVERRIDESTATIC_OP_ADD ? IDOVERRIDESTATIC_OP_SUBTRACT : IDOVERRIDESTATIC_OP_ADD; + bool do_set = true; + array_b = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_local, __func__) : array_stack_b; + RNA_property_int_get_array(ptr_local, prop_local, array_b); + for (int i = len_local; i--;) { + array_b[i] = fac * (array_b[i] - array_a[i]); + if (array_b[i] < prop_min || array_b[i] > prop_max) { + opop->operation = other_op; + for (int j = len_local; j--;) { + array_b[j] = j >= i ? -array_b[j] : fac * (array_a[j] - array_b[j]); + if (array_b[j] < prop_min || array_b[j] > prop_max) { + /* We failed to find a suitable diff op, + * fall back to plain REPLACE one. */ + opop->operation = IDOVERRIDESTATIC_OP_REPLACE; + do_set = false; + break; + } + } + break; + } + } + if (do_set) { + changed = true; + RNA_property_int_set_array(ptr_storage, prop_storage, array_b); + } + if (array_b != array_stack_b) MEM_freeN(array_b); + break; + } + default: + BLI_assert(0 && "Unsupported RNA override diff operation on integer"); + break; + } + + if (array_a != array_stack_a) MEM_freeN(array_a); + } + else { + const int value = RNA_PROPERTY_GET_SINGLE(int, ptr_reference, prop_reference, index); + + switch (opop->operation) { + case IDOVERRIDESTATIC_OP_ADD: + case IDOVERRIDESTATIC_OP_SUBTRACT: + { + const int fac = opop->operation == IDOVERRIDESTATIC_OP_ADD ? 1 : -1; + const int other_op = opop->operation == IDOVERRIDESTATIC_OP_ADD ? IDOVERRIDESTATIC_OP_SUBTRACT : IDOVERRIDESTATIC_OP_ADD; + int b = fac * (RNA_PROPERTY_GET_SINGLE(int, ptr_local, prop_local, index) - value); + if (b < prop_min || b > prop_max) { + opop->operation = other_op; + b = -b; + if (b < prop_min || b > prop_max) { + opop->operation = IDOVERRIDESTATIC_OP_REPLACE; + break; + } + } + changed = true; + RNA_PROPERTY_SET_SINGLE(int, ptr_storage, prop_storage, index, b); + break; + } + default: + BLI_assert(0 && "Unsupported RNA override diff operation on integer"); + break; + } + } + break; + } + case PROP_FLOAT: + { + float prop_min, prop_max; + RNA_property_float_range(ptr_local, prop_local, &prop_min, &prop_max); + + if (is_array && index == -1) { + float array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY]; + float *array_a, *array_b; + + array_a = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_local, __func__) : array_stack_a; + + RNA_property_float_get_array(ptr_reference, prop_reference, array_a); + switch (opop->operation) { + case IDOVERRIDESTATIC_OP_ADD: + case IDOVERRIDESTATIC_OP_SUBTRACT: + { + const float fac = opop->operation == IDOVERRIDESTATIC_OP_ADD ? 1.0 : -1.0; + const int other_op = opop->operation == IDOVERRIDESTATIC_OP_ADD ? IDOVERRIDESTATIC_OP_SUBTRACT : IDOVERRIDESTATIC_OP_ADD; + bool do_set = true; + array_b = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_local, __func__) : array_stack_b; + RNA_property_float_get_array(ptr_local, prop_local, array_b); + for (int i = len_local; i--;) { + array_b[i] = fac * (array_b[i] - array_a[i]); + if (array_b[i] < prop_min || array_b[i] > prop_max) { + opop->operation = other_op; + for (int j = len_local; j--;) { + array_b[j] = j >= i ? -array_b[j] : fac * (array_a[j] - array_b[j]); + if (array_b[j] < prop_min || array_b[j] > prop_max) { + /* We failed to find a suitable diff op, + * fall back to plain REPLACE one. */ + opop->operation = IDOVERRIDESTATIC_OP_REPLACE; + do_set = false; + break; + } + } + break; + } + } + if (do_set) { + changed = true; + RNA_property_float_set_array(ptr_storage, prop_storage, array_b); + } + if (array_b != array_stack_b) MEM_freeN(array_b); + break; + } + case IDOVERRIDESTATIC_OP_MULTIPLY: + { + bool do_set = true; + array_b = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_local, __func__) : array_stack_b; + RNA_property_float_get_array(ptr_local, prop_local, array_b); + for (int i = len_local; i--;) { + array_b[i] = array_a[i] == 0.0f ? array_b[i] : array_b[i] / array_a[i]; + if (array_b[i] < prop_min || array_b[i] > prop_max) { + opop->operation = IDOVERRIDESTATIC_OP_REPLACE; + do_set = false; + break; + } + } + if (do_set) { + changed = true; + RNA_property_float_set_array(ptr_storage, prop_storage, array_b); + } + if (array_b != array_stack_b) MEM_freeN(array_b); + break; + } + default: + BLI_assert(0 && "Unsupported RNA override diff operation on float"); + break; + } + + if (array_a != array_stack_a) MEM_freeN(array_a); + } + else { + const float value = RNA_PROPERTY_GET_SINGLE(float, ptr_reference, prop_reference, index); + + switch (opop->operation) { + case IDOVERRIDESTATIC_OP_ADD: + case IDOVERRIDESTATIC_OP_SUBTRACT: + { + const float fac = opop->operation == IDOVERRIDESTATIC_OP_ADD ? 1.0f : -1.0f; + const int other_op = opop->operation == IDOVERRIDESTATIC_OP_ADD ? IDOVERRIDESTATIC_OP_SUBTRACT : IDOVERRIDESTATIC_OP_ADD; + float b = fac * (RNA_PROPERTY_GET_SINGLE(float, ptr_local, prop_local, index) - value); + if (b < prop_min || b > prop_max) { + opop->operation = other_op; + b = -b; + if (b < prop_min || b > prop_max) { + opop->operation = IDOVERRIDESTATIC_OP_REPLACE; + break; + } + } + changed = true; + RNA_PROPERTY_SET_SINGLE(float, ptr_storage, prop_storage, index, b); + break; + } + case IDOVERRIDESTATIC_OP_MULTIPLY: + { + const float b = RNA_property_float_get_index(ptr_local, prop_local, index) / (value == 0.0f ? 1.0f : value); + if (b < prop_min || b > prop_max) { + opop->operation = IDOVERRIDESTATIC_OP_REPLACE; + break; + } + changed = true; + RNA_property_float_set_index(ptr_storage, prop_storage, index, b); + break; + } + default: + BLI_assert(0 && "Unsupported RNA override diff operation on float"); + break; + } + } + return true; + } + case PROP_ENUM: + /* TODO support add/sub, for bitflags? */ + BLI_assert(0 && "Enum properties support no override diff operation"); + break; + case PROP_POINTER: + BLI_assert(0 && "Pointer properties support no override diff operation"); + break; + case PROP_STRING: + BLI_assert(0 && "String properties support no override diff operation"); + break; + case PROP_COLLECTION: + /* XXX TODO support this of course... */ + BLI_assert(0 && "Collection properties support no override diff operation"); + break; + default: + break; + } + + return changed; +} + +bool rna_property_override_apply_default( + Main *UNUSED(bmain), + PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, + PropertyRNA *prop_dst, PropertyRNA *prop_src, PropertyRNA *prop_storage, + const int len_dst, const int len_src, const int len_storage, + PointerRNA *UNUSED(ptr_item_dst), PointerRNA *UNUSED(ptr_item_src), PointerRNA *UNUSED(ptr_item_storage), + IDOverrideStaticPropertyOperation *opop) +{ + BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage)); + UNUSED_VARS_NDEBUG(len_src, len_storage); + + const bool is_array = len_dst > 0; + const int index = is_array ? opop->subitem_reference_index : 0; + const short override_op = opop->operation; + + switch (RNA_property_type(prop_dst)) { + case PROP_BOOLEAN: + if (is_array && index == -1) { + bool array_stack_a[RNA_STACK_ARRAY]; + bool *array_a; + + array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) : array_stack_a; + + RNA_property_boolean_get_array(ptr_src, prop_src, array_a); + + switch (override_op) { + case IDOVERRIDESTATIC_OP_REPLACE: + RNA_property_boolean_set_array(ptr_dst, prop_dst, array_a); + break; + default: + BLI_assert(0 && "Unsupported RNA override operation on boolean"); + return false; + } + + if (array_a != array_stack_a) MEM_freeN(array_a); + } + else { + const bool value = RNA_PROPERTY_GET_SINGLE(boolean, ptr_src, prop_src, index); + + switch (override_op) { + case IDOVERRIDESTATIC_OP_REPLACE: + RNA_PROPERTY_SET_SINGLE(boolean, ptr_dst, prop_dst, index, value); + break; + default: + BLI_assert(0 && "Unsupported RNA override operation on boolean"); + return false; + } + } + return true; + case PROP_INT: + if (is_array && index == -1) { + int array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY]; + int *array_a, *array_b; + + array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) : array_stack_a; + + switch (override_op) { + case IDOVERRIDESTATIC_OP_REPLACE: + RNA_property_int_get_array(ptr_src, prop_src, array_a); + RNA_property_int_set_array(ptr_dst, prop_dst, array_a); + break; + case IDOVERRIDESTATIC_OP_ADD: + case IDOVERRIDESTATIC_OP_SUBTRACT: + RNA_property_int_get_array(ptr_dst, prop_dst, array_a); + array_b = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_dst, __func__) : array_stack_b; + RNA_property_int_get_array(ptr_storage, prop_storage, array_b); + if (override_op == IDOVERRIDESTATIC_OP_ADD) { + for (int i = len_dst; i--;) array_a[i] += array_b[i]; + } + else { + for (int i = len_dst; i--;) array_a[i] -= array_b[i]; + } + RNA_property_int_set_array(ptr_dst, prop_dst, array_a); + if (array_b != array_stack_b) MEM_freeN(array_b); + break; + default: + BLI_assert(0 && "Unsupported RNA override operation on integer"); + return false; + } + + if (array_a != array_stack_a) MEM_freeN(array_a); + } + else { + const int storage_value = ptr_storage ? RNA_PROPERTY_GET_SINGLE(int, ptr_storage, prop_storage, index) : 0; + + switch (override_op) { + case IDOVERRIDESTATIC_OP_REPLACE: + RNA_PROPERTY_SET_SINGLE(int, ptr_dst, prop_dst, index, + RNA_PROPERTY_GET_SINGLE(int, ptr_src, prop_src, index)); + break; + case IDOVERRIDESTATIC_OP_ADD: + RNA_PROPERTY_SET_SINGLE(int, ptr_dst, prop_dst, index, + RNA_PROPERTY_GET_SINGLE(int, ptr_dst, prop_dst, index) - storage_value); + break; + case IDOVERRIDESTATIC_OP_SUBTRACT: + RNA_PROPERTY_SET_SINGLE(int, ptr_dst, prop_dst, index, + RNA_PROPERTY_GET_SINGLE(int, ptr_dst, prop_dst, index) - storage_value); + break; + default: + BLI_assert(0 && "Unsupported RNA override operation on integer"); + return false; + } + } + return true; + case PROP_FLOAT: + if (is_array && index == -1) { + float array_stack_a[RNA_STACK_ARRAY], array_stack_b[RNA_STACK_ARRAY]; + float *array_a, *array_b; + + array_a = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_a) * len_dst, __func__) : array_stack_a; + + switch (override_op) { + case IDOVERRIDESTATIC_OP_REPLACE: + RNA_property_float_get_array(ptr_src, prop_src, array_a); + RNA_property_float_set_array(ptr_dst, prop_dst, array_a); + break; + case IDOVERRIDESTATIC_OP_ADD: + case IDOVERRIDESTATIC_OP_SUBTRACT: + case IDOVERRIDESTATIC_OP_MULTIPLY: + RNA_property_float_get_array(ptr_dst, prop_dst, array_a); + array_b = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_dst, __func__) : array_stack_b; + RNA_property_float_get_array(ptr_storage, prop_storage, array_b); + if (override_op == IDOVERRIDESTATIC_OP_ADD) { + for (int i = len_dst; i--;) array_a[i] += array_b[i]; + } + else if (override_op == IDOVERRIDESTATIC_OP_SUBTRACT) { + for (int i = len_dst; i--;) array_a[i] -= array_b[i]; + } + else { + for (int i = len_dst; i--;) array_a[i] *= array_b[i]; + } + RNA_property_float_set_array(ptr_dst, prop_dst, array_a); + if (array_b != array_stack_b) MEM_freeN(array_b); + break; + default: + BLI_assert(0 && "Unsupported RNA override operation on float"); + return false; + } + + if (array_a != array_stack_a) MEM_freeN(array_a); + } + else { + const float storage_value = ptr_storage ? RNA_PROPERTY_GET_SINGLE(float, ptr_storage, prop_storage, index) : 0.0f; + + switch (override_op) { + case IDOVERRIDESTATIC_OP_REPLACE: + RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, index, + RNA_PROPERTY_GET_SINGLE(float, ptr_src, prop_src, index)); + break; + case IDOVERRIDESTATIC_OP_ADD: + RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, index, + RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) + storage_value); + break; + case IDOVERRIDESTATIC_OP_SUBTRACT: + RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, index, + RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) - storage_value); + break; + case IDOVERRIDESTATIC_OP_MULTIPLY: + RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, index, + RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) * storage_value); + break; + default: + BLI_assert(0 && "Unsupported RNA override operation on float"); + return false; + } + } + return true; + case PROP_ENUM: + { + const int value = RNA_property_enum_get(ptr_src, prop_src); + + switch (override_op) { + case IDOVERRIDESTATIC_OP_REPLACE: + RNA_property_enum_set(ptr_dst, prop_dst, value); + break; + /* TODO support add/sub, for bitflags? */ + default: + BLI_assert(0 && "Unsupported RNA override operation on enum"); + return false; + } + return true; + } + case PROP_POINTER: + { + PointerRNA value = RNA_property_pointer_get(ptr_src, prop_src); + + switch (override_op) { + case IDOVERRIDESTATIC_OP_REPLACE: + RNA_property_pointer_set(ptr_dst, prop_dst, value); + break; + default: + BLI_assert(0 && "Unsupported RNA override operation on pointer"); + return false; + } + return true; + } + case PROP_STRING: + { + char buff[256]; + char *value = RNA_property_string_get_alloc(ptr_src, prop_src, buff, sizeof(buff), NULL); + + switch (override_op) { + case IDOVERRIDESTATIC_OP_REPLACE: + RNA_property_string_set(ptr_dst, prop_dst, value); + break; + default: + BLI_assert(0 && "Unsupported RNA override operation on string"); + return false; + } + + if (value != buff) MEM_freeN(value); + return true; + } + case PROP_COLLECTION: + { + BLI_assert(!"You need to define a specific override apply callback for enums."); + return false; + } + default: + BLI_assert(0); + return false; + } + + return false; +} + +#undef RNA_PROPERTY_GET_SINGLE +#undef RNA_PROPERTY_SET_SINGLE + #else @@ -1284,6 +2419,11 @@ static void rna_def_property(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, "rna_Property_animatable_get", NULL); RNA_def_property_ui_text(prop, "Animatable", "Property is animatable through RNA"); + prop = RNA_def_property(srna, "is_overridable", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Property_overridable_get", NULL); + RNA_def_property_ui_text(prop, "Overridable", "Property is overridable through RNA"); + prop = RNA_def_property(srna, "is_required", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Property_is_required_get", NULL); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index d6c45fd69d0..24889d97898 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -27,15 +27,18 @@ #include <stdlib.h> #include "DNA_brush_types.h" -#include "DNA_group_types.h" +#include "DNA_collection_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" +#include "DNA_layer_types.h" #include "DNA_linestyle_types.h" #include "DNA_userdef_types.h" #include "DNA_world_types.h" #include "DNA_gpencil_types.h" +#include "DNA_view3d_types.h" +#include "DNA_screen_types.h" /* TransformOrientation */ #include "IMB_imbuf_types.h" @@ -47,8 +50,13 @@ #include "BKE_editmesh.h" #include "BKE_paint.h" +#include "ED_object.h" +#include "ED_gpencil.h" + #include "GPU_extensions.h" +#include "DRW_engine.h" + #include "RNA_define.h" #include "RNA_enum_types.h" @@ -66,12 +74,15 @@ #endif #include "ED_render.h" +#include "ED_transform.h" #include "WM_api.h" #include "WM_types.h" #include "BLI_threads.h" +#include "DEG_depsgraph.h" + #ifdef WITH_OPENEXR const EnumPropertyItem rna_enum_exr_codec_items[] = { {R_IMF_EXR_CODEC_NONE, "NONE", 0, "None", ""}, @@ -155,6 +166,14 @@ const EnumPropertyItem rna_enum_mesh_select_mode_items[] = { {0, NULL, 0, NULL, NULL} }; +const EnumPropertyItem rna_enum_mesh_select_mode_uv_items[] = { + {UV_SELECT_VERTEX, "VERTEX", ICON_UV_VERTEXSEL, "Vertex", "Vertex selection mode"}, + {UV_SELECT_EDGE, "EDGE", ICON_UV_EDGESEL, "Edge", "Edge selection mode"}, + {UV_SELECT_FACE, "FACE", ICON_UV_FACESEL, "Face", "Face selection mode"}, + {UV_SELECT_ISLAND, "ISLAND", ICON_UV_ISLANDSEL, "Island", "Island selection mode"}, + {0, NULL, 0, NULL, NULL} +}; + const EnumPropertyItem rna_enum_snap_element_items[] = { {SCE_SNAP_MODE_INCREMENT, "INCREMENT", ICON_SNAP_INCREMENT, "Increment", "Snap to increments of grid"}, {SCE_SNAP_MODE_VERTEX, "VERTEX", ICON_SNAP_VERTEX, "Vertex", "Snap to vertices"}, @@ -165,10 +184,10 @@ const EnumPropertyItem rna_enum_snap_element_items[] = { }; const EnumPropertyItem rna_enum_snap_node_element_items[] = { - {SCE_SNAP_MODE_GRID, "GRID", ICON_SNAP_GRID, "Grid", "Snap to grid"}, - {SCE_SNAP_MODE_NODE_X, "NODE_X", ICON_SNAP_EDGE, "Node X", "Snap to left/right node border"}, - {SCE_SNAP_MODE_NODE_Y, "NODE_Y", ICON_SNAP_EDGE, "Node Y", "Snap to top/bottom node border"}, - {SCE_SNAP_MODE_NODE_XY, "NODE_XY", ICON_SNAP_EDGE, "Node X / Y", "Snap to any node border"}, + {SCE_SNAP_MODE_GRID, "GRID", ICON_SNAP_GRID, "Grid", "Snap to grid"}, + {SCE_SNAP_MODE_NODE_X, "NODE_X", ICON_NODE_SIDE, "Node X", "Snap to left/right node border"}, + {SCE_SNAP_MODE_NODE_Y, "NODE_Y", ICON_NODE_TOP, "Node Y", "Snap to top/bottom node border"}, + {SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y, "NODE_XY", ICON_NODE_CORNER, "Node X / Y", "Snap to any node border"}, {0, NULL, 0, NULL, NULL} }; @@ -281,9 +300,6 @@ const EnumPropertyItem rna_enum_image_type_items[] = { {0, "", 0, N_("Movie"), NULL}, {R_IMF_IMTYPE_AVIJPEG, "AVI_JPEG", ICON_FILE_MOVIE, "AVI JPEG", "Output video in AVI JPEG format"}, {R_IMF_IMTYPE_AVIRAW, "AVI_RAW", ICON_FILE_MOVIE, "AVI Raw", "Output video in AVI Raw format"}, -#ifdef WITH_FRAMESERVER - {R_IMF_IMTYPE_FRAMESERVER, "FRAMESERVER", ICON_FILE_SCRIPT, "Frame Server", "Output image to a frameserver"}, -#endif #ifdef WITH_FFMPEG {R_IMF_IMTYPE_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "FFmpeg video", "The most versatile way to output video files"}, #endif @@ -394,7 +410,7 @@ const EnumPropertyItem rna_enum_stereo3d_interlace_type_items[] = { const EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = { {R_BAKE_PASS_FILTER_NONE, "NONE", 0, "None", ""}, - {R_BAKE_PASS_FILTER_AO, "AO", 0, "AO", ""}, + {R_BAKE_PASS_FILTER_AO, "AO", 0, "Ambient Occlusion", ""}, {R_BAKE_PASS_FILTER_EMIT, "EMIT", 0, "Emit", ""}, {R_BAKE_PASS_FILTER_DIRECT, "DIRECT", 0, "Direct", ""}, {R_BAKE_PASS_FILTER_INDIRECT, "INDIRECT", 0, "Indirect", ""}, @@ -406,6 +422,13 @@ const EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = { {0, NULL, 0, NULL, NULL} }; +static const EnumPropertyItem rna_enum_gizmo_items[] = { + {SCE_GIZMO_SHOW_TRANSLATE, "TRANSLATE", 0, "Move", ""}, + {SCE_GIZMO_SHOW_ROTATE, "ROTATE", 0, "Rotate", ""}, + {SCE_GIZMO_SHOW_SCALE, "SCALE", 0, "Scale", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifndef RNA_RUNTIME static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { /* interpolation */ @@ -430,8 +453,35 @@ static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { {0, NULL, 0, NULL, NULL} }; + #endif +const EnumPropertyItem rna_enum_transform_pivot_items_full[] = { + {V3D_AROUND_CENTER_BOUNDS, "BOUNDING_BOX_CENTER", ICON_PIVOT_BOUNDBOX, "Bounding Box Center", + "Pivot around bounding box center of selected object(s)"}, + {V3D_AROUND_CURSOR, "CURSOR", ICON_PIVOT_CURSOR, "3D Cursor", "Pivot around the 3D cursor"}, + {V3D_AROUND_LOCAL_ORIGINS, "INDIVIDUAL_ORIGINS", ICON_PIVOT_INDIVIDUAL, + "Individual Origins", "Pivot around each object's own origin"}, + {V3D_AROUND_CENTER_MEAN, "MEDIAN_POINT", ICON_PIVOT_MEDIAN, "Median Point", + "Pivot around the median point of selected objects"}, + {V3D_AROUND_ACTIVE, "ACTIVE_ELEMENT", ICON_PIVOT_ACTIVE, "Active Element", "Pivot around active object"}, + {0, NULL, 0, NULL, NULL} +}; + +/* Icons could be made a consistent set of images. */ +const EnumPropertyItem rna_enum_transform_orientation_items[] = { + {V3D_MANIP_GLOBAL, "GLOBAL", ICON_ORIENTATION_GLOBAL, "Global", "Align the transformation axes to world space"}, + {V3D_MANIP_LOCAL, "LOCAL", ICON_ORIENTATION_LOCAL, "Local", "Align the transformation axes to the selected objects' local space"}, + {V3D_MANIP_NORMAL, "NORMAL", ICON_ORIENTATION_NORMAL, "Normal", + "Align the transformation axes to average normal of selected elements " + "(bone Y axis for pose mode)"}, + {V3D_MANIP_GIMBAL, "GIMBAL", ICON_ORIENTATION_GIMBAL, "Gimbal", "Align each axis to the Euler rotation axis as used for input"}, + {V3D_MANIP_VIEW, "VIEW", ICON_ORIENTATION_VIEW, "View", "Align the transformation axes to the window"}, + {V3D_MANIP_CURSOR, "CURSOR", ICON_PIVOT_CURSOR, "Cursor", "Align the transformation axes to the 3D cursor"}, + // {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "DNA_anim_types.h" @@ -440,22 +490,24 @@ static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { #include "DNA_object_types.h" #include "DNA_mesh_types.h" #include "DNA_text_types.h" +#include "DNA_workspace_types.h" #include "RNA_access.h" #include "MEM_guardedalloc.h" #include "BKE_brush.h" +#include "BKE_collection.h" #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_image.h" +#include "BKE_layer.h" #include "BKE_main.h" #include "BKE_node.h" #include "BKE_pointcache.h" #include "BKE_scene.h" -#include "BKE_depsgraph.h" #include "BKE_mesh.h" #include "BKE_sound.h" #include "BKE_screen.h" @@ -463,6 +515,7 @@ static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { #include "BKE_animsys.h" #include "BKE_freestyle.h" #include "BKE_gpencil.h" +#include "BKE_unit.h" #include "ED_info.h" #include "ED_node.h" @@ -470,11 +523,44 @@ static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { #include "ED_mesh.h" #include "ED_keyframing.h" #include "ED_image.h" +#include "ED_scene.h" + +#include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" #ifdef WITH_FREESTYLE #include "FRS_freestyle.h" #endif +static void rna_ToolSettings_snap_mode_set(struct PointerRNA *ptr, int value) +{ + ToolSettings *ts = (ToolSettings *)ptr->data; + if (value != 0) { + ts->snap_mode = value; + } +} + +/* Grease Pencil update cache */ +static void rna_GPencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +{ + /* mark all grease pencil datablocks of the scene */ + FOREACH_SCENE_COLLECTION_BEGIN(scene, collection) + { + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, ob) + { + if (ob->type == OB_GPENCIL) { + bGPdata *gpd = (bGPdata *)ob->data; + gpd->flag |= GP_DATA_CACHE_IS_DIRTY; + DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA); + } + } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; + } + FOREACH_SCENE_COLLECTION_END; + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); +} + /* Grease Pencil Interpolation settings */ static char *rna_GPencilInterpolateSettings_path(PointerRNA *UNUSED(ptr)) { @@ -496,219 +582,53 @@ static void rna_GPencilInterpolateSettings_type_set(PointerRNA *ptr, int value) { settings->custom_ipo = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } -} -/* Grease pencil Drawing Brushes */ -static bGPDbrush *rna_GPencil_brush_new(ToolSettings *ts, const char *name, bool setactive) -{ - bGPDbrush *brush = BKE_gpencil_brush_addnew(ts, name, setactive != 0); - - WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - - return brush; } - -static void rna_GPencil_brush_remove(ToolSettings *ts, ReportList *reports, PointerRNA *brush_ptr) +static void rna_ToolSettings_gizmo_flag_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { - bGPDbrush *brush = brush_ptr->data; - if (BLI_findindex(&ts->gp_brushes, brush) == -1) { - BKE_report(reports, RPT_ERROR, "Brush not found in grease pencil data"); - return; + ToolSettings *ts = scene->toolsettings; + if ((ts->gizmo_flag & (SCE_GIZMO_SHOW_TRANSLATE | SCE_GIZMO_SHOW_ROTATE | SCE_GIZMO_SHOW_SCALE)) == 0) { + ts->gizmo_flag |= SCE_GIZMO_SHOW_TRANSLATE; } - - BKE_gpencil_brush_delete(ts, brush); - RNA_POINTER_INVALIDATE(brush_ptr); - - WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); -} - -static PointerRNA rna_GPencilBrushes_active_get(PointerRNA *ptr) -{ - ToolSettings *ts = (ToolSettings *) ptr->data; - - bGPDbrush *brush; - - for (brush = ts->gp_brushes.first; brush; brush = brush->next) { - if (brush->flag & GP_BRUSH_ACTIVE) { - break; - } - } - - if (brush) { - return rna_pointer_inherit_refine(ptr, &RNA_GPencilBrush, brush); - } - - return rna_pointer_inherit_refine(ptr, NULL, NULL); -} - -static void rna_GPencilBrushes_active_set(PointerRNA *ptr, PointerRNA value) -{ - ToolSettings *ts = (ToolSettings *) ptr->data; - - bGPDbrush *brush; - - for (brush = ts->gp_brushes.first; brush; brush = brush->next) { - if (brush == value.data) { - brush->flag |= GP_BRUSH_ACTIVE; - } - else { - brush->flag &= ~GP_BRUSH_ACTIVE; - } - } - WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); -} - -static int rna_GPencilBrushes_index_get(PointerRNA *ptr) -{ - ToolSettings *ts = (ToolSettings *) ptr->data; - bGPDbrush *brush = BKE_gpencil_brush_getactive(ts); - - return BLI_findindex(&ts->gp_brushes, brush); -} - -static void rna_GPencilBrushes_index_set(PointerRNA *ptr, int value) -{ - ToolSettings *ts = (ToolSettings *) ptr->data; - - bGPDbrush *brush = BLI_findlink(&ts->gp_brushes, value); - - BKE_gpencil_brush_setactive(ts, brush); - WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); -} - -static void rna_GPencilBrushes_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) -{ - ToolSettings *ts = (ToolSettings *) ptr->data; - - *min = 0; - *max = max_ii(0, BLI_listbase_count(&ts->gp_brushes) - 1); - - *softmin = *min; - *softmax = *max; } -static void rna_GPencilBrush_name_set(PointerRNA *ptr, const char *value) -{ - ToolSettings *ts = ((Scene *) ptr->id.data)->toolsettings; - bGPDbrush *brush = ptr->data; - - /* copy the new name into the name slot */ - BLI_strncpy_utf8(brush->info, value, sizeof(brush->info)); - - BLI_uniquename(&ts->gp_brushes, brush, DATA_("GP_Brush"), '.', offsetof(bGPDbrush, info), sizeof(brush->info)); -} - -/* ----------------- end of Grease pencil drawing brushes ------------*/ - static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) { ED_space_image_uv_sculpt_update(bmain, bmain->wm.first, scene); } -static int rna_Scene_object_bases_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) -{ - Scene *scene = (Scene *)ptr->data; - Base *base; - - for (base = scene->base.first; base; base = base->next) { - if (STREQLEN(base->object->id.name + 2, key, sizeof(base->object->id.name) - 2)) { - *r_ptr = rna_pointer_inherit_refine(ptr, &RNA_ObjectBase, base); - return true; - } - } - - return false; -} - -static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter) -{ - ListBaseIterator *internal = &iter->internal.listbase; - /* we are actually iterating a Base list, so override get */ - return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((Base *)internal->link)->object); -} +/* Read-only Iterator of all the scene objects. */ -static Base *rna_Scene_object_link(Scene *scene, Main *UNUSED(bmain), bContext *C, ReportList *reports, Object *ob) +static void rna_Scene_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - Scene *scene_act = CTX_data_scene(C); - Base *base; - - if (BKE_scene_base_find(scene, ob)) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' is already in scene '%s'", ob->id.name + 2, scene->id.name + 2); - return NULL; - } - - base = BKE_scene_base_add(scene, ob); - id_us_plus(&ob->id); - - /* this is similar to what object_add_type and BKE_object_add do */ - base->lay = scene->lay; - - /* when linking to an inactive scene don't touch the layer */ - if (scene == scene_act) - ob->lay = base->lay; - - /* TODO(sergey): Only update relations for the current scene. */ - DAG_relations_tag_update(CTX_data_main(C)); - DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); - - /* slows down importers too much, run scene.update() */ - /* DAG_srelations_tag_update(bmain); */ - - WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene); + Scene *scene = (Scene *)ptr->data; + iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__); - return base; + ((BLI_Iterator *)iter->internal.custom)->valid = true; + BKE_scene_objects_iterator_begin(iter->internal.custom, (void *)scene); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; } -static void rna_Scene_object_unlink(Scene *scene, Main *bmain, ReportList *reports, Object *ob) +static void rna_Scene_objects_next(CollectionPropertyIterator *iter) { - Base *base = BKE_scene_base_find(scene, ob); - if (!base) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' is not in this scene '%s'", ob->id.name + 2, scene->id.name + 2); - return; - } - if (base == scene->basact && ob->mode != OB_MODE_OBJECT) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' must be in object mode to unlink", ob->id.name + 2); - return; - } - if (scene->basact == base) { - scene->basact = NULL; - } - - BKE_scene_base_unlink(scene, base); - MEM_freeN(base); - - id_us_min(&ob->id); - - /* needed otherwise the depgraph will contain freed objects which can crash, see [#20958] */ - DAG_relations_tag_update(bmain); - - WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene); + BKE_scene_objects_iterator_next(iter->internal.custom); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; } -static void rna_Scene_skgen_etch_template_set(PointerRNA *ptr, PointerRNA value) +static void rna_Scene_objects_end(CollectionPropertyIterator *iter) { - ToolSettings *ts = (ToolSettings *)ptr->data; - if (value.data && ((Object *)value.data)->type == OB_ARMATURE) - ts->skgen_template = value.data; - else - ts->skgen_template = NULL; + BKE_scene_objects_iterator_end(iter->internal.custom); + MEM_freeN(iter->internal.custom); } -static PointerRNA rna_Scene_active_object_get(PointerRNA *ptr) +static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter) { - Scene *scene = (Scene *)ptr->data; - return rna_pointer_inherit_refine(ptr, &RNA_Object, scene->basact ? scene->basact->object : NULL); + Object *ob = ((BLI_Iterator *)iter->internal.custom)->current; + return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ob); } -static void rna_Scene_active_object_set(PointerRNA *ptr, PointerRNA value) -{ - Scene *scene = (Scene *)ptr->data; - if (value.data) - scene->basact = BKE_scene_base_find(scene, (Object *)value.data); - else - scene->basact = NULL; -} +/* End of read-only Iterator of all the scene objects. */ static void rna_Scene_set_set(PointerRNA *ptr, PointerRNA value) { @@ -728,35 +648,26 @@ static void rna_Scene_set_set(PointerRNA *ptr, PointerRNA value) scene->set = set; } -static void rna_Scene_layer_set(PointerRNA *ptr, const bool *values) -{ - Scene *scene = (Scene *)ptr->data; - - scene->lay = ED_view3d_scene_layer_set(scene->lay, values, &scene->layact); -} - -static int rna_Scene_active_layer_get(PointerRNA *ptr) +void rna_Scene_set_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - Scene *scene = (Scene *)ptr->data; + Scene *scene = (Scene *)ptr->id.data; - return (int)(log(scene->layact) / M_LN2); + DEG_relations_tag_update(bmain); + DEG_id_tag_update_ex(bmain, &scene->id, 0); + if (scene->set != NULL) { + /* Objects which are pulled into main scene's depsgraph needs to have + * their base flags updated. + */ + DEG_id_tag_update_ex(bmain, &scene->set->id, 0); + } } static void rna_Scene_view3d_update(Main *bmain, Scene *UNUSED(scene_unused), PointerRNA *ptr) { + wmWindowManager *wm = bmain->wm.first; Scene *scene = (Scene *)ptr->data; - BKE_screen_view3d_main_sync(&bmain->screen, scene); -} - -static void rna_Scene_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - rna_Scene_view3d_update(bmain, scene, ptr); - /* XXX We would need do_time=true here, else we can have update issues like [#36289]... - * However, this has too much drawbacks (like slower layer switch, undesired updates...). - * That's TODO for future DAG updates. - */ - DAG_on_visible_update(bmain, false); + WM_windows_scene_data_sync(&wm->windows, scene); } static void rna_Scene_fps_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) @@ -899,6 +810,7 @@ static void rna_Scene_frame_update(Main *bmain, Scene *UNUSED(current_scene), Po { Scene *scene = (Scene *)ptr->id.data; BKE_sound_seek_scene(bmain, scene); + WM_main_add_notifier(NC_SCENE | ND_FRAME, scene); } static PointerRNA rna_Scene_active_keying_set_get(PointerRNA *ptr) @@ -965,6 +877,11 @@ static void rna_Scene_all_keyingsets_next(CollectionPropertyIterator *iter) iter->valid = (internal->link != NULL); } +static char *rna_SceneEEVEE_path(PointerRNA *UNUSED(ptr)) +{ + return BLI_strdup("eevee"); +} + static int rna_RenderSettings_stereoViews_skip(CollectionPropertyIterator *iter, void *UNUSED(data)) { ListBaseIterator *internal = &iter->internal.listbase; @@ -1065,17 +982,6 @@ static bool rna_RenderSettings_is_movie_format_get(PointerRNA *ptr) return BKE_imtype_is_movie(rd->im_format.imtype); } -static bool rna_RenderSettings_save_buffers_get(PointerRNA *ptr) -{ - RenderData *rd = (RenderData *)ptr->data; - Scene *scene = (Scene *)ptr->id.data; - - if (!BKE_scene_use_new_shading_nodes(scene)) - return (rd->scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE)) != 0; - else - return (rd->scemode & R_EXR_TILE_FILE) != 0; -} - static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) { ImageFormatData *imf = (ImageFormatData *)ptr->data; @@ -1334,73 +1240,6 @@ static void rna_FFmpegSettings_codec_settings_update(Main *UNUSED(bmain), Scene } #endif -static int rna_RenderSettings_active_layer_index_get(PointerRNA *ptr) -{ - RenderData *rd = (RenderData *)ptr->data; - return rd->actlay; -} - -static void rna_RenderSettings_active_layer_index_set(PointerRNA *ptr, int value) -{ - RenderData *rd = (RenderData *)ptr->data; - int num_layers = BLI_listbase_count(&rd->layers); - rd->actlay = min_ff(value, num_layers - 1); -} - -static void rna_RenderSettings_active_layer_index_range( - PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) -{ - RenderData *rd = (RenderData *)ptr->data; - - *min = 0; - *max = max_ii(0, BLI_listbase_count(&rd->layers) - 1); -} - -static PointerRNA rna_RenderSettings_active_layer_get(PointerRNA *ptr) -{ - RenderData *rd = (RenderData *)ptr->data; - SceneRenderLayer *srl = BLI_findlink(&rd->layers, rd->actlay); - - return rna_pointer_inherit_refine(ptr, &RNA_SceneRenderLayer, srl); -} - -static void rna_RenderSettings_active_layer_set(PointerRNA *ptr, PointerRNA value) -{ - RenderData *rd = (RenderData *)ptr->data; - SceneRenderLayer *srl = (SceneRenderLayer *)value.data; - const int index = BLI_findindex(&rd->layers, srl); - if (index != -1) rd->actlay = index; -} - -static SceneRenderLayer *rna_RenderLayer_new(ID *id, RenderData *UNUSED(rd), const char *name) -{ - Scene *scene = (Scene *)id; - SceneRenderLayer *srl = BKE_scene_add_render_layer(scene, name); - - DAG_id_tag_update(&scene->id, 0); - WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); - - return srl; -} - -static void rna_RenderLayer_remove( - ID *id, RenderData *UNUSED(rd), Main *bmain, ReportList *reports, PointerRNA *srl_ptr) -{ - SceneRenderLayer *srl = srl_ptr->data; - Scene *scene = (Scene *)id; - - if (!BKE_scene_remove_render_layer(bmain, scene, srl)) { - BKE_reportf(reports, RPT_ERROR, "Render layer '%s' could not be removed from scene '%s'", - srl->name, scene->id.name + 2); - return; - } - - RNA_POINTER_INVALIDATE(srl_ptr); - - DAG_id_tag_update(&scene->id, 0); - WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); -} - static int rna_RenderSettings_active_view_index_get(PointerRNA *ptr) { RenderData *rd = (RenderData *)ptr->data; @@ -1465,13 +1304,29 @@ static void rna_RenderView_remove( WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); } +static void rna_RenderSettings_views_format_set(PointerRNA *ptr, int value) +{ + RenderData *rd = (RenderData *)ptr->data; + + if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW && + value == SCE_VIEWS_FORMAT_STEREO_3D) + { + /* make sure the actview is visible */ + if (rd->actview > 1) rd->actview = 1; + } + + rd->views_format = value; +} + static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value) { RenderData *rd = (RenderData *)ptr->data; RenderEngineType *type = BLI_findlink(&R_engines, value); - if (type) + if (type) { BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine)); + DEG_id_tag_update(ptr->id.data, DEG_TAG_COPY_ON_WRITE); + } } static const EnumPropertyItem *rna_RenderSettings_engine_itemf( @@ -1513,139 +1368,63 @@ static void rna_RenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), ED_render_engine_changed(bmain); } -static void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static bool rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) { - Scene *scene = (Scene *)ptr->id.data; - - DAG_id_tag_update(&scene->id, 0); + return (BLI_listbase_count(&R_engines) > 1); } -static void rna_Scene_freestyle_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static bool rna_RenderSettings_use_spherical_stereo_get(PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; - - DAG_id_tag_update(&scene->id, 0); -} - -static void rna_Scene_use_view_map_cache_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) -{ -#ifdef WITH_FREESTYLE - FRS_free_view_map_cache(); -#endif -} - -static IDProperty *rna_SceneRenderLayer_idprops(PointerRNA *ptr, bool create) -{ - SceneRenderLayer *srl = (SceneRenderLayer *)ptr->data; - - if (create && !srl->prop) { - IDPropertyTemplate val = {0}; - srl->prop = IDP_New(IDP_GROUP, &val, "SceneRenderLayer ID properties"); - } - - return srl->prop; + return BKE_scene_use_spherical_stereo(scene); } -static void rna_SceneRenderLayer_name_set(PointerRNA *ptr, const char *value) +void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; - SceneRenderLayer *rl = (SceneRenderLayer *)ptr->data; - char oldname[sizeof(rl->name)]; - - BLI_strncpy(oldname, rl->name, sizeof(rl->name)); - - BLI_strncpy_utf8(rl->name, value, sizeof(rl->name)); - BLI_uniquename(&scene->r.layers, rl, DATA_("RenderLayer"), '.', offsetof(SceneRenderLayer, name), sizeof(rl->name)); - - if (scene->nodetree) { - bNode *node; - int index = BLI_findindex(&scene->r.layers, rl); - - for (node = scene->nodetree->nodes.first; node; node = node->next) { - if (node->type == CMP_NODE_R_LAYERS && node->id == NULL) { - if (node->custom1 == index) - BLI_strncpy(node->name, rl->name, NODE_MAXSTR); - } - } - } - /* fix all the animation data which may link to this */ - BKE_animdata_fix_paths_rename_all(NULL, "render.layers", oldname, rl->name); + DEG_id_tag_update(&scene->id, 0); } -static char *rna_SceneRenderLayer_path(PointerRNA *ptr) +static void rna_Scene_world_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - SceneRenderLayer *srl = (SceneRenderLayer *)ptr->data; - char name_esc[sizeof(srl->name) * 2]; + Scene *sc = (Scene *)ptr->id.data; - BLI_strescape(name_esc, srl->name, sizeof(name_esc)); - return BLI_sprintfN("render.layers[\"%s\"]", name_esc); + rna_Scene_glsl_update(bmain, scene, ptr); + WM_main_add_notifier(NC_WORLD | ND_WORLD, &sc->id); } -static void rna_SceneRenderView_name_set(PointerRNA *ptr, const char *value) +void rna_Scene_freestyle_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; - SceneRenderView *rv = (SceneRenderView *)ptr->data; - BLI_strncpy_utf8(rv->name, value, sizeof(rv->name)); - BLI_uniquename(&scene->r.views, rv, DATA_("RenderView"), '.', offsetof(SceneRenderView, name), sizeof(rv->name)); -} -static char *rna_SceneRenderView_path(PointerRNA *ptr) -{ - SceneRenderView *srv = (SceneRenderView *)ptr->data; - return BLI_sprintfN("render.views[\"%s\"]", srv->name); + DEG_id_tag_update(&scene->id, 0); } -static void rna_RenderSettings_views_format_set(PointerRNA *ptr, int value) +void rna_Scene_use_view_map_cache_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { - RenderData *rd = (RenderData *)ptr->data; - - if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW && - value == SCE_VIEWS_FORMAT_STEREO_3D) - { - /* make sure the actview is visible */ - if (rd->actview > 1) rd->actview = 1; - } - - rd->views_format = value; -} - -static bool rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) -{ - return (BLI_listbase_count(&R_engines) > 1); +#ifdef WITH_FREESTYLE + FRS_free_view_map_cache(); +#endif } -static bool rna_RenderSettings_use_shading_nodes_get(PointerRNA *ptr) +void rna_ViewLayer_name_set(PointerRNA *ptr, const char *value) { Scene *scene = (Scene *)ptr->id.data; - return BKE_scene_use_new_shading_nodes(scene); + ViewLayer *view_layer = (ViewLayer *)ptr->data; + BLI_assert(BKE_id_is_in_gobal_main(&scene->id)); + BKE_view_layer_rename(G_MAIN, scene, view_layer, value); } -static bool rna_RenderSettings_use_spherical_stereo_get(PointerRNA *ptr) +static void rna_SceneRenderView_name_set(PointerRNA *ptr, const char *value) { Scene *scene = (Scene *)ptr->id.data; - return BKE_scene_use_spherical_stereo(scene); -} - -static bool rna_RenderSettings_use_game_engine_get(PointerRNA *ptr) -{ - RenderData *rd = (RenderData *)ptr->data; - RenderEngineType *type; - - for (type = R_engines.first; type; type = type->next) - if (STREQ(type->idname, rd->engine)) - return (type->flag & RE_GAME) != 0; - - return 0; -} - -static void rna_SceneRenderLayer_layer_set(PointerRNA *ptr, const bool *values) -{ - SceneRenderLayer *rl = (SceneRenderLayer *)ptr->data; - rl->lay = ED_view3d_scene_layer_set(rl->lay, values, NULL); + SceneRenderView *rv = (SceneRenderView *)ptr->data; + BLI_strncpy_utf8(rv->name, value, sizeof(rv->name)); + BLI_uniquename(&scene->r.views, rv, DATA_("RenderView"), '.', offsetof(SceneRenderView, name), sizeof(rv->name)); } -static void rna_SceneRenderLayer_pass_update(Main *bmain, Scene *activescene, PointerRNA *ptr) +void rna_ViewLayer_pass_update(Main *bmain, Scene *activescene, PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; @@ -1655,61 +1434,72 @@ static void rna_SceneRenderLayer_pass_update(Main *bmain, Scene *activescene, Po rna_Scene_glsl_update(bmain, activescene, ptr); } -static void rna_SceneRenderLayer_update_render_passes(ID *id) +static char *rna_SceneRenderView_path(PointerRNA *ptr) { - Scene *scene = (Scene *)id; - if (scene->nodetree) - ntreeCompositUpdateRLayers(scene->nodetree); + SceneRenderView *srv = (SceneRenderView *)ptr->data; + return BLI_sprintfN("render.views[\"%s\"]", srv->name); } static void rna_Scene_use_nodes_update(bContext *C, PointerRNA *ptr) { Scene *scene = (Scene *)ptr->data; - - if (scene->use_nodes && scene->nodetree == NULL) + if (scene->use_nodes && scene->nodetree == NULL) { ED_node_composit_default(C, scene); + } + DEG_relations_tag_update(CTX_data_main(C)); } static void rna_Physics_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; - Base *base; + FOREACH_SCENE_OBJECT_BEGIN(scene, ob) + { + BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH); + } + FOREACH_SCENE_OBJECT_END; - for (base = scene->base.first; base; base = base->next) - BKE_ptcache_object_reset(scene, base->object, PTCACHE_RESET_DEPSGRAPH); + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); } static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const bool *value) { - Scene *scene = (Scene *)ptr->id.data; ToolSettings *ts = (ToolSettings *)ptr->data; int flag = (value[0] ? SCE_SELECT_VERTEX : 0) | (value[1] ? SCE_SELECT_EDGE : 0) | (value[2] ? SCE_SELECT_FACE : 0); if (flag) { ts->selectmode = flag; - if (scene->basact) { - Mesh *me = BKE_mesh_from_object(scene->basact->object); - if (me && me->edit_btmesh && me->edit_btmesh->selectmode != flag) { - me->edit_btmesh->selectmode = flag; - EDBM_selectmode_set(me->edit_btmesh); + /* Update select mode in all the workspaces in mesh edit mode. */ + wmWindowManager *wm = G_MAIN->wm.first; + for (wmWindow *win = wm->windows.first; win; win = win->next) { + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + + if (view_layer && view_layer->basact) { + Mesh *me = BKE_mesh_from_object(view_layer->basact->object); + if (me && me->edit_btmesh && me->edit_btmesh->selectmode != flag) { + me->edit_btmesh->selectmode = flag; + EDBM_selectmode_set(me->edit_btmesh); + } } } } } -static void rna_Scene_editmesh_select_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_Scene_editmesh_select_mode_update(bContext *C, PointerRNA *UNUSED(ptr)) { + ViewLayer *view_layer = CTX_data_view_layer(C); Mesh *me = NULL; - if (scene->basact) { - me = BKE_mesh_from_object(scene->basact->object); + if (view_layer->basact) { + me = BKE_mesh_from_object(view_layer->basact->object); if (me && me->edit_btmesh == NULL) me = NULL; } - WM_main_add_notifier(NC_GEOM | ND_SELECT, me); - WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); + if (me) { + DEG_id_tag_update(&me->id, DEG_TAG_SELECT_UPDATE); + WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); + } } static void object_simplify_update(Object *ob) @@ -1725,7 +1515,7 @@ static void object_simplify_update(Object *ob) for (md = ob->modifiers.first; md; md = md->next) { if (ELEM(md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem)) { - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } } @@ -1733,40 +1523,40 @@ static void object_simplify_update(Object *ob) psys->recalc |= PSYS_RECALC_CHILD; if (ob->dup_group) { - GroupObject *gob; + CollectionObject *cob; - for (gob = ob->dup_group->gobject.first; gob; gob = gob->next) - object_simplify_update(gob->ob); + for (cob = ob->dup_group->gobject.first; cob; cob = cob->next) + object_simplify_update(cob->ob); } } -static void rna_Scene_use_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Scene_use_simplify_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Scene *sce = ptr->id.data; Scene *sce_iter; Base *base; BKE_main_id_tag_listbase(&bmain->object, LIB_TAG_DOIT, true); - for (SETLOOPER(sce, sce_iter, base)) + FOREACH_SCENE_OBJECT_BEGIN(sce, ob) + { + object_simplify_update(ob); + } + FOREACH_SCENE_OBJECT_END; + + for (SETLOOPER_SET_ONLY(sce, sce_iter, base)) { object_simplify_update(base->object); + } WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); - DAG_id_tag_update(&scene->id, 0); + DEG_id_tag_update(&sce->id, 0); } -static void rna_Scene_simplify_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Scene *sce = ptr->id.data; if (sce->r.mode & R_SIMPLIFY) - rna_Scene_use_simplify_update(bmain, sce, ptr); -} - -static void rna_SceneRenderData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - Scene *sce = ptr->id.data; - - DAG_id_tag_update(&sce->id, 0); + rna_Scene_use_simplify_update(bmain, scene, ptr); } static void rna_Scene_use_persistent_data_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -1820,26 +1610,7 @@ static void rna_Scene_sync_mode_set(PointerRNA *ptr, int value) } } -static bool rna_GameSettings_auto_start_get(PointerRNA *UNUSED(ptr)) -{ - return (G.fileflags & G_FILE_AUTOPLAY) != 0; -} -static void rna_GameSettings_auto_start_set(PointerRNA *UNUSED(ptr), bool value) -{ - if (value) - G.fileflags |= G_FILE_AUTOPLAY; - else - G.fileflags &= ~G_FILE_AUTOPLAY; -} - -static void rna_GameSettings_exit_key_set(PointerRNA *ptr, int value) -{ - GameData *gm = (GameData *)ptr->data; - - if (ISKEYBOARD(value)) - gm->exitkey = value; -} static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[], int frame) { @@ -1896,9 +1667,11 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons } } -static void rna_UnifiedPaintSettings_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_UnifiedPaintSettings_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Brush *br = BKE_paint_brush(BKE_paint_get_active(scene)); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer)); WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); } @@ -1921,11 +1694,11 @@ static void rna_UnifiedPaintSettings_unprojected_radius_set(PointerRNA *ptr, flo ups->unprojected_radius = value; } -static void rna_UnifiedPaintSettings_radius_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_UnifiedPaintSettings_radius_update(bContext *C, PointerRNA *ptr) { /* changing the unified size should invalidate the overlay but also update the brush */ BKE_paint_invalidate_overlay_all(); - rna_UnifiedPaintSettings_update(bmain, scene, ptr); + rna_UnifiedPaintSettings_update(C, ptr); } static char *rna_UnifiedPaintSettings_path(PointerRNA *UNUSED(ptr)) @@ -1939,18 +1712,19 @@ static char *rna_CurvePaintSettings_path(PointerRNA *UNUSED(ptr)) } /* generic function to recalc geometry */ -static void rna_EditMesh_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_EditMesh_update(bContext *C, PointerRNA *UNUSED(ptr)) { + ViewLayer *view_layer = CTX_data_view_layer(C); Mesh *me = NULL; - if (scene->basact) { - me = BKE_mesh_from_object(scene->basact->object); + if (view_layer->basact) { + me = BKE_mesh_from_object(view_layer->basact->object); if (me && me->edit_btmesh == NULL) me = NULL; } if (me) { - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DEG_id_tag_update(&me->id, OB_RECALC_DATA); WM_main_add_notifier(NC_GEOM | ND_DATA, me); } } @@ -1965,11 +1739,13 @@ static char *rna_MeshStatVis_path(PointerRNA *UNUSED(ptr)) * is not for general use and only for the few cases where changing scene * settings and NOT for general purpose updates, possibly this should be * given its own notifier. */ -static void rna_Scene_update_active_object_data(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_Scene_update_active_object_data(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = OBACT; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); + if (ob) { - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id); } } @@ -1979,8 +1755,9 @@ static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po Scene *scene = (Scene *)ptr->id.data; Object *camera = scene->camera; - if (camera) - DAG_id_tag_update(&camera->id, 0); + if (camera && (camera->type == OB_CAMERA)) { + DEG_id_tag_update(&camera->id, OB_RECALC_DATA); + } } static void rna_SceneSequencer_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) @@ -1994,14 +1771,14 @@ static char *rna_ToolSettings_path(PointerRNA *UNUSED(ptr)) return BLI_strdup("tool_settings"); } -static PointerRNA rna_FreestyleLineSet_linestyle_get(PointerRNA *ptr) +PointerRNA rna_FreestyleLineSet_linestyle_get(PointerRNA *ptr) { FreestyleLineSet *lineset = (FreestyleLineSet *)ptr->data; return rna_pointer_inherit_refine(ptr, &RNA_FreestyleLineStyle, lineset->linestyle); } -static void rna_FreestyleLineSet_linestyle_set(PointerRNA *ptr, PointerRNA value) +void rna_FreestyleLineSet_linestyle_set(PointerRNA *ptr, PointerRNA value) { FreestyleLineSet *lineset = (FreestyleLineSet *)ptr->data; @@ -2011,19 +1788,19 @@ static void rna_FreestyleLineSet_linestyle_set(PointerRNA *ptr, PointerRNA value id_us_plus(&lineset->linestyle->id); } -static FreestyleLineSet *rna_FreestyleSettings_lineset_add( +FreestyleLineSet *rna_FreestyleSettings_lineset_add( ID *id, FreestyleSettings *config, Main *bmain, const char *name) { Scene *scene = (Scene *)id; FreestyleLineSet *lineset = BKE_freestyle_lineset_add(bmain, (FreestyleConfig *)config, name); - DAG_id_tag_update(&scene->id, 0); + DEG_id_tag_update(&scene->id, 0); WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); return lineset; } -static void rna_FreestyleSettings_lineset_remove( +void rna_FreestyleSettings_lineset_remove( ID *id, FreestyleSettings *config, ReportList *reports, PointerRNA *lineset_ptr) { FreestyleLineSet *lineset = lineset_ptr->data; @@ -2036,18 +1813,18 @@ static void rna_FreestyleSettings_lineset_remove( RNA_POINTER_INVALIDATE(lineset_ptr); - DAG_id_tag_update(&scene->id, 0); + DEG_id_tag_update(&scene->id, 0); WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); } -static PointerRNA rna_FreestyleSettings_active_lineset_get(PointerRNA *ptr) +PointerRNA rna_FreestyleSettings_active_lineset_get(PointerRNA *ptr) { FreestyleConfig *config = (FreestyleConfig *)ptr->data; FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config); return rna_pointer_inherit_refine(ptr, &RNA_FreestyleLineSet, lineset); } -static void rna_FreestyleSettings_active_lineset_index_range( +void rna_FreestyleSettings_active_lineset_index_range( PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) { FreestyleConfig *config = (FreestyleConfig *)ptr->data; @@ -2056,30 +1833,30 @@ static void rna_FreestyleSettings_active_lineset_index_range( *max = max_ii(0, BLI_listbase_count(&config->linesets) - 1); } -static int rna_FreestyleSettings_active_lineset_index_get(PointerRNA *ptr) +int rna_FreestyleSettings_active_lineset_index_get(PointerRNA *ptr) { FreestyleConfig *config = (FreestyleConfig *)ptr->data; return BKE_freestyle_lineset_get_active_index(config); } -static void rna_FreestyleSettings_active_lineset_index_set(PointerRNA *ptr, int value) +void rna_FreestyleSettings_active_lineset_index_set(PointerRNA *ptr, int value) { FreestyleConfig *config = (FreestyleConfig *)ptr->data; BKE_freestyle_lineset_set_active_index(config, value); } -static FreestyleModuleConfig *rna_FreestyleSettings_module_add(ID *id, FreestyleSettings *config) +FreestyleModuleConfig *rna_FreestyleSettings_module_add(ID *id, FreestyleSettings *config) { Scene *scene = (Scene *)id; FreestyleModuleConfig *module = BKE_freestyle_module_add((FreestyleConfig *)config); - DAG_id_tag_update(&scene->id, 0); + DEG_id_tag_update(&scene->id, 0); WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); return module; } -static void rna_FreestyleSettings_module_remove( +void rna_FreestyleSettings_module_remove( ID *id, FreestyleSettings *config, ReportList *reports, PointerRNA *module_ptr) { Scene *scene = (Scene *)id; @@ -2095,7 +1872,7 @@ static void rna_FreestyleSettings_module_remove( RNA_POINTER_INVALIDATE(module_ptr); - DAG_id_tag_update(&scene->id, 0); + DEG_id_tag_update(&scene->id, 0); WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); } @@ -2114,23 +1891,21 @@ char *rna_GPUDOF_path(PointerRNA *ptr) return BLI_strdup(""); } -static void rna_GPUFXSettings_fx_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - GPUFXSettings *fx_settings = ptr->data; - - BKE_screen_gpu_fx_validate(fx_settings); -} - static void rna_GPUDOFSettings_blades_set(PointerRNA *ptr, const int value) { GPUDOFSettings *dofsettings = (GPUDOFSettings *)ptr->data; - if (value < 3 && dofsettings->num_blades > 2) - dofsettings->num_blades = 0; - else if (value > 0 && dofsettings->num_blades == 0) - dofsettings->num_blades = 3; - else + if (value == 1 || value == 2) { + if (dofsettings->num_blades == 0) { + dofsettings->num_blades = 3; + } + else { + dofsettings->num_blades = 0; + } + } + else { dofsettings->num_blades = value; + } } static void rna_GPUDOFSettings_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) @@ -2162,9 +1937,155 @@ static void rna_Stereo3dFormat_update(Main *bmain, Scene *UNUSED(scene), Pointer } } -static bool rna_gpu_is_hq_supported_get(PointerRNA *UNUSED(ptr)) +static ViewLayer *rna_ViewLayer_new( + ID *id, Scene *UNUSED(sce), Main *bmain, const char *name) +{ + Scene *scene = (Scene *)id; + ViewLayer *view_layer = BKE_view_layer_add(scene, name); + + DEG_id_tag_update(&scene->id, 0); + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + + return view_layer; +} + +static void rna_ViewLayer_remove( + ID *id, Scene *UNUSED(sce), Main *bmain, ReportList *reports, PointerRNA *sl_ptr) +{ + Scene *scene = (Scene *)id; + ViewLayer *view_layer = sl_ptr->data; + + if (ED_scene_view_layer_delete(bmain, scene, view_layer, reports)) { + RNA_POINTER_INVALIDATE(sl_ptr); + } +} + +static int rna_Scene_transform_orientation_get(PointerRNA *ptr) +{ + Scene *scene = ptr->data; + /* convert to enum value */ + return (scene->orientation_type == V3D_MANIP_CUSTOM) ? + (scene->orientation_type + scene->orientation_index_custom) : scene->orientation_type; +} + +void rna_Scene_transform_orientation_set(PointerRNA *ptr, int value) +{ + Scene *scene = ptr->data; + BIF_selectTransformOrientationValue(scene, value); +} + +static PointerRNA rna_Scene_current_orientation_get(PointerRNA *ptr) +{ + Scene *scene = ptr->data; + TransformOrientation *orientation; + + if (scene->orientation_type < V3D_MANIP_CUSTOM) { + orientation = NULL; + } + else { + orientation = BKE_scene_transform_orientation_find(scene, scene->orientation_index_custom); + } + + return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, orientation); +} + +const EnumPropertyItem *rna_TransformOrientation_itemf( + bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return GPU_instanced_drawing_support() && GPU_geometry_shader_support(); + EnumPropertyItem tmp = {0, "", 0, "", ""}; + EnumPropertyItem *item = NULL; + int i = V3D_MANIP_CUSTOM, totitem = 0; + + RNA_enum_items_add(&item, &totitem, rna_enum_transform_orientation_items); + + Scene *scene; + if (ptr->type == &RNA_Scene) { + scene = ptr->data; + } + else { + scene = CTX_data_scene(C); + } + const ListBase *transform_orientations = scene ? &scene->transform_spaces : NULL; + + if (transform_orientations && (BLI_listbase_is_empty(transform_orientations) == false)) { + RNA_enum_item_add_separator(&item, &totitem); + + for (TransformOrientation *ts = transform_orientations->first; ts; ts = ts->next) { + tmp.identifier = ts->name; + tmp.name = ts->name; + tmp.value = i++; + RNA_enum_item_add(&item, &totitem, &tmp); + } + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + +static const EnumPropertyItem *get_unit_enum_items(int system, int type, bool *r_free) +{ + const void *usys; + int len; + bUnit_GetSystem(system, type, &usys, &len); + + EnumPropertyItem *items = NULL; + int totitem = 0; + + EnumPropertyItem adaptive = { 0 }; + adaptive.identifier = "ADAPTIVE"; + adaptive.name = "Adaptive"; + adaptive.value = USER_UNIT_ADAPTIVE; + RNA_enum_item_add(&items, &totitem, &adaptive); + + for (int i = 0; i < len; i++) { + if (!bUnit_IsSuppressed(usys, i)) { + EnumPropertyItem tmp = { 0 }; + tmp.identifier = bUnit_GetName(usys, i); + tmp.name = bUnit_GetNameDisplay(usys, i); + tmp.value = i; + RNA_enum_item_add(&items, &totitem, &tmp); + } + } + + *r_free = true; + return items; +} + +const EnumPropertyItem *rna_get_length_unit_items( + bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) +{ + UnitSettings *units = ptr->data; + return get_unit_enum_items(units->system, B_UNIT_LENGTH, r_free); +} + +const EnumPropertyItem *rna_get_mass_unit_items( + bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) +{ + UnitSettings *units = ptr->data; + return get_unit_enum_items(units->system, B_UNIT_MASS, r_free); +} + +const EnumPropertyItem *rna_get_time_unit_items( + bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) +{ + UnitSettings *units = ptr->data; + return get_unit_enum_items(units->system, B_UNIT_TIME, r_free); +} + +static void rna_unit_system_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +{ + UnitSettings *unit = &scene->unit; + if (unit->system == USER_UNIT_NONE) { + unit->length_unit = USER_UNIT_ADAPTIVE; + unit->mass_unit = USER_UNIT_ADAPTIVE; + } + else { + unit->length_unit = bUnit_GetBaseUnitOfType(unit->system, B_UNIT_LENGTH); + unit->mass_unit = bUnit_GetBaseUnitOfType(unit->system, B_UNIT_MASS); + } } #else @@ -2236,205 +2157,6 @@ static void rna_def_gpencil_interpolate(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); } -/* Grease Pencil Drawing Brushes */ -static void rna_def_gpencil_brush(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GPencilBrush", NULL); - RNA_def_struct_sdna(srna, "bGPDbrush"); - RNA_def_struct_ui_text(srna, "Grease Pencil Brush", - "Collection of brushes being used to control the line style of new strokes"); - RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA); - - /* Name */ - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "info"); - RNA_def_property_ui_text(prop, "Name", "Brush name"); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilBrush_name_set"); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Line Thickness */ - prop = RNA_def_property(srna, "line_width", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "thickness"); - RNA_def_property_range(prop, 1, 300); - RNA_def_property_ui_range(prop, 1, 10, 1, 0); - RNA_def_property_ui_text(prop, "Thickness", "Thickness of strokes (in pixels)"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Sensitivity factor for new strokes */ - prop = RNA_def_property(srna, "pen_sensitivity_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "draw_sensitivity"); - RNA_def_property_range(prop, 0.1f, 3.0f); - RNA_def_property_ui_text(prop, "Sensitivity", "Pressure sensitivity factor for new strokes"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Strength factor for new strokes */ - prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "draw_strength"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Strength", "Color strength for new strokes (affect alpha factor of color)"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Jitter factor for new strokes */ - prop = RNA_def_property(srna, "jitter", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "draw_jitter"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Jitter", "Jitter factor for new strokes"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Randomnes factor for sensitivity and strength */ - prop = RNA_def_property(srna, "random_press", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "draw_random_press"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Randomness", "Randomness factor for pressure and strength in new strokes"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Randomnes factor for subdivision */ - prop = RNA_def_property(srna, "random_subdiv", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "draw_random_sub"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Random Subdivision", "Randomness factor for new strokes after subdivision"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Angle when brush is full size */ - prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "draw_angle"); - RNA_def_property_range(prop, -M_PI_2, M_PI_2); - RNA_def_property_ui_text(prop, "Angle", - "Direction of the stroke at which brush gives maximal thickness " - "(0° for horizontal)"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Factor to change brush size depending of angle */ - prop = RNA_def_property(srna, "angle_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "draw_angle_factor"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Angle Factor", - "Reduce brush thickness by this factor when stroke is perpendicular to 'Angle' direction"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Smoothing factor for new strokes */ - prop = RNA_def_property(srna, "pen_smooth_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "draw_smoothfac"); - RNA_def_property_range(prop, 0.0, 2.0f); - RNA_def_property_ui_text(prop, "Smooth", - "Amount of smoothing to apply to newly created strokes, to reduce jitter/noise"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Iterations of the Smoothing factor */ - prop = RNA_def_property(srna, "pen_smooth_steps", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "draw_smoothlvl"); - RNA_def_property_range(prop, 1, 3); - RNA_def_property_ui_text(prop, "Iterations", - "Number of times to smooth newly created strokes"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Subdivision level for new strokes */ - prop = RNA_def_property(srna, "pen_subdivision_steps", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "sublevel"); - RNA_def_property_range(prop, 0, 3); - RNA_def_property_ui_text(prop, "Subdivision Steps", - "Number of times to subdivide newly created strokes, for less jagged strokes"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Curves for pressure */ - prop = RNA_def_property(srna, "curve_sensitivity", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "cur_sensitivity"); - RNA_def_property_struct_type(prop, "CurveMapping"); - RNA_def_property_ui_text(prop, "Curve Sensitivity", "Curve used for the sensitivity"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - prop = RNA_def_property(srna, "curve_strength", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "cur_strength"); - RNA_def_property_struct_type(prop, "CurveMapping"); - RNA_def_property_ui_text(prop, "Curve Strength", "Curve used for the strength"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - prop = RNA_def_property(srna, "curve_jitter", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "cur_jitter"); - RNA_def_property_struct_type(prop, "CurveMapping"); - RNA_def_property_ui_text(prop, "Curve Jitter", "Curve used for the jitter effect"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - /* Flags */ - prop = RNA_def_property(srna, "use_pressure", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_PRESSURE); - RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); - RNA_def_property_ui_text(prop, "Use Pressure", "Use tablet pressure"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - prop = RNA_def_property(srna, "use_strength_pressure", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_STENGTH_PRESSURE); - RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); - RNA_def_property_ui_text(prop, "Use Pressure Strength", "Use tablet pressure for color strength"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - prop = RNA_def_property(srna, "use_jitter_pressure", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_JITTER_PRESSURE); - RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); - RNA_def_property_ui_text(prop, "Use Pressure Jitter", "Use tablet pressure for jitter"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - prop = RNA_def_property(srna, "use_random_pressure", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_RANDOM_PRESSURE); - RNA_def_property_ui_icon(prop, ICON_PARTICLES, 0); - RNA_def_property_ui_text(prop, "Random Pressure", "Use random value for pressure"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - - prop = RNA_def_property(srna, "use_random_strength", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_RANDOM_STRENGTH); - RNA_def_property_ui_icon(prop, ICON_PARTICLES, 0); - RNA_def_property_ui_text(prop, "Random Strength", "Use random value for strength"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - -} - -/* Grease Pencil Drawing Brushes API */ -static void rna_def_gpencil_brushes(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - PropertyRNA *prop; - - FunctionRNA *func; - PropertyRNA *parm; - - RNA_def_property_srna(cprop, "GreasePencilBrushes"); - srna = RNA_def_struct(brna, "GreasePencilBrushes", NULL); - RNA_def_struct_sdna(srna, "ToolSettings"); - RNA_def_struct_ui_text(srna, "Grease Pencil Brushes", "Collection of grease pencil brushes"); - - func = RNA_def_function(srna, "new", "rna_GPencil_brush_new"); - RNA_def_function_ui_description(func, "Add a new grease pencil brush"); - parm = RNA_def_string(func, "name", "GPencilBrush", MAX_NAME, "Name", "Name of the brush"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_boolean(func, "set_active", 0, "Set Active", "Set the newly created brush to the active brush"); - parm = RNA_def_pointer(func, "palette", "GPencilBrush", "", "The newly created brush"); - RNA_def_function_return(func, parm); - - func = RNA_def_function(srna, "remove", "rna_GPencil_brush_remove"); - RNA_def_function_ui_description(func, "Remove a grease pencil brush"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "brush", "GPencilBrush", "", "The brush to remove"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); - RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); - - prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "GPencilBrush"); - RNA_def_property_pointer_funcs(prop, "rna_GPencilBrushes_active_get", "rna_GPencilBrushes_active_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Active Brush", "Current active brush"); - - prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, - "rna_GPencilBrushes_index_get", - "rna_GPencilBrushes_index_set", - "rna_GPencilBrushes_index_range"); - RNA_def_property_ui_text(prop, "Active Brush Index", "Index of active brush"); -} - static void rna_def_transform_orientation(BlenderRNA *brna) { StructRNA *srna; @@ -2458,14 +2180,6 @@ static void rna_def_tool_settings(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem uv_select_mode_items[] = { - {UV_SELECT_VERTEX, "VERTEX", ICON_UV_VERTEXSEL, "Vertex", "Vertex selection mode"}, - {UV_SELECT_EDGE, "EDGE", ICON_UV_EDGESEL, "Edge", "Edge selection mode"}, - {UV_SELECT_FACE, "FACE", ICON_UV_FACESEL, "Face", "Face selection mode"}, - {UV_SELECT_ISLAND, "ISLAND", ICON_UV_ISLANDSEL, "Island", "Island selection mode"}, - {0, NULL, 0, NULL, NULL} - }; - /* the construction of this enum is quite special - everything is stored as bitflags, * with 1st position only for for on/off (and exposed as boolean), while others are mutually * exclusive options but which will only have any effect when autokey is enabled @@ -2476,22 +2190,6 @@ static void rna_def_tool_settings(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem retarget_roll_items[] = { - {SK_RETARGET_ROLL_NONE, "NONE", 0, "None", "Don't adjust roll"}, - {SK_RETARGET_ROLL_VIEW, "VIEW", 0, "View", "Roll bones to face the view"}, - {SK_RETARGET_ROLL_JOINT, "JOINT", 0, "Joint", "Roll bone to original joint plane offset"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem sketch_convert_items[] = { - {SK_CONVERT_CUT_FIXED, "FIXED", 0, "Fixed", "Subdivide stroke in fixed number of bones"}, - {SK_CONVERT_CUT_LENGTH, "LENGTH", 0, "Length", "Subdivide stroke in bones of specific length"}, - {SK_CONVERT_CUT_ADAPTATIVE, "ADAPTIVE", 0, "Adaptive", - "Subdivide stroke adaptively, with more subdivision in curvier parts"}, - {SK_CONVERT_RETARGET, "RETARGET", 0, "Retarget", "Retarget template bone chain to stroke"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem edge_tag_items[] = { {EDGE_MODE_SELECT, "SELECT", 0, "Select", ""}, {EDGE_MODE_TAG_SEAM, "SEAM", 0, "Tag Seam", ""}, @@ -2502,6 +2200,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem mod_weighted_strength[] = { + {FACE_STRENGTH_WEAK, "Weak", 0, "Weak", ""}, + {FACE_STRENGTH_MEDIUM, "Medium", 0, "Medium", ""}, + {FACE_STRENGTH_STRONG, "Strong", 0, "Strong", ""}, + {0, NULL, 0, NULL, NULL}, + }; + static const EnumPropertyItem draw_groupuser_items[] = { {OB_DRAW_GROUPUSER_NONE, "NONE", 0, "None", ""}, {OB_DRAW_GROUPUSER_ACTIVE, "ACTIVE", 0, "Active", "Show vertices with no weights in the active group"}, @@ -2516,21 +2221,34 @@ static void rna_def_tool_settings(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem gpencil_source_3d_items[] = { - {GP_TOOL_SOURCE_SCENE, "SCENE", 0, "Scene", - "Grease Pencil data attached to the current scene is used, " - "unless the active object already has Grease Pencil data (i.e. for old files)"}, - {GP_TOOL_SOURCE_OBJECT, "OBJECT", 0, "Object", - "Grease Pencil data-blocks attached to the active object are used " - "(required when using pre 2.73 add-ons, e.g. BSurfaces)"}, + static const EnumPropertyItem gpencil_stroke_placement_items[] = { + {GP_PROJECT_VIEWSPACE, "ORIGIN", ICON_OBJECT_ORIGIN, "Origin", "Draw stroke at Object origin"}, + {GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR, "CURSOR", ICON_PIVOT_CURSOR, "3D Cursor", "Draw stroke at 3D cursor location" }, + {GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_VIEW, "SURFACE", ICON_SNAP_FACE, "Surface", "Stick stroke to surfaces"}, + {GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_STROKE, "STROKE", ICON_GP_STROKE, "Stroke", "Stick stroke to other strokes"}, {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem gpencil_stroke_placement_items[] = { - {GP_PROJECT_VIEWSPACE, "CURSOR", 0, "Cursor", "Draw stroke at the 3D cursor"}, - {0, "VIEW", 0, "View", "Stick stroke to the view "}, /* weird, GP_PROJECT_VIEWALIGN is inverted */ - {GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_VIEW, "SURFACE", 0, "Surface", "Stick stroke to surfaces"}, - {GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_STROKE, "STROKE", 0, "Stroke", "Stick stroke to other strokes"}, + static const EnumPropertyItem gpencil_stroke_snap_items[] = { + {0, "NONE", 0, "All points", "No snap"}, + {GP_PROJECT_DEPTH_STROKE_ENDPOINTS, "ENDS", 0, "End points", "Snap to first and last points and interpolate" }, + {GP_PROJECT_DEPTH_STROKE_FIRST, "FIRST", 0, "First point", "Snap to first point" }, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem gpencil_selectmode_items[] = { + {GP_SELECTMODE_POINT, "POINT", ICON_GP_SELECT_POINTS, "Point", "Select only points"}, + {GP_SELECTMODE_STROKE, "STROKE", ICON_GP_SELECT_STROKES, "Stroke", "Select all stroke points" }, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem annotation_stroke_placement_items[] = { + {GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR, "CURSOR", ICON_PIVOT_CURSOR, "3D Cursor", "Draw stroke at 3D cursor location" }, + {0, "VIEW", ICON_VISIBLE_IPO_ON, "View", "Stick stroke to the view "}, /* weird, GP_PROJECT_VIEWALIGN is inverted */ + {GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_VIEW, "SURFACE", ICON_FACESEL, "Surface", "Stick stroke to surfaces"}, + /* Stroke option is disabled because is not working as expected and maybe is not + * required. If we confirm this is not used, we can remove it. */ + //{GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_STROKE, "STROKE", ICON_GREASEPENCIL, "Stroke", "Stick stroke to other strokes"}, {0, NULL, 0, NULL, NULL} }; @@ -2544,6 +2262,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Sculpt", ""); prop = RNA_def_property(srna, "use_auto_normalize", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_boolean_sdna(prop, NULL, "auto_normalize", 1); RNA_def_property_ui_text(prop, "WPaint Auto-Normalize", "Ensure all bone-deforming vertex groups add up " @@ -2551,6 +2270,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Scene_update_active_object_data"); prop = RNA_def_property(srna, "use_multipaint", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_boolean_sdna(prop, NULL, "multipaint", 1); RNA_def_property_ui_text(prop, "WPaint Multi-Paint", "Paint across the weights of all selected bones, " @@ -2558,19 +2278,22 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Scene_update_active_object_data"); prop = RNA_def_property(srna, "vertex_group_user", PROP_ENUM, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_enum_sdna(prop, NULL, "weightuser"); RNA_def_property_enum_items(prop, draw_groupuser_items); RNA_def_property_ui_text(prop, "Mask Non-Group Vertices", "Display unweighted vertices"); RNA_def_property_update(prop, 0, "rna_Scene_update_active_object_data"); prop = RNA_def_property(srna, "vertex_group_subset", PROP_ENUM, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_enum_sdna(prop, NULL, "vgroupsubset"); RNA_def_property_enum_items(prop, vertex_group_select_items); RNA_def_property_ui_text(prop, "Subset", "Filter Vertex groups for Display"); RNA_def_property_update(prop, 0, "rna_Scene_update_active_object_data"); prop = RNA_def_property(srna, "vertex_paint", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "vpaint"); RNA_def_property_ui_text(prop, "Vertex Paint", ""); + RNA_def_property_pointer_sdna(prop, NULL, "vpaint"); + RNA_def_property_ui_text(prop, "Vertex Paint", ""); prop = RNA_def_property(srna, "weight_paint", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "wpaint"); @@ -2584,6 +2307,10 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "uvsculpt"); RNA_def_property_ui_text(prop, "UV Sculpt", ""); + prop = RNA_def_property(srna, "gpencil_paint", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "gp_paint"); + RNA_def_property_ui_text(prop, "Grease Pencil Paint", ""); + prop = RNA_def_property(srna, "particle_edit", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "particle"); RNA_def_property_ui_text(prop, "Particle Edit", ""); @@ -2612,6 +2339,11 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, uv_sculpt_relaxation_items); RNA_def_property_ui_text(prop, "Relaxation Method", "Algorithm used for UV relaxation"); + prop = RNA_def_property(srna, "lock_object_mode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "object_flag", SCE_OBJECT_MODE_LOCK); + RNA_def_property_ui_text(prop, "Lock Object Modes", "Restrict select to the current mode"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + /* Transform */ prop = RNA_def_property(srna, "proportional_edit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "proportional"); @@ -2659,19 +2391,25 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Proportional Size", "Display size for proportional editing circle"); RNA_def_property_range(prop, 0.00001, 5000.0); - prop = RNA_def_property(srna, "normal_size", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "normalsize"); - RNA_def_property_ui_text(prop, "Normal Size", "Display size for normals in the 3D view"); - RNA_def_property_range(prop, 0.00001, 1000.0); - RNA_def_property_ui_range(prop, 0.01, 10.0, 10.0, 2); - RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL); - prop = RNA_def_property(srna, "double_threshold", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "doublimit"); RNA_def_property_ui_text(prop, "Double Threshold", "Limit for removing duplicates and 'Auto Merge'"); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_range(prop, 0.0, 0.1, 0.01, 6); + /* Pivot Point */ + prop = RNA_def_property(srna, "transform_pivot_point", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "transform_pivot_point"); + RNA_def_property_enum_items(prop, rna_enum_transform_pivot_items_full); + RNA_def_property_ui_text(prop, "Pivot Point", "Pivot center for rotation/scaling"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_transform_pivot_point_align", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "transform_flag", SCE_XFORM_AXIS_ALIGN); + RNA_def_property_ui_text(prop, "Align", "Manipulate center points (object, pose and weight paint mode only)"); + RNA_def_property_ui_icon(prop, ICON_CENTER_ONLY, 0); + RNA_def_property_update(prop, NC_SCENE, NULL); + prop = RNA_def_property(srna, "use_mesh_automerge", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "automerge", 0); RNA_def_property_ui_text(prop, "AutoMerge Editing", "Automatically merge vertices moved to the same location"); @@ -2685,33 +2423,33 @@ static void rna_def_tool_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "use_snap_align_rotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_ROTATE); - RNA_def_property_ui_text(prop, "Snap Align Rotation", "Align rotation with the snapping target"); - RNA_def_property_ui_icon(prop, ICON_SNAP_NORMAL, 0); + RNA_def_property_ui_text(prop, "Align Rotation to Target", "Align rotation with the snapping target"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "use_snap_grid_absolute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_ABS_GRID); RNA_def_property_ui_text(prop, "Absolute Grid Snap", "Absolute grid alignment while translating (based on the pivot center)"); - RNA_def_property_ui_icon(prop, ICON_SNAP_GRID, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ - prop = RNA_def_property(srna, "snap_element", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "snap_mode"); + prop = RNA_def_property(srna, "snap_elements", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_mode"); RNA_def_property_enum_items(prop, rna_enum_snap_element_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_ToolSettings_snap_mode_set", NULL); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); RNA_def_property_ui_text(prop, "Snap Element", "Type of element to snap to"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ /* node editor uses own set of snap modes */ prop = RNA_def_property(srna, "snap_node_element", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "snap_node_mode"); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_node_mode"); RNA_def_property_enum_items(prop, rna_enum_snap_node_element_items); RNA_def_property_ui_text(prop, "Snap Node Element", "Type of element to snap to"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ /* image editor uses own set of snap modes */ prop = RNA_def_property(srna, "snap_uv_element", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "snap_uv_mode"); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_uv_mode"); RNA_def_property_enum_items(prop, snap_uv_element_items); RNA_def_property_ui_text(prop, "Snap UV Element", "Type of element to snap to"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ @@ -2725,29 +2463,27 @@ static void rna_def_tool_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "use_snap_peel_object", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PEEL_OBJECT); RNA_def_property_ui_text(prop, "Snap Peel Object", "Consider objects as whole when finding volume center"); - RNA_def_property_ui_icon(prop, ICON_SNAP_PEEL_OBJECT, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "use_snap_project", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PROJECT); RNA_def_property_ui_text(prop, "Project Individual Elements", "Project individual elements on the surface of other objects"); - RNA_def_property_ui_icon(prop, ICON_RETOPO, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "use_snap_self", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_flag", SCE_SNAP_NO_SELF); - RNA_def_property_ui_text(prop, "Project to Self", "Snap onto itself (editmode)"); - RNA_def_property_ui_icon(prop, ICON_ORTHO, 0); + RNA_def_property_ui_text(prop, "Project onto Self", "Snap onto itself (Edit Mode Only)"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ - /* Grease Pencil */ - prop = RNA_def_property(srna, "use_gpencil_continuous_drawing", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_PAINTSESSIONS_ON); - RNA_def_property_ui_text(prop, "Use Continuous Drawing", - "Allow drawing multiple strokes at a time with Grease Pencil"); - RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* xxx: need toolbar to be redrawn... */ + prop = RNA_def_property(srna, "use_gizmo_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "gizmo_flag"); + RNA_def_property_enum_items(prop, rna_enum_gizmo_items); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Gizmo Mode", ""); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ToolSettings_gizmo_flag_update"); + /* Grease Pencil */ prop = RNA_def_property(srna, "use_gpencil_additive_drawing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_RETAIN_LAST); RNA_def_property_ui_text(prop, "Use Additive Drawing", @@ -2761,12 +2497,18 @@ static void rna_def_tool_settings(BlenderRNA *brna) "When draw new strokes, the new stroke is drawn below of all strokes in the layer"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "grease_pencil_source", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_src"); - RNA_def_property_enum_items(prop, gpencil_source_3d_items); - RNA_def_property_ui_text(prop, "Grease Pencil Source", - "Data-block where active Grease Pencil data is found from"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + prop = RNA_def_property(srna, "use_gpencil_thumbnail_list", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_THUMBNAIL_LIST); + RNA_def_property_ui_text(prop, "Compact List", + "Show compact list of color instead of thumbnails"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_gpencil_weight_data_add", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_CREATE_WEIGHTS); + RNA_def_property_ui_text(prop, "Add weight data for new strokes", + "When creating new strokes, the weight data is added according to the current vertex group and weight, " + "if no vertex group selected, weight is not added"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "gpencil_sculpt", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "gp_sculpt"); @@ -2780,13 +2522,6 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Grease Pencil Interpolate", "Settings for Grease Pencil Interpolation tools"); - /* Grease Pencil - Drawing brushes */ - prop = RNA_def_property(srna, "gpencil_brushes", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "gp_brushes", NULL); - RNA_def_property_struct_type(prop, "GPencilBrush"); - RNA_def_property_ui_text(prop, "Grease Pencil Brushes", "Grease Pencil drawing brushes"); - rna_def_gpencil_brushes(brna, prop); - /* Grease Pencil - 3D View Stroke Placement */ prop = RNA_def_property(srna, "gpencil_stroke_placement_view3d", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_v3d_align"); @@ -2794,32 +2529,59 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Stroke Placement (3D View)", ""); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + prop = RNA_def_property(srna, "gpencil_stroke_snap_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_v3d_align"); + RNA_def_property_enum_items(prop, gpencil_stroke_snap_items); + RNA_def_property_ui_text(prop, "Stroke Snap", ""); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + prop = RNA_def_property(srna, "use_gpencil_stroke_endpoints", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gpencil_v3d_align", GP_PROJECT_DEPTH_STROKE_ENDPOINTS); RNA_def_property_ui_text(prop, "Only Endpoints", "Only use the first and last parts of the stroke for snapping"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - /* Grease Pencil - 2D Views Stroke Placement */ - prop = RNA_def_property(srna, "gpencil_stroke_placement_view2d", PROP_ENUM, PROP_NONE); + /* Grease Pencil - Select mode */ + prop = RNA_def_property(srna, "gpencil_selectmode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "gpencil_selectmode"); + RNA_def_property_enum_items(prop, gpencil_selectmode_items); + RNA_def_property_ui_text(prop, "Select Mode", ""); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + /* Annotations - 2D Views Stroke Placement */ + prop = RNA_def_property(srna, "annotation_stroke_placement_view2d", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_v2d_align"); - RNA_def_property_enum_items(prop, gpencil_stroke_placement_items); + RNA_def_property_enum_items(prop, annotation_stroke_placement_items); RNA_def_property_ui_text(prop, "Stroke Placement (2D View)", ""); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - /* Grease Pencil - Sequencer Preview Stroke Placement */ - prop = RNA_def_property(srna, "gpencil_stroke_placement_sequencer_preview", PROP_ENUM, PROP_NONE); + /* Annotations - Sequencer Preview Stroke Placement */ + prop = RNA_def_property(srna, "annotation_stroke_placement_sequencer_preview", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_seq_align"); - RNA_def_property_enum_items(prop, gpencil_stroke_placement_items); + RNA_def_property_enum_items(prop, annotation_stroke_placement_items); RNA_def_property_ui_text(prop, "Stroke Placement (Sequencer Preview)", ""); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - /* Grease Pencil - Image Editor Stroke Placement */ - prop = RNA_def_property(srna, "gpencil_stroke_placement_image_editor", PROP_ENUM, PROP_NONE); + /* Annotations - Image Editor Stroke Placement */ + prop = RNA_def_property(srna, "annotation_stroke_placement_image_editor", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_ima_align"); - RNA_def_property_enum_items(prop, gpencil_stroke_placement_items); + RNA_def_property_enum_items(prop, annotation_stroke_placement_items); RNA_def_property_ui_text(prop, "Stroke Placement (Image Editor)", ""); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + /* Annotations - 3D View Stroke Placement */ + /* XXX: Do we need to decouple the stroke_endpoints setting too? */ + prop = RNA_def_property(srna, "annotation_stroke_placement_view3d", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "annotate_v3d_align"); + RNA_def_property_enum_items(prop, annotation_stroke_placement_items); + RNA_def_property_ui_text(prop, "Annotation Stroke Placement (3D View)", "How annotation strokes are orientated in 3D space"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + + /* Annotations - Stroke Thickness */ + prop = RNA_def_property(srna, "annotation_thickness", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "annotate_thickness"); + RNA_def_property_range(prop, 1, 10); + RNA_def_property_ui_text(prop, "Annotation Stroke Thickness", "Thickness of annotation strokes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* Auto Keying */ prop = RNA_def_property(srna, "use_keyframe_insert_auto", PROP_BOOLEAN, PROP_NONE); @@ -2844,6 +2606,12 @@ static void rna_def_tool_settings(BlenderRNA *brna) "Automatic keyframe insertion using active Keying Set only"); RNA_def_property_ui_icon(prop, ICON_KEYINGSET, 0); + prop = RNA_def_property(srna, "use_keyframe_cycle_aware", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_CYCLEAWARE); + RNA_def_property_ui_text(prop, "Cycle-Aware Keying", + "For channels with cyclic extrapolation, keyframe insertion is automatically " + "remapped inside the cycle time range, and keeps ends in sync"); + /* Keyframing */ prop = RNA_def_property(srna, "keyframe_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "keyframe_type"); @@ -2853,19 +2621,19 @@ static void rna_def_tool_settings(BlenderRNA *brna) /* UV */ prop = RNA_def_property(srna, "uv_select_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "uv_selectmode"); - RNA_def_property_enum_items(prop, uv_select_mode_items); + RNA_def_property_enum_items(prop, rna_enum_mesh_select_mode_uv_items); RNA_def_property_ui_text(prop, "UV Selection Mode", "UV selection and display mode"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "use_uv_select_sync", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uv_flag", UV_SYNC_SELECTION); RNA_def_property_ui_text(prop, "UV Sync Selection", "Keep UV and edit mode mesh selection in sync"); - RNA_def_property_ui_icon(prop, ICON_EDIT, 0); + RNA_def_property_ui_icon(prop, ICON_UV_SYNC_SELECT, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "show_uv_local_view", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uv_flag", UV_SHOW_SAME_IMAGE); - RNA_def_property_ui_text(prop, "UV Local View", "Draw only faces with the currently displayed image assigned"); + RNA_def_property_ui_text(prop, "UV Local View", "Display only faces with the currently displayed image assigned"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); /* Mesh */ @@ -2874,6 +2642,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_editmesh_select_mode_set"); RNA_def_property_ui_text(prop, "Mesh Selection Mode", "Which mesh elements selection works on"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_Scene_editmesh_select_mode_update"); prop = RNA_def_property(srna, "vertex_group_weight", PROP_FLOAT, PROP_FACTOR); @@ -2890,71 +2659,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "edge_mode_live_unwrap", 1); RNA_def_property_ui_text(prop, "Live Unwrap", "Changing edges seam re-calculates UV unwrap"); - /* etch-a-ton */ - prop = RNA_def_property(srna, "use_bone_sketching", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bone_sketching", BONE_SKETCHING); - RNA_def_property_ui_text(prop, "Use Bone Sketching", "Use sketching to create and edit bones"); -/* RNA_def_property_ui_icon(prop, ICON_EDIT, 0); */ - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "use_etch_quick", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bone_sketching", BONE_SKETCHING_QUICK); - RNA_def_property_ui_text(prop, "Quick Sketching", "Automatically convert and delete on stroke end"); - - prop = RNA_def_property(srna, "use_etch_overdraw", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bone_sketching", BONE_SKETCHING_ADJUST); - RNA_def_property_ui_text(prop, "Overdraw Sketching", "Adjust strokes by drawing near them"); - - prop = RNA_def_property(srna, "use_etch_autoname", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "skgen_retarget_options", SK_RETARGET_AUTONAME); - RNA_def_property_ui_text(prop, "Autoname Bones", - "Automatically generate values to replace &N and &S suffix placeholders in template names"); - - prop = RNA_def_property(srna, "etch_number", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "skgen_num_string"); - RNA_def_property_ui_text(prop, "Number", "Text to replace &N with (e.g. 'Finger.&N' -> 'Finger.1' or 'Finger.One')"); - - prop = RNA_def_property(srna, "etch_side", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "skgen_num_string"); - RNA_def_property_ui_text(prop, "Side", "Text to replace &S with (e.g. 'Arm.&S' -> 'Arm.R' or 'Arm.Right')"); - - prop = RNA_def_property(srna, "etch_template", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "skgen_template"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_funcs(prop, NULL, "rna_Scene_skgen_etch_template_set", NULL, NULL); - RNA_def_property_ui_text(prop, "Template", "Template armature that will be retargeted to the stroke"); - - prop = RNA_def_property(srna, "etch_subdivision_number", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "skgen_subdivision_number"); - RNA_def_property_range(prop, 1, 255); - RNA_def_property_ui_text(prop, "Subdivisions", "Number of bones in the subdivided stroke"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "etch_adaptive_limit", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "skgen_correlation_limit"); - RNA_def_property_range(prop, 0.00001, 1.0); - RNA_def_property_ui_range(prop, 0.01, 1.0, 0.01, 2); - RNA_def_property_ui_text(prop, "Limit", "Correlation threshold for number of bones in the subdivided stroke"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "etch_length_limit", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "skgen_length_limit"); - RNA_def_property_range(prop, 0.00001, 100000.0); - RNA_def_property_ui_range(prop, 0.001, 100.0, 0.1, 3); - RNA_def_property_ui_text(prop, "Length", "Maximum length of the subdivided bones"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "normal_vector", PROP_FLOAT, PROP_XYZ); + RNA_def_property_ui_text(prop, "Normal Vector", "Normal Vector used to copy, add or multiply"); + RNA_def_property_ui_range(prop, -10000.0, 10000.0, 1, 3); - prop = RNA_def_property(srna, "etch_roll_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "skgen_retarget_roll"); - RNA_def_property_enum_items(prop, retarget_roll_items); - RNA_def_property_ui_text(prop, "Retarget roll mode", "Method used to adjust the roll of bones when retargeting"); - - prop = RNA_def_property(srna, "etch_convert_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "bone_sketching_convert"); - RNA_def_property_enum_items(prop, sketch_convert_items); - RNA_def_property_ui_text(prop, "Stroke conversion method", "Method used to convert stroke to bones"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "face_strength", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, mod_weighted_strength); + RNA_def_property_ui_text(prop, "Face Strength", "Set strength of face to specified value"); /* Unified Paint Settings */ prop = RNA_def_property(srna, "unified_paint_settings", PROP_POINTER, PROP_NONE); @@ -3009,6 +2720,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) * from the active brush */ prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL); RNA_def_property_int_funcs(prop, NULL, "rna_UnifiedPaintSettings_size_set", NULL); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10); RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, -1); RNA_def_property_ui_text(prop, "Radius", "Radius of the brush"); @@ -3016,6 +2728,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_funcs(prop, NULL, "rna_UnifiedPaintSettings_unprojected_radius_set", NULL); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_range(prop, 0.001, FLT_MAX); RNA_def_property_ui_range(prop, 0.001, 1, 0, -1); RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units"); @@ -3023,6 +2736,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "alpha"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_float_default(prop, 0.5f); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3); @@ -3031,6 +2745,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "weight"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_float_default(prop, 0.5f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3); @@ -3038,12 +2753,14 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update"); prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_float_sdna(prop, NULL, "rgb"); RNA_def_property_ui_text(prop, "Color", ""); RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update"); prop = RNA_def_property(srna, "secondary_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_float_sdna(prop, NULL, "secondary_rgb"); RNA_def_property_ui_text(prop, "Secondary Color", ""); @@ -3154,9 +2871,9 @@ static void rna_def_curve_paint_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Depth", "Method of projecting depth"); static const EnumPropertyItem surface_plane_items[] = { - {CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW, "NORMAL_VIEW", 0, "Normal/View", "Draw perpendicular to the surface"}, - {CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE, "NORMAL_SURFACE", 0, "Normal/Surface", "Draw aligned to the surface"}, - {CURVE_PAINT_SURFACE_PLANE_VIEW, "VIEW", 0, "View", "Draw aligned to the viewport"}, + {CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW, "NORMAL_VIEW", 0, "Normal/View", "Display perpendicular to the surface"}, + {CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE, "NORMAL_SURFACE", 0, "Normal/Surface", "Display aligned to the surface"}, + {CURVE_PAINT_SURFACE_PLANE_VIEW, "VIEW", 0, "View", "Display aligned to the viewport"}, {0, NULL, 0, NULL, NULL}}; prop = RNA_def_property(srna, "surface_plane", PROP_ENUM, PROP_NONE); @@ -3185,6 +2902,7 @@ static void rna_def_statvis(BlenderRNA *brna) prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, stat_type); RNA_def_property_ui_text(prop, "Type", "Type of data to visualize/check"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); @@ -3195,6 +2913,7 @@ static void rna_def_statvis(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f)); RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 0.001, 3); RNA_def_property_ui_text(prop, "Overhang Min", "Minimum angle to display"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); prop = RNA_def_property(srna, "overhang_max", PROP_FLOAT, PROP_ANGLE); @@ -3203,12 +2922,14 @@ static void rna_def_statvis(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f)); RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 10, 3); RNA_def_property_ui_text(prop, "Overhang Max", "Maximum angle to display"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); prop = RNA_def_property(srna, "overhang_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "overhang_axis"); RNA_def_property_enum_items(prop, rna_enum_object_axis_items); RNA_def_property_ui_text(prop, "Axis", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); @@ -3219,6 +2940,7 @@ static void rna_def_statvis(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1000.0); RNA_def_property_ui_range(prop, 0.0f, 100.0, 0.001, 3); RNA_def_property_ui_text(prop, "Thickness Min", "Minimum for measuring thickness"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); prop = RNA_def_property(srna, "thickness_max", PROP_FLOAT, PROP_DISTANCE); @@ -3227,12 +2949,14 @@ static void rna_def_statvis(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1000.0); RNA_def_property_ui_range(prop, 0.0f, 100.0, 0.001, 3); RNA_def_property_ui_text(prop, "Thickness Max", "Maximum for measuring thickness"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); prop = RNA_def_property(srna, "thickness_samples", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "thickness_samples"); RNA_def_property_range(prop, 1, 32); RNA_def_property_ui_text(prop, "Samples", "Number of samples to test per face"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); /* distort */ @@ -3242,6 +2966,7 @@ static void rna_def_statvis(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f)); RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 10, 3); RNA_def_property_ui_text(prop, "Distort Min", "Minimum angle to display"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); prop = RNA_def_property(srna, "distort_max", PROP_FLOAT, PROP_ANGLE); @@ -3250,6 +2975,7 @@ static void rna_def_statvis(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f)); RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 10, 3); RNA_def_property_ui_text(prop, "Distort Max", "Maximum angle to display"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); /* sharp */ @@ -3259,6 +2985,7 @@ static void rna_def_statvis(BlenderRNA *brna) RNA_def_property_range(prop, -DEG2RADF(180.0f), DEG2RADF(180.0f)); RNA_def_property_ui_range(prop, -DEG2RADF(180.0f), DEG2RADF(180.0f), 10, 3); RNA_def_property_ui_text(prop, "Distort Min", "Minimum angle to display"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); prop = RNA_def_property(srna, "sharp_max", PROP_FLOAT, PROP_ANGLE); @@ -3267,10 +2994,11 @@ static void rna_def_statvis(BlenderRNA *brna) RNA_def_property_range(prop, -DEG2RADF(180.0f), DEG2RADF(180.0f)); RNA_def_property_ui_range(prop, -DEG2RADF(180.0f), DEG2RADF(180.0f), 10, 3); RNA_def_property_ui_text(prop, "Distort Max", "Maximum angle to display"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); } -static void rna_def_unit_settings(BlenderRNA *brna) +static void rna_def_unit_settings(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -3295,7 +3023,7 @@ static void rna_def_unit_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "system", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, unit_systems); RNA_def_property_ui_text(prop, "Unit System", "The unit system to use for button display"); - RNA_def_property_update(prop, NC_WINDOW, NULL); + RNA_def_property_update(prop, NC_WINDOW, "rna_unit_system_update"); prop = RNA_def_property(srna, "system_rotation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, rotation_units); @@ -3303,7 +3031,9 @@ static void rna_def_unit_settings(BlenderRNA *brna) RNA_def_property_update(prop, NC_WINDOW, NULL); prop = RNA_def_property(srna, "scale_length", PROP_FLOAT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Unit Scale", "Scale to use when converting between blender units and dimensions"); + RNA_def_property_ui_text(prop, "Unit Scale", "Scale to use when converting between blender units and dimensions." + " When working at microscopic or astronomical scale, a small or large unit scale" + " respectively can be used to avoid numerical precision problems"); RNA_def_property_range(prop, 0.00001, 100000.0); RNA_def_property_ui_range(prop, 0.001, 100.0, 0.1, 6); RNA_def_property_update(prop, NC_WINDOW, NULL); @@ -3312,69 +3042,39 @@ static void rna_def_unit_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_UNIT_OPT_SPLIT); RNA_def_property_ui_text(prop, "Separate Units", "Display units in pairs (e.g. 1m 0cm)"); RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop = RNA_def_property(srna, "length_unit", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_get_length_unit_items"); + RNA_def_property_ui_text(prop, "Length Unit", "Unit that will be used to display length values"); + RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop = RNA_def_property(srna, "mass_unit", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_get_mass_unit_items"); + RNA_def_property_ui_text(prop, "Mass Unit", "Unit that will be used to display mass values"); + RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop = RNA_def_property(srna, "time_unit", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_get_time_unit_items"); + RNA_def_property_ui_text(prop, "Time Unit", "Unit that will be used to display time values"); + RNA_def_property_update(prop, NC_WINDOW, NULL); } -void rna_def_render_layer_common(StructRNA *srna, int scene) +void rna_def_view_layer_common(StructRNA *srna, int scene) { PropertyRNA *prop; prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - if (scene) RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneRenderLayer_name_set"); + if (scene) RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ViewLayer_name_set"); else RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Name", "Render layer name"); + RNA_def_property_ui_text(prop, "Name", "View layer name"); RNA_def_struct_name_property(srna, prop); if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "material_override", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "mat_override"); - RNA_def_property_struct_type(prop, "Material"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Material Override", - "Material to override all other materials in this render layer"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "light_override", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "light_override"); - RNA_def_property_struct_type(prop, "Group"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Light Override", "Group to override all other lights in this render layer"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - /* layers */ - 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, "Visible Layers", "Scene layers included in this render layer"); - if (scene) RNA_def_property_boolean_funcs(prop, NULL, "rna_SceneRenderLayer_layer_set"); - else RNA_def_property_boolean_funcs(prop, NULL, "rna_RenderLayer_layer_set"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - /* this seems to be too much trouble with depsgraph updates/etc. currently (20140423) */ - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - - prop = RNA_def_property(srna, "layers_zmask", PROP_BOOLEAN, PROP_LAYER); - RNA_def_property_boolean_sdna(prop, NULL, "lay_zmask", 1); - RNA_def_property_array(prop, 20); - RNA_def_property_ui_text(prop, "Zmask Layers", "Zmask scene layers for solid faces"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "layers_exclude", PROP_BOOLEAN, PROP_LAYER); - RNA_def_property_boolean_sdna(prop, NULL, "lay_exclude", 1); - RNA_def_property_array(prop, 20); - RNA_def_property_ui_text(prop, "Exclude Layers", "Exclude scene layers from having any influence"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - if (scene) { - prop = RNA_def_property(srna, "samples", PROP_INT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Samples", "Override number of render samples for this render layer, " - "0 will use the scene setting"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "pass_alpha_threshold", PROP_FLOAT, PROP_FACTOR); RNA_def_property_ui_text(prop, "Alpha Threshold", "Z, Index, normal, UV and vector passes are only affected by surfaces with " @@ -3383,12 +3083,6 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) } /* layer options */ - prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "layflag", SCE_LAY_DISABLE); - RNA_def_property_ui_text(prop, "Enabled", "Disable or enable the render layer"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "use_zmask", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_ZMASK); RNA_def_property_ui_text(prop, "Zmask", "Only render what's in front of the solid z values"); @@ -3434,7 +3128,7 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) prop = RNA_def_property(srna, "use_ao", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_AO); - RNA_def_property_ui_text(prop, "AO", "Render AO in this Layer"); + RNA_def_property_ui_text(prop, "Ambient Occlusion", "Render Ambient Occlusion in this Layer"); if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -3450,247 +3144,161 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_FRS); - RNA_def_property_ui_text(prop, "Freestyle", "Render stylized strokes in this Layer"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_freestyle_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - /* passes */ prop = RNA_def_property(srna, "use_pass_combined", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_COMBINED); RNA_def_property_ui_text(prop, "Combined", "Deliver full combined RGBA buffer"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_Z); RNA_def_property_ui_text(prop, "Z", "Deliver Z values pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_vector", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_VECTOR); RNA_def_property_ui_text(prop, "Vector", "Deliver speed vector pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_normal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_NORMAL); RNA_def_property_ui_text(prop, "Normal", "Deliver normal pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_uv", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_UV); RNA_def_property_ui_text(prop, "UV", "Deliver texture UV pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_mist", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_MIST); RNA_def_property_ui_text(prop, "Mist", "Deliver mist factor pass (0.0-1.0)"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_object_index", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_INDEXOB); RNA_def_property_ui_text(prop, "Object Index", "Deliver object index pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_material_index", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_INDEXMA); RNA_def_property_ui_text(prop, "Material Index", "Deliver material index pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "use_pass_color", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_RGBA); - RNA_def_property_ui_text(prop, "Color", "Deliver shade-less color pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "use_pass_diffuse", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE); - RNA_def_property_ui_text(prop, "Diffuse", "Deliver diffuse pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_specular", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SPEC); RNA_def_property_ui_text(prop, "Specular", "Deliver specular pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_shadow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SHADOW); RNA_def_property_ui_text(prop, "Shadow", "Deliver shadow pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_ambient_occlusion", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_AO); - RNA_def_property_ui_text(prop, "AO", "Deliver AO pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "use_pass_reflection", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_REFLECT); - RNA_def_property_ui_text(prop, "Reflection", "Deliver raytraced reflection pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "use_pass_refraction", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_REFRACT); - RNA_def_property_ui_text(prop, "Refraction", "Deliver raytraced refraction pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + RNA_def_property_ui_text(prop, "Ambient Occlusion", "Deliver Ambient Occlusion pass"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_emit", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_EMIT); RNA_def_property_ui_text(prop, "Emit", "Deliver emission pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_environment", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_ENVIRONMENT); RNA_def_property_ui_text(prop, "Environment", "Deliver environment lighting pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_INDIRECT); RNA_def_property_ui_text(prop, "Indirect", "Deliver indirect lighting pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "exclude_specular", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_SPEC); - RNA_def_property_ui_text(prop, "Specular Exclude", "Exclude specular pass from combined"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "exclude_shadow", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_SHADOW); - RNA_def_property_ui_text(prop, "Shadow Exclude", "Exclude shadow pass from combined"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "exclude_ambient_occlusion", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_AO); - RNA_def_property_ui_text(prop, "AO Exclude", "Exclude AO pass from combined"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "exclude_reflection", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_REFLECT); - RNA_def_property_ui_text(prop, "Reflection Exclude", "Exclude raytraced reflection pass from combined"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "exclude_refraction", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_REFRACT); - RNA_def_property_ui_text(prop, "Refraction Exclude", "Exclude raytraced refraction pass from combined"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "exclude_emit", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_EMIT); - RNA_def_property_ui_text(prop, "Emit Exclude", "Exclude emission pass from combined"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "exclude_environment", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_ENVIRONMENT); - RNA_def_property_ui_text(prop, "Environment Exclude", "Exclude environment pass from combined"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "exclude_indirect", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_INDIRECT); - RNA_def_property_ui_text(prop, "Indirect Exclude", "Exclude indirect pass from combined"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_diffuse_direct", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_DIRECT); RNA_def_property_ui_text(prop, "Diffuse Direct", "Deliver diffuse direct pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_diffuse_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_INDIRECT); RNA_def_property_ui_text(prop, "Diffuse Indirect", "Deliver diffuse indirect pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_diffuse_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_COLOR); RNA_def_property_ui_text(prop, "Diffuse Color", "Deliver diffuse color pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_glossy_direct", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_DIRECT); RNA_def_property_ui_text(prop, "Glossy Direct", "Deliver glossy direct pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_glossy_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_INDIRECT); RNA_def_property_ui_text(prop, "Glossy Indirect", "Deliver glossy indirect pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_glossy_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_COLOR); RNA_def_property_ui_text(prop, "Glossy Color", "Deliver glossy color pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_transmission_direct", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_DIRECT); RNA_def_property_ui_text(prop, "Transmission Direct", "Deliver transmission direct pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_transmission_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_INDIRECT); RNA_def_property_ui_text(prop, "Transmission Indirect", "Deliver transmission indirect pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_transmission_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_COLOR); RNA_def_property_ui_text(prop, "Transmission Color", "Deliver transmission color pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_subsurface_direct", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SUBSURFACE_DIRECT); RNA_def_property_ui_text(prop, "Subsurface Direct", "Deliver subsurface direct pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_subsurface_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SUBSURFACE_INDIRECT); RNA_def_property_ui_text(prop, "Subsurface Indirect", "Deliver subsurface indirect pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_subsurface_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SUBSURFACE_COLOR); RNA_def_property_ui_text(prop, "Subsurface Color", "Deliver subsurface color pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); } @@ -3760,7 +3368,7 @@ static void rna_def_freestyle_linesets(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); } -static void rna_def_freestyle_settings(BlenderRNA *brna) +void rna_def_freestyle_settings(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -3885,16 +3493,16 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "group"); - RNA_def_property_struct_type(prop, "Group"); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Group", "A group of objects based on which feature edges are selected"); + RNA_def_property_ui_text(prop, "Collection", "A collection of objects based on which feature edges are selected"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_freestyle_update"); prop = RNA_def_property(srna, "group_negation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags"); RNA_def_property_enum_items(prop, group_negation_items); - RNA_def_property_ui_text(prop, "Group Negation", - "Specify either inclusion or exclusion of feature edges belonging to a group of objects"); + RNA_def_property_ui_text(prop, "Collection Negation", + "Specify either inclusion or exclusion of feature edges belonging to a collection of objects"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_freestyle_update"); prop = RNA_def_property(srna, "face_mark_negation", PROP_ENUM, PROP_NONE); @@ -4053,8 +3661,8 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) srna = RNA_def_struct(brna, "FreestyleSettings", NULL); RNA_def_struct_sdna(srna, "FreestyleConfig"); - RNA_def_struct_nested(brna, srna, "SceneRenderLayer"); - RNA_def_struct_ui_text(srna, "Freestyle Settings", "Freestyle settings for a SceneRenderLayer data-block"); + RNA_def_struct_nested(brna, srna, "ViewLayer"); + RNA_def_struct_ui_text(srna, "Freestyle Settings", "Freestyle settings for a ViewLayer data-block"); prop = RNA_def_property(srna, "modules", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "modules", NULL); @@ -4130,124 +3738,6 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) rna_def_freestyle_linesets(brna, prop); } -static void rna_def_scene_game_recast_data(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem rna_enum_partitioning_items[] = { - {RC_PARTITION_WATERSHED, "WATERSHED", 0, "Watershed", "Classic Recast partitioning method generating the nicest tessellation"}, - {RC_PARTITION_MONOTONE, "MONOTONE", 0, "Monotone", "Fastest navmesh generation method, may create long thin polygons"}, - {RC_PARTITION_LAYERS, "LAYERS", 0, "Layers", "Reasonably fast method that produces better triangles than monotone partitioning"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "SceneGameRecastData", NULL); - RNA_def_struct_sdna(srna, "RecastData"); - RNA_def_struct_nested(brna, srna, "Scene"); - RNA_def_struct_ui_text(srna, "Recast Data", "Recast data for a Game data-block"); - - prop = RNA_def_property(srna, "cell_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "cellsize"); - RNA_def_property_ui_range(prop, 0.1, 1, 1, 2); - RNA_def_property_float_default(prop, 0.3f); - RNA_def_property_ui_text(prop, "Cell Size", "Rasterized cell size"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "cell_height", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "cellheight"); - RNA_def_property_ui_range(prop, 0.1, 1, 1, 2); - RNA_def_property_float_default(prop, 0.2f); - RNA_def_property_ui_text(prop, "Cell Height", "Rasterized cell height"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "agent_height", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "agentheight"); - RNA_def_property_ui_range(prop, 0.1, 5, 1, 2); - RNA_def_property_float_default(prop, 2.0f); - RNA_def_property_ui_text(prop, "Agent Height", "Minimum height where the agent can still walk"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "agent_radius", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "agentradius"); - RNA_def_property_ui_range(prop, 0.1, 5, 1, 2); - RNA_def_property_float_default(prop, 0.6f); - RNA_def_property_ui_text(prop, "Agent Radius", "Radius of the agent"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "climb_max", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "agentmaxclimb"); - RNA_def_property_ui_range(prop, 0.1, 5, 1, 2); - RNA_def_property_float_default(prop, 0.9f); - RNA_def_property_ui_text(prop, "Max Climb", "Maximum height between grid cells the agent can climb"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "slope_max", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, NULL, "agentmaxslope"); - RNA_def_property_range(prop, 0, M_PI_2); - RNA_def_property_float_default(prop, M_PI_4); - RNA_def_property_ui_text(prop, "Max Slope", "Maximum walkable slope angle"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - - prop = RNA_def_property(srna, "region_min_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "regionminsize"); - RNA_def_property_ui_range(prop, 0, 150, 1, 2); - RNA_def_property_float_default(prop, 8.0f); - RNA_def_property_ui_text(prop, "Min Region Size", "Minimum regions size (smaller regions will be deleted)"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "region_merge_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "regionmergesize"); - RNA_def_property_ui_range(prop, 0, 150, 1, 2); - RNA_def_property_float_default(prop, 20.0f); - RNA_def_property_ui_text(prop, "Merged Region Size", "Minimum regions size (smaller regions will be merged)"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "partitioning", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "partitioning"); - RNA_def_property_enum_items(prop, rna_enum_partitioning_items); - RNA_def_property_enum_default(prop, RC_PARTITION_WATERSHED); - RNA_def_property_ui_text(prop, "Partitioning", "Choose partitioning method"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "edge_max_len", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "edgemaxlen"); - RNA_def_property_ui_range(prop, 0, 50, 1, 2); - RNA_def_property_float_default(prop, 12.0f); - RNA_def_property_ui_text(prop, "Max Edge Length", "Maximum contour edge length"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "edge_max_error", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "edgemaxerror"); - RNA_def_property_ui_range(prop, 0.1, 3.0, 1, 2); - RNA_def_property_float_default(prop, 1.3f); - RNA_def_property_ui_text(prop, "Max Edge Error", "Maximum distance error from contour to cells"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "verts_per_poly", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "vertsperpoly"); - RNA_def_property_ui_range(prop, 3, 12, 1, -1); - RNA_def_property_int_default(prop, 6); - RNA_def_property_ui_text(prop, "Verts Per Poly", "Max number of vertices per polygon"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "sample_dist", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "detailsampledist"); - RNA_def_property_ui_range(prop, 0.0, 16.0, 1, 2); - RNA_def_property_float_default(prop, 6.0f); - RNA_def_property_ui_text(prop, "Sample Distance", "Detail mesh sample spacing"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "sample_max_error", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "detailsamplemaxerror"); - RNA_def_property_ui_range(prop, 0.0, 16.0, 1, 2); - RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Max Sample Error", "Detail mesh simplification max sample error"); - RNA_def_property_update(prop, NC_SCENE, NULL); -} - - static void rna_def_bake_data(BlenderRNA *brna) { StructRNA *srna; @@ -4362,7 +3852,7 @@ static void rna_def_bake_data(BlenderRNA *brna) /* custom passes flags */ prop = RNA_def_property(srna, "use_pass_ambient_occlusion", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pass_filter", R_BAKE_PASS_FILTER_AO); - RNA_def_property_ui_text(prop, "AO", "Add ambient occlusion contribution"); + RNA_def_property_ui_text(prop, "Ambient Occlusion", "Add ambient occlusion contribution"); prop = RNA_def_property(srna, "use_pass_emit", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pass_filter", R_BAKE_PASS_FILTER_EMIT); @@ -4411,498 +3901,6 @@ static void rna_def_bake_data(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); } -static void rna_def_scene_game_data(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem aasamples_items[] = { - {0, "SAMPLES_0", 0, "Off", ""}, - {2, "SAMPLES_2", 0, "2x", ""}, - {4, "SAMPLES_4", 0, "4x", ""}, - {8, "SAMPLES_8", 0, "8x", ""}, - {16, "SAMPLES_16", 0, "16x", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem framing_types_items[] = { - {SCE_GAMEFRAMING_BARS, "LETTERBOX", 0, "Letterbox", - "Show the entire viewport in the display window, using bar horizontally or vertically"}, - {SCE_GAMEFRAMING_EXTEND, "EXTEND", 0, "Extend", - "Show the entire viewport in the display window, viewing more horizontally " - "or vertically"}, - {SCE_GAMEFRAMING_SCALE, "SCALE", 0, "Scale", "Stretch or squeeze the viewport to fill the display window"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem dome_modes_items[] = { - {DOME_FISHEYE, "FISHEYE", 0, "Fisheye", ""}, - {DOME_TRUNCATED_FRONT, "TRUNCATED_FRONT", 0, "Front-Truncated", ""}, - {DOME_TRUNCATED_REAR, "TRUNCATED_REAR", 0, "Rear-Truncated", ""}, - {DOME_ENVMAP, "ENVMAP", 0, "Cube Map", ""}, - {DOME_PANORAM_SPH, "PANORAM_SPH", 0, "Spherical Panoramic", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem stereo_modes_items[] = { - {STEREO_QUADBUFFERED, "QUADBUFFERED", 0, "Quad-Buffer", ""}, - {STEREO_ABOVEBELOW, "ABOVEBELOW", 0, "Above-Below", ""}, - {STEREO_INTERLACED, "INTERLACED", 0, "Interlaced", ""}, - {STEREO_ANAGLYPH, "ANAGLYPH", 0, "Anaglyph", ""}, - {STEREO_SIDEBYSIDE, "SIDEBYSIDE", 0, "Side-by-side", ""}, - {STEREO_VINTERLACE, "VINTERLACE", 0, "Vinterlace", ""}, - {STEREO_3DTVTOPBOTTOM, "3DTVTOPBOTTOM", 0, "3DTV Top-Bottom", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem stereo_items[] = { - {STEREO_NOSTEREO, "NONE", 0, "None", "Disable Stereo and Dome environments"}, - {STEREO_ENABLED, "STEREO", 0, "Stereo", "Enable Stereo environment"}, - {STEREO_DOME, "DOME", 0, "Dome", "Enable Dome environment"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem physics_engine_items[] = { - {WOPHY_NONE, "NONE", 0, "None", "Don't use a physics engine"}, - {WOPHY_BULLET, "BULLET", 0, "Bullet", "Use the Bullet physics engine"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem material_items[] = { - {GAME_MAT_MULTITEX, "MULTITEXTURE", 0, "Multitexture", "Multitexture materials"}, - {GAME_MAT_GLSL, "GLSL", 0, "GLSL", "OpenGL shading language shaders"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem obstacle_simulation_items[] = { - {OBSTSIMULATION_NONE, "NONE", 0, "None", ""}, - {OBSTSIMULATION_TOI_rays, "RVO_RAYS", 0, "RVO (rays)", ""}, - {OBSTSIMULATION_TOI_cells, "RVO_CELLS", 0, "RVO (cells)", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem vsync_items[] = { - {VSYNC_OFF, "OFF", 0, "Off", "Disable vsync"}, - {VSYNC_ON, "ON", 0, "On", "Enable vsync"}, - {VSYNC_ADAPTIVE, "ADAPTIVE", 0, "Adaptive", "Enable adaptive vsync (if supported)"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem storage_items[] = { - {RAS_STORE_AUTO, "AUTO", 0, "Auto Select", "Choose the best supported mode"}, - {RAS_STORE_VA, "VERTEX_ARRAY", 0, "Vertex Arrays", "Usually the best choice (good performance with display lists)"}, - {RAS_STORE_VBO, "VERTEX_BUFFER_OBJECT", 0, "Vertex Buffer Objects", - "Typically slower than vertex arrays with display lists, requires at least OpenGL 1.4"}, - {0, NULL, 0, NULL, NULL}}; - - srna = RNA_def_struct(brna, "SceneGameData", NULL); - RNA_def_struct_sdna(srna, "GameData"); - RNA_def_struct_nested(brna, srna, "Scene"); - RNA_def_struct_ui_text(srna, "Game Data", "Game data for a Scene data-block"); - - prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "xplay"); - RNA_def_property_range(prop, 4, 10000); - RNA_def_property_int_default(prop, 640); - RNA_def_property_ui_text(prop, "Resolution X", "Number of horizontal pixels in the screen"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "yplay"); - RNA_def_property_range(prop, 4, 10000); - RNA_def_property_int_default(prop, 480); - RNA_def_property_ui_text(prop, "Resolution Y", "Number of vertical pixels in the screen"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "vsync", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "vsync"); - RNA_def_property_enum_items(prop, vsync_items); - RNA_def_property_ui_text(prop, "Vsync", "Change vsync settings"); - - prop = RNA_def_property(srna, "samples", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "aasamples"); - RNA_def_property_enum_items(prop, aasamples_items); - RNA_def_property_ui_text(prop, "AA Samples", "The number of AA Samples to use for MSAA"); - - prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "depth"); - RNA_def_property_range(prop, 8, 32); - RNA_def_property_int_default(prop, 32); - RNA_def_property_ui_text(prop, "Bits", "Display bit depth of full screen display"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "exit_key", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "exitkey"); - RNA_def_property_enum_items(prop, rna_enum_event_type_items); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS); - RNA_def_property_enum_default(prop, ESCKEY); - RNA_def_property_enum_funcs(prop, NULL, "rna_GameSettings_exit_key_set", NULL); - RNA_def_property_ui_text(prop, "Exit Key", "The key that exits the Game Engine"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "raster_storage", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "raster_storage"); - RNA_def_property_enum_items(prop, storage_items); - RNA_def_property_ui_text(prop, "Storage", "Set the storage mode used by the rasterizer"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - /* Do we need it here ? (since we already have it in World */ - prop = RNA_def_property(srna, "frequency", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "freqplay"); - RNA_def_property_range(prop, 4, 2000); - RNA_def_property_int_default(prop, 60); - RNA_def_property_ui_text(prop, "Freq", "Display clock frequency of fullscreen display"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "show_fullscreen", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "playerflag", GAME_PLAYER_FULLSCREEN); - RNA_def_property_ui_text(prop, "Fullscreen", "Start player in a new fullscreen display"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "use_desktop", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "playerflag", GAME_PLAYER_DESKTOP_RESOLUTION); - RNA_def_property_ui_text(prop, "Desktop", "Use the current desktop resolution in fullscreen mode"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - /* Framing */ - prop = RNA_def_property(srna, "frame_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "framing.type"); - RNA_def_property_enum_items(prop, framing_types_items); - RNA_def_property_ui_text(prop, "Framing Types", "Select the type of Framing you want"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "frame_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "framing.col"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Framing Color", "Set color of the bars"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - /* Stereo */ - prop = RNA_def_property(srna, "stereo", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "stereoflag"); - RNA_def_property_enum_items(prop, stereo_items); - RNA_def_property_ui_text(prop, "Stereo Options", ""); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "stereo_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "stereomode"); - RNA_def_property_enum_items(prop, stereo_modes_items); - RNA_def_property_enum_default(prop, STEREO_ANAGLYPH); - RNA_def_property_ui_text(prop, "Stereo Mode", "Stereographic techniques"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "stereo_eye_separation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "eyeseparation"); - RNA_def_property_range(prop, 0.01, 5.0); - RNA_def_property_float_default(prop, 0.1f); - RNA_def_property_ui_text(prop, "Eye Separation", - "Set the distance between the eyes - the camera focal distance/30 should be fine"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - /* Dome */ - prop = RNA_def_property(srna, "dome_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "dome.mode"); - RNA_def_property_enum_items(prop, dome_modes_items); - RNA_def_property_ui_text(prop, "Dome Mode", "Dome physical configurations"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "dome_tessellation", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "dome.res"); - RNA_def_property_ui_range(prop, 1, 8, 1, 1); - RNA_def_property_int_default(prop, 4); - RNA_def_property_ui_text(prop, "Tessellation", "Tessellation level - check the generated mesh in wireframe mode"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "dome_buffer_resolution", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dome.resbuf"); - RNA_def_property_ui_range(prop, 0.1, 1.0, 0.1, 2); - RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Buffer Resolution", "Buffer Resolution - decrease it to increase speed"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "dome_angle", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "dome.angle"); - RNA_def_property_ui_range(prop, 90, 250, 1, 1); - RNA_def_property_int_default(prop, 180); - RNA_def_property_ui_text(prop, "Angle", "Field of View of the Dome - it only works in mode Fisheye and Truncated"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "dome_tilt", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "dome.tilt"); - RNA_def_property_ui_range(prop, -180, 180, 1, 1); - RNA_def_property_ui_text(prop, "Tilt", "Camera rotation in horizontal axis"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "dome_text", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "dome.warptext"); - RNA_def_property_struct_type(prop, "Text"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Warp Data", "Custom Warp Mesh data file"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - /* physics */ - prop = RNA_def_property(srna, "physics_engine", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "physicsEngine"); - RNA_def_property_enum_items(prop, physics_engine_items); - RNA_def_property_enum_default(prop, WOPHY_BULLET); - RNA_def_property_ui_text(prop, "Physics Engine", "Physics engine used for physics simulation in the game engine"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "physics_gravity", PROP_FLOAT, PROP_ACCELERATION); - RNA_def_property_float_sdna(prop, NULL, "gravity"); - RNA_def_property_ui_range(prop, 0.0, 25.0, 1, 2); - RNA_def_property_range(prop, 0.0, 10000.0); - RNA_def_property_float_default(prop, 9.8f); - RNA_def_property_ui_text(prop, "Physics Gravity", - "Gravitational constant used for physics simulation in the game engine"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "occlusion_culling_resolution", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "occlusionRes"); - RNA_def_property_range(prop, 128.0, 1024.0); - RNA_def_property_int_default(prop, 128); - RNA_def_property_ui_text(prop, "Occlusion Resolution", - "Size of the occlusion buffer, use higher value for better precision (slower)"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "fps", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "ticrate"); - RNA_def_property_ui_range(prop, 1, 60, 1, 1); - RNA_def_property_range(prop, 1, 10000); - RNA_def_property_int_default(prop, 60); - RNA_def_property_ui_text(prop, "Frames Per Second", - "Nominal number of game frames per second " - "(physics fixed timestep = 1/fps, independently of actual frame rate)"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "logic_step_max", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "maxlogicstep"); - RNA_def_property_range(prop, 1, 10000); - RNA_def_property_ui_range(prop, 1, 50, 1, 1); - RNA_def_property_int_default(prop, 5); - RNA_def_property_ui_text(prop, "Max Logic Steps", - "Maximum number of logic frame per game frame if graphics slows down the game, " - "higher value allows better synchronization with physics"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "physics_step_max", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "maxphystep"); - RNA_def_property_range(prop, 1, 10000); - RNA_def_property_ui_range(prop, 1, 50, 1, 1); - RNA_def_property_int_default(prop, 5); - RNA_def_property_ui_text(prop, "Max Physics Steps", - "Maximum number of physics step per game frame if graphics slows down the game, " - "higher value allows physics to keep up with realtime"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "physics_step_sub", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "physubstep"); - RNA_def_property_range(prop, 1, 50); - RNA_def_property_ui_range(prop, 1, 5, 1, 1); - RNA_def_property_int_default(prop, 1); - RNA_def_property_ui_text(prop, "Physics Sub Steps", - "Number of simulation substep per physic timestep, " - "higher value give better physics precision"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "deactivation_linear_threshold", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "lineardeactthreshold"); - RNA_def_property_ui_range(prop, 0.001, 10000.0, 2, 3); - RNA_def_property_range(prop, 0.001, 10000.0); - RNA_def_property_float_default(prop, 0.8f); - RNA_def_property_ui_text(prop, "Deactivation Linear Threshold", - "Linear velocity that an object must be below before the deactivation timer can start"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "deactivation_angular_threshold", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "angulardeactthreshold"); - RNA_def_property_ui_range(prop, 0.001, 10000.0, 2, 3); - RNA_def_property_range(prop, 0.001, 10000.0); - RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Deactivation Angular Threshold", - "Angular velocity that an object must be below before the deactivation timer can start"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "deactivation_time", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "deactivationtime"); - RNA_def_property_ui_range(prop, 0.0, 60.0, 1, 1); - RNA_def_property_range(prop, 0.0, 60.0); - RNA_def_property_ui_text(prop, "Deactivation Time", - "Amount of time (in seconds) after which objects with a velocity less than the given " - "threshold will deactivate (0.0 means no deactivation)"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - /* mode */ - /* not used *//* deprecated !!!!!!!!!!!!! */ - prop = RNA_def_property(srna, "use_occlusion_culling", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_DBVT_CULLING); - RNA_def_property_ui_text(prop, "DBVT Culling", - "Use optimized Bullet DBVT tree for view frustum and occlusion culling (more efficient, " - "but it can waste unnecessary CPU if the scene doesn't have occluder objects)"); - - /* not used *//* deprecated !!!!!!!!!!!!! */ - prop = RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_ACTIVITY_CULLING); - RNA_def_property_ui_text(prop, "Activity Culling", "Activity culling is enabled"); - - /* not used *//* deprecated !!!!!!!!!!!!! */ - prop = RNA_def_property(srna, "activity_culling_box_radius", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "activityBoxRadius"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Box Radius", - "Radius of the activity bubble, in Manhattan length " - "(objects outside the box are activity-culled)"); - - /* booleans */ - prop = RNA_def_property(srna, "show_debug_properties", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_DEBUG_PROPS); - RNA_def_property_ui_text(prop, "Show Debug Properties", - "Show properties marked for debugging while the game runs"); - - prop = RNA_def_property(srna, "show_framerate_profile", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_FRAMERATE); - RNA_def_property_ui_text(prop, "Show Framerate and Profile", - "Show framerate and profiling information while the game runs"); - - prop = RNA_def_property(srna, "show_physics_visualization", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_PHYSICS); - RNA_def_property_ui_text(prop, "Show Physics Visualization", - "Show a visualization of physics bounds and interactions"); - - prop = RNA_def_property(srna, "show_mouse", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_MOUSE); - RNA_def_property_ui_text(prop, "Show Mouse", "Start player with a visible mouse cursor"); - - prop = RNA_def_property(srna, "use_frame_rate", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_ENABLE_ALL_FRAMES); - RNA_def_property_ui_text(prop, "Use Frame Rate", - "Respect the frame rate from the Physics panel in the world properties " - "rather than rendering as many frames as possible"); - - prop = RNA_def_property(srna, "use_display_lists", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_DISPLAY_LISTS); - RNA_def_property_ui_text(prop, "Display Lists", - "Use display lists to speed up rendering by keeping geometry on the GPU"); - - prop = RNA_def_property(srna, "use_deprecation_warnings", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_IGNORE_DEPRECATION_WARNINGS); - RNA_def_property_ui_text(prop, "Deprecation Warnings", - "Print warnings when using deprecated features in the python API"); - - prop = RNA_def_property(srna, "use_animation_record", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_ENABLE_ANIMATION_RECORD); - RNA_def_property_ui_text(prop, "Record Animation", "Record animation to F-Curves"); - - prop = RNA_def_property(srna, "use_auto_start", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_GameSettings_auto_start_get", "rna_GameSettings_auto_start_set"); - RNA_def_property_ui_text(prop, "Auto Start", "Automatically start game at load time"); - - prop = RNA_def_property(srna, "use_restrict_animation_updates", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_RESTRICT_ANIM_UPDATES); - RNA_def_property_ui_text(prop, "Restrict Animation Updates", - "Restrict the number of animation updates to the animation FPS (this is " - "better for performance, but can cause issues with smooth playback)"); - - /* materials */ - prop = RNA_def_property(srna, "material_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "matmode"); - RNA_def_property_enum_items(prop, material_items); - RNA_def_property_ui_text(prop, "Material Mode", "Material mode to use for rendering"); - RNA_def_property_update(prop, NC_SCENE | NA_EDITED, NULL); - - prop = RNA_def_property(srna, "use_glsl_lights", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_LIGHTS); - RNA_def_property_ui_text(prop, "GLSL Lights", "Use lights for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_glsl_shaders", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_SHADERS); - RNA_def_property_ui_text(prop, "GLSL Shaders", "Use shaders for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_glsl_shadows", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_SHADOWS); - RNA_def_property_ui_text(prop, "GLSL Shadows", "Use shadows for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_glsl_ramps", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_RAMPS); - RNA_def_property_ui_text(prop, "GLSL Ramps", "Use ramps for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_glsl_nodes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_NODES); - RNA_def_property_ui_text(prop, "GLSL Nodes", "Use nodes for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_glsl_color_management", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_COLOR_MANAGEMENT); - RNA_def_property_ui_text(prop, "GLSL Color Management", "Use color management for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_glsl_extra_textures", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_EXTRA_TEX); - RNA_def_property_ui_text(prop, "GLSL Extra Textures", - "Use extra textures like normal or specular maps for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_glsl_environment_lighting", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_ENV_LIGHTING); - RNA_def_property_ui_text(prop, "GLSL Environment Lighting", "Use environment lighting for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_material_caching", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_NO_MATERIAL_CACHING); - RNA_def_property_ui_text(prop, "Use Material Caching", - "Cache materials in the converter (this is faster, but can cause problems with older " - "Singletexture and Multitexture games)"); - - /* obstacle simulation */ - prop = RNA_def_property(srna, "obstacle_simulation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "obstacleSimulation"); - RNA_def_property_enum_items(prop, obstacle_simulation_items); - RNA_def_property_ui_text(prop, "Obstacle simulation", "Simulation used for obstacle avoidance in the game engine"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "level_height", PROP_FLOAT, PROP_ACCELERATION); - RNA_def_property_float_sdna(prop, NULL, "levelHeight"); - RNA_def_property_range(prop, 0.0f, 200.0f); - RNA_def_property_float_default(prop, 2.0f); - RNA_def_property_ui_text(prop, "Level height", - "Max difference in heights of obstacles to enable their interaction"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "show_obstacle_simulation", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_SHOW_OBSTACLE_SIMULATION); - RNA_def_property_ui_text(prop, "Visualization", "Enable debug visualization for obstacle simulation"); - - /* Recast Settings */ - prop = RNA_def_property(srna, "recast_data", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "recastData"); - RNA_def_property_struct_type(prop, "SceneGameRecastData"); - RNA_def_property_ui_text(prop, "Recast Data", ""); - - /* Nestled Data */ - rna_def_scene_game_recast_data(brna); - - /* LoD */ - prop = RNA_def_property(srna, "use_scene_hysteresis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "lodflag", SCE_LOD_USE_HYST); - RNA_def_property_ui_text(prop, "Hysteresis", "Use LoD Hysteresis setting for the scene"); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop = RNA_def_property(srna, "scene_hysteresis_percentage", PROP_INT, PROP_PERCENTAGE); - RNA_def_property_int_sdna(prop, NULL, "scehysteresis"); - RNA_def_property_range(prop, 0, 100); - RNA_def_property_ui_range(prop, 0, 100, 10, 1); - RNA_def_property_int_default(prop, 10); - 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_SCENE, NULL); -} - static void rna_def_gpu_dof_fx(BlenderRNA *brna) { StructRNA *srna; @@ -4910,7 +3908,6 @@ static void rna_def_gpu_dof_fx(BlenderRNA *brna) srna = RNA_def_struct(brna, "GPUDOFSettings", NULL); RNA_def_struct_ui_text(srna, "GPU DOF", "Settings for GPU based depth of field"); - RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS); RNA_def_struct_path_func(srna, "rna_GPUDOF_path"); prop = RNA_def_property(srna, "focus_distance", PROP_FLOAT, PROP_DISTANCE); @@ -4933,6 +3930,7 @@ static void rna_def_gpu_dof_fx(BlenderRNA *brna) prop = RNA_def_property(srna, "fstop", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text(prop, "F-stop", "F-stop for dof effect"); + RNA_def_property_float_default(prop, 128.0f); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0.1f, 128.0f, 10, 1); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUDOFSettings_update"); @@ -4944,15 +3942,16 @@ static void rna_def_gpu_dof_fx(BlenderRNA *brna) RNA_def_property_int_funcs(prop, NULL, "rna_GPUDOFSettings_blades_set", NULL); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUDOFSettings_update"); - prop = RNA_def_property(srna, "use_high_quality", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "high_quality", 1); - RNA_def_property_ui_text(prop, "High Quality", "Use high quality depth of field"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUDOFSettings_update"); + prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_ui_text(prop, "Rotation", "Rotation of blades in aperture"); + RNA_def_property_range(prop, -M_PI, M_PI); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "is_hq_supported", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_gpu_is_hq_supported_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "High Quality", "Use high quality depth of field"); + prop = RNA_def_property(srna, "ratio", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Ratio", "Distortion to simulate anamorphic lens bokeh"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_range(prop, 0.0000001f, FLT_MAX); + RNA_def_property_ui_range(prop, 1.0f, 2.0f, 0.1, 3); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); } @@ -4963,7 +3962,6 @@ static void rna_def_gpu_ssao_fx(BlenderRNA *brna) srna = RNA_def_struct(brna, "GPUSSAOSettings", NULL); RNA_def_struct_ui_text(srna, "GPU SSAO", "Settings for GPU based screen space ambient occlusion"); - RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS); prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text(prop, "Strength", "Strength of the SSAO effect"); @@ -5004,7 +4002,6 @@ static void rna_def_gpu_fx(BlenderRNA *brna) srna = RNA_def_struct(brna, "GPUFXSettings", NULL); RNA_def_struct_ui_text(srna, "GPU FX Settings", "Settings for GPU based compositing"); - RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS); prop = RNA_def_property(srna, "dof", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); @@ -5015,7 +4012,7 @@ static void rna_def_gpu_fx(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "fx_flag", GPU_FX_FLAG_DOF); RNA_def_property_ui_text(prop, "Depth Of Field", "Use depth of field on viewport using the values from active camera"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUFXSettings_fx_update"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "ssao", PROP_POINTER, PROP_NONE); @@ -5026,80 +4023,32 @@ static void rna_def_gpu_fx(BlenderRNA *brna) prop = RNA_def_property(srna, "use_ssao", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "fx_flag", GPU_FX_FLAG_SSAO); RNA_def_property_ui_text(prop, "SSAO", "Use screen space ambient occlusion of field on viewport"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUFXSettings_fx_update"); -} - - -static void rna_def_scene_render_layer(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - FunctionRNA *func; - - srna = RNA_def_struct(brna, "SceneRenderLayer", NULL); - RNA_def_struct_ui_text(srna, "Scene Render Layer", "Render layer"); - RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS); - RNA_def_struct_path_func(srna, "rna_SceneRenderLayer_path"); - RNA_def_struct_idprops_func(srna, "rna_SceneRenderLayer_idprops"); - - rna_def_render_layer_common(srna, 1); - - func = RNA_def_function(srna, "update_render_passes", "rna_SceneRenderLayer_update_render_passes"); - RNA_def_function_ui_description(func, "Requery the enabled render passes from the render engine"); - RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_NO_SELF); - - /* Freestyle */ - rna_def_freestyle_settings(brna); - - prop = RNA_def_property(srna, "freestyle_settings", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "freestyleConfig"); - RNA_def_property_struct_type(prop, "FreestyleSettings"); - RNA_def_property_ui_text(prop, "Freestyle Settings", ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); } -/* Render Layers */ -static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_view_layers(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; - PropertyRNA *prop; - FunctionRNA *func; PropertyRNA *parm; - RNA_def_property_srna(cprop, "RenderLayers"); - srna = RNA_def_struct(brna, "RenderLayers", NULL); - RNA_def_struct_sdna(srna, "RenderData"); + RNA_def_property_srna(cprop, "ViewLayers"); + srna = RNA_def_struct(brna, "ViewLayers", NULL); + RNA_def_struct_sdna(srna, "Scene"); RNA_def_struct_ui_text(srna, "Render Layers", "Collection of render layers"); - prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "actlay"); - RNA_def_property_int_funcs(prop, "rna_RenderSettings_active_layer_index_get", - "rna_RenderSettings_active_layer_index_set", - "rna_RenderSettings_active_layer_index_range"); - RNA_def_property_ui_text(prop, "Active Layer Index", "Active index in render layer array"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "SceneRenderLayer"); - RNA_def_property_pointer_funcs(prop, "rna_RenderSettings_active_layer_get", - "rna_RenderSettings_active_layer_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); - RNA_def_property_ui_text(prop, "Active Render Layer", "Active Render Layer"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - - func = RNA_def_function(srna, "new", "rna_RenderLayer_new"); - RNA_def_function_ui_description(func, "Add a render layer to scene"); - RNA_def_function_flag(func, FUNC_USE_SELF_ID); - parm = RNA_def_string(func, "name", "RenderLayer", 0, "", "New name for the render layer (not unique)"); + func = RNA_def_function(srna, "new", "rna_ViewLayer_new"); + RNA_def_function_ui_description(func, "Add a view layer to scene"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_string(func, "name", "ViewLayer", 0, "", "New name for the view layer (not unique)"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_pointer(func, "result", "SceneRenderLayer", "", "Newly created render layer"); + parm = RNA_def_pointer(func, "result", "ViewLayer", "", "Newly created view layer"); RNA_def_function_return(func, parm); - func = RNA_def_function(srna, "remove", "rna_RenderLayer_remove"); - RNA_def_function_ui_description(func, "Remove a render layer"); - RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS | FUNC_USE_SELF_ID); - parm = RNA_def_pointer(func, "layer", "SceneRenderLayer", "", "Render layer to remove"); + func = RNA_def_function(srna, "remove", "rna_ViewLayer_remove"); + RNA_def_function_ui_description(func, "Remove a view layer"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "layer", "ViewLayer", "", "View layer to remove"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); } @@ -5134,6 +4083,7 @@ static void rna_def_scene_render_view(BlenderRNA *brna) prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "viewflag", SCE_VIEW_DISABLE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Enabled", "Disable or enable the render view"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); } @@ -5665,17 +4615,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem pixel_filter_items[] = { - {R_FILTER_BOX, "BOX", 0, "Box", "Use a box filter for anti-aliasing"}, - {R_FILTER_TENT, "TENT", 0, "Tent", "Use a tent filter for anti-aliasing"}, - {R_FILTER_QUAD, "QUADRATIC", 0, "Quadratic", "Use a quadratic filter for anti-aliasing"}, - {R_FILTER_CUBIC, "CUBIC", 0, "Cubic", "Use a cubic filter for anti-aliasing"}, - {R_FILTER_CATROM, "CATMULLROM", 0, "Catmull-Rom", "Use a Catmull-Rom filter for anti-aliasing"}, - {R_FILTER_GAUSS, "GAUSSIAN", 0, "Gaussian", "Use a Gaussian filter for anti-aliasing"}, - {R_FILTER_MITCH, "MITCHELL", 0, "Mitchell-Netravali", "Use a Mitchell-Netravali filter for anti-aliasing"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem alpha_mode_items[] = { {R_ADDSKY, "SKY", 0, "Sky", "Transparent pixels are filled with sky color"}, {R_ALPHAPREMUL, "TRANSPARENT", 0, "Transparent", "World background is transparent with premultiplied alpha"}, @@ -5683,49 +4622,23 @@ static void rna_def_scene_render_data(BlenderRNA *brna) }; static const EnumPropertyItem display_mode_items[] = { - {R_OUTPUT_SCREEN, "SCREEN", 0, "Full Screen", "Images are rendered in full Screen"}, - {R_OUTPUT_AREA, "AREA", 0, "Image Editor", "Images are rendered in Image Editor"}, - {R_OUTPUT_WINDOW, "WINDOW", 0, "New Window", "Images are rendered in new Window"}, - {R_OUTPUT_NONE, "NONE", 0, "Keep UI", "Images are rendered without forcing UI changes"}, + {R_OUTPUT_SCREEN, "SCREEN", 0, "Full Screen", "Images are rendered in a maximized Image Editor"}, + {R_OUTPUT_AREA, "AREA", 0, "Image Editor", "Images are rendered in an Image Editor"}, + {R_OUTPUT_WINDOW, "WINDOW", 0, "New Window", "Images are rendered in a new window"}, + {R_OUTPUT_NONE, "NONE", 0, "Keep User Interface", "Images are rendered without changing the user interface"}, {0, NULL, 0, NULL, NULL} }; /* Bake */ static const EnumPropertyItem bake_mode_items[] = { - {RE_BAKE_ALL, "FULL", 0, "Full Render", "Bake everything"}, - {RE_BAKE_AO, "AO", 0, "Ambient Occlusion", "Bake ambient occlusion"}, - {RE_BAKE_SHADOW, "SHADOW", 0, "Shadow", "Bake shadows"}, + //{RE_BAKE_AO, "AO", 0, "Ambient Occlusion", "Bake ambient occlusion"}, {RE_BAKE_NORMALS, "NORMALS", 0, "Normals", "Bake normals"}, - {RE_BAKE_TEXTURE, "TEXTURE", 0, "Textures", "Bake textures"}, {RE_BAKE_DISPLACEMENT, "DISPLACEMENT", 0, "Displacement", "Bake displacement"}, - {RE_BAKE_DERIVATIVE, "DERIVATIVE", 0, "Derivative", "Bake derivative map"}, - {RE_BAKE_VERTEX_COLORS, "VERTEX_COLORS", 0, "Vertex Colors", "Bake vertex colors"}, - {RE_BAKE_EMIT, "EMIT", 0, "Emission", "Bake Emit values (glow)"}, - {RE_BAKE_ALPHA, "ALPHA", 0, "Alpha", "Bake Alpha values (transparency)"}, - {RE_BAKE_MIRROR_INTENSITY, "MIRROR_INTENSITY", 0, "Mirror Intensity", "Bake Mirror values"}, - {RE_BAKE_MIRROR_COLOR, "MIRROR_COLOR", 0, "Mirror Colors", "Bake Mirror colors"}, - {RE_BAKE_SPEC_INTENSITY, "SPEC_INTENSITY", 0, "Specular Intensity", "Bake Specular values"}, - {RE_BAKE_SPEC_COLOR, "SPEC_COLOR", 0, "Specular Colors", "Bake Specular colors"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem bake_normal_space_items[] = { - {R_BAKE_SPACE_CAMERA, "CAMERA", 0, "Camera", "Bake the normals in camera space"}, - {R_BAKE_SPACE_WORLD, "WORLD", 0, "World", "Bake the normals in world space"}, - {R_BAKE_SPACE_OBJECT, "OBJECT", 0, "Object", "Bake the normals in object space"}, - {R_BAKE_SPACE_TANGENT, "TANGENT", 0, "Tangent", "Bake the normals in tangent space"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem bake_qyad_split_items[] = { - {0, "AUTO", 0, "Automatic", "Split quads to give the least distortion while baking"}, - {1, "FIXED", 0, "Fixed", "Split quads predictably (0,1,2) (0,2,3)"}, - {2, "FIXED_ALT", 0, "Fixed Alternate", "Split quads predictably (1,2,3) (1,3,0)"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem pixel_size_items[] = { - {0, "AUTO", 0, "Automatic", "Automatic pixel size, depends on the UI scale"}, + {0, "AUTO", 0, "Automatic", "Automatic pixel size, depends on the user interface scale"}, {1, "1", 0, "1x", "Render at full resolution"}, {2, "2", 0, "2x", "Render at 50% resolution"}, {4, "4", 0, "4x", "Render at 25% resolution"}, @@ -5733,23 +4646,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem octree_resolution_items[] = { - {64, "64", 0, "64", ""}, - {128, "128", 0, "128", ""}, - {256, "256", 0, "256", ""}, - {512, "512", 0, "512", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem raytrace_structure_items[] = { - {R_RAYSTRUCTURE_AUTO, "AUTO", 0, "Auto", "Automatically select acceleration structure"}, - {R_RAYSTRUCTURE_OCTREE, "OCTREE", 0, "Octree", "Use old Octree structure"}, - {R_RAYSTRUCTURE_VBVH, "VBVH", 0, "vBVH", "Use vBVH"}, - {R_RAYSTRUCTURE_SIMD_SVBVH, "SIMD_SVBVH", 0, "SIMD SVBVH", "Use SIMD SVBVH"}, - {R_RAYSTRUCTURE_SIMD_QBVH, "SIMD_QBVH", 0, "SIMD QBVH", "Use SIMD QBVH"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem fixed_oversample_items[] = { {5, "5", 0, "5", ""}, {8, "8", 0, "8", ""}, @@ -5758,12 +4654,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem field_order_items[] = { - {0, "EVEN_FIRST", 0, "Upper First", "Upper field first"}, - {R_ODDFIELD, "ODD_FIRST", 0, "Lower First", "Lower field first"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem threads_mode_items[] = { {0, "AUTO", 0, "Auto-detect", "Automatically determine the number of threads, based on CPUs"}, {R_FIXED_THREADS, "FIXED", 0, "Fixed", "Manually determine the number of threads"}, @@ -5771,7 +4661,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) }; static const EnumPropertyItem engine_items[] = { - {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"}, + {0, "BLENDER_EEVEE", 0, "Eevee", ""}, {0, NULL, 0, NULL, NULL} }; @@ -5790,7 +4680,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - + static const EnumPropertyItem hair_shape_type_items[] = { + {SCE_HAIR_SHAPE_STRAND, "STRAND", 0, "Strand", ""}, + {SCE_HAIR_SHAPE_STRIP, "STRIP", 0, "Strip", ""}, + {0, NULL, 0, NULL, NULL} + }; rna_def_scene_ffmpeg_settings(brna); @@ -5857,7 +4751,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "preview_pixel_size"); RNA_def_property_enum_items(prop, pixel_size_items); RNA_def_property_ui_text(prop, "Pixel Size", "Pixel size for viewport rendering"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderData_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "pixel_aspect_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xasp"); @@ -5922,15 +4816,10 @@ static void rna_def_scene_render_data(BlenderRNA *brna) "Amount of dithering noise added to the rendered image to break up banding"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "pixel_filter_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "filtertype"); - RNA_def_property_enum_items(prop, pixel_filter_items); - RNA_def_property_ui_text(prop, "Pixel Filter", "Reconstruction filter used for combining anti-aliasing samples"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "filter_size", PROP_FLOAT, PROP_PIXEL); RNA_def_property_float_sdna(prop, NULL, "gauss"); - RNA_def_property_range(prop, 0.5f, 1.5f); + RNA_def_property_range(prop, 0.0f, 500.0f); + RNA_def_property_ui_range(prop, 0.01f, 10.0f, 1, 2); RNA_def_property_ui_text(prop, "Filter Size", "Width over which the reconstruction filter combines samples"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); @@ -5940,32 +4829,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Alpha Mode", "Representation of alpha information in the RGBA pixels"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - prop = RNA_def_property(srna, "octree_resolution", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "ocres"); - RNA_def_property_enum_items(prop, octree_resolution_items); - RNA_def_property_ui_text(prop, "Octree Resolution", - "Resolution of raytrace accelerator, use higher resolutions for larger scenes"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - prop = RNA_def_property(srna, "raytrace_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "raytrace_structure"); - RNA_def_property_enum_items(prop, raytrace_structure_items); - RNA_def_property_ui_text(prop, "Raytrace Acceleration Structure", "Type of raytrace accelerator structure"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - prop = RNA_def_property(srna, "use_instances", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "raytrace_options", R_RAYTRACE_USE_INSTANCES); - RNA_def_property_ui_text(prop, "Use Instances", - "Instance support leads to effective memory reduction when using duplicates"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - prop = RNA_def_property(srna, "use_local_coords", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "raytrace_options", R_RAYTRACE_USE_LOCAL_COORDS); - RNA_def_property_ui_text(prop, "Use Local Coords", - "Vertex coordinates are stored locally on each primitive " - "(increases memory usage, but may have impact on speed)"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_OSA); RNA_def_property_ui_text(prop, "Anti-Aliasing", @@ -5978,72 +4841,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Anti-Aliasing Samples", "Amount of anti-aliasing samples per pixel"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", R_FIELDS); - RNA_def_property_ui_text(prop, "Fields", "Render image to two fields per frame, for interlaced TV output"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - prop = RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, field_order_items); - RNA_def_property_ui_text(prop, "Field Order", - "Order of video fields (select which lines get rendered first, " - "to create smooth motion for TV output)"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - prop = RNA_def_property(srna, "use_fields_still", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", R_FIELDSTILL); - RNA_def_property_ui_text(prop, "Fields Still", "Disable the time difference between fields"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - /* rendering features */ - prop = RNA_def_property(srna, "use_shadows", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SHADOW); - RNA_def_property_ui_text(prop, "Shadows", "Calculate shadows while rendering"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_envmaps", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", R_ENVMAP); - RNA_def_property_ui_text(prop, "Environment Maps", "Calculate environment maps while rendering"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_sss", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SSS); - RNA_def_property_ui_text(prop, "Subsurface Scattering", "Calculate sub-surface scattering in materials rendering"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_world_space_shading", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", R_USE_WS_SHADING); - RNA_def_property_ui_text(prop, "World Space Shading", "Use world space interpretation of lighting data for node materials"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", R_RAYTRACE); - RNA_def_property_ui_text(prop, "Raytracing", - "Pre-calculate the raytrace accelerator and render raytracing effects"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "scemode", R_NO_TEX); - RNA_def_property_ui_text(prop, "Textures", "Use textures to affect material properties"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "use_edge_enhance", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE); - RNA_def_property_ui_text(prop, "Edge", "Create a toon outline around the edges of geometry"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "edge_threshold", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "edgeint"); - RNA_def_property_range(prop, 0, 255); - RNA_def_property_ui_text(prop, "Edge Threshold", "Threshold for drawing outlines on geometry edges"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - - prop = RNA_def_property(srna, "edge_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "edgeR"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Edge Color", "Edge color"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -6075,13 +4872,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "mblur_samples"); - RNA_def_property_range(prop, 1, 32); - RNA_def_property_ui_text(prop, "Motion Samples", "Number of scene samples to take with motion blur"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); - prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "blurfac"); RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 2); @@ -6094,17 +4884,24 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_struct_type(prop, "CurveMapping"); RNA_def_property_ui_text(prop, "Shutter Curve", "Curve defining the shutter's openness over time"); + /* Hairs */ + prop = RNA_def_property(srna, "hair_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, hair_shape_type_items); + RNA_def_property_ui_text(prop, "Hair Shape Type", "Hair shape type"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + + prop = RNA_def_property(srna, "hair_subdiv", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, 3); + RNA_def_property_ui_text(prop, "Additional Subdiv", "Additional subdivision along the hair"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + /* border */ prop = RNA_def_property(srna, "use_border", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_BORDER); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Border", - "Render a user-defined border region, within the frame size " - "(note that this disables save_buffers and full_sample)"); + RNA_def_property_ui_text(prop, "Border", "Render a user-defined border region, within the frame size "); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - prop = RNA_def_property(srna, "border_min_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "border.xmin"); RNA_def_property_range(prop, 0.0f, 1.0f); @@ -6194,16 +4991,9 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Movie Format", "When true the format is a movie"); - prop = RNA_def_property(srna, "use_free_image_textures", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE); - RNA_def_property_ui_text(prop, "Free Image Textures", - "Free all image textures from memory after render, to save memory before compositing"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_save_buffers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXR_TILE_FILE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_save_buffers_get", NULL); RNA_def_property_ui_text(prop, "Save Buffers", "Save tiles for all RenderLayers and SceneNodes to files in the temp directory " "(saves memory, required for Full Sample)"); @@ -6254,46 +5044,17 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Bake Mode", "Choose shading information to bake into the image"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "bake_normal_space", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "bake_normal_space"); - RNA_def_property_enum_items(prop, bake_normal_space_items); - RNA_def_property_ui_text(prop, "Normal Space", "Choose normal space for baking"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - prop = RNA_def_property(srna, "bake_quad_split", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, bake_qyad_split_items); - RNA_def_property_ui_text(prop, "Quad Split", "Choose the method used to split a quad into 2 triangles for baking"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - prop = RNA_def_property(srna, "bake_aa_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "bake_osa"); - RNA_def_property_enum_items(prop, fixed_oversample_items); - RNA_def_property_ui_text(prop, "Anti-Aliasing Level", ""); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_bake_selected_to_active", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_TO_ACTIVE); RNA_def_property_ui_text(prop, "Selected to Active", "Bake shading on the surface of selected objects to the active object"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_bake_normalize", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_NORMALIZE); - RNA_def_property_ui_text(prop, "Normalized", - "With displacement normalize to the distance, with ambient occlusion " - "normalize without using material settings"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_bake_clear", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_CLEAR); RNA_def_property_ui_text(prop, "Clear", "Clear Images before baking"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_bake_antialiasing", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_OSA); - RNA_def_property_ui_text(prop, "Anti-Aliasing", "Enables Anti-aliasing"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "bake_margin", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "bake_filter"); RNA_def_property_range(prop, 0, 64); @@ -6301,13 +5062,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) "Extends the baked result as a post process filter"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "bake_distance", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "bake_maxdist"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Distance", - "Maximum distance from active object to other object (in blender units)"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "bake_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bake_biasdist"); RNA_def_property_range(prop, 0.0, 1000.0); @@ -6332,12 +5086,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Samples", "Number of samples used for ambient occlusion baking from multires"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_bake_to_vertex_color", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_VCOL); - RNA_def_property_ui_text(prop, "Bake to Vertex Color", - "Bake to vertex colors instead of to a UV-mapped image"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_bake_user_scale", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_USERSCALE); RNA_def_property_ui_text(prop, "User scale", "Use a user scale for the derivative map"); @@ -6425,7 +5173,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "use_stamp_labels", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "stamp", R_STAMP_HIDE_LABELS); - RNA_def_property_ui_text(prop, "Stamp Labels", "Draw stamp labels (\"Camera\" in front of camera name, etc.)"); + RNA_def_property_ui_text(prop, "Stamp Labels", "Display stamp labels (\"Camera\" in front of camera name, etc.)"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_strip_meta", PROP_BOOLEAN, PROP_NONE); @@ -6468,21 +5216,21 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "sequencer_gl_preview", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "seq_prev_type"); - RNA_def_property_enum_items(prop, rna_enum_viewport_shade_items); + RNA_def_property_enum_items(prop, rna_enum_shading_type_items); RNA_def_property_ui_text(prop, "Sequencer Preview Shading", "Method to draw in the sequencer view"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update"); #if 0 /* UNUSED, see R_SEQ_GL_REND comment */ prop = RNA_def_property(srna, "sequencer_gl_render", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "seq_rend_type"); - RNA_def_property_enum_items(prop, rna_enum_viewport_shade_items); + RNA_def_property_enum_items(prop, rna_enum_shading_type_items); /* XXX Label and tooltips are obviously wrong! */ RNA_def_property_ui_text(prop, "Sequencer Preview Shading", "Method to draw in the sequencer view"); #endif prop = RNA_def_property(srna, "use_sequencer_gl_textured_solid", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_SOLID_TEX); - RNA_def_property_ui_text(prop, "Textured Solid", "Draw face-assigned textures in solid draw method"); + RNA_def_property_ui_text(prop, "Textured Solid", "Display face-assigned textures in solid draw method"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update"); prop = RNA_def_property(srna, "use_sequencer_gl_dof", PROP_BOOLEAN, PROP_NONE); @@ -6490,18 +5238,10 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Depth of Field", "Use depth of field using the values from scene strip active camera"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update"); - /* layers */ - prop = RNA_def_property(srna, "layers", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "layers", NULL); - RNA_def_property_struct_type(prop, "SceneRenderLayer"); - RNA_def_property_ui_text(prop, "Render Layers", ""); - rna_def_render_layers(brna, prop); - - prop = RNA_def_property(srna, "use_single_layer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_SINGLE_LAYER); - RNA_def_property_ui_text(prop, "Single Layer", "Only render the active layer"); - RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); + RNA_def_property_ui_text(prop, "Render Single Layer", "Only render the active layer. Only affects rendering from the interface, ignored for rendering from command line"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* views (stereoscopy et al) */ @@ -6544,21 +5284,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available"); - prop = RNA_def_property(srna, "use_shading_nodes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_shading_nodes_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Use Shading Nodes", "Active render engine uses new shading nodes system"); - prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_spherical_stereo_get", NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Use Spherical Stereo", "Active render engine supports spherical stereo rendering"); - prop = RNA_def_property(srna, "use_game_engine", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_game_engine_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine"); - /* simplify */ prop = RNA_def_property(srna, "use_simplify", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SIMPLIFY); @@ -6587,20 +5317,36 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Simplify Child Particles", "Global child particles percentage during rendering"); RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); - prop = RNA_def_property(srna, "simplify_shadow_samples", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "simplify_shadowsamples"); - RNA_def_property_ui_range(prop, 1, 16, 1, -1); - RNA_def_property_ui_text(prop, "Simplify Shadow Samples", "Global maximum shadow samples"); - RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); - - prop = RNA_def_property(srna, "simplify_ao_sss", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "simplify_aosss"); - RNA_def_property_ui_text(prop, "Simplify AO and SSS", "Global approximate AO and SSS quality factor"); - RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); - - prop = RNA_def_property(srna, "use_simplify_triangulate", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE); - RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planar quads being triangulated"); + /* Grease Pencil - Simplify Options */ + prop = RNA_def_property(srna, "simplify_gpencil", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_ENABLE); + RNA_def_property_ui_text(prop, "Simplify", "Simplify Grease Pencil drawing"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "simplify_gpencil_onplay", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_ON_PLAY); + RNA_def_property_ui_text(prop, "Simplify Playback", "Simplify Grease Pencil only during animation playback"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "simplify_gpencil_view_fill", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_FILL); + RNA_def_property_ui_text(prop, "Disable Fill", "Disable fill strokes in the viewport"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "simplify_gpencil_remove_lines", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_REMOVE_FILL_LINE); + RNA_def_property_ui_text(prop, "Disable Lines", "Disable external lines of fill strokes"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "simplify_gpencil_view_modifier", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_MODIFIER); + RNA_def_property_ui_text(prop, "Disable Modifiers", "Do not apply modifiers in the viewport"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "simplify_gpencil_shader_fx", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_FX); + RNA_def_property_ui_text(prop, "Simplify Shaders", "Do not apply shader fx"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* persistent data */ prop = RNA_def_property(srna, "use_persistent_data", PROP_BOOLEAN, PROP_NONE); @@ -6644,61 +5390,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna) static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; - PropertyRNA *prop; - - FunctionRNA *func; - PropertyRNA *parm; RNA_def_property_srna(cprop, "SceneObjects"); srna = RNA_def_struct(brna, "SceneObjects", NULL); RNA_def_struct_sdna(srna, "Scene"); - RNA_def_struct_ui_text(srna, "Scene Objects", "Collection of scene objects"); - - func = RNA_def_function(srna, "link", "rna_Scene_object_link"); - RNA_def_function_ui_description(func, "Link object to scene, run scene.update() after"); - RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "object", "Object", "", "Object to add to scene"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_pointer(func, "base", "ObjectBase", "", "The newly created base"); - RNA_def_function_return(func, parm); - - func = RNA_def_function(srna, "unlink", "rna_Scene_object_unlink"); - RNA_def_function_ui_description(func, "Unlink object from scene"); - RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove from scene"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - - prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_funcs(prop, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); - RNA_def_property_ui_text(prop, "Active Object", "Active object for this scene"); - /* Could call: ED_base_object_activate(C, scene->basact); - * but would be a bad level call and it seems the notifier is enough */ - RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL); -} - - -/* scene.bases.* */ -static void rna_def_scene_bases(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - PropertyRNA *prop; - -/* FunctionRNA *func; */ -/* PropertyRNA *parm; */ - - RNA_def_property_srna(cprop, "SceneBases"); - srna = RNA_def_struct(brna, "SceneBases", NULL); - RNA_def_struct_sdna(srna, "Scene"); - RNA_def_struct_ui_text(srna, "Scene Bases", "Collection of scene bases"); - - prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "ObjectBase"); - RNA_def_property_pointer_sdna(prop, NULL, "basact"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Active Base", "Active object base in the scene"); - RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL); + RNA_def_struct_ui_text(srna, "Scene Objects", "All the of scene objects"); } /* scene.timeline_markers */ @@ -6874,6 +5570,491 @@ static void rna_def_display_safe_areas(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE | ND_DRAW_RENDER_VIEWPORT, NULL); } +static void rna_def_scene_display(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static float default_light_direction[3] = {-M_SQRT1_3, -M_SQRT1_3, M_SQRT1_3}; + + srna = RNA_def_struct(brna, "SceneDisplay", NULL); + RNA_def_struct_ui_text(srna, "Scene Display", "Scene display settings for 3d viewport"); + RNA_def_struct_sdna(srna, "SceneDisplay"); + + prop = RNA_def_property(srna, "light_direction", PROP_FLOAT, PROP_DIRECTION); + RNA_def_property_float_sdna(prop, NULL, "light_direction"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_array(prop, 3); + RNA_def_property_float_array_default(prop, default_light_direction); + RNA_def_property_ui_text(prop, "Light Direction", "Direction of the light for shadows and highlights"); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update"); + + prop = RNA_def_property(srna, "shadow_shift", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "shadow_shift"); + RNA_def_property_float_default(prop, 0.1); + RNA_def_property_ui_text(prop, "Shadow Shift", "Shadow termination angle"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 2); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update"); + + prop = RNA_def_property(srna, "matcap_ssao_distance", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_default(prop, 0.2f); + RNA_def_property_ui_text(prop, "Distance", "Distance of object that contribute to the Cavity/Edge effect"); + RNA_def_property_range(prop, 0.0f, 100000.0f); + RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3); + + prop = RNA_def_property(srna, "matcap_ssao_attenuation", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Attenuation", "Attenuation constant"); + RNA_def_property_range(prop, 1.0f, 100000.0f); + RNA_def_property_ui_range(prop, 1.0f, 100.0f, 1, 3); + + prop = RNA_def_property(srna, "matcap_ssao_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_default(prop, 16); + RNA_def_property_ui_text(prop, "Samples", "Number of samples"); + RNA_def_property_range(prop, 1, 500); + + /* OpenGL render engine settings. */ + prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Shading Settings", "Shading settings for OpenGL render engine"); +} + +static void rna_def_scene_eevee(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static const EnumPropertyItem eevee_shadow_method_items[] = { + {SHADOW_ESM, "ESM", 0, "ESM", "Exponential Shadow Mapping"}, + {SHADOW_VSM, "VSM", 0, "VSM", "Variance Shadow Mapping"}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem eevee_shadow_size_items[] = { + {64, "64", 0, "64px", ""}, + {128, "128", 0, "128px", ""}, + {256, "256", 0, "256px", ""}, + {512, "512", 0, "512px", ""}, + {1024, "1024", 0, "1024px", ""}, + {2048, "2048", 0, "2048px", ""}, + {4096, "4096", 0, "4096px", ""}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem eevee_gi_visibility_size_items[] = { + {8, "8", 0, "8px", ""}, + {16, "16", 0, "16px", ""}, + {32, "32", 0, "32px", ""}, + {64, "64", 0, "64px", ""}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem eevee_volumetric_tile_size_items[] = { + {2, "2", 0, "2px", ""}, + {4, "4", 0, "4px", ""}, + {8, "8", 0, "8px", ""}, + {16, "16", 0, "16px", ""}, + {0, NULL, 0, NULL, NULL} + }; + + static float default_bloom_color[3] = {1.0f, 1.0f, 1.0f}; + + srna = RNA_def_struct(brna, "SceneEEVEE", NULL); + RNA_def_struct_path_func(srna, "rna_SceneEEVEE_path"); + RNA_def_struct_ui_text(srna, "Scene Display", "Scene display settings for 3d viewport"); + + /* Indirect Lighting */ + prop = RNA_def_property(srna, "gi_diffuse_bounces", PROP_INT, PROP_NONE); + RNA_def_property_int_default(prop, 3); + RNA_def_property_ui_text(prop, "Diffuse Bounces", "Number of time the light is reinjected inside light grids, " + "0 disable indirect diffuse light"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "gi_cubemap_resolution", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, eevee_shadow_size_items); + RNA_def_property_enum_default(prop, 512); + RNA_def_property_ui_text(prop, "Cubemap Size", "Size of every cubemaps"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "gi_visibility_resolution", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, eevee_gi_visibility_size_items); + RNA_def_property_enum_default(prop, 32); + RNA_def_property_ui_text(prop, "Irradiance Visibility Size", + "Size of the shadow map applied to each irradiance sample"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "gi_show_irradiance", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHOW_IRRADIANCE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_icon(prop, ICON_HIDE_ON, 1); + RNA_def_property_ui_text(prop, "Show Irradiance Cache", "Display irradiance samples in the viewport"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "gi_show_cubemaps", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHOW_CUBEMAPS); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_icon(prop, ICON_HIDE_ON, 1); + RNA_def_property_ui_text(prop, "Show Cubemap Cache", "Display captured cubemaps in the viewport"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "gi_irradiance_display_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "gi_irradiance_draw_size"); + RNA_def_property_range(prop, 0.05f, 10.0f); + RNA_def_property_float_default(prop, 0.1f); + RNA_def_property_ui_text(prop, "Irradiance Display Size", "Size of the irradiance sample spheres to debug captured light"); + + prop = RNA_def_property(srna, "gi_cubemap_display_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "gi_cubemap_draw_size"); + RNA_def_property_range(prop, 0.05f, 10.0f); + RNA_def_property_float_default(prop, 0.3f); + RNA_def_property_ui_text(prop, "Cubemap Display Size", "Size of the cubemap spheres to debug captured light"); + + prop = RNA_def_property(srna, "gi_auto_bake", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GI_AUTOBAKE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Auto Bake", "Auto bake indirect lighting when editing probes"); + + prop = RNA_def_property(srna, "gi_cache_info", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "light_cache_info"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Light Cache Info", "Info on current cache status"); + + /* Temporal Anti-Aliasing (super sampling) */ + prop = RNA_def_property(srna, "taa_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_default(prop, 16); + RNA_def_property_ui_text(prop, "Viewport Samples", "Number of samples, unlimited if 0"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "taa_render_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_default(prop, 64); + RNA_def_property_ui_text(prop, "Render Samples", "Number of samples per pixels for rendering"); + RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "use_taa_reprojection", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_TAA_REPROJECTION); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_ui_text(prop, "Viewport Denoising", "Denoise image using temporal reprojection " + "(can leave some ghosting)"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + /* Screen Space Subsurface Scattering */ + prop = RNA_def_property(srna, "use_sss", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSS_ENABLED); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Subsurface Scattering", "Enable screen space subsurface scattering"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "sss_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_default(prop, 7); + RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute the scattering effect"); + RNA_def_property_range(prop, 1, 32); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "sss_jitter_threshold", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.3f); + RNA_def_property_ui_text(prop, "Jitter Threshold", "Rotate samples that are below this threshold"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "use_sss_separate_albedo", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSS_SEPARATE_ALBEDO); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Separate Albedo", "Avoid albedo being blurred by the subsurface scattering " + "but uses more video memory"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + /* Screen Space Reflection */ + prop = RNA_def_property(srna, "use_ssr", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSR_ENABLED); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Screen Space Reflections", "Enable screen space reflection"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "use_ssr_refraction", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSR_REFRACTION); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Screen Space Refractions", "Enable screen space Refractions"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "use_ssr_halfres", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SSR_HALF_RESOLUTION); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_ui_text(prop, "Half Res Trace", "Raytrace at a lower resolution"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "ssr_quality", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.25f); + RNA_def_property_ui_text(prop, "Trace Precision", "Precision of the screen space raytracing"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "ssr_max_roughness", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_ui_text(prop, "Max Roughness", "Do not raytrace reflections for roughness above this value"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "ssr_thickness", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_default(prop, 0.2f); + RNA_def_property_ui_text(prop, "Thickness", "Pixel thickness used to detect intersection"); + RNA_def_property_range(prop, 1e-6f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 5, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "ssr_border_fade", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.075f); + RNA_def_property_ui_text(prop, "Edge Fading", "Screen percentage used to fade the SSR"); + RNA_def_property_range(prop, 0.0f, 0.5f); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "ssr_firefly_fac", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_default(prop, 10.0f); + RNA_def_property_ui_text(prop, "Clamp", "Clamp pixel intensity to remove noise (0 to disabled)"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + /* Volumetrics */ + prop = RNA_def_property(srna, "use_volumetric", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_VOLUMETRIC_ENABLED); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Volumetrics", "Enable scattering and absorbance of volumetric material"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "volumetric_start", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_default(prop, 0.1f); + RNA_def_property_ui_text(prop, "Start", "Start distance of the volumetric effect"); + RNA_def_property_range(prop, 1e-6f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "volumetric_end", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_default(prop, 100.0f); + RNA_def_property_ui_text(prop, "End", "End distance of the volumetric effect"); + RNA_def_property_range(prop, 1e-6f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "volumetric_tile_size", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_default(prop, 8); + RNA_def_property_enum_items(prop, eevee_volumetric_tile_size_items); + RNA_def_property_ui_text(prop, "Tile Size", "Control the quality of the volumetric effects " + "(lower size increase vram usage and quality)"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "volumetric_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_default(prop, 64); + RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute volumetric effects"); + RNA_def_property_range(prop, 1, 256); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "volumetric_sample_distribution", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.8f); + RNA_def_property_ui_text(prop, "Exponential Sampling", "Distribute more samples closer to the camera"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "use_volumetric_lights", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_VOLUMETRIC_LIGHTS); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_ui_text(prop, "Volumetric Lighting", "Enable scene light interactions with volumetrics"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "volumetric_light_clamp", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_default(prop, 0.0f); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_text(prop, "Clamp", "Maximum light contribution, reducing noise"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "use_volumetric_shadows", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_VOLUMETRIC_SHADOWS); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Volumetric Shadows", "Generate shadows from volumetric material (Very expensive)"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "volumetric_shadow_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_default(prop, 16); + RNA_def_property_range(prop, 1, 128); + RNA_def_property_ui_text(prop, "Volumetric Shadow Samples", "Number of samples to compute volumetric shadowing"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + /* Ambient Occlusion */ + prop = RNA_def_property(srna, "use_gtao", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GTAO_ENABLED); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Ambient Occlusion", "Enable ambient occlusion to simulate medium scale indirect shadowing"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "use_gtao_bent_normals", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GTAO_BENT_NORMALS); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_ui_text(prop, "Bent Normals", "Compute main non occluded direction to sample the environment"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "use_gtao_bounce", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_GTAO_BOUNCE); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_ui_text(prop, "Bounces Approximation", "An approximation to simulate light bounces " + "giving less occlusion on brighter objects"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "gtao_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Factor", "Factor for ambient occlusion blending"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 2); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "gtao_quality", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.25f); + RNA_def_property_ui_text(prop, "Trace Precision", "Precision of the horizon search"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "gtao_distance", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_default(prop, 0.2f); + RNA_def_property_ui_text(prop, "Distance", "Distance of object that contribute to the ambient occlusion effect"); + RNA_def_property_range(prop, 0.0f, 100000.0f); + RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + /* Depth of Field */ + prop = RNA_def_property(srna, "use_dof", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_DOF_ENABLED); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Depth of Field", "Enable depth of field using the values from the active camera"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "bokeh_max_size", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 100.0f); + RNA_def_property_ui_text(prop, "Max Size", "Max size of the bokeh shape for the depth of field (lower is faster)"); + RNA_def_property_range(prop, 0.0f, 2000.0f); + RNA_def_property_ui_range(prop, 2.0f, 200.0f, 1, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "bokeh_threshold", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Sprite Threshold", "Brightness threshold for using sprite base depth of field"); + RNA_def_property_range(prop, 0.0f, 100000.0f); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + /* Bloom */ + prop = RNA_def_property(srna, "use_bloom", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_BLOOM_ENABLED); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Bloom", "High brightness pixels generate a glowing effect"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "bloom_threshold", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.8f); + RNA_def_property_ui_text(prop, "Threshold", "Filters out pixels under this level of brightness"); + RNA_def_property_range(prop, 0.0f, 100000.0f); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "bloom_color", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_array_default(prop, default_bloom_color); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Color", "Color applied to the bloom effect"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "bloom_knee", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_ui_text(prop, "Knee", "Makes transition between under/over-threshold gradual"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "bloom_radius", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 6.5f); + RNA_def_property_ui_text(prop, "Radius", "Bloom spread distance"); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "bloom_clamp", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Clamp", "Maximum intensity a bloom pixel can have"); + RNA_def_property_range(prop, 0.0f, 1000.0f); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "bloom_intensity", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_default(prop, 0.8f); + RNA_def_property_ui_text(prop, "Intensity", "Blend factor"); + RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + /* Motion blur */ + prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_MOTION_BLUR_ENABLED); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Motion Blur", "Enable motion blur effect (only in camera view)"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_default(prop, 8); + RNA_def_property_ui_text(prop, "Samples", "Number of samples to take with motion blur"); + RNA_def_property_range(prop, 1, 64); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close"); + RNA_def_property_ui_range(prop, 0.01f, 2.0f, 1, 2); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + /* Shadows */ + prop = RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_default(prop, SHADOW_ESM); + RNA_def_property_enum_items(prop, eevee_shadow_method_items); + RNA_def_property_ui_text(prop, "Method", "Technique use to compute the shadows"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "shadow_cube_size", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_default(prop, 512); + RNA_def_property_enum_items(prop, eevee_shadow_size_items); + RNA_def_property_ui_text(prop, "Cube Shadows Resolution", "Size of point and area light shadow maps"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "shadow_cascade_size", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_default(prop, 1024); + RNA_def_property_enum_items(prop, eevee_shadow_size_items); + RNA_def_property_ui_text(prop, "Directional Shadows Resolution", "Size of sun light shadow maps"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "use_shadow_high_bitdepth", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHADOW_HIGH_BITDEPTH); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "High Bitdepth", "Use 32bit shadows"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "use_soft_shadows", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHADOW_SOFT); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Soft Shadows", "Randomize shadowmaps origin to create soft shadows"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + /* Overscan */ + prop = RNA_def_property(srna, "use_overscan", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_OVERSCAN); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Overscan", "Internally render past the image border to avoid " + "screen-space effects disapearing"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + + prop = RNA_def_property(srna, "overscan_size", PROP_FLOAT, PROP_PERCENTAGE); + RNA_def_property_float_sdna(prop, NULL, "overscan"); + RNA_def_property_float_default(prop, 3.0f); + RNA_def_property_ui_text(prop, "Overscan Size", "Percentage of render size to add as overscan to the " + "internal render buffers"); + RNA_def_property_range(prop, 0.0f, 50.0f); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 2); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); +} void RNA_def_scene(BlenderRNA *brna) { @@ -6921,51 +6102,35 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); RNA_def_property_pointer_funcs(prop, NULL, "rna_Scene_set_set", NULL, NULL); RNA_def_property_ui_text(prop, "Background Scene", "Background set scene"); - RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update"); prop = RNA_def_property(srna, "world", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "World", "World used for rendering the scene"); - RNA_def_property_update(prop, NC_SCENE | ND_WORLD, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | ND_WORLD, "rna_Scene_world_update"); prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH); - RNA_def_property_float_sdna(prop, NULL, "cursor"); + RNA_def_property_float_sdna(prop, NULL, "cursor.location"); RNA_def_property_ui_text(prop, "Cursor Location", "3D cursor location"); RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4); RNA_def_property_update(prop, NC_WINDOW, NULL); - /* Bases/Objects */ - prop = RNA_def_property(srna, "object_bases", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "base", NULL); - RNA_def_property_struct_type(prop, "ObjectBase"); - RNA_def_property_ui_text(prop, "Bases", ""); - RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, - "rna_Scene_object_bases_lookup_string", NULL); - rna_def_scene_bases(brna, prop); + prop = RNA_def_property(srna, "cursor_rotation", PROP_FLOAT, PROP_QUATERNION); + RNA_def_property_float_sdna(prop, NULL, "cursor.rotation"); + RNA_def_property_ui_text(prop, "Cursor Rotation", "3D cursor rotation in quaternions (keep normalized)"); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "base", NULL); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Objects", ""); - RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_Scene_objects_get", NULL, NULL, NULL, NULL); + RNA_def_property_collection_funcs(prop, + "rna_Scene_objects_begin", + "rna_Scene_objects_next", + "rna_Scene_objects_end", + "rna_Scene_objects_get", + NULL, NULL, NULL, NULL); rna_def_scene_objects(brna, prop); - /* Layers */ - prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); - /* this seems to be too much trouble with depsgraph updates/etc. currently (20110420) */ - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); - RNA_def_property_array(prop, 20); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_layer_set"); - RNA_def_property_ui_text(prop, "Layers", "Visible layers - Shift-Click/Drag to select multiple layers"); - RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_Scene_layer_update"); - - /* active layer */ - prop = RNA_def_property(srna, "active_layer", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_int_funcs(prop, "rna_Scene_active_layer_get", NULL, NULL); - RNA_def_property_ui_text(prop, "Active Layer", "Active scene layer index"); - /* Frame Range Stuff */ prop = RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -6997,6 +6162,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "r.sfra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_start_frame_set", NULL); RNA_def_property_range(prop, MINFRAME, MAXFRAME); + RNA_def_property_int_default(prop, 1); RNA_def_property_ui_text(prop, "Start Frame", "First frame of the playback/rendering range"); RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL); @@ -7005,6 +6171,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "r.efra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_end_frame_set", NULL); RNA_def_property_range(prop, MINFRAME, MAXFRAME); + RNA_def_property_int_default(prop, 250); RNA_def_property_ui_text(prop, "End Frame", "Final frame of the playback/rendering range"); RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL); @@ -7030,7 +6197,6 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lock Frame Selection", "Don't allow frame to be selected with mouse outside of frame range"); RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL); - RNA_def_property_ui_icon(prop, ICON_LOCKED, 0); /* Preview Range (frame-range for UI playback) */ prop = RNA_def_property(srna, "use_preview_range", PROP_BOOLEAN, PROP_NONE); @@ -7091,14 +6257,17 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); /* Frame dropping flag for playback and sync enum */ +#if 0 /* XXX: Is this actually needed? */ prop = RNA_def_property(srna, "use_frame_drop", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_FRAME_DROP); RNA_def_property_ui_text(prop, "Frame Dropping", "Play back dropping frames if frame display is too slow"); RNA_def_property_update(prop, NC_SCENE, NULL); +#endif prop = RNA_def_property(srna, "sync_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_funcs(prop, "rna_Scene_sync_mode_get", "rna_Scene_sync_mode_set", NULL); RNA_def_property_enum_items(prop, sync_mode_items); + RNA_def_property_enum_default(prop, AUDIO_SYNC); RNA_def_property_ui_text(prop, "Sync Mode", "How to sync playback"); RNA_def_property_update(prop, NC_SCENE, NULL); @@ -7193,17 +6362,33 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Timeline Markers", "Markers used in all timelines for the current scene"); rna_def_timeline_markers(brna, prop); + /* Orientations */ + prop = RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "orientation_type"); + RNA_def_property_enum_items(prop, rna_enum_transform_orientation_items); + RNA_def_property_enum_funcs(prop, "rna_Scene_transform_orientation_get", "rna_Scene_transform_orientation_set", + "rna_TransformOrientation_itemf"); + RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "current_orientation", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "TransformOrientation"); + RNA_def_property_pointer_funcs(prop, "rna_Scene_current_orientation_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current transformation orientation"); + /* Audio Settings */ prop = RNA_def_property(srna, "use_audio", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_Scene_use_audio_get", "rna_Scene_use_audio_set"); RNA_def_property_ui_text(prop, "Audio Muted", "Play back of audio from Sequence Editor will be muted"); RNA_def_property_update(prop, NC_SCENE, NULL); +#if 0 /* XXX: Is this actually needed? */ prop = RNA_def_property(srna, "use_audio_sync", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "audio.flag", AUDIO_SYNC); RNA_def_property_ui_text(prop, "Audio Sync", "Play back and sync with audio clock, dropping frames if frame display is too slow"); RNA_def_property_update(prop, NC_SCENE, NULL); +#endif prop = RNA_def_property(srna, "use_audio_scrub", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "audio.flag", AUDIO_SCRUB); @@ -7239,15 +6424,10 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE, NULL); RNA_def_property_float_funcs(prop, NULL, "rna_Scene_volume_set", NULL); - /* Game Settings */ - prop = RNA_def_property(srna, "game_settings", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "gm"); - RNA_def_property_struct_type(prop, "SceneGameData"); - RNA_def_property_ui_text(prop, "Game Data", ""); - /* Statistics */ func = RNA_def_function(srna, "statistics", "ED_info_stats_string"); + parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Active layer"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_string(func, "statistics", NULL, 0, "Statistics", ""); RNA_def_function_return(func, parm); @@ -7255,16 +6435,11 @@ void RNA_def_scene(BlenderRNA *brna) 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_annotations_poll"); 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, "Annotations", "Grease Pencil data-block used for annotations in the 3D view"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - /* Transform Orientations */ - prop = RNA_def_property(srna, "orientations", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "transform_spaces", NULL); - RNA_def_property_struct_type(prop, "TransformOrientation"); - RNA_def_property_ui_text(prop, "Transform Orientations", ""); - /* active MovieClip */ prop = RNA_def_property(srna, "active_clip", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "clip"); @@ -7289,30 +6464,48 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ColorManagedSequencerColorspaceSettings"); RNA_def_property_ui_text(prop, "Sequencer Color Space Settings", "Settings of color space sequencer is working in"); - /* Dependency Graph */ - prop = RNA_def_property(srna, "depsgraph", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Depsgraph"); - RNA_def_property_ui_text(prop, "Dependency Graph", "Dependencies in the scene data"); + /* Layer and Collections */ + prop = RNA_def_property(srna, "view_layers", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "view_layers", NULL); + RNA_def_property_struct_type(prop, "ViewLayer"); + RNA_def_property_ui_text(prop, "View Layers", ""); + rna_def_view_layers(brna, prop); + + prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "master_collection"); + RNA_def_property_struct_type(prop, "Collection"); + RNA_def_property_ui_text(prop, "Collection", "Scene master collection that objects and other collections in the scene"); + + /* Scene 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, "SceneDisplay"); + RNA_def_property_ui_text(prop, "Scene Display", "Scene display settings for 3d viewport"); + + /* EEVEE */ + prop = RNA_def_property(srna, "eevee", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "SceneEEVEE"); + RNA_def_property_ui_text(prop, "EEVEE", "EEVEE settings for the scene"); /* Nestled Data */ /* *** Non-Animated *** */ RNA_define_animate_sdna(false); rna_def_tool_settings(brna); - rna_def_gpencil_brush(brna); rna_def_gpencil_interpolate(brna); rna_def_unified_paint_settings(brna); rna_def_curve_paint_settings(brna); rna_def_statvis(brna); rna_def_unit_settings(brna); rna_def_scene_image_format_data(brna); - rna_def_scene_game_data(brna); rna_def_transform_orientation(brna); rna_def_selected_uv_element(brna); rna_def_display_safe_areas(brna); + rna_def_scene_display(brna); + rna_def_scene_eevee(brna); RNA_define_animate_sdna(true); /* *** Animated *** */ rna_def_scene_render_data(brna); - rna_def_scene_render_layer(brna); rna_def_gpu_fx(brna); rna_def_scene_render_view(brna); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index eff9576248c..f25e093c8a9 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -60,13 +60,14 @@ const EnumPropertyItem rna_enum_abc_compression_items[] = { #ifdef RNA_RUNTIME #include "BKE_animsys.h" -#include "BKE_depsgraph.h" #include "BKE_editmesh.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_scene.h" #include "BKE_writeavi.h" +#include "DEG_depsgraph_query.h" + #include "ED_transform.h" #include "ED_transform_snap_object_context.h" #include "ED_uvedit.h" @@ -86,8 +87,13 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf BPy_BEGIN_ALLOW_THREADS; #endif - /* It's possible that here we're including layers which were never visible before. */ - BKE_scene_update_for_newframe_ex(bmain->eval_ctx, bmain, scene, (1 << 20) - 1, true); + for (ViewLayer *view_layer = scene->view_layers.first; + view_layer != NULL; + view_layer = view_layer->next) + { + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); + BKE_scene_graph_update_for_newframe(depsgraph, bmain); + } #ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; @@ -99,7 +105,7 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf * redrawing while the data is being modified for render */ if (!G.is_rendering) { /* cant use NC_SCENE|ND_FRAME because this causes wm_event_do_notifiers to call - * BKE_scene_update_for_newframe which will loose any un-keyed changes [#24690] */ + * BKE_scene_graph_update_for_newframe which will loose any un-keyed changes [#24690] */ /* WM_main_add_notifier(NC_SCENE|ND_FRAME, scene); */ /* instead just redraw the views */ @@ -127,7 +133,13 @@ static void rna_Scene_update_tagged(Scene *scene, Main *bmain) BPy_BEGIN_ALLOW_THREADS; #endif - BKE_scene_update_tagged(bmain->eval_ctx, bmain, scene); + for (ViewLayer *view_layer = scene->view_layers.first; + view_layer != NULL; + view_layer = view_layer->next) + { + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); + BKE_scene_graph_update_tagged(depsgraph, bmain); + } #ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; @@ -154,14 +166,15 @@ static void rna_SceneRender_get_frame_path( } static void rna_Scene_ray_cast( - Scene *scene, Main *bmain, + Scene *scene, Main *bmain, ViewLayer *view_layer, float origin[3], float direction[3], float ray_dist, bool *r_success, float r_location[3], float r_normal[3], int *r_index, Object **r_ob, float r_obmat[16]) { normalize_v3(direction); - SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, 0); + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); + SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, depsgraph, 0); bool ret = ED_transform_snap_object_project_ray_ex( sctx, @@ -174,6 +187,10 @@ static void rna_Scene_ray_cast( ED_transform_snap_object_context_destroy(sctx); + if (r_ob != NULL && *r_ob != NULL) { + *r_ob = DEG_get_original_object(*r_ob); + } + if (ret) { *r_success = true; } @@ -299,6 +316,8 @@ void RNA_api_scene(StructRNA *srna) func = RNA_def_function(srna, "ray_cast", "rna_Scene_ray_cast"); RNA_def_function_flag(func, FUNC_USE_MAIN); RNA_def_function_ui_description(func, "Cast a ray onto in object space"); + parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Scene Layer"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); /* ray start and end */ parm = RNA_def_float_vector(func, "origin", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -333,7 +352,6 @@ void RNA_api_scene(StructRNA *srna) func = RNA_def_function(srna, "sequence_editor_clear", "rna_Scene_sequencer_editing_free"); RNA_def_function_ui_description(func, "Clear sequence editor in this scene"); - #ifdef WITH_ALEMBIC /* XXX Deprecated, will be removed in 2.8 in favour of calling the export operator. */ func = RNA_def_function(srna, "alembic_export", "rna_Scene_alembic_export"); @@ -362,7 +380,7 @@ void RNA_api_scene(StructRNA *srna) RNA_def_boolean(func, "export_hair", 1, "Export Hair", "Exports hair particle systems as animated curves"); RNA_def_boolean(func, "export_particles", 1, "Export Particles", "Exports non-hair particle systems"); RNA_def_enum(func, "compression_type", rna_enum_abc_compression_items, 0, "Compression", ""); - RNA_def_boolean(func, "packuv" , 0, "Export with packed UV islands", "Export with packed UV islands"); + RNA_def_boolean(func, "packuv", 0, "Export with packed UV islands", "Export with packed UV islands"); RNA_def_float(func, "scale", 1.0f, 0.0001f, 1000.0f, "Scale", "Value by which to enlarge or shrink the objects with respect to the world's origin", 0.0001f, 1000.0f); RNA_def_boolean(func, "triangulate", 0, "Triangulate", "Export Polygons (Quads & NGons) as Triangles"); RNA_def_enum(func, "quad_method", rna_enum_modifier_triangulate_quad_method_items, 0, "Quad Method", "Method for splitting the quads into triangles"); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 0a997ca2163..f4311f820ce 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -35,6 +35,7 @@ #include "DNA_screen_types.h" #include "DNA_scene_types.h" +#include "DNA_workspace_types.h" const EnumPropertyItem rna_enum_region_type_items[] = { {RGN_TYPE_WINDOW, "WINDOW", 0, "Window", ""}, @@ -45,6 +46,7 @@ const EnumPropertyItem rna_enum_region_type_items[] = { {RGN_TYPE_TOOLS, "TOOLS", 0, "Tools", ""}, {RGN_TYPE_TOOL_PROPS, "TOOL_PROPS", 0, "Tool Properties", ""}, {RGN_TYPE_PREVIEW, "PREVIEW", 0, "Preview", ""}, + {RGN_TYPE_NAV_BAR, "NAVIGATION_BAR", 0, "Navigation Bar", ""}, {0, NULL, 0, NULL, NULL} }; @@ -56,7 +58,10 @@ const EnumPropertyItem rna_enum_region_type_items[] = { #ifdef RNA_RUNTIME #include "BKE_global.h" -#include "BKE_depsgraph.h" +#include "BKE_workspace.h" +#include "BKE_screen.h" + +#include "DEG_depsgraph.h" #include "UI_view2d.h" @@ -64,55 +69,72 @@ const EnumPropertyItem rna_enum_region_type_items[] = { # include "BPY_extern.h" #endif -static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value) +static void rna_Screen_bar_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - bScreen *sc = (bScreen *)ptr->data; - - if (value.data == NULL) - return; - - sc->newscene = value.data; + bScreen *screen = (bScreen *)ptr->data; + screen->do_draw = true; + screen->do_refresh = true; } -static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr) +static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - bScreen *sc = (bScreen *)ptr->data; - - /* exception: must use context so notifier gets to the right window */ - if (sc->newscene) { -#ifdef WITH_PYTHON - BPy_BEGIN_ALLOW_THREADS; -#endif + bScreen *screen = (bScreen *)ptr->data; - ED_screen_set_scene(C, sc, sc->newscene); + /* the settings for this are currently only available from a menu in the TimeLine, + * hence refresh=SPACE_ACTION, as timeline is now in there + */ + ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_ACTION); +} -#ifdef WITH_PYTHON - BPy_END_ALLOW_THREADS; -#endif +static bool rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) +{ + /* can be NULL on file load, T42619 */ + wmWindowManager *wm = G_MAIN->wm.first; + return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; +} - WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, sc->newscene); +static int rna_region_alignment_get(PointerRNA *ptr) +{ + ARegion *region = ptr->data; + return (region->alignment & ~RGN_SPLIT_PREV); +} - if (G.debug & G_DEBUG) - printf("scene set %p\n", sc->newscene); +static void rna_Screen_layout_name_get(PointerRNA *ptr, char *value) +{ + const bScreen *screen = ptr->data; + const WorkSpaceLayout *layout = BKE_workspace_layout_find_global(G_MAIN, screen, NULL); - sc->newscene = NULL; + if (layout) { + const char *name = BKE_workspace_layout_name_get(layout); + strcpy(value, name); + } + else { + value[0] = '\0'; } } -static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static int rna_Screen_layout_name_length(PointerRNA *ptr) { - bScreen *screen = (bScreen *)ptr->data; + const bScreen *screen = ptr->data; + const WorkSpaceLayout *layout = BKE_workspace_layout_find_global(G_MAIN, screen, NULL); - /* the settings for this are currently only available from a menu in the TimeLine, hence refresh=SPACE_TIME */ - ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_TIME); -} + if (layout) { + const char *name = BKE_workspace_layout_name_get(layout); + return strlen(name); + } + return 0; +} -static bool rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) +static void rna_Screen_layout_name_set(PointerRNA *ptr, const char *value) { - /* can be NULL on file load, T42619 */ - wmWindowManager *wm = G_MAIN->wm.first; - return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; + bScreen *screen = ptr->data; + WorkSpace *workspace; + WorkSpaceLayout *layout = BKE_workspace_layout_find_global(G_MAIN, screen, &workspace); + + if (layout) { + BKE_workspace_layout_name_set(workspace, layout, value); + } } static bool rna_Screen_fullscreen_get(PointerRNA *ptr) @@ -124,21 +146,41 @@ static bool rna_Screen_fullscreen_get(PointerRNA *ptr) /* UI compatible list: should not be needed, but for now we need to keep EMPTY * at least in the static version of this enum for python scripts. */ static const EnumPropertyItem *rna_Area_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) + PropertyRNA *UNUSED(prop), bool *r_free) { + EnumPropertyItem *item = NULL; + int totitem = 0; + /* +1 to skip SPACE_EMPTY */ - return rna_enum_space_type_items + 1; + for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) { + if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR, SPACE_USERPREF)) { + continue; + } + RNA_enum_item_add(&item, &totitem, item_from); + } + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; } static int rna_Area_type_get(PointerRNA *ptr) { ScrArea *sa = (ScrArea *)ptr->data; - /* read from this instead of 'spacetype' for correct reporting: T41435 */ - return sa->butspacetype; + /* Usually 'spacetype' is used. It lags behind a bit while switching area + * type though, then we use 'butspacetype' instead (T41435). */ + return (sa->butspacetype == SPACE_EMPTY) ? sa->spacetype : sa->butspacetype; } static void rna_Area_type_set(PointerRNA *ptr, int value) { + if (ELEM(value, SPACE_TOPBAR, SPACE_STATUSBAR, SPACE_USERPREF)) { + /* Special case: An area can not be set to show the top-bar editor (or + * other global areas). However it should still be possible to identify + * its type from Python. */ + return; + } + ScrArea *sa = (ScrArea *)ptr->data; sa->butspacetype = value; } @@ -152,7 +194,7 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr) /* XXX this call still use context, so we trick it to work in the right context */ for (win = wm->windows.first; win; win = win->next) { - if (sc == win->screen) { + if (sc == WM_window_get_active_screen(win)) { wmWindow *prevwin = CTX_wm_window(C); ScrArea *prevsa = CTX_wm_area(C); ARegion *prevar = CTX_wm_region(C); @@ -164,9 +206,12 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr) ED_area_newspace(C, sa, sa->butspacetype, true); ED_area_tag_redraw(sa); + /* Unset so that rna_Area_type_get uses spacetype instead. */ + sa->butspacetype = SPACE_EMPTY; + /* It is possible that new layers becomes visible. */ if (sa->spacetype == SPACE_VIEW3D) { - DAG_on_visible_update(CTX_data_main(C), false); + DEG_on_visible_update(CTX_data_main(C), false); } CTX_wm_window_set(C, prevwin); @@ -177,6 +222,75 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr) } } + +static const EnumPropertyItem *rna_Area_ui_type_itemf( + bContext *C, PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), bool *r_free) +{ + EnumPropertyItem *item = NULL; + int totitem = 0; + + /* +1 to skip SPACE_EMPTY */ + for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) { + if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR, SPACE_USERPREF)) { + continue; + } + + SpaceType *st = item_from->identifier[0] ? BKE_spacetype_from_id(item_from->value) : NULL; + int totitem_prev = totitem; + if (st && st->space_subtype_item_extend != NULL) { + st->space_subtype_item_extend(C, &item, &totitem); + while (totitem_prev < totitem) { + item[totitem_prev++].value |= item_from->value << 16; + } + } + else { + RNA_enum_item_add(&item, &totitem, item_from); + item[totitem_prev++].value = item_from->value << 16; + } + } + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + +static int rna_Area_ui_type_get(PointerRNA *ptr) +{ + int value = rna_Area_type_get(ptr) << 16; + ScrArea *sa = ptr->data; + if (sa->type->space_subtype_item_extend != NULL) { + value |= sa->type->space_subtype_get(sa); + } + return value; +} + +static void rna_Area_ui_type_set(PointerRNA *ptr, int value) +{ + ScrArea *sa = ptr->data; + const int space_type = value >> 16; + SpaceType *st = BKE_spacetype_from_id(space_type); + + rna_Area_type_set(ptr, space_type); + + if (st && st->space_subtype_item_extend != NULL) { + sa->butspacetype_subtype = value & 0xffff; + } +} + +static void rna_Area_ui_type_update(bContext *C, PointerRNA *ptr) +{ + ScrArea *sa = ptr->data; + SpaceType *st = BKE_spacetype_from_id(sa->butspacetype); + + rna_Area_type_update(C, ptr); + + if ((sa->type == st) && (st->space_subtype_item_extend != NULL)) { + st->space_subtype_set(sa, sa->butspacetype_subtype); + } + sa->butspacetype_subtype = 0; +} + static void rna_View2D_region_to_view(struct View2D *v2d, int x, int y, float result[2]) { UI_view2d_region_to_view(v2d, x, y, &result[0], &result[1]); @@ -212,12 +326,15 @@ static void rna_def_area_spaces(BlenderRNA *brna, PropertyRNA *cprop) static void rna_def_area_api(StructRNA *srna) { FunctionRNA *func; + PropertyRNA *parm; RNA_def_function(srna, "tag_redraw", "ED_area_tag_redraw"); - func = RNA_def_function(srna, "header_text_set", "ED_area_headerprint"); - RNA_def_function_ui_description(func, "Set the header text"); - RNA_def_string(func, "text", NULL, 0, "Text", "New string for the header, no argument clears the text"); + func = RNA_def_function(srna, "header_text_set", "ED_area_status_text"); + RNA_def_function_ui_description(func, "Set the header status text"); + parm = RNA_def_string(func, "text", NULL, 0, "Text", "New string for the header, None clears the text"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_property_clear_flag(parm, PROP_NEVER_NULL); } static void rna_def_area(BlenderRNA *brna) @@ -257,6 +374,15 @@ static void rna_def_area(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, 0, "rna_Area_type_update"); + prop = RNA_def_property(srna, "ui_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); /* infact dummy */ + RNA_def_property_enum_default(prop, 0); + RNA_def_property_enum_funcs(prop, "rna_Area_ui_type_get", "rna_Area_ui_type_set", "rna_Area_ui_type_itemf"); + RNA_def_property_ui_text(prop, "Editor Type", "Current editor type for this area"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, 0, "rna_Area_ui_type_update"); + prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "totrct.xmin"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -329,15 +455,23 @@ static void rna_def_region(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static const EnumPropertyItem alignment_types[] = { + {RGN_ALIGN_NONE, "NONE", 0, "None", "Don't use any fixed alignment, fill available space"}, + {RGN_ALIGN_TOP, "TOP", 0, "Top", ""}, + {RGN_ALIGN_BOTTOM, "BOTTOM", 0, "Bottom", ""}, + {RGN_ALIGN_LEFT, "LEFT", 0, "Left", ""}, + {RGN_ALIGN_RIGHT, "RIGHT", 0, "Right", ""}, + {RGN_ALIGN_HSPLIT, "HORIZONTAL_SPLIT", 0, "Horizontal Split", ""}, + {RGN_ALIGN_VSPLIT, "VERTICAL_SPLIT", 0, "Vertical Split", ""}, + {RGN_ALIGN_FLOAT, "FLOAT", 0, "Float", "Region floats on screen, doesn't use any fixed alignment"}, + {RGN_ALIGN_QSPLIT, "QUAD_SPLIT", 0, "Quad Split", "Region is split horizontally and vertically"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "Region", NULL); RNA_def_struct_ui_text(srna, "Region", "Region in a subdivided screen area"); RNA_def_struct_sdna(srna, "ARegion"); - prop = RNA_def_property(srna, "id", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "swinid"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Region ID", "Unique ID for this region"); - prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "regiontype"); RNA_def_property_enum_items(prop, rna_enum_region_type_items); @@ -370,6 +504,12 @@ static void rna_def_region(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_ui_text(prop, "View2D", "2D view of the region"); + prop = RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_items(prop, alignment_types); + RNA_def_property_enum_funcs(prop, "rna_region_alignment_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Alignment", "Alignment of the region within the area"); + RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw"); } @@ -381,15 +521,13 @@ static void rna_def_screen(BlenderRNA *brna) srna = RNA_def_struct(brna, "Screen", "ID"); RNA_def_struct_sdna(srna, "Screen"); /* it is actually bScreen but for 2.5 the dna is patched! */ RNA_def_struct_ui_text(srna, "Screen", "Screen data-block, defining the layout of areas in a window"); - RNA_def_struct_ui_icon(srna, ICON_SPLITSCREEN); + RNA_def_struct_ui_icon(srna, ICON_WORKSPACE); - /* pointers */ - prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); - RNA_def_property_pointer_funcs(prop, NULL, "rna_Screen_scene_set", NULL, NULL); - RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the screen"); - RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); - RNA_def_property_update(prop, 0, "rna_Screen_scene_update"); + prop = RNA_def_property(srna, "layout_name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_Screen_layout_name_get", "rna_Screen_layout_name_length", + "rna_Screen_layout_name_set"); + RNA_def_property_ui_text(prop, "Layout Name", "The name of the layout that refers to the screen"); + RNA_def_struct_name_property(srna, prop); /* collections */ prop = RNA_def_property(srna, "areas", PROP_COLLECTION, PROP_NONE); @@ -408,6 +546,16 @@ static void rna_def_screen(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL); RNA_def_property_ui_text(prop, "Maximize", "An area is maximized, filling this screen"); + prop = RNA_def_property(srna, "show_topbar", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SCREEN_COLLAPSE_TOPBAR); + RNA_def_property_ui_text(prop, "Show Top Bar", "Show top bar with tool settings"); + RNA_def_property_update(prop, 0, "rna_Screen_bar_update"); + + prop = RNA_def_property(srna, "show_statusbar", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SCREEN_COLLAPSE_STATUSBAR); + RNA_def_property_ui_text(prop, "Show Status Bar", "Show status bar"); + RNA_def_property_update(prop, 0, "rna_Screen_bar_update"); + /* Define Anim Playback Areas */ prop = RNA_def_property(srna, "use_play_top_left_3d_editor", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_REGION); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 92f05bf366f..841a5be1aff 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -35,6 +35,7 @@ #include "rna_internal.h" #include "DNA_ID.h" +#include "DNA_gpencil_types.h" #include "DNA_scene_types.h" #include "DNA_brush_types.h" #include "DNA_screen_types.h" @@ -43,6 +44,7 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_paint.h" +#include "BKE_brush.h" #include "ED_image.h" @@ -64,26 +66,29 @@ const EnumPropertyItem rna_enum_particle_edit_hair_brush_items[] = { }; const EnumPropertyItem rna_enum_gpencil_sculpt_brush_items[] = { - {GP_EDITBRUSH_TYPE_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth stroke points"}, - {GP_EDITBRUSH_TYPE_THICKNESS, "THICKNESS", 0, "Thickness", "Adjust thickness of strokes"}, - { GP_EDITBRUSH_TYPE_STRENGTH, "STRENGTH", 0, "Strength", "Adjust color strength of strokes" }, - { GP_EDITBRUSH_TYPE_GRAB, "GRAB", 0, "Grab", "Translate the set of points initially within the brush circle" }, - {GP_EDITBRUSH_TYPE_PUSH, "PUSH", 0, "Push", "Move points out of the way, as if combing them"}, - {GP_EDITBRUSH_TYPE_TWIST, "TWIST", 0, "Twist", "Rotate points around the midpoint of the brush"}, - {GP_EDITBRUSH_TYPE_PINCH, "PINCH", 0, "Pinch", "Pull points towards the midpoint of the brush"}, - {GP_EDITBRUSH_TYPE_RANDOMIZE, "RANDOMIZE", 0, "Randomize", "Introduce jitter/randomness into strokes"}, - //{GP_EDITBRUSH_TYPE_SUBDIVIDE, "SUBDIVIDE", 0, "Subdivide", "Increase point density for higher resolution strokes when zoomed in"}, - //{GP_EDITBRUSH_TYPE_SIMPLIFY, "SIMPLIFY", 0, "Simplify", "Reduce density of stroke points"}, - {GP_EDITBRUSH_TYPE_CLONE, "CLONE", 0, "Clone", "Paste copies of the strokes stored on the clipboard"}, + {GP_EDITBRUSH_TYPE_SMOOTH, "SMOOTH", ICON_GPBRUSH_SMOOTH, "Smooth", "Smooth stroke points"}, + {GP_EDITBRUSH_TYPE_THICKNESS, "THICKNESS", ICON_GPBRUSH_THICKNESS, "Thickness", "Adjust thickness of strokes"}, + {GP_EDITBRUSH_TYPE_STRENGTH, "STRENGTH", ICON_GPBRUSH_STRENGTH, "Strength", "Adjust color strength of strokes" }, + {GP_EDITBRUSH_TYPE_GRAB, "GRAB", ICON_GPBRUSH_GRAB, "Grab", "Translate the set of points initially within the brush circle" }, + {GP_EDITBRUSH_TYPE_PUSH, "PUSH", ICON_GPBRUSH_PUSH, "Push", "Move points out of the way, as if combing them"}, + {GP_EDITBRUSH_TYPE_TWIST, "TWIST", ICON_GPBRUSH_TWIST, "Twist", "Rotate points around the midpoint of the brush"}, + {GP_EDITBRUSH_TYPE_PINCH, "PINCH", ICON_GPBRUSH_PINCH, "Pinch", "Pull points towards the midpoint of the brush"}, + {GP_EDITBRUSH_TYPE_RANDOMIZE, "RANDOMIZE", ICON_GPBRUSH_RANDOMIZE, "Randomize", "Introduce jitter/randomness into strokes"}, + {GP_EDITBRUSH_TYPE_CLONE, "CLONE", ICON_GPBRUSH_CLONE, "Clone", "Paste copies of the strokes stored on the clipboard"}, { 0, NULL, 0, NULL, NULL } }; #ifndef RNA_RUNTIME -static const EnumPropertyItem rna_enum_gpencil_lockaxis_items[] = { - { GP_LOCKAXIS_NONE, "GP_LOCKAXIS_NONE", 0, "None", "" }, - { GP_LOCKAXIS_X, "GP_LOCKAXIS_X", 0, "X", "Project strokes to plane locked to X" }, - { GP_LOCKAXIS_Y, "GP_LOCKAXIS_Y", 0, "Y", "Project strokes to plane locked to Y" }, - { GP_LOCKAXIS_Z, "GP_LOCKAXIS_Z", 0, "Z", "Project strokes to plane locked to Z" }, +static EnumPropertyItem rna_enum_gpencil_weight_brush_items[] = { + { GP_EDITBRUSH_TYPE_WEIGHT, "WEIGHT", ICON_GPBRUSH_WEIGHT, "Weight", "Weight Paint for Vertex Groups" }, + { 0, NULL, 0, NULL, NULL } +}; + +static const EnumPropertyItem rna_enum_gpencil_lock_axis_items[] = { + { GP_LOCKAXIS_VIEW, "VIEW", ICON_RESTRICT_VIEW_ON, "View", "Align strokes to current view plane" }, + { GP_LOCKAXIS_X, "AXIS_X", ICON_AXIS_SIDE, "Y-Z Plane", "Project strokes to plane locked to X" }, + { GP_LOCKAXIS_Y, "AXIS_Y", ICON_AXIS_FRONT, "X-Z Plane", "Project strokes to plane locked to Y" }, + { GP_LOCKAXIS_Z, "AXIS_Z", ICON_AXIS_TOP, "X-Y Plane", "Project strokes to plane locked to Z" }, { 0, NULL, 0, NULL, NULL } }; #endif @@ -103,20 +108,36 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = { #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" +#include "BKE_collection.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" -#include "BKE_DerivedMesh.h" -#include "BKE_global.h" #include "BKE_particle.h" -#include "BKE_pointcache.h" #include "BKE_pbvh.h" +#include "BKE_pointcache.h" +#include "BKE_object.h" +#include "BKE_gpencil.h" + -#include "GPU_buffers.h" +#include "DEG_depsgraph.h" #include "ED_particle.h" -static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +static void rna_GPencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { + /* mark all grease pencil datablocks of the scene */ + FOREACH_SCENE_COLLECTION_BEGIN(scene, collection) + { + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, ob) + { + if (ob->type == OB_GPENCIL) { + bGPdata *gpd = (bGPdata *)ob->data; + gpd->flag |= GP_DATA_CACHE_IS_DIRTY; + DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA); + } + } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; + } + FOREACH_SCENE_COLLECTION_END; + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } @@ -154,32 +175,43 @@ static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_CurveMapping, NULL); } -static void rna_ParticleEdit_redo(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ParticleEdit_redo(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = (scene->basact) ? scene->basact->object : NULL; - PTCacheEdit *edit = PE_get_current(bmain, scene, ob); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); + PTCacheEdit *edit = PE_get_current(scene, ob); if (!edit) return; + if (ob) DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + + BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL); psys_free_path_cache(edit->psys, edit); + DEG_id_tag_update(&CTX_data_scene(C)->id, DEG_TAG_COPY_ON_WRITE); } -static void rna_ParticleEdit_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ParticleEdit_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = (scene->basact) ? scene->basact->object : NULL; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); + + if (ob) DEG_id_tag_update(&ob->id, OB_RECALC_DATA); - if (ob) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + /* Sync tool setting changes from original to evaluated scenes. */ + DEG_id_tag_update(&CTX_data_scene(C)->id, DEG_TAG_COPY_ON_WRITE); } + static void rna_ParticleEdit_tool_set(PointerRNA *ptr, int value) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; /* redraw hair completely if weight brush is/was used */ - if ((pset->brushtype == PE_BRUSH_WEIGHT || value == PE_BRUSH_WEIGHT) && pset->scene) { - Object *ob = (pset->scene->basact) ? pset->scene->basact->object : NULL; + if ((pset->brushtype == PE_BRUSH_WEIGHT || value == PE_BRUSH_WEIGHT) && pset->object) { + Object *ob = pset->object; if (ob) { - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); } } @@ -190,11 +222,11 @@ static const EnumPropertyItem *rna_ParticleEdit_tool_itemf( bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) { - Scene *scene = CTX_data_scene(C); - Object *ob = (scene->basact) ? scene->basact->object : NULL; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); #if 0 - Main *bmain = CTX_data_main(C); - PTCacheEdit *edit = PE_get_current(bmain, scene, ob); + Scene *scene = CTX_data_scene(C); + PTCacheEdit *edit = PE_get_current(scene, ob); ParticleSystem *psys = edit ? edit->psys : NULL; #else /* use this rather than PE_get_current() - because the editing cache is @@ -219,20 +251,14 @@ static bool rna_ParticleEdit_editable_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; - if (pset->object != NULL && pset->scene != NULL) { - BLI_assert(BKE_id_is_in_gobal_main(&pset->object->id)); - BLI_assert(BKE_id_is_in_gobal_main(&pset->scene->id)); - } - return (pset->object && pset->scene && PE_get_current(G_MAIN, pset->scene, pset->object)); + return (pset->object && pset->scene && PE_get_current(pset->scene, pset->object)); } static bool rna_ParticleEdit_hair_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; if (pset->scene) { - BLI_assert(BKE_id_is_in_gobal_main(&pset->scene->id)); - BLI_assert(BKE_id_is_in_gobal_main(&pset->object->id)); - PTCacheEdit *edit = PE_get_current(G_MAIN, pset->scene, pset->object); + PTCacheEdit *edit = PE_get_current(pset->scene, pset->object); return (edit && edit->psys); } @@ -247,32 +273,88 @@ static char *rna_ParticleEdit_path(PointerRNA *UNUSED(ptr)) static bool rna_Brush_mode_poll(PointerRNA *ptr, PointerRNA value) { + const Paint *paint = ptr->data; + Brush *brush = value.id.data; + const uint tool_offset = paint->runtime.tool_offset; + const eObjectMode ob_mode = paint->runtime.ob_mode; + BLI_assert(tool_offset && ob_mode); + + if (brush->ob_mode & ob_mode) { + if (paint->brush) { + if (BKE_brush_tool_get(paint->brush, paint) == BKE_brush_tool_get(brush, paint)) { + return true; + } + } + else { + return true; + } + } + + return false; +} + +static bool paint_contains_brush_slot(const Paint *paint, const PaintToolSlot *tslot, int *r_index) +{ + if ((tslot >= paint->tool_slots) && + (tslot < (paint->tool_slots + paint->tool_slots_len))) + { + *r_index = (int)(tslot - paint->tool_slots); + return true; + } + return false; +} + +static bool rna_Brush_mode_with_tool_poll(PointerRNA *ptr, PointerRNA value) +{ Scene *scene = (Scene *)ptr->id.data; + const PaintToolSlot *tslot = ptr->data; ToolSettings *ts = scene->toolsettings; Brush *brush = value.id.data; int mode = 0; + int slot_index = 0; - /* check the origin of the Paint struct to see which paint - * mode to select from */ - - if (ptr->data == &ts->imapaint) + if (paint_contains_brush_slot(&ts->imapaint.paint, tslot, &slot_index)) { + if (slot_index != brush->imagepaint_tool) { + return false; + } mode = OB_MODE_TEXTURE_PAINT; - else if (ptr->data == ts->sculpt) + } + else if (paint_contains_brush_slot(&ts->sculpt->paint, tslot, &slot_index)) { + if (slot_index != brush->sculpt_tool) { + return false; + } mode = OB_MODE_SCULPT; - else if (ptr->data == ts->vpaint) + } + else if (paint_contains_brush_slot(&ts->vpaint->paint, tslot, &slot_index)) { + if (slot_index != brush->vertexpaint_tool) { + return false; + } mode = OB_MODE_VERTEX_PAINT; - else if (ptr->data == ts->wpaint) + } + else if (paint_contains_brush_slot(&ts->wpaint->paint, tslot, &slot_index)) { + if (slot_index != brush->weightpaint_tool) { + return false; + } mode = OB_MODE_WEIGHT_PAINT; + } + else if (paint_contains_brush_slot(&ts->gp_paint->paint, tslot, &slot_index)) { + if (slot_index != brush->gpencil_tool) { + return false; + } + mode = OB_MODE_GPENCIL_PAINT; + } return brush->ob_mode & mode; } -static void rna_Sculpt_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_Sculpt_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = (scene->basact) ? scene->basact->object : NULL; + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); if (ob) { - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); if (ob->sculpt) { @@ -282,11 +364,13 @@ static void rna_Sculpt_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNU } } -static void rna_Sculpt_ShowDiffuseColor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_Sculpt_ShowDiffuseColor_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = (scene->basact) ? scene->basact->object : NULL; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); if (ob && ob->sculpt) { + Scene *scene = CTX_data_scene(C); Sculpt *sd = scene->toolsettings->sculpt; ob->sculpt->show_diffuse_color = ((sd->flags & SCULPT_SHOW_DIFFUSE) != 0); @@ -297,12 +381,14 @@ static void rna_Sculpt_ShowDiffuseColor_update(Main *UNUSED(bmain), Scene *scene } } -static void rna_Sculpt_ShowMask_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_Sculpt_ShowMask_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *object = (scene->basact) ? scene->basact->object : NULL; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *object = OBACT(view_layer); if (object == NULL || object->sculpt == NULL) { return; } + Scene *scene = CTX_data_scene(C); Sculpt *sd = scene->toolsettings->sculpt; object->sculpt->show_mask = ((sd->flags & SCULPT_HIDE_MASK) == 0); if (object->sculpt->pbvh != NULL) { @@ -338,6 +424,11 @@ static char *rna_UvSculpt_path(PointerRNA *UNUSED(ptr)) return BLI_strdup("tool_settings.uv_sculpt"); } +static char *rna_GpPaint_path(PointerRNA *UNUSED(ptr)) +{ + return BLI_strdup("tool_settings.gpencil_paint"); +} + static char *rna_ParticleBrush_path(PointerRNA *UNUSED(ptr)) { return BLI_strdup("tool_settings.particle_edit.brush"); @@ -348,6 +439,8 @@ static void rna_Paint_brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po Paint *paint = ptr->data; Brush *br = paint->brush; BKE_paint_invalidate_overlay_all(); + /* Needed because we're not calling 'BKE_paint_brush_set' which handles this. */ + BKE_paint_toolslots_brush_update(paint); WM_main_add_notifier(NC_BRUSH | NA_SELECTED, br); } @@ -357,55 +450,60 @@ static void rna_ImaPaint_viewport_update(Main *UNUSED(bmain), Scene *UNUSED(scen WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } -static void rna_ImaPaint_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ImaPaint_mode_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = OBACT; + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); if (ob && ob->type == OB_MESH) { /* of course we need to invalidate here */ BKE_texpaint_slots_refresh_object(scene, ob); /* we assume that changing the current mode will invalidate the uv layers so we need to refresh display */ - GPU_drawobject_free(ob->derivedFinal); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } } -static void rna_ImaPaint_stencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ImaPaint_stencil_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = OBACT; + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); if (ob && ob->type == OB_MESH) { - GPU_drawobject_free(ob->derivedFinal); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } } -static void rna_ImaPaint_canvas_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = OBACT; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); + Object *obedit = OBEDIT_FROM_OBACT(ob); bScreen *sc; Image *ima = scene->toolsettings->imapaint.canvas; for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { - SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_IMAGE) { - SpaceImage *sima = (SpaceImage *)sl; + SpaceLink *slink; + for (slink = sa->spacedata.first; slink; slink = slink->next) { + if (slink->spacetype == SPACE_IMAGE) { + SpaceImage *sima = (SpaceImage *)slink; if (!sima->pin) - ED_space_image_set(bmain, sima, scene, scene->obedit, ima); + ED_space_image_set(bmain, sima, scene, obedit, ima); } } } } if (ob && ob->type == OB_MESH) { - GPU_drawobject_free(ob->derivedFinal); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } @@ -422,9 +520,14 @@ static PointerRNA rna_GPencilSculptSettings_brush_get(PointerRNA *ptr) GP_BrushEdit_Settings *gset = (GP_BrushEdit_Settings *)ptr->data; GP_EditBrush_Data *brush = NULL; - if ((gset->brushtype >= 0) && (gset->brushtype < TOT_GP_EDITBRUSH_TYPES)) - brush = &gset->brush[gset->brushtype]; - + if ((gset) && (gset->flag & GP_BRUSHEDIT_FLAG_WEIGHT_MODE)) { + if ((gset->weighttype >= GP_EDITBRUSH_TYPE_WEIGHT) && (gset->weighttype < TOT_GP_EDITBRUSH_TYPES)) + brush = &gset->brush[gset->weighttype]; + } + else { + if ((gset->brushtype >= 0) && (gset->brushtype < GP_EDITBRUSH_TYPE_WEIGHT)) + brush = &gset->brush[gset->brushtype]; + } return rna_pointer_inherit_refine(ptr, &RNA_GPencilSculptBrush, brush); } @@ -450,6 +553,19 @@ static void rna_def_paint_curve(BlenderRNA *brna) RNA_def_struct_ui_icon(srna, ICON_CURVE_BEZCURVE); } +static void rna_def_paint_tool_slot(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "PaintToolSlot", NULL); + RNA_def_struct_ui_text(srna, "Paint Tool Slot", ""); + + prop = RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Brush_mode_with_tool_poll"); + RNA_def_property_ui_text(prop, "Brush", ""); +} static void rna_def_paint(BlenderRNA *brna) { @@ -466,6 +582,14 @@ static void rna_def_paint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Brush", "Active Brush"); RNA_def_property_update(prop, 0, "rna_Paint_brush_update"); + /* paint_tool_slots */ + prop = RNA_def_property(srna, "tool_slots", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "tool_slots", "tool_slots_len"); + RNA_def_property_struct_type(prop, "PaintToolSlot"); + /* 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, "Paint Tool Slots", ""); + prop = RNA_def_property(srna, "palette", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, NULL); @@ -564,8 +688,10 @@ static void rna_def_sculpt(BlenderRNA *brna) "Relative Detail", "Mesh detail is relative to the brush size and detail size"}, {SCULPT_DYNTOPO_DETAIL_CONSTANT, "CONSTANT", 0, "Constant Detail", "Mesh detail is constant in object space according to detail size"}, - {SCULPT_DYNTOPO_DETAIL_BRUSH, "BRUSH", 0, + {SCULPT_DYNTOPO_DETAIL_BRUSH, "BRUSH", 0, "Brush Detail", "Mesh detail is relative to brush radius"}, + {SCULPT_DYNTOPO_DETAIL_MANUAL, "MANUAL", 0, + "Manual Detail", "Mesh detail does not change on each stroke, only when using Flood Fill"}, {0, NULL, 0, NULL, NULL} }; @@ -610,17 +736,20 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Deform Only", "Use only deformation modifiers (temporary disable all " "constructive modifiers except multi-resolution)"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); prop = RNA_def_property(srna, "show_diffuse_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SHOW_DIFFUSE); RNA_def_property_ui_text(prop, "Show Diffuse Color", "Show diffuse color of object and overlay sculpt mask on top of it"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update"); prop = RNA_def_property(srna, "show_mask", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", SCULPT_HIDE_MASK); RNA_def_property_ui_text(prop, "Show Mask", "Show mask as overlay on object"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowMask_update"); prop = RNA_def_property(srna, "detail_size", PROP_FLOAT, PROP_PIXEL); @@ -646,6 +775,7 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Smooth Shading", "Show faces in dynamic-topology mode with smooth " "shading rather than flat shaded"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); prop = RNA_def_property(srna, "symmetrize_direction", PROP_ENUM, PROP_NONE); @@ -689,6 +819,14 @@ static void rna_def_uv_sculpt(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "UV Sculpting", ""); } +static void rna_def_gp_paint(BlenderRNA *brna) +{ + StructRNA *srna; + + srna = RNA_def_struct(brna, "GpPaint", "Paint"); + RNA_def_struct_path_func(srna, "rna_GpPaint_path"); + RNA_def_struct_ui_text(srna, "Grease Pencil Paint", ""); +} /* use for weight paint too */ static void rna_def_vertex_paint(BlenderRNA *brna) @@ -727,7 +865,7 @@ static void rna_def_image_paint(BlenderRNA *brna) {IMAGEPAINT_MODE_MATERIAL, "MATERIAL", 0, "Material", "Detect image slots from the material"}, {IMAGEPAINT_MODE_IMAGE, "IMAGE", 0, - "Image", "Set image for texture painting directly"}, + "Single Image", "Set image for texture painting directly"}, {0, NULL, 0, NULL, NULL} }; @@ -771,12 +909,12 @@ static void rna_def_image_paint(BlenderRNA *brna) prop = RNA_def_property(srna, "stencil_image", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "stencil"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Stencil Image", "Image used as stencil"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_stencil_update"); prop = RNA_def_property(srna, "canvas", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Canvas", "Image used as canvas"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_canvas_update"); @@ -818,6 +956,7 @@ static void rna_def_image_paint(BlenderRNA *brna) RNA_def_property_range(prop, 512, 16384); prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_enum_items(prop, paint_type_items); RNA_def_property_ui_text(prop, "Mode", "Mode of operation for projection painting"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_mode_update"); @@ -897,6 +1036,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_enum_bitflag_sdna(prop, NULL, "selectmode"); RNA_def_property_enum_items(prop, select_mode_items); RNA_def_property_ui_text(prop, "Selection Mode", "Particle select and display mode"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_update"); prop = RNA_def_property(srna, "use_preserve_length", PROP_BOOLEAN, PROP_NONE); @@ -919,6 +1059,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) prop = RNA_def_property(srna, "use_fade_time", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_FADE_TIME); RNA_def_property_ui_text(prop, "Fade Time", "Fade paths and keys further away from current frame"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_update"); prop = RNA_def_property(srna, "use_auto_velocity", PROP_BOOLEAN, PROP_NONE); @@ -926,6 +1067,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Auto Velocity", "Calculate point velocities automatically"); prop = RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_DRAW_PART); RNA_def_property_ui_text(prop, "Draw Particles", "Draw actual particles"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_redo"); @@ -945,17 +1087,21 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_ParticleEdit_brush_get", NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Brush", ""); - prop = RNA_def_property(srna, "draw_step", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "display_step", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "draw_step"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_range(prop, 1, 10); - RNA_def_property_ui_text(prop, "Steps", "How many steps to draw the path with"); + RNA_def_property_ui_text(prop, "Steps", "How many steps to display the path with"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_redo"); prop = RNA_def_property(srna, "fade_frames", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, 100); RNA_def_property_ui_text(prop, "Frames", "How many frames to fade"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_update"); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_enum_sdna(prop, NULL, "edittype"); RNA_def_property_enum_items(prop, edit_type_items); RNA_def_property_ui_text(prop, "Type", ""); @@ -976,7 +1122,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Object", "The edited object"); prop = RNA_def_property(srna, "shape_object", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Shape Object", "Outer shape to use for tools"); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_redo"); @@ -1033,8 +1179,8 @@ static void rna_def_particle_edit(BlenderRNA *brna) static void rna_def_gpencil_sculpt(BlenderRNA *brna) { static const EnumPropertyItem prop_direction_items[] = { - {0, "ADD", 0, "Add", "Add effect of brush"}, - {GP_EDITBRUSH_FLAG_INVERT, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"}, + {0, "ADD", ICON_ADD, "Add", "Add effect of brush"}, + {GP_EDITBRUSH_FLAG_INVERT, "SUBTRACT", ICON_REMOVE, "Subtract", "Subtract effect of brush"}, {0, NULL, 0, NULL, NULL}}; StructRNA *srna; @@ -1050,86 +1196,155 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "brushtype"); RNA_def_property_enum_items(prop, rna_enum_gpencil_sculpt_brush_items); RNA_def_property_ui_text(prop, "Tool", ""); - RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "weight_tool", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "weighttype"); + RNA_def_property_enum_items(prop, rna_enum_gpencil_weight_brush_items); + RNA_def_property_ui_text(prop, "Tool", "Tool for weight painting"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_GPencil_update"); prop = RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "GPencilSculptBrush"); RNA_def_property_pointer_funcs(prop, "rna_GPencilSculptSettings_brush_get", NULL, NULL, NULL); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_ui_text(prop, "Brush", ""); prop = RNA_def_property(srna, "use_select_mask", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_SELECT_MASK); RNA_def_property_ui_text(prop, "Selection Mask", "Only sculpt selected stroke points"); - RNA_def_property_ui_icon(prop, ICON_VERTEXSEL, 0); // FIXME: this needs a custom icon + RNA_def_property_ui_icon(prop, ICON_GP_ONLY_SELECTED, 0); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "affect_position", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_edit_position", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_POSITION); RNA_def_property_ui_text(prop, "Affect Position", "The brush affects the position of the point"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "affect_strength", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_edit_strength", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_STRENGTH); RNA_def_property_ui_text(prop, "Affect Strength", "The brush affects the color strength of the point"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "affect_thickness", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_edit_thickness", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_THICKNESS); RNA_def_property_ui_text(prop, "Affect Thickness", "The brush affects the thickness of the point"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + prop = RNA_def_property(srna, "use_edit_uv", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_APPLY_UV); + RNA_def_property_ui_text(prop, "Affect UV", "The brush affects the UV rotation of the point"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "selection_alpha", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "alpha"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Alpha", "Alpha value for selected vertices"); - RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_GPencil_update"); + prop = RNA_def_property(srna, "use_multiframe_falloff", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_FRAME_FALLOFF); + RNA_def_property_ui_text(prop, "Use Falloff", "Use falloff effect when edit in multiframe mode to compute brush effect by frame"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + /* custom falloff curve */ + prop = RNA_def_property(srna, "multiframe_falloff_curve", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "cur_falloff"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Curve", + "Custom curve to control falloff of brush effect by Grease Pencil frames"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* lock axis */ - prop = RNA_def_property(srna, "lockaxis", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "lock_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "lock_axis"); - RNA_def_property_enum_items(prop, rna_enum_gpencil_lockaxis_items); - RNA_def_property_ui_text(prop, "Lock", ""); - RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + RNA_def_property_enum_items(prop, rna_enum_gpencil_lock_axis_items); + RNA_def_property_ui_text(prop, "Lock Axis", ""); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* brush */ srna = RNA_def_struct(brna, "GPencilSculptBrush", NULL); RNA_def_struct_sdna(srna, "GP_EditBrush_Data"); RNA_def_struct_path_func(srna, "rna_GPencilSculptBrush_path"); RNA_def_struct_ui_text(srna, "GPencil Sculpt Brush", "Stroke editing brush"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL); - RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS); - RNA_def_property_ui_range(prop, 1, 100, 10, 3); // XXX: too big + RNA_def_property_range(prop, 1, GP_MAX_BRUSH_PIXEL_RADIUS); + RNA_def_property_ui_range(prop, 1, 500, 10, 3); RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR); RNA_def_property_range(prop, 0.001, 1.0); RNA_def_property_ui_text(prop, "Strength", "Brush strength"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_USE_PRESSURE); RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_pressure_radius", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_PRESSURE_RADIUS); + RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); + RNA_def_property_ui_text(prop, "Radius Pressure", "Enable tablet pressure sensitivity for radius"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_falloff", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_USE_FALLOFF); RNA_def_property_ui_text(prop, "Use Falloff", "Strength of brush decays with distance from cursor"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "affect_pressure", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_edit_pressure", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE); RNA_def_property_ui_text(prop, "Affect Pressure", "Affect pressure values as well when smoothing strokes"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, prop_direction_items); RNA_def_property_ui_text(prop, "Direction", ""); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + /* Cursor Color */ + static float default_1[3] = { 1.0f, 0.6f, 0.6f }; + static float default_2[3] = { 0.6f, 0.6f, 1.0f }; + + prop = RNA_def_property(srna, "cursor_color_add", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "curcolor_add"); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_array_default(prop, default_1); + RNA_def_property_ui_text(prop, "Cursor Add", "Color for the cursor for addition"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "cursor_color_sub", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "curcolor_sub"); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_array_default(prop, default_2); + RNA_def_property_ui_text(prop, "Cursor Sub", "Color for the cursor for substration"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "use_cursor", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_EDITBRUSH_FLAG_ENABLE_CURSOR); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_ui_text(prop, "Enable Cursor", "Enable cursor on screen"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + } void RNA_def_sculpt_paint(BlenderRNA *brna) @@ -1137,9 +1352,11 @@ void RNA_def_sculpt_paint(BlenderRNA *brna) /* *** Non-Animated *** */ RNA_define_animate_sdna(false); rna_def_paint_curve(brna); + rna_def_paint_tool_slot(brna); rna_def_paint(brna); rna_def_sculpt(brna); rna_def_uv_sculpt(brna); + rna_def_gp_paint(brna); rna_def_vertex_paint(brna); rna_def_image_paint(brna); rna_def_particle_edit(brna); diff --git a/source/blender/makesrna/intern/rna_sensor_api.c b/source/blender/makesrna/intern/rna_sensor_api.c deleted file mode 100644 index 9db5c3f9f92..00000000000 --- a/source/blender/makesrna/intern/rna_sensor_api.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2010 Blender Foundation. - * All rights reserved. - * - * - * Contributor(s): - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/makesrna/intern/rna_sensor_api.c - * \ingroup RNA - */ - -#include <stdlib.h> -#include <stdio.h> - -#include "BLI_utildefines.h" - -#include "RNA_define.h" - -#include "rna_internal.h" /* own include */ - -#include "WM_types.h" - -#ifdef RNA_RUNTIME - -#include "BKE_sca.h" -#include "DNA_sensor_types.h" -#include "DNA_controller_types.h" - -static void rna_Sensor_link(bSensor *sens, bController *cont) -{ - link_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks, sizeof(bController *)); -} - -static void rna_Sensor_unlink(bSensor *sens, bController *cont) -{ - unlink_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks); -} - -#else - -void RNA_api_sensor(StructRNA *srna) -{ - FunctionRNA *func; - PropertyRNA *parm; - - func = RNA_def_function(srna, "link", "rna_Sensor_link"); - RNA_def_function_ui_description(func, "Link the sensor to a controller"); - parm = RNA_def_pointer(func, "controller", "Controller", "", "Controller to link to"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_property_update(parm, NC_LOGIC, NULL); - - func = RNA_def_function(srna, "unlink", "rna_Sensor_unlink"); - RNA_def_function_ui_description(func, "Unlink the sensor from a controller"); - parm = RNA_def_pointer(func, "controller", "Controller", "", "Controller to unlink from"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_property_update(parm, NC_LOGIC, NULL); -} - -#endif diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index e78bce9170d..4bf3ed6cce8 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1363,31 +1363,37 @@ static void rna_def_strip_color_balance(BlenderRNA *brna) static const EnumPropertyItem blend_mode_items[] = { {SEQ_BLEND_REPLACE, "REPLACE", 0, "Replace", ""}, {SEQ_TYPE_CROSS, "CROSS", 0, "Cross", ""}, - {SEQ_TYPE_ADD, "ADD", 0, "Add", ""}, - {SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", ""}, - {SEQ_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""}, - {SEQ_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""}, - {SEQ_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""}, + {0, "", ICON_NONE, NULL, NULL}, + {SEQ_TYPE_DARKEN, "DARKEN", 0, "Darken", ""}, {SEQ_TYPE_MUL, "MULTIPLY", 0, "Multiply", ""}, - {SEQ_TYPE_OVERDROP, "OVER_DROP", 0, "Over Drop", ""}, + {SEQ_TYPE_BURN, "BURN", 0, "Burn", ""}, + {SEQ_TYPE_LINEAR_BURN, "LINEAR_BURN", 0, "Linear Burn", ""}, + {0, "", ICON_NONE, NULL, NULL}, {SEQ_TYPE_LIGHTEN, "LIGHTEN", 0, "Lighten", ""}, - {SEQ_TYPE_DARKEN, "DARKEN", 0, "Darken", ""}, {SEQ_TYPE_SCREEN, "SCREEN", 0, "Screen", ""}, - {SEQ_TYPE_OVERLAY, "OVERLAY", 0, "Overlay", ""}, {SEQ_TYPE_DODGE, "DODGE", 0, "Dodge", ""}, - {SEQ_TYPE_BURN, "BURN", 0, "Burn", ""}, - {SEQ_TYPE_LINEAR_BURN, "LINEAR_BURN", 0, "Linear Burn", ""}, + {SEQ_TYPE_ADD, "ADD", 0, "Add", ""}, + {0, "", ICON_NONE, NULL, NULL}, + {SEQ_TYPE_OVERLAY, "OVERLAY", 0, "Overlay", ""}, {SEQ_TYPE_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""}, {SEQ_TYPE_HARD_LIGHT, "HARD_LIGHT", 0, "Hard Light", ""}, - {SEQ_TYPE_PIN_LIGHT, "PIN_LIGHT", 0, "Pin Light", ""}, - {SEQ_TYPE_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""}, {SEQ_TYPE_VIVID_LIGHT, "VIVID_LIGHT", 0, "Vivid Light", ""}, - {SEQ_TYPE_BLEND_COLOR, "COLOR", 0, "Color", ""}, + {SEQ_TYPE_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""}, + {SEQ_TYPE_PIN_LIGHT, "PIN_LIGHT", 0, "Pin Light", ""}, + {0, "", ICON_NONE, NULL, NULL}, + {SEQ_TYPE_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""}, + {SEQ_TYPE_EXCLUSION, "EXCLUSION", 0, "Exclusion", ""}, + {SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", ""}, + {0, "", ICON_NONE, NULL, NULL}, {SEQ_TYPE_HUE, "HUE", 0, "Hue", ""}, {SEQ_TYPE_SATURATION, "SATURATION", 0, "Saturation", ""}, + {SEQ_TYPE_BLEND_COLOR, "COLOR", 0, "Color", ""}, {SEQ_TYPE_VALUE, "VALUE", 0, "Value", ""}, - {SEQ_TYPE_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""}, - {SEQ_TYPE_EXCLUSION, "EXCLUSION", 0, "Exclusion", ""}, + {0, "", ICON_NONE, NULL, NULL}, + {SEQ_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""}, + {SEQ_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""}, + {SEQ_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""}, + {SEQ_TYPE_OVERDROP, "OVER_DROP", 0, "Over Drop", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1504,7 +1510,7 @@ static void rna_def_sequence(BlenderRNA *brna) prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MUTE); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, true); + RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1); RNA_def_property_ui_text(prop, "Mute", "Disable strip so that it cannot be viewed in the output"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_mute_update"); @@ -2581,7 +2587,7 @@ static void rna_def_modifier(BlenderRNA *brna) prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQUENCE_MODIFIER_MUTE); RNA_def_property_ui_text(prop, "Mute", "Mute this modifier"); - RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 509b6da2048..4c56f4c7ccd 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -48,9 +48,8 @@ #include "BLI_path_util.h" /* BLI_split_dirfile */ #include "BKE_image.h" -#include "BKE_library.h" /* id_us_plus */ -#include "BKE_movieclip.h" #include "BKE_mask.h" +#include "BKE_movieclip.h" #include "BKE_report.h" #include "BKE_sequencer.h" diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c new file mode 100644 index 00000000000..c1bc9ba191e --- /dev/null +++ b/source/blender/makesrna/intern/rna_shader_fx.c @@ -0,0 +1,707 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_shader_fx.c + * \ingroup RNA + */ + + +#include <float.h> +#include <limits.h> +#include <stdlib.h> + +#include "DNA_shader_fx_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "BLT_translation.h" + +#include "BKE_animsys.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "rna_internal.h" + +#include "WM_api.h" +#include "WM_types.h" + +const EnumPropertyItem rna_enum_object_shaderfx_type_items[] = { + {eShaderFxType_Blur, "FX_BLUR", ICON_SHADERFX, "Blur", "Apply Gaussian Blur to object" }, + {eShaderFxType_Colorize, "FX_COLORIZE", ICON_SHADERFX, "Colorize", "Apply different tint effects" }, + {eShaderFxType_Flip, "FX_FLIP", ICON_SHADERFX, "Flip", "Flip image" }, + {eShaderFxType_Glow, "FX_GLOW", ICON_SHADERFX, "Glow", "Create a glow effect" }, + {eShaderFxType_Light, "FX_LIGHT", ICON_SHADERFX, "Light", "Simulate ilumination" }, + {eShaderFxType_Pixel, "FX_PIXEL", ICON_SHADERFX, "Pixelate", "Pixelate image"}, + {eShaderFxType_Rim, "FX_RIM", ICON_SHADERFX, "Rim", "Add a rim to the image" }, + {eShaderFxType_Shadow, "FX_SHADOW", ICON_SHADERFX, "Shadow", "Create a shadow effect"}, + {eShaderFxType_Swirl, "FX_SWIRL", ICON_SHADERFX, "Swirl", "Create a rotation distortion"}, + {eShaderFxType_Wave, "FX_WAVE", ICON_SHADERFX, "Wave Distortion", "Apply sinusoidal deformation"}, + {0, NULL, 0, NULL, NULL} +}; + +static const EnumPropertyItem rna_enum_shaderfx_rim_modes_items[] = { + {eShaderFxRimMode_Normal, "NORMAL", 0, "Normal", "" }, + {eShaderFxRimMode_Overlay, "OVERLAY", 0, "Overlay", "" }, + {eShaderFxRimMode_Add, "ADD", 0, "Add", "" }, + {eShaderFxRimMode_Subtract, "SUBTRACT", 0, "Subtract", "" }, + {eShaderFxRimMode_Multiply, "MULTIPLY", 0, "Multiply", "" }, + {eShaderFxRimMode_Divide, "DIVIDE", 0, "Divide", "" }, + {0, NULL, 0, NULL, NULL } +}; + +static const EnumPropertyItem rna_enum_shaderfx_glow_modes_items[] = { + {eShaderFxGlowMode_Luminance, "LUMINANCE", 0, "Luminance", "" }, + {eShaderFxGlowMode_Color, "COLOR", 0, "Color", "" }, + {0, NULL, 0, NULL, NULL } +}; + +static const EnumPropertyItem rna_enum_shaderfx_colorize_modes_items[] = { + {eShaderFxColorizeMode_GrayScale, "GRAYSCALE", 0, "Gray Scale", "" }, + {eShaderFxColorizeMode_Sepia, "SEPIA", 0, "Sepia", "" }, + {eShaderFxColorizeMode_BiTone, "BITONE", 0, "Bi-Tone", "" }, + {eShaderFxColorizeMode_Transparent, "TRANSPARENT", 0, "Transparent", "" }, + {eShaderFxColorizeMode_Custom, "CUSTOM", 0, "Custom", "" }, + {0, NULL, 0, NULL, NULL } +}; + +#ifdef RNA_RUNTIME + +#include "BKE_shader_fx.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + +static StructRNA *rna_ShaderFx_refine(struct PointerRNA *ptr) +{ + ShaderFxData *md = (ShaderFxData *)ptr->data; + + switch ((ShaderFxType)md->type) { + case eShaderFxType_Blur: + return &RNA_ShaderFxBlur; + case eShaderFxType_Colorize: + return &RNA_ShaderFxColorize; + case eShaderFxType_Wave: + return &RNA_ShaderFxWave; + case eShaderFxType_Pixel: + return &RNA_ShaderFxPixel; + case eShaderFxType_Rim: + return &RNA_ShaderFxRim; + case eShaderFxType_Shadow: + return &RNA_ShaderFxShadow; + case eShaderFxType_Swirl: + return &RNA_ShaderFxSwirl; + case eShaderFxType_Flip: + return &RNA_ShaderFxFlip; + case eShaderFxType_Glow: + return &RNA_ShaderFxGlow; + case eShaderFxType_Light: + return &RNA_ShaderFxLight; + /* Default */ + case eShaderFxType_None: + case NUM_SHADER_FX_TYPES: + return &RNA_ShaderFx; + } + + return &RNA_ShaderFx; +} + +static void rna_ShaderFx_name_set(PointerRNA *ptr, const char *value) +{ + ShaderFxData *gmd = ptr->data; + char oldname[sizeof(gmd->name)]; + + /* make a copy of the old name first */ + BLI_strncpy(oldname, gmd->name, sizeof(gmd->name)); + + /* copy the new name into the name slot */ + BLI_strncpy_utf8(gmd->name, value, sizeof(gmd->name)); + + /* make sure the name is truly unique */ + if (ptr->id.data) { + Object *ob = ptr->id.data; + BKE_shaderfx_unique_name(&ob->shader_fx, gmd); + } + + /* fix all the animation data which may link to this */ + BKE_animdata_fix_paths_rename_all(NULL, "shader_effects", oldname, gmd->name); +} + +static char *rna_ShaderFx_path(PointerRNA *ptr) +{ + ShaderFxData *gmd = ptr->data; + char name_esc[sizeof(gmd->name) * 2]; + + BLI_strescape(name_esc, gmd->name, sizeof(name_esc)); + return BLI_sprintfN("shader_effects[\"%s\"]", name_esc); +} + +static void rna_ShaderFx_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->id.data); +} + +static void rna_ShaderFx_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + rna_ShaderFx_update(bmain, scene, ptr); + DEG_relations_tag_update(bmain); +} + +/* Objects */ + +static void shaderfx_object_set(Object *self, Object **ob_p, int type, PointerRNA value) +{ + Object *ob = value.data; + + if (!self || ob != self) { + if (!ob || type == OB_EMPTY || ob->type == type) { + id_lib_extern((ID *)ob); + *ob_p = ob; + } + } +} + +#define RNA_FX_OBJECT_SET(_type, _prop, _obtype) \ +static void rna_##_type##ShaderFx_##_prop##_set(PointerRNA *ptr, PointerRNA value) \ +{ \ + _type##ShaderFxData *tmd = (_type##ShaderFxData *)ptr->data; \ + shaderfx_object_set(ptr->id.data, &tmd->_prop, _obtype, value); \ +} + +RNA_FX_OBJECT_SET(Light, object, OB_EMPTY); +RNA_FX_OBJECT_SET(Shadow, object, OB_EMPTY); +RNA_FX_OBJECT_SET(Swirl, object, OB_EMPTY); + +#undef RNA_FX_OBJECT_SET + +#else + +static void rna_def_shader_fx_blur(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShaderFxBlur", "ShaderFx"); + RNA_def_struct_ui_text(srna, "Gaussian Blur Effect", "Gaussian Blur effect"); + RNA_def_struct_sdna(srna, "BlurShaderFxData"); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); + + prop = RNA_def_property(srna, "factor", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "radius"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Factor", "Factor of Blur"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "samples"); + RNA_def_property_range(prop, 0, 32); + RNA_def_property_ui_range(prop, 0, 32, 2, -1); + RNA_def_property_int_default(prop, 4); + RNA_def_property_ui_text(prop, "Samples", "Number of Blur Samples (zero, disable blur)"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "coc", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "coc"); + RNA_def_property_range(prop, 0.001f, 1.0f); + RNA_def_property_float_default(prop, 0.025f); + RNA_def_property_ui_text(prop, "Precision", "Define circle of confusion for depth of field"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "use_dof_mode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", FX_BLUR_DOF_MODE); + RNA_def_property_ui_text(prop, "Lock Focal Plane", "Blur using focal plane distance as factor to simulate depth of field effect (only in camera view)"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); +} + +static void rna_def_shader_fx_colorize(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShaderFxColorize", "ShaderFx"); + RNA_def_struct_ui_text(srna, "Colorize Effect", "Colorize effect"); + RNA_def_struct_sdna(srna, "ColorizeShaderFxData"); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); + + prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "factor"); + RNA_def_property_range(prop, 0, 1.0); + RNA_def_property_ui_text(prop, "Factor", "Mix factor"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "low_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_float_sdna(prop, NULL, "low_color"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Low color", "First color used for effect"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "high_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_float_sdna(prop, NULL, "high_color"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Height color", "Second color used for effect"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, rna_enum_shaderfx_colorize_modes_items); + RNA_def_property_ui_text(prop, "Mode", "Effect mode"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); +} + +static void rna_def_shader_fx_wave(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_shaderfx_wave_type_items[] = { + { 0, "HORIZONTAL", 0, "Horizontal", "" }, + { 1, "VERTICAL", 0, "Vertical", "" }, + { 0, NULL, 0, NULL, NULL } + }; + + srna = RNA_def_struct(brna, "ShaderFxWave", "ShaderFx"); + RNA_def_struct_ui_text(srna, "Wave Deformation Effect", "Wave Deformation effect"); + RNA_def_struct_sdna(srna, "WaveShaderFxData"); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); + + prop = RNA_def_property(srna, "orientation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "orientation"); + RNA_def_property_enum_items(prop, prop_shaderfx_wave_type_items); + RNA_def_property_ui_text(prop, "Orientation", "Direction of the wave"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "amplitude"); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of Wave"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "period", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "period"); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_text(prop, "Period", "Period of Wave"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "phase"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_text(prop, "Phase", "Phase Shift of Wave"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); +} + +static void rna_def_shader_fx_pixel(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShaderFxPixel", "ShaderFx"); + RNA_def_struct_ui_text(srna, "Pixelate Effect", "Pixelate effect"); + RNA_def_struct_sdna(srna, "PixelShaderFxData"); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); + + prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "size"); + RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Size", "Pixel size"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_float_sdna(prop, NULL, "rgba"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Color", "Color used for lines"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "use_lines", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", FX_PIXEL_USE_LINES); + RNA_def_property_ui_text(prop, "Lines", "Display lines between pixels"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); +} + +static void rna_def_shader_fx_rim(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShaderFxRim", "ShaderFx"); + RNA_def_struct_ui_text(srna, "Rim Effect", "Rim effect"); + RNA_def_struct_sdna(srna, "RimShaderFxData"); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); + + prop = RNA_def_property(srna, "offset", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "offset"); + RNA_def_property_range(prop, -INT_MAX, INT_MAX); + RNA_def_property_ui_text(prop, "Offset", "Offset of the rim"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "rim_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_float_sdna(prop, NULL, "rim_rgb"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Rim Color", "Color used for Rim"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "mask_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_float_sdna(prop, NULL, "mask_rgb"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Mask Color", "Color that must be keept"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, rna_enum_shaderfx_rim_modes_items); + RNA_def_property_ui_text(prop, "Mode", "Blend mode"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "blur", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "blur"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Blur", "Number of pixels for bluring rim (set to 0 to disable)"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "samples"); + RNA_def_property_range(prop, 0, 32); + RNA_def_property_ui_range(prop, 0, 32, 2, -1); + RNA_def_property_int_default(prop, 4); + RNA_def_property_ui_text(prop, "Samples", "Number of Blur Samples (zero, disable blur)"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); +} + +static void rna_def_shader_fx_shadow(BlenderRNA *brna) +{ + static EnumPropertyItem prop_shaderfx_shadow_type_items[] = { + { 0, "HORIZONTAL", 0, "Horizontal", "" }, + { 1, "VERTICAL", 0, "Vertical", "" }, + { 0, NULL, 0, NULL, NULL } + }; + + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShaderFxShadow", "ShaderFx"); + RNA_def_struct_ui_text(srna, "Shadow Effect", "Shadow effect"); + RNA_def_struct_sdna(srna, "ShadowShaderFxData"); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Object to determine center of rotation"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ShadowShaderFx_object_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_update(prop, 0, "rna_ShaderFx_dependency_update"); + + prop = RNA_def_property(srna, "offset", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "offset"); + RNA_def_property_range(prop, -INT_MAX, INT_MAX); + RNA_def_property_ui_text(prop, "Offset", "Offset of the shadow"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "scale"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_text(prop, "Scale", "Offset of the shadow"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_float_sdna(prop, NULL, "shadow_rgba"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Shadow Color", "Color used for Shadow"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "orientation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "orientation"); + RNA_def_property_enum_items(prop, prop_shaderfx_shadow_type_items); + RNA_def_property_ui_text(prop, "Orientation", "Direction of the wave"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "amplitude"); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of Wave"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "period", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "period"); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_text(prop, "Period", "Period of Wave"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "phase"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_text(prop, "Phase", "Phase Shift of Wave"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "rotation"); + RNA_def_property_range(prop, DEG2RAD(-360), DEG2RAD(360)); + RNA_def_property_ui_range(prop, DEG2RAD(-360), DEG2RAD(360), 5, 2); + RNA_def_property_ui_text(prop, "Rotation", "Rotation around center or object"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "blur", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "blur"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Blur", "Number of pixels for bluring shadow (set to 0 to disable)"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "samples"); + RNA_def_property_range(prop, 0, 32); + RNA_def_property_ui_range(prop, 0, 32, 2, -1); + RNA_def_property_int_default(prop, 4); + RNA_def_property_ui_text(prop, "Samples", "Number of Blur Samples (zero, disable blur)"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "use_object", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", FX_SHADOW_USE_OBJECT); + RNA_def_property_ui_text(prop, "Use Object", "Use object as center of rotation"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "use_wave", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", FX_SHADOW_USE_WAVE); + RNA_def_property_ui_text(prop, "Wave", "Use wave effect"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); +} + +static void rna_def_shader_fx_glow(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShaderFxGlow", "ShaderFx"); + RNA_def_struct_ui_text(srna, "Glow Effect", "Glow effect"); + RNA_def_struct_sdna(srna, "GlowShaderFxData"); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); + + prop = RNA_def_property(srna, "glow_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_float_sdna(prop, NULL, "glow_color"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Glow Color", "Color used for generated glow"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "select_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_float_sdna(prop, NULL, "select_color"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Select Color", "Color selected to apply glow"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, rna_enum_shaderfx_glow_modes_items); + RNA_def_property_ui_text(prop, "Mode", "Glow mode"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "threshold"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 3); + RNA_def_property_ui_text(prop, "Threshold", "Limit to select color for glow effect"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + /* use blur fields to make compatible with blur filter, but only makes public first array element */ + prop = RNA_def_property(srna, "radius", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "blur[0]"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Radius", "Number of pixels for bluring glow (set to 0 to disable)"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "samples"); + RNA_def_property_range(prop, 1, 32); + RNA_def_property_ui_range(prop, 1, 32, 2, -1); + RNA_def_property_int_default(prop, 4); + RNA_def_property_ui_text(prop, "Samples", "Number of Blur Samples"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "use_alpha_mode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", FX_GLOW_USE_ALPHA); + RNA_def_property_ui_text(prop, "Use Alpha", "Glow only areas with alpha"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); +} + +static void rna_def_shader_fx_swirl(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShaderFxSwirl", "ShaderFx"); + RNA_def_struct_ui_text(srna, "Swirl Effect", "Swirl effect"); + RNA_def_struct_sdna(srna, "SwirlShaderFxData"); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); + + prop = RNA_def_property(srna, "radius", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "radius"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Radius", "Radius to apply"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "angle"); + RNA_def_property_range(prop, DEG2RAD(-5 * 360), DEG2RAD(5 * 360)); + RNA_def_property_ui_range(prop, DEG2RAD(-5 * 360), DEG2RAD(5 * 360), 5, 2); + RNA_def_property_ui_text(prop, "Angle", "Angle of rotation"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "transparent", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", FX_SWIRL_MAKE_TRANSPARENT); + RNA_def_property_ui_text(prop, "Transparent", "Make image transparent outside of radius"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Object to determine center location"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_SwirlShaderFx_object_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_update(prop, 0, "rna_ShaderFx_dependency_update"); +} + +static void rna_def_shader_fx_flip(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShaderFxFlip", "ShaderFx"); + RNA_def_struct_ui_text(srna, "Flip Effect", "Flip effect"); + RNA_def_struct_sdna(srna, "FlipShaderFxData"); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); + + prop = RNA_def_property(srna, "flip_horizontal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", FX_FLIP_HORIZONTAL); + RNA_def_property_ui_text(prop, "Horizontal", "Flip image horizontally"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "flip_vertical", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", FX_FLIP_VERTICAL); + RNA_def_property_ui_text(prop, "Vertical", "Flip image vertically"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); +} + +static void rna_def_shader_fx_light(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShaderFxLight", "ShaderFx"); + RNA_def_struct_ui_text(srna, "Light Effect", "Light effect"); + RNA_def_struct_sdna(srna, "LightShaderFxData"); + RNA_def_struct_ui_icon(srna, ICON_SHADERFX); + + prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "energy"); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_range(prop, 1, FLT_MAX, 1, 2); + RNA_def_property_ui_text(prop, "Energy", "Strength of light source"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "ambient"); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_range(prop, 0, FLT_MAX, 1, 2); + RNA_def_property_ui_text(prop, "Ambient", "Strength of ambient light source"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Object to determine light source location"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_LightShaderFx_object_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_update(prop, 0, "rna_ShaderFx_dependency_update"); +} + +void RNA_def_shader_fx(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + /* data */ + srna = RNA_def_struct(brna, "ShaderFx", NULL); + RNA_def_struct_ui_text(srna, "ShaderFx", "Effect affecting the grease pencil object"); + RNA_def_struct_refine_func(srna, "rna_ShaderFx_refine"); + RNA_def_struct_path_func(srna, "rna_ShaderFx_path"); + RNA_def_struct_sdna(srna, "ShaderFxData"); + + /* strings */ + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ShaderFx_name_set"); + RNA_def_property_ui_text(prop, "Name", "Effect name"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER | NA_RENAME, NULL); + RNA_def_struct_name_property(srna, prop); + + /* enums */ + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, rna_enum_object_shaderfx_type_items); + RNA_def_property_ui_text(prop, "Type", ""); + + /* flags */ + prop = RNA_def_property(srna, "show_viewport", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", eShaderFxMode_Realtime); + RNA_def_property_ui_text(prop, "Realtime", "Display effect in viewport"); + RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_ON, 1); + + prop = RNA_def_property(srna, "show_render", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", eShaderFxMode_Render); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_ui_text(prop, "Render", "Use effect during render"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_ON, 1); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL); + + prop = RNA_def_property(srna, "show_in_editmode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", eShaderFxMode_Editmode); + RNA_def_property_ui_text(prop, "Edit Mode", "Display effect in Edit mode"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update"); + RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0); + + prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", eShaderFxMode_Expanded); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); + RNA_def_property_ui_text(prop, "Expanded", "Set effect expanded in the user interface"); + RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); + + /* types */ + rna_def_shader_fx_blur(brna); + rna_def_shader_fx_colorize(brna); + rna_def_shader_fx_wave(brna); + rna_def_shader_fx_pixel(brna); + rna_def_shader_fx_rim(brna); + rna_def_shader_fx_shadow(brna); + rna_def_shader_fx_glow(brna); + rna_def_shader_fx_swirl(brna); + rna_def_shader_fx_flip(brna); + rna_def_shader_fx_light(brna); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 65e56ddb487..591798d508a 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -54,21 +54,23 @@ #include "BKE_colorband.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_particle.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "smoke_API.h" static void rna_Smoke_update(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, OB_RECALC_DATA); } static void rna_Smoke_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) { rna_Smoke_update(bmain, scene, ptr); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } static void rna_Smoke_resetCache(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -76,7 +78,7 @@ static void rna_Smoke_resetCache(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data; if (settings->smd && settings->smd->domain) settings->point_cache[0]->flag |= PTCACHE_OUTDATED; - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); } static void rna_Smoke_cachetype_set(struct PointerRNA *ptr, int value) @@ -512,6 +514,12 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static const EnumPropertyItem interp_method_item[] = { + {VOLUME_INTERP_LINEAR, "LINEAR", 0, "Linear", "Good smoothness and speed"}, + {VOLUME_INTERP_CUBIC, "CUBIC", 0, "Cubic", "Smoothed high quality interpolation, but slower"}, + {0, NULL, 0, NULL, NULL} + }; + static const EnumPropertyItem axis_slice_position_items[] = { {SLICE_AXIS_AUTO, "AUTO", 0, "Auto", "Adjust slice direction according to the view direction"}, {SLICE_AXIS_X, "X", 0, "X", "Slice along the X axis"}, @@ -521,8 +529,8 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) }; static const EnumPropertyItem vector_draw_items[] = { - {VECTOR_DRAW_NEEDLE, "NEEDLE", 0, "Needle", "Draw vectors as needles"}, - {VECTOR_DRAW_STREAMLINE, "STREAMLINE", 0, "Streamlines", "Draw vectors as streamlines"}, + {VECTOR_DRAW_NEEDLE, "NEEDLE", 0, "Needle", "Display vectors as needles"}, + {VECTOR_DRAW_STREAMLINE, "STREAMLINE", 0, "Streamlines", "Display vectors as streamlines"}, {0, NULL, 0, NULL, NULL} }; @@ -583,23 +591,23 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "coll_group"); - RNA_def_property_struct_type(prop, "Group"); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Collision Group", "Limit collisions to this group"); + RNA_def_property_ui_text(prop, "Collision Collection", "Limit collisions to this collection"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset_dependency"); prop = RNA_def_property(srna, "fluid_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "fluid_group"); - RNA_def_property_struct_type(prop, "Group"); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Fluid Group", "Limit fluid objects to this group"); + RNA_def_property_ui_text(prop, "Fluid Collection", "Limit fluid objects to this collection"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset_dependency"); prop = RNA_def_property(srna, "effector_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "eff_group"); - RNA_def_property_struct_type(prop, "Group"); + RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Effector Group", "Limit effectors to this group"); + RNA_def_property_ui_text(prop, "Effector Collection", "Limit effectors to this collection"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset_dependency"); prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); @@ -854,15 +862,21 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Thickness", "Thickness of smoke drawing in the viewport"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL); - prop = RNA_def_property(srna, "draw_velocity", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "display_interpolation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "interp_method"); + RNA_def_property_enum_items(prop, interp_method_item); + RNA_def_property_ui_text(prop, "Interpolation", "Interpolation method to use for smoke/fire volumes in solid mode"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + + prop = RNA_def_property(srna, "display_velocity", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw_velocity", 0); - RNA_def_property_ui_text(prop, "Draw Velocity", "Toggle visualization of the velocity field as needles"); + RNA_def_property_ui_text(prop, "Display Velocity", "Toggle visualization of the velocity field as needles"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); - prop = RNA_def_property(srna, "vector_draw_type", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "vector_display_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "vector_draw_type"); RNA_def_property_enum_items(prop, vector_draw_items); - RNA_def_property_ui_text(prop, "Draw Type", ""); + RNA_def_property_ui_text(prop, "Display Type", ""); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "vector_scale", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index 3339c5ec405..fb0ba0cdd11 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -32,7 +32,6 @@ #include "rna_internal.h" #include "DNA_sound_types.h" -#include "DNA_property_types.h" #ifdef RNA_RUNTIME diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index ae1761faec1..ea02fdac98d 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -35,8 +35,12 @@ #include "BKE_key.h" #include "BKE_movieclip.h" #include "BKE_node.h" +#include "BKE_studiolight.h" + +#include "BLI_math.h" #include "DNA_action_types.h" +#include "DNA_gpencil_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" @@ -45,6 +49,7 @@ #include "DNA_sequence_types.h" #include "DNA_mask_types.h" #include "DNA_view3d_types.h" +#include "DNA_workspace_types.h" #include "RNA_access.h" #include "RNA_define.h" @@ -66,38 +71,110 @@ const EnumPropertyItem rna_enum_space_type_items[] = { /* General */ {0, "", ICON_NONE, "General", ""}, - {SPACE_VIEW3D, "VIEW_3D", ICON_VIEW3D, "3D View", "3D viewport"}, - {SPACE_IMAGE, "IMAGE_EDITOR", ICON_IMAGE_COL, "UV/Image Editor", "View and edit images and UV Maps"}, + {SPACE_VIEW3D, "VIEW_3D", ICON_VIEW3D, "3D Viewport", "Manipulate objects in a 3D environment"}, + {SPACE_IMAGE, "IMAGE_EDITOR", ICON_IMAGE, "UV/Image Editor", "View and edit images and UV Maps"}, {SPACE_NODE, "NODE_EDITOR", ICON_NODETREE, "Node Editor", "Editor for node-based shading and compositing tools"}, {SPACE_SEQ, "SEQUENCE_EDITOR", ICON_SEQUENCE, "Video Sequencer", "Video editing tools"}, {SPACE_CLIP, "CLIP_EDITOR", ICON_CLIP, "Movie Clip Editor", "Motion tracking tools"}, /* Animation */ {0, "", ICON_NONE, "Animation", ""}, - {SPACE_TIME, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls"}, - {SPACE_IPO, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", "Edit drivers and keyframe interpolation"}, + //{SPACE_ACTION, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls (NOTE: Switch to 'Timeline' mode)"}, /* XXX */ {SPACE_ACTION, "DOPESHEET_EDITOR", ICON_ACTION, "Dope Sheet", "Adjust timing of keyframes"}, - {SPACE_NLA, "NLA_EDITOR", ICON_NLA, "NLA Editor", "Combine and layer Actions"}, + {SPACE_IPO, "GRAPH_EDITOR", ICON_GRAPH, "Graph Editor", "Edit drivers and keyframe interpolation"}, + {SPACE_NLA, "NLA_EDITOR", ICON_NLA, "Nonlinear Animation", "Combine and layer Actions"}, /* Scripting */ {0, "", ICON_NONE, "Scripting", ""}, {SPACE_TEXT, "TEXT_EDITOR", ICON_TEXT, "Text Editor", "Edit scripts and in-file documentation"}, - {SPACE_LOGIC, "LOGIC_EDITOR", ICON_LOGIC, "Logic Editor", "Game logic editing"}, {SPACE_CONSOLE, "CONSOLE", ICON_CONSOLE, "Python Console", "Interactive programmatic console for " "advanced editing and script development"}, {SPACE_INFO, "INFO", ICON_INFO, "Info", "Main menu bar and list of error messages " "(drag down to expand and display)"}, + /* Special case: Top-bar and Status-bar aren't supposed to be a regular editor for the user. */ + {SPACE_TOPBAR, "TOPBAR", ICON_NONE, "Top Bar", "Global bar at the top of the screen for " + "global per-window settings"}, + {SPACE_STATUSBAR, "STATUSBAR", ICON_NONE, "Status Bar", "Global bar at the bottom of the " + "screen for general status information"}, /* Data */ {0, "", ICON_NONE, "Data", ""}, - {SPACE_OUTLINER, "OUTLINER", ICON_OOPS, "Outliner", "Overview of scene graph and all available data-blocks"}, - {SPACE_BUTS, "PROPERTIES", ICON_BUTS, "Properties", "Edit properties of active object and related data-blocks"}, - {SPACE_FILE, "FILE_BROWSER", ICON_FILESEL, "File Browser", "Browse for files and assets"}, + {SPACE_OUTLINER, "OUTLINER", ICON_OUTLINER, "Outliner", "Overview of scene graph and all available data-blocks"}, + {SPACE_BUTS, "PROPERTIES", ICON_PROPERTIES, "Properties", "Edit properties of active object and related data-blocks"}, + {SPACE_FILE, "FILE_BROWSER", ICON_FILEBROWSER, "File Browser", "Browse for files and assets"}, {SPACE_USERPREF, "USER_PREFERENCES", ICON_PREFERENCES, "User Preferences", "Edit persistent configuration settings"}, {0, NULL, 0, NULL, NULL} }; +const EnumPropertyItem rna_enum_space_graph_mode_items[] = { + {SIPO_MODE_ANIMATION, "FCURVES", ICON_GRAPH, "Graph Editor", + "Edit animation/keyframes displayed as 2D curves"}, + {SIPO_MODE_DRIVERS, "DRIVERS", ICON_DRIVER, "Drivers", "Edit drivers"}, + {0, NULL, 0, NULL, NULL} +}; + +#define SACT_ITEM_DOPESHEET \ + {SACTCONT_DOPESHEET, "DOPESHEET", ICON_ACTION, "Dope Sheet", "Edit all keyframes in scene"} +#define SACT_ITEM_TIMELINE \ + {SACTCONT_TIMELINE, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls"} +#define SACT_ITEM_ACTION \ + {SACTCONT_ACTION, "ACTION", ICON_OBJECT_DATA, "Action Editor", "Edit keyframes in active object's Object-level action"} +#define SACT_ITEM_SHAPEKEY \ + {SACTCONT_SHAPEKEY, "SHAPEKEY", ICON_SHAPEKEY_DATA, "Shape Key Editor", "Edit keyframes in active object's Shape Keys action"} +#define SACT_ITEM_GPENCIL \ + {SACTCONT_GPENCIL, "GPENCIL", ICON_GREASEPENCIL, "Grease Pencil", "Edit timings for all Grease Pencil sketches in file"} +#define SACT_ITEM_MASK \ + {SACTCONT_MASK, "MASK", ICON_MOD_MASK, "Mask", "Edit timings for Mask Editor splines"} +#define SACT_ITEM_CACHEFILE \ + {SACTCONT_CACHEFILE, "CACHEFILE", ICON_FILE, "Cache File", "Edit timings for Cache File data-blocks"} + +#ifndef RNA_RUNTIME +/* XXX: action-editor is currently for object-level only actions, so show that using object-icon hint */ +static EnumPropertyItem rna_enum_space_action_mode_all_items[] = { + SACT_ITEM_DOPESHEET, + SACT_ITEM_TIMELINE, + SACT_ITEM_ACTION, + SACT_ITEM_SHAPEKEY, + SACT_ITEM_GPENCIL, + SACT_ITEM_MASK, + SACT_ITEM_CACHEFILE, + {0, NULL, 0, NULL, NULL} +}; +static EnumPropertyItem rna_enum_space_action_ui_mode_items[] = { + SACT_ITEM_DOPESHEET, + /* SACT_ITEM_TIMELINE, */ + SACT_ITEM_ACTION, + SACT_ITEM_SHAPEKEY, + SACT_ITEM_GPENCIL, + SACT_ITEM_MASK, + SACT_ITEM_CACHEFILE, + {0, NULL, 0, NULL, NULL} +}; +#endif +/* expose as ui_mode */ +const EnumPropertyItem rna_enum_space_action_mode_items[] = { + SACT_ITEM_DOPESHEET, + SACT_ITEM_TIMELINE, + {0, NULL, 0, NULL, NULL} +}; + +#undef SACT_ITEM_DOPESHEET +#undef SACT_ITEM_TIMELINE +#undef SACT_ITEM_ACTION +#undef SACT_ITEM_SHAPEKEY +#undef SACT_ITEM_GPENCIL +#undef SACT_ITEM_MASK +#undef SACT_ITEM_CACHEFILE + +const EnumPropertyItem rna_enum_space_image_mode_items[] = { + {SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image"}, + {SI_MODE_UV, "UV", ICON_GROUP_UVS, "UV Edit", "UV edit in mesh editmode"}, + {SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"}, + {SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"}, + {0, NULL, 0, NULL, NULL} +}; + #define V3D_S3D_CAMERA_LEFT {STEREO_LEFT_ID, "LEFT", ICON_RESTRICT_RENDER_OFF, "Left", ""}, #define V3D_S3D_CAMERA_RIGHT {STEREO_RIGHT_ID, "RIGHT", ICON_RESTRICT_RENDER_OFF, "Right", ""}, #define V3D_S3D_CAMERA_S3D {STEREO_3D_ID, "S3D", ICON_CAMERA_STEREO, "3D", ""}, @@ -133,43 +210,19 @@ static const EnumPropertyItem stereo3d_eye_items[] = { }; #endif -static const EnumPropertyItem pivot_items_full[] = { - {V3D_AROUND_CENTER_BOUNDS, "BOUNDING_BOX_CENTER", ICON_ROTATE, "Bounding Box Center", - "Pivot around bounding box center of selected object(s)"}, - {V3D_AROUND_CURSOR, "CURSOR", ICON_CURSOR, "3D Cursor", "Pivot around the 3D cursor"}, - {V3D_AROUND_LOCAL_ORIGINS, "INDIVIDUAL_ORIGINS", ICON_ROTATECOLLECTION, - "Individual Origins", "Pivot around each object's own origin"}, - {V3D_AROUND_CENTER_MEAN, "MEDIAN_POINT", ICON_ROTATECENTER, "Median Point", - "Pivot around the median point of selected objects"}, - {V3D_AROUND_ACTIVE, "ACTIVE_ELEMENT", ICON_ROTACTIVE, "Active Element", "Pivot around active object"}, - {0, NULL, 0, NULL, NULL} -}; - -static const EnumPropertyItem draw_channels_items[] = { +static const EnumPropertyItem display_channels_items[] = { {SI_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha", - "Draw image with RGB colors and alpha transparency"}, - {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors"}, - {SI_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel"}, + "Display image with RGB colors and alpha transparency"}, + {0, "COLOR", ICON_IMAGE_RGB, "Color", "Display image with RGB colors"}, + {SI_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Display alpha transparency channel"}, {SI_SHOW_ZBUF, "Z_BUFFER", ICON_IMAGE_ZDEPTH, "Z-Buffer", - "Draw Z-buffer associated with image (mapped from camera clip start to end)"}, + "Display Z-buffer associated with image (mapped from camera clip start to end)"}, {SI_SHOW_R, "RED", ICON_COLOR_RED, "Red", ""}, {SI_SHOW_G, "GREEN", ICON_COLOR_GREEN, "Green", ""}, {SI_SHOW_B, "BLUE", ICON_COLOR_BLUE, "Blue", ""}, {0, NULL, 0, NULL, NULL} }; -static const EnumPropertyItem transform_orientation_items[] = { - {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", "Align the transformation axes to world space"}, - {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", "Align the transformation axes to the selected objects' local space"}, - {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", - "Align the transformation axes to average normal of selected elements " - "(bone Y axis for pose mode)"}, - {V3D_MANIP_GIMBAL, "GIMBAL", 0, "Gimbal", "Align each axis to the Euler rotation axis as used for input"}, - {V3D_MANIP_VIEW, "VIEW", 0, "View", "Align the transformation axes to the window"}, - // {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"}, - {0, NULL, 0, NULL, NULL} -}; - #ifndef RNA_RUNTIME static const EnumPropertyItem autosnap_items[] = { {SACTSNAP_OFF, "NONE", 0, "No Auto-Snap", ""}, @@ -185,17 +238,35 @@ static const EnumPropertyItem autosnap_items[] = { }; #endif -const EnumPropertyItem rna_enum_viewport_shade_items[] = { - {OB_BOUNDBOX, "BOUNDBOX", ICON_BBOX, "Bounding Box", "Display the object's local bounding boxes only"}, - {OB_WIRE, "WIREFRAME", ICON_WIRE, "Wireframe", "Display the object as wire edges"}, - {OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display the object solid, lit with default OpenGL lights"}, - {OB_TEXTURE, "TEXTURED", ICON_POTATO, "Texture", "Display the object solid, with a texture"}, - {OB_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Display objects solid, with GLSL material"}, - {OB_RENDER, "RENDERED", ICON_SMOOTH, "Rendered", "Display render preview"}, +const EnumPropertyItem rna_enum_shading_type_items[] = { + {OB_WIRE, "WIREFRAME", ICON_SHADING_WIRE, "Wireframe", "Display the object as wire edges"}, + {OB_SOLID, "SOLID", ICON_SHADING_SOLID, "Solid", "Display in solid mode"}, + {OB_MATERIAL, "MATERIAL", ICON_SHADING_TEXTURE, "LookDev", "Display in LookDev mode"}, + {OB_RENDER, "RENDERED", ICON_SHADING_RENDERED, "Rendered", "Display render preview"}, + {0, NULL, 0, NULL, NULL} +}; + +static const EnumPropertyItem rna_enum_viewport_lighting_items[] = { + {V3D_LIGHTING_FLAT, "FLAT", 0, "Flat", "Display using flat lighting"}, + {V3D_LIGHTING_STUDIO, "STUDIO", 0, "Studio", "Display using studio lighting"}, + {V3D_LIGHTING_MATCAP, "MATCAP", 0, "MatCap", "Display using matcap material and lighting"}, + {0, NULL, 0, NULL, NULL} +}; + +static const EnumPropertyItem rna_enum_shading_color_type_items[] = { + {V3D_SHADING_SINGLE_COLOR, "SINGLE", 0, "Single", "Show scene in a single color"}, + {V3D_SHADING_MATERIAL_COLOR, "MATERIAL", 0, "Material", "Show material color"}, + {V3D_SHADING_RANDOM_COLOR, "RANDOM", 0, "Random", "Show random object color"}, + {V3D_SHADING_TEXTURE_COLOR, "TEXTURE", 0, "Texture", "Show texture"}, {0, NULL, 0, NULL, NULL} }; +static const EnumPropertyItem rna_enum_studio_light_items[] = { + {0, "DEFAULT", 0, "Default", ""}, + {0, NULL, 0, NULL, NULL} +}; + const EnumPropertyItem rna_enum_clip_editor_mode_items[] = { {SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"}, {SC_MODE_MASKEDIT, "MASK", ICON_MOD_MASK, "Mask", "Show mask editing tools"}, @@ -204,35 +275,26 @@ const EnumPropertyItem rna_enum_clip_editor_mode_items[] = { /* Actually populated dynamically trough a function, but helps for context-less access (e.g. doc, i18n...). */ static const EnumPropertyItem buttons_context_items[] = { + {BCONTEXT_TOOL, "TOOL", ICON_TOOL_SETTINGS, "Tool", "Active Tool and Workspace settings"}, {BCONTEXT_SCENE, "SCENE", ICON_SCENE_DATA, "Scene", "Scene"}, {BCONTEXT_RENDER, "RENDER", ICON_SCENE, "Render", "Render"}, - {BCONTEXT_RENDER_LAYER, "RENDER_LAYER", ICON_RENDERLAYERS, "Render Layers", "Render layers"}, + {BCONTEXT_OUTPUT, "OUTPUT", ICON_IMAGE_DATA, "Output", "Output"}, + {BCONTEXT_VIEW_LAYER, "VIEW_LAYER", ICON_RENDER_RESULT, "View Layer", "View Layer"}, {BCONTEXT_WORLD, "WORLD", ICON_WORLD, "World", "World"}, {BCONTEXT_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Object"}, - {BCONTEXT_CONSTRAINT, "CONSTRAINT", ICON_CONSTRAINT, "Constraints", "Object constraints"}, - {BCONTEXT_MODIFIER, "MODIFIER", ICON_MODIFIER, "Modifiers", "Object modifiers"}, - {BCONTEXT_DATA, "DATA", ICON_NONE, "Data", "Object data"}, + {BCONTEXT_CONSTRAINT, "CONSTRAINT", ICON_CONSTRAINT, "Constraints", "Object Constraints"}, + {BCONTEXT_MODIFIER, "MODIFIER", ICON_MODIFIER, "Modifiers", "Modifiers"}, + {BCONTEXT_DATA, "DATA", ICON_NONE, "Data", "Object Data"}, {BCONTEXT_BONE, "BONE", ICON_BONE_DATA, "Bone", "Bone"}, - {BCONTEXT_BONE_CONSTRAINT, "BONE_CONSTRAINT", ICON_CONSTRAINT_BONE, "Bone Constraints", "Bone constraints"}, + {BCONTEXT_BONE_CONSTRAINT, "BONE_CONSTRAINT", ICON_CONSTRAINT_BONE, "Bone Constraints", "Bone Constraints"}, {BCONTEXT_MATERIAL, "MATERIAL", ICON_MATERIAL, "Material", "Material"}, {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"}, - {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"}, + {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particles"}, {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"}, + {BCONTEXT_SHADERFX, "SHADERFX", ICON_SHADERFX, "Effects", "Object visual effects" }, {0, NULL, 0, NULL, NULL} }; -/* Actually populated dynamically trough a function, but helps for context-less access (e.g. doc, i18n...). */ -static const EnumPropertyItem buttons_texture_context_items[] = { - {SB_TEXC_MATERIAL, "MATERIAL", ICON_MATERIAL, "", "Show material textures"}, - {SB_TEXC_WORLD, "WORLD", ICON_WORLD, "", "Show world textures"}, - {SB_TEXC_LAMP, "LAMP", ICON_LAMP, "", "Show lamp textures"}, - {SB_TEXC_PARTICLES, "PARTICLES", ICON_PARTICLES, "", "Show particles textures"}, - {SB_TEXC_LINESTYLE, "LINESTYLE", ICON_LINE_DATA, "", "Show linestyle textures"}, - {SB_TEXC_OTHER, "OTHER", ICON_TEXTURE, "", "Show other data textures"}, - {0, NULL, 0, NULL, NULL} -}; - - static const EnumPropertyItem fileselectparams_recursion_level_items[] = { {0, "NONE", 0, "None", "Only list current directory's content, with no recursion"}, {1, "BLEND", 0, "Blend File", "List .blend files' content"}, @@ -257,7 +319,6 @@ const EnumPropertyItem rna_enum_file_sort_items[] = { #include "DNA_screen_types.h" #include "DNA_userdef_types.h" -#include "BLI_math.h" #include "BLI_path_util.h" #include "BLI_string.h" @@ -265,18 +326,24 @@ const EnumPropertyItem rna_enum_file_sort_items[] = { #include "BKE_brush.h" #include "BKE_colortools.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" +#include "BKE_layer.h" #include "BKE_global.h" #include "BKE_nla.h" #include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_icons.h" +#include "BKE_workspace.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + +#include "ED_anim_api.h" #include "ED_buttons.h" #include "ED_fileselect.h" #include "ED_image.h" #include "ED_node.h" +#include "ED_transform.h" #include "ED_screen.h" #include "ED_view3d.h" #include "ED_sequencer.h" @@ -316,12 +383,8 @@ static StructRNA *rna_Space_refine(struct PointerRNA *ptr) return &RNA_SpaceDopeSheetEditor; case SPACE_NLA: return &RNA_SpaceNLA; - case SPACE_TIME: - return &RNA_SpaceTimeline; case SPACE_NODE: return &RNA_SpaceNodeEditor; - case SPACE_LOGIC: - return &RNA_SpaceLogicEditor; case SPACE_CONSOLE: return &RNA_SpaceConsole; case SPACE_USERPREF: @@ -416,55 +479,15 @@ static void rna_Space_view2d_sync_update(Main *UNUSED(bmain), Scene *UNUSED(scen } } -static PointerRNA rna_CurrentOrientation_get(PointerRNA *ptr) +static void rna_GPencil_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; - View3D *v3d = (View3D *)ptr->data; - - if (v3d->twmode < V3D_MANIP_CUSTOM) - return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, NULL); - else - return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, - BLI_findlink(&scene->transform_spaces, v3d->twmode - V3D_MANIP_CUSTOM)); -} - -const EnumPropertyItem *rna_TransformOrientation_itemf( - bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) -{ - Scene *scene = NULL; - ListBase *transform_spaces; - TransformOrientation *ts = NULL; - EnumPropertyItem tmp = {0, "", 0, "", ""}; - EnumPropertyItem *item = NULL; - int i = V3D_MANIP_CUSTOM, totitem = 0; - - RNA_enum_items_add(&item, &totitem, transform_orientation_items); - - if (ptr->type == &RNA_SpaceView3D) - scene = ((bScreen *)ptr->id.data)->scene; - else - scene = CTX_data_scene(C); /* can't use scene from ptr->id.data because that enum is also used by operators */ - - if (scene) { - transform_spaces = &scene->transform_spaces; - ts = transform_spaces->first; - } - - if (ts) { - RNA_enum_item_add_separator(&item, &totitem); - - for (; ts; ts = ts->next) { - tmp.identifier = ts->name; - tmp.name = ts->name; - tmp.value = i++; - RNA_enum_item_add(&item, &totitem, &tmp); + /* need set all caches as dirty to recalculate onion skinning */ + for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { + if (ob->type == OB_GPENCIL) { + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } } - - RNA_enum_item_end(&item, &totitem); - *r_free = true; - - return item; + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } /* Space 3D View */ @@ -472,8 +495,10 @@ static void rna_SpaceView3D_camera_update(Main *bmain, Scene *scene, PointerRNA { View3D *v3d = (View3D *)(ptr->data); if (v3d->scenelock) { + wmWindowManager *wm = bmain->wm.first; + scene->camera = v3d->camera; - BKE_screen_view3d_main_sync(&bmain->screen, scene); + WM_windows_scene_data_sync(&wm->windows, scene); } } @@ -485,8 +510,13 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, bool val v3d->scenelock = value; if (value) { + Scene *scene = ED_screen_scene_find(sc, G_MAIN->wm.first); + + /* TODO: restore local view. */ +#if 0 int bit; - v3d->lay = sc->scene->lay; + v3d->lay = scene->lay; + /* seek for layact */ bit = 0; while (bit < 32) { @@ -496,118 +526,59 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, bool val } bit++; } - v3d->camera = sc->scene->camera; +#endif + v3d->camera = scene->camera; } } -static void rna_View3D_CursorLocation_get(PointerRNA *ptr, float *values) -{ - View3D *v3d = (View3D *)(ptr->data); - bScreen *sc = (bScreen *)ptr->id.data; - Scene *scene = (Scene *)sc->scene; - const float *loc = ED_view3d_cursor3d_get(scene, v3d); - - copy_v3_v3(values, loc); -} - -static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values) -{ - View3D *v3d = (View3D *)(ptr->data); - bScreen *sc = (bScreen *)ptr->id.data; - Scene *scene = (Scene *)sc->scene; - float *cursor = ED_view3d_cursor3d_get(scene, v3d); - - copy_v3_v3(cursor, values); -} -static float rna_View3D_GridScaleUnit_get(PointerRNA *ptr) +static View3DCursor *rna_View3D_Cursor_get_from_scene_or_localview(PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); - bScreen *sc = (bScreen *)ptr->id.data; - Scene *scene = (Scene *)sc->scene; - - return ED_view3d_grid_scale(scene, v3d, NULL); + bScreen *screen = ptr->id.data; + Scene *scene = ED_screen_scene_find(screen, G_MAIN->wm.first); + return ED_view3d_cursor3d_get(scene, v3d); } -static void rna_SpaceView3D_layer_set(PointerRNA *ptr, const bool *values) +static void rna_View3D_Cursor_location_get(PointerRNA *ptr, float *values) { - View3D *v3d = (View3D *)(ptr->data); - - v3d->lay = ED_view3d_scene_layer_set(v3d->lay, values, &v3d->layact); + const View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr); + copy_v3_v3(values, cursor->location); } -static int rna_SpaceView3D_active_layer_get(PointerRNA *ptr) +static void rna_View3D_Cursor_location_set(PointerRNA *ptr, const float *values) { - View3D *v3d = (View3D *)(ptr->data); - - return (int)(log(v3d->layact) / M_LN2); + View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr); + copy_v3_v3(cursor->location, values); } -static void rna_SpaceView3D_layer_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +static void rna_View3D_Cursor_rotation_get(PointerRNA *ptr, float *values) { - DAG_on_visible_update(bmain, false); + const View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr); + copy_qt_qt(values, cursor->rotation); } -static void rna_SpaceView3D_viewport_shade_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_View3D_Cursor_rotation_set(PointerRNA *ptr, const float *values) { - View3D *v3d = (View3D *)(ptr->data); - ScrArea *sa = rna_area_from_space(ptr); - - ED_view3d_shade_update(bmain, v3d, sa); + View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr); + copy_qt_qt(cursor->rotation, values); } -static void rna_SpaceView3D_matcap_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_View3D_Cursor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) { - View3D *v3d = (View3D *)(ptr->data); - - if (v3d->defmaterial) { - Material *ma = v3d->defmaterial; - - if (ma->preview) - BKE_previewimg_free(&ma->preview); - - if (ma->gpumaterial.first) - GPU_material_free(&ma->gpumaterial); - - WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma); + View3D *v3d = ptr->data; + if (v3d->localvd == NULL) { + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); } } -static void rna_SpaceView3D_matcap_enable(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static float rna_View3DOverlay_GridScaleUnit_get(PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); + bScreen *screen = ptr->id.data; + Scene *scene = ED_screen_scene_find(screen, G_MAIN->wm.first); - if (v3d->matcap_icon < ICON_MATCAP_01 || - v3d->matcap_icon > ICON_MATCAP_24) - { - v3d->matcap_icon = ICON_MATCAP_01; - } -} - -static void rna_SpaceView3D_pivot_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) -{ - if (U.uiflag & USER_LOCKAROUND) { - View3D *v3d_act = (View3D *)(ptr->data); - - /* TODO, space looper */ - bScreen *screen; - for (screen = bmain->screen.first; screen; screen = screen->id.next) { - ScrArea *sa; - for (sa = screen->areabase.first; sa; sa = sa->next) { - SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_VIEW3D) { - View3D *v3d = (View3D *)sl; - if (v3d != v3d_act) { - v3d->around = v3d_act->around; - v3d->flag = (v3d->flag & ~V3D_ALIGN) | (v3d_act->flag & V3D_ALIGN); - ED_area_tag_redraw_regiontype(sa, RGN_TYPE_HEADER); - } - } - } - } - } - } + return ED_view3d_grid_scale(scene, v3d, NULL); } static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr) @@ -706,56 +677,274 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value ED_view3d_from_m4(mat, rv3d->ofs, rv3d->viewquat, &rv3d->dist); } -static int rna_SpaceView3D_viewport_shade_get(PointerRNA *ptr) +static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; - RenderEngineType *type = RE_engines_find(scene->r.engine); - View3D *v3d = (View3D *)ptr->data; - int drawtype = v3d->drawtype; + ID *id = ptr->id.data; + if (GS(id->name) == ID_SCE) { + return; + } - if (drawtype == OB_RENDER && !(type && type->view_draw)) - return OB_SOLID; + for (Material *ma = bmain->mat.first; ma; ma = ma->id.next) { + /* XXX Dependency graph does not support CD mask tracking, + * so we trigger materials shading for until it's properly supported. + * This is to ensure material batches are all recreated when switching + * shading type. In the future DEG should replace this and just tag + * the meshes itself. + * This hack just tag BKE_MESH_BATCH_DIRTY_SHADING for every mesh that + * have a material. (see T55059) */ + DEG_id_tag_update(&ma->id, DEG_TAG_SHADING_UPDATE); + } + + bScreen *screen = ptr->id.data; + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + if (&v3d->shading == ptr->data) { + ED_view3d_shade_update(bmain, v3d, sa); + return; + } + } + } + } +} + +static Scene *rna_3DViewShading_scene(PointerRNA *ptr) +{ + /* Get scene, depends if using 3D view or OpenGL render settings. */ + ID *id = ptr->id.data; + if (GS(id->name) == ID_SCE) { + return (Scene *)id; + } + else { + bScreen *screen = ptr->id.data; + return WM_windows_scene_get_from_screen(G_MAIN->wm.first, screen); + } +} - return drawtype; +static int rna_3DViewShading_type_get(PointerRNA *ptr) +{ + /* Available shading types depend on render engine. */ + Scene *scene = rna_3DViewShading_scene(ptr); + RenderEngineType *type = RE_engines_find(scene->r.engine); + View3DShading *shading = (View3DShading *)ptr->data; + + if (BKE_scene_uses_blender_eevee(scene)) { + return shading->type; + } + else if (BKE_scene_uses_blender_opengl(scene)) { + return (shading->type == OB_MATERIAL) ? OB_RENDER : shading->type; + } + else { + if (shading->type == OB_RENDER && !(type && type->view_draw)) { + return OB_MATERIAL; + } + else { + return shading->type; + } + } } -static void rna_SpaceView3D_viewport_shade_set(PointerRNA *ptr, int value) +static void rna_3DViewShading_type_set(PointerRNA *ptr, int value) { - View3D *v3d = (View3D *)ptr->data; - if (value != v3d->drawtype && value == OB_RENDER) { - v3d->prev_drawtype = v3d->drawtype; + View3DShading *shading = (View3DShading *)ptr->data; + if (value != shading->type && value == OB_RENDER) { + shading->prev_type = shading->type; } - v3d->drawtype = value; + shading->type = value; } -static const EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *rna_3DViewShading_type_itemf( + bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *r_free) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; + Scene *scene = rna_3DViewShading_scene(ptr); RenderEngineType *type = RE_engines_find(scene->r.engine); EnumPropertyItem *item = NULL; int totitem = 0; - RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_BOUNDBOX); - RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_WIRE); - RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_SOLID); - RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_TEXTURE); - RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_MATERIAL); + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_WIRE); + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_SOLID); + + if (BKE_scene_uses_blender_eevee(scene)) { + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_MATERIAL); + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER); + } + else if (BKE_scene_uses_blender_opengl(scene)) { + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER); + } + else { + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_MATERIAL); + if (type && type->view_draw) { + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_RENDER); + } + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + +/* Shading.selected_studio_light */ +static PointerRNA rna_View3DShading_selected_studio_light_get(PointerRNA *ptr) +{ + View3DShading *shading = (View3DShading *)ptr->data; + StudioLight *sl; + if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) { + sl = BKE_studiolight_find(shading->matcap, STUDIOLIGHT_FLAG_ALL); + } + else { + sl = BKE_studiolight_find(shading->studio_light, STUDIOLIGHT_FLAG_ALL); + } + return rna_pointer_inherit_refine(ptr, &RNA_StudioLight, sl); +} + +/* shading.light */ +static int rna_View3DShading_light_get(PointerRNA *ptr) +{ + View3DShading *shading = (View3DShading *)ptr->data; + return shading->light; +} + +static void rna_View3DShading_light_set(PointerRNA *ptr, int value) +{ + View3DShading *shading = (View3DShading *)ptr->data; + if (value == V3D_LIGHTING_MATCAP && shading->color_type == V3D_SHADING_TEXTURE_COLOR) { + shading->color_type = V3D_SHADING_MATERIAL_COLOR; + } + shading->light = value; +} + +static const EnumPropertyItem *rna_View3DShading_color_type_itemf( + bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *r_free) +{ + View3DShading *shading = (View3DShading *)ptr->data; + + int totitem = 0; + EnumPropertyItem *item = NULL; - if (type && type->view_draw) - RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_RENDER); + if (shading->type == OB_SOLID) { + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_SINGLE_COLOR); + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_MATERIAL_COLOR); + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_RANDOM_COLOR); + if (shading->light != V3D_LIGHTING_MATCAP) { + RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_TEXTURE_COLOR); + } + } RNA_enum_item_end(&item, &totitem); *r_free = true; + return item; +} + +/* Studio light */ +static int rna_View3DShading_studio_light_get(PointerRNA *ptr) +{ + View3DShading *shading = (View3DShading *)ptr->data; + char *dna_storage = shading->studio_light; + + int flag = STUDIOLIGHT_ORIENTATIONS_SOLID; + if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) { + flag = STUDIOLIGHT_ORIENTATION_VIEWNORMAL; + dna_storage = shading->matcap; + } + else if (shading->type == OB_MATERIAL) { + flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE; + } + StudioLight *sl = BKE_studiolight_find(dna_storage, flag); + if (sl) { + BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE); + return sl->index; + } + else { + return 0; + } +} + +static void rna_View3DShading_studio_light_set(PointerRNA *ptr, int value) +{ + View3DShading *shading = (View3DShading *)ptr->data; + char *dna_storage = shading->studio_light; + + int flag = STUDIOLIGHT_ORIENTATIONS_SOLID; + if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) { + flag = STUDIOLIGHT_ORIENTATION_VIEWNORMAL; + dna_storage = shading->matcap; + } + else if (shading->type == OB_MATERIAL) { + flag = STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE; + } + StudioLight *sl = BKE_studiolight_findindex(value, flag); + if (sl) { + BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE); + } +} + +static const EnumPropertyItem *rna_View3DShading_studio_light_itemf( + bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *r_free) +{ + View3DShading *shading = (View3DShading *)ptr->data; + EnumPropertyItem *item = NULL; + int totitem = 0; + + if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) { + const int flags = (STUDIOLIGHT_EXTERNAL_FILE | STUDIOLIGHT_ORIENTATION_VIEWNORMAL); + LISTBASE_FOREACH(StudioLight *, sl, BKE_studiolight_listbase()) { + int icon_id = (shading->flag & V3D_SHADING_MATCAP_FLIP_X) ? sl->icon_id_matcap_flipped: sl->icon_id_matcap; + if ((sl->flag & flags) == flags) { + EnumPropertyItem tmp = {sl->index, sl->name, icon_id, sl->name, ""}; + RNA_enum_item_add(&item, &totitem, &tmp); + } + } + } + else { + LISTBASE_FOREACH(StudioLight *, sl, BKE_studiolight_listbase()) { + int icon_id = sl->icon_id_irradiance; + bool show_studiolight = false; + + if (sl->flag & STUDIOLIGHT_INTERNAL) { + /* always show internal lights for solid */ + if (shading->type == OB_SOLID) { + show_studiolight = true; + } + } + else { + switch (shading->type) { + case OB_SOLID: + case OB_TEXTURE: + show_studiolight = ( + (sl->flag & (STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_CAMERA)) != 0); + break; + + case OB_MATERIAL: + show_studiolight = ((sl->flag & STUDIOLIGHT_ORIENTATION_WORLD) != 0); + icon_id = sl->icon_id_radiance; + break; + } + } + + if (show_studiolight) { + EnumPropertyItem tmp = {sl->index, sl->name, icon_id, sl->name, ""}; + RNA_enum_item_add(&item, &totitem, &tmp); + } + } + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; return item; } -static const EnumPropertyItem *rna_SpaceView3D_stereo3d_camera_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) +static const EnumPropertyItem *rna_SpaceView3D_stereo3d_camera_itemf( + bContext *C, PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; + Scene *scene = CTX_data_scene(C); if (scene->r.views_format == SCE_VIEWS_FORMAT_MULTIVIEW) return multiview_camera_items; @@ -763,6 +952,30 @@ static const EnumPropertyItem *rna_SpaceView3D_stereo3d_camera_itemf(bContext *U return stereo3d_camera_items; } +static int rna_SpaceView3D_icon_from_show_object_viewport_get(PointerRNA *ptr) +{ + const View3D *v3d = (View3D *)ptr->data; + /* Ignore selection values when view is off, intent is to show if visible objects aren't selectable. */ + const int view_value = (v3d->object_type_exclude_viewport != 0); + const int select_value = (v3d->object_type_exclude_select & ~v3d->object_type_exclude_viewport) != 0; + return ICON_VIS_SEL_11 + (view_value << 1) + select_value; +} + +static char *rna_View3DShading_path(PointerRNA *UNUSED(ptr)) +{ + return BLI_sprintfN("shading"); +} + +static PointerRNA rna_SpaceView3D_overlay_get(PointerRNA *ptr) +{ + return rna_pointer_inherit_refine(ptr, &RNA_View3DOverlay, ptr->data); +} + +static char *rna_View3DOverlay_path(PointerRNA *UNUSED(ptr)) +{ + return BLI_sprintfN("overlay"); +} + /* Space Image Editor */ static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr) @@ -823,23 +1036,32 @@ static bool rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; - return ED_space_image_show_uvedit(sima, sc->scene->obedit); + wmWindow *win = ED_screen_window_find(sc, G_MAIN->wm.first); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + return ED_space_image_show_uvedit(sima, obedit); } static bool rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; - return ED_space_image_check_show_maskedit(sc->scene, sima); + wmWindow *win = ED_screen_window_find(sc, G_MAIN->wm.first); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + return ED_space_image_check_show_maskedit(sima, view_layer); } static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; + wmWindow *win; + Scene *scene = ED_screen_scene_find_with_window(sc, G_MAIN->wm.first, &win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); BLI_assert(BKE_id_is_in_gobal_main(value.data)); - ED_space_image_set(G_MAIN, sima, sc->scene, sc->scene->obedit, (Image *)value.data); + ED_space_image_set(G_MAIN, sima, scene, obedit, (Image *)value.data); } static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value) @@ -849,8 +1071,9 @@ static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value) ED_space_image_set_mask(NULL, sima, (Mask *)value.data); } -static const EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *rna_SpaceImageEditor_display_channels_itemf( + bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *r_free) { SpaceImage *sima = (SpaceImage *)ptr->data; EnumPropertyItem *item = NULL; @@ -866,24 +1089,24 @@ static const EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext ED_space_image_release_buffer(sima, ibuf, lock); if (alpha && zbuf) - return draw_channels_items; + return display_channels_items; if (alpha) { - RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_USE_ALPHA); - RNA_enum_items_add_value(&item, &totitem, draw_channels_items, 0); - RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_ALPHA); + RNA_enum_items_add_value(&item, &totitem, display_channels_items, SI_USE_ALPHA); + RNA_enum_items_add_value(&item, &totitem, display_channels_items, 0); + RNA_enum_items_add_value(&item, &totitem, display_channels_items, SI_SHOW_ALPHA); } else if (zbuf) { - RNA_enum_items_add_value(&item, &totitem, draw_channels_items, 0); - RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_ZBUF); + RNA_enum_items_add_value(&item, &totitem, display_channels_items, 0); + RNA_enum_items_add_value(&item, &totitem, display_channels_items, SI_SHOW_ZBUF); } else { - RNA_enum_items_add_value(&item, &totitem, draw_channels_items, 0); + RNA_enum_items_add_value(&item, &totitem, display_channels_items, 0); } - RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_R); - RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_G); - RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_B); + RNA_enum_items_add_value(&item, &totitem, display_channels_items, SI_SHOW_R); + RNA_enum_items_add_value(&item, &totitem, display_channels_items, SI_SHOW_G); + RNA_enum_items_add_value(&item, &totitem, display_channels_items, SI_SHOW_B); RNA_enum_item_end(&item, &totitem); *r_free = true; @@ -971,14 +1194,15 @@ static void rna_SpaceImageEditor_scopes_update(struct bContext *C, struct Pointe ED_space_image_release_buffer(sima, ibuf, lock); } -static const EnumPropertyItem *rna_SpaceImageEditor_pivot_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) +static const EnumPropertyItem *rna_SpaceImageEditor_pivot_itemf( + bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) { static const EnumPropertyItem pivot_items[] = { - {V3D_AROUND_CENTER_BOUNDS, "CENTER", ICON_ROTATE, "Bounding Box Center", ""}, - {V3D_AROUND_CENTER_MEAN, "MEDIAN", ICON_ROTATECENTER, "Median Point", ""}, - {V3D_AROUND_CURSOR, "CURSOR", ICON_CURSOR, "2D Cursor", ""}, - {V3D_AROUND_LOCAL_ORIGINS, "INDIVIDUAL_ORIGINS", ICON_ROTATECOLLECTION, + {V3D_AROUND_CENTER_BOUNDS, "CENTER", ICON_PIVOT_BOUNDBOX, "Bounding Box Center", ""}, + {V3D_AROUND_CENTER_MEAN, "MEDIAN", ICON_PIVOT_MEDIAN, "Median Point", ""}, + {V3D_AROUND_CURSOR, "CURSOR", ICON_PIVOT_CURSOR, "2D Cursor", ""}, + {V3D_AROUND_LOCAL_ORIGINS, "INDIVIDUAL_ORIGINS", ICON_PIVOT_INDIVIDUAL, "Individual Origins", "Pivot around each selected island's own median point"}, {0, NULL, 0, NULL, NULL} }; @@ -986,7 +1210,7 @@ static const EnumPropertyItem *rna_SpaceImageEditor_pivot_itemf(bContext *UNUSED SpaceImage *sima = (SpaceImage *)ptr->data; if (sima->mode == SI_MODE_PAINT) - return pivot_items_full; + return rna_enum_transform_pivot_items_full; else return pivot_items; } @@ -1074,19 +1298,32 @@ static void rna_SpaceProperties_context_set(PointerRNA *ptr, int value) sbuts->mainbuser = value; } -static const EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *rna_SpaceProperties_context_itemf( + bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *r_free) { SpaceButs *sbuts = (SpaceButs *)(ptr->data); EnumPropertyItem *item = NULL; int totitem = 0; + if (sbuts->pathflag & (1 << BCONTEXT_TOOL)) { + RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_TOOL); + } + + if (totitem) { + RNA_enum_item_add_separator(&item, &totitem); + } + if (sbuts->pathflag & (1 << BCONTEXT_RENDER)) { RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_RENDER); } - if (sbuts->pathflag & (1 << BCONTEXT_RENDER_LAYER)) { - RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_RENDER_LAYER); + if (sbuts->pathflag & (1 << BCONTEXT_OUTPUT)) { + RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_OUTPUT); + } + + if (sbuts->pathflag & (1 << BCONTEXT_VIEW_LAYER)) { + RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_VIEW_LAYER); } if (sbuts->pathflag & (1 << BCONTEXT_SCENE)) { @@ -1097,6 +1334,10 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSE RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORLD); } + if (totitem) { + RNA_enum_item_add_separator(&item, &totitem); + } + if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) { RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_OBJECT); } @@ -1109,6 +1350,10 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSE RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_MODIFIER); } + if (sbuts->pathflag & (1 << BCONTEXT_SHADERFX)) { + RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_SHADERFX); + } + if (sbuts->pathflag & (1 << BCONTEXT_DATA)) { RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_DATA); (item + totitem - 1)->icon = sbuts->dataicon; @@ -1147,63 +1392,12 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSE static void rna_SpaceProperties_context_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { SpaceButs *sbuts = (SpaceButs *)(ptr->data); - /* XXX BCONTEXT_DATA is ugly, but required for lamps... See T51318. */ + /* XXX BCONTEXT_DATA is ugly, but required for lights... See T51318. */ if (ELEM(sbuts->mainb, BCONTEXT_WORLD, BCONTEXT_MATERIAL, BCONTEXT_TEXTURE, BCONTEXT_DATA)) { sbuts->preview = 1; } } -static void rna_SpaceProperties_align_set(PointerRNA *ptr, int value) -{ - SpaceButs *sbuts = (SpaceButs *)(ptr->data); - - sbuts->align = value; - sbuts->re_align = 1; -} - -static const EnumPropertyItem *rna_SpaceProperties_texture_context_itemf(bContext *C, PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), bool *r_free) -{ - EnumPropertyItem *item = NULL; - int totitem = 0; - - if (ED_texture_context_check_world(C)) { - RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_WORLD); - } - - if (ED_texture_context_check_lamp(C)) { - RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_LAMP); - } - else if (ED_texture_context_check_material(C)) { - RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_MATERIAL); - } - - if (ED_texture_context_check_particles(C)) { - RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_PARTICLES); - } - - if (ED_texture_context_check_linestyle(C)) { - RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_LINESTYLE); - } - - if (ED_texture_context_check_others(C)) { - RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_OTHER); - } - - RNA_enum_item_end(&item, &totitem); - *r_free = true; - - return item; -} - -static void rna_SpaceProperties_texture_context_set(PointerRNA *ptr, int value) -{ - SpaceButs *sbuts = (SpaceButs *)(ptr->data); - - /* User action, no need to keep "better" value in prev here! */ - sbuts->texture_context = sbuts->texture_context_prev = value; -} - /* Space Console */ static void rna_ConsoleLine_body_get(PointerRNA *ptr, char *value) { @@ -1278,10 +1472,12 @@ static void rna_SpaceDopeSheetEditor_action_set(PointerRNA *ptr, PointerRNA valu } } -static void rna_SpaceDopeSheetEditor_action_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr) { SpaceAction *saction = (SpaceAction *)(ptr->data); - Object *obact = (scene->basact) ? scene->basact->object : NULL; + ViewLayer *view_layer = CTX_data_view_layer(C); + Main *bmain = CTX_data_main(C); + Object *obact = OBACT(view_layer); /* we must set this action to be the one used by active object (if not pinned) */ if (obact /* && saction->pin == 0*/) { @@ -1347,16 +1543,18 @@ static void rna_SpaceDopeSheetEditor_action_update(Main *bmain, Scene *scene, Po } /* force depsgraph flush too */ - DAG_id_tag_update(&obact->id, OB_RECALC_OB | OB_RECALC_DATA); + DEG_id_tag_update(&obact->id, OB_RECALC_OB | OB_RECALC_DATA); /* Update relations as well, so new time source dependency is added. */ - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } } -static void rna_SpaceDopeSheetEditor_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr) { SpaceAction *saction = (SpaceAction *)(ptr->data); - Object *obact = (scene->basact) ? scene->basact->object : NULL; + ScrArea *sa = CTX_wm_area(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *obact = OBACT(view_layer); /* special exceptions for ShapeKey Editor mode */ if (saction->mode == SACTCONT_SHAPEKEY) { @@ -1384,15 +1582,46 @@ static void rna_SpaceDopeSheetEditor_mode_update(Main *UNUSED(bmain), Scene *sce saction->action = NULL; } + /* Collapse (and show) summary channel and hide channel list for timeline */ + if (saction->mode == SACTCONT_TIMELINE) { + saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED; + saction->ads.filterflag |= ADS_FILTER_SUMMARY; + } + + if (sa && sa->spacedata.first == saction) { + ARegion *channels_region = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); + if (channels_region) { + if (saction->mode == SACTCONT_TIMELINE) { + channels_region->flag |= RGN_FLAG_HIDDEN; + } + else { + channels_region->flag &= ~RGN_FLAG_HIDDEN; + } + ED_region_visibility_change_update(C, channels_region); + } + } + /* recalculate extents of channel list */ saction->flag |= SACTION_TEMP_NEEDCHANSYNC; + + /* store current mode as "old mode", so that returning from other editors doesn't always reset to "Action Editor" */ + if (saction->mode != SACTCONT_TIMELINE) { + saction->mode_prev = saction->mode; + } } /* Space Graph Editor */ -static void rna_SpaceGraphEditor_display_mode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_SpaceGraphEditor_display_mode_update(bContext *C, PointerRNA *ptr) { ScrArea *sa = rna_area_from_space(ptr); + SpaceIpo *sipo = (SpaceIpo *)ptr->data; + + /* for "Drivers" mode, enable all the necessary bits and pieces */ + if (sipo->mode == SIPO_MODE_DRIVERS) { + ED_drivers_editor_init(C, sa); + ED_area_tag_redraw(sa); + } /* after changing view mode, must force recalculation of F-Curve colors * which can only be achieved using refresh as opposed to redraw @@ -1418,59 +1647,6 @@ static void rna_Sequencer_view_type_update(Main *UNUSED(bmain), Scene *UNUSED(sc ED_area_tag_refresh(sa); } -static float rna_BackgroundImage_opacity_get(PointerRNA *ptr) -{ - BGpic *bgpic = (BGpic *)ptr->data; - return 1.0f - bgpic->blend; -} - -static void rna_BackgroundImage_opacity_set(PointerRNA *ptr, float value) -{ - BGpic *bgpic = (BGpic *)ptr->data; - bgpic->blend = 1.0f - value; -} - -/* radius internally (expose as a distance value) */ -static float rna_BackgroundImage_size_get(PointerRNA *ptr) -{ - BGpic *bgpic = ptr->data; - return bgpic->size * 2.0f; -} - -static void rna_BackgroundImage_size_set(PointerRNA *ptr, float value) -{ - BGpic *bgpic = ptr->data; - bgpic->size = value * 0.5f; -} - -static BGpic *rna_BackgroundImage_new(View3D *v3d) -{ - BGpic *bgpic = ED_view3d_background_image_new(v3d); - - WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, v3d); - - return bgpic; -} - -static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, PointerRNA *bgpic_ptr) -{ - BGpic *bgpic = bgpic_ptr->data; - if (BLI_findindex(&v3d->bgpicbase, bgpic) == -1) { - BKE_report(reports, RPT_ERROR, "Background image cannot be removed"); - } - - ED_view3d_background_image_remove(v3d, bgpic); - RNA_POINTER_INVALIDATE(bgpic_ptr); - - WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, v3d); -} - -static void rna_BackgroundImage_clear(View3D *v3d) -{ - ED_view3d_background_image_clear(v3d); - WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, v3d); -} - /* Space Node Editor */ static void rna_SpaceNodeEditor_node_tree_set(PointerRNA *ptr, const PointerRNA value) @@ -1511,12 +1687,19 @@ static bool rna_SpaceNodeEditor_tree_type_poll(void *Cv, bNodeTreeType *type) else return true; } -static const EnumPropertyItem *rna_SpaceNodeEditor_tree_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), bool *r_free) + +const EnumPropertyItem *RNA_enum_node_tree_types_itemf_impl(bContext *C, bool *r_free) { return rna_node_tree_type_itemf(C, rna_SpaceNodeEditor_tree_type_poll, r_free); } +static const EnumPropertyItem *rna_SpaceNodeEditor_tree_type_itemf( + bContext *C, PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), bool *r_free) +{ + return RNA_enum_node_tree_types_itemf_impl(C, r_free); +} + static void rna_SpaceNodeEditor_path_get(PointerRNA *ptr, char *value) { SpaceNode *snode = ptr->data; @@ -1696,6 +1879,18 @@ static int rna_FileBrowser_FSMenuEntry_name_get_editable(PointerRNA *ptr, const return fsm->save ? PROP_EDITABLE : 0; } +static bool rna_FileBrowser_FSMenuEntry_use_save_get(PointerRNA *ptr) +{ + FSMenuEntry *fsm = ptr->data; + return fsm->save; +} + +static bool rna_FileBrowser_FSMenuEntry_is_valid_get(PointerRNA *ptr) +{ + FSMenuEntry *fsm = ptr->data; + return fsm->valid; +} + static void rna_FileBrowser_FSMenu_next(CollectionPropertyIterator *iter) { ListBaseIterator *internal = &iter->internal.listbase; @@ -1913,10 +2108,10 @@ static void rna_FileBrowser_FSMenuRecent_active_range(PointerRNA *ptr, int *min, #else static const EnumPropertyItem dt_uv_items[] = { - {SI_UVDT_OUTLINE, "OUTLINE", 0, "Outline", "Draw white edges with black outline"}, - {SI_UVDT_DASH, "DASH", 0, "Dash", "Draw dashed black-white edges"}, - {SI_UVDT_BLACK, "BLACK", 0, "Black", "Draw black edges"}, - {SI_UVDT_WHITE, "WHITE", 0, "White", "Draw white edges"}, + {SI_UVDT_OUTLINE, "OUTLINE", 0, "Outline", "Display white edges with black outline"}, + {SI_UVDT_DASH, "DASH", 0, "Dash", "Display dashed black-white edges"}, + {SI_UVDT_BLACK, "BLACK", 0, "Black", "Display black edges"}, + {SI_UVDT_WHITE, "WHITE", 0, "White", "Display white edges"}, {0, NULL, 0, NULL, NULL} }; @@ -1933,6 +2128,7 @@ static void rna_def_space(BlenderRNA *brna) prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "spacetype"); RNA_def_property_enum_items(prop, rna_enum_space_type_items); + /* When making this editable, take care for the special case of global areas (see rna_Area_type_set). */ RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Type", "Space data type"); @@ -1962,15 +2158,15 @@ static void rna_def_space_mask_info(StructRNA *srna, int noteflag, const char *m RNA_def_property_update(prop, noteflag, NULL); /* mask drawing */ - prop = RNA_def_property(srna, "mask_draw_type", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "mask_display_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mask_info.draw_type"); RNA_def_property_enum_items(prop, dt_uv_items); - RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for mask splines"); + RNA_def_property_ui_text(prop, "Edge Display Type", "Display type for mask splines"); RNA_def_property_update(prop, noteflag, NULL); prop = RNA_def_property(srna, "show_mask_smooth", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mask_info.draw_flag", MASK_DRAWFLAG_SMOOTH); - RNA_def_property_ui_text(prop, "Draw Smooth Splines", ""); + RNA_def_property_ui_text(prop, "Display Smooth Splines", ""); RNA_def_property_update(prop, noteflag, NULL); prop = RNA_def_property(srna, "show_mask_overlay", PROP_BOOLEAN, PROP_NONE); @@ -2005,13 +2201,6 @@ static void rna_def_space_image_uv(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem other_uv_filter_items[] = { - {SI_FILTER_ALL, "ALL", 0, "All", "No filter, show all islands from other objects"}, - {SI_FILTER_SAME_IMAGE, "SAME_IMAGE", ICON_IMAGE_DATA, "Same Image", - "Only show others' UV islands whose active image matches image of the active face"}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "SpaceUVEditor", NULL); RNA_def_struct_sdna(srna, "SpaceImage"); RNA_def_struct_nested(brna, srna, "SpaceImageEditor"); @@ -2026,59 +2215,59 @@ static void rna_def_space_image_uv(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); /* drawing */ - prop = RNA_def_property(srna, "edge_draw_type", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "edge_display_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dt_uv"); RNA_def_property_enum_items(prop, dt_uv_items); - RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for drawing UV edges"); + RNA_def_property_ui_text(prop, "Edge Display Type", "Display type for drawing UV edges"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "show_smooth_edges", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SMOOTH_UV); - RNA_def_property_ui_text(prop, "Draw Smooth Edges", "Draw UV edges anti-aliased"); + RNA_def_property_ui_text(prop, "Display Smooth Edges", "Display UV edges anti-aliased"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "show_stretch", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_STRETCH); - RNA_def_property_ui_text(prop, "Draw Stretch", - "Draw faces colored according to the difference in shape between UVs and " + RNA_def_property_ui_text(prop, "Display Stretch", + "Display faces colored according to the difference in shape between UVs and " "their 3D coordinates (blue for low distortion, red for high distortion)"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - prop = RNA_def_property(srna, "draw_stretch_type", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "display_stretch_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch"); RNA_def_property_enum_items(prop, dt_uvstretch_items); - RNA_def_property_ui_text(prop, "Draw Stretch Type", "Type of stretch to draw"); + RNA_def_property_ui_text(prop, "Display Stretch Type", "Type of stretch to draw"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "show_modified_edges", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAWSHADOW); - RNA_def_property_ui_text(prop, "Draw Modified Edges", "Draw edges after modifiers are applied"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - - prop = RNA_def_property(srna, "show_other_objects", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_OTHER); - RNA_def_property_ui_text(prop, "Draw Other Objects", "Draw other selected objects that share the same image"); + RNA_def_property_ui_text(prop, "Display Modified Edges", "Display edges after modifiers are applied"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "show_metadata", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_METADATA); - RNA_def_property_ui_text(prop, "Show Metadata", "Draw metadata properties of the image"); + RNA_def_property_ui_text(prop, "Show Metadata", "Display metadata properties of the image"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "show_texpaint", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SI_NO_DRAW_TEXPAINT); - RNA_def_property_ui_text(prop, "Draw Texture Paint UVs", "Draw overlay of texture paint uv layer"); + RNA_def_property_ui_text(prop, "Display Texture Paint UVs", "Display overlay of texture paint uv layer"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - prop = RNA_def_property(srna, "show_normalized_coords", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_COORDFLOATS); - RNA_def_property_ui_text(prop, "Normalized Coordinates", - "Display UV coordinates from 0.0 to 1.0 rather than in pixels"); + prop = RNA_def_property(srna, "show_pixel_coords", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SI_COORDFLOATS); + RNA_def_property_ui_text(prop, "Pixel Coordinates", + "Display UV coordinates in pixels rather than from 0.0 to 1.0"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "show_faces", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SI_NO_DRAWFACES); - RNA_def_property_ui_text(prop, "Draw Faces", "Draw faces over the image"); + RNA_def_property_ui_text(prop, "Display Faces", "Display faces over the image"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); + + prop = RNA_def_property(srna, "show_edges", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SI_NO_DRAWEDGES); + RNA_def_property_ui_text(prop, "Display Edges", "Display edges in vertex select mode"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); /* todo: move edge and face drawing options here from G.f */ @@ -2099,13 +2288,6 @@ static void rna_def_space_image_uv(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Live Unwrap", "Continuously unwrap the selected UV island while transforming pinned vertices"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - - /* Other UV filtering */ - prop = RNA_def_property(srna, "other_uv_filter", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, other_uv_filter_items); - RNA_def_property_ui_text(prop, "Other UV filter", - "Filter applied on the other object's UV to limit displayed"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); } static void rna_def_space_outliner(BlenderRNA *brna) @@ -2114,23 +2296,24 @@ static void rna_def_space_outliner(BlenderRNA *brna) PropertyRNA *prop; static const EnumPropertyItem display_mode_items[] = { - {SO_ALL_SCENES, "ALL_SCENES", 0, "All Scenes", "Display data-blocks in all scenes"}, - {SO_CUR_SCENE, "CURRENT_SCENE", 0, "Current Scene", "Display data-blocks in current scene"}, - {SO_VISIBLE, "VISIBLE_LAYERS", 0, "Visible Layers", "Display data-blocks in visible layers"}, - {SO_SELECTED, "SELECTED", 0, "Selected", "Display data-blocks of selected, visible objects"}, - {SO_ACTIVE, "ACTIVE", 0, "Active", "Display data-blocks of active object"}, - {SO_SAME_TYPE, "SAME_TYPES", 0, "Same Types", - "Display data-blocks of all objects of same type as selected object"}, - {SO_GROUPS, "GROUPS", 0, "Groups", "Display groups and their data-blocks"}, - {SO_SEQUENCE, "SEQUENCE", 0, "Sequence", "Display sequence data-blocks"}, - {SO_LIBRARIES, "LIBRARIES", 0, "Blender File", "Display data of current file and linked libraries"}, - {SO_DATABLOCKS, "DATABLOCKS", 0, "Data-Blocks", "Display all raw data-blocks"}, - {SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", "Display user preference data"}, - {SO_ID_ORPHANS, "ORPHAN_DATA", 0, "Orphan Data", + {SO_SCENES, "SCENES", ICON_SCENE_DATA, "Scenes", "Display scenes and their view layers, collections and objects"}, + {SO_VIEW_LAYER, "VIEW_LAYER", ICON_RENDER_RESULT, "View Layer", "Display collections and objects in the view layer"}, + {SO_SEQUENCE, "SEQUENCE", ICON_SEQUENCE, "Sequence", "Display sequence data-blocks"}, + {SO_LIBRARIES, "LIBRARIES", ICON_FILE_BLEND, "Blender File", "Display data of current file and linked libraries"}, + {SO_DATA_API, "DATA_API", ICON_RNA, "Data API", "Display low level Blender data and its properties"}, + {SO_ID_ORPHANS, "ORPHAN_DATA", ICON_ORPHAN_DATA, "Orphan Data", "Display data-blocks which are unused and/or will be lost when the file is reloaded"}, {0, NULL, 0, NULL, NULL} }; + static const EnumPropertyItem filter_state_items[] = { + {SO_FILTER_OB_ALL, "ALL", 0, "All", "Show all objects in the view layer"}, + {SO_FILTER_OB_VISIBLE, "VISIBLE", 0, "Visible", "Show visible objects"}, + {SO_FILTER_OB_SELECTED, "SELECTED", 0, "Selected", "Show selected objects"}, + {SO_FILTER_OB_ACTIVE, "ACTIVE", 0, "Active", "Show only the active object"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "SpaceOutliner", "Space"); RNA_def_struct_sdna(srna, "SpaceOops"); RNA_def_struct_ui_text(srna, "Space Outliner", "Outliner space data"); @@ -2150,227 +2333,699 @@ static void rna_def_space_outliner(BlenderRNA *brna) prop = RNA_def_property(srna, "use_filter_case_sensitive", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "search_flags", SO_FIND_CASE_SENSITIVE); RNA_def_property_ui_text(prop, "Case Sensitive Matches Only", "Only use case sensitive matches of search string"); + RNA_def_property_ui_icon(prop, ICON_SYNTAX_OFF, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); prop = RNA_def_property(srna, "use_filter_complete", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "search_flags", SO_FIND_COMPLETE); RNA_def_property_ui_text(prop, "Complete Matches Only", "Only use complete matches of search string"); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_DATA_FONT, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); prop = RNA_def_property(srna, "use_sort_alpha", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SO_SKIP_SORT_ALPHA); RNA_def_property_ui_text(prop, "Sort Alphabetically", ""); + RNA_def_property_ui_icon(prop, ICON_SORTALPHA, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); prop = RNA_def_property(srna, "show_restrict_columns", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SO_HIDE_RESTRICTCOLS); RNA_def_property_ui_text(prop, "Show Restriction Columns", "Show column"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + /* Filters. */ + prop = RNA_def_property(srna, "use_filter_object", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OBJECT); + RNA_def_property_ui_text(prop, "Filter Objects", "Show objects"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + prop = RNA_def_property(srna, "use_filter_object_content", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OB_CONTENT); + RNA_def_property_ui_text(prop, "Show Object Contents", "Show what is inside the objects elements"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + prop = RNA_def_property(srna, "use_filter_children", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_CHILDREN); + RNA_def_property_ui_text(prop, "Show Object Children", "Show children"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + prop = RNA_def_property(srna, "use_filter_collection", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_COLLECTION); + RNA_def_property_ui_text(prop, "Show Collections", "Show collections"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + /* Filters object state. */ + prop = RNA_def_property(srna, "filter_state", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "filter_state"); + RNA_def_property_enum_items(prop, filter_state_items); + RNA_def_property_ui_text(prop, "Object State Filter", ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + /* Filters object type. */ + prop = RNA_def_property(srna, "use_filter_object_mesh", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OB_MESH); + RNA_def_property_ui_text(prop, "Show Meshes", "Show mesh objects"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + prop = RNA_def_property(srna, "use_filter_object_armature", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OB_ARMATURE); + RNA_def_property_ui_text(prop, "Show Armatures", "Show armature objects"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + prop = RNA_def_property(srna, "use_filter_object_empty", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OB_EMPTY); + RNA_def_property_ui_text(prop, "Show Empties", "Show empty objects"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + prop = RNA_def_property(srna, "use_filter_object_light", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OB_LAMP); + RNA_def_property_ui_text(prop, "Show Lights", "Show light objects"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + prop = RNA_def_property(srna, "use_filter_object_camera", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OB_CAMERA); + RNA_def_property_ui_text(prop, "Show Cameras", "Show camera objects"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + prop = RNA_def_property(srna, "use_filter_object_others", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OB_OTHERS); + RNA_def_property_ui_text(prop, "Show Other Objects", "Show curves, lattices, light probes, fonts, ..."); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + /* Libraries filter. */ + prop = RNA_def_property(srna, "use_filter_id_type", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", SO_FILTER_ID_TYPE); + RNA_def_property_ui_text(prop, "Filter By Type", "Show only data-blocks of one type"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); + + prop = RNA_def_property(srna, "filter_id_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "filter_id_type"); + RNA_def_property_enum_items(prop, rna_enum_id_type_items); + RNA_def_property_ui_text(prop, "Filter ID Type", "Data-block type to show"); } -static void rna_def_background_image(BlenderRNA *brna) +static void rna_def_space_view3d_shading(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - /* note: combinations work but don't flip so arnt that useful */ - static const EnumPropertyItem bgpic_axis_items[] = { - {0, "", 0, N_("X Axis"), ""}, - {(1 << RV3D_VIEW_LEFT), "LEFT", 0, "Left", "Show background image while looking to the left"}, - {(1 << RV3D_VIEW_RIGHT), "RIGHT", 0, "Right", "Show background image while looking to the right"}, - /*{(1<<RV3D_VIEW_LEFT)|(1<<RV3D_VIEW_RIGHT), "LEFT_RIGHT", 0, "Left/Right", ""},*/ - {0, "", 0, N_("Y Axis"), ""}, - {(1 << RV3D_VIEW_BACK), "BACK", 0, "Back", "Show background image in back view"}, - {(1 << RV3D_VIEW_FRONT), "FRONT", 0, "Front", "Show background image in front view"}, - /*{(1<<RV3D_VIEW_BACK)|(1<<RV3D_VIEW_FRONT), "BACK_FRONT", 0, "Back/Front", ""},*/ - {0, "", 0, N_("Z Axis"), ""}, - {(1 << RV3D_VIEW_BOTTOM), "BOTTOM", 0, "Bottom", "Show background image in bottom view"}, - {(1 << RV3D_VIEW_TOP), "TOP", 0, "Top", "Show background image in top view"}, - /*{(1<<RV3D_VIEW_BOTTOM)|(1<<RV3D_VIEW_TOP), "BOTTOM_TOP", 0, "Top/Bottom", ""},*/ - {0, "", 0, N_("Other"), ""}, - {0, "ALL", 0, "All Views", "Show background image in all views"}, - {(1 << RV3D_VIEW_CAMERA), "CAMERA", 0, "Camera", "Show background image in camera view"}, + static const EnumPropertyItem background_type_items[] = { + {V3D_SHADING_BACKGROUND_THEME, "THEME", 0, "Theme", "Use the theme for background color"}, + {V3D_SHADING_BACKGROUND_WORLD, "WORLD", 0, "World", "Use the world for background color"}, + {V3D_SHADING_BACKGROUND_VIEWPORT, "VIEWPORT", 0, "Viewport", "Use a custom color limited to this viewport only"}, {0, NULL, 0, NULL, NULL} }; + static const float default_background_color[] = {0.05f, 0.05f, 0.05f}; - static const EnumPropertyItem bgpic_source_items[] = { - {V3D_BGPIC_IMAGE, "IMAGE", 0, "Image", ""}, - {V3D_BGPIC_MOVIE, "MOVIE_CLIP", 0, "Movie Clip", ""}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem bgpic_camera_frame_items[] = { - {0, "STRETCH", 0, "Stretch", ""}, - {V3D_BGPIC_CAMERA_ASPECT, "FIT", 0, "Fit", ""}, - {V3D_BGPIC_CAMERA_ASPECT | V3D_BGPIC_CAMERA_CROP, "CROP", 0, "Crop", ""}, - {0, NULL, 0, NULL, NULL} - }; + /* Note these settings are used for both 3D viewport and the OpenGL render + * engine in the scene, so can't assume to always be part of a screen. */ + srna = RNA_def_struct(brna, "View3DShading", NULL); + RNA_def_struct_path_func(srna, "rna_View3DShading_path"); + RNA_def_struct_ui_text(srna, "3D View Shading Settings", "Settings for shading in the 3D viewport"); - static const EnumPropertyItem bgpic_draw_depth_items[] = { - {0, "BACK", 0, "Back", ""}, - {V3D_BGPIC_FOREGROUND, "FRONT", 0, "Front", ""}, - {0, NULL, 0, NULL, NULL} - }; + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_enum_shading_type_items); + RNA_def_property_enum_funcs(prop, "rna_3DViewShading_type_get", "rna_3DViewShading_type_set", + "rna_3DViewShading_type_itemf"); + RNA_def_property_ui_text(prop, "Viewport Shading", "Method to display/shade objects in the 3D View"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_3DViewShading_type_update"); - srna = RNA_def_struct(brna, "BackgroundImage", NULL); - RNA_def_struct_sdna(srna, "BGpic"); - RNA_def_struct_ui_text(srna, "Background Image", "Image and settings for display in the 3D View background"); + prop = RNA_def_property(srna, "light", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "light"); + RNA_def_property_enum_items(prop, rna_enum_viewport_lighting_items); + RNA_def_property_enum_funcs(prop, "rna_View3DShading_light_get", "rna_View3DShading_light_set", NULL); + RNA_def_property_ui_text(prop, "Lighting", "Lighting Method for Solid/Texture Viewport Shading"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "source"); - RNA_def_property_enum_items(prop, bgpic_source_items); - RNA_def_property_ui_text(prop, "Background Source", "Data source used for background"); + prop = RNA_def_property(srna, "show_object_outline", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_OBJECT_OUTLINE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Outline", "Show Object Outline"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "ima"); - RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space"); - RNA_def_property_flag(prop, PROP_EDITABLE); + prop = RNA_def_property(srna, "studio_light", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_enum_studio_light_items); + RNA_def_property_enum_default(prop, 0); + RNA_def_property_enum_funcs(prop, "rna_View3DShading_studio_light_get", "rna_View3DShading_studio_light_set", "rna_View3DShading_studio_light_itemf"); + RNA_def_property_ui_text(prop, "Studiolight", "Studio lighting setup"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "clip"); - RNA_def_property_ui_text(prop, "MovieClip", "Movie clip displayed and edited in this space"); - RNA_def_property_flag(prop, PROP_EDITABLE); + prop = RNA_def_property(srna, "show_cavity", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_CAVITY); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Cavity", "Show Cavity"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "iuser"); - RNA_def_property_ui_text(prop, "Image User", - "Parameters defining which layer, pass and frame of the image is displayed"); + prop = RNA_def_property(srna, "cavity_ridge_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "cavity_ridge_factor"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Ridge", "Factor for the ridges"); + RNA_def_property_range(prop, 0.0f, 250.0f); + RNA_def_property_ui_range(prop, 0.00f, 2.5f, 1, 3); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "clip_user", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "MovieClipUser"); - RNA_def_property_pointer_sdna(prop, NULL, "cuser"); - RNA_def_property_ui_text(prop, "Clip User", "Parameters defining which frame of the movie clip is displayed"); + prop = RNA_def_property(srna, "cavity_valley_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "cavity_valley_factor"); + RNA_def_property_float_default(prop, 1.0); + RNA_def_property_ui_text(prop, "Valley", "Factor for the valleys"); + RNA_def_property_range(prop, 0.0f, 250.0f); + RNA_def_property_ui_range(prop, 0.00f, 2.5f, 1, 3); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "offset_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "xof"); - RNA_def_property_ui_text(prop, "X Offset", "Offset image horizontally from the world origin"); + prop = RNA_def_property(srna, "selected_studio_light", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "StudioLight"); + RNA_define_verify_sdna(0); + RNA_def_property_ui_text(prop, "Studio Light", "Selected StudioLight"); + RNA_def_property_pointer_funcs(prop, "rna_View3DShading_selected_studio_light_get", NULL, NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_define_verify_sdna(1); + + prop = RNA_def_property(srna, "studiolight_rotate_z", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "studiolight_rot_z"); + RNA_def_property_float_default(prop, 0.0); + RNA_def_property_ui_text(prop, "Studiolight Rotation", "Rotation of the studiolight around the Z-Axis"); + RNA_def_property_range(prop, -M_PI, M_PI); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "offset_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "yof"); - RNA_def_property_ui_text(prop, "Y Offset", "Offset image vertically from the world origin"); + prop = RNA_def_property(srna, "color_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "color_type"); + RNA_def_property_enum_items(prop, rna_enum_shading_color_type_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_View3DShading_color_type_itemf"); + RNA_def_property_ui_text(prop, "Color", "Color Type"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "size"); - RNA_def_property_float_funcs(prop, "rna_BackgroundImage_size_get", "rna_BackgroundImage_size_set", NULL); - RNA_def_property_ui_text(prop, "Size", "Size of the background image (ortho view only)"); - RNA_def_property_range(prop, 0.0, FLT_MAX); + prop = RNA_def_property(srna, "single_color", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "single_color"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Color", "Color for single color mode"); + RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER); - RNA_def_property_float_sdna(prop, NULL, "rotation"); - RNA_def_property_ui_text(prop, "Rotation", "Rotation for the background image (ortho view only)"); + prop = RNA_def_property(srna, "background_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, background_type_items); + RNA_def_property_ui_text(prop, "Background", "Way to draw the background"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "use_flip_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_BGPIC_FLIP_X); - RNA_def_property_ui_text(prop, "Flip Horizontally", "Flip the background image horizontally"); + prop = RNA_def_property(srna, "background_color", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_float_array_default(prop, default_background_color); + RNA_def_property_ui_text(prop, "Background Color", "Color for custom background color"); + RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "use_flip_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_BGPIC_FLIP_Y); - RNA_def_property_ui_text(prop, "Flip Vertically", "Flip the background image vertically"); + prop = RNA_def_property(srna, "show_shadows", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SHADOW); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Shadow", "Show Shadow"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "opacity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "blend"); - RNA_def_property_float_funcs(prop, "rna_BackgroundImage_opacity_get", "rna_BackgroundImage_opacity_set", NULL); - RNA_def_property_ui_text(prop, "Opacity", "Image opacity to blend the image against the background color"); - RNA_def_property_range(prop, 0.0, 1.0); + prop = RNA_def_property(srna, "show_xray", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_XRAY); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show X-Ray", "Show whole scene transparent"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "view_axis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "view"); - RNA_def_property_enum_items(prop, bgpic_axis_items); - RNA_def_property_ui_text(prop, "Image Axis", "The axis to display the image on"); + prop = RNA_def_property(srna, "show_xray_wireframe", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_XRAY_WIREFRAME); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Show X-Ray", "Show whole scene transparent"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_BGPIC_EXPANDED); - RNA_def_property_ui_text(prop, "Show Expanded", "Show the expanded in the user interface"); - RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); + prop = RNA_def_property(srna, "xray_alpha", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "xray_alpha"); + RNA_def_property_float_default(prop, 0.5); + RNA_def_property_ui_text(prop, "X-Ray Alpha", "Amount of alpha to use"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "use_camera_clip", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_BGPIC_CAMERACLIP); - RNA_def_property_ui_text(prop, "Camera Clip", "Use movie clip from active scene camera"); + prop = RNA_def_property(srna, "xray_alpha_wireframe", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "xray_alpha_wire"); + RNA_def_property_float_default(prop, 0.5); + RNA_def_property_ui_text(prop, "X-Ray Alpha", "Amount of alpha to use"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_background_image", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", V3D_BGPIC_DISABLED); - RNA_def_property_ui_text(prop, "Show Background Image", "Show this image as background"); + prop = RNA_def_property(srna, "use_scene_lights", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_LIGHTS); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Scene Lights", "Render lights and light probes of the scene"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_on_foreground", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_BGPIC_FOREGROUND); - RNA_def_property_ui_text(prop, "Show On Foreground", "Show this image in front of objects in viewport"); + prop = RNA_def_property(srna, "use_scene_world", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_WORLD); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Scene World", "Use scene world for lighting"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - /* expose 1 flag as a enum of 2 items */ - prop = RNA_def_property(srna, "draw_depth", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, bgpic_draw_depth_items); - RNA_def_property_ui_text(prop, "Depth", "Draw under or over everything"); + prop = RNA_def_property(srna, "show_specular_highlight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SPECULAR_HIGHLIGHT); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Specular Highlights", "Render specular highlights"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - /* expose 2 flags as a enum of 3 items */ - prop = RNA_def_property(srna, "frame_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, bgpic_camera_frame_items); - RNA_def_property_ui_text(prop, "Frame Method", "How the image fits in the camera frame"); + prop = RNA_def_property(srna, "object_outline_color", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "object_outline_color"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Outline Color", "Color for object outline"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "shadow_intensity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "shadow_intensity"); + RNA_def_property_float_default(prop, 0.5); + RNA_def_property_ui_text(prop, "Shadow Intensity", "Darkness of shadows"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "studiolight_background_alpha", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "studiolight_background"); + RNA_def_property_float_default(prop, 0.0); + RNA_def_property_ui_text(prop, "Background", "Show the studiolight in the background"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); } -static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_space_view3d_overlay(BlenderRNA *brna) { StructRNA *srna; - FunctionRNA *func; - PropertyRNA *parm; + PropertyRNA *prop; - RNA_def_property_srna(cprop, "BackgroundImages"); - srna = RNA_def_struct(brna, "BackgroundImages", NULL); + srna = RNA_def_struct(brna, "View3DOverlay", NULL); RNA_def_struct_sdna(srna, "View3D"); - RNA_def_struct_ui_text(srna, "Background Images", "Collection of background images"); + RNA_def_struct_nested(brna, srna, "SpaceView3D"); + RNA_def_struct_path_func(srna, "rna_View3DOverlay_path"); + RNA_def_struct_ui_text(srna, "3D View Overlay Settings", "Settings for display of overlays in the 3D viewport"); - func = RNA_def_function(srna, "new", "rna_BackgroundImage_new"); - RNA_def_function_ui_description(func, "Add new background image"); - parm = RNA_def_pointer(func, "image", "BackgroundImage", "", "Image displayed as viewport background"); - RNA_def_function_return(func, parm); + prop = RNA_def_property(srna, "show_overlays", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag2", V3D_RENDER_OVERRIDE); + RNA_def_property_ui_text(prop, "Show Overlays", "Display overlays like gizmos and outlines"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update"); - func = RNA_def_function(srna, "remove", "rna_BackgroundImage_remove"); - RNA_def_function_ui_description(func, "Remove background image"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "image", "BackgroundImage", "", "Image displayed as viewport background"); - RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); - RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + prop = RNA_def_property(srna, "show_floor", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_FLOOR); + RNA_def_property_ui_text(prop, "Display Grid Floor", "Show the ground plane grid in perspective view"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - func = RNA_def_function(srna, "clear", "rna_BackgroundImage_clear"); - RNA_def_function_ui_description(func, "Remove all background images"); -} + prop = RNA_def_property(srna, "show_axis_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_X); + RNA_def_property_ui_text(prop, "Display X Axis", "Show the X axis line in perspective view"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_axis_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_Y); + RNA_def_property_ui_text(prop, "Display Y Axis", "Show the Y axis line in perspective view"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_axis_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_Z); + RNA_def_property_ui_text(prop, "Display Z Axis", "Show the Z axis line in perspective view"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "grid_scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "grid"); + RNA_def_property_ui_text(prop, "Grid Scale", "Distance between 3D View grid lines"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.001f, 1000.0f, 0.1f, 3); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "grid_lines", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "gridlines"); + RNA_def_property_ui_text(prop, "Grid Lines", "Number of grid lines to display in perspective view"); + RNA_def_property_range(prop, 0, 1024); + RNA_def_property_int_default(prop, 16); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "grid_subdivisions", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "gridsubdiv"); + RNA_def_property_ui_text(prop, "Grid Subdivisions", "Number of subdivisions between grid lines"); + RNA_def_property_range(prop, 1, 1024); + RNA_def_property_int_default(prop, 10); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "grid_scale_unit", PROP_FLOAT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_float_funcs(prop, "rna_View3DOverlay_GridScaleUnit_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Grid Scale Unit", "Grid cell size scaled by scene unit system settings"); + + prop = RNA_def_property(srna, "show_outline_selected", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SELECT_OUTLINE); + RNA_def_property_ui_text(prop, "Outline Selected", + "Show an outline highlight around selected objects in non-wireframe views"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_object_origins", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_OBJECT_ORIGINS); + RNA_def_property_ui_text(prop, "Object Origins", "Show object center dots"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_object_origins_all", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_DRAW_CENTERS); + RNA_def_property_ui_text(prop, "All Object Origins", + "Show the object origin center dot for all (selected and unselected) objects"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_relationship_lines", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", V3D_HIDE_HELPLINES); + RNA_def_property_ui_text(prop, "Relationship Lines", + "Show dashed lines indicating parent or constraint relationships"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + /* TODO: this should become a per object setting? */ + prop = RNA_def_property(srna, "show_backface_culling", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_BACKFACE_CULLING); + RNA_def_property_ui_text(prop, "Backface Culling", "Use back face culling to hide the back side of faces"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_cursor", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_CURSOR); + RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_text", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_TEXT); + RNA_def_property_ui_text(prop, "Show Text", "Display overlay text"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_extras", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_OBJECT_XTRAS); + RNA_def_property_ui_text(prop, "Extras", "Object details, including empty wire, cameras and other visual guides"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_bones", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_BONES); + RNA_def_property_ui_text(prop, "Show Bones", "Display bones"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_face_orientation", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_FACE_ORIENTATION); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Face Orientation", "Show the Face Orientation Overlay"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_bone_select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_BONE_SELECT); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Bone Selection", "Show the Bone Selection Overlay"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "bone_select_alpha", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.bone_select_alpha"); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_ui_text(prop, "Opacity", "Opacity to use for bone selection"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "show_motion_paths", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_MOTION_PATHS); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Motion Paths", "Show the Motion Paths Overlay"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_onion_skins", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_ONION_SKINS); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Onion Skins", "Show the Onion Skinning Overlay"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_look_dev", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_LOOK_DEV); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Look Dev Preview", "Show look development balls and palette"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_wireframes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_WIREFRAMES); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Wireframe", "Show face edges wires"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "wireframe_threshold", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.wireframe_threshold"); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_ui_text(prop, "Wireframe Threshold", "Adjust the number of wires displayed (1 for all wires)"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_paint_wire", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.paint_flag", V3D_OVERLAY_PAINT_WIRE); + RNA_def_property_ui_text(prop, "Show Wire", "Use wireframe display in painting modes"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_wpaint_contours", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.wpaint_flag", V3D_OVERLAY_WPAINT_CONTOURS); + RNA_def_property_ui_text(prop, "Show Weight Contours", "Show contour lines formed by points with the same interpolated weight"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_weight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_WEIGHT); + RNA_def_property_ui_text(prop, "Show Weights", "Display weights in editmode"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_OCCLUDE_WIRE); + RNA_def_property_ui_text(prop, "Hidden Wire", "Use hidden wireframe display"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_face_normals", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_FACE_NORMALS); + RNA_def_property_ui_text(prop, "Display Normals", "Display face normals as lines"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_vertex_normals", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_VERT_NORMALS); + RNA_def_property_ui_text(prop, "Display Vertex Normals", "Display vertex normals as lines"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_split_normals", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_LOOP_NORMALS); + RNA_def_property_ui_text(prop, "Display Split Normals", "Display vertex-per-face normals as lines"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_edges", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_EDGES); + RNA_def_property_ui_text(prop, "Draw Edges", + "Display selected edges using highlights in the 3D view and UV editor"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_faces", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_FACES); + RNA_def_property_ui_text(prop, "Draw Faces", "Display all faces as shades in the 3D view and UV editor"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_face_center", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_FACE_DOT); + RNA_def_property_ui_text(prop, "Draw Face Center", "Display face center"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_edge_crease", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_CREASES); + RNA_def_property_ui_text(prop, "Draw Creases", "Display creases created for Subdivision Surface modifier"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_edge_bevel_weight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_BWEIGHTS); + RNA_def_property_ui_text(prop, "Draw Bevel Weights", "Display weights created for the Bevel modifier"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_edge_seams", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_SEAMS); + RNA_def_property_ui_text(prop, "Draw Seams", "Display UV unwrapping seams"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_edge_sharp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_SHARP); + RNA_def_property_ui_text(prop, "Draw Sharp", "Display sharp edges, used with the Edge Split modifier"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_freestyle_edge_marks", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_FREESTYLE_EDGE); + RNA_def_property_ui_text(prop, "Draw Freestyle Edge Marks", "Display Freestyle edge marks, used with the Freestyle renderer"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_freestyle_face_marks", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_FREESTYLE_FACE); + RNA_def_property_ui_text(prop, "Draw Freestyle Face Marks", "Display Freestyle face marks, used with the Freestyle renderer"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_statvis", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_STATVIS); + RNA_def_property_ui_text(prop, "Stat Vis", "Display statistical information about the mesh"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_extra_edge_length", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_EDGE_LEN); + RNA_def_property_ui_text(prop, "Edge Length", + "Display selected edge lengths, using global values when set in the transform panel"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_extra_edge_angle", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_EDGE_ANG); + RNA_def_property_ui_text(prop, "Edge Angle", + "Display selected edge angle, using global values when set in the transform panel"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_extra_face_angle", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_FACE_ANG); + RNA_def_property_ui_text(prop, "Face Angles", + "Display the angles in the selected edges, " + "using global values when set in the transform panel"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_extra_face_area", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_FACE_AREA); + RNA_def_property_ui_text(prop, "Face Area", + "Display the area of selected faces, " + "using global values when set in the transform panel"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_extra_indices", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_INDICES); + RNA_def_property_ui_text(prop, "Indices", "Display the index numbers of selected vertices, edges, and faces"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_curve_handles", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_CU_HANDLES); + RNA_def_property_ui_text(prop, "Draw Handles", "Display Bezier handles in editmode"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_curve_normals", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_CU_NORMALS); + RNA_def_property_ui_text(prop, "Draw Normals", "Display 3D curve normals in editmode"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "normals_length", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.normals_length"); + RNA_def_property_ui_text(prop, "Normal Size", "Display size for normals in the 3D view"); + RNA_def_property_range(prop, 0.00001, 1000.0); + RNA_def_property_ui_range(prop, 0.01, 10.0, 10.0, 2); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "backwire_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.backwire_opacity"); + RNA_def_property_ui_text(prop, "Backwire Opacity", "Opacity when rendering transparent wires"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_transparent_bones", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.arm_flag", V3D_OVERLAY_ARM_TRANSP_BONES); + RNA_def_property_ui_text(prop, "Transparent Bones", "Display bones as transparent"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "texture_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.texture_paint_mode_opacity"); + RNA_def_property_float_default(prop, 0.8f); + RNA_def_property_ui_text(prop, "Texture Opacity", "Opacity of the texture paint mode overlay"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "vertex_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.vertex_paint_mode_opacity"); + RNA_def_property_float_default(prop, 0.8f); + RNA_def_property_ui_text(prop, "Vertex Paint Opacity", "Opacity of the vertex paint mode overlay"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "weight_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.weight_paint_mode_opacity"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Weight Paint Opacity", "Opacity of the weight paint mode overlay"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + /* grease pencil paper settings */ + prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_ANNOTATION); + RNA_def_property_ui_text(prop, "Show Annotation", + "Show annotations for this view"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "use_gpencil_paper", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_SHOW_PAPER); + RNA_def_property_ui_text(prop, "Use Paper", + "Cover all viewport with a full color layer to improve visibility while drawing over complex scenes"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "use_gpencil_grid", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_SHOW_GRID); + RNA_def_property_ui_text(prop, "Use Grid", + "Display a grid over grease pencil paper"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "use_gpencil_fade_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_FADE_NOACTIVE_LAYERS); + RNA_def_property_ui_text(prop, "Fade Layers", + "Toggle fading of Grease Pencil layers except the active one"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "gpencil_grid_opacity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_grid_opacity"); + RNA_def_property_range(prop, 0.1f, 1.0f); + RNA_def_property_float_default(prop, 0.9f); + RNA_def_property_ui_text(prop, "Opacity", "Canvas grid opacity"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + /* Paper opacity factor */ + prop = RNA_def_property(srna, "gpencil_paper_opacity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_paper_opacity"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_ui_text(prop, "Opacity", "Paper opacity"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + /* Paper opacity factor */ + prop = RNA_def_property(srna, "gpencil_fade_layer", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_fade_layer"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_ui_text(prop, "Opacity", + "Fade layer opacity for Grease Pencil layers except the active one"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update"); + + /* show edit lines */ + prop = RNA_def_property(srna, "use_gpencil_edit_lines", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_SHOW_EDIT_LINES); + RNA_def_property_ui_text(prop, "Show Edit Lines", "Show edit lines when editing strokes"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "use_gpencil_multiedit_line_only", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_SHOW_MULTIEDIT_LINES); + RNA_def_property_ui_text(prop, "Lines Only", "Only show edit lines for additional frames"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update"); + + /* main grease pencil onion switch */ + prop = RNA_def_property(srna, "use_gpencil_onion_skin", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_SHOW_ONION_SKIN); + RNA_def_property_ui_text(prop, "Onion Skins", "Show ghosts of the keyframes before and after the current frame"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update"); + + /* vertex opacity */ + prop = RNA_def_property(srna, "vertex_opacity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vertex_opacity"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Vertex Opacity", "Opacity for edit vertices"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_GPencil_update"); +} static void rna_def_space_view3d(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem manipulators_items[] = { - {V3D_MANIP_TRANSLATE, "TRANSLATE", ICON_MAN_TRANS, "Translate", - "Use the manipulator for movement transformations"}, - {V3D_MANIP_ROTATE, "ROTATE", ICON_MAN_ROT, "Rotate", - "Use the manipulator for rotation transformations"}, - {V3D_MANIP_SCALE, "SCALE", ICON_MAN_SCALE, "Scale", - "Use the manipulator for scale transformations"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem rv3d_persp_items[] = { {RV3D_PERSP, "PERSP", 0, "Perspective", ""}, {RV3D_ORTHO, "ORTHO", 0, "Orthographic", ""}, @@ -2389,34 +3044,6 @@ static void rna_def_space_view3d(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem view3d_matcap_items[] = { - {ICON_MATCAP_01, "01", ICON_MATCAP_01, "", ""}, - {ICON_MATCAP_02, "02", ICON_MATCAP_02, "", ""}, - {ICON_MATCAP_03, "03", ICON_MATCAP_03, "", ""}, - {ICON_MATCAP_04, "04", ICON_MATCAP_04, "", ""}, - {ICON_MATCAP_05, "05", ICON_MATCAP_05, "", ""}, - {ICON_MATCAP_06, "06", ICON_MATCAP_06, "", ""}, - {ICON_MATCAP_07, "07", ICON_MATCAP_07, "", ""}, - {ICON_MATCAP_08, "08", ICON_MATCAP_08, "", ""}, - {ICON_MATCAP_09, "09", ICON_MATCAP_09, "", ""}, - {ICON_MATCAP_10, "10", ICON_MATCAP_10, "", ""}, - {ICON_MATCAP_11, "11", ICON_MATCAP_11, "", ""}, - {ICON_MATCAP_12, "12", ICON_MATCAP_12, "", ""}, - {ICON_MATCAP_13, "13", ICON_MATCAP_13, "", ""}, - {ICON_MATCAP_14, "14", ICON_MATCAP_14, "", ""}, - {ICON_MATCAP_15, "15", ICON_MATCAP_15, "", ""}, - {ICON_MATCAP_16, "16", ICON_MATCAP_16, "", ""}, - {ICON_MATCAP_17, "17", ICON_MATCAP_17, "", ""}, - {ICON_MATCAP_18, "18", ICON_MATCAP_18, "", ""}, - {ICON_MATCAP_19, "19", ICON_MATCAP_19, "", ""}, - {ICON_MATCAP_20, "20", ICON_MATCAP_20, "", ""}, - {ICON_MATCAP_21, "21", ICON_MATCAP_21, "", ""}, - {ICON_MATCAP_22, "22", ICON_MATCAP_22, "", ""}, - {ICON_MATCAP_23, "23", ICON_MATCAP_23, "", ""}, - {ICON_MATCAP_24, "24", ICON_MATCAP_24, "", ""}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "SpaceView3D", "Space"); RNA_def_struct_sdna(srna, "View3D"); RNA_def_struct_ui_text(srna, "3D View Space", "3D View space data"); @@ -2476,14 +3103,6 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lock to Cursor", "3D View center is locked to the cursor's position"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "viewport_shade", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "drawtype"); - RNA_def_property_enum_items(prop, rna_enum_viewport_shade_items); - RNA_def_property_enum_funcs(prop, "rna_SpaceView3D_viewport_shade_get", "rna_SpaceView3D_viewport_shade_set", - "rna_SpaceView3D_viewport_shade_itemf"); - RNA_def_property_ui_text(prop, "Viewport Shading", "Method to display/shade objects in the 3D View"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update"); - prop = RNA_def_property(srna, "local_view", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "localvd"); RNA_def_property_ui_text(prop, "Local View", @@ -2491,11 +3110,18 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH); RNA_def_property_array(prop, 3); - RNA_def_property_float_funcs(prop, "rna_View3D_CursorLocation_get", "rna_View3D_CursorLocation_set", NULL); + RNA_def_property_float_funcs(prop, "rna_View3D_Cursor_location_get", "rna_View3D_Cursor_location_set", NULL); RNA_def_property_ui_text(prop, "3D Cursor Location", "3D cursor location for this view (dependent on local view setting)"); RNA_def_property_ui_range(prop, -10000.0, 10000.0, 1, RNA_TRANSLATION_PREC_DEFAULT); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_View3D_Cursor_update"); + + prop = RNA_def_property(srna, "cursor_rotation", PROP_FLOAT, PROP_QUATERNION); + RNA_def_property_array(prop, 4); + RNA_def_property_float_funcs(prop, "rna_View3D_Cursor_rotation_get", "rna_View3D_Cursor_rotation_set", NULL); + RNA_def_property_ui_text(prop, "3D Cursor Rotation", + "Rotation in quaternions (keep normalized)"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_View3D_Cursor_update"); prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_UNIT_CAMERA); RNA_def_property_float_sdna(prop, NULL, "lens"); @@ -2519,168 +3145,36 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Clip End", "3D View far clipping distance"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "grid_scale", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "grid"); - RNA_def_property_ui_text(prop, "Grid Scale", "Distance between 3D View grid lines"); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.001f, 1000.0f, 0.1f, 3); - RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "grid_lines", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "gridlines"); - RNA_def_property_ui_text(prop, "Grid Lines", "Number of grid lines to display in perspective view"); - RNA_def_property_range(prop, 0, 1024); - RNA_def_property_int_default(prop, 16); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "grid_subdivisions", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "gridsubdiv"); - RNA_def_property_ui_text(prop, "Grid Subdivisions", "Number of subdivisions between grid lines"); - RNA_def_property_range(prop, 1, 1024); - RNA_def_property_int_default(prop, 10); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "grid_scale_unit", PROP_FLOAT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_float_funcs(prop, "rna_View3D_GridScaleUnit_get", NULL, NULL); - RNA_def_property_ui_text(prop, "Grid Scale Unit", "Grid cell size scaled by scene unit system settings"); - - prop = RNA_def_property(srna, "show_floor", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_FLOOR); - RNA_def_property_ui_text(prop, "Display Grid Floor", "Show the ground plane grid in perspective view"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_axis_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_X); - RNA_def_property_ui_text(prop, "Display X Axis", "Show the X axis line in perspective view"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_axis_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_Y); - RNA_def_property_ui_text(prop, "Display Y Axis", "Show the Y axis line in perspective view"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_axis_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_Z); - RNA_def_property_ui_text(prop, "Display Z Axis", "Show the Z axis line in perspective view"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_outline_selected", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SELECT_OUTLINE); - RNA_def_property_ui_text(prop, "Outline Selected", - "Show an outline highlight around selected objects in non-wireframe views"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_all_objects_origin", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_DRAW_CENTERS); - RNA_def_property_ui_text(prop, "All Object Origins", - "Show the object origin center dot for all (selected and unselected) objects"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_relationship_lines", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", V3D_HIDE_HELPLINES); - RNA_def_property_ui_text(prop, "Relationship Lines", - "Show dashed lines indicating parent or constraint relationships"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_grease_pencil", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_GPENCIL); - RNA_def_property_ui_text(prop, "Show Grease Pencil", - "Show grease pencil for this view"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_textured_solid", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SOLID_TEX); RNA_def_property_ui_text(prop, "Textured Solid", "Display face-assigned textures in solid view"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_backface_culling", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_BACKFACE_CULLING); - RNA_def_property_ui_text(prop, "Backface Culling", "Use back face culling to hide the back side of faces"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_textured_shadeless", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHADELESS_TEX); - RNA_def_property_ui_text(prop, "Shadeless", "Show shadeless texture without lighting in textured draw mode"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_OCCLUDE_WIRE); - RNA_def_property_ui_text(prop, "Hidden Wire", "Use hidden wireframe display"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "lock_camera", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_LOCK_CAMERA); RNA_def_property_ui_text(prop, "Lock Camera to View", "Enable view navigation within the camera view"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "show_only_render", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_RENDER_OVERRIDE); - RNA_def_property_ui_text(prop, "Only Render", "Display only objects which will be rendered"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "show_world", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_WORLD); - RNA_def_property_ui_text(prop, "World Background", "Display world colors in the background"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "use_occlude_geometry", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_ZBUF_SELECT); - RNA_def_property_ui_text(prop, "Occlude Geometry", "Limit selection to visible (clipped with depth buffer)"); - RNA_def_property_ui_icon(prop, ICON_ORTHO, 0); + prop = RNA_def_property(srna, "show_gizmo", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE); + RNA_def_property_ui_text(prop, "Show Gizmo", "Show gizmos of all types"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "background_images", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "bgpicbase", NULL); - RNA_def_property_struct_type(prop, "BackgroundImage"); - RNA_def_property_ui_text(prop, "Background Images", "List of background images"); + prop = RNA_def_property(srna, "show_gizmo_navigate", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE_NAVIGATE); + RNA_def_property_ui_text(prop, "Navigate Gizmo", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - rna_def_backgroundImages(brna, prop); - prop = RNA_def_property(srna, "show_background_images", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_DISPBGPICS); - RNA_def_property_ui_text(prop, "Display Background Images", - "Display reference images behind objects in the 3D View"); + prop = RNA_def_property(srna, "show_gizmo_context", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE_CONTEXT); + RNA_def_property_ui_text(prop, "Context Gizmo", "Context sensitive gizmos for the active item"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "pivot_point", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "around"); - RNA_def_property_enum_items(prop, pivot_items_full); - RNA_def_property_ui_text(prop, "Pivot Point", "Pivot center for rotation/scaling"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_pivot_update"); - - prop = RNA_def_property(srna, "use_pivot_point_align", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_ALIGN); - RNA_def_property_ui_text(prop, "Align", "Manipulate center points (object, pose and weight paint mode only)"); - RNA_def_property_ui_icon(prop, ICON_ALIGN, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_pivot_update"); - - prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "twflag", V3D_USE_MANIPULATOR); - RNA_def_property_ui_text(prop, "Manipulator", "Use a 3D manipulator widget for controlling transforms"); - RNA_def_property_ui_icon(prop, ICON_MANIPUL, 0); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "transform_manipulators", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "twtype"); - RNA_def_property_enum_items(prop, manipulators_items); - RNA_def_property_flag(prop, PROP_ENUM_FLAG); - RNA_def_property_ui_text(prop, "Transform Manipulators", "Transformation manipulators"); + prop = RNA_def_property(srna, "show_gizmo_tool", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", V3D_GIZMO_HIDE_TOOL); + RNA_def_property_ui_text(prop, "Tool Gizmo", "Active tool gizmo"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "twmode"); - RNA_def_property_enum_items(prop, transform_orientation_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_TransformOrientation_itemf"); - RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "current_orientation", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "TransformOrientation"); - RNA_def_property_pointer_funcs(prop, "rna_CurrentOrientation_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current transformation orientation"); - prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scenelock", 1); RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_lock_camera_and_layers_set"); @@ -2689,30 +3183,6 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_LOCKVIEW_OFF, 1); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - 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_boolean_funcs(prop, NULL, "rna_SpaceView3D_layer_set"); - RNA_def_property_ui_text(prop, "Visible Layers", "Layers visible in this 3D View"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_layer_update"); - - prop = RNA_def_property(srna, "active_layer", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_int_funcs(prop, "rna_SpaceView3D_active_layer_get", NULL, NULL); - RNA_def_property_ui_text(prop, "Active Layer", "Active 3D view layer index"); - - 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", "Local view layers visible in this 3D View"); - - prop = RNA_def_property(srna, "layers_used", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, NULL, "lay_used", 1); - RNA_def_property_array(prop, 20); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Used Layers", "Layers that contain something"); - prop = RNA_def_property(srna, "region_3d", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "RegionView3D"); RNA_def_property_pointer_funcs(prop, "rna_SpaceView3D_region_3d_get", NULL, NULL, NULL); @@ -2731,14 +3201,14 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Reconstruction", "Display reconstruction data from active movie clip"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "tracks_draw_size", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "tracks_display_size", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 5, 1, 3); RNA_def_property_float_sdna(prop, NULL, "bundle_size"); RNA_def_property_ui_text(prop, "Tracks Size", "Display size of tracks from reconstructed data"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "tracks_draw_type", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "tracks_display_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "bundle_drawtype"); RNA_def_property_enum_items(prop, bundle_drawtype_items); RNA_def_property_ui_text(prop, "Tracks Display Type", "Viewport display style for tracks"); @@ -2754,17 +3224,6 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show 3D Marker Names", "Show names for reconstructed tracks objects"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "use_matcap", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SOLID_MATCAP); - RNA_def_property_ui_text(prop, "Matcap", "Active Objects draw images mapped on normals, enhancing Solid Draw Mode"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_matcap_enable"); - - prop = RNA_def_property(srna, "matcap_icon", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "matcap_icon"); - RNA_def_property_enum_items(prop, view3d_matcap_items); - RNA_def_property_ui_text(prop, "Matcap", "Image to use for Material Capture, active objects only"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_matcap_update"); - prop = RNA_def_property(srna, "fx_settings", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "FX Options", "Options used for real time compositing"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); @@ -2809,6 +3268,77 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Volume Alpha", "Opacity (alpha) of the cameras' frustum volume"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + { + struct { + const char *name; + int type_mask; + const char *identifier[2]; + } info[] = { + {"Mesh", (1 << OB_MESH), + {"show_object_viewport_mesh", "show_object_select_mesh"}}, + {"Curve", (1 << OB_CURVE), + {"show_object_viewport_curve", "show_object_select_curve"}}, + {"Surface", (1 << OB_SURF), + {"show_object_viewport_surf", "show_object_select_surf"}}, + {"Meta", (1 << OB_MBALL), + {"show_object_viewport_meta", "show_object_select_meta"}}, + {"Font", (1 << OB_FONT), + {"show_object_viewport_font", "show_object_select_font"}}, + {"Armature", (1 << OB_ARMATURE), + {"show_object_viewport_armature", "show_object_select_armature"}}, + {"Lattice", (1 << OB_LATTICE), + {"show_object_viewport_lattice", "show_object_select_lattice"}}, + {"Empty", (1 << OB_EMPTY), + {"show_object_viewport_empty", "show_object_select_empty"}}, + {"Grease Pencil", (1 << OB_GPENCIL), + {"show_object_viewport_grease_pencil", "show_object_select_grease_pencil"}}, + {"Camera", (1 << OB_CAMERA), + {"show_object_viewport_camera", "show_object_select_camera"}}, + {"Light", (1 << OB_LAMP), + {"show_object_viewport_light", "show_object_select_light"}}, + {"Speaker", (1 << OB_SPEAKER), + {"show_object_viewport_speaker", "show_object_select_speaker"}}, + {"Light Probe", (1 << OB_LIGHTPROBE), + {"show_object_viewport_light_probe", "show_object_select_light_probe"}}, + }; + + const char *view_mask_member[2] = { + "object_type_exclude_viewport", + "object_type_exclude_select", + }; + for (int mask_index = 0; mask_index < 2; mask_index++) { + for (int type_index = 0; type_index < ARRAY_SIZE(info); type_index++) { + prop = RNA_def_property(srna, info[type_index].identifier[mask_index], PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna( + prop, NULL, view_mask_member[mask_index], info[type_index].type_mask); + RNA_def_property_ui_text(prop, info[type_index].name, ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + + } + } + + /* Heper for drawing the icon. */ + prop = RNA_def_property(srna, "icon_from_show_object_viewport", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_SpaceView3D_icon_from_show_object_viewport_get", NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Visibility Iconm", ""); + } + + /* Nested Structs */ + prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "View3DShading"); + RNA_def_property_ui_text(prop, "Shading Settings", "Settings for shading in the 3D viewport"); + + prop = RNA_def_property(srna, "overlay", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "View3DOverlay"); + RNA_def_property_pointer_funcs(prop, "rna_SpaceView3D_overlay_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Overlay Settings", "Settings for display of overlays in the 3D viewport"); + + rna_def_space_view3d_shading(brna); + rna_def_space_view3d_overlay(brna); + /* *** Animated *** */ RNA_define_animate_sdna(true); /* region */ @@ -2922,12 +3452,6 @@ static void rna_def_space_buttons(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem align_items[] = { - {BUT_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""}, - {BUT_VERTICAL, "VERTICAL", 0, "Vertical", ""}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "SpaceProperties", "Space"); RNA_def_struct_sdna(srna, "SpaceButs"); RNA_def_struct_ui_text(srna, "Properties Space", "Properties space data"); @@ -2936,28 +3460,9 @@ static void rna_def_space_buttons(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "mainb"); RNA_def_property_enum_items(prop, buttons_context_items); RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_context_set", "rna_SpaceProperties_context_itemf"); - RNA_def_property_ui_text(prop, "Context", "Type of active data to display and edit"); + RNA_def_property_ui_text(prop, "Context", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, "rna_SpaceProperties_context_update"); - prop = RNA_def_property(srna, "align", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "align"); - RNA_def_property_enum_items(prop, align_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_align_set", NULL); - RNA_def_property_ui_text(prop, "Align", "Arrangement of the panels"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, NULL); - - prop = RNA_def_property(srna, "texture_context", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, buttons_texture_context_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_texture_context_set", - "rna_SpaceProperties_texture_context_itemf"); - RNA_def_property_ui_text(prop, "Texture Context", "Type of texture data to display and edit"); - RNA_def_property_update(prop, NC_TEXTURE, NULL); - - prop = RNA_def_property(srna, "use_limited_texture_context", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SB_TEX_USER_LIMITED); - RNA_def_property_ui_text(prop, "Limited Texture Context", - "Use the limited version of texture user (for 'old shading' mode)"); - /* pinned data */ prop = RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "pinid"); @@ -2975,13 +3480,6 @@ static void rna_def_space_buttons(BlenderRNA *brna) static void rna_def_space_image(BlenderRNA *brna) { - static const EnumPropertyItem image_space_mode_items[] = { - {SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image and UV edit in mesh editmode"}, - {SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"}, - {SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"}, - {0, NULL, 0, NULL, NULL} - }; - StructRNA *srna; PropertyRNA *prop; @@ -3030,20 +3528,20 @@ static void rna_def_space_image(BlenderRNA *brna) /* image draw */ prop = RNA_def_property(srna, "show_repeat", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_TILE); - RNA_def_property_ui_text(prop, "Draw Repeated", "Draw the image repeated outside of the main view"); + RNA_def_property_ui_text(prop, "Display Repeated", "Display the image repeated outside of the main view"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - prop = RNA_def_property(srna, "show_grease_pencil", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SHOW_GPENCIL); - RNA_def_property_ui_text(prop, "Show Grease Pencil", - "Show grease pencil for this view"); + RNA_def_property_ui_text(prop, "Show Annotation", + "Show annotations for this view"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - prop = RNA_def_property(srna, "draw_channels", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "display_channels", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, draw_channels_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_SpaceImageEditor_draw_channels_itemf"); - RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw"); + RNA_def_property_enum_items(prop, display_channels_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_SpaceImageEditor_display_channels_itemf"); + RNA_def_property_ui_text(prop, "Display Channels", "Channels of the image to draw"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "show_stereo_3d", PROP_BOOLEAN, PROP_NONE); @@ -3062,7 +3560,7 @@ static void rna_def_space_image(BlenderRNA *brna) /* mode */ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, image_space_mode_items); + RNA_def_property_enum_items(prop, rna_enum_space_image_mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_mode_update"); @@ -3076,7 +3574,7 @@ static void rna_def_space_image(BlenderRNA *brna) prop = RNA_def_property(srna, "pivot_point", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "around"); - RNA_def_property_enum_items(prop, pivot_items_full); + RNA_def_property_enum_items(prop, rna_enum_transform_pivot_items_full); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_SpaceImageEditor_pivot_itemf"); RNA_def_property_ui_text(prop, "Pivot", "Rotation/Scaling Pivot"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); @@ -3085,6 +3583,7 @@ static void rna_def_space_image(BlenderRNA *brna) 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_annotations_poll"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); @@ -3130,8 +3629,8 @@ static void rna_def_space_sequencer(BlenderRNA *brna) static const EnumPropertyItem view_type_items[] = { {SEQ_VIEW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""}, - {SEQ_VIEW_PREVIEW, "PREVIEW", ICON_SEQ_PREVIEW, "Image Preview", ""}, - {SEQ_VIEW_SEQUENCE_PREVIEW, "SEQUENCER_PREVIEW", ICON_SEQ_SPLITVIEW, "Sequencer and Image Preview", ""}, + {SEQ_VIEW_PREVIEW, "PREVIEW", ICON_SEQ_PREVIEW, "Preview", ""}, + {SEQ_VIEW_SEQUENCE_PREVIEW, "SEQUENCER_PREVIEW", ICON_SEQ_SPLITVIEW, "Sequencer/Preview", ""}, {0, NULL, 0, NULL, NULL} }; @@ -3163,12 +3662,12 @@ static void rna_def_space_sequencer(BlenderRNA *brna) static const EnumPropertyItem preview_channels_items[] = { {SEQ_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha", - "Draw image with RGB colors and alpha transparency"}, - {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors"}, + "Display image with RGB colors and alpha transparency"}, + {0, "COLOR", ICON_IMAGE_RGB, "Color", "Display image with RGB colors"}, {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem waveform_type_draw_items[] = { + static const EnumPropertyItem waveform_type_display_items[] = { {SEQ_NO_WAVEFORMS, "NO_WAVEFORMS", 0, "Waveforms Off", "No waveforms drawn for any sound strips"}, {SEQ_ALL_WAVEFORMS, "ALL_WAVEFORMS", 0, "Waveforms On", @@ -3205,7 +3704,7 @@ static void rna_def_space_sequencer(BlenderRNA *brna) prop = RNA_def_property(srna, "show_frames", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_DRAWFRAMES); - RNA_def_property_ui_text(prop, "Draw Frames", "Draw frames rather than seconds"); + RNA_def_property_ui_text(prop, "Display Frames", "Display frames rather than seconds"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); prop = RNA_def_property(srna, "use_marker_sync", PROP_BOOLEAN, PROP_NONE); @@ -3238,10 +3737,10 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); - prop = RNA_def_property(srna, "show_grease_pencil", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_SHOW_GPENCIL); - RNA_def_property_ui_text(prop, "Show Grease Pencil", - "Show grease pencil for this view"); + RNA_def_property_ui_text(prop, "Show Annotation", + "Show annotations for this view"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); prop = RNA_def_property(srna, "display_channel", PROP_INT, PROP_NONE); @@ -3254,16 +3753,16 @@ static void rna_def_space_sequencer(BlenderRNA *brna) prop = RNA_def_property(srna, "preview_channels", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, preview_channels_items); - RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the preview to draw"); + RNA_def_property_ui_text(prop, "Display Channels", "Channels of the preview to draw"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); - prop = RNA_def_property(srna, "waveform_draw_type", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "waveform_display_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, waveform_type_draw_items); - RNA_def_property_ui_text(prop, "Waveform Drawing", "How Waveforms are drawn"); + RNA_def_property_enum_items(prop, waveform_type_display_items); + RNA_def_property_ui_text(prop, "Waveform Displaying", "How Waveforms are drawn"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); - prop = RNA_def_property(srna, "draw_overexposed", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "show_overexposed", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "zebra"); RNA_def_property_ui_text(prop, "Show Overexposed", "Show overexposed areas with zebra stripes"); RNA_def_property_range(prop, 0, 110); @@ -3272,16 +3771,17 @@ static void rna_def_space_sequencer(BlenderRNA *brna) prop = RNA_def_property(srna, "proxy_render_size", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "render_size"); RNA_def_property_enum_items(prop, proxy_render_size_items); - RNA_def_property_ui_text(prop, "Proxy render size", - "Draw preview using full resolution or different proxy resolutions"); + RNA_def_property_ui_text(prop, "Proxy Render Size", + "Display preview using full resolution or different proxy resolutions"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); /* grease pencil */ 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_annotations_poll"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); - RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space"); + RNA_def_property_ui_text(prop, "Grease Pencil", "Grease Pencil data for this Preview region"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); prop = RNA_def_property(srna, "overlay_type", PROP_ENUM, PROP_NONE); @@ -3322,19 +3822,19 @@ static void rna_def_space_text(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "wordwrap", 0); RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceTextEditor_word_wrap_set"); RNA_def_property_ui_text(prop, "Word Wrap", "Wrap words if there is not enough horizontal space"); - RNA_def_property_ui_icon(prop, ICON_WORDWRAP_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_WORDWRAP_ON, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TEXT, NULL); prop = RNA_def_property(srna, "show_line_numbers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "showlinenrs", 0); RNA_def_property_ui_text(prop, "Line Numbers", "Show line numbers next to the text"); - RNA_def_property_ui_icon(prop, ICON_LINENUMBERS_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_LINENUMBERS_ON, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TEXT, NULL); prop = RNA_def_property(srna, "show_syntax_highlight", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "showsyntax", 0); RNA_def_property_ui_text(prop, "Syntax Highlight", "Syntax highlight for scripting"); - RNA_def_property_ui_icon(prop, ICON_SYNTAX_OFF, 1); + RNA_def_property_ui_icon(prop, ICON_SYNTAX_ON, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TEXT, NULL); prop = RNA_def_property(srna, "show_line_highlight", PROP_BOOLEAN, PROP_NONE); @@ -3421,18 +3921,6 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - /* XXX: action-editor is currently for object-level only actions, so show that using object-icon hint */ - static const EnumPropertyItem mode_items[] = { - {SACTCONT_DOPESHEET, "DOPESHEET", ICON_OOPS, "Dope Sheet", "Edit all keyframes in scene"}, - {SACTCONT_ACTION, "ACTION", ICON_OBJECT_DATA, "Action Editor", "Edit keyframes in active object's Object-level action"}, - {SACTCONT_SHAPEKEY, "SHAPEKEY", ICON_SHAPEKEY_DATA, "Shape Key Editor", "Edit keyframes in active object's Shape Keys action"}, - {SACTCONT_GPENCIL, "GPENCIL", ICON_GREASEPENCIL, "Grease Pencil", "Edit timings for all Grease Pencil sketches in file"}, - {SACTCONT_MASK, "MASK", ICON_MOD_MASK, "Mask", "Edit timings for Mask Editor splines"}, - {SACTCONT_CACHEFILE, "CACHEFILE", ICON_FILE, "Cache File", "Edit timings for Cache File data-blocks"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "SpaceDopeSheetEditor", "Space"); RNA_def_struct_sdna(srna, "SpaceAction"); RNA_def_struct_ui_text(srna, "Space Dope Sheet Editor", "Dope Sheet space data"); @@ -3443,13 +3931,22 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceDopeSheetEditor_action_set", NULL, "rna_Action_actedit_assign_poll"); RNA_def_property_ui_text(prop, "Action", "Action displayed and edited in this space"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_SpaceDopeSheetEditor_action_update"); - /* mode */ + /* mode (hidden in the UI, see 'ui_mode') */ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_enum_items(prop, rna_enum_space_action_mode_all_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, "rna_SpaceDopeSheetEditor_mode_update"); + + prop = RNA_def_property(srna, "ui_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, rna_enum_space_action_ui_mode_items); + RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, "rna_SpaceDopeSheetEditor_mode_update"); /* display */ @@ -3479,10 +3976,22 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NODRAWGCOLORS); RNA_def_property_ui_text(prop, "Show Group Colors", - "Draw groups and channels with colors matching their corresponding groups " + "Display groups and channels with colors matching their corresponding groups " "(pose bones only currently)"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL); + prop = RNA_def_property(srna, "show_interpolation", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SACTION_SHOW_INTERPOLATION); + RNA_def_property_ui_text(prop, "Show Handles And Interpolation", + "Display keyframe handle types and non-bezier interpolation modes"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL); + + prop = RNA_def_property(srna, "show_extremes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SACTION_SHOW_EXTREMES); + RNA_def_property_ui_text(prop, "Show Curve Extremes", + "Mark keyframes where the key value flow changes direction, based on comparison with adjacent keys"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL); + /* editing */ prop = RNA_def_property(srna, "use_auto_merge_keyframes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NOTRANSKEYCULL); @@ -3511,6 +4020,42 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) RNA_def_property_enum_items(prop, autosnap_items); RNA_def_property_ui_text(prop, "Auto Snap", "Automatic time snapping settings for transformations"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL); + + /* displaying cache status */ + prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DISPLAY); + RNA_def_property_ui_text(prop, "Show Cache", "Show the status of cached frames in the timeline"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); + + prop = RNA_def_property(srna, "cache_softbody", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SOFTBODY); + RNA_def_property_ui_text(prop, "Softbody", "Show the active object's softbody point cache"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); + + prop = RNA_def_property(srna, "cache_particles", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_PARTICLES); + RNA_def_property_ui_text(prop, "Particles", "Show the active object's particle point cache"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); + + prop = RNA_def_property(srna, "cache_cloth", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_CLOTH); + RNA_def_property_ui_text(prop, "Cloth", "Show the active object's cloth point cache"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); + + prop = RNA_def_property(srna, "cache_smoke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SMOKE); + RNA_def_property_ui_text(prop, "Smoke", "Show the active object's smoke cache"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); + + prop = RNA_def_property(srna, "cache_dynamicpaint", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DYNAMICPAINT); + RNA_def_property_ui_text(prop, "Dynamic Paint", "Show the active object's Dynamic Paint cache"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); + + prop = RNA_def_property(srna, "cache_rigidbody", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_RIGIDBODY); + RNA_def_property_ui_text(prop, "Rigid Body", "Show the active object's Rigid Body cache"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); } static void rna_def_space_graph(BlenderRNA *brna) @@ -3518,18 +4063,11 @@ static void rna_def_space_graph(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem mode_items[] = { - {SIPO_MODE_ANIMATION, "FCURVES", ICON_IPO, "F-Curve", - "Edit animation/keyframes displayed as 2D curves"}, - {SIPO_MODE_DRIVERS, "DRIVERS", ICON_DRIVER, "Drivers", "Edit drivers"}, - {0, NULL, 0, NULL, NULL} - }; - /* this is basically the same as the one for the 3D-View, but with some entries omitted */ static const EnumPropertyItem gpivot_items[] = { - {V3D_AROUND_CENTER_BOUNDS, "BOUNDING_BOX_CENTER", ICON_ROTATE, "Bounding Box Center", ""}, - {V3D_AROUND_CURSOR, "CURSOR", ICON_CURSOR, "2D Cursor", ""}, - {V3D_AROUND_LOCAL_ORIGINS, "INDIVIDUAL_ORIGINS", ICON_ROTATECOLLECTION, "Individual Centers", ""}, + {V3D_AROUND_CENTER_BOUNDS, "BOUNDING_BOX_CENTER", ICON_PIVOT_BOUNDBOX, "Bounding Box Center", ""}, + {V3D_AROUND_CURSOR, "CURSOR", ICON_PIVOT_CURSOR, "2D Cursor", ""}, + {V3D_AROUND_LOCAL_ORIGINS, "INDIVIDUAL_ORIGINS", ICON_PIVOT_INDIVIDUAL, "Individual Centers", ""}, /*{V3D_AROUND_CENTER_MEAN, "MEDIAN_POINT", 0, "Median Point", ""}, */ /*{V3D_AROUND_ACTIVE, "ACTIVE_ELEMENT", 0, "Active Element", ""}, */ {0, NULL, 0, NULL, NULL} @@ -3543,8 +4081,9 @@ static void rna_def_space_graph(BlenderRNA *brna) /* mode */ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_enum_items(prop, rna_enum_space_graph_mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, "rna_SpaceGraphEditor_display_mode_update"); /* display */ @@ -3583,15 +4122,15 @@ static void rna_def_space_graph(BlenderRNA *brna) prop = RNA_def_property(srna, "use_beauty_drawing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_BEAUTYDRAW_OFF); - RNA_def_property_ui_text(prop, "Use High Quality Drawing", - "Draw F-Curves using Anti-Aliasing and other fancy effects " + RNA_def_property_ui_text(prop, "Use High Quality Display", + "Display F-Curves using Anti-Aliasing and other fancy effects " "(disable for better performance)"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NODRAWGCOLORS); RNA_def_property_ui_text(prop, "Show Group Colors", - "Draw groups and channels with colors matching their corresponding groups"); + "Display groups and channels with colors matching their corresponding groups"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); /* editing */ @@ -3714,63 +4253,6 @@ static void rna_def_space_nla(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NLA, NULL); } -static void rna_def_space_time(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "SpaceTimeline", "Space"); - RNA_def_struct_sdna(srna, "SpaceTime"); - RNA_def_struct_ui_text(srna, "Space Timeline Editor", "Timeline editor space data"); - - /* view settings */ - prop = RNA_def_property(srna, "show_frame_indicator", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_CFRA_NUM); - RNA_def_property_ui_text(prop, "Show Frame Number Indicator", - "Show frame number beside the current frame indicator line"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); - - prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TIME_DRAWFRAMES); - RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); - - /* displaying cache status */ - prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DISPLAY); - RNA_def_property_ui_text(prop, "Show Cache", "Show the status of cached frames in the timeline"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); - - prop = RNA_def_property(srna, "cache_softbody", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SOFTBODY); - RNA_def_property_ui_text(prop, "Softbody", "Show the active object's softbody point cache"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); - - prop = RNA_def_property(srna, "cache_particles", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_PARTICLES); - RNA_def_property_ui_text(prop, "Particles", "Show the active object's particle point cache"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); - - prop = RNA_def_property(srna, "cache_cloth", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_CLOTH); - RNA_def_property_ui_text(prop, "Cloth", "Show the active object's cloth point cache"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); - - prop = RNA_def_property(srna, "cache_smoke", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SMOKE); - RNA_def_property_ui_text(prop, "Smoke", "Show the active object's smoke cache"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); - - prop = RNA_def_property(srna, "cache_dynamicpaint", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DYNAMICPAINT); - RNA_def_property_ui_text(prop, "Dynamic Paint", "Show the active object's Dynamic Paint cache"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); - - prop = RNA_def_property(srna, "cache_rigidbody", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_RIGIDBODY); - RNA_def_property_ui_text(prop, "Rigid Body", "Show the active object's Rigid Body cache"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL); -} static void rna_def_console_line(BlenderRNA *brna) { @@ -3878,7 +4360,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) {FILTER_ID_GD, "GREASE_PENCIL", ICON_GREASEPENCIL, "Grease Pencil", "Show/hide Grease pencil data-blocks"}, {FILTER_ID_GR, "GROUP", ICON_GROUP, "Groups", "Show/hide Group data-blocks"}, {FILTER_ID_IM, "IMAGE", ICON_IMAGE_DATA, "Images", "Show/hide Image data-blocks"}, - {FILTER_ID_LA, "LAMP", ICON_LAMP_DATA, "Lamps", "Show/hide Lamp data-blocks"}, + {FILTER_ID_LA, "LIGHT", ICON_LIGHT_DATA, "Lights", "Show/hide Light data-blocks"}, {FILTER_ID_LS, "LINESTYLE", ICON_LINE_DATA, "Freestyle Linestyles", "Show/hide Freestyle's Line Style data-blocks"}, {FILTER_ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattices", "Show/hide Lattice data-blocks"}, @@ -3893,6 +4375,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) "Particles Settings", "Show/hide Particle Settings data-blocks"}, {FILTER_ID_PAL, "PALETTE", ICON_COLOR, "Palettes", "Show/hide Palette data-blocks"}, {FILTER_ID_PC, "PAINT_CURVE", ICON_CURVE_BEZCURVE, "Paint Curves", "Show/hide Paint Curve data-blocks"}, + {FILTER_ID_LP, "LIGHT_PROBE", ICON_LIGHTPROBE_CUBEMAP, "Light Probes", "Show/hide Light Probe data-blocks"}, {FILTER_ID_SCE, "SCENE", ICON_SCENE_DATA, "Scenes", "Show/hide Scene data-blocks"}, {FILTER_ID_SPK, "SPEAKER", ICON_SPEAKER, "Speakers", "Show/hide Speaker data-blocks"}, {FILTER_ID_SO, "SOUND", ICON_SOUND, "Sounds", "Show/hide Sound data-blocks"}, @@ -3900,6 +4383,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) {FILTER_ID_TXT, "TEXT", ICON_TEXT, "Texts", "Show/hide Text data-blocks"}, {FILTER_ID_VF, "FONT", ICON_FONT_DATA, "Fonts", "Show/hide Font data-blocks"}, {FILTER_ID_WO, "WORLD", ICON_WORLD_DATA, "Worlds", "Show/hide World data-blocks"}, + {FILTER_ID_WS, "WORK_SPACE", ICON_NONE, "Workspaces", "Show/hide workspace data-blocks"}, {0, NULL, 0, NULL, NULL} }; @@ -3917,8 +4401,8 @@ static void rna_def_fileselect_params(BlenderRNA *brna) "Show/hide materials, nodetrees, textures and Freestyle's linestyles"}, {FILTER_ID_IM | FILTER_ID_MC | FILTER_ID_MSK | FILTER_ID_SO, "IMAGE", ICON_IMAGE_DATA, "Images & Sounds", "Show/hide images, movie clips, sounds and masks"}, - {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_SPK | FILTER_ID_WO, - "ENVIRONMENT", ICON_WORLD_DATA, "Environment", "Show/hide worlds, lamps, cameras and speakers"}, + {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_SPK | FILTER_ID_WO | FILTER_ID_WS, + "ENVIRONMENT", ICON_WORLD_DATA, "Environment", "Show/hide worlds, lights, cameras and speakers"}, {FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_CF, "MISC", ICON_GREASEPENCIL, "Miscellaneous", "Show/hide other data types"}, {0, NULL, 0, NULL, NULL} @@ -4081,14 +4565,12 @@ static void rna_def_filemenu_entry(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "File Select Parameters", "File Select Parameters"); prop = RNA_def_property(srna, "path", PROP_STRING, PROP_FILEPATH); - RNA_def_property_string_sdna(prop, NULL, "path"); RNA_def_property_string_funcs(prop, "rna_FileBrowser_FSMenuEntry_path_get", "rna_FileBrowser_FSMenuEntry_path_length", "rna_FileBrowser_FSMenuEntry_path_set"); RNA_def_property_ui_text(prop, "Path", ""); prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_string_funcs(prop, "rna_FileBrowser_FSMenuEntry_name_get", "rna_FileBrowser_FSMenuEntry_name_length", "rna_FileBrowser_FSMenuEntry_name_set"); @@ -4097,12 +4579,12 @@ static void rna_def_filemenu_entry(BlenderRNA *brna) RNA_def_struct_name_property(srna, prop); prop = RNA_def_property(srna, "use_save", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "save", 1); + RNA_def_property_boolean_funcs(prop, "rna_FileBrowser_FSMenuEntry_use_save_get", NULL); RNA_def_property_ui_text(prop, "Save", "Whether this path is saved in bookmarks, or generated from OS"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "valid", 1); + RNA_def_property_boolean_funcs(prop, "rna_FileBrowser_FSMenuEntry_is_valid_get", NULL); RNA_def_property_ui_text(prop, "Valid", "Whether this path is currently reachable"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); } @@ -4315,7 +4797,6 @@ static void rna_def_space_node(BlenderRNA *brna) PropertyRNA *prop; static const EnumPropertyItem texture_id_type_items[] = { - {SNODE_TEX_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit texture nodes from Object"}, {SNODE_TEX_WORLD, "WORLD", ICON_WORLD_DATA, "World", "Edit texture nodes from World"}, {SNODE_TEX_BRUSH, "BRUSH", ICON_BRUSH_DATA, "Brush", "Edit texture nodes from Brush"}, #ifdef WITH_FREESTYLE @@ -4335,9 +4816,9 @@ static void rna_def_space_node(BlenderRNA *brna) static const EnumPropertyItem backdrop_channels_items[] = { {SNODE_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha", - "Draw image with RGB colors and alpha transparency"}, - {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors"}, - {SNODE_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel"}, + "Display image with RGB colors and alpha transparency"}, + {0, "COLOR", ICON_IMAGE_RGB, "Color", "Display image with RGB colors"}, + {SNODE_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Display alpha transparency channel"}, {SNODE_SHOW_R, "RED", ICON_COLOR_RED, "Red", ""}, {SNODE_SHOW_G, "GREEN", ICON_COLOR_GREEN, "Green", ""}, {SNODE_SHOW_B, "BLUE", ICON_COLOR_BLUE, "Blue", ""}, @@ -4416,10 +4897,10 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Backdrop", "Use active Viewer Node output as backdrop for compositing nodes"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, "rna_SpaceNodeEditor_show_backdrop_update"); - prop = RNA_def_property(srna, "show_grease_pencil", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_SHOW_GPENCIL); - RNA_def_property_ui_text(prop, "Show Grease Pencil", - "Show grease pencil for this view"); + RNA_def_property_ui_text(prop, "Show Annotation", + "Show annotations for this view"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); prop = RNA_def_property(srna, "use_auto_render", PROP_BOOLEAN, PROP_NONE); @@ -4435,20 +4916,16 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Backdrop Zoom", "Backdrop zoom factor"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); - prop = RNA_def_property(srna, "backdrop_x", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "backdrop_offset", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xof"); - RNA_def_property_ui_text(prop, "Backdrop X", "Backdrop X offset"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); - - prop = RNA_def_property(srna, "backdrop_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "yof"); - RNA_def_property_ui_text(prop, "Backdrop Y", "Backdrop Y offset"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Backdrop Offset", "Backdrop offset"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); prop = RNA_def_property(srna, "backdrop_channels", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, backdrop_channels_items); - RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw"); + RNA_def_property_ui_text(prop, "Display Channels", "Channels of the image to draw"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); /* the mx/my "cursor" in the node editor is used only by operators to store the mouse position */ @@ -4475,75 +4952,6 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_api_space_node(srna); } -static void rna_def_space_logic(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "SpaceLogicEditor", "Space"); - RNA_def_struct_sdna(srna, "SpaceLogic"); - RNA_def_struct_ui_text(srna, "Space Logic Editor", "Logic editor space data"); - - /* sensors */ - prop = RNA_def_property(srna, "show_sensors_selected_objects", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_SEL); - RNA_def_property_ui_text(prop, "Show Selected Object", "Show sensors of all selected objects"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_sensors_active_object", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_ACT); - RNA_def_property_ui_text(prop, "Show Active Object", "Show sensors of active object"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_sensors_linked_controller", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_LINK); - RNA_def_property_ui_text(prop, "Show Linked to Controller", "Show linked objects to the controller"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_sensors_active_states", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_STATE); - RNA_def_property_ui_text(prop, "Show Active States", "Show only sensors connected to active states"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* controllers */ - prop = RNA_def_property(srna, "show_controllers_selected_objects", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_CONT_SEL); - RNA_def_property_ui_text(prop, "Show Selected Object", "Show controllers of all selected objects"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_controllers_active_object", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_CONT_ACT); - RNA_def_property_ui_text(prop, "Show Active Object", "Show controllers of active object"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_controllers_linked_controller", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_CONT_LINK); - RNA_def_property_ui_text(prop, "Show Linked to Controller", "Show linked objects to sensor/actuator"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - /* actuators */ - prop = RNA_def_property(srna, "show_actuators_selected_objects", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_SEL); - RNA_def_property_ui_text(prop, "Show Selected Object", "Show actuators of all selected objects"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_actuators_active_object", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_ACT); - RNA_def_property_ui_text(prop, "Show Active Object", "Show actuators of active object"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_actuators_linked_controller", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_LINK); - RNA_def_property_ui_text(prop, "Show Linked to Actuator", "Show linked objects to the actuator"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop = RNA_def_property(srna, "show_actuators_active_states", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_STATE); - RNA_def_property_ui_text(prop, "Show Active States", "Show only actuators connected to active states"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - -} - static void rna_def_space_clip(BlenderRNA *brna) { StructRNA *srna; @@ -4551,24 +4959,24 @@ static void rna_def_space_clip(BlenderRNA *brna) static const EnumPropertyItem view_items[] = { {SC_VIEW_CLIP, "CLIP", ICON_SEQUENCE, "Clip", "Show editing clip preview"}, - {SC_VIEW_GRAPH, "GRAPH", ICON_IPO, "Graph", "Show graph view for active element"}, + {SC_VIEW_GRAPH, "GRAPH", ICON_GRAPH, "Graph", "Show graph view for active element"}, {SC_VIEW_DOPESHEET, "DOPESHEET", ICON_ACTION, "Dopesheet", "Dopesheet view for tracking data"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem gpencil_source_items[] = { - {SC_GPENCIL_SRC_CLIP, "CLIP", 0, "Clip", "Show grease pencil data-block which belongs to movie clip"}, - {SC_GPENCIL_SRC_TRACK, "TRACK", 0, "Track", "Show grease pencil data-block which belongs to active track"}, + {SC_GPENCIL_SRC_CLIP, "CLIP", 0, "Clip", "Show annotation data-block which belongs to movie clip"}, + {SC_GPENCIL_SRC_TRACK, "TRACK", 0, "Track", "Show annotation data-block which belongs to active track"}, {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem pivot_items[] = { - {V3D_AROUND_CENTER_BOUNDS, "BOUNDING_BOX_CENTER", ICON_ROTATE, "Bounding Box Center", + {V3D_AROUND_CENTER_BOUNDS, "BOUNDING_BOX_CENTER", ICON_PIVOT_BOUNDBOX, "Bounding Box Center", "Pivot around bounding box center of selected object(s)"}, - {V3D_AROUND_CURSOR, "CURSOR", ICON_CURSOR, "2D Cursor", "Pivot around the 2D cursor"}, - {V3D_AROUND_LOCAL_ORIGINS, "INDIVIDUAL_ORIGINS", ICON_ROTATECOLLECTION, + {V3D_AROUND_CURSOR, "CURSOR", ICON_PIVOT_CURSOR, "2D Cursor", "Pivot around the 2D cursor"}, + {V3D_AROUND_LOCAL_ORIGINS, "INDIVIDUAL_ORIGINS", ICON_CENTER_ONLY, "Individual Origins", "Pivot around each object's own origin"}, - {V3D_AROUND_CENTER_MEAN, "MEDIAN_POINT", ICON_ROTATECENTER, "Median Point", + {V3D_AROUND_CENTER_MEAN, "MEDIAN_POINT", ICON_PIVOT_MEDIAN, "Median Point", "Pivot around the median point of selected objects"}, {0, NULL, 0, NULL, NULL} }; @@ -4708,11 +5116,11 @@ static void rna_def_space_clip(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Manual Calibration", "Use manual calibration helpers"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL); - /* show grease pencil */ - prop = RNA_def_property(srna, "show_grease_pencil", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GPENCIL); - RNA_def_property_ui_text(prop, "Show Grease Pencil", - "Show grease pencil for this view"); + /* show annotation */ + prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_ANNOTATION); + RNA_def_property_ui_text(prop, "Show Annotation", + "Show annotations for this view"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL); /* show filters */ @@ -4816,20 +5224,17 @@ void RNA_def_space(BlenderRNA *brna) rna_def_filemenu_entry(brna); rna_def_space_filebrowser(brna); rna_def_space_outliner(brna); - rna_def_background_image(brna); rna_def_space_view3d(brna); rna_def_space_buttons(brna); rna_def_space_dopesheet(brna); rna_def_space_graph(brna); rna_def_space_nla(brna); - rna_def_space_time(brna); rna_def_space_console(brna); rna_def_console_line(brna); rna_def_space_info(brna); rna_def_space_userpref(brna); rna_def_node_tree_path(brna); rna_def_space_node(brna); - rna_def_space_logic(brna); rna_def_space_clip(brna); } diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c index 8f771eda99d..f1206b7130f 100644 --- a/source/blender/makesrna/intern/rna_space_api.c +++ b/source/blender/makesrna/intern/rna_space_api.c @@ -31,9 +31,12 @@ #ifdef RNA_RUNTIME +#include "BKE_global.h" + +#include "ED_screen.h" #include "ED_text.h" -static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d) +static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d, bContext *C) { bScreen *sc = (bScreen *)id; @@ -43,11 +46,20 @@ static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d) area_region_from_regiondata(sc, rv3d, &sa, &ar); if (sa && ar && sa->spacetype == SPACE_VIEW3D) { - View3D *v3d; - - v3d = (View3D *)sa->spacedata.first; - - ED_view3d_update_viewmat(sc->scene, v3d, ar, NULL, NULL, NULL); + View3D *v3d = sa->spacedata.first; + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win; + + for (win = wm->windows.first; win; win = win->next) { + if (WM_window_get_active_screen(win) == sc) { + Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); + + ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, NULL, NULL, NULL); + break; + } + } } } @@ -71,7 +83,7 @@ void RNA_api_region_view3d(StructRNA *srna) FunctionRNA *func; func = RNA_def_function(srna, "update", "rna_RegionView3D_update"); - RNA_def_function_flag(func, FUNC_USE_SELF_ID); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Recalculate the view matrices"); } diff --git a/source/blender/makesrna/intern/rna_speaker.c b/source/blender/makesrna/intern/rna_speaker.c index 3a4bc3860d4..41f22929143 100644 --- a/source/blender/makesrna/intern/rna_speaker.c +++ b/source/blender/makesrna/intern/rna_speaker.c @@ -41,7 +41,6 @@ #include "MEM_guardedalloc.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" #include "WM_api.h" diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index b2271c3903d..e9ef4bf7a8c 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -67,19 +67,14 @@ const EnumPropertyItem rna_enum_texture_type_items[] = { {TEX_CLOUDS, "CLOUDS", ICON_TEXTURE, "Clouds", "Procedural - create a cloud-like fractal noise texture"}, {TEX_DISTNOISE, "DISTORTED_NOISE", ICON_TEXTURE, "Distorted Noise", "Procedural - noise texture distorted by two noise algorithms"}, - {TEX_ENVMAP, "ENVIRONMENT_MAP", ICON_IMAGE_DATA, - "Environment Map", "Create a render of the environment mapped to a texture"}, {TEX_IMAGE, "IMAGE", ICON_IMAGE_DATA, "Image or Movie", "Allow for images or movies to be used as textures"}, {TEX_MAGIC, "MAGIC", ICON_TEXTURE, "Magic", "Procedural - color texture based on trigonometric functions"}, {TEX_MARBLE, "MARBLE", ICON_TEXTURE, "Marble", "Procedural - marble-like noise texture with wave generated bands"}, {TEX_MUSGRAVE, "MUSGRAVE", ICON_TEXTURE, "Musgrave", "Procedural - highly flexible fractal noise texture"}, {TEX_NOISE, "NOISE", ICON_TEXTURE, "Noise", "Procedural - random noise, gives a different result every time, for every frame, for every pixel"}, - {TEX_OCEAN, "OCEAN", ICON_TEXTURE, "Ocean", "Use a texture generated by an Ocean modifier"}, - {TEX_POINTDENSITY, "POINT_DENSITY", ICON_TEXTURE, "Point Density", ""}, {TEX_STUCCI, "STUCCI", ICON_TEXTURE, "Stucci", "Procedural - create a fractal noise texture"}, {TEX_VORONOI, "VORONOI", ICON_TEXTURE, "Voronoi", "Procedural - create cell-like patterns based on Worley noise"}, - {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", "Create a 3D texture based on volumetric data"}, {TEX_WOOD, "WOOD", ICON_TEXTURE, "Wood", "Procedural - wave generated bands or rings, with optional noise"}, {0, NULL, 0, NULL, NULL} }; @@ -87,21 +82,26 @@ const EnumPropertyItem rna_enum_texture_type_items[] = { #ifndef RNA_RUNTIME static const EnumPropertyItem blend_type_items[] = { {MTEX_BLEND, "MIX", 0, "Mix", ""}, - {MTEX_ADD, "ADD", 0, "Add", ""}, - {MTEX_SUB, "SUBTRACT", 0, "Subtract", ""}, + {0, "", ICON_NONE, NULL, NULL}, + {MTEX_DARK, "DARKEN", 0, "Darken", ""}, {MTEX_MUL, "MULTIPLY", 0, "Multiply", ""}, + {0, "", ICON_NONE, NULL, NULL}, + {MTEX_LIGHT, "LIGHTEN", 0, "Lighten", ""}, {MTEX_SCREEN, "SCREEN", 0, "Screen", ""}, + {MTEX_ADD, "ADD", 0, "Add", ""}, + {0, "", ICON_NONE, NULL, NULL}, {MTEX_OVERLAY, "OVERLAY", 0, "Overlay", ""}, + {MTEX_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""}, + {MTEX_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""}, + {0, "", ICON_NONE, NULL, NULL}, {MTEX_DIFF, "DIFFERENCE", 0, "Difference", ""}, + {MTEX_SUB, "SUBTRACT", 0, "Subtract", ""}, {MTEX_DIV, "DIVIDE", 0, "Divide", ""}, - {MTEX_DARK, "DARKEN", 0, "Darken", ""}, - {MTEX_LIGHT, "LIGHTEN", 0, "Lighten", ""}, + {0, "", ICON_NONE, NULL, NULL}, {MTEX_BLEND_HUE, "HUE", 0, "Hue", ""}, {MTEX_BLEND_SAT, "SATURATION", 0, "Saturation", ""}, - {MTEX_BLEND_VAL, "VALUE", 0, "Value", ""}, {MTEX_BLEND_COLOR, "COLOR", 0, "Color", ""}, - {MTEX_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""}, - {MTEX_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""}, + {MTEX_BLEND_VAL, "VALUE", 0, "Value", ""}, {0, NULL, 0, NULL, NULL} }; #endif @@ -114,11 +114,12 @@ static const EnumPropertyItem blend_type_items[] = { #include "BKE_colorband.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_image.h" #include "BKE_texture.h" #include "BKE_main.h" +#include "DEG_depsgraph.h" + #include "ED_node.h" #include "ED_render.h" @@ -133,8 +134,6 @@ static StructRNA *rna_Texture_refine(struct PointerRNA *ptr) return &RNA_CloudsTexture; case TEX_DISTNOISE: return &RNA_DistortedNoiseTexture; - case TEX_ENVMAP: - return &RNA_EnvironmentMapTexture; case TEX_IMAGE: return &RNA_ImageTexture; case TEX_MAGIC: @@ -145,18 +144,12 @@ static StructRNA *rna_Texture_refine(struct PointerRNA *ptr) return &RNA_MusgraveTexture; case TEX_NOISE: return &RNA_NoiseTexture; - case TEX_POINTDENSITY: - return &RNA_PointDensityTexture; case TEX_STUCCI: return &RNA_StucciTexture; case TEX_VORONOI: return &RNA_VoronoiTexture; - case TEX_VOXELDATA: - return &RNA_VoxelDataTexture; case TEX_WOOD: return &RNA_WoodTexture; - case TEX_OCEAN: - return &RNA_OceanTexture; default: return &RNA_Texture; } @@ -169,7 +162,7 @@ static void rna_Texture_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *pt if (GS(id->name) == ID_TE) { Tex *tex = ptr->id.data; - DAG_id_tag_update(&tex->id, 0); + DEG_id_tag_update(&tex->id, 0); WM_main_add_notifier(NC_TEXTURE, tex); WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, NULL); } @@ -191,31 +184,12 @@ static void rna_Color_mapping_update(Main *UNUSED(bmain), Scene *UNUSED(scene), /* nothing to do */ } -static void rna_Texture_voxeldata_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - Tex *tex = ptr->id.data; - - tex->vd->ok = 0; - rna_Texture_update(bmain, scene, ptr); -} - -static void rna_Texture_voxeldata_image_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - Tex *tex = ptr->id.data; - - if (tex->ima) { /* may be getting cleared too */ - tex->ima->source = IMA_SRC_SEQUENCE; - } - rna_Texture_voxeldata_update(bmain, scene, ptr); -} - - /* Used for Texture Properties, used (also) for/in Nodes */ static void rna_Texture_nodes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Tex *tex = ptr->id.data; - DAG_id_tag_update(&tex->id, 0); + DEG_id_tag_update(&tex->id, 0); WM_main_add_notifier(NC_TEXTURE | ND_NODES, tex); } @@ -226,11 +200,11 @@ static void rna_Texture_type_set(PointerRNA *ptr, int value) BKE_texture_type_set(tex, value); } -void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +void rna_TextureSlot_update(bContext *C, PointerRNA *ptr) { ID *id = ptr->id.data; - DAG_id_tag_update(id, 0); + DEG_id_tag_update(id, 0); switch (GS(id->name)) { case ID_MA: @@ -246,8 +220,10 @@ void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) break; case ID_BR: { + Scene *scene = CTX_data_scene(C); MTex *mtex = ptr->data; - BKE_paint_invalidate_overlay_tex(scene, mtex->tex); + ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex); WM_main_add_notifier(NC_BRUSH, id); break; } @@ -264,7 +240,7 @@ void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) if (mtex->mapto & PAMAP_CHILD) recalc |= PSYS_RECALC_CHILD; - DAG_id_tag_update(id, recalc); + DEG_id_tag_update(id, recalc); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); break; } @@ -430,54 +406,6 @@ static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, bool value) else tex->imaflag &= ~TEX_MIPMAP; } -static void rna_Envmap_update_generic(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - Tex *tex = ptr->id.data; - if (tex->env) { - ED_preview_kill_jobs(bmain->wm.first, bmain); - BKE_texture_envmap_free_data(tex->env); - } - rna_Texture_update(bmain, scene, ptr); -} - -static PointerRNA rna_PointDensity_psys_get(PointerRNA *ptr) -{ - PointDensity *pd = ptr->data; - Object *ob = pd->object; - ParticleSystem *psys = NULL; - PointerRNA value; - - if (ob && pd->psys) - psys = BLI_findlink(&ob->particlesystem, pd->psys - 1); - - RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &value); - return value; -} - -static void rna_PointDensity_psys_set(PointerRNA *ptr, PointerRNA value) -{ - PointDensity *pd = ptr->data; - Object *ob = pd->object; - - if (ob && value.id.data == ob) - pd->psys = BLI_findindex(&ob->particlesystem, value.data) + 1; -} - -static char *rna_PointDensity_path(PointerRNA *UNUSED(ptr)) -{ - return BLI_sprintfN("point_density"); -} - -static char *rna_VoxelData_path(PointerRNA *UNUSED(ptr)) -{ - return BLI_sprintfN("voxel_data"); -} - -static char *rna_OceanTex_path(PointerRNA *UNUSED(ptr)) -{ - return BLI_sprintfN("ocean"); -} - #else static void rna_def_texmapping(BlenderRNA *brna) @@ -649,7 +577,7 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tex"); RNA_def_property_struct_type(prop, "Texture"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Texture", "Texture data-block used by this texture slot"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_TextureSlot_update"); @@ -657,6 +585,7 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_string_funcs(prop, "rna_TextureSlot_name_get", "rna_TextureSlot_name_length", NULL); RNA_def_property_ui_text(prop, "Name", "Texture slot name"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_struct_name_property(srna, prop); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); @@ -664,12 +593,13 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "ofs"); RNA_def_property_ui_range(prop, -10, 10, 10, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Offset", "Fine tune of the texture mapping X, Y and Z locations"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); 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_flag(prop, PROP_PROPORTIONAL | PROP_CONTEXT_UPDATE); RNA_def_property_ui_range(prop, -100, 100, 10, 2); RNA_def_property_ui_text(prop, "Size", "Set scaling for the texture's X, Y and Z sizes"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); @@ -677,6 +607,7 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "r"); RNA_def_property_array(prop, 3); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Color", "Default color for textures that don't return RGB or when RGB to intensity is enabled"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); @@ -684,26 +615,31 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "blendtype"); RNA_def_property_enum_items(prop, blend_type_items); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Blend Type", "Mode used to apply the texture"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "use_stencil", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_STENCIL); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Stencil", "Use this texture as a blending value on the next texture"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_NEGATIVE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Negate", "Invert the values of the texture to reverse its effect"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "use_rgb_to_intensity", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_RGBTOINT); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "RGB to Intensity", "Convert texture RGB values to intensity (gray) values"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "def_var"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Default Value", "Value to use for Ref, Spec, Amb, Emit, Alpha, RayMir, TransLu and Hard"); @@ -712,6 +648,7 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "output_node", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "which_output"); RNA_def_property_enum_items(prop, output_node_items); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_enum_funcs(prop, "rna_TextureSlot_output_node_get", NULL, "rna_TextureSlot_output_node_itemf"); RNA_def_property_ui_text(prop, "Output Node", "Which output node to use, for node-based textures"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); @@ -738,7 +675,7 @@ static void rna_def_filter_common(StructRNA *srna) RNA_def_property_ui_text(prop, "Filter", "Texture filter to use for sampling image"); RNA_def_property_update(prop, 0, "rna_Texture_update"); - prop = RNA_def_property(srna, "filter_probes", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "filter_lightprobes", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "afmax"); RNA_def_property_range(prop, 1, 256); RNA_def_property_ui_text(prop, "Filter Probes", @@ -767,94 +704,6 @@ static void rna_def_filter_common(StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Texture_update"); } -static void rna_def_environment_map(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem prop_source_items[] = { - {ENV_STATIC, "STATIC", 0, "Static", "Calculate environment map only once"}, - {ENV_ANIM, "ANIMATED", 0, "Animated", "Calculate environment map at each rendering"}, - {ENV_LOAD, "IMAGE_FILE", 0, "Image File", "Load a saved environment map image from disk"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_mapping_items[] = { - {ENV_CUBE, "CUBE", 0, "Cube", "Use environment map with six cube sides"}, - {ENV_PLANE, "PLANE", 0, "Plane", "Only one side is rendered, with Z axis pointing in direction of image"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "EnvironmentMap", NULL); - RNA_def_struct_sdna(srna, "EnvMap"); - RNA_def_struct_ui_text(srna, "EnvironmentMap", - "Environment map created by the renderer and cached for subsequent renders"); - - prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "stype"); - RNA_def_property_enum_items(prop, prop_source_items); - RNA_def_property_ui_text(prop, "Source", ""); - RNA_def_property_update(prop, 0, "rna_Envmap_update_generic"); - - prop = RNA_def_property(srna, "viewpoint_object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - RNA_def_property_ui_text(prop, "Viewpoint Object", "Object to use as the environment map's viewpoint location"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_mapping_items); - RNA_def_property_ui_text(prop, "Mapping", ""); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "clipsta"); - RNA_def_property_range(prop, 0.001, FLT_MAX); - RNA_def_property_ui_range(prop, 0.01, 50, 100, 2); - RNA_def_property_ui_text(prop, "Clip Start", "Objects nearer than this are not visible to map"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "clipend"); - RNA_def_property_range(prop, 0.01, FLT_MAX); - RNA_def_property_ui_range(prop, 0.10, 20000, 100, 2); - RNA_def_property_ui_text(prop, "Clip End", "Objects further than this are not visible to map"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "zoom", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "viewscale"); - RNA_def_property_range(prop, 0.1, 5.0); - RNA_def_property_ui_range(prop, 0.5, 1.5, 1, 2); - RNA_def_property_ui_text(prop, "Zoom", ""); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "layers_ignore", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, NULL, "notlay", 1); - RNA_def_property_array(prop, 20); - RNA_def_property_ui_text(prop, "Ignore Layers", - "Hide objects on these layers when generating the Environment Map"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "resolution", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "cuberes"); - RNA_def_property_range(prop, 50, 4096); - RNA_def_property_ui_text(prop, "Resolution", "Pixel resolution of the rendered environment map"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED); - RNA_def_property_range(prop, 0, 5); - RNA_def_property_ui_text(prop, "Depth", "Number of times a map will be rendered recursively (mirror effects)"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, 0); - RNA_def_property_boolean_sdna(prop, NULL, "ok", 2); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Validity", "True if this map is ready for use, False if it needs rendering"); - - RNA_api_environment_map(srna); -} - static const EnumPropertyItem prop_noise_basis_items[] = { {TEX_BLENDER, "BLENDER_ORIGINAL", 0, "Blender Original", "Noise algorithm - Blender original: Smooth interpolated noise"}, @@ -1360,43 +1209,6 @@ static void rna_def_texture_image(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_NORMALMAP); RNA_def_property_ui_text(prop, "Normal Map", "Use image RGB values for normal mapping"); RNA_def_property_update(prop, 0, "rna_Texture_update"); - - /* Derivative Map */ - prop = RNA_def_property(srna, "use_derivative_map", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_DERIVATIVEMAP); - RNA_def_property_ui_text(prop, "Derivative Map", "Use red and green as derivative values"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); -} - -static void rna_def_texture_environment_map(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "EnvironmentMapTexture", "Texture"); - RNA_def_struct_ui_text(srna, "Environment Map", "Environment map texture"); - RNA_def_struct_sdna(srna, "Tex"); - - prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "ima"); - RNA_def_property_struct_type(prop, "Image"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Image", "Source image file to read the environment map from"); - RNA_def_property_update(prop, 0, "rna_Envmap_update_generic"); - - prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "iuser"); - RNA_def_property_ui_text(prop, "Image User", - "Parameters defining which layer, pass and frame of the image is displayed"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - rna_def_filter_common(srna); - - prop = RNA_def_property(srna, "environment_map", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "env"); - RNA_def_property_struct_type(prop, "EnvironmentMap"); - RNA_def_property_ui_text(prop, "Environment Map", "Get the environment map associated with this texture"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); } static void rna_def_texture_musgrave(BlenderRNA *brna) @@ -1621,407 +1433,6 @@ static void rna_def_texture_distorted_noise(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Texture_update"); } -static void rna_def_texture_pointdensity(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem point_source_items[] = { - {TEX_PD_PSYS, "PARTICLE_SYSTEM", 0, "Particle System", "Generate point density from a particle system"}, - {TEX_PD_OBJECT, "OBJECT", 0, "Object Vertices", "Generate point density from an object's vertices"}, - /*{TEX_PD_FILE, "FILE", 0, "File", ""}, */ - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem particle_cache_items[] = { - {TEX_PD_OBJECTLOC, "OBJECT_LOCATION", 0, "Emit Object Location", ""}, - {TEX_PD_OBJECTSPACE, "OBJECT_SPACE", 0, "Emit Object Space", ""}, - {TEX_PD_WORLDSPACE, "WORLD_SPACE", 0, "Global Space", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem vertex_cache_items[] = { - {TEX_PD_OBJECTLOC, "OBJECT_LOCATION", 0, "Object Location", ""}, - {TEX_PD_OBJECTSPACE, "OBJECT_SPACE", 0, "Object Space", ""}, - {TEX_PD_WORLDSPACE, "WORLD_SPACE", 0, "Global Space", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem falloff_items[] = { - {TEX_PD_FALLOFF_STD, "STANDARD", 0, "Standard", ""}, - {TEX_PD_FALLOFF_SMOOTH, "SMOOTH", 0, "Smooth", ""}, - {TEX_PD_FALLOFF_SOFT, "SOFT", 0, "Soft", ""}, - {TEX_PD_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", "Density is constant within lookup radius"}, - {TEX_PD_FALLOFF_ROOT, "ROOT", 0, "Root", ""}, - {TEX_PD_FALLOFF_PARTICLE_AGE, "PARTICLE_AGE", 0, "Particle Age", ""}, - {TEX_PD_FALLOFF_PARTICLE_VEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", ""}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem particle_color_source_items[] = { - {TEX_PD_COLOR_CONSTANT, "CONSTANT", 0, "Constant", ""}, - {TEX_PD_COLOR_PARTAGE, "PARTICLE_AGE", 0, "Particle Age", "Lifetime mapped as 0.0 - 1.0 intensity"}, - {TEX_PD_COLOR_PARTSPEED, "PARTICLE_SPEED", 0, "Particle Speed", - "Particle speed (absolute magnitude of velocity) mapped as 0.0-1.0 intensity"}, - {TEX_PD_COLOR_PARTVEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", "XYZ velocity mapped to RGB colors"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem vertex_color_source_items[] = { - {TEX_PD_COLOR_CONSTANT, "CONSTANT", 0, "Constant", ""}, - {TEX_PD_COLOR_VERTCOL, "VERTEX_COLOR", 0, "Vertex Color", "Vertex color layer"}, - {TEX_PD_COLOR_VERTWEIGHT, "VERTEX_WEIGHT", 0, "Vertex Weight", "Vertex group weight"}, - {TEX_PD_COLOR_VERTNOR, "VERTEX_NORMAL", 0, "Vertex Normal", "XYZ normal vector mapped to RGB colors"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem turbulence_influence_items[] = { - {TEX_PD_NOISE_STATIC, "STATIC", 0, "Static", - "Noise patterns will remain unchanged, faster and suitable for stills"}, - {TEX_PD_NOISE_VEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", - "Turbulent noise driven by particle velocity"}, - {TEX_PD_NOISE_AGE, "PARTICLE_AGE", 0, "Particle Age", - "Turbulent noise driven by the particle's age between birth and death"}, - {TEX_PD_NOISE_TIME, "GLOBAL_TIME", 0, "Global Time", "Turbulent noise driven by the global current frame"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "PointDensity", NULL); - RNA_def_struct_sdna(srna, "PointDensity"); - RNA_def_struct_ui_text(srna, "PointDensity", "Point density settings"); - RNA_def_struct_path_func(srna, "rna_PointDensity_path"); - - prop = RNA_def_property(srna, "point_source", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "source"); - RNA_def_property_enum_items(prop, point_source_items); - RNA_def_property_ui_text(prop, "Point Source", "Point data to use as renderable point density"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - 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 to take point data from"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); - RNA_def_property_ui_text(prop, "Particle System", "Particle System to render as points"); - RNA_def_property_struct_type(prop, "ParticleSystem"); - RNA_def_property_pointer_funcs(prop, "rna_PointDensity_psys_get", "rna_PointDensity_psys_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "particle_cache_space", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "psys_cache_space"); - RNA_def_property_enum_items(prop, particle_cache_items); - RNA_def_property_ui_text(prop, "Particle Cache", "Coordinate system to cache particles in"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "vertex_cache_space", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "ob_cache_space"); - RNA_def_property_enum_items(prop, vertex_cache_items); - RNA_def_property_ui_text(prop, "Vertices Cache", "Coordinate system to cache vertices in"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "radius"); - RNA_def_property_range(prop, 0.001, FLT_MAX); - RNA_def_property_ui_text(prop, "Radius", "Radius from the shaded sample to look for points within"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "falloff_type"); - RNA_def_property_enum_items(prop, falloff_items); - RNA_def_property_ui_text(prop, "Falloff", "Method of attenuating density by distance from the point"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "falloff_soft", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "falloff_softness"); - RNA_def_property_range(prop, 0.01, FLT_MAX); - RNA_def_property_ui_text(prop, "Softness", "Softness of the 'soft' falloff option"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "particle_color_source", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "color_source"); - RNA_def_property_enum_items(prop, particle_color_source_items); - RNA_def_property_ui_text(prop, "Color Source", "Data to derive color results from"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "vertex_color_source", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "ob_color_source"); - RNA_def_property_enum_items(prop, vertex_color_source_items); - RNA_def_property_ui_text(prop, "Color Source", "Data to derive color results from"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "vertex_attribute_name", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Vertex Attribute Name", "Vertex attribute to use for color"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "speed_scale", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "speed_scale"); - RNA_def_property_range(prop, 0.001, 100.0); - RNA_def_property_ui_text(prop, "Scale", "Multiplier to bring particle speed within an acceptable range"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "falloff_speed_scale", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "falloff_speed_scale"); - RNA_def_property_range(prop, 0.001, 100.0); - RNA_def_property_ui_text(prop, "Velocity Scale", "Multiplier to bring particle speed within an acceptable range"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - - prop = RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "coba"); - RNA_def_property_struct_type(prop, "ColorRamp"); - RNA_def_property_ui_text(prop, "Color Ramp", ""); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "falloff_curve"); - RNA_def_property_struct_type(prop, "CurveMapping"); - RNA_def_property_ui_text(prop, "Falloff Curve", ""); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "use_falloff_curve", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PD_FALLOFF_CURVE); - RNA_def_property_ui_text(prop, "Falloff Curve", "Use a custom falloff curve"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - /* Turbulence */ - prop = RNA_def_property(srna, "use_turbulence", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PD_TURBULENCE); - RNA_def_property_ui_text(prop, "Turbulence", "Add directed noise to the density at render-time"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "turbulence_scale", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "noise_size"); - RNA_def_property_range(prop, 0.01, FLT_MAX); - RNA_def_property_ui_text(prop, "Size", "Scale of the added turbulent noise"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "turbulence_strength", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "noise_fac"); - RNA_def_property_range(prop, 0.01, FLT_MAX); - RNA_def_property_ui_text(prop, "Turbulence Strength", "Strength of the added turbulent noise"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "noise_depth"); - RNA_def_property_range(prop, 0, 30); - RNA_def_property_ui_text(prop, "Depth", "Level of detail in the added turbulent noise"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "turbulence_influence", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "noise_influence"); - RNA_def_property_enum_items(prop, turbulence_influence_items); - RNA_def_property_ui_text(prop, "Turbulence Influence", "Method for driving added turbulent noise"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "noise_basis"); - RNA_def_property_enum_items(prop, prop_noise_basis_items); - RNA_def_property_ui_text(prop, "Noise Basis", "Noise formula used for turbulence"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - - srna = RNA_def_struct(brna, "PointDensityTexture", "Texture"); - RNA_def_struct_sdna(srna, "Tex"); - RNA_def_struct_ui_text(srna, "Point Density", "Settings for the Point Density texture"); - - prop = RNA_def_property(srna, "point_density", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "pd"); - RNA_def_property_struct_type(prop, "PointDensity"); - RNA_def_property_ui_text(prop, "Point Density", "The point density settings associated with this texture"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); -} - -static void rna_def_texture_voxeldata(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem interpolation_type_items[] = { - {TEX_VD_NEARESTNEIGHBOR, "NEREASTNEIGHBOR", 0, "Nearest Neighbor", - "No interpolation, fast but blocky and low quality"}, - {TEX_VD_LINEAR, "TRILINEAR", 0, "Linear", "Good smoothness and speed"}, - {TEX_VD_QUADRATIC, "QUADRATIC", 0, "Quadratic", "Mid-range quality and speed"}, - {TEX_VD_TRICUBIC_CATROM, "TRICUBIC_CATROM", 0, "Cubic Catmull-Rom", "High quality interpolation, but slower"}, - {TEX_VD_TRICUBIC_BSPLINE, "TRICUBIC_BSPLINE", 0, "Cubic B-Spline", - "Smoothed high quality interpolation, but slower"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem file_format_items[] = { - {TEX_VD_BLENDERVOXEL, "BLENDER_VOXEL", 0, "Blender Voxel", "Default binary voxel file format"}, - {TEX_VD_RAW_8BIT, "RAW_8BIT", 0, "8 bit RAW", "8 bit grayscale binary data"}, - /*{TEX_VD_RAW_16BIT, "RAW_16BIT", 0, "16 bit RAW", ""}, */ - {TEX_VD_IMAGE_SEQUENCE, "IMAGE_SEQUENCE", 0, "Image Sequence", - "Generate voxels from a sequence of image slices"}, - {TEX_VD_SMOKE, "SMOKE", 0, "Smoke", "Render voxels from a Blender smoke simulation"}, - {TEX_VD_HAIR, "HAIR", 0, "Hair", "Render voxels from a Blender hair simulation"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem voxeldata_extension[] = { - {TEX_EXTEND, "EXTEND", 0, "Extend", "Extend by repeating edge pixels of the image"}, - {TEX_CLIP, "CLIP", 0, "Clip", "Clip to image size and set exterior pixels as transparent"}, - {TEX_REPEAT, "REPEAT", 0, "Repeat", "Cause the image to repeat horizontally and vertically"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem smoked_type_items[] = { - {TEX_VD_SMOKEDENSITY, "SMOKEDENSITY", 0, "Smoke", "Use smoke density and color as texture data"}, - {TEX_VD_SMOKEFLAME, "SMOKEFLAME", 0, "Flame", "Use flame temperature as texture data"}, - {TEX_VD_SMOKEHEAT, "SMOKEHEAT", 0, "Heat", "Use smoke heat as texture data. Values from -2.0 to 2.0 are used"}, - {TEX_VD_SMOKEVEL, "SMOKEVEL", 0, "Velocity", "Use smoke velocity as texture data"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem hair_type_items[] = { - {TEX_VD_HAIRDENSITY, "HAIRDENSITY", 0, "Density", "Use hair density as texture data"}, - {TEX_VD_HAIRRESTDENSITY, "HAIRRESTDENSITY", 0, "Rest Density", "Use hair rest density as texture data"}, - {TEX_VD_HAIRVELOCITY, "HAIRVELOCITY", 0, "Velocity", "Use hair velocity as texture data"}, - {TEX_VD_HAIRENERGY, "HAIRENERGY", 0, "Energy", "Use potential hair energy as texture data"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "VoxelData", NULL); - RNA_def_struct_sdna(srna, "VoxelData"); - RNA_def_struct_ui_text(srna, "VoxelData", "Voxel data settings"); - RNA_def_struct_path_func(srna, "rna_VoxelData_path"); - - prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "interp_type"); - RNA_def_property_enum_items(prop, interpolation_type_items); - RNA_def_property_ui_text(prop, "Interpolation", "Method to interpolate/smooth values between voxel cells"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "smoke_data_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "smoked_type"); - RNA_def_property_enum_items(prop, smoked_type_items); - RNA_def_property_ui_text(prop, "Source", "Simulation value to be used as a texture"); - RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); - - prop = RNA_def_property(srna, "hair_data_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "hair_type"); - RNA_def_property_enum_items(prop, hair_type_items); - RNA_def_property_ui_text(prop, "Source", "Simulation value to be used as a texture"); - RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); - - prop = RNA_def_property(srna, "extension", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "extend"); - RNA_def_property_enum_items(prop, voxeldata_extension); - RNA_def_property_ui_text(prop, "Extension", "How the texture is extrapolated past its original bounds"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "int_multiplier"); - RNA_def_property_range(prop, 0.01, FLT_MAX); - RNA_def_property_ui_text(prop, "Intensity", "Multiplier for intensity values"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "file_format"); - RNA_def_property_enum_items(prop, file_format_items); - RNA_def_property_ui_text(prop, "File Format", "Format of the source data set to render"); - RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); - - prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); - RNA_def_property_string_sdna(prop, NULL, "source_path"); - RNA_def_property_ui_text(prop, "Source Path", "The external source data file to use"); - RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); - - prop = RNA_def_property(srna, "resolution", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "resol"); - RNA_def_property_range(prop, 1, 100000); - RNA_def_property_ui_text(prop, "Resolution", "Resolution of the voxel grid"); - RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); - - prop = RNA_def_property(srna, "use_still_frame", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_VD_STILL); - RNA_def_property_ui_text(prop, "Still Frame Only", "Always render a still frame from the voxel data sequence"); - RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); - - prop = RNA_def_property(srna, "still_frame", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "still_frame"); - RNA_def_property_range(prop, -MAXFRAME, MAXFRAME); - RNA_def_property_ui_text(prop, "Still Frame Number", "The frame number to always use"); - RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); - - prop = RNA_def_property(srna, "domain_object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - RNA_def_property_ui_text(prop, "Domain Object", "Object used as the smoke simulation domain"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); - - - srna = RNA_def_struct(brna, "VoxelDataTexture", "Texture"); - RNA_def_struct_sdna(srna, "Tex"); - RNA_def_struct_ui_text(srna, "Voxel Data", "Settings for the Voxel Data texture"); - - prop = RNA_def_property(srna, "voxel_data", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "vd"); - RNA_def_property_struct_type(prop, "VoxelData"); - RNA_def_property_ui_text(prop, "Voxel Data", "The voxel data associated with this texture"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "ima"); - RNA_def_property_struct_type(prop, "Image"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Image", ""); - RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_image_update"); - - prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "iuser"); - RNA_def_property_ui_text(prop, "Image User", - "Parameters defining which layer, pass and frame of the image is displayed"); - RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); -} - -static void rna_def_texture_ocean(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem ocean_output_items[] = { - {TEX_OCN_DISPLACEMENT, "DISPLACEMENT", 0, "Displacement", "Output XYZ displacement in RGB channels"}, - /*{TEX_OCN_NORMALS, "NORMALS", 0, "Normals", "Outputs wave normals"}, *//* these are in nor channel now */ - {TEX_OCN_FOAM, "FOAM", 0, "Foam", "Output Foam (wave overlap) amount in single channel"}, - {TEX_OCN_JPLUS, "JPLUS", 0, "Eigenvalues", "Positive Eigenvalues"}, - {TEX_OCN_EMINUS, "EMINUS", 0, "Eigenvectors (-)", "Negative Eigenvectors"}, - {TEX_OCN_EPLUS, "EPLUS", 0, "Eigenvectors (+)", "Positive Eigenvectors"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "OceanTexData", NULL); - RNA_def_struct_sdna(srna, "OceanTex"); - RNA_def_struct_ui_text(srna, "Ocean", "Ocean Texture settings"); - RNA_def_struct_path_func(srna, "rna_OceanTex_path"); - - prop = RNA_def_property(srna, "output", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "output"); - RNA_def_property_enum_items(prop, ocean_output_items); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Output", "The data that is output by the texture"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - prop = RNA_def_property(srna, "ocean_object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - RNA_def_property_ui_text(prop, "Modifier Object", "Object containing the ocean modifier"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, 0, "rna_Texture_update"); - - srna = RNA_def_struct(brna, "OceanTexture", "Texture"); - RNA_def_struct_sdna(srna, "Tex"); - RNA_def_struct_ui_text(srna, "Ocean", "Settings for the Ocean texture"); - - prop = RNA_def_property(srna, "ocean", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "ot"); - RNA_def_property_struct_type(prop, "OceanTexData"); - RNA_def_property_ui_text(prop, "Ocean", "The ocean data associated with this texture"); - RNA_def_property_update(prop, 0, "rna_Texture_update"); -} - static void rna_def_texture(BlenderRNA *brna) { StructRNA *srna; @@ -2029,7 +1440,7 @@ static void rna_def_texture(BlenderRNA *brna) srna = RNA_def_struct(brna, "Texture", "ID"); RNA_def_struct_sdna(srna, "Tex"); - RNA_def_struct_ui_text(srna, "Texture", "Texture data-block used by materials, lamps, worlds and brushes"); + RNA_def_struct_ui_text(srna, "Texture", "Texture data-block used by materials, lights, worlds and brushes"); RNA_def_struct_ui_icon(srna, ICON_TEXTURE_DATA); RNA_def_struct_refine_func(srna, "rna_Texture_refine"); @@ -2122,13 +1533,9 @@ static void rna_def_texture(BlenderRNA *brna) rna_def_texture_stucci(brna); rna_def_texture_noise(brna); rna_def_texture_image(brna); - rna_def_texture_environment_map(brna); rna_def_texture_musgrave(brna); rna_def_texture_voronoi(brna); rna_def_texture_distorted_noise(brna); - rna_def_texture_pointdensity(brna); - rna_def_texture_voxeldata(brna); - rna_def_texture_ocean(brna); /* XXX add more types here .. */ RNA_api_texture(srna); @@ -2138,7 +1545,6 @@ void RNA_def_texture(BlenderRNA *brna) { rna_def_texture(brna); rna_def_mtex(brna); - rna_def_environment_map(brna); rna_def_texmapping(brna); rna_def_colormapping(brna); } diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c index 615d435f72e..1d513a494d7 100644 --- a/source/blender/makesrna/intern/rna_texture_api.c +++ b/source/blender/makesrna/intern/rna_texture_api.c @@ -45,30 +45,6 @@ #include "RE_pipeline.h" #include "RE_shader_ext.h" -static void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const char *filepath, - struct Scene *scene, float layout[12]) -{ - if (scene == NULL) { - scene = CTX_data_scene(C); - } - - RE_WriteEnvmapResult(reports, scene, env, filepath, scene->r.im_format.imtype, layout); -} - -static void clear_envmap(struct EnvMap *env, bContext *C) -{ - Main *bmain = CTX_data_main(C); - Tex *tex; - - BKE_texture_envmap_free_data(env); - - for (tex = bmain->tex.first; tex; tex = tex->id.next) - if (tex->env == env) { - WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex); - break; - } -} - static void texture_evaluate(struct Tex *tex, float value[3], float r_color[4]) { TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; @@ -102,31 +78,4 @@ void RNA_api_texture(StructRNA *srna) } -void RNA_api_environment_map(StructRNA *srna) -{ - FunctionRNA *func; - PropertyRNA *parm; - - static const float default_layout[] = {0, 0, 1, 0, 2, 0, 0, 1, 1, 1, 2, 1}; - - func = RNA_def_function(srna, "clear", "clear_envmap"); - RNA_def_function_ui_description(func, "Discard the environment map and free it from memory"); - RNA_def_function_flag(func, FUNC_USE_CONTEXT); - - - func = RNA_def_function(srna, "save", "save_envmap"); - RNA_def_function_ui_description(func, "Save the environment map to disc using the scene render settings"); - RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); - - parm = RNA_def_string_file_name(func, "filepath", NULL, FILE_MAX, "File path", "Location of the output file"); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - - RNA_def_pointer(func, "scene", "Scene", "", "Overrides the scene from which image parameters are taken"); - - RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 1000.0f, "File layout", - "Flat array describing the X,Y position of each cube face in the " - "output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] " - "(use -1 to skip a face)", 0.0f, 1000.0f); -} - #endif diff --git a/source/blender/makesrna/intern/rna_timeline.c b/source/blender/makesrna/intern/rna_timeline.c index a732b550261..45f90d13477 100644 --- a/source/blender/makesrna/intern/rna_timeline.c +++ b/source/blender/makesrna/intern/rna_timeline.c @@ -74,7 +74,7 @@ static void rna_def_timeline_marker(BlenderRNA *brna) prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); - RNA_def_property_ui_text(prop, "Camera", "Camera this timeline sets to active"); + RNA_def_property_ui_text(prop, "Camera", "Camera that becomes active on this frame"); #endif } diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index deb40070fe9..4c5af755b13 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -51,9 +51,10 @@ #include "DNA_anim_types.h" #include "BKE_animsys.h" -#include "BKE_depsgraph.h" #include "BKE_node.h" +#include "DEG_depsgraph.h" + #include "IMB_imbuf.h" #include "WM_api.h" @@ -426,7 +427,7 @@ static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerR WM_main_add_notifier(NC_SCENE | ND_NODES, NULL); WM_main_add_notifier(NC_SCENE, NULL); - DAG_id_tag_update(&clip->id, 0); + DEG_id_tag_update(&clip->id, 0); } static void rna_tracking_resetIntrinsics(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -515,7 +516,7 @@ static void rna_trackingObject_flushUpdate(Main *UNUSED(bmain), Scene *UNUSED(sc MovieClip *clip = (MovieClip *)ptr->id.data; WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, NULL); - DAG_id_tag_update(&clip->id, 0); + DEG_id_tag_update(&clip->id, 0); } static void rna_trackingMarker_frame_set(PointerRNA *ptr, int value) @@ -1479,6 +1480,7 @@ static void rna_def_trackingTrack(BlenderRNA *brna) 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_annotations_poll"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this track"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 782d39bcb7e..9d395f3ec9b 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -28,6 +28,7 @@ #include <stdlib.h> #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "BLT_translation.h" @@ -41,6 +42,7 @@ #include "UI_interface.h" #include "WM_types.h" +#include "WM_toolsystem.h" /* see WM_types.h */ const EnumPropertyItem rna_enum_operator_context_items[] = { @@ -113,7 +115,7 @@ static bool panel_poll(const bContext *C, PanelType *pt) ParameterList list; FunctionRNA *func; void *ret; - int visible; + bool visible; RNA_pointer_create(NULL, pt->ext.srna, NULL, &ptr); /* dummy */ func = &rna_Panel_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ @@ -166,6 +168,24 @@ static void panel_draw_header(const bContext *C, Panel *pnl) RNA_parameter_list_free(&list); } +static void panel_draw_header_preset(const bContext *C, Panel *pnl) +{ + extern FunctionRNA rna_Panel_draw_header_preset_func; + + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->ext.srna, pnl, &ptr); + func = &rna_Panel_draw_header_preset_func; + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + pnl->type->ext.call((bContext *)C, &ptr, func, &list); + + RNA_parameter_list_free(&list); +} + static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type) { ARegionType *art; @@ -179,6 +199,19 @@ static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type) RNA_struct_free_extension(type, &pt->ext); RNA_struct_free(&BLENDER_RNA, type); + if (pt->parent) { + LinkData *link = BLI_findptr(&pt->parent->children, pt, offsetof(LinkData, data)); + BLI_freelinkN(&pt->parent->children, link); + } + + WM_paneltype_remove(pt); + + for (LinkData *link = pt->children.first; link; link = link->next) { + PanelType *child_pt = link->data; + child_pt->parent = NULL; + } + + BLI_freelistN(&pt->children); BLI_freelinkN(&art->paneltypes, pt); /* update while blender is running */ @@ -190,10 +223,10 @@ static StructRNA *rna_Panel_register( StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; - PanelType *pt, dummypt = {NULL}; + PanelType *pt, *parent = NULL, dummypt = {NULL}; Panel dummypanel = {NULL}; PointerRNA dummyptr; - int have_function[3]; + int have_function[4]; /* setup dummy panel & panel type to store static properties in */ dummypanel.type = &dummypt; @@ -212,9 +245,20 @@ static StructRNA *rna_Panel_register( return NULL; } - if ((dummypt.category[0] == '\0') && (dummypt.region_type == RGN_TYPE_TOOLS)) { - /* Use a fallback, otherwise an empty value will draw the panel in every category. */ - strcpy(dummypt.category, PNL_CATEGORY_FALLBACK); + if ((1 << dummypt.region_type) & RGN_TYPE_HAS_CATEGORY_MASK) { + if (dummypt.category[0] == '\0') { + /* Use a fallback, otherwise an empty value will draw the panel in every category. */ + strcpy(dummypt.category, PNL_CATEGORY_FALLBACK); + } + } + else { + if (dummypt.category[0] != '\0') { + if ((1 << dummypt.space_type) & WM_TOOLSYSTEM_SPACE_MASK) { + BKE_reportf(reports, RPT_ERROR, "Registering panel class: '%s' has category '%s' ", + dummypt.idname, dummypt.category); + return NULL; + } + } } if (!(art = region_type_find(reports, dummypt.space_type, dummypt.region_type))) @@ -229,6 +273,10 @@ static StructRNA *rna_Panel_register( BLI_freelinkN(&art->paneltypes, pt); break; } + + if (dummypt.parent_id[0] && STREQ(pt->idname, dummypt.parent_id)) { + parent = pt; + } } if (!RNA_struct_available_or_report(reports, dummypt.idname)) { return NULL; @@ -236,6 +284,11 @@ static StructRNA *rna_Panel_register( if (!RNA_struct_bl_idname_ok_or_report(reports, dummypt.idname, "_PT_")) { return NULL; } + if (dummypt.parent_id[0] && !parent) { + BKE_reportf(reports, RPT_ERROR, "Registering panel class: parent '%s' for '%s' not found", + dummypt.parent_id, dummypt.idname); + return NULL; + } /* create a new panel type */ pt = MEM_callocN(sizeof(PanelType), "python buttons panel"); @@ -252,6 +305,7 @@ static StructRNA *rna_Panel_register( pt->poll = (have_function[0]) ? panel_poll : NULL; pt->draw = (have_function[1]) ? panel_draw : NULL; pt->draw_header = (have_function[2]) ? panel_draw_header : NULL; + pt->draw_header_preset = (have_function[3]) ? panel_draw_header_preset : NULL; /* XXX use "no header" flag for some ordering of panels until we have real panel ordering */ if (pt->flag & PNL_NO_HEADER) { @@ -267,6 +321,20 @@ static StructRNA *rna_Panel_register( else BLI_addtail(&art->paneltypes, pt); + if (parent) { + pt->parent = parent; + BLI_addtail(&parent->children, BLI_genericNodeN(pt)); + } + + { + const char *owner_id = RNA_struct_state_owner_get(); + if (owner_id) { + BLI_strncpy(pt->owner_id, owner_id, sizeof(pt->owner_id)); + } + } + + WM_paneltype_add(pt); + /* update while blender is running */ WM_main_add_notifier(NC_WINDOW, NULL); @@ -323,7 +391,7 @@ static void uilist_draw_item(uiList *ui_list, bContext *C, uiLayout *layout, Poi RNA_parameter_list_free(&list); } -static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout) +static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout, bool reverse) { extern FunctionRNA rna_UIList_draw_filter_func; @@ -337,6 +405,7 @@ static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout) RNA_parameter_list_create(&list, &ul_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "layout", &layout); + RNA_parameter_set_lookup(&list, "reverse", &reverse); ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list); RNA_parameter_list_free(&list); @@ -561,7 +630,7 @@ static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type) if (!ht) return; - if (!(art = region_type_find(NULL, ht->space_type, RGN_TYPE_HEADER))) + if (!(art = region_type_find(NULL, ht->space_type, ht->region_type))) return; RNA_struct_free_extension(type, &ht->ext); @@ -585,6 +654,7 @@ static StructRNA *rna_Header_register( /* setup dummy header & header type to store static properties in */ dummyheader.type = &dummyht; + dummyht.region_type = RGN_TYPE_HEADER; /* RGN_TYPE_HEADER by default, may be overridden */ RNA_pointer_create(NULL, &RNA_Header, &dummyheader, &dummyhtr); /* validate the python class */ @@ -597,7 +667,7 @@ static StructRNA *rna_Header_register( return NULL; } - if (!(art = region_type_find(reports, dummyht.space_type, RGN_TYPE_HEADER))) + if (!(art = region_type_find(reports, dummyht.space_type, dummyht.region_type))) return NULL; /* check if we have registered this header type before, and remove it */ @@ -773,6 +843,13 @@ static StructRNA *rna_Menu_register( mt->poll = (have_function[0]) ? menu_poll : NULL; mt->draw = (have_function[1]) ? menu_draw : NULL; + { + const char *owner_id = RNA_struct_state_owner_get(); + if (owner_id) { + BLI_strncpy(mt->owner_id, owner_id, sizeof(mt->owner_id)); + } + } + WM_menutype_add(mt); /* update while blender is running */ @@ -889,6 +966,56 @@ static void rna_UILayout_scale_y_set(PointerRNA *ptr, float value) uiLayoutSetScaleY(ptr->data, value); } +static float rna_UILayout_units_x_get(PointerRNA *ptr) +{ + return uiLayoutGetUnitsX(ptr->data); +} + +static void rna_UILayout_units_x_set(PointerRNA *ptr, float value) +{ + uiLayoutSetUnitsX(ptr->data, value); +} + +static float rna_UILayout_units_y_get(PointerRNA *ptr) +{ + return uiLayoutGetUnitsY(ptr->data); +} + +static void rna_UILayout_units_y_set(PointerRNA *ptr, float value) +{ + uiLayoutSetUnitsY(ptr->data, value); +} + +static int rna_UILayout_emboss_get(PointerRNA *ptr) +{ + return uiLayoutGetEmboss(ptr->data); +} + +static void rna_UILayout_emboss_set(PointerRNA *ptr, int value) +{ + uiLayoutSetEmboss(ptr->data, value); +} + +static bool rna_UILayout_property_split_get(PointerRNA *ptr) +{ + return uiLayoutGetPropSep(ptr->data); +} + +static void rna_UILayout_property_split_set(PointerRNA *ptr, bool value) +{ + uiLayoutSetPropSep(ptr->data, value); +} + +static bool rna_UILayout_property_decorate_get(PointerRNA *ptr) +{ + return uiLayoutGetPropDecorate(ptr->data); +} + +static void rna_UILayout_property_decorate_set(PointerRNA *ptr, bool value) +{ + uiLayoutSetPropDecorate(ptr->data, value); +} + #else /* RNA_RUNTIME */ static void rna_def_ui_layout(BlenderRNA *brna) @@ -904,6 +1031,14 @@ static void rna_def_ui_layout(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static const EnumPropertyItem emboss_items[] = { + {UI_EMBOSS, "NORMAL", 0, "Normal", "Draw standard button emboss style"}, + {UI_EMBOSS_NONE, "NONE", 0, "None", "Draw only text and icons"}, + {UI_EMBOSS_PULLDOWN, "PULLDOWN_MENU", 0, "Pulldown Menu", "Draw pulldown menu style"}, + {UI_EMBOSS_RADIAL, "RADIAL_MENU", 0, "Radial Menu", "Draw radial menu style"}, + {0, NULL, 0, NULL, NULL} + }; + /* layout */ srna = RNA_def_struct(brna, "UILayout", NULL); @@ -940,7 +1075,25 @@ static void rna_def_ui_layout(BlenderRNA *brna) prop = RNA_def_property(srna, "scale_y", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_funcs(prop, "rna_UILayout_scale_y_get", "rna_UILayout_scale_y_set", NULL); RNA_def_property_ui_text(prop, "Scale Y", "Scale factor along the Y for items in this (sub)layout"); + + prop = RNA_def_property(srna, "ui_units_x", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_funcs(prop, "rna_UILayout_units_x_get", "rna_UILayout_units_x_set", NULL); + RNA_def_property_ui_text(prop, "Units X", "Fixed Size along the X for items in this (sub)layout"); + + prop = RNA_def_property(srna, "ui_units_y", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_funcs(prop, "rna_UILayout_units_y_get", "rna_UILayout_units_y_set", NULL); + RNA_def_property_ui_text(prop, "Units Y", "Fixed Size along the Y for items in this (sub)layout"); RNA_api_ui_layout(srna); + + prop = RNA_def_property(srna, "emboss", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, emboss_items); + RNA_def_property_enum_funcs(prop, "rna_UILayout_emboss_get", "rna_UILayout_emboss_set", NULL); + + prop = RNA_def_property(srna, "use_property_split", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_UILayout_property_split_get", "rna_UILayout_property_split_set"); + + prop = RNA_def_property(srna, "use_property_decorate", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_UILayout_property_decorate_get", "rna_UILayout_property_decorate_set"); } static void rna_def_panel(BlenderRNA *brna) @@ -988,6 +1141,12 @@ static void rna_def_panel(BlenderRNA *brna) parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + func = RNA_def_function(srna, "draw_header_preset", NULL); + RNA_def_function_ui_description(func, "Draw UI elements for presets in the panel's header"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "UILayout"); RNA_def_property_ui_text(prop, "Layout", "Defines the structure of the panel in the UI"); @@ -1023,6 +1182,10 @@ static void rna_def_panel(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "type->category"); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->owner_id"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type->space_type"); RNA_def_property_enum_items(prop, rna_enum_space_type_items); @@ -1048,11 +1211,26 @@ static void rna_def_panel(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG); RNA_def_property_ui_text(prop, "Options", "Options for this panel type"); + prop = RNA_def_property(srna, "bl_parent_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->parent_id"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_def_property_ui_text(prop, "Parent ID Name", "If this is set, the panel becomes a subpanel"); + + prop = RNA_def_property(srna, "bl_ui_units_x", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "type->ui_units_x"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_def_property_ui_text(prop, "Units X", "When set, defines popup panel width"); + prop = RNA_def_property(srna, "use_pin", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_PIN); RNA_def_property_ui_text(prop, "Pin", ""); /* XXX, should only tag region for redraw */ RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop = RNA_def_property(srna, "is_popover", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_POPOVER); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Popover", ""); } static void rna_def_uilist(BlenderRNA *brna) @@ -1143,6 +1321,7 @@ static void rna_def_uilist(BlenderRNA *brna) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_pointer(func, "layout", "UILayout", "", "Layout to draw the item"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + RNA_def_boolean(func, "reverse", false, "", "Display items in reverse order"); /* filter */ func = RNA_def_function(srna, "filter_items", NULL); @@ -1222,6 +1401,14 @@ static void rna_def_header(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER); RNA_def_property_ui_text(prop, "Space type", "The space where the header is going to be used in"); + prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->region_type"); + RNA_def_property_enum_default(prop, RGN_TYPE_HEADER); + RNA_def_property_enum_items(prop, rna_enum_region_type_items); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_def_property_ui_text(prop, "Region Type", "The region where the header is going to be used in " + "(defaults to header region)"); + RNA_define_verify_sdna(1); } @@ -1290,6 +1477,10 @@ static void rna_def_menu(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */ + prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->owner_id"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_define_verify_sdna(1); } diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index d647876796a..4d361920dcb 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -47,16 +47,14 @@ #include "rna_internal.h" -#define DEF_ICON_BLANK_SKIP #define DEF_ICON(name) {ICON_##name, (#name), 0, (#name), ""}, -#define DEF_VICO(name) {VICO_##name, (#name), 0, (#name), ""}, +#define DEF_ICON_VECTOR(name) {ICON_##name, (#name), 0, (#name), ""}, +#define DEF_ICON_COLOR(name) {ICON_##name, (#name), 0, (#name), ""}, +#define DEF_ICON_BLANK(name) const EnumPropertyItem rna_enum_icon_items[] = { #include "UI_icons.h" {0, NULL, 0, NULL, NULL} }; -#undef DEF_ICON_BLANK_SKIP -#undef DEF_ICON -#undef DEF_VICO #ifdef RNA_RUNTIME @@ -142,6 +140,25 @@ static void rna_uiItemMenuEnumR( uiItemMenuEnumR_prop(layout, ptr, prop, name, icon); } +static void rna_uiItemTabsEnumR( + uiLayout *layout, bContext *C, + struct PointerRNA *ptr, const char *propname, + bool icon_only) +{ + PropertyRNA *prop = RNA_struct_find_property(ptr, propname); + + if (!prop) { + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); + return; + } + if (RNA_property_type(prop) != PROP_ENUM) { + RNA_warning("property is not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname); + return; + } + + uiItemTabsEnumR_prop(layout, C, ptr, prop, icon_only); +} + static void rna_uiItemEnumR_string( uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, const char *text_ctxt, bool translate, int icon) @@ -277,6 +294,28 @@ static void rna_uiItemM( uiItemM(layout, menuname, name, icon); } +static void rna_uiItemPopoverPanel( + uiLayout *layout, bContext *C, + const char *panel_type, const char *name, const char *text_ctxt, + bool translate, int icon, int icon_value) +{ + /* Get translated name (label). */ + name = rna_translate_ui_text(name, text_ctxt, NULL, NULL, translate); + + if (icon_value && !icon) { + icon = icon_value; + } + + uiItemPopoverPanel(layout, C, panel_type, name, icon); +} + +static void rna_uiItemPopoverPanelFromGroup( + uiLayout *layout, bContext *C, + int space_id, int region_id, const char *context, const char *category) +{ + uiItemPopoverPanelFromGroup(layout, C, space_id, region_id, context, category); +} + static void rna_uiTemplateAnyID( uiLayout *layout, PointerRNA *ptr, const char *propname, const char *proptypename, const char *name, const char *text_ctxt, bool translate) @@ -497,6 +536,19 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_return(func, parm); RNA_def_boolean(func, "align", false, "", "Align buttons to each other"); + func = RNA_def_function(srna, "grid_flow", "uiLayoutGridFlow"); + RNA_def_boolean(func, "row_major", false, "", "Fill row by row, instead of column by column"); + RNA_def_int(func, "columns", 0, INT_MIN, INT_MAX, "", + "Number of columns, positive are absolute fixed numbers, 0 is automatic, negative are " + "automatic multiple numbers along major axis (e.g. -2 will only produce 2, 4, 6 etc. " + "columns for row major layout, and 2, 4, 6 etc. rows for column major layout)", + INT_MIN, INT_MAX); + RNA_def_boolean(func, "even_columns", false, "", "All columns will have the same width"); + RNA_def_boolean(func, "even_rows", false, "", "All rows will have the same height"); + RNA_def_boolean(func, "align", false, "", "Align buttons to each other"); + parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in"); + RNA_def_function_return(func, parm); + /* box layout */ func = RNA_def_function(srna, "box", "uiLayoutBox"); parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in"); @@ -508,7 +560,10 @@ void RNA_api_ui_layout(StructRNA *srna) func = RNA_def_function(srna, "split", "uiLayoutSplit"); parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in"); RNA_def_function_return(func, parm); - RNA_def_float(func, "percentage", 0.0f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at", 0.0f, 1.0f); + RNA_def_float( + func, "factor", 0.0f, 0.0f, 1.0f, "Percentage", + "Percentage of width to split at (leave unset for automatic calculation)", + 0.0f, 1.0f); RNA_def_boolean(func, "align", false, "", "Align buttons to each other"); /* radial/pie layout */ @@ -581,6 +636,11 @@ void RNA_api_ui_layout(StructRNA *srna) api_ui_item_rna_common(func); api_ui_item_common(func); + func = RNA_def_function(srna, "prop_tabs_enum", "rna_uiItemTabsEnumR"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + api_ui_item_rna_common(func); + RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text"); + func = RNA_def_function(srna, "prop_enum", "rna_uiItemEnumR_string"); api_ui_item_rna_common(func); parm = RNA_def_string(func, "value", NULL, 0, "", "Enum property value"); @@ -681,8 +741,34 @@ void RNA_api_ui_layout(StructRNA *srna) parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED); RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item"); - func = RNA_def_function(srna, "separator", "uiItemS"); + func = RNA_def_function(srna, "popover", "rna_uiItemPopoverPanel"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + parm = RNA_def_string(func, "panel", NULL, 0, "", "Identifier of the panel"); + api_ui_item_common(func); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED); + RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item"); + + func = RNA_def_function(srna, "popover_group", "rna_uiItemPopoverPanelFromGroup"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + parm = RNA_def_enum(func, "space_type", rna_enum_space_type_items, 0, "Space Type", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_enum(func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_string(func, "context", NULL, 0, "", "panel type context"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_string(func, "category", NULL, 0, "", "panel type category"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + func = RNA_def_function(srna, "separator", "uiItemS_ex"); RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items"); + RNA_def_float( + func, "factor", 1.0f, 0.0f, FLT_MAX, "Percentage", + "Percentage of width to space (leave unset for default space)", + 0.0f, FLT_MAX); + + func = RNA_def_function(srna, "separator_spacer", "uiItemSpacer"); + RNA_def_function_ui_description(func, "Item. Inserts horizontal spacing empty space into the layout between items"); /* context */ func = RNA_def_function(srna, "context_pointer_set", "uiLayoutSetContextPointer"); @@ -704,6 +790,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_string(func, "unlink", NULL, 0, "", "Operator identifier to unlink the ID block"); RNA_def_enum(func, "filter", id_template_filter_items, UI_TEMPLATE_ID_FILTER_ALL, "", "Optionally limit the items which can be selected"); + RNA_def_boolean(func, "live_icon", false, "", "Show preview instead of fixed icon"); func = RNA_def_function(srna, "template_ID_preview", "uiTemplateIDPreview"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); @@ -715,6 +802,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX); RNA_def_enum(func, "filter", id_template_filter_items, UI_TEMPLATE_ID_FILTER_ALL, "", "Optionally limit the items which can be selected"); + RNA_def_boolean(func, "hide_buttons", false, "", "Show only list, no buttons"); func = RNA_def_function(srna, "template_any_ID", "rna_uiTemplateAnyID"); parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property"); @@ -726,6 +814,38 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); api_ui_item_common_text(func); + func = RNA_def_function(srna, "template_ID_tabs", "uiTemplateIDTabs"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + api_ui_item_rna_common(func); + RNA_def_string(func, "new", NULL, 0, "", "Operator identifier to create a new ID block"); + RNA_def_string(func, "menu", NULL, 0, "", "Context menu identifier"); + RNA_def_enum(func, "filter", id_template_filter_items, UI_TEMPLATE_ID_FILTER_ALL, + "", "Optionally limit the items which can be selected"); + + func = RNA_def_function(srna, "template_search", "uiTemplateSearch"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + api_ui_item_rna_common(func); + parm = RNA_def_pointer(func, "search_data", "AnyType", "", "Data from which to take collection to search in"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + parm = RNA_def_string(func, "search_property", NULL, 0, "", "Identifier of search collection property"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_string(func, "new", NULL, 0, "", "Operator identifier to create a new item for the collection"); + RNA_def_string(func, "unlink", NULL, 0, "", "Operator identifier to unlink or delete the active " + "item from the collection"); + + func = RNA_def_function(srna, "template_search_preview", "uiTemplateSearchPreview"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + api_ui_item_rna_common(func); + parm = RNA_def_pointer(func, "search_data", "AnyType", "", "Data from which to take collection to search in"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + parm = RNA_def_string(func, "search_property", NULL, 0, "", "Identifier of search collection property"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_string(func, "new", NULL, 0, "", "Operator identifier to create a new item for the collection"); + RNA_def_string(func, "unlink", NULL, 0, "", "Operator identifier to unlink or delete the active " + "item from the collection"); + RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX); + RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX); + func = RNA_def_function(srna, "template_path_builder", "rna_uiTemplatePathBuilder"); parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); @@ -743,6 +863,31 @@ void RNA_api_ui_layout(StructRNA *srna) parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "template_greasepencil_modifier", "uiTemplateGpencilModifier"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Generates the UI layout for grease pencil modifiers"); + parm = RNA_def_pointer(func, "data", "GpencilModifier", "", "Modifier data"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "template_shaderfx", "uiTemplateShaderFx"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Generates the UI layout for shader effect"); + parm = RNA_def_pointer(func, "data", "ShaderFx", "", "Shader data"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "template_greasepencil_color", "uiTemplateGpencilColorPreview"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + api_ui_item_rna_common(func); + RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX); + RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX); + RNA_def_float(func, "scale", 1.0f, 0.1f, 1.5f, "Scale of the image thumbnails", "", 0.5f, 1.0f); + RNA_def_enum(func, "filter", id_template_filter_items, UI_TEMPLATE_ID_FILTER_ALL, + "", "Optionally limit the items which can be selected"); + func = RNA_def_function(srna, "template_constraint", "uiTemplateConstraint"); RNA_def_function_ui_description(func, "Generates the UI layout for constraints"); parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data"); @@ -751,7 +896,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "template_preview", "uiTemplatePreview"); - RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lamps or worlds"); + RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lights or worlds"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "id", "ID", "", "ID data-block"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -763,18 +908,25 @@ void RNA_api_ui_layout(StructRNA *srna) "(i.e. all previews of materials without explicit ID will have the same size...)"); func = RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping"); - RNA_def_function_ui_description(func, "Item. A curve mapping widget used for e.g falloff curves for lamps"); + RNA_def_function_ui_description(func, "Item. A curve mapping widget used for e.g falloff curves for lights"); api_ui_item_rna_common(func); RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display"); RNA_def_boolean(func, "levels", false, "", "Show black/white levels"); RNA_def_boolean(func, "brush", false, "", "Show brush options"); RNA_def_boolean(func, "use_negative_slope", false, "", "Use a negative slope by default"); + RNA_def_boolean(func, "show_tone", false, "", "Show tone options"); func = RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp"); RNA_def_function_ui_description(func, "Item. A color ramp widget"); api_ui_item_rna_common(func); RNA_def_boolean(func, "expand", false, "", "Expand button to show more detail"); + func = RNA_def_function(srna, "template_icon", "uiTemplateIcon"); + RNA_def_function_ui_description(func, "Display a large icon"); + parm = RNA_def_int(func, "icon_value", 0, 0, INT_MAX, "Icon to display", "", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_float(func, "scale", 1.0f, 1.0f, 100.0f, "Scale", "Scale the icon size (by the button size)", 1.0f, 100.0f); + func = RNA_def_function(srna, "template_icon_view", "uiTemplateIconView"); RNA_def_function_ui_description(func, "Enum. Large widget showing Icon previews"); api_ui_item_rna_common(func); @@ -880,10 +1032,11 @@ void RNA_api_ui_layout(StructRNA *srna) parm = RNA_def_string(func, "list_id", NULL, 0, "", "Identifier of this list widget (mandatory when using default \"" UI_UL_DEFAULT_CLASS_NAME "\" class). " - "If this is set, the uilist gets a custom ID, otherwise it takes the " + "If this not an empty string, the uilist gets a custom ID, otherwise it takes the " "name of the class used to define the uilist (for example, if the " "class name is \"OBJECT_UL_vgroups\", and list_id is not set by the " "script, then bl_idname = \"OBJECT_UL_vgroups\")"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_pointer(func, "dataptr", "AnyType", "", "Data from which to take the Collection property"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR); parm = RNA_def_string(func, "propname", NULL, 0, "", "Identifier of the Collection property in data"); @@ -900,6 +1053,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_int(func, "maxrows", 5, 0, INT_MAX, "", "Default maximum number of rows to display", 0, INT_MAX); RNA_def_enum(func, "type", rna_enum_uilist_layout_type_items, UILST_LAYOUT_DEFAULT, "Type", "Type of layout to use"); RNA_def_int(func, "columns", 9, 0, INT_MAX, "", "Number of items to display per row, for GRID layout", 0, INT_MAX); + RNA_def_boolean(func, "reverse", false, "", "Display items in reverse order"); func = RNA_def_function(srna, "template_running_jobs", "uiTemplateRunningJobs"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); @@ -910,6 +1064,9 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Inserts common 3DView header UI (selectors for context mode, shading, etc.)"); + func = RNA_def_function(srna, "template_header_3D_mode", "uiTemplateHeader3D_mode"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, ""); func = RNA_def_function(srna, "template_edit_mode_selection", "uiTemplateEditModeSelection"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); @@ -918,6 +1075,9 @@ void RNA_api_ui_layout(StructRNA *srna) func = RNA_def_function(srna, "template_reports_banner", "uiTemplateReportsBanner"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func = RNA_def_function(srna, "template_input_status", "uiTemplateInputStatus"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + func = RNA_def_function(srna, "template_node_link", "uiTemplateNodeLink"); parm = RNA_def_pointer(func, "ntree", "NodeTree", "", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -971,6 +1131,12 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_ui_description(func, "Item(s). User interface for selecting cache files and their source paths"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); api_ui_item_rna_common(func); + + func = RNA_def_function(srna, "template_recent_files", "uiTemplateRecentFiles"); + RNA_def_function_ui_description(func, "Show list of recently saved .blend files"); + RNA_def_int(func, "rows", 5, 1, INT_MAX, "", "Maximum number of items to show", 1, INT_MAX); + parm = RNA_def_int(func, "found", 0, 0, INT_MAX, "", "Number of items drawn", 0, INT_MAX); + RNA_def_function_return(func, parm); } #endif diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index c3e30de10af..1ea5c164449 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -36,11 +36,12 @@ #include "BLI_utildefines.h" #include "BLI_math_base.h" +#include "BLI_math_vector.h" #include "BKE_appdir.h" -#include "BKE_DerivedMesh.h" #include "BKE_sound.h" #include "BKE_addon.h" +#include "BKE_studiolight.h" #include "RNA_access.h" #include "RNA_define.h" @@ -52,7 +53,6 @@ #include "WM_types.h" #include "BLT_lang.h" -#include "GPU_buffers.h" #ifdef WITH_OPENSUBDIV static const EnumPropertyItem opensubdiv_compute_type_items[] = { @@ -68,16 +68,7 @@ static const EnumPropertyItem opensubdiv_compute_type_items[] = { #endif static const EnumPropertyItem audio_device_items[] = { - {0, "NONE", 0, "None", "Null device - there will be no audio output"}, -#ifdef WITH_SDL - {1, "SDL", 0, "SDL", "SDL device - simple direct media layer, recommended for sequencer usage"}, -#endif -#ifdef WITH_OPENAL - {2, "OPENAL", 0, "OpenAL", "OpenAL device - supports 3D audio, recommended for game engine usage"}, -#endif -#ifdef WITH_JACK - {3, "JACK", 0, "JACK", "JACK Audio Connection Kit, recommended for pro audio users"}, -#endif + {0, "Null", 0, "None", "Null device - there will be no audio output"}, {0, NULL, 0, NULL, NULL} }; @@ -87,6 +78,7 @@ const EnumPropertyItem rna_enum_navigation_mode_items[] = { {0, NULL, 0, NULL, NULL} }; + #if defined(WITH_INTERNATIONAL) || !defined(RNA_RUNTIME) static const EnumPropertyItem rna_enum_language_default_items[] = { {0, "DEFAULT", 0, "Default (Default)", ""}, @@ -94,19 +86,29 @@ static const EnumPropertyItem rna_enum_language_default_items[] = { }; #endif +static const EnumPropertyItem rna_enum_studio_light_orientation_items[] = { + {STUDIOLIGHT_ORIENTATION_CAMERA, "CAMERA", 0, "Camera", ""}, + {STUDIOLIGHT_ORIENTATION_WORLD, "WORLD", 0, "World", ""}, + {STUDIOLIGHT_ORIENTATION_VIEWNORMAL, "MATCAP", 0, "MatCap", ""}, + {0, NULL, 0, NULL, NULL} +}; + + #ifdef RNA_RUNTIME #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "BKE_blender.h" -#include "BKE_depsgraph.h" #include "BKE_global.h" -#include "BKE_main.h" #include "BKE_idprop.h" +#include "BKE_main.h" +#include "BKE_mesh_runtime.h" #include "BKE_pbvh.h" #include "BKE_paint.h" +#include "DEG_depsgraph.h" + #include "GPU_draw.h" #include "GPU_select.h" @@ -140,17 +142,11 @@ static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe } /* also used by buffer swap switching */ -static void rna_userdef_dpi_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +static void rna_userdef_dpi_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { /* font's are stored at each DPI level, without this we can easy load 100's of fonts */ BLF_cache_clear(); - /* force setting drawable again */ - wmWindowManager *wm = bmain->wm.first; - if (wm) { - wm->windrawable = NULL; - } - WM_main_add_notifier(NC_WINDOW, NULL); /* full redraw */ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); /* refresh region sizes */ } @@ -168,34 +164,6 @@ static void rna_userdef_language_update(Main *UNUSED(bmain), Scene *UNUSED(scene UI_reinit_font(); } -static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - UserDef *userdef = (UserDef *)ptr->data; - - /* lame, loop over all views and set */ - bScreen *sc; - ScrArea *sa; - SpaceLink *sl; - - /* from scene copy to the other views */ - for (sc = bmain->screen.first; sc; sc = sc->id.next) { - for (sa = sc->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_VIEW3D) { - View3D *v3d = (View3D *)sl; - if (userdef->tw_flag & V3D_USE_MANIPULATOR) - v3d->twflag |= V3D_USE_MANIPULATOR; - else - v3d->twflag &= ~V3D_USE_MANIPULATOR; - } - } - } - } - - rna_userdef_update(bmain, scene, ptr); -} - - static void rna_userdef_script_autoexec_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { UserDef *userdef = (UserDef *)ptr->data; @@ -210,12 +178,6 @@ static void rna_userdef_load_ui_update(Main *UNUSED(bmain), Scene *UNUSED(scene) else G.fileflags &= ~G_FILE_NO_UI; } -static void rna_userdef_mipmap_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - GPU_set_mipmap(bmain, !(U.gameflags & USER_DISABLE_MIPMAP)); - rna_userdef_update(bmain, scene, ptr); -} - static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA *ptr) { GPU_set_anisotropic(bmain, U.anisotropic_filter); @@ -366,12 +328,9 @@ static void rna_UserDef_weight_color_update(Main *bmain, Scene *scene, PointerRN { Object *ob; - bTheme *btheme = UI_GetTheme(); - vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, btheme->tv3d.vertex_unreferenced); - for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->mode & OB_MODE_WEIGHT_PAINT) - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } rna_userdef_update(bmain, scene, ptr); @@ -505,11 +464,7 @@ static void rna_userdef_opensubdiv_update(Main *bmain, Scene *UNUSED(scene), Poi object; object = object->id.next) { - if (object->derivedFinal != NULL && - object->derivedFinal->type == DM_TYPE_CCGDM) - { - DAG_id_tag_update(&object->id, OB_RECALC_OB); - } + DEG_id_tag_update(&object->id, OB_RECALC_OB); } } @@ -522,7 +477,6 @@ static const EnumPropertyItem *rna_userdef_audio_device_itemf(bContext *UNUSED(C int totitem = 0; EnumPropertyItem *item = NULL; -#ifdef WITH_SYSTEM_AUDASPACE int i; char **names = BKE_sound_get_device_names(); @@ -531,30 +485,12 @@ static const EnumPropertyItem *rna_userdef_audio_device_itemf(bContext *UNUSED(C EnumPropertyItem new_item = {i, names[i], 0, names[i], names[i]}; RNA_enum_item_add(&item, &totitem, &new_item); } -#else - /* NONE */ - RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]); - -#ifdef WITH_SDL -# ifdef WITH_SDL_DYNLOAD - if (sdlewInit() == SDLEW_SUCCESS) -# endif - { - RNA_enum_item_add(&item, &totitem, &audio_device_items[index]); - } - index++; -#endif - -#ifdef WITH_OPENAL - RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]); -#endif -#ifdef WITH_JACK - if (BKE_sound_is_jack_supported()) { - RNA_enum_item_add(&item, &totitem, &audio_device_items[index]); +#ifndef NDEBUG + if (i == 0) { + EnumPropertyItem new_item = {i, "SOUND_NONE", 0, "No Sound", ""}; + RNA_enum_item_add(&item, &totitem, &new_item); } - index++; -#endif #endif /* may be unused */ @@ -674,6 +610,140 @@ static StructRNA *rna_AddonPref_refine(PointerRNA *ptr) return (ptr->type) ? ptr->type : &RNA_AddonPreferences; } +static float rna_ThemeUI_roundness_get(PointerRNA *ptr) +{ + /* Remap from relative radius to 0..1 range. */ + uiWidgetColors *tui = (uiWidgetColors *)ptr->data; + return tui->roundness * 2.0f; +} + +static void rna_ThemeUI_roundness_set(PointerRNA *ptr, float value) +{ + uiWidgetColors *tui = (uiWidgetColors *)ptr->data; + tui->roundness = value * 0.5f; +} + +/* Studio Light */ +static void rna_UserDef_studiolight_begin(CollectionPropertyIterator *iter, PointerRNA *UNUSED(ptr)) +{ + rna_iterator_listbase_begin(iter, BKE_studiolight_listbase(), NULL); +} + +static void rna_StudioLights_refresh(UserDef *UNUSED(userdef)) +{ + BKE_studiolight_refresh(); +} + +static void rna_StudioLights_remove(UserDef *UNUSED(userdef), StudioLight *studio_light) +{ + BKE_studiolight_remove(studio_light); +} + +static StudioLight *rna_StudioLights_new(UserDef *UNUSED(userdef), const char *path, int orientation) +{ + return BKE_studiolight_new(path, orientation); +} + +/* StudioLight.name */ +static void rna_UserDef_studiolight_name_get(PointerRNA *ptr, char *value) +{ + StudioLight *sl = (StudioLight *)ptr->data; + BLI_strncpy(value, sl->name, FILE_MAXFILE); +} + +static int rna_UserDef_studiolight_name_length(PointerRNA *ptr) +{ + StudioLight *sl = (StudioLight *)ptr->data; + return strlen(sl->name); +} + +/* StudioLight.path */ +static void rna_UserDef_studiolight_path_get(PointerRNA *ptr, char *value) +{ + StudioLight *sl = (StudioLight *)ptr->data; + BLI_strncpy(value, sl->path, FILE_MAX); +} + +static int rna_UserDef_studiolight_path_length(PointerRNA *ptr) +{ + StudioLight *sl = (StudioLight *)ptr->data; + return strlen(sl->path); +} + +/* StudioLight.path_irr_cache */ +static void rna_UserDef_studiolight_path_irr_cache_get(PointerRNA *ptr, char *value) +{ + StudioLight *sl = (StudioLight *)ptr->data; + if (sl->path_irr_cache) { + BLI_strncpy(value, sl->path_irr_cache, FILE_MAX); + } + else { + value[0] = '\0'; + } +} + +static int rna_UserDef_studiolight_path_irr_cache_length(PointerRNA *ptr) +{ + StudioLight *sl = (StudioLight *)ptr->data; + if (sl->path_irr_cache) { + return strlen(sl->path_irr_cache); + } + return 0; +} + +/* StudioLight.path_sh_cache */ +static void rna_UserDef_studiolight_path_sh_cache_get(PointerRNA *ptr, char *value) +{ + StudioLight *sl = (StudioLight *)ptr->data; + if (sl->path_sh_cache) { + BLI_strncpy(value, sl->path_sh_cache, FILE_MAX); + } + else { + value[0] = '\0'; + } +} + +static int rna_UserDef_studiolight_path_sh_cache_length(PointerRNA *ptr) +{ + StudioLight *sl = (StudioLight *)ptr->data; + if (sl->path_sh_cache) { + return strlen(sl->path_sh_cache); + } + return 0; +} + +/* StudioLight.index */ +static int rna_UserDef_studiolight_index_get(PointerRNA *ptr) +{ + StudioLight *sl = (StudioLight *)ptr->data; + return sl->index; +} + +/* StudioLight.is_user_defined */ +static bool rna_UserDef_studiolight_is_user_defined_get(PointerRNA *ptr) +{ + StudioLight *sl = (StudioLight *)ptr->data; + return (sl->flag & STUDIOLIGHT_USER_DEFINED) != 0; +} + +/* StudioLight.orientation */ + +static int rna_UserDef_studiolight_orientation_get(PointerRNA *ptr) +{ + StudioLight *sl = (StudioLight *)ptr->data; + return sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS; +} + +static void rna_UserDef_studiolight_spherical_harmonics_coefficients_get(PointerRNA *ptr, float *values) +{ + StudioLight *sl = (StudioLight *)ptr->data; + float *value = values; + for (int i = 0; i < STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS; i++) { + copy_v3_v3(value, sl->spherical_harmonics_coefs[i]); + value += 3; + } +} + #else /* TODO(sergey): This technically belongs to blenlib, but we don't link @@ -844,6 +914,11 @@ static void rna_def_userdef_theme_ui_wcol(BlenderRNA *brna) RNA_def_property_range(prop, -100, 100); RNA_def_property_ui_text(prop, "Shade Down", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "roundness", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_ThemeUI_roundness_get", "rna_ThemeUI_roundness_set", NULL); + RNA_def_property_ui_text(prop, "Roundness", "Amount of edge rounding"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); } static void rna_def_userdef_theme_ui_wcol_state(BlenderRNA *brna) @@ -886,6 +961,16 @@ static void rna_def_userdef_theme_ui_wcol_state(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Driven Selected", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "inner_overridden", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Overridden", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "inner_overridden_sel", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Overridden Selected", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "blend", PROP_FLOAT, PROP_FACTOR); RNA_def_property_ui_text(prop, "Blend", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); @@ -909,12 +994,8 @@ static void rna_def_userdef_theme_ui_panel(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Background", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "show_header", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_ui_text(prop, "Show Header", ""); - RNA_def_property_update(prop, 0, "rna_userdef_update"); - - prop = RNA_def_property(srna, "show_back", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_ui_text(prop, "Show Background", ""); + prop = RNA_def_property(srna, "sub_back", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_ui_text(prop, "Sub Background", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); } @@ -969,6 +1050,11 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Tool Widget Colors", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "wcol_toolbar_item", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_ui_text(prop, "Toolbar Item Widget Colors", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "wcol_radio", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_ui_text(prop, "Radio Widget Colors", ""); @@ -1054,6 +1140,11 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "State Colors", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "wcol_tab", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_ui_text(prop, "Tab Colors", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "menu_shadow_fac", PROP_FLOAT, PROP_FACTOR); RNA_def_property_ui_text(prop, "Menu Shadow Strength", "Blending factor for menu shadows"); RNA_def_property_range(prop, 0.01f, 1.0f); @@ -1073,12 +1164,22 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Icon Alpha", "Transparency of icons in the interface, to reduce contrast"); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "icon_saturation", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_ui_text(prop, "Icon Saturation", "Saturation of icons in the interface"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "widget_emboss", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "widget_emboss"); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Widget Emboss", "Color of the 1px shadow line underlying widgets"); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "editor_outline", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "editor_outline"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Editor Outline", "Color of the outline of the editors and their round corners"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + /* axis */ prop = RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "xaxis"); @@ -1097,6 +1198,68 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Z Axis", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + + /* Generic gizmo colors. */ + prop = RNA_def_property(srna, "gizmo_hi", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_hi"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Gizmo Highlight", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "gizmo_primary", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_primary"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Gizmo Primary", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "gizmo_secondary", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_secondary"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Gizmo Secondary", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "gizmo_a", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_a"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Gizmo A", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "gizmo_b", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gizmo_b"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Gizmo B", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + /* Icon colors. */ + prop = RNA_def_property(srna, "icon_collection", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "icon_collection"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Collection", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "icon_object", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "icon_object"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Object", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "icon_object_data", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "icon_object_data"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Object Data", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "icon_modifier", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "icon_modifier"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Modifier", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "icon_shading", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "icon_shading"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Shading", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); } static void rna_def_userdef_theme_space_common(StructRNA *srna) @@ -1120,7 +1283,7 @@ static void rna_def_userdef_theme_space_common(StructRNA *srna) /* header */ prop = RNA_def_property(srna, "header", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Header", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); @@ -1162,6 +1325,11 @@ static void rna_def_userdef_theme_space_common(StructRNA *srna) RNA_def_property_ui_text(prop, "Region Text Highlight", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "navigation_bar", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Navigation Bar Background", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + /* tabs */ prop = RNA_def_property(srna, "tab_active", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); @@ -1300,7 +1468,7 @@ static void rna_def_userdef_theme_spaces_vertex(StructRNA *srna) RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "vertex_size", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 1, 10); + RNA_def_property_range(prop, 1, 32); RNA_def_property_ui_text(prop, "Vertex Size", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); @@ -1522,7 +1690,7 @@ static void rna_def_userdef_theme_spaces_curves(StructRNA *srna, bool incl_nurbs RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "handle_vertex_size", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 0, 255); + RNA_def_property_range(prop, 1, 100); RNA_def_property_ui_text(prop, "Handle Vertex Size", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); } @@ -1565,7 +1733,7 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) /* General Viewport options */ prop = RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Grid", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); @@ -1581,7 +1749,7 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "wire_edit", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Wire Edit", ""); + RNA_def_property_ui_text(prop, "Wire Edit", "Color for wireframe when in edit mode, but edge selection is active"); RNA_def_property_update(prop, 0, "rna_userdef_update"); @@ -1609,18 +1777,6 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Active Object", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "object_grouped", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "group"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Object Grouped", ""); - RNA_def_property_update(prop, 0, "rna_userdef_update"); - - prop = RNA_def_property(srna, "object_grouped_active", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "group_active"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Object Grouped Active", ""); - RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "text_keyframe", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "time_keyframe"); RNA_def_property_array(prop, 3); @@ -1639,9 +1795,10 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Empty", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "lamp", PROP_FLOAT, PROP_COLOR_GAMMA); + prop = RNA_def_property(srna, "light", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "lamp"); RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Lamp", ""); + RNA_def_property_ui_text(prop, "Light", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "speaker", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -1823,6 +1980,12 @@ static void rna_def_userdef_theme_space_graph(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Active Channel Group", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "preview_range", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "anim_preview_range"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Preview Range", "Color of preview range overlay"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + rna_def_userdef_theme_spaces_vertex(srna); rna_def_userdef_theme_spaces_curves(srna, false, true, true, true); } @@ -2268,23 +2431,6 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_userdef_update"); } -static void rna_def_userdef_theme_space_logic(BlenderRNA *brna) -{ - StructRNA *srna; -// PropertyRNA *prop; - - /* space_logic */ - - srna = RNA_def_struct(brna, "ThemeLogicEditor", NULL); - RNA_def_struct_sdna(srna, "ThemeSpace"); - RNA_def_struct_clear_flag(srna, STRUCT_UNDO); - RNA_def_struct_ui_text(srna, "Theme Logic Editor", "Theme settings for the Logic Editor"); - - rna_def_userdef_theme_spaces_main(srna); - -} - - static void rna_def_userdef_theme_space_buts(BlenderRNA *brna) { StructRNA *srna; @@ -2301,44 +2447,6 @@ static void rna_def_userdef_theme_space_buts(BlenderRNA *brna) } -static void rna_def_userdef_theme_space_time(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - /* space_time */ - - srna = RNA_def_struct(brna, "ThemeTimeline", NULL); - RNA_def_struct_sdna(srna, "ThemeSpace"); - RNA_def_struct_clear_flag(srna, STRUCT_UNDO); - RNA_def_struct_ui_text(srna, "Theme Timeline", "Theme settings for the Timeline"); - - rna_def_userdef_theme_spaces_main(srna); - - prop = RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Grid", ""); - RNA_def_property_update(prop, 0, "rna_userdef_update"); - - prop = RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "cframe"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Current Frame", ""); - RNA_def_property_update(prop, 0, "rna_userdef_update"); - - prop = RNA_def_property(srna, "time_keyframe", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "time_keyframe"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Keyframe", "Base color for keyframe indicator lines"); - RNA_def_property_update(prop, 0, "rna_userdef_update"); - - prop = RNA_def_property(srna, "time_grease_pencil", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "time_gp_keyframe"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Grease Pencil", "Color of Grease Pencil keyframes"); - RNA_def_property_update(prop, 0, "rna_userdef_update"); -} - static void rna_def_userdef_theme_space_image(BlenderRNA *brna) { StructRNA *srna; @@ -2606,51 +2714,51 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna) prop = RNA_def_property(srna, "dopesheet_channel", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "ds_channel"); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Dope Sheet Channel", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "dopesheet_subchannel", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "ds_subchannel"); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Dope Sheet Sub-Channel", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "channels", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "shade2"); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Channels", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "channels_selected", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "hilite"); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Channels Selected", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "channel_group", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "group"); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Channel Group", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "active_channels_group", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "group_active"); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Active Channel Group", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "long_key", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "strip"); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Long Key", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "long_key_selected", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "strip_select"); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Long Key Selected", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); @@ -2704,6 +2812,18 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Jitter Keyframe Selected", "Color of selected jitter keyframe"); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "keyframe_movehold", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "keytype_movehold"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Moving Hold Keyframe", "Color of moving hold keyframe"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "keyframe_movehold_selected", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "keytype_movehold_select"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Moving Hold Keyframe Selected", "Color of selected moving hold keyframe"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "keyframe_border", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "keyborder"); RNA_def_property_array(prop, 4); @@ -2723,12 +2843,23 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna) RNA_def_property_range(prop, 0.8f, 5.0f); /* Note: These limits prevent buttons overlapping (min), and excessive size... (max) */ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, "rna_userdef_update"); - prop = RNA_def_property(srna, "summary", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "anim_active"); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Summary", "Color of summary channel"); RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "preview_range", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "anim_preview_range"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Preview Range", "Color of preview range overlay"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "interpolation_line", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "ds_ipoline"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Interpolation Line", "Color of lines showing non-bezier interpolation modes"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); } static void rna_def_userdef_theme_space_nla(BlenderRNA *brna) @@ -2740,7 +2871,7 @@ static void rna_def_userdef_theme_space_nla(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeNLAEditor", NULL); RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_clear_flag(srna, STRUCT_UNDO); - RNA_def_struct_ui_text(srna, "Theme NLA Editor", "Theme settings for the NLA Editor"); + RNA_def_struct_ui_text(srna, "Theme Nonlinear Animation", "Theme settings for the NLA Editor"); rna_def_userdef_theme_spaces_main(srna); rna_def_userdef_theme_spaces_list_main(srna); @@ -2768,6 +2899,12 @@ static void rna_def_userdef_theme_space_nla(BlenderRNA *brna) RNA_def_property_ui_text(prop, "No Active Action", "Animation data-block doesn't have active action"); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "preview_range", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "anim_preview_range"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Preview Range", "Color of preview range overlay"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "strips", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "strip"); RNA_def_property_array(prop, 3); @@ -2970,32 +3107,60 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna) rna_def_userdef_theme_spaces_curves(srna, false, false, false, true); } +static void rna_def_userdef_theme_space_topbar(BlenderRNA *brna) +{ + StructRNA *srna; + + /* space_topbar */ + + srna = RNA_def_struct(brna, "ThemeTopBar", NULL); + RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); + RNA_def_struct_ui_text(srna, "Theme Top Bar", "Theme settings for the Top Bar"); + + rna_def_userdef_theme_spaces_main(srna); +} + +static void rna_def_userdef_theme_space_statusbar(BlenderRNA *brna) +{ + StructRNA *srna; + + /* space_statusbar */ + + srna = RNA_def_struct(brna, "ThemeStatusBar", NULL); + RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); + RNA_def_struct_ui_text(srna, "Theme Status Bar", "Theme settings for the Status Bar"); + + rna_def_userdef_theme_spaces_main(srna); +} + static void rna_def_userdef_themes(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; static const EnumPropertyItem active_theme_area[] = { - {0, "USER_INTERFACE", ICON_UI, "User Interface", ""}, + {0, "USER_INTERFACE", ICON_WORKSPACE, "User Interface", ""}, {19, "STYLE", ICON_FONTPREVIEW, "Text Style", ""}, {18, "BONE_COLOR_SETS", ICON_COLOR, "Bone Color Sets", ""}, {1, "VIEW_3D", ICON_VIEW3D, "3D View", ""}, - {2, "TIMELINE", ICON_TIME, "Timeline", ""}, - {3, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", ""}, + {3, "GRAPH_EDITOR", ICON_GRAPH, "Graph Editor", ""}, {4, "DOPESHEET_EDITOR", ICON_ACTION, "Dope Sheet", ""}, - {5, "NLA_EDITOR", ICON_NLA, "NLA Editor", ""}, - {6, "IMAGE_EDITOR", ICON_IMAGE_COL, "UV/Image Editor", ""}, + {5, "NLA_EDITOR", ICON_NLA, "Nonlinear Animation", ""}, + {6, "IMAGE_EDITOR", ICON_IMAGE, "UV/Image Editor", ""}, {7, "SEQUENCE_EDITOR", ICON_SEQUENCE, "Video Sequence Editor", ""}, {8, "TEXT_EDITOR", ICON_TEXT, "Text Editor", ""}, {9, "NODE_EDITOR", ICON_NODETREE, "Node Editor", ""}, - {10, "LOGIC_EDITOR", ICON_LOGIC, "Logic Editor", ""}, - {11, "PROPERTIES", ICON_BUTS, "Properties", ""}, - {12, "OUTLINER", ICON_OOPS, "Outliner", ""}, + {11, "PROPERTIES", ICON_PROPERTIES, "Properties", ""}, + {12, "OUTLINER", ICON_OUTLINER, "Outliner", ""}, {14, "USER_PREFERENCES", ICON_PREFERENCES, "User Preferences", ""}, {15, "INFO", ICON_INFO, "Info", ""}, - {16, "FILE_BROWSER", ICON_FILESEL, "File Browser", ""}, + {16, "FILE_BROWSER", ICON_FILEBROWSER, "File Browser", ""}, {17, "CONSOLE", ICON_CONSOLE, "Python Console", ""}, {20, "CLIP_EDITOR", ICON_CLIP, "Movie Clip Editor", ""}, + {21, "TOPBAR", ICON_NONE, "Top Bar", ""}, + {22, "STATUSBAR", ICON_NONE, "Status Bar", ""}, {0, NULL, 0, NULL, NULL} }; @@ -3044,7 +3209,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "tnla"); RNA_def_property_struct_type(prop, "ThemeNLAEditor"); - RNA_def_property_ui_text(prop, "NLA Editor", ""); + RNA_def_property_ui_text(prop, "Nonlinear Animation", ""); prop = RNA_def_property(srna, "dopesheet_editor", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); @@ -3076,24 +3241,12 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ThemeTextEditor"); RNA_def_property_ui_text(prop, "Text Editor", ""); - prop = RNA_def_property(srna, "timeline", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "ttime"); - RNA_def_property_struct_type(prop, "ThemeTimeline"); - RNA_def_property_ui_text(prop, "Timeline", ""); - prop = RNA_def_property(srna, "node_editor", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "tnode"); RNA_def_property_struct_type(prop, "ThemeNodeEditor"); RNA_def_property_ui_text(prop, "Node Editor", ""); - prop = RNA_def_property(srna, "logic_editor", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "tlogic"); - RNA_def_property_struct_type(prop, "ThemeLogicEditor"); - RNA_def_property_ui_text(prop, "Logic Editor", ""); - prop = RNA_def_property(srna, "outliner", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "toops"); @@ -3129,6 +3282,18 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "tclip"); RNA_def_property_struct_type(prop, "ThemeClipEditor"); RNA_def_property_ui_text(prop, "Clip Editor", ""); + + prop = RNA_def_property(srna, "topbar", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "ttopbar"); + RNA_def_property_struct_type(prop, "ThemeTopBar"); + RNA_def_property_ui_text(prop, "Top Bar", ""); + + prop = RNA_def_property(srna, "statusbar", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "tstatusbar"); + RNA_def_property_struct_type(prop, "ThemeStatusBar"); + RNA_def_property_ui_text(prop, "Status Bar", ""); } static void rna_def_userdef_addon(BlenderRNA *brna) @@ -3151,6 +3316,90 @@ static void rna_def_userdef_addon(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_Addon_preferences_get", NULL, NULL, NULL); } +static void rna_def_userdef_studiolights(BlenderRNA *brna) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + srna = RNA_def_struct(brna, "StudioLights", NULL); + RNA_def_struct_sdna(srna, "UserDef"); + RNA_def_struct_ui_text(srna, "Studio Lights", "Collection of studio lights"); + + func = RNA_def_function(srna, "new", "rna_StudioLights_new"); + RNA_def_function_ui_description(func, "Create a new studiolight"); + parm = RNA_def_string(func, "path", NULL, 0, "File Path", "File path where the studio light file can be found"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_enum(func, "orientation", rna_enum_studio_light_orientation_items, STUDIOLIGHT_ORIENTATION_WORLD, "Orientation", "The orientation for the new studio light"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "studio_light", "StudioLight", "", "Newly created StudioLight"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_StudioLights_remove"); + RNA_def_function_ui_description(func, "Remove a studio light"); + parm = RNA_def_pointer(func, "studio_light", "StudioLight", "", "The studio light to remove"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + func = RNA_def_function(srna, "refresh", "rna_StudioLights_refresh"); + RNA_def_function_ui_description(func, "Refresh Studio Lights from disk"); +} + +static void rna_def_userdef_studiolight(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + RNA_define_verify_sdna(false); + srna = RNA_def_struct(brna, "StudioLight", NULL); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); + RNA_def_struct_ui_text(srna, "Studio Light", "Studio light"); + + prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_UserDef_studiolight_index_get", NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Index", ""); + + prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_UserDef_studiolight_is_user_defined_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "User Defined", ""); + + prop = RNA_def_property(srna, "orientation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_enum_studio_light_orientation_items); + RNA_def_property_enum_funcs(prop, "rna_UserDef_studiolight_orientation_get", NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Orientation", ""); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_name_get", "rna_UserDef_studiolight_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "path", PROP_STRING, PROP_DIRPATH); + RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_path_get", "rna_UserDef_studiolight_path_length", NULL); + RNA_def_property_ui_text(prop, "Path", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop = RNA_def_property(srna, "path_irr_cache", PROP_STRING, PROP_DIRPATH); + RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_path_irr_cache_get", "rna_UserDef_studiolight_path_irr_cache_length", NULL); + RNA_def_property_ui_text(prop, "Irradiance Cache Path", "Path where the irradiance cache is stored"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop = RNA_def_property(srna, "path_sh_cache", PROP_STRING, PROP_DIRPATH); + RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_path_sh_cache_get", "rna_UserDef_studiolight_path_sh_cache_length", NULL); + RNA_def_property_ui_text(prop, "SH Cache Path", "Path where the spherical harmonics cache is stored"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + const int spherical_harmonics_dim[] = {STUDIOLIGHT_SPHERICAL_HARMONICS_COMPONENTS, 3}; + prop = RNA_def_property(srna, "spherical_harmonics_coefficients", PROP_FLOAT, PROP_COLOR); + RNA_def_property_multi_array(prop, 2, spherical_harmonics_dim); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_float_funcs(prop, "rna_UserDef_studiolight_spherical_harmonics_coefficients_get", NULL, NULL); + + RNA_define_verify_sdna(true); +} + static void rna_def_userdef_pathcompare(BlenderRNA *brna) { StructRNA *srna; @@ -3212,14 +3461,14 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna) rna_def_userdef_theme_space_seq(brna); rna_def_userdef_theme_space_buts(brna); rna_def_userdef_theme_space_text(brna); - rna_def_userdef_theme_space_time(brna); rna_def_userdef_theme_space_node(brna); rna_def_userdef_theme_space_outliner(brna); rna_def_userdef_theme_space_info(brna); rna_def_userdef_theme_space_userpref(brna); rna_def_userdef_theme_space_console(brna); - rna_def_userdef_theme_space_logic(brna); rna_def_userdef_theme_space_clip(brna); + rna_def_userdef_theme_space_topbar(brna); + rna_def_userdef_theme_space_statusbar(brna); rna_def_userdef_theme_colorset(brna); rna_def_userdef_themes(brna); } @@ -3247,12 +3496,6 @@ static void rna_def_userdef_solidlight(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Direction", "Direction that the OpenGL light is shining"); RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update"); - prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "col"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the OpenGL light"); - RNA_def_property_update(prop, 0, "rna_UserDef_viewport_lights_update"); - prop = RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "spec"); RNA_def_property_array(prop, 3); @@ -3366,7 +3609,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Tooltips", "Display tooltips (when off hold Alt to force display)"); prop = RNA_def_property(srna, "show_tooltips_python", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_TOOLTIPS_PYTHON); + RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_TOOLTIPS_PYTHON); RNA_def_property_ui_text(prop, "Python Tooltips", "Show Python references in tooltips"); prop = RNA_def_property(srna, "show_developer_ui", PROP_BOOLEAN, PROP_NONE); @@ -3380,11 +3623,6 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Display Object Info", "Display objects name and frame number in 3D view"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "use_global_scene", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_SCENEGLOBAL); - RNA_def_property_ui_text(prop, "Global Scene", "Force the current Scene to be displayed in all Screens"); - RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "show_large_cursors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "curssize", 0); RNA_def_property_ui_text(prop, "Large Cursors", "Use large mouse cursors when available"); @@ -3488,10 +3726,6 @@ static void rna_def_userdef_view(BlenderRNA *brna) "Otherwise menus, etc will always be top to bottom, left to right, " "no matter opening direction"); - prop = RNA_def_property(srna, "use_global_pivot", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_LOCKAROUND); - RNA_def_property_ui_text(prop, "Global Pivot", "Lock the same rotation/scaling pivot in all 3D Views"); - prop = RNA_def_property(srna, "use_mouse_depth_navigate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_DEPTH_NAVIGATE); RNA_def_property_ui_text(prop, "Auto Depth", @@ -3499,8 +3733,8 @@ static void rna_def_userdef_view(BlenderRNA *brna) prop = RNA_def_property(srna, "use_mouse_depth_cursor", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_DEPTH_CURSOR); - RNA_def_property_ui_text(prop, "Cursor Depth", - "Use the depth under the mouse when placing the cursor"); + RNA_def_property_ui_text(prop, "Cursor Surface Project", + "Use the surface depth for cursor placement"); prop = RNA_def_property(srna, "use_cursor_lock_adjust", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_LOCK_CURSOR_ADJUST); @@ -3532,10 +3766,17 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Rotate Around Selection", "Use selection as the pivot point"); /* mini axis */ - prop = RNA_def_property(srna, "show_mini_axis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_ROTVIEWICON); - RNA_def_property_ui_text(prop, "Show Mini Axes", - "Show a small rotating 3D axes in the bottom left corner of the 3D View"); + static const EnumPropertyItem mini_axis_type_items[] = { + {0, "MINIMAL", 0, "Simple Axis", ""}, + {USER_SHOW_GIZMO_AXIS, "GIZMO", 0, "Interactive Navigation", ""}, + {0, NULL, 0, NULL, NULL} + }; + + prop = RNA_def_property(srna, "mini_axis_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, mini_axis_type_items); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "uiflag"); + RNA_def_property_ui_text(prop, "Mini Axes Type", + "Show a small rotating 3D axes in the top right corner of the 3D View"); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "mini_axis_size", PROP_INT, PROP_NONE); @@ -3561,35 +3802,22 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Rotation Angle", "Rotation step for numerical pad keys (2 4 6 8)"); /* 3D transform widget */ - prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "tw_flag", V3D_USE_MANIPULATOR); - RNA_def_property_ui_text(prop, "Manipulator", "Use 3D transform manipulator"); - RNA_def_property_update(prop, 0, "rna_userdef_show_manipulator_update"); + prop = RNA_def_property(srna, "show_gizmo", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gizmo_flag", USER_GIZMO_DRAW); + RNA_def_property_ui_text(prop, "Gizmos", "Use transform gizmos by default"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "manipulator_size", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "tw_size"); + prop = RNA_def_property(srna, "gizmo_size", PROP_INT, PROP_PIXEL); + RNA_def_property_int_sdna(prop, NULL, "gizmo_size"); RNA_def_property_range(prop, 10, 200); RNA_def_property_int_default(prop, 75); - RNA_def_property_ui_text(prop, "Manipulator Size", "Diameter of the manipulator"); - RNA_def_property_update(prop, 0, "rna_userdef_update"); - - prop = RNA_def_property(srna, "manipulator_handle_size", PROP_INT, PROP_PERCENTAGE); - RNA_def_property_int_sdna(prop, NULL, "tw_handlesize"); - RNA_def_property_range(prop, 2, 40); - RNA_def_property_int_default(prop, 25); - RNA_def_property_ui_text(prop, "Manipulator Handle Size", "Size of manipulator handles as percentage of the radius"); + RNA_def_property_ui_text(prop, "Gizmo Size", "Diameter of the gizmo"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "manipulator_hotspot", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "tw_hotspot"); - RNA_def_property_range(prop, 4, 40); - RNA_def_property_int_default(prop, 14); - RNA_def_property_ui_text(prop, "Manipulator Hotspot", "Distance around the handles to accept mouse clicks"); - prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "obcenter_dia"); RNA_def_property_range(prop, 4, 10); - RNA_def_property_ui_text(prop, "Object Origin Size", "Diameter in Pixels for Object/Lamp origin display"); + RNA_def_property_ui_text(prop, "Object Origin Size", "Diameter in Pixels for Object/Light origin display"); RNA_def_property_update(prop, 0, "rna_userdef_update"); /* View2D Grid Displays */ @@ -3680,6 +3908,14 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Release confirms", "Moving things with a mouse drag confirms when releasing the button"); + prop = RNA_def_property(srna, "use_numeric_input_advanced", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_FLAG_NUMINPUT_ADVANCED); + RNA_def_property_ui_text( + prop, "Default to Advanced Numeric Input", + "When entering numbers while transforming, " + "default to advanced mode for full math expression evaluation"); + + /* Undo */ prop = RNA_def_property(srna, "undo_steps", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "undosteps"); @@ -3786,11 +4022,10 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_range(prop, 1, 500); RNA_def_property_ui_text(prop, "Grease Pencil Eraser Radius", "Radius of eraser 'brush'"); - prop = RNA_def_property(srna, "grease_pencil_default_color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "gpencil_new_layer_col"); RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Grease Pencil Default Color", "Color of new Grease Pencil layers"); + RNA_def_property_ui_text(prop, "Annotation Default Color", "Color of new annotation layers"); /* sculpt and paint */ @@ -3824,9 +4059,9 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_ARM); RNA_def_property_ui_text(prop, "Duplicate Armature", "Causes armature data to be duplicated with the object"); - prop = RNA_def_property(srna, "use_duplicate_lamp", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_duplicate_light", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_LAMP); - RNA_def_property_ui_text(prop, "Duplicate Lamp", "Causes lamp data to be duplicated with the object"); + RNA_def_property_ui_text(prop, "Duplicate Light", "Causes light data to be duplicated with the object"); prop = RNA_def_property(srna, "use_duplicate_material", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_MAT); @@ -3927,20 +4162,6 @@ static void rna_def_userdef_system(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem draw_method_items[] = { - {USER_DRAW_AUTOMATIC, "AUTOMATIC", 0, "Automatic", "Automatically set based on graphics card and driver"}, - {USER_DRAW_TRIPLE, "TRIPLE_BUFFER", 0, "Triple Buffer", - "Use a third buffer for minimal redraws at the cost of more memory"}, - {USER_DRAW_OVERLAP, "OVERLAP", 0, "Overlap", - "Redraw all overlapping regions, minimal memory usage but more redraws"}, - {USER_DRAW_OVERLAP_FLIP, "OVERLAP_FLIP", 0, "Overlap Flip", - "Redraw all overlapping regions, minimal memory usage but more redraws " - "(for graphics drivers that do flipping)"}, - {USER_DRAW_FULL, "FULL", 0, "Full", - "Do a full redraw each time, slow, only use for reference or when everything else fails"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem color_picker_types[] = { {USER_CP_CIRCLE_HSV, "CIRCLE_HSV", 0, "Circle (HSV)", "A circular Hue/Saturation color wheel, with Value slider"}, {USER_CP_CIRCLE_HSL, "CIRCLE_HSL", 0, "Circle (HSL)", "A circular Hue/Saturation color wheel, with Lightness slider"}, @@ -3994,20 +4215,27 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_ui_text(prop, "International Fonts", "Use international fonts"); RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_language_update"); + prop = RNA_def_property(srna, "ui_scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_float_sdna(prop, NULL, "dpi_fac"); + RNA_def_property_ui_text(prop, "UI Scale", + "Size multiplier to use when drawing custom user interface elements, so that " + "they are scaled correctly on screens with different DPI. This value is based " + "on operating system DPI settings and Blender display scale"); + + prop = RNA_def_property(srna, "ui_line_width", PROP_FLOAT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_float_sdna(prop, NULL, "pixelsize"); + RNA_def_property_ui_text(prop, "UI Line Width", + "Suggested line thickness and point size in pixels, for add-ons drawing custom " + "user interface elements, based on operating system settings and Blender UI scale"); + prop = RNA_def_property(srna, "dpi", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "DPI", - "DPI for add-ons to use when drawing custom user interface elements, controlled by " - "operating system settings and Blender UI scale, with a reference value of 72 DPI " - "(note that since this value includes a user defined scale, it is not always the " - "actual monitor DPI)"); prop = RNA_def_property(srna, "pixel_size", PROP_FLOAT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_float_sdna(prop, NULL, "pixelsize"); - RNA_def_property_ui_text(prop, "Pixel Size", - "Suggested line thickness and point size in pixels, for add-ons drawing custom user " - "interface elements, controlled by operating system settings and Blender UI scale"); prop = RNA_def_property(srna, "font_path_ui", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "font_path_ui"); @@ -4111,24 +4339,12 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Memory Cache Limit", "Memory cache limit (in megabytes)"); RNA_def_property_update(prop, 0, "rna_Userdef_memcache_update"); - prop = RNA_def_property(srna, "frame_server_port", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "frameserverport"); - RNA_def_property_range(prop, 0, 32727); - RNA_def_property_ui_text(prop, "Frame Server Port", "Frameserver Port for Frameserver Rendering"); - prop = RNA_def_property(srna, "gl_clip_alpha", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "glalphaclip"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Clip Alpha", "Clip alpha below this threshold in the 3D textured view"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "use_mipmaps", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_MIPMAP); - RNA_def_property_ui_text(prop, "Mipmaps", - "Scale textures for the 3D View (looks nicer but uses more memory and slows image " - "reloading)"); - RNA_def_property_update(prop, 0, "rna_userdef_mipmap_update"); - prop = RNA_def_property(srna, "use_16bit_textures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_16bit_textures", 1); RNA_def_property_ui_text(prop, "16 Bit Float Textures", "Use 16 bit per component texture for float images"); @@ -4173,12 +4389,6 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Texture Collection Rate", "Number of seconds between each run of the GL texture garbage collector"); - prop = RNA_def_property(srna, "window_draw_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "wmdrawmethod"); - RNA_def_property_enum_items(prop, draw_method_items); - RNA_def_property_ui_text(prop, "Window Draw Method", "Drawing method used by the window manager"); - RNA_def_property_update(prop, 0, "rna_userdef_dpi_update"); - prop = RNA_def_property(srna, "audio_mixing_buffer", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mixbufsize"); RNA_def_property_enum_items(prop, audio_mixing_samples_items); @@ -4237,6 +4447,15 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_enum_items(prop, multi_sample_levels); RNA_def_property_ui_text(prop, "MultiSample", "Enable OpenGL multi-sampling, only for systems that support it, requires restart"); + RNA_def_property_update(prop, 0, "rna_userdef_dpi_update"); + + /* grease pencil anti-aliasing */ + prop = RNA_def_property(srna, "gpencil_multi_sample", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_multisamples"); + RNA_def_property_enum_items(prop, multi_sample_levels); + RNA_def_property_ui_text(prop, "Gpencil MultiSample", + "Enable Grease Pencil OpenGL multi-sampling, only for systems that support it"); + RNA_def_property_update(prop, 0, "rna_userdef_dpi_update"); prop = RNA_def_property(srna, "use_region_overlap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_REGION_OVERLAP); @@ -4244,6 +4463,14 @@ static void rna_def_userdef_system(BlenderRNA *brna) "Draw tool/property regions over the main region, when using Triple Buffer"); RNA_def_property_update(prop, 0, "rna_userdef_dpi_update"); + prop = RNA_def_property(srna, "gpu_viewport_quality", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "gpu_viewport_quality"); + RNA_def_property_float_default(prop, 0.6f); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Viewport Quality", "Quality setting for Solid mode rendering in the 3d viewport"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + #ifdef WITH_OPENSUBDIV prop = RNA_def_property(srna, "opensubdiv_compute_type", PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); @@ -4704,6 +4931,7 @@ void RNA_def_userdef(BlenderRNA *brna) {USER_SECTION_INPUT, "INPUT", 0, "Input", ""}, {USER_SECTION_ADDONS, "ADDONS", 0, "Add-ons", ""}, {USER_SECTION_THEME, "THEMES", 0, "Themes", ""}, + {USER_SECTION_LIGHT, "LIGHTS", 0, "Lights", ""}, {USER_SECTION_FILE, "FILES", 0, "File", ""}, {USER_SECTION_SYSTEM, "SYSTEM", 0, "System", ""}, {0, NULL, 0, NULL, NULL} @@ -4789,6 +5017,16 @@ void RNA_def_userdef(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_THICK_WRAP); + /* StudioLight Collection */ + prop = RNA_def_property(srna, "studio_lights", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "StudioLight"); + RNA_def_property_srna(prop, "StudioLights"); + RNA_def_property_collection_funcs( + prop, "rna_UserDef_studiolight_begin", "rna_iterator_listbase_next", + "rna_iterator_listbase_end", "rna_iterator_listbase_get", + NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Studio Lights", ""); + rna_def_userdef_view(brna); rna_def_userdef_edit(brna); rna_def_userdef_input(brna); @@ -4796,6 +5034,8 @@ void RNA_def_userdef(BlenderRNA *brna) rna_def_userdef_system(brna); rna_def_userdef_addon(brna); rna_def_userdef_addon_pref(brna); + rna_def_userdef_studiolights(brna); + rna_def_userdef_studiolight(brna); rna_def_userdef_pathcompare(brna); } diff --git a/source/blender/makesrna/intern/rna_vfont.c b/source/blender/makesrna/intern/rna_vfont.c index 5c42a86c52e..487b5220c86 100644 --- a/source/blender/makesrna/intern/rna_vfont.c +++ b/source/blender/makesrna/intern/rna_vfont.c @@ -38,9 +38,10 @@ #ifdef RNA_RUNTIME #include "BKE_font.h" -#include "BKE_depsgraph.h" #include "DNA_object_types.h" +#include "DEG_depsgraph.h" + #include "WM_api.h" /* matching fnction in rna_ID.c */ @@ -60,7 +61,7 @@ static void rna_VectorFont_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scen /* update */ WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); - DAG_id_tag_update(&vf->id, OB_RECALC_OB | OB_RECALC_DATA); + DEG_id_tag_update(&vf->id, OB_RECALC_OB | OB_RECALC_DATA); } #else diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index d0d01b9e43e..7ceaa769d78 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -36,6 +36,8 @@ #include "BLT_translation.h" +#include "BKE_workspace.h" + #include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -434,6 +436,8 @@ static const EnumPropertyItem operator_flag_items[] = { "is enabled"}, {OPTYPE_PRESET, "PRESET", 0, "Preset", "Display a preset button with the operators settings"}, {OPTYPE_INTERNAL, "INTERNAL", 0, "Internal", "Removes the operator from search results"}, + {OPTYPE_USE_EVAL_DATA, "USE_EVAL_DATA", 0, "Use Evaluated Data", + "Uses evaluated data (i.e. needs a valid depsgraph for current context)"}, {0, NULL, 0, NULL, NULL} }; #endif @@ -448,6 +452,11 @@ const EnumPropertyItem rna_enum_operator_return_items[] = { {0, NULL, 0, NULL, NULL} }; +const EnumPropertyItem rna_enum_operator_property_tags[] = { + {OP_PROP_TAG_ADVANCED, "ADVANCED", 0, "Advanced", "The property is advanced so UI is suggested to hide it"}, + {0, NULL, 0, NULL, NULL} +}; + /* flag/enum */ const EnumPropertyItem rna_enum_wm_report_items[] = { {RPT_DEBUG, "DEBUG", 0, "Debug", ""}, @@ -468,12 +477,23 @@ const EnumPropertyItem rna_enum_wm_report_items[] = { #include "WM_api.h" +#include "DNA_object_types.h" +#include "DNA_workspace_types.h" + +#include "ED_screen.h" + #include "UI_interface.h" +#include "BKE_global.h" #include "BKE_idprop.h" #include "MEM_guardedalloc.h" +#ifdef WITH_PYTHON +# include "BPY_extern.h" +#endif + + static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr) { wmWindowManager *wm = ptr->id.data; @@ -617,6 +637,17 @@ static PointerRNA rna_PopupMenu_layout_get(PointerRNA *ptr) return rptr; } +static PointerRNA rna_PopoverMenu_layout_get(PointerRNA *ptr) +{ + struct uiPopover *pup = ptr->data; + uiLayout *layout = UI_popover_layout(pup); + + PointerRNA rptr; + RNA_pointer_create(ptr->id.data, &RNA_UILayout, layout, &rptr); + + return rptr; +} + static PointerRNA rna_PieMenu_layout_get(PointerRNA *ptr) { struct uiPieMenu *pie = ptr->data; @@ -628,42 +659,142 @@ static PointerRNA rna_PieMenu_layout_get(PointerRNA *ptr) return rptr; } -static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value) +static void rna_Window_scene_set(PointerRNA *ptr, PointerRNA value) +{ + wmWindow *win = ptr->data; + + if (value.data == NULL) { + return; + } + + win->new_scene = value.data; +} + +static void rna_Window_scene_update(bContext *C, PointerRNA *ptr) +{ + Main *bmain = CTX_data_main(C); + wmWindow *win = ptr->data; + + /* exception: must use context so notifier gets to the right window */ + if (win->new_scene) { +#ifdef WITH_PYTHON + BPy_BEGIN_ALLOW_THREADS; +#endif + + WM_window_set_active_scene(bmain, C, win, win->new_scene); + +#ifdef WITH_PYTHON + BPy_END_ALLOW_THREADS; +#endif + + WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, win->new_scene); + + if (G.debug & G_DEBUG) + printf("scene set %p\n", win->new_scene); + + win->new_scene = NULL; + } +} + +static PointerRNA rna_Window_workspace_get(PointerRNA *ptr) +{ + wmWindow *win = ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_WorkSpace, BKE_workspace_active_get(win->workspace_hook)); +} + +static void rna_Window_workspace_set(PointerRNA *ptr, PointerRNA value) { wmWindow *win = (wmWindow *)ptr->data; /* disallow ID-browsing away from temp screens */ - if (win->screen->temp) { + if (WM_window_is_temp_screen(win)) { return; } + if (value.data == NULL) { + return; + } + + /* exception: can't set workspaces inside of area/region handlers */ + win->workspace_hook->temp_workspace_store = value.data; +} + +static void rna_Window_workspace_update(bContext *C, PointerRNA *ptr) +{ + wmWindow *win = ptr->data; + WorkSpace *new_workspace = win->workspace_hook->temp_workspace_store; + + /* exception: can't set screens inside of area/region handlers, + * and must use context so notifier gets to the right window */ + if (new_workspace) { + WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_SET, new_workspace); + win->workspace_hook->temp_workspace_store = NULL; + } +} + +PointerRNA rna_Window_screen_get(PointerRNA *ptr) +{ + wmWindow *win = ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_Screen, BKE_workspace_active_screen_get(win->workspace_hook)); +} + +static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value) +{ + wmWindow *win = ptr->data; + WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); + WorkSpaceLayout *layout_new; + const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - if (value.data == NULL) + /* disallow ID-browsing away from temp screens */ + if (screen->temp) { return; + } + if (value.data == NULL) { + return; + } /* exception: can't set screens inside of area/region handlers */ - win->newscreen = value.data; + layout_new = BKE_workspace_layout_find(workspace, value.data); + win->workspace_hook->temp_layout_store = layout_new; } static bool rna_Window_screen_assign_poll(PointerRNA *UNUSED(ptr), PointerRNA value) { - bScreen *screen = (bScreen *)value.id.data; - + bScreen *screen = value.id.data; return !screen->temp; } - -static void rna_Window_screen_update(bContext *C, PointerRNA *ptr) +static void rna_workspace_screen_update(bContext *C, PointerRNA *ptr) { - wmWindow *win = (wmWindow *)ptr->data; + wmWindow *win = ptr->data; + WorkSpaceLayout *layout_new = win->workspace_hook->temp_layout_store; /* exception: can't set screens inside of area/region handlers, * and must use context so notifier gets to the right window */ - if (win->newscreen) { - WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, win->newscreen); - win->newscreen = NULL; + if (layout_new) { + WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTBROWSE, layout_new); + win->workspace_hook->temp_layout_store = NULL; } } +static PointerRNA rna_Window_view_layer_get(PointerRNA *ptr) +{ + wmWindow *win = ptr->data; + Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + PointerRNA scene_ptr; + + RNA_id_pointer_create(&scene->id, &scene_ptr); + return rna_pointer_inherit_refine(&scene_ptr, &RNA_ViewLayer, view_layer); +} + +static void rna_Window_view_layer_set(PointerRNA *ptr, PointerRNA value) +{ + wmWindow *win = ptr->data; + ViewLayer *view_layer = value.data; + + WM_window_set_active_view_layer(win, view_layer); +} + static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr) { wmKeyMapItem *kmi = ptr->data; @@ -1199,6 +1330,7 @@ static StructRNA *rna_Operator_register( /* create a new operator type */ dummyot.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummyot.idname, &RNA_Operator); RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */ + RNA_def_struct_property_tags(dummyot.ext.srna, rna_enum_operator_property_tags); RNA_def_struct_translation_context(dummyot.ext.srna, dummyot.translation_context); dummyot.ext.data = data; dummyot.ext.call = call; @@ -1558,6 +1690,7 @@ static void rna_def_operator(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator"); RNA_def_struct_refine_func(srna, "rna_OperatorProperties_refine"); RNA_def_struct_idprops_func(srna, "rna_OperatorProperties_idprops"); + RNA_def_struct_property_tags(srna, rna_enum_operator_property_tags); RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES); } @@ -1863,6 +1996,11 @@ static void rna_def_popupmenu(BlenderRNA *brna) rna_def_popup_menu_wrapper(brna, "UIPopupMenu", "uiPopupMenu", "rna_PopupMenu_layout_get"); } +static void rna_def_popovermenu(BlenderRNA *brna) +{ + rna_def_popup_menu_wrapper(brna, "UIPopover", "uiPopover", "rna_PopoverMenu_layout_get"); +} + static void rna_def_piemenu(BlenderRNA *brna) { rna_def_popup_menu_wrapper(brna, "UIPieMenu", "uiPieMenu", "rna_PieMenu_layout_get"); @@ -1908,16 +2046,40 @@ static void rna_def_window(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Window", "Open window"); RNA_def_struct_sdna(srna, "wmWindow"); + prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Parent Window", "Active workspace and scene follow this window"); + rna_def_window_stereo3d(brna); - prop = RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE); + prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_scene_set", NULL, NULL); + RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the window"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, 0, "rna_Window_scene_update"); + + prop = RNA_def_property(srna, "workspace", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "WorkSpace"); + RNA_def_property_ui_text(prop, "Workspace", "Active workspace showing in the window"); + RNA_def_property_pointer_funcs(prop, "rna_Window_workspace_get", "rna_Window_workspace_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, 0, "rna_Window_workspace_update"); + + prop = RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Screen"); - RNA_def_property_ui_text(prop, "Screen", "Active screen showing in the window"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_screen_set", NULL, "rna_Window_screen_assign_poll"); - RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); - RNA_def_property_update(prop, 0, "rna_Window_screen_update"); + RNA_def_property_ui_text(prop, "Screen", "Active workspace screen showing in the window"); + RNA_def_property_pointer_funcs(prop, "rna_Window_screen_get", "rna_Window_screen_set", NULL, + "rna_Window_screen_assign_poll"); + RNA_def_property_flag(prop, PROP_NEVER_NULL | PROP_EDITABLE | PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, 0, "rna_workspace_screen_update"); + + prop = RNA_def_property(srna, "view_layer", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ViewLayer"); + RNA_def_property_pointer_funcs(prop, "rna_Window_view_layer_get", "rna_Window_view_layer_set", NULL, NULL); + RNA_def_property_ui_text(prop, "Active View Layer", "The active workspace view layer showing in the window"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL); prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "posx"); @@ -2092,6 +2254,10 @@ static void rna_def_keyconfig(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", "Name of the key map"); RNA_def_struct_name_property(srna, prop); + prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "owner_id"); + RNA_def_property_ui_text(prop, "Owner", "Internal owner"); + prop = RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "spaceid"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -2275,6 +2441,7 @@ void RNA_def_wm(BlenderRNA *brna) rna_def_event(brna); rna_def_timer(brna); rna_def_popupmenu(brna); + rna_def_popovermenu(brna); rna_def_piemenu(brna); rna_def_window(brna); rna_def_windowmanager(brna); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 3015d56e1ee..f8a9b00c724 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -71,6 +71,8 @@ const EnumPropertyItem rna_enum_window_cursor_items[] = { #include "UI_interface.h" #include "BKE_context.h" +#include "WM_types.h" + static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); @@ -115,6 +117,37 @@ static void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer) WM_event_remove_timer(wm, timer->win, timer); } + +static wmGizmoGroupType *wm_gizmogrouptype_find_for_add_remove(ReportList *reports, const char *idname) +{ + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, true); + if (gzgt == NULL) { + BKE_reportf(reports, RPT_ERROR, "Gizmo group type '%s' not found!", idname); + return NULL; + } + if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) { + BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' has 'PERSISTENT' option set!", idname); + return NULL; + } + return gzgt; +} + +static void rna_gizmo_group_type_add(ReportList *reports, const char *idname) +{ + wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname); + if (gzgt != NULL) { + WM_gizmo_group_type_add_ptr(gzgt); + } +} + +static void rna_gizmo_group_type_remove(Main *bmain, ReportList *reports, const char *idname) +{ + wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname); + if (gzgt != NULL) { + WM_gizmo_group_type_remove_ptr(bmain, gzgt); + } +} + /* placeholder data for final implementation of a true progressbar */ static struct wmStaticProgress { float min; @@ -342,6 +375,24 @@ static void rna_PopMenuEnd(bContext *C, PointerRNA *handle) UI_popup_menu_end(C, handle->data); } +/* popover wrapper */ +static PointerRNA rna_PopoverBegin(bContext *C, int ui_units_x) +{ + PointerRNA r_ptr; + void *data; + + data = (void *)UI_popover_begin(C, U.widget_unit * ui_units_x); + + RNA_pointer_create(NULL, &RNA_UIPopover, data, &r_ptr); + + return r_ptr; +} + +static void rna_PopoverEnd(bContext *C, PointerRNA *handle, wmKeyMap *keymap) +{ + UI_popover_end(C, handle->data, keymap); +} + /* pie menu wrapper */ static PointerRNA rna_PieMenuBegin(bContext *C, const char *title, int icon, PointerRNA *event) { @@ -360,6 +411,18 @@ static void rna_PieMenuEnd(bContext *C, PointerRNA *handle) UI_pie_menu_end(C, handle->data); } +static PointerRNA rna_WindoManager_operator_properties_last(const char *idname) +{ + wmOperatorType *ot = WM_operatortype_find(idname, true); + + if (ot != NULL) { + PointerRNA ptr; + WM_operator_last_properties_ensure(ot, &ptr); + return ptr; + } + return PointerRNA_NULL; +} + #else #define WM_GEN_INVOKE_EVENT (1 << 0) @@ -453,6 +516,18 @@ void RNA_api_wm(StructRNA *srna) parm = RNA_def_pointer(func, "timer", "Timer", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + func = RNA_def_function(srna, "gizmo_group_type_add", "rna_gizmo_group_type_add"); + RNA_def_function_ui_description(func, "Activate an existing widget group (when the persistent option isn't set)"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS); + parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + func = RNA_def_function(srna, "gizmo_group_type_remove", "rna_gizmo_group_type_remove"); + RNA_def_function_ui_description(func, "De-activate a widget group (when the persistent option isn't set)"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_MAIN | FUNC_USE_REPORTS); + parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* Progress bar interface */ func = RNA_def_function(srna, "progress_begin", "rna_progress_begin"); RNA_def_function_ui_description(func, "Start progress report"); @@ -521,7 +596,24 @@ void RNA_api_wm(StructRNA *srna) func = RNA_def_function(srna, "popmenu_end__internal", "rna_PopMenuEnd"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED); + + /* wrap UI_popover_begin */ + func = RNA_def_function(srna, "popover_begin__internal", "rna_PopoverBegin"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); + RNA_def_property(func, "ui_units_x", PROP_INT, PROP_UNSIGNED); + /* return */ + parm = RNA_def_pointer(func, "menu", "UIPopover", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); + RNA_def_function_return(func, parm); + + /* wrap UI_popover_end */ + func = RNA_def_function(srna, "popover_end__internal", "rna_PopoverEnd"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); + parm = RNA_def_pointer(func, "menu", "UIPopover", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED); + RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map"); + /* wrap uiPieMenuBegin */ func = RNA_def_function(srna, "piemenu_begin__internal", "rna_PieMenuBegin"); @@ -541,7 +633,18 @@ void RNA_api_wm(StructRNA *srna) func = RNA_def_function(srna, "piemenu_end__internal", "rna_PieMenuEnd"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "menu", "UIPieMenu", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED); + + /* access last operator options (optionally create). */ + func = RNA_def_function(srna, "operator_properties_last", "rna_WindoManager_operator_properties_last"); + RNA_def_function_flag(func, FUNC_NO_SELF); + parm = RNA_def_string(func, "operator", NULL, 0, "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return */ + parm = RNA_def_pointer(func, "result", "OperatorProperties", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); + RNA_def_function_return(func, parm); + } void RNA_api_operator(StructRNA *srna) @@ -822,10 +925,10 @@ void RNA_api_keyconfigs(StructRNA *srna) parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", ""); RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); RNA_def_boolean(func, "is_hotkey", 0, "Hotkey", "Event is not a modifier"); - parm = RNA_def_pointer(func, "item", "KeyMapItem", "", ""); - RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); parm = RNA_def_pointer(func, "keymap", "KeyMap", "", ""); RNA_def_parameter_flags(parm, 0, PARM_RNAPTR | PARM_OUTPUT); + parm = RNA_def_pointer(func, "item", "KeyMapItem", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); RNA_def_function_return(func, parm); RNA_def_function(srna, "update", "rna_KeyConfig_update"); /* WM_keyconfig_update */ diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c new file mode 100644 index 00000000000..41e3929e8ae --- /dev/null +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -0,0 +1,1408 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_wm_gizmo.c + * \ingroup RNA + */ + +#include <stdlib.h> + +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_userdef_types.h" +#include "DNA_view3d_types.h" +#include "DNA_windowmanager_types.h" + +#include "BLI_utildefines.h" +#include "BLI_string_utils.h" + +#include "BLT_translation.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "rna_internal.h" + +#include "WM_types.h" + +#ifdef RNA_RUNTIME +/* enum definitions */ +#endif /* RNA_RUNTIME */ + +#ifdef RNA_RUNTIME + +#include <assert.h> + +#include "WM_api.h" + +#include "DNA_workspace_types.h" + +#include "ED_screen.h" + +#include "UI_interface.h" + +#include "BKE_global.h" +#include "BKE_idprop.h" +#include "BKE_workspace.h" + +#include "MEM_guardedalloc.h" + +#ifdef WITH_PYTHON +# include "BPY_extern.h" +#endif + +/* -------------------------------------------------------------------- */ + +/** \name Gizmo API + * \{ */ + +#ifdef WITH_PYTHON +static void rna_gizmo_draw_cb( + const struct bContext *C, struct wmGizmo *gz) +{ + extern FunctionRNA rna_Gizmo_draw_func; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "draw"); */ + func = &rna_Gizmo_draw_func; + RNA_parameter_list_create(&list, &gz_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static void rna_gizmo_draw_select_cb( + const struct bContext *C, struct wmGizmo *gz, int select_id) +{ + extern FunctionRNA rna_Gizmo_draw_select_func; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "draw_select"); */ + func = &rna_Gizmo_draw_select_func; + RNA_parameter_list_create(&list, &gz_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "select_id", &select_id); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static int rna_gizmo_test_select_cb( + struct bContext *C, struct wmGizmo *gz, const int location[2]) +{ + extern FunctionRNA rna_Gizmo_test_select_func; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "test_select"); */ + func = &rna_Gizmo_test_select_func; + RNA_parameter_list_create(&list, &gz_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "location", location); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + + void *ret; + RNA_parameter_get_lookup(&list, "intersect_id", &ret); + int intersect_id = *(int *)ret; + + RNA_parameter_list_free(&list); + return intersect_id; +} + +static int rna_gizmo_modal_cb( + struct bContext *C, struct wmGizmo *gz, const struct wmEvent *event, + eWM_GizmoFlagTweak tweak_flag) +{ + extern FunctionRNA rna_Gizmo_modal_func; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; + ParameterList list; + FunctionRNA *func; + const int tweak_flag_int = tweak_flag; + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "modal"); */ + func = &rna_Gizmo_modal_func; + RNA_parameter_list_create(&list, &gz_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "event", &event); + RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + + void *ret; + RNA_parameter_get_lookup(&list, "result", &ret); + int ret_enum = *(int *)ret; + + RNA_parameter_list_free(&list); + return ret_enum; +} + +static void rna_gizmo_setup_cb( + struct wmGizmo *gz) +{ + extern FunctionRNA rna_Gizmo_setup_func; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "setup"); */ + func = &rna_Gizmo_setup_func; + RNA_parameter_list_create(&list, &gz_ptr, func); + gzgroup->type->ext.call((bContext *)NULL, &gz_ptr, func, &list); + RNA_parameter_list_free(&list); +} + + +static int rna_gizmo_invoke_cb( + struct bContext *C, struct wmGizmo *gz, const struct wmEvent *event) +{ + extern FunctionRNA rna_Gizmo_invoke_func; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "invoke"); */ + func = &rna_Gizmo_invoke_func; + RNA_parameter_list_create(&list, &gz_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "event", &event); + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + + void *ret; + RNA_parameter_get_lookup(&list, "result", &ret); + int ret_enum = *(int *)ret; + + RNA_parameter_list_free(&list); + return ret_enum; +} + +static void rna_gizmo_exit_cb( + struct bContext *C, struct wmGizmo *gz, bool cancel) +{ + extern FunctionRNA rna_Gizmo_exit_func; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "exit"); */ + func = &rna_Gizmo_exit_func; + RNA_parameter_list_create(&list, &gz_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + { + int cancel_i = cancel; + RNA_parameter_set_lookup(&list, "cancel", &cancel_i); + } + gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static void rna_gizmo_select_refresh_cb( + struct wmGizmo *gz) +{ + extern FunctionRNA rna_Gizmo_select_refresh_func; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + PointerRNA gz_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, gz->type->ext.srna, gz, &gz_ptr); + /* RNA_struct_find_function(&gz_ptr, "select_refresh"); */ + func = &rna_Gizmo_select_refresh_func; + RNA_parameter_list_create(&list, &gz_ptr, func); + gzgroup->type->ext.call((bContext *)NULL, &gz_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +#endif /* WITH_PYTHON */ + +/* just to work around 'const char *' warning and to ensure this is a python op */ +static void rna_Gizmo_bl_idname_set(PointerRNA *ptr, const char *value) +{ + wmGizmo *data = ptr->data; + char *str = (char *)data->type->idname; + if (!str[0]) { + BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ + } + else { + assert(!"setting the bl_idname on a non-builtin operator"); + } +} + +static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr) +{ +#if 0 + wmWindowManager *wm = ptr->id.data; +#endif + + /* We could try workaruond this lookup, but not trivial. */ + for (bScreen *screen = G_MAIN->screen.first; screen; screen = screen->id.next) { + IDProperty *properties = ptr->data; + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->gizmo_map) { + wmGizmoMap *gzmap = ar->gizmo_map; + for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first; + gzgroup; + gzgroup = gzgroup->next) + { + for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + if (gz->properties == properties) { + return gz; + } + } + } + } + } + } + } + return NULL; +} + +static StructRNA *rna_GizmoProperties_refine(PointerRNA *ptr) +{ + wmGizmo *gz = rna_GizmoProperties_find_operator(ptr); + + if (gz) + return gz->type->srna; + else + return ptr->type; +} + +static IDProperty *rna_GizmoProperties_idprops(PointerRNA *ptr, bool create) +{ + if (create && !ptr->data) { + IDPropertyTemplate val = {0}; + ptr->data = IDP_New(IDP_GROUP, &val, "RNA_GizmoProperties group"); + } + + return ptr->data; +} + +static PointerRNA rna_Gizmo_properties_get(PointerRNA *ptr) +{ + wmGizmo *gz = ptr->data; + return rna_pointer_inherit_refine(ptr, gz->type->srna, gz->properties); +} + +/* wmGizmo.float */ +#define RNA_GIZMO_GENERIC_FLOAT_RW_DEF(func_id, member_id) \ +static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmGizmo *gz = ptr->data; \ + return gz->member_id; \ +} \ +static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \ +{ \ + wmGizmo *gz = ptr->data; \ + gz->member_id = value; \ +} +#define RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \ +static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmGizmo *gz = ptr->data; \ + return gz->member_id[index]; \ +} \ +static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \ +{ \ + wmGizmo *gz = ptr->data; \ + gz->member_id[index] = value; \ +} +/* wmGizmo.float[len] */ +#define RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \ +static void rna_Gizmo_##func_id##_get(PointerRNA *ptr, float value[len]) \ +{ \ + wmGizmo *gz = ptr->data; \ + memcpy(value, gz->member_id, sizeof(float[len])); \ +} \ +static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, const float value[len]) \ +{ \ + wmGizmo *gz = ptr->data; \ + memcpy(gz->member_id, value, sizeof(float[len])); \ +} + +/* wmGizmo.flag */ +#define RNA_GIZMO_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \ +static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmGizmo *gz = ptr->data; \ + return (gz->member_id & flag_value) != 0; \ +} \ +static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \ +{ \ + wmGizmo *gz = ptr->data; \ + SET_FLAG_FROM_TEST(gz->member_id, value, flag_value); \ +} + +/* wmGizmo.flag (negative) */ +#define RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \ +static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmGizmo *gz = ptr->data; \ + return (gz->member_id & flag_value) == 0; \ +} \ +static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \ +{ \ + wmGizmo *gz = ptr->data; \ + SET_FLAG_FROM_TEST(gz->member_id, !value, flag_value); \ +} + +#define RNA_GIZMO_FLAG_RO_DEF(func_id, member_id, flag_value) \ +static int rna_Gizmo_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmGizmo *gz = ptr->data; \ + return (gz->member_id & flag_value) != 0; \ +} + +RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3); + +RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3); + +RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16); +RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16); + +static void rna_Gizmo_matrix_world_get(PointerRNA *ptr, float value[16]) +{ + wmGizmo *gz = ptr->data; + WM_gizmo_calc_matrix_final(gz, (float (*)[4])value); +} + +RNA_GIZMO_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis); +RNA_GIZMO_GENERIC_FLOAT_RW_DEF(line_width, line_width); + +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_GIZMO_DRAW_HOVER); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_GIZMO_DRAW_MODAL); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_GIZMO_DRAW_VALUE); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE); +RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_GIZMO_HIDDEN); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_select, flag, WM_GIZMO_HIDDEN_SELECT); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_GIZMO_MOVE_CURSOR); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_GIZMO_SELECT_BACKGROUND); + +/* wmGizmo.state */ +RNA_GIZMO_FLAG_RO_DEF(state_is_highlight, state, WM_GIZMO_STATE_HIGHLIGHT); +RNA_GIZMO_FLAG_RO_DEF(state_is_modal, state, WM_GIZMO_STATE_MODAL); +RNA_GIZMO_FLAG_RO_DEF(state_select, state, WM_GIZMO_STATE_SELECT); + +static void rna_Gizmo_state_select_set(struct PointerRNA *ptr, bool value) +{ + wmGizmo *gz = ptr->data; + wmGizmoGroup *gzgroup = gz->parent_gzgroup; + WM_gizmo_select_set(gzgroup->parent_gzmap, gz, value); +} + +static PointerRNA rna_Gizmo_group_get(PointerRNA *ptr) +{ + wmGizmo *gz = ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_GizmoGroup, gz->parent_gzgroup); +} + +#ifdef WITH_PYTHON + +static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type); +void BPY_RNA_gizmo_wrapper(wmGizmoType *gzgt, void *userdata); + +static StructRNA *rna_Gizmo_register( + Main *bmain, ReportList *reports, void *data, const char *identifier, + StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +{ + struct { + char idname[MAX_NAME]; + } temp_buffers; + + wmGizmoType dummygt = {NULL}; + wmGizmo dummymnp = {NULL}; + PointerRNA mnp_ptr; + + /* Two sets of functions. */ + int have_function[8]; + + /* setup dummy gizmo & gizmo type to store static properties in */ + dummymnp.type = &dummygt; + dummygt.idname = temp_buffers.idname; + RNA_pointer_create(NULL, &RNA_Gizmo, &dummymnp, &mnp_ptr); + + /* Clear so we can detect if it's left unset. */ + temp_buffers.idname[0] = '\0'; + + /* validate the python class */ + if (validate(&mnp_ptr, data, have_function) != 0) + return NULL; + + if (strlen(identifier) >= sizeof(temp_buffers.idname)) { + BKE_reportf(reports, RPT_ERROR, "Registering gizmo class: '%s' is too long, maximum length is %d", + identifier, (int)sizeof(temp_buffers.idname)); + return NULL; + } + + /* check if we have registered this gizmo type before, and remove it */ + { + const wmGizmoType *gzt = WM_gizmotype_find(dummygt.idname, true); + if (gzt && gzt->ext.srna) { + rna_Gizmo_unregister(bmain, gzt->ext.srna); + } + } + if (!RNA_struct_available_or_report(reports, dummygt.idname)) { + return NULL; + } + + { /* allocate the idname */ + /* For multiple strings see GizmoGroup. */ + dummygt.idname = BLI_strdup(temp_buffers.idname); + } + + /* create a new gizmo type */ + dummygt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummygt.idname, &RNA_Gizmo); + /* gizmo properties are registered separately */ + RNA_def_struct_flag(dummygt.ext.srna, STRUCT_NO_IDPROPERTIES); + dummygt.ext.data = data; + dummygt.ext.call = call; + dummygt.ext.free = free; + + { + int i = 0; + dummygt.draw = (have_function[i++]) ? rna_gizmo_draw_cb : NULL; + dummygt.draw_select = (have_function[i++]) ? rna_gizmo_draw_select_cb : NULL; + dummygt.test_select = (have_function[i++]) ? rna_gizmo_test_select_cb : NULL; + dummygt.modal = (have_function[i++]) ? rna_gizmo_modal_cb : NULL; +// dummygt.property_update = (have_function[i++]) ? rna_gizmo_property_update : NULL; +// dummygt.position_get = (have_function[i++]) ? rna_gizmo_position_get : NULL; + dummygt.setup = (have_function[i++]) ? rna_gizmo_setup_cb : NULL; + dummygt.invoke = (have_function[i++]) ? rna_gizmo_invoke_cb : NULL; + dummygt.exit = (have_function[i++]) ? rna_gizmo_exit_cb : NULL; + dummygt.select_refresh = (have_function[i++]) ? rna_gizmo_select_refresh_cb : NULL; + + BLI_assert(i == ARRAY_SIZE(have_function)); + } + + WM_gizmotype_append_ptr(BPY_RNA_gizmo_wrapper, (void *)&dummygt); + + /* update while blender is running */ + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + return dummygt.ext.srna; +} + +static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type) +{ + wmGizmoType *gzt = RNA_struct_blender_type_get(type); + + if (!gzt) { + return; + } + + RNA_struct_free_extension(type, &gzt->ext); + RNA_struct_free(&BLENDER_RNA, type); + + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + WM_gizmotype_remove_ptr(NULL, bmain, gzt); +} + +static void **rna_Gizmo_instance(PointerRNA *ptr) +{ + wmGizmo *gz = ptr->data; + return &gz->py_instance; +} + +#endif /* WITH_PYTHON */ + + +static StructRNA *rna_Gizmo_refine(PointerRNA *mnp_ptr) +{ + wmGizmo *gz = mnp_ptr->data; + return (gz->type && gz->type->ext.srna) ? gz->type->ext.srna : &RNA_Gizmo; +} + +/** \} */ + +/** \name Gizmo Group API + * \{ */ + +static wmGizmoGroupType *rna_GizmoGroupProperties_find_gizmo_group_type(PointerRNA *ptr) +{ + IDProperty *properties = (IDProperty *)ptr->data; + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(properties->name, false); + return gzgt; +} + +static StructRNA *rna_GizmoGroupProperties_refine(PointerRNA *ptr) +{ + wmGizmoGroupType *gzgt = rna_GizmoGroupProperties_find_gizmo_group_type(ptr); + + if (gzgt) + return gzgt->srna; + else + return ptr->type; +} + +static IDProperty *rna_GizmoGroupProperties_idprops(PointerRNA *ptr, bool create) +{ + if (create && !ptr->data) { + IDPropertyTemplate val = {0}; + ptr->data = IDP_New(IDP_GROUP, &val, "RNA_GizmoGroupProperties group"); + } + + return ptr->data; +} + + +static wmGizmo *rna_GizmoGroup_gizmo_new( + wmGizmoGroup *gzgroup, ReportList *reports, const char *idname) +{ + const wmGizmoType *gzt = WM_gizmotype_find(idname, true); + if (gzt == NULL) { + BKE_reportf(reports, RPT_ERROR, "GizmoType '%s' not known", idname); + return NULL; + } + wmGizmo *gz = WM_gizmo_new_ptr(gzt, gzgroup, NULL); + return gz; +} + +static void rna_GizmoGroup_gizmo_remove( + wmGizmoGroup *gzgroup, bContext *C, wmGizmo *gz) +{ + WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gz, C); +} + +static void rna_GizmoGroup_gizmo_clear( + wmGizmoGroup *gzgroup, bContext *C) +{ + while (gzgroup->gizmos.first) { + WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gzgroup->gizmos.first, C); + } +} + +static void rna_GizmoGroup_name_get(PointerRNA *ptr, char *value) +{ + wmGizmoGroup *gzgroup = ptr->data; + strcpy(value, gzgroup->type->name); +} + +static int rna_GizmoGroup_name_length(PointerRNA *ptr) +{ + wmGizmoGroup *gzgroup = ptr->data; + return strlen(gzgroup->type->name); +} + +/* just to work around 'const char *' warning and to ensure this is a python op */ +static void rna_GizmoGroup_bl_idname_set(PointerRNA *ptr, const char *value) +{ + wmGizmoGroup *data = ptr->data; + char *str = (char *)data->type->idname; + if (!str[0]) + BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ + else + assert(!"setting the bl_idname on a non-builtin operator"); +} + +static void rna_GizmoGroup_bl_label_set(PointerRNA *ptr, const char *value) +{ + wmGizmoGroup *data = ptr->data; + char *str = (char *)data->type->name; + if (!str[0]) + BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */ + else + assert(!"setting the bl_label on a non-builtin operator"); +} + +static bool rna_GizmoGroup_has_reports_get(PointerRNA *ptr) +{ + wmGizmoGroup *gzgroup = ptr->data; + return (gzgroup->reports && gzgroup->reports->list.first); +} + +#ifdef WITH_PYTHON + +static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *gzgt) +{ + + extern FunctionRNA rna_GizmoGroup_poll_func; + + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + void *ret; + bool visible; + + RNA_pointer_create(NULL, gzgt->ext.srna, NULL, &ptr); /* dummy */ + func = &rna_GizmoGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + gzgt->ext.call((bContext *)C, &ptr, func, &list); + + RNA_parameter_get_lookup(&list, "visible", &ret); + visible = *(bool *)ret; + + RNA_parameter_list_free(&list); + + return visible; +} + +static void rna_gizmogroup_setup_cb(const bContext *C, wmGizmoGroup *gzgroup) +{ + extern FunctionRNA rna_GizmoGroup_setup_func; + + PointerRNA gzgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); + func = &rna_GizmoGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */ + + RNA_parameter_list_create(&list, &gzgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *gzgt, wmKeyConfig *config) +{ + extern FunctionRNA rna_GizmoGroup_setup_keymap_func; + void *ret; + + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, gzgt->ext.srna, NULL, &ptr); /* dummy */ + func = &rna_GizmoGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */ + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "keyconfig", &config); + gzgt->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_get_lookup(&list, "keymap", &ret); + wmKeyMap *keymap = *(wmKeyMap **)ret; + + RNA_parameter_list_free(&list); + + return keymap; +} + +static void rna_gizmogroup_refresh_cb(const bContext *C, wmGizmoGroup *gzgroup) +{ + extern FunctionRNA rna_GizmoGroup_refresh_func; + + PointerRNA gzgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); + func = &rna_GizmoGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */ + + RNA_parameter_list_create(&list, &gzgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +static void rna_gizmogroup_draw_prepare_cb(const bContext *C, wmGizmoGroup *gzgroup) +{ + extern FunctionRNA rna_GizmoGroup_draw_prepare_func; + + PointerRNA gzgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); + func = &rna_GizmoGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */ + + RNA_parameter_list_create(&list, &gzgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +static void rna_gizmogroup_invoke_prepare_cb(const bContext *C, wmGizmoGroup *gzgroup, wmGizmo *gz) +{ + extern FunctionRNA rna_GizmoGroup_invoke_prepare_func; + + PointerRNA gzgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr); + func = &rna_GizmoGroup_invoke_prepare_func; /* RNA_struct_find_function(&wgroupr, "invoke_prepare"); */ + + RNA_parameter_list_create(&list, &gzgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "gizmo", &gz); + gzgroup->type->ext.call((bContext *)C, &gzgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata); +static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type); + +static StructRNA *rna_GizmoGroup_register( + Main *bmain, ReportList *reports, void *data, const char *identifier, + StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +{ + struct { + char name[MAX_NAME]; + char idname[MAX_NAME]; + } temp_buffers; + + wmGizmoGroupType dummywgt = {NULL}; + wmGizmoGroup dummywg = {NULL}; + PointerRNA wgptr; + + /* Two sets of functions. */ + int have_function[6]; + + /* setup dummy gizmogroup & gizmogroup type to store static properties in */ + dummywg.type = &dummywgt; + dummywgt.name = temp_buffers.name; + dummywgt.idname = temp_buffers.idname; + + RNA_pointer_create(NULL, &RNA_GizmoGroup, &dummywg, &wgptr); + + /* Clear so we can detect if it's left unset. */ + temp_buffers.idname[0] = temp_buffers.name[0] = '\0'; + + /* validate the python class */ + if (validate(&wgptr, data, have_function) != 0) + return NULL; + + if (strlen(identifier) >= sizeof(temp_buffers.idname)) { + BKE_reportf(reports, RPT_ERROR, "Registering gizmogroup class: '%s' is too long, maximum length is %d", + identifier, (int)sizeof(temp_buffers.idname)); + return NULL; + } + + /* check if the area supports widgets */ + const struct wmGizmoMapType_Params wmap_params = { + .spaceid = dummywgt.gzmap_params.spaceid, + .regionid = dummywgt.gzmap_params.regionid, + }; + + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&wmap_params); + if (gzmap_type == NULL) { + BKE_reportf(reports, RPT_ERROR, "Area type does not support gizmos"); + return NULL; + } + + /* check if we have registered this gizmogroup type before, and remove it */ + { + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(dummywgt.idname, true); + if (gzgt && gzgt->ext.srna) { + rna_GizmoGroup_unregister(bmain, gzgt->ext.srna); + } + } + if (!RNA_struct_available_or_report(reports, dummywgt.idname)) { + return NULL; + } + + { /* allocate the idname */ + const char *strings[] = { + temp_buffers.idname, + temp_buffers.name, + }; + char *strings_table[ARRAY_SIZE(strings)]; + BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings)); + + dummywgt.idname = strings_table[0]; /* allocated string stored here */ + dummywgt.name = strings_table[1]; + BLI_assert(ARRAY_SIZE(strings) == 2); + } + + /* create a new gizmogroup type */ + dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_GizmoGroup); + RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* gizmogroup properties are registered separately */ + dummywgt.ext.data = data; + dummywgt.ext.call = call; + dummywgt.ext.free = free; + + /* We used to register widget group types like this, now we do it similar to + * operator types. Thus we should be able to do the same as operator types now. */ + dummywgt.poll = (have_function[0]) ? rna_gizmogroup_poll_cb : NULL; + dummywgt.setup_keymap = (have_function[1]) ? rna_gizmogroup_setup_keymap_cb : NULL; + dummywgt.setup = (have_function[2]) ? rna_gizmogroup_setup_cb : NULL; + dummywgt.refresh = (have_function[3]) ? rna_gizmogroup_refresh_cb : NULL; + dummywgt.draw_prepare = (have_function[4]) ? rna_gizmogroup_draw_prepare_cb : NULL; + dummywgt.invoke_prepare = (have_function[5]) ? rna_gizmogroup_invoke_prepare_cb : NULL; + + wmGizmoGroupType *gzgt = WM_gizmogrouptype_append_ptr( + BPY_RNA_gizmogroup_wrapper, (void *)&dummywgt); + + { + const char *owner_id = RNA_struct_state_owner_get(); + if (owner_id) { + BLI_strncpy(gzgt->owner_id, owner_id, sizeof(gzgt->owner_id)); + } + } + + if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) { + WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type); + + /* update while blender is running */ + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + } + + return dummywgt.ext.srna; +} + +static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type) +{ + wmGizmoGroupType *gzgt = RNA_struct_blender_type_get(type); + + if (!gzgt) + return; + + RNA_struct_free_extension(type, &gzgt->ext); + RNA_struct_free(&BLENDER_RNA, type); + + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + WM_gizmo_group_type_remove_ptr(bmain, gzgt); +} + +static void **rna_GizmoGroup_instance(PointerRNA *ptr) +{ + wmGizmoGroup *gzgroup = ptr->data; + return &gzgroup->py_instance; +} + +#endif /* WITH_PYTHON */ + +static StructRNA *rna_GizmoGroup_refine(PointerRNA *gzgroup_ptr) +{ + wmGizmoGroup *gzgroup = gzgroup_ptr->data; + return (gzgroup->type && gzgroup->type->ext.srna) ? gzgroup->type->ext.srna : &RNA_GizmoGroup; +} + +static void rna_GizmoGroup_gizmos_begin(CollectionPropertyIterator *iter, PointerRNA *gzgroup_ptr) +{ + wmGizmoGroup *gzgroup = gzgroup_ptr->data; + rna_iterator_listbase_begin(iter, &gzgroup->gizmos, NULL); +} + +/** \} */ + + +#else /* RNA_RUNTIME */ + + +/* GizmoGroup.gizmos */ +static void rna_def_gizmos(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "Gizmos"); + srna = RNA_def_struct(brna, "Gizmos", NULL); + RNA_def_struct_sdna(srna, "wmGizmoGroup"); + RNA_def_struct_ui_text(srna, "Gizmos", "Collection of gizmos"); + + func = RNA_def_function(srna, "new", "rna_GizmoGroup_gizmo_new"); + RNA_def_function_ui_description(func, "Add gizmo"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_string(func, "type", "Type", 0, "", "Gizmo identifier"); /* optional */ + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_GizmoGroup_gizmo_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Delete gizmo"); + parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + + func = RNA_def_function(srna, "clear", "rna_GizmoGroup_gizmo_clear"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Delete all gizmos"); +} + + +static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "Gizmo"); + srna = RNA_def_struct(brna, "Gizmo", NULL); + RNA_def_struct_sdna(srna, "wmGizmo"); + RNA_def_struct_ui_text(srna, "Gizmo", "Collection of gizmos"); + RNA_def_struct_refine_func(srna, "rna_Gizmo_refine"); + +#ifdef WITH_PYTHON + RNA_def_struct_register_funcs( + srna, + "rna_Gizmo_register", + "rna_Gizmo_unregister", + "rna_Gizmo_instance"); +#endif + RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + + prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "GizmoProperties"); + RNA_def_property_ui_text(prop, "Properties", ""); + RNA_def_property_pointer_funcs(prop, "rna_Gizmo_properties_get", NULL, NULL, NULL); + + /* -------------------------------------------------------------------- */ + /* Registerable Variables */ + + RNA_define_verify_sdna(0); /* not in sdna */ + + prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->idname"); + RNA_def_property_string_maxlength(prop, MAX_NAME); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Gizmo_bl_idname_set"); + /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ + RNA_def_property_flag(prop, PROP_REGISTER); + + RNA_define_verify_sdna(1); /* not in sdna */ + + /* wmGizmo.draw */ + func = RNA_def_function(srna, "draw", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* wmGizmo.draw_select */ + func = RNA_def_function(srna, "draw_select", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX); + + /* wmGizmo.test_select */ + func = RNA_def_function(srna, "test_select", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_int_array(func, "location", 2, NULL, INT_MIN, INT_MAX, "Location", "Region coordinates", INT_MIN, INT_MAX); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_int(func, "intersect_id", 0, 0, INT_MAX, "", "", 0, INT_MAX); + RNA_def_function_return(func, parm); + + /* wmGizmo.handler */ + static EnumPropertyItem tweak_actions[] = { + {WM_GIZMO_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""}, + {WM_GIZMO_TWEAK_SNAP, "SNAP", 0, "Snap", ""}, + {0, NULL, 0, NULL, NULL} + }; + func = RNA_def_function(srna, "modal", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "event", "Event", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + /* TODO, shuold be a enum-flag */ + parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", ""); + RNA_def_function_return(func, parm); + /* wmGizmo.property_update */ + /* TODO */ + + /* wmGizmo.setup */ + func = RNA_def_function(srna, "setup", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + + /* wmGizmo.invoke */ + func = RNA_def_function(srna, "invoke", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "event", "Event", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_enum_flag(func, "result", rna_enum_operator_return_items, OPERATOR_CANCELLED, "result", ""); + RNA_def_function_return(func, parm); + + /* wmGizmo.exit */ + func = RNA_def_function(srna, "exit", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_boolean(func, "cancel", 0, "Cancel, otherwise confirm", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + /* wmGizmo.cursor_get */ + /* TODO */ + + /* wmGizmo.select_refresh */ + func = RNA_def_function(srna, "select_refresh", NULL); + RNA_def_function_ui_description(func, ""); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + + + /* -------------------------------------------------------------------- */ + /* Instance Variables */ + + prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "GizmoGroup"); + RNA_def_property_pointer_funcs(prop, "rna_Gizmo_group_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "", "Gizmo group this gizmo is a member of"); + + /* Color & Alpha */ + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_float_funcs(prop, "rna_Gizmo_color_get", "rna_Gizmo_color_set", NULL); + + prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Alpha", ""); + RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_get", "rna_Gizmo_alpha_set", NULL); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + /* Color & Alpha (highlight) */ + prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_float_funcs(prop, "rna_Gizmo_color_hi_get", "rna_Gizmo_color_hi_set", NULL); + + prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Alpha", ""); + RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_hi_get", "rna_Gizmo_alpha_hi_set", NULL); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Space Matrix", ""); + RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_space_get", "rna_Gizmo_matrix_space_set", NULL); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Basis Matrix", ""); + RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_basis_get", "rna_Gizmo_matrix_basis_set", NULL); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Offset Matrix", ""); + RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_offset_get", "rna_Gizmo_matrix_offset_set", NULL); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Final World Matrix", ""); + RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_world_get", NULL, NULL); + + prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Scale Basis", ""); + RNA_def_property_float_funcs(prop, "rna_Gizmo_scale_basis_get", "rna_Gizmo_scale_basis_set", NULL); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL); + RNA_def_property_ui_text(prop, "Line Width", ""); + RNA_def_property_float_funcs(prop, "rna_Gizmo_line_width_get", "rna_Gizmo_line_width_set", NULL); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + /* wmGizmo.flag */ + /* WM_GIZMO_HIDDEN */ + prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Gizmo_flag_hide_get", "rna_Gizmo_flag_hide_set"); + RNA_def_property_ui_text(prop, "Hide", ""); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_GIZMO_HIDDEN_SELECT */ + prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Gizmo_flag_hide_select_get", "rna_Gizmo_flag_hide_select_set"); + RNA_def_property_ui_text(prop, "Hide Select", ""); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_GIZMO_MOVE_CURSOR */ + prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Gizmo_flag_use_grab_cursor_get", "rna_Gizmo_flag_use_grab_cursor_set"); + RNA_def_property_ui_text(prop, "Grab Cursor", ""); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + /* WM_GIZMO_DRAW_HOVER */ + prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Gizmo_flag_use_draw_hover_get", "rna_Gizmo_flag_use_draw_hover_set"); + RNA_def_property_ui_text(prop, "Draw Hover", ""); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_GIZMO_DRAW_MODAL */ + prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Gizmo_flag_use_draw_modal_get", "rna_Gizmo_flag_use_draw_modal_set"); + RNA_def_property_ui_text(prop, "Draw Active", "Draw while dragging"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_GIZMO_DRAW_VALUE */ + prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Gizmo_flag_use_draw_value_get", "rna_Gizmo_flag_use_draw_value_set"); + RNA_def_property_ui_text(prop, "Draw Value", "Show an indicator for the current value while dragging"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_GIZMO_DRAW_OFFSET_SCALE */ + prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Gizmo_flag_use_draw_offset_scale_get", "rna_Gizmo_flag_use_draw_offset_scale_set"); + RNA_def_property_ui_text(prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_GIZMO_DRAW_NO_SCALE (negated) */ + prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Gizmo_flag_use_draw_scale_get", "rna_Gizmo_flag_use_draw_scale_set"); + RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_GIZMO_SELECT_BACKGROUND */ + prop = RNA_def_property(srna, "use_select_background", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Gizmo_flag_use_select_background_get", "rna_Gizmo_flag_use_select_background_set"); + RNA_def_property_ui_text(prop, "Select Background", "Don't write into the depth buffer"); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + /* wmGizmo.state (readonly) */ + /* WM_GIZMO_STATE_HIGHLIGHT */ + prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_highlight_get", NULL); + RNA_def_property_ui_text(prop, "Highlight", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + /* WM_GIZMO_STATE_MODAL */ + prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_modal_get", NULL); + RNA_def_property_ui_text(prop, "Highlight", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + /* WM_GIZMO_STATE_SELECT */ + /* (note that setting is involved, needs to handle array) */ + prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_select_get", "rna_Gizmo_state_select_set"); + RNA_def_property_ui_text(prop, "Select", ""); + + RNA_api_gizmo(srna); + + srna = RNA_def_struct(brna, "GizmoProperties", NULL); + RNA_def_struct_ui_text(srna, "Gizmo Properties", "Input properties of an Gizmo"); + RNA_def_struct_refine_func(srna, "rna_GizmoProperties_refine"); + RNA_def_struct_idprops_func(srna, "rna_GizmoProperties_idprops"); + RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES); +} + +static void rna_def_gizmogroup(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + srna = RNA_def_struct(brna, "GizmoGroup", NULL); + RNA_def_struct_ui_text(srna, "GizmoGroup", "Storage of an operator being executed, or registered after execution"); + RNA_def_struct_sdna(srna, "wmGizmoGroup"); + RNA_def_struct_refine_func(srna, "rna_GizmoGroup_refine"); +#ifdef WITH_PYTHON + RNA_def_struct_register_funcs( + srna, + "rna_GizmoGroup_register", + "rna_GizmoGroup_unregister", + "rna_GizmoGroup_instance"); +#endif + RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + + /* -------------------------------------------------------------------- */ + /* Registration */ + + RNA_define_verify_sdna(0); /* not in sdna */ + + prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->idname"); + RNA_def_property_string_maxlength(prop, MAX_NAME); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GizmoGroup_bl_idname_set"); + RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->name"); + RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */ + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GizmoGroup_bl_label_set"); + /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ + RNA_def_property_flag(prop, PROP_REGISTER); + + prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->gzmap_params.spaceid"); + RNA_def_property_enum_items(prop, rna_enum_space_type_items); + RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_property_ui_text(prop, "Space type", "The space where the panel is going to be used in"); + + prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->gzmap_params.regionid"); + RNA_def_property_enum_items(prop, rna_enum_region_type_items); + RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_property_ui_text(prop, "Region Type", "The region where the panel is going to be used in"); + + prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->owner_id"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + + /* bl_options */ + static EnumPropertyItem gizmogroup_flag_items[] = { + {WM_GIZMOGROUPTYPE_3D, "3D", 0, "3D", + "Use in 3D viewport"}, + {WM_GIZMOGROUPTYPE_SCALE, "SCALE", 0, "Scale", + "Scale to respect zoom (otherwise zoom independent draw size)"}, + {WM_GIZMOGROUPTYPE_DEPTH_3D, "DEPTH_3D", 0, "Depth 3D", + "Supports culled depth by other objects in the view"}, + {WM_GIZMOGROUPTYPE_SELECT, "SELECT", 0, "Select", + "Supports selection"}, + {WM_GIZMOGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent", + ""}, + {WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL, "SHOW_MODAL_ALL", 0, "Show Modal All", + "Show all while interacting"}, + {WM_GIZMOGROUPTYPE_TOOL_INIT, "TOOL_INIT", 0, "Tool Init", + "Postpone running until tool operator run (when used with a tool)"}, + {0, NULL, 0, NULL, NULL} + }; + prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->flag"); + RNA_def_property_enum_items(prop, gizmogroup_flag_items); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Options", "Options for this operator type"); + + RNA_define_verify_sdna(1); /* not in sdna */ + + + /* Functions */ + + /* poll */ + func = RNA_def_function(srna, "poll", NULL); + RNA_def_function_ui_description(func, "Test if the gizmo group can be called or not"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL); + RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* setup_keymap */ + func = RNA_def_function(srna, "setup_keymap", NULL); + RNA_def_function_ui_description( + func, + "Initialize keymaps for this gizmo group, use fallback keymap when not present"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + /* return */ + parm = RNA_def_pointer(func, "keymap", "KeyMap", "", ""); + RNA_def_property_flag(parm, PROP_NEVER_NULL); + RNA_def_function_return(func, parm); + + /* setup */ + func = RNA_def_function(srna, "setup", NULL); + RNA_def_function_ui_description(func, "Create gizmos function for the gizmo group"); + RNA_def_function_flag(func, FUNC_REGISTER); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* refresh */ + func = RNA_def_function(srna, "refresh", NULL); + RNA_def_function_ui_description(func, "Refresh data (called on common state changes such as selection)"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + func = RNA_def_function(srna, "draw_prepare", NULL); + RNA_def_function_ui_description(func, "Run before each redraw"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + func = RNA_def_function(srna, "invoke_prepare", NULL); + RNA_def_function_ui_description(func, "Run before invoke"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + /* -------------------------------------------------------------------- */ + /* Instance Variables */ + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs(prop, "rna_GizmoGroup_name_get", "rna_GizmoGroup_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", ""); + + prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */ + RNA_def_property_boolean_funcs(prop, "rna_GizmoGroup_has_reports_get", NULL); + RNA_def_property_ui_text(prop, "Has Reports", + "GizmoGroup has a set of reports (warnings and errors) from last execution"); + + + RNA_define_verify_sdna(0); /* not in sdna */ + + prop = RNA_def_property(srna, "gizmos", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "gizmos", NULL); + RNA_def_property_struct_type(prop, "Gizmo"); + RNA_def_property_collection_funcs( + prop, "rna_GizmoGroup_gizmos_begin", "rna_iterator_listbase_next", + "rna_iterator_listbase_end", "rna_iterator_listbase_get", + NULL, NULL, NULL, NULL); + + RNA_def_property_ui_text(prop, "Gizmos", "List of gizmos in the Gizmo Map"); + rna_def_gizmo(brna, prop); + rna_def_gizmos(brna, prop); + + RNA_define_verify_sdna(1); /* not in sdna */ + + RNA_api_gizmogroup(srna); + + srna = RNA_def_struct(brna, "GizmoGroupProperties", NULL); + RNA_def_struct_ui_text(srna, "Gizmo Group Properties", "Input properties of a Gizmo Group"); + RNA_def_struct_refine_func(srna, "rna_GizmoGroupProperties_refine"); + RNA_def_struct_idprops_func(srna, "rna_GizmoGroupProperties_idprops"); + RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES); +} + +void RNA_def_wm_gizmo(BlenderRNA *brna) +{ + rna_def_gizmogroup(brna); +} + +#endif /* RNA_RUNTIME */ diff --git a/source/blender/makesrna/intern/rna_wm_gizmo_api.c b/source/blender/makesrna/intern/rna_wm_gizmo_api.c new file mode 100644 index 00000000000..37c4e22b68e --- /dev/null +++ b/source/blender/makesrna/intern/rna_wm_gizmo_api.c @@ -0,0 +1,290 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_wm_gizmo_api.c + * \ingroup RNA + */ + + +#include <stdlib.h> +#include <stdio.h> + +#include "BLI_utildefines.h" + +#include "BKE_report.h" + +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "DNA_windowmanager_types.h" + +#include "WM_api.h" + +#include "rna_internal.h" /* own include */ + +#ifdef RNA_RUNTIME + +#include "UI_interface.h" +#include "BKE_context.h" + +#include "ED_gizmo_library.h" + +static void rna_gizmo_draw_preset_box( + wmGizmo *gz, float matrix[16], int select_id) +{ + ED_gizmo_draw_preset_box(gz, (float (*)[4])matrix, select_id); +} + +static void rna_gizmo_draw_preset_arrow( + wmGizmo *gz, float matrix[16], int axis, int select_id) +{ + ED_gizmo_draw_preset_arrow(gz, (float (*)[4])matrix, axis, select_id); +} + +static void rna_gizmo_draw_preset_circle( + wmGizmo *gz, float matrix[16], int axis, int select_id) +{ + ED_gizmo_draw_preset_circle(gz, (float (*)[4])matrix, axis, select_id); +} + +static void rna_gizmo_draw_preset_facemap( + wmGizmo *gz, struct bContext *C, struct Object *ob, int facemap, int select_id) +{ + ED_gizmo_draw_preset_facemap(C, gz, ob, facemap, select_id); +} + +/* -------------------------------------------------------------------- */ +/** \name Gizmo Property Define + * \{ */ + +static void rna_gizmo_target_set_prop( + wmGizmo *gz, ReportList *reports, const char *target_propname, + PointerRNA *ptr, const char *propname, int index) +{ + const wmGizmoPropertyType *gz_prop_type = + WM_gizmotype_target_property_find(gz->type, target_propname); + if (gz_prop_type == NULL) { + BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s' not found", + gz->type->idname, target_propname); + return; + } + + PropertyRNA *prop = RNA_struct_find_property(ptr, propname); + if (prop == NULL) { + BKE_reportf(reports, RPT_ERROR, "Property '%s.%s' not found", + RNA_struct_identifier(ptr->type), target_propname); + return; + } + + if (gz_prop_type->data_type != RNA_property_type(prop)) { + const int gizmo_type_index = RNA_enum_from_value(rna_enum_property_type_items, gz_prop_type->data_type); + const int prop_type_index = RNA_enum_from_value(rna_enum_property_type_items, RNA_property_type(prop)); + BLI_assert((gizmo_type_index != -1) && (prop_type_index == -1)); + + BKE_reportf(reports, RPT_ERROR, "Gizmo target '%s.%s' expects '%s', '%s.%s' is '%s'", + gz->type->idname, target_propname, + rna_enum_property_type_items[gizmo_type_index].identifier, + RNA_struct_identifier(ptr->type), propname, + rna_enum_property_type_items[prop_type_index].identifier); + return; + } + + if (RNA_property_array_check(prop)) { + if (index == -1) { + const int prop_array_length = RNA_property_array_length(ptr, prop); + if (gz_prop_type->array_length != prop_array_length) { + BKE_reportf(reports, RPT_ERROR, + "Gizmo target property '%s.%s' expects an array of length %d, found %d", + gz->type->idname, target_propname, + gz_prop_type->array_length, + prop_array_length); + return; + } + } + } + else { + if (gz_prop_type->array_length != 1) { + BKE_reportf(reports, RPT_ERROR, + "Gizmo target property '%s.%s' expects an array of length %d", + gz->type->idname, target_propname, + gz_prop_type->array_length); + return; + } + } + + if (index >= gz_prop_type->array_length) { + BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s', index %d must be below %d", + gz->type->idname, target_propname, index, gz_prop_type->array_length); + return; + } + + WM_gizmo_target_property_def_rna_ptr(gz, gz_prop_type, ptr, prop, index); +} + +static PointerRNA rna_gizmo_target_set_operator( + wmGizmo *gz, ReportList *reports, const char *opname, int part_index) +{ + wmOperatorType *ot; + + ot = WM_operatortype_find(opname, 0); /* print error next */ + if (!ot || !ot->srna) { + BKE_reportf(reports, RPT_ERROR, "%s '%s'", ot ? "unknown operator" : "operator missing srna", opname); + return PointerRNA_NULL; + } + + /* For the return value to be usable, we need 'PointerRNA.data' to be set. */ + IDProperty *properties; + { + IDPropertyTemplate val = {0}; + properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties"); + } + + return *WM_gizmo_operator_set(gz, part_index, ot, properties); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Gizmo Property Access + * \{ */ + +static bool rna_gizmo_target_is_valid( + wmGizmo *gz, ReportList *reports, const char *target_propname) +{ + wmGizmoProperty *gz_prop = + WM_gizmo_target_property_find(gz, target_propname); + if (gz_prop == NULL) { + BKE_reportf(reports, RPT_ERROR, "Gizmo target property '%s.%s' not found", + gz->type->idname, target_propname); + return false; + } + return WM_gizmo_target_property_is_valid(gz_prop); +} + +/** \} */ + +#else + +void RNA_api_gizmo(StructRNA *srna) +{ + /* Utility draw functions, since we don't expose new OpenGL drawing wrappers via Python yet. + * exactly how these should be exposed isn't totally clear. + * However it's probably good to have some high level API's for this anyway. + * Just note that this could be re-worked once tests are done. + */ + + FunctionRNA *func; + PropertyRNA *parm; + + /* -------------------------------------------------------------------- */ + /* Primitive Shapes */ + + /* draw_preset_box */ + func = RNA_def_function(srna, "draw_preset_box", "rna_gizmo_draw_preset_box"); + RNA_def_function_ui_description(func, "Draw a box"); + parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(parm, "", "The matrix to transform"); + RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); + + /* draw_preset_box */ + func = RNA_def_function(srna, "draw_preset_arrow", "rna_gizmo_draw_preset_arrow"); + RNA_def_function_ui_description(func, "Draw a box"); + parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(parm, "", "The matrix to transform"); + RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow Orientation"); + RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); + + func = RNA_def_function(srna, "draw_preset_circle", "rna_gizmo_draw_preset_circle"); + RNA_def_function_ui_description(func, "Draw a box"); + parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(parm, "", "The matrix to transform"); + RNA_def_enum(func, "axis", rna_enum_object_axis_items, 2, "", "Arrow Orientation"); + RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); + + /* -------------------------------------------------------------------- */ + /* Other Shapes */ + + /* draw_preset_facemap */ + func = RNA_def_function(srna, "draw_preset_facemap", "rna_gizmo_draw_preset_facemap"); + RNA_def_function_ui_description(func, "Draw the face-map of a mesh object"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + parm = RNA_def_pointer(func, "object", "Object", "", "Object"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_int(func, "face_map", 0, 0, INT_MAX, "Face map index", "", 0, INT_MAX); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); + + + /* -------------------------------------------------------------------- */ + /* Property API */ + + /* Define Properties */ + /* note, 'target_set_handler' is defined in 'bpy_rna_gizmo.c' */ + func = RNA_def_function(srna, "target_set_prop", "rna_gizmo_target_set_prop"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, ""); + parm = RNA_def_string(func, "target", NULL, 0, "", "Target property"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* similar to UILayout.prop */ + parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in data"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_int(func, "index", -1, -1, INT_MAX, "", "", -1, INT_MAX); /* RNA_NO_INDEX == -1 */ + + func = RNA_def_function(srna, "target_set_operator", "rna_gizmo_target_set_operator"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description( + func, "Operator to run when activating the gizmo " + "(overrides property targets)"); + parm = RNA_def_string(func, "operator", NULL, 0, "", "Target operator"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_int(func, "index", 0, 0, 255, "Part index", "", 0, 255); + + /* similar to UILayout.operator */ + parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "Operator properties to fill in"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_function_return(func, parm); + + /* Access Properties */ + /* note, 'target_get', 'target_set' is defined in 'bpy_rna_gizmo.c' */ + func = RNA_def_function(srna, "target_is_valid", "rna_gizmo_target_is_valid"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_string(func, "property", NULL, 0, "", "Property identifier"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_function_ui_description(func, ""); + parm = RNA_def_boolean(func, "result", 0, "", ""); + RNA_def_function_return(func, parm); + +} + + +void RNA_api_gizmogroup(StructRNA *UNUSED(srna)) +{ + /* nothing yet */ +} + +#endif diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c new file mode 100644 index 00000000000..59b1086e17e --- /dev/null +++ b/source/blender/makesrna/intern/rna_workspace.c @@ -0,0 +1,371 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_workspace.c + * \ingroup RNA + */ + +#include "RNA_define.h" +#include "RNA_enum_types.h" +#include "RNA_types.h" + +#include "BKE_workspace.h" + +#include "ED_render.h" + +#include "RE_engine.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "rna_internal.h" + +/* Allow accessing private members of DNA_workspace_types.h */ +#define DNA_PRIVATE_WORKSPACE_ALLOW +#include "DNA_workspace_types.h" + +#ifdef RNA_RUNTIME + +#include "BLI_listbase.h" + +#include "BKE_global.h" + +#include "DNA_object_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" + +#include "RNA_access.h" + +#include "WM_toolsystem.h" + +static void rna_window_update_all(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ + WM_main_add_notifier(NC_WINDOW, NULL); +} + +void rna_workspace_screens_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + WorkSpace *workspace = ptr->id.data; + rna_iterator_listbase_begin(iter, BKE_workspace_layouts_get(workspace), NULL); +} + +static PointerRNA rna_workspace_screens_item_get(CollectionPropertyIterator *iter) +{ + WorkSpaceLayout *layout = rna_iterator_listbase_get(iter); + bScreen *screen = BKE_workspace_layout_screen_get(layout); + + return rna_pointer_inherit_refine(&iter->parent, &RNA_Screen, screen); +} + +/* workspace.owner_ids */ + +static wmOwnerID *rna_WorkSpace_owner_ids_new( + WorkSpace *workspace, const char *name) +{ + wmOwnerID *owner_id = MEM_callocN(sizeof(*owner_id), __func__); + BLI_addtail(&workspace->owner_ids, owner_id); + BLI_strncpy(owner_id->name, name, sizeof(owner_id->name)); + WM_main_add_notifier(NC_WINDOW, NULL); + return owner_id; +} + +static void rna_WorkSpace_owner_ids_remove( + WorkSpace *workspace, ReportList *reports, PointerRNA *wstag_ptr) +{ + wmOwnerID *owner_id = wstag_ptr->data; + if (BLI_remlink_safe(&workspace->owner_ids, owner_id) == false) { + BKE_reportf(reports, RPT_ERROR, + "wmOwnerID '%s' not in workspace '%s'", + owner_id->name, workspace->id.name + 2); + return; + } + + MEM_freeN(owner_id); + RNA_POINTER_INVALIDATE(wstag_ptr); + + WM_main_add_notifier(NC_WINDOW, NULL); +} + +static void rna_WorkSpace_owner_ids_clear( + WorkSpace *workspace) +{ + BLI_freelistN(&workspace->owner_ids); + WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, workspace); +} + +static bToolRef *rna_WorkSpace_tools_from_tkey(WorkSpace *workspace, const bToolKey *tkey, bool create) +{ + if (create) { + bToolRef *tref; + WM_toolsystem_ref_ensure(workspace, tkey, &tref); + return tref; + } + return WM_toolsystem_ref_find(workspace, tkey); +} + +static bToolRef *rna_WorkSpace_tools_from_space_view3d_mode( + WorkSpace *workspace, int mode, bool create) +{ + return rna_WorkSpace_tools_from_tkey(workspace, &(bToolKey){ .space_type = SPACE_VIEW3D, .mode = mode}, create); +} + +static bToolRef *rna_WorkSpace_tools_from_space_image_mode( + WorkSpace *workspace, int mode, bool create) +{ + return rna_WorkSpace_tools_from_tkey(workspace, &(bToolKey){ .space_type = SPACE_IMAGE, .mode = mode}, create); +} + +const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf( + bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) +{ + WorkSpace *workspace = ptr->id.data; + + switch (workspace->tools_space_type) { + case SPACE_VIEW3D: + return rna_enum_context_mode_items; + case SPACE_IMAGE: + return rna_enum_space_image_mode_items; + } + return DummyRNA_DEFAULT_items; +} + +static int rna_WorkspaceTool_index_get(PointerRNA *ptr) +{ + bToolRef *tref = ptr->data; + return (tref->runtime) ? tref->runtime->index : 0; +} + +static int rna_WorkspaceTool_has_datablock_get(PointerRNA *ptr) +{ + bToolRef *tref = ptr->data; + return (tref->runtime) ? (tref->runtime->data_block[0] != '\0') : false; +} + +static void rna_WorkspaceTool_widget_get(PointerRNA *ptr, char *value) +{ + bToolRef *tref = ptr->data; + strcpy(value, tref->runtime ? tref->runtime->gizmo_group : ""); +} + +static int rna_WorkspaceTool_widget_length(PointerRNA *ptr) +{ + bToolRef *tref = ptr->data; + return tref->runtime ? strlen(tref->runtime->gizmo_group) : 0; +} + +#else /* RNA_RUNTIME */ + +static void rna_def_workspace_owner(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "wmOwnerID", NULL); + RNA_def_struct_sdna(srna, "wmOwnerID"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); + RNA_def_struct_ui_text(srna, "Work Space UI Tag", ""); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_struct_name_property(srna, prop); +} + +static void rna_def_workspace_owner_ids(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "wmOwnerIDs"); + srna = RNA_def_struct(brna, "wmOwnerIDs", NULL); + RNA_def_struct_sdna(srna, "WorkSpace"); + RNA_def_struct_ui_text(srna, "WorkSpace UI Tags", ""); + + /* add owner_id */ + func = RNA_def_function(srna, "new", "rna_WorkSpace_owner_ids_new"); + RNA_def_function_ui_description(func, "Add ui tag"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the tag"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "owner_id", "wmOwnerID", "", ""); + RNA_def_function_return(func, parm); + + /* remove owner_id */ + func = RNA_def_function(srna, "remove", "rna_WorkSpace_owner_ids_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove ui tag"); + /* owner_id to remove */ + parm = RNA_def_pointer(func, "owner_id", "wmOwnerID", "", "Tag 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 modifiers */ + func = RNA_def_function(srna, "clear", "rna_WorkSpace_owner_ids_clear"); + RNA_def_function_ui_description(func, "Remove all tags"); +} + +static void rna_def_workspace_tool(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "WorkspaceTool", NULL); + RNA_def_struct_sdna(srna, "bToolRef"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); + RNA_def_struct_ui_text(srna, "Work Space Tool", ""); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "idname"); + RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Index", ""); + RNA_def_property_int_funcs(prop, "rna_WorkspaceTool_index_get", NULL, NULL); + + prop = RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "space_type"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_items(prop, rna_enum_space_type_items); + RNA_def_property_ui_text(prop, "Space Type", ""); + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_WorkSpace_tools_mode_itemf"); + RNA_def_property_ui_text(prop, "Tool Mode", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + RNA_define_verify_sdna(0); + prop = RNA_def_property(srna, "has_datablock", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Has Datablock", ""); + RNA_def_property_boolean_funcs(prop, "rna_WorkspaceTool_has_datablock_get", NULL); + RNA_define_verify_sdna(1); + + prop = RNA_def_property(srna, "widget", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Widget", ""); + RNA_def_property_string_funcs(prop, "rna_WorkspaceTool_widget_get", "rna_WorkspaceTool_widget_length", NULL); + RNA_define_verify_sdna(1); + + RNA_api_workspace_tool(srna); +} + +static void rna_def_workspace_tools(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "wmTools"); + srna = RNA_def_struct(brna, "wmTools", NULL); + RNA_def_struct_sdna(srna, "WorkSpace"); + RNA_def_struct_ui_text(srna, "WorkSpace UI Tags", ""); + + /* add owner_id */ + func = RNA_def_function(srna, "from_space_view3d_mode", "rna_WorkSpace_tools_from_space_view3d_mode"); + RNA_def_function_ui_description(func, ""); + parm = RNA_def_enum(func, "mode", rna_enum_context_mode_items, 0, "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_boolean(func, "create", false, "Create", ""); + /* return type */ + parm = RNA_def_pointer(func, "result", "WorkspaceTool", "", ""); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "from_space_image_mode", "rna_WorkSpace_tools_from_space_image_mode"); + RNA_def_function_ui_description(func, ""); + parm = RNA_def_enum(func, "mode", rna_enum_space_image_mode_items, 0, "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_boolean(func, "create", false, "Create", ""); + /* return type */ + parm = RNA_def_pointer(func, "result", "WorkspaceTool", "", ""); + RNA_def_function_return(func, parm); +} + +static void rna_def_workspace(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "WorkSpace", "ID"); + RNA_def_struct_sdna(srna, "WorkSpace"); + RNA_def_struct_ui_text(srna, "Workspace", "Workspace data-block, defining the working environment for the user"); + /* TODO: real icon, just to show something */ + RNA_def_struct_ui_icon(srna, ICON_WORKSPACE); + + prop = RNA_def_property(srna, "screens", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "layouts", NULL); + RNA_def_property_struct_type(prop, "Screen"); + RNA_def_property_collection_funcs(prop, "rna_workspace_screens_begin", NULL, NULL, + "rna_workspace_screens_item_get", NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Screens", "Screen layouts of a workspace"); + + prop = RNA_def_property(srna, "owner_ids", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "wmOwnerID"); + RNA_def_property_ui_text(prop, "UI Tags", ""); + rna_def_workspace_owner_ids(brna, prop); + + prop = RNA_def_property(srna, "tools", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "tools", NULL); + RNA_def_property_struct_type(prop, "WorkspaceTool"); + RNA_def_property_ui_text(prop, "Tools", ""); + rna_def_workspace_tools(brna, prop); + + prop = RNA_def_property(srna, "tools_space_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "tools_space_type"); + RNA_def_property_enum_items(prop, rna_enum_space_type_items); + RNA_def_property_ui_text(prop, "Active Tool Space", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop = RNA_def_property(srna, "tools_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "tools_mode"); + RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_WorkSpace_tools_mode_itemf"); + RNA_def_property_ui_text(prop, "Active Tool Mode", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_enum_workspace_object_mode_items); + RNA_def_property_ui_text(prop, "Object Mode", "Switch to this object mode when activating the workspace"); + + /* Flags */ + prop = RNA_def_property(srna, "use_filter_by_owner", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", WORKSPACE_USE_FILTER_BY_ORIGIN); + RNA_def_property_ui_text(prop, "Use UI Tags", + "Filter the UI by tags"); + RNA_def_property_update(prop, 0, "rna_window_update_all"); + + RNA_api_workspace(srna); +} + +void RNA_def_workspace(BlenderRNA *brna) +{ + rna_def_workspace_owner(brna); + rna_def_workspace_tool(brna); + + rna_def_workspace(brna); +} + +#endif /* RNA_RUNTIME */ diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c new file mode 100644 index 00000000000..fd268c898ff --- /dev/null +++ b/source/blender/makesrna/intern/rna_workspace_api.c @@ -0,0 +1,176 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_workspace_api.c + * \ingroup RNA + */ + + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <time.h> + +#include "BLI_utildefines.h" + +#include "RNA_define.h" + +#include "DNA_object_types.h" +#include "DNA_windowmanager_types.h" + +#include "RNA_enum_types.h" /* own include */ + +#include "rna_internal.h" /* own include */ + +#ifdef RNA_RUNTIME + +#include "BKE_paint.h" + +#include "ED_screen.h" + +static void rna_WorkspaceTool_setup( + ID *id, + bToolRef *tref, + bContext *C, + const char *name, + /* Args for: 'bToolRef_Runtime'. */ + int cursor, + const char *keymap, + const char *gizmo_group, + const char *data_block, + const char *operator, + int index) +{ + bToolRef_Runtime tref_rt = {0}; + + tref_rt.cursor = cursor; + STRNCPY(tref_rt.keymap, keymap); + STRNCPY(tref_rt.gizmo_group, gizmo_group); + STRNCPY(tref_rt.data_block, data_block); + STRNCPY(tref_rt.op, operator); + tref_rt.index = index; + + WM_toolsystem_ref_set_from_runtime(C, (WorkSpace *)id, tref, &tref_rt, name); +} + +static void rna_WorkspaceTool_refresh_from_context( + ID *id, + bToolRef *tref, + Main *bmain) +{ + WM_toolsystem_ref_sync_from_context(bmain, (WorkSpace *)id, tref); +} + +static PointerRNA rna_WorkspaceTool_operator_properties( + bToolRef *tref, + ReportList *reports, + const char *idname) +{ + wmOperatorType *ot = WM_operatortype_find(idname, true); + + if (ot != NULL) { + PointerRNA ptr; + WM_toolsystem_ref_properties_ensure_from_operator(tref, ot, &ptr); + return ptr; + } + else { + BKE_reportf(reports, RPT_ERROR, "Operator '%s' not found!", idname); + } + return PointerRNA_NULL; +} + +static PointerRNA rna_WorkspaceTool_gizmo_group_properties( + bToolRef *tref, + ReportList *reports, + const char *idname) +{ + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + if (gzgt != NULL) { + PointerRNA ptr; + WM_toolsystem_ref_properties_ensure_from_gizmo_group(tref, gzgt, &ptr); + return ptr; + } + else { + BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' not found!", idname); + } + return PointerRNA_NULL; +} + +#else + +void RNA_api_workspace(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func = RNA_def_function(srna, "status_text_set", "ED_workspace_status_text"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Set the status bar text, typically key shortcuts for modal operators"); + parm = RNA_def_string(func, "text", NULL, 0, "Text", "New string for the status bar, None clears the text"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_property_clear_flag(parm, PROP_NEVER_NULL); +} + +void RNA_api_workspace_tool(StructRNA *srna) +{ + PropertyRNA *parm; + FunctionRNA *func; + + func = RNA_def_function(srna, "setup", "rna_WorkspaceTool_setup"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Set the tool settings"); + + parm = RNA_def_string(func, "name", NULL, KMAP_MAX_NAME, "Name", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + /* 'bToolRef_Runtime' */ + parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(parm, rna_enum_window_cursor_items); + RNA_def_string(func, "keymap", NULL, KMAP_MAX_NAME, "Key Map", ""); + RNA_def_string(func, "gizmo_group", NULL, MAX_NAME, "Gizmo Group", ""); + RNA_def_string(func, "data_block", NULL, MAX_NAME, "Data Block", ""); + RNA_def_string(func, "operator", NULL, MAX_NAME, "Operator", ""); + RNA_def_int(func, "index", 0, INT_MIN, INT_MAX, "Index", "", INT_MIN, INT_MAX); + + /* Access tool operator options (optionally create). */ + func = RNA_def_function(srna, "operator_properties", "rna_WorkspaceTool_operator_properties"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_string(func, "operator", NULL, 0, "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return */ + parm = RNA_def_pointer(func, "result", "OperatorProperties", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); + RNA_def_function_return(func, parm); + + /* Access gizmo-group options (optionally create). */ + func = RNA_def_function(srna, "gizmo_group_properties", "rna_WorkspaceTool_gizmo_group_properties"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_string(func, "group", NULL, 0, "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return */ + parm = RNA_def_pointer(func, "result", "GizmoGroupProperties", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "refresh_from_context", "rna_WorkspaceTool_refresh_from_context"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 08287308e08..fe561cdef1c 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -43,10 +43,12 @@ #include "MEM_guardedalloc.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_texture.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "ED_node.h" #include "WM_api.h" @@ -62,33 +64,11 @@ static PointerRNA rna_World_mist_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_WorldMistSettings, ptr->id.data); } -static void rna_World_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - World *wo = (World *)ptr->data; - rna_iterator_array_begin(iter, (void *)wo->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL); -} - -static PointerRNA rna_World_active_texture_get(PointerRNA *ptr) -{ - World *wo = (World *)ptr->data; - Tex *tex; - - tex = give_current_world_texture(wo); - return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex); -} - -static void rna_World_active_texture_set(PointerRNA *ptr, PointerRNA value) -{ - World *wo = (World *)ptr->data; - - set_current_world_texture(wo, value.data); -} - static void rna_World_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { World *wo = ptr->id.data; - DAG_id_tag_update(&wo->id, 0); + DEG_id_tag_update(&wo->id, 0); WM_main_add_notifier(NC_WORLD | ND_WORLD, wo); } @@ -97,7 +77,7 @@ static void rna_World_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi { World *wo = ptr->id.data; - DAG_id_tag_update(&wo->id, 0); + DEG_id_tag_update(&wo->id, 0); WM_main_add_notifier(NC_WORLD | ND_WORLD_DRAW, wo); } #endif @@ -106,7 +86,7 @@ static void rna_World_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi { World *wo = ptr->id.data; - DAG_id_tag_update(&wo->id, 0); + DEG_id_tag_update(&wo->id, 0); WM_main_add_notifier(NC_WORLD | ND_WORLD_DRAW, wo); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } @@ -114,126 +94,24 @@ static void rna_World_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi static void rna_World_use_nodes_update(bContext *C, PointerRNA *ptr) { World *wrld = (World *)ptr->data; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); if (wrld->use_nodes && wrld->nodetree == NULL) ED_node_shader_default(C, &wrld->id); - rna_World_update(CTX_data_main(C), CTX_data_scene(C), ptr); + DEG_relations_tag_update(bmain); + rna_World_update(bmain, scene, ptr); + rna_World_draw_update(bmain, scene, ptr); } #else -static void rna_def_world_mtex(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem texco_items[] = { - {TEXCO_VIEW, "VIEW", 0, "View", "Use view vector for the texture coordinates"}, - {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates (interior mist)"}, - {TEXCO_ANGMAP, "ANGMAP", 0, "AngMap", "Use 360 degree angular coordinates, e.g. for spherical light probes"}, - {TEXCO_H_SPHEREMAP, "SPHERE", 0, "Sphere", "For 360 degree panorama sky, spherical mapped, only top half"}, - {TEXCO_EQUIRECTMAP, "EQUIRECT", 0, "Equirectangular", "For 360 degree panorama sky, equirectangular mapping"}, - {TEXCO_H_TUBEMAP, "TUBE", 0, "Tube", "For 360 degree panorama sky, cylindrical mapped, only top half"}, - {TEXCO_OBJECT, "OBJECT", 0, "Object", "Use linked object's coordinates for texture coordinates"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "WorldTextureSlot", "TextureSlot"); - RNA_def_struct_sdna(srna, "MTex"); - RNA_def_struct_ui_text(srna, "World Texture Slot", "Texture slot for textures in a World data-block"); - - /* map to */ - prop = RNA_def_property(srna, "use_map_blend", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_BLEND); - RNA_def_property_ui_text(prop, "Blend", "Affect the color progression of the background"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "use_map_horizon", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_HORIZ); - RNA_def_property_ui_text(prop, "Horizon", "Affect the color of the horizon"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "use_map_zenith_up", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENUP); - RNA_def_property_ui_text(prop, "Zenith Up", "Affect the color of the zenith above"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "use_map_zenith_down", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENDOWN); - RNA_def_property_ui_text(prop, "Zenith Down", "Affect the color of the zenith below"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "texco"); - RNA_def_property_enum_items(prop, texco_items); - RNA_def_property_ui_text(prop, "Texture Coordinates", - "Texture coordinates used to map the texture onto the background"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - 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 mapping with Object texture coordinates"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "blend_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "blendfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Blend Factor", "Amount texture affects color progression of the background"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "horizon_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "colfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Horizon Factor", "Amount texture affects color of the horizon"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "zenith_up_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "zenupfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Zenith Up Factor", "Amount texture affects color of the zenith above"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "zenith_down_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "zendownfac"); - RNA_def_property_ui_range(prop, 0, 1, 10, 3); - RNA_def_property_ui_text(prop, "Zenith Down Factor", "Amount texture affects color of the zenith below"); - RNA_def_property_update(prop, 0, "rna_World_update"); -} - static void rna_def_lighting(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem blend_mode_items[] = { - {WO_AOMUL, "MULTIPLY", 0, "Multiply", "Multiply direct lighting with ambient occlusion, darkening the result"}, - {WO_AOADD, "ADD", 0, "Add", "Add light and shadow"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_color_items[] = { - {WO_AOPLAIN, "PLAIN", 0, "White", "Plain diffuse energy (white.)"}, - {WO_AOSKYCOL, "SKY_COLOR", 0, "Sky Color", "Use horizon and zenith color for diffuse energy"}, - {WO_AOSKYTEX, "SKY_TEXTURE", 0, "Sky Texture", "Does full Sky texture render for diffuse energy"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_sample_method_items[] = { - {WO_AOSAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", "Fastest and gives the most noise"}, - {WO_AOSAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", "Fast in high-contrast areas"}, - {WO_AOSAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", "Best quality"}, - {0, NULL, 0, NULL, NULL} - }; - - static const EnumPropertyItem prop_gather_method_items[] = { - {WO_AOGATHER_RAYTRACE, "RAYTRACE", 0, "Raytrace", "Accurate, but slow when noise-free results are required"}, - {WO_AOGATHER_APPROX, "APPROXIMATE", 0, "Approximate", "Inaccurate, but faster and without noise"}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "WorldLighting", NULL); RNA_def_struct_sdna(srna, "World"); RNA_def_struct_nested(brna, srna, "World"); @@ -253,135 +131,12 @@ static void rna_def_lighting(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Factor", "Factor for ambient occlusion blending"); RNA_def_property_update(prop, 0, "rna_World_update"); - prop = RNA_def_property(srna, "ao_blend_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "aomix"); - RNA_def_property_enum_items(prop, blend_mode_items); - RNA_def_property_ui_text(prop, "Blend Mode", "Defines how AO mixes with material shading"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - /* environment lighting */ - prop = RNA_def_property(srna, "use_environment_light", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_ENV_LIGHT); - RNA_def_property_ui_text(prop, "Use Environment Lighting", "Add light coming from the environment"); - RNA_def_property_update(prop, 0, "rna_World_draw_update"); - - prop = RNA_def_property(srna, "environment_energy", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ao_env_energy"); - RNA_def_property_ui_range(prop, 0, FLT_MAX, 1, 3); - RNA_def_property_ui_text(prop, "Environment Color", "Defines the strength of environment light"); - RNA_def_property_update(prop, 0, "rna_World_draw_update"); - - prop = RNA_def_property(srna, "environment_color", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "aocolor"); - RNA_def_property_enum_items(prop, prop_color_items); - RNA_def_property_ui_text(prop, "Environment Color", "Defines where the color of the environment light comes from"); - RNA_def_property_update(prop, 0, "rna_World_draw_update"); - - /* indirect lighting */ - prop = RNA_def_property(srna, "use_indirect_light", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_INDIRECT_LIGHT); - RNA_def_property_ui_text(prop, "Use Indirect Lighting", "Add indirect light bouncing of surrounding objects"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "indirect_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "ao_indirect_energy"); - RNA_def_property_range(prop, 0, INT_MAX); - RNA_def_property_ui_range(prop, 0, 1, 0.1, 2); - RNA_def_property_ui_text(prop, "Indirect Factor", "Factor for how much surrounding objects contribute to light"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "indirect_bounces", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "ao_indirect_bounces"); - RNA_def_property_range(prop, 1, SHRT_MAX); - RNA_def_property_ui_text(prop, "Bounces", "Number of indirect diffuse light bounces"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - /* gathering parameters */ - prop = RNA_def_property(srna, "gather_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "ao_gather_method"); - RNA_def_property_enum_items(prop, prop_gather_method_items); - RNA_def_property_ui_text(prop, "Gather Method", ""); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "passes", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "ao_approx_passes"); - RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Passes", "Number of preprocessing passes to reduce over-occlusion"); - RNA_def_property_update(prop, 0, "rna_World_update"); - prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "aodist"); RNA_def_property_ui_text(prop, "Distance", "Length of rays, defines how far away other faces give occlusion effect"); RNA_def_property_update(prop, 0, "rna_World_update"); - prop = RNA_def_property(srna, "falloff_strength", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "aodistfac"); - RNA_def_property_ui_text(prop, "Strength", - "Attenuation falloff strength, the higher, the less influence distant objects have"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "bias", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "aobias"); - RNA_def_property_range(prop, 0, 0.5); - RNA_def_property_ui_text(prop, "Bias", - "Bias (in radians) to prevent smoothed faces from showing banding " - "(for Raytrace Constant Jittered)"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ao_adapt_thresh"); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Threshold", - "Samples below this threshold will be considered fully shadowed/unshadowed and skipped " - "(for Raytrace Adaptive QMC)"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "adapt_to_speed", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ao_adapt_speed_fac"); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Adapt To Speed", - "Use the speed vector pass to reduce AO samples in fast moving pixels - " - "higher values result in more aggressive sample reduction " - "(requires Vec pass enabled, for Raytrace Adaptive QMC)"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "error_threshold", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ao_approx_error"); - RNA_def_property_range(prop, 0.0001, 10); - RNA_def_property_ui_text(prop, "Error Tolerance", "Low values are slower and higher quality"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "correction", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ao_approx_correction"); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_range(prop, 0, 1, 0.1, 2); - RNA_def_property_ui_text(prop, "Correction", "Ad-hoc correction for over-occlusion due to the approximation"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "use_falloff", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AODIST); - RNA_def_property_ui_text(prop, "Falloff", "Distance will be used to attenuate shadows"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "use_cache", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AOCACHE); - RNA_def_property_ui_text(prop, "Pixel Cache", - "Cache AO results in pixels and interpolate over neighboring pixels for speedup"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "aosamp"); - RNA_def_property_range(prop, 1, 128); - RNA_def_property_ui_text(prop, "Samples", - "Amount of ray samples. Higher values give smoother results and longer rendering times"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "sample_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "ao_samp_method"); - RNA_def_property_enum_items(prop, prop_sample_method_items); - RNA_def_property_ui_text(prop, "Sample Method", "Method for generating shadow samples (for Raytrace)"); - RNA_def_property_update(prop, 0, "rna_World_update"); } static void rna_def_world_mist(BlenderRNA *brna) @@ -390,9 +145,9 @@ static void rna_def_world_mist(BlenderRNA *brna) PropertyRNA *prop; static const EnumPropertyItem falloff_items[] = { - {0, "QUADRATIC", 0, "Quadratic", "Use quadratic progression"}, - {1, "LINEAR", 0, "Linear", "Use linear progression"}, - {2, "INVERSE_QUADRATIC", 0, "Inverse Quadratic", "Use inverse quadratic progression"}, + {WO_MIST_QUADRATIC, "QUADRATIC", 0, "Quadratic", "Use quadratic progression"}, + {WO_MIST_LINEAR, "LINEAR", 0, "Linear", "Use linear progression"}, + {WO_MIST_INVERSE_QUADRATIC, "INVERSE_QUADRATIC", 0, "Inverse Quadratic", "Use inverse quadratic progression"}, {0, NULL, 0, NULL, NULL} }; @@ -444,66 +199,25 @@ void RNA_def_world(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static float default_world_color[] = {0.05f, 0.05f, 0.05f}; + srna = RNA_def_struct(brna, "World", "ID"); RNA_def_struct_ui_text(srna, "World", "World data-block describing the environment and ambient lighting of a scene"); RNA_def_struct_ui_icon(srna, ICON_WORLD_DATA); rna_def_animdata_common(srna); - rna_def_mtex_common(brna, srna, "rna_World_mtex_begin", "rna_World_active_texture_get", - "rna_World_active_texture_set", NULL, "WorldTextureSlot", "WorldTextureSlots", - "rna_World_update", "rna_World_update"); /* colors */ - prop = RNA_def_property(srna, "horizon_color", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "horr"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Horizon Color", "Color at the horizon"); + RNA_def_property_float_array_default(prop, default_world_color); + RNA_def_property_ui_text(prop, "Color", "Color of the background"); /* RNA_def_property_update(prop, 0, "rna_World_update"); */ /* render-only uses this */ RNA_def_property_update(prop, 0, "rna_World_draw_update"); - prop = RNA_def_property(srna, "zenith_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "zenr"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Zenith Color", "Color at the zenith"); - RNA_def_property_update(prop, 0, "rna_World_draw_update"); - - prop = RNA_def_property(srna, "ambient_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "ambr"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Ambient Color", "Ambient color of the world"); - RNA_def_property_update(prop, 0, "rna_World_draw_update"); - - /* exp, range */ - prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "exp"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Exposure", "Amount of exponential color correction for light"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - prop = RNA_def_property(srna, "color_range", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "range"); - RNA_def_property_range(prop, 0.2, 5.0); - RNA_def_property_ui_text(prop, "Range", "The color range that will be mapped to 0-1"); - RNA_def_property_update(prop, 0, "rna_World_update"); - - /* sky type */ - prop = RNA_def_property(srna, "use_sky_blend", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYBLEND); - RNA_def_property_ui_text(prop, "Blend Sky", "Render background with natural progression from horizon to zenith"); - RNA_def_property_update(prop, NC_WORLD | ND_WORLD_DRAW, "rna_World_update"); - - prop = RNA_def_property(srna, "use_sky_paper", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYPAPER); - RNA_def_property_ui_text(prop, "Paper Sky", "Flatten blend or texture coordinates"); - RNA_def_property_update(prop, NC_WORLD | ND_WORLD_DRAW, "rna_World_update"); - - prop = RNA_def_property(srna, "use_sky_real", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYREAL); - RNA_def_property_ui_text(prop, "Real Sky", "Render background with a real horizon, relative to the camera angle"); - RNA_def_property_update(prop, NC_WORLD | ND_WORLD_DRAW, "rna_World_update"); - /* nested structs */ prop = RNA_def_property(srna, "light_settings", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); @@ -531,7 +245,6 @@ void RNA_def_world(BlenderRNA *brna) rna_def_lighting(brna); rna_def_world_mist(brna); - rna_def_world_mtex(brna); } #endif |