diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-16 14:50:11 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-16 14:50:11 +0300 |
commit | 6cd3ebfc9fa4838a74192f2e5cc82b5d5d2e6fe7 (patch) | |
tree | 546c8e187f3b5185f019153ee083fa246b698436 /source/blender/makesrna/intern | |
parent | 97a50e78ca88b4ffe180bc6567e5ed0358239efe (diff) | |
parent | 5684ad80723454f0d910aad3fa48240da19c4e3b (diff) |
Merge branch 'master' into alembic_pointcache
Conflicts:
release/scripts/addons
source/blender/blenkernel/intern/pointcache.c
source/blender/blenloader/intern/versioning_270.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesrna/intern/rna_modifier.c
source/blender/modifiers/MOD_modifiertypes.h
source/blender/modifiers/intern/MOD_collision.c
source/blender/modifiers/intern/MOD_util.c
Diffstat (limited to 'source/blender/makesrna/intern')
38 files changed, 1405 insertions, 199 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 40d752a3ed2..0c1701f6089 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -35,7 +35,6 @@ #include "BLI_utildefines.h" -#include "RNA_access.h" #include "RNA_define.h" #include "RNA_types.h" @@ -47,6 +46,14 @@ # endif #endif +/* stub for BLI_abort() */ +#ifndef NDEBUG +void BLI_system_backtrace(FILE *fp) +{ + (void)fp; +} +#endif + /* Replace if different */ #define TMP_EXT ".tmp" @@ -1621,7 +1628,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop; int i; - if (eprop->item) { + if (eprop->item && eprop->totitem) { fprintf(f, "enum {\n"); for (i = 0; i < eprop->totitem; i++) @@ -3676,7 +3683,7 @@ static const char *cpp_classes = "" " int length;\n" "\n" " DynamicArray() : data(NULL), length(0) {}\n" -" DynamicArray(int new_length) : data(NULL), length(new_length) { data = (float *)malloc(sizeof(T) * new_length); }\n" +" DynamicArray(int new_length) : data(NULL), length(new_length) { data = (T *)malloc(sizeof(T) * new_length); }\n" " DynamicArray(const DynamicArray<T>& other) { copy_from(other); }\n" " const DynamicArray<T>& operator = (const DynamicArray<T>& other) { copy_from(other); return *this; }\n" "\n" @@ -3687,7 +3694,7 @@ static const char *cpp_classes = "" "protected:\n" " void copy_from(const DynamicArray<T>& other) {\n" " if (data) free(data);\n" -" data = (float *)malloc(sizeof(T) * other.length);\n" +" data = (T *)malloc(sizeof(T) * other.length);\n" " memcpy(data, other.data, sizeof(T) * other.length);\n" " length = other.length;\n" " }\n" diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 51d81295f8c..009e3799c49 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -64,6 +64,7 @@ EnumPropertyItem id_type_items[] = { {ID_MA, "MATERIAL", ICON_MATERIAL_DATA, "Material", ""}, {ID_MB, "META", ICON_META_DATA, "MetaBall", ""}, {ID_ME, "MESH", ICON_MESH_DATA, "Mesh", ""}, + {ID_MC, "MOVIECLIP", ICON_CLIP, "MovieClip", ""}, {ID_NT, "NODETREE", ICON_NODETREE, "NodeTree", ""}, {ID_OB, "OBJECT", ICON_OBJECT_DATA, "Object", ""}, {ID_PC, "PAINTCURVE", ICON_CURVE_BEZCURVE, "Paint Curve", ""}, @@ -71,12 +72,12 @@ EnumPropertyItem id_type_items[] = { {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""}, {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""}, {ID_SCR, "SCREEN", ICON_SPLITSCREEN, "Screen", ""}, + {ID_SO, "SOUND", ICON_PLAY_AUDIO, "Sound", ""}, {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""}, - {ID_SO, "SOUND", ICON_PLAY_AUDIO, "Sound", ""}, {ID_TXT, "TEXT", ICON_TEXT, "Text", ""}, {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""}, - {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""}, {ID_WM, "WINDOWMANAGER", ICON_FULLSCREEN, "Window Manager", ""}, + {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""}, {0, NULL, 0, NULL, NULL} }; @@ -141,23 +142,23 @@ short RNA_type_to_ID_code(StructRNA *type) 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_NodeTree)) return ID_NT; + 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_Speaker)) return ID_SPK; if (RNA_struct_is_a(type, &RNA_Sound)) return ID_SO; - if (RNA_struct_is_a(type, &RNA_Text)) return ID_TXT; + 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; - if (RNA_struct_is_a(type, &RNA_MovieClip)) return ID_MC; - if (RNA_struct_is_a(type, &RNA_Mask)) return ID_MSK; - if (RNA_struct_is_a(type, &RNA_Palette)) return ID_PAL; - if (RNA_struct_is_a(type, &RNA_PaintCurve)) return ID_PC; return 0; } @@ -180,23 +181,23 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_LT: return &RNA_Lattice; case ID_MA: return &RNA_Material; case ID_MB: return &RNA_MetaBall; - case ID_NT: return &RNA_NodeTree; + case ID_MC: return &RNA_MovieClip; case ID_ME: return &RNA_Mesh; + case ID_MSK: return &RNA_Mask; + case ID_NT: return &RNA_NodeTree; case ID_OB: return &RNA_Object; case ID_PA: return &RNA_ParticleSettings; + case ID_PAL: return &RNA_Palette; + case ID_PC: return &RNA_PaintCurve; case ID_SCE: return &RNA_Scene; case ID_SCR: return &RNA_Screen; - case ID_SPK: return &RNA_Speaker; case ID_SO: return &RNA_Sound; - case ID_TXT: return &RNA_Text; + case ID_SPK: return &RNA_Speaker; case ID_TE: return &RNA_Texture; + case ID_TXT: return &RNA_Text; case ID_VF: return &RNA_VectorFont; - case ID_WO: return &RNA_World; case ID_WM: return &RNA_WindowManager; - case ID_MC: return &RNA_MovieClip; - case ID_MSK: return &RNA_Mask; - case ID_PAL: return &RNA_Palette; - case ID_PC: return &RNA_PaintCurve; + case ID_WO: return &RNA_World; default: return &RNA_ID; } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index e681552103b..09b970fe7fd 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -466,7 +466,7 @@ static const char *rna_ensure_property_identifier(const PropertyRNA *prop) if (prop->magic == RNA_MAGIC) return prop->identifier; else - return ((IDProperty *)prop)->name; + return ((const IDProperty *)prop)->name; } static const char *rna_ensure_property_description(PropertyRNA *prop) @@ -499,7 +499,7 @@ static const char *rna_ensure_property_name(const PropertyRNA *prop) if (prop->magic == RNA_MAGIC) name = prop->name; else - name = ((IDProperty *)prop)->name; + name = ((const IDProperty *)prop)->name; return name; } @@ -4284,7 +4284,7 @@ char *RNA_path_append(const char *path, PointerRNA *UNUSED(ptr), PropertyRNA *pr /* add .identifier */ if (path) { - BLI_dynstr_append(dynstr, (char *)path); + BLI_dynstr_append(dynstr, path); if (*path) BLI_dynstr_append(dynstr, "."); } diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 8d7a05896a3..e256d145016 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -462,6 +462,12 @@ static void rna_def_dopesheet(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Display Speaker", "Include visualization of speaker related animation data"); RNA_def_property_ui_icon(prop, ICON_SPEAKER, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "show_gpencil", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOGPENCIL); + RNA_def_property_ui_text(prop, "Display Grease Pencil", "Include visualization of Grease Pencil related animation data and frames"); + RNA_def_property_ui_icon(prop, ICON_GREASEPENCIL, 0); + RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } static void rna_def_action_group(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 0114ffa35c0..6792dd7e5f8 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -55,16 +55,16 @@ static EnumPropertyItem actuator_type_items[] = { {ACT_2DFILTER, "FILTER_2D", 0, "Filter 2D", ""}, {ACT_GAME, "GAME", 0, "Game", ""}, {ACT_MESSAGE, "MESSAGE", 0, "Message", ""}, - {ACT_MOUSE, "MOUSE", 0, "Mouse", ""}, {ACT_OBJECT, "MOTION", 0, "Motion", ""}, + {ACT_MOUSE, "MOUSE", 0, "Mouse", ""}, {ACT_PARENT, "PARENT", 0, "Parent", ""}, {ACT_PROPERTY, "PROPERTY", 0, "Property", ""}, {ACT_RANDOM, "RANDOM", 0, "Random", ""}, {ACT_SCENE, "SCENE", 0, "Scene", ""}, {ACT_SOUND, "SOUND", 0, "Sound", ""}, {ACT_STATE, "STATE", 0, "State", ""}, - {ACT_VISIBILITY, "VISIBILITY", 0, "Visibility", ""}, {ACT_STEERING, "STEERING", 0, "Steering", ""}, + {ACT_VISIBILITY, "VISIBILITY", 0, "Visibility", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index bbc2e0572fa..81ba3a9066f 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -194,14 +194,20 @@ static int rna_SculptToolCapabilities_has_random_texture_angle_get(PointerRNA *p SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } -static int rna_BrushCapabilities_has_random_texture_angle_get(PointerRNA *ptr) +static int rna_TextureCapabilities_has_random_texture_angle_get(PointerRNA *ptr) { - Brush *br = (Brush *)ptr->data; - return (ELEM(br->mtex.brush_map_mode, + MTex *mtex = (MTex *)ptr->data; + return ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_VIEW, MTEX_MAP_MODE_AREA, - MTEX_MAP_MODE_RANDOM) && - !(br->flag & BRUSH_ANCHORED)); + MTEX_MAP_MODE_RANDOM); +} + + +static int rna_BrushCapabilities_has_random_texture_angle_get(PointerRNA *ptr) +{ + Brush *br = (Brush *)ptr->data; + return !(br->flag & BRUSH_ANCHORED); } static int rna_SculptToolCapabilities_has_sculpt_plane_get(PointerRNA *ptr) @@ -270,15 +276,10 @@ static int rna_SculptToolCapabilities_has_strength_pressure_get(PointerRNA *ptr) return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK); } -static int rna_BrushCapabilities_has_texture_angle_get(PointerRNA *ptr) +static int rna_TextureCapabilities_has_texture_angle_get(PointerRNA *ptr) { - Brush *br = (Brush *)ptr->data; - return ELEM(br->mtex.brush_map_mode, - MTEX_MAP_MODE_VIEW, - MTEX_MAP_MODE_AREA, - MTEX_MAP_MODE_TILED, - MTEX_MAP_MODE_STENCIL, - MTEX_MAP_MODE_RANDOM); + MTex *mtex = (MTex *)ptr->data; + return mtex->brush_map_mode != MTEX_MAP_MODE_3D; } static int rna_SculptToolCapabilities_has_gravity_get(PointerRNA *ptr) @@ -287,10 +288,10 @@ static int rna_SculptToolCapabilities_has_gravity_get(PointerRNA *ptr) return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH); } -static int rna_BrushCapabilities_has_texture_angle_source_get(PointerRNA *ptr) +static int rna_TextureCapabilities_has_texture_angle_source_get(PointerRNA *ptr) { - Brush *br = (Brush *)ptr->data; - return ELEM(br->mtex.brush_map_mode, + MTex *mtex = (MTex *)ptr->data; + return ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_VIEW, MTEX_MAP_MODE_AREA, MTEX_MAP_MODE_RANDOM); @@ -627,6 +628,15 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; +#define TEXTURE_CAPABILITY(prop_name_, ui_name_) \ + prop = RNA_def_property(srna, #prop_name_, \ + PROP_BOOLEAN, PROP_NONE); \ + RNA_def_property_clear_flag(prop, PROP_EDITABLE); \ + RNA_def_property_boolean_funcs(prop, "rna_TextureCapabilities_" \ + #prop_name_ "_get", NULL); \ + RNA_def_property_ui_text(prop, ui_name_, NULL) + + srna = RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot"); RNA_def_struct_sdna(srna, "MTex"); RNA_def_struct_ui_text(srna, "Brush Texture Slot", "Texture slot for textures in a Brush datablock"); @@ -654,6 +664,25 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_mask_paint_map_mode_items); RNA_def_property_ui_text(prop, "Mode", ""); RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_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_update(prop, 0, "rna_TextureSlot_brush_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_update(prop, 0, "rna_TextureSlot_brush_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_update(prop, 0, "rna_TextureSlot_brush_update"); + + TEXTURE_CAPABILITY(has_texture_angle_source, "Has Texture Angle Source"); + TEXTURE_CAPABILITY(has_random_texture_angle, "Has Random Texture Angle"); + TEXTURE_CAPABILITY(has_texture_angle, "Has Texture Angle Source"); } static void rna_def_sculpt_capabilities(BlenderRNA *brna) @@ -717,8 +746,6 @@ static void rna_def_brush_capabilities(BlenderRNA *brna) BRUSH_CAPABILITY(has_overlay, "Has Overlay"); BRUSH_CAPABILITY(has_random_texture_angle, "Has Random Texture Angle"); - BRUSH_CAPABILITY(has_texture_angle, "Has Texture Angle"); - BRUSH_CAPABILITY(has_texture_angle_source, "Has Texture Angle Source"); BRUSH_CAPABILITY(has_spacing, "Has Spacing"); BRUSH_CAPABILITY(has_smooth_stroke, "Has Smooth Stroke"); @@ -786,19 +813,6 @@ static void rna_def_brush(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem texture_angle_source_items[] = { - {0, "USER", 0, "User", "Rotate the brush texture by given angle"}, - {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"}, - {BRUSH_RANDOM_ROTATION, "RANDOM", 0, "Random", "Rotate the brush texture at random"}, - {0, NULL, 0, NULL, NULL} - }; - - static EnumPropertyItem texture_angle_source_no_random_items[] = { - {0, "USER", 0, "User", "Rotate the brush texture by given angle"}, - {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem brush_sculpt_plane_items[] = { {SCULPT_DISP_DIR_AREA, "AREA", 0, "Area Plane", ""}, {SCULPT_DISP_DIR_VIEW, "VIEW", 0, "View Plane", ""}, @@ -881,18 +895,6 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Stroke Method", ""); RNA_def_property_update(prop, 0, "rna_Brush_stroke_update"); - prop = RNA_def_property(srna, "texture_angle_source_random", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, texture_angle_source_items); - RNA_def_property_ui_text(prop, "Texture Angle Source", ""); - RNA_def_property_update(prop, 0, "rna_Brush_update"); - - prop = RNA_def_property(srna, "texture_angle_source_no_random", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, texture_angle_source_no_random_items); - RNA_def_property_ui_text(prop, "Texture Angle Source", ""); - RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "sculpt_plane", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, brush_sculpt_plane_items); RNA_def_property_ui_text(prop, "Sculpt Plane", ""); @@ -1158,22 +1160,12 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Inverse Smooth Pressure", "Lighter pressure causes more smoothing to be applied"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_rake", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RAKE); - RNA_def_property_ui_text(prop, "Rake", "Rotate the brush texture to match the stroke direction"); - RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_relative_jitter", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BRUSH_ABSOLUTE_JITTER); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true); RNA_def_property_ui_text(prop, "Absolute Jitter", "Jittering happens in screen space, not relative to brush size"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_random_rotation", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RANDOM_ROTATION); - RNA_def_property_ui_text(prop, "Random Rotation", "Rotate the brush texture at random"); - RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_plane_trim", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_PLANE_TRIM); RNA_def_property_ui_text(prop, "Use Plane Trim", "Enable Plane Trim"); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index fa2a3258d1a..37201eca5f6 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -614,6 +614,10 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain) IMB_free_anim(seq->anim); seq->anim = NULL; } + if (seq->strip->proxy && seq->strip->proxy->anim) { + IMB_free_anim(seq->strip->proxy->anim); + seq->strip->proxy->anim = NULL; + } BKE_sequence_invalidate_cache(scene, seq); BKE_sequencer_preprocessed_cache_cleanup_sequence(seq); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 77355dbad0e..b6845b1df2e 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1388,7 +1388,7 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna) prop = RNA_def_property(srna, "bulge_smooth", PROP_FLOAT, PROP_FACTOR); RNA_def_property_range(prop, 0.0, 1.0f); - RNA_def_property_ui_text(prop, "Volume Variation Smoothness", ""); + RNA_def_property_ui_text(prop, "Volume Variation Smoothness", "Strength of volume stretching clamping"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); } @@ -2272,8 +2272,10 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna) {CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't scale the X and Z axes (Default)"}, {CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "BONE_ORIGINAL", 0, "Bone Original", "Use the original scaling of the bones"}, + {CONSTRAINT_SPLINEIK_XZS_INVERSE, "INVERSE_PRESERVE", 0, "Inverse Scale", + "Scale of the X and Z axes is the inverse of the Y-Scale"}, {CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC, "VOLUME_PRESERVE", 0, "Volume Preservation", - "Scale of the X and Z axes is the inverse of the Y-Scale"}, + "Scale of the X and Z axes are adjusted to preserve the volume of the bones"}, {0, NULL, 0, NULL, NULL} }; @@ -2333,12 +2335,44 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna) "on top of XZ Scale mode"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + /* xz scaling mode */ prop = RNA_def_property(srna, "xz_scale_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "xzScaleMode"); RNA_def_property_enum_items(prop, splineik_xz_scale_mode); RNA_def_property_ui_text(prop, "XZ Scale Mode", "Method used for determining the scaling of the X and Z axes of the bones"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + /* volume presevation for "volumetric" scale mode */ + prop = RNA_def_property(srna, "bulge", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0, 100.f); + RNA_def_property_ui_text(prop, "Volume Variation", "Factor between volume variation and stretching"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "use_bulge_min", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_USE_BULGE_MIN); + RNA_def_property_ui_text(prop, "Use Volume Variation Minimum", "Use lower limit for volume variation"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "use_bulge_max", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_USE_BULGE_MAX); + RNA_def_property_ui_text(prop, "Use Volume Variation Maximum", "Use upper limit for volume variation"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "bulge_min", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0, 1.0f); + RNA_def_property_ui_text(prop, "Volume Variation Minimum", "Minimum volume stretching factor"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "bulge_max", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 1.0, 100.0f); + RNA_def_property_ui_text(prop, "Volume Variation Maximum", "Maximum volume stretching factor"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "bulge_smooth", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, 0.0, 1.0f); + RNA_def_property_ui_text(prop, "Volume Variation Smoothness", "Strength of volume stretching clamping"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_pivot(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 6668ce812cf..54c08009792 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -639,7 +639,7 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) if (srna->flag & STRUCT_RUNTIME) rna_freelinkN(&brna->structs, srna); #else - (void)brna, (void)srna; + UNUSED_VARS(brna, srna); #endif } diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index c4677710676..6b61b37ce5c 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -44,6 +44,8 @@ #ifdef RNA_RUNTIME +#include "BLI_math.h" + #include "WM_api.h" #include "BKE_gpencil.h" @@ -53,6 +55,16 @@ static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } +static char *rna_GPencilLayer_path(PointerRNA *ptr) +{ + bGPDlayer *gpl = (bGPDlayer *)ptr->data; + char name_esc[sizeof(gpl->info) * 2]; + + BLI_strescape(name_esc, gpl->info, sizeof(name_esc)); + + return BLI_sprintfN("layers[\"%s\"]", name_esc); +} + static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr) { bGPDlayer *gpl = (bGPDlayer *)ptr->data; @@ -64,9 +76,54 @@ static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr) return 1; } -static PointerRNA rna_GPencil_active_layer_get(PointerRNA *ptr) +static void rna_GPencilLayer_line_width_range(PointerRNA *ptr, int *min, int *max, + int *softmin, int *softmax) { + bGPDlayer *gpl = ptr->data; + + /* The restrictions on max width here are due to OpenGL on Windows not supporting + * any widths greater than 10 (for driver-drawn) strokes/points. + * + * Although most of our 2D strokes also don't suffer from this restriction, + * it's relatively hard to test for that. So, for now, only volumetric strokes + * get to be larger... + */ + if (gpl->flag & GP_LAYER_VOLUMETRIC) { + *min = 1; + *max = 300; + + *softmin = 1; + *softmax = 100; + } + else { + *min = 1; + *max = 10; + + *softmin = 1; + *softmax = 10; + } +} +static int rna_GPencilLayer_is_stroke_visible_get(PointerRNA *ptr) +{ + /* see drawgpencil.c -> gp_draw_data_layers() for more details + * about this limit for showing/not showing + */ + bGPDlayer *gpl = (bGPDlayer *)ptr->data; + return (gpl->color[3] > 0.001f); +} + +static int rna_GPencilLayer_is_fill_visible_get(PointerRNA *ptr) +{ + /* see drawgpencil.c -> gp_draw_data_layers() for more details + * about this limit for showing/not showing + */ + bGPDlayer *gpl = (bGPDlayer *)ptr->data; + return (gpl->fill[3] > 0.001f); +} + +static PointerRNA rna_GPencil_active_layer_get(PointerRNA *ptr) +{ bGPdata *gpd = ptr->id.data; if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */ @@ -106,6 +163,33 @@ static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value) } } +static int rna_GPencil_active_layer_index_get(PointerRNA *ptr) +{ + bGPdata *gpd = (bGPdata *)ptr->id.data; + bGPDlayer *gpl = gpencil_layer_getactive(gpd); + + return BLI_findindex(&gpd->layers, gpl); +} + +static void rna_GPencil_active_layer_index_set(PointerRNA *ptr, int value) +{ + bGPdata *gpd = (bGPdata *)ptr->id.data; + bGPDlayer *gpl = BLI_findlink(&gpd->layers, value); + + gpencil_layer_setactive(gpd, gpl); +} + +static void rna_GPencil_active_layer_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) +{ + bGPdata *gpd = (bGPdata *)ptr->id.data; + + *min = 0; + *max = max_ii(0, BLI_listbase_count(&gpd->layers) - 1); + + *softmin = *min; + *softmax = *max; +} + static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) { bGPdata *gpd = ptr->id.data; @@ -117,6 +201,63 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) BLI_uniquename(&gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); } + +static bGPDstroke *rna_GPencil_stroke_point_find_stroke(const bGPdata *gpd, const bGPDspoint *pt, bGPDlayer **r_gpl, bGPDframe **r_gpf) +{ + bGPDlayer *gpl; + bGPDstroke *gps; + + /* sanity checks */ + if (ELEM(NULL, gpd, pt)) { + return NULL; + } + + if (r_gpl) *r_gpl = NULL; + if (r_gpf) *r_gpf = NULL; + + /* there's no faster alternative than just looping over everything... */ + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { + if (gpl->actframe) { + for (gps = gpl->actframe->strokes.first; gps; gps = gps->next) { + if ((pt >= gps->points) && (pt < &gps->points[gps->totpoints])) { + /* found it */ + if (r_gpl) *r_gpl = gpl; + if (r_gpf) *r_gpf = gpl->actframe; + + return gps; + } + } + } + } + + /* didn't find it */ + return NULL; +} + +static void rna_GPencil_stroke_point_select_set(PointerRNA *ptr, const int value) +{ + bGPdata *gpd = ptr->id.data; + bGPDspoint *pt = ptr->data; + bGPDstroke *gps = NULL; + + /* Ensure that corresponding stroke is set + * - Since we don't have direct access, we're going to have to search + * - We don't apply selection value unless we can find the corresponding + * stroke, so that they don't get out of sync + */ + gps = rna_GPencil_stroke_point_find_stroke(gpd, pt, NULL, NULL); + if (gps) { + /* Set the new selection state for the point */ + if (value) + pt->flag |= GP_SPOINT_SELECT; + else + pt->flag &= ~GP_SPOINT_SELECT; + + /* Check if the stroke should be selected or not... */ + gpencil_stroke_sync_selection(gps); + } +} + static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count) { if (count > 0) { @@ -180,6 +321,27 @@ static void rna_GPencil_stroke_remove(bGPDframe *frame, ReportList *reports, Poi WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } +static void rna_GPencil_stroke_select_set(PointerRNA *ptr, const int value) +{ + bGPDstroke *gps = ptr->data; + bGPDspoint *pt; + int i; + + /* set new value */ + if (value) + gps->flag |= GP_STROKE_SELECT; + else + gps->flag &= ~GP_STROKE_SELECT; + + /* ensure that the stroke's points are selected in the same way */ + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { + if (value) + pt->flag |= GP_SPOINT_SELECT; + else + pt->flag &= ~GP_SPOINT_SELECT; + } +} + static bGPDframe *rna_GPencil_frame_new(bGPDlayer *layer, ReportList *reports, int frame_number) { bGPDframe *frame; @@ -291,6 +453,12 @@ static void rna_def_gpencil_stroke_point(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Pressure", "Pressure of tablet at point when drawing it"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SPOINT_SELECT); + RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_stroke_point_select_set"); + RNA_def_property_ui_text(prop, "Select", "Point is selected for viewport editing"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); } static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -338,12 +506,19 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna) RNA_def_property_struct_type(prop, "GPencilStrokePoint"); RNA_def_property_ui_text(prop, "Stroke Points", "Stroke data points"); rna_def_gpencil_stroke_points_api(brna, prop); - + + /* Settings */ prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, stroke_draw_mode_items); RNA_def_property_ui_text(prop, "Draw Mode", ""); RNA_def_property_update(prop, 0, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_SELECT); + RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencil_stroke_select_set"); + RNA_def_property_ui_text(prop, "Select", "Stroke is selected for viewport editing"); + RNA_def_property_update(prop, 0, "rna_GPencil_update"); } static void rna_def_gpencil_strokes_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -455,6 +630,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) srna = RNA_def_struct(brna, "GPencilLayer", NULL); RNA_def_struct_sdna(srna, "bGPDlayer"); RNA_def_struct_ui_text(srna, "Grease Pencil Layer", "Collection of related sketches"); + RNA_def_struct_path_func(srna, "rna_GPencilLayer_path"); /* Name */ prop = RNA_def_property(srna, "info", PROP_STRING, PROP_NONE); @@ -477,7 +653,14 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_editable_func(prop, "rna_GPencilLayer_active_frame_editable"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - /* Drawing Color */ + /* Draw Style */ + // TODO: replace these with a "draw type" combo (i.e. strokes only, filled strokes, strokes + fills, volumetric)? + prop = RNA_def_property(srna, "use_volumetric_strokes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_VOLUMETRIC); + RNA_def_property_ui_text(prop, "Volumetric Strokes", "Draw strokes as a series of circular blobs, resulting in a volumetric effect"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + /* Stroke Drawing Color */ prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, 0.0f, 1.0f); @@ -486,14 +669,29 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "color[3]"); - RNA_def_property_range(prop, 0.3, 1.0f); + RNA_def_property_range(prop, 0.0, 1.0f); RNA_def_property_ui_text(prop, "Opacity", "Layer Opacity"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* Fill Drawing Color */ + prop = RNA_def_property(srna, "fill_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "fill"); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region bounded by each stroke"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "fill_alpha", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fill[3]"); + RNA_def_property_range(prop, 0.0, 1.0f); + RNA_def_property_ui_text(prop, "Fill Opacity", "Opacity for filling region bounded by each stroke"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* Line Thickness */ prop = RNA_def_property(srna, "line_width", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "thickness"); - RNA_def_property_range(prop, 1, 10); + //RNA_def_property_range(prop, 1, 10); /* 10 px limit comes from Windows OpenGL limits for natively-drawn strokes */ + RNA_def_property_int_funcs(prop, NULL, NULL, "rna_GPencilLayer_line_width_range"); RNA_def_property_ui_text(prop, "Thickness", "Thickness of strokes (in pixels)"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); @@ -503,29 +701,59 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Onion Skinning", "Ghost frames on either side of frame"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - prop = RNA_def_property(srna, "ghost_range_max", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "ghost_before_range", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gstep"); RNA_def_property_range(prop, 0, 120); - RNA_def_property_ui_text(prop, "Max Ghost Range", - "Maximum number of frames on either side of the active frame to show " - "(0 = show the 'first' available sketch on either side)"); + RNA_def_property_ui_text(prop, "Frames Before", + "Maximum number of frames to show before current frame " + "(0 = show only the previous sketch)"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "gstep_next"); + RNA_def_property_range(prop, 0, 120); + RNA_def_property_ui_text(prop, "Frames After", + "Maximum number of frames to show after current frame " + "(0 = show only the next sketch)"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "use_ghost_custom_colors", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_GHOST_PREVCOL | GP_LAYER_GHOST_NEXTCOL); + RNA_def_property_ui_text(prop, "Use Custom Ghost Colors", "Use custom colors for ghost frames"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "before_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gcolor_prev"); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "after_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gcolor_next"); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* Flags */ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); RNA_def_property_ui_text(prop, "Hide", "Set layer Visibility"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_LOCKED); + RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_ui_text(prop, "Locked", "Protect layer from further editing and/or frame changes"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "lock_frame", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_FRAMELOCK); + RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_ui_text(prop, "Frame Locked", "Lock current frame displayed by layer"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* expose as layers.active */ #if 0 @@ -539,7 +767,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_SELECT); RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the Dope Sheet"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* XXX keep this option? */ prop = RNA_def_property(srna, "show_points", PROP_BOOLEAN, PROP_NONE); @@ -554,6 +782,17 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + /* Read-only state props (for simpler UI code) */ + prop = RNA_def_property(srna, "is_stroke_visible", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_GPencilLayer_is_stroke_visible_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Is Stroke Visible", "True when opacity of stroke is set high enough to be visible"); + + prop = RNA_def_property(srna, "is_fill_visible", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_GPencilLayer_is_fill_visible_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Is Fill Visible", "True when opacity of fill is set high enough to be visible"); + /* Layers API */ func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear"); RNA_def_function_ui_description(func, "Remove all the grease pencil layer data"); @@ -592,6 +831,14 @@ static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_pointer_funcs(prop, "rna_GPencil_active_layer_get", "rna_GPencil_active_layer_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active Layer", "Active grease pencil layer"); + + prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); + + RNA_def_property_int_funcs(prop, + "rna_GPencil_active_layer_index_get", + "rna_GPencil_active_layer_index_set", + "rna_GPencil_active_layer_index_range"); + RNA_def_property_ui_text(prop, "Active Layer Index", "Index of active grease pencil layer"); } static void rna_def_gpencil_data(BlenderRNA *brna) @@ -620,6 +867,9 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Layers", ""); rna_def_gpencil_layers_api(brna, prop); + /* Animation Data */ + rna_def_animdata_common(srna); + /* Flags */ prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); @@ -631,7 +881,13 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_DEPTH_STROKE_ENDPOINTS); RNA_def_property_ui_text(prop, "Only Endpoints", "Only use the first and last parts of the stroke for snapping"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - + + prop = RNA_def_property(srna, "use_stroke_edit_mode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_STROKE_EDITMODE); + RNA_def_property_ui_text(prop, "Stroke Edit Mode", "Enable alternative keymap to make editing stroke points easier"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, "rna_GPencil_update"); + + /* API Functions */ func = RNA_def_function(srna, "clear", "rna_GPencil_clear"); RNA_def_function_ui_description(func, "Remove all the grease pencil data"); } diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 141de511a09..b1935b34251 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -292,11 +292,21 @@ static int rna_Image_depth_get(PointerRNA *ptr) static int rna_Image_frame_duration_get(PointerRNA *ptr) { - Image *im = (Image *)ptr->data; + Image *ima = ptr->id.data; + int duration = 1; + + if (!ima->anim) { + /* acquire ensures ima->anim is set, if possible! */ + void *lock; + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); + BKE_image_release_ibuf(ima, ibuf, lock); + } + + if (ima->anim) { + duration = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); + } - if (im->anim) - return IMB_anim_get_duration(im->anim, IMB_TC_RECORD_RUN); - return 1; + return duration; } static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) @@ -665,7 +675,7 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - prop = RNA_def_property(srna, "generated_color", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "generated_color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "gen_color"); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Color", "Fill color for the generated image"); diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index d9a59c4dc55..90f90ea8632 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -74,7 +74,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports } if (scene) { - ImageUser iuser; + ImageUser iuser = {0}; void *lock; iuser.scene = scene; diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 2b1df7a713e..2c00b70d1a9 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -288,6 +288,7 @@ void RNA_api_ui_layout(struct StructRNA *srna); void RNA_api_window(struct StructRNA *srna); void RNA_api_wm(struct StructRNA *srna); void RNA_api_space_node(struct StructRNA *srna); +void RNA_api_space_text(struct StructRNA *srna); void RNA_api_region_view3d(struct StructRNA *srna); void RNA_api_sensor(struct StructRNA *srna); void RNA_api_controller(struct StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 7d10511d1c4..8a3626de81d 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -675,13 +675,6 @@ static void rna_def_key(BlenderRNA *brna) RNA_def_property_range(prop, MINFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Evaluation Time", "Evaluation time for absolute shape keys"); RNA_def_property_update(prop, 0, "rna_Key_update_data"); - - prop = RNA_def_property(srna, "slurph", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "slurph"); - RNA_def_property_range(prop, -500, 500); - RNA_def_property_ui_text(prop, "Slurph", - "Create a delay (in frames) in applying key positions, first vertex goes first"); - RNA_def_property_update(prop, 0, "rna_Key_update_data"); } void RNA_def_key(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index b0b99dcd2ca..3d6eab2bc88 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1415,8 +1415,6 @@ static char *rna_FaceCustomData_data_path(PointerRNA *ptr, const char *collectio } - - static char *rna_MeshUVLoop_path(PointerRNA *ptr) { return rna_LoopCustomData_data_path(ptr, "uv_layers", CD_MLOOPUV); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 5c63b95eaaf..d8d27a06bb5 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -43,10 +43,15 @@ #include "BLF_translation.h" #include "BKE_animsys.h" +#include "BKE_data_transfer.h" +#include "BKE_DerivedMesh.h" #include "BKE_dynamicpaint.h" +#include "BKE_mesh_mapping.h" +#include "BKE_mesh_remap.h" #include "BKE_multires.h" #include "BKE_smoke.h" /* For smokeModifier_free & smokeModifier_createType */ +#include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -57,6 +62,7 @@ EnumPropertyItem modifier_type_items[] = { {0, "", 0, N_("Modify"), ""}, + {eModifierType_DataTransfer, "DATA_TRANSFER", ICON_MOD_DATA_TRANSFER, "Data Transfer", ""}, {eModifierType_MeshCache, "MESH_CACHE", ICON_MOD_MESHDEFORM, "Mesh Cache", ""}, {eModifierType_PointCache, "POINT_CACHE", ICON_MOD_MESHDEFORM, "Point Cache", ""}, {eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV Project", ""}, @@ -128,9 +134,114 @@ EnumPropertyItem modifier_triangulate_ngon_method_items[] = { {0, NULL, 0, NULL, NULL} }; +/* ***** Data Transfer ***** */ + +EnumPropertyItem DT_method_vertex_items[] = { + {MREMAP_MODE_TOPOLOGY, "TOPOLOGY", 0, "Topology", + "Copy from identical topology meshes"}, + {MREMAP_MODE_VERT_NEAREST, "NEAREST", 0, "Nearest vertex", + "Copy from closest vertex"}, + {MREMAP_MODE_VERT_EDGE_NEAREST, "EDGE_NEAREST", 0, "Nearest Edge Vertex", + "Copy from closest vertex of closest edge"}, + {MREMAP_MODE_VERT_EDGEINTERP_NEAREST, "EDGEINTERP_NEAREST", 0, "Nearest Edge Interpolated", + "Copy from interpolated values of vertices from closest point on closest edge"}, + {MREMAP_MODE_VERT_POLY_NEAREST, "POLY_NEAREST", 0, "Nearest Face Vertex", + "Copy from closest vertex of closest face"}, + {MREMAP_MODE_VERT_POLYINTERP_NEAREST, "POLYINTERP_NEAREST", 0, "Nearest Face Interpolated", + "Copy from interpolated values of vertices from closest point on closest face"}, + {MREMAP_MODE_VERT_POLYINTERP_VNORPROJ, "POLYINTERP_VNORPROJ", 0, "Projected Face Interpolated", + "Copy from interpolated values of vertices from point on closest face hit by normal-projection"}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem DT_method_edge_items[] = { + {MREMAP_MODE_TOPOLOGY, "TOPOLOGY", 0, "Topology", + "Copy from identical topology meshes"}, + {MREMAP_MODE_EDGE_VERT_NEAREST, "VERT_NEAREST", 0, "Nearest Vertices", + "Copy from most similar edge (edge which vertices are the closest of destination edge’s ones)"}, + {MREMAP_MODE_EDGE_NEAREST, "NEAREST", 0, "Nearest Edge", + "Copy from closest edge (using midpoints)"}, + {MREMAP_MODE_EDGE_POLY_NEAREST, "POLY_NEAREST", 0, "Nearest Face Edge", + "Copy from closest edge of closest face (using midpoints)"}, + {MREMAP_MODE_EDGE_EDGEINTERP_VNORPROJ, "EDGEINTERP_VNORPROJ", 0, "Projected Edge Interpolated", + "Interpolate all source edges hit by the projection of destination one along its own normal (from vertices)"}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem DT_method_loop_items[] = { + {MREMAP_MODE_TOPOLOGY, "TOPOLOGY", 0, "Topology", + "Copy from identical topology meshes"}, + {MREMAP_MODE_LOOP_NEAREST_LOOPNOR, "NEAREST_NORMAL", 0, "Nearest Corner And Best Matching Normal", + "Copy from nearest corner which has the best matching normal"}, + {MREMAP_MODE_LOOP_NEAREST_POLYNOR, "NEAREST_POLYNOR", 0, "Nearest Corner And Best Matching Face Normal", + "Copy from nearest corner which has the face with the best matching normal to destination corner's face one"}, + {MREMAP_MODE_LOOP_POLY_NEAREST, "NEAREST_POLY", 0, "Nearest Corner Of Nearest Face", + "Copy from nearest corner of nearest polygon"}, + {MREMAP_MODE_LOOP_POLYINTERP_NEAREST, "POLYINTERP_NEAREST", 0, "Nearest Face Interpolated", + "Copy from interpolated corners of the nearest source polygon"}, + {MREMAP_MODE_LOOP_POLYINTERP_LNORPROJ, "POLYINTERP_LNORPROJ", 0, "Projected Face Interpolated", + "Copy from interpolated corners of the source polygon hit by corner normal projection"}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem DT_method_poly_items[] = { + {MREMAP_MODE_TOPOLOGY, "TOPOLOGY", 0, "Topology", + "Copy from identical topology meshes"}, + {MREMAP_MODE_POLY_NEAREST, "NEAREST", 0, "Nearest Face", + "Copy from nearest polygon (using center points)"}, + {MREMAP_MODE_POLY_NOR, "NORMAL", 0, "Best Normal-Matching", + "Copy from source polygon which normal is the closest to destination one"}, + {MREMAP_MODE_POLY_POLYINTERP_PNORPROJ, "POLYINTERP_PNORPROJ", 0, "Projected Face Interpolated", + "Interpolate all source polygons intersected by the projection of destination one along its own normal"}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem DT_mix_mode_items[] = { + {CDT_MIX_TRANSFER, "REPLACE", 0, "Replace", + "Overwrite all elements' data"}, + {CDT_MIX_REPLACE_ABOVE_THRESHOLD, "ABOVE_THRESHOLD", 0, "Above Threshold", + "Only replace destination elements where data is above given threshold (exact behavior depends on data type)"}, + {CDT_MIX_REPLACE_BELOW_THRESHOLD, "BELOW_THRESHOLD", 0, "Below Threshold", + "Only replace destination elements where data is below given threshold (exact behavior depends on data type)"}, + {CDT_MIX_MIX, "MIX", 0, "Mix", + "Mix source value into destination one, using given threshold as factor"}, + {CDT_MIX_ADD, "ADD", 0, "Add", + "Add source value to destination one, using given threshold as factor"}, + {CDT_MIX_SUB, "SUB", 0, "Subtract", + "Subtract source value to destination one, using given threshold as factor"}, + {CDT_MIX_MUL, "MUL", 0, "Multiply", + "Multiply source value to destination one, using given threshold as factor"}, + /* etc. etc. */ + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem DT_layers_select_src_items[] = { + {DT_LAYERS_ACTIVE_SRC, "ACTIVE", 0, "Active Layer", + "Only transfer active data layer"}, + {DT_LAYERS_ALL_SRC, "ALL", 0, "All Layers", + "Transfer all data layers"}, + {DT_LAYERS_VGROUP_SRC_BONE_SELECT, "BONE_SELECT", 0, "Selected Pose Bones", + "Transfer all vertex groups used by selected pose bones"}, + {DT_LAYERS_VGROUP_SRC_BONE_DEFORM, "BONE_DEFORM", 0, "Deform Pose Bones", + "Transfer all vertex groups used by deform bones"}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem DT_layers_select_dst_items[] = { + {DT_LAYERS_ACTIVE_DST, "ACTIVE", 0, "Active Layer", + "Affect active data layer of all targets"}, + {DT_LAYERS_NAME_DST, "NAME", 0, "By Name", + "Match target data layers to affect by name"}, + {DT_LAYERS_INDEX_DST, "INDEX", 0, "By Order", + "Match target data layers to affect by order (indices)"}, + {0, NULL, 0, NULL, NULL} +}; + + #ifdef RNA_RUNTIME #include "DNA_particle_types.h" +#include "DNA_curve_types.h" #include "DNA_smoke_types.h" #include "BKE_context.h" @@ -245,6 +356,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr) return &RNA_LaplacianDeformModifier; case eModifierType_Wireframe: return &RNA_WireframeModifier; + case eModifierType_DataTransfer: + return &RNA_DataTransferModifier; case eModifierType_PointCache: return &RNA_PointCacheModifier; /* Default */ @@ -312,6 +425,7 @@ RNA_MOD_VGROUP_NAME_SET(Armature, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Bevel, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Cast, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Curve, name); +RNA_MOD_VGROUP_NAME_SET(DataTransfer, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Decimate, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Displace, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Hook, name); @@ -402,6 +516,7 @@ RNA_MOD_OBJECT_SET(Array, curve_ob, OB_CURVE); RNA_MOD_OBJECT_SET(Boolean, object, OB_MESH); RNA_MOD_OBJECT_SET(Cast, object, OB_EMPTY); RNA_MOD_OBJECT_SET(Curve, object, OB_CURVE); +RNA_MOD_OBJECT_SET(DataTransfer, ob_source, OB_MESH); RNA_MOD_OBJECT_SET(Lattice, object, OB_LATTICE); RNA_MOD_OBJECT_SET(Mask, ob_arm, OB_ARMATURE); RNA_MOD_OBJECT_SET(MeshDeform, object, OB_MESH); @@ -607,6 +722,299 @@ static int rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr) return ((lmd->flag & MOD_LAPLACIANDEFORM_BIND) && (lmd->cache_system != NULL)); } +/* NOTE: Curve and array modifiers requires curve path to be evaluated, + * dependency graph will make sure that curve eval would create such a path, + * but if curve was already evaluated we might miss path. + * + * So what we do here is: if path was not calculated for target curve we + * tag it for update. + */ + +static void rna_CurveModifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + CurveModifierData *cmd = (CurveModifierData *)ptr->data; + rna_Modifier_update(bmain, scene, ptr); + DAG_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); + } + } +} + +static void rna_ArrayModifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + ArrayModifierData *amd = (ArrayModifierData *)ptr->data; + rna_Modifier_update(bmain, scene, ptr); + DAG_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); + } + } +} + + +static void rna_DataTransferModifier_use_data_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data; + + if (!(dtmd->flags & MOD_DATATRANSFER_USE_VERT)) { + dtmd->data_types &= ~DT_TYPE_VERT_ALL; + } + if (!(dtmd->flags & MOD_DATATRANSFER_USE_EDGE)) { + dtmd->data_types &= ~DT_TYPE_EDGE_ALL; + } + if (!(dtmd->flags & MOD_DATATRANSFER_USE_LOOP)) { + dtmd->data_types &= ~DT_TYPE_LOOP_ALL; + } + if (!(dtmd->flags & MOD_DATATRANSFER_USE_POLY)) { + dtmd->data_types &= ~DT_TYPE_POLY_ALL; + } + + rna_Modifier_update(bmain, scene, ptr); +} + +static void rna_DataTransferModifier_data_types_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data; + const int item_types = BKE_object_data_transfer_get_dttypes_item_types(dtmd->data_types); + + if (item_types & ME_VERT) { + dtmd->flags |= MOD_DATATRANSFER_USE_VERT; + } + if (item_types & ME_EDGE) { + dtmd->flags |= MOD_DATATRANSFER_USE_EDGE; + } + if (item_types & ME_LOOP) { + dtmd->flags |= MOD_DATATRANSFER_USE_LOOP; + } + if (item_types & ME_POLY) { + dtmd->flags |= MOD_DATATRANSFER_USE_POLY; + } + + rna_Modifier_update(bmain, scene, ptr); +} + +static EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free) +{ + DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data; + EnumPropertyItem *item = NULL, tmp_item = {0}; + int totitem = 0; + + if (!C) { /* needed for docs and i18n tools */ + return DT_layers_select_src_items; + } + + /* No active here! */ + RNA_enum_items_add_value(&item, &totitem, DT_layers_select_src_items, DT_LAYERS_ALL_SRC); + + if (STREQ(RNA_property_identifier(prop), "layers_vgroup_select_src")) { + Object *ob_src = dtmd->ob_source; + +#if 0 /* XXX Don't think we want this in modifier version... */ + if (BKE_object_pose_armature_get(ob_src)) { + RNA_enum_items_add_value(&item, &totitem, DT_layers_select_src_items, DT_LAYERS_VGROUP_SRC_BONE_SELECT); + RNA_enum_items_add_value(&item, &totitem, DT_layers_select_src_items, DT_LAYERS_VGROUP_SRC_BONE_DEFORM); + } +#endif + + if (ob_src) { + bDeformGroup *dg; + int i; + + RNA_enum_item_add_separator(&item, &totitem); + + for (i = 0, dg = ob_src->defbase.first; dg; i++, dg = dg->next) { + tmp_item.value = i; + tmp_item.identifier = tmp_item.name = dg->name; + RNA_enum_item_add(&item, &totitem, &tmp_item); + } + } + } + else if (STREQ(RNA_property_identifier(prop), "layers_shapekey_select_src")) { + /* TODO */ + } + else if (STREQ(RNA_property_identifier(prop), "layers_uv_select_src")) { + Object *ob_src = dtmd->ob_source; + + if (ob_src) { + DerivedMesh *dm_src; + CustomData *pdata; + int num_data, i; + + /* XXX Is this OK? */ + dm_src = mesh_get_derived_final(dtmd->modifier.scene, ob_src, CD_MASK_BAREMESH | CD_MTEXPOLY); + pdata = dm_src->getPolyDataLayout(dm_src); + num_data = CustomData_number_of_layers(pdata, CD_MTEXPOLY); + + RNA_enum_item_add_separator(&item, &totitem); + + for (i = 0; i < num_data; i++) { + tmp_item.value = i; + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(pdata, CD_MTEXPOLY, i); + RNA_enum_item_add(&item, &totitem, &tmp_item); + } + } + } + else if (STREQ(RNA_property_identifier(prop), "layers_vcol_select_src")) { + Object *ob_src = dtmd->ob_source; + + if (ob_src) { + DerivedMesh *dm_src; + CustomData *ldata; + int num_data, i; + + /* XXX Is this OK? */ + dm_src = mesh_get_derived_final(dtmd->modifier.scene, ob_src, CD_MASK_BAREMESH | CD_MLOOPCOL); + ldata = dm_src->getLoopDataLayout(dm_src); + num_data = CustomData_number_of_layers(ldata, CD_MLOOPCOL); + + RNA_enum_item_add_separator(&item, &totitem); + + for (i = 0; i < num_data; i++) { + tmp_item.value = i; + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(ldata, CD_MLOOPCOL, i); + RNA_enum_item_add(&item, &totitem, &tmp_item); + } + } + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + +static EnumPropertyItem *rna_DataTransferModifier_layers_select_dst_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free) +{ + DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data; + EnumPropertyItem *item = NULL, tmp_item = {0}; + int totitem = 0; + + if (!C) { /* needed for docs and i18n tools */ + return DT_layers_select_dst_items; + } + + /* No active here! */ + RNA_enum_items_add_value(&item, &totitem, DT_layers_select_dst_items, DT_LAYERS_NAME_DST); + RNA_enum_items_add_value(&item, &totitem, DT_layers_select_dst_items, DT_LAYERS_INDEX_DST); + + if (STREQ(RNA_property_identifier(prop), "layers_vgroup_select_dst")) { + /* Only list destination layers if we have a single source! */ + if (dtmd->layers_select_src[DT_MULTILAYER_INDEX_MDEFORMVERT] >= 0) { + Object *ob_dst = CTX_data_active_object(C); /* XXX Is this OK? */ + + if (ob_dst) { + bDeformGroup *dg; + int i; + + RNA_enum_item_add_separator(&item, &totitem); + + for (i = 0, dg = ob_dst->defbase.first; dg; i++, dg = dg->next) { + tmp_item.value = i; + tmp_item.identifier = tmp_item.name = dg->name; + RNA_enum_item_add(&item, &totitem, &tmp_item); + } + } + } + } + else if (STREQ(RNA_property_identifier(prop), "layers_shapekey_select_dst")) { + /* TODO */ + } + else if (STREQ(RNA_property_identifier(prop), "layers_uv_select_dst")) { + /* Only list destination layers if we have a single source! */ + if (dtmd->layers_select_src[DT_MULTILAYER_INDEX_UV] >= 0) { + Object *ob_dst = CTX_data_active_object(C); /* XXX Is this OK? */ + + if (ob_dst && ob_dst->data) { + Mesh *me_dst; + CustomData *pdata; + int num_data, i; + + me_dst = ob_dst->data; + pdata = &me_dst->pdata; + num_data = CustomData_number_of_layers(pdata, CD_MTEXPOLY); + + RNA_enum_item_add_separator(&item, &totitem); + + for (i = 0; i < num_data; i++) { + tmp_item.value = i; + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(pdata, CD_MTEXPOLY, i); + RNA_enum_item_add(&item, &totitem, &tmp_item); + } + } + } + } + else if (STREQ(RNA_property_identifier(prop), "layers_vcol_select_dst")) { + /* Only list destination layers if we have a single source! */ + if (dtmd->layers_select_src[DT_MULTILAYER_INDEX_VCOL] >= 0) { + Object *ob_dst = CTX_data_active_object(C); /* XXX Is this OK? */ + + if (ob_dst && ob_dst->data) { + Mesh *me_dst; + CustomData *ldata; + int num_data, i; + + me_dst = ob_dst->data; + ldata = &me_dst->ldata; + num_data = CustomData_number_of_layers(ldata, CD_MLOOPCOL); + + RNA_enum_item_add_separator(&item, &totitem); + + for (i = 0; i < num_data; i++) { + tmp_item.value = i; + tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(ldata, CD_MLOOPCOL, i); + RNA_enum_item_add(&item, &totitem, &tmp_item); + } + } + } + } + + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + +static EnumPropertyItem *rna_DataTransferModifier_mix_mode_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) +{ + DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data; + EnumPropertyItem *item = NULL; + int totitem = 0; + + bool support_advanced_mixing, support_threshold; + + if (!C) { /* needed for docs and i18n tools */ + return DT_mix_mode_items; + } + + RNA_enum_items_add_value(&item, &totitem, DT_mix_mode_items, CDT_MIX_TRANSFER); + + BKE_object_data_transfer_get_dttypes_capacity(dtmd->data_types, &support_advanced_mixing, &support_threshold); + + if (support_threshold) { + RNA_enum_items_add_value(&item, &totitem, DT_mix_mode_items, CDT_MIX_REPLACE_ABOVE_THRESHOLD); + RNA_enum_items_add_value(&item, &totitem, DT_mix_mode_items, CDT_MIX_REPLACE_BELOW_THRESHOLD); + } + + if (support_advanced_mixing) { + RNA_enum_item_add_separator(&item, &totitem); + RNA_enum_items_add_value(&item, &totitem, DT_mix_mode_items, CDT_MIX_MIX); + RNA_enum_items_add_value(&item, &totitem, DT_mix_mode_items, CDT_MIX_ADD); + RNA_enum_items_add_value(&item, &totitem, DT_mix_mode_items, CDT_MIX_SUB); + RNA_enum_items_add_value(&item, &totitem, DT_mix_mode_items, CDT_MIX_MUL); + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + #else static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[]) @@ -879,7 +1287,7 @@ static void rna_def_modifier_curve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Object", "Curve object to deform with"); RNA_def_property_pointer_funcs(prop, NULL, "rna_CurveModifier_object_set", NULL, "rna_Curve_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); - RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + RNA_def_property_update(prop, 0, "rna_CurveModifier_dependency_update"); prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); @@ -1402,7 +1810,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Curve", "Curve object to fit array length to"); RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_curve_ob_set", NULL, "rna_Curve_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); - RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + RNA_def_property_update(prop, 0, "rna_ArrayModifier_dependency_update"); /* Offset parameters */ prop = RNA_def_property(srna, "use_constant_offset", PROP_BOOLEAN, PROP_NONE); @@ -2456,7 +2864,7 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "origin", PROP_POINTER, PROP_NONE); - RNA_def_property_ui_text(prop, "Origin", "Origin of modifier space coordinates"); + RNA_def_property_ui_text(prop, "Origin", "Offset the origin and orientation of the deformation"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); @@ -3667,6 +4075,251 @@ static void rna_def_modifier_wireframe(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); } +static void rna_def_modifier_datatransfer(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem DT_layer_vert_items[] = { +#if 0 /* XXX When SkinModifier is enabled, it seems to erase its own CD_MVERT_SKIN layer from final DM :( */ + {DT_TYPE_SKIN, "SKIN", 0, "Skin Weight", "Transfer skin weights"}, +#endif + {DT_TYPE_BWEIGHT_VERT, "BEVEL_WEIGHT_VERT", 0, "Bevel Weight", "Transfer bevel weights"}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem DT_layer_vert_vgroup_items[] = { + {DT_TYPE_MDEFORMVERT, "VGROUP_WEIGHTS", 0, "Vertex Group(s)", "Transfer active or all vertex groups"}, + {0, NULL, 0, NULL, NULL} + }; +#if 0 /* XXX For now, would like to finish/merge work from 2014 gsoc first. */ + static EnumPropertyItem DT_layer_vert_shapekey_items[] = { + {DT_TYPE_SHAPEKEY, "SHAPEKEYS", 0, "Shapekey(s)", "Transfer active or all shape keys"}, + {0, NULL, 0, NULL, NULL} + }; +#endif + + static EnumPropertyItem DT_layer_edge_items[] = { + {DT_TYPE_SHARP_EDGE, "SHARP_EDGE", 0, "Sharp", "Transfer sharp mark"}, + {DT_TYPE_SEAM, "SEAM", 0, "UV Seam", "Transfer UV seam mark"}, + {DT_TYPE_CREASE, "CREASE", 0, "Subsurf Crease", "Transfer crease values"}, + {DT_TYPE_BWEIGHT_EDGE, "BEVEL_WEIGHT_EDGE", 0, "Bevel Weight", "Transfer bevel weights"}, + {DT_TYPE_FREESTYLE_EDGE, "FREESTYLE_EDGE", 0, "Freestyle Mark", "Transfer Freestyle edge mark"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem DT_layer_loop_items[] = { + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem DT_layer_loop_vcol_items[] = { + {DT_TYPE_VCOL, "VCOL", 0, "VCol", "Vertex (face corners) colors"}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem DT_layer_loop_uv_items[] = { + {DT_TYPE_UV, "UV", 0, "UVs", "Transfer UV layers"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem DT_layer_poly_items[] = { + {DT_TYPE_SHARP_FACE, "SMOOTH", 0, "Smooth", "Transfer flat/smooth mark"}, + {DT_TYPE_FREESTYLE_FACE, "FREESTYLE_FACE", 0, "Freestyle Mark", "Transfer Freestyle face mark"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "DataTransferModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Data Transfer Modifier", "Modifier transferring some data from a source mesh"); + RNA_def_struct_sdna(srna, "DataTransferModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_DATA_TRANSFER); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "ob_source"); + RNA_def_property_ui_text(prop, "Source Object", "Object to transfer data from"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_pointer_funcs(prop, NULL, "rna_DataTransferModifier_ob_source_set", NULL, "rna_Mesh_object_poll"); + RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + + prop = RNA_def_boolean(srna, "use_object_transform", true, "Object Transform", + "Evaluate source and destination meshes in their respective object spaces"); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_OBSRC_TRANSFORM); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* Generic, UI-only data types toggles. */ + prop = RNA_def_boolean(srna, "use_vert_data", false, "Vertex Data", "Enable vertex data transfer"); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_USE_VERT); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_use_data_update"); + + prop = RNA_def_boolean(srna, "use_edge_data", false, "Edge Data", "Enable edge data transfer"); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_USE_EDGE); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_use_data_update"); + + prop = RNA_def_boolean(srna, "use_loop_data", false, "Face Corner Data", "Enable face corner data transfer"); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_USE_LOOP); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_use_data_update"); + + prop = RNA_def_boolean(srna, "use_poly_data", false, "Face Data", "Enable face data transfer"); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_USE_POLY); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_use_data_update"); + + /* Actual data types selection. */ + prop = RNA_def_enum(srna, "data_types_verts", DT_layer_vert_items, 0, "Vertex Data Types", + "Which vertex data layers to transfer"); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_enum_sdna(prop, NULL, "data_types"); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update"); + prop = RNA_def_enum(srna, "data_types_verts_vgroup", DT_layer_vert_vgroup_items, 0, "Vertex Data Types", + "Which vertex data layers to transfer"); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_enum_sdna(prop, NULL, "data_types"); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update"); + + prop = RNA_def_enum(srna, "data_types_edges", DT_layer_edge_items, 0, "Edge Data Types", + "Which edge data layers to transfer"); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_enum_sdna(prop, NULL, "data_types"); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update"); + + prop = RNA_def_enum(srna, "data_types_loops", DT_layer_loop_items, 0, "Face Corner Data Types", + "Which face corner data layers to transfer"); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_enum_sdna(prop, NULL, "data_types"); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update"); + prop = RNA_def_enum(srna, "data_types_loops_vcol", DT_layer_loop_vcol_items, 0, "Face Corner Data Types", + "Which face corner data layers to transfer"); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_enum_sdna(prop, NULL, "data_types"); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update"); + prop = RNA_def_enum(srna, "data_types_loops_uv", DT_layer_loop_uv_items, 0, "Face Corner Data Types", + "Which face corner data layers to transfer"); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_enum_sdna(prop, NULL, "data_types"); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update"); + + prop = RNA_def_enum(srna, "data_types_polys", DT_layer_poly_items, 0, "Poly Data Types", + "Which poly data layers to transfer"); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_enum_sdna(prop, NULL, "data_types"); + RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update"); + + /* Mapping methods. */ + prop = RNA_def_enum(srna, "vert_mapping", DT_method_vertex_items, MREMAP_MODE_VERT_NEAREST, "Vertex Mapping", + "Method used to map source vertices to destination ones"); + RNA_def_property_enum_sdna(prop, NULL, "vmap_mode"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_enum(srna, "edge_mapping", DT_method_edge_items, MREMAP_MODE_EDGE_NEAREST, "Edge Mapping", + "Method used to map source edges to destination ones"); + RNA_def_property_enum_sdna(prop, NULL, "emap_mode"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_enum(srna, "loop_mapping", DT_method_loop_items, MREMAP_MODE_LOOP_NEAREST_POLYNOR, + "Face Corner Mapping", "Method used to map source faces' corners to destination ones"); + RNA_def_property_enum_sdna(prop, NULL, "lmap_mode"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_enum(srna, "poly_mapping", DT_method_poly_items, MREMAP_MODE_POLY_NEAREST, "Face Mapping", + "Method used to map source faces to destination ones"); + RNA_def_property_enum_sdna(prop, NULL, "pmap_mode"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* Mapping options and filtering. */ + prop = RNA_def_boolean(srna, "use_max_distance", false, "Only Neighbor Geometry", + "Source elements must be closer than given distance from destination one"); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_MAP_MAXDIST); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_float(srna, "max_distance", 1.0f, 0.0f, FLT_MAX, "Max Distance", + "Maximum allowed distance between source and destination element, for non-topology mappings", + 0.0f, 100.0f); + RNA_def_property_float_sdna(prop, NULL, "map_max_distance"); + RNA_def_property_subtype(prop, PROP_DISTANCE); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_float(srna, "ray_radius", 0.0f, 0.0f, FLT_MAX, "Ray Radius", + "'Width' of rays (especially useful when raycasting against vertices or edges)", 0.0f, 10.0f); + RNA_def_property_float_sdna(prop, NULL, "map_ray_radius"); + RNA_def_property_subtype(prop, PROP_DISTANCE); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_float(srna, "islands_precision", 0.0f, 0.0f, 1.0f, "Islands Handling Refinement", + "Factor controlling precision of islands handling " + "(typically, 0.1 should be enough, higher values can make things really slow)", 0.0f, 1.0f); + RNA_def_property_subtype(prop, PROP_DISTANCE); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* How to handle multi-layers types of data. */ + prop = RNA_def_enum(srna, "layers_vgroup_select_src", DT_layers_select_src_items, DT_LAYERS_ALL_SRC, + "Source Layers Selection", "Which layers to transfer, in case of multi-layers types"); + RNA_def_property_enum_sdna(prop, NULL, "layers_select_src[DT_MULTILAYER_INDEX_MDEFORMVERT]"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_layers_select_src_itemf"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + +#if 0 + prop = RNA_def_enum(srna, "layers_shapekey_select_src", DT_layers_select_src_items, DT_LAYERS_ALL_SRC, + "Source Layers Selection", "Which layers to transfer, in case of multi-layers types"); + RNA_def_property_enum_sdna(prop, NULL, "layers_select_src[DT_MULTILAYER_INDEX_SHAPEKEY]"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_layers_select_src_itemf"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +#endif + + prop = RNA_def_enum(srna, "layers_vcol_select_src", DT_layers_select_src_items, DT_LAYERS_ALL_SRC, + "Source Layers Selection", "Which layers to transfer, in case of multi-layers types"); + RNA_def_property_enum_sdna(prop, NULL, "layers_select_src[DT_MULTILAYER_INDEX_VCOL]"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_layers_select_src_itemf"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_enum(srna, "layers_uv_select_src", DT_layers_select_src_items, DT_LAYERS_ALL_SRC, + "Source Layers Selection", "Which layers to transfer, in case of multi-layers types"); + RNA_def_property_enum_sdna(prop, NULL, "layers_select_src[DT_MULTILAYER_INDEX_UV]"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_layers_select_src_itemf"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_enum(srna, "layers_vgroup_select_dst", DT_layers_select_dst_items, DT_LAYERS_NAME_DST, + "Destination Layers Matching", "How to match source and destination layers"); + RNA_def_property_enum_sdna(prop, NULL, "layers_select_dst[DT_MULTILAYER_INDEX_MDEFORMVERT]"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_layers_select_dst_itemf"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + +#if 0 + prop = RNA_def_enum(srna, "layers_shapekey_select_dst", DT_layers_select_dst_items, DT_LAYERS_NAME_DST, + "Destination Layers Matching", "How to match source and destination layers"); + RNA_def_property_enum_sdna(prop, NULL, "layers_select_dst[DT_MULTILAYER_INDEX_SHAPEKEY]"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_layers_select_dst_itemf"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +#endif + + prop = RNA_def_enum(srna, "layers_vcol_select_dst", DT_layers_select_dst_items, DT_LAYERS_NAME_DST, + "Destination Layers Matching", "How to match source and destination layers"); + RNA_def_property_enum_sdna(prop, NULL, "layers_select_dst[DT_MULTILAYER_INDEX_VCOL]"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_layers_select_dst_itemf"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_enum(srna, "layers_uv_select_dst", DT_layers_select_dst_items, DT_LAYERS_NAME_DST, + "Destination Layers Matching", "How to match source and destination layers"); + RNA_def_property_enum_sdna(prop, NULL, "layers_select_dst[DT_MULTILAYER_INDEX_UV]"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_layers_select_dst_itemf"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* Mix stuff */ + prop = RNA_def_enum(srna, "mix_mode", DT_mix_mode_items, CDT_MIX_TRANSFER, "Mix Mode", + "How to affect destination elements with source values"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_mix_mode_itemf"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_float(srna, "mix_factor", 1.0f, 0.0f, 1.0f, "Mix Factor", + "Factor to use when applying data to destination (exact behavior depends on mix mode)", + 0.0f, 1.0f); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_string(srna, "vertex_group", NULL, MAX_VGROUP_NAME, "Vertex Group", + "Vertex group name for selecting the affected areas"); + RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DataTransferModifier_defgrp_name_set"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_boolean(srna, "invert_vertex_group", false, "Invert", "Invert vertex group influence"); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_INVERT_VGROUP); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +} + static void rna_def_modifier_pointcache(BlenderRNA *brna) { StructRNA *srna; @@ -3797,6 +4450,7 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_meshcache(brna); rna_def_modifier_laplaciandeform(brna); rna_def_modifier_wireframe(brna); + rna_def_modifier_datatransfer(brna); rna_def_modifier_pointcache(brna); } diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c index 170856a3061..e891ab520f9 100644 --- a/source/blender/makesrna/intern/rna_movieclip.c +++ b/source/blender/makesrna/intern/rna_movieclip.c @@ -317,8 +317,8 @@ static void rna_def_movieclip(BlenderRNA *brna) /* grease pencil */ prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "gpd"); - RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this movie clip"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 91dcb9f4d81..fa8d2669161 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2199,6 +2199,10 @@ static void rna_NodeSocketStandard_float_range(PointerRNA *ptr, float *min, floa bNodeSocketValueFloat *dval = sock->default_value; int subtype = sock->typeinfo->subtype; + if (dval->max < dval->min) { + dval->max = dval->min; + } + *min = (subtype == PROP_UNSIGNED ? 0.0f : -FLT_MAX); *max = FLT_MAX; *softmin = dval->min; @@ -2211,6 +2215,10 @@ static void rna_NodeSocketStandard_int_range(PointerRNA *ptr, int *min, int *max bNodeSocketValueInt *dval = sock->default_value; int subtype = sock->typeinfo->subtype; + if (dval->max < dval->min) { + dval->max = dval->min; + } + *min = (subtype == PROP_UNSIGNED ? 0 : INT_MIN); *max = INT_MAX; *softmin = dval->min; @@ -2222,6 +2230,10 @@ static void rna_NodeSocketStandard_vector_range(PointerRNA *ptr, float *min, flo bNodeSocket *sock = ptr->data; bNodeSocketValueVector *dval = sock->default_value; + if (dval->max < dval->min) { + dval->max = dval->min; + } + *min = -FLT_MAX; *max = FLT_MAX; *softmin = dval->min; @@ -7572,8 +7584,8 @@ static void rna_def_nodetree(BlenderRNA *brna) /* Grease Pencil */ prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "gpd"); - RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock"); RNA_def_property_update(prop, NC_NODE, NULL); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 8ebeeafbc58..f9a76005df8 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -42,10 +42,13 @@ #include "BLI_utildefines.h" #include "BLI_listbase.h" +#include "BKE_camera.h" #include "BKE_paint.h" #include "BKE_editmesh.h" #include "BKE_group.h" /* needed for BKE_group_object_exists() */ #include "BKE_object.h" /* Needed for BKE_object_matrix_local_get() */ +#include "BKE_object_deform.h" + #include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -231,21 +234,21 @@ static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16]) { Object *ob = ptr->id.data; + float local_mat[4][4]; - /* localspace matrix is truly relative to the parent, but parameters - * stored in object are relative to parentinv matrix. Undo the parent - * inverse part before updating obmat and calling apply_obmat() */ + /* localspace matrix is truly relative to the parent, but parameters stored in object are + * relative to parentinv matrix. Undo the parent inverse part before applying it as local matrix. */ if (ob->parent) { float invmat[4][4]; invert_m4_m4(invmat, ob->parentinv); - mul_m4_m4m4(ob->obmat, invmat, (float(*)[4])values); + mul_m4_m4m4(local_mat, invmat, (float(*)[4])values); } else { - copy_m4_m4(ob->obmat, (float(*)[4])values); + copy_m4_m4(local_mat, (float(*)[4])values); } - /* don't use compat so we get predictable rotation */ - BKE_object_apply_mat4(ob, ob->obmat, false, false); + /* don't use compat so we get predictable rotation, and do not use parenting either, because it's a local matrix! */ + BKE_object_apply_mat4(ob, local_mat, false, false); } static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16]) @@ -775,7 +778,7 @@ static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *val /* for now, assume that rotation mode is axis-angle */ ob->rotAngle = value[0]; - copy_v3_v3(ob->rotAxis, (float *)&value[1]); + copy_v3_v3(ob->rotAxis, &value[1]); /* TODO: validate axis? */ } @@ -1389,7 +1392,7 @@ static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name) { - bDeformGroup *defgroup = ED_vgroup_add_name(ob, name); + bDeformGroup *defgroup = BKE_object_defgroup_add_name(ob, name); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); @@ -1404,7 +1407,7 @@ static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA return; } - ED_vgroup_delete(ob, defgroup); + BKE_object_defgroup_remove(ob, defgroup); RNA_POINTER_INVALIDATE(defgroup_ptr); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); @@ -1412,7 +1415,7 @@ static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA static void rna_Object_vgroup_clear(Object *ob) { - ED_vgroup_clear(ob); + BKE_object_defgroup_remove_all(ob); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); } @@ -1422,7 +1425,7 @@ static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *re { Object *ob = (Object *)id; - if (ED_vgroup_object_is_edit_mode(ob)) { + if (BKE_object_is_in_editmode_vgroup(ob)) { BKE_report(reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode"); return; } @@ -1437,7 +1440,7 @@ static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList * { Object *ob = (Object *)id; - if (ED_vgroup_object_is_edit_mode(ob)) { + if (BKE_object_is_in_editmode_vgroup(ob)) { BKE_report(reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode"); return; } @@ -2427,7 +2430,9 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Local Matrix", "Parent relative transformation matrix"); + RNA_def_property_ui_text(prop, "Local Matrix", "Parent relative transformation matrix - " + "WARNING: Only takes into account 'Object' parenting, so e.g. in case of bone parenting " + "you get a matrix relative to the Armature object, not to the actual parent bone"); RNA_def_property_float_funcs(prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", NULL); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, NULL); @@ -2727,16 +2732,16 @@ static void rna_def_object(BlenderRNA *brna) /* Grease Pencil */ prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "gpd"); - RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); /* pose */ prop = RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "poselib"); - RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Action"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Pose Library", "Action used as a pose library for armatures"); prop = RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 831e5486236..1b4bc10551b 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -109,7 +109,29 @@ static void rna_Scene_mat_convert_space(Object *ob, ReportList *reports, bPoseCh } } - BKE_constraint_mat_convertspace(ob, pchan, (float (*)[4])mat_ret, from, to); + BKE_constraint_mat_convertspace(ob, pchan, (float (*)[4])mat_ret, from, to, false); +} + +static void rna_Object_calc_matrix_camera( + Object *ob, float mat_ret[16], int width, int height, float scalex, float scaley) +{ + CameraParams params; + + /* setup parameters */ + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, ob); + + /* compute matrix, viewplane, .. */ + BKE_camera_params_compute_viewplane(¶ms, width, height, scalex, scaley); + BKE_camera_params_compute_matrix(¶ms); + + copy_m4_m4((float (*)[4])mat_ret, params.winmat); +} + +static void rna_Object_camera_fit_coords( + Object *ob, Scene *scene, int num_cos, float *cos, float co_ret[3], float *scale_ret) +{ + BKE_camera_view_frame_fit_to_coords(scene, (float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret); } /* copied from Mesh_getFromObject and adapted to RNA interface */ @@ -203,10 +225,9 @@ static void rna_Object_free_duplilist(Object *ob) static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports, const char *name, int from_mix) { - Scene *scene = CTX_data_scene(C); KeyBlock *kb = NULL; - if ((kb = BKE_object_insert_shape_key(scene, ob, name, from_mix))) { + if ((kb = BKE_object_insert_shape_key(ob, name, from_mix))) { PointerRNA keyptr; RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr); @@ -468,6 +489,35 @@ void RNA_api_object(StructRNA *srna) parm = RNA_def_enum(func, "to_space", space_items, CONSTRAINT_SPACE_WORLD, "", "The space to which you want to transform 'matrix'"); + /* Camera-related operations */ + func = RNA_def_function(srna, "calc_matrix_camera", "rna_Object_calc_matrix_camera"); + RNA_def_function_ui_description(func, "Generate the camera projection matrix of this object " + "(mostly useful for Camera and Lamp types)"); + parm = RNA_def_property(func, "result", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(parm, "", "The camera projection matrix"); + RNA_def_function_output(func, parm); + parm = RNA_def_int(func, "x", 1, 0, INT_MAX, "", "Width of the render area", 0, 10000); + parm = RNA_def_int(func, "y", 1, 0, INT_MAX, "", "Height of the render area", 0, 10000); + parm = RNA_def_float(func, "scale_x", 1.0f, 1.0e-6f, FLT_MAX, "", "Width scaling factor", 1.0e-2f, 100.0f); + parm = RNA_def_float(func, "scale_y", 1.0f, 1.0e-6f, FLT_MAX, "", "height scaling factor", 1.0e-2f, 100.0f); + + func = RNA_def_function(srna, "camera_fit_coords", "rna_Object_camera_fit_coords"); + RNA_def_function_ui_description(func, "Compute the coordinate (and scale for ortho cameras) " + "given object should be to 'see' all given coordinates"); + parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to get render size information from, if available"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_float_array(func, "coordinates", 1, NULL, -FLT_MAX, FLT_MAX, "", "Coordinates to fit in", + -FLT_MAX, FLT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_DYNAMIC); + parm = RNA_def_property(func, "co_return", PROP_FLOAT, PROP_XYZ); + RNA_def_property_array(parm, 3); + RNA_def_property_ui_text(parm, "", "The location to aim to be able to see all given points"); + RNA_def_property_flag(parm, PROP_OUTPUT); + parm = RNA_def_property(func, "scale_return", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(parm, "", "The ortho scale to aim to be able to see all given points (if relevant)"); + RNA_def_property_flag(parm, PROP_OUTPUT); + /* mesh */ func = RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh"); RNA_def_function_ui_description(func, "Create a Mesh datablock with modifiers applied"); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index f72f97b1681..07dac63f3fe 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -258,7 +258,7 @@ static void rna_PoseChannel_rotation_axis_angle_set(PointerRNA *ptr, const float /* for now, assume that rotation mode is axis-angle */ pchan->rotAngle = value[0]; - copy_v3_v3(pchan->rotAxis, (float *)&value[1]); + copy_v3_v3(pchan->rotAxis, &value[1]); /* TODO: validate axis? */ } diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 0ee654d4ecc..6db9c8e9cd9 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -38,7 +38,6 @@ #include "RE_engine.h" #include "RE_pipeline.h" -#include "RE_engine.h" EnumPropertyItem render_pass_type_items[] = { @@ -520,6 +519,11 @@ static void rna_def_render_engine(BlenderRNA *brna) prop = RNA_def_string(func, "message", NULL, 0, "Report Message", ""); RNA_def_property_flag(prop, PROP_REQUIRED); + func = RNA_def_function(srna, "error_set", "RE_engine_set_error_message"); + RNA_def_function_ui_description(func, "Set error message displaying after the render is finished"); + prop = RNA_def_string(func, "message", NULL, 0, "Report Message", ""); + RNA_def_property_flag(prop, PROP_REQUIRED); + func = RNA_def_function(srna, "bind_display_space_shader", "engine_bind_display_space_shader"); RNA_def_function_ui_description(func, "Bind GLSL fragment shader that converts linear colors to display space colors using scene color management settings"); prop = RNA_def_pointer(func, "scene", "Scene", "", ""); diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c index 86a8b162614..58a12f62644 100644 --- a/source/blender/makesrna/intern/rna_rigidbody.c +++ b/source/blender/makesrna/intern/rna_rigidbody.c @@ -644,8 +644,7 @@ static void rna_RigidBodyWorld_convex_sweep_test( BKE_report(reports, RPT_ERROR, "Rigidbody world was not properly initialized, need to step the simulation first"); } #else - (void)rbw, (void)reports, (void)object, (void)ray_start, (void)ray_end; - (void)r_location, (void)r_hitpoint, (void)r_normal, (void)r_hit; + UNUSED_VARS(rbw, reports, object, ray_start, ray_end, r_location, r_hitpoint, r_normal, r_hit); #endif } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 519a52b04e2..d9587b8d983 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -737,7 +737,7 @@ static int rna_RenderSettings_threads_mode_get(PointerRNA *ptr) return (rd->mode & R_FIXED_THREADS); } -static int rna_RenderSettings_is_movie_fomat_get(PointerRNA *ptr) +static int rna_RenderSettings_is_movie_format_get(PointerRNA *ptr) { RenderData *rd = (RenderData *)ptr->data; return BKE_imtype_is_movie(rd->im_format.imtype); @@ -1773,6 +1773,14 @@ static void rna_def_tool_settings(BlenderRNA *brna) {WT_VGROUP_BONE_DEFORM_OFF, "OTHER_DEFORM", 0, "Other", "Vertex Groups assigned to non Deform Bones"}, {0, NULL, 0, NULL, NULL} }; + + static EnumPropertyItem gpencil_source_3d_items[] = { + {GP_TOOL_SOURCE_SCENE, "SCENE", 0, "Scene", + "Grease Pencil data attached to the current scene is used, unless the active object already has Grease Pencil data (i.e. for old files)"}, + {GP_TOOL_SOURCE_OBJECT, "OBJECT", 0, "Object", + "Grease Pencil datablocks attached to the active object are used (required using pre 2.73 add-ons, e.g. BSurfaces)"}, + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "ToolSettings", NULL); @@ -1965,6 +1973,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) "Allow drawing multiple strokes at a time with Grease Pencil"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* xxx: need toolbar to be redrawn... */ + prop = RNA_def_property(srna, "grease_pencil_source", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_src"); + RNA_def_property_enum_items(prop, gpencil_source_3d_items); + RNA_def_property_ui_text(prop, "Grease Pencil Source", + "Datablock where active Grease Pencil data is found from"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + /* Auto Keying */ prop = RNA_def_property(srna, "use_keyframe_insert_auto", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "autokey_mode", AUTOKEY_ON); @@ -4801,7 +4816,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "is_movie_format", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_is_movie_fomat_get", NULL); + RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_is_movie_format_get", NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Movie Format", "When true the format is a movie"); @@ -5459,7 +5474,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); RNA_def_property_array(prop, 20); RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_layer_set"); - RNA_def_property_ui_text(prop, "Layers", "Visible layers - Shift-Click to select multiple layers"); + RNA_def_property_ui_text(prop, "Layers", "Visible layers - Shift-Click/Drag to select multiple layers"); RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_Scene_layer_update"); /* active layer */ @@ -5738,10 +5753,10 @@ void RNA_def_scene(BlenderRNA *brna) /* Grease Pencil */ prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "gpd"); - RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock"); - RNA_def_property_update(prop, NC_SCENE, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); /* Transform Orientations */ prop = RNA_def_property(srna, "orientations", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 84134e7cd3a..be618c5d1a3 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -47,12 +47,14 @@ #include "BKE_animsys.h" #include "BKE_depsgraph.h" +#include "BKE_editmesh.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_scene.h" #include "BKE_writeavi.h" #include "ED_transform.h" +#include "ED_uvedit.h" #ifdef WITH_PYTHON # include "BPY_extern.h" @@ -90,6 +92,20 @@ static void rna_Scene_frame_set(Scene *scene, int frame, float subframe) } } +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)) { + ED_uvedit_get_aspect(scene, ob, em->bm, aspect, aspect + 1); + return; + } + } + + aspect[0] = aspect[1] = 1.0f; +} + static void rna_Scene_update_tagged(Scene *scene) { #ifdef WITH_PYTHON @@ -191,6 +207,15 @@ void RNA_api_scene(StructRNA *srna) RNA_def_function_ui_description(func, "Update data tagged to be updated from previous access to data or operators"); + func = RNA_def_function(srna, "uvedit_aspect", "rna_Scene_uvedit_aspect"); + RNA_def_function_ui_description(func, "Get uv aspect for current object"); + parm = RNA_def_pointer(func, "object", "Object", "", "Object"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + + parm = RNA_def_float_vector(func, "result", 2, NULL, 0.0f, FLT_MAX, "", "aspect", 0.0f, FLT_MAX); + RNA_def_property_flag(parm, PROP_THICK_WRAP); + RNA_def_function_output(func, parm); + /* 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"); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 86a28fb80bf..7b01acff6a5 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -110,7 +110,9 @@ static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) { - return (ED_screen_animation_playing(G.main->wm.first) != NULL); + /* can be NULL on file load, T42619 */ + wmWindowManager *wm = G.main->wm.first; + return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; } static int rna_Screen_fullscreen_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 09e42e48e93..8e83543812d 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -289,7 +289,8 @@ static char *rna_ParticleBrush_path(PointerRNA *UNUSED(ptr)) static void rna_Paint_brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - Brush *br = (Brush *)ptr->data; + Paint *paint = ptr->data; + Brush *br = paint->brush; BKE_paint_invalidate_overlay_all(); WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); } @@ -303,22 +304,27 @@ static void rna_ImaPaint_viewport_update(Main *UNUSED(bmain), Scene *UNUSED(scen static void rna_ImaPaint_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { Object *ob = OBACT; - - /* of course we need to invalidate here */ - BKE_texpaint_slots_refresh_object(scene, ob); - /* we assume that changing the current mode will invalidate the uv layers so we need to refresh display */ - GPU_drawobject_free(ob->derivedFinal); - BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); + if (ob && ob->type == OB_MESH) { + /* of course we need to invalidate here */ + BKE_texpaint_slots_refresh_object(scene, ob); + + /* we assume that changing the current mode will invalidate the uv layers so we need to refresh display */ + GPU_drawobject_free(ob->derivedFinal); + BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); + } } static void rna_ImaPaint_stencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { - Object *ob = OBACT; - GPU_drawobject_free(ob->derivedFinal); - BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); + Object *ob = OBACT; + + if (ob && ob->type == OB_MESH) { + GPU_drawobject_free(ob->derivedFinal); + BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); + } } static void rna_ImaPaint_canvas_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) @@ -342,9 +348,11 @@ static void rna_ImaPaint_canvas_update(Main *bmain, Scene *scene, PointerRNA *UN } } - GPU_drawobject_free(ob->derivedFinal); - BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); + if (ob && ob->type == OB_MESH) { + GPU_drawobject_free(ob->derivedFinal); + BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); + } } static int rna_ImaPaint_detect_data(ImagePaintSettings *imapaint) diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 00f0a6ff487..dda0e8493d9 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1846,6 +1846,11 @@ static void rna_def_scene(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll"); RNA_def_property_ui_text(prop, "Camera Override", "Override the scenes active camera"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); + + prop = RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_SCENE_NO_GPENCIL); + RNA_def_property_ui_text(prop, "Use Grease Pencil", "Show Grease Pencil strokes in OpenGL previews"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); rna_def_filter_video(srna); rna_def_proxy(srna); diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 70370f1ae36..3d358b412c8 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -313,6 +313,7 @@ static Sequence *rna_Sequences_new_effect(ID *id, Editing *ed, ReportList *repor seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; + BKE_sequence_calc(scene, seq); BKE_sequence_calc_disp(scene, seq); WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index 206a72a01b0..aa39e81d390 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -38,6 +38,7 @@ #include "BKE_sound.h" #include "BKE_context.h" +#include "BKE_sequencer.h" static void rna_Sound_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { @@ -59,9 +60,9 @@ static void rna_Sound_caching_set(PointerRNA *ptr, const int value) sound_delete_cache(sound); } -static void rna_Sound_caching_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Sound_caching_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) { - sound_update_sequencer(bmain, (bSound *)(ptr->data)); + BKE_sequencer_update_sound(scene, (bSound *)(ptr->data)); } #else diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 68173ebefb4..af0e69cdc3e 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -266,13 +266,7 @@ static ScrArea *rna_area_from_space(PointerRNA *ptr) { bScreen *sc = (bScreen *)ptr->id.data; SpaceLink *link = (SpaceLink *)ptr->data; - ScrArea *sa; - - for (sa = sc->areabase.first; sa; sa = sa->next) - if (BLI_findindex(&sa->spacedata, link) != -1) - return sa; - - return NULL; + return BKE_screen_find_area_from_space(sc, link); } static void area_region_from_regiondata(bScreen *sc, void *regiondata, ScrArea **r_sa, ARegion **r_ar) @@ -485,7 +479,7 @@ static void rna_SpaceView3D_matcap_update(Main *UNUSED(bmain), Scene *UNUSED(sce BKE_previewimg_free(&ma->preview); if (ma->gpumaterial.first) - GPU_material_free(ma); + GPU_material_free(&ma->gpumaterial); WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma); } @@ -856,7 +850,6 @@ static void rna_SpaceTextEditor_updateEdited(Main *UNUSED(bmain), Scene *UNUSED( WM_main_add_notifier(NC_TEXT | NA_EDITED, st->text); } - /* Space Properties */ /* note: this function exists only to avoid id refcounting */ @@ -1588,6 +1581,7 @@ static void rna_def_space_outliner(BlenderRNA *brna) prop = RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "search_string"); RNA_def_property_ui_text(prop, "Display Filter", "Live search filtering string"); + RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); prop = RNA_def_property(srna, "use_filter_case_sensitive", PROP_BOOLEAN, PROP_NONE); @@ -2041,6 +2035,11 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Only Render", "Display only objects which will be rendered"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_world", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag3", V3D_SHOW_WORLD); + RNA_def_property_ui_text(prop, "World Background", "Display world colors in the background"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "use_occlude_geometry", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_ZBUF_SELECT); RNA_def_property_ui_text(prop, "Occlude Geometry", "Limit selection to visible (clipped with depth buffer)"); @@ -2201,13 +2200,20 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "persmat"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* XXX: for now, it's too risky for users to do this */ RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); - RNA_def_property_ui_text(prop, "Perspective Matrix", "Current perspective matrix of the 3D region"); + RNA_def_property_ui_text(prop, "Perspective Matrix", + "Current perspective matrix (``window_matrix * view_matrix``)"); + + prop = RNA_def_property(srna, "window_matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_float_sdna(prop, NULL, "winmat"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); + RNA_def_property_ui_text(prop, "Window Matrix", "Current window matrix"); prop = RNA_def_property(srna, "view_matrix", PROP_FLOAT, PROP_MATRIX); RNA_def_property_float_sdna(prop, NULL, "viewmat"); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_float_funcs(prop, NULL, "rna_RegionView3D_view_matrix_set", NULL); - RNA_def_property_ui_text(prop, "View Matrix", "Current view matrix of the 3D region"); + RNA_def_property_ui_text(prop, "View Matrix", "Current view matrix"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "view_perspective", PROP_ENUM, PROP_NONE); @@ -2425,8 +2431,8 @@ static void rna_def_space_image(BlenderRNA *brna) /* grease pencil */ prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "gpd"); - RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); @@ -2509,6 +2515,16 @@ static void rna_def_space_sequencer(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem waveform_type_draw_items[] = { + {SEQ_NO_WAVEFORMS, "NO_WAVEFORMS", 0, "Waveforms Off", + "No waveforms drawn for any sound strips"}, + {SEQ_ALL_WAVEFORMS, "ALL_WAVEFORMS", 0, "Waveforms On", + "Waveforms drawn for all sound strips"}, + {0, "DEFAULT_WAVEFORMS", 0, "Use Strip Option", + "Waveforms drawn according to strip setting"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "SpaceSequenceEditor", "Space"); RNA_def_struct_sdna(srna, "SpaceSeq"); RNA_def_struct_ui_text(srna, "Space Sequence Editor", "Sequence editor space data"); @@ -2578,6 +2594,12 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the preview to draw"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + prop = RNA_def_property(srna, "waveform_draw_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, waveform_type_draw_items); + RNA_def_property_ui_text(prop, "Waveform Drawing", "How Waveforms are drawn"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + prop = RNA_def_property(srna, "draw_overexposed", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "zebra"); RNA_def_property_ui_text(prop, "Show Overexposed", "Show overexposed areas with zebra stripes"); @@ -2594,8 +2616,8 @@ static void rna_def_space_sequencer(BlenderRNA *brna) /* grease pencil */ prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "gpd"); - RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); @@ -2604,6 +2626,16 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_enum_items(prop, overlay_type_items); RNA_def_property_ui_text(prop, "Overlay Type", "Overlay draw type"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + + prop = RNA_def_property(srna, "show_backdrop", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "draw_flag", SEQ_DRAW_BACKDROP); + RNA_def_property_ui_text(prop, "Use Backdrop", "Display result under strips"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + + prop = RNA_def_property(srna, "show_strip_offset", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "draw_flag", SEQ_DRAW_OFFSET_EXT); + RNA_def_property_ui_text(prop, "Show Offsets", "Display strip in/out offsets"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); } static void rna_def_space_text(BlenderRNA *brna) @@ -2716,6 +2748,8 @@ static void rna_def_space_text(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "replacestr"); RNA_def_property_ui_text(prop, "Replace Text", "Text to replace selected text with using the replace tool"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TEXT, NULL); + + RNA_api_space_text(srna); } static void rna_def_space_dopesheet(BlenderRNA *brna) @@ -2935,14 +2969,12 @@ static void rna_def_space_graph(BlenderRNA *brna) RNA_def_property_enum_items(prop, autosnap_items); RNA_def_property_ui_text(prop, "Auto Snap", "Automatic time snapping settings for transformations"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); - + /* readonly state info */ prop = RNA_def_property(srna, "has_ghost_curves", PROP_BOOLEAN, PROP_NONE); - /* XXX: hack to make this compile, since this property doesn't actually exist*/ - RNA_def_property_boolean_sdna(prop, NULL, "flag", 0); RNA_def_property_boolean_funcs(prop, "rna_SpaceGraphEditor_has_ghost_curves_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Has Ghost Curves", "Graph Editor instance has some ghost curves stored"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); /* nromalize curves */ prop = RNA_def_property(srna, "use_normalization", PROP_BOOLEAN, PROP_NONE); @@ -3078,7 +3110,6 @@ static void rna_def_console_line(BlenderRNA *brna) srna = RNA_def_struct(brna, "ConsoleLine", NULL); RNA_def_struct_ui_text(srna, "Console Input", "Input line for the interactive console"); - /* XXX using non-inited "prop", uh? RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE, NULL); */ prop = RNA_def_property(srna, "body", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, "rna_ConsoleLine_body_get", "rna_ConsoleLine_body_length", @@ -3203,55 +3234,55 @@ static void rna_def_fileselect_params(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); prop = RNA_def_property(srna, "use_filter_image", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filter", IMAGEFILE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", FILE_TYPE_IMAGE); RNA_def_property_ui_text(prop, "Filter Images", "Show image files"); RNA_def_property_ui_icon(prop, ICON_FILE_IMAGE, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); prop = RNA_def_property(srna, "use_filter_blender", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filter", BLENDERFILE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", FILE_TYPE_BLENDER); RNA_def_property_ui_text(prop, "Filter Blender", "Show .blend files"); RNA_def_property_ui_icon(prop, ICON_FILE_BLEND, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); prop = RNA_def_property(srna, "use_filter_backup", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filter", BLENDERFILE_BACKUP); + RNA_def_property_boolean_sdna(prop, NULL, "filter", FILE_TYPE_BLENDER_BACKUP); RNA_def_property_ui_text(prop, "Filter BlenderBackup files", "Show .blend1, .blend2, etc. files"); RNA_def_property_ui_icon(prop, ICON_FILE_BACKUP, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); prop = RNA_def_property(srna, "use_filter_movie", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filter", MOVIEFILE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", FILE_TYPE_MOVIE); RNA_def_property_ui_text(prop, "Filter Movies", "Show movie files"); RNA_def_property_ui_icon(prop, ICON_FILE_MOVIE, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); prop = RNA_def_property(srna, "use_filter_script", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filter", PYSCRIPTFILE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", FILE_TYPE_PYSCRIPT); RNA_def_property_ui_text(prop, "Filter Script", "Show script files"); RNA_def_property_ui_icon(prop, ICON_FILE_SCRIPT, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); prop = RNA_def_property(srna, "use_filter_font", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filter", FTFONTFILE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", FILE_TYPE_FTFONT); RNA_def_property_ui_text(prop, "Filter Fonts", "Show font files"); RNA_def_property_ui_icon(prop, ICON_FILE_FONT, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); prop = RNA_def_property(srna, "use_filter_sound", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filter", SOUNDFILE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", FILE_TYPE_SOUND); RNA_def_property_ui_text(prop, "Filter Sound", "Show sound files"); RNA_def_property_ui_icon(prop, ICON_FILE_SOUND, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); prop = RNA_def_property(srna, "use_filter_text", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filter", TEXTFILE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", FILE_TYPE_TEXT); RNA_def_property_ui_text(prop, "Filter Text", "Show text files"); RNA_def_property_ui_icon(prop, ICON_FILE_TEXT, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); prop = RNA_def_property(srna, "use_filter_folder", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "filter", FOLDERFILE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", FILE_TYPE_FOLDER); RNA_def_property_ui_text(prop, "Filter Folder", "Show folders"); RNA_def_property_ui_icon(prop, ICON_FILE_FOLDER, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); @@ -3261,6 +3292,11 @@ static void rna_def_fileselect_params(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Extension Filter", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_LIST, NULL); + prop = RNA_def_property(srna, "filter_search", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "filter_search"); + RNA_def_property_ui_text(prop, "Name Filter", "Filter by name, supports '*' wildcard"); + RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } static void rna_def_space_filebrowser(BlenderRNA *brna) @@ -3345,6 +3381,7 @@ static void rna_def_space_userpref(BlenderRNA *brna) prop = RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "filter"); + RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); RNA_def_property_ui_text(prop, "Filter", "Search term for filtering in the UI"); } diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c index aed77378241..4114ee8a289 100644 --- a/source/blender/makesrna/intern/rna_space_api.c +++ b/source/blender/makesrna/intern/rna_space_api.c @@ -31,6 +31,8 @@ #ifdef RNA_RUNTIME +#include "ED_text.h" + static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d) { bScreen *sc = (bScreen *)id; @@ -49,6 +51,19 @@ static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d) } } +static void rna_SpaceTextEditor_region_location_from_cursor( + ID *id, SpaceText *st, + int line, int column, int r_pixel_pos[2]) +{ + bScreen *sc = (bScreen *)id; + ScrArea *sa = BKE_screen_find_area_from_space(sc, (SpaceLink *)st); + if (sa) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + const int cursor_co[2] = {line, column}; + ED_text_region_location_from_cursor(st, ar, cursor_co, r_pixel_pos); + } +} + #else void RNA_api_region_view3d(StructRNA *srna) @@ -74,4 +89,20 @@ void RNA_api_space_node(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED); } +void RNA_api_space_text(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func = RNA_def_function(srna, "region_location_from_cursor", "rna_SpaceTextEditor_region_location_from_cursor"); + RNA_def_function_ui_description(func, "Retrieve the region position from the given line and character position"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + parm = RNA_def_int(func, "line", 0, INT_MIN, INT_MAX, "Line", "Line index", 0, INT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "column", 0, INT_MIN, INT_MAX, "Column", "Column index", 0, INT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int_array(func, "result", 2, 0, -1, INT_MAX, "", "Region coordinates", -1, INT_MAX); + RNA_def_function_output(func, parm); +} + #endif diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index f098a659671..188a30d23ce 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -119,6 +119,7 @@ static EnumPropertyItem blend_type_items[] = { #include "BKE_main.h" #include "ED_node.h" +#include "ED_render.h" static StructRNA *rna_Texture_refine(struct PointerRNA *ptr) { @@ -443,8 +444,10 @@ static void rna_Envmap_source_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Tex *tex = ptr->id.data; - if (tex->env) + if (tex->env) { + ED_preview_kill_jobs(bmain->wm.first, bmain); BKE_free_envmapdata(tex->env); + } rna_Texture_update(bmain, scene, ptr); } diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 899da62d9d3..5a70d47a19a 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1435,8 +1435,8 @@ static void rna_def_trackingTrack(BlenderRNA *brna) /* grease pencil */ prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "gpd"); - RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this track"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 92c5530202b..a61846fa028 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -1062,6 +1062,7 @@ static void rna_def_uilist(BlenderRNA *brna) prop = RNA_def_property(srna, "filter_name", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "filter_byname"); + RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); RNA_def_property_ui_text(prop, "Filter by Name", "Only show items matching this name (use '*' as wildcard)"); prop = RNA_def_property(srna, "use_filter_invert", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 33c35313b38..4f889c91665 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -137,9 +137,7 @@ static void rna_uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const /* Get translated name (label). */ name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate); - - /* XXX This will search property again :( */ - uiItemMenuEnumR(layout, ptr, propname, name, icon); + uiItemMenuEnumR_prop(layout, ptr, prop, name, icon); } static void rna_uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index ab5039df627..fa0e1db10e2 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -35,6 +35,8 @@ #include "BLI_utildefines.h" +#include "BKE_appdir.h" +#include "BKE_DerivedMesh.h" #include "BKE_sound.h" #include "BKE_addon.h" @@ -48,6 +50,7 @@ #include "WM_types.h" #include "BLF_translation.h" +#include "GPU_buffers.h" #ifdef WITH_CYCLES static EnumPropertyItem compute_device_type_items[] = { @@ -141,6 +144,15 @@ static void rna_userdef_language_update(Main *UNUSED(bmain), Scene *UNUSED(scene UI_reinit_font(); } +static void rna_userdef_vbo_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ + Object *ob; + + for (ob = bmain->object.first; ob; ob = ob->id.next) { + GPU_drawobject_free(ob->derivedFinal); + } +} + static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, PointerRNA *ptr) { UserDef *userdef = (UserDef *)ptr->data; @@ -414,7 +426,7 @@ static void rna_userdef_pathcompare_remove(ReportList *reports, PointerRNA *path static void rna_userdef_temp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { - BLI_temp_dir_init(U.tempdir); + BKE_tempdir_init(U.tempdir); } static void rna_userdef_text_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) @@ -1031,10 +1043,10 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Icon Alpha", "Transparency of icons in the interface, to reduce contrast"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "emboss", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "emboss"); + prop = RNA_def_property(srna, "widget_emboss", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "widget_emboss"); RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Emboss", ""); + RNA_def_property_ui_text(prop, "Widget Emboss", "Color of the 1px shadow line underlying widgets"); RNA_def_property_update(prop, 0, "rna_userdef_update"); /* axis */ @@ -1476,6 +1488,26 @@ static void rna_def_userdef_theme_spaces_curves(StructRNA *srna, bool incl_nurbs } } +static void rna_def_userdef_theme_spaces_gpencil(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "gp_vertex", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Grease Pencil Vertex", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "gp_vertex_select", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Grease Pencil Vertex Select", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "gp_vertex_size", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 1, 10); + RNA_def_property_ui_text(prop, "Grease Pencil Vertex Size", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); +} + static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) { StructRNA *srna; @@ -1504,6 +1536,8 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Wire Edit", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + + rna_def_userdef_theme_spaces_gpencil(srna); prop = RNA_def_property(srna, "lamp", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 4); @@ -2034,6 +2068,8 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna) rna_def_userdef_theme_spaces_main(srna); rna_def_userdef_theme_spaces_list_main(srna); + + rna_def_userdef_theme_spaces_gpencil(srna); prop = RNA_def_property(srna, "node_selected", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "select"); @@ -2238,6 +2274,18 @@ static void rna_def_userdef_theme_space_time(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Current Frame", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "time_keyframe", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "time_keyframe"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Keyframe", "Base color for keyframe indicator lines"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "time_grease_pencil", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "time_gp_keyframe"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Grease Pencil", "Color of Grease Pencil keyframes"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); } static void rna_def_userdef_theme_space_image(BlenderRNA *brna) @@ -2253,8 +2301,10 @@ static void rna_def_userdef_theme_space_image(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Theme Image Editor", "Theme settings for the Image Editor"); rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_gpencil(srna); rna_def_userdef_theme_spaces_vertex(srna); rna_def_userdef_theme_spaces_face(srna); + prop = RNA_def_property(srna, "editmesh_active", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 4); @@ -2349,6 +2399,7 @@ static void rna_def_userdef_theme_space_seq(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Theme Sequence Editor", "Theme settings for the Sequence Editor"); rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_gpencil(srna); prop = RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); @@ -2760,6 +2811,8 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna) rna_def_userdef_theme_spaces_main(srna); rna_def_userdef_theme_spaces_list_main(srna); + + rna_def_userdef_theme_spaces_gpencil(srna); prop = RNA_def_property(srna, "marker_outline", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "marker_outline"); @@ -3951,7 +4004,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_ui_text(prop, "VBOs", "Use Vertex Buffer Objects (or Vertex Arrays, if unsupported) for viewport rendering"); /* this isn't essential but nice to check if VBO draws any differently */ - RNA_def_property_update(prop, NC_WINDOW, NULL); + RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_vbo_update"); prop = RNA_def_property(srna, "anisotropic_filter", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "anisotropic_filter"); diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index f63350ea0ae..721cbaf21c7 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -89,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); - WM_main_add_notifier(NC_WORLD, wo); + WM_main_add_notifier(NC_WORLD | ND_WORLD, wo); } static void rna_World_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) |