diff options
Diffstat (limited to 'source/blender/makesrna')
74 files changed, 6163 insertions, 967 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index a1af3f98274..a07cb86fdf7 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -106,6 +106,7 @@ extern StructRNA RNA_ClothCollisionSettings; extern StructRNA RNA_ClothModifier; extern StructRNA RNA_ClothSettings; extern StructRNA RNA_CloudsTexture; +extern StructRNA RNA_CollectionEngineSettings; extern StructRNA RNA_CollectionProperty; extern StructRNA RNA_CollisionModifier; extern StructRNA RNA_CollisionSensor; @@ -201,6 +202,8 @@ extern StructRNA RNA_CurveMapPoint; extern StructRNA RNA_CurveMapping; extern StructRNA RNA_CurveModifier; extern StructRNA RNA_CurvePoint; +extern StructRNA RNA_Depsgraph; +extern StructRNA RNA_DepsgraphIter; extern StructRNA RNA_DampedTrackConstraint; extern StructRNA RNA_DataTransferModifier; extern StructRNA RNA_DecimateModifier; @@ -230,6 +233,7 @@ extern StructRNA RNA_EnvironmentMapTexture; extern StructRNA RNA_Event; extern StructRNA RNA_ExplodeModifier; extern StructRNA RNA_ExpressionController; +extern StructRNA RNA_FaceMap; extern StructRNA RNA_FCurve; extern StructRNA RNA_FCurveSample; extern StructRNA RNA_FFmpegSettings; @@ -317,6 +321,8 @@ extern StructRNA RNA_LaplacianSmoothModifier; extern StructRNA RNA_Lattice; extern StructRNA RNA_LatticeModifier; extern StructRNA RNA_LatticePoint; +extern StructRNA RNA_LayerCollection; +extern StructRNA RNA_LayerCollectionOverride; extern StructRNA RNA_Library; extern StructRNA RNA_LimitDistanceConstraint; extern StructRNA RNA_LimitLocationConstraint; @@ -370,6 +376,8 @@ extern StructRNA RNA_LineStyleThicknessModifier_Tangent; extern StructRNA RNA_LockedTrackConstraint; extern StructRNA RNA_Macro; extern StructRNA RNA_MagicTexture; +extern StructRNA RNA_Manipulator; +extern StructRNA RNA_ManipulatorProperties; extern StructRNA RNA_MarbleTexture; extern StructRNA RNA_MaskModifier; extern StructRNA RNA_MaskSequence; @@ -482,6 +490,7 @@ extern StructRNA RNA_PointLamp; extern StructRNA RNA_PointerProperty; extern StructRNA RNA_Pose; extern StructRNA RNA_PoseBone; +extern StructRNA RNA_LightProbe; extern StructRNA RNA_Property; extern StructRNA RNA_PropertyGroup; extern StructRNA RNA_PropertyGroupItem; @@ -498,12 +507,15 @@ extern StructRNA RNA_RenderLayer; extern StructRNA RNA_RenderPass; extern StructRNA RNA_RenderResult; extern StructRNA RNA_RenderSettings; +extern StructRNA RNA_RenderEngineSettings; +extern StructRNA RNA_RenderEngineSettingsClay; extern StructRNA RNA_RigidBodyWorld; extern StructRNA RNA_RigidBodyObject; extern StructRNA RNA_RigidBodyJointConstraint; extern StructRNA RNA_SPHFluidSettings; extern StructRNA RNA_Scene; extern StructRNA RNA_SceneGameData; +extern StructRNA RNA_SceneLayer; extern StructRNA RNA_SceneRenderLayer; extern StructRNA RNA_SceneSequence; extern StructRNA RNA_SceneObjects; @@ -700,6 +712,7 @@ extern StructRNA RNA_WindowManager; extern StructRNA RNA_WipeSequence; extern StructRNA RNA_WireframeModifier; extern StructRNA RNA_WoodTexture; +extern StructRNA RNA_WorkSpace; extern StructRNA RNA_World; extern StructRNA RNA_WorldAmbientOcclusion; extern StructRNA RNA_WorldLighting; @@ -745,9 +758,10 @@ const char *RNA_struct_ui_description_raw(const StructRNA *type); const char *RNA_struct_translation_context(const StructRNA *type); int RNA_struct_ui_icon(const StructRNA *type); -PropertyRNA *RNA_struct_name_property(StructRNA *type); +PropertyRNA *RNA_struct_name_property(const StructRNA *type); PropertyRNA *RNA_struct_iterator_property(StructRNA *type); StructRNA *RNA_struct_base(StructRNA *type); +const StructRNA *RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type); bool RNA_struct_is_ID(const StructRNA *type); bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna); @@ -1183,9 +1197,13 @@ int RNA_function_call_direct_va(struct bContext *C, struct ReportList *reports, int RNA_function_call_direct_va_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, va_list args); +const char *RNA_translate_ui_text(const char *text, const char *text_ctxt, + struct StructRNA *type, struct PropertyRNA *prop, + int translate); + /* ID */ -short RNA_type_to_ID_code(StructRNA *type); +short RNA_type_to_ID_code(const StructRNA *type); StructRNA *ID_code_to_RNA_type(short idcode); diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 6e62313b00a..54938b236d5 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -37,6 +37,14 @@ extern "C" { #endif +#ifdef UNIT_TEST +#define RNA_MAX_ARRAY_LENGTH 64 +#else +#define RNA_MAX_ARRAY_LENGTH 32 +#endif + +#define RNA_MAX_ARRAY_DIMENSION 3 + /* Blender RNA */ BlenderRNA *RNA_create(void); diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 1c9b3593d17..b9bb741bcde 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -61,6 +61,7 @@ extern EnumPropertyItem rna_enum_object_modifier_type_items[]; extern EnumPropertyItem rna_enum_constraint_type_items[]; extern EnumPropertyItem rna_enum_boidrule_type_items[]; extern EnumPropertyItem rna_enum_sequence_modifier_type_items[]; +extern EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[]; extern EnumPropertyItem rna_enum_modifier_triangulate_quad_method_items[]; extern EnumPropertyItem rna_enum_modifier_triangulate_ngon_method_items[]; diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index cd04f9e8a6d..99ef0f9c8c4 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -282,6 +282,7 @@ typedef struct CollectionPropertyIterator { union { ArrayIterator array; ListBaseIterator listbase; + void *custom; } internal; int idprop; int level; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 6a08d762920..75d127079b9 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -72,6 +72,7 @@ set(DEFSRC rna_palette.c rna_particle.c rna_pose.c + rna_lightprobe.c rna_property.c rna_render.c rna_rigidbody.c @@ -94,6 +95,8 @@ set(DEFSRC rna_userdef.c rna_vfont.c rna_wm.c + rna_wm_manipulator.c + rna_workspace.c rna_world.c ) @@ -124,6 +127,7 @@ set(APISRC rna_ui_api.c rna_vfont_api.c rna_wm_api.c + rna_wm_manipulator_api.c ) string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}") @@ -189,6 +193,10 @@ if(WITH_GAMEENGINE) add_definitions(-DWITH_GAMEENGINE) endif() +if(WITH_CLAY_ENGINE) + add_definitions(-DWITH_CLAY_ENGINE) +endif() + if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() @@ -338,6 +346,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 de436172bfd..7d2ce4cb3b2 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3321,7 +3321,6 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"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}, @@ -3341,10 +3340,12 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"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_lightprobe.c", NULL, RNA_def_lightprobe}, {"rna_property.c", NULL, RNA_def_gameproperty}, {"rna_render.c", NULL, RNA_def_render}, {"rna_rigidbody.c", NULL, RNA_def_rigidbody}, @@ -3364,6 +3365,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_manipulator.c", "rna_wm_manipulator_api.c", RNA_def_wm_manipulator}, + {"rna_workspace.c", NULL, RNA_def_workspace}, {"rna_world.c", NULL, RNA_def_world}, {"rna_movieclip.c", NULL, RNA_def_movieclip}, {"rna_tracking.c", NULL, RNA_def_tracking}, diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index a74758a4f71..1c6172ef667 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -74,6 +74,7 @@ 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_LT, "LIGHT_PROBE", ICON_RADIO, "Light Probe", ""}, {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""}, {ID_SCR, "SCREEN", ICON_SPLITSCREEN, "Screen", ""}, {ID_SO, "SOUND", ICON_PLAY_AUDIO, "Sound", ""}, @@ -82,6 +83,7 @@ EnumPropertyItem rna_enum_id_type_items[] = { {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""}, {ID_WM, "WINDOWMANAGER", ICON_FULLSCREEN, "Window Manager", ""}, {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""}, + {ID_WS, "WORKSPACE", ICON_NONE, "Workspace", ""}, {0, NULL, 0, NULL, NULL} }; @@ -98,9 +100,11 @@ EnumPropertyItem rna_enum_id_type_items[] = { #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 "WM_api.h" /* name functions that ignore the first two ID characters */ @@ -136,48 +140,56 @@ static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info)) return PROP_EDITABLE; } -short RNA_type_to_ID_code(StructRNA *type) -{ - if (RNA_struct_is_a(type, &RNA_Action)) return ID_AC; - if (RNA_struct_is_a(type, &RNA_Armature)) return ID_AR; - if (RNA_struct_is_a(type, &RNA_Brush)) return ID_BR; - if (RNA_struct_is_a(type, &RNA_CacheFile)) return ID_CF; - if (RNA_struct_is_a(type, &RNA_Camera)) return ID_CA; - if (RNA_struct_is_a(type, &RNA_Curve)) return ID_CU; - if (RNA_struct_is_a(type, &RNA_GreasePencil)) return ID_GD; - if (RNA_struct_is_a(type, &RNA_Group)) return ID_GR; - if (RNA_struct_is_a(type, &RNA_Image)) return ID_IM; - if (RNA_struct_is_a(type, &RNA_Key)) return ID_KE; - if (RNA_struct_is_a(type, &RNA_Lamp)) return ID_LA; - if (RNA_struct_is_a(type, &RNA_Library)) return ID_LI; - if (RNA_struct_is_a(type, &RNA_FreestyleLineStyle)) return ID_LS; - if (RNA_struct_is_a(type, &RNA_Lattice)) return ID_LT; - if (RNA_struct_is_a(type, &RNA_Material)) return ID_MA; - if (RNA_struct_is_a(type, &RNA_MetaBall)) return ID_MB; - if (RNA_struct_is_a(type, &RNA_MovieClip)) return ID_MC; - if (RNA_struct_is_a(type, &RNA_Mesh)) return ID_ME; - if (RNA_struct_is_a(type, &RNA_Mask)) return ID_MSK; - if (RNA_struct_is_a(type, &RNA_NodeTree)) return ID_NT; - if (RNA_struct_is_a(type, &RNA_Object)) return ID_OB; - if (RNA_struct_is_a(type, &RNA_ParticleSettings)) return ID_PA; - if (RNA_struct_is_a(type, &RNA_Palette)) return ID_PAL; - if (RNA_struct_is_a(type, &RNA_PaintCurve)) return ID_PC; - if (RNA_struct_is_a(type, &RNA_Scene)) return ID_SCE; - if (RNA_struct_is_a(type, &RNA_Screen)) return ID_SCR; - if (RNA_struct_is_a(type, &RNA_Sound)) return ID_SO; - if (RNA_struct_is_a(type, &RNA_Speaker)) return ID_SPK; - if (RNA_struct_is_a(type, &RNA_Texture)) return ID_TE; - if (RNA_struct_is_a(type, &RNA_Text)) return ID_TXT; - if (RNA_struct_is_a(type, &RNA_VectorFont)) return ID_VF; - if (RNA_struct_is_a(type, &RNA_World)) return ID_WO; - if (RNA_struct_is_a(type, &RNA_WindowManager)) return ID_WM; +short RNA_type_to_ID_code(const StructRNA *type) +{ + const StructRNA *base_type = RNA_struct_base_child_of(type, &RNA_ID); + if (UNLIKELY(base_type == NULL)) { + return 0; + } + if (base_type == &RNA_Action) return ID_AC; + if (base_type == &RNA_Armature) return ID_AR; + if (base_type == &RNA_Brush) return ID_BR; + if (base_type == &RNA_CacheFile) return ID_CF; + 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_Image) return ID_IM; + if (base_type == &RNA_Key) return ID_KE; + if (base_type == &RNA_Lamp) 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; + if (base_type == &RNA_Material) return ID_MA; + if (base_type == &RNA_MetaBall) return ID_MB; + if (base_type == &RNA_MovieClip) return ID_MC; + if (base_type == &RNA_Mesh) return ID_ME; + if (base_type == &RNA_Mask) return ID_MSK; + if (base_type == &RNA_NodeTree) return ID_NT; + if (base_type == &RNA_Object) return ID_OB; + 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; + if (base_type == &RNA_Speaker) return ID_SPK; + 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; return 0; } StructRNA *ID_code_to_RNA_type(short idcode) { - switch (idcode) { + /* Note, this switch doesn't use a 'default', + * so adding new ID's causes a warning. */ + switch ((ID_Type)idcode) { case ID_AC: return &RNA_Action; case ID_AR: return &RNA_Armature; case ID_BR: return &RNA_Brush; @@ -202,6 +214,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; @@ -211,9 +224,13 @@ 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; - default: return &RNA_ID; + /* deprecated */ + case ID_IP: break; } + + return &RNA_ID; } StructRNA *rna_ID_refine(PointerRNA *ptr) @@ -331,7 +348,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) @@ -367,15 +384,23 @@ static struct ID *rna_ID_make_local(struct ID *self, Main *bmain, int clear_prox 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 +void **rna_ID_instance(PointerRNA *ptr) +{ + ID *id = (ID *)ptr->data; + return &id->py_instance; } +#endif static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { @@ -432,7 +457,7 @@ static Material *rna_IDMaterials_pop_id(ID *id, Main *bmain, ReportList *reports 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); @@ -443,7 +468,7 @@ static void rna_IDMaterials_clear_id(ID *id, int remove_material_slot) { BKE_material_clear_id(G.main, 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); } @@ -1054,6 +1079,10 @@ static void rna_def_ID(BlenderRNA *brna) "Tag the ID to update its display data, " "e.g. when calling :class:`bpy.types.Scene.update`"); RNA_def_enum_flag(func, "refresh", update_flag_items, 0, "", "Type of updates to perform"); + +#ifdef WITH_PYTHON + RNA_def_struct_register_funcs(srna, NULL, NULL, "rna_ID_instance"); +#endif } static void rna_def_library(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 5a4db47d281..f349d4a44dc 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -54,6 +54,8 @@ #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" @@ -62,7 +64,6 @@ /* flush updates */ #include "DNA_object_types.h" -#include "BKE_depsgraph.h" #include "WM_types.h" #include "rna_internal.h" @@ -560,7 +561,7 @@ const char *RNA_struct_translation_context(const StructRNA *type) return type->translation_context; } -PropertyRNA *RNA_struct_name_property(StructRNA *type) +PropertyRNA *RNA_struct_name_property(const StructRNA *type) { return type->nameproperty; } @@ -575,6 +576,22 @@ StructRNA *RNA_struct_base(StructRNA *type) return type->base; } +/** + * 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`. + */ +const StructRNA *RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type) +{ + while (type) { + if (type->base == parent_type) { + return type; + } + type = type->base; + } + return NULL; +} + bool RNA_struct_is_ID(const StructRNA *type) { return (type->flag & STRUCT_ID) != 0; @@ -1799,7 +1816,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 { @@ -1817,7 +1834,7 @@ static void rna_property_update(bContext *C, Main *bmain, Scene *scene, PointerR 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 | OB_RECALC_TIME); 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. @@ -2765,6 +2782,9 @@ char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, int length; BLI_assert(RNA_property_type(prop) == PROP_STRING); + if (!ptr->data) { + return NULL; + } length = RNA_property_string_length(ptr, prop); @@ -6700,6 +6720,13 @@ int RNA_function_call_direct_va_lookup(bContext *C, ReportList *reports, Pointer return 0; } +const char *RNA_translate_ui_text( + const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, + int translate) +{ + return rna_translate_ui_text(text, text_ctxt, type, prop, translate); +} + bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index) { int len; diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index f271bccd326..f49d4717ad6 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -73,10 +73,11 @@ 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" @@ -88,7 +89,7 @@ static void rna_AnimData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point /* 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); + DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA); } static int rna_AnimData_action_editable(PointerRNA *ptr, const char **UNUSED(r_info)) @@ -114,7 +115,7 @@ static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value) adt = BKE_animdata_from_id(ownerId); if (adt) { adt->recalc |= ADT_RECALC_ANIM; - DAG_id_tag_update(ownerId, OB_RECALC_TIME); + DEG_id_tag_update(ownerId, OB_RECALC_TIME); } } diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 891f5c43ca6..014a08b70ce 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -44,18 +44,19 @@ #ifdef RNA_RUNTIME #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_idprop.h" #include "BKE_main.h" #include "ED_armature.h" #include "BKE_armature.h" +#include "DEG_depsgraph.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); */ } @@ -173,7 +174,7 @@ static void rna_Bone_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po 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); } } else if (GS(id->name) == ID_OB) { @@ -181,7 +182,7 @@ static void rna_Bone_select_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po 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); } } } diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c index 72f67b86c23..cee2b7ed9bc 100644 --- a/source/blender/makesrna/intern/rna_boid.c +++ b/source/blender/makesrna/intern/rna_boid.c @@ -87,9 +87,11 @@ static 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 ac348c1750c..1948f425083 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -360,17 +360,23 @@ 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_main_tex_update(bContext *C, PointerRNA *ptr) { + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SceneLayer *sl = CTX_data_scene_layer(C); Brush *br = (Brush *)ptr->data; - BKE_paint_invalidate_overlay_tex(scene, br->mtex.tex); + BKE_paint_invalidate_overlay_tex(scene, sl, br->mtex.tex); rna_Brush_update(bmain, scene, ptr); } -static void rna_Brush_secondary_tex_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); + SceneLayer *sl = CTX_data_scene_layer(C); Brush *br = (Brush *)ptr->data; - BKE_paint_invalidate_overlay_tex(scene, br->mask_mtex.tex); + BKE_paint_invalidate_overlay_tex(scene, sl, br->mask_mtex.tex); rna_Brush_update(bmain, scene, ptr); } @@ -426,14 +432,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) { + SceneLayer *sl = CTX_data_scene_layer(C); + BKE_paint_invalidate_overlay_tex(scene, sl, mtex->tex); + } - rna_TextureSlot_update(bmain, scene, ptr); + rna_TextureSlot_update(C, ptr); } static void rna_Brush_set_size(PointerRNA *ptr, int value) @@ -647,39 +656,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"); @@ -1338,7 +1354,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"); @@ -1350,7 +1366,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"); diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c index 09fdeb15b10..bfe419ca8e3 100644 --- a/source/blender/makesrna/intern/rna_cachefile.c +++ b/source/blender/makesrna/intern/rna_cachefile.c @@ -35,7 +35,6 @@ #ifdef RNA_RUNTIME #include "BKE_cachefile.h" -#include "BKE_depsgraph.h" #include "BLI_string.h" @@ -52,7 +51,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 +62,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 078ba13d76d..1127940de44 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -40,7 +40,9 @@ #include "BKE_camera.h" #include "BKE_object.h" -#include "BKE_depsgraph.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" static float rna_Camera_angle_get(PointerRNA *ptr) { @@ -84,14 +86,14 @@ 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); } #else diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index d8bcbc2cc72..effd140ab15 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -46,19 +46,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 +71,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); } diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 5339df34a38..4d9dcdf0fce 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -53,7 +53,6 @@ #include "MEM_guardedalloc.h" #include "BKE_colortools.h" -#include "BKE_depsgraph.h" #include "BKE_image.h" #include "BKE_movieclip.h" #include "BKE_node.h" @@ -61,6 +60,8 @@ #include "BKE_texture.h" #include "BKE_linestyle.h" +#include "DEG_depsgraph.h" + #include "ED_node.h" #include "IMB_colormanagement.h" @@ -315,7 +316,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 +336,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 +351,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 +447,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 +582,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain) 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(ima, NULL, IMA_SIGNAL_COLORMANAGE); @@ -664,7 +665,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); } } diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index de1a0f24c31..8ecbd438c2e 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -154,7 +154,6 @@ static 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" diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index d7a679e9702..5701150b1bf 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -51,6 +51,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 +101,52 @@ static PointerRNA rna_Context_region_data_get(PointerRNA *ptr) return PointerRNA_NULL; } +static PointerRNA rna_Context_manipulator_group_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + PointerRNA newptr; + RNA_pointer_create(NULL, &RNA_ManipulatorGroup, CTX_wm_manipulator_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_scene_layer_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, CTX_data_scene_layer(C)); +} + +static PointerRNA rna_Context_scene_collection_get(PointerRNA *ptr) +{ + bContext *C = (bContext *)ptr->data; + ptr->id.data = CTX_data_scene(C); + return rna_pointer_inherit_refine(ptr, &RNA_SceneCollection, CTX_data_scene_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; @@ -167,6 +207,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 +237,42 @@ 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, "manipulator_group", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "ManipulatorGroup"); + RNA_def_property_pointer_funcs(prop, "rna_Context_manipulator_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, "render_layer", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "SceneLayer"); + RNA_def_property_pointer_funcs(prop, "rna_Context_scene_layer_get", NULL, NULL, NULL); + + prop = RNA_def_property(srna, "scene_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "SceneCollection"); + RNA_def_property_pointer_funcs(prop, "rna_Context_scene_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"); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 7787533d311..50938eb75dc 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -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); } diff --git a/source/blender/makesrna/intern/rna_curve_api.c b/source/blender/makesrna/intern/rna_curve_api.c index b4b3aa84ec5..4da262daf8d 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, int shape_keys) { BKE_curve_transform(cu, (float (*)[4])mat, shape_keys); - 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(cu, BKE_CURVE_BATCH_DIRTY_ALL); +} + #else void RNA_api_curve(StructRNA *srna) @@ -67,6 +73,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"); } #endif diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c index 2748bd8b877..6043224df5d 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.c +++ b/source/blender/makesrna/intern/rna_depsgraph.c @@ -36,31 +36,112 @@ #include "DEG_depsgraph.h" -#include "BKE_depsgraph.h" +#include "DNA_object_types.h" #ifdef RNA_RUNTIME +#include "BLI_iterator.h" #include "BKE_report.h" +#include "DNA_object_types.h" +#include "DEG_depsgraph_build.h" #include "DEG_depsgraph_debug.h" +#include "DEG_depsgraph_query.h" + +#include "MEM_guardedalloc.h" + +/* **************** Depsgraph **************** */ + +static PointerRNA rna_DepsgraphIter_object_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_Object, iterator->current); +} + +static PointerRNA rna_DepsgraphIter_instance_object_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)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_DepsgraphIter_parent_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)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 void rna_DepsgraphIter_persistent_id_get(PointerRNA *ptr, int *persistent_id) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data; + memcpy(persistent_id, deg_iter->dupli_object_current->persistent_id, + sizeof(deg_iter->dupli_object_current->persistent_id)); +} + +static void rna_DepsgraphIter_orco_get(PointerRNA *ptr, float *orco) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data; + memcpy(orco, deg_iter->dupli_object_current->orco, + sizeof(deg_iter->dupli_object_current->orco)); +} + +static unsigned int rna_DepsgraphIter_random_id_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data; + return deg_iter->dupli_object_current->random_id; +} + +static void rna_DepsgraphIter_uv_get(PointerRNA *ptr, float *uv) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data; + memcpy(uv, deg_iter->dupli_object_current->uv, + sizeof(deg_iter->dupli_object_current->uv)); +} + +static int rna_DepsgraphIter_is_instance_get(PointerRNA *ptr) +{ + BLI_Iterator *iterator = ptr->data; + DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data; + return (deg_iter->dupli_object_current != NULL); +} + +/* **************** Depsgraph **************** */ static void rna_Depsgraph_debug_graphviz(Depsgraph *graph, const char *filename) { FILE *f = fopen(filename, "w"); if (f == NULL) return; - + DEG_debug_graphviz(graph, f, "Depsgraph", false); - + fclose(f); } -static void rna_Depsgraph_debug_rebuild(Depsgraph *UNUSED(graph), Main *bmain) +static void rna_Depsgraph_debug_rebuild(Depsgraph *UNUSED(graph), bContext *C) { + Main *bmain = CTX_data_main(C); + EvaluationContext eval_ctx; Scene *sce; - DAG_relations_tag_update(bmain); + + CTX_data_eval_ctx(C, &eval_ctx); + + DEG_relations_tag_update(bmain); for (sce = bmain->scene.first; sce; sce = sce->id.next) { - DAG_scene_relations_rebuild(bmain, sce); + DEG_scene_relations_rebuild(bmain, sce); DEG_graph_on_visible_update(bmain, sce); } } @@ -68,43 +149,204 @@ static void rna_Depsgraph_debug_rebuild(Depsgraph *UNUSED(graph), Main *bmain) static void rna_Depsgraph_debug_stats(Depsgraph *graph, ReportList *reports) { size_t outer, ops, rels; - + DEG_stats_simple(graph, &outer, &ops, &rels); - + // XXX: report doesn't seem to work printf("Approx %lu Operations, %lu Relations, %lu Outer Nodes\n", ops, rels, outer); - + BKE_reportf(reports, RPT_WARNING, "Approx. %lu Operations, %lu Relations, %lu Outer Nodes", 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__); + DEGObjectsIteratorData *data = MEM_callocN(sizeof(DEGObjectsIteratorData), __func__); + + data->graph = (Depsgraph *)ptr->data; + data->flag = DEG_OBJECT_ITER_FLAG_SET; + + DEG_objects_iterator_begin(iter->internal.custom, data); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static void rna_Depsgraph_objects_next(CollectionPropertyIterator *iter) +{ + DEG_objects_iterator_next(iter->internal.custom); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static void rna_Depsgraph_objects_end(CollectionPropertyIterator *iter) +{ + DEG_objects_iterator_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_duplis_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__); + DEGObjectsIteratorData *data = MEM_callocN(sizeof(DEGObjectsIteratorData), __func__); + + data->graph = (Depsgraph *)ptr->data; + data->flag = DEG_OBJECT_ITER_FLAG_ALL; + + DEG_objects_iterator_begin(iter->internal.custom, data); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static void rna_Depsgraph_duplis_next(CollectionPropertyIterator *iter) +{ + DEG_objects_iterator_next(iter->internal.custom); + iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid; +} + +static void rna_Depsgraph_duplis_end(CollectionPropertyIterator *iter) +{ + DEG_objects_iterator_end(iter->internal.custom); + MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data); + MEM_freeN(iter->internal.custom); +} + +static PointerRNA rna_Depsgraph_duplis_get(CollectionPropertyIterator *iter) +{ + BLI_Iterator *iterator = (BLI_Iterator *)iter->internal.custom; + return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphIter, iterator); +} + +static ID *rna_Depsgraph_evaluated_id_get(Depsgraph *depsgraph, ID *id_orig) +{ + return DEG_get_evaluated_id(depsgraph, id_orig); +} + #else +static void rna_def_depsgraph_iter(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "DepsgraphIter", NULL); + RNA_def_struct_ui_text(srna, "Dependency Graph Iterator", + "Extended information about dependency graph object iterator"); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_ui_text(prop, "Object", "Object the iterator points to"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphIter_object_get", NULL, NULL, 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", "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_DepsgraphIter_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", "Parent of the duplication list"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_DepsgraphIter_parent_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_DepsgraphIter_persistent_id_get", NULL, NULL); + + prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + /* Seems system is not smart enough to figure that getter function should return + * array for PROP_TRANSLATION. + */ + 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_DepsgraphIter_orco_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_DepsgraphIter_random_id_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_DepsgraphIter_uv_get", 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 ocming from dupli-list"); + RNA_def_property_boolean_funcs(prop, "rna_DepsgraphIter_is_instance_get", NULL); +} + static void rna_def_depsgraph(BlenderRNA *brna) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; srna = RNA_def_struct(brna, "Depsgraph", NULL); RNA_def_struct_ui_text(srna, "Dependency Graph", ""); - + func = RNA_def_function(srna, "debug_graphviz", "rna_Depsgraph_debug_graphviz"); parm = RNA_def_string_file_path(func, "filename", NULL, FILE_MAX, "File Name", "File in which to store graphviz debug output"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); func = RNA_def_function(srna, "debug_rebuild", "rna_Depsgraph_debug_rebuild"); - RNA_def_function_flag(func, FUNC_USE_MAIN); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); func = RNA_def_function(srna, "debug_stats", "rna_Depsgraph_debug_stats"); RNA_def_function_ui_description(func, "Report the number of elements in the Dependency Graph"); RNA_def_function_flag(func, FUNC_USE_REPORTS); + + 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); + + func = RNA_def_function(srna, "evaluated_id_get", "rna_Depsgraph_evaluated_id_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, "evaluated_id", "ID", "", "Evaluated ID for the given original one"); + RNA_def_function_return(func, parm); + + /* TODO(sergey): Find a better name. */ + prop = RNA_def_property(srna, "duplis", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "DepsgraphIter"); + RNA_def_property_collection_funcs(prop, + "rna_Depsgraph_duplis_begin", + "rna_Depsgraph_duplis_next", + "rna_Depsgraph_duplis_end", + "rna_Depsgraph_duplis_get", + NULL, NULL, NULL, NULL); } void RNA_def_depsgraph(BlenderRNA *brna) { + rna_def_depsgraph_iter(brna); rna_def_depsgraph(brna); } diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c index 4bb7f3a9ffd..f51bd9d93cc 100644 --- a/source/blender/makesrna/intern/rna_dynamicpaint.c +++ b/source/blender/makesrna/intern/rna_dynamicpaint.c @@ -55,9 +55,10 @@ 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) diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index ad63a652b12..e951e15ca8c 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -127,9 +127,11 @@ 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 void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) { ID *id = ptr->id.data; @@ -138,8 +140,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); } @@ -587,7 +589,7 @@ static void rna_FModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin { ID *id = ptr->id.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); if (adt != NULL) { adt->recalc |= ADT_RECALC_ANIM; } diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 8c3984e4b29..de2076868ec 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_group.c b/source/blender/makesrna/intern/rna_group.c index aa02a3c159d..2a5a0011279 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -53,9 +53,9 @@ static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter) 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) +static void rna_Group_objects_link(Group *group, ReportList *reports, Object *object) { - if (!BKE_group_object_add(group, object, CTX_data_scene(C), NULL)) { + if (!BKE_group_object_add(group, object)) { BKE_reportf(reports, RPT_ERROR, "Object '%s' already in group '%s'", object->id.name + 2, group->id.name + 2); return; } @@ -63,9 +63,9 @@ static void rna_Group_objects_link(Group *group, bContext *C, ReportList *report WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id); } -static void rna_Group_objects_unlink(Group *group, bContext *C, ReportList *reports, Object *object) +static void rna_Group_objects_unlink(Group *group, ReportList *reports, Object *object) { - if (!BKE_group_object_unlink(group, object, CTX_data_scene(C), NULL)) { + if (!BKE_group_object_unlink(group, object)) { BKE_reportf(reports, RPT_ERROR, "Object '%s' not in group '%s'", object->id.name + 2, group->id.name + 2); return; } @@ -91,7 +91,7 @@ static void rna_def_group_objects(BlenderRNA *brna, PropertyRNA *cprop) /* 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_flag(func, 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"); @@ -100,7 +100,7 @@ static void rna_def_group_objects(BlenderRNA *brna, PropertyRNA *cprop) /* 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); + RNA_def_function_flag(func, FUNC_USE_REPORTS); /* object to remove */ parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index b6e84cf8ac3..686e830f1ba 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -32,9 +32,10 @@ #include "BLI_utildefines.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" @@ -104,7 +105,7 @@ static void rna_Image_source_set(PointerRNA *ptr, int value) if (value != ima->source) { ima->source = value; BKE_image_signal(ima, NULL, IMA_SIGNAL_SRC_CHANGE); - DAG_id_tag_update(&ima->id, 0); + DEG_id_tag_update(&ima->id, 0); } } @@ -134,7 +135,7 @@ static void rna_Image_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P Image *ima = ptr->id.data; BKE_image_signal(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 *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -147,7 +148,7 @@ static void rna_Image_colormanage_update(Main *UNUSED(bmain), Scene *UNUSED(scen { Image *ima = ptr->id.data; BKE_image_signal(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); } diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 344c1781b46..936674a1e96 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" @@ -251,6 +248,8 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int f 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) { diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index dfd5af788f6..00b1b53ad71 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -42,6 +42,7 @@ struct Mesh; struct Object; struct ReportList; struct SDNA; +struct SceneLayer; /* Data structures used during define */ @@ -166,6 +167,7 @@ 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); @@ -186,6 +188,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_manipulator(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); @@ -217,6 +221,7 @@ void rna_ID_name_set(struct PointerRNA *ptr, const char *value); struct StructRNA *rna_ID_refine(struct PointerRNA *ptr); struct IDProperty *rna_ID_idprops(struct PointerRNA *ptr, bool create); void rna_ID_fake_user_set(struct PointerRNA *ptr, int value); +void **rna_ID_instance(PointerRNA *ptr); struct IDProperty *rna_PropertyGroup_idprops(struct PointerRNA *ptr, bool create); void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type); struct StructRNA *rna_PropertyGroup_register(struct Main *bmain, struct ReportList *reports, void *data, @@ -236,7 +241,7 @@ int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current); /* 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 */ int rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value); @@ -267,6 +272,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_manipulator(struct StructRNA *srna); +void RNA_api_manipulatorgroup(struct StructRNA *srna); void RNA_api_keyconfig(struct StructRNA *srna); void RNA_api_keyconfigs(struct StructRNA *srna); void RNA_api_keyingset(struct StructRNA *srna); @@ -279,7 +286,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); @@ -335,6 +342,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 */ @@ -402,7 +411,7 @@ 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 Main *bmain, struct ReportList *reports, struct Scene *sce, struct SceneLayer *sl, struct Object *ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed); /* XXX, these should not need to be defined here~! */ @@ -413,6 +422,8 @@ void rna_mtex_texture_slots_clear(struct ID *self, struct bContext *C, struct Re int rna_IDMaterials_assign_int(struct PointerRNA *ptr, int key, const struct PointerRNA *assign_ptr); +const char *rna_translate_ui_text( + const char *text, const char *text_ctxt, struct StructRNA *type, struct PropertyRNA *prop, int translate); /* Internal functions that cycles uses so we need to declare (tsk tsk) */ void rna_RenderLayer_rect_set(PointerRNA *ptr, const float *values); diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index df591659fdb..c412d110e5e 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -45,15 +45,6 @@ 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" diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index a5abc8a3be2..5cf7e7238e0 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" @@ -484,7 +485,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); } } diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 51709d3137c..76f5044a95c 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -45,10 +45,11 @@ #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" @@ -134,7 +135,7 @@ static void rna_Lamp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN { 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); } @@ -142,7 +143,7 @@ static void rna_Lamp_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin { 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); } @@ -150,7 +151,7 @@ static void rna_Lamp_sky_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point { 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_SKY, la); } @@ -587,7 +588,7 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area) 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_ui_text(prop, "Shadow Buffer Bias", "Bias for reducing self shadowing"); RNA_def_property_update(prop, 0, "rna_Lamp_update"); prop = RNA_def_property(srna, "shadow_buffer_bleed_bias", PROP_FLOAT, PROP_NONE); @@ -596,6 +597,12 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area) 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"); + prop = RNA_def_property(srna, "shadow_buffer_exp", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "bleedexp"); + 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_Lamp_update"); + prop = RNA_def_property(srna, "shadow_buffer_soft", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "soft"); RNA_def_property_range(prop, 0.0f, 100.0f); @@ -722,6 +729,7 @@ static void rna_def_area_lamp(BlenderRNA *brna) RNA_def_struct_ui_icon(srna, ICON_LAMP_AREA); rna_def_lamp_shadow(srna, 0, 1); + rna_def_lamp_falloff(srna); prop = RNA_def_property(srna, "use_umbra", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_UMBRA); diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 9424ddf7d0e..904a6289fc1 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 2ea59d31262..5637f8d9248 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, int 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(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_lightprobe.c b/source/blender/makesrna/intern/rna_lightprobe.c new file mode 100644 index 00000000000..a628dade59b --- /dev/null +++ b/source/blender/makesrna/intern/rna_lightprobe.c @@ -0,0 +1,188 @@ +/* + * ***** 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 "DNA_object_types.h" + +#include "MEM_guardedalloc.h" + +#include "BKE_main.h" +#include "DEG_depsgraph.h" + +#include "DNA_object_types.h" + +#include "WM_api.h" +#include "WM_types.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_NONE, "Reflection Cubemap", "Capture reflections"}, + {LIGHTPROBE_TYPE_PLANAR, "PLANAR", ICON_NONE, "Reflection Plane", ""}, + {LIGHTPROBE_TYPE_GRID, "GRID", ICON_NONE, "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_RADIO); + + 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_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_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 parallax 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_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_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_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_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_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_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"); + + /* 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 debuging purpose"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + + prop = RNA_def_property(srna, "data_draw_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.05f, 10.0f); + RNA_def_property_ui_text(prop, "Data Draw Size", "Size of the spheres to debug captured light"); + 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 a163d9764c1..13d655f81bf 100644 --- a/source/blender/makesrna/intern/rna_linestyle.c +++ b/source/blender/makesrna/intern/rna_linestyle.c @@ -101,7 +101,8 @@ 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 94687b6fd46..6479826b7b3 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -293,6 +293,18 @@ 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 void rna_Main_version_get(PointerRNA *ptr, int *value) { Main *bmain = (Main *)ptr->data; @@ -368,6 +380,8 @@ void RNA_def_main(BlenderRNA *brna) {"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}, + {"workspaces", "WorkSpace", "rna_Main_workspaces_begin", "Workspaces", "Workspace data-blocks", RNA_def_main_workspaces}, + {"lightprobes", "LightProbe", "rna_Main_lightprobes_begin", "LightProbes", "LightProbe data-blocks", RNA_def_main_lightprobes}, {NULL, NULL, NULL, NULL, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index c110dbff6c4..d980916aeec 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -78,12 +78,15 @@ #include "BKE_paint.h" #include "BKE_font.h" #include "BKE_node.h" -#include "BKE_depsgraph.h" #include "BKE_speaker.h" +#include "BKE_lightprobe.h" #include "BKE_movieclip.h" #include "BKE_mask.h" #include "BKE_gpencil.h" #include "BKE_linestyle.h" +#include "BKE_workspace.h" + +#include "DEG_depsgraph_query.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -93,6 +96,7 @@ #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" @@ -115,6 +119,8 @@ # include "BPY_extern.h" #endif +#include "WM_api.h" + static void rna_idname_validate(const char *name, char *r_name) { @@ -169,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_change_active_scene(bmain, C, win, scene_new); #ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; @@ -292,9 +299,15 @@ 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, + Main *bmain, ReportList *reports, Scene *sce, SceneLayer *sl, Object *ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed) { + EvaluationContext eval_ctx; + + DEG_evaluation_context_init(&eval_ctx, settings); + eval_ctx.ctime = (float)sce->r.cfra + sce->r.subframe; + eval_ctx.scene_layer = sl; + switch (ob->type) { case OB_FONT: case OB_CURVE: @@ -307,7 +320,7 @@ 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(&eval_ctx, bmain, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed); } static Lamp *rna_Main_lamps_new(Main *bmain, const char *name, int type) @@ -568,13 +581,23 @@ static FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char *name return linestyle; } +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 and is_updated 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, int value) { \ BKE_main_id_tag_listbase(&bmain->_listbase_name, LIB_TAG_DOIT, value); \ } \ static int rna_Main_##_func_name##_is_updated_get(PointerRNA *ptr) { \ - return DAG_id_type_tagged(ptr->data, _id_type) != 0; \ + return DEG_id_type_tagged(ptr->data, _id_type) != 0; \ } RNA_MAIN_ID_TAG_FUNCS_DEF(cameras, camera, ID_CA) @@ -610,6 +633,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 @@ -860,6 +885,8 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "Scene layer 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"); @@ -1587,6 +1614,7 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) 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; @@ -1818,4 +1846,64 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_boolean_funcs(prop, "rna_Main_linestyle_is_updated_get", NULL); } +void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + PropertyRNA *prop; + + 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); + + 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_workspaces_is_updated_get", NULL); +} + +void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + PropertyRNA *prop; + + 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)"); + + 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); + + 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_lightprobes_is_updated_get", NULL); +} + #endif diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 24dfff89832..12f8a584c2c 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -54,9 +54,10 @@ #include "DNA_movieclip_types.h" -#include "BKE_depsgraph.h" #include "BKE_mask.h" +#include "DEG_depsgraph.h" + #include "BLI_math.h" #include "RNA_access.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); } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index b293f20dd95..d01ce407815 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -86,13 +86,14 @@ EnumPropertyItem rna_enum_ramp_blend_items[] = { #include "DNA_space_types.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_texture.h" #include "BKE_node.h" #include "BKE_paint.h" +#include "DEG_depsgraph.h" + #include "ED_node.h" #include "ED_image.h" #include "BKE_scene.h" @@ -101,7 +102,7 @@ static void rna_Material_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point { 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, ma); } @@ -119,7 +120,7 @@ static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), { 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); } @@ -213,7 +214,7 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s } } - DAG_id_tag_update(&ma->id, 0); + DEG_id_tag_update(&ma->id, 0); WM_main_add_notifier(NC_MATERIAL | ND_SHADING, ma); } @@ -427,7 +428,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 */ @@ -1804,6 +1805,24 @@ void RNA_def_material(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + 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} + }; + srna = RNA_def_struct(brna, "Material", "ID"); RNA_def_struct_ui_text(srna, "Material", "Material data-block to define the appearance of geometric objects for rendering"); @@ -1826,7 +1845,30 @@ void RNA_def_material(BlenderRNA *brna) 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"); - + + /* 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, "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, "alpha_threshold", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, 0, 1); + 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, "transparent_hide_backside", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "blend_flag", MA_BL_HIDE_BACKSIDE); + RNA_def_property_ui_text(prop, "Hide Backside" , "Limit transparency to a single layer " + "(avoids transparency sorting problems)"); + RNA_def_property_update(prop, 0, "rna_Material_draw_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"); @@ -1887,6 +1929,12 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Light Group", "Limit lighting to lamps in this Group"); RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "edit_image", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "edit_image"); + RNA_def_property_struct_type(prop, "Image"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Edit Image", "Image to use for UV-mapping"); + 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"); @@ -1964,18 +2012,6 @@ void RNA_def_material(BlenderRNA *brna) 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", diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index ad5f320625c..a76a53fb667 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -67,11 +67,12 @@ 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_report.h" +#include "DEG_depsgraph.h" + #include "ED_mesh.h" /* XXX Bad level call */ #include "WM_api.h" @@ -185,12 +186,10 @@ 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); @@ -223,7 +222,7 @@ 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); } } @@ -237,6 +236,20 @@ static void rna_Mesh_update_data_edit_color(Main *bmain, Scene *scene, PointerRN } } +static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_NOCHECK); + + rna_Mesh_update_data(bmain, scene, ptr); +} + + +static void rna_Mesh_update_data_edit_active_color(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + BKE_mesh_batch_cache_dirty(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_NOCHECK); + + 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; @@ -262,6 +275,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(me, BKE_MESH_BATCH_DIRTY_NOCHECK); + rna_Mesh_update_draw(bmain, scene, ptr); } @@ -271,6 +287,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(me, BKE_MESH_BATCH_DIRTY_NOCHECK); + rna_Mesh_update_draw(bmain, scene, ptr); } @@ -747,13 +766,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); } @@ -858,6 +870,36 @@ static int rna_MeshUVLoopLayer_data_length(PointerRNA *ptr) return (me->edit_btmesh) ? 0 : me->totloop; } +static int rna_MeshUVLoopLayer_active_render_get(PointerRNA *ptr) +{ + return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV, 1); +} + +static int rna_MeshUVLoopLayer_active_get(PointerRNA *ptr) +{ + return rna_CustomDataLayer_active_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV, 0); +} + +static int rna_MeshUVLoopLayer_clone_get(PointerRNA *ptr) +{ + return rna_CustomDataLayer_clone_get(ptr, rna_mesh_ldata(ptr), CD_MLOOPUV); +} + +static void rna_MeshUVLoopLayer_active_render_set(PointerRNA *ptr, int value) +{ + rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV, 1); +} + +static void rna_MeshUVLoopLayer_active_set(PointerRNA *ptr, int value) +{ + rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV, 0); +} + +static void rna_MeshUVLoopLayer_clone_set(PointerRNA *ptr, int value) +{ + rna_CustomDataLayer_clone_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV); +} + /* face uv_textures */ DEFINE_CUSTOMDATA_LAYER_COLLECTION(tessface_uv_texture, fdata, CD_MTFACE) @@ -909,57 +951,6 @@ 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 int rna_MeshTexturePolyLayer_active_render_get(PointerRNA *ptr) -{ - return rna_CustomDataLayer_active_get(ptr, rna_mesh_pdata(ptr), CD_MTEXPOLY, 1); -} - -static int rna_MeshTexturePolyLayer_active_get(PointerRNA *ptr) -{ - return rna_CustomDataLayer_active_get(ptr, rna_mesh_pdata(ptr), CD_MTEXPOLY, 0); -} - -static int 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, int 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, int value) -{ - rna_CustomDataLayer_clone_set(ptr, rna_mesh_pdata(ptr), value, CD_MTEXPOLY); -} - /* vertex_color_layers */ DEFINE_CUSTOMDATA_LAYER_COLLECTION(tessface_vertex_color, fdata, CD_MCOL) @@ -1183,42 +1174,75 @@ static int rna_MeshPaintMaskLayer_data_length(PointerRNA *ptr) /* End paint mask */ -static void rna_TexturePoly_image_set(PointerRNA *ptr, PointerRNA value) +/* Face maps */ + +DEFINE_CUSTOMDATA_LAYER_COLLECTION(face_map, pdata, CD_FACEMAP) +DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(face_map, pdata, CD_FACEMAP, active, MeshFaceMapLayer) + +static char *rna_MeshFaceMapLayer_path(PointerRNA *ptr) { - MTexPoly *tf = (MTexPoly *)ptr->data; - ID *id = value.data; + 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); +} + +static void rna_MeshFaceMapLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Mesh *me = rna_mesh(ptr); + CustomDataLayer *layer = (CustomDataLayer *)ptr->data; + rna_iterator_array_begin(iter, layer->data, sizeof(int), me->totpoly, 0, NULL); +} + +static int rna_MeshFaceMapLayer_data_length(PointerRNA *ptr) +{ + Mesh *me = rna_mesh(ptr); + return me->totpoly; +} - 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); +static PointerRNA rna_Mesh_face_map_new(struct Mesh *me, ReportList *reports, const char *name) +{ + if (BKE_mesh_ensure_facemap_customdata(me) == false) { + BKE_report(reports, RPT_ERROR, "Currently only single face-map layers are supported"); + return PointerRNA_NULL; } - tf->tpage = (struct Image *)id; + CustomData *pdata = rna_mesh_pdata_helper(me); + + 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); + + PointerRNA ptr; + RNA_pointer_create(&me->id, &RNA_MeshFaceMapLayer, cdl, &ptr); + return ptr; } -/* 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) -{ - 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); +static void rna_Mesh_face_map_remove(struct Mesh *me, ReportList *reports, struct CustomDataLayer *layer) +{ + /* 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; + } + } } - tf->tpage = (struct Image *)id; + if (BKE_mesh_clear_facemap_customdata(me) == false) { + BKE_reportf(reports, RPT_ERROR, "Error removing face-map"); + } } +/* End face maps */ + + static int rna_MeshTessFace_verts_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) { MFace *face = (MFace *)ptr->data; @@ -1369,14 +1393,6 @@ static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr) 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; @@ -1472,11 +1488,6 @@ 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; @@ -1664,6 +1675,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) @@ -1757,23 +1774,23 @@ 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); @@ -1848,14 +1865,14 @@ static void UNUSED_FUNCTION(rna_mesh_unused)(void) (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 */ } @@ -1883,7 +1900,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) @@ -2253,6 +2270,24 @@ 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"); + prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); + 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_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_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"); + srna = RNA_def_struct(brna, "MeshUVLoop", NULL); RNA_def_struct_sdna(srna, "MLoopUV"); RNA_def_struct_path_func(srna, "rna_MeshUVLoop_path"); @@ -2322,13 +2357,6 @@ static void rna_def_mtface(BlenderRNA *brna) 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); @@ -2383,84 +2411,6 @@ static void rna_def_mtface(BlenderRNA *brna) } -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_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_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_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); - - 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", ""); - 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_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; @@ -2927,13 +2877,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) @@ -2941,14 +2891,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", @@ -3113,7 +3076,6 @@ static void rna_def_tessface_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) 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", @@ -3123,49 +3085,7 @@ static void rna_def_tessface_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) 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_Mesh_tessface_uv_texture_active_index_set", "rna_Mesh_uv_layer_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"); } @@ -3248,6 +3168,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; @@ -3337,41 +3330,6 @@ static void rna_def_mesh(BlenderRNA *brna) "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); @@ -3442,6 +3400,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"); @@ -3712,10 +3679,10 @@ void RNA_def_mesh(BlenderRNA *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 9b0a25560f9..6886321a498 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -48,6 +48,7 @@ #include "DNA_mesh_types.h" #include "BKE_mesh.h" +#include "BKE_mesh_tangent.h" #include "BKE_mesh_mapping.h" #include "ED_mesh.h" @@ -92,7 +93,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) @@ -172,7 +173,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 +191,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, int 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) @@ -206,7 +207,7 @@ static void rna_Mesh_flip_normals(Mesh *mesh) BKE_mesh_tessface_clear(mesh); BKE_mesh_calc_normals(mesh); - DAG_id_tag_update(&mesh->id, 0); + DEG_id_tag_update(&mesh->id, 0); } static void rna_Mesh_split_faces(Mesh *mesh, int free_loop_normals) @@ -214,6 +215,12 @@ static void rna_Mesh_split_faces(Mesh *mesh, int 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(mesh, BKE_MESH_BATCH_DIRTY_NOCHECK); +} + + #else void RNA_api_mesh(StructRNA *srna) @@ -304,6 +311,8 @@ void RNA_api_mesh(StructRNA *srna) RNA_def_boolean(func, "calc_tessface", 0, "Calculate Tessellation", "Force recalculation of tessellation faces"); 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 0f42596ff13..05274e13e1e 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 91a65c7ccc5..9c91bea7c45 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -47,9 +47,10 @@ #include "DNA_object_types.h" #include "BKE_mball.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" +#include "DEG_depsgraph.h" + #include "WM_types.h" #include "WM_api.h" @@ -103,7 +104,7 @@ static void rna_MetaBall_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) if (ob->data == mb) 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 +122,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 +143,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 +154,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 3d8f375fd88..117162babd5 100644 --- a/source/blender/makesrna/intern/rna_meta_api.c +++ b/source/blender/makesrna/intern/rna_meta_api.c @@ -47,7 +47,7 @@ static void rna_Meta_transform(struct MetaBall *mb, float *mat) { BKE_mball_transform(mb, (float (*)[4])mat); - DAG_id_tag_update(&mb->id, 0); + DEG_id_tag_update(&mb->id, 0); } #else diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 1a8dd05a7b5..03340c6c356 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -286,12 +286,14 @@ 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_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 @@ -453,14 +455,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 */ @@ -793,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); } } } @@ -806,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); } } } @@ -933,19 +935,19 @@ static EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf(bConte if (ob_src) { DerivedMesh *dm_src; - CustomData *pdata; + CustomData *ldata; 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); + ldata = dm_src->getLoopDataLayout(dm_src); + 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); } } @@ -1024,18 +1026,18 @@ static EnumPropertyItem *rna_DataTransferModifier_layers_select_dst_itemf(bConte 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); } } @@ -2248,11 +2250,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"); diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c index 15411f85ba3..925bc048bc3 100644 --- a/source/blender/makesrna/intern/rna_movieclip.c +++ b/source/blender/makesrna/intern/rna_movieclip.c @@ -47,7 +47,7 @@ #ifdef RNA_RUNTIME -#include "BKE_depsgraph.h" +#include "DEG_depsgraph.h" #include "ED_clip.h" @@ -59,7 +59,7 @@ static void rna_MovieClip_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene MovieClip *clip = (MovieClip *)ptr->id.data; BKE_movieclip_reload(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) diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index d72c858a5d5..0e43f12b64b 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" diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 77b42a5aeca..3f540128622 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -66,6 +66,8 @@ #include "NOD_composite.h" +#include "DEG_depsgraph.h" + EnumPropertyItem rna_enum_node_socket_in_out_items[] = { { SOCK_IN, "IN", 0, "Input", "" }, { SOCK_OUT, "OUT", 0, "Output", "" }, @@ -180,6 +182,8 @@ static EnumPropertyItem node_sampler_type_items[] = { #include "ED_node.h" #include "ED_render.h" +#include "GPU_material.h" + #include "NOD_common.h" #include "NOD_socket.h" @@ -2273,13 +2277,25 @@ static void rna_NodeSocketStandard_vector_range(PointerRNA *ptr, float *min, flo *softmax = dval->max; } +static void rna_NodeSocket_value_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bNodeTree *ntree = (bNodeTree *)ptr->id.data; + if (ntree->type == NTREE_SHADER) { + DEG_id_tag_update_ex(bmain, ptr->id.data, DEG_TAG_SHADING_UPDATE); + WM_main_add_notifier(NC_MATERIAL | ND_SHADING, NULL); + } + else { + rna_NodeSocket_update(bmain, scene, ptr); + } +} + /* using a context update function here, to avoid searching the node if possible */ static void rna_NodeSocketStandard_value_update(struct bContext *C, PointerRNA *ptr) { bNode *node; /* default update */ - rna_NodeSocket_update(CTX_data_main(C), CTX_data_scene(C), ptr); + rna_NodeSocket_value_update(CTX_data_main(C), CTX_data_scene(C), ptr); /* try to use node from context, faster */ node = CTX_data_pointer_get(C, "node").data; @@ -3086,6 +3102,7 @@ static int point_density_vertex_color_source_from_shader(NodeShaderTexPointDensi void rna_ShaderNodePointDensity_density_cache(bNode *self, Scene *scene, + SceneLayer *sl, int settings) { NodeShaderTexPointDensity *shader_point_density = self->storage; @@ -3123,12 +3140,13 @@ void rna_ShaderNodePointDensity_density_cache(bNode *self, /* Single-threaded sampling of the voxel domain. */ RE_point_density_cache(scene, - pd, + sl, pd, settings == 1); } void rna_ShaderNodePointDensity_density_calc(bNode *self, Scene *scene, + SceneLayer *sl, int settings, int *length, float **values) @@ -3150,7 +3168,7 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self, } /* Single-threaded sampling of the voxel domain. */ - RE_point_density_sample(scene, pd, + RE_point_density_sample(scene, sl, pd, resolution, settings == 1, *values); @@ -3163,6 +3181,7 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self, void rna_ShaderNodePointDensity_density_minmax(bNode *self, Scene *scene, + SceneLayer *sl, int settings, float r_min[3], float r_max[3]) @@ -3174,7 +3193,7 @@ void rna_ShaderNodePointDensity_density_minmax(bNode *self, zero_v3(r_max); return; } - RE_point_density_minmax(scene, pd, settings == 1, r_min, r_max); + RE_point_density_minmax(scene, sl, pd, settings == 1, r_min, r_max); } #else @@ -4158,11 +4177,13 @@ 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_pointer(func, "sl", "SceneLayer", "", ""); RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); 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_pointer(func, "sl", "SceneLayer", "", ""); RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); /* 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); @@ -4172,6 +4193,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_pointer(func, "sl", "SceneLayer", "", ""); RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_COORDS); RNA_def_property_array(parm, 3); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index a167ab03ba1..50160b5b189 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -47,6 +47,7 @@ #include "BKE_editmesh.h" #include "BKE_group.h" /* needed for BKE_group_object_exists() */ #include "BKE_object_deform.h" +#include "BKE_object_facemap.h" #include "RNA_access.h" #include "RNA_define.h" @@ -96,16 +97,27 @@ static 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_GROUP \ + {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"} static 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_GROUP, + {0, NULL, 0, NULL, NULL} +}; +#ifdef RNA_RUNTIME +static EnumPropertyItem dupli_items_nogroup[] = { + DUPLI_ITEMS_SHARED, {0, NULL, 0, NULL, NULL} }; #endif +#undef DUPLI_ITEMS_SHARED +#undef DUPLI_ITEM_GROUP static EnumPropertyItem collision_bounds_items[] = { {OB_BOUND_BOX, "BOX", ICON_MESH_CUBE, "Box", ""}, @@ -147,6 +159,7 @@ EnumPropertyItem rna_enum_object_type_items[] = { {OB_CAMERA, "CAMERA", 0, "Camera", ""}, {OB_LAMP, "LAMP", 0, "Lamp", ""}, {OB_SPEAKER, "SPEAKER", 0, "Speaker", ""}, + {OB_LIGHTPROBE, "LIGHT_PROBE", 0, "Probe", ""}, {0, NULL, 0, NULL, NULL} }; @@ -181,7 +194,6 @@ EnumPropertyItem rna_enum_object_axis_items[] = { #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" @@ -192,6 +204,9 @@ EnumPropertyItem rna_enum_object_axis_items[] = { #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" @@ -199,7 +214,7 @@ 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_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -211,7 +226,7 @@ static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { - DAG_id_type_tag(bmain, ID_OB); + DEG_id_type_tag(bmain, ID_OB); } static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) @@ -254,7 +269,7 @@ 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); } @@ -269,7 +284,7 @@ static void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA EDBM_mesh_load(ob); EDBM_mesh_make(scene->toolsettings, ob, 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); @@ -291,29 +306,20 @@ 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; + BaseLegacy *base = (BaseLegacy *)ptr->data; + short mode = (base->flag_legacy & 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) +static void rna_Object_layer_update__internal(Main *bmain, Scene *scene, BaseLegacy *base, Object *ob) { /* try to avoid scene sort */ if (scene == NULL) { @@ -326,16 +332,16 @@ static void rna_Object_layer_update__internal(Main *bmain, Scene *scene, Base *b /* pass */ } else { - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } - DAG_id_type_tag(bmain, ID_OB); + DEG_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; + BaseLegacy *base; base = scene ? BKE_scene_base_find(scene, ob) : NULL; if (!base) @@ -351,7 +357,7 @@ static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Base *base = (Base *)ptr->data; + BaseLegacy *base = (BaseLegacy *)ptr->data; Object *ob = (Object *)base->object; rna_Object_layer_update__internal(bmain, scene, base, ob); @@ -424,6 +430,7 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) case OB_LATTICE: return &RNA_Lattice; case OB_ARMATURE: return &RNA_Armature; case OB_SPEAKER: return &RNA_Speaker; + case OB_LIGHTPROBE: return &RNA_LightProbe; default: return &RNA_ID; } } @@ -519,6 +526,23 @@ static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value) ED_object_parent(ob, ob->parent, ob->partype, value); } +static EnumPropertyItem *rna_Object_dupli_type_itemf( + bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) +{ + Object *ob = (Object *)ptr->data; + EnumPropertyItem *item; + + 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; @@ -528,9 +552,15 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value) * 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 (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, @@ -618,6 +648,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; @@ -628,10 +739,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; } @@ -705,7 +816,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); assign_material(ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING); } @@ -747,9 +858,14 @@ static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int val 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(scene, ob); + PE_current_changed(NULL, scene, ob); +#else + (void) scene; + (void) ptr; +#endif } /* rotation - axis-angle */ @@ -938,7 +1054,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) @@ -1065,7 +1181,7 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value) 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); + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); } } @@ -1117,7 +1233,7 @@ static void rna_Object_layer_set(PointerRNA *ptr, const int *values) static void rna_Base_layer_set(PointerRNA *ptr, const int *values) { - Base *base = (Base *)ptr->data; + BaseLegacy *base = (BaseLegacy *)ptr->data; unsigned int lay; lay = rna_Object_layer_validate__internal(values, base->lay); @@ -1462,6 +1578,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 */ int rna_Lattice_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) { @@ -1581,6 +1760,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; @@ -2108,6 +2330,54 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Delete all vertex groups from object"); } +/* object.face_maps */ +static void rna_def_object_face_maps(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + PropertyRNA *prop; + + 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"); + + /* 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); + + 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); + + 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_lodlevel(BlenderRNA *brna) { @@ -2247,11 +2517,6 @@ static void rna_def_object(BlenderRNA *brna) 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); @@ -2530,6 +2795,14 @@ 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); RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype"); @@ -2624,6 +2897,12 @@ static void rna_def_object(BlenderRNA *brna) 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, "collection_properties", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "base_collection_properties->data.group", NULL); + RNA_def_property_struct_type(prop, "LayerCollectionSettings"); + RNA_def_property_ui_text(prop, "Collection Settings", + "Engine specific render settings to be overridden by collections"); + /* anim */ rna_def_animdata_common(srna); @@ -2658,6 +2937,7 @@ static void rna_def_object(BlenderRNA *brna) 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"); @@ -2900,14 +3180,14 @@ static void rna_def_dupli_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Dupli random id", "Random id for this dupli object"); } -static void rna_def_object_base(BlenderRNA *brna) +static void rna_def_object_base_legacy(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "ObjectBase", NULL); + srna = RNA_def_struct(brna, "ObjectBaseLegacy", 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_text(srna, "Object Base Legacy", "An object instance in a scene (deprecated)"); RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); @@ -2927,13 +3207,13 @@ static void rna_def_object_base(BlenderRNA *brna) 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 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_boolean_sdna(prop, NULL, "flag_legacy", 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"); - - RNA_api_object_base(srna); + + RNA_api_object_base_legacy(srna); } void RNA_def_object(BlenderRNA *brna) @@ -2942,8 +3222,9 @@ void RNA_def_object(BlenderRNA *brna) RNA_define_animate_sdna(false); rna_def_object_game_settings(brna); - rna_def_object_base(brna); + rna_def_object_base_legacy(brna); rna_def_vertex_group(brna); + rna_def_face_map(brna); rna_def_material_slot(brna); rna_def_dupli_object(brna); RNA_define_animate_sdna(true); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 9b9f0705bb4..7bf483ad2f0 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 */ @@ -88,7 +91,61 @@ static EnumPropertyItem space_items[] = { #include "MEM_guardedalloc.h" -#include "DEG_depsgraph.h" +static void rna_Object_select_set(Object *ob, bContext *C, ReportList *reports, int action) +{ + SceneLayer *sl = CTX_data_scene_layer(C); + Base *base = BKE_scene_layer_base_find(sl, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in Render Layer '%s'!", ob->id.name + 2, sl->name); + return; + } + + if (action == 2) { /* TOGGLE */ + if ((base->flag & BASE_SELECTED) != 0) { + action = 1; /* DESELECT */ + } + else { + action = 0; /* SELECT */ + } + } + + switch (action) { + case 1: /* DESELECT */ + base->flag &= ~BASE_SELECTED; + break; + case 0: /* SELECT */ + default: + BKE_scene_layer_base_select(sl, base); + break; + } +} + +static int rna_Object_select_get(Object *ob, bContext *C, ReportList *reports) +{ + SceneLayer *sl = CTX_data_scene_layer(C); + Base *base = BKE_scene_layer_base_find(sl, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in Render Layer '%s'!", ob->id.name + 2, sl->name); + return -1; + } + + return ((base->flag & BASE_SELECTED) != 0) ? 1 : 0; +} + +static int rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports) +{ + SceneLayer *sl = CTX_data_scene_layer(C); + Base *base = BKE_scene_layer_base_find(sl, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in Render Layer '%s'!", ob->id.name + 2, sl->name); + return -1; + } + + return ((base->flag & BASE_VISIBLED) != 0) ? 1 : 0; +} /* Convert a given matrix from a space to another (using the object and/or a bone as reference). */ static void rna_Scene_mat_convert_space(Object *ob, ReportList *reports, bPoseChannel *pchan, @@ -140,14 +197,16 @@ static void rna_Object_camera_fit_coords( /* copied from Mesh_getFromObject and adapted to RNA interface */ /* settings: 0 - preview, 1 - render */ static Mesh *rna_Object_to_mesh( - Object *ob, ReportList *reports, Scene *sce, + Object *ob, bContext *C, ReportList *reports, Scene *sce, SceneLayer *sl, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed) { - return rna_Main_meshes_new_from_object(G.main, reports, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed); + Main *bmain = CTX_data_main(C); + + return rna_Main_meshes_new_from_object(bmain, reports, sce, sl, 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) +static void dupli_render_particle_set(EvaluationContext *eval_ctx, 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 */ @@ -176,7 +235,7 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e /* 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 = mesh_create_derived_render(eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL); dm->release(dm); for (psys = ob->particlesystem.first; psys; psys = psys->next) @@ -188,14 +247,17 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e group = ob->dup_group; for (go = group->gobject.first; go; go = go->next) - dupli_render_particle_set(scene, go->ob, level + 1, enable); + dupli_render_particle_set(eval_ctx, 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, ReportList *reports, Scene *sce, int settings) +static void rna_Object_create_duplilist(Object *ob, bContext *C, ReportList *reports, Scene *sce, int settings) { bool for_render = (settings == DAG_EVAL_RENDER); EvaluationContext eval_ctx; - DEG_evaluation_context_init(&eval_ctx, settings); + + CTX_data_eval_ctx(C, &eval_ctx); + + eval_ctx.mode = settings; if (!(ob->transflag & OB_DUPLI)) { BKE_report(reports, RPT_ERROR, "Object does not have duplis"); @@ -210,10 +272,10 @@ static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene * ob->duplilist = NULL; } if (for_render) - dupli_render_particle_set(sce, ob, 0, 1); + dupli_render_particle_set(&eval_ctx, sce, ob, 0, 1); ob->duplilist = object_duplilist(&eval_ctx, sce, ob); if (for_render) - dupli_render_particle_set(sce, ob, 0, 0); + dupli_render_particle_set(&eval_ctx, sce, ob, 0, 0); /* ob->duplilist should now be freed with Object.free_duplilist */ } @@ -261,7 +323,7 @@ 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); @@ -419,9 +481,9 @@ finally: free_bvhtree_from_mesh(&treeData); } -/* ObjectBase */ +/* ObjectBaseLegacy */ -static void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d) +static void rna_ObjectBaseLegacy_layers_from_view(BaseLegacy *base, View3D *v3d) { base->lay = base->object->lay = v3d->lay; } @@ -510,6 +572,32 @@ void RNA_api_object(StructRNA *srna) }; #endif + static EnumPropertyItem object_select_items[] = { + {0, "SELECT", 0, "Select", "Select object from the active render layer"}, + {1, "DESELECT", 0, "Deselect", "Deselect object from the active render layer"}, + {2, "TOGGLE", 0, "Toggle", "Toggle object selection from the active render layer"}, + {0, NULL, 0, NULL, NULL} + }; + + /* 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 render layer)"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + parm = RNA_def_enum(func, "action", object_select_items, 0, "Action", "Select mode"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + func = RNA_def_function(srna, "select_get", "rna_Object_select_get"); + RNA_def_function_ui_description(func, "Get the object selection for the active render 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 render 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); + /* Matrix space conversion */ func = RNA_def_function(srna, "convert_space", "rna_Scene_mat_convert_space"); RNA_def_function_ui_description(func, "Convert (transform) the given matrix from one space to another"); @@ -561,9 +649,11 @@ 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_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "Scene layer 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"); @@ -582,7 +672,7 @@ void RNA_api_object(StructRNA *srna) 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"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT); func = RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist"); RNA_def_function_ui_description(func, "Free the list of dupli objects"); @@ -713,12 +803,12 @@ void RNA_api_object(StructRNA *srna) } -void RNA_api_object_base(StructRNA *srna) +void RNA_api_object_base_legacy(StructRNA *srna) { FunctionRNA *func; PropertyRNA *parm; - func = RNA_def_function(srna, "layers_from_view", "rna_ObjectBase_layers_from_view"); + func = RNA_def_function(srna, "layers_from_view", "rna_ObjectBaseLegacy_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", "", ""); diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 514fca1b011..2ae674ea961 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -94,10 +94,13 @@ static 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_modifier.h" #include "BKE_pointcache.h" -#include "BKE_depsgraph.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" #include "ED_object.h" @@ -115,7 +118,7 @@ static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) @@ -184,7 +187,7 @@ static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), P 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 { @@ -499,7 +502,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); } @@ -511,7 +514,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); } } @@ -547,7 +550,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; @@ -563,12 +566,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); } @@ -605,23 +608,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(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); } @@ -718,7 +721,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); } @@ -726,13 +729,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); } diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 00104b8667d..93801a508c5 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -135,7 +135,6 @@ static 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" @@ -145,6 +144,9 @@ static 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) @@ -612,8 +614,14 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, R } } -static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Scene *scene, Object *object, int resolution) +static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Scene *scene, SceneLayer *sl, Object *object, int resolution) { + EvaluationContext eval_ctx; + + DEG_evaluation_context_init(&eval_ctx, resolution); + eval_ctx.ctime = (float)scene->r.cfra + scene->r.subframe; + eval_ctx.scene_layer = sl; + if (resolution == eModifierMode_Render) { ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem); float mat[4][4]; @@ -622,7 +630,7 @@ static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Sc psys_render_set(object, particlesystem, mat, mat, 1, 1, 0.f); psmd->flag &= ~eParticleSystemFlag_psys_updated; - particle_system_update(scene, object, particlesystem, true); + particle_system_update(&eval_ctx, scene, object, particlesystem, true); } else { ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem); @@ -632,7 +640,7 @@ static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Sc } psmd->flag &= ~eParticleSystemFlag_psys_updated; - particle_system_update(scene, object, particlesystem, false); + particle_system_update(&eval_ctx, scene, object, particlesystem, false); } } @@ -643,10 +651,10 @@ static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN psys->recalc = flag; - 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 | flag); + DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA | flag); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); } @@ -657,7 +665,7 @@ 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); } @@ -668,7 +676,7 @@ 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); } @@ -691,7 +699,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); } @@ -736,8 +744,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); @@ -752,7 +760,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); } } @@ -772,7 +780,7 @@ static void rna_Particle_hair_dynamics(Main *bmain, Scene *scene, PointerRNA *pt else WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } static PointerRNA rna_particle_settings_get(PointerRNA *ptr) { @@ -2372,10 +2380,10 @@ static void rna_def_particle_settings(BlenderRNA *brna) 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, "draw_size", PROP_FLOAT, PROP_NONE); 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 (0.1 = default)"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); prop = RNA_def_property(srna, "child_type", PROP_ENUM, PROP_NONE); @@ -3545,6 +3553,7 @@ static void rna_def_particle_system(BlenderRNA *brna) 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_pointer(func, "scene", "Scene", "", "Scene"); + RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "SceneLayer"); RNA_def_pointer(func, "object", "Object", "", "Object"); RNA_def_enum(func, "resolution", resolution_items, 0, "", "Resolution settings to apply"); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 8d161466d56..d9e7d3f6a84 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -106,9 +106,11 @@ EnumPropertyItem rna_enum_color_sets_items[] = { #include "BKE_context.h" #include "BKE_constraint.h" -#include "BKE_depsgraph.h" #include "BKE_idprop.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "ED_object.h" #include "ED_armature.h" @@ -120,7 +122,7 @@ 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); } static void rna_Pose_IK_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -128,7 +130,7 @@ 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); BIK_clear_data(ob->pose); } @@ -233,13 +235,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(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 */ @@ -349,7 +351,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) @@ -671,7 +673,7 @@ 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 */ } diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 44dcb72264a..19002d1229b 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 "RNA_define.h" #include "RNA_enum_types.h" @@ -136,7 +138,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 *graph, Scene *scene) { extern FunctionRNA rna_RenderEngine_update_func; PointerRNA ptr; @@ -148,24 +150,25 @@ 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, "depsgraph", &graph); RNA_parameter_set_lookup(&list, "scene", &scene); 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_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) { - extern FunctionRNA rna_RenderEngine_render_func; + extern FunctionRNA rna_RenderEngine_render_to_image_func; PointerRNA ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); - func = &rna_RenderEngine_render_func; + func = &rna_RenderEngine_render_to_image_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); @@ -216,15 +219,15 @@ static void engine_view_update(RenderEngine *engine, const struct bContext *cont RNA_parameter_list_free(&list); } -static void engine_view_draw(RenderEngine *engine, const struct bContext *context) +static void engine_render_to_view(RenderEngine *engine, const struct bContext *context) { - extern FunctionRNA rna_RenderEngine_view_draw_func; + extern FunctionRNA rna_RenderEngine_render_to_view_func; PointerRNA ptr; ParameterList list; FunctionRNA *func; RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); - func = &rna_RenderEngine_view_draw_func; + func = &rna_RenderEngine_render_to_view_func; RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "context", &context); @@ -251,6 +254,23 @@ static void engine_update_script_node(RenderEngine *engine, struct bNodeTree *nt RNA_parameter_list_free(&list); } +static void engine_collection_settings_create(RenderEngine *engine, struct IDProperty *props) +{ + extern FunctionRNA rna_RenderEngine_collection_settings_create_func; + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + func = &rna_RenderEngine_collection_settings_create_func; + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "props", &props); + engine->type->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_list_free(&list); +} + static void engine_update_render_passes(RenderEngine *engine, struct Scene *scene, struct SceneRenderLayer *srl) { extern FunctionRNA rna_RenderEngine_update_render_passes_func; @@ -289,7 +309,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo 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; @@ -326,14 +346,15 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo RNA_struct_blender_type_set(et->ext.srna, et); et->update = (have_function[0]) ? engine_update : NULL; - et->render = (have_function[1]) ? engine_render : NULL; + et->render_to_image = (have_function[1]) ? engine_render_to_image : NULL; et->bake = (have_function[2]) ? engine_bake : NULL; et->view_update = (have_function[3]) ? engine_view_update : NULL; - et->view_draw = (have_function[4]) ? engine_view_draw : NULL; + et->render_to_view = (have_function[4]) ? engine_render_to_view : NULL; et->update_script_node = (have_function[5]) ? engine_update_script_node : NULL; et->update_render_passes = (have_function[6]) ? engine_update_render_passes : NULL; + et->collection_settings_create = (have_function[7]) ? engine_collection_settings_create : NULL; - BLI_addtail(&R_engines, et); + RE_engines_register(bmain, et); return et->ext.srna; } @@ -364,6 +385,16 @@ static PointerRNA rna_RenderEngine_render_get(PointerRNA *ptr) } } +static PointerRNA rna_RenderEngine_scene_layer_get(PointerRNA *ptr) +{ + RenderEngine *engine = (RenderEngine *)ptr->data; + if (engine->re != NULL) { + SceneLayer* scene_layer = RE_engine_get_scene_layer(engine->re); + return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, scene_layer); + } + return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, NULL); +} + static PointerRNA rna_RenderEngine_camera_override_get(PointerRNA *ptr) { RenderEngine *engine = (RenderEngine *)ptr->data; @@ -462,12 +493,13 @@ 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, "depsgraph", "Depsgraph", "", ""); RNA_def_pointer(func, "scene", "Scene", "", ""); - func = RNA_def_function(srna, "render", NULL); + func = RNA_def_function(srna, "render_to_image", 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", "", ""); + RNA_def_pointer(func, "desgraph", "Depsgraph", "", ""); func = RNA_def_function(srna, "bake", NULL); RNA_def_function_ui_description(func, "Bake passes"); @@ -498,7 +530,7 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); RNA_def_pointer(func, "context", "Context", "", ""); - func = RNA_def_function(srna, "view_draw", NULL); + func = RNA_def_function(srna, "render_to_view", NULL); RNA_def_function_ui_description(func, "Draw viewport render"); RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); RNA_def_pointer(func, "context", "Context", "", ""); @@ -510,6 +542,19 @@ 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", "SceneRenderLayer", "", ""); + + /* per-collection engine settings initialization */ + func = RNA_def_function(srna, "collection_settings_create", NULL); + RNA_def_function_ui_description(func, "Create the per collection settings for the engine"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + parm = RNA_def_pointer(func, "collection_settings", "LayerCollectionSettings", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); + /* tag for redraw */ func = RNA_def_function(srna, "tag_redraw", "engine_tag_redraw"); RNA_def_function_ui_description(func, "Request redraw for viewport rendering"); @@ -518,12 +563,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); @@ -700,6 +739,11 @@ static void rna_def_render_engine(BlenderRNA *brna) prop = RNA_def_enum(func, "type", render_pass_type_items, SOCK_FLOAT, "Type", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + prop = RNA_def_property(srna, "scene_layer", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "SceneLayer"); + RNA_def_property_pointer_funcs(prop, "rna_RenderEngine_scene_layer_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Scene layer", ""); + /* registration */ prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c index a1a7efdaba5..1ed375706df 100644 --- a/source/blender/makesrna/intern/rna_rigidbody.c +++ b/source/blender/makesrna/intern/rna_rigidbody.c @@ -91,7 +91,6 @@ static EnumPropertyItem rigidbody_mesh_source_items[] = { # include "RBI_api.h" #endif -#include "BKE_depsgraph.h" #include "BKE_rigidbody.h" #include "WM_api.h" diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b9231574a24..2c0ffd6af05 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -32,6 +32,7 @@ #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" @@ -47,8 +48,12 @@ #include "BKE_editmesh.h" #include "BKE_paint.h" +#include "ED_object.h" + #include "GPU_extensions.h" +#include "DRW_engine.h" + #include "RNA_define.h" #include "RNA_enum_types.h" @@ -432,6 +437,14 @@ EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = { + {COLLECTION_MODE_OBJECT, "OBJECT", 0, "Object", ""}, + {COLLECTION_MODE_EDIT, "EDIT", 0, "Edit", ""}, + {COLLECTION_MODE_PAINT_WEIGHT, "PAINT_WEIGHT", 0, "Weight Paint", ""}, + {COLLECTION_MODE_PAINT_WEIGHT, "PAINT_VERTEX", 0, "Vertex Paint", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "DNA_anim_types.h" @@ -446,16 +459,18 @@ EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { #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_idprop.h" #include "BKE_mesh.h" #include "BKE_sound.h" #include "BKE_screen.h" @@ -464,12 +479,19 @@ EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { #include "BKE_freestyle.h" #include "BKE_gpencil.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "ED_info.h" #include "ED_node.h" #include "ED_view3d.h" #include "ED_mesh.h" #include "ED_keyframing.h" #include "ED_image.h" +#include "ED_scene.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #ifdef WITH_FREESTYLE #include "FRS_freestyle.h" @@ -608,11 +630,11 @@ static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, Poi static int rna_Scene_object_bases_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) { Scene *scene = (Scene *)ptr->data; - Base *base; + BaseLegacy *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); + *r_ptr = rna_pointer_inherit_refine(ptr, &RNA_ObjectBaseLegacy, base); return true; } } @@ -625,13 +647,13 @@ 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); + return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((BaseLegacy *)internal->link)->object); } -static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *reports, Object *ob) +static BaseLegacy *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *reports, Object *ob) { Scene *scene_act = CTX_data_scene(C); - Base *base; + BaseLegacy *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); @@ -649,11 +671,11 @@ static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *report 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); + DEG_relations_tag_update(CTX_data_main(C)); + DEG_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(G.main); */ + /* DEG_srelations_tag_update(G.main); */ WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene); @@ -662,7 +684,7 @@ static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *report static void rna_Scene_object_unlink(Scene *scene, ReportList *reports, Object *ob) { - Base *base = BKE_scene_base_find(scene, ob); + BaseLegacy *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; @@ -681,7 +703,7 @@ static void rna_Scene_object_unlink(Scene *scene, ReportList *reports, Object *o id_us_min(&ob->id); /* needed otherwise the depgraph will contain freed objects which can crash, see [#20958] */ - DAG_relations_tag_update(G.main); + DEG_relations_tag_update(G.main); WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene); } @@ -744,19 +766,21 @@ static int rna_Scene_active_layer_get(PointerRNA *ptr) 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); + WM_windows_scene_data_sync(&wm->windows, scene); } -static void rna_Scene_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Scene_layer_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(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); + DEG_on_visible_update(bmain, false); + + /* No need to sync scene data here (WM_windows_scene_data_sync), handled through notifier. */ } static void rna_Scene_fps_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) @@ -1453,7 +1477,7 @@ static SceneRenderLayer *rna_RenderLayer_new(ID *id, RenderData *UNUSED(rd), con Scene *scene = (Scene *)id; SceneRenderLayer *srl = BKE_scene_add_render_layer(scene, 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 srl; @@ -1473,7 +1497,7 @@ static void rna_RenderLayer_remove( RNA_POINTER_INVALIDATE(srl_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); } @@ -1545,9 +1569,12 @@ static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value) { RenderData *rd = (RenderData *)ptr->data; RenderEngineType *type = BLI_findlink(&R_engines, value); + Scene *scene = (Scene *)ptr->id.data; if (type) BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine)); + + DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE); } static EnumPropertyItem *rna_RenderSettings_engine_itemf( @@ -1593,14 +1620,22 @@ static void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi { Scene *scene = (Scene *)ptr->id.data; - DAG_id_tag_update(&scene->id, 0); + DEG_id_tag_update(&scene->id, 0); +} + +static void rna_Scene_world_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Scene *sc = (Scene *)ptr->id.data; + + rna_Scene_glsl_update(bmain, scene, ptr); + WM_main_add_notifier(NC_WORLD | ND_WORLD, &sc->id); } static void rna_Scene_freestyle_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; - DAG_id_tag_update(&scene->id, 0); + DEG_id_tag_update(&scene->id, 0); } static void rna_Scene_use_view_map_cache_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) @@ -1749,23 +1784,25 @@ static void rna_Scene_use_nodes_update(bContext *C, PointerRNA *ptr) static void rna_Physics_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; - Base *base; - - for (base = scene->base.first; base; base = base->next) - BKE_ptcache_object_reset(scene, base->object, PTCACHE_RESET_DEPSGRAPH); + FOREACH_SCENE_OBJECT(scene, ob) + { + BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH); + } + FOREACH_SCENE_OBJECT_END } static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const int *value) { Scene *scene = (Scene *)ptr->id.data; + SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene); 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 (sl->basact) { + Mesh *me = BKE_mesh_from_object(sl->basact->object); if (me && me->edit_btmesh && me->edit_btmesh->selectmode != flag) { me->edit_btmesh->selectmode = flag; EDBM_selectmode_set(me->edit_btmesh); @@ -1774,12 +1811,13 @@ static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const int *value } } -static void rna_Scene_editmesh_select_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_Scene_editmesh_select_mode_update(Main *UNUSED(bmain), bContext *C, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { + SceneLayer *sl = CTX_data_scene_layer(C); Mesh *me = NULL; - if (scene->basact) { - me = BKE_mesh_from_object(scene->basact->object); + if (sl->basact) { + me = BKE_mesh_from_object(sl->basact->object); if (me && me->edit_btmesh == NULL) me = NULL; } @@ -1801,7 +1839,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); } } @@ -1827,7 +1865,7 @@ static void rna_Scene_use_simplify_update(Main *bmain, Scene *scene, PointerRNA 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(&scene->id, 0); } static void rna_Scene_simplify_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) @@ -1910,6 +1948,71 @@ static void rna_GameSettings_exit_key_set(PointerRNA *ptr, int value) gm->exitkey = value; } +static StructRNA *rna_SceneLayerSettings_refine(PointerRNA *ptr) +{ + IDProperty *props = (IDProperty *)ptr->data; + BLI_assert(props && props->type == IDP_GROUP); + + switch (props->subtype) { + case IDP_GROUP_SUB_ENGINE_RENDER: +#ifdef WITH_CLAY_ENGINE + if (STREQ(props->name, RE_engine_id_BLENDER_CLAY)) { + return &RNA_SceneLayerEngineSettingsClay; + } +#endif + if (STREQ(props->name, RE_engine_id_BLENDER_EEVEE)) { + return &RNA_SceneLayerEngineSettingsEevee; + } + break; + case IDP_GROUP_SUB_MODE_OBJECT: + case IDP_GROUP_SUB_MODE_EDIT: + case IDP_GROUP_SUB_MODE_PAINT_WEIGHT: + case IDP_GROUP_SUB_MODE_PAINT_VERTEX: + default: + BLI_assert(!"Mode not fully implemented"); + break; + } + + return &RNA_SceneLayerSettings; +} + +static StructRNA *rna_LayerCollectionSettings_refine(PointerRNA *ptr) +{ + IDProperty *props = (IDProperty *)ptr->data; + BLI_assert(props && props->type == IDP_GROUP); + + switch (props->subtype) { + case IDP_GROUP_SUB_ENGINE_RENDER: +#ifdef WITH_CLAY_ENGINE + if (STREQ(props->name, RE_engine_id_BLENDER_CLAY)) { + return &RNA_LayerCollectionEngineSettingsClay; + } +#endif + if (STREQ(props->name, RE_engine_id_BLENDER_EEVEE)) { + /* printf("Mode not fully implemented\n"); */ + return &RNA_LayerCollectionSettings; + } + break; + case IDP_GROUP_SUB_MODE_OBJECT: + return &RNA_LayerCollectionModeSettingsObject; + break; + case IDP_GROUP_SUB_MODE_EDIT: + return &RNA_LayerCollectionModeSettingsEdit; + break; + case IDP_GROUP_SUB_MODE_PAINT_WEIGHT: + return &RNA_LayerCollectionModeSettingsPaintWeight; + break; + case IDP_GROUP_SUB_MODE_PAINT_VERTEX: + return &RNA_LayerCollectionModeSettingsPaintVertex; + break; + default: + BLI_assert(!"Mode not fully implemented"); + break; + } + + return &RNA_LayerCollectionSettings; +} + static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[], int frame) { TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); @@ -1965,9 +2068,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); + SceneLayer *sl = CTX_data_scene_layer(C); + Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, sl)); WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); } @@ -1990,11 +2095,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)) @@ -2008,18 +2113,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(Main *UNUSED(bmain), bContext *C, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { + SceneLayer *sl = CTX_data_scene_layer(C); Mesh *me = NULL; - if (scene->basact) { - me = BKE_mesh_from_object(scene->basact->object); + if (sl->basact) { + me = BKE_mesh_from_object(sl->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); } } @@ -2034,11 +2140,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; + SceneLayer *sl = CTX_data_scene_layer(C); + Object *ob = OBACT_NEW; + 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); } } @@ -2049,7 +2157,7 @@ static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po Object *camera = scene->camera; if (camera) - DAG_id_tag_update(&camera->id, 0); + DEG_id_tag_update(&camera->id, 0); } static void rna_SceneSequencer_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) @@ -2086,7 +2194,7 @@ static FreestyleLineSet *rna_FreestyleSettings_lineset_add( 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; @@ -2105,7 +2213,7 @@ 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); } @@ -2142,7 +2250,7 @@ static FreestyleModuleConfig *rna_FreestyleSettings_module_add(ID *id, Freestyle 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; @@ -2164,7 +2272,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); } @@ -2225,9 +2333,810 @@ static void rna_Stereo3dFormat_update(Main *UNUSED(bmain), Scene *UNUSED(scene), static int rna_gpu_is_hq_supported_get(PointerRNA *UNUSED(ptr)) { - return GPU_instanced_drawing_support() && GPU_geometry_shader_support(); + return true; +} + +static void rna_SceneCollection_name_set(PointerRNA *ptr, const char *value) +{ + Scene *scene = (Scene *)ptr->id.data; + SceneCollection *sc = (SceneCollection *)ptr->data; + BKE_collection_rename(scene, sc, value); +} + +static void rna_SceneCollection_filter_set(PointerRNA *ptr, const char *value) +{ + Scene *scene = (Scene *)ptr->id.data; + SceneCollection *sc = (SceneCollection *)ptr->data; + BLI_strncpy_utf8(sc->filter, value, sizeof(sc->filter)); + + TODO_LAYER_SYNC_FILTER; + (void)scene; +} + +static PointerRNA rna_SceneCollection_objects_get(CollectionPropertyIterator *iter) +{ + ListBaseIterator *internal = &iter->internal.listbase; + + /* we are actually iterating a LinkData list, so override get */ + return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((LinkData *)internal->link)->data); +} + +static int rna_SceneCollection_move_above(ID *id, SceneCollection *sc_src, Main *bmain, SceneCollection *sc_dst) +{ + Scene *scene = (Scene *)id; + + if (!BKE_collection_move_above(scene, sc_dst, sc_src)) { + return 0; + } + + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + + return 1; +} + +static int rna_SceneCollection_move_below(ID *id, SceneCollection *sc_src, Main *bmain, SceneCollection *sc_dst) +{ + Scene *scene = (Scene *)id; + + if (!BKE_collection_move_below(scene, sc_dst, sc_src)) { + return 0; + } + + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + + return 1; +} + +static int rna_SceneCollection_move_into(ID *id, SceneCollection *sc_src, Main *bmain, SceneCollection *sc_dst) +{ + Scene *scene = (Scene *)id; + + if (!BKE_collection_move_into(scene, sc_dst, sc_src)) { + return 0; + } + + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + + return 1; +} + +static SceneCollection *rna_SceneCollection_new( + ID *id, SceneCollection *sc_parent, Main *bmain, const char *name) +{ + Scene *scene = (Scene *)id; + SceneCollection *sc = BKE_collection_add(scene, sc_parent, name); + + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + + return sc; +} + +static void rna_SceneCollection_remove( + ID *id, SceneCollection *sc_parent, Main *bmain, ReportList *reports, PointerRNA *sc_ptr) +{ + Scene *scene = (Scene *)id; + SceneCollection *sc = sc_ptr->data; + + const int index = BLI_findindex(&sc_parent->scene_collections, sc); + if (index == -1) { + BKE_reportf(reports, RPT_ERROR, "Collection '%s' is not a sub-collection of '%s'", + sc->name, sc_parent->name); + return; + } + + if (!BKE_collection_remove(scene, sc)) { + BKE_reportf(reports, RPT_ERROR, "Collection '%s' could not be removed from collection '%s'", + sc->name, sc_parent->name); + return; + } + + RNA_POINTER_INVALIDATE(sc_ptr); + + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); +} + +static int rna_SceneCollection_objects_active_index_get(PointerRNA *ptr) +{ + SceneCollection *sc = (SceneCollection *)ptr->data; + return sc->active_object_index; +} + +static void rna_SceneCollection_objects_active_index_set(PointerRNA *ptr, int value) +{ + SceneCollection *sc = (SceneCollection *)ptr->data; + sc->active_object_index = value; +} + +static void rna_SceneCollection_objects_active_index_range( + PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) +{ + SceneCollection *sc = (SceneCollection *)ptr->data; + *min = 0; + *max = max_ii(0, BLI_listbase_count(&sc->objects) - 1); +} + +void rna_SceneCollection_object_link( + ID *id, SceneCollection *sc, Main *bmain, ReportList *reports, Object *ob) +{ + Scene *scene = (Scene *)id; + + if (BLI_findptr(&sc->objects, ob, offsetof(LinkData, data))) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' is already in collection '%s'", ob->id.name + 2, sc->name); + return; + } + + BKE_collection_object_add(scene, sc, ob); + + /* TODO(sergey): Only update relations for the current scene. */ + DEG_relations_tag_update(bmain); + + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(&scene->id, 0); + + DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + + WM_main_add_notifier(NC_SCENE | ND_LAYER | ND_OB_ACTIVE, scene); +} + +static void rna_SceneCollection_object_unlink( + ID *id, SceneCollection *sc, Main *bmain, ReportList *reports, Object *ob) +{ + Scene *scene = (Scene *)id; + + if (!BLI_findptr(&sc->objects, ob, offsetof(LinkData, data))) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' is not in collection '%s'", ob->id.name + 2, sc->name); + return; + } + + BKE_collection_object_remove(bmain, scene, sc, ob, false); + + /* needed otherwise the depgraph will contain freed objects which can crash, see [#20958] */ + DEG_relations_tag_update(bmain); + + WM_main_add_notifier(NC_SCENE | ND_LAYER | ND_OB_ACTIVE, scene); +} + +/****** layer collection engine settings *******/ + +#define RNA_LAYER_ENGINE_GET_SET(_TYPE_, _ENGINE_, _MODE_, _NAME_) \ +static _TYPE_ rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_get(PointerRNA *ptr) \ +{ \ + IDProperty *props = (IDProperty *)ptr->data; \ + return BKE_collection_engine_property_value_get_##_TYPE_(props, #_NAME_); \ +} \ + \ +static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr, _TYPE_ value) \ +{ \ + IDProperty *props = (IDProperty *)ptr->data; \ + BKE_collection_engine_property_value_set_##_TYPE_(props, #_NAME_, value); \ +} + +#define RNA_LAYER_ENGINE_GET_SET_ARRAY(_TYPE_, _ENGINE_, _MODE_, _NAME_, _LEN_) \ +static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_get(PointerRNA *ptr, _TYPE_ *values) \ +{ \ + IDProperty *props = (IDProperty *)ptr->data; \ + IDProperty *idprop = IDP_GetPropertyFromGroup(props, #_NAME_); \ + if (idprop != NULL) { \ + memcpy(values, IDP_Array(idprop), sizeof(_TYPE_) * idprop->len); \ + } \ +} \ + \ +static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr, const _TYPE_ *values) \ +{ \ + IDProperty *props = (IDProperty *)ptr->data; \ + BKE_collection_engine_property_value_set_##_TYPE_##_array(props, #_NAME_, values); \ +} + +#define RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(float, Clay, COLLECTION_MODE_NONE, _NAME_) + +#define RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT_ARRAY(_NAME_, _LEN_) \ + RNA_LAYER_ENGINE_GET_SET_ARRAY(float, Clay, COLLECTION_MODE_NONE, _NAME_, _LEN_) + +#define RNA_LAYER_ENGINE_CLAY_GET_SET_INT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(int, Clay, COLLECTION_MODE_NONE, _NAME_) + +#define RNA_LAYER_ENGINE_CLAY_GET_SET_BOOL(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(bool, Clay, COLLECTION_MODE_NONE, _NAME_) + +#define RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(float, Eevee, COLLECTION_MODE_NONE, _NAME_) + +#define RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(int, Eevee, COLLECTION_MODE_NONE, _NAME_) + +#define RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(bool, Eevee, COLLECTION_MODE_NONE, _NAME_) + +/* mode engines */ + +#define RNA_LAYER_MODE_OBJECT_GET_SET_FLOAT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(float, ObjectMode, COLLECTION_MODE_OBJECT, _NAME_) + +#define RNA_LAYER_MODE_OBJECT_GET_SET_INT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(int, ObjectMode, COLLECTION_MODE_OBJECT, _NAME_) + +#define RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(bool, ObjectMode, COLLECTION_MODE_OBJECT, _NAME_) + +#define RNA_LAYER_MODE_EDIT_GET_SET_FLOAT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(float, EditMode, COLLECTION_MODE_EDIT, _NAME_) + +#define RNA_LAYER_MODE_EDIT_GET_SET_INT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(int, EditMode, COLLECTION_MODE_EDIT, _NAME_) + +#define RNA_LAYER_MODE_EDIT_GET_SET_BOOL(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(bool, EditMode, COLLECTION_MODE_EDIT, _NAME_) + +#define RNA_LAYER_MODE_PAINT_WEIGHT_GET_SET_BOOL(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(bool, PaintWeightMode, COLLECTION_MODE_PAINT_WEIGHT, _NAME_) + +#define RNA_LAYER_MODE_PAINT_VERTEX_GET_SET_BOOL(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(bool, PaintVertexMode, COLLECTION_MODE_PAINT_VERTEX, _NAME_) + +/* clay engine */ +#ifdef WITH_CLAY_ENGINE +/* SceneLayer settings. */ +RNA_LAYER_ENGINE_CLAY_GET_SET_INT(ssao_samples) + +/* LayerCollection settings. */ +RNA_LAYER_ENGINE_CLAY_GET_SET_INT(matcap_icon) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_rotation) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_hue) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_saturation) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_value) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_factor_cavity) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_factor_edge) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_distance) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_attenuation) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(hair_brightness_randomness) +#endif /* WITH_CLAY_ENGINE */ + +/* eevee engine */ +/* SceneLayer settings. */ +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_enable) +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_use_bent_normals) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(gtao_factor) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(gtao_distance) +RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(gtao_samples) +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(dof_enable) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bokeh_max_size) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bokeh_threshold) +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(bloom_enable) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_threshold) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_knee) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_radius) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_intensity) +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(motion_blur_enable) +RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(motion_blur_samples) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(motion_blur_shutter) +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_enable) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_start) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_end) +RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(volumetric_samples) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_sample_distribution) +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_lights) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(volumetric_light_clamp) +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_shadows) +RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(volumetric_shadow_samples) +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(volumetric_colored_transmittance) +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(ssr_enable) +RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(ssr_halfres) +RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(ssr_ray_count) +RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(ssr_stride) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_thickness) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_border_fade) +RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_firefly_fac) + +/* object engine */ +RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(show_wire) +RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(show_backface_culling) + +/* mesh engine */ +RNA_LAYER_MODE_EDIT_GET_SET_BOOL(show_occlude_wire) +RNA_LAYER_MODE_EDIT_GET_SET_BOOL(show_weight) +RNA_LAYER_MODE_EDIT_GET_SET_BOOL(face_normals_show) +RNA_LAYER_MODE_EDIT_GET_SET_BOOL(vert_normals_show) +RNA_LAYER_MODE_EDIT_GET_SET_BOOL(loop_normals_show) +RNA_LAYER_MODE_EDIT_GET_SET_FLOAT(normals_length) +RNA_LAYER_MODE_EDIT_GET_SET_FLOAT(backwire_opacity) + +/* weight paint engine */ +RNA_LAYER_MODE_PAINT_WEIGHT_GET_SET_BOOL(use_shading) +RNA_LAYER_MODE_PAINT_WEIGHT_GET_SET_BOOL(use_wire) + +/* vertex paint engine */ +RNA_LAYER_MODE_PAINT_VERTEX_GET_SET_BOOL(use_shading) +RNA_LAYER_MODE_PAINT_VERTEX_GET_SET_BOOL(use_wire) + +#undef RNA_LAYER_ENGINE_GET_SET + +static void rna_SceneLayerEngineSettings_update(bContext *C, PointerRNA *UNUSED(ptr)) +{ + Scene *scene = CTX_data_scene(C); + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(&scene->id, 0); +} + +static void rna_LayerCollectionEngineSettings_update(bContext *C, PointerRNA *UNUSED(ptr)) +{ + Scene *scene = CTX_data_scene(C); + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(&scene->id, 0); +} + +static void rna_LayerCollectionEngineSettings_wire_update(bContext *C, PointerRNA *UNUSED(ptr)) +{ + Scene *scene = CTX_data_scene(C); + SceneLayer *sl = CTX_data_scene_layer(C); + Object *ob = OBACT_NEW; + + if (ob != NULL && ob->type == OB_MESH) { + BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_NOCHECK); + } + + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(&scene->id, 0); +} + +/***********************************/ + +static void engine_settings_use(IDProperty *root, IDProperty *props, PointerRNA *props_ptr, const char *identifier) +{ + PropertyRNA *prop = RNA_struct_find_property(props_ptr, identifier); + + switch (RNA_property_type(prop)) { + case PROP_FLOAT: + { + float value = BKE_collection_engine_property_value_get_float(props, identifier); + BKE_collection_engine_property_add_float(root, identifier, value); + break; + } + case PROP_ENUM: + { + int value = BKE_collection_engine_property_value_get_int(props, identifier); + BKE_collection_engine_property_add_int(root, identifier, value); + break; + } + case PROP_INT: + { + int value = BKE_collection_engine_property_value_get_int(props, identifier); + BKE_collection_engine_property_add_int(root, identifier, value); + break; + } + case PROP_BOOLEAN: + { + int value = BKE_collection_engine_property_value_get_int(props, identifier); + BKE_collection_engine_property_add_bool(root, identifier, value); + break; + } + case PROP_STRING: + case PROP_POINTER: + case PROP_COLLECTION: + default: + break; + } +} + +static void rna_SceneLayerSettings_name_get(PointerRNA *ptr, char *value) +{ + IDProperty *props = (IDProperty *)ptr->data; + strcpy(value, props->name); +} + +static int rna_SceneLayerSettings_name_length(PointerRNA *ptr) +{ + IDProperty *props = (IDProperty *)ptr->data; + return strnlen(props->name, sizeof(props->name)); +} + +static void rna_SceneLayerSettings_use(ID *id, IDProperty *props, const char *identifier) +{ + Scene *scene = (Scene *)id; + PointerRNA scene_props_ptr; + IDProperty *scene_props; + + scene_props = BKE_scene_layer_engine_scene_get(scene, COLLECTION_MODE_NONE, props->name); + RNA_pointer_create(id, &RNA_SceneLayerSettings, scene_props, &scene_props_ptr); + + engine_settings_use(props, scene_props, &scene_props_ptr, identifier); + + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(id, 0); +} + +static void rna_SceneLayerSettings_unuse(ID *id, IDProperty *props, const char *identifier) +{ + IDProperty *prop_to_remove = IDP_GetPropertyFromGroup(props, identifier); + IDP_FreeFromGroup(props, prop_to_remove); + + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(id, 0); +} + +static void rna_LayerCollectionSettings_name_get(PointerRNA *ptr, char *value) +{ + IDProperty *props = (IDProperty *)ptr->data; + strcpy(value, props->name); +} + +static int rna_LayerCollectionSettings_name_length(PointerRNA *ptr) +{ + IDProperty *props = (IDProperty *)ptr->data; + return strnlen(props->name, sizeof(props->name)); +} + +static void rna_LayerCollectionSettings_use(ID *id, IDProperty *props, const char *identifier) +{ + Scene *scene = (Scene *)id; + PointerRNA scene_props_ptr; + IDProperty *scene_props; + + scene_props = BKE_layer_collection_engine_scene_get(scene, COLLECTION_MODE_NONE, props->name); + RNA_pointer_create(id, &RNA_LayerCollectionSettings, scene_props, &scene_props_ptr); + engine_settings_use(props, scene_props, &scene_props_ptr, identifier); + + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(id, 0); +} + +static void rna_LayerCollectionSettings_unuse(ID *id, IDProperty *props, const char *identifier) +{ + IDProperty *prop_to_remove = IDP_GetPropertyFromGroup(props, identifier); + IDP_FreeFromGroup(props, prop_to_remove); + + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(id, 0); +} + +static void rna_LayerCollection_name_get(PointerRNA *ptr, char *value) +{ + SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection; + strcpy(value, sc->name); +} + +static int rna_LayerCollection_name_length(PointerRNA *ptr) +{ + SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection; + return strnlen(sc->name, sizeof(sc->name)); +} + +static void rna_LayerCollection_name_set(PointerRNA *ptr, const char *value) +{ + Scene *scene = (Scene *)ptr->id.data; + SceneCollection *sc = ((LayerCollection *)ptr->data)->scene_collection; + BKE_collection_rename(scene, sc, value); +} + +static PointerRNA rna_LayerCollection_objects_get(CollectionPropertyIterator *iter) +{ + ListBaseIterator *internal = &iter->internal.listbase; + Base *base = ((LinkData *)internal->link)->data; + return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, base->object); +} + +static int rna_LayerCollection_move_above(ID *id, LayerCollection *lc_src, Main *bmain, LayerCollection *lc_dst) +{ + Scene *scene = (Scene *)id; + + if (!BKE_layer_collection_move_above(scene, lc_dst, lc_src)) { + return 0; + } + + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + + return 1; +} + +static int rna_LayerCollection_move_below(ID *id, LayerCollection *lc_src, Main *bmain, LayerCollection *lc_dst) +{ + Scene *scene = (Scene *)id; + + if (!BKE_layer_collection_move_below(scene, lc_dst, lc_src)) { + return 0; + } + + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + + return 1; +} + +static int rna_LayerCollection_move_into(ID *id, LayerCollection *lc_src, Main *bmain, LayerCollection *lc_dst) +{ + Scene *scene = (Scene *)id; + + if (!BKE_layer_collection_move_into(scene, lc_dst, lc_src)) { + return 0; + } + + DEG_relations_tag_update(bmain); + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + + return 1; +} + +static void rna_LayerCollection_flag_update(bContext *C, PointerRNA *UNUSED(ptr)) +{ + Scene *scene = CTX_data_scene(C); + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(&scene->id, 0); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); +} + +static int rna_LayerCollections_active_collection_index_get(PointerRNA *ptr) +{ + SceneLayer *sl = (SceneLayer *)ptr->data; + return sl->active_collection; +} + +static void rna_LayerCollections_active_collection_index_set(PointerRNA *ptr, int value) +{ + SceneLayer *sl = (SceneLayer *)ptr->data; + int num_collections = BKE_layer_collection_count(sl); + sl->active_collection = min_ff(value, num_collections - 1); +} + +static void rna_LayerCollections_active_collection_index_range( + PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) +{ + SceneLayer *sl = (SceneLayer *)ptr->data; + *min = 0; + *max = max_ii(0, BKE_layer_collection_count(sl) - 1); +} + +static PointerRNA rna_LayerCollections_active_collection_get(PointerRNA *ptr) +{ + SceneLayer *sl = (SceneLayer *)ptr->data; + LayerCollection *lc = BKE_layer_collection_get_active(sl); + return rna_pointer_inherit_refine(ptr, &RNA_LayerCollection, lc); +} + +static void rna_LayerCollections_active_collection_set(PointerRNA *ptr, PointerRNA value) +{ + SceneLayer *sl = (SceneLayer *)ptr->data; + LayerCollection *lc = (LayerCollection *)value.data; + const int index = BKE_layer_collection_findindex(sl, lc); + if (index != -1) sl->active_collection = index; +} + +LayerCollection * rna_SceneLayer_collection_link( + ID *id, SceneLayer *sl, Main *bmain, SceneCollection *sc) +{ + Scene *scene = (Scene *)id; + LayerCollection *lc = BKE_collection_link(sl, sc); + + DEG_relations_tag_update(bmain); + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(id, 0); + WM_main_add_notifier(NC_SCENE | ND_LAYER, scene); + + return lc; +} + +static void rna_SceneLayer_collection_unlink( + ID *id, SceneLayer *sl, Main *bmain, ReportList *reports, LayerCollection *lc) +{ + Scene *scene = (Scene *)id; + + if (BLI_findindex(&sl->layer_collections, lc) == -1) { + BKE_reportf(reports, RPT_ERROR, "Layer collection '%s' is not in '%s'", lc->scene_collection->name, sl->name); + return; + } + + BKE_collection_unlink(sl, lc); + + DEG_relations_tag_update(bmain); + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(id, 0); + WM_main_add_notifier(NC_SCENE | ND_LAYER | ND_OB_ACTIVE, scene); +} + +static PointerRNA rna_LayerObjects_active_object_get(PointerRNA *ptr) +{ + SceneLayer *sl = (SceneLayer *)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_Object, sl->basact ? sl->basact->object : NULL); +} + +static void rna_LayerObjects_active_object_set(PointerRNA *ptr, PointerRNA value) +{ + SceneLayer *sl = (SceneLayer *)ptr->data; + if (value.data) + sl->basact = BKE_scene_layer_base_find(sl, (Object *)value.data); + else + sl->basact = NULL; +} + +static void rna_SceneLayer_name_set(PointerRNA *ptr, const char *value) +{ + Scene *scene = (Scene *)ptr->id.data; + SceneLayer *sl = (SceneLayer *)ptr->data; + char oldname[sizeof(sl->name)]; + + BLI_strncpy(oldname, sl->name, sizeof(sl->name)); + + BLI_strncpy_utf8(sl->name, value, sizeof(sl->name)); + BLI_uniquename(&scene->render_layers, sl, DATA_("SceneLayer"), '.', offsetof(SceneLayer, name), sizeof(sl->name)); + + if (scene->nodetree) { + bNode *node; + int index = BLI_findindex(&scene->render_layers, sl); + + 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, sl->name, NODE_MAXSTR); + } + } + } +} + +static PointerRNA rna_SceneLayer_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 int rna_SceneLayer_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 void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + SceneLayer *sl = (SceneLayer *)ptr->data; + rna_iterator_listbase_begin(iter, &sl->object_bases, rna_SceneLayer_objects_selected_skip); +} + +static void rna_SceneLayer_engine_set(PointerRNA *ptr, int value) +{ + SceneLayer *sl = (SceneLayer *)ptr->data; + RenderEngineType *type = BLI_findlink(&R_engines, value); + + if (type) + BKE_scene_layer_engine_set(sl, type->idname); +} + +static EnumPropertyItem *rna_SceneLayer_engine_itemf( + bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +{ + RenderEngineType *type; + EnumPropertyItem *item = NULL; + EnumPropertyItem tmp = {0, "", 0, "", ""}; + int a = 0, totitem = 0; + + for (type = R_engines.first; type; type = type->next, a++) { + tmp.value = a; + tmp.identifier = type->idname; + tmp.name = type->name; + RNA_enum_item_add(&item, &totitem, &tmp); + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + +static int rna_SceneLayer_engine_get(PointerRNA *ptr) +{ + SceneLayer *sl = (SceneLayer *)ptr->data; + RenderEngineType *type; + int a = 0; + + for (type = R_engines.first; type; type = type->next, a++) + if (STREQ(type->idname, sl->engine)) + return a; + + return 0; +} + +static void rna_SceneLayer_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr)) +{ + ED_render_engine_changed(bmain); +} + +static int rna_SceneLayer_multiple_engines_get(PointerRNA *UNUSED(ptr)) +{ + return (BLI_listbase_count(&R_engines) > 1); +} + +static void rna_SceneLayer_update_tagged(SceneLayer *UNUSED(sl), bContext *C) +{ + Depsgraph *graph = CTX_data_depsgraph(C); + DEG_OBJECT_ITER(graph, ob, DEG_OBJECT_ITER_FLAG_ALL) + { + /* Don't do anything, we just need to run the iterator to flush + * the base info to the objects. */ + UNUSED_VARS(ob); + } + DEG_OBJECT_ITER_END +} + +static int rna_SceneLayer_active_layer_index_get(PointerRNA *ptr) +{ + Scene *scene = (Scene *)ptr->data; + return scene->active_layer; +} + +static void rna_SceneLayer_active_layer_index_set(PointerRNA *ptr, int value) +{ + Scene *scene = (Scene *)ptr->data; + int num_layers = BLI_listbase_count(&scene->render_layers); + scene->active_layer = min_ff(value, num_layers - 1); +} + +static void rna_SceneLayer_active_layer_index_range( + PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) +{ + Scene *scene = (Scene *)ptr->data; + + *min = 0; + *max = max_ii(0, BLI_listbase_count(&scene->render_layers) - 1); +} + +static PointerRNA rna_SceneLayer_active_layer_get(PointerRNA *ptr) +{ + Scene *scene = (Scene *)ptr->data; + SceneLayer *sl = BLI_findlink(&scene->render_layers, scene->active_layer); + + return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, sl); +} + +static void rna_SceneLayer_active_layer_set(PointerRNA *ptr, PointerRNA value) +{ + Scene *scene = (Scene *)ptr->data; + SceneLayer *sl = (SceneLayer *)value.data; + const int index = BLI_findindex(&scene->render_layers, sl); + if (index != -1) scene->active_layer = index; +} + +static SceneLayer *rna_SceneLayer_new( + ID *id, Scene *UNUSED(sce), Main *bmain, const char *name) +{ + Scene *scene = (Scene *)id; + SceneLayer *sl = BKE_scene_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 sl; +} + +static void rna_SceneLayer_remove( + ID *id, Scene *UNUSED(sce), Main *bmain, ReportList *reports, PointerRNA *sl_ptr) +{ + Scene *scene = (Scene *)id; + SceneLayer *sl = sl_ptr->data; + + if (ED_scene_render_layer_delete(bmain, scene, sl, reports)) { + RNA_POINTER_INVALIDATE(sl_ptr); + } } +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); +} #else /* Grease Pencil Interpolation tool settings */ @@ -2496,24 +3405,6 @@ static void rna_def_gpencil_brushes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_ui_text(prop, "Active Brush Index", "Index of active brush"); } -static void rna_def_transform_orientation(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "TransformOrientation", NULL); - - 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_3x3); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_ui_text(prop, "Name", "Name of the custom transform orientation"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); -} - static void rna_def_tool_settings(BlenderRNA *brna) { StructRNA *srna; @@ -2605,6 +3496,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 " @@ -2612,6 +3504,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, " @@ -2619,12 +3512,14 @@ 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"); @@ -2935,6 +3830,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); @@ -3070,6 +3966,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"); @@ -3077,6 +3974,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"); @@ -3084,6 +3982,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); @@ -3092,6 +3991,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); @@ -3099,12 +3999,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", ""); @@ -3246,6 +4148,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"); @@ -3256,6 +4159,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); @@ -3264,12 +4168,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"); @@ -3280,6 +4186,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); @@ -3288,12 +4195,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 */ @@ -3303,6 +4212,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); @@ -3311,6 +4221,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 */ @@ -3320,6 +4231,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); @@ -3328,6 +4240,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 Max", "Maximum angle to display"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_EditMesh_update"); } @@ -4840,11 +5753,6 @@ static void rna_def_scene_game_data(BlenderRNA *brna) "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", @@ -5004,11 +5912,23 @@ 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, NULL); + prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_ui_text(prop, "Rotation", "Rotation of blades in apperture"); + 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, "ratio", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Ratio", "Distortion to simulate anamorphic lens bokeh"); + 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); + 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, NULL); + /* NOTE: high quality is always supported */ 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); @@ -5089,6 +6009,1086 @@ static void rna_def_gpu_fx(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUFXSettings_fx_update"); } +/* Render Layers and Collections */ + +static void rna_def_scene_collections(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "SceneCollections"); + srna = RNA_def_struct(brna, "SceneCollections", NULL); + RNA_def_struct_sdna(srna, "SceneCollection"); + RNA_def_struct_ui_text(srna, "Scene Collection", "Collection of scene collections"); + + func = RNA_def_function(srna, "new", "rna_SceneCollection_new"); + RNA_def_function_ui_description(func, "Add a collection to scene"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_string(func, "name", "SceneCollection", 0, "", "New name for the collection (not unique)"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "result", "SceneCollection", "", "Newly created collection"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_SceneCollection_remove"); + RNA_def_function_ui_description(func, "Remove a collection layer"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "layer", "SceneCollection", "", "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); +} + +static void rna_def_collection_objects(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "CollectionObjects"); + srna = RNA_def_struct(brna, "CollectionObjects", NULL); + RNA_def_struct_sdna(srna, "SceneCollection"); + RNA_def_struct_ui_text(srna, "Collection Objects", "Objects of a collection"); + + prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_SceneCollection_objects_active_index_get", + "rna_SceneCollection_objects_active_index_set", + "rna_SceneCollection_objects_active_index_range"); + RNA_def_property_ui_text(prop, "Active Object Index", "Active index in collection objects array"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL); + + func = RNA_def_function(srna, "link", "rna_SceneCollection_object_link"); + RNA_def_function_ui_description(func, "Link an object to collection"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "object", "Object", "", "Object to add to collection"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + + func = RNA_def_function(srna, "unlink", "rna_SceneCollection_object_unlink"); + RNA_def_function_ui_description(func, "Unlink object from collection"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove from collection"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); +} + +static void rna_def_scene_collection(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + srna = RNA_def_struct(brna, "SceneCollection", NULL); + RNA_def_struct_ui_text(srna, "Scene Collection", "Collection"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneCollection_name_set"); + RNA_def_property_ui_text(prop, "Name", "Collection name"); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL); + + prop = RNA_def_property(srna, "filter", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneCollection_filter_set"); + RNA_def_property_ui_text(prop, "Filter", "Filter to dynamically include objects based on their names (e.g., CHAR_*)"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL); + + prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "scene_collections", NULL); + RNA_def_property_struct_type(prop, "SceneCollection"); + RNA_def_property_ui_text(prop, "SceneCollections", ""); + rna_def_scene_collections(brna, prop); + + prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "objects", NULL); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_SceneCollection_objects_get", NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Objects", "All the objects directly added to this collection (not including sub-collection objects)"); + rna_def_collection_objects(brna, prop); + + prop = RNA_def_property(srna, "filters_objects", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "filter_objects", NULL); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_SceneCollection_objects_get", NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Filter Objects", "All the objects dynamically added to this collection via the filter"); + + /* Functions */ + func = RNA_def_function(srna, "move_above", "rna_SceneCollection_move_above"); + RNA_def_function_ui_description(func, "Move collection after another"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Reference collection above which the collection will move"); + parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "move_below", "rna_SceneCollection_move_below"); + RNA_def_function_ui_description(func, "Move collection before another"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Reference collection below which the collection will move"); + parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "move_into", "rna_SceneCollection_move_into"); + RNA_def_function_ui_description(func, "Move collection into another"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "sc_dst", "SceneCollection", "Collection", "Collection to insert into"); + parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded"); + RNA_def_function_return(func, parm); +} + +static void rna_def_layer_collection_override(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LayerCollectionOverride", NULL); + RNA_def_struct_sdna(srna, "CollectionOverride"); + RNA_def_struct_ui_text(srna, "Collection Override", "Collection Override"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Name", "Collection name"); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL); +} + + +#ifdef WITH_CLAY_ENGINE +static void rna_def_scene_layer_engine_settings_clay(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "SceneLayerEngineSettingsClay", "SceneLayerSettings"); + RNA_def_struct_ui_text(srna, "Clay Scene Layer Settings", "Clay Engine settings"); + + RNA_define_verify_sdna(0); /* not in sdna */ + + /* see RNA_LAYER_ENGINE_GET_SET macro */ + prop = RNA_def_property(srna, "ssao_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_samples_get", + "rna_LayerEngineSettings_Clay_ssao_samples_set", NULL); + RNA_def_property_ui_text(prop, "Samples", "Number of samples"); + RNA_def_property_range(prop, 1, 500); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + RNA_define_verify_sdna(1); /* not in sdna */ +} +#endif /* WITH_CLAY_ENGINE */ + +static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "SceneLayerEngineSettingsEevee", "SceneLayerSettings"); + RNA_def_struct_ui_text(srna, "Eevee Scene Layer Settings", "Eevee Engine settings"); + + RNA_define_verify_sdna(0); /* not in sdna */ + + /* see RNA_LAYER_ENGINE_GET_SET macro */ + + /* Screen Space Reflection */ + prop = RNA_def_property(srna, "ssr_enable", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_enable_get", + "rna_LayerEngineSettings_Eevee_ssr_enable_set"); + RNA_def_property_ui_text(prop, "Screen Space Reflections", "Enable screen space reflection"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "ssr_halfres", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_halfres_get", + "rna_LayerEngineSettings_Eevee_ssr_halfres_set"); + RNA_def_property_ui_text(prop, "Half Res Trace", "Raytrace at a lower resolution"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "ssr_stride", PROP_INT, PROP_PIXEL); + RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_stride_get", + "rna_LayerEngineSettings_Eevee_ssr_stride_set", NULL); + RNA_def_property_ui_text(prop, "Stride", "Step size between two raymarching samples"); + RNA_def_property_range(prop, 1, 32); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "ssr_ray_count", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_ray_count_get", + "rna_LayerEngineSettings_Eevee_ssr_ray_count_set", NULL); + RNA_def_property_ui_text(prop, "Samples", "Number of rays to trace per pixels"); + RNA_def_property_range(prop, 1, 4); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "ssr_thickness", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_thickness_get", + "rna_LayerEngineSettings_Eevee_ssr_thickness_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "ssr_border_fade", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_border_fade_get", + "rna_LayerEngineSettings_Eevee_ssr_border_fade_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "ssr_firefly_fac", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_ssr_firefly_fac_get", + "rna_LayerEngineSettings_Eevee_ssr_firefly_fac_set", NULL); + RNA_def_property_ui_text(prop, "Clamp", "Smoothly clamp pixel intensity to remove noise"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + /* Volumetrics */ + prop = RNA_def_property(srna, "volumetric_enable", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_enable_get", + "rna_LayerEngineSettings_Eevee_volumetric_enable_set"); + RNA_def_property_ui_text(prop, "Volumetrics", "Enable scattering and absorbance of volumetric material"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "volumetric_start", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_start_get", + "rna_LayerEngineSettings_Eevee_volumetric_start_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "volumetric_end", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_end_get", + "rna_LayerEngineSettings_Eevee_volumetric_end_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "volumetric_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_samples_get", + "rna_LayerEngineSettings_Eevee_volumetric_samples_set", NULL); + RNA_def_property_ui_text(prop, "Samples", "Number of samples to compute volumetric effects"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_range(prop, 1, 256); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "volumetric_sample_distribution", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_sample_distribution_get", + "rna_LayerEngineSettings_Eevee_volumetric_sample_distribution_set", NULL); + RNA_def_property_ui_text(prop, "Exponential Sampling", "Distribute more samples closer to the camera"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "volumetric_lights", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_lights_get", + "rna_LayerEngineSettings_Eevee_volumetric_lights_set"); + RNA_def_property_ui_text(prop, "Volumetric Lighting", "Enable scene lamps interactions with volumetrics"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "volumetric_light_clamp", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_light_clamp_get", + "rna_LayerEngineSettings_Eevee_volumetric_light_clamp_set", NULL); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_text(prop, "Clamp", "Maximum light contribution, reducing noise"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "volumetric_shadows", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_shadows_get", + "rna_LayerEngineSettings_Eevee_volumetric_shadows_set"); + RNA_def_property_ui_text(prop, "Volumetric Shadows", "Generate shadows from volumetric material (Very expensive)"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "volumetric_shadow_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_shadow_samples_get", + "rna_LayerEngineSettings_Eevee_volumetric_shadow_samples_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "volumetric_colored_transmittance", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_volumetric_colored_transmittance_get", + "rna_LayerEngineSettings_Eevee_volumetric_colored_transmittance_set"); + RNA_def_property_ui_text(prop, "Colored Transmittance", "Enable wavelength dependent volumetric transmittance"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + /* Ambient Occlusion */ + prop = RNA_def_property(srna, "gtao_enable", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_enable_get", + "rna_LayerEngineSettings_Eevee_gtao_enable_set"); + RNA_def_property_ui_text(prop, "Ambient Occlusion", "Enable ambient occlusion to simulate medium scale indirect shadowing"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "gtao_use_bent_normals", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_use_bent_normals_get", + "rna_LayerEngineSettings_Eevee_gtao_use_bent_normals_set"); + RNA_def_property_ui_text(prop, "Bent Normals", "Compute main non occluded direction to sample the environment"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "gtao_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_factor_get", "rna_LayerEngineSettings_Eevee_gtao_factor_set", NULL); + RNA_def_property_ui_text(prop, "Factor", "Factor for ambient occlusion blending"); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 2); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "gtao_distance", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_distance_get", "rna_LayerEngineSettings_Eevee_gtao_distance_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "gtao_samples", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_gtao_samples_get", + "rna_LayerEngineSettings_Eevee_gtao_samples_set", NULL); + RNA_def_property_ui_text(prop, "Samples", "Number of samples to take to compute occlusion"); + RNA_def_property_range(prop, 2, 32); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + /* Depth of Field */ + prop = RNA_def_property(srna, "dof_enable", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_dof_enable_get", + "rna_LayerEngineSettings_Eevee_dof_enable_set"); + RNA_def_property_ui_text(prop, "Depth of Field", "Enable depth of field using the values from the active camera"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "bokeh_max_size", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bokeh_max_size_get", + "rna_LayerEngineSettings_Eevee_bokeh_max_size_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "bokeh_threshold", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bokeh_threshold_get", + "rna_LayerEngineSettings_Eevee_bokeh_threshold_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + /* Bloom */ + prop = RNA_def_property(srna, "bloom_enable", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_enable_get", + "rna_LayerEngineSettings_Eevee_bloom_enable_set"); + RNA_def_property_ui_text(prop, "Bloom", "High brighness pixels generate a glowing effect"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "bloom_threshold", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_threshold_get", + "rna_LayerEngineSettings_Eevee_bloom_threshold_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "bloom_knee", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_knee_get", + "rna_LayerEngineSettings_Eevee_bloom_knee_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "bloom_radius", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_radius_get", + "rna_LayerEngineSettings_Eevee_bloom_radius_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "bloom_intensity", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_intensity_get", + "rna_LayerEngineSettings_Eevee_bloom_intensity_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + /* Motion blur */ + prop = RNA_def_property(srna, "motion_blur_enable", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_motion_blur_enable_get", + "rna_LayerEngineSettings_Eevee_motion_blur_enable_set"); + RNA_def_property_ui_text(prop, "Motion Blur", "Enable motion blur effect (only in camera view)"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_motion_blur_samples_get", + "rna_LayerEngineSettings_Eevee_motion_blur_samples_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_motion_blur_shutter_get", + "rna_LayerEngineSettings_Eevee_motion_blur_shutter_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update"); + + RNA_define_verify_sdna(1); /* not in sdna */ +} + +#ifdef WITH_CLAY_ENGINE +static void rna_def_layer_collection_engine_settings_clay(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem clay_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, "LayerCollectionEngineSettingsClay", "LayerCollectionSettings"); + RNA_def_struct_ui_text(srna, "Collections Clay Engine Settings", "Engine specific settings for this collection"); + + RNA_define_verify_sdna(0); /* not in sdna */ + + /* see RNA_LAYER_ENGINE_GET_SET macro */ + prop = RNA_def_property(srna, "matcap_icon", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_icon_get", "rna_LayerEngineSettings_Clay_matcap_icon_set", NULL); + RNA_def_property_enum_items(prop, clay_matcap_items); + RNA_def_property_ui_text(prop, "Matcap", "Image to use for Material Capture by this material"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "matcap_rotation", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_rotation_get", "rna_LayerEngineSettings_Clay_matcap_rotation_set", NULL); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Matcap Rotation", "Orientation of the matcap on the model"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "matcap_hue", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_hue_get", "rna_LayerEngineSettings_Clay_matcap_hue_set", NULL); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Matcap Hue Shift", "Hue correction of the matcap"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "matcap_saturation", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_saturation_get", "rna_LayerEngineSettings_Clay_matcap_saturation_set", NULL); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Matcap Saturation", "Saturation correction of the matcap"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "matcap_value", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_value_get", "rna_LayerEngineSettings_Clay_matcap_value_set", NULL); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Matcap Value", "Value correction of the matcap"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "ssao_factor_cavity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_factor_cavity_get", "rna_LayerEngineSettings_Clay_ssao_factor_cavity_set", NULL); + RNA_def_property_ui_text(prop, "Cavity Strength", "Strength of the Cavity effect"); + RNA_def_property_range(prop, 0.0f, 250.0f); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "ssao_factor_edge", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_factor_edge_get", "rna_LayerEngineSettings_Clay_ssao_factor_edge_set", NULL); + RNA_def_property_ui_text(prop, "Edge Strength", "Strength of the Edge effect"); + RNA_def_property_range(prop, 0.0f, 250.0f); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "ssao_distance", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_distance_get", "rna_LayerEngineSettings_Clay_ssao_distance_set", NULL); + 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); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "ssao_attenuation", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_attenuation_get", "rna_LayerEngineSettings_Clay_ssao_attenuation_set", NULL); + 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); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "hair_brightness_randomness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_hair_brightness_randomness_get", "rna_LayerEngineSettings_Clay_hair_brightness_randomness_set", NULL); + RNA_def_property_ui_text(prop, "Hair Brightness Randomness", "Brightness randomness for hair"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + RNA_define_verify_sdna(1); /* not in sdna */ +} +#endif /* WITH_CLAY_ENGINE */ + +static void rna_def_layer_collection_mode_settings_object(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LayerCollectionModeSettingsObject", "LayerCollectionSettings"); + RNA_def_struct_ui_text(srna, "Collections Object Mode Settings", "Object Mode specific settings for this collection"); + RNA_define_verify_sdna(0); /* not in sdna */ + + /* see RNA_LAYER_ENGINE_GET_SET macro */ + + prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Wire", "Add the object's wireframe over solid drawing"); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_ObjectMode_show_wire_get", "rna_LayerEngineSettings_ObjectMode_show_wire_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "show_backface_culling", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Backface Culling", ""); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_ObjectMode_show_backface_culling_get", "rna_LayerEngineSettings_ObjectMode_show_backface_culling_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + RNA_define_verify_sdna(1); /* not in sdna */ +} + +static void rna_def_layer_collection_mode_settings_edit(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LayerCollectionModeSettingsEdit", "LayerCollectionSettings"); + RNA_def_struct_ui_text(srna, "Collections Edit Mode Settings", "Edit Mode specific settings to be overridden per collection"); + RNA_define_verify_sdna(0); /* not in sdna */ + + /* see RNA_LAYER_ENGINE_GET_SET macro */ + + prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Hidden Wire", "Use hidden wireframe display"); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_show_occlude_wire_get", "rna_LayerEngineSettings_EditMode_show_occlude_wire_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "show_weight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Show Weights", "Draw weights in editmode"); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_show_weight_get", "rna_LayerEngineSettings_EditMode_show_weight_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "face_normals_show", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Draw Normals", "Display face normals as lines"); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_face_normals_show_get", "rna_LayerEngineSettings_EditMode_face_normals_show_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "vert_normals_show", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Draw Vertex Normals", "Display vertex normals as lines"); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_vert_normals_show_get", "rna_LayerEngineSettings_EditMode_vert_normals_show_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "loop_normals_show", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Draw Split Normals", "Display vertex-per-face normals as lines"); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_EditMode_loop_normals_show_get", "rna_LayerEngineSettings_EditMode_loop_normals_show_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "normals_length", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_ui_text(prop, "Normal Size", "Display size for normals in the 3D view"); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_EditMode_normals_length_get", "rna_LayerEngineSettings_EditMode_normals_length_set", NULL); + 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_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "backwire_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_ui_text(prop, "Backwire Opacity", "Opacity when rendering transparent wires"); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_EditMode_backwire_opacity_get", "rna_LayerEngineSettings_EditMode_backwire_opacity_set", NULL); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + RNA_define_verify_sdna(1); /* not in sdna */ +} + +static void rna_def_layer_collection_mode_settings_paint_weight(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LayerCollectionModeSettingsPaintWeight", "LayerCollectionSettings"); + RNA_def_struct_ui_text(srna, "Collections Weight Paint Mode Settings", "Weight Paint Mode specific settings to be overridden per collection"); + RNA_define_verify_sdna(0); /* not in sdna */ + + /* see RNA_LAYER_ENGINE_GET_SET macro */ + + prop = RNA_def_property(srna, "use_shading", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Use Shading", "Whether to use shaded or shadeless drawing"); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintWeightMode_use_shading_get", "rna_LayerEngineSettings_PaintWeightMode_use_shading_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "use_wire", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Show Wire", "Whether to overlay wireframe onto the mesh"); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintWeightMode_use_wire_get", "rna_LayerEngineSettings_PaintWeightMode_use_wire_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_wire_update"); + + RNA_define_verify_sdna(1); /* not in sdna */ +} + +static void rna_def_layer_collection_mode_settings_paint_vertex(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LayerCollectionModeSettingsPaintVertex", "LayerCollectionSettings"); + RNA_def_struct_ui_text(srna, "Collections Vertex Paint Mode Settings", "Vertex Paint Mode specific settings to be overridden per collection"); + RNA_define_verify_sdna(0); /* not in sdna */ + + /* see RNA_LAYER_ENGINE_GET_SET macro */ + + prop = RNA_def_property(srna, "use_shading", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Use Shading", "Whether to use shaded or shadeless drawing"); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintVertexMode_use_shading_get", "rna_LayerEngineSettings_PaintVertexMode_use_shading_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_update"); + + prop = RNA_def_property(srna, "use_wire", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Show Wire", "Whether to overlay wireframe onto the mesh"); + RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_PaintVertexMode_use_wire_get", "rna_LayerEngineSettings_PaintVertexMode_use_wire_set"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollectionEngineSettings_wire_update"); + + RNA_define_verify_sdna(1); /* not in sdna */ +} + +static void rna_def_scene_layer_settings(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + FunctionRNA *func; + PropertyRNA *parm; + + srna = RNA_def_struct(brna, "SceneLayerSettings", NULL); + RNA_def_struct_sdna(srna, "IDProperty"); + RNA_def_struct_ui_text(srna, "Scene Layer Settings", + "Engine specific settings that can be overriden by SceneLayer"); + RNA_def_struct_refine_func(srna, "rna_SceneLayerSettings_refine"); + + RNA_define_verify_sdna(0); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_SceneLayerSettings_name_get", "rna_SceneLayerSettings_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", "Engine Name"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_struct_name_property(srna, prop); + + func = RNA_def_function(srna, "use", "rna_SceneLayerSettings_use"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Initialize this property to use"); + parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to set"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + func = RNA_def_function(srna, "unuse", "rna_SceneLayerSettings_unuse"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Remove the property"); + parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to unset"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + +#ifdef WITH_CLAY_ENGINE + rna_def_scene_layer_engine_settings_clay(brna); +#endif + rna_def_scene_layer_engine_settings_eevee(brna); + +#if 0 + rna_def_scene_layer_mode_settings_object(brna); + rna_def_scene_layer_mode_settings_edit(brna); + rna_def_scene_layer_mode_settings_paint_weight(brna); + rna_def_scene_layer_mode_settings_paint_vertex(brna); +#endif + + RNA_define_verify_sdna(1); +} + +static void rna_def_layer_collection_settings(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + FunctionRNA *func; + PropertyRNA *parm; + + srna = RNA_def_struct(brna, "LayerCollectionSettings", NULL); + RNA_def_struct_sdna(srna, "IDProperty"); + RNA_def_struct_ui_text(srna, "Layer Collection Settings", + "Engine specific settings that can be overriden by LayerCollection"); + RNA_def_struct_refine_func(srna, "rna_LayerCollectionSettings_refine"); + + RNA_define_verify_sdna(0); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_LayerCollectionSettings_name_get", "rna_LayerCollectionSettings_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", "Engine Name"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_struct_name_property(srna, prop); + + func = RNA_def_function(srna, "use", "rna_LayerCollectionSettings_use"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Initialize this property to use"); + parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to set"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + func = RNA_def_function(srna, "unuse", "rna_LayerCollectionSettings_unuse"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Remove the property"); + parm = RNA_def_string(func, "identifier", NULL, 0, "Property Name", "Name of the property to unset"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + +#ifdef WITH_CLAY_ENGINE + rna_def_layer_collection_engine_settings_clay(brna); +#endif + + rna_def_layer_collection_mode_settings_object(brna); + rna_def_layer_collection_mode_settings_edit(brna); + rna_def_layer_collection_mode_settings_paint_weight(brna); + rna_def_layer_collection_mode_settings_paint_vertex(brna); + + RNA_define_verify_sdna(1); +} + +static void rna_def_layer_collection(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + srna = RNA_def_struct(brna, "LayerCollection", NULL); + RNA_def_struct_ui_text(srna, "Layer Collection", "Layer collection"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_LayerCollection_name_get", "rna_LayerCollection_name_length", "rna_LayerCollection_name_set"); + RNA_def_property_ui_text(prop, "Name", "Collection name"); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL); + + 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, "scene_collection"); + RNA_def_property_struct_type(prop, "SceneCollection"); + RNA_def_property_ui_text(prop, "Collection", "Collection this layer collection is wrapping"); + + prop = RNA_def_property(srna, "collections", 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, "Layer Collections", ""); + + 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_LayerCollection_objects_get", NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Objects", "All the objects directly or indirectly added to this collection (not including sub-collection objects)"); + + prop = RNA_def_property(srna, "overrides", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "overrides", NULL); + RNA_def_property_struct_type(prop, "LayerCollectionOverride"); + RNA_def_property_ui_text(prop, "Collection Overrides", ""); + + /* Override settings */ + prop = RNA_def_property(srna, "engine_overrides", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "properties->data.group", NULL); + RNA_def_property_struct_type(prop, "LayerCollectionSettings"); + RNA_def_property_ui_text(prop, "Collection Settings", "Override of engine specific render settings"); + + /* Functions */ + func = RNA_def_function(srna, "move_above", "rna_LayerCollection_move_above"); + RNA_def_function_ui_description(func, "Move collection after another"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Reference collection above which the collection will move"); + parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "move_below", "rna_LayerCollection_move_below"); + RNA_def_function_ui_description(func, "Move collection before another"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Reference collection below which the collection will move"); + parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "move_into", "rna_LayerCollection_move_into"); + RNA_def_function_ui_description(func, "Move collection into another"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "lc_dst", "LayerCollection", "Collection", "Collection to insert into"); + parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded"); + RNA_def_function_return(func, parm); + + /* Flags */ + prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_VISIBLE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); + RNA_def_property_ui_text(prop, "Hide", "Restrict visiblity"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update"); + + prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_SELECTABLE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1); + RNA_def_property_ui_text(prop, "Hide Selectable", "Restrict selection"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update"); + + /* TODO_LAYER_OVERRIDE */ +} + +static void rna_def_layer_collections(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *prop; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "LayerCollections"); + srna = RNA_def_struct(brna, "LayerCollections", NULL); + RNA_def_struct_sdna(srna, "SceneLayer"); + RNA_def_struct_ui_text(srna, "Layer Collections", "Collections of render layer"); + + prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "active_collection"); + RNA_def_property_int_funcs(prop, "rna_LayerCollections_active_collection_index_get", + "rna_LayerCollections_active_collection_index_set", + "rna_LayerCollections_active_collection_index_range"); + RNA_def_property_ui_text(prop, "Active Collection Index", "Active index in layer collection array"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL); + + prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "LayerCollection"); + RNA_def_property_pointer_funcs(prop, "rna_LayerCollections_active_collection_get", + "rna_LayerCollections_active_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"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL); + + func = RNA_def_function(srna, "link", "rna_SceneLayer_collection_link"); + RNA_def_function_ui_description(func, "Link a collection to render layer"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_pointer(func, "scene_collection", "SceneCollection", "", "Collection to add to render layer"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + parm = RNA_def_pointer(func, "result", "LayerCollection", "", "Newly created layer collection"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "unlink", "rna_SceneLayer_collection_unlink"); + RNA_def_function_ui_description(func, "Unlink a collection from render layer"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "layer_collection", "LayerCollection", "", "Layer collection to remove from render layer"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); +} + +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, "SceneLayer"); + 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_base_object_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_SceneLayer_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_scene_layer(BlenderRNA *brna) +{ + FunctionRNA *func; + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem engine_items[] = { + {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "SceneLayer", NULL); + RNA_def_struct_ui_text(srna, "Render Layer", "Render layer"); + RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SceneLayer_name_set"); + RNA_def_property_ui_text(prop, "Name", "Render layer name"); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL); + + prop = RNA_def_property(srna, "collections", 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, "Layer Collections", ""); + rna_def_layer_collections(brna, prop); + + 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_SceneLayer_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", SCENE_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); + + /* Override settings */ + prop = RNA_def_property(srna, "engine_overrides", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "properties->data.group", NULL); + RNA_def_property_struct_type(prop, "SceneLayerSettings"); + RNA_def_property_ui_text(prop, "Layer Settings", "Override of engine specific render settings"); + + /* engine */ + prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, engine_items); + RNA_def_property_enum_funcs(prop, "rna_SceneLayer_engine_get", "rna_SceneLayer_engine_set", + "rna_SceneLayer_engine_itemf"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering"); + RNA_def_property_update(prop, NC_WINDOW, "rna_SceneLayer_engine_update"); + + prop = RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_SceneLayer_multiple_engines_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available"); + + /* debug update routine */ + func = RNA_def_function(srna, "update", "rna_SceneLayer_update_tagged"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, + "Update data tagged to be updated from previous access to data or operators"); +} + +static void rna_def_scene_layers(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "SceneLayers"); + srna = RNA_def_struct(brna, "SceneLayers", 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, "active_layer"); + RNA_def_property_int_funcs(prop, "rna_SceneLayer_active_layer_index_get", + "rna_SceneLayer_active_layer_index_set", + "rna_SceneLayer_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_LAYER, NULL); + + prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "SceneLayer"); + RNA_def_property_pointer_funcs(prop, "rna_SceneLayer_active_layer_get", + "rna_SceneLayer_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_LAYER, NULL); + + func = RNA_def_function(srna, "new", "rna_SceneLayer_new"); + RNA_def_function_ui_description(func, "Add a render layer to scene"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + parm = RNA_def_string(func, "name", "SceneLayer", 0, "", "New name for the render layer (not unique)"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "result", "SceneLayer", "", "Newly created render layer"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_SceneLayer_remove"); + RNA_def_function_ui_description(func, "Remove a render layer"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "layer", "SceneLayer", "", "Render 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); +} + +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"); +} + +/* TODO LAYERS: legacy SceneRenderLayers, to be removed */ static void rna_def_scene_render_layer(BlenderRNA *brna) { @@ -6801,7 +8801,7 @@ static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, 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"); + parm = RNA_def_pointer(func, "base", "ObjectBaseLegacy", "", "The newly created base"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "unlink", "rna_Scene_object_unlink"); @@ -6836,7 +8836,7 @@ static void rna_def_scene_bases(BlenderRNA *brna, PropertyRNA *cprop) 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_struct_type(prop, "ObjectBaseLegacy"); 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"); @@ -7068,7 +9068,7 @@ void RNA_def_scene(BlenderRNA *brna) 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"); @@ -7079,7 +9079,7 @@ void RNA_def_scene(BlenderRNA *brna) /* 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_struct_type(prop, "ObjectBaseLegacy"); 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); @@ -7328,7 +9328,20 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "r"); RNA_def_property_struct_type(prop, "RenderSettings"); RNA_def_property_ui_text(prop, "Render Data", ""); - + + /* Render Engine Data */ + prop = RNA_def_property(srna, "layer_properties", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "layer_properties->data.group", NULL); + RNA_def_property_struct_type(prop, "SceneLayerSettings"); + RNA_def_property_ui_text(prop, "Layer Settings", + "Engine specific render settings to be overridden by layers"); + + prop = RNA_def_property(srna, "collection_properties", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "collection_properties->data.group", NULL); + RNA_def_property_struct_type(prop, "LayerCollectionSettings"); + RNA_def_property_ui_text(prop, "Collection Settings", + "Engine specific render settings to be overridden by collections"); + /* Safe Areas */ prop = RNA_def_property(srna, "safe_areas", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "safe_areas"); @@ -7398,6 +9411,8 @@ void RNA_def_scene(BlenderRNA *brna) /* Statistics */ func = RNA_def_function(srna, "statistics", "ED_info_stats_string"); + parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "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); @@ -7408,12 +9423,6 @@ void RNA_def_scene(BlenderRNA *brna) 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_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); @@ -7441,9 +9450,23 @@ void RNA_def_scene(BlenderRNA *brna) /* Dependency Graph */ prop = RNA_def_property(srna, "depsgraph", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "depsgraph_legacy"); 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, "render_layers", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "render_layers", NULL); + RNA_def_property_struct_type(prop, "SceneLayer"); + RNA_def_property_ui_text(prop, "Render Layers", ""); + rna_def_scene_layers(brna, prop); + + prop = RNA_def_property(srna, "master_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "collection"); + RNA_def_property_struct_type(prop, "SceneCollection"); + RNA_def_property_ui_text(prop, "Master Collection", "Collection that contains all other collections"); + /* Nestled Data */ /* *** Non-Animated *** */ RNA_define_animate_sdna(false); @@ -7456,11 +9479,17 @@ void RNA_def_scene(BlenderRNA *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_collection(brna); + rna_def_layer_collection(brna); + rna_def_layer_collection_override(brna); + rna_def_scene_layer(brna); + rna_def_object_base(brna); RNA_define_animate_sdna(true); /* *** Animated *** */ + rna_def_scene_layer_settings(brna); + rna_def_layer_collection_settings(brna); rna_def_scene_render_data(brna); rna_def_scene_render_layer(brna); rna_def_gpu_fx(brna); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index ea7327cfa31..ff870ec40b7 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -60,7 +60,6 @@ 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" @@ -86,8 +85,7 @@ static void rna_Scene_frame_set(Scene *scene, int frame, float subframe) 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(G.main->eval_ctx, G.main, scene, (1 << 20) - 1, true); + BKE_scene_update_for_newframe(G.main->eval_ctx, G.main, scene); #ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; @@ -112,7 +110,7 @@ static void rna_Scene_uvedit_aspect(Scene *scene, Object *ob, float *aspect) if ((ob->type == OB_MESH) && (ob->mode == OB_MODE_EDIT)) { BMEditMesh *em; em = BKE_editmesh_from_object(ob); - if (EDBM_mtexpoly_check(em)) { + if (EDBM_uv_check(em)) { ED_uvedit_get_aspect(scene, ob, em->bm, aspect, aspect + 1); return; } @@ -153,17 +151,17 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, int previe } static void rna_Scene_ray_cast( - Scene *scene, float origin[3], float direction[3], float ray_dist, + Scene *scene, bContext *C, SceneLayer *sl, float origin[3], float direction[3], float ray_dist, int *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( - G.main, scene, 0); + G.main, scene, sl, 0); bool ret = ED_transform_snap_object_project_ray_ex( - sctx, + C, sctx, &(const struct SnapObjectParams){ .snap_select = SNAP_ALL, }, @@ -269,6 +267,7 @@ static void rna_Scene_alembic_export( /* Note: This definition must match to the generated function call */ static void rna_Scene_collada_export( Scene *scene, + bContext *C, const char *filepath, int apply_modifiers, @@ -279,7 +278,7 @@ static void rna_Scene_collada_export( int include_shapekeys, int deform_bones_only, int active_uv_only, - int export_texture_type, + int include_material_textures, int use_texture_copies, int triangulate, int use_object_instantiation, @@ -290,7 +289,13 @@ static void rna_Scene_collada_export( int limit_precision, int keep_bind_info) { - collada_export(scene, + EvaluationContext eval_ctx; + + CTX_data_eval_ctx(C, &eval_ctx); + + collada_export(&eval_ctx, + scene, + CTX_data_scene_layer(C), filepath, apply_modifiers, @@ -303,7 +308,7 @@ static void rna_Scene_collada_export( deform_bones_only, active_uv_only, - export_texture_type, + include_material_textures, use_texture_copies, triangulate, @@ -347,6 +352,9 @@ void RNA_api_scene(StructRNA *srna) /* Ray Cast */ func = RNA_def_function(srna, "ray_cast", "rna_Scene_ray_cast"); RNA_def_function_ui_description(func, "Cast a ray onto in object space"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "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); @@ -400,8 +408,8 @@ void RNA_api_scene(StructRNA *srna) RNA_def_boolean(func, "active_uv_only", false, "Only Selected UV Map", "Export only the selected UV Map"); - RNA_def_int(func, "export_texture_type", 0, INT_MIN, INT_MAX, - "Texture Type", "Type for exported Textures (UV or MAT)", INT_MIN, INT_MAX); + RNA_def_boolean(func, "include_material_textures", false, + "Include Material Textures", "Export textures assigned to the object Materials"); RNA_def_boolean(func, "use_texture_copies", true, "Copy", "Copy textures to same folder where the .dae file is exported"); @@ -430,6 +438,8 @@ void RNA_api_scene(StructRNA *srna) "Keep Bind Info", "Store bind pose information in custom bone properties for later use during Collada export"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + #endif #ifdef WITH_ALEMBIC diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index b44e404c364..003445889c3 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" EnumPropertyItem rna_enum_region_type_items[] = { {RGN_TYPE_WINDOW, "WINDOW", 0, "Window", ""}, @@ -56,7 +57,9 @@ EnumPropertyItem rna_enum_region_type_items[] = { #ifdef RNA_RUNTIME #include "BKE_global.h" -#include "BKE_depsgraph.h" +#include "BKE_workspace.h" + +#include "DEG_depsgraph.h" #include "UI_view2d.h" @@ -64,55 +67,58 @@ EnumPropertyItem rna_enum_region_type_items[] = { # include "BPY_extern.h" #endif -static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value) -{ - bScreen *sc = (bScreen *)ptr->data; - if (value.data == NULL) - return; +static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + bScreen *screen = (bScreen *)ptr->data; - sc->newscene = value.data; + /* 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); } -static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr) +static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(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 - - ED_screen_set_scene(C, sc, sc->newscene); - -#ifdef WITH_PYTHON - BPy_END_ALLOW_THREADS; -#endif - - WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, sc->newscene); + /* can be NULL on file load, T42619 */ + wmWindowManager *wm = G.main->wm.first; + return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; +} - 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 int 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 int rna_Screen_fullscreen_get(PointerRNA *ptr) @@ -152,7 +158,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); @@ -166,7 +172,7 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr) /* 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); @@ -377,13 +383,11 @@ static void rna_def_screen(BlenderRNA *brna) 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); - /* 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); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 40aea37d9d2..ec719d90ef6 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -102,9 +102,10 @@ EnumPropertyItem rna_enum_symmetrize_direction_items[] = { #include "BKE_DerivedMesh.h" #include "BKE_pointcache.h" #include "BKE_particle.h" -#include "BKE_depsgraph.h" #include "BKE_pbvh.h" +#include "DEG_depsgraph.h" + #include "GPU_buffers.h" #include "ED_particle.h" @@ -148,10 +149,12 @@ static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_CurveMapping, NULL); } -static void rna_ParticleEdit_redo(Main *UNUSED(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(scene, ob); + Scene *scene = CTX_data_scene(C); + SceneLayer *sl = CTX_data_scene_layer(C); + Object *ob = OBACT_NEW; + PTCacheEdit *edit = PE_get_current(scene, sl, ob); if (!edit) return; @@ -159,21 +162,23 @@ static void rna_ParticleEdit_redo(Main *UNUSED(bmain), Scene *scene, PointerRNA psys_free_path_cache(edit->psys, edit); } -static void rna_ParticleEdit_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ParticleEdit_update(Main *UNUSED(bmain), Scene *UNUSED(scene), bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = (scene->basact) ? scene->basact->object : NULL; + SceneLayer *sl = CTX_data_scene_layer(C); + Object *ob = OBACT_NEW; - if (ob) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + if (ob) DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } + 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->scene_layer) { + Object *ob = (pset->scene_layer->basact) ? pset->scene_layer->basact->object : NULL; 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); } } @@ -183,9 +188,10 @@ static void rna_ParticleEdit_tool_set(PointerRNA *ptr, int value) static 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; + SceneLayer *sl = CTX_data_scene_layer(C); + Object *ob = OBACT_NEW; #if 0 + Scene *scene = CTX_data_scene(C); PTCacheEdit *edit = PE_get_current(scene, ob); ParticleSystem *psys = edit ? edit->psys : NULL; #else @@ -211,14 +217,14 @@ static int rna_ParticleEdit_editable_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; - return (pset->object && pset->scene && PE_get_current(pset->scene, pset->object)); + return (pset->object && pset->scene && PE_get_current(pset->scene, pset->scene_layer, pset->object)); } static int rna_ParticleEdit_hair_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; if (pset->scene) { - PTCacheEdit *edit = PE_get_current(pset->scene, pset->object); + PTCacheEdit *edit = PE_get_current(pset->scene, pset->scene_layer, pset->object); return (edit && edit->psys); } @@ -253,12 +259,14 @@ static int rna_Brush_mode_poll(PointerRNA *ptr, PointerRNA value) 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); + SceneLayer *sl = CTX_data_scene_layer(C); + Object *ob = OBACT_NEW; 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) { @@ -268,9 +276,10 @@ 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, Scene *scene, PointerRNA *UNUSED(ptr)) { - Object *ob = (scene->basact) ? scene->basact->object : NULL; + SceneLayer *sl = CTX_data_scene_layer(C); + Object *ob = OBACT_NEW; if (ob && ob->sculpt) { Sculpt *sd = scene->toolsettings->sculpt; @@ -329,9 +338,11 @@ 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);\ + SceneLayer *sl = CTX_data_scene_layer(C); + Object *ob = OBACT_NEW; if (ob && ob->type == OB_MESH) { /* of course we need to invalidate here */ @@ -344,9 +355,11 @@ static void rna_ImaPaint_mode_update(Main *UNUSED(bmain), Scene *scene, PointerR } } -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); + SceneLayer *sl = CTX_data_scene_layer(C); + Object *ob = OBACT_NEW; if (ob && ob->type == OB_MESH) { GPU_drawobject_free(ob->derivedFinal); @@ -355,19 +368,22 @@ static void rna_ImaPaint_stencil_update(Main *UNUSED(bmain), Scene *scene, Point } } -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); + SceneLayer *sl = CTX_data_scene_layer(C); + Object *ob = OBACT_NEW; 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(sima, scene, scene->obedit, ima); @@ -582,12 +598,14 @@ 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, "detail_size", PROP_FLOAT, PROP_PIXEL); @@ -613,6 +631,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); @@ -740,12 +759,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"); @@ -787,6 +806,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"); @@ -866,6 +886,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); @@ -888,6 +909,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); @@ -895,6 +917,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"); @@ -915,6 +938,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Brush", ""); prop = RNA_def_property(srna, "draw_step", PROP_INT, PROP_NONE); + 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_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_redo"); @@ -922,9 +946,11 @@ static void rna_def_particle_edit(BlenderRNA *brna) 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", ""); @@ -945,7 +971,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"); diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index c12937bd2bf..687541b96b0 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -52,22 +52,24 @@ #ifdef RNA_RUNTIME #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_particle.h" #include "BKE_texture.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) @@ -75,7 +77,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) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index f2e856bf1ba..c8cceb54f9b 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -45,6 +45,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" @@ -208,6 +209,7 @@ static EnumPropertyItem buttons_context_items[] = { {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"}, {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"}, {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"}, + {BCONTEXT_COLLECTION, "COLLECTION", ICON_COLLAPSEMENU, "Collection", "Collection"}, {0, NULL, 0, NULL, NULL} }; @@ -253,17 +255,23 @@ 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_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" @@ -403,43 +411,63 @@ static void rna_Space_view2d_sync_update(Main *UNUSED(bmain), Scene *UNUSED(scen } } -static PointerRNA rna_CurrentOrientation_get(PointerRNA *ptr) +static int rna_View3D_transform_orientation_get(PointerRNA *ptr) +{ + const View3D *v3d = (View3D *)ptr->data; + /* convert to enum value */ + return (v3d->twmode == V3D_MANIP_CUSTOM) ? (v3d->twmode + v3d->custom_orientation_index) : v3d->twmode; +} + +void rna_View3D_transform_orientation_set(PointerRNA *ptr, int value) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; View3D *v3d = (View3D *)ptr->data; + BIF_selectTransformOrientationValue(v3d, value); +} - 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)); +static PointerRNA rna_View3D_current_orientation_get(PointerRNA *ptr) +{ + View3D *v3d = (View3D *)ptr->data; + TransformOrientation *orientation; + + if (v3d->twmode < V3D_MANIP_CUSTOM) { + orientation = NULL; + } + else { + WorkSpace *workspace; + bScreen *screen = ptr->id.data; + + BKE_workspace_layout_find_global(G.main, screen, &workspace); + orientation = BKE_workspace_transform_orientation_find(workspace, v3d->custom_orientation_index); + } + + return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, orientation); } EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - Scene *scene = NULL; - ListBase *transform_spaces; - TransformOrientation *ts = NULL; + WorkSpace *workspace; + ListBase *transform_orientations; 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 (ptr->type == &RNA_SpaceView3D) { + bScreen *screen = ptr->id.data; + BKE_workspace_layout_find_global(G.main, screen, &workspace); + } + else { + /* can't use scene from ptr->id.data because that enum is also used by operators */ + workspace = C ? CTX_wm_workspace(C) : NULL; } - if (ts) { + transform_orientations = workspace ? BKE_workspace_transform_orientations_get(workspace) : NULL; + + if (transform_orientations && (BLI_listbase_is_empty(transform_orientations) == false)) { RNA_enum_item_add_separator(&item, &totitem); - for (; ts; ts = ts->next) { + for (TransformOrientation *ts = transform_orientations->first; ts; ts = ts->next) { tmp.identifier = ts->name; tmp.name = ts->name; tmp.value = i++; @@ -458,8 +486,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); } } @@ -471,8 +501,10 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int valu v3d->scenelock = value; if (value) { + Scene *scene = ED_screen_scene_find(sc, G.main->wm.first); int bit; - v3d->lay = sc->scene->lay; + + v3d->lay = scene->lay; /* seek for layact */ bit = 0; while (bit < 32) { @@ -482,15 +514,15 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int valu } bit++; } - v3d->camera = sc->scene->camera; + 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; + bScreen *screen = ptr->id.data; + Scene *scene = ED_screen_scene_find(screen, G.main->wm.first); const float *loc = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(values, loc); @@ -499,8 +531,8 @@ static void rna_View3D_CursorLocation_get(PointerRNA *ptr, float *values) 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; + bScreen *screen = ptr->id.data; + Scene *scene = ED_screen_scene_find(screen, G.main->wm.first); float *cursor = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(cursor, values); @@ -509,8 +541,8 @@ static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values) static float rna_View3D_GridScaleUnit_get(PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); - bScreen *sc = (bScreen *)ptr->id.data; - Scene *scene = (Scene *)sc->scene; + bScreen *screen = ptr->id.data; + Scene *scene = ED_screen_scene_find(screen, G.main->wm.first); return ED_view3d_grid_scale(scene, v3d, NULL); } @@ -531,7 +563,7 @@ static int rna_SpaceView3D_active_layer_get(PointerRNA *ptr) static void rna_SpaceView3D_layer_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { - DAG_on_visible_update(bmain, false); + DEG_on_visible_update(bmain, false); } static void rna_SpaceView3D_viewport_shade_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -694,12 +726,12 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value static int rna_SpaceView3D_viewport_shade_get(PointerRNA *ptr) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; + Scene *scene = WM_windows_scene_get_from_screen(G.main->wm.first, ptr->id.data); RenderEngineType *type = RE_engines_find(scene->r.engine); View3D *v3d = (View3D *)ptr->data; int drawtype = v3d->drawtype; - if (drawtype == OB_RENDER && !(type && type->view_draw)) + if (drawtype == OB_RENDER && !(type && type->render_to_view)) return OB_SOLID; return drawtype; @@ -714,10 +746,11 @@ static void rna_SpaceView3D_viewport_shade_set(PointerRNA *ptr, int value) v3d->drawtype = value; } -static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C), PointerRNA *ptr, +static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { - Scene *scene = ((bScreen *)ptr->id.data)->scene; + wmWindow *win = CTX_wm_window(C); + Scene *scene = WM_window_get_active_scene(win); RenderEngineType *type = RE_engines_find(scene->r.engine); EnumPropertyItem *item = NULL; @@ -729,7 +762,7 @@ static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C 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); - if (type && type->view_draw) + if (type && type->render_to_view) RNA_enum_items_add_value(&item, &totitem, rna_enum_viewport_shade_items, OB_RENDER); RNA_enum_item_end(&item, &totitem); @@ -738,10 +771,10 @@ static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C return item; } -static EnumPropertyItem *rna_SpaceView3D_stereo3d_camera_itemf(bContext *UNUSED(C), PointerRNA *ptr, +static 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; @@ -809,22 +842,28 @@ static int 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); + Scene *scene = ED_screen_scene_find(sc, G.main->wm.first); + + return ED_space_image_show_uvedit(sima, scene->obedit); } static int 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); + Scene *scene = ED_screen_scene_find(sc, G.main->wm.first); + SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene); + + return ED_space_image_check_show_maskedit(sl, sima); } static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; + Scene *scene = ED_screen_scene_find(sc, G.main->wm.first); - ED_space_image_set(sima, sc->scene, sc->scene->obedit, (Image *)value.data); + ED_space_image_set(sima, scene, scene->obedit, (Image *)value.data); } static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value) @@ -1076,6 +1115,10 @@ static EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSED(C), RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_SCENE); } + if (sbuts->pathflag & (1 << BCONTEXT_COLLECTION)) { + RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_COLLECTION); + } + if (sbuts->pathflag & (1 << BCONTEXT_WORLD)) { RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORLD); } @@ -1261,10 +1304,11 @@ 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(Main *bmain, bContext *C, Scene *UNUSED(scene), PointerRNA *ptr) { SpaceAction *saction = (SpaceAction *)(ptr->data); - Object *obact = (scene->basact) ? scene->basact->object : NULL; + SceneLayer *sl = CTX_data_scene_layer(C); + Object *obact = OBACT_NEW; /* we must set this action to be the one used by active object (if not pinned) */ if (obact /* && saction->pin == 0*/) { @@ -1330,16 +1374,17 @@ 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; + SceneLayer *sl = CTX_data_scene_layer(C); + Object *obact = OBACT_NEW; /* special exceptions for ShapeKey Editor mode */ if (saction->mode == SACTCONT_SHAPEKEY) { @@ -2101,6 +2146,9 @@ static void rna_def_space_outliner(BlenderRNA *brna) {SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", "Display user preference data"}, {SO_ID_ORPHANS, "ORPHAN_DATA", 0, "Orphan Data", "Display data-blocks which are unused and/or will be lost when the file is reloaded"}, + {SO_ACT_LAYER, "ACT_LAYER", 0, "Active Render Layer", "Display the collections of the active render layer"}, + {SO_COLLECTIONS, "MASTER_COLLECTION", 0, "Master Collection Tree", "Display all collections based on the " + "master collection hierarchy"}, {0, NULL, 0, NULL, NULL} }; @@ -2573,9 +2621,9 @@ static void rna_def_space_view3d(BlenderRNA *brna) 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"); + prop = RNA_def_property(srna, "show_mode_shade_override", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_MODE_SHADE_OVERRIDE); + RNA_def_property_ui_text(prop, "Full Shading", "Use full shading for mode drawing (to view final result)"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE); @@ -2630,7 +2678,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) 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_boolean_sdna(prop, NULL, "twflag", V3D_MANIPULATOR_DRAW); 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); @@ -2645,13 +2693,14 @@ static void rna_def_space_view3d(BlenderRNA *brna) 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_enum_funcs(prop, "rna_View3D_transform_orientation_get", "rna_View3D_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_CurrentOrientation_get", NULL, NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_View3D_current_orientation_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); @@ -3406,6 +3455,7 @@ 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 */ @@ -3413,6 +3463,7 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, 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 */ @@ -3856,6 +3907,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_RADIO, "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"}, @@ -3863,6 +3915,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} }; @@ -3880,7 +3933,7 @@ 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, + {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_SPK | FILTER_ID_WO | FILTER_ID_WS, "ENVIRONMENT", ICON_WORLD_DATA, "Environment", "Show/hide worlds, lamps, 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"}, @@ -4395,14 +4448,10 @@ 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); diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c index 8f771eda99d..822f5cbb4b6 100644 --- a/source/blender/makesrna/intern/rna_space_api.c +++ b/source/blender/makesrna/intern/rna_space_api.c @@ -31,23 +31,28 @@ #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; + EvaluationContext eval_ctx; ScrArea *sa; ARegion *ar; + CTX_data_eval_ctx(C, &eval_ctx); + area_region_from_regiondata(sc, rv3d, &sa, &ar); if (sa && ar && sa->spacetype == SPACE_VIEW3D) { - View3D *v3d; + View3D *v3d = sa->spacedata.first; + Scene *scene = ED_screen_scene_find(sc, G.main->wm.first); - v3d = (View3D *)sa->spacedata.first; - - ED_view3d_update_viewmat(sc->scene, v3d, ar, NULL, NULL, NULL); + ED_view3d_update_viewmat(&eval_ctx, scene, v3d, ar, NULL, NULL, NULL); } } @@ -71,7 +76,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 f47b54c2d95..f37b75b3db2 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 1e88585a286..1c7b750fbe1 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -113,11 +113,12 @@ static EnumPropertyItem blend_type_items[] = { #include "RNA_access.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" @@ -168,7 +169,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); } @@ -214,7 +215,7 @@ static void rna_Texture_nodes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), { 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); } @@ -225,11 +226,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: @@ -245,8 +246,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); + SceneLayer *sl = CTX_data_scene_layer(C); + BKE_paint_invalidate_overlay_tex(scene, sl, mtex->tex); WM_main_add_notifier(NC_BRUSH, id); break; } @@ -263,7 +266,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; } @@ -645,7 +648,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"); @@ -653,6 +656,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"); @@ -660,12 +664,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"); @@ -673,6 +678,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"); @@ -680,26 +686,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"); @@ -708,6 +719,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"); @@ -734,7 +746,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", diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 7a01e3a4f6b..ea45b08458c 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -48,9 +48,10 @@ #ifdef RNA_RUNTIME -#include "BKE_depsgraph.h" #include "BKE_node.h" +#include "DEG_depsgraph.h" + #include "IMB_imbuf.h" #include "WM_api.h" @@ -466,7 +467,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) @@ -555,7 +556,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) diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 7d8d24670a7..fd7346379a1 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -60,7 +60,7 @@ EnumPropertyItem rna_enum_icon_items[] = { #ifdef RNA_RUNTIME -static const char *rna_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, +const char *rna_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, int translate) { /* Also return text if UI labels translation is disabled. */ @@ -670,7 +670,31 @@ void RNA_api_ui_layout(StructRNA *srna) "Identifier of property in data giving the type of the ID-blocks to use"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); api_ui_item_common_text(func); - + + 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); @@ -887,6 +911,16 @@ void RNA_api_ui_layout(StructRNA *srna) parm = RNA_def_pointer(func, "item", "KeyMapItem", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + func = RNA_def_function(srna, "template_override_property", "uiTemplateOverrideProperty"); + parm = RNA_def_pointer(func, "collection_render_overrides", "AnyType", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + parm = RNA_def_pointer(func, "scene_collection_properties", "AnyType", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in collection_properties"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + api_ui_item_common(func); + parm = RNA_def_string(func, "custom_template", NULL, 0, "", "Optional template to use for property"); + func = RNA_def_function(srna, "template_component_menu", "uiTemplateComponentMenu"); RNA_def_function_ui_description(func, "Item. Display expanded property in a popup menu"); parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f2ed79cb5ff..0a4e69934b7 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -98,13 +98,14 @@ static EnumPropertyItem rna_enum_language_default_items[] = { #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_pbvh.h" #include "BKE_paint.h" +#include "DEG_depsgraph.h" + #include "GPU_draw.h" #include "GPU_select.h" @@ -175,10 +176,12 @@ static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, Point 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; + if (userdef->manipulator_flag & USER_MANIPULATOR_DRAW) { + v3d->twflag |= V3D_MANIPULATOR_DRAW; + } + else { + v3d->twflag &= ~V3D_MANIPULATOR_DRAW; + } } } } @@ -363,7 +366,7 @@ static void rna_UserDef_weight_color_update(Main *bmain, Scene *scene, PointerRN 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); @@ -502,7 +505,7 @@ static void rna_userdef_opensubdiv_update(Main *bmain, Scene *UNUSED(scene), Poi 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); } } } @@ -3335,11 +3338,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"); @@ -3505,30 +3503,25 @@ static void rna_def_userdef_view(BlenderRNA *brna) /* 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_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_DRAW); RNA_def_property_ui_text(prop, "Manipulator", "Use 3D transform manipulator"); RNA_def_property_update(prop, 0, "rna_userdef_show_manipulator_update"); + /* TODO, expose once it's working. */ +#if 0 + prop = RNA_def_property(srna, "show_manipulator_shaded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_SHADED); + RNA_def_property_ui_text(prop, "Manipulator Shaded", "Use 3D transform manipulator"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); +#endif + prop = RNA_def_property(srna, "manipulator_size", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "tw_size"); + RNA_def_property_int_sdna(prop, NULL, "manipulator_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_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); diff --git a/source/blender/makesrna/intern/rna_vfont.c b/source/blender/makesrna/intern/rna_vfont.c index c743751649c..78d46d35246 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 b5ecaf739c7..fe30890d5ba 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -461,12 +461,23 @@ EnumPropertyItem rna_enum_wm_report_items[] = { #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 + + static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr) { wmWindowManager *wm = ptr->id.data; @@ -621,39 +632,120 @@ 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_change_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)); +} - if (value.data == NULL) +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); + + /* 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 int 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; } } @@ -1927,14 +2019,28 @@ static void rna_def_window(BlenderRNA *brna) 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, "x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "posx"); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 677ea92aea1..166b6f96956 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -71,6 +71,8 @@ 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 wmManipulatorGroupType *wm_manipulatorgrouptype_find_for_add_remove(ReportList *reports, const char *idname) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, true); + if (wgt == NULL) { + BKE_reportf(reports, RPT_ERROR, "Manipulator group type '%s' not found!", idname); + return NULL; + } + if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) { + BKE_reportf(reports, RPT_ERROR, "Manipulator group '%s' has 'PERSISTENT' option set!", idname); + return NULL; + } + return wgt; +} + +static void rna_manipulator_group_type_add(ReportList *reports, const char *idname) +{ + wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_find_for_add_remove(reports, idname); + if (wgt != NULL) { + WM_manipulator_group_add_ptr(wgt); + } +} + +static void rna_manipulator_group_type_remove(Main *bmain, ReportList *reports, const char *idname) +{ + wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_find_for_add_remove(reports, idname); + if (wgt != NULL) { + WM_manipulator_group_remove_ptr(bmain, wgt); + } +} + /* placeholder data for final implementation of a true progressbar */ static struct wmStaticProgress { float min; @@ -426,6 +459,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, "manipulator_group_type_add", "rna_manipulator_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, "", "Manipulator group type name"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + func = RNA_def_function(srna, "manipulator_group_type_remove", "rna_manipulator_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, "", "Manipulator 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"); diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c new file mode 100644 index 00000000000..fc7dcdbe3cb --- /dev/null +++ b/source/blender/makesrna/intern/rna_wm_manipulator.c @@ -0,0 +1,1237 @@ +/* + * ***** 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_manipulator.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 "BLT_translation.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" + +#ifdef RNA_RUNTIME +/* enum definitions */ +#endif /* RNA_RUNTIME */ + +#ifdef RNA_RUNTIME + +#include <assert.h> + +#include "WM_api.h" +#include "WM_types.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 "BKE_utildefines.h" + +#include "MEM_guardedalloc.h" + +#ifdef WITH_PYTHON +# include "BPY_extern.h" +#endif + +/* -------------------------------------------------------------------- */ + +/** \name Manipulator API + * \{ */ + +static void rna_manipulator_draw_cb( + const struct bContext *C, struct wmManipulator *mpr) +{ + extern FunctionRNA rna_Manipulator_draw_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "draw"); */ + func = &rna_Manipulator_draw_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static void rna_manipulator_draw_select_cb( + const struct bContext *C, struct wmManipulator *mpr, int select_id) +{ + extern FunctionRNA rna_Manipulator_draw_select_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "draw_select"); */ + func = &rna_Manipulator_draw_select_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "select_id", &select_id); + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static int rna_manipulator_test_select_cb( + struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event) +{ + extern FunctionRNA rna_Manipulator_test_select_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "test_select"); */ + func = &rna_Manipulator_test_select_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "event", &event); + mgroup->type->ext.call((bContext *)C, &mpr_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 void rna_manipulator_modal_cb( + struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event, + eWM_ManipulatorTweak tweak_flag) +{ + extern FunctionRNA rna_Manipulator_modal_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + const int tweak_flag_int = tweak_flag; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "modal"); */ + func = &rna_Manipulator_modal_func; + RNA_parameter_list_create(&list, &mpr_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); + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static void rna_manipulator_setup_cb( + struct wmManipulator *mpr) +{ + extern FunctionRNA rna_Manipulator_setup_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "setup"); */ + func = &rna_Manipulator_setup_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + + +static void rna_manipulator_invoke_cb( + struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event) +{ + extern FunctionRNA rna_Manipulator_invoke_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "invoke"); */ + func = &rna_Manipulator_invoke_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + RNA_parameter_set_lookup(&list, "event", &event); + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static void rna_manipulator_exit_cb( + struct bContext *C, struct wmManipulator *mpr, bool cancel) +{ + extern FunctionRNA rna_Manipulator_exit_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "exit"); */ + func = &rna_Manipulator_exit_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + { + int cancel_i = cancel; + RNA_parameter_set_lookup(&list, "cancel", &cancel_i); + } + mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +static void rna_manipulator_select_refresh_cb( + struct wmManipulator *mpr) +{ + extern FunctionRNA rna_Manipulator_select_refresh_func; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + PointerRNA mpr_ptr; + ParameterList list; + FunctionRNA *func; + RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr); + /* RNA_struct_find_function(&mpr_ptr, "select_refresh"); */ + func = &rna_Manipulator_select_refresh_func; + RNA_parameter_list_create(&list, &mpr_ptr, func); + mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list); + RNA_parameter_list_free(&list); +} + +/* just to work around 'const char *' warning and to ensure this is a python op */ +static void rna_Manipulator_bl_idname_set(PointerRNA *ptr, const char *value) +{ + wmManipulator *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 wmManipulator *rna_ManipulatorProperties_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->manipulator_map) { + wmManipulatorMap *mmap = ar->manipulator_map; + for (wmManipulatorGroup *mgroup = WM_manipulatormap_group_list(mmap)->first; + mgroup; + mgroup = mgroup->next) + { + for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { + if (mpr->properties == properties) { + return mpr; + } + } + } + } + } + } + } + return NULL; +} + +static StructRNA *rna_ManipulatorProperties_refine(PointerRNA *ptr) +{ + wmManipulator *mpr = rna_ManipulatorProperties_find_operator(ptr); + + if (mpr) + return mpr->type->srna; + else + return ptr->type; +} + +static IDProperty *rna_ManipulatorProperties_idprops(PointerRNA *ptr, bool create) +{ + if (create && !ptr->data) { + IDPropertyTemplate val = {0}; + ptr->data = IDP_New(IDP_GROUP, &val, "RNA_ManipulatorProperties group"); + } + + return ptr->data; +} + +static PointerRNA rna_Manipulator_properties_get(PointerRNA *ptr) +{ + wmManipulator *mpr = ptr->data; + return rna_pointer_inherit_refine(ptr, mpr->type->srna, mpr->properties); +} + +/* wmManipulator.float */ +#define RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(func_id, member_id) \ +static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmManipulator *mpr = ptr->data; \ + return mpr->member_id; \ +} \ +static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \ +{ \ + wmManipulator *mpr = ptr->data; \ + mpr->member_id = value; \ +} +#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \ +static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmManipulator *mpr = ptr->data; \ + return mpr->member_id[index]; \ +} \ +static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \ +{ \ + wmManipulator *mpr = ptr->data; \ + mpr->member_id[index] = value; \ +} +/* wmManipulator.float[len] */ +#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \ +static void rna_Manipulator_##func_id##_get(PointerRNA *ptr, float value[len]) \ +{ \ + wmManipulator *mpr = ptr->data; \ + memcpy(value, mpr->member_id, sizeof(float[len])); \ +} \ +static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, const float value[len]) \ +{ \ + wmManipulator *mpr = ptr->data; \ + memcpy(mpr->member_id, value, sizeof(float[len])); \ +} + +/* wmManipulator.flag */ +#define RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \ +static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmManipulator *mpr = ptr->data; \ + return (mpr->member_id & flag_value) != 0; \ +} \ +static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, int value) \ +{ \ + wmManipulator *mpr = ptr->data; \ + BKE_BIT_TEST_SET(mpr->member_id, value, flag_value); \ +} + +#define RNA_MANIPULATOR_FLAG_RO_DEF(func_id, member_id, flag_value) \ +static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \ +{ \ + wmManipulator *mpr = ptr->data; \ + return (mpr->member_id & flag_value) != 0; \ +} + +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3); +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3); + +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3); +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3); + +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16); +RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16); + +RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis); +RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(line_width, line_width); + +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_MANIPULATOR_DRAW_HOVER); +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_MANIPULATOR_DRAW_MODAL); +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_MANIPULATOR_DRAW_VALUE); +RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_MANIPULATOR_HIDDEN); + +/* wmManipulator.state */ +RNA_MANIPULATOR_FLAG_RO_DEF(state_is_highlight, state, WM_MANIPULATOR_STATE_HIGHLIGHT); +RNA_MANIPULATOR_FLAG_RO_DEF(state_is_modal, state, WM_MANIPULATOR_STATE_MODAL); +RNA_MANIPULATOR_FLAG_RO_DEF(state_select, state, WM_MANIPULATOR_STATE_SELECT); + +static void rna_Manipulator_state_select_set(struct PointerRNA *ptr, int value) +{ + wmManipulator *mpr = ptr->data; + wmManipulatorGroup *mgroup = mpr->parent_mgroup; + WM_manipulator_select_set(mgroup->parent_mmap, mpr, value); +} + +static PointerRNA rna_Manipulator_group_get(PointerRNA *ptr) +{ + wmManipulator *mpr = ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_ManipulatorGroup, mpr->parent_mgroup); +} + +#ifdef WITH_PYTHON + +static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type); +void BPY_RNA_manipulator_wrapper(wmManipulatorType *wgt, void *userdata); + +static StructRNA *rna_Manipulator_register( + Main *bmain, ReportList *reports, void *data, const char *identifier, + StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +{ + struct { + char idname[MAX_NAME]; + } temp_buffers; + + wmManipulatorType dummywt = {NULL}; + wmManipulator dummymnp = {NULL}; + PointerRNA mnp_ptr; + + /* Two sets of functions. */ + int have_function[8]; + + /* setup dummy manipulator & manipulator type to store static properties in */ + dummymnp.type = &dummywt; + dummywt.idname = temp_buffers.idname; + RNA_pointer_create(NULL, &RNA_Manipulator, &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 manipulator class: '%s' is too long, maximum length is %d", + identifier, (int)sizeof(temp_buffers.idname)); + return NULL; + } + + /* check if we have registered this manipulator type before, and remove it */ + { + const wmManipulatorType *wt = WM_manipulatortype_find(dummywt.idname, true); + if (wt && wt->ext.srna) { + rna_Manipulator_unregister(bmain, wt->ext.srna); + } + } + + /* create a new manipulator type */ + dummywt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywt.idname, &RNA_Manipulator); + /* manipulator properties are registered separately */ + RNA_def_struct_flag(dummywt.ext.srna, STRUCT_NO_IDPROPERTIES); + dummywt.ext.data = data; + dummywt.ext.call = call; + dummywt.ext.free = free; + + { + int i = 0; + dummywt.draw = (have_function[i++]) ? rna_manipulator_draw_cb : NULL; + dummywt.draw_select = (have_function[i++]) ? rna_manipulator_draw_select_cb : NULL; + dummywt.test_select = (have_function[i++]) ? rna_manipulator_test_select_cb : NULL; + dummywt.modal = (have_function[i++]) ? rna_manipulator_modal_cb : NULL; +// dummywt.property_update = (have_function[i++]) ? rna_manipulator_property_update : NULL; +// dummywt.position_get = (have_function[i++]) ? rna_manipulator_position_get : NULL; + dummywt.setup = (have_function[i++]) ? rna_manipulator_setup_cb : NULL; + dummywt.invoke = (have_function[i++]) ? rna_manipulator_invoke_cb : NULL; + dummywt.exit = (have_function[i++]) ? rna_manipulator_exit_cb : NULL; + dummywt.select_refresh = (have_function[i++]) ? rna_manipulator_select_refresh_cb : NULL; + + BLI_assert(i == ARRAY_SIZE(have_function)); + } + + RNA_def_struct_duplicate_pointers(dummywt.ext.srna); + + /* use duplicated string */ + dummywt.idname = dummywt.ext.srna->identifier; + + WM_manipulatortype_append_ptr(BPY_RNA_manipulator_wrapper, (void *)&dummywt); + + /* update while blender is running */ + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + return dummywt.ext.srna; +} + +static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type) +{ + wmManipulatorType *wt = RNA_struct_blender_type_get(type); + + if (!wt) + return; + + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + RNA_struct_free_extension(type, &wt->ext); + + WM_manipulatortype_remove_ptr(NULL, bmain, wt); + + RNA_struct_free(&BLENDER_RNA, type); +} + +static void **rna_Manipulator_instance(PointerRNA *ptr) +{ + wmManipulator *mpr = ptr->data; + return &mpr->py_instance; +} + +#endif /* WITH_PYTHON */ + + +static StructRNA *rna_Manipulator_refine(PointerRNA *mnp_ptr) +{ + wmManipulator *mpr = mnp_ptr->data; + return (mpr->type && mpr->type->ext.srna) ? mpr->type->ext.srna : &RNA_Manipulator; +} + +/** \} */ + +/** \name Manipulator Group API + * \{ */ + +static wmManipulator *rna_ManipulatorGroup_manipulator_new( + wmManipulatorGroup *mgroup, ReportList *reports, const char *idname) +{ + const wmManipulatorType *wt = WM_manipulatortype_find(idname, true); + if (wt == NULL) { + BKE_reportf(reports, RPT_ERROR, "ManipulatorType '%s' not known", idname); + return NULL; + } + wmManipulator *mpr = WM_manipulator_new_ptr(wt, mgroup, NULL); + return mpr; +} + +static void rna_ManipulatorGroup_manipulator_remove( + wmManipulatorGroup *mgroup, bContext *C, wmManipulator *mpr) +{ + WM_manipulator_free(&mgroup->manipulators, mgroup->parent_mmap, mpr, C); +} + +static void rna_ManipulatorGroup_manipulator_clear( + wmManipulatorGroup *mgroup, bContext *C) +{ + while (mgroup->manipulators.first) { + WM_manipulator_free(&mgroup->manipulators, mgroup->parent_mmap, mgroup->manipulators.first, C); + } +} + +static void rna_ManipulatorGroup_name_get(PointerRNA *ptr, char *value) +{ + wmManipulatorGroup *mgroup = ptr->data; + strcpy(value, mgroup->type->name); +} + +static int rna_ManipulatorGroup_name_length(PointerRNA *ptr) +{ + wmManipulatorGroup *mgroup = ptr->data; + return strlen(mgroup->type->name); +} + +/* just to work around 'const char *' warning and to ensure this is a python op */ +static void rna_ManipulatorGroup_bl_idname_set(PointerRNA *ptr, const char *value) +{ + wmManipulatorGroup *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_ManipulatorGroup_bl_label_set(PointerRNA *ptr, const char *value) +{ + wmManipulatorGroup *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 int rna_ManipulatorGroup_has_reports_get(PointerRNA *ptr) +{ + wmManipulatorGroup *mgroup = ptr->data; + return (mgroup->reports && mgroup->reports->list.first); +} + +#ifdef WITH_PYTHON + +static bool rna_manipulatorgroup_poll_cb(const bContext *C, wmManipulatorGroupType *wgt) +{ + + extern FunctionRNA rna_ManipulatorGroup_poll_func; + + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + void *ret; + int visible; + + RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */ + func = &rna_ManipulatorGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + wgt->ext.call((bContext *)C, &ptr, func, &list); + + RNA_parameter_get_lookup(&list, "visible", &ret); + visible = *(int *)ret; + + RNA_parameter_list_free(&list); + + return visible; +} + +static void rna_manipulatorgroup_setup_cb(const bContext *C, wmManipulatorGroup *mgroup) +{ + extern FunctionRNA rna_ManipulatorGroup_setup_func; + + PointerRNA mgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); + func = &rna_ManipulatorGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */ + + RNA_parameter_list_create(&list, &mgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +static wmKeyMap *rna_manipulatorgroup_setup_keymap_cb(const wmManipulatorGroupType *wgt, wmKeyConfig *config) +{ + extern FunctionRNA rna_ManipulatorGroup_setup_keymap_func; + void *ret; + + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */ + func = &rna_ManipulatorGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */ + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "keyconfig", &config); + wgt->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_manipulatorgroup_refresh_cb(const bContext *C, wmManipulatorGroup *mgroup) +{ + extern FunctionRNA rna_ManipulatorGroup_refresh_func; + + PointerRNA mgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); + func = &rna_ManipulatorGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */ + + RNA_parameter_list_create(&list, &mgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +static void rna_manipulatorgroup_draw_prepare_cb(const bContext *C, wmManipulatorGroup *mgroup) +{ + extern FunctionRNA rna_ManipulatorGroup_draw_prepare_func; + + PointerRNA mgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr); + func = &rna_ManipulatorGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */ + + RNA_parameter_list_create(&list, &mgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata); + +static StructRNA *rna_ManipulatorGroup_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; + + wmManipulatorGroupType dummywgt = {NULL}; + wmManipulatorGroup dummywg = {NULL}; + PointerRNA wgptr; + + /* Two sets of functions. */ + int have_function[5]; + + /* setup dummy manipulatorgroup & manipulatorgroup type to store static properties in */ + dummywg.type = &dummywgt; + dummywgt.name = temp_buffers.name; + dummywgt.idname = temp_buffers.idname; + + RNA_pointer_create(NULL, &RNA_ManipulatorGroup, &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 manipulatorgroup 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 wmManipulatorMapType_Params wmap_params = { + .spaceid = dummywgt.mmap_params.spaceid, + .regionid = dummywgt.mmap_params.regionid, + }; + + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wmap_params); + if (mmap_type == NULL) { + BKE_reportf(reports, RPT_ERROR, "Area type does not support manipulators"); + return NULL; + } + + /* check if we have registered this manipulatorgroup type before, and remove it */ + { + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(dummywgt.idname, true); + if (wgt && wgt->ext.srna) { + WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt); + WM_manipulatorgrouptype_remove_ptr(wgt); + + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + } + } + + /* create a new manipulatorgroup type */ + dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_ManipulatorGroup); + RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* manipulatorgroup 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_manipulatorgroup_poll_cb : NULL; + dummywgt.setup_keymap = (have_function[1]) ? rna_manipulatorgroup_setup_keymap_cb : NULL; + dummywgt.setup = (have_function[2]) ? rna_manipulatorgroup_setup_cb : NULL; + dummywgt.refresh = (have_function[3]) ? rna_manipulatorgroup_refresh_cb : NULL; + dummywgt.draw_prepare = (have_function[4]) ? rna_manipulatorgroup_draw_prepare_cb : NULL; + + RNA_def_struct_duplicate_pointers(dummywgt.ext.srna); + dummywgt.idname = dummywgt.ext.srna->identifier; + dummywgt.name = dummywgt.ext.srna->name; + + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append_ptr( + BPY_RNA_manipulatorgroup_wrapper, (void *)&dummywgt); + + if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) { + WM_manipulator_group_add_ptr_ex(wgt, mmap_type); + + /* update while blender is running */ + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + } + + return dummywgt.ext.srna; +} + +static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type) +{ + wmManipulatorGroupType *wgt = RNA_struct_blender_type_get(type); + + if (!wgt) + return; + + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + RNA_struct_free_extension(type, &wgt->ext); + + WM_manipulator_group_remove_ptr(bmain, wgt); + + RNA_struct_free(&BLENDER_RNA, type); +} + +static void **rna_ManipulatorGroup_instance(PointerRNA *ptr) +{ + wmManipulatorGroup *mgroup = ptr->data; + return &mgroup->py_instance; +} + +#endif /* WITH_PYTHON */ + +static StructRNA *rna_ManipulatorGroup_refine(PointerRNA *mgroup_ptr) +{ + wmManipulatorGroup *mgroup = mgroup_ptr->data; + return (mgroup->type && mgroup->type->ext.srna) ? mgroup->type->ext.srna : &RNA_ManipulatorGroup; +} + +static void rna_ManipulatorGroup_manipulators_begin(CollectionPropertyIterator *iter, PointerRNA *mgroup_ptr) +{ + wmManipulatorGroup *mgroup = mgroup_ptr->data; + rna_iterator_listbase_begin(iter, &mgroup->manipulators, NULL); +} + +/** \} */ + + +#else /* RNA_RUNTIME */ + + +/* ManipulatorGroup.manipulators */ +static void rna_def_manipulators(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "Manipulators"); + srna = RNA_def_struct(brna, "Manipulators", NULL); + RNA_def_struct_sdna(srna, "wmManipulatorGroup"); + RNA_def_struct_ui_text(srna, "Manipulators", "Collection of manipulators"); + + func = RNA_def_function(srna, "new", "rna_ManipulatorGroup_manipulator_new"); + RNA_def_function_ui_description(func, "Add manipulator"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_string(func, "type", "Type", 0, "", "Manipulator identifier"); /* optional */ + parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_ManipulatorGroup_manipulator_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Delete manipulator"); + parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator"); + 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_ManipulatorGroup_manipulator_clear"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Delete all manipulators"); +} + + +static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "Manipulator"); + srna = RNA_def_struct(brna, "Manipulator", NULL); + RNA_def_struct_sdna(srna, "wmManipulator"); + RNA_def_struct_ui_text(srna, "Manipulator", "Collection of manipulators"); + RNA_def_struct_refine_func(srna, "rna_Manipulator_refine"); + +#ifdef WITH_PYTHON + RNA_def_struct_register_funcs( + srna, + "rna_Manipulator_register", + "rna_Manipulator_unregister", + "rna_Manipulator_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, "ManipulatorProperties"); + RNA_def_property_ui_text(prop, "Properties", ""); + RNA_def_property_pointer_funcs(prop, "rna_Manipulator_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_Manipulator_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 */ + + /* wmManipulator.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); + + /* wmManipulator.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); + + /* wmManipulator.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_pointer(func, "event", "Event", "", ""); + 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); + + /* wmManipulator.handler */ + static EnumPropertyItem tweak_actions[] = { + {WM_MANIPULATOR_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""}, + {WM_MANIPULATOR_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(func, "tweak", tweak_actions, 0, "Tweak", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_property_flag(parm, PROP_ENUM_FLAG); + + /* wmManipulator.property_update */ + /* TODO */ + + /* wmManipulator.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); + + /* wmManipulator.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); + + /* wmManipulator.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); + + /* wmManipulator.cursor_get */ + /* TODO */ + + /* wmManipulator.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, "ManipulatorGroup"); + RNA_def_property_pointer_funcs(prop, "rna_Manipulator_group_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "", "Manipulator group this manipulator 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_Manipulator_color_get", "rna_Manipulator_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_Manipulator_alpha_get", "rna_Manipulator_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_Manipulator_color_hi_get", "rna_Manipulator_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_Manipulator_alpha_hi_get", "rna_Manipulator_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_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_Manipulator_matrix_basis_get", "rna_Manipulator_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_Manipulator_matrix_offset_get", "rna_Manipulator_matrix_offset_set", NULL); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, 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_Manipulator_scale_basis_get", "rna_Manipulator_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_Manipulator_line_width_get", "rna_Manipulator_line_width_set", NULL); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + + /* wmManipulator.flag */ + /* WM_MANIPULATOR_HIDDEN */ + prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_hide_get", "rna_Manipulator_flag_hide_set"); + RNA_def_property_ui_text(prop, "Hide", ""); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_MANIPULATOR_DRAW_HOVER */ + prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_draw_hover_get", "rna_Manipulator_flag_use_draw_hover_set"); + RNA_def_property_ui_text(prop, "Draw Hover", ""); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_MANIPULATOR_DRAW_MODAL */ + prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_draw_modal_get", "rna_Manipulator_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_MANIPULATOR_DRAW_VALUE */ + prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Manipulator_flag_use_draw_value_get", "rna_Manipulator_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); + + /* wmManipulator.state (readonly) */ + /* WM_MANIPULATOR_STATE_HIGHLIGHT */ + prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_highlight_get", NULL); + RNA_def_property_ui_text(prop, "Highlight", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + /* WM_MANIPULATOR_STATE_MODAL */ + prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_modal_get", NULL); + RNA_def_property_ui_text(prop, "Highlight", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + /* WM_MANIPULATOR_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_Manipulator_state_select_get", "rna_Manipulator_state_select_set"); + RNA_def_property_ui_text(prop, "Select", ""); + + RNA_api_manipulator(srna); + + srna = RNA_def_struct(brna, "ManipulatorProperties", NULL); + RNA_def_struct_ui_text(srna, "Manipulator Properties", "Input properties of an Manipulator"); + RNA_def_struct_refine_func(srna, "rna_ManipulatorProperties_refine"); + RNA_def_struct_idprops_func(srna, "rna_ManipulatorProperties_idprops"); + RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES); +} + +static void rna_def_manipulatorgroup(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + srna = RNA_def_struct(brna, "ManipulatorGroup", NULL); + RNA_def_struct_ui_text(srna, "ManipulatorGroup", "Storage of an operator being executed, or registered after execution"); + RNA_def_struct_sdna(srna, "wmManipulatorGroup"); + RNA_def_struct_refine_func(srna, "rna_ManipulatorGroup_refine"); +#ifdef WITH_PYTHON + RNA_def_struct_register_funcs( + srna, + "rna_ManipulatorGroup_register", + "rna_ManipulatorGroup_unregister", + "rna_ManipulatorGroup_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_ManipulatorGroup_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_ManipulatorGroup_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->mmap_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->mmap_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"); + + /* bl_options */ + static EnumPropertyItem manipulatorgroup_flag_items[] = { + {WM_MANIPULATORGROUPTYPE_3D, "3D", 0, "3D", + "Use in 3D viewport"}, + {WM_MANIPULATORGROUPTYPE_SCALE, "SCALE", 0, "Scale", + "Scale to respect zoom (otherwise zoom independent draw size)"}, + {WM_MANIPULATORGROUPTYPE_DEPTH_3D, "DEPTH_3D", 0, "Depth 3D", + "Supports culled depth by other objects in the view"}, + {WM_MANIPULATORGROUPTYPE_SELECT, "SELECT", 0, "Select", + "Supports selection"}, + {WM_MANIPULATORGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent", + ""}, + {WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL, "SHOW_MODAL_ALL", 0, "Show Modal All", + "Show all while interacting"}, + {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, manipulatorgroup_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 manipulator 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 manipulator 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 manipulators function for the manipulator 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); + + /* -------------------------------------------------------------------- */ + /* 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_ManipulatorGroup_name_get", "rna_ManipulatorGroup_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_ManipulatorGroup_has_reports_get", NULL); + RNA_def_property_ui_text(prop, "Has Reports", + "ManipulatorGroup has a set of reports (warnings and errors) from last execution"); + + + RNA_define_verify_sdna(0); /* not in sdna */ + + prop = RNA_def_property(srna, "manipulators", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "manipulators", NULL); + RNA_def_property_struct_type(prop, "Manipulator"); + RNA_def_property_collection_funcs( + prop, "rna_ManipulatorGroup_manipulators_begin", "rna_iterator_listbase_next", + "rna_iterator_listbase_end", "rna_iterator_listbase_get", + NULL, NULL, NULL, NULL); + + RNA_def_property_ui_text(prop, "Manipulators", "List of manipulators in the Manipulator Map"); + rna_def_manipulator(brna, prop); + rna_def_manipulators(brna, prop); + + RNA_define_verify_sdna(1); /* not in sdna */ + + RNA_api_manipulatorgroup(srna); +} + +void RNA_def_wm_manipulator(BlenderRNA *brna) +{ + rna_def_manipulatorgroup(brna); +} + +#endif /* RNA_RUNTIME */ diff --git a/source/blender/makesrna/intern/rna_wm_manipulator_api.c b/source/blender/makesrna/intern/rna_wm_manipulator_api.c new file mode 100644 index 00000000000..7c805512e0b --- /dev/null +++ b/source/blender/makesrna/intern/rna_wm_manipulator_api.c @@ -0,0 +1,254 @@ +/* + * ***** 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_manipulator_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_manipulator_library.h" + +static void rna_manipulator_draw_preset_box( + wmManipulator *mpr, float matrix[16], int select_id) +{ + ED_manipulator_draw_preset_box(mpr, (float (*)[4])matrix, select_id); +} + +static void rna_manipulator_draw_preset_arrow( + wmManipulator *mpr, float matrix[16], int axis, int select_id) +{ + ED_manipulator_draw_preset_arrow(mpr, (float (*)[4])matrix, axis, select_id); +} + +static void rna_manipulator_draw_preset_circle( + wmManipulator *mpr, float matrix[16], int axis, int select_id) +{ + ED_manipulator_draw_preset_circle(mpr, (float (*)[4])matrix, axis, select_id); +} + +static void rna_manipulator_draw_preset_facemap( + wmManipulator *mpr, struct bContext *C, struct Object *ob, int facemap, int select_id) +{ + struct Scene *scene = CTX_data_scene(C); + ED_manipulator_draw_preset_facemap(C, mpr, scene, ob, facemap, select_id); +} + +static void rna_manipulator_target_set_prop( + wmManipulator *mpr, ReportList *reports, const char *target_propname, + PointerRNA *ptr, const char *propname, int index) +{ + const wmManipulatorPropertyType *mpr_prop_type = + WM_manipulatortype_target_property_find(mpr->type, target_propname); + if (mpr_prop_type == NULL) { + BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s' not found", + mpr->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 (mpr_prop_type->data_type != RNA_property_type(prop)) { + const int manipulator_type_index = RNA_enum_from_value(rna_enum_property_type_items, mpr_prop_type->data_type); + const int prop_type_index = RNA_enum_from_value(rna_enum_property_type_items, RNA_property_type(prop)); + BLI_assert((manipulator_type_index != -1) && (prop_type_index == -1)); + + BKE_reportf(reports, RPT_ERROR, "Manipulator target '%s.%s' expects '%s', '%s.%s' is '%s'", + mpr->type->idname, target_propname, + rna_enum_property_type_items[manipulator_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 (mpr_prop_type->array_length != prop_array_length) { + BKE_reportf(reports, RPT_ERROR, + "Manipulator target property '%s.%s' expects an array of length %d, found %d", + mpr->type->idname, target_propname, + mpr_prop_type->array_length, + prop_array_length); + return; + } + } + } + else { + if (mpr_prop_type->array_length != 1) { + BKE_reportf(reports, RPT_ERROR, + "Manipulator target property '%s.%s' expects an array of length %d", + mpr->type->idname, target_propname, + mpr_prop_type->array_length); + return; + } + } + + if (index >= mpr_prop_type->array_length) { + BKE_reportf(reports, RPT_ERROR, "Manipulator target property '%s.%s', index %d must be below %d", + mpr->type->idname, target_propname, index, mpr_prop_type->array_length); + return; + } + + WM_manipulator_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); +} + +static PointerRNA rna_manipulator_target_set_operator( + wmManipulator *mpr, ReportList *reports, const char *opname) +{ + 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, "wmManipulatorProperties"); + } + + WM_manipulator_set_operator(mpr, ot, properties); + + return mpr->op_data.ptr; +} + +#else + +void RNA_api_manipulator(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_manipulator_draw_preset_box"); + RNA_def_function_ui_description(func, "Draw a box"); + parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_flag(parm, 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_manipulator_draw_preset_arrow"); + RNA_def_function_ui_description(func, "Draw a box"); + parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_flag(parm, 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_manipulator_draw_preset_circle"); + RNA_def_function_ui_description(func, "Draw a box"); + parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_flag(parm, 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_manipulator_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); + RNA_def_int(func, "facemap", 0, 0, INT_MAX, "Face map index", "", 0, INT_MAX); + RNA_def_int(func, "select_id", -1, -1, INT_MAX, "Zero when not selecting", "", -1, INT_MAX); + + + /* -------------------------------------------------------------------- */ + /* Property API */ + + /* note, 'target_set_handler' is defined in 'bpy_rna_manipulator.c' */ + func = RNA_def_function(srna, "target_set_prop", "rna_manipulator_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_manipulator_target_set_operator"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description( + func,"Operator to run when activating the manipulator " + "(overrides property targets)"); + parm = RNA_def_string(func, "operator", NULL, 0, "", "Target operator"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* 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); + +} + + +void RNA_api_manipulatorgroup(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..c09cc204bbc --- /dev/null +++ b/source/blender/makesrna/intern/rna_workspace.c @@ -0,0 +1,183 @@ +/* + * ***** 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 "WM_api.h" +#include "WM_types.h" + +#include "rna_internal.h" + + +#ifdef RNA_RUNTIME + +#include "BKE_global.h" + +#include "BLI_listbase.h" + +#include "DNA_object_types.h" +#include "DNA_screen_types.h" +#include "DNA_workspace_types.h" + +#include "RNA_access.h" + + +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); +} + +#ifdef USE_WORKSPACE_MODE + +static int rna_workspace_object_mode_get(PointerRNA *ptr) +{ + WorkSpace *workspace = ptr->data; + return (int)BKE_workspace_object_mode_get(workspace); +} + +static void rna_workspace_object_mode_set(PointerRNA *ptr, int value) +{ + WorkSpace *workspace = ptr->data; + BKE_workspace_object_mode_set(workspace, value); +} + +#endif /* USE_WORKSPACE_MODE */ + +void rna_workspace_transform_orientations_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + WorkSpace *workspace = ptr->id.data; + rna_iterator_listbase_begin(iter, BKE_workspace_transform_orientations_get(workspace), NULL); +} + +static PointerRNA rna_workspace_transform_orientations_item_get(CollectionPropertyIterator *iter) +{ + TransformOrientation *transform_orientation = rna_iterator_listbase_get(iter); + return rna_pointer_inherit_refine(&iter->parent, &RNA_TransformOrientation, transform_orientation); +} + +static PointerRNA rna_workspace_render_layer_get(PointerRNA *ptr) +{ + WorkSpace *workspace = ptr->data; + SceneLayer *render_layer = BKE_workspace_render_layer_get(workspace); + + /* XXX hmrf... lookup in getter... but how could we avoid it? */ + for (Scene *scene = G.main->scene.first; scene; scene = scene->id.next) { + if (BLI_findindex(&scene->render_layers, render_layer) != -1) { + PointerRNA scene_ptr; + + RNA_id_pointer_create(&scene->id, &scene_ptr); + return rna_pointer_inherit_refine(&scene_ptr, &RNA_SceneLayer, render_layer); + } + } + + return PointerRNA_NULL; +} + +static void rna_workspace_render_layer_set(PointerRNA *ptr, PointerRNA value) +{ + WorkSpace *workspace = ptr->data; + BKE_workspace_render_layer_set(workspace, value.data); +} + +#else /* RNA_RUNTIME */ + +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_RENDER_RESULT); + + 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"); + +#ifdef USE_WORKSPACE_MODE + prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_enum_object_mode_items); + RNA_def_property_enum_funcs(prop, "rna_workspace_object_mode_get", "rna_workspace_object_mode_set", NULL); + RNA_def_property_ui_text(prop, "Mode", "Object interaction mode"); +#endif + + prop = RNA_def_property(srna, "orientations", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "transform_orientations", NULL); + RNA_def_property_struct_type(prop, "TransformOrientation"); + RNA_def_property_collection_funcs(prop, "rna_workspace_transform_orientations_begin", NULL, NULL, + "rna_workspace_transform_orientations_item_get", NULL, NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Transform Orientations", ""); + + prop = RNA_def_property(srna, "render_layer", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "SceneLayer"); + RNA_def_property_pointer_funcs(prop, "rna_workspace_render_layer_get", "rna_workspace_render_layer_set", + NULL, NULL); + RNA_def_property_ui_text(prop, "Active Render Layer", "The active render layer used in this workspace"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL); +} + +static void rna_def_transform_orientation(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "TransformOrientation", NULL); + + 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_3x3); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_ui_text(prop, "Name", "Name of the custom transform orientation"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); +} + +void RNA_def_workspace(BlenderRNA *brna) +{ + rna_def_workspace(brna); + rna_def_transform_orientation(brna); +} + +#endif /* RNA_RUNTIME */ diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 7c1ef6b0d87..8e3e5b67a76 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -43,10 +43,11 @@ #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" @@ -88,7 +89,7 @@ static void rna_World_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR { 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 +98,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 +107,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); } @@ -119,6 +120,7 @@ static void rna_World_use_nodes_update(bContext *C, PointerRNA *ptr) ED_node_shader_default(C, &wrld->id); rna_World_update(CTX_data_main(C), CTX_data_scene(C), ptr); + rna_World_draw_update(CTX_data_main(C), CTX_data_scene(C), ptr); } #else |