From 5505697ac508c02b8a2e196c5a8c07431bc687cf Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Wed, 14 Jul 2010 14:11:03 +0000 Subject: [PATCH 01/51] Merge GSOC Sculpt Branch: 28499-30319 https://svn.blender.org/svnroot/bf-blender/branches/soc-2010-jwilkins See log of that branch for details. --- intern/ghost/SConscript | 3 +- intern/ghost/intern/GHOST_WindowCarbon.cpp | 4 +- intern/ghost/intern/GHOST_WindowCocoa.mm | 3 +- intern/ghost/intern/GHOST_WindowWin32.cpp | 2 +- .../scripts/ui/properties_data_modifier.py | 1 + release/scripts/ui/properties_texture.py | 19 +- release/scripts/ui/space_userpref.py | 14 + release/scripts/ui/space_view3d_toolbar.py | 476 ++- source/blender/blenkernel/BKE_blender.h | 4 +- source/blender/blenkernel/BKE_brush.h | 10 + source/blender/blenkernel/BKE_paint.h | 4 + source/blender/blenkernel/intern/brush.c | 106 +- source/blender/blenkernel/intern/colortools.c | 56 +- source/blender/blenkernel/intern/icons.c | 5 +- source/blender/blenkernel/intern/image.c | 6 +- source/blender/blenlib/BLI_pbvh.h | 26 +- source/blender/blenlib/intern/math_geom.c | 77 +- source/blender/blenlib/intern/pbvh.c | 321 +- source/blender/blenloader/intern/readfile.c | 77 + .../blender/editors/gpencil/gpencil_buttons.c | 2 +- source/blender/editors/include/UI_interface.h | 6 +- .../editors/interface/interface_icons.c | 12 + .../editors/interface/interface_templates.c | 73 +- source/blender/editors/interface/resources.c | 15 +- .../blender/editors/sculpt_paint/SConscript | 12 +- .../editors/sculpt_paint/paint_image.c | 78 +- .../editors/sculpt_paint/paint_intern.h | 7 + .../blender/editors/sculpt_paint/paint_ops.c | 93 +- .../editors/sculpt_paint/paint_stroke.c | 816 ++++- .../editors/sculpt_paint/paint_utils.c | 6 +- source/blender/editors/sculpt_paint/sculpt.c | 3109 ++++++++++++----- .../editors/sculpt_paint/sculpt_intern.h | 44 + .../editors/sculpt_paint/sculpt_undo.c | 302 ++ .../editors/space_image/image_buttons.c | 2 +- .../editors/space_logic/logic_window.c | 2 +- .../blender/editors/space_nla/nla_buttons.c | 2 +- source/blender/editors/space_node/drawnode.c | 10 +- source/blender/gpu/intern/gpu_draw.c | 1 + source/blender/makesdna/DNA_ID.h | 2 +- source/blender/makesdna/DNA_brush_types.h | 135 +- source/blender/makesdna/DNA_color_types.h | 7 +- source/blender/makesdna/DNA_scene_types.h | 43 +- source/blender/makesdna/DNA_userdef_types.h | 13 +- .../makesdna/DNA_windowmanager_types.h | 3 +- source/blender/makesrna/SConscript | 1 - source/blender/makesrna/intern/CMakeLists.txt | 1 + source/blender/makesrna/intern/rna_brush.c | 384 +- source/blender/makesrna/intern/rna_image.c | 17 + .../makesrna/intern/rna_sculpt_paint.c | 25 +- source/blender/makesrna/intern/rna_ui_api.c | 2 + source/blender/makesrna/intern/rna_userdef.c | 41 +- source/blender/windowmanager/SConscript | 4 +- source/blender/windowmanager/intern/wm_draw.c | 4 +- .../windowmanager/intern/wm_operators.c | 101 +- .../bad_level_call_stubs/stubs.c | 24 + 55 files changed, 5239 insertions(+), 1374 deletions(-) create mode 100644 source/blender/editors/sculpt_paint/sculpt_undo.c diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript index 1269c631190..65c00b16373 100644 --- a/intern/ghost/SConscript +++ b/intern/ghost/SConscript @@ -56,9 +56,8 @@ else: if env['BF_GHOST_DEBUG']: defs.append('BF_GHOST_DEBUG') - + incs = '. ../string #extern/glew/include #source/blender/imbuf #source/blender/makesdna ' + env['BF_OPENGL_INC'] if window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-vc'): incs = env['BF_WINTAB_INC'] + ' ' + incs env.BlenderLib ('bf_ghost', sources, Split(incs), defines=defs, libtype=['intern','player'], priority = [40,15] ) - diff --git a/intern/ghost/intern/GHOST_WindowCarbon.cpp b/intern/ghost/intern/GHOST_WindowCarbon.cpp index 376859d3e16..a8295ec57d3 100644 --- a/intern/ghost/intern/GHOST_WindowCarbon.cpp +++ b/intern/ghost/intern/GHOST_WindowCarbon.cpp @@ -42,7 +42,7 @@ AGLContext GHOST_WindowCarbon::s_firstaglCtx = NULL; const GHOST_TInt32 GHOST_WindowCarbon::s_sizeRectSize = 16; #endif //GHOST_DRAW_CARBON_GUTTER -static const GLint sPreferredFormatWindow[8] = { +static const GLint sPreferredFormatWindow[10] = { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_ACCELERATED, @@ -50,7 +50,7 @@ AGL_DEPTH_SIZE, 32, AGL_NONE, }; -static const GLint sPreferredFormatFullScreen[9] = { +static const GLint sPreferredFormatFullScreen[11] = { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_ACCELERATED, diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 0b22017c92c..a97f7621bb0 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -348,10 +348,11 @@ GHOST_WindowCocoa::GHOST_WindowCocoa( pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated; //pixelFormatAttrsWindow[i++] = NSOpenGLPFAAllowOfflineRenderers,; // Removed to allow 10.4 builds, and 2 GPUs rendering is not used anyway - + pixelFormatAttrsWindow[i++] = NSOpenGLPFADepthSize; pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) 32; + if (stereoVisual) pixelFormatAttrsWindow[i++] = NSOpenGLPFAStereo; if (numOfAASamples>0) { diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index bbfa84dbae0..1366aebf9e7 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -1093,7 +1093,7 @@ static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd) { !(pfd.dwFlags & PFD_DRAW_TO_WINDOW) || !(pfd.dwFlags & PFD_DOUBLEBUFFER) || /* Blender _needs_ this */ ( pfd.cDepthBits <= 8 ) || - !(pfd.iPixelType == PFD_TYPE_RGBA) ) + !(pfd.iPixelType == PFD_TYPE_RGBA)) return 0; weight = 1; /* it's usable */ diff --git a/release/scripts/ui/properties_data_modifier.py b/release/scripts/ui/properties_data_modifier.py index 37764e20854..dfa0d8029b2 100644 --- a/release/scripts/ui/properties_data_modifier.py +++ b/release/scripts/ui/properties_data_modifier.py @@ -437,6 +437,7 @@ class DATA_PT_modifiers(DataButtonsPanel): col.prop(md, "levels", text="Preview") col.prop(md, "sculpt_levels", text="Sculpt") col.prop(md, "render_levels", text="Render") + col.prop(bpy.context.tool_settings.sculpt, "fast_navigate") if wide_ui: col = split.column() diff --git a/release/scripts/ui/properties_texture.py b/release/scripts/ui/properties_texture.py index 86f2d867d41..2bfbe188c9e 100644 --- a/release/scripts/ui/properties_texture.py +++ b/release/scripts/ui/properties_texture.py @@ -275,15 +275,12 @@ class TEXTURE_PT_mapping(TextureSlotPanel): if type(idblock) == bpy.types.Brush: if context.sculpt_object: + layout.label(text="Brush Mapping:") layout.prop(tex, "map_mode", expand=True) row = layout.row() row.active = tex.map_mode in ('FIXED', 'TILED') row.prop(tex, "angle") - - row = layout.row() - row.active = tex.map_mode in ('TILED', '3D') - row.column().prop(tex, "size") else: if type(idblock) == bpy.types.Material: split = layout.split(percentage=0.3) @@ -307,15 +304,17 @@ class TEXTURE_PT_mapping(TextureSlotPanel): row.prop(tex, "y_mapping", text="") row.prop(tex, "z_mapping", text="") - # any non brush - split = layout.split() + split = layout.split() + col = split.column() + col.prop(tex, "offset") + + if wide_ui: col = split.column() - col.prop(tex, "offset") + else: + col.separator() - if wide_ui: - col = split.column() - col.prop(tex, "size") + col.prop(tex, "size") class TEXTURE_PT_influence(TextureSlotPanel): diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index 44b6858bed3..61f759a1d83 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -327,7 +327,21 @@ class USERPREF_PT_edit(bpy.types.Panel): row.separator() row.separator() + sculpt = context.tool_settings.sculpt col = row.column() + col.label(text="Paint and Sculpt:") + col.prop(edit, "sculpt_paint_use_unified_size", text="Unify Size") + col.prop(edit, "sculpt_paint_use_unified_strength", text="Unify Strength") + row = col.row(align=True) + row.label("Overlay Color:") + row.prop(edit, "sculpt_paint_overlay_col", text="") + col.prop(sculpt, "use_openmp", text="Threaded Sculpt") + col.prop(sculpt, "show_brush") + + col.separator() + col.separator() + col.separator() + col.label(text="Duplicate Data:") col.prop(edit, "duplicate_mesh", text="Mesh") col.prop(edit, "duplicate_surface", text="Surface") diff --git a/release/scripts/ui/space_view3d_toolbar.py b/release/scripts/ui/space_view3d_toolbar.py index c503eaa9b3e..515fa236fc0 100644 --- a/release/scripts/ui/space_view3d_toolbar.py +++ b/release/scripts/ui/space_view3d_toolbar.py @@ -19,6 +19,7 @@ # import bpy +narrowui = bpy.context.user_preferences.view.properties_width_check class View3DPanel(bpy.types.Panel): bl_space_type = 'VIEW_3D' @@ -503,18 +504,26 @@ class VIEW3D_PT_tools_brush(PaintPanel): if not context.particle_edit_object: col = layout.split().column() - row = col.row() - if context.sculpt_object and brush: - defaultbrushes = 8 - elif context.texture_paint_object and brush: - defaultbrushes = 4 + if context.sculpt_object and context.tool_settings.sculpt: + col.template_ID_preview(settings, "brush", new="brush.add", filter="is_sculpt_brush", rows=3, cols=8) + elif context.texture_paint_object and context.tool_settings.image_paint: + col.template_ID_preview(settings, "brush", new="brush.add", filter="is_imapaint_brush", rows=3, cols=8) + elif context.vertex_paint_object and context.tool_settings.vertex_paint: + col.template_ID_preview(settings, "brush", new="brush.add", filter="is_vpaint_brush", rows=3, cols=8) + elif context.weight_paint_object and context.tool_settings.weight_paint: + col.template_ID_preview(settings, "brush", new="brush.add", filter="is_wpaint_brush", rows=3, cols=8) else: - defaultbrushes = 7 + row = col.row() - row.template_list(settings, "brushes", settings, "active_brush_index", rows=2, maxrows=defaultbrushes) + if context.sculpt_object and brush: + defaultbrushes = 8 + elif context.texture_paint_object and brush: + defaultbrushes = 4 + else: + defaultbrushes = 7 - col.template_ID(settings, "brush", new="brush.add") + row.template_list(settings, "brushes", settings, "active_brush_index", rows=2, maxrows=defaultbrushes) # Particle Mode # @@ -546,44 +555,152 @@ class VIEW3D_PT_tools_brush(PaintPanel): # Sculpt Mode # elif context.sculpt_object and brush: + edit = context.user_preferences.edit + col = layout.column() + + col.separator() row = col.row(align=True) - row.prop(brush, "size", slider=True) - if brush.sculpt_tool != 'GRAB': - row.prop(brush, "use_size_pressure", toggle=True, text="") + if edit.sculpt_paint_use_unified_size: + if edit.sculpt_paint_unified_lock_brush_size: + row.prop(edit, "sculpt_paint_unified_lock_brush_size", toggle=True, text="", icon='LOCKED') + row.prop(edit, "sculpt_paint_unified_unprojected_radius", text="Unified Radius", slider=True) + else: + row.prop(edit, "sculpt_paint_unified_lock_brush_size", toggle=True, text="", icon='UNLOCKED') + row.prop(edit, "sculpt_paint_unified_size", text="Unified Radius", slider=True) + + else: + if brush.lock_brush_size: + row.prop(brush, "lock_brush_size", toggle=True, text="", icon='LOCKED') + row.prop(brush, "unprojected_radius", text="Radius", slider=True) + else: + row.prop(brush, "lock_brush_size", toggle=True, text="", icon='UNLOCKED') + row.prop(brush, "size", text="Radius", slider=True) + + row.prop(brush, "use_size_pressure", toggle=True, text="") + + + if brush.sculpt_tool not in ('SNAKE_HOOK', 'GRAB', 'ROTATE'): + col.separator() row = col.row(align=True) - row.prop(brush, "strength", slider=True) + + if brush.use_space and brush.sculpt_tool not in ('SMOOTH'): + if brush.use_space_atten: + row.prop(brush, "use_space_atten", toggle=True, text="", icon='LOCKED') + else: + row.prop(brush, "use_space_atten", toggle=True, text="", icon='UNLOCKED') + + if edit.sculpt_paint_use_unified_strength: + row.prop(edit, "sculpt_paint_unified_strength", text="Unified Strength", slider=True) + else: + row.prop(brush, "strength", text="Strength", slider=True) + row.prop(brush, "use_strength_pressure", text="") - # XXX - TODO - #row = col.row(align=True) - #row.prop(brush, "jitter", slider=True) - #row.prop(brush, "use_jitter_pressure", toggle=True, text="") - col = layout.column() - if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'): - col.row().prop(brush, "direction", expand=True) + if brush.sculpt_tool not in ('SMOOTH'): + col.separator() - if brush.sculpt_tool in ('DRAW', 'INFLATE', 'LAYER'): - col.prop(brush, "use_accumulate") + row = col.row(align=True) + row.prop(brush, "autosmooth_factor", slider=True) + row.prop(brush, "use_inverse_smooth_pressure", toggle=True, text="") - if brush.sculpt_tool == 'LAYER': - ob = context.sculpt_object - do_persistent = True - # not supported yet for this case - for md in ob.modifiers: - if md.type == 'MULTIRES': - do_persistent = False - if do_persistent: - col.prop(brush, "use_persistent") - col.operator("sculpt.set_persistent_base") + if brush.sculpt_tool in ('GRAB', 'SNAKE_HOOK'): + col.separator() + + row = col.row(align=True) + row.prop(brush, "normal_weight", slider=True) + + + + if brush.sculpt_tool in ('CREASE', 'BLOB'): + col.separator() + + row = col.row(align=True) + row.prop(brush, "crease_pinch_factor", slider=True, text="Pinch") + + if brush.sculpt_tool not in ('PINCH', 'INFLATE', 'SMOOTH'): + row = col.row(align=True) + + col.separator() + + if brush.use_original_normal: + row.prop(brush, "use_original_normal", toggle=True, text="", icon='LOCKED') + else: + row.prop(brush, "use_original_normal", toggle=True, text="", icon='UNLOCKED') + + row.prop(brush, "sculpt_plane", text="") + + #if brush.sculpt_tool in ('CLAY', 'CLAY_TUBES', 'FLATTEN', 'FILL', 'SCRAPE'): + if brush.sculpt_tool in ('CLAY', 'FLATTEN', 'FILL', 'SCRAPE'): + row = col.row(align=True) + row.prop(brush, "plane_offset", slider=True) + row.prop(brush, "use_offset_pressure", text="") + + col.separator() + + row= col.row() + row.prop(brush, "use_plane_trim", text="Trim") + row= col.row() + row.active=brush.use_plane_trim + row.prop(brush, "plane_trim", slider=True, text="Distance") + + col.separator() + + row= col.row() + row.prop(brush, "use_frontface", text="Front Faces Only") + + #if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'LAYER', 'CLAY', 'CLAY_TUBES'): + if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'LAYER', 'CLAY'): + col.separator() + col.row().prop(brush, "direction", expand=True) + elif brush.sculpt_tool in ('FLATTEN'): + col.separator() + col.row().prop(brush, "flatten_contrast", expand=True) + elif brush.sculpt_tool in ('FILL'): + col.separator() + col.row().prop(brush, "fill_deepen", expand=True) + elif brush.sculpt_tool in ('SCRAPE'): + col.separator() + col.row().prop(brush, "scrape_peaks", expand=True) + elif brush.sculpt_tool in ('INFLATE'): + col.separator() + col.row().prop(brush, "inflate_deflate", expand=True) + elif brush.sculpt_tool in ('PINCH'): + col.separator() + col.row().prop(brush, "pinch_magnify", expand=True) + + + + #if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'INFLATE', 'LAYER', 'CLAY', 'CLAY_TUBES'): + if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'INFLATE', 'LAYER', 'CLAY'): + col.separator() + + col.prop(brush, "use_accumulate") + + + + if brush.sculpt_tool == 'LAYER': + col.separator() + + ob = context.sculpt_object + do_persistent = True + + # not supported yet for this case + for md in ob.modifiers: + if md.type == 'MULTIRES': + do_persistent = False + + if do_persistent: + col.prop(brush, "use_persistent") + col.operator("sculpt.set_persistent_base") # Texture Paint Mode # @@ -669,10 +786,88 @@ class VIEW3D_PT_tools_brush_texture(PaintPanel): col = layout.column() - col.template_ID_preview(brush, "texture", new="texture.new", rows=2, cols=4) + col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8) if context.sculpt_object: - col.row().prop(tex_slot, "map_mode", expand=True) + #XXX duplicated from properties_texture.py + + wide_ui = context.region.width > narrowui + + + col.separator() + + + col.label(text="Brush Mapping:") + row = col.row(align=True) + row.prop(tex_slot, "map_mode", expand=True) + + col.separator() + + col = layout.column() + col.active = tex_slot.map_mode in ('FIXED') + col.label(text="Angle:") + + col = layout.column() + if not brush.use_anchor and brush.sculpt_tool not in ('GRAB', 'SNAKE_HOOK', 'THUMB', 'ROTATE') and tex_slot.map_mode in ('FIXED'): + col.prop(brush, "texture_angle_source", text="") + else: + col.prop(brush, "texture_angle_source_no_random", text="") + + #row = col.row(align=True) + #row.label(text="Angle:") + #row.active = tex_slot.map_mode in ('FIXED', 'TILED') + + #row = col.row(align=True) + + #col = row.column() + #col.active = tex_slot.map_mode in ('FIXED') + #col.prop(brush, "use_rake", toggle=True, icon='PARTICLEMODE', text="") + + col = layout.column() + col.prop(tex_slot, "angle", text="") + col.active = tex_slot.map_mode in ('FIXED', 'TILED') + + #col = layout.column() + #col.prop(brush, "use_random_rotation") + #col.active = (not brush.use_rake) and (not brush.use_anchor) and brush.sculpt_tool not in ('GRAB', 'SNAKE_HOOK', 'THUMB', 'ROTATE') and tex_slot.map_mode in ('FIXED') + + split = layout.split() + + col = split.column() + col.prop(tex_slot, "offset") + + if wide_ui: + col = split.column() + else: + col.separator() + + col.prop(tex_slot, "size") + + col = layout.column() + + row = col.row(align=True) + row.label(text="Sample Bias:") + row = col.row(align=True) + row.prop(brush, "texture_sample_bias", slider=True, text="") + + row = col.row(align=True) + row.label(text="Overlay:") + row.active = tex_slot.map_mode in ('FIXED', 'TILED') + + row = col.row(align=True) + + col = row.column() + + if brush.use_texture_overlay: + col.prop(brush, "use_texture_overlay", toggle=True, text="", icon='MUTE_IPO_OFF') + else: + col.prop(brush, "use_texture_overlay", toggle=True, text="", icon='MUTE_IPO_ON') + + col.active = tex_slot.map_mode in ('FIXED', 'TILED') + + col = row.column() + col.prop(brush, "texture_overlay_alpha", text="Alpha") + col.active = tex_slot.map_mode in ('FIXED', 'TILED') and brush.use_texture_overlay class VIEW3D_PT_tools_brush_tool(PaintPanel): @@ -696,15 +891,11 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel): col = layout.column(align=True) if context.sculpt_object: - col.prop(brush, "sculpt_tool", expand=True) + col.prop(brush, "sculpt_tool", expand=False, text="") elif context.texture_paint_object: - col.prop(brush, "imagepaint_tool", expand=True) - #col.prop_enum(settings, "tool", 'DRAW') - #col.prop_enum(settings, "tool", 'SOFTEN') - #col.prop_enum(settings, "tool", 'CLONE') - #col.prop_enum(settings, "tool", 'SMEAR') + col.prop(brush, "imagepaint_tool", expand=False, text="") elif context.vertex_paint_object or context.weight_paint_object: - col.prop(brush, "vertexpaint_tool", expand=True) + col.prop(brush, "vertexpaint_tool", expand=False, text="") class VIEW3D_PT_tools_brush_stroke(PaintPanel): @@ -725,29 +916,83 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel): brush = settings.brush texture_paint = context.texture_paint_object - if context.sculpt_object: - if brush.sculpt_tool != 'LAYER': - layout.prop(brush, "use_anchor") - layout.prop(brush, "use_rake") - - layout.prop(brush, "use_airbrush") col = layout.column() - col.active = brush.use_airbrush - col.prop(brush, "rate", slider=True) - if not texture_paint: - layout.prop(brush, "use_smooth_stroke") + if context.sculpt_object: + col.label(text="Stroke Method:") + col.prop(brush, "stroke_method", text="") + + if brush.use_anchor: + col.separator() + row = col.row() + row.prop(brush, "edge_to_edge", "Edge To Edge") + + if brush.use_airbrush: + col.separator() + row = col.row() + row.prop(brush, "rate", text="Rate", slider=True) + + if brush.use_space: + col.separator() + row = col.row() + row.active = brush.use_space + row.prop(brush, "spacing", text="Spacing") + + if brush.sculpt_tool not in ('GRAB', 'THUMB', 'SNAKE_HOOK', 'ROTATE') and (not brush.use_anchor) and (not brush.restore_mesh): + col = layout.column() + col.separator() + + col.prop(brush, "use_smooth_stroke") + + sub = col.column() + sub.active = brush.use_smooth_stroke + sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True) + sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True) + + col.separator() + + row = col.row(align=True) + row.prop(brush, "jitter", slider=True) + row.prop(brush, "use_jitter_pressure", toggle=True, text="") + + else: + row = col.row() + row.prop(brush, "use_airbrush") + + row = col.row() + row.active = brush.use_airbrush and (not brush.use_space) and (not brush.use_anchor) + row.prop(brush, "rate", slider=True) + + col.separator() + + if not texture_paint: + row = col.row() + row.prop(brush, "use_smooth_stroke") + + col = layout.column() + col.active = brush.use_smooth_stroke + col.prop(brush, "smooth_stroke_radius", text="Radius", slider=True) + col.prop(brush, "smooth_stroke_factor", text="Factor", slider=True) + + col.separator() + col = layout.column() - col.active = brush.use_smooth_stroke - col.prop(brush, "smooth_stroke_radius", text="Radius", slider=True) - col.prop(brush, "smooth_stroke_factor", text="Factor", slider=True) + col.active = (not brush.use_anchor) and (brush.sculpt_tool not in ('GRAB', 'THUMB', 'ROTATE', 'SNAKE_HOOK')) - layout.prop(brush, "use_space") - row = layout.row(align=True) - row.active = brush.use_space - row.prop(brush, "spacing", text="Distance", slider=True) - if texture_paint: - row.prop(brush, "use_spacing_pressure", toggle=True, text="") + row = col.row() + row.prop(brush, "use_space") + + row = col.row() + row.active = brush.use_space + row.prop(brush, "spacing", text="Spacing") + + #col.prop(brush, "use_space_atten", text="Adaptive Strength") + #col.prop(brush, "use_adaptive_space", text="Adaptive Spacing") + + #col.separator() + + #if texture_paint: + # row.prop(brush, "use_spacing_pressure", toggle=True, text="") class VIEW3D_PT_tools_brush_curve(PaintPanel): @@ -767,13 +1012,17 @@ class VIEW3D_PT_tools_brush_curve(PaintPanel): layout.template_curve_mapping(brush, "curve", brush=True) row = layout.row(align=True) - row.operator("brush.curve_preset", text="Sharp").shape = 'SHARP' - row.operator("brush.curve_preset", text="Smooth").shape = 'SMOOTH' - row.operator("brush.curve_preset", text="Max").shape = 'MAX' - + row.operator("brush.curve_preset", icon="SMOOTHCURVE", text="").shape = 'SMOOTH' + row.operator("brush.curve_preset", icon="SPHERECURVE", text="").shape = 'ROUND' + row.operator("brush.curve_preset", icon="ROOTCURVE", text="").shape = 'ROOT' + row.operator("brush.curve_preset", icon="SHARPCURVE", text="").shape = 'SHARP' + row.operator("brush.curve_preset", icon="LINCURVE", text="").shape = 'LINE' + row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX' + row.operator("brush.curve_preset", icon="RNDCURVE", text="").shape = 'MID9' class VIEW3D_PT_sculpt_options(PaintPanel): bl_label = "Options" + bl_default_closed = True def poll(self, context): return (context.sculpt_object and context.tool_settings.sculpt) @@ -781,25 +1030,100 @@ class VIEW3D_PT_sculpt_options(PaintPanel): def draw(self, context): layout = self.layout + wide_ui = context.region.width > narrowui + sculpt = context.tool_settings.sculpt + settings = self.paint_settings(context) + brush = settings.brush - col = layout.column() - col.prop(sculpt, "show_brush") - col.prop(sculpt, "fast_navigate") - - split = self.layout.split() + split = layout.split() col = split.column() - col.label(text="Symmetry:") + + edit = context.user_preferences.edit + col.label(text="Unified Settings:") + col.prop(edit, "sculpt_paint_use_unified_size", text="Size") + col.prop(edit, "sculpt_paint_use_unified_strength", text="Strength") + + if wide_ui: + col = split.column() + else: + col.separator() + + col.label(text="Lock:") + row = col.row(align=True) + row.prop(sculpt, "lock_x", text="X", toggle=True) + row.prop(sculpt, "lock_y", text="Y", toggle=True) + row.prop(sculpt, "lock_z", text="Z", toggle=True) + +class VIEW3D_PT_sculpt_symmetry(PaintPanel): + bl_label = "Symmetry" + bl_default_closed = True + + def poll(self, context): + return (context.sculpt_object and context.tool_settings.sculpt) + + def draw(self, context): + wide_ui = context.region.width > narrowui + + layout = self.layout + + sculpt = context.tool_settings.sculpt + settings = self.paint_settings(context) + brush = settings.brush + + split = layout.split() + + col = split.column() + + col.label(text="Mirror:") col.prop(sculpt, "symmetry_x", text="X") col.prop(sculpt, "symmetry_y", text="Y") col.prop(sculpt, "symmetry_z", text="Z") - col = split.column() - col.label(text="Lock:") - col.prop(sculpt, "lock_x", text="X") - col.prop(sculpt, "lock_y", text="Y") - col.prop(sculpt, "lock_z", text="Z") + if wide_ui: + col = split.column() + else: + col.separator() + + col.prop(sculpt, "radial_symm", text="Radial") + + col = layout.column() + + col.separator() + + col.prop(sculpt, "use_symmetry_feather", text="Feather") + +class VIEW3D_PT_tools_brush_appearance(PaintPanel): + bl_label = "Appearance" + bl_default_closed = True + + def poll(self, context): + return (context.sculpt_object and context.tool_settings.sculpt) or (context.vertex_paint_object and context.tool_settings.vertex_paint) or (context.weight_paint_object and context.tool_settings.weight_paint) or (context.texture_paint_object and context.tool_settings.image_paint) + + def draw(self, context): + layout = self.layout + + sculpt = context.tool_settings.sculpt + settings = self.paint_settings(context) + brush = settings.brush + + col = layout.column(); + + if context.sculpt_object and context.tool_settings.sculpt: + #if brush.sculpt_tool in ('DRAW', 'INFLATE', 'CLAY', 'CLAY_TUBES', 'PINCH', 'CREASE', 'BLOB', 'FLATTEN'): + if brush.sculpt_tool in ('DRAW', 'INFLATE', 'CLAY', 'PINCH', 'CREASE', 'BLOB', 'FLATTEN'): + col.prop(brush, "add_col", text="Add Color") + col.prop(brush, "sub_col", text="Substract Color") + else: + col.prop(brush, "add_col", text="Color") + + col.separator() + + col = layout.column() + col.label(text="Icon:") + #col.template_ID_preview(brush, "image_icon", open="image.open", filter="is_image_icon", rows=3, cols=8) + col.template_ID_preview(brush, "image_icon", open="image.open", rows=3, cols=8) # ********** default tools for weightpaint **************** @@ -1049,9 +1373,11 @@ classes = [ VIEW3D_PT_tools_posemode_options, VIEW3D_PT_tools_brush, VIEW3D_PT_tools_brush_texture, - VIEW3D_PT_tools_brush_tool, VIEW3D_PT_tools_brush_stroke, VIEW3D_PT_tools_brush_curve, + VIEW3D_PT_tools_brush_appearance, + VIEW3D_PT_tools_brush_tool, + VIEW3D_PT_sculpt_symmetry, VIEW3D_PT_sculpt_options, VIEW3D_PT_tools_vertexpaint, VIEW3D_PT_tools_weightpaint_options, diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 7ac5815943a..5936805765d 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -43,9 +43,9 @@ struct bContext; struct ReportList; struct Scene; struct Main; - + #define BLENDER_VERSION 252 -#define BLENDER_SUBVERSION 5 +#define BLENDER_SUBVERSION 6 // XXX: this shouldn't be merged with trunk, this is so Sculpt branch can detect old files #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index fcc636215c9..6a209167f93 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -84,5 +84,15 @@ unsigned int *brush_gen_texture_cache(struct Brush *br, int half_side); void brush_radial_control_invoke(struct wmOperator *op, struct Brush *br, float size_weight); int brush_radial_control_exec(struct wmOperator *op, struct Brush *br, float size_weight); +/* unified strength and size */ +int sculpt_get_brush_size(struct Brush *brush); +void sculpt_set_brush_size(struct Brush *brush, int size); +int sculpt_get_lock_brush_size(struct Brush *brush); +float sculpt_get_brush_unprojected_radius(struct Brush *brush); +void sculpt_set_brush_unprojected_radius(struct Brush *brush, float unprojected_radius); +float sculpt_get_brush_alpha(struct Brush *brush); +void sculpt_set_brush_alpha(struct Brush *brush, float alpha); + + #endif diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index cd412ca5a74..f9954b3d55d 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -28,6 +28,8 @@ #ifndef BKE_PAINT_H #define BKE_PAINT_H +#include "DNA_vec_types.h" + struct Brush; struct MFace; struct MultireModifierData; @@ -96,6 +98,8 @@ typedef struct SculptSession { struct GPUDrawObject *drawobject; int modifiers_active; + + rcti previous_r; } SculptSession; void free_sculptsession(struct Object *ob); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 538012ccc41..c423d426e32 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -53,8 +53,7 @@ #include "BKE_main.h" #include "BKE_paint.h" #include "BKE_texture.h" - - +#include "BKE_icons.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -70,29 +69,59 @@ Brush *add_brush(const char *name) brush= alloc_libblock(&G.main->brush, ID_BR, name); - brush->rgb[0]= 1.0f; + /* BRUSH SCULPT TOOL SETTINGS */ + brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */ + brush->size= 35; /* radius of the brush in pixels */ + brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */ + brush->autosmooth_factor= 0.0f; + brush->crease_pinch_factor= 0.5f; + brush->sculpt_plane = SCULPT_DISP_DIR_VIEW; + brush->plane_offset= 0.0f; /* how far above or below the plane that is found by averaging the faces */ + brush->plane_trim= 0.5f; + brush->clone.alpha= 0.5f; + brush->normal_weight= 0.0f; + + /* BRUSH PAINT TOOL SETTINGS */ + brush->rgb[0]= 1.0f; /* default rgb color of the brush when painting - white */ brush->rgb[1]= 1.0f; brush->rgb[2]= 1.0f; - brush->alpha= 0.2f; - brush->size= 25; - brush->spacing= 3.5f; - brush->smooth_stroke_radius= 75; - brush->smooth_stroke_factor= 0.9; - brush->rate= 0.1f; - brush->jitter= 0.0f; - brush->clone.alpha= 0.5; - brush->sculpt_tool = SCULPT_TOOL_DRAW; - brush->flag |= BRUSH_SPACE; - brush_curve_preset(brush, CURVE_PRESET_SMOOTH); - + /* BRUSH STROKE SETTINGS */ + brush->flag |= (BRUSH_SPACE|BRUSH_SPACE_ATTEN); + brush->spacing= 10; /* how far each brush dot should be spaced as a percentage of brush diameter */ + + brush->smooth_stroke_radius= 75; + brush->smooth_stroke_factor= 0.9f; + + brush->rate= 0.1f; /* time delay between dots of paint or sculpting when doing airbrush mode */ + + brush->jitter= 0.0f; + + /* BRUSH TEXTURE SETTINGS */ default_mtex(&brush->mtex); + brush->texture_sample_bias= 0; /* value to added to texture samples */ + + /* brush appearance */ + + brush->image_icon= NULL; + + brush->add_col[0]= 1.00; /* add mode color is light red */ + brush->add_col[1]= 0.39; + brush->add_col[2]= 0.39; + + brush->sub_col[0]= 0.39; /* subtract mode color is light blue */ + brush->sub_col[1]= 0.39; + brush->sub_col[2]= 1.00; + + /* the default alpha falloff curve */ + brush_curve_preset(brush, CURVE_PRESET_SMOOTH); + /* enable fake user by default */ brush->id.flag |= LIB_FAKEUSER; brush_toggled_fake_user(brush); - - return brush; + + return brush; } Brush *copy_brush(Brush *brush) @@ -118,7 +147,7 @@ Brush *copy_brush(Brush *brush) void free_brush(Brush *brush) { if(brush->mtex.tex) brush->mtex.tex->id.us--; - + curvemapping_free(brush->curve); } @@ -731,11 +760,19 @@ static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pres brush->spacing = MAX2(1.0, painter->startspacing*(1.5f-pressure)); } -static void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos) +void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos) { if(brush->jitter){ - jitterpos[0] = pos[0] + ((BLI_frand()-0.5f) * brush->size * brush->jitter * 2); - jitterpos[1] = pos[1] + ((BLI_frand()-0.5f) * brush->size * brush->jitter * 2); + float rand_pos[2]; + + // find random position within a circle of diameter 1 + do { + rand_pos[0] = BLI_frand()-0.5f; + rand_pos[1] = BLI_frand()-0.5f; + } while (len_v2(rand_pos) > 0.5f); + + jitterpos[0] = pos[0] + 2*rand_pos[0]*brush->size*brush->jitter; + jitterpos[1] = pos[1] + 2*rand_pos[1]*brush->size*brush->jitter; } else { VECCOPY2D(jitterpos, pos); @@ -887,7 +924,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl /* Uses the brush curve control to find a strength value between 0 and 1 */ float brush_curve_strength_clamp(Brush *br, float p, const float len) { - if(p >= len) p= 1.0f; + if(p >= len) return 0; else p= p/len; p= curvemapping_evaluateF(br->curve, 0, p); @@ -899,9 +936,12 @@ float brush_curve_strength_clamp(Brush *br, float p, const float len) * used for sculpt only */ float brush_curve_strength(Brush *br, float p, const float len) { - if(p >= len) p= 1.0f; - else p= p/len; - return curvemapping_evaluateF(br->curve, 0, p); + if(p >= len) + p= 1.0f; + else + p= p/len; + + return curvemapping_evaluateF(br->curve, 0, p); } /* TODO: should probably be unified with BrushPainter stuff? */ @@ -915,7 +955,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side) memset(&texres, 0, sizeof(TexResult)); - if(mtex && mtex->tex) { + if(mtex->tex) { float x, y, step = 2.0 / side, co[3]; texcache = MEM_callocN(sizeof(int) * side * side, "Brush texture cache"); @@ -993,9 +1033,9 @@ void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight) float original_value= 0; if(mode == WM_RADIALCONTROL_SIZE) - original_value = br->size * size_weight; + original_value = sculpt_get_brush_size(br) * size_weight; else if(mode == WM_RADIALCONTROL_STRENGTH) - original_value = br->alpha; + original_value = sculpt_get_brush_alpha(br); else if(mode == WM_RADIALCONTROL_ANGLE) { MTex *mtex = brush_active_texture(br); if(mtex) @@ -1013,9 +1053,15 @@ int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight) const float conv = 0.017453293; if(mode == WM_RADIALCONTROL_SIZE) - br->size = new_value * size_weight; + if (sculpt_get_lock_brush_size(br)) { + float initial_value = RNA_float_get(op->ptr, "initial_value"); + const float unprojected_radius = sculpt_get_brush_unprojected_radius(br); + sculpt_set_brush_unprojected_radius(br, unprojected_radius * new_value/initial_value * size_weight); + } + else + sculpt_set_brush_size(br, new_value * size_weight); else if(mode == WM_RADIALCONTROL_STRENGTH) - br->alpha = new_value; + sculpt_set_brush_alpha(br, new_value); else if(mode == WM_RADIALCONTROL_ANGLE) { MTex *mtex = brush_active_texture(br); if(mtex) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index c8a01b1c12f..a07c18f42f3 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -126,6 +126,9 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa cumap->cm[a].curve[1].x= maxx; cumap->cm[a].curve[1].y= maxy; } + + cumap->changed_timestamp = 0; + return cumap; } @@ -240,10 +243,12 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset) switch(preset) { case CURVE_PRESET_LINE: cuma->totpoint= 2; break; - case CURVE_PRESET_SHARP: cuma->totpoint= 3; break; + case CURVE_PRESET_SHARP: cuma->totpoint= 4; break; case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break; case CURVE_PRESET_MAX: cuma->totpoint= 2; break; - case CURVE_PRESET_MID9: cuma->totpoint= 9; + case CURVE_PRESET_MID9: cuma->totpoint= 9; break; + case CURVE_PRESET_ROUND: cuma->totpoint= 4; break; + case CURVE_PRESET_ROOT: cuma->totpoint= 4; break; } cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points"); @@ -251,27 +256,29 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset) switch(preset) { case CURVE_PRESET_LINE: cuma->curve[0].x= clipr->xmin; - cuma->curve[0].y= clipr->ymin; + cuma->curve[0].y= clipr->ymax; cuma->curve[0].flag= 0; cuma->curve[1].x= clipr->xmax; - cuma->curve[1].y= clipr->ymax; + cuma->curve[1].y= clipr->ymin; cuma->curve[1].flag= 0; break; case CURVE_PRESET_SHARP: cuma->curve[0].x= 0; cuma->curve[0].y= 1; - cuma->curve[1].x= 0.33; - cuma->curve[1].y= 0.33; - cuma->curve[2].x= 1; - cuma->curve[2].y= 0; + cuma->curve[1].x= 0.25; + cuma->curve[1].y= 0.50; + cuma->curve[2].x= 0.75; + cuma->curve[2].y= 0.04; + cuma->curve[3].x= 1; + cuma->curve[3].y= 0; break; case CURVE_PRESET_SMOOTH: cuma->curve[0].x= 0; cuma->curve[0].y= 1; cuma->curve[1].x= 0.25; - cuma->curve[1].y= 0.92; + cuma->curve[1].y= 0.94; cuma->curve[2].x= 0.75; - cuma->curve[2].y= 0.08; + cuma->curve[2].y= 0.06; cuma->curve[3].x= 1; cuma->curve[3].y= 0; break; @@ -290,8 +297,29 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset) cuma->curve[i].y= 0.5; } } + break; + case CURVE_PRESET_ROUND: + cuma->curve[0].x= 0; + cuma->curve[0].y= 1; + cuma->curve[1].x= 0.5; + cuma->curve[1].y= 0.90; + cuma->curve[2].x= 0.86; + cuma->curve[2].y= 0.5; + cuma->curve[3].x= 1; + cuma->curve[3].y= 0; + break; + case CURVE_PRESET_ROOT: + cuma->curve[0].x= 0; + cuma->curve[0].y= 1; + cuma->curve[1].x= 0.25; + cuma->curve[1].y= 0.95; + cuma->curve[2].x= 0.75; + cuma->curve[2].y= 0.44; + cuma->curve[3].x= 1; + cuma->curve[3].y= 0; + break; } - + if(cuma->table) { MEM_freeN(cuma->table); cuma->table= NULL; @@ -619,7 +647,9 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) float thresh= 0.01f*(clipr->xmax - clipr->xmin); float dx= 0.0f, dy= 0.0f; int a; - + + cumap->changed_timestamp++; + /* clamp with clip */ if(cumap->flag & CUMA_DO_CLIP) { for(a=0; atotpoint; a++) { @@ -701,7 +731,7 @@ float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value) if(cuma->table==NULL) { curvemap_make_table(cuma, &cumap->clipr); if(cuma->table==NULL) - return value; + return 1.0f-value; } return curvemap_evaluateF(cuma, value); } diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 29314fb4865..ad2c857be75 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -38,6 +38,7 @@ #include "DNA_material_types.h" #include "DNA_texture_types.h" #include "DNA_world_types.h" +#include "DNA_brush_types.h" #include "BLI_ghash.h" @@ -120,6 +121,7 @@ struct PreviewImage* BKE_previewimg_create() for (i=0; ichanged[i] = 1; + prv_img->changed_timestamp[i] = 0; } return prv_img; } @@ -202,7 +204,7 @@ PreviewImage* BKE_previewimg_get(ID *id) Image *img = (Image*)id; if (!img->preview) img->preview = BKE_previewimg_create(); prv_img = img->preview; - } + } return prv_img; } @@ -224,6 +226,7 @@ void BKE_icon_changed(int id) int i; for (i=0; ichanged[i] = 1; + prv->changed_timestamp[i]++; } } } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index dc78dac04dd..b66b5c60916 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -200,9 +200,9 @@ void free_image(Image *ima) } BKE_icon_delete(&ima->id); ima->id.icon_id = 0; - if (ima->preview) { - BKE_previewimg_free(&ima->preview); - } + + BKE_previewimg_free(&ima->preview); + for(a=0; arenders[a]) { RE_FreeRenderResult(ima->renders[a]); diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h index 519e3ddde1d..4797aeb2364 100644 --- a/source/blender/blenlib/BLI_pbvh.h +++ b/source/blender/blenlib/BLI_pbvh.h @@ -36,12 +36,17 @@ struct ListBase; typedef struct PBVH PBVH; typedef struct PBVHNode PBVHNode; +typedef struct { + float (*co)[3]; +} PBVHProxyNode; + /* Callbacks */ /* returns 1 if the search should continue from this node, 0 otherwise */ typedef int (*BLI_pbvh_SearchCallback)(PBVHNode *node, void *data); typedef void (*BLI_pbvh_HitCallback)(PBVHNode *node, void *data); +typedef void (*BLI_pbvh_HitOccludedCallback)(PBVHNode *node, void *data, float* tmin); /* Building */ @@ -70,7 +75,7 @@ void BLI_pbvh_search_gather(PBVH *bvh, it's up to the callback to find the primitive within the leaves that is hit first */ -void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitCallback cb, void *data, +void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data, float ray_start[3], float ray_normal[3], int original); int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3], float ray_start[3], float ray_normal[3], float *dist); @@ -106,6 +111,8 @@ void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node, void BLI_pbvh_node_get_BB(PBVHNode *node, float bb_min[3], float bb_max[3]); void BLI_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max[3]); +float BLI_pbvh_node_get_tmin(PBVHNode* node); + /* Update Normals/Bounding Box/Draw Buffers/Redraw and clear flags */ void BLI_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]); @@ -159,13 +166,21 @@ typedef struct PBVHVertexIter { float *fno; } PBVHVertexIter; +#ifdef _MSC_VER +#pragma warning (disable:4127) // conditional expression is constant +#endif + #define BLI_pbvh_vertex_iter_begin(bvh, node, vi, mode) \ { \ struct DMGridData **grids; \ struct MVert *verts; \ int *grid_indices, totgrid, gridsize, *vert_indices, uniq_verts, totvert; \ \ - memset(&vi, 0, sizeof(PBVHVertexIter)); \ + vi.grid= 0; \ + vi.no= 0; \ + vi.fno= 0; \ + vi.mvert= 0; \ + vi.skip= 0; \ \ BLI_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids, NULL); \ BLI_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert); \ @@ -222,6 +237,13 @@ typedef struct PBVHVertexIter { } \ } +void BLI_pbvh_node_get_proxies(PBVHNode* node, PBVHProxyNode** proxies, int* proxy_count); +void BLI_pbvh_node_free_proxies(PBVHNode* node); +PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node); +void BLI_pbvh_gather_proxies(PBVH* pbvh, PBVHNode*** nodes, int* totnode); + +//void BLI_pbvh_node_BB_reset(PBVHNode* node); +//void BLI_pbvh_node_BB_expand(PBVHNode* node, float co[3]); #endif /* BLI_PBVH_H */ diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 0a06cd10e1e..e8fb922ce4d 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -62,6 +62,7 @@ float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const floa n[0]= n1[1]*n2[2]-n1[2]*n2[1]; n[1]= n1[2]*n2[0]-n1[0]*n2[2]; n[2]= n1[0]*n2[1]-n1[1]*n2[0]; + return normalize_v3(n); } @@ -401,16 +402,17 @@ int isect_line_tri_v3(float p1[3], float p2[3], float v0[3], float v1[3], float sub_v3_v3v3(s, p1, v0); - cross_v3_v3v3(q, s, e1); - *lambda = f * dot_v3v3(e2, q); - if ((*lambda < 0.0)||(*lambda > 1.0)) return 0; - u = f * dot_v3v3(s, p); if ((u < 0.0)||(u > 1.0)) return 0; - v = f * dot_v3v3(d, q); + cross_v3_v3v3(q, s, e1); + + v = f * dot_v3v3(d, q); if ((v < 0.0)||((u + v) > 1.0)) return 0; + *lambda = f * dot_v3v3(e2, q); + if ((*lambda < 0.0)||(*lambda > 1.0)) return 0; + if(uv) { uv[0]= u; uv[1]= v; @@ -440,17 +442,18 @@ int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2 sub_v3_v3v3(s, p1, v0); - cross_v3_v3v3(q, s, e1); - *lambda = f * dot_v3v3(e2, q); - if ((*lambda < 0.0)) return 0; - u = f * dot_v3v3(s, p); if ((u < 0.0)||(u > 1.0)) return 0; + cross_v3_v3v3(q, s, e1); + v = f * dot_v3v3(d, q); if ((v < 0.0)||((u + v) > 1.0)) return 0; - if(uv) { + *lambda = f * dot_v3v3(e2, q); + if ((*lambda < 0.0)) return 0; + + if(uv) { uv[0]= u; uv[1]= v; } @@ -460,36 +463,36 @@ int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2 int isect_ray_tri_epsilon_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float epsilon) { - float p[3], s[3], e1[3], e2[3], q[3]; - float a, f, u, v; - - sub_v3_v3v3(e1, v1, v0); - sub_v3_v3v3(e2, v2, v0); - - cross_v3_v3v3(p, d, e2); - a = dot_v3v3(e1, p); - if (a == 0.0f) return 0; - f = 1.0f/a; - - sub_v3_v3v3(s, p1, v0); - - cross_v3_v3v3(q, s, e1); + float p[3], s[3], e1[3], e2[3], q[3]; + float a, f, u, v; - u = f * dot_v3v3(s, p); - if ((u < -epsilon)||(u > 1.0f+epsilon)) return 0; - - v = f * dot_v3v3(d, q); - if ((v < -epsilon)||((u + v) > 1.0f+epsilon)) return 0; + sub_v3_v3v3(e1, v1, v0); + sub_v3_v3v3(e2, v2, v0); - *lambda = f * dot_v3v3(e2, q); - if ((*lambda < 0.0f)) return 0; + cross_v3_v3v3(p, d, e2); + a = dot_v3v3(e1, p); + if (a == 0.0f) return 0; + f = 1.0f/a; - if(uv) { - uv[0]= u; - uv[1]= v; - } - - return 1; + sub_v3_v3v3(s, p1, v0); + + u = f * dot_v3v3(s, p); + if ((u < -epsilon)||(u > 1.0f+epsilon)) return 0; + + cross_v3_v3v3(q, s, e1); + + v = f * dot_v3v3(d, q); + if ((v < -epsilon)||((u + v) > 1.0f+epsilon)) return 0; + + *lambda = f * dot_v3v3(e2, q); + if ((*lambda < 0.0f)) return 0; + + if(uv) { + uv[0]= u; + uv[1]= v; + } + + return 1; } int isect_ray_tri_threshold_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float threshold) diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 426181e5304..7069eeea510 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -92,6 +92,11 @@ struct PBVHNode { unsigned int uniq_verts, face_verts; char flag; + + float tmin; // used for raycasting, is how close bb is to the ray point + + int proxy_count; + PBVHProxyNode* proxies; }; struct PBVH { @@ -227,6 +232,17 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node) node->vb= vb; } +//void BLI_pbvh_node_BB_reset(PBVHNode* node) +//{ +// BB_reset(&node->vb); +//} +// +//void BLI_pbvh_node_BB_expand(PBVHNode* node, float co[3]) +//{ +// BB_expand(&node->vb, co); +//} + + /* Adapted from BLI_kdopbvh.c */ /* Returns the index of the first element on the right of the partition */ static int partition_indices(int *prim_indices, int lo, int hi, int axis, @@ -354,10 +370,10 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) if(!G.background) { node->draw_buffers = GPU_build_mesh_buffers(map, bvh->verts, bvh->faces, - node->prim_indices, - node->totprim, node->vert_indices, - node->uniq_verts, - node->uniq_verts + node->face_verts); + node->prim_indices, + node->totprim, node->vert_indices, + node->uniq_verts, + node->uniq_verts + node->face_verts); } node->flag |= PBVH_UpdateDrawBuffers; @@ -641,13 +657,12 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter) { PBVHNode *node; int revisiting; - void *search_data; /* purpose here is to traverse tree, visiting child nodes before their parents, this order is necessary for e.g. computing bounding boxes */ while(iter->stacksize) { - /* pop node */ + /* pop node */ iter->stacksize--; node= iter->stack[iter->stacksize].node; @@ -662,10 +677,7 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter) if(revisiting) return node; - /* check search callback */ - search_data= iter->search_data; - - if(iter->scb && !iter->scb(node, search_data)) + if(iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */ if(node->flag & PBVH_Leaf) { @@ -685,6 +697,34 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter) return NULL; } +static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter) +{ + PBVHNode *node; + + while(iter->stacksize) { + /* pop node */ + iter->stacksize--; + node= iter->stack[iter->stacksize].node; + + /* on a mesh with no faces this can happen + * can remove this check if we know meshes have at least 1 face */ + if(node==NULL) return NULL; + + if(iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */ + + if(node->flag & PBVH_Leaf) { + /* immediately hit leaf node */ + return node; + } + else { + pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0); + pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0); + } + } + + return NULL; +} + void BLI_pbvh_search_gather(PBVH *bvh, BLI_pbvh_SearchCallback scb, void *search_data, PBVHNode ***r_array, int *r_tot) @@ -736,12 +776,105 @@ void BLI_pbvh_search_callback(PBVH *bvh, pbvh_iter_begin(&iter, bvh, scb, search_data); while((node=pbvh_iter_next(&iter))) - if(node->flag & PBVH_Leaf) + if (node->flag & PBVH_Leaf) hcb(node, hit_data); pbvh_iter_end(&iter); } +typedef struct node_tree { + PBVHNode* data; + + struct node_tree* left; + struct node_tree* right; +} node_tree; + +static void node_tree_insert(node_tree* tree, node_tree* new_node) +{ + if (new_node->data->tmin < tree->data->tmin) { + if (tree->left) { + node_tree_insert(tree->left, new_node); + } + else { + tree->left = new_node; + } + } + else { + if (tree->right) { + node_tree_insert(tree->right, new_node); + } + else { + tree->right = new_node; + } + } +} + +static void traverse_tree(node_tree* tree, BLI_pbvh_HitOccludedCallback hcb, void* hit_data, float* tmin) +{ + if (tree->left) traverse_tree(tree->left, hcb, hit_data, tmin); + + hcb(tree->data, hit_data, tmin); + + if (tree->right) traverse_tree(tree->right, hcb, hit_data, tmin); +} + +static void free_tree(node_tree* tree) +{ + if (tree->left) { + free_tree(tree->left); + tree->left = 0; + } + + if (tree->right) { + free_tree(tree->right); + tree->right = 0; + } + + free(tree); +} + +float BLI_pbvh_node_get_tmin(PBVHNode* node) +{ + return node->tmin; +} + +void BLI_pbvh_search_callback_occluded(PBVH *bvh, + BLI_pbvh_SearchCallback scb, void *search_data, + BLI_pbvh_HitOccludedCallback hcb, void *hit_data) +{ + PBVHIter iter; + PBVHNode *node; + node_tree *tree = 0; + + pbvh_iter_begin(&iter, bvh, scb, search_data); + + while((node=pbvh_iter_next_occluded(&iter))) { + if(node->flag & PBVH_Leaf) { + node_tree* new_node = malloc(sizeof(node_tree)); + + new_node->data = node; + + new_node->left = NULL; + new_node->right = NULL; + + if (tree) { + node_tree_insert(tree, new_node); + } + else { + tree = new_node; + } + } + } + + pbvh_iter_end(&iter); + + if (tree) { + float tmin = FLT_MAX; + traverse_tree(tree, hcb, hit_data, &tmin); + free_tree(tree); + } +} + static int update_search_cb(PBVHNode *node, void *data_v) { int flag= GET_INT_FROM_POINTER(data_v); @@ -985,7 +1118,8 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot GHashIterator *hiter; GHash *map; void *face, **faces; - int i, tot; + unsigned i; + int tot; map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "pbvh_get_grid_updates gh"); @@ -1086,6 +1220,18 @@ void BLI_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max copy_v3_v3(bb_max, node->orig_vb.bmax); } +void BLI_pbvh_node_get_proxies(PBVHNode* node, PBVHProxyNode** proxies, int* proxy_count) +{ + if (node->proxy_count > 0) { + if (proxies) *proxies = node->proxies; + if (proxy_count) *proxy_count = node->proxy_count; + } + else { + if (proxies) *proxies = 0; + if (proxy_count) *proxy_count = 0; + } +} + /********************************* Raycast ***********************************/ typedef struct { @@ -1100,16 +1246,13 @@ typedef struct { static int ray_aabb_intersect(PBVHNode *node, void *data_v) { RaycastData *ray = data_v; - float bb_min[3], bb_max[3], bbox[2][3]; + float bbox[2][3]; float tmin, tmax, tymin, tymax, tzmin, tzmax; if(ray->original) - BLI_pbvh_node_get_original_BB(node, bb_min, bb_max); + BLI_pbvh_node_get_original_BB(node, bbox[0], bbox[1]); else - BLI_pbvh_node_get_BB(node, bb_min, bb_max); - - copy_v3_v3(bbox[0], bb_min); - copy_v3_v3(bbox[1], bb_max); + BLI_pbvh_node_get_BB(node, bbox[0], bbox[1]); tmin = (bbox[ray->sign[0]][0] - ray->start[0]) * ray->inv_dir[0]; tmax = (bbox[1-ray->sign[0]][0] - ray->start[0]) * ray->inv_dir[0]; @@ -1119,8 +1262,10 @@ static int ray_aabb_intersect(PBVHNode *node, void *data_v) if((tmin > tymax) || (tymin > tmax)) return 0; + if(tymin > tmin) tmin = tymin; + if(tymax < tmax) tmax = tymax; @@ -1129,20 +1274,20 @@ static int ray_aabb_intersect(PBVHNode *node, void *data_v) if((tmin > tzmax) || (tzmin > tmax)) return 0; - + + if(tzmin > tmin) + tmin = tzmin; + + // XXX jwilkins: tmax does not need to be updated since we don't use it + // keeping this here for future reference + //if(tzmax < tmax) tmax = tzmax; + + node->tmin = tmin; + return 1; - - /* XXX: Not sure about this? - if(tzmin > tmin) - tmin = tzmin; - if(tzmax < tmax) - tmax = tzmax; - return ((tmin < t1) && (tmax > t0)); - */ - } -void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitCallback cb, void *data, +void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data, float ray_start[3], float ray_normal[3], int original) { RaycastData rcd; @@ -1156,37 +1301,24 @@ void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitCallback cb, void *data, rcd.sign[2] = rcd.inv_dir[2] < 0; rcd.original = original; - BLI_pbvh_search_callback(bvh, ray_aabb_intersect, &rcd, cb, data); + BLI_pbvh_search_callback_occluded(bvh, ray_aabb_intersect, &rcd, cb, data); } -/* XXX: Code largely copied from bvhutils.c, could be unified */ -/* Returns 1 if a better intersection has been found */ static int ray_face_intersection(float ray_start[3], float ray_normal[3], float *t0, float *t1, float *t2, float *t3, float *fdist) { - int hit = 0; + float dist; - do - { - float dist = FLT_MAX; - - if(!isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, - &dist, NULL, 0.1f)) - dist = FLT_MAX; - - if(dist >= 0 && dist < *fdist) { - hit = 1; - *fdist = dist; - } - - t1 = t2; - t2 = t3; - t3 = NULL; - - } while(t2); - - return hit; + if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist, NULL, 0.1f) && dist < *fdist) || + (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist)) + { + *fdist = dist; + return 1; + } + else { + return 0; + } } int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3], @@ -1399,3 +1531,86 @@ int BLI_pbvh_isDeformed(PBVH *pbvh) { return pbvh->deformed; } +/* Proxies */ + +PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node) +{ + int index, totverts; + + #pragma omp critical + { + + index = node->proxy_count; + + node->proxy_count++; + + if (node->proxies) + node->proxies= MEM_reallocN(node->proxies, node->proxy_count*sizeof(PBVHProxyNode)); + else + node->proxies= MEM_mallocN(sizeof(PBVHProxyNode), "PBVHNodeProxy"); + + if (bvh->grids) + totverts = node->totprim*bvh->gridsize*bvh->gridsize; + else + totverts = node->uniq_verts; + + node->proxies[index].co= MEM_callocN(sizeof(float[3])*totverts, "PBVHNodeProxy.co"); + } + + return node->proxies + index; +} + +void BLI_pbvh_node_free_proxies(PBVHNode* node) +{ + #pragma omp critical + { + int p; + + for (p= 0; p < node->proxy_count; p++) { + MEM_freeN(node->proxies[p].co); + node->proxies[p].co= 0; + } + + MEM_freeN(node->proxies); + node->proxies = 0; + + node->proxy_count= 0; + } +} + +void BLI_pbvh_gather_proxies(PBVH* pbvh, PBVHNode*** r_array, int* r_tot) +{ + PBVHNode **array= NULL, **newarray, *node; + int tot= 0, space= 0; + int n; + + for (n= 0; n < pbvh->totnode; n++) { + node = pbvh->nodes + n; + + if(node->proxy_count > 0) { + if(tot == space) { + /* resize array if needed */ + space= (tot == 0)? 32: space*2; + newarray= MEM_callocN(sizeof(PBVHNode)*space, "BLI_pbvh_gather_proxies"); + + if (array) { + memcpy(newarray, array, sizeof(PBVHNode)*tot); + MEM_freeN(array); + } + + array= newarray; + } + + array[tot]= node; + tot++; + } + } + + if(tot == 0 && array) { + MEM_freeN(array); + array= NULL; + } + + *r_array= array; + *r_tot= tot; +} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f6122161130..7b29ab2a666 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1539,6 +1539,7 @@ static void lib_link_brush(FileData *fd, Main *main) brush->id.flag -= LIB_NEEDLINK; brush->mtex.tex= newlibadr_us(fd, brush->id.lib, brush->mtex.tex); + brush->image_icon= newlibadr_us(fd, brush->id.lib, brush->image_icon); brush->clone.image= newlibadr_us(fd, brush->id.lib, brush->clone.image); } } @@ -10971,6 +10972,82 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + { + /* GSOC 2010 Sculpt - New settings for Brush */ + + Brush *brush; + for (brush= main->brush.first; brush; brush= brush->id.next) { + /* Sanity Check */ + + // infinite number of dabs + if (brush->spacing == 0) + brush->spacing = 10; + + // will have no effect + if (brush->alpha == 0) + brush->alpha = 0.5f; + + // bad radius + if (brush->unprojected_radius == 0) + brush->unprojected_radius = 0.125; + + // unusable size + if (brush->size == 0) + brush->size = 35; + + // can't see overlay + if (brush->texture_overlay_alpha == 0) + brush->texture_overlay_alpha = 33; + + // same as draw brush + if (brush->crease_pinch_factor == 0) + brush->crease_pinch_factor = 0.5f; + + // will sculpt no vertexes + if (brush->plane_trim == 0) + brush->plane_trim = 0.5f; + + // same as smooth stroke off + if (brush->smooth_stroke_radius == 0) + brush->smooth_stroke_radius= 75; + + // will keep cursor in one spot + if (brush->smooth_stroke_radius == 1) + brush->smooth_stroke_factor= 0.9f; + + // same as dots + if (brush->rate == 0) + brush->rate = 0.1f; + + /* New Settings */ + if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 6)) { + brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space + + // spacing was originally in pixels, convert it to percentage for new version + // size should not be zero due to sanity check above + brush->spacing = (int)(100*((float)brush->spacing) / ((float)brush->size)); + + if (brush->add_col[0] == 0 && + brush->add_col[1] == 0 && + brush->add_col[2] == 0) + { + brush->add_col[0] = 1.00; + brush->add_col[1] = 0.39; + brush->add_col[2] = 0.39; + } + + if (brush->sub_col[0] == 0 && + brush->sub_col[1] == 0 && + brush->sub_col[2] == 0) + { + brush->sub_col[0] = 0.39; + brush->sub_col[1] = 0.39; + brush->sub_col[2] = 1.00; + } + } + } + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 001773fc02a..17bafa3d399 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -243,7 +243,7 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi col= uiLayoutColumn(layout, 0); /* current Grease Pencil block */ // TODO: show some info about who owns this? - uiTemplateID(col, C, ctx_ptr, "grease_pencil", "GPENCIL_OT_data_add", NULL, "GPENCIL_OT_data_unlink"); + uiTemplateID(col, C, ctx_ptr, "grease_pencil", "GPENCIL_OT_data_add", NULL, "GPENCIL_OT_data_unlink", NULL); /* add new layer button - can be used even when no data, since it can add a new block too */ uiItemO(col, NULL, 0, "GPENCIL_OT_layer_add"); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 93e91d02599..4b6b396483d 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -669,11 +669,11 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout); void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus); void uiTemplateDopeSheetFilter(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, - char *newop, char *openop, char *unlinkop); + char *newop, char *openop, char *unlinkop, char *filterop); void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, - char *newop, char *openop, char *unlinkop); + char *newop, char *openop, char *unlinkop, char *filterop); void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, - char *newop, char *openop, char *unlinkop, int rows, int cols); + char *newop, char *openop, char *unlinkop, char *filterop, int rows, int cols); void uiTemplateAnyID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *proptypename, char *text); void uiTemplatePathBuilder(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 499fe3b9767..232b6f7f317 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -46,6 +46,7 @@ #include "DNA_screen_types.h" #include "DNA_userdef_types.h" +#include "DNA_brush_types.h" #include "BKE_context.h" #include "BKE_global.h" @@ -762,6 +763,7 @@ static void icon_create_mipmap(struct PreviewImage* prv_img, int miplevel) prv_img->w[miplevel] = size; prv_img->h[miplevel] = size; prv_img->changed[miplevel] = 1; + prv_img->changed_timestamp[miplevel] = 0; prv_img->rect[miplevel] = MEM_callocN(size*size*sizeof(unsigned int), "prv_rect"); } } @@ -976,6 +978,16 @@ int ui_id_icon_get(bContext *C, ID *id, int preview) /* checks if not exists, or changed */ ui_id_icon_render(C, id, preview); break; + case ID_BR: + { /* use the image in the brush as the icon */ + /* XXX redundancy here can be reduced be rewriting this switch as an if */ + ID* ima_id = (ID*)((Brush*)id)->image_icon; + id = ima_id ? ima_id : id; + iconid= BKE_icon_getid(id); + /* checks if not exists, or changed */ + ui_id_icon_render(C, id, preview); + } + break; default: break; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 7a5e0413f6d..cbe10496a72 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -42,6 +42,7 @@ #include "BKE_main.h" #include "BKE_texture.h" #include "BKE_utildefines.h" +#include "BKE_report.h" #include "ED_screen.h" #include "ED_render.h" @@ -141,6 +142,8 @@ typedef struct TemplateID { ListBase *idlb; int prv_rows, prv_cols; + + char filterop[64]; } TemplateID; /* Search browse menu, assign */ @@ -170,15 +173,53 @@ static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSea /* ID listbase */ for(id= lb->first; id; id= id->next) { if(!((flag & PROP_ID_SELF_CHECK) && id == id_from)) { + int filter_yes; - /* hide dot-datablocks */ - if(U.uiflag & USER_HIDE_DOT) + filter_yes= 0; + + /* use filter */ + if (template->filterop[0] != 0) { + PointerRNA ptr; + ReportList reports; + FunctionRNA *func; + ParameterList parms; + + RNA_id_pointer_create(id, &ptr); + + BKE_reports_init(&reports, RPT_PRINT); + + func= RNA_struct_find_function(&ptr, template->filterop); + + if (func) { + RNA_parameter_list_create(&parms, &ptr, func); + + RNA_parameter_set_lookup(&parms, "context", &C); + + if (RNA_function_call(C, &reports, &ptr, func, &parms) == 0) { + int* ret; + RNA_parameter_get_lookup(&parms, "ret", &ret); + + if (!(*ret)) { + RNA_parameter_list_free(&parms); + continue; + } + else { + filter_yes= 1; + } + } + + RNA_parameter_list_free(&parms); + } + } + + /* hide dot-datablocks, but only if filter does not force it visible */ + if(!filter_yes && U.uiflag & USER_HIDE_DOT) if ((id->name[2]=='.') && (str[0] != '.')) continue; if(BLI_strcasestr(id->name+2, str)) { iconid= ui_id_icon_get((bContext*)C, id, 1); - + if(!uiSearchItemAdd(items, id->name+2, id, iconid)) break; } @@ -340,7 +381,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) } } -static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag, char *newop, char *openop, char *unlinkop) +static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag, char *newop, char *openop, char *unlinkop, char *filterop) { uiBut *but; uiBlock *block; @@ -480,7 +521,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiBlockEndAlign(block); } -static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int flag, int prv_rows, int prv_cols) +static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, char* filterop, int flag, int prv_rows, int prv_cols) { TemplateID *template; PropertyRNA *prop; @@ -498,7 +539,12 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char template->prop= prop; template->prv_rows = prv_rows; template->prv_cols = prv_cols; - + + if (filterop) + BLI_strncpy(template->filterop, filterop, sizeof(template->filterop)); + else + template->filterop[0] = 0; + if(newop) flag |= UI_ID_ADD_NEW; if(openop) @@ -512,26 +558,25 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char */ if(template->idlb) { uiLayoutRow(layout, 1); - template_ID(C, layout, template, type, flag, newop, openop, unlinkop); + template_ID(C, layout, template, type, flag, newop, openop, unlinkop, filterop); } MEM_freeN(template); - } -void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop) +void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, char *filterop) { - ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE, 0, 0); + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, filterop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE, 0, 0); } -void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop) +void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, char *filterop) { - ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME, 0, 0); + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, filterop, UI_ID_BROWSE|UI_ID_RENAME, 0, 0); } -void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int rows, int cols) +void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, char *filterop, int rows, int cols) { - ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE|UI_ID_PREVIEWS, rows, cols); + ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, filterop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE|UI_ID_PREVIEWS, rows, cols); } /************************ ID Chooser Template ***************************/ diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index cf47feb312b..bea8d3bd1f6 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1463,7 +1463,7 @@ void init_userdef_do_versions(void) SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255); } } - if (G.main->versionfile <= 252 || (G.main->versionfile == 252 && G.main->subversionfile < 5)) { + if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 5)) { bTheme *btheme; /* interface_widgets.c */ @@ -1521,7 +1521,14 @@ void init_userdef_do_versions(void) /* this timer uses U */ // XXX reset_autosave(); + /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */ + + if (U.sculpt_paint_unified_alpha == 0) + U.sculpt_paint_unified_alpha = 0.5f; + + if (U.sculpt_paint_unified_unprojected_radius == 0) + U.sculpt_paint_unified_unprojected_radius = 0.125f; + + if (U.sculpt_paint_unified_size == 0) + U.sculpt_paint_unified_size = 35; } - - - diff --git a/source/blender/editors/sculpt_paint/SConscript b/source/blender/editors/sculpt_paint/SConscript index 472ba361059..3d9a5144c93 100644 --- a/source/blender/editors/sculpt_paint/SConscript +++ b/source/blender/editors/sculpt_paint/SConscript @@ -3,6 +3,8 @@ Import ('env') sources = env.Glob('*.c') +defs = [] + incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../render/extern/include' @@ -12,7 +14,11 @@ if env['OURPLATFORM'] == 'linux2': cflags='-pthread' incs += ' ../../../extern/binreloc/include' -if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): - incs += ' ' + env['BF_PTHREADS_INC'] +if env['OURPLATFORM'] == 'linuxcross': + if env['WITH_BF_OPENMP']: + incs += ' ' + env['BF_OPENMP_INC'] -env.BlenderLib ( 'bf_editors_sculpt_paint', sources, Split(incs), [], libtype=['core'], priority=[40] ) +if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): + incs += ' ' + env['BF_PTHREADS_INC'] + +env.BlenderLib ( 'bf_editors_sculpt_paint', sources, Split(incs), defines=defs, libtype=['core'], priority=[40] ) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 41908bbe388..45c0396855d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -641,8 +641,8 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float } } else { - xi = (uv[0]*ibuf->x) + 0.5f; - yi = (uv[1]*ibuf->y) + 0.5f; + xi = (int)((uv[0]*ibuf->x) + 0.5f); + yi = (int)((uv[1]*ibuf->y) + 0.5f); //if (xi<0 || xi>=ibuf->x || yi<0 || yi>=ibuf->y) return 0; @@ -1053,15 +1053,15 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl * This is incorrect. Its already given radians but without it wont work. * need to look into a fix - campbell */ if (is_quad) { - a1 = shell_angle_to_dist(angle_normalized_v2v2(dir4, dir1) * (M_PI/180.0f)); - a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * (M_PI/180.0f)); - a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * (M_PI/180.0f)); - a4 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir4) * (M_PI/180.0f)); + a1 = shell_angle_to_dist(angle_normalized_v2v2(dir4, dir1) * ((float)M_PI/180.0f)); + a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * ((float)M_PI/180.0f)); + a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * ((float)M_PI/180.0f)); + a4 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir4) * ((float)M_PI/180.0f)); } else { - a1 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir1) * (M_PI/180.0f)); - a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * (M_PI/180.0f)); - a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * (M_PI/180.0f)); + a1 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir1) * ((float)M_PI/180.0f)); + a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * ((float)M_PI/180.0f)); + a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * ((float)M_PI/180.0f)); } if (is_quad) { @@ -1197,7 +1197,7 @@ static void screen_px_from_persp( w[2] *= wtot_inv; } else { - w[0] = w[1] = w[2] = 1.0/3.0; /* dummy values for zero area face */ + w[0] = w[1] = w[2] = 1.0f/3.0f; /* dummy values for zero area face */ } /* done re-weighting */ @@ -2513,11 +2513,11 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i w[0]=w[1]=w[2]= 0.0; if (side) { w[fidx1?fidx1-1:0] = fac; - w[fidx2?fidx2-1:0] = 1.0-fac; + w[fidx2?fidx2-1:0] = 1.0f-fac; } else { w[fidx1] = fac; - w[fidx2] = 1.0-fac; + w[fidx2] = 1.0f-fac; } #endif } @@ -2571,11 +2571,12 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i static void project_paint_bucket_bounds(const ProjPaintState *ps, const float min[2], const float max[2], int bucketMin[2], int bucketMax[2]) { /* divide by bucketWidth & bucketHeight so the bounds are offset in bucket grid units */ - bucketMin[0] = (int)(((float)(min[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) + 0.5f; /* these offsets of 0.5 and 1.5 seem odd but they are correct */ - bucketMin[1] = (int)(((float)(min[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y) + 0.5f; + /* XXX: the offset of 0.5 is always truncated to zero and the offset of 1.5f is always truncated to 1, is this really correct?? - jwilkins */ + bucketMin[0] = (int)((int)(((float)(min[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) + 0.5f); /* these offsets of 0.5 and 1.5 seem odd but they are correct */ + bucketMin[1] = (int)((int)(((float)(min[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y) + 0.5f); - bucketMax[0] = (int)(((float)(max[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) + 1.5f; - bucketMax[1] = (int)(((float)(max[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y) + 1.5f; + bucketMax[0] = (int)((int)(((float)(max[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x) + 1.5f); + bucketMax[1] = (int)((int)(((float)(max[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y) + 1.5f); /* incase the rect is outside the mesh 2d bounds */ CLAMP(bucketMin[0], 0, ps->buckets_x); @@ -3029,19 +3030,19 @@ static void project_paint_begin(ProjPaintState *ps) if(ps->source==PROJ_SRC_VIEW) { #ifdef PROJ_DEBUG_WINCLIP - CLAMP(ps->screenMin[0], -ps->brush->size, ps->winx + ps->brush->size); - CLAMP(ps->screenMax[0], -ps->brush->size, ps->winx + ps->brush->size); + CLAMP(ps->screenMin[0], (float)(-ps->brush->size), (float)(ps->winx + ps->brush->size)); + CLAMP(ps->screenMax[0], (float)(-ps->brush->size), (float)(ps->winx + ps->brush->size)); - CLAMP(ps->screenMin[1], -ps->brush->size, ps->winy + ps->brush->size); - CLAMP(ps->screenMax[1], -ps->brush->size, ps->winy + ps->brush->size); + CLAMP(ps->screenMin[1], (float)(-ps->brush->size), (float)(ps->winy + ps->brush->size)); + CLAMP(ps->screenMax[1], (float)(-ps->brush->size), (float)(ps->winy + ps->brush->size)); #endif } else { /* reprojection, use bounds */ ps->screenMin[0]= 0; - ps->screenMax[0]= ps->winx; + ps->screenMax[0]= (float)(ps->winx); ps->screenMin[1]= 0; - ps->screenMax[1]= ps->winy; + ps->screenMax[1]= (float)(ps->winy); } /* only for convenience */ @@ -3497,7 +3498,7 @@ static int project_bucket_iter_next(ProjPaintState *ps, int *bucket_index, rctf project_bucket_bounds(ps, ps->context_bucket_x, ps->context_bucket_y, bucket_bounds); if ( (ps->source != PROJ_SRC_VIEW) || - project_bucket_isect_circle(ps->context_bucket_x, ps->context_bucket_y, mval, ps->brush->size * ps->brush->size, bucket_bounds) + project_bucket_isect_circle(ps->context_bucket_x, ps->context_bucket_y, mval, (float)(ps->brush->size * ps->brush->size), bucket_bounds) ) { *bucket_index = ps->context_bucket_x + (ps->context_bucket_y * ps->buckets_x); ps->context_bucket_x++; @@ -3545,7 +3546,7 @@ static void blend_color_mix(unsigned char *cp, const unsigned char *cp1, const u static void blend_color_mix_float(float *cp, const float *cp1, const float *cp2, const float fac) { - const float mfac= 1.0-fac; + const float mfac= 1.0f-fac; cp[0]= mfac*cp1[0] + fac*cp2[0]; cp[1]= mfac*cp1[1] + fac*cp2[1]; cp[2]= mfac*cp1[2] + fac*cp2[2]; @@ -3712,7 +3713,7 @@ static void *do_projectpaint_thread(void *ph_v) } /* avoid a square root with every dist comparison */ - brush_size_sqared = ps->brush->size * ps->brush->size; + brush_size_sqared = (float)(ps->brush->size * ps->brush->size); /* printf("brush bounds %d %d %d %d\n", bucketMin[0], bucketMin[1], bucketMax[0], bucketMax[1]); */ @@ -3771,7 +3772,7 @@ static void *do_projectpaint_thread(void *ph_v) falloff = 1.0f - falloff; falloff = 1.0f - (falloff * falloff); - mask_short = projPixel->mask * (ps->brush->alpha * falloff); + mask_short = (unsigned short)(projPixel->mask * (ps->brush->alpha * falloff)); if (mask_short > projPixel->mask_max) { mask = ((float)mask_short)/65535.0f; projPixel->mask_max = mask_short; @@ -3932,8 +3933,8 @@ static int project_paint_sub_stroke(ProjPaintState *ps, BrushPainter *painter, i /* Use mouse coords as floats for projection painting */ float pos[2]; - pos[0] = mval_i[0]; - pos[1] = mval_i[1]; + pos[0] = (float)(mval_i[0]); + pos[1] = (float)(mval_i[1]); // we may want to use this later // brush_painter_require_imbuf(painter, ((ibuf->rect_float)? 1: 0), 0, 0); @@ -4057,7 +4058,8 @@ static int imapaint_ibuf_add_if(ImBuf *ibuf, unsigned int x, unsigned int y, flo { float inrgb[3]; - if ((x >= ibuf->x) || (y >= ibuf->y)) { + // XXX: signed unsigned mismatch + if ((x >= (unsigned int)(ibuf->x)) || (y >= (unsigned int)(ibuf->y))) { if (torus) imapaint_ibuf_get_set_rgb(ibuf, x, y, 1, 0, inrgb); else return 0; } @@ -4611,8 +4613,8 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps) ps->normal_angle_inner= ps->normal_angle= settings->imapaint.normal_angle; } - ps->normal_angle_inner *= M_PI_2 / 90; - ps->normal_angle *= M_PI_2 / 90; + ps->normal_angle_inner *= (float)(M_PI_2 / 90); + ps->normal_angle *= (float)(M_PI_2 / 90); ps->normal_angle_range = ps->normal_angle - ps->normal_angle_inner; if(ps->normal_angle_range <= 0.0f) @@ -4711,8 +4713,8 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) int mouse[2], redraw; RNA_float_get_array(itemptr, "mouse", mousef); - mouse[0] = mousef[0]; - mouse[1] = mousef[1]; + mouse[0] = (int)(mousef[0]); + mouse[1] = (int)(mousef[1]); time= RNA_float_get(itemptr, "time"); pressure= RNA_float_get(itemptr, "pressure"); @@ -4832,8 +4834,8 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* fill in stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); - mousef[0] = mouse[0]; - mousef[1] = mouse[1]; + mousef[0] = (float)(mouse[0]); + mousef[1] = (float)(mouse[1]); RNA_float_set_array(&itemptr, "mouse", mousef); RNA_float_set(&itemptr, "time", (float)(time - pop->starttime)); RNA_float_set(&itemptr, "pressure", pressure); @@ -4950,7 +4952,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *customdata) glColor4ub(255, 255, 255, 128); glEnable( GL_LINE_SMOOTH ); glEnable(GL_BLEND); - glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size*0.5f, 40); + glutil_draw_lined_arc(0, (float)(M_PI*2.0), brush->size*0.5f, 40); glDisable(GL_BLEND); glDisable( GL_LINE_SMOOTH ); @@ -4977,7 +4979,7 @@ static int paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *eve ToolSettings *ts = CTX_data_scene(C)->toolsettings; get_imapaint_zoom(C, &zoom, &zoom); toggle_paint_cursor(C, !ts->imapaint.paintcursor); - brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 0.5 * zoom); + brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 0.5f * zoom); return WM_radial_control_invoke(C, op, event); } @@ -4997,7 +4999,7 @@ static int paint_radial_control_exec(bContext *C, wmOperator *op) int ret; char str[256]; get_imapaint_zoom(C, &zoom, &zoom); - ret = brush_radial_control_exec(op, brush, 2.0 / zoom); + ret = brush_radial_control_exec(op, brush, 2.0f / zoom); WM_radial_control_string(op, str, 256); WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index b25eec70311..0ae7c7fac19 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -110,6 +110,13 @@ void PAINT_OT_face_select_all(struct wmOperatorType *ot); int facemask_paint_poll(struct bContext *C); +/* stroke operator */ +typedef enum wmBrushStrokeMode { + WM_BRUSHSTROKE_NORMAL, + WM_BRUSHSTROKE_INVERT, + WM_BRUSHSTROKE_SMOOTH, +} wmBrushStrokeMode; + /* paint_undo.c */ typedef void (*UndoRestoreCb)(struct bContext *C, struct ListBase *lb); typedef void (*UndoFreeCb)(struct ListBase *lb); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 5470ac83370..5d52b0a3272 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -39,28 +39,25 @@ #include "sculpt_intern.h" #include +//#include /* Brush operators */ static int brush_add_exec(bContext *C, wmOperator *op) { /*int type = RNA_enum_get(op->ptr, "type");*/ - Brush *br = NULL; + Paint *paint = paint_get_active(CTX_data_scene(C)); + Brush *br = paint_brush(paint); - br = add_brush("Brush"); + if (br) + br = copy_brush(br); + else + br = add_brush("Brush"); - if(br) - paint_brush_set(paint_get_active(CTX_data_scene(C)), br); + paint_brush_set(paint_get_active(CTX_data_scene(C)), br); return OPERATOR_FINISHED; } -static EnumPropertyItem brush_type_items[] = { - {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""}, - {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""}, - {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, - {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, - {0, NULL, 0, NULL, NULL}}; - void BRUSH_OT_add(wmOperatorType *ot) { /* identifiers */ @@ -72,9 +69,43 @@ void BRUSH_OT_add(wmOperatorType *ot) ot->exec= brush_add_exec; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_UNDO; +} - RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_VERTEX_PAINT, "Type", "Which paint mode to create the brush for."); + +static int brush_scale_size_exec(bContext *C, wmOperator *op) +{ + /*int type = RNA_enum_get(op->ptr, "type");*/ + Paint *paint = paint_get_active(CTX_data_scene(C)); + Brush *br = paint_brush(paint); + float factor = RNA_float_get(op->ptr, "scalar"); + + if (br) { + if (U.sculpt_paint_settings & SCULPT_PAINT_USE_UNIFIED_SIZE) { + U.sculpt_paint_unified_size *= factor; + } + else { + br->size *= factor; + } + } + + return OPERATOR_FINISHED; +} + +void BRUSH_OT_scale_size(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Scale Sculpt/Paint Brush Size"; + ot->description= "Change brush size by a scalar"; + ot->idname= "BRUSH_OT_scale_size"; + + /* api callbacks */ + ot->exec= brush_scale_size_exec; + + /* flags */ + ot->flag= OPTYPE_UNDO; + + RNA_def_float(ot->srna, "scalar", 1, 0, 2, "Scalar", "Factor to scale brush size by", 0, 2); } static int vertex_color_set_exec(bContext *C, wmOperator *op) @@ -108,8 +139,10 @@ void ED_operatortypes_paint(void) { /* brush */ WM_operatortype_append(BRUSH_OT_add); + WM_operatortype_append(BRUSH_OT_scale_size); WM_operatortype_append(BRUSH_OT_curve_preset); + /* image */ WM_operatortype_append(PAINT_OT_texture_paint_toggle); WM_operatortype_append(PAINT_OT_texture_paint_radial_control); @@ -141,6 +174,7 @@ void ED_operatortypes_paint(void) WM_operatortype_append(PAINT_OT_face_select_all); } + static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *path) { wmKeyMapItem *kmi; @@ -180,15 +214,13 @@ static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *path) static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *path) { wmKeyMapItem *kmi; - - kmi= WM_keymap_add_item(keymap, "WM_OT_context_scale_int", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", path); - RNA_float_set(kmi->ptr, "value", 0.9); - - kmi= WM_keymap_add_item(keymap, "WM_OT_context_scale_int", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", path); - RNA_float_set(kmi->ptr, "value", 10.0/9.0); // 1.1111.... -} + + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_scale_size", LEFTBRACKETKEY, KM_PRESS, 0, 0); + RNA_float_set(kmi->ptr, "scalar", 0.9); + + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_scale_size", RIGHTBRACKETKEY, KM_PRESS, 0, 0); + RNA_float_set(kmi->ptr, "scalar", 10.0/9.0); // 1.1111.... +} void ED_keymap_paint(wmKeyConfig *keyconf) { @@ -200,12 +232,15 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Sculpt", 0, 0); keymap->poll= sculpt_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_RADIALCONTROL_ANGLE); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_RADIALCONTROL_ANGLE); - WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", WM_BRUSHSTROKE_NORMAL); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_BRUSHSTROKE_INVERT); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_BRUSHSTROKE_SMOOTH); + + //stroke_mode_modal_keymap(keyconf); for(i=0; i<=5; i++) RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i); @@ -221,7 +256,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "tool_settings.sculpt.active_brush_index"); ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size"); - + + /* */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", AKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.use_anchor"); @@ -254,11 +290,10 @@ void ED_keymap_paint(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", LKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); RNA_string_set(kmi->ptr, "value", "Layer"); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", TKEY, KM_PRESS, KM_SHIFT, 0); // was just T in 2.4x RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.active_brush_name"); RNA_string_set(kmi->ptr, "value", "Flatten"); - /* Vertex Paint mode */ keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 441464c5743..e373a254c3e 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -20,7 +20,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Jason Wilkins, Tom Musgrove. * * ***** END GPL LICENSE BLOCK ***** * @@ -35,6 +35,7 @@ #include "BKE_context.h" #include "BKE_paint.h" +#include "BKE_brush.h" #include "WM_api.h" #include "WM_types.h" @@ -49,6 +50,9 @@ #include "ED_view3d.h" #include "paint_intern.h" +#include "sculpt_intern.h" // XXX, for expedience in getting this working, refactor later (or this just shows that this needs unification) + +#include "BKE_image.h" #include #include @@ -96,54 +100,748 @@ static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata glDisable(GL_LINE_SMOOTH); } -static void paint_draw_cursor(bContext *C, int x, int y, void *customdata) +#if 0 + +// grid texture for testing + +#define GRID_WIDTH 8 +#define GRID_LENGTH 8 + +#define W (0xFFFFFFFF) +#define G (0x00888888) +#define E (0xE1E1E1E1) +#define C (0xC3C3C3C3) +#define O (0xB4B4B4B4) +#define Q (0xA9A9A9A9) + +static unsigned grid_texture0[256] = { - Paint *paint = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(paint); + W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, + W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W, +}; - if(!(paint->flags & PAINT_SHOW_BRUSH)) - return; +static unsigned grid_texture1[64] = +{ + C,C,C,C,C,C,C,C, + C,G,G,G,G,G,G,C, + C,G,G,G,G,G,G,C, + C,G,G,G,G,G,G,C, + C,G,G,G,G,G,G,C, + C,G,G,G,G,G,G,C, + C,G,G,G,G,G,G,C, + C,C,C,C,C,C,C,C, +}; - glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); +static unsigned grid_texture2[16] = +{ + O,O,O,O, + O,G,G,O, + O,G,G,O, + O,O,O,O, +}; - glTranslatef((float)x, (float)y, 0.0f); - glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40); - glTranslatef((float)-x, (float)-y, 0.0f); +static unsigned grid_texture3[4] = +{ + Q,Q, + Q,Q, +}; - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); +static unsigned grid_texture4[1] = +{ + Q, +}; + +#undef W +#undef G +#undef E +#undef C +#undef O +#undef Q + +static void load_grid() +{ + static GLuint overlay_texture; + + if (!overlay_texture) { + //GLfloat largest_supported_anisotropy; + + glGenTextures(1, &overlay_texture); + glBindTexture(GL_TEXTURE_2D, overlay_texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture0); + glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture1); + glTexImage2D(GL_TEXTURE_2D, 2, GL_RGB, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture2); + glTexImage2D(GL_TEXTURE_2D, 3, GL_RGB, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture3); + glTexImage2D(GL_TEXTURE_2D, 4, GL_RGB, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture4); + glEnable(GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); + + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + //glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy); + //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy); + } +} + +#endif + +extern float get_tex_pixel(Brush* br, float u, float v); + +typedef struct Snapshot { + float size[3]; + float ofs[3]; + float rot; + int brush_size; + int winx; + int winy; + int brush_map_mode; + int curve_changed_timestamp; +} Snapshot; + +static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc) +{ + MTex* mtex = &brush->mtex; + + return + (mtex->tex && + mtex->ofs[0] == snap->ofs[0] && + mtex->ofs[1] == snap->ofs[1] && + mtex->ofs[2] == snap->ofs[2] && + mtex->size[0] == snap->size[0] && + mtex->size[1] == snap->size[1] && + mtex->size[2] == snap->size[2] && + mtex->rot == snap->rot) && + ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED && sculpt_get_brush_size(brush) <= snap->brush_size) || (sculpt_get_brush_size(brush) == snap->brush_size)) && // make brush smaller shouldn't cause a resample + mtex->brush_map_mode == snap->brush_map_mode && + vc->ar->winx == snap->winx && + vc->ar->winy == snap->winy; +} + +static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc) +{ + if (brush->mtex.tex) { + snap->brush_map_mode = brush->mtex.brush_map_mode; + copy_v3_v3(snap->ofs, brush->mtex.ofs); + copy_v3_v3(snap->size, brush->mtex.size); + snap->rot = brush->mtex.rot; + } + else { + snap->brush_map_mode = -1; + snap->ofs[0]= snap->ofs[0]= snap->ofs[0]= -1; + snap->size[0]= snap->size[0]= snap->size[0]= -1; + snap->rot = -1; + } + + snap->brush_size = sculpt_get_brush_size(brush); + snap->winx = vc->ar->winx; + snap->winy = vc->ar->winy; +} + +int load_tex(Sculpt *sd, Brush* br, ViewContext* vc) +{ + static GLuint overlay_texture = 0; + static int init = 0; + static int tex_changed_timestamp = -1; + static int curve_changed_timestamp = -1; + static Snapshot snap; + static int old_size = -1; + + GLubyte* buffer = 0; + + int size; + int j; + int refresh; + + if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED && !br->mtex.tex) return 0; + + refresh = + !overlay_texture || + (br->mtex.tex && + (!br->mtex.tex->preview || + br->mtex.tex->preview->changed_timestamp[0] != tex_changed_timestamp)) || + !br->curve || + br->curve->changed_timestamp != curve_changed_timestamp || + !same_snap(&snap, br, vc); + + if (refresh) { + if (br->mtex.tex && br->mtex.tex->preview) + tex_changed_timestamp = br->mtex.tex->preview->changed_timestamp[0]; + + if (br->curve) + curve_changed_timestamp = br->curve->changed_timestamp; + + make_snap(&snap, br, vc); + + if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { + int s = sculpt_get_brush_size(br); + int r = 1; + + for (s >>= 1; s > 0; s >>= 1) + r++; + + size = (1<flags & SCULPT_USE_OPENMP) + for (j= 0; j < size; j++) { + int i; + float y; + float len; + + for (i= 0; i < size; i++) { + + // largely duplicated from tex_strength + + const float rotation = -br->mtex.rot; + float diameter = sculpt_get_brush_size(br); + int index = j*size + i; + float x; + float avg; + + x = (float)i/size; + y = (float)j/size; + + x -= 0.5f; + y -= 0.5f; + + if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) { + x *= vc->ar->winx / diameter; + y *= vc->ar->winy / diameter; + } + else { + x *= 2; + y *= 2; + } + + len = sqrtf(x*x + y*y); + + if ((br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) || len <= 1) { + /* it is probably worth optimizing for those cases where + the texture is not rotated by skipping the calls to + atan2, sqrtf, sin, and cos. */ + if (br->mtex.tex && (rotation > 0.001 || rotation < -0.001)) { + const float angle = atan2(y, x) + rotation; + + x = len * cos(angle); + y = len * sin(angle); + } + + x *= br->mtex.size[0]; + y *= br->mtex.size[1]; + + x += br->mtex.ofs[0]; + y += br->mtex.ofs[1]; + + avg = br->mtex.tex ? get_tex_pixel(br, x, y) : 1; + + avg += br->texture_sample_bias; + + if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) + avg *= brush_curve_strength(br, len, 1); /* Falloff curve */ + + buffer[index] = (GLubyte)(255*avg); + } + else { + buffer[index] = 0; + } + } + } + + if (!overlay_texture) + glGenTextures(1, &overlay_texture); + } + else { + size= old_size; + } + + glBindTexture(GL_TEXTURE_2D, overlay_texture); + + if (refresh) { + if (!init) { + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, size, size, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buffer); + init = 1; + } + else { + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, GL_ALPHA, GL_UNSIGNED_BYTE, buffer); + } + + if (buffer) + MEM_freeN(buffer); + } + + glEnable(GL_TEXTURE_2D); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + } + + return 1; +} + +/* Convert a point in model coordinates to 2D screen coordinates. */ +// XXX duplicated from sculpt.c, deal with this later. +static void projectf(bglMats *mats, const float v[3], float p[2]) +{ + double ux, uy, uz; + + gluProject(v[0],v[1],v[2], mats->modelview, mats->projection, + (GLint *)mats->viewport, &ux, &uy, &uz); + p[0]= ux; + p[1]= uy; +} + +static int project_brush_radius(RegionView3D* rv3d, float radius, float location[3], bglMats* mats) +{ + float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2]; + + viewvector(rv3d, location, view); + + // create a vector that is not orthogonal to view + + if (fabsf(view[0]) < 0.1) { + nonortho[0] = view[0] + 1; + nonortho[1] = view[1]; + nonortho[2] = view[2]; + } + else if (fabsf(view[1]) < 0.1) { + nonortho[0] = view[0]; + nonortho[1] = view[1] + 1; + nonortho[2] = view[2]; + } + else { + nonortho[0] = view[0]; + nonortho[1] = view[1]; + nonortho[2] = view[2] + 1; + } + + // get a vector in the plane of the view + cross_v3_v3v3(ortho, nonortho, view); + normalize_v3(ortho); + + // make a point on the surface of the brush tagent to the view + mul_v3_fl(ortho, radius); + add_v3_v3v3(offset, location, ortho); + + // project the center of the brush, and the tagent point to the view onto the screen + projectf(mats, location, p1); + projectf(mats, offset, p2); + + // the distance between these points is the size of the projected brush in pixels + return len_v2v2(p1, p2); +} + +int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radius, float location[3], float modelview[16], float projection[16], int viewport[4]) +{ + struct PaintStroke *stroke; + float window[2]; + int hit; + + stroke = paint_stroke_new(C, NULL, NULL, NULL, NULL); + + window[0] = x + stroke->vc.ar->winrct.xmin; + window[1] = y + stroke->vc.ar->winrct.ymin; + + memcpy(modelview, stroke->vc.rv3d->viewmat, sizeof(float[16])); + memcpy(projection, stroke->vc.rv3d->winmat, sizeof(float[16])); + memcpy(viewport, stroke->mats.viewport, sizeof(int[4])); + + if (stroke->vc.obact->sculpt && stroke->vc.obact->sculpt->pbvh && sculpt_stroke_get_location(C, stroke, location, window)) { + *pixel_radius = project_brush_radius(stroke->vc.rv3d, sculpt_get_brush_unprojected_radius(stroke->brush), location, &stroke->mats); + + if (*pixel_radius == 0) + *pixel_radius = sculpt_get_brush_size(stroke->brush); + + mul_m4_v3(stroke->vc.obact->sculpt->ob->obmat, location); + + hit = 1; + } + else { + Sculpt* sd = CTX_data_tool_settings(C)->sculpt; + Brush* brush = paint_brush(&sd->paint); + + *pixel_radius = sculpt_get_brush_size(brush); + hit = 0; + } + + paint_stroke_free(stroke); + + return hit; +} + +// XXX duplicated from sculpt.c +float unproject_brush_radius(Object *ob, ViewContext *vc, float center[3], float offset) +{ + float delta[3], scale, loc[3]; + + mul_v3_m4v3(loc, ob->obmat, center); + + initgrabz(vc->rv3d, loc[0], loc[1], loc[2]); + window_to_3d_delta(vc->ar, delta, offset, 0); + + scale= fabsf(mat4_to_scale(ob->obmat)); + scale= (scale == 0.0f)? 1.0f: scale; + + return len_v3(delta)/scale; +} + +// XXX paint cursor now does a lot of the same work that is needed during a sculpt stroke +// problem: all this stuff was not intended to be used at this point, so things feel a +// bit hacked. I've put lots of stuff in Brush that probably better goes in Paint +// Functions should be refactored so that they can be used between sculpt.c and +// paint_stroke.c clearly and optimally and the lines of communication between the +// two modules should be more clearly defined. +static void paint_draw_cursor(bContext *C, int x, int y, void *unused) +{ + ViewContext vc; + + (void)unused; + + view3d_set_viewcontext(C, &vc); + + if (vc.obact->sculpt) { + Paint *paint = paint_get_active(CTX_data_scene(C)); + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + Brush *brush = paint_brush(paint); + + int pixel_radius, viewport[4]; + float location[3], modelview[16], projection[16]; + + int hit; + + int flip; + int sign; + + float* col; + float alpha; + + float visual_strength = sculpt_get_brush_alpha(brush)*sculpt_get_brush_alpha(brush); + + const float min_alpha = 0.20f; + const float max_alpha = 0.80f; + + { + const float u = 0.5f; + const float v = 1 - u; + const float r = 20; + + const float dx = sd->last_x - x; + const float dy = sd->last_y - y; + + if (dx*dx + dy*dy >= r*r) { + sd->last_angle = atan2(dx, dy); + + sd->last_x = u*sd->last_x + v*x; + sd->last_y = u*sd->last_y + v*y; + } + } + + if(!sculpt_get_lock_brush_size(brush) && !(paint->flags & PAINT_SHOW_BRUSH)) + return; + + hit = sculpt_get_brush_geometry(C, x, y, &pixel_radius, location, modelview, projection, viewport); + + if (sculpt_get_lock_brush_size(brush)) + sculpt_set_brush_size(brush, pixel_radius); + + // XXX: no way currently to know state of pen flip or invert key modifier without starting a stroke + flip = 1; + + sign = flip * ((brush->flag & BRUSH_DIR_IN)? -1 : 1); + + if (sign < 0 && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH)) + col = brush->sub_col; + else + col = brush->add_col; + + alpha = (paint->flags & PAINT_SHOW_BRUSH_ON_SURFACE) ? min_alpha + (visual_strength*(max_alpha-min_alpha)) : 0.50f; + + if (ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED) && brush->flag & BRUSH_TEXTURE_OVERLAY) { + glPushAttrib( + GL_COLOR_BUFFER_BIT| + GL_CURRENT_BIT| + GL_DEPTH_BUFFER_BIT| + GL_ENABLE_BIT| + GL_LINE_BIT| + GL_POLYGON_BIT| + GL_STENCIL_BUFFER_BIT| + GL_TRANSFORM_BIT| + GL_VIEWPORT_BIT| + GL_TEXTURE_BIT); + + if (load_tex(sd, brush, &vc)) { + glEnable(GL_BLEND); + + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glDepthMask(GL_FALSE); + glDepthFunc(GL_ALWAYS); + + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); + + if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { + glTranslatef(0.5f, 0.5f, 0); + + if (brush->flag & BRUSH_RAKE) { + glRotatef(sd->last_angle*(float)(180.0/M_PI), 0, 0, 1); + } + else { + glRotatef(sd->special_rotation*(float)(180.0/M_PI), 0, 0, 1); + } + + glTranslatef(-0.5f, -0.5f, 0); + + if (sd->draw_pressure && (brush->flag & BRUSH_SIZE_PRESSURE)) { + glTranslatef(0.5f, 0.5f, 0); + glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1); + glTranslatef(-0.5f, -0.5f, 0); + } + } + + glColor4f( + U.sculpt_paint_overlay_col[0], + U.sculpt_paint_overlay_col[1], + U.sculpt_paint_overlay_col[2], + brush->texture_overlay_alpha / 100.0f); + + glBegin(GL_QUADS); + if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { + if (sd->draw_anchored) { + glTexCoord2f(0, 0); + glVertex2f(sd->anchored_initial_mouse[0]-sd->anchored_size - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1]-sd->anchored_size - vc.ar->winrct.ymin); + + glTexCoord2f(1, 0); + glVertex2f(sd->anchored_initial_mouse[0]+sd->anchored_size - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1]-sd->anchored_size - vc.ar->winrct.ymin); + + glTexCoord2f(1, 1); + glVertex2f(sd->anchored_initial_mouse[0]+sd->anchored_size - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1]+sd->anchored_size - vc.ar->winrct.ymin); + + glTexCoord2f(0, 1); + glVertex2f(sd->anchored_initial_mouse[0]-sd->anchored_size - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1]+sd->anchored_size - vc.ar->winrct.ymin); + } + else { + glTexCoord2f(0, 0); + glVertex2f((float)x-sculpt_get_brush_size(brush), (float)y-sculpt_get_brush_size(brush)); + + glTexCoord2f(1, 0); + glVertex2f((float)x+sculpt_get_brush_size(brush), (float)y-sculpt_get_brush_size(brush)); + + glTexCoord2f(1, 1); + glVertex2f((float)x+sculpt_get_brush_size(brush), (float)y+sculpt_get_brush_size(brush)); + + glTexCoord2f(0, 1); + glVertex2f((float)x-sculpt_get_brush_size(brush), (float)y+sculpt_get_brush_size(brush)); + } + } + else { + glTexCoord2f(0, 0); + glVertex2f(0, 0); + + glTexCoord2f(1, 0); + glVertex2f(viewport[2], 0); + + glTexCoord2f(1, 1); + glVertex2f(viewport[2], viewport[3]); + + glTexCoord2f(0, 1); + glVertex2f(0, viewport[3]); + } + glEnd(); + + glPopMatrix(); + } + + glPopAttrib(); + } + + if (hit) { + float unprojected_radius; + + // XXX duplicated from brush_strength & paint_stroke_add_step, refactor later + //wmEvent* event = CTX_wm_window(C)->eventstate; + + if (sd->draw_pressure && (brush->flag & BRUSH_ALPHA_PRESSURE)) + visual_strength *= sd->pressure_value; + + // don't show effect of strength past the soft limit + if (visual_strength > 1) visual_strength = 1; + + if (sd->draw_anchored) { + unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, sd->anchored_size); + } + else { + if (brush->flag & BRUSH_ANCHORED) + unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, 8); + else + unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, sculpt_get_brush_size(brush)); + } + + if (sd->draw_pressure && (brush->flag & BRUSH_SIZE_PRESSURE)) + unprojected_radius *= sd->pressure_value; + + if (!sculpt_get_lock_brush_size(brush)) + sculpt_set_brush_unprojected_radius(brush, unprojected_radius); + + if(!(paint->flags & PAINT_SHOW_BRUSH)) + return; + + } + + glPushAttrib( + GL_COLOR_BUFFER_BIT| + GL_CURRENT_BIT| + GL_DEPTH_BUFFER_BIT| + GL_ENABLE_BIT| + GL_LINE_BIT| + GL_POLYGON_BIT| + GL_STENCIL_BUFFER_BIT| + GL_TRANSFORM_BIT| + GL_VIEWPORT_BIT| + GL_TEXTURE_BIT); + + glColor4f(col[0], col[1], col[2], alpha); + + glEnable(GL_BLEND); + + glEnable(GL_LINE_SMOOTH); + + if (sd->draw_anchored) { + glTranslatef(sd->anchored_initial_mouse[0] - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1] - vc.ar->winrct.ymin, 0.0f); + glutil_draw_lined_arc(0.0, M_PI*2.0, sd->anchored_size, 40); + glTranslatef(-sd->anchored_initial_mouse[0] + vc.ar->winrct.xmin, -sd->anchored_initial_mouse[1] + vc.ar->winrct.xmin, 0.0f); + } + else { + glTranslatef((float)x, (float)y, 0.0f); + glutil_draw_lined_arc(0.0, M_PI*2.0, sculpt_get_brush_size(brush), 40); + glTranslatef(-(float)x, -(float)y, 0.0f); + } + + glPopAttrib(); + } + else { + Paint *paint = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(paint); + + if(!(paint->flags & PAINT_SHOW_BRUSH)) + return; + + glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + + glTranslatef((float)x, (float)y, 0.0f); + glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size, 40); // XXX: for now use the brushes size instead of potentially using the unified size because the feature has been enabled for sculpt + glTranslatef((float)-x, (float)-y, 0.0f); + + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + } } /* Put the location of the next stroke dot into the stroke RNA and apply it to the mesh */ -static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse[2]) +static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse_in[2]) { + Paint *paint = paint_get_active(CTX_data_scene(C)); // XXX + Brush *brush = paint_brush(paint); // XXX + + float mouse[2]; + PointerRNA itemptr; - float pressure = 1; - float center[3] = {0, 0, 0}; - int flip= event->shift?1:0; + + float location[3]; + + float pressure; + int pen_flip; + + ViewContext vc; // XXX + PaintStroke *stroke = op->customdata; - /* XXX: can remove the if statement once all modes have this */ - if(stroke->get_location) - stroke->get_location(C, stroke, center, mouse); + view3d_set_viewcontext(C, &vc); // XXX /* Tablet */ if(event->custom == EVT_DATA_TABLET) { wmTabletData *wmtab= event->customdata; - if(wmtab->Active != EVT_TABLET_NONE) - pressure= wmtab->Pressure; - if(wmtab->Active == EVT_TABLET_ERASER) - flip = 1; + + pressure = (wmtab->Active != EVT_TABLET_NONE) ? wmtab->Pressure : 1; + pen_flip = (wmtab->Active == EVT_TABLET_ERASER); } - + else { + pressure = 1; + pen_flip = 0; + } + + // XXX: temporary check for sculpt mode until things are more unified + if (vc.obact->sculpt) { + float delta[3]; + + brush_jitter_pos(brush, mouse_in, mouse); + + // XXX: meh, this is round about because brush_jitter_pos isn't written in the best way to be reused here + if (brush->flag & BRUSH_JITTER_PRESSURE) { + sub_v3_v3v3(delta, mouse, mouse_in); + mul_v3_fl(delta, pressure); + add_v3_v3v3(mouse, mouse_in, delta); + } + } + else + copy_v3_v3(mouse, mouse_in); + + /* XXX: can remove the if statement once all modes have this */ + if(stroke->get_location) + stroke->get_location(C, stroke, location, mouse); + else + zero_v3(location); + /* Add to stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); - RNA_float_set_array(&itemptr, "location", center); - RNA_float_set_array(&itemptr, "mouse", mouse); - RNA_boolean_set(&itemptr, "flip", flip); - RNA_float_set(&itemptr, "pressure", pressure); + + RNA_float_set_array(&itemptr, "location", location); + RNA_float_set_array(&itemptr, "mouse", mouse); + RNA_boolean_set (&itemptr, "pen_flip", pen_flip); + RNA_float_set (&itemptr, "pressure", pressure); stroke->last_mouse_position[0] = mouse[0]; stroke->last_mouse_position[1] = mouse[1]; @@ -154,10 +852,14 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev /* Returns zero if no sculpt changes should be made, non-zero otherwise */ static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *event) { - output[0] = event->x; + output[0] = event->x; output[1] = event->y; - if(stroke->brush->flag & BRUSH_SMOOTH_STROKE && stroke->brush->sculpt_tool != SCULPT_TOOL_GRAB) { + if ((stroke->brush->flag & BRUSH_SMOOTH_STROKE) && + !ELEM4(stroke->brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK) && + !(stroke->brush->flag & BRUSH_ANCHORED) && + !(stroke->brush->flag & BRUSH_RESTORE_MESH)) + { float u = stroke->brush->smooth_stroke_factor, v = 1.0 - u; float dx = stroke->last_mouse_position[0] - event->x, dy = stroke->last_mouse_position[1] - event->y; @@ -176,7 +878,9 @@ static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *ev /* Returns zero if the stroke dots should not be spaced, non-zero otherwise */ static int paint_space_stroke_enabled(Brush *br) { - return (br->flag & BRUSH_SPACE) && !(br->flag & BRUSH_ANCHORED) && (br->sculpt_tool != SCULPT_TOOL_GRAB); + return (br->flag & BRUSH_SPACE) && + !(br->flag & BRUSH_ANCHORED) && + !ELEM4(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK); } /* For brushes with stroke spacing enabled, moves mouse in steps @@ -187,23 +891,34 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const int cnt = 0; if(paint_space_stroke_enabled(stroke->brush)) { - float mouse[2] = {stroke->last_mouse_position[0], stroke->last_mouse_position[1]}; - float vec[2] = {final_mouse[0] - mouse[0], final_mouse[1] - mouse[1]}; + float mouse[2]; + float vec[2]; float length, scale; - int steps = 0, i; - /* Normalize the vector between the last stroke dot and the goal */ - length = sqrt(vec[0]*vec[0] + vec[1]*vec[1]); + copy_v2_v2(mouse, stroke->last_mouse_position); + sub_v2_v2v2(vec, final_mouse, mouse); + + length = len_v2(vec); if(length > FLT_EPSILON) { - scale = stroke->brush->spacing / length; - vec[0] *= scale; - vec[1] *= scale; + int steps; + int i; + float pressure = 1; + + // XXX duplicate code + if(event->custom == EVT_DATA_TABLET) { + wmTabletData *wmtab= event->customdata; + if(wmtab->Active != EVT_TABLET_NONE) + pressure = stroke->brush->flag & BRUSH_SIZE_PRESSURE ? wmtab->Pressure : 1; + } + + scale = (sculpt_get_brush_size(stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length; + mul_v2_fl(vec, scale); + + steps = (int)(1.0f / scale); - steps = (int)(length / stroke->brush->spacing); for(i = 0; i < steps; ++i, ++cnt) { - mouse[0] += vec[0]; - mouse[1] += vec[1]; + add_v2_v2(mouse, vec); paint_brush_stroke_add_step(C, op, event, mouse); } } @@ -283,14 +998,25 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) //ED_region_tag_redraw(ar); } } - else + else { paint_brush_stroke_add_step(C, op, event, mouse); + } } else ;//ED_region_tag_redraw(ar); } } + /* we want the stroke to have the first daub at the start location instead of waiting till we have moved the space distance */ + if(first && + stroke->stroke_started && + paint_space_stroke_enabled(stroke->brush) && + !(stroke->brush->flag & BRUSH_ANCHORED) && + !(stroke->brush->flag & BRUSH_SMOOTH_STROKE)) + { + paint_brush_stroke_add_step(C, op, event, mouse); + } + return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 85fbd5954e8..21ea6cb7f75 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -216,6 +216,10 @@ void BRUSH_OT_curve_preset(wmOperatorType *ot) {CURVE_PRESET_SHARP, "SHARP", 0, "Sharp", ""}, {CURVE_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""}, {CURVE_PRESET_MAX, "MAX", 0, "Max", ""}, + {CURVE_PRESET_MID9, "MID9", 0, "Mid9", ""}, + {CURVE_PRESET_LINE, "LINE", 0, "Line", ""}, + {CURVE_PRESET_ROUND, "ROUND", 0, "Round", ""}, + {CURVE_PRESET_ROOT, "ROOT", 0, "Root", ""}, {0, NULL, 0, NULL, NULL}}; ot->name= "Preset"; @@ -225,7 +229,7 @@ void BRUSH_OT_curve_preset(wmOperatorType *ot) ot->exec= brush_curve_preset_exec; ot->poll= brush_curve_preset_poll; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_UNDO; RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", ""); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index b53771c92ae..eee0d520747 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -22,7 +22,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Jason Wilkins, Tom Musgrove. * * ***** END GPL LICENSE BLOCK ***** * @@ -38,6 +38,8 @@ #include "BLI_ghash.h" #include "BLI_pbvh.h" #include "BLI_threads.h" +#include "BLI_editVert.h" +#include "BLI_rand.h" #include "DNA_key_types.h" #include "DNA_mesh_types.h" @@ -73,6 +75,7 @@ #include "ED_screen.h" #include "ED_sculpt.h" #include "ED_view3d.h" +#include "ED_mesh.h" #include "paint_intern.h" #include "sculpt_intern.h" @@ -81,6 +84,7 @@ #include "RE_render_ext.h" +#include "RE_shader_ext.h" #include "GPU_buffers.h" @@ -88,13 +92,70 @@ #include #include -/* Number of vertices to average in order to determine the flatten distance */ -#define FLATTEN_SAMPLE_SIZE 10 +#ifdef _OPENMP +#include +#endif /* ==== FORWARD DEFINITIONS ===== * */ -static void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]); + +void ED_sculpt_force_update(bContext *C) +{ + Object *ob= CTX_data_active_object(C); + + if(ob && (ob->mode & OB_MODE_SCULPT)) + multires_force_update(ob); +} + +/* Sculpt mode handles multires differently from regular meshes, but only if + it's the last modifier on the stack and it is not on the first level */ +struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) +{ + ModifierData *md, *nmd; + + for(md= modifiers_getVirtualModifierList(ob); md; md= md->next) { + if(md->type == eModifierType_Multires) { + MultiresModifierData *mmd= (MultiresModifierData*)md; + + /* Check if any of the modifiers after multires are active + * if not it can use the multires struct */ + for(nmd= md->next; nmd; nmd= nmd->next) + if(modifier_isEnabled(scene, nmd, eModifierMode_Realtime)) + break; + + if(!nmd && mmd->sculptlvl > 0) + return mmd; + } + } + + return NULL; +} + +/* Checks whether full update mode (slower) needs to be used to work with modifiers */ +int sculpt_modifiers_active(Scene *scene, Object *ob) +{ + ModifierData *md; + MultiresModifierData *mmd= sculpt_multires_active(scene, ob); + + /* check if there are any modifiers after what we are sculpting, + for a multires modifier with a deform modifier in front, we + do no need to recalculate the modifier stack. note that this + needs to be in sync with ccgDM_use_grid_pbvh! */ + if(mmd) + md= mmd->modifier.next; + else + md= modifiers_getVirtualModifierList(ob); + + /* exception for shape keys because we can edit those */ + for(; md; md= md->next) { + if(modifier_isEnabled(scene, md, eModifierMode_Realtime)) + if(md->type != eModifierType_ShapeKey) + return 1; + } + + return 0; +} /* ===== STRUCTS ===== * @@ -121,10 +182,13 @@ typedef struct StrokeCache { /* Variants */ float radius; + float radius_squared; + //float traced_location[3]; float true_location[3]; float location[3]; - float flip; + float pen_flip; + float invert; float pressure; float mouse[2]; float bstrength; @@ -141,15 +205,32 @@ typedef struct StrokeCache { Brush *brush; float (*face_norms)[3]; /* Copy of the mesh faces' normals */ - float rotation; /* Texture rotation (radians) for anchored and rake modes */ + float special_rotation; /* Texture rotation (radians) for anchored and rake modes */ int pixel_radius, previous_pixel_radius; - float grab_active_location[8][3]; float grab_delta[3], grab_delta_symmetry[3]; float old_grab_location[3], orig_grab_location[3]; - int symmetry; /* Symmetry index between 0 and 7 */ - float view_normal[3], view_normal_symmetry[3]; - int last_rake[2]; /* Last location of updating rake rotation */ + + int symmetry; /* Symmetry index between 0 and 7 bit combo 0 is Brush only; + 1 is X mirror; 2 is Y mirror; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ + int mirror_symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/ + float true_view_normal[3]; + float view_normal[3]; + float last_area_normal[3]; + float last_center[3]; + int radial_symmetry_pass; + float symm_rot_mat[4][4]; + float symm_rot_mat_inv[4][4]; + float last_rake[2]; /* Last location of updating rake rotation */ int original; + + float vertex_rotation; + + char saved_active_brush_name[24]; + int alt_smooth; + + float plane_trim_squared; + + float autosmooth_overlap; } StrokeCache; /* ===== OPENGL ===== @@ -224,10 +305,12 @@ void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar, RegionView3D *rv3d, Object *ob) { PBVH *pbvh= ob->sculpt->pbvh; - BoundBox *bb = MEM_callocN(sizeof(BoundBox), "sculpt boundbox"); + BoundBox bb; bglMats mats; rcti rect; + memset(&bb, 0, sizeof(BoundBox)); + view3d_get_transformation(ar, rv3d, ob, &mats); sculpt_get_redraw_rect(ar, rv3d,ob, &rect); @@ -246,386 +329,172 @@ void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar, rect.ymax -= 2; #endif - view3d_calculate_clipping(bb, planes, &mats, &rect); + view3d_calculate_clipping(&bb, planes, &mats, &rect); mul_m4_fl(planes, -1.0f); - MEM_freeN(bb); - /* clear redraw flag from nodes */ if(pbvh) BLI_pbvh_update(pbvh, PBVH_UpdateRedraw, NULL); } -/************************** Undo *************************/ - -typedef struct SculptUndoNode { - struct SculptUndoNode *next, *prev; - - char idname[MAX_ID_NAME]; /* name instead of pointer*/ - void *node; /* only during push, not valid afterwards! */ - - float (*co)[3]; - short (*no)[3]; - int totvert; - - /* non-multires */ - int maxvert; /* to verify if totvert it still the same */ - int *index; /* to restore into right location */ - - /* multires */ - int maxgrid; /* same for grid */ - int gridsize; /* same for grid */ - int totgrid; /* to restore into right location */ - int *grids; /* to restore into right location */ - - /* layer brush */ - float *layer_disp; - - /* shape keys */ - char *shapeName[32]; /* keep size in sync with keyblock dna */ -} SculptUndoNode; - -static void update_cb(PBVHNode *node, void *data) -{ - BLI_pbvh_node_mark_update(node); -} - -/* Checks whether full update mode (slower) needs to be used to work with modifiers */ -static int sculpt_modifiers_active(Scene *scene, Object *ob) -{ - ModifierData *md; - MultiresModifierData *mmd = sculpt_multires_active(scene, ob); - - /* check if there are any modifiers after what we are sculpting, - for a multires modifier with a deform modifier in front, we - do no need to recalculate the modifier stack. note that this - needs to be in sync with ccgDM_use_grid_pbvh! */ - if(mmd) - md= mmd->modifier.next; - else - md= modifiers_getVirtualModifierList(ob); - - /* exception for shape keys because we can edit those */ - for(; md; md= md->next) { - if(modifier_isEnabled(scene, md, eModifierMode_Realtime)) - if(md->type != eModifierType_ShapeKey) - return 1; - } - - return 0; -} - -static void sculpt_undo_restore(bContext *C, ListBase *lb) -{ - Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); - DerivedMesh *dm = mesh_get_derived_final(scene, ob, 0); - SculptSession *ss = ob->sculpt; - SculptUndoNode *unode; - MVert *mvert; - MultiresModifierData *mmd; - int *index; - int i, j, update= 0; - - sculpt_update_mesh_elements(scene, ob, 0); - - for(unode=lb->first; unode; unode=unode->next) { - if(!(strcmp(unode->idname, ob->id.name)==0)) - continue; - - if(unode->maxvert) { - char *shapeName= (char*)unode->shapeName; - - /* regular mesh restore */ - if(ss->totvert != unode->maxvert) - continue; - - if (ss->kb && strcmp(ss->kb->name, shapeName)) { - /* shape key has been changed before calling undo operator */ - - Key *key= ob_get_key(ob); - KeyBlock *kb= key_get_named_keyblock(key, shapeName); - - if (kb) { - ob->shapenr= BLI_findindex(&key->block, kb) + 1; - ob->shapeflag|= OB_SHAPE_LOCK; - - sculpt_update_mesh_elements(scene, ob, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_DATA, ob); - } else { - /* key has been removed -- skip this undo node */ - continue; - } - } - - index= unode->index; - mvert= ss->mvert; - - if (ss->kb) { - float (*vertCos)[3]; - vertCos= key_to_vertcos(ob, ss->kb); - - for(i=0; itotvert; i++) - swap_v3_v3(vertCos[index[i]], unode->co[i]); - - /* propagate new coords to keyblock */ - sculpt_vertcos_to_key(ob, ss->kb, vertCos); - - /* pbvh uses it's own mvert array, so coords should be */ - /* propagated to pbvh here */ - BLI_pbvh_apply_vertCos(ss->pbvh, vertCos); - - MEM_freeN(vertCos); - } else { - for(i=0; itotvert; i++) { - swap_v3_v3(mvert[index[i]].co, unode->co[i]); - mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; - } - } - } - else if(unode->maxgrid && dm->getGridData) { - /* multires restore */ - DMGridData **grids, *grid; - float (*co)[3]; - int gridsize; - - if(dm->getNumGrids(dm) != unode->maxgrid) - continue; - if(dm->getGridSize(dm) != unode->gridsize) - continue; - - grids= dm->getGridData(dm); - gridsize= dm->getGridSize(dm); - - co = unode->co; - for(j=0; jtotgrid; j++) { - grid= grids[unode->grids[j]]; - - for(i=0; ipbvh, NULL, NULL, update_cb, NULL); - BLI_pbvh_update(ss->pbvh, PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateRedraw, NULL); - - if((mmd=sculpt_multires_active(scene, ob))) - multires_mark_as_modified(ob); - - if(ss->modifiers_active || ((Mesh*)ob->data)->id.us > 1) - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - } -} - -static void sculpt_undo_free(ListBase *lb) -{ - SculptUndoNode *unode; - - for(unode=lb->first; unode; unode=unode->next) { - if(unode->co) - MEM_freeN(unode->co); - if(unode->no) - MEM_freeN(unode->no); - if(unode->index) - MEM_freeN(unode->index); - if(unode->grids) - MEM_freeN(unode->grids); - if(unode->layer_disp) - MEM_freeN(unode->layer_disp); - } -} - -static SculptUndoNode *sculpt_undo_get_node(SculptSession *ss, PBVHNode *node) -{ - ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH); - SculptUndoNode *unode; - - if(!lb) - return NULL; - - for(unode=lb->first; unode; unode=unode->next) - if(unode->node == node) - return unode; - - return NULL; -} - -static SculptUndoNode *sculpt_undo_push_node(SculptSession *ss, PBVHNode *node) -{ - ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH); - Object *ob= ss->ob; - SculptUndoNode *unode; - int totvert, allvert, totgrid, maxgrid, gridsize, *grids; - - /* list is manipulated by multiple threads, so we lock */ - BLI_lock_thread(LOCK_CUSTOM1); - - if((unode= sculpt_undo_get_node(ss, node))) { - BLI_unlock_thread(LOCK_CUSTOM1); - return unode; - } - - unode= MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode"); - strcpy(unode->idname, ob->id.name); - unode->node= node; - - BLI_pbvh_node_num_verts(ss->pbvh, node, &totvert, &allvert); - BLI_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid, - &maxgrid, &gridsize, NULL, NULL); - - unode->totvert= totvert; - /* we will use this while sculpting, is mapalloc slow to access then? */ - unode->co= MEM_mapallocN(sizeof(float)*3*allvert, "SculptUndoNode.co"); - unode->no= MEM_mapallocN(sizeof(short)*3*allvert, "SculptUndoNode.no"); - undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float)*3 + sizeof(short)*3 + sizeof(int))*allvert); - BLI_addtail(lb, unode); - - if(maxgrid) { - /* multires */ - unode->maxgrid= maxgrid; - unode->totgrid= totgrid; - unode->gridsize= gridsize; - unode->grids= MEM_mapallocN(sizeof(int)*totgrid, "SculptUndoNode.grids"); - } - else { - /* regular mesh */ - unode->maxvert= ss->totvert; - unode->index= MEM_mapallocN(sizeof(int)*allvert, "SculptUndoNode.index"); - } - - BLI_unlock_thread(LOCK_CUSTOM1); - - /* copy threaded, hopefully this is the performance critical part */ - { - PBVHVertexIter vd; - - BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL) { - copy_v3_v3(unode->co[vd.i], vd.co); - if(vd.no) VECCOPY(unode->no[vd.i], vd.no) - else normal_float_to_short_v3(unode->no[vd.i], vd.fno); - if(vd.vert_indices) unode->index[vd.i]= vd.vert_indices[vd.i]; - } - BLI_pbvh_vertex_iter_end; - } - - if(unode->grids) - memcpy(unode->grids, grids, sizeof(int)*totgrid); - - /* store active shape key */ - if(ss->kb) BLI_strncpy((char*)unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); - else unode->shapeName[0]= '\0'; - - return unode; -} - -static void sculpt_undo_push_begin(SculptSession *ss, char *name) -{ - undo_paint_push_begin(UNDO_PAINT_MESH, name, - sculpt_undo_restore, sculpt_undo_free); -} - -static void sculpt_undo_push_end(SculptSession *ss) -{ - ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH); - SculptUndoNode *unode; - - /* we don't need normals in the undo stack */ - for(unode=lb->first; unode; unode=unode->next) { - if(unode->no) { - MEM_freeN(unode->no); - unode->no= NULL; - } - - if(unode->layer_disp) { - MEM_freeN(unode->layer_disp); - unode->layer_disp= NULL; - } - } - - undo_paint_push_end(UNDO_PAINT_MESH); -} - -void ED_sculpt_force_update(bContext *C) -{ - Object *ob= CTX_data_active_object(C); - - if(ob && (ob->mode & OB_MODE_SCULPT)) - multires_force_update(ob); -} - /************************ Brush Testing *******************/ typedef struct SculptBrushTest { float radius_squared; float location[3]; - float dist; } SculptBrushTest; static void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test) { - test->radius_squared= ss->cache->radius*ss->cache->radius; + test->radius_squared= ss->cache->radius_squared; copy_v3_v3(test->location, ss->cache->location); } static int sculpt_brush_test(SculptBrushTest *test, float co[3]) { - float distsq, delta[3]; + float distsq = len_squared_v3v3(co, test->location); - sub_v3_v3v3(delta, co, test->location); - distsq = INPR(delta, delta); - - if(distsq < test->radius_squared) { + if(distsq <= test->radius_squared) { test->dist = sqrt(distsq); return 1; } + else { + return 0; + } +} + +static int sculpt_brush_test_sq(SculptBrushTest *test, float co[3]) +{ + float distsq = len_squared_v3v3(co, test->location); + + if(distsq <= test->radius_squared) { + test->dist = distsq; + return 1; + } + else { + return 0; + } +} + +static int sculpt_brush_test_fast(SculptBrushTest *test, float co[3]) +{ + return len_squared_v3v3(co, test->location) <= test->radius_squared; +} + +static int sculpt_brush_test_cube(SculptBrushTest *test, float co[3], float local[4][4]) +{ + const static float side = 0.70710678118654752440084436210485; // sqrt(.5); + + float local_co[3]; + + mul_v3_m4v3(local_co, local, co); + + local_co[0] = fabs(local_co[0]); + local_co[1] = fabs(local_co[1]); + local_co[2] = fabs(local_co[2]); + + if (local_co[0] <= side && local_co[1] <= side && local_co[2] <= side) { + test->dist = MAX3(local_co[0], local_co[1], local_co[2]) / side; + + return 1; + } + else { + return 0; + } +} + +static float frontface(Brush *brush, float sculpt_normal[3], short no[3], float fno[3]) +{ + if (brush->flag & BRUSH_FRONTFACE) { + float dot; + + if (no) { + float tmp[3]; + + normal_short_to_float_v3(tmp, no); + dot= dot_v3v3(tmp, sculpt_normal); + } + else { + dot= dot_v3v3(fno, sculpt_normal); + } + + return dot > 0 ? dot : 0; + } + else { + return 1; + } +} + +#if 0 + +static int sculpt_brush_test_cyl(SculptBrushTest *test, float co[3], float location[3], float an[3]) +{ + if (sculpt_brush_test_fast(test, co)) { + float t1[3], t2[3], t3[3], dist; + + sub_v3_v3v3(t1, location, co); + sub_v3_v3v3(t2, x2, location); + + cross_v3_v3v3(t3, an, t1); + + dist = len_v3(t3)/len_v3(t2); + + test->dist = dist; + + return 1; + } return 0; } +#endif + /* ===== Sculpting ===== * */ + -/* Return modified brush strength. Includes the direction of the brush, positive - values pull vertices, negative values push. Uses tablet pressure and a - special multiplier found experimentally to scale the strength factor. */ -static float brush_strength(Sculpt *sd, StrokeCache *cache) +static float overlapped_curve(Brush* br, float x) { - Brush *brush = paint_brush(&sd->paint); - /* Primary strength input; square it to make lower values more sensitive */ - float alpha = brush->alpha * brush->alpha; + int i; + const int n = 100 / br->spacing; + const float h = br->spacing / 50.0f; + const float x0 = x-1; - float dir= brush->flag & BRUSH_DIR_IN ? -1 : 1; - float pressure= 1; - float flip= cache->flip ? -1:1; + float sum; - if(brush->flag & BRUSH_ALPHA_PRESSURE) - pressure *= cache->pressure; - - switch(brush->sculpt_tool){ - case SCULPT_TOOL_DRAW: - case SCULPT_TOOL_INFLATE: - case SCULPT_TOOL_CLAY: - case SCULPT_TOOL_FLATTEN: - case SCULPT_TOOL_LAYER: - return alpha * dir * pressure * flip; /*XXX: not sure why? was multiplied by G.vd->grid */; - case SCULPT_TOOL_SMOOTH: - return alpha * 4 * pressure; - case SCULPT_TOOL_PINCH: - return alpha / 2 * dir * pressure * flip; - case SCULPT_TOOL_GRAB: - return 1; - default: - return 0; + sum = 0; + for (i= 0; i < n; i++) { + float xx; + + xx = fabs(x0 + i*h); + + if (xx < 1.0f) + sum += brush_curve_strength(br, xx, 1); } + + return sum; +} + +static float integrate_overlap(Brush* br) +{ + int i; + int m= 10; + float g = 1.0f/m; + float overlap; + float max; + + overlap= 0; + max= 0; + for(i= 0; i < m; i++) { + overlap = overlapped_curve(br, i*g); + + if (overlap > max) + max = overlap; + } + + return max; } /* Uses symm to selectively flip any axis of a coordinate. */ @@ -645,6 +514,166 @@ static void flip_coord(float out[3], float in[3], const char symm) out[2]= in[2]; } +float calc_overlap(StrokeCache *cache, const char symm, const char axis, const float angle) +{ + float mirror[3]; + float distsq; + float mat[4][4]; + + //flip_coord(mirror, cache->traced_location, symm); + flip_coord(mirror, cache->true_location, symm); + + unit_m4(mat); + rotate_m4(mat, axis, angle); + + mul_m4_v3(mat, mirror); + + //distsq = len_squared_v3v3(mirror, cache->traced_location); + distsq = len_squared_v3v3(mirror, cache->true_location); + + if (distsq <= 4*(cache->radius_squared)) + return (2*(cache->radius) - sqrt(distsq)) / (2*(cache->radius)); + else + return 0; +} + +static float calc_radial_symmetry_feather(Sculpt *sd, StrokeCache *cache, const char symm, const char axis) +{ + int i; + float overlap; + + overlap = 0; + for(i = 1; i < sd->radial_symm[axis-'X']; ++i) { + const float angle = 2*M_PI*i/sd->radial_symm[axis-'X']; + overlap += calc_overlap(cache, symm, axis, angle); + } + + return overlap; +} + +static float calc_symmetry_feather(Sculpt *sd, StrokeCache* cache) +{ + if (sd->flags & SCULPT_SYMMETRY_FEATHER) { + float overlap; + int symm = cache->symmetry; + int i; + + overlap = 0; + for (i = 0; i <= symm; i++) { + if(i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { + + overlap += calc_overlap(cache, i, 0, 0); + + overlap += calc_radial_symmetry_feather(sd, cache, i, 'X'); + overlap += calc_radial_symmetry_feather(sd, cache, i, 'Y'); + overlap += calc_radial_symmetry_feather(sd, cache, i, 'Z'); + } + } + + return 1/overlap; + } + else { + return 1; + } +} + +/* Return modified brush strength. Includes the direction of the brush, positive + values pull vertices, negative values push. Uses tablet pressure and a + special multiplier found experimentally to scale the strength factor. */ +static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather, float overlap) +{ + Brush *brush = paint_brush(&sd->paint); + + /* Primary strength input; square it to make lower values more sensitive */ + float alpha = sculpt_get_brush_alpha(brush)*sculpt_get_brush_alpha(brush); + float dir = brush->flag & BRUSH_DIR_IN ? -1 : 1; + float pressure = brush->flag & BRUSH_ALPHA_PRESSURE ? cache->pressure : 1; + float pen_flip = cache->pen_flip ? -1 : 1; + float invert = cache->invert ? -1 : 1; + float flip = dir * invert * pen_flip; + + switch(brush->sculpt_tool){ + case SCULPT_TOOL_CLAY: + case SCULPT_TOOL_CLAY_TUBES: + case SCULPT_TOOL_DRAW: + case SCULPT_TOOL_LAYER: + return alpha * flip * pressure * overlap * feather; + + case SCULPT_TOOL_CREASE: + case SCULPT_TOOL_BLOB: + return alpha * flip * pressure * overlap * feather; + + case SCULPT_TOOL_INFLATE: + if (flip > 0) { + return 0.250f * alpha * flip * pressure * overlap * feather; + } + else { + return 0.125f * alpha * flip * pressure * overlap * feather; + } + + case SCULPT_TOOL_FILL: + case SCULPT_TOOL_SCRAPE: + case SCULPT_TOOL_FLATTEN: + if (flip > 0) { + overlap = (1+overlap) / 2; + return alpha * flip * pressure * overlap * feather; + } + else { + /* reduce strength for DEEPEN, PEAKS, and CONTRAST */ + return 0.5f * alpha * flip * pressure * overlap * feather; + } + + case SCULPT_TOOL_SMOOTH: + return alpha * pressure * feather; + + case SCULPT_TOOL_PINCH: + if (flip > 0) { + return alpha * flip * pressure * overlap * feather; + } + else { + return 0.25f * alpha * flip * pressure * overlap * feather; + } + + case SCULPT_TOOL_NUDGE: + overlap = (1+overlap) / 2; + return alpha * pressure * overlap * feather; + + case SCULPT_TOOL_THUMB: + return alpha*pressure*feather; + + case SCULPT_TOOL_SNAKE_HOOK: + return feather; + + case SCULPT_TOOL_GRAB: + case SCULPT_TOOL_ROTATE: + return feather; + + default: + return 0; + } +} + +float get_tex_pixel(Brush* br, float u, float v) +{ + TexResult texres; + float co[3]; + int hasrgb; + + co[0] = u; + co[1] = v; + co[2] = 0; + + memset(&texres, 0, sizeof(TexResult)); + hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 1, &texres); + + if (hasrgb & TEX_RGB) + texres.tin = (0.35*texres.tr + 0.45*texres.tg + 0.2*texres.tb)*texres.ta; + + return texres.tin; +} + +#if 0 + /* Get a pixel from the texcache at (px, py) */ static unsigned char get_texcache_pixel(const SculptSession *ss, int px, int py) { @@ -655,7 +684,7 @@ static unsigned char get_texcache_pixel(const SculptSession *ss, int px, int py) static float get_texcache_pixel_bilinear(const SculptSession *ss, float u, float v) { - int x, y, x2, y2; + unsigned x, y, x2, y2; const int tc_max = ss->texcache_side - 1; float urat, vrat, uopp; @@ -682,76 +711,97 @@ static float get_texcache_pixel_bilinear(const SculptSession *ss, float u, float get_texcache_pixel(ss, x2, y2) * urat) * vrat) / 255.0; } +#endif + /* Return a multiplier for brush strength on a particular vertex. */ static float tex_strength(SculptSession *ss, Brush *br, float *point, const float len) { - MTex *tex = &br->mtex; + MTex *mtex = &br->mtex; float avg= 1; - if(!tex) { + if(!mtex->tex) { avg= 1; } - else if(tex->brush_map_mode == MTEX_MAP_MODE_3D) { + else if(mtex->brush_map_mode == MTEX_MAP_MODE_3D) { float jnk; /* Get strength by feeding the vertex location directly into a texture */ - externtex(tex, point, &avg, + externtex(mtex, point, &avg, &jnk, &jnk, &jnk, &jnk); } else if(ss->texcache) { - const float bsize= ss->cache->pixel_radius * 2; - const float rot= tex->rot + ss->cache->rotation; - int px, py; - float flip[3], point_2d[2]; + float rotation = -mtex->rot; + float x, y, point_2d[3]; + float diameter; - /* If the active area is being applied for symmetry, flip it - across the symmetry axis in order to project it. This insures - that the brush texture will be oriented correctly. */ - copy_v3_v3(flip, point); - flip_coord(flip, flip, ss->cache->symmetry); - projectf(ss->cache->mats, flip, point_2d); + /* if the active area is being applied for symmetry, flip it + across the symmetry axis and rotate it back to the orignal + position in order to project it. This insures that the + brush texture will be oriented correctly. */ - /* For Tile and Drag modes, get the 2D screen coordinates of the - and scale them up or down to the texture size. */ - if(tex->brush_map_mode == MTEX_MAP_MODE_TILED) { - const int sx= (const int)tex->size[0]; - const int sy= (const int)tex->size[1]; - - float fx= point_2d[0]; - float fy= point_2d[1]; - - float angle= atan2(fy, fx) - rot; - float flen= sqrtf(fx*fx + fy*fy); - - if(rot<0.001 && rot>-0.001) { - px= point_2d[0]; - py= point_2d[1]; - } else { - px= flen * cos(angle) + 2000; - py= flen * sin(angle) + 2000; - } - if(sx != 1) - px %= sx-1; - if(sy != 1) - py %= sy-1; - avg= get_texcache_pixel_bilinear(ss, ss->texcache_side*px/sx, ss->texcache_side*py/sy); + flip_coord(point_2d, point, ss->cache->mirror_symmetry_pass); + + if (ss->cache->radial_symmetry_pass) + mul_m4_v3(ss->cache->symm_rot_mat_inv, point_2d); + + projectf(ss->cache->mats, point_2d, point_2d); + + /* if fixed mode, keep coordinates relative to mouse */ + if(mtex->brush_map_mode == MTEX_MAP_MODE_FIXED) { + rotation += ss->cache->special_rotation; + + point_2d[0] -= ss->cache->tex_mouse[0]; + point_2d[1] -= ss->cache->tex_mouse[1]; + + diameter = ss->cache->pixel_radius; // use pressure adjusted size for fixed mode + + x = point_2d[0]; + y = point_2d[1]; } - else if(tex->brush_map_mode == MTEX_MAP_MODE_FIXED) { - float fx= (point_2d[0] - ss->cache->tex_mouse[0]) / bsize; - float fy= (point_2d[1] - ss->cache->tex_mouse[1]) / bsize; - - float angle= atan2(fy, fx) - rot; - float flen= sqrtf(fx*fx + fy*fy); - - fx = flen * cos(angle) + 0.5; - fy = flen * sin(angle) + 0.5; - - avg= get_texcache_pixel_bilinear(ss, fx * ss->texcache_side, fy * ss->texcache_side); + else /* else (mtex->brush_map_mode == MTEX_MAP_MODE_TILED), + leave the coordinates relative to the screen */ + { + diameter = sculpt_get_brush_size(br); // use unadjusted size for tiled mode + + x = point_2d[0] - ss->cache->vc->ar->winrct.xmin; + y = point_2d[1] - ss->cache->vc->ar->winrct.ymin; } + + x /= ss->cache->vc->ar->winx; + y /= ss->cache->vc->ar->winy; + + if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) { + x -= 0.5f; + y -= 0.5f; + } + + x *= ss->cache->vc->ar->winx / diameter; + y *= ss->cache->vc->ar->winy / diameter; + + /* it is probably worth optimizing for those cases where + the texture is not rotated by skipping the calls to + atan2, sqrtf, sin, and cos. */ + if (rotation > 0.001 || rotation < -0.001) { + const float angle = atan2(y, x) + rotation; + const float flen = sqrtf(x*x + y*y); + + x = flen * cos(angle); + y = flen * sin(angle); + } + + x *= br->mtex.size[0]; + y *= br->mtex.size[1]; + + x += br->mtex.ofs[0]; + y += br->mtex.ofs[1]; + + avg = get_tex_pixel(br, x, y); } - avg*= brush_curve_strength(br, len, ss->cache->radius); /* Falloff curve */ + avg += br->texture_sample_bias; + + avg *= brush_curve_strength(br, len, ss->cache->radius); /* Falloff curve */ return avg; } @@ -787,7 +837,7 @@ static int sculpt_search_sphere_cb(PBVHNode *node, void *data_v) sub_v3_v3v3(t, center, nearest); - return t[0] * t[0] + t[1] * t[1] + t[2] * t[2] < data->radius_squared; + return dot_v3v3(t, t) < data->radius_squared; } /* Handles clipping against a mirror modifier and SCULPT_LOCK axis flags */ @@ -803,7 +853,7 @@ static void sculpt_clip(Sculpt *sd, SculptSession *ss, float *co, const float va co[i]= 0.0f; else co[i]= val[i]; - } + } } static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], float fno[3]) @@ -815,52 +865,48 @@ static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], floa } } -/* For draw/layer/flatten; finds average normal for all active vertices */ -static void calc_area_normal(Sculpt *sd, SculptSession *ss, float area_normal[3], PBVHNode **nodes, int totnode) +static void calc_area_normal(Sculpt *sd, SculptSession *ss, float an[3], PBVHNode **nodes, int totnode) { - PBVH *bvh= ss->pbvh; - StrokeCache *cache = ss->cache; - const int view = 0; /* XXX: should probably be a flag, not number: brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */ - float out[3] = {0.0f, 0.0f, 0.0f}; - float out_flip[3] = {0.0f, 0.0f, 0.0f}; - float out_dir[3]; int n; - copy_v3_v3(out_dir, cache->view_normal_symmetry); + float out_flip[3] = {0.0f, 0.0f, 0.0f}; - /* threaded loop over nodes */ - //#pragma omp parallel for private(n) schedule(static) + zero_v3(an); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; ncache->original) { - BLI_pbvh_vertex_iter_begin(bvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, unode->co[vd.i])) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test_fast(&test, unode->co[vd.i])) { + float fno[3]; + normal_short_to_float_v3(fno, unode->no[vd.i]); - add_norm_if(out_dir, nout, nout_flip, fno); + add_norm_if(ss->cache->view_normal, private_an, private_out_flip, fno); } } BLI_pbvh_vertex_iter_end; } else { - BLI_pbvh_vertex_iter_begin(bvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test_fast(&test, vd.co)) { if(vd.no) { + float fno[3]; + normal_short_to_float_v3(fno, vd.no); - add_norm_if(out_dir, nout, nout_flip, fno); + add_norm_if(ss->cache->view_normal, private_an, private_out_flip, fno); + } + else { + add_norm_if(ss->cache->view_normal, private_an, private_out_flip, vd.fno); } - else - add_norm_if(out_dir, nout, nout_flip, vd.fno); } } BLI_pbvh_vertex_iter_end; @@ -868,72 +914,70 @@ static void calc_area_normal(Sculpt *sd, SculptSession *ss, float area_normal[3] //#pragma omp critical { - /* we sum per node and add together later for threads */ - add_v3_v3(out, nout); - add_v3_v3(out_flip, nout_flip); + add_v3_v3(an, private_an); + add_v3_v3(out_flip, private_out_flip); } } - if (out[0]==0.0 && out[1]==0.0 && out[2]==0.0) { - copy_v3_v3(out, out_flip); - } - - normalize_v3(out); + if (is_zero_v3(an)) + copy_v3_v3(an, out_flip); - out[0] = out_dir[0] * view + out[0] * (10-view); - out[1] = out_dir[1] * view + out[1] * (10-view); - out[2] = out_dir[2] * view + out[2] * (10-view); - - normalize_v3(out); - copy_v3_v3(area_normal, out); + normalize_v3(an); } -static void do_draw_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +/* This initializes the faces to be moved for this sculpt for draw/layer/flatten; then it + finds average normal for all active vertices - note that this is called once for each mirroring direction */ +static void calc_sculpt_normal(Sculpt *sd, SculptSession *ss, float an[3], PBVHNode **nodes, int totnode) { Brush *brush = paint_brush(&sd->paint); - float offset[3], area_normal[3]; - float bstrength= ss->cache->bstrength; - int n; - /* area normal */ - calc_area_normal(sd, ss, area_normal, nodes, totnode); + if (ss->cache->mirror_symmetry_pass == 0 && + ss->cache->radial_symmetry_pass == 0 && + (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL))) + { + switch (brush->sculpt_plane) { + case SCULPT_DISP_DIR_VIEW: + viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an); + break; - /* offset with as much as possible factored in already */ - offset[0]= area_normal[0]*ss->cache->radius*ss->cache->scale[0]*bstrength; - offset[1]= area_normal[1]*ss->cache->radius*ss->cache->scale[1]*bstrength; - offset[2]= area_normal[2]*ss->cache->radius*ss->cache->scale[2]*bstrength; + case SCULPT_DISP_DIR_X: + an[1] = 0.0; + an[2] = 0.0; + an[0] = 1.0; + break; - /* threaded loop over nodes */ - //#pragma omp parallel for private(n) schedule(static) - for(n=0; npbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { - /* offset vertex */ - float fade = tex_strength(ss, brush, vd.co, test.dist); - float val[3]= {vd.co[0] + offset[0]*fade, - vd.co[1] + offset[1]*fade, - vd.co[2] + offset[2]*fade}; + case SCULPT_DISP_DIR_Z: + an[0] = 0.0; + an[1] = 0.0; + an[2] = 1.0; + break; - sculpt_clip(sd, ss, vd.co, val); - if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } + case SCULPT_DISP_DIR_AREA: + calc_area_normal(sd, ss, an, nodes, totnode); + + default: + break; } - BLI_pbvh_vertex_iter_end; - BLI_pbvh_node_mark_update(nodes[n]); + copy_v3_v3(ss->cache->last_area_normal, an); + } + else { + copy_v3_v3(an, ss->cache->last_area_normal); + flip_coord(an, an, ss->cache->mirror_symmetry_pass); + mul_m4_v3(ss->cache->symm_rot_mat, an); } } /* For the smooth brush, uses the neighboring vertices around vert to calculate a smoothed location for vert. Skips corner vertices (used by only one polygon.) */ -static void neighbor_average(SculptSession *ss, float avg[3], const int vert) +static void neighbor_average(SculptSession *ss, float avg[3], const unsigned vert) { int i, skip= -1, total=0; IndexNode *node= ss->fmap[vert].first; @@ -974,52 +1018,58 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) copy_v3_v3(avg, ss->mvert[vert].co); } -static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node) +static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength) { Brush *brush = paint_brush(&sd->paint); - float bstrength= ss->cache->bstrength; PBVHVertexIter vd; SculptBrushTest test; + CLAMP(bstrength, 0.0f, 1.0f); + sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, vd.co)) { - float fade = tex_strength(ss, brush, vd.co, test.dist)*bstrength; + const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->view_normal, vd.no, vd.fno); float avg[3], val[3]; - CLAMP(fade, 0.0f, 1.0f); - neighbor_average(ss, avg, vd.vert_indices[vd.i]); - val[0] = vd.co[0]+(avg[0]-vd.co[0])*fade; - val[1] = vd.co[1]+(avg[1]-vd.co[1])*fade; - val[2] = vd.co[2]+(avg[2]-vd.co[2])*fade; - - sculpt_clip(sd, ss, vd.co, val); - if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + sub_v3_v3v3(val, avg, vd.co); + mul_v3_fl(val, fade); + + add_v3_v3(val, vd.co); + + sculpt_clip(sd, ss, vd.co, val); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } BLI_pbvh_vertex_iter_end; } -static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node) +static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength) { Brush *brush = paint_brush(&sd->paint); SculptBrushTest test; DMGridData **griddata, *data; DMGridAdjacency *gridadj, *adj; - float bstrength= ss->cache->bstrength; - float co[3], (*tmpgrid)[3]; + float (*tmpgrid)[3], (*tmprow)[3]; int v1, v2, v3, v4; int *grid_indices, totgrid, gridsize, i, x, y; - + sculpt_brush_test_init(ss, &test); + CLAMP(bstrength, 0.0f, 1.0f); + BLI_pbvh_node_get_grids(ss->pbvh, node, &grid_indices, &totgrid, NULL, &gridsize, &griddata, &gridadj); //#pragma omp critical - tmpgrid= MEM_mallocN(sizeof(float)*3*gridsize*gridsize, "tmpgrid"); + { + tmpgrid= MEM_mallocN(sizeof(float)*3*gridsize*gridsize, "tmpgrid"); + tmprow= MEM_mallocN(sizeof(float)*3*gridsize, "tmprow"); + } for(i = 0; i < totgrid; ++i) { data = griddata[grid_indices[i]]; @@ -1027,75 +1077,106 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no memset(tmpgrid, 0, sizeof(float)*3*gridsize*gridsize); - /* average grid values */ - for(y = 0; y < gridsize-1; ++y) { - for(x = 0; x < gridsize-1; ++x) { + for (y= 0; y < gridsize-1; y++) { + float tmp[3]; + + v1 = y*gridsize; + add_v3_v3v3(tmprow[0], data[v1].co, data[v1+gridsize].co); + + for (x= 0; x < gridsize-1; x++) { v1 = x + y*gridsize; - v2 = (x + 1) + y*gridsize; - v3 = (x + 1) + (y + 1)*gridsize; - v4 = x + (y + 1)*gridsize; + v2 = v1 + 1; + v3 = v1 + gridsize; + v4 = v3 + 1; - cent_quad_v3(co, data[v1].co, data[v2].co, data[v3].co, data[v4].co); - mul_v3_fl(co, 0.25f); + add_v3_v3v3(tmprow[x+1], data[v2].co, data[v4].co); + add_v3_v3v3(tmp, tmprow[x+1], tmprow[x]); - add_v3_v3(tmpgrid[v1], co); - add_v3_v3(tmpgrid[v2], co); - add_v3_v3(tmpgrid[v3], co); - add_v3_v3(tmpgrid[v4], co); + add_v3_v3(tmpgrid[v1], tmp); + add_v3_v3(tmpgrid[v2], tmp); + add_v3_v3(tmpgrid[v3], tmp); + add_v3_v3(tmpgrid[v4], tmp); } } /* blend with existing coordinates */ for(y = 0; y < gridsize; ++y) { for(x = 0; x < gridsize; ++x) { - if(x == 0 && adj->index[0] == -1) continue; - if(x == gridsize - 1 && adj->index[2] == -1) continue; - if(y == 0 && adj->index[3] == -1) continue; - if(y == gridsize - 1 && adj->index[1] == -1) continue; + float *co; + float *fno; + int index; - copy_v3_v3(co, data[x + y*gridsize].co); + if(x == 0 && adj->index[0] == -1) + continue; + + if(x == gridsize - 1 && adj->index[2] == -1) + continue; + + if(y == 0 && adj->index[3] == -1) + continue; + + if(y == gridsize - 1 && adj->index[1] == -1) + continue; + + index = x + y*gridsize; + co= data[index].co; + fno= data[index].no; if(sculpt_brush_test(&test, co)) { - float fade = tex_strength(ss, brush, co, test.dist)*bstrength; - float avg[3], val[3]; + const float fade = bstrength*tex_strength(ss, brush, co, test.dist)*frontface(brush, ss->cache->view_normal, NULL, fno); + float *avg, val[3]; + float n; + + avg = tmpgrid[x + y*gridsize]; + + n = 1/16.0f; - copy_v3_v3(avg, tmpgrid[x + y*gridsize]); if(x == 0 || x == gridsize - 1) - mul_v3_fl(avg, 2.0f); + n *= 2; + if(y == 0 || y == gridsize - 1) - mul_v3_fl(avg, 2.0f); + n *= 2; - CLAMP(fade, 0.0f, 1.0f); + mul_v3_fl(avg, n); - val[0] = co[0]+(avg[0]-co[0])*fade; - val[1] = co[1]+(avg[1]-co[1])*fade; - val[2] = co[2]+(avg[2]-co[2])*fade; - - sculpt_clip(sd, ss, data[x + y*gridsize].co, val); + sub_v3_v3v3(val, avg, co); + mul_v3_fl(val, fade); + + add_v3_v3(val, co); + + sculpt_clip(sd, ss, co, val); } } } } //#pragma omp critical - MEM_freeN(tmpgrid); + { + MEM_freeN(tmpgrid); + MEM_freeN(tmprow); + } } -static void do_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +static void smooth(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float bstrength) { - int iteration, n; + const int max_iterations = 4; + const float fract = 1.0f/max_iterations; + int iteration, n, count; + float last; - for(iteration = 0; iteration < 2; ++iteration) { - //#pragma omp parallel for private(n) schedule(static) + CLAMP(bstrength, 0, 1); + + count = (int)(bstrength*max_iterations); + last = max_iterations*(bstrength - count*fract); + + for(iteration = 1; iteration <= count; ++iteration) { + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; nmultires) - do_multires_smooth_brush(sd, ss, nodes[n]); + if(ss->multires) { + do_multires_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last); + } else if(ss->fmap) - do_mesh_smooth_brush(sd, ss, nodes[n]); - - BLI_pbvh_node_mark_update(nodes[n]); + do_mesh_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last); } if(ss->multires) @@ -1103,69 +1184,378 @@ static void do_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int } } +static void do_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + smooth(sd, ss, nodes, totnode, ss->cache->bstrength); +} + +static void do_draw_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + Brush *brush = paint_brush(&sd->paint); + float offset[3], area_normal[3]; + float bstrength= ss->cache->bstrength; + int n; + + calc_sculpt_normal(sd, ss, area_normal, nodes, totnode); + + /* offset with as much as possible factored in already */ + mul_v3_v3fl(offset, area_normal, ss->cache->radius); + mul_v3_v3(offset, ss->cache->scale); + mul_v3_fl(offset, bstrength); + + /* threaded loop over nodes */ + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for(n=0; npbvh, nodes[n])->co; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if (sculpt_brush_test(&test, vd.co)) { + //if(sculpt_brush_test_cyl(&test, vd.co, ss->cache->location, area_normal)) { + /* offset vertex */ + float fade = tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, area_normal, vd.no, vd.fno); + + mul_v3_v3fl(proxy[vd.i], offset, fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + BLI_pbvh_vertex_iter_end; + } +} + +static void do_crease_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + Brush *brush = paint_brush(&sd->paint); + float offset[3], area_normal[3]; + float bstrength= ss->cache->bstrength; + float flippedbstrength, crease_correction; + int n; + + calc_sculpt_normal(sd, ss, area_normal, nodes, totnode); + + /* offset with as much as possible factored in already */ + mul_v3_v3fl(offset, area_normal, ss->cache->radius); + mul_v3_v3(offset, ss->cache->scale); + mul_v3_fl(offset, bstrength); + + /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */ + + if(sculpt_get_brush_alpha(brush) > 0.0f) + crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor/(sculpt_get_brush_alpha(brush)*sculpt_get_brush_alpha(brush)); + else + crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor; + + /* we always want crease to pinch or blob to relax even when draw is negative */ + flippedbstrength = (bstrength < 0) ? -crease_correction*bstrength : crease_correction*bstrength; + + if(brush->sculpt_tool == SCULPT_TOOL_BLOB) flippedbstrength *= -1.0f; + + /* threaded loop over nodes */ + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for(n=0; npbvh, nodes[n])->co; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test(&test, vd.co)) { + /* offset vertex */ + const float fade = tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, area_normal, vd.no, vd.fno); + float val1[3]; + float val2[3]; + + /* first we pinch */ + sub_v3_v3v3(val1, test.location, vd.co); + //mul_v3_v3(val1, ss->cache->scale); + mul_v3_fl(val1, fade*flippedbstrength); + + /* then we draw */ + mul_v3_v3fl(val2, offset, fade); + + add_v3_v3v3(proxy[vd.i], val1, val2); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + BLI_pbvh_vertex_iter_end; + } +} + static void do_pinch_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) { Brush *brush = paint_brush(&sd->paint); float bstrength= ss->cache->bstrength; int n; - //#pragma omp parallel for private(n) schedule(static) + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; npbvh, nodes[n])->co; + sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, vd.co)) { - float fade = tex_strength(ss, brush, vd.co, test.dist)*bstrength; - float val[3]= {vd.co[0]+(test.location[0]-vd.co[0])*fade, - vd.co[1]+(test.location[1]-vd.co[1])*fade, - vd.co[2]+(test.location[2]-vd.co[2])*fade}; + float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->view_normal, vd.no, vd.fno); + float val[3]; - sculpt_clip(sd, ss, vd.co, val); - if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } + sub_v3_v3v3(val, test.location, vd.co); + mul_v3_v3fl(proxy[vd.i], val, fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } } BLI_pbvh_vertex_iter_end; - - BLI_pbvh_node_mark_update(nodes[n]); } } static void do_grab_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) { - Brush *brush = paint_brush(&sd->paint); + Brush *brush= paint_brush(&sd->paint); float bstrength= ss->cache->bstrength; - float grab_delta[3]; + float grab_delta[3], an[3]; int n; - + float len; + + if (brush->normal_weight > 0) + calc_sculpt_normal(sd, ss, an, nodes, totnode); + copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry); - //#pragma omp parallel for private(n) schedule(static) + len = len_v3(grab_delta); + + if (brush->normal_weight > 0) { + mul_v3_fl(an, len*brush->normal_weight); + mul_v3_fl(grab_delta, 1.0f - brush->normal_weight); + add_v3_v3(grab_delta, an); + } + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; nco; + short (*origno)[3]; + float (*proxy)[3]; + + unode= sculpt_undo_push_node(ss, nodes[n]); + origco= unode->co; + origno= unode->no; + + proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; + sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, origco[vd.i])) { - float fade = tex_strength(ss, brush, origco[vd.i], test.dist)*bstrength; - float add[3]= {vd.co[0]+fade*grab_delta[0], - vd.co[1]+fade*grab_delta[1], - vd.co[2]+fade*grab_delta[2]}; + const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist)*frontface(brush, an, origno[vd.i], NULL); - sculpt_clip(sd, ss, vd.co, add); - if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + mul_v3_v3fl(proxy[vd.i], grab_delta, fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } BLI_pbvh_vertex_iter_end; + } +} - BLI_pbvh_node_mark_update(nodes[n]); +static void do_nudge_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + Brush *brush = paint_brush(&sd->paint); + float bstrength = ss->cache->bstrength; + float grab_delta[3]; + int n; + float an[3]; + float tmp[3], cono[3]; + + copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry); + + calc_sculpt_normal(sd, ss, an, nodes, totnode); + + cross_v3_v3v3(tmp, an, grab_delta); + cross_v3_v3v3(cono, tmp, an); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for(n = 0; n < totnode; n++) { + PBVHVertexIter vd; + SculptBrushTest test; + float (*proxy)[3]; + + proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test(&test, vd.co)) { + const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, an, vd.no, vd.fno); + + mul_v3_v3fl(proxy[vd.i], cono, fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + BLI_pbvh_vertex_iter_end; + } +} + +static void do_snake_hook_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + Brush *brush = paint_brush(&sd->paint); + float bstrength = ss->cache->bstrength; + float grab_delta[3], an[3]; + int n; + float len; + + if (brush->normal_weight > 0) + calc_sculpt_normal(sd, ss, an, nodes, totnode); + + copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry); + + len = len_v3(grab_delta); + + if (bstrength < 0) + negate_v3(grab_delta); + + if (brush->normal_weight > 0) { + mul_v3_fl(an, len*brush->normal_weight); + mul_v3_fl(grab_delta, 1.0f - brush->normal_weight); + add_v3_v3(grab_delta, an); + } + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for(n = 0; n < totnode; n++) { + PBVHVertexIter vd; + SculptBrushTest test; + float (*proxy)[3]; + + proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test(&test, vd.co)) { + const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, an, vd.no, vd.fno); + + mul_v3_v3fl(proxy[vd.i], grab_delta, fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + BLI_pbvh_vertex_iter_end; + } +} + +static void do_thumb_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + Brush *brush = paint_brush(&sd->paint); + float bstrength = ss->cache->bstrength; + float grab_delta[3]; + int n; + float an[3]; + float tmp[3], cono[3]; + + copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry); + + calc_sculpt_normal(sd, ss, an, nodes, totnode); + + cross_v3_v3v3(tmp, an, grab_delta); + cross_v3_v3v3(cono, tmp, an); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for(n = 0; n < totnode; n++) { + PBVHVertexIter vd; + SculptUndoNode* unode; + SculptBrushTest test; + float (*origco)[3]; + short (*origno)[3]; + float (*proxy)[3]; + + unode= sculpt_undo_push_node(ss, nodes[n]); + origco= unode->co; + origno= unode->no; + + proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test(&test, origco[vd.i])) { + const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist)*frontface(brush, an, origno[vd.i], NULL); + + mul_v3_v3fl(proxy[vd.i], cono, fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + BLI_pbvh_vertex_iter_end; + } +} + +static void do_rotate_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + Brush *brush= paint_brush(&sd->paint); + float bstrength= ss->cache->bstrength; + float an[3]; + int n; + float m[3][3]; + static const int flip[8] = { 1, -1, -1, 1, -1, 1, 1, -1 }; + float angle = ss->cache->vertex_rotation * flip[ss->cache->mirror_symmetry_pass]; + + calc_sculpt_normal(sd, ss, an, nodes, totnode); + + axis_angle_to_mat3(m, an, angle); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for(n=0; nco; + origno= unode->no; + + proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test(&test, origco[vd.i])) { + const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist)*frontface(brush, an, origno[vd.i], NULL); + + mul_v3_m3v3(proxy[vd.i], m, origco[vd.i]); + sub_v3_v3(proxy[vd.i], origco[vd.i]); + mul_v3_fl(proxy[vd.i], fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + BLI_pbvh_vertex_iter_end; } } @@ -1177,63 +1567,66 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int float lim= ss->cache->radius / 4; int n; - if(ss->cache->flip) + if(bstrength < 0) lim = -lim; - calc_area_normal(sd, ss, area_normal, nodes, totnode); + calc_sculpt_normal(sd, ss, area_normal, nodes, totnode); - offset[0]= ss->cache->scale[0]*area_normal[0]; - offset[1]= ss->cache->scale[1]*area_normal[1]; - offset[2]= ss->cache->scale[2]*area_normal[2]; + mul_v3_v3v3(offset, ss->cache->scale, area_normal); - //#pragma omp parallel for private(n) schedule(static) + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; npbvh, nodes[n])->co; unode= sculpt_undo_push_node(ss, nodes[n]); origco=unode->co; if(!unode->layer_disp) - unode->layer_disp= MEM_callocN(sizeof(float)*unode->totvert, "layer disp"); + { + #pragma omp critical + unode->layer_disp= MEM_callocN(sizeof(float)*unode->totvert, "layer disp"); + } + layer_disp= unode->layer_disp; sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, vd.co)) { - float fade = tex_strength(ss, brush, vd.co, test.dist)*bstrength; + const float fade = bstrength*ss->cache->radius*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, area_normal, vd.no, vd.fno); float *disp= &layer_disp[vd.i]; float val[3]; - + *disp+= fade; - + /* Don't let the displacement go past the limit */ if((lim < 0 && *disp < lim) || (lim > 0 && *disp > lim)) *disp = lim; - + + mul_v3_v3fl(val, offset, *disp); + if(ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { int index= vd.vert_indices[vd.i]; /* persistent base */ - val[0] = ss->layer_co[index][0] + (*disp)*offset[0]; - val[1] = ss->layer_co[index][1] + (*disp)*offset[1]; - val[2] = ss->layer_co[index][2] + (*disp)*offset[2]; + add_v3_v3(val, ss->layer_co[index]); } else { - val[0] = origco[vd.i][0] + (*disp)*offset[0]; - val[1] = origco[vd.i][1] + (*disp)*offset[1]; - val[2] = origco[vd.i][2] + (*disp)*offset[2]; + add_v3_v3(val, origco[vd.i]); } sculpt_clip(sd, ss, vd.co, val); - if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } BLI_pbvh_vertex_iter_end; - - BLI_pbvh_node_mark_update(nodes[n]); } } @@ -1243,177 +1636,634 @@ static void do_inflate_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, in float bstrength= ss->cache->bstrength; int n; - //#pragma omp parallel for private(n) schedule(static) + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; npbvh, nodes[n])->co; + sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, vd.co)) { - float fade = tex_strength(ss, brush, vd.co, test.dist)*bstrength; - float add[3]; + const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->view_normal, vd.no, vd.fno); + float val[3]; - if(vd.fno) copy_v3_v3(add, vd.fno); - else normal_short_to_float_v3(add, vd.no); + if(vd.fno) copy_v3_v3(val, vd.fno); + else normal_short_to_float_v3(val, vd.no); - mul_v3_fl(add, fade * ss->cache->radius); - add[0]*= ss->cache->scale[0]; - add[1]*= ss->cache->scale[1]; - add[2]*= ss->cache->scale[2]; - add_v3_v3(add, vd.co); - - sculpt_clip(sd, ss, vd.co, add); - if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + mul_v3_fl(val, fade * ss->cache->radius); + mul_v3_v3v3(proxy[vd.i], val, ss->cache->scale); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } BLI_pbvh_vertex_iter_end; - - BLI_pbvh_node_mark_update(nodes[n]); } } -static void calc_flatten_center(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float co[3]) +static void calc_flatten_center(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float fc[3]) { - float outer_dist[FLATTEN_SAMPLE_SIZE]; - float outer_co[FLATTEN_SAMPLE_SIZE][3]; - int i, n; - - for(i = 0; i < FLATTEN_SAMPLE_SIZE; ++i) { - zero_v3(outer_co[i]); - outer_dist[i]= -1.0f; - } - - //#pragma omp parallel for private(n) schedule(static) + int n; + + float count = 0; + + zero_v3(fc); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; npbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { - for(j = 0; j < FLATTEN_SAMPLE_SIZE; ++j) { - if(test.dist > outer_dist[j]) { - copy_v3_v3(outer_co[j], vd.co); - outer_dist[j] = test.dist; - break; - } + if(ss->cache->original) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test_fast(&test, unode->co[vd.i])) { + add_v3_v3(private_fc, vd.co); + private_count++; } } + BLI_pbvh_vertex_iter_end; + } + else { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test_fast(&test, vd.co)) { + add_v3_v3(private_fc, vd.co); + private_count++; + } + } + BLI_pbvh_vertex_iter_end; } - BLI_pbvh_vertex_iter_end; - BLI_pbvh_node_mark_update(nodes[n]); + #pragma omp critical + { + add_v3_v3(fc, private_fc); + count += private_count; + } + } + + mul_v3_fl(fc, 1.0f / count); +} + +/* this calculates flatten center and area normal together, +amortizing the memory bandwidth and loop overhead to calculate both at the same time */ +static void calc_area_normal_and_flatten_center(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float an[3], float fc[3]) +{ + int n; + + // an + float out_flip[3] = {0.0f, 0.0f, 0.0f}; + + // fc + float count = 0; + + // an + zero_v3(an); + + // fc + zero_v3(fc); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for(n=0; ncache->original) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test_fast(&test, unode->co[vd.i])) { + // an + float fno[3]; + + normal_short_to_float_v3(fno, unode->no[vd.i]); + add_norm_if(ss->cache->view_normal, private_an, private_out_flip, fno); + + // fc + add_v3_v3(private_fc, vd.co); + private_count++; + } + } + BLI_pbvh_vertex_iter_end; + } + else { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if(sculpt_brush_test_fast(&test, vd.co)) { + // an + if(vd.no) { + float fno[3]; + + normal_short_to_float_v3(fno, vd.no); + add_norm_if(ss->cache->view_normal, private_an, private_out_flip, fno); + } + else { + add_norm_if(ss->cache->view_normal, private_an, private_out_flip, vd.fno); + } + + // fc + add_v3_v3(private_fc, vd.co); + private_count++; + } + } + BLI_pbvh_vertex_iter_end; + } + + #pragma omp critical + { + // an + add_v3_v3(an, private_an); + add_v3_v3(out_flip, private_out_flip); + + // fc + add_v3_v3(fc, private_fc); + count += private_count; + } + } + + // an + if (is_zero_v3(an)) + copy_v3_v3(an, out_flip); + + normalize_v3(an); + + // fc + mul_v3_fl(fc, 1.0f / count); +} + +static void calc_sculpt_plane(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float an[3], float fc[3]) +{ + Brush *brush = paint_brush(&sd->paint); + + if (ss->cache->mirror_symmetry_pass == 0 && + ss->cache->radial_symmetry_pass == 0 && + (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL))) + { + switch (brush->sculpt_plane) { + case SCULPT_DISP_DIR_VIEW: + viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an); + break; + + case SCULPT_DISP_DIR_X: + an[1] = 0.0; + an[2] = 0.0; + an[0] = 1.0; + break; + + case SCULPT_DISP_DIR_Y: + an[0] = 0.0; + an[2] = 0.0; + an[1] = 1.0; + break; + + case SCULPT_DISP_DIR_Z: + an[0] = 0.0; + an[1] = 0.0; + an[2] = 1.0; + break; + + case SCULPT_DISP_DIR_AREA: + calc_area_normal_and_flatten_center(sd, ss, nodes, totnode, an, fc); + + default: + break; + } + + // fc + /* flatten center has not been calculated yet if we are not using the area normal */ + if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA) + calc_flatten_center(sd, ss, nodes, totnode, fc); + + // an + copy_v3_v3(ss->cache->last_area_normal, an); + + // fc + copy_v3_v3(ss->cache->last_center, fc); + } + else { + // an + copy_v3_v3(an, ss->cache->last_area_normal); + + // fc + copy_v3_v3(fc, ss->cache->last_center); + + // an + flip_coord(an, an, ss->cache->mirror_symmetry_pass); + + // fc + flip_coord(fc, fc, ss->cache->mirror_symmetry_pass); + + // an + mul_m4_v3(ss->cache->symm_rot_mat, an); + + // fc + mul_m4_v3(ss->cache->symm_rot_mat, fc); } - - co[0] = co[1] = co[2] = 0.0f; - for(i = 0; i < FLATTEN_SAMPLE_SIZE; ++i) - if(outer_dist[i] >= 0.0f) - add_v3_v3(co, outer_co[i]); - mul_v3_fl(co, 1.0f / FLATTEN_SAMPLE_SIZE); } /* Projects a point onto a plane along the plane's normal */ static void point_plane_project(float intr[3], float co[3], float plane_normal[3], float plane_center[3]) { - float p1[3], sub1[3], sub2[3]; - - /* Find the intersection between squash-plane and vertex (along the area normal) */ - sub_v3_v3v3(p1, co, plane_normal); - sub_v3_v3v3(sub1, plane_center, p1); - sub_v3_v3v3(sub2, co, p1); - sub_v3_v3v3(intr, co, p1); - mul_v3_fl(intr, dot_v3v3(plane_normal, sub1) / dot_v3v3(plane_normal, sub2)); - add_v3_v3(intr, p1); + sub_v3_v3v3(intr, co, plane_center); + mul_v3_v3fl(intr, plane_normal, dot_v3v3(plane_normal, intr)); + sub_v3_v3v3(intr, co, intr); } -static int plane_point_side(float co[3], float plane_normal[3], float plane_center[3], int flip) +static int plane_trim(StrokeCache *cache, Brush *brush, float val[3]) { - float delta[3]; - float d; - - sub_v3_v3v3(delta, co, plane_center); - d = dot_v3v3(plane_normal, delta); - - if(flip) - d = -d; - - return d <= 0.0f; + return !(brush->flag & BRUSH_PLANE_TRIM) || (dot_v3v3(val, val) <= cache->radius_squared*cache->plane_trim_squared); } -static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, int clay) +static int plane_point_side_flip(float co[3], float plane_normal[3], float plane_center[3], int flip) { - /* area_normal and cntr define the plane towards which vertices are squashed */ - Brush *brush = paint_brush(&sd->paint); - float bstrength= ss->cache->bstrength; - float area_normal[3]; - float cntr[3], cntr2[3] = {0}, bstr = 0; - int n, flip = 0; + float delta[3]; + float d; - calc_area_normal(sd, ss, area_normal, nodes, totnode); - calc_flatten_center(sd, ss, nodes, totnode, cntr); + sub_v3_v3v3(delta, co, plane_center); + d = dot_v3v3(plane_normal, delta); - if(clay) { - bstr= brush_strength(sd, ss->cache); - /* Limit clay application to here */ - cntr2[0]=cntr[0]+area_normal[0]*bstr*ss->cache->scale[0]; - cntr2[1]=cntr[1]+area_normal[1]*bstr*ss->cache->scale[1]; - cntr2[2]=cntr[2]+area_normal[2]*bstr*ss->cache->scale[2]; - flip = bstr < 0; + if (flip) d = -d; + + return d <= 0.0f; +} + +static int plane_point_side(float co[3], float plane_normal[3], float plane_center[3]) +{ + float delta[3]; + + sub_v3_v3v3(delta, co, plane_center); + return dot_v3v3(plane_normal, delta) <= 0.0f; +} + +static float get_offset(Sculpt *sd, SculptSession *ss) +{ + Brush* brush = paint_brush(&sd->paint); + + float rv = brush->plane_offset; + + if (brush->flag & BRUSH_OFFSET_PRESSURE) { + rv *= ss->cache->pressure; } - //#pragma omp parallel for private(n) schedule(static) - for(n=0; npaint); + + float bstrength = ss->cache->bstrength; + const float radius = ss->cache->radius; + + float an[3]; + float fc[3]; + + float offset = get_offset(sd, ss); + + float displace; + + int n; + + float temp[3]; + + calc_sculpt_plane(sd, ss, nodes, totnode, an, fc); + + displace = radius*offset; + + mul_v3_v3v3(temp, an, ss->cache->scale); + mul_v3_fl(temp, displace); + add_v3_v3(fc, temp); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for(n = 0; n < totnode; n++) { + PBVHVertexIter vd; SculptBrushTest test; - - sculpt_undo_push_node(ss, nodes[n]); + float (*proxy)[3]; + + proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; + sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { - float intr[3], val[3]; - - if(!clay || plane_point_side(vd.co, area_normal, cntr2, flip)) { - const float fade = tex_strength(ss, brush, vd.co, test.dist)*bstrength; + if (sculpt_brush_test_sq(&test, vd.co)) { + float intr[3]; + float val[3]; - /* Find the intersection between squash-plane and vertex (along the area normal) */ - point_plane_project(intr, vd.co, area_normal, cntr); + point_plane_project(intr, vd.co, an, fc); - sub_v3_v3v3(val, intr, vd.co); + sub_v3_v3v3(val, intr, vd.co); - if(clay) { - if(bstr > FLT_EPSILON) - mul_v3_fl(val, fade / bstr); - else - mul_v3_fl(val, fade); - /* Clay displacement */ - val[0]+=area_normal[0] * ss->cache->scale[0]*fade; - val[1]+=area_normal[1] * ss->cache->scale[1]*fade; - val[2]+=area_normal[2] * ss->cache->scale[2]*fade; - } - else - mul_v3_fl(val, fabs(fade)); + if (plane_trim(ss->cache, brush, val)) { + const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist))*frontface(brush, an, vd.no, vd.fno); - add_v3_v3(val, vd.co); + mul_v3_v3fl(proxy[vd.i], val, fade); - sculpt_clip(sd, ss, vd.co, val); - if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } } BLI_pbvh_vertex_iter_end; - - BLI_pbvh_node_mark_update(nodes[n]); } } -static void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) +static void do_clay_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + Brush *brush = paint_brush(&sd->paint); + + float bstrength = ss->cache->bstrength; + float radius = ss->cache->radius; + float offset = get_offset(sd, ss); + + float displace; + + float an[3]; // area normal + float fc[3]; // flatten center + + int n; + + float temp[3]; + //float p[3]; + + int flip; + + calc_sculpt_plane(sd, ss, nodes, totnode, an, fc); + + flip = bstrength < 0; + + if (flip) { + bstrength = -bstrength; + radius = -radius; + } + + displace = radius * (0.25f+offset); + + mul_v3_v3v3(temp, an, ss->cache->scale); + mul_v3_fl(temp, displace); + add_v3_v3(fc, temp); + + //add_v3_v3v3(p, ss->cache->location, an); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (n = 0; n < totnode; n++) { + PBVHVertexIter vd; + SculptBrushTest test; + float (*proxy)[3]; + + proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if (sculpt_brush_test_sq(&test, vd.co)) { + if (plane_point_side_flip(vd.co, an, fc, flip)) { + //if (sculpt_brush_test_cyl(&test, vd.co, ss->cache->location, p)) { + float intr[3]; + float val[3]; + + point_plane_project(intr, vd.co, an, fc); + + sub_v3_v3v3(val, intr, vd.co); + + if (plane_trim(ss->cache, brush, val)) { + const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist))*frontface(brush, an, vd.no, vd.fno); + + mul_v3_v3fl(proxy[vd.i], val, fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + } + } + BLI_pbvh_vertex_iter_end; + } +} + +static void do_clay_tubes_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + Brush *brush = paint_brush(&sd->paint); + + float bstrength = ss->cache->bstrength; + float radius = ss->cache->radius; + float offset = get_offset(sd, ss); + + float displace; + + float sn[3]; // sculpt normal + float an[3]; // area normal + float fc[3]; // flatten center + + int n; + + float temp[3]; + float mat[4][4]; + float scale[4][4]; + float tmat[4][4]; + + int flip; + + calc_sculpt_plane(sd, ss, nodes, totnode, sn, fc); + + if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA || (brush->flag & BRUSH_ORIGINAL_NORMAL)) + calc_area_normal(sd, ss, an, nodes, totnode); + else + copy_v3_v3(an, sn); + + if (ss->cache->first_time) + return; // delay the first daub because grab delta is not setup + + flip = bstrength < 0; + + if (flip) { + bstrength = -bstrength; + radius = -radius; + } + + displace = radius * (0.25f+offset); + + mul_v3_v3v3(temp, sn, ss->cache->scale); + mul_v3_fl(temp, displace); + add_v3_v3(fc, temp); + + cross_v3_v3v3(mat[0], an, ss->cache->grab_delta_symmetry); mat[0][3] = 0; + cross_v3_v3v3(mat[1], an, mat[0]); mat[1][3] = 0; + copy_v3_v3(mat[2], an); mat[2][3] = 0; + copy_v3_v3(mat[3], ss->cache->location); mat[3][3] = 1; + normalize_m4(mat); + scale_m4_fl(scale, ss->cache->radius); + mul_m4_m4m4(tmat, scale, mat); + invert_m4_m4(mat, tmat); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (n = 0; n < totnode; n++) { + PBVHVertexIter vd; + SculptBrushTest test; + float (*proxy)[3]; + + proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if (sculpt_brush_test_cube(&test, vd.co, mat)) { + if (plane_point_side_flip(vd.co, sn, fc, flip)) { + float intr[3]; + float val[3]; + + point_plane_project(intr, vd.co, sn, fc); + + sub_v3_v3v3(val, intr, vd.co); + + if (plane_trim(ss->cache, brush, val)) { + const float fade = bstrength*tex_strength(ss, brush, vd.co, ss->cache->radius*test.dist)*frontface(brush, an, vd.no, vd.fno); + + mul_v3_v3fl(proxy[vd.i], val, fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + } + } + BLI_pbvh_vertex_iter_end; + } +} + +static void do_fill_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + Brush *brush = paint_brush(&sd->paint); + + float bstrength = ss->cache->bstrength; + const float radius = ss->cache->radius; + + float an[3]; + float fc[3]; + float offset = get_offset(sd, ss); + + float displace; + + int n; + + float temp[3]; + + calc_sculpt_plane(sd, ss, nodes, totnode, an, fc); + + displace = radius*offset; + + mul_v3_v3v3(temp, an, ss->cache->scale); + mul_v3_fl(temp, displace); + add_v3_v3(fc, temp); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (n = 0; n < totnode; n++) { + PBVHVertexIter vd; + SculptBrushTest test; + float (*proxy)[3]; + + proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if (sculpt_brush_test_sq(&test, vd.co)) { + if (plane_point_side(vd.co, an, fc)) { + float intr[3]; + float val[3]; + + point_plane_project(intr, vd.co, an, fc); + + sub_v3_v3v3(val, intr, vd.co); + + if (plane_trim(ss->cache, brush, val)) { + const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist))*frontface(brush, an, vd.no, vd.fno); + + mul_v3_v3fl(proxy[vd.i], val, fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + } + } + BLI_pbvh_vertex_iter_end; + } +} + +static void do_scrape_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode) +{ + Brush *brush = paint_brush(&sd->paint); + + float bstrength = ss->cache->bstrength; + const float radius = ss->cache->radius; + + float an[3]; + float fc[3]; + float offset = get_offset(sd, ss); + + float displace; + + int n; + + float temp[3]; + + calc_sculpt_plane(sd, ss, nodes, totnode, an, fc); + + displace = -radius*offset; + + mul_v3_v3v3(temp, an, ss->cache->scale); + mul_v3_fl(temp, displace); + add_v3_v3(fc, temp); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (n = 0; n < totnode; n++) { + PBVHVertexIter vd; + SculptBrushTest test; + float (*proxy)[3]; + + proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + if (sculpt_brush_test_sq(&test, vd.co)) { + if (!plane_point_side(vd.co, an, fc)) { + float intr[3]; + float val[3]; + + point_plane_project(intr, vd.co, an, fc); + + sub_v3_v3v3(val, intr, vd.co); + + if (plane_trim(ss->cache, brush, val)) { + const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist))*frontface(brush, an, vd.no, vd.fno); + + mul_v3_v3fl(proxy[vd.i], val, fade); + + if(vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + } + } + } + BLI_pbvh_vertex_iter_end; + } +} + +void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) { Mesh *me= (Mesh*)ob->data; float (*ofs)[3]= NULL; @@ -1475,36 +2325,27 @@ static void sculpt_update_keyblock(SculptSession *ss) } } -static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) +static void do_brush_action(Sculpt *sd, SculptSession *ss, Brush *brush) { SculptSearchSphereData data; - Brush *brush = paint_brush(&sd->paint); - PBVHNode **nodes= NULL; - int totnode; + PBVHNode **nodes = NULL; + int n, totnode; + /* Build a list of all nodes that are potentially within the brush's area of influence */ data.ss = ss; data.sd = sd; - data.radius_squared = ss->cache->radius * ss->cache->radius; - - /* Build a list of all nodes that are potentially within the brush's - area of influence */ - if(brush->sculpt_tool == SCULPT_TOOL_GRAB) { - data.original= 1; - BLI_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, - &nodes, &totnode); - - if(cache->first_time) - copy_v3_v3(ss->cache->grab_active_location[ss->cache->symmetry], ss->cache->location); - else - copy_v3_v3(ss->cache->location, ss->cache->grab_active_location[ss->cache->symmetry]); - } - else { - BLI_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, - &nodes, &totnode); - } + data.radius_squared = ss->cache->radius_squared; + data.original = ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB, SCULPT_TOOL_LAYER); + BLI_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode); /* Only act if some verts are inside the brush area */ - if(totnode) { + if (totnode) { + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (n= 0; n < totnode; n++) { + sculpt_undo_push_node(ss, nodes[n]); + BLI_pbvh_node_mark_update(nodes[n]); + } + /* Apply one type of brush action */ switch(brush->sculpt_tool){ case SCULPT_TOOL_DRAW: @@ -1513,6 +2354,12 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) case SCULPT_TOOL_SMOOTH: do_smooth_brush(sd, ss, nodes, totnode); break; + case SCULPT_TOOL_CREASE: + do_crease_brush(sd, ss, nodes, totnode); + break; + case SCULPT_TOOL_BLOB: + do_crease_brush(sd, ss, nodes, totnode); + break; case SCULPT_TOOL_PINCH: do_pinch_brush(sd, ss, nodes, totnode); break; @@ -1522,57 +2369,244 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) case SCULPT_TOOL_GRAB: do_grab_brush(sd, ss, nodes, totnode); break; + case SCULPT_TOOL_ROTATE: + do_rotate_brush(sd, ss, nodes, totnode); + break; + case SCULPT_TOOL_SNAKE_HOOK: + do_snake_hook_brush(sd, ss, nodes, totnode); + break; + case SCULPT_TOOL_NUDGE: + do_nudge_brush(sd, ss, nodes, totnode); + break; + case SCULPT_TOOL_THUMB: + do_thumb_brush(sd, ss, nodes, totnode); + break; case SCULPT_TOOL_LAYER: do_layer_brush(sd, ss, nodes, totnode); break; case SCULPT_TOOL_FLATTEN: - do_flatten_clay_brush(sd, ss, nodes, totnode, 0); + do_flatten_brush(sd, ss, nodes, totnode); break; case SCULPT_TOOL_CLAY: - do_flatten_clay_brush(sd, ss, nodes, totnode, 1); + do_clay_brush(sd, ss, nodes, totnode); + break; + case SCULPT_TOOL_CLAY_TUBES: + do_clay_tubes_brush(sd, ss, nodes, totnode); + break; + case SCULPT_TOOL_FILL: + do_fill_brush(sd, ss, nodes, totnode); + break; + case SCULPT_TOOL_SCRAPE: + do_scrape_brush(sd, ss, nodes, totnode); break; } + if (brush->sculpt_tool != SCULPT_TOOL_SMOOTH && brush->autosmooth_factor > 0) { + if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) { + smooth(sd, ss, nodes, totnode, brush->autosmooth_factor*(1-ss->cache->pressure)*ss->cache->autosmooth_overlap); + } + else { + smooth(sd, ss, nodes, totnode, brush->autosmooth_factor*ss->cache->autosmooth_overlap); + } + } + + /* copy the modified vertices from mesh to the active key */ + if(ss->kb) + mesh_to_key(ss->ob->data, ss->kb); + /* optimization: we could avoid copying new coords to keyblock at each */ /* stroke step if there are no modifiers due to pbvh is used for displaying */ /* so to increase speed we'll copy new coords to keyblock when stroke is done */ if(ss->kb && ss->modifiers_active) sculpt_update_keyblock(ss); - if(nodes) - MEM_freeN(nodes); + MEM_freeN(nodes); } } +static void sculpt_combine_proxies(Sculpt *sd, SculptSession *ss) +{ + Brush *brush= paint_brush(&sd->paint); + PBVHNode** nodes; + int totnode; + int n; + + BLI_pbvh_gather_proxies(ss->pbvh, &nodes, &totnode); + + switch (brush->sculpt_tool) { + case SCULPT_TOOL_GRAB: + case SCULPT_TOOL_ROTATE: + case SCULPT_TOOL_THUMB: + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (n= 0; n < totnode; n++) { + PBVHVertexIter vd; + PBVHProxyNode* proxies; + int proxy_count; + float (*origco)[3]; + + origco= sculpt_undo_push_node(ss, nodes[n])->co; + + BLI_pbvh_node_get_proxies(nodes[n], &proxies, &proxy_count); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + float val[3]; + int p; + + copy_v3_v3(val, origco[vd.i]); + + for (p= 0; p < proxy_count; p++) + add_v3_v3(val, proxies[p].co[vd.i]); + + sculpt_clip(sd, ss, vd.co, val); + } + BLI_pbvh_vertex_iter_end; + + BLI_pbvh_node_free_proxies(nodes[n]); + } + + break; + + case SCULPT_TOOL_DRAW: + case SCULPT_TOOL_CLAY: + case SCULPT_TOOL_CLAY_TUBES: + case SCULPT_TOOL_CREASE: + case SCULPT_TOOL_BLOB: + case SCULPT_TOOL_FILL: + case SCULPT_TOOL_FLATTEN: + case SCULPT_TOOL_INFLATE: + case SCULPT_TOOL_NUDGE: + case SCULPT_TOOL_PINCH: + case SCULPT_TOOL_SCRAPE: + case SCULPT_TOOL_SNAKE_HOOK: + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (n= 0; n < totnode; n++) { + PBVHVertexIter vd; + PBVHProxyNode* proxies; + int proxy_count; + + BLI_pbvh_node_get_proxies(nodes[n], &proxies, &proxy_count); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + float val[3]; + int p; + + copy_v3_v3(val, vd.co); + + for (p= 0; p < proxy_count; p++) + add_v3_v3(val, proxies[p].co[vd.i]); + + sculpt_clip(sd, ss, vd.co, val); + } + BLI_pbvh_vertex_iter_end; + + BLI_pbvh_node_free_proxies(nodes[n]); + + } + + break; + + case SCULPT_TOOL_SMOOTH: + case SCULPT_TOOL_LAYER: + default: + break; + } + + if (nodes) + MEM_freeN(nodes); +} + +//static int max_overlap_count(Sculpt *sd) +//{ +// int count[3]; +// int i, j; +// +// for (i= 0; i < 3; i++) { +// count[i] = sd->radial_symm[i]; +// +// for (j= 0; j < 3; j++) { +// if (i != j && sd->flags & (SCULPT_SYMM_X<location, cache->true_location, symm); - flip_coord(cache->view_normal_symmetry, cache->view_normal, symm); flip_coord(cache->grab_delta_symmetry, cache->grab_delta, symm); - cache->symmetry= symm; + flip_coord(cache->view_normal, cache->true_view_normal, symm); + + // XXX This reduces the length of the grab delta if it approaches the line of symmetry + // XXX However, a different approach appears to be needed + //if (sd->flags & SCULPT_SYMMETRY_FEATHER) { + // float frac = 1.0f/max_overlap_count(sd); + // float reduce = (feather-frac)/(1-frac); + + // printf("feather: %f frac: %f reduce: %f\n", feather, frac, reduce); + + // if (frac < 1) + // mul_v3_fl(cache->grab_delta_symmetry, reduce); + //} + + unit_m4(cache->symm_rot_mat); + unit_m4(cache->symm_rot_mat_inv); + rotate_m4(cache->symm_rot_mat, axis, angle); + rotate_m4(cache->symm_rot_mat_inv, axis, -angle); + + mul_m4_v3(cache->symm_rot_mat, cache->location); + mul_m4_v3(cache->symm_rot_mat, cache->grab_delta_symmetry); +} + +static void do_radial_symmetry(Sculpt *sd, SculptSession *ss, Brush *brush, const char symm, const int axis, const float feather) +{ + int i; + + for(i = 1; i < sd->radial_symm[axis-'X']; ++i) { + const float angle = 2*M_PI*i/sd->radial_symm[axis-'X']; + ss->cache->radial_symmetry_pass= i; + calc_brushdata_symm(sd, ss->cache, symm, axis, angle, feather); + do_brush_action(sd, ss, brush); + } } static void do_symmetrical_brush_actions(Sculpt *sd, SculptSession *ss) { + Brush *brush = paint_brush(&sd->paint); StrokeCache *cache = ss->cache; const char symm = sd->flags & 7; int i; - copy_v3_v3(cache->location, cache->true_location); - copy_v3_v3(cache->grab_delta_symmetry, cache->grab_delta); - cache->symmetry = 0; - cache->bstrength = brush_strength(sd, cache); - do_brush_action(sd, ss, cache); + float feather = calc_symmetry_feather(sd, ss->cache); + float accum = integrate_overlap(brush); + float overlap = (brush->flag & BRUSH_SPACE_ATTEN && brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100) ? 1.0f/accum : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter - for(i = 1; i <= symm; ++i) { - if(symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5))) { - calc_brushdata_symm(cache, i); - do_brush_action(sd, ss, cache); + ss->cache->autosmooth_overlap = overlap; + + cache->bstrength= brush_strength(sd, cache, feather, overlap); + + cache->symmetry= symm; + + /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ + for(i = 0; i <= symm; ++i) { + if(i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { + cache->mirror_symmetry_pass= i; + cache->radial_symmetry_pass= 0; + + calc_brushdata_symm(sd, cache, i, 0, 0, feather); + do_brush_action(sd, ss, brush); + + do_radial_symmetry(sd, ss, brush, i, 'X', feather); + do_radial_symmetry(sd, ss, brush, i, 'Y', feather); + do_radial_symmetry(sd, ss, brush, i, 'Z', feather); } } - cache->first_time = 0; + sculpt_combine_proxies(sd, ss); + + cache->first_time= 0; } static void sculpt_update_tex(Sculpt *sd, SculptSession *ss) @@ -1585,37 +2619,13 @@ static void sculpt_update_tex(Sculpt *sd, SculptSession *ss) } /* Need to allocate a bigger buffer for bigger brush size */ - ss->texcache_side = brush->size * 2; + ss->texcache_side = 2*sculpt_get_brush_size(brush); if(!ss->texcache || ss->texcache_side > ss->texcache_actual) { - ss->texcache = brush_gen_texture_cache(brush, brush->size); + ss->texcache = brush_gen_texture_cache(brush, sculpt_get_brush_size(brush)); ss->texcache_actual = ss->texcache_side; } } -/* Sculpt mode handles multires differently from regular meshes, but only if - it's the last modifier on the stack and it is not on the first level */ -struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) -{ - ModifierData *md, *nmd; - - for(md= modifiers_getVirtualModifierList(ob); md; md= md->next) { - if(md->type == eModifierType_Multires) { - MultiresModifierData *mmd= (MultiresModifierData*)md; - - /* Check if any of the modifiers after multires are active - * if not it can use the multires struct */ - for(nmd= md->next; nmd; nmd= nmd->next) - if(modifier_isEnabled(scene, nmd, eModifierMode_Realtime)) - break; - - if(!nmd && mmd->sculptlvl > 0) - return mmd; - } - } - - return NULL; -} - void sculpt_update_mesh_elements(Scene *scene, Object *ob, int need_fmap) { DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); @@ -1682,16 +2692,32 @@ static char *sculpt_tool_name(Sculpt *sd) return "Draw Brush"; break; case SCULPT_TOOL_SMOOTH: return "Smooth Brush"; break; + case SCULPT_TOOL_CREASE: + return "Crease Brush"; break; + case SCULPT_TOOL_BLOB: + return "Blob Brush"; break; case SCULPT_TOOL_PINCH: return "Pinch Brush"; break; case SCULPT_TOOL_INFLATE: return "Inflate Brush"; break; case SCULPT_TOOL_GRAB: return "Grab Brush"; break; + case SCULPT_TOOL_NUDGE: + return "Nudge Brush"; break; + case SCULPT_TOOL_THUMB: + return "Thumb Brush"; break; case SCULPT_TOOL_LAYER: return "Layer Brush"; break; case SCULPT_TOOL_FLATTEN: - return "Flatten Brush"; break; + return "Flatten Brush"; break; + case SCULPT_TOOL_CLAY: + return "Clay Brush"; break; + case SCULPT_TOOL_CLAY_TUBES: + return "Clay Tubes Brush"; break; + case SCULPT_TOOL_FILL: + return "Fill Brush"; break; + case SCULPT_TOOL_SCRAPE: + return "Scrape Brush"; break; default: return "Sculpting"; break; } @@ -1769,20 +2795,119 @@ static void sculpt_cache_free(StrokeCache *cache) MEM_freeN(cache); } +int sculpt_get_brush_size(Brush *brush) +{ + return (U.sculpt_paint_settings & SCULPT_PAINT_USE_UNIFIED_SIZE) ? U.sculpt_paint_unified_size : brush->size; +} + +void sculpt_set_brush_size(Brush *brush, int size) +{ + if (U.sculpt_paint_settings & SCULPT_PAINT_USE_UNIFIED_SIZE) + U.sculpt_paint_unified_size = size; + else + brush->size = size; +} + +int sculpt_get_lock_brush_size(Brush *brush) +{ + return (U.sculpt_paint_settings & SCULPT_PAINT_USE_UNIFIED_SIZE) ? (U.sculpt_paint_settings & SCULPT_PAINT_UNIFIED_LOCK_BRUSH_SIZE) : (brush->flag & BRUSH_LOCK_SIZE); +} + +float sculpt_get_brush_unprojected_radius(Brush *brush) +{ + return (U.sculpt_paint_settings & SCULPT_PAINT_USE_UNIFIED_SIZE) ? U.sculpt_paint_unified_unprojected_radius : brush->unprojected_radius; +} + +void sculpt_set_brush_unprojected_radius(Brush *brush, float unprojected_radius) +{ + if (U.sculpt_paint_settings & SCULPT_PAINT_USE_UNIFIED_SIZE) + U.sculpt_paint_unified_unprojected_radius = unprojected_radius; + else + brush->unprojected_radius = unprojected_radius; +} + +float sculpt_get_brush_alpha(Brush *brush) +{ + return (U.sculpt_paint_settings & SCULPT_PAINT_USE_UNIFIED_ALPHA) ? U.sculpt_paint_unified_alpha : brush->alpha; +} + +void sculpt_set_brush_alpha(Brush *brush, float alpha) +{ + if (U.sculpt_paint_settings & SCULPT_PAINT_USE_UNIFIED_ALPHA) + U.sculpt_paint_unified_alpha = alpha; + else + brush->alpha = alpha; +} + /* Initialize the stroke cache invariants from operator properties */ -static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bContext *C, wmOperator *op) +static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSession *ss, wmOperator *op, wmEvent *event) { StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache"); Brush *brush = paint_brush(&sd->paint); ViewContext *vc = paint_stroke_view_context(op->customdata); + Object *ob= CTX_data_active_object(C); + ModifierData *md; int i; + int mode; ss->cache = cache; - RNA_float_get_array(op->ptr, "scale", cache->scale); - cache->flag = RNA_int_get(op->ptr, "flag"); - RNA_float_get_array(op->ptr, "clip_tolerance", cache->clip_tolerance); - RNA_float_get_array(op->ptr, "initial_mouse", cache->initial_mouse); + /* Set scaling adjustment */ + ss->cache->scale[0] = 1.0f / ob->size[0]; + ss->cache->scale[1] = 1.0f / ob->size[1]; + ss->cache->scale[2] = 1.0f / ob->size[2]; + + ss->cache->plane_trim_squared = brush->plane_trim * brush->plane_trim; + + /* Initialize mirror modifier clipping */ + + ss->cache->flag = 0; + + for(md= ob->modifiers.first; md; md= md->next) { + if(md->type==eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) { + const MirrorModifierData *mmd = (MirrorModifierData*) md; + + /* Mark each axis that needs clipping along with its tolerance */ + if(mmd->flag & MOD_MIR_CLIPPING) { + ss->cache->flag |= CLIP_X << mmd->axis; + if(mmd->tolerance > ss->cache->clip_tolerance[mmd->axis]) + ss->cache->clip_tolerance[mmd->axis] = mmd->tolerance; + } + } + } + + /* Initial mouse location */ + if (event) { + ss->cache->initial_mouse[0] = event->x; + ss->cache->initial_mouse[1] = event->y; + } + else { + ss->cache->initial_mouse[0] = 0; + ss->cache->initial_mouse[1] = 0; + } + + mode = RNA_int_get(op->ptr, "mode"); + cache->invert = mode == WM_BRUSHSTROKE_INVERT; + cache->alt_smooth = mode == WM_BRUSHSTROKE_SMOOTH; + + /* Alt-Smooth */ + if (ss->cache->alt_smooth) { + Paint *p= &sd->paint; + Brush *br; + int i; + + BLI_strncpy(cache->saved_active_brush_name, brush->id.name+2, sizeof(cache->saved_active_brush_name)); + + for(i = 0; i < p->brush_count; ++i) { + br = p->brushes[i]; + + if (strcmp(br->id.name+2, "Smooth")==0) { + paint_brush_set(p, br); + brush = br; + break; + } + } + } copy_v2_v2(cache->mouse, cache->initial_mouse); copy_v2_v2(cache->tex_mouse, cache->initial_mouse); @@ -1790,11 +2915,13 @@ static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bConte /* Truly temporary data that isn't stored in properties */ cache->vc = vc; + cache->brush = brush; cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats"); view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, cache->mats); + viewvector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal); /* Initialize layer brush displacements and persistent coords */ if(brush->sculpt_tool == SCULPT_TOOL_LAYER) { /* not supported yet for multires */ @@ -1820,69 +2947,143 @@ static void sculpt_update_cache_invariants(Sculpt *sd, SculptSession *ss, bConte cache->original = 1; } - if(ELEM3(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE)) + if(ELEM7(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_TUBES)) if(!(brush->flag & BRUSH_ACCUMULATE)) cache->original = 1; - cache->rotation = 0; - cache->first_time = 1; + cache->special_rotation = (brush->flag & BRUSH_RAKE) ? sd->last_angle : 0; + //cache->last_rake[0] = sd->last_x; + //cache->last_rake[1] = sd->last_y; + + cache->first_time= 1; + + cache->vertex_rotation= 0; } /* Initialize the stroke cache variants from operator properties */ -static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, struct PaintStroke *stroke, PointerRNA *ptr) +static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, SculptSession *ss, struct PaintStroke *stroke, PointerRNA *ptr) { StrokeCache *cache = ss->cache; Brush *brush = paint_brush(&sd->paint); - + int dx, dy; - if(!(brush->flag & BRUSH_ANCHORED) || cache->first_time) + //RNA_float_get_array(ptr, "location", cache->traced_location); + + if (cache->first_time || + !((brush->flag & BRUSH_ANCHORED)|| + (brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK)|| + (brush->sculpt_tool == SCULPT_TOOL_ROTATE)) + ) + { RNA_float_get_array(ptr, "location", cache->true_location); - cache->flip = RNA_boolean_get(ptr, "flip"); + } + + cache->pen_flip = RNA_boolean_get(ptr, "pen_flip"); RNA_float_get_array(ptr, "mouse", cache->mouse); + cache->pressure = RNA_float_get(ptr, "pressure"); - + /* Truly temporary data that isn't stored in properties */ + sd->draw_pressure= 1; + sd->pressure_value= cache->pressure; + cache->previous_pixel_radius = cache->pixel_radius; - cache->pixel_radius = brush->size; + cache->pixel_radius = sculpt_get_brush_size(brush); - if(cache->first_time) - cache->initial_radius = unproject_brush_radius(ss->ob, cache->vc, cache->true_location, brush->size); + if(cache->first_time) { + if (!sculpt_get_lock_brush_size(brush)) { + cache->initial_radius= unproject_brush_radius(ss->ob, cache->vc, cache->true_location, sculpt_get_brush_size(brush)); + sculpt_set_brush_unprojected_radius(brush, cache->initial_radius); + } + else { + cache->initial_radius= sculpt_get_brush_unprojected_radius(brush); + } - if(brush->flag & BRUSH_SIZE_PRESSURE && brush->sculpt_tool != SCULPT_TOOL_GRAB) { + if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK)) + cache->initial_radius *= 2.0f; + } + + if(brush->flag & BRUSH_SIZE_PRESSURE) { cache->pixel_radius *= cache->pressure; - cache->radius = cache->initial_radius * cache->pressure; + cache->radius= cache->initial_radius * cache->pressure; } else - cache->radius = cache->initial_radius; + cache->radius= cache->initial_radius; - if(!(brush->flag & BRUSH_ANCHORED)) + cache->radius_squared = cache->radius*cache->radius; + + if(!(brush->flag & BRUSH_ANCHORED || ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))) { copy_v2_v2(cache->tex_mouse, cache->mouse); + if ( (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) && + (brush->flag & BRUSH_RANDOM_ROTATION) && + !(brush->flag & BRUSH_RAKE)) + { + cache->special_rotation = 2*M_PI*BLI_frand(); + } + } + if(brush->flag & BRUSH_ANCHORED) { + int hit = 0; + dx = cache->mouse[0] - cache->initial_mouse[0]; dy = cache->mouse[1] - cache->initial_mouse[1]; - cache->pixel_radius = sqrt(dx*dx + dy*dy); - cache->radius = unproject_brush_radius(ss->ob, paint_stroke_view_context(stroke), - cache->true_location, cache->pixel_radius); - cache->rotation = atan2(dy, dx); + + sd->anchored_size = cache->pixel_radius = sqrt(dx*dx + dy*dy); + + cache->special_rotation = atan2(dx, dy) + M_PI; + + if (brush->flag & BRUSH_EDGE_TO_EDGE) { + float d[3]; + float halfway[3]; + float out[3]; + + d[0] = dx; + d[1] = dy; + d[2] = 0; + + mul_v3_v3fl(halfway, d, 0.5f); + add_v3_v3(halfway, cache->initial_mouse); + + if (sculpt_stroke_get_location(C, stroke, out, halfway)) { + copy_v3_v3(sd->anchored_location, out); + copy_v3_v3(sd->anchored_initial_mouse, halfway); + copy_v2_v2(cache->tex_mouse, halfway); + copy_v3_v3(cache->true_location, sd->anchored_location); + sd->anchored_size /= 2.0f; + cache->pixel_radius /= 2.0f; + hit = 1; + } + } + + if (!hit) + copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse); + + cache->radius= unproject_brush_radius(ss->ob, paint_stroke_view_context(stroke), cache->true_location, cache->pixel_radius); + cache->radius_squared = cache->radius*cache->radius; + + copy_v3_v3(sd->anchored_location, cache->true_location); + + sd->draw_anchored = 1; } else if(brush->flag & BRUSH_RAKE) { - int update; + const float u = 0.5f; + const float v = 1 - u; + const float r = 20; - dx = cache->last_rake[0] - cache->mouse[0]; - dy = cache->last_rake[1] - cache->mouse[1]; + const float dx = cache->last_rake[0] - cache->mouse[0]; + const float dy = cache->last_rake[1] - cache->mouse[1]; - update = dx*dx + dy*dy > 100; + if (cache->first_time) { + copy_v3_v3(cache->last_rake, cache->mouse); + } + else if (dx*dx + dy*dy >= r*r) { + cache->special_rotation = atan2(dx, dy); - /* To prevent jitter, only update the angle if the mouse has moved over 10 pixels */ - if(update && !cache->first_time) - cache->rotation = M_PI_2 + atan2(dy, dx); - - if(update || cache->first_time) { - cache->last_rake[0] = cache->mouse[0]; - cache->last_rake[1] = cache->mouse[1]; + cache->last_rake[0] = u*cache->last_rake[0] + v*cache->mouse[0]; + cache->last_rake[1] = u*cache->last_rake[1] + v*cache->mouse[1]; } } @@ -1900,16 +3101,123 @@ static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, struct P /* compute delta to move verts by */ if(!cache->first_time) { - sub_v3_v3v3(cache->grab_delta, grab_location, cache->old_grab_location); + float delta[3]; + sub_v3_v3v3(delta, grab_location, cache->old_grab_location); invert_m4_m4(imat, ss->ob->obmat); - mul_mat3_m4_v3(imat, cache->grab_delta); + mul_mat3_m4_v3(imat, delta); + add_v3_v3(cache->grab_delta, delta); + } + else { + zero_v3(cache->grab_delta); } copy_v3_v3(cache->old_grab_location, grab_location); /* location stays the same for finding vertices in brush radius */ copy_v3_v3(cache->true_location, cache->orig_grab_location); + + sd->draw_anchored = 1; + copy_v3_v3(sd->anchored_location, cache->true_location); + copy_v3_v3(sd->anchored_initial_mouse, cache->initial_mouse); + sd->anchored_size = cache->pixel_radius; } + /* Find the nudge/clay tubes delta */ + else if(brush->sculpt_tool == SCULPT_TOOL_NUDGE || brush->sculpt_tool == SCULPT_TOOL_CLAY_TUBES) { + float grab_location[3], imat[4][4]; + + if(cache->first_time) + copy_v3_v3(cache->orig_grab_location, cache->true_location); + + /* compute 3d coordinate at same z from original location + mouse */ + initgrabz(cache->vc->rv3d, cache->orig_grab_location[0], + cache->orig_grab_location[1], cache->orig_grab_location[2]); + window_to_3d_delta(cache->vc->ar, grab_location, cache->mouse[0], cache->mouse[1]); + + /* compute delta to move verts by */ + if (!cache->first_time) { + sub_v3_v3v3(cache->grab_delta, grab_location, cache->old_grab_location); + invert_m4_m4(imat, ss->ob->obmat); + mul_mat3_m4_v3(imat, cache->grab_delta); + } + else { + zero_v3(cache->grab_delta); + } + + copy_v3_v3(cache->old_grab_location, grab_location); + } + /* Find the snake hook delta */ + else if(brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK) { + float grab_location[3], imat[4][4]; + + if(cache->first_time) + copy_v3_v3(cache->orig_grab_location, cache->true_location); + else + add_v3_v3(cache->true_location, cache->grab_delta); + + /* compute 3d coordinate at same z from original location + mouse */ + initgrabz(cache->vc->rv3d, cache->orig_grab_location[0], + cache->orig_grab_location[1], cache->orig_grab_location[2]); + window_to_3d_delta(cache->vc->ar, grab_location, cache->mouse[0], cache->mouse[1]); + + /* compute delta to move verts by */ + if (!cache->first_time) { + sub_v3_v3v3(cache->grab_delta, grab_location, cache->old_grab_location); + invert_m4_m4(imat, ss->ob->obmat); + mul_mat3_m4_v3(imat, cache->grab_delta); + } + else { + zero_v3(cache->grab_delta); + } + + copy_v3_v3(cache->old_grab_location, grab_location); + } + /* Find the thumb delta */ + else if(brush->sculpt_tool == SCULPT_TOOL_THUMB) { + float grab_location[3], imat[4][4]; + + if(cache->first_time) + copy_v3_v3(cache->orig_grab_location, cache->true_location); + + /* compute 3d coordinate at same z from original location + mouse */ + initgrabz(cache->vc->rv3d, cache->orig_grab_location[0], + cache->orig_grab_location[1], cache->orig_grab_location[2]); + window_to_3d_delta(cache->vc->ar, grab_location, cache->mouse[0], cache->mouse[1]); + + /* compute delta to move verts by */ + if (!cache->first_time) { + float delta[3]; + sub_v3_v3v3(delta, grab_location, cache->old_grab_location); + invert_m4_m4(imat, ss->ob->obmat); + mul_mat3_m4_v3(imat, delta); + add_v3_v3(cache->grab_delta, delta); + } + else { + zero_v3(cache->grab_delta); + } + + copy_v3_v3(cache->old_grab_location, grab_location); + + /* location stays the same for finding vertices in brush radius */ + copy_v3_v3(cache->true_location, cache->orig_grab_location); + + sd->draw_anchored = 1; + copy_v3_v3(sd->anchored_location, cache->orig_grab_location); + copy_v3_v3(sd->anchored_initial_mouse, cache->initial_mouse); + sd->anchored_size = cache->pixel_radius; + } + else if(brush->sculpt_tool == SCULPT_TOOL_ROTATE) { + dx = cache->mouse[0] - cache->initial_mouse[0]; + dy = cache->mouse[1] - cache->initial_mouse[1]; + + cache->vertex_rotation = -atan2(dx, dy) / 4.0f; + + sd->draw_anchored = 1; + copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse); + copy_v3_v3(sd->anchored_location, cache->true_location); + sd->anchored_size = cache->pixel_radius; + } + + sd->special_rotation = cache->special_rotation; } static void sculpt_stroke_modifiers_check(bContext *C, SculptSession *ss) @@ -1930,19 +3238,23 @@ typedef struct { int original; } SculptRaycastData; -void sculpt_raycast_cb(PBVHNode *node, void *data_v) +void sculpt_raycast_cb(PBVHNode *node, void *data_v, float* tmin) { - SculptRaycastData *srd = data_v; - float (*origco)[3]= NULL; + if (BLI_pbvh_node_get_tmin(node) < *tmin) { + SculptRaycastData *srd = data_v; + float (*origco)[3]= NULL; - if(srd->original && srd->ss->cache) { - /* intersect with coordinates from before we started stroke */ - SculptUndoNode *unode= sculpt_undo_get_node(srd->ss, node); - origco= (unode)? unode->co: NULL; + if(srd->original && srd->ss->cache) { + /* intersect with coordinates from before we started stroke */ + SculptUndoNode *unode= sculpt_undo_get_node(node); + origco= (unode)? unode->co: NULL; + } + + if (BLI_pbvh_node_raycast(srd->ss->pbvh, node, origco, srd->ray_start, srd->ray_normal, &srd->dist)) { + srd->hit = 1; + *tmin = srd->dist; + } } - - srd->hit |= BLI_pbvh_node_raycast(srd->ss->pbvh, node, origco, - srd->ray_start, srd->ray_normal, &srd->dist); } /* Do a raycast in the tree to find the 3d brush location @@ -1956,10 +3268,12 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou StrokeCache *cache= ss->cache; float ray_start[3], ray_end[3], ray_normal[3], dist; float obimat[4][4]; - float mval[2] = {mouse[0] - vc->ar->winrct.xmin, - mouse[1] - vc->ar->winrct.ymin}; + float mval[2]; SculptRaycastData srd; + mval[0] = mouse[0] - vc->ar->winrct.xmin; + mval[1] = mouse[1] - vc->ar->winrct.ymin; + sculpt_stroke_modifiers_check(C, ss); viewline(vc->ar, vc->v3d, mval, ray_start, ray_end); @@ -1987,43 +3301,6 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou return srd.hit; } -/* Initialize stroke operator properties */ -static void sculpt_brush_stroke_init_properties(bContext *C, wmOperator *op, wmEvent *event, SculptSession *ss) -{ - Object *ob= CTX_data_active_object(C); - ModifierData *md; - float scale[3], clip_tolerance[3] = {0,0,0}; - float mouse[2]; - int flag = 0; - - /* Set scaling adjustment */ - scale[0] = 1.0f / ob->size[0]; - scale[1] = 1.0f / ob->size[1]; - scale[2] = 1.0f / ob->size[2]; - RNA_float_set_array(op->ptr, "scale", scale); - - /* Initialize mirror modifier clipping */ - for(md= ob->modifiers.first; md; md= md->next) { - if(md->type==eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) { - const MirrorModifierData *mmd = (MirrorModifierData*) md; - - /* Mark each axis that needs clipping along with its tolerance */ - if(mmd->flag & MOD_MIR_CLIPPING) { - flag |= CLIP_X << mmd->axis; - if(mmd->tolerance > clip_tolerance[mmd->axis]) - clip_tolerance[mmd->axis] = mmd->tolerance; - } - } - } - RNA_int_set(op->ptr, "flag", flag); - RNA_float_set_array(op->ptr, "clip_tolerance", clip_tolerance); - - /* Initial mouse location */ - mouse[0] = event->x; - mouse[1] = event->y; - RNA_float_set_array(op->ptr, "initial_mouse", mouse); -} - static int sculpt_brush_stroke_init(bContext *C, ReportList *reports) { Scene *scene= CTX_data_scene(C); @@ -2051,22 +3328,26 @@ static int sculpt_brush_stroke_init(bContext *C, ReportList *reports) static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) { - StrokeCache *cache = ss->cache; Brush *brush = paint_brush(&sd->paint); - int i; /* Restore the mesh before continuing with anchored stroke */ - if(brush->flag & BRUSH_ANCHORED) { + if((brush->flag & BRUSH_ANCHORED) || + (brush->sculpt_tool == SCULPT_TOOL_GRAB && (brush->flag & BRUSH_SIZE_PRESSURE)) || + (brush->flag & BRUSH_RESTORE_MESH)) + { + StrokeCache *cache = ss->cache; + int i; + PBVHNode **nodes; int n, totnode; BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); - //#pragma omp parallel for private(n) schedule(static) + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; nco[vd.i]); if(vd.no) VECCOPY(vd.no, unode->no[vd.i]) else normal_short_to_float_v3(vd.fno, unode->no[vd.i]); + + if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } BLI_pbvh_vertex_iter_end; + + BLI_pbvh_node_mark_update(nodes[n]); } } @@ -2096,7 +3381,6 @@ static void sculpt_flush_update(bContext *C) SculptSession *ss = ob->sculpt; ARegion *ar = CTX_wm_region(C); MultiresModifierData *mmd = ss->multires; - int redraw = 0; if(mmd) multires_mark_as_modified(ob); @@ -2109,14 +3393,22 @@ static void sculpt_flush_update(bContext *C) rcti r; BLI_pbvh_update(ss->pbvh, PBVH_UpdateBB, NULL); - redraw = sculpt_get_redraw_rect(ar, CTX_wm_region_view3d(C), ob, &r); - if(redraw) { + if (sculpt_get_redraw_rect(ar, CTX_wm_region_view3d(C), ob, &r)) { + //rcti tmp; + r.xmin += ar->winrct.xmin + 1; r.xmax += ar->winrct.xmin - 1; r.ymin += ar->winrct.ymin + 1; r.ymax += ar->winrct.ymin - 1; - + + //tmp = r; + + //if (!BLI_rcti_is_empty(&ss->previous_r)) + // BLI_union_rcti(&r, &ss->previous_r); + + //ss->previous_r= tmp; + ss->partial_redraw = 1; ED_region_tag_redraw_partial(ar, &r); } @@ -2127,9 +3419,12 @@ static void sculpt_flush_update(bContext *C) or over the background (0) */ static int over_mesh(bContext *C, struct wmOperator *op, float x, float y) { - float mouse[2] = {x, y}, co[3]; - - return (int)sculpt_stroke_get_location(C, op->customdata, co, mouse); + float mouse[2], co[3]; + + mouse[0] = x; + mouse[1] = y; + + return sculpt_stroke_get_location(C, op->customdata, co, mouse); } static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op, @@ -2143,11 +3438,22 @@ static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op, ED_view3d_init_mats_rv3d(ob, CTX_wm_region_view3d(C)); - sculpt_brush_stroke_init_properties(C, op, event, ss); + sculpt_update_cache_invariants(C, sd, ss, op, event); - sculpt_update_cache_invariants(sd, ss, C, op); + sculpt_undo_push_begin(sculpt_tool_name(sd)); - sculpt_undo_push_begin(ss, sculpt_tool_name(sd)); +#ifdef _OPENMP + /* If using OpenMP then create a number of threads two times the + number of processor cores. + Justification: Empirically I've found that two threads per + processor gives higher throughput. */ + if (sd->flags & SCULPT_USE_OPENMP) { + int num_procs; + + num_procs = omp_get_num_procs(); + omp_set_num_threads(2*num_procs); + } +#endif return 1; } @@ -2161,7 +3467,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, P SculptSession *ss = CTX_data_active_object(C)->sculpt; sculpt_stroke_modifiers_check(C, ss); - sculpt_update_cache_variants(sd, ss, stroke, itemptr); + sculpt_update_cache_variants(C, sd, ss, stroke, itemptr); sculpt_restore_mesh(sd, ss); do_symmetrical_brush_actions(sd, ss); @@ -2169,19 +3475,43 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, P sculpt_flush_update(C); } -static void sculpt_stroke_done(bContext *C, struct PaintStroke *stroke) +static void sculpt_stroke_done(bContext *C, struct PaintStroke *unused) { Object *ob= CTX_data_active_object(C); SculptSession *ss = ob->sculpt; + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + + (void)unused; + + // reset values used to draw brush after completing the stroke + sd->draw_anchored= 0; + sd->draw_pressure= 0; + sd->special_rotation= 0; /* Finished */ if(ss->cache) { sculpt_stroke_modifiers_check(C, ss); + /* Alt-Smooth */ + if (ss->cache->alt_smooth) { + Paint *p= &sd->paint; + Brush *br; + int i; + + for(i = 0; i < p->brush_count; ++i) { + br = p->brushes[i]; + + if (strcmp(br->id.name+2, ss->cache->saved_active_brush_name)==0) { + paint_brush_set(p, br); + break; + } + } + } + sculpt_cache_free(ss->cache); ss->cache = NULL; - sculpt_undo_push_end(ss); + sculpt_undo_push_end(); BLI_pbvh_update(ss->pbvh, PBVH_UpdateOriginalBB, NULL); @@ -2218,6 +3548,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even /* For tablet rotation */ ignore_background_click = RNA_boolean_get(op->ptr, "ignore_background_click"); + if(ignore_background_click && !over_mesh(C, op, event->x, event->y)) { paint_stroke_free(stroke); return OPERATOR_PASS_THROUGH; @@ -2242,7 +3573,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, sculpt_stroke_update_step, sculpt_stroke_done); - sculpt_update_cache_invariants(sd, ss, C, op); + sculpt_update_cache_invariants(C, sd, ss, op, NULL); paint_stroke_exec(C, op); @@ -2254,7 +3585,12 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) static void SCULPT_OT_brush_stroke(wmOperatorType *ot) { - ot->flag |= OPTYPE_REGISTER; + static EnumPropertyItem stroke_mode_items[] = { + { WM_BRUSHSTROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally" }, + { WM_BRUSHSTROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke" }, + { WM_BRUSHSTROKE_SMOOTH, "SMOOTH", 0, "Smooth", "Switch brush to smooth mode for duration of stroke" }, + { 0 } + }; /* identifiers */ ot->name= "Sculpt Mode"; @@ -2265,36 +3601,32 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) ot->modal= paint_stroke_modal; ot->exec= sculpt_brush_stroke_exec; ot->poll= sculpt_poll; - + /* flags (sculpt does own undo? (ton) */ - ot->flag= OPTYPE_REGISTER|OPTYPE_BLOCKING; + ot->flag= OPTYPE_BLOCKING; /* properties */ - RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); - /* If the object has a scaling factor, brushes also need to be scaled - to work as expected. */ - RNA_def_float_vector(ot->srna, "scale", 3, NULL, 0.0f, FLT_MAX, "Scale", "", 0.0f, 1000.0f); + RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, + "Stroke", ""); - RNA_def_int(ot->srna, "flag", 0, 0, INT_MAX, "flag", "", 0, INT_MAX); - - /* For mirror modifiers */ - RNA_def_float_vector(ot->srna, "clip_tolerance", 3, NULL, 0.0f, FLT_MAX, "clip_tolerance", "", 0.0f, 1000.0f); - - /* The initial 2D location of the mouse */ - RNA_def_float_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX); + RNA_def_enum(ot->srna, "mode", stroke_mode_items, WM_BRUSHSTROKE_NORMAL, + "Sculpt Stroke Mode", + "Action taken when a sculpt stroke is made"); RNA_def_boolean(ot->srna, "ignore_background_click", 0, "Ignore Background Click", - "Clicks on the background don't start the stroke"); + "Clicks on the background do not start the stroke"); } /**** Reset the copy of the mesh that is being sculpted on (currently just for the layer brush) ****/ -static int sculpt_set_persistent_base(bContext *C, wmOperator *op) +static int sculpt_set_persistent_base(bContext *C, wmOperator *unused) { SculptSession *ss = CTX_data_active_object(C)->sculpt; + (void)unused; + if(ss) { if(ss->layer_co) MEM_freeN(ss->layer_co); @@ -2314,7 +3646,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) ot->exec= sculpt_set_persistent_base; ot->poll= sculpt_mode_poll; - ot->flag= OPTYPE_REGISTER; + ot->flag= 0;//OPTYPE_REGISTER; } /**** Toggle operator for turning sculpt mode on or off ****/ @@ -2322,18 +3654,21 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) static void sculpt_init_session(Scene *scene, Object *ob) { ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); + ob->sculpt->ob = ob; sculpt_update_mesh_elements(scene, ob, 0); } -static int sculpt_toggle_mode(bContext *C, wmOperator *op) +static int sculpt_toggle_mode(bContext *C, wmOperator *unused) { Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); Object *ob = CTX_data_active_object(C); - MultiresModifierData *mmd = sculpt_multires_active(scene, ob); + MultiresModifierData *mmd= sculpt_multires_active(scene, ob); int flush_recalc= 0; + (void)unused; + /* multires in sculpt mode could have different from object mode subdivision level */ flush_recalc |= mmd && mmd->sculptlvl != mmd->lvl; /* if object has got active modifiers, it's dm could be different in sculpt mode */ @@ -2359,9 +3694,13 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op) DAG_id_flush_update(&ob->id, OB_RECALC_DATA); /* Create persistent sculpt mode data */ - if(!ts->sculpt) + if(!ts->sculpt) { ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data"); + /* Turn on X plane mirror symmetry by default */ + ts->sculpt->flags |= SCULPT_SYMM_X; + } + /* Create sculpt mode session data */ if(ob->sculpt) free_sculptsession(ob); @@ -2388,7 +3727,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) ot->exec= sculpt_toggle_mode; ot->poll= ED_operator_object_active; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= 0; } void ED_operatortypes_sculpt() diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index c7c6833b695..a46823a0b28 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -32,6 +32,9 @@ #include "DNA_listBase.h" #include "DNA_vec_types.h" +#include "DNA_key_types.h" + +#include "BLI_pbvh.h" struct bContext; struct Brush; @@ -65,8 +68,49 @@ void sculpt_stroke_free(struct SculptStroke *); void sculpt_stroke_add_point(struct SculptStroke *, const short x, const short y); void sculpt_stroke_apply(struct Sculpt *sd, struct SculptStroke *); void sculpt_stroke_apply_all(struct Sculpt *sd, struct SculptStroke *); +int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float out[3], float mouse[2]); /* Partial Mesh Visibility */ void sculptmode_pmv(int mode); +/* Undo */ + +typedef struct SculptUndoNode { + struct SculptUndoNode *next, *prev; + + char idname[MAX_ID_NAME]; /* name instead of pointer*/ + void *node; /* only during push, not valid afterwards! */ + + float (*co)[3]; + short (*no)[3]; + int totvert; + + /* non-multires */ + int maxvert; /* to verify if totvert it still the same */ + int *index; /* to restore into right location */ + + /* multires */ + int maxgrid; /* same for grid */ + int gridsize; /* same for grid */ + int totgrid; /* to restore into right location */ + int *grids; /* to restore into right location */ + + /* layer brush */ + float *layer_disp; + + /* shape keys */ + char *shapeName[32]; /* keep size in sync with keyblock dna */ +} SculptUndoNode; + +SculptUndoNode *sculpt_undo_push_node(SculptSession *ss, PBVHNode *node); +SculptUndoNode *sculpt_undo_get_node(PBVHNode *node); +void sculpt_undo_push_begin(char *name); +void sculpt_undo_push_end(void); + +struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct Object *ob); +int sculpt_modifiers_active(Scene *scene, Object *ob); +void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]); + +void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos); + #endif diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c new file mode 100644 index 00000000000..303a7686a96 --- /dev/null +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -0,0 +1,302 @@ +/* + * $Id: sculpt.c 29425 2010-06-12 15:05:19Z jwilkins $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2006 by Nicholas Bishop + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * + * Implements the Sculpt Mode tools + * + */ + +#include "BLI_math.h" +#include "BLI_ghash.h" +#include "BLI_threads.h" + +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_mesh_types.h" +#include "DNA_key_types.h" + +#include "BKE_cdderivedmesh.h" +#include "BKE_context.h" +#include "BKE_depsgraph.h" +#include "BKE_modifier.h" +#include "BKE_multires.h" +#include "BKE_paint.h" +#include "BKE_mesh.h" +#include "BKE_key.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_sculpt.h" +#include "paint_intern.h" +#include "sculpt_intern.h" + +/************************** Undo *************************/ + +static void update_cb(PBVHNode *node, void *unused) +{ + (void)unused; + BLI_pbvh_node_mark_update(node); +} + +static void sculpt_undo_restore(bContext *C, ListBase *lb) +{ + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + DerivedMesh *dm = mesh_get_derived_final(scene, ob, 0); + SculptSession *ss = ob->sculpt; + SculptUndoNode *unode; + MVert *mvert; + MultiresModifierData *mmd; + int *index; + int i, j, update= 0; + + sculpt_update_mesh_elements(scene, ob, 0); + + for(unode=lb->first; unode; unode=unode->next) { + if(!(strcmp(unode->idname, ob->id.name)==0)) + continue; + + if(unode->maxvert) { + char *shapeName= (char*)unode->shapeName; + + /* regular mesh restore */ + if(ss->totvert != unode->maxvert) + continue; + + if (ss->kb && strcmp(ss->kb->name, shapeName)) { + /* shape key has been changed before calling undo operator */ + + Key *key= ob_get_key(ob); + KeyBlock *kb= key_get_named_keyblock(key, shapeName); + + if (kb) { + ob->shapenr= BLI_findindex(&key->block, kb) + 1; + ob->shapeflag|= OB_SHAPE_LOCK; + + sculpt_update_mesh_elements(scene, ob, 0); + WM_event_add_notifier(C, NC_OBJECT|ND_DATA, ob); + } else { + /* key has been removed -- skip this undo node */ + continue; + } + } + + index= unode->index; + mvert= ss->mvert; + + if (ss->kb) { + float (*vertCos)[3]; + vertCos= key_to_vertcos(ob, ss->kb); + + for(i=0; itotvert; i++) + swap_v3_v3(vertCos[index[i]], unode->co[i]); + + /* propagate new coords to keyblock */ + sculpt_vertcos_to_key(ob, ss->kb, vertCos); + + /* pbvh uses it's own mvert array, so coords should be */ + /* propagated to pbvh here */ + BLI_pbvh_apply_vertCos(ss->pbvh, vertCos); + + MEM_freeN(vertCos); + } else { + for(i=0; itotvert; i++) { + swap_v3_v3(mvert[index[i]].co, unode->co[i]); + mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; + } + } + } + else if(unode->maxgrid && dm->getGridData) { + /* multires restore */ + DMGridData **grids, *grid; + float (*co)[3]; + int gridsize; + + if(dm->getNumGrids(dm) != unode->maxgrid) + continue; + if(dm->getGridSize(dm) != unode->gridsize) + continue; + + grids= dm->getGridData(dm); + gridsize= dm->getGridSize(dm); + + co = unode->co; + for(j=0; jtotgrid; j++) { + grid= grids[unode->grids[j]]; + + for(i=0; ipbvh, NULL, NULL, update_cb, NULL); + BLI_pbvh_update(ss->pbvh, PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateRedraw, NULL); + + if((mmd=sculpt_multires_active(scene, ob))) + multires_mark_as_modified(ob); + + if(ss->modifiers_active || ((Mesh*)ob->data)->id.us > 1) + DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + } +} + +static void sculpt_undo_free(ListBase *lb) +{ + SculptUndoNode *unode; + + for(unode=lb->first; unode; unode=unode->next) { + if(unode->co) + MEM_freeN(unode->co); + if(unode->no) + MEM_freeN(unode->no); + if(unode->index) + MEM_freeN(unode->index); + if(unode->grids) + MEM_freeN(unode->grids); + if(unode->layer_disp) + MEM_freeN(unode->layer_disp); + } +} + +SculptUndoNode *sculpt_undo_get_node(PBVHNode *node) +{ + ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH); + SculptUndoNode *unode; + + if(!lb) + return NULL; + + for(unode=lb->first; unode; unode=unode->next) + if(unode->node == node) + return unode; + + return NULL; +} + +SculptUndoNode *sculpt_undo_push_node(SculptSession *ss, PBVHNode *node) +{ + ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH); + Object *ob= ss->ob; + SculptUndoNode *unode; + int totvert, allvert, totgrid, maxgrid, gridsize, *grids; + + /* list is manipulated by multiple threads, so we lock */ + BLI_lock_thread(LOCK_CUSTOM1); + + if((unode= sculpt_undo_get_node(node))) { + BLI_unlock_thread(LOCK_CUSTOM1); + return unode; + } + + unode= MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode"); + strcpy(unode->idname, ob->id.name); + unode->node= node; + + BLI_pbvh_node_num_verts(ss->pbvh, node, &totvert, &allvert); + BLI_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid, + &maxgrid, &gridsize, NULL, NULL); + + unode->totvert= totvert; + /* we will use this while sculpting, is mapalloc slow to access then? */ + unode->co= MEM_mapallocN(sizeof(float)*3*allvert, "SculptUndoNode.co"); + unode->no= MEM_mapallocN(sizeof(short)*3*allvert, "SculptUndoNode.no"); + undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float)*3 + sizeof(short)*3 + sizeof(int))*allvert); + BLI_addtail(lb, unode); + + if(maxgrid) { + /* multires */ + unode->maxgrid= maxgrid; + unode->totgrid= totgrid; + unode->gridsize= gridsize; + unode->grids= MEM_mapallocN(sizeof(int)*totgrid, "SculptUndoNode.grids"); + } + else { + /* regular mesh */ + unode->maxvert= ss->totvert; + unode->index= MEM_mapallocN(sizeof(int)*allvert, "SculptUndoNode.index"); + } + + BLI_unlock_thread(LOCK_CUSTOM1); + + /* copy threaded, hopefully this is the performance critical part */ + { + PBVHVertexIter vd; + + BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL) { + copy_v3_v3(unode->co[vd.i], vd.co); + if(vd.no) VECCOPY(unode->no[vd.i], vd.no) + else normal_float_to_short_v3(unode->no[vd.i], vd.fno); + if(vd.vert_indices) unode->index[vd.i]= vd.vert_indices[vd.i]; + } + BLI_pbvh_vertex_iter_end; + } + + if(unode->grids) + memcpy(unode->grids, grids, sizeof(int)*totgrid); + + /* store active shape key */ + if(ss->kb) BLI_strncpy((char*)unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); + else unode->shapeName[0]= '\0'; + + return unode; +} + +void sculpt_undo_push_begin(char *name) +{ + undo_paint_push_begin(UNDO_PAINT_MESH, name, + sculpt_undo_restore, sculpt_undo_free); +} + +void sculpt_undo_push_end(void) +{ + ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH); + SculptUndoNode *unode; + + /* we don't need normals in the undo stack */ + for(unode=lb->first; unode; unode=unode->next) { + if(unode->no) { + MEM_freeN(unode->no); + unode->no= NULL; + } + + if(unode->layer_disp) { + MEM_freeN(unode->layer_disp); + unode->layer_disp= NULL; + } + } + + undo_paint_push_end(UNDO_PAINT_MESH); +} diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 357aa9dacdf..f58326239ae 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -792,7 +792,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn uiLayoutSetContextPointer(layout, "edit_image", &imaptr); if(!compact) - uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL); + uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL, NULL); // XXX missing: reload, pack diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 3a264cbb259..005ebfb5b88 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -4278,7 +4278,7 @@ static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C) { uiLayout *row, *col; - uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL); + uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL, NULL); if (!RNA_pointer_get(ptr, "sound").data) { uiItemL(layout, "Select a sound from the list or load a new one", 0); diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 9b7bc9a8002..81d4e8b6b01 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -237,7 +237,7 @@ static void nla_panel_animdata (const bContext *C, Panel *pa) /* Active Action Properties ------------------------------------- */ /* action */ row= uiLayoutRow(layout, 1); - uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/); // XXX: need to make these operators + uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/, NULL); // XXX: need to make these operators /* extrapolation */ row= uiLayoutRow(layout, 1); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 2d111b731ad..082f3f97dfd 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -81,7 +81,7 @@ void node_buts_group(uiLayout *layout, bContext *C, PointerRNA *ptr) { - uiTemplateIDBrowse(layout, C, ptr, "nodetree", NULL, NULL, ""); + uiTemplateIDBrowse(layout, C, ptr, "nodetree", NULL, NULL, "", NULL); } static void node_buts_value(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -306,7 +306,7 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA bNode *node= ptr->data; uiLayout *col; - uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL); + uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL, NULL); if(!node->id) return; @@ -467,7 +467,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * PointerRNA imaptr; PropertyRNA *prop; - uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); + uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL, NULL); if(!node->id) return; @@ -504,7 +504,7 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point const char *layer_name; char scene_name[19]; - uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL); + uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL, NULL); if(!node->id) return; @@ -1204,7 +1204,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *C, PointerRNA *pt static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr) { - uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); + uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL, NULL); } static void node_texture_buts_output(uiLayout *layout, bContext *C, PointerRNA *ptr) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 488eea40500..14068fe5f47 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -69,6 +69,7 @@ #include "GPU_draw.h" #include "GPU_extensions.h" #include "GPU_material.h" +#include "gpu_buffers.h" #include "smoke_API.h" diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 7c3641db379..76468ada523 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -130,7 +130,7 @@ typedef struct PreviewImage { unsigned int w[2]; unsigned int h[2]; short changed[2]; - short pad0, pad1; + short changed_timestamp[2]; unsigned int * rect[2]; } PreviewImage; diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 14930f85e63..3b2ce6b436e 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -33,9 +33,9 @@ #include "DNA_ID.h" #include "DNA_texture_types.h" -#ifndef MAX_MTEX -#define MAX_MTEX 18 -#endif +//#ifndef MAX_MTEX // XXX Not used? +//#define MAX_MTEX 18 +//#endif struct CurveMapping; struct MTex; @@ -43,8 +43,8 @@ struct Image; typedef struct BrushClone { struct Image *image; /* image for clone tool */ - float offset[2]; /* offset of clone image from canvas */ - float alpha, pad; /* transparency for drawing of clone image */ + float offset[2]; /* offset of clone image from canvas */ + float alpha, pad; /* transparency for drawing of clone image */ } BrushClone; typedef struct Brush { @@ -53,50 +53,94 @@ typedef struct Brush { struct BrushClone clone; struct CurveMapping *curve; /* falloff curve */ struct MTex mtex; - - short flag, blend; /* general purpose flag, blend mode */ - int size; /* brush diameter */ - float jitter; /* jitter the position of the brush */ - float spacing; /* spacing of paint operations */ - int smooth_stroke_radius; /* turning radius (in pixels) for smooth stroke */ - float smooth_stroke_factor; /* higher values limit fast changes in the stroke direction */ - float rate; /* paint operations / second (airbrush) */ + struct Image *image_icon; - float rgb[3]; /* color */ - float alpha; /* opacity */ + float normal_weight; - char sculpt_tool; /* active sculpt tool */ + short blend, pad; /* blend mode */ + int size; /* brush diameter */ + int flag; /* general purpose flag */ + float jitter; /* jitter the position of the brush */ + int spacing; /* spacing of paint operations */ + int smooth_stroke_radius; /* turning radius (in pixels) for smooth stroke */ + float smooth_stroke_factor; /* higher values limit fast changes in the stroke direction */ + float rate; /* paint operations / second (airbrush) */ + + float rgb[3]; /* color */ + float alpha; /* opacity */ + + int sculpt_plane; /* the direction of movement for sculpt vertices */ + + float plane_offset; /* offset for plane brushes (clay, flatten, fill, scrape) */ + + char sculpt_tool; /* active sculpt tool */ char vertexpaint_tool; /* active vertex/weight paint tool/blend mode */ char imagepaint_tool; /* active image paint tool */ - char pad2; + char pad3; + + float autosmooth_factor; + + float crease_pinch_factor; + + float plane_trim; + + float texture_sample_bias; + int texture_overlay_alpha; + + float unprojected_radius; + + float add_col[3]; + float sub_col[3]; } Brush; /* Brush.flag */ -#define BRUSH_AIRBRUSH 1 -#define BRUSH_TORUS 2 -#define BRUSH_ALPHA_PRESSURE 4 -#define BRUSH_SIZE_PRESSURE 8 -#define BRUSH_JITTER_PRESSURE 16 /* was BRUSH_RAD_PRESSURE */ -#define BRUSH_SPACING_PRESSURE 32 -#define BRUSH_FIXED_TEX 64 -#define BRUSH_RAKE 128 -#define BRUSH_ANCHORED 256 -#define BRUSH_DIR_IN 512 -#define BRUSH_SPACE 1024 -#define BRUSH_SMOOTH_STROKE 2048 -#define BRUSH_PERSISTENT 4096 -#define BRUSH_ACCUMULATE 8192 -#define BRUSH_LOCK_ALPHA 16384 +#define BRUSH_AIRBRUSH (1<<0) +#define BRUSH_TORUS (1<<1) +#define BRUSH_ALPHA_PRESSURE (1<<2) +#define BRUSH_SIZE_PRESSURE (1<<3) +#define BRUSH_JITTER_PRESSURE (1<<4) /* was BRUSH_RAD_PRESSURE */ +#define BRUSH_SPACING_PRESSURE (1<<5) +#define BRUSH_FIXED_TEX (1<<6) +#define BRUSH_RAKE (1<<7) +#define BRUSH_ANCHORED (1<<8) +#define BRUSH_DIR_IN (1<<9) +#define BRUSH_SPACE (1<<10) +#define BRUSH_SMOOTH_STROKE (1<<11) +#define BRUSH_PERSISTENT (1<<12) +#define BRUSH_ACCUMULATE (1<<13) +#define BRUSH_LOCK_ALPHA (1<<14) +#define BRUSH_ORIGINAL_NORMAL (1<<15) +#define BRUSH_OFFSET_PRESSURE (1<<16) +#define BRUSH_SPACE_ATTEN (1<<18) +#define BRUSH_ADAPTIVE_SPACE (1<<19) +#define BRUSH_LOCK_SIZE (1<<20) +#define BRUSH_TEXTURE_OVERLAY (1<<21) +#define BRUSH_EDGE_TO_EDGE (1<<22) +#define BRUSH_RESTORE_MESH (1<<23) +#define BRUSH_INVERSE_SMOOTH_PRESSURE (1<<24) +#define BRUSH_RANDOM_ROTATION (1<<25) +#define BRUSH_PLANE_TRIM (1<<26) +#define BRUSH_FRONTFACE (1<<27) /* Brush.sculpt_tool */ -#define SCULPT_TOOL_DRAW 1 -#define SCULPT_TOOL_SMOOTH 2 -#define SCULPT_TOOL_PINCH 3 -#define SCULPT_TOOL_INFLATE 4 -#define SCULPT_TOOL_GRAB 5 -#define SCULPT_TOOL_LAYER 6 -#define SCULPT_TOOL_FLATTEN 7 -#define SCULPT_TOOL_CLAY 8 +#define SCULPT_TOOL_DRAW 1 +#define SCULPT_TOOL_SMOOTH 2 +#define SCULPT_TOOL_PINCH 3 +#define SCULPT_TOOL_INFLATE 4 +#define SCULPT_TOOL_GRAB 5 +#define SCULPT_TOOL_LAYER 6 +#define SCULPT_TOOL_FLATTEN 7 +#define SCULPT_TOOL_CLAY 8 +#define SCULPT_TOOL_FILL 9 +#define SCULPT_TOOL_SCRAPE 10 +#define SCULPT_TOOL_NUDGE 11 +#define SCULPT_TOOL_THUMB 12 +#define SCULPT_TOOL_SNAKE_HOOK 13 +#define SCULPT_TOOL_ROTATE 14 +//#define SCULPT_TOOL_WAX 15 // XXX: reuse this slot later +#define SCULPT_TOOL_CREASE 16 +#define SCULPT_TOOL_BLOB 17 +#define SCULPT_TOOL_CLAY_TUBES 18 /* ImagePaintSettings.tool */ #define PAINT_TOOL_DRAW 0 @@ -104,5 +148,16 @@ typedef struct Brush { #define PAINT_TOOL_SMEAR 2 #define PAINT_TOOL_CLONE 3 +/* direction that the brush displaces along */ +enum { + SCULPT_DISP_DIR_AREA, + SCULPT_DISP_DIR_VIEW, + SCULPT_DISP_DIR_X, + SCULPT_DISP_DIR_Y, + SCULPT_DISP_DIR_Z, +}; + +#define MAX_BRUSH_PIXEL_RADIUS 200 + #endif diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h index bc35d379334..83cd7979ce7 100644 --- a/source/blender/makesdna/DNA_color_types.h +++ b/source/blender/makesdna/DNA_color_types.h @@ -64,7 +64,8 @@ typedef struct CurveMap { typedef struct CurveMapping { int flag, cur; /* cur; for buttons, to show active curve */ - int preset, pad; + int preset; + int changed_timestamp; rctf curr, clipr; /* current rect, clip rect (is default rect too) */ @@ -87,7 +88,9 @@ typedef enum CurveMappingPreset { CURVE_PRESET_SHARP, CURVE_PRESET_SMOOTH, CURVE_PRESET_MAX, - CURVE_PRESET_MID9 + CURVE_PRESET_MID9, + CURVE_PRESET_ROUND, + CURVE_PRESET_ROOT, } CurveMappingPreset; /* histogram->mode */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index a4e9deaa7d9..3ac11eabe54 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -569,12 +569,30 @@ typedef struct Sculpt { Paint paint; /* For rotating around a pivot point */ - float pivot[3]; + //float pivot[3]; XXX not used? int flags; /* Control tablet input */ - char tablet_size, tablet_strength; - char pad[6]; + //char tablet_size, tablet_strength; XXX not used? + int radial_symm[3]; + + // all this below is used to communicate with the cursor drawing routine + + /* record movement of mouse so that rake can start at an intuitive angle */ + float last_x, last_y; + float last_angle; + + int draw_anchored; + int anchored_size; + float anchored_location[3]; + float anchored_initial_mouse[2]; + + int draw_pressure; + float pressure_value; + + float special_rotation; + + int pad; } Sculpt; typedef struct VPaint { @@ -1105,19 +1123,22 @@ typedef struct Scene { /* Paint.flags */ typedef enum { - PAINT_SHOW_BRUSH = 1, - PAINT_FAST_NAVIGATE = 2 + PAINT_SHOW_BRUSH = (1<<0), + PAINT_FAST_NAVIGATE = (1<<1), + PAINT_SHOW_BRUSH_ON_SURFACE = (1<<2), } PaintFlags; /* Sculpt.flags */ /* These can eventually be moved to paint flags? */ typedef enum SculptFlags { - SCULPT_SYMM_X = 1, - SCULPT_SYMM_Y = 2, - SCULPT_SYMM_Z = 4, - SCULPT_LOCK_X = 64, - SCULPT_LOCK_Y = 128, - SCULPT_LOCK_Z = 256 + SCULPT_SYMM_X = (1<<0), + SCULPT_SYMM_Y = (1<<1), + SCULPT_SYMM_Z = (1<<2), + SCULPT_LOCK_X = (1<<3), + SCULPT_LOCK_Y = (1<<4), + SCULPT_LOCK_Z = (1<<5), + SCULPT_SYMMETRY_FEATHER = (1<<6), + SCULPT_USE_OPENMP = (1<<7), } SculptFlags; /* ImagePaintSettings.flag */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index b6e52699340..19db6316659 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -341,9 +341,10 @@ typedef struct UserDef { short gp_settings; short tb_leftmouse, tb_rightmouse; struct SolidLight light[3]; + short sculpt_paint_settings; /* user preferences for sculpt and paint */ short tw_hotspot, tw_flag, tw_handlesize, tw_size; short textimeout,texcollectrate; - short wmdrawmethod, wmpad; + short wmdrawmethod; /* removed wmpad */ int memcachelimit; int prefetchframes; short frameserverport; @@ -373,6 +374,11 @@ typedef struct UserDef { short autokey_flag; /* flags for autokeying */ struct ColorBand coba_weight; /* from texture.h */ + + int sculpt_paint_unified_size; /* unified radius of brush in pixels */ + float sculpt_paint_unified_unprojected_radius;/* unified radius of brush in Blender units */ + float sculpt_paint_unified_alpha; /* unified strength of brush */ + float sculpt_paint_overlay_col[3]; } UserDef; extern UserDef U; /* from blenkernel blender.c */ @@ -524,6 +530,11 @@ extern UserDef U; /* from blenkernel blender.c */ #define GP_PAINT_DOSMOOTH (1<<0) #define GP_PAINT_DOSIMPLIFY (1<<1) +/* sculpt_paint_settings */ +#define SCULPT_PAINT_USE_UNIFIED_SIZE (1<<0) +#define SCULPT_PAINT_USE_UNIFIED_ALPHA (1<<1) +#define SCULPT_PAINT_UNIFIED_LOCK_BRUSH_SIZE (1<<2) + /* color picker types */ #define USER_CP_CIRCLE 0 #define USER_CP_SQUARE_SV 1 diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index ed52316990e..e6d0772f425 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -307,8 +307,7 @@ typedef struct wmOperator { typedef enum wmRadialControlMode { WM_RADIALCONTROL_SIZE, WM_RADIALCONTROL_STRENGTH, - WM_RADIALCONTROL_ANGLE + WM_RADIALCONTROL_ANGLE, } wmRadialControlMode; #endif /* DNA_WINDOWMANAGER_TYPES_H */ - diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index bd500adc8e4..1558eef713e 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -45,7 +45,6 @@ if env['WITH_BF_GAMEENGINE']: if env['BF_UNIT_TEST']: defs.append('UNIT_TEST') - if env['OURPLATFORM'] == 'linux2': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 9b824279d8d..207e4e15a72 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -52,6 +52,7 @@ INCLUDE_DIRECTORIES( ../../gpu ../../imbuf ../../render/extern/include + ../../../../extern/glew/include . ) FILE(GLOB INC_FILES ../*.h ../../makesdna/*.h) diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index fff29ba8f56..6d5a06d4f81 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -30,6 +30,7 @@ #include "DNA_brush_types.h" #include "DNA_texture_types.h" +#include "DNA_scene_types.h" #include "BLI_math.h" @@ -51,6 +52,58 @@ static void rna_Brush_update(Main *bmain, Scene *scene, PointerRNA *ptr) WM_main_add_notifier(NC_BRUSH|NA_EDITED, br); } +static int rna_Brush_is_sculpt_brush(Brush *me, bContext *C) +{ + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + int i; + + for (i= 0; i < sd->paint.brush_count; i++) { + if (strcmp(me->id.name+2, sd->paint.brushes[i]->id.name+2) == 0) + return 1; + } + + return 0; +} + +static int rna_Brush_is_vpaint_brush(Brush *me, bContext *C) +{ + VPaint *vp = CTX_data_tool_settings(C)->vpaint; + int i; + + for (i= 0; i < vp->paint.brush_count; i++) { + if (strcmp(me->id.name+2, vp->paint.brushes[i]->id.name+2) == 0) + return 1; + } + + return 0; +} + +static int rna_Brush_is_wpaint_brush(Brush *me, bContext *C) +{ + VPaint *vp = CTX_data_tool_settings(C)->wpaint; + int i; + + for (i= 0; i < vp->paint.brush_count; i++) { + if (strcmp(me->id.name+2, vp->paint.brushes[i]->id.name+2) == 0) + return 1; + } + + return 0; +} + +static int rna_Brush_is_imapaint_brush(Brush *me, bContext *C) +{ + ImagePaintSettings *data = &(CTX_data_tool_settings(C)->imapaint); + int i; + + for (i= 0; i < data->paint.brush_count; i++) { + if (strcmp(me->id.name+2, data->paint.brushes[i]->id.name+2) == 0) + return 1; + } + + return 0; +} + #else static void rna_def_brush_texture_slot(BlenderRNA *brna) @@ -100,14 +153,42 @@ static void rna_def_brush(BlenderRNA *brna) static EnumPropertyItem brush_sculpt_tool_items[] = { {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {SCULPT_TOOL_CREASE, "CREASE", 0, "Crease", ""}, + {SCULPT_TOOL_BLOB, "BLOB", 0, "Blob", ""}, {SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""}, {SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""}, {SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""}, + {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", 0, "Snake Hook", ""}, + {SCULPT_TOOL_ROTATE, "ROTATE", 0, "Rotate", ""}, + {SCULPT_TOOL_THUMB, "THUMB", 0, "Thumb", ""}, + {SCULPT_TOOL_NUDGE, "NUDGE", 0, "Nudge", ""}, {SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""}, {SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""}, {SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""}, + //{SCULPT_TOOL_CLAY_TUBES, "CLAY_TUBES", 0, "Clay Tubes", ""}, XXX: remove clay tubes from UI + {SCULPT_TOOL_FILL, "FILL", 0, "Fill", ""}, + {SCULPT_TOOL_SCRAPE, "SCRAPE", 0, "Scrape", ""}, {0, NULL, 0, NULL, NULL}}; - + + static EnumPropertyItem brush_stroke_method_items[] = { + {0, "DOTS", 0, "Dots", ""}, + {BRUSH_RESTORE_MESH, "DRAG_DOT", 0, "Drag Dot", ""}, + {BRUSH_SPACE, "SPACE", 0, "Space", ""}, + {BRUSH_ANCHORED, "ANCHORED", 0, "Anchored", ""}, + {BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", ""}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem texture_angle_source_items[] = { + {0, "USER", 0, "User", ""}, + {BRUSH_RAKE, "RAKE", 0, "Rake", ""}, + {BRUSH_RANDOM_ROTATION, "RANDOM", 0, "Random", ""}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem texture_angle_source_no_random_items[] = { + {0, "USER", 0, "User", ""}, + {BRUSH_RAKE, "RAKE", 0, "Rake", ""}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem brush_vertexpaint_tool_items[] = { {0, "MIX", 0, "Mix", "Use mix blending mode while painting"}, {1, "ADD", 0, "Add", "Use add blending mode while painting"}, @@ -129,11 +210,76 @@ static void rna_def_brush(BlenderRNA *brna) {0, "ADD", 0, "Add", "Add effect of brush"}, {BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"}, {0, NULL, 0, NULL, NULL}}; - + + static const EnumPropertyItem prop_flatten_contrast_items[]= { + {0, "FLATTEN", 0, "Flatten", "Add effect of brush"}, + {BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + + static const EnumPropertyItem prop_fill_deepen_items[]= { + {0, "FILL", 0, "Fill", "Add effect of brush"}, + {BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + + static const EnumPropertyItem prop_scrape_peaks_items[]= { + {0, "SCRAPE", 0, "Scrape", "Add effect of brush"}, + {BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + + static const EnumPropertyItem prop_pinch_magnify_items[]= { + {0, "PINCH", 0, "Pinch", "Add effect of brush"}, + {BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + + static const EnumPropertyItem prop_inflate_deflate_items[]= { + {0, "INFLATE", 0, "Inflate", "Add effect of brush"}, + {BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"}, + {0, 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", ""}, + {SCULPT_DISP_DIR_X, "X", 0, "X Plane", ""}, + {SCULPT_DISP_DIR_Y, "Y", 0, "Y Plane", ""}, + {SCULPT_DISP_DIR_Z, "Z", 0, "Z Plane", ""}, + {0, NULL, 0, NULL, NULL}}; + + FunctionRNA *func; + PropertyRNA *parm; + srna= RNA_def_struct(brna, "Brush", "ID"); RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting"); RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA); - + + /* functions */ + func= RNA_def_function(srna, "is_sculpt_brush", "rna_Brush_is_sculpt_brush"); + RNA_def_function_ui_description(func, "Returns true if Brush can be used for sculpting"); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_boolean(func, "ret", 0, "", ""); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "is_vpaint_brush", "rna_Brush_is_vpaint_brush"); + RNA_def_function_ui_description(func, "Returns true if Brush can be used for vertex painting"); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_boolean(func, "ret", 0, "", ""); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "is_wpaint_brush", "rna_Brush_is_wpaint_brush"); + RNA_def_function_ui_description(func, "Returns true if Brush can be used for weight painting"); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_boolean(func, "ret", 0, "", ""); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "is_imapaint_brush", "rna_Brush_is_imapaint_brush"); + RNA_def_function_ui_description(func, "Returns true if Brush can be used for image painting"); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_boolean(func, "ret", 0, "", ""); + RNA_def_function_return(func, parm); + /* enums */ prop= RNA_def_property(srna, "blend", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_blend_items); @@ -144,7 +290,7 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_enum_items(prop, brush_sculpt_tool_items); RNA_def_property_ui_text(prop, "Sculpt Tool", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); - + prop= RNA_def_property(srna, "vertexpaint_tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, brush_vertexpaint_tool_items); RNA_def_property_ui_text(prop, "Vertex/Weight Paint Tool", ""); @@ -158,33 +304,94 @@ static void rna_def_brush(BlenderRNA *brna) prop= RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, prop_flip_direction_items); - RNA_def_property_ui_text(prop, "Direction", "Mapping type to use for this image in the game engine"); + RNA_def_property_ui_text(prop, "Direction", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "stroke_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, brush_stroke_method_items); + RNA_def_property_ui_text(prop, "Stroke Method", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "texture_angle_source", 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, "flatten_contrast", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, prop_flatten_contrast_items); + RNA_def_property_ui_text(prop, "Flatten/Contrast", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "inflate_deflate", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, prop_inflate_deflate_items); + RNA_def_property_ui_text(prop, "Inflate/Deflate", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "fill_deepen", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, prop_fill_deepen_items); + RNA_def_property_ui_text(prop, "Fill/Deepen", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "scrape_peaks", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, prop_scrape_peaks_items); + RNA_def_property_ui_text(prop, "Scrape/Peaks", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "pinch_magnify", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, prop_pinch_magnify_items); + RNA_def_property_ui_text(prop, "Pinch/Magnify", ""); + 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", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); /* number values */ - prop= RNA_def_property(srna, "size", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 1, 200); - RNA_def_property_ui_text(prop, "Size", "Diameter of the brush"); + prop= RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE); + RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS*10); + RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0); + RNA_def_property_ui_text(prop, "Size", "Radius of the brush in pixels"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop= RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_range(prop, 0, 1, 0, 0); + RNA_def_property_ui_text(prop, "Surface Size", "Radius of brush in Blender units"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop= RNA_def_property(srna, "jitter", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "jitter"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Jitter", "Jitter the position of the brush while painting"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop= RNA_def_property(srna, "spacing", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "spacing"); - RNA_def_property_range(prop, 1.0f, 100.0f); - RNA_def_property_ui_text(prop, "Spacing", "Spacing between brush stamps"); + prop= RNA_def_property(srna, "spacing", PROP_INT, PROP_PERCENTAGE); + RNA_def_property_int_sdna(prop, NULL, "spacing"); + RNA_def_property_range(prop, 1, 1000); + RNA_def_property_ui_range(prop, 1, 500, 5, 0); + RNA_def_property_ui_text(prop, "Spacing", "Spacing between brush daubs as a percentage of brush diameter"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop= RNA_def_property(srna, "smooth_stroke_radius", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "smooth_stroke_radius", PROP_INT, PROP_DISTANCE); RNA_def_property_range(prop, 10, 200); RNA_def_property_ui_text(prop, "Smooth Stroke Radius", "Minimum distance from last point before stroke continues"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop= RNA_def_property(srna, "smooth_stroke_factor", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "smooth_stroke_factor", PROP_FLOAT, PROP_FACTOR); RNA_def_property_range(prop, 0.5, 0.99); RNA_def_property_ui_text(prop, "Smooth Stroke Factor", "Higher values give a smoother stroke"); RNA_def_property_update(prop, 0, "rna_Brush_update"); @@ -202,10 +409,56 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Color", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "alpha"); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_range(prop, 0.0f, 10.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 0.001); + RNA_def_property_ui_text(prop, "Strength", "How powerful the effect of the brush is when applied"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "plane_offset", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "plane_offset"); + RNA_def_property_float_default(prop, 0); + RNA_def_property_range(prop, -2.0f, 2.0f); + RNA_def_property_ui_range(prop, -0.5f, 0.5f, 0.001, 0.001); + RNA_def_property_ui_text(prop, "Plane Offset", "Adjusts plane on which the brush acts towards or away from the object surface"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "plane_trim", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "plane_trim"); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_range(prop, 0, 1.0f); + RNA_def_property_ui_text(prop, "Plane Trim", "If a vertex is further from offset plane than this then it is not affected"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "texture_sample_bias", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "texture_sample_bias"); + RNA_def_property_float_default(prop, 0); + RNA_def_property_range(prop, -1, 1); + RNA_def_property_ui_text(prop, "Texture Sample Bias", "Value added to texture samples"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "normal_weight", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "normal_weight"); + RNA_def_property_float_default(prop, 0); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Strength", "The amount of pressure on the brush"); + RNA_def_property_ui_text(prop, "Normal Weight", "How much grab will pull vertexes out of surface during a grab"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "crease_pinch_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "crease_pinch_factor"); + RNA_def_property_float_default(prop, 2.0f/3.0f); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Crease Brush Pinch Factor", "How much the crease brush pinches"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "autosmooth_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "autosmooth_factor"); + RNA_def_property_float_default(prop, 0); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 0.001); + RNA_def_property_ui_text(prop, "Autosmooth", "Amount of smoothing to automatically apply to each stroke"); RNA_def_property_update(prop, 0, "rna_Brush_update"); /* flag */ @@ -214,6 +467,11 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Airbrush", "Keep applying paint effect while holding mouse (spray)"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop= RNA_def_property(srna, "use_original_normal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ORIGINAL_NORMAL); + RNA_def_property_ui_text(prop, "Original Normal", "When locked keep using normal of surface where stroke was initiated"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop= RNA_def_property(srna, "use_wrap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_TORUS); RNA_def_property_ui_text(prop, "Wrap", "Enable torus wrapping while painting"); @@ -225,6 +483,12 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop= RNA_def_property(srna, "use_offset_pressure", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_OFFSET_PRESSURE); + RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); + RNA_def_property_ui_text(prop, "Plane Offset Pressure", "Enable tablet pressure sensitivity for offset"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop= RNA_def_property(srna, "use_size_pressure", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SIZE_PRESSURE); RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); @@ -243,11 +507,32 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Spacing Pressure", "Enable tablet pressure sensitivity for spacing"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop= RNA_def_property(srna, "use_inverse_smooth_pressure", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_INVERSE_SMOOTH_PRESSURE); + RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); + 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_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"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "use_frontface", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FRONTFACE); + RNA_def_property_ui_text(prop, "Use Front-Face", "Brush only affects vertexes that face the viewer"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop= RNA_def_property(srna, "use_anchor", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ANCHORED); RNA_def_property_ui_text(prop, "Anchored", "Keep the brush anchored to the initial location"); @@ -273,6 +558,37 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Accumulate", "Accumulate stroke dabs on top of each other"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop= RNA_def_property(srna, "use_space_atten", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SPACE_ATTEN); + RNA_def_property_ui_text(prop, "Use Automatic Strength Adjustment", "Automatically adjusts strength to give consistent results for different spacings"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + /* adaptive space is not implemented yet */ + prop= RNA_def_property(srna, "use_adaptive_space", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ADAPTIVE_SPACE); + RNA_def_property_ui_text(prop, "Adaptive Spacing", "Space daubs according to surface orientation instead of screen space"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "lock_brush_size", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_LOCK_SIZE); + RNA_def_property_ui_text(prop, "Use Blender Units", "When locked brush stays same size relative to object; when unlocked brush size is given in pixels"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "use_texture_overlay", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_TEXTURE_OVERLAY); + RNA_def_property_ui_text(prop, "Use Texture Overlay", "Show texture in viewport"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "edge_to_edge", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_EDGE_TO_EDGE); + RNA_def_property_ui_text(prop, "Edge-to-edge", "Drag anchor brush from edge-to-edge"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "restore_mesh", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RESTORE_MESH); + RNA_def_property_ui_text(prop, "Restore Mesh", "Allows a single dot to be carefully positioned"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + /* not exposed in the interface yet prop= RNA_def_property(srna, "fixed_tex", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FIXED_TEX); @@ -303,6 +619,31 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Texture", ""); RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_update"); + prop= RNA_def_property(srna, "texture_overlay_alpha", PROP_INT, PROP_PERCENTAGE); + RNA_def_property_int_sdna(prop, NULL, "texture_overlay_alpha"); + RNA_def_property_range(prop, 1, 100); + RNA_def_property_ui_text(prop, "Texture Overlay Alpha", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "add_col", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "add_col"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Add Color", "Color of cursor when adding"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "sub_col", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "sub_col"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Subract Color", "Color of cursor when subtracting"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop= RNA_def_property(srna, "image_icon", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "image_icon"); + RNA_def_property_struct_type(prop, "Image"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Image Icon", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + /* clone tool */ prop= RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "clone.image"); @@ -357,16 +698,19 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Pressure", "Tablet pressure"); + prop= RNA_def_property(srna, "pen_flip", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_flag(prop, PROP_IDPROPERTY); + RNA_def_property_ui_text(prop, "Flip", ""); + + // used in uv painting prop= RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_ui_text(prop, "Time", ""); - prop= RNA_def_property(srna, "flip", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_flag(prop, PROP_IDPROPERTY); - RNA_def_property_ui_text(prop, "Flip", ""); - /* XXX: Tool (this will be for pressing a modifier key for a different brush, e.g. switching to a Smooth brush in the middle of the stroke */ + + // XXX: i don't think blender currently supports the ability to properly do a remappable modifier in the middle of a stroke } void RNA_def_brush(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 7d8248b58ed..7144b409299 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -213,6 +213,12 @@ static int rna_Image_depth_get(PointerRNA *ptr) return depth; } +static int rna_Image_is_image_icon(Image *me, bContext *C) +{ + const char prefix[] = ".imageicon."; + return strncmp(me->id.name+2, prefix, sizeof(prefix)-1) == 0; +} + #else static void rna_def_imageuser(BlenderRNA *brna) @@ -292,6 +298,9 @@ static void rna_def_image(BlenderRNA *brna) {IMA_STD_FIELD, "ODD", 0, "Lower First", "Lower field first"}, {0, NULL, 0, NULL, NULL}}; + FunctionRNA *func; + PropertyRNA *parm; + srna= RNA_def_struct(brna, "Image", "ID"); RNA_def_struct_ui_text(srna, "Image", "Image datablock referencing an external or packed image"); RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA); @@ -333,6 +342,14 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Field Order", "Order of video fields. Select which lines are displayed first"); RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); + /* functions */ + func= RNA_def_function(srna, "is_image_icon", "rna_Image_is_image_icon"); + RNA_def_function_ui_description(func, "Returns true if Image name is prefixed with .imageicon."); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_boolean(func, "ret", 0, "", ""); + RNA_def_function_return(func, parm); + /* booleans */ prop= RNA_def_property(srna, "fields", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 3a7e7a02837..604f7776d56 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -193,7 +193,7 @@ static void rna_Paint_active_brush_name_get(PointerRNA *ptr, char *value) Paint *p= ptr->data; Brush *br = paint_brush(p); - BLI_strncpy(value, br->id.name+2, sizeof(br->id.name-2)); + BLI_strncpy(value, br->id.name+2, sizeof(br->id.name)-2); } @@ -212,7 +212,7 @@ static void rna_Paint_active_brush_name_set(PointerRNA *ptr, const char *value) for(i = 0; i < p->brush_count; ++i) { br = p->brushes[i]; - + if (strcmp(br->id.name+2, value)==0) { paint_brush_set(p, br); return; @@ -262,6 +262,10 @@ static void rna_def_paint(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", PAINT_SHOW_BRUSH); RNA_def_property_ui_text(prop, "Show Brush", ""); + prop= RNA_def_property(srna, "show_brush_on_surface", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", PAINT_SHOW_BRUSH_ON_SURFACE); + RNA_def_property_ui_text(prop, "Show Brush On Surface", ""); + prop= RNA_def_property(srna, "fast_navigate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", PAINT_FAST_NAVIGATE); RNA_def_property_ui_text(prop, "Fast Navigate", "For multires, show low resolution while navigating the view"); @@ -274,7 +278,14 @@ static void rna_def_sculpt(BlenderRNA *brna) srna= RNA_def_struct(brna, "Sculpt", "Paint"); RNA_def_struct_ui_text(srna, "Sculpt", ""); - + + prop= RNA_def_property(srna, "radial_symm", PROP_INT, PROP_XYZ); + RNA_def_property_int_sdna(prop, NULL, "radial_symm"); + RNA_def_property_int_default(prop, 1); + RNA_def_property_range(prop, 1, 64); + RNA_def_property_ui_range(prop, 0, 32, 1, 1); + RNA_def_property_ui_text(prop, "Radial Symmetry Count X Axis", "Number of times to copy strokes across the surface"); + prop= RNA_def_property(srna, "symmetry_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_X); RNA_def_property_ui_text(prop, "Symmetry X", "Mirror brush across the X axis"); @@ -298,6 +309,14 @@ static void rna_def_sculpt(BlenderRNA *brna) prop= RNA_def_property(srna, "lock_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_Z); RNA_def_property_ui_text(prop, "Lock Z", "Disallow changes to the Z axis of vertices"); + + prop= RNA_def_property(srna, "use_symmetry_feather", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMMETRY_FEATHER); + RNA_def_property_ui_text(prop, "Symmetry Feathering", "Reduce the strength of the brush where it overlaps symmetrical daubs"); + + prop= RNA_def_property(srna, "use_openmp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_USE_OPENMP); + RNA_def_property_ui_text(prop, "Use OpenMP", "Take advantage of multiple CPU cores to improve sculpting performance"); } static void rna_def_vertex_paint(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 1c751433e31..b2831c4b1d3 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -274,6 +274,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block."); RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a file for creating a new ID block."); RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block."); + RNA_def_string(func, "filter", "", 0, "", "Function identifier to filter the ID block."); func= RNA_def_function(srna, "template_ID_preview", "uiTemplateIDPreview"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); @@ -281,6 +282,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block."); RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a file for creating a new ID block."); RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block."); + RNA_def_string(func, "filter", "", 0, "", "Function identifier to filter the ID block."); RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX); RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index d6aec37d6fb..a03488d3878 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -32,6 +32,7 @@ #include "DNA_curve_types.h" #include "DNA_space_types.h" #include "DNA_userdef_types.h" +#include "DNA_brush_types.h" #include "WM_api.h" #include "WM_types.h" @@ -867,7 +868,7 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Transform", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); - + rna_def_userdef_theme_spaces_vertex(srna); rna_def_userdef_theme_spaces_edge(srna); rna_def_userdef_theme_spaces_face(srna); @@ -2194,7 +2195,43 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "gp_eraser"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Grease Pencil Eraser Radius", "Radius of eraser 'brush'"); - + + /* sculpt and paint */ + + prop= RNA_def_property(srna, "sculpt_paint_overlay_col", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "sculpt_paint_overlay_col"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Sculpt/Paint Overlay Color", "Color of texture overlay"); + + prop= RNA_def_property(srna, "sculpt_paint_use_unified_size", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "sculpt_paint_settings", SCULPT_PAINT_USE_UNIFIED_SIZE); + RNA_def_property_ui_text(prop, "Sculpt/Paint Use Unified Radius", "Instead of per brush radius, the radius is shared across brushes"); + + prop= RNA_def_property(srna, "sculpt_paint_use_unified_strength", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "sculpt_paint_settings", SCULPT_PAINT_USE_UNIFIED_ALPHA); + RNA_def_property_ui_text(prop, "Sculpt/Paint Use Unified Strength", "Instead of per brush strength, the strength is shared across brushes"); + + prop= RNA_def_property(srna, "sculpt_paint_unified_lock_brush_size", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "sculpt_paint_settings", SCULPT_PAINT_UNIFIED_LOCK_BRUSH_SIZE); + RNA_def_property_ui_text(prop, "Sculpt/Paint Use Unified Blender Units", "When locked all brushes stay same size relative to object; when unlocked all brush sizes are given in pixels"); + + prop= RNA_def_property(srna, "sculpt_paint_unified_size", PROP_INT, PROP_DISTANCE); + RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS*10); + RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0); + RNA_def_property_ui_text(prop, "Sculpt/Paint Unified Size", "Unified radius of the brush in pixels"); + + prop= RNA_def_property(srna, "sculpt_paint_unified_unprojected_radius", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_range(prop, 0, 1, 0, 0); + RNA_def_property_ui_text(prop, "Sculpt/Paint Unified Surface Size", "Unified radius of brush in Blender units"); + + prop= RNA_def_property(srna, "sculpt_paint_unified_strength", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "sculpt_paint_unified_alpha"); + RNA_def_property_float_default(prop, 0.5f); + RNA_def_property_range(prop, 0.0f, 10.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 0.001); + RNA_def_property_ui_text(prop, "Sculpt/Paint Unified Strength", "Unified power of effect of brushes when applied"); + /* duplication linking */ prop= RNA_def_property(srna, "duplicate_mesh", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_MESH); diff --git a/source/blender/windowmanager/SConscript b/source/blender/windowmanager/SConscript index 0a86133e614..179b1ddc998 100644 --- a/source/blender/windowmanager/SConscript +++ b/source/blender/windowmanager/SConscript @@ -24,7 +24,7 @@ if env['WITH_BF_COLLADA']: if env['OURPLATFORM'] == 'linux2': cflags='-pthread' - incs += ' ../../../extern/binreloc/include' + incs += ' ../../../extern/binreloc/include' if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): incs += ' ' + env['BF_PTHREADS_INC'] @@ -35,4 +35,4 @@ if env['WITH_GHOST_COCOA']: if env['BF_BUILDINFO']: defs.append('NAN_BUILDINFO') -env.BlenderLib ( 'bf_windowmanager', sources, Split(incs), defs, libtype=['core'], priority=[5] ) +env.BlenderLib ( 'bf_windowmanager', sources, Split(incs), defines=defs, libtype=['core'], priority=[5] ) diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 5dbbf35796f..38322b66bbb 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -389,6 +389,7 @@ static void wm_draw_triple_free(wmWindow *win) wmDrawTriple *triple= win->drawdata; glDeleteTextures(triple->nx*triple->ny, triple->bind); + MEM_freeN(triple); win->drawdata= NULL; @@ -560,7 +561,8 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) else { win->drawdata= MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple"); - if(!wm_triple_gen_textures(win, win->drawdata)) { + if(!wm_triple_gen_textures(win, win->drawdata)) + { wm_draw_triple_fail(C, win); return; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 0023ded23f0..78e1c7d87a3 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -61,6 +61,7 @@ #include "BKE_scene.h" #include "BKE_screen.h" /* BKE_ST_MAXNAME */ #include "BKE_utildefines.h" +#include "BKE_brush.h" // JW #include "BIF_gl.h" #include "BIF_glutil.h" /* for paint cursor */ @@ -69,6 +70,7 @@ #include "ED_screen.h" #include "ED_util.h" +#include "ED_view3d.h" // JW #include "RNA_access.h" #include "RNA_define.h" @@ -2595,19 +2597,28 @@ typedef struct wmRadialControl { GLuint tex; } wmRadialControl; +extern Paint *paint_get_active(Scene *sce); +extern struct Brush *paint_brush(struct Paint *paint); + static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) { wmRadialControl *rc = (wmRadialControl*)customdata; ARegion *ar = CTX_wm_region(C); float r1=0.0f, r2=0.0f, r3=0.0f, angle=0.0f; - /* Keep cursor in the original place */ - x = rc->initial_mouse[0] - ar->winrct.xmin; - y = rc->initial_mouse[1] - ar->winrct.ymin; + Paint *paint = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(paint); - glPushMatrix(); - - glTranslatef((float)x, (float)y, 0.0f); + ViewContext vc; + + int hit = 0; + + int flip; + int sign; + + float* col; + + const float str = rc->mode == WM_RADIALCONTROL_STRENGTH ? (rc->value + 0.5) : (brush->texture_overlay_alpha / 100.0f); if(rc->mode == WM_RADIALCONTROL_SIZE) { r1= rc->value; @@ -2615,29 +2626,37 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) r3= r1; } else if(rc->mode == WM_RADIALCONTROL_STRENGTH) { r1= (1 - rc->value) * WM_RADIAL_CONTROL_DISPLAY_SIZE; - r2= WM_RADIAL_CONTROL_DISPLAY_SIZE; - r3= WM_RADIAL_CONTROL_DISPLAY_SIZE; + r2= r3= WM_RADIAL_CONTROL_DISPLAY_SIZE; } else if(rc->mode == WM_RADIALCONTROL_ANGLE) { - r1= r2= WM_RADIAL_CONTROL_DISPLAY_SIZE; - r3= WM_RADIAL_CONTROL_DISPLAY_SIZE; + r1= r2= r3= WM_RADIAL_CONTROL_DISPLAY_SIZE; angle = rc->value; } - glColor4ub(255, 255, 255, 128); - glEnable( GL_LINE_SMOOTH ); + /* Keep cursor in the original place */ + x = rc->initial_mouse[0] - ar->winrct.xmin; + y = rc->initial_mouse[1] - ar->winrct.ymin; + + view3d_set_viewcontext(C, &vc); + + // XXX: no way currently to know state of pen flip or invert key modifier without starting a stroke + flip = 1; + + sign = flip * ((brush->flag & BRUSH_DIR_IN)? -1 : 1); + + if (sign < 0 && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH)) + col = brush->sub_col; + else + col = brush->add_col; + + glTranslatef((float)x, (float)y, 0.0f); + glEnable(GL_BLEND); - if(rc->mode == WM_RADIALCONTROL_ANGLE) - fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); - - if(rc->tex) { - const float str = rc->mode == WM_RADIALCONTROL_STRENGTH ? (rc->value + 0.5) : 1; - - if(rc->mode == WM_RADIALCONTROL_ANGLE) { - glRotatef(angle, 0, 0, 1); - fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); - } + if(rc->mode == WM_RADIALCONTROL_ANGLE) { + glRotatef(angle, 0, 0, 1); + } + if (rc->tex) { glBindTexture(GL_TEXTURE_2D, rc->tex); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -2645,7 +2664,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); - glColor4f(0,0,0, str); + glColor4f(U.sculpt_paint_overlay_col[0],U.sculpt_paint_overlay_col[1],U.sculpt_paint_overlay_col[2], str); glTexCoord2f(0,0); glVertex2f(-r3, -r3); glTexCoord2f(1,0); @@ -2658,11 +2677,20 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) glDisable(GL_TEXTURE_2D); } - glColor4ub(255, 255, 255, 128); + if(rc->mode == WM_RADIALCONTROL_ANGLE) { + glColor4f(col[0], col[1], col[2], 0.5f); + glEnable(GL_LINE_SMOOTH); + glRotatef(-angle, 0, 0, 1); + fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); + glRotatef(angle, 0, 0, 1); + fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); + glDisable(GL_LINE_SMOOTH); + } + + glColor4f(col[0], col[1], col[2], 0.5f); glutil_draw_lined_arc(0.0, M_PI*2.0, r1, 40); glutil_draw_lined_arc(0.0, M_PI*2.0, r2, 40); glDisable(GL_BLEND); - glDisable( GL_LINE_SMOOTH ); glPopMatrix(); } @@ -2674,6 +2702,7 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) float dist; double new_value = RNA_float_get(op->ptr, "new_value"); int ret = OPERATOR_RUNNING_MODAL; + float initial_value = RNA_float_get(op->ptr, "initial_value"); mode = RNA_int_get(op->ptr, "mode"); RNA_int_get_array(op->ptr, "initial_mouse", initial_mouse); @@ -2682,6 +2711,16 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) case MOUSEMOVE: delta[0]= initial_mouse[0] - event->x; delta[1]= initial_mouse[1] - event->y; + + //if (mode == WM_RADIALCONTROL_SIZE) + // delta[0]+= initial_value; + //else if(mode == WM_RADIALCONTROL_STRENGTH) + // delta[0]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * (1 - initial_value); + //else if(mode == WM_RADIALCONTROL_ANGLE) { + // delta[0]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(initial_value*M_PI/180.0f); + // delta[1]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(initial_value*M_PI/180.0f); + //} + dist= sqrt(delta[0]*delta[0]+delta[1]*delta[1]); if(mode == WM_RADIALCONTROL_SIZE) @@ -2728,6 +2767,11 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(CTX_wm_region(C)); + //if (ret != OPERATOR_RUNNING_MODAL) { + // wmWindow *win = CTX_wm_window(C); + // WM_cursor_restore(win); + //} + return ret; } @@ -2735,10 +2779,15 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { wmRadialControl *rc = MEM_callocN(sizeof(wmRadialControl), "radial control"); + wmWindow *win = CTX_wm_window(C); int mode = RNA_int_get(op->ptr, "mode"); float initial_value = RNA_float_get(op->ptr, "initial_value"); + //float initial_size = RNA_float_get(op->ptr, "initial_size"); int mouse[2] = {event->x, event->y}; + //if (initial_size == 0) + // initial_size = WM_RADIAL_CONTROL_DISPLAY_SIZE; + if(mode == WM_RADIALCONTROL_SIZE) { rc->max_value = 200; mouse[0]-= initial_value; @@ -2775,6 +2824,8 @@ int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) rc->cursor = WM_paint_cursor_activate(CTX_wm_manager(C), op->type->poll, wm_radial_control_paint, op->customdata); + //WM_cursor_modal(win, CURSOR_NONE); + /* add modal handler */ WM_event_add_modal_handler(C, op); diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index add9ac05189..4599f8ff17b 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -36,12 +36,14 @@ struct ARegion; struct ARegionType; struct Base; +struct Brush; struct bNodeTree; struct CSG_FaceIteratorDescriptor; struct CSG_VertexIteratorDescriptor; struct ColorBand; struct CurveMapping; struct EditBone; +struct EditFace; struct EditMesh; struct ID; struct FCurve; @@ -54,16 +56,20 @@ struct LOD_Decimation_Info; struct MTex; struct Main; struct Material; +struct MCol; struct MenuType; struct Mesh; struct ModifierData; +struct MultiresModifierData; struct NodeBlurData; struct Object; +struct PBVHNode; struct Render; struct RenderEngine; struct RenderLayer; struct RenderResult; struct ScrArea; +struct SculptSession; struct ShadeInput; struct ShadeResult; struct SpaceImage; @@ -375,6 +381,24 @@ void smoke_get_index(void) {return;} void smoke_step(void) {return;} */ +/* sculpt */ +/* + void ED_sculpt_force_update(struct bContext *C) {} +struct SculptUndoNode *sculpt_undo_push_node(struct SculptSession *ss, struct PBVHNode *node) {return (struct SculptUndoNode *)NULL;} +void sculpt_undo_push_end(void) {} +void sculpt_undo_push_begin(char *name) {} +struct SculptUndoNode *sculpt_undo_get_node(struct PBVHNode *node) {return (struct SculptUndoNode *) NULL;} +struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct Object *ob) {return (struct MultiresModifierData *) NULL;} +int sculpt_modifiers_active(struct Scene *scene, struct Object *ob) {return 0;} +*/ +int sculpt_get_brush_size(struct Brush *brush) {return 0;} +void sculpt_set_brush_size(struct Brush *brush, int size) {} +int sculpt_get_lock_brush_size(struct Brush *brush){ return 0;} +float sculpt_get_brush_unprojected_radius(struct Brush *brush){return 0.0f;} +void sculpt_set_brush_unprojected_radius(struct Brush *brush, float unprojected_radius){} +float sculpt_get_brush_alpha(struct Brush *brush){return 0.0f;} +void sculpt_set_brush_alpha(struct Brush *brush, float alpha){} + char blender_path[] = ""; /* CSG */ From 267c286091d84cec17bfb6eb392699a4f2018a5b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 14 Jul 2010 14:31:27 +0000 Subject: [PATCH 02/51] Fix compile error after merge, gpu_buffers.h -> GPU_buffers.h. --- source/blender/gpu/intern/gpu_draw.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 14068fe5f47..488eea40500 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -69,7 +69,6 @@ #include "GPU_draw.h" #include "GPU_extensions.h" #include "GPU_material.h" -#include "gpu_buffers.h" #include "smoke_API.h" From 46f89336d644fd45d1960465637f67d0918a94bd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2010 14:56:33 +0000 Subject: [PATCH 03/51] fix for autocomp., was raising an error when autocompleating functions defined in the console because their file wasnt found (which is correct in this case). --- release/scripts/modules/console/complete_calltip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/modules/console/complete_calltip.py b/release/scripts/modules/console/complete_calltip.py index c4687b4f10b..87fac9f4c07 100644 --- a/release/scripts/modules/console/complete_calltip.py +++ b/release/scripts/modules/console/complete_calltip.py @@ -124,7 +124,7 @@ def get_argspec(func, strip_self=True, doc=None, source=None): if source is None: try: source = inspect.getsource(func) - except TypeError: + except (TypeError, IOError): source = '' if source: match = re.search(DEF_SOURCE % func_name, source, RE_FLAG) From 18c82ce390f017baff8fd3020a189512e980c7a9 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 14 Jul 2010 16:38:09 +0000 Subject: [PATCH 04/51] Make SConstruct look in build_files/scons/tools and import from there, so no more 'import tools.Blender'. This fixes problem after change to this new location, but with .pyc files still lingering in old tools/ directory that still got imported due to syspath form. --- SConstruct | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/SConstruct b/SConstruct index 09ada7d7f70..b11df1b4c67 100644 --- a/SConstruct +++ b/SConstruct @@ -47,19 +47,18 @@ import re from tempfile import mkdtemp # needed for importing tools -sys.path.append(os.path.join(".", "build_files", "scons")) +sys.path.append(os.path.join(".", "build_files", "scons", "tools")) -import tools.Blender -import tools.btools -import tools.bcolors +import Blender +import btools +import bcolors EnsureSConsVersion(1,0,0) -BlenderEnvironment = tools.Blender.BlenderEnvironment -btools = tools.btools -B = tools.Blender +BlenderEnvironment = Blender.BlenderEnvironment +B = Blender -VERSION = tools.btools.VERSION # This is used in creating the local config directories +VERSION = btools.VERSION # This is used in creating the local config directories ### globals ### platform = sys.platform From fe958e647fe8caea6f764c4ab7192b95ec3d2a07 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Wed, 14 Jul 2010 17:27:56 +0000 Subject: [PATCH 05/51] SVN maintenance. --- source/blender/editors/sculpt_paint/sculpt_undo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 303a7686a96..e4121c9c76a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -1,5 +1,5 @@ /* - * $Id: sculpt.c 29425 2010-06-12 15:05:19Z jwilkins $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * From 8e3a9634a3dd939225d1424e0fd97b3d45746503 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2010 17:47:58 +0000 Subject: [PATCH 06/51] Change to text3d: When back or front is enabled, the bevel rim on the other side is not created anymore, just as the back/front filling faces are not created when disabled. when both are off the behavior is unchanged. This is needed when rendering alpha text so its possible to have a single layer of faces but use the bevel option to make text thicker. adding a rim on the back when back is disabled also doesnt make much sense IMHO. minor python edits too. --- doc/blender.1.py | 2 +- release/scripts/op/console_python.py | 2 +- source/blender/blenkernel/intern/curve.c | 99 ++++++++++--------- .../blender/python/doc/examples/bpy.data.py | 3 +- 4 files changed, 56 insertions(+), 50 deletions(-) diff --git a/doc/blender.1.py b/doc/blender.1.py index 576b58758cd..05b491cf21e 100644 --- a/doc/blender.1.py +++ b/doc/blender.1.py @@ -53,7 +53,7 @@ blender_version = blender_version.split("Build")[0] date_string = datetime.date.fromtimestamp(time.time()).strftime("%B %d, %Y") -filepath = __file__.replace(".py", "") +filepath = os.path.splitext(__file__)[0] + ".1" file = open(filepath, "w") diff --git a/release/scripts/op/console_python.py b/release/scripts/op/console_python.py index 83a3130f80e..d3a90cb7acc 100644 --- a/release/scripts/op/console_python.py +++ b/release/scripts/op/console_python.py @@ -68,7 +68,7 @@ def get_console(console_id): stderr = io.StringIO() else: namespace = {'__builtins__': __builtins__, 'bpy': bpy} - console = InteractiveConsole(namespace) + console = InteractiveConsole(locals=namespace, filename="") import io stdout = io.StringIO() diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 2e645592229..aa7b44aecda 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1318,30 +1318,33 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) short dnr; /* bevel now in three parts, for proper vertex normals */ - /* part 1 */ - dnr= nr= 2+ cu->bevresol; - if( (cu->flag & (CU_FRONT|CU_BACK))==0) - nr= 3+ 2*cu->bevresol; - - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p1"); - dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p1"); - BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->parts= 1; - dl->flag= DL_BACK_CURVE; - dl->nr= nr; + /* part 1, back */ - /* half a circle */ - fp= dl->verts; - dangle= (0.5*M_PI/(dnr-1)); - angle= -(nr-1)*dangle; - - for(a=0; aext2)); - fp[2]= (float)(sin(angle)*(cu->ext2)) - cu->ext1; - angle+= dangle; - fp+= 3; + if((cu->flag & CU_BACK) || !(cu->flag & CU_FRONT)) { + dnr= nr= 2+ cu->bevresol; + if( (cu->flag & (CU_FRONT|CU_BACK))==0) + nr= 3+ 2*cu->bevresol; + + dl= MEM_callocN(sizeof(DispList), "makebevelcurve p1"); + dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p1"); + BLI_addtail(disp, dl); + dl->type= DL_SEGM; + dl->parts= 1; + dl->flag= DL_BACK_CURVE; + dl->nr= nr; + + /* half a circle */ + fp= dl->verts; + dangle= (0.5*M_PI/(dnr-1)); + angle= -(nr-1)*dangle; + + for(a=0; aext2)); + fp[2]= (float)(sin(angle)*(cu->ext2)) - cu->ext1; + angle+= dangle; + fp+= 3; + } } /* part 2, sidefaces */ @@ -1374,30 +1377,32 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) } } - /* part 3 */ - dnr= nr= 2+ cu->bevresol; - if( (cu->flag & (CU_FRONT|CU_BACK))==0) - nr= 3+ 2*cu->bevresol; - - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p3"); - dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p3"); - BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->flag= DL_FRONT_CURVE; - dl->parts= 1; - dl->nr= nr; - - /* half a circle */ - fp= dl->verts; - angle= 0.0; - dangle= (0.5*M_PI/(dnr-1)); - - for(a=0; aext2)); - fp[2]= (float)(sin(angle)*(cu->ext2)) + cu->ext1; - angle+= dangle; - fp+= 3; + /* part 3, front */ + if((cu->flag & CU_FRONT) || !(cu->flag & CU_BACK)) { + dnr= nr= 2+ cu->bevresol; + if( (cu->flag & (CU_FRONT|CU_BACK))==0) + nr= 3+ 2*cu->bevresol; + + dl= MEM_callocN(sizeof(DispList), "makebevelcurve p3"); + dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p3"); + BLI_addtail(disp, dl); + dl->type= DL_SEGM; + dl->flag= DL_FRONT_CURVE; + dl->parts= 1; + dl->nr= nr; + + /* half a circle */ + fp= dl->verts; + angle= 0.0; + dangle= (0.5*M_PI/(dnr-1)); + + for(a=0; aext2)); + fp[2]= (float)(sin(angle)*(cu->ext2)) + cu->ext1; + angle+= dangle; + fp+= 3; + } } } } diff --git a/source/blender/python/doc/examples/bpy.data.py b/source/blender/python/doc/examples/bpy.data.py index 0c2a463c01b..fc1145a523f 100644 --- a/source/blender/python/doc/examples/bpy.data.py +++ b/source/blender/python/doc/examples/bpy.data.py @@ -18,7 +18,8 @@ if "Cube" in bpy.data.meshes: # write images into a file next to the blend -file = open(bpy.data.filepath.replace(".blend", ".txt"), 'w') +import os +file = open(os.path.splitext(bpy.data.filepath)[0] + ".txt", 'w') for image in bpy.data.images: file.write("%s %dx%d\n" % (image.filepath, image.size[0], image.size[1])) From a6a646cf5bc18848ea7d51cbe9e88575999bc831 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Wed, 14 Jul 2010 18:19:34 +0000 Subject: [PATCH 07/51] Scons/darwin (OSX): blender.app package is now created correctly in the install folder --- build_files/scons/tools/Blender.py | 36 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 1195b00b39d..7f5ce4767e3 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -498,7 +498,9 @@ def AppIt(target=None, source=None, env=None): builddir, b = os.path.split(a) libdir = env['LCGDIR'][1:] osxarch = env['MACOSX_ARCHITECTURE'] + installdir = env['BF_INSTALLDIR'] print("compiled architecture: %s"%(osxarch)) + print("Installing to %s"%(installdir)) if libdir == '../lib/darwin-9.x.universal': python_zip = 'python_' + osxarch + '.zip' # set specific python_arch.zip else: @@ -513,45 +515,45 @@ def AppIt(target=None, source=None, env=None): sourcedir = bldroot + '/source/darwin/%s.app'%binary sourceinfo = bldroot + "/source/darwin/%s.app/Contents/Info.plist"%binary - targetinfo = builddir +'/' + "%s.app/Contents/Info.plist"%binary - cmd = builddir + '/' +'%s.app'%binary + targetinfo = installdir +'/' + "%s.app/Contents/Info.plist"%binary + cmd = installdir + '/' +'%s.app'%binary if os.path.isdir(cmd): shutil.rmtree(cmd) shutil.copytree(sourcedir, cmd) cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo) commands.getoutput(cmd) - cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s'%(builddir, binary,builddir, binary, binary) + cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s'%(builddir, binary,installdir, binary, binary) commands.getoutput(cmd) - cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/'%(builddir, binary, VERSION) + cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/'%(installdir, binary, VERSION) # print cmd commands.getoutput(cmd) - cmd = builddir + '/%s.app/Contents/MacOS/%s'%(binary,VERSION) + cmd = installdir + '/%s.app/Contents/MacOS/%s'%(binary,VERSION) shutil.copy(bldroot + '/bin/.blender/.bfont.ttf', cmd) shutil.copy(bldroot + '/bin/.blender/.Blanguages', cmd) - cmd = 'cp -R %s/bin/%s/locale %s/%s.app/Contents/Resources/'%(bldroot,VERSION,builddir,binary) + cmd = 'cp -R %s/bin/%s/locale %s/%s.app/Contents/Resources/'%(bldroot,VERSION,installdir,binary) commands.getoutput(cmd) - cmd = 'cp -R %s/bin/%s/locale %s/%s.app/Contents/MacOS/%s/'%(bldroot,VERSION,builddir,binary,VERSION) + cmd = 'cp -R %s/bin/%s/locale %s/%s.app/Contents/MacOS/%s/'%(bldroot,VERSION,installdir,binary,VERSION) commands.getoutput(cmd) - cmd = 'cp %s/bin/%s/.Blanguages %s/%s.app/Contents/Resources/'%(bldroot,VERSION,builddir,binary) + cmd = 'cp %s/bin/%s/.Blanguages %s/%s.app/Contents/Resources/'%(bldroot,VERSION,installdir,binary) commands.getoutput(cmd) - cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/python/'%(builddir,binary, VERSION) + cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/python/'%(installdir,binary, VERSION) commands.getoutput(cmd) - cmd = 'unzip -q %s/release/%s -d %s/%s.app/Contents/MacOS/%s/python/'%(libdir,python_zip,builddir,binary,VERSION) + cmd = 'unzip -q %s/release/%s -d %s/%s.app/Contents/MacOS/%s/python/'%(libdir,python_zip,installdir,binary,VERSION) commands.getoutput(cmd) - cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/%s/'%(bldroot,builddir,binary,VERSION) + cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/%s/'%(bldroot,installdir,binary,VERSION) commands.getoutput(cmd) - cmd = 'cp -R %s/release/ui %s/%s.app/Contents/MacOS/%s/'%(bldroot,builddir,binary,VERSION) + cmd = 'cp -R %s/release/ui %s/%s.app/Contents/MacOS/%s/'%(bldroot,installdir,binary,VERSION) commands.getoutput(cmd) - cmd = 'cp -R %s/release/io %s/%s.app/Contents/MacOS/%s/'%(bldroot,builddir,binary,VERSION) + cmd = 'cp -R %s/release/io %s/%s.app/Contents/MacOS/%s/'%(bldroot,installdir,binary,VERSION) commands.getoutput(cmd) - cmd = 'chmod +x %s/%s.app/Contents/MacOS/%s'%(builddir,binary, binary) + cmd = 'chmod +x %s/%s.app/Contents/MacOS/%s'%(installdir,binary, binary) commands.getoutput(cmd) - cmd = 'find %s/%s.app -name .svn -prune -exec rm -rf {} \;'%(builddir, binary) + cmd = 'find %s/%s.app -name .svn -prune -exec rm -rf {} \;'%(installdir, binary) commands.getoutput(cmd) - cmd = 'find %s/%s.app -name .DS_Store -exec rm -rf {} \;'%(builddir, binary) + cmd = 'find %s/%s.app -name .DS_Store -exec rm -rf {} \;'%(installdir, binary) commands.getoutput(cmd) - cmd = 'find %s/%s.app -name __MACOSX -exec rm -rf {} \;'%(builddir, binary) + cmd = 'find %s/%s.app -name __MACOSX -exec rm -rf {} \;'%(installdir, binary) commands.getoutput(cmd) # extract copy system python, be sure to update other build systems From d4b04fac044b2fe0b6295f271a78c73d57ef0533 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2010 18:22:39 +0000 Subject: [PATCH 08/51] partial fix [#22846] GCC 4.4.1 support in Windows Still getting error: Warning: .drectve `/DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized --- CMakeLists.txt | 6 ++++++ source/blender/windowmanager/CMakeLists.txt | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c14bdd6b9e..70ec8952ce1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -628,6 +628,12 @@ IF(WIN32) SET(WITH_JACK OFF) ENDIF(WITH_JACK) + IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD) + SET(PLATFORM_CFLAGS " -msse -msse2 ${PLATFORM_CFLAGS}") + ADD_DEFINITIONS(-D__SSE__) + ADD_DEFINITIONS(-D__MMX__) + ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD) + ENDIF(MSVC) ENDIF(WIN32) diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 6db32f8bba9..ce7474af477 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -49,10 +49,6 @@ IF(WITH_INTERNATIONAL) ADD_DEFINITIONS(-DINTERNATIONAL) ENDIF(WITH_INTERNATIONAL) -IF(WITH_OPENEXR) - ADD_DEFINITIONS(-DWITH_OPENEXR) -ENDIF(WITH_OPENEXR) - IF(WITH_OPENCOLLADA) ADD_DEFINITIONS(-DWITH_COLLADA) ENDIF(WITH_OPENCOLLADA) From fd8380da934d5de1f9b7b84f18632ceaf8f21389 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Wed, 14 Jul 2010 20:04:02 +0000 Subject: [PATCH 09/51] * removed unneeded autosmooth_overlap, forgot to remove before merge * replaced omp critical sections, code either crashes or does not function correctly without them --- source/blender/editors/sculpt_paint/sculpt.c | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index eee0d520747..fcc4fbab9bd 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -229,8 +229,6 @@ typedef struct StrokeCache { int alt_smooth; float plane_trim_squared; - - float autosmooth_overlap; } StrokeCache; /* ===== OPENGL ===== @@ -580,7 +578,7 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache* cache) /* Return modified brush strength. Includes the direction of the brush, positive values pull vertices, negative values push. Uses tablet pressure and a special multiplier found experimentally to scale the strength factor. */ -static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather, float overlap) +static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) { Brush *brush = paint_brush(&sd->paint); @@ -590,6 +588,8 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather, float float pressure = brush->flag & BRUSH_ALPHA_PRESSURE ? cache->pressure : 1; float pen_flip = cache->pen_flip ? -1 : 1; float invert = cache->invert ? -1 : 1; + float accum = integrate_overlap(brush); + float overlap = (brush->flag & BRUSH_SPACE_ATTEN && brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100) ? 1.0f/accum : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter float flip = dir * invert * pen_flip; switch(brush->sculpt_tool){ @@ -912,7 +912,7 @@ static void calc_area_normal(Sculpt *sd, SculptSession *ss, float an[3], PBVHNod BLI_pbvh_vertex_iter_end; } - //#pragma omp critical + #pragma omp critical { add_v3_v3(an, private_an); add_v3_v3(out_flip, private_out_flip); @@ -1065,7 +1065,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no BLI_pbvh_node_get_grids(ss->pbvh, node, &grid_indices, &totgrid, NULL, &gridsize, &griddata, &gridadj); - //#pragma omp critical + #pragma omp critical { tmpgrid= MEM_mallocN(sizeof(float)*3*gridsize*gridsize, "tmpgrid"); tmprow= MEM_mallocN(sizeof(float)*3*gridsize, "tmprow"); @@ -1150,7 +1150,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no } } - //#pragma omp critical + #pragma omp critical { MEM_freeN(tmpgrid); MEM_freeN(tmprow); @@ -2403,10 +2403,10 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, Brush *brush) if (brush->sculpt_tool != SCULPT_TOOL_SMOOTH && brush->autosmooth_factor > 0) { if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) { - smooth(sd, ss, nodes, totnode, brush->autosmooth_factor*(1-ss->cache->pressure)*ss->cache->autosmooth_overlap); + smooth(sd, ss, nodes, totnode, brush->autosmooth_factor*(1-ss->cache->pressure)); } else { - smooth(sd, ss, nodes, totnode, brush->autosmooth_factor*ss->cache->autosmooth_overlap); + smooth(sd, ss, nodes, totnode, brush->autosmooth_factor); } } @@ -2580,12 +2580,8 @@ static void do_symmetrical_brush_actions(Sculpt *sd, SculptSession *ss) int i; float feather = calc_symmetry_feather(sd, ss->cache); - float accum = integrate_overlap(brush); - float overlap = (brush->flag & BRUSH_SPACE_ATTEN && brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100) ? 1.0f/accum : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter - ss->cache->autosmooth_overlap = overlap; - - cache->bstrength= brush_strength(sd, cache, feather, overlap); + cache->bstrength= brush_strength(sd, cache, feather); cache->symmetry= symm; From 7de6a8e1aceaa109cd4c4f9274b25303c7c8a2ba Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Wed, 14 Jul 2010 20:08:30 +0000 Subject: [PATCH 10/51] * Accidentally bumped file subversion after sculpt merge. Perhaps this should be done, but not without permission. My comment even said not to merge it :) --- source/blender/blenkernel/BKE_blender.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 5936805765d..baec6ecfe6a 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -45,7 +45,7 @@ struct Scene; struct Main; #define BLENDER_VERSION 252 -#define BLENDER_SUBVERSION 6 // XXX: this shouldn't be merged with trunk, this is so Sculpt branch can detect old files +#define BLENDER_SUBVERSION 5 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 From e25c0445f51122af4de9715946c9d5b6fd51d21d Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Wed, 14 Jul 2010 20:16:04 +0000 Subject: [PATCH 11/51] * new settings for brushes in do_versions had wrong subversionfile --- source/blender/blenloader/intern/readfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 7b29ab2a666..ea05352a73c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11020,7 +11020,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) brush->rate = 0.1f; /* New Settings */ - if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 6)) { + if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) { brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space // spacing was originally in pixels, convert it to percentage for new version From eb4795be57b9f56f2b1679310b2bf1e092e2c70a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2010 20:19:53 +0000 Subject: [PATCH 12/51] mistake in recent commit, set all axis values. --- source/blender/editors/sculpt_paint/paint_stroke.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index e373a254c3e..7b8d7c4b7ef 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -243,8 +243,8 @@ static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc) } else { snap->brush_map_mode = -1; - snap->ofs[0]= snap->ofs[0]= snap->ofs[0]= -1; - snap->size[0]= snap->size[0]= snap->size[0]= -1; + snap->ofs[0]= snap->ofs[1]= snap->ofs[2]= -1; + snap->size[0]= snap->size[1]= snap->size[2]= -1; snap->rot = -1; } From 1bb789956d42dc3e4a222a28b95a956ff8c97742 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2010 20:26:46 +0000 Subject: [PATCH 13/51] =?UTF-8?q?CMake=20patch=20from=20Ralf=20H=C3=B6lzem?= =?UTF-8?q?er=20(cheleb)=20[#22849]=20Fix=20cmake=20install=20target=20on?= =?UTF-8?q?=20linux=20---=20from=20the=20tracker=20---=20This=20patch=20fi?= =?UTF-8?q?xes=20the=20install=20target=20for=20the=20linux=20platform.=20?= =?UTF-8?q?Since=20the=20new=20configuration=20path=20changes=20are=20in?= =?UTF-8?q?=20effect,=20files=20have=20to=20be=20installed=20in=20the=20co?= =?UTF-8?q?rrect=20places=20instead=20of=20just=20copying=20the=20local=20?= =?UTF-8?q?installation=20to=20$PREFIX/share/blender.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It also provides a new macro to determine the correct blender version values. Changes in this patch include: - the .desktop menu file is installed in $PREFIX/share/applications and points to the svg icon instead of a png one, which is also installed in $PREFIX/share/pixmaps - docs are installed in $PREFIX/share/doc/blender - scripts are installed in in $PREFIX/share/blender/x.xx/ - locales are installed in in $PREFIX/share/blender/x.xx/datafiles - a new cmake macro determines and sets the correct values for BLENDER_VERSION_MAJOR, BLENDER_VERSION_MINOR, BLENDER_SUBVERSION, BLENDER_VERSION, BLENDER_MINVERSION_MAJOR, BLENDER_MINVERSION_MINOR, BLENDER_MINSUBVERSION and BLENDER_MINVERSION by parsing source/blender/blenkernel/BKE_blender.h and calculating major/minor values. This replaces the hardcoded value in the top CMakeLists file and is used by all platforms. --- CMakeLists.txt | 6 ++---- build_files/cmake/macros.cmake | 33 +++++++++++++++++++++++++++++ release/freedesktop/blender.desktop | 2 +- source/creator/CMakeLists.txt | 28 +++++++++++++++++++++--- 4 files changed, 61 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70ec8952ce1..bec1353a8cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,10 +55,6 @@ PROJECT(Blender) SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) -# Note! - Could create this from the blender version string -# ...but thats quite involved, make sure this matches the blender version. -SET(BLENDER_VERSION 2.5) - #----------------------------------------------------------------------------- # Load some macros. INCLUDE(build_files/cmake/macros.cmake) @@ -66,6 +62,8 @@ INCLUDE(build_files/cmake/macros.cmake) #----------------------------------------------------------------------------- # Set default config options +GET_BLENDER_VERSION() + # Blender internal features OPTION(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON) OPTION(WITH_LCMS "Enable color correction with lcms" OFF) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index aec86f7467a..84e6b788dc0 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -198,3 +198,36 @@ MACRO(TEST_SSE_SUPPORT) SUPPORT_SSE_BUILD) ENDMACRO(TEST_SSE_SUPPORT) +MACRO(GET_BLENDER_VERSION) + FILE(READ ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender.h CONTENT) + STRING(REGEX REPLACE "\n" ";" CONTENT "${CONTENT}") + STRING(REGEX REPLACE "\t" ";" CONTENT "${CONTENT}") + STRING(REGEX REPLACE " " ";" CONTENT "${CONTENT}") + + FOREACH(ITEM ${CONTENT}) + IF(LASTITEM MATCHES "BLENDER_VERSION") + MATH(EXPR BLENDER_VERSION_MAJOR "${ITEM} / 100") + MATH(EXPR BLENDER_VERSION_MINOR "${ITEM} % 100") + SET(BLENDER_VERSION "${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}") + ENDIF(LASTITEM MATCHES "BLENDER_VERSION") + + IF(LASTITEM MATCHES "BLENDER_SUBVERSION") + SET(BLENDER_SUBVERSION ${ITEM}) + ENDIF(LASTITEM MATCHES "BLENDER_SUBVERSION") + + IF(LASTITEM MATCHES "BLENDER_MINVERSION") + MATH(EXPR BLENDER_MINVERSION_MAJOR "${ITEM} / 100") + MATH(EXPR BLENDER_MINVERSION_MINOR "${ITEM} % 100") + SET(BLENDER_MINVERSION "${BLENDER_MINVERSION_MAJOR}.${BLENDER_MINVERSION_MINOR}") + ENDIF(LASTITEM MATCHES "BLENDER_MINVERSION") + + IF(LASTITEM MATCHES "BLENDER_MINSUBVERSION") + SET(BLENDER_MINSUBVERSION ${ITEM}) + ENDIF(LASTITEM MATCHES "BLENDER_MINSUBVERSION") + + SET(LASTITEM ${ITEM}) + ENDFOREACH(ITEM ${CONTENT}) + + MESSAGE(STATUS "Version major: ${BLENDER_VERSION_MAJOR}, Version minor: ${BLENDER_VERSION_MINOR}, Subversion: ${BLENDER_SUBVERSION}, Version: ${BLENDER_VERSION}") + MESSAGE(STATUS "Minversion major: ${BLENDER_MINVERSION_MAJOR}, Minversion minor: ${BLENDER_MINVERSION_MINOR}, MinSubversion: ${BLENDER_MINSUBVERSION}, Minversion: ${BLENDER_MINVERSION}") +ENDMACRO(GET_BLENDER_VERSION) diff --git a/release/freedesktop/blender.desktop b/release/freedesktop/blender.desktop index 39e0e3afe8e..1069958f6f1 100644 --- a/release/freedesktop/blender.desktop +++ b/release/freedesktop/blender.desktop @@ -3,7 +3,7 @@ Encoding=UTF-8 Name=Blender Comment=3D modeling, animation, rendering and post-production Exec=blender -Icon=blender.png +Icon=blender.svg Terminal=false Type=Application Categories=Graphics;3DGraphics; diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 36fd67c85c6..e9e6c982fde 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -192,9 +192,31 @@ IF(WITH_INSTALL) ENDIF(WITH_GAMEENGINE AND WITH_PLAYER) INSTALL( - DIRECTORY ${TARGETDIR}/.blender/ - DESTINATION ${BLENDERPATH} - ) + FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications + ) + INSTALL( + FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/blender.svg + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps + ) + INSTALL( + DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/ + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender + PATTERN ".svn" EXCLUDE + ) + INSTALL( + DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts/ + DESTINATION ${BLENDERPATH}/scripts + PATTERN ".svn" EXCLUDE + ) + IF(WITH_INTERNATIONAL) + INSTALL( + DIRECTORY ${CMAKE_SOURCE_DIR}/bin/.blender/locale/ + DESTINATION ${BLENDERPATH}/datafiles/locale + PATTERN ".svn" EXCLUDE + ) + ENDIF(WITH_INTERNATIONAL) + # end "make install" ENDIF(UNIX AND NOT APPLE) From 64875e9fda7bf0c78a535e9ea354c37d8f113019 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2010 20:31:11 +0000 Subject: [PATCH 14/51] - change blend thumbnail loading function not to use goto's - fix for some warnings --- .../editors/interface/interface_templates.c | 2 +- source/blender/imbuf/intern/thumbs_blend.c | 125 +++++++++++------- .../windowmanager/intern/wm_operators.c | 4 +- 3 files changed, 77 insertions(+), 54 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index cbe10496a72..f951def739f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -197,7 +197,7 @@ static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSea if (RNA_function_call(C, &reports, &ptr, func, &parms) == 0) { int* ret; - RNA_parameter_get_lookup(&parms, "ret", &ret); + RNA_parameter_get_lookup(&parms, "ret", (void **)&ret); if (!(*ret)) { RNA_parameter_list_free(&parms); diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c index c5c853f0c93..2b55e87546a 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.c @@ -37,54 +37,60 @@ /* extracts the thumbnail from between the 'REND' and the 'GLOB' * chunks of the header, dont use typical blend loader because its too slow */ -ImBuf *IMB_loadblend_thumb(const char *path) + +static ImBuf *loadblend_thumb(gzFile gzfile) { char buf[8]; int code= 0; char endian, pointer_size; char endian_switch; int len, im_len, x, y; - int *rect= NULL; + ImBuf *img= NULL; - gzFile gzfile; - - ImBuf *img; - - /* not necessarily a gzip */ - gzfile = gzopen(path, "rb"); - if (NULL == gzfile ) { - return NULL; - } - /* read the blend file header */ - if(gzread(gzfile, buf, 8) != 8) goto thumb_error; - if(strncmp(buf, "BLENDER", 7)) goto thumb_error; - - if(buf[7]=='-') pointer_size= 8; - else if(buf[7]=='_') pointer_size= 4; - else goto thumb_error; - + if(gzread(gzfile, buf, 8) != 8) + return NULL; + if(strncmp(buf, "BLENDER", 7)) + return NULL; + + if(buf[7]=='-') + pointer_size= 8; + else if(buf[7]=='_') + pointer_size= 4; + else + return NULL; + /* read the next 4 bytes, only need the first char, ignore the version */ /* endian and vertsion (ignored) */ - if(gzread(gzfile, buf, 4) != 4) goto thumb_error; - - if(buf[0]=='V') endian= B_ENDIAN; /* big: PPC */ - else if(buf[0]=='v') endian= L_ENDIAN; /* little: x86 */ - else goto thumb_error; + if(gzread(gzfile, buf, 4) != 4) + return NULL; + + if(buf[0]=='V') + endian= B_ENDIAN; /* big: PPC */ + else if(buf[0]=='v') + endian= L_ENDIAN; /* little: x86 */ + else + return NULL; while(gzread(gzfile, &code, sizeof(int)) == sizeof(int)) { endian_switch = ((ENDIAN_ORDER != endian)) ? 1 : 0; - - if(gzread(gzfile, buf, sizeof(int)) != sizeof(int)) goto thumb_error; + + if(gzread(gzfile, buf, sizeof(int)) != sizeof(int)) + return NULL; + len = *( (int *)((void *)buf) ); - if(endian_switch) SWITCH_INT(len); - + + if(endian_switch) + SWITCH_INT(len); + /* finally read the rest of the bhead struct, pointer and 2 ints */ - if(gzread(gzfile, buf, pointer_size) != pointer_size) goto thumb_error; - if(gzread(gzfile, buf, sizeof(int) * 2) != sizeof(int) * 2) goto thumb_error; + if(gzread(gzfile, buf, pointer_size) != pointer_size) + return NULL; + if(gzread(gzfile, buf, sizeof(int) * 2) != sizeof(int) * 2) + return NULL; + /* we dont actually care whats in the bhead */ - if (code==REND) { gzseek(gzfile, len, SEEK_CUR); /* skip to the next */ } @@ -92,40 +98,57 @@ ImBuf *IMB_loadblend_thumb(const char *path) break; } } - + /* using 'TEST' since new names segfault when loading in old blenders */ - if(code != TEST) goto thumb_error; - - if(gzread(gzfile, &x, sizeof(int)) != sizeof(int)) goto thumb_error; - if(gzread(gzfile, &y, sizeof(int)) != sizeof(int)) goto thumb_error; + if(code != TEST) + return NULL; + + if(gzread(gzfile, &x, sizeof(int)) != sizeof(int)) + return NULL; + if(gzread(gzfile, &y, sizeof(int)) != sizeof(int)) + return NULL; + len -= sizeof(int) * 2; - if(endian_switch) { SWITCH_INT(x); SWITCH_INT(y); } + if(endian_switch) { + SWITCH_INT(x); + SWITCH_INT(y); + } /* inconsistant image size, quit early */ im_len = x * y * sizeof(int); - if(im_len != len) goto thumb_error; + if(im_len != len) + return NULL; /* finally malloc and read the data */ - rect= MEM_mallocN(len, "imb_loadblend_thumb"); + img= IMB_allocImBuf(x, y, 32, IB_rect, 0); - if(gzread(gzfile, rect, len) != len) goto thumb_error; + if(gzread(gzfile, img->rect, len) != len) { + IMB_freeImBuf(img); + img= NULL; + } - /* read ok! */ - gzclose(gzfile); + return img; +} - img = IMB_allocImBuf(x, y, 32, IB_rect | IB_metadata, 0); +ImBuf *IMB_loadblend_thumb(const char *path) +{ + gzFile gzfile; - memcpy(img->rect, rect, im_len); + /* not necessarily a gzip */ + gzfile = gzopen(path, "rb"); - MEM_freeN(rect); - - return img; + if (NULL == gzfile ) { + return NULL; + } + else { + ImBuf *img= loadblend_thumb(gzfile); -thumb_error: - gzclose(gzfile); - if(rect) MEM_freeN(rect); - return NULL; + /* read ok! */ + gzclose(gzfile); + + return img; + } } /* add a fake passepartout overlay to a byte buffer, use for blend file thumbnails */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 78e1c7d87a3..09c11bcfda5 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2611,7 +2611,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) ViewContext vc; - int hit = 0; + // int hit = 0; int flip; int sign; @@ -2779,7 +2779,7 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { wmRadialControl *rc = MEM_callocN(sizeof(wmRadialControl), "radial control"); - wmWindow *win = CTX_wm_window(C); + // wmWindow *win = CTX_wm_window(C); int mode = RNA_int_get(op->ptr, "mode"); float initial_value = RNA_float_get(op->ptr, "initial_value"); //float initial_size = RNA_float_get(op->ptr, "initial_size"); From dd3f9cff91be36c48d24a3d6124727ea83234a1c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2010 20:52:04 +0000 Subject: [PATCH 15/51] patch from Goran Milovanovic for the BGE python api. camera.ortho_scale (use when in ortho mode only) (own previous commit incorrectly removed thumb metadata from new imbuf) --- source/blender/imbuf/intern/thumbs_blend.c | 2 +- source/gameengine/Ketsji/KX_Camera.cpp | 21 +++++++++++++++++++++ source/gameengine/Ketsji/KX_Camera.h | 2 ++ source/gameengine/PyDoc/bge.types.rst | 6 ++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c index 2b55e87546a..7f1c903e9de 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.c @@ -121,7 +121,7 @@ static ImBuf *loadblend_thumb(gzFile gzfile) return NULL; /* finally malloc and read the data */ - img= IMB_allocImBuf(x, y, 32, IB_rect, 0); + img= IMB_allocImBuf(x, y, 32, IB_rect | IB_metadata, 0); if(gzread(gzfile, img->rect, len) != len) { IMB_freeImBuf(img); diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index bba3b2219ed..82786456589 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -499,6 +499,7 @@ PyAttributeDef KX_Camera::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("perspective", KX_Camera, pyattr_get_perspective, pyattr_set_perspective), KX_PYATTRIBUTE_RW_FUNCTION("lens", KX_Camera, pyattr_get_lens, pyattr_set_lens), + KX_PYATTRIBUTE_RW_FUNCTION("ortho_scale", KX_Camera, pyattr_get_ortho_scale, pyattr_set_ortho_scale), KX_PYATTRIBUTE_RW_FUNCTION("near", KX_Camera, pyattr_get_near, pyattr_set_near), KX_PYATTRIBUTE_RW_FUNCTION("far", KX_Camera, pyattr_get_far, pyattr_set_far), @@ -728,6 +729,26 @@ int KX_Camera::pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, return PY_SET_ATTR_SUCCESS; } +PyObject* KX_Camera::pyattr_get_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_Camera* self= static_cast(self_v); + return PyFloat_FromDouble(self->m_camdata.m_scale); +} + +int KX_Camera::pyattr_set_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_Camera* self= static_cast(self_v); + float param = PyFloat_AsDouble(value); + if (param == -1) { + PyErr_SetString(PyExc_AttributeError, "camera.scale = float: KX_Camera, expected a float greater then zero"); + return PY_SET_ATTR_FAIL; + } + + self->m_camdata.m_scale= param; + self->m_set_projection_matrix = false; + return PY_SET_ATTR_SUCCESS; +} + PyObject* KX_Camera::pyattr_get_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_Camera* self= static_cast(self_v); diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index e209f0461b9..406ee1d0764 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -289,6 +289,8 @@ public: static PyObject* pyattr_get_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + static PyObject* pyattr_get_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/PyDoc/bge.types.rst b/source/gameengine/PyDoc/bge.types.rst index 935d3e7e00e..e0ace6ad85b 100644 --- a/source/gameengine/PyDoc/bge.types.rst +++ b/source/gameengine/PyDoc/bge.types.rst @@ -4185,6 +4185,12 @@ Game Engine bge.types Module :type: float + .. attribute:: ortho_scale + + The camera's view scale when in orthographic mode. + + :type: float + .. attribute:: near The camera's near clip distance. From ad12866e1947f6723e0b6111f67cdabdbed33538 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 14 Jul 2010 20:52:23 +0000 Subject: [PATCH 16/51] To be actually useful, also report the filename when write operation fails. --- source/blender/blenloader/intern/writefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 82d46a84bdd..ed471117bdd 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2481,7 +2481,7 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report file = open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666); if(file == -1) { - BKE_reportf(reports, RPT_ERROR, "Can't open file for writing: %s.", strerror(errno)); + BKE_reportf(reports, RPT_ERROR, "Can't open file %s for writing: %s.", tempname, strerror(errno)); return 0; } From aa15c8a5bfdb11bccd9927f9bb77808d55c4356e Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 14 Jul 2010 22:16:56 +0000 Subject: [PATCH 17/51] S_ISDIR and S_ISREG were checking completely wrong for directory and regular file bits. --- source/blender/blenlib/BLI_winstuff.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h index 957fdb2b017..e8689895735 100644 --- a/source/blender/blenlib/BLI_winstuff.h +++ b/source/blender/blenlib/BLI_winstuff.h @@ -74,10 +74,10 @@ extern "C" { #define MAXPATHLEN MAX_PATH #ifndef S_ISREG -#define S_ISREG(x) ((x&S_IFMT) == S_IFREG) +#define S_ISREG(x) (((x)&_S_IFREG) == _S_IFREG) #endif #ifndef S_ISDIR -#define S_ISDIR(x) ((x&S_IFMT) == S_IFDIR) +#define S_ISDIR(x) (((x)&_S_IFDIR) == _S_IFDIR) #endif /* defines for using ISO C++ conformant names */ From 0980f2555f565bfac0958483da76b7e75e8921e5 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 14 Jul 2010 23:39:23 +0000 Subject: [PATCH 18/51] * Use same BLI_exist() on all platforms. * remove extra sys/types.h include. --- source/blender/blenlib/intern/fileops.c | 16 ++++++---------- source/blender/blenlib/intern/storage.c | 9 +++++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index a543f4623f1..7a24d9b36b1 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -205,6 +205,10 @@ int BLI_touch(const char *file) return 0; } +int BLI_exists(char *file) { + return BLI_exist(file); +} + #ifdef WIN32 static char str[MAXPATHLEN+12]; @@ -282,10 +286,6 @@ int BLI_link(char *file, char *to) { return 1; } -int BLI_exists(char *file) { - return (GetFileAttributes(file) != 0xFFFFFFFF); -} - void BLI_recurdir_fileops(char *dirname) { char *lslash; char tmp[MAXPATHLEN]; @@ -326,10 +326,10 @@ int BLI_rename(char *from, char *to) { return rename(from, to); } -#else /* The sane UNIX world */ +#else /* The weirdo UNIX world */ /* - * but the sane UNIX world is tied to the interface, and the system + * but the UNIX world is tied to the interface, and the system * timer, and... We implement a callback mechanism. The system will * have to initialise the callback before the functions will work! * */ @@ -374,10 +374,6 @@ int BLI_link(char *file, char *to) { return system(str); } -int BLI_exists(char *file) { - return BLI_exist(file); -} - void BLI_recurdir_fileops(char *dirname) { char *lslash; char tmp[MAXPATHLEN]; diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 51d5f0354f9..3315e9645d4 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -76,7 +76,6 @@ #endif #ifdef WIN32 -#include #include #include #include "BLI_winstuff.h" @@ -433,18 +432,20 @@ int BLI_filepathsize(const char *path) int BLI_exist(char *name) { - struct stat st; #ifdef WIN32 + struct _stat64i32 st; /* in Windows stat doesn't recognize dir ending on a slash To not break code where the ending slash is expected we don't mess with the argument name directly here - elubie */ char tmp[FILE_MAXDIR+FILE_MAXFILE]; - int len; + int len, res; BLI_strncpy(tmp, name, FILE_MAXDIR+FILE_MAXFILE); len = strlen(tmp); if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0'; - if (stat(tmp,&st)) return(0); + res = _stat(tmp, &st); + if (res == -1) return(0); #else + struct stat st; if (stat(name,&st)) return(0); #endif return(st.st_mode); From 4242baa704a516400a415f4f05b3e908cc41ea27 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 14 Jul 2010 23:51:21 +0000 Subject: [PATCH 19/51] Logic UI: Changing Controllers names to follow Sensors and actuators (back to have only the first latter capitalized) + change the controller state only when in expanded mode (show the number otherwise). Cosmetic commit, no structural/big code changes (patch by dfelinto). --- .../editors/space_logic/logic_window.c | 22 +++++++++---------- .../blender/makesrna/intern/rna_controller.c | 12 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 005ebfb5b88..c4a42d89758 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -644,17 +644,17 @@ static char *controller_name(int type) { switch (type) { case CONT_LOGIC_AND: - return "AND"; + return "And"; case CONT_LOGIC_OR: - return "OR"; + return "Or"; case CONT_LOGIC_NAND: - return "NAND"; + return "Nand"; case CONT_LOGIC_NOR: - return "NOR"; + return "Nor"; case CONT_LOGIC_XOR: - return "XOR"; + return "Xor"; case CONT_LOGIC_XNOR: - return "XNOR"; + return "Xnor"; case CONT_EXPRESSION: return "Expression"; case CONT_PYTHON: @@ -3537,7 +3537,8 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i uiLayout *box, *row, *subrow; bController *cont= (bController *)ptr->data; - char name[3]; //XXX provisorly for state number + char state[3]; + sprintf(state, "%d", RNA_int_get(ptr, "state")); box= uiLayoutBox(layout); row= uiLayoutRow(box, 0); @@ -3546,15 +3547,14 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i if(RNA_boolean_get(ptr, "expanded")) { uiItemR(row, ptr, "type", 0, "", 0); uiItemR(row, ptr, "name", 0, "", 0); + /* XXX provisory for Blender 2.50Beta */ + uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, state, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, "Set controller state index (from 1 to 30)"); } else { uiItemL(row, controller_name(cont->type), 0); uiItemL(row, cont->name, 0); + uiItemL(row, state, 0); } - /* XXX provisory for Blender 2.50Beta */ - sprintf(name, "%d", RNA_int_get(ptr, "state")); - uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, name, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, "Set controller state index (from 1 to 30)"); - uiItemR(row, ptr, "priority", 0, "", 0); if(RNA_boolean_get(ptr, "expanded")==0) { diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index 6307c39be52..c66ce532351 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -32,12 +32,12 @@ #include "DNA_controller_types.h" EnumPropertyItem controller_type_items[] ={ - {CONT_LOGIC_AND, "LOGIC_AND", 0, "AND", "Logic And"}, - {CONT_LOGIC_OR, "LOGIC_OR", 0, "OR", "Logic Or"}, - {CONT_LOGIC_NAND, "LOGIC_NAND", 0, "NAND", "Logic Nand"}, - {CONT_LOGIC_NOR, "LOGIC_NOR", 0, "NOR", "Logic Nor"}, - {CONT_LOGIC_XOR, "LOGIC_XOR", 0, "XOR", "Logic Xor"}, - {CONT_LOGIC_XNOR, "LOGIC_XNOR", 0, "XNOR", "Logic Xnor"}, + {CONT_LOGIC_AND, "LOGIC_AND", 0, "And", "Logic And"}, + {CONT_LOGIC_OR, "LOGIC_OR", 0, "Or", "Logic Or"}, + {CONT_LOGIC_NAND, "LOGIC_NAND", 0, "Nand", "Logic Nand"}, + {CONT_LOGIC_NOR, "LOGIC_NOR", 0, "Nor", "Logic Nor"}, + {CONT_LOGIC_XOR, "LOGIC_XOR", 0, "Xor", "Logic Xor"}, + {CONT_LOGIC_XNOR, "LOGIC_XNOR", 0, "Xnor", "Logic Xnor"}, {CONT_EXPRESSION, "EXPRESSION", 0, "Expression", ""}, {CONT_PYTHON, "PYTHON", 0, "Python Script", ""}, {0, NULL, 0, NULL, NULL}}; From 7f083c45bee15f7540e2a35a725efe28fc962239 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Jul 2010 00:52:26 +0000 Subject: [PATCH 20/51] use dict comprehension where possible --- release/scripts/io/import_scene_3ds.py | 2 +- release/scripts/io/import_scene_obj.py | 4 ++-- release/scripts/modules/bpy_types.py | 2 +- release/scripts/op/uvcalc_follow_active.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/release/scripts/io/import_scene_3ds.py b/release/scripts/io/import_scene_3ds.py index 6502dee73f1..7b3004d4f52 100644 --- a/release/scripts/io/import_scene_3ds.py +++ b/release/scripts/io/import_scene_3ds.py @@ -360,7 +360,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH): vertMappingIndex = 0 vertsToUse = [i for i in range(len(myContextMesh_vertls)) if faceVertUsers[i]] - myVertMapping = dict( [ (ii, i) for i, ii in enumerate(vertsToUse) ] ) + myVertMapping = {ii: i for i, ii in enumerate(vertsToUse)} tempName= '%s_%s' % (contextObName, matName) # matName may be None. bmesh = bpy.data.meshes.new(tempName) diff --git a/release/scripts/io/import_scene_obj.py b/release/scripts/io/import_scene_obj.py index 942619c49ee..afe82410557 100644 --- a/release/scripts/io/import_scene_obj.py +++ b/release/scripts/io/import_scene_obj.py @@ -596,7 +596,7 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l if unique_smooth_groups: sharp_edges= {} - smooth_group_users= dict([ (context_smooth_group, {}) for context_smooth_group in list(unique_smooth_groups.keys()) ]) + smooth_group_users = {context_smooth_group: {} for context_smooth_group in list(unique_smooth_groups.keys())} context_smooth_group_old= -1 # Split fgons into tri's @@ -691,7 +691,7 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l # map the material names to an index - material_mapping= dict([(name, i) for i, name in enumerate(unique_materials)]) # enumerate over unique_materials keys() + material_mapping = {name: i for i, name in enumerate(unique_materials)} # enumerate over unique_materials keys() materials= [None] * len(unique_materials) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index b1c5429d4ba..9d6f5ce7b2f 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -444,7 +444,7 @@ class Mesh(bpy_types.ID): if not hasattr(edges, "pop"): edges = edges[:] - edge_dict = dict((ed.key, ed) for ed in self.edges if ed.selected) + edge_dict = {ed.key: ed for ed in self.edges if ed.selected} while edges: current_edge = edges.pop() diff --git a/release/scripts/op/uvcalc_follow_active.py b/release/scripts/op/uvcalc_follow_active.py index 81229f73461..61c149c8735 100644 --- a/release/scripts/op/uvcalc_follow_active.py +++ b/release/scripts/op/uvcalc_follow_active.py @@ -65,9 +65,9 @@ def extend(obj, operator, EXTEND_MODE): # vertex index is the key, uv is the value - uvs_vhash_source = dict([(vindex, uvs_source[i]) for i, vindex in enumerate(vidx_source)]) + uvs_vhash_source = {vindex: uvs_source[i] for i, vindex in enumerate(vidx_source)} - uvs_vhash_target = dict([(vindex, uvs_target[i]) for i, vindex in enumerate(vidx_target)]) + uvs_vhash_target = {vindex: uvs_target[i] for i, vindex in enumerate(vidx_target)} edge_idxs_source = face_edge_vs(vidx_source) edge_idxs_target = face_edge_vs(vidx_target) From 82b55d93919101ac7e6e02aaf1bf93753f42d77a Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 15 Jul 2010 03:49:32 +0000 Subject: [PATCH 21/51] Disabled mode-switching keys during 3D View orbit/zoom etc. in default key map. Still possible to re-enable via editing the modal keymap, but was getting a bit annoying in its current state. Can probably be implemented a bit better in the future with timers etc, but no time at the moment. --- source/blender/editors/space_view3d/view3d_edit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 9ac3d7cacdd..9a58536d029 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -490,9 +490,11 @@ void viewrotate_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, LEFTALTKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_AXIS_SNAP_ENABLE); WM_modalkeymap_add_item(keymap, LEFTALTKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_AXIS_SNAP_DISABLE); + /* disabled mode switching for now, can re-implement better, later on WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ZOOM); WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ZOOM); WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_MOVE); + */ /* assign map to operators */ WM_modalkeymap_assign(keymap, "VIEW3D_OT_rotate"); @@ -796,9 +798,11 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM); WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, VIEW_MODAL_CONFIRM); + /* disabled mode switching for now, can re-implement better, later on WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ZOOM); WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ZOOM); WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE); + */ /* assign map to operators */ WM_modalkeymap_assign(keymap, "VIEW3D_OT_move"); @@ -936,9 +940,11 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM); WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, VIEW_MODAL_CONFIRM); + /* disabled mode switching for now, can re-implement better, later on WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE); WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE); WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_MOVE); + */ /* assign map to operators */ WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom"); From a5aa3ff7958ffb5e4778e7f09fcbbfe7f0296f65 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Thu, 15 Jul 2010 05:53:11 +0000 Subject: [PATCH 22/51] * smooth wasn't working with strengths below .5 --- source/blender/editors/sculpt_paint/sculpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index fcc4fbab9bd..9577eb4eea2 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1169,7 +1169,7 @@ static void smooth(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, count = (int)(bstrength*max_iterations); last = max_iterations*(bstrength - count*fract); - for(iteration = 1; iteration <= count; ++iteration) { + for(iteration = 0; iteration <= count; ++iteration) { #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; nmultires) { From dcc1e6019df2f5655fa38aa9f6c8c98e2e57e4fa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Jul 2010 10:51:05 +0000 Subject: [PATCH 23/51] Fix: rename to .blend1 as last before writing, after creating blend thumbnail. --- source/blender/windowmanager/intern/wm_files.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 8a05e6c4916..deeb6ab154a 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -616,11 +616,12 @@ int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports) ED_object_exit_editmode(C, EM_DO_UNDO); ED_sculpt_force_update(C); - do_history(di, reports); - /* blend file thumbnail */ ibuf_thumb= blend_file_thumb(di, CTX_data_scene(C), &thumb); + /* rename to .blend1, do this as last before write */ + do_history(di, reports); + if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) { strcpy(G.sce, di); G.relbase_valid = 1; From 5daf9354d255bb40e832e7e0d48008e56158e0b4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Jul 2010 11:51:43 +0000 Subject: [PATCH 24/51] change some references to .B.blend, .Blog to new names --- release/scripts/modules/rna_info.py | 4 ++-- source/blender/blenlib/intern/path_util.c | 2 +- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/blenloader/intern/writefile.c | 2 +- source/blender/editors/interface/interface_style.c | 2 +- source/blender/editors/interface/resources.c | 4 ++-- source/blender/python/doc/sphinx_doc_gen.py | 7 +++---- source/blender/python/generic/bgl.c | 5 ++--- source/blender/windowmanager/intern/wm_files.c | 10 +++++----- source/blender/windowmanager/intern/wm_window.c | 2 +- source/creator/creator.c | 6 +++--- source/gameengine/Ketsji/KX_Camera.cpp | 2 +- 12 files changed, 23 insertions(+), 25 deletions(-) diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py index 3fd70fedd8c..71895a25446 100644 --- a/release/scripts/modules/rna_info.py +++ b/release/scripts/modules/rna_info.py @@ -631,8 +631,8 @@ if __name__ == "__main__": props = [(prop.identifier, prop) for prop in v.properties] for prop_id, prop in sorted(props): - if prop.type == 'boolean': - continue + # if prop.type == 'boolean': + # continue data += "%s.%s -> %s: %s%s %s\n" % (struct_id_str, prop.identifier, prop.identifier, prop.type, ", (read-only)" if prop.is_readonly else "", prop.description) if bpy.app.background: diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 423bf452a4d..092cca7de88 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -364,7 +364,7 @@ void BLI_path_rel(char *file, const char *relfile) if (strlen(relfile) > 2 && relfile[1] != ':') { char* ptemp; /* fix missing volume name in relative base, - can happen with old .Blog files */ + can happen with old recent-files.txt files */ get_default_root(temp); ptemp = &temp[2]; if (relfile[0] != '\\' && relfile[0] != '/') { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ea05352a73c..536f133c91b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -174,7 +174,7 @@ READ - read associated 'direct data' - link direct data (internal and to LibBlock) - read FileGlobal -- read USER data, only when indicated (file is ~/.B.blend or .B25.blend) +- read USER data, only when indicated (file is ~/X.XX/startup.blend) - free file - per Library (per Main) - read file diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index ed471117bdd..902f572b2f3 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -65,7 +65,7 @@ Any case: direct data is ALWAYS after the lib block - write TEST (128x128, blend file preview, optional) - write FileGlobal (some global vars) - write SDNA -- write USER if filename is ~/.B.blend +- write USER if filename is ~/X.XX/config/startup.blend */ diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index e3317e5598f..f12b8aeeca5 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -264,7 +264,7 @@ void UI_DrawString(float x, float y, char *str) /* ************** init exit ************************ */ -/* called on each .B.blend read */ +/* called on each startup.blend read */ /* reading without uifont will create one */ void uiStyleInit(void) { diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index bea8d3bd1f6..b5f2a59dedd 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -999,7 +999,7 @@ void init_userdef_do_versions(void) } if (U.savetime <= 0) { U.savetime = 1; -// XXX error(".B.blend is buggy, please consider removing it.\n"); +// XXX error("startup.blend is buggy, please consider removing it.\n"); } /* transform widget settings */ if(U.tw_hotspot==0) { @@ -1138,7 +1138,7 @@ void init_userdef_do_versions(void) } /* set defaults for 3D View rotating axis indicator */ - /* since size can't be set to 0, this indicates it's not saved in .B.blend */ + /* since size can't be set to 0, this indicates it's not saved in startup.blend */ if (U.rvisize == 0) { U.rvisize = 15; U.rvibright = 8; diff --git a/source/blender/python/doc/sphinx_doc_gen.py b/source/blender/python/doc/sphinx_doc_gen.py index 27524c66c36..04fdedd8c8f 100644 --- a/source/blender/python/doc/sphinx_doc_gen.py +++ b/source/blender/python/doc/sphinx_doc_gen.py @@ -553,10 +553,9 @@ def rna2sphinx(BASEPATH): fw(" %s\n\n" % struct.description) # properties sorted in alphabetical order - zip_props_ids = zip(struct.properties, [prop.identifier for prop in struct.properties]) - zip_props_ids = sorted(zip_props_ids, key=lambda p: p[1]) - sorted_struct_properties = [x[0] for x in zip_props_ids] - + sorted_struct_properties = struct.properties[:] + sorted_struct_properties.sort(key=lambda prop: prop.identifier) + for prop in sorted_struct_properties: type_descr = prop.get_type_description(class_fmt=":class:`%s`") # readonly properties use "data" directive, variables properties use "attribute" directive diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index ae19db28011..bb0b3a43186 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -27,9 +27,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -/* This file is the Blender.BGL part of opy_draw.c, from the old - * bpython/intern dir, with minor changes to adapt it to the new Python - * implementation. The BGL submodule "wraps" OpenGL functions and constants, +/* This file is the 'bgl' module. + * The BGL submodule "wraps" OpenGL functions and constants, * allowing script writers to make OpenGL calls in their Python scripts. */ #include "bgl.h" /*This must come first */ diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index deeb6ab154a..ff859ebe166 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -382,7 +382,7 @@ int WM_read_homefile(bContext *C, wmOperator *op) /* XXX */ G.save_over = 0; // start with save preference untitled.blend - G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in .B.blend... */ + G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in startup.blend... */ // mainwindow_set_filename_to_title(""); // empty string re-initializes title to "Blender" // refresh_interface_font(); @@ -418,7 +418,7 @@ void read_history(void) G.recent_files.first = G.recent_files.last = NULL; - /* read list of recent opend files from .Blog to memory */ + /* read list of recent opend files from recent-files.txt to memory */ for (l= lines, num= 0; l && (numnext) { line = l->link; if (line[0] && BLI_exists(line)) { @@ -452,7 +452,7 @@ static void write_history(void) BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_HISTORY_FILE); recent = G.recent_files.first; - /* refresh .Blog of recent opened files, when current file was changed */ + /* refresh recent-files.txt of recent opened files, when current file was changed */ if(!(recent) || (strcmp(recent->filepath, G.sce)!=0)) { fp= fopen(name, "w"); if (fp) { @@ -462,11 +462,11 @@ static void write_history(void) recent->filepath[0] = '\0'; strcpy(recent->filepath, G.sce); BLI_addhead(&(G.recent_files), recent); - /* write current file to .Blog */ + /* write current file to recent-files.txt */ fprintf(fp, "%s\n", recent->filepath); recent = recent->next; i=1; - /* write rest of recent opened files to .Blog */ + /* write rest of recent opened files to recent-files.txt */ while((ifilepath, G.sce)!=0) { diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 6d01620dae8..e4bb5b797d3 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -258,7 +258,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) } else { - /* this is set to 1 if you don't have .B.blend open */ + /* this is set to 1 if you don't have startup.blend open */ if(G.save_over) { char *str= MEM_mallocN(strlen(G.sce) + 16, "title"); diff --git a/source/creator/creator.c b/source/creator/creator.c index c3499a5788c..34322ea6b73 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -289,7 +289,7 @@ static int print_help(int argc, char **argv, void *data) printf ("\t\t\"blender --background test.blend --render-output /tmp --render-frame 1\" works as expected.\n\n"); printf ("\nEnvironment Variables:\n"); - printf (" $HOME\t\t\tStore files such as .blender/ .B.blend .Bfs .Blog here.\n"); + printf (" $HOME\t\t\tStore '.blender/' containing defaults, bookmarks and user scripts.\n"); printf (" $BLENDERPATH System directory to use for data files and scripts.\n"); printf (" For this build of blender the default $BLENDERPATH is...\n"); printf (" \"%s\"\n", blender_path); @@ -1101,7 +1101,7 @@ int main(int argc, char **argv) WM_init(C, argc, argv); /* this is properly initialized with user defs, but this is default */ - BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */ + BLI_where_is_temp( btempdir, 1 ); /* call after loading the startup.blend so we can read U.tempdir */ #ifndef DISABLE_SDL BLI_setenv("SDL_VIDEODRIVER", "dummy"); @@ -1119,7 +1119,7 @@ int main(int argc, char **argv) WM_init(C, argc, argv); - BLI_where_is_temp( btempdir, 0 ); /* call after loading the .B.blend so we can read U.tempdir */ + BLI_where_is_temp( btempdir, 0 ); /* call after loading the startup.blend so we can read U.tempdir */ } #ifndef DISABLE_PYTHON /** diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 82786456589..36b90411e1f 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -740,7 +740,7 @@ int KX_Camera::pyattr_set_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *at KX_Camera* self= static_cast(self_v); float param = PyFloat_AsDouble(value); if (param == -1) { - PyErr_SetString(PyExc_AttributeError, "camera.scale = float: KX_Camera, expected a float greater then zero"); + PyErr_SetString(PyExc_AttributeError, "camera.ortho_scale = float: KX_Camera, expected a float greater then zero"); return PY_SET_ATTR_FAIL; } From f5957e62378f1ae9fd08c9a14222b940aaab15d0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Jul 2010 13:32:20 +0000 Subject: [PATCH 25/51] own recent commit which added support for writing srgb float buffers broke writing char buffers as half EXR's. --- source/blender/imbuf/intern/openexr/openexr_api.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index a0969979817..9b68e0e45eb 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -267,6 +267,8 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags) if(ibuf->profile == IB_PROFILE_LINEAR_RGB) { for (int i = ibuf->y-1; i >= 0; i--) { + from= (unsigned char *)ibuf->rect + channels*i*width; + for (int j = ibuf->x; j > 0; j--) { to->r = (float)(from[0])/255.0; @@ -280,6 +282,8 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags) else { for (int i = ibuf->y-1; i >= 0; i--) { + from= (unsigned char *)ibuf->rect + channels*i*width; + for (int j = ibuf->x; j > 0; j--) { to->r = srgb_to_linearrgb((float)from[0] / 255.0); From df3da6ec4981de8a568f50ec5f70578ed06991f4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Jul 2010 13:34:14 +0000 Subject: [PATCH 26/51] Fix #22851: missing undo push for color picker, these only work if there is a button label or tooltip. --- .../editors/interface/interface_regions.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index f17a3371df1..2f19ab6698a 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1745,11 +1745,11 @@ static void circle_picker(uiBlock *block, PointerRNA *ptr, const char *propname) uiBut *bt; /* HS circle */ - bt= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, propname, 0, 0.0, 0.0, 0, 0, ""); + bt= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, propname, 0, 0.0, 0.0, 0, 0, "Color"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); /* value */ - bt= uiDefButR(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, propname, 0, 0.0, 0.0, UI_GRAD_V_ALT, 0, ""); + bt= uiDefButR(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, propname, 0, 0.0, 0.0, UI_GRAD_V_ALT, 0, "Value"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } @@ -1760,11 +1760,11 @@ static void square_picker(uiBlock *block, PointerRNA *ptr, const char *propname, int bartype = type + 3; /* HS square */ - bt= uiDefButR(block, HSVCUBE, 0, "", 0, PICKER_BAR+PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, propname, 0, 0.0, 0.0, type, 0, ""); + bt= uiDefButR(block, HSVCUBE, 0, "", 0, PICKER_BAR+PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, propname, 0, 0.0, 0.0, type, 0, "Color"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); /* value */ - bt= uiDefButR(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, propname, 0, 0.0, 0.0, bartype, 0, ""); + bt= uiDefButR(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, propname, 0, 0.0, 0.0, bartype, 0, "Value"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } @@ -1832,11 +1832,11 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR /* RGB values */ uiBlockBeginAlign(block); - bt= uiDefButR(block, NUMSLI, 0, "R ", 0, -60, butwidth, UI_UNIT_Y, ptr, propname, 0, 0.0, 0.0, 0, 3, ""); + bt= uiDefButR(block, NUMSLI, 0, "R ", 0, -60, butwidth, UI_UNIT_Y, ptr, propname, 0, 0.0, 0.0, 0, 3, "Red"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); - bt= uiDefButR(block, NUMSLI, 0, "G ", 0, -80, butwidth, UI_UNIT_Y, ptr, propname, 1, 0.0, 0.0, 0, 3, ""); + bt= uiDefButR(block, NUMSLI, 0, "G ", 0, -80, butwidth, UI_UNIT_Y, ptr, propname, 1, 0.0, 0.0, 0, 3, "Green"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); - bt= uiDefButR(block, NUMSLI, 0, "B ", 0, -100, butwidth, UI_UNIT_Y, ptr, propname, 2, 0.0, 0.0, 0, 3, ""); + bt= uiDefButR(block, NUMSLI, 0, "B ", 0, -100, butwidth, UI_UNIT_Y, ptr, propname, 2, 0.0, 0.0, 0, 3, "Blue"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); // could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", 0); @@ -1844,16 +1844,16 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR /* HSV values */ uiBlockBeginAlign(block); - bt= uiDefButF(block, NUMSLI, 0, "H ", 0, -60, butwidth, UI_UNIT_Y, hsv, 0.0, 1.0, 10, 3, ""); + bt= uiDefButF(block, NUMSLI, 0, "H ", 0, -60, butwidth, UI_UNIT_Y, hsv, 0.0, 1.0, 10, 3, "Hue"); uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv); - bt= uiDefButF(block, NUMSLI, 0, "S ", 0, -80, butwidth, UI_UNIT_Y, hsv+1, 0.0, 1.0, 10, 3, ""); + bt= uiDefButF(block, NUMSLI, 0, "S ", 0, -80, butwidth, UI_UNIT_Y, hsv+1, 0.0, 1.0, 10, 3, "Saturation"); uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv); - bt= uiDefButF(block, NUMSLI, 0, "V ", 0, -100, butwidth, UI_UNIT_Y, hsv+2, 0.0, max, 10, 3, ""); + bt= uiDefButF(block, NUMSLI, 0, "V ", 0, -100, butwidth, UI_UNIT_Y, hsv+2, 0.0, max, 10, 3, "Value"); uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv); uiBlockEndAlign(block); if(rgb[3] != FLT_MAX) { - bt= uiDefButR(block, NUMSLI, 0, "A ", 0, -120, butwidth, UI_UNIT_Y, ptr, propname, 3, 0.0, 0.0, 0, 0, ""); + bt= uiDefButR(block, NUMSLI, 0, "A ", 0, -120, butwidth, UI_UNIT_Y, ptr, propname, 3, 0.0, 0.0, 0, 0, "Alpha"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } else { From cfa5580843cabf86e1c6ca9eef132c5ebfa65f2d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Jul 2010 15:03:42 +0000 Subject: [PATCH 27/51] Fix for use of path environment variables, was not appending subfolder. --- source/blender/blenlib/intern/path_util.c | 44 +++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 092cca7de88..76877198bcb 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -947,13 +947,13 @@ static int test_path(char *targetpath, char *path_base, char *path_sep, char *fo } } -static int test_env_path(char *path, char *envvar) +static int test_env_path(char *path, char *subfolder_name, char *envvar) { char *env = envvar?getenv(envvar):NULL; if (!env) return 0; if (BLI_is_dir(env)) { - BLI_strncpy(path, env, FILE_MAX); + BLI_make_file_string("/", path, env, subfolder_name); return 1; } else { path[0] = '\0'; @@ -1002,14 +1002,14 @@ static int get_path_local(char *targetpath, char *folder_name) return 0; } -static int get_path_user(char *targetpath, char *folder_name, char *envvar) +static int get_path_user(char *targetpath, char *folder_name, char *subfolder_name, char *envvar) { char user_path[FILE_MAX]; const char *user_base_path; user_path[0] = '\0'; - if (test_env_path(targetpath, envvar)) + if (test_env_path(targetpath, subfolder_name, envvar)) return 1; user_base_path = (const char *)GHOST_getUserDir(); @@ -1028,14 +1028,14 @@ static int get_path_user(char *targetpath, char *folder_name, char *envvar) return test_path(targetpath, user_path, NULL, folder_name); } -static int get_path_system(char *targetpath, char *folder_name, char *envvar) +static int get_path_system(char *targetpath, char *folder_name, char *subfolder_name, char *envvar) { char system_path[FILE_MAX]; const char *system_base_path; system_path[0] = '\0'; - if (test_env_path(targetpath, envvar)) + if (test_env_path(targetpath, subfolder_name, envvar)) return 1; system_base_path = (const char *)GHOST_getSystemDir(); @@ -1065,66 +1065,66 @@ char *BLI_get_folder(int folder_id, char *subfolder) case BLENDER_DATAFILES: /* general case */ BLI_join_dirfile(search_path, "datafiles", subfolder); if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, "BLENDER_USER_DATAFILES")) break; - if (get_path_system(path, search_path, "BLENDER_SYSTEM_DATAFILES")) break; + if (get_path_user(path, search_path, subfolder, "BLENDER_USER_DATAFILES")) break; + if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_DATAFILES")) break; return NULL; case BLENDER_USER_DATAFILES: BLI_join_dirfile(search_path, "datafiles", subfolder); if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, "BLENDER_USER_DATAFILES")) break; + if (get_path_user(path, search_path, subfolder, "BLENDER_USER_DATAFILES")) break; return NULL; case BLENDER_SYSTEM_DATAFILES: BLI_join_dirfile(search_path, "datafiles", subfolder); - if (get_path_system(path, search_path, "BLENDER_SYSTEM_DATAFILES")) break; + if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_DATAFILES")) break; return NULL; case BLENDER_CONFIG: /* general case */ BLI_join_dirfile(search_path, "config", subfolder); if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, "BLENDER_USER_CONFIG")) break; - if (get_path_system(path, search_path, "BLENDER_SYSTEM_CONFIG")) break; + if (get_path_user(path, search_path, subfolder, "BLENDER_USER_CONFIG")) break; + if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_CONFIG")) break; return NULL; case BLENDER_USER_CONFIG: BLI_join_dirfile(search_path, "config", subfolder); if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, "BLENDER_USER_CONFIG")) break; + if (get_path_user(path, search_path, subfolder, "BLENDER_USER_CONFIG")) break; return NULL; case BLENDER_SYSTEM_CONFIG: BLI_join_dirfile(search_path, "config", subfolder); - if (get_path_system(path, search_path, "BLENDER_SYSTEM_CONFIG")) break; + if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_CONFIG")) break; return NULL; case BLENDER_SCRIPTS: /* general case */ BLI_join_dirfile(search_path, "scripts", subfolder); if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, "BLENDER_USER_SCRIPTS")) break; - if (get_path_system(path, search_path, "BLENDER_SYSTEM_SCRIPTS")) break; + if (get_path_user(path, search_path, subfolder, "BLENDER_USER_SCRIPTS")) break; + if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_SCRIPTS")) break; return NULL; case BLENDER_USER_SCRIPTS: BLI_join_dirfile(search_path, "scripts", subfolder); if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, "BLENDER_USER_SCRIPTS")) break; + if (get_path_user(path, search_path, subfolder, "BLENDER_USER_SCRIPTS")) break; return NULL; case BLENDER_SYSTEM_SCRIPTS: BLI_join_dirfile(search_path, "scripts", subfolder); - if (get_path_system(path, search_path, "BLENDER_SYSTEM_SCRIPTS")) break; + if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_SCRIPTS")) break; return NULL; case BLENDER_PYTHON: /* general case */ BLI_join_dirfile(search_path, "python", subfolder); if (get_path_local(path, search_path)) break; - if (get_path_system(path, search_path, "BLENDER_SYSTEM_PYTHON")) break; + if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_PYTHON")) break; return NULL; case BLENDER_SYSTEM_PYTHON: BLI_join_dirfile(search_path, "python", subfolder); - if (get_path_system(path, search_path, "BLENDER_SYSTEM_PYTHON")) break; + if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_PYTHON")) break; return NULL; } @@ -1139,11 +1139,11 @@ static char *BLI_get_user_folder_notest(int folder_id, char *subfolder) switch (folder_id) { case BLENDER_USER_DATAFILES: BLI_join_dirfile(search_path, "datafiles", subfolder); - get_path_user(path, search_path, "BLENDER_USER_DATAFILES"); + get_path_user(path, search_path, subfolder, "BLENDER_USER_DATAFILES"); break; case BLENDER_USER_CONFIG: BLI_join_dirfile(search_path, "config", subfolder); - get_path_user(path, search_path, "BLENDER_USER_CONFIG"); + get_path_user(path, search_path, subfolder, "BLENDER_USER_CONFIG"); break; } if ('\0' == path[0]) { From 7fb16fb5ec8951a2118aadbeaf8fbff214a059f0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Jul 2010 15:20:53 +0000 Subject: [PATCH 28/51] Update --help message for new path environment variables. --- source/creator/creator.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/creator/creator.c b/source/creator/creator.c index 34322ea6b73..ac79c0e6f80 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -289,11 +289,13 @@ static int print_help(int argc, char **argv, void *data) printf ("\t\t\"blender --background test.blend --render-output /tmp --render-frame 1\" works as expected.\n\n"); printf ("\nEnvironment Variables:\n"); - printf (" $HOME\t\t\tStore '.blender/' containing defaults, bookmarks and user scripts.\n"); - printf (" $BLENDERPATH System directory to use for data files and scripts.\n"); - printf (" For this build of blender the default $BLENDERPATH is...\n"); - printf (" \"%s\"\n", blender_path); - printf (" setting the $BLENDERPATH will override this\n"); + printf (" $BLENDER_USER_CONFIG Directory for user configuration files.\n"); + printf (" $BLENDER_SYSTEM_CONFIG Directory for system wide configuration files.\n"); + printf (" $BLENDER_USER_SCRIPTS Directory for user scripts.\n"); + printf (" $BLENDER_SYSTEM_SCRIPTS Directory for system wide scripts.\n"); + printf (" $BLENDER_USER_DATAFILES Directory for user data files (icons, translations, ..).\n"); + printf (" $BLENDER_SYSTEM_DATAFILES Directory for system wide data files.\n"); + printf (" $BLENDER_SYSTEM_PYTHON Directory for system python libraries.\n"); #ifdef WIN32 printf (" $TEMP Store temporary files here.\n"); #else From 220fd2e80aa353087e512d5333a64de1b0734954 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Jul 2010 15:37:57 +0000 Subject: [PATCH 29/51] rna name edits as discussed with brecht. restrict -> hide. --- source/blender/makesrna/rna_cleanup/rna_booleans.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/makesrna/rna_cleanup/rna_booleans.txt b/source/blender/makesrna/rna_cleanup/rna_booleans.txt index 614db736d64..87d4f8a0736 100644 --- a/source/blender/makesrna/rna_cleanup/rna_booleans.txt +++ b/source/blender/makesrna/rna_cleanup/rna_booleans.txt @@ -64,7 +64,7 @@ Bone.inherit_scale -> use_inherit_scale: boolean Bone inherits scaling fro Bone.layer -> layer: boolean Layers bone exists in Bone.local_location -> use_local_location: boolean Bone location is set in local space Bone.multiply_vertexgroup_with_envelope -> use_envelope_multiply: boolean When deforming bone, multiply effects of Vertex Group weights with Envelope influence -Bone.restrict_select -> restrict_select: boolean Bone is able to be selected +Bone.restrict_select -> hide_select: boolean Bone is able to be selected Bone.selected -> select: boolean BooleanProperty.default -> default: boolean, (read-only) Default value for this number BooleanProperty.default_array -> default_array: boolean, (read-only) Default value for this array @@ -221,7 +221,7 @@ EditBone.layer -> layer: boolean Layers bone exists in EditBone.local_location -> use_local_location: boolean Bone location is set in local space EditBone.locked -> lock: boolean Bone is not able to be transformed when in Edit Mode EditBone.multiply_vertexgroup_with_envelope -> use_envelope_multiply: boolean When deforming bone, multiply effects of Vertex Group weights with Envelope influence -EditBone.restrict_select -> restrict_select: boolean Bone is able to be selected +EditBone.restrict_select -> hide_select: boolean Bone is able to be selected EditBone.selected -> select: boolean EditBone.selected_head -> select_head: boolean EditBone.selected_tail -> select_tail: boolean @@ -682,9 +682,9 @@ Object.lock_rotation -> lock_rotation: boolean Lock editing of rotation in Object.lock_rotation_w -> lock_rotation_w: boolean Lock editing of 'angle' component of four-component rotations in the interface Object.lock_rotations_4d -> lock_rotations_4d: boolean Lock editing of four component rotations by components (instead of as Eulers) Object.lock_scale -> lock_scale: boolean Lock editing of scale in the interface -Object.restrict_render -> restrict_render: boolean Restrict renderability -Object.restrict_select -> restrict_select: boolean Restrict selection in the viewport -Object.restrict_view -> restrict_view: boolean Restrict visibility in the viewport +Object.restrict_render -> hide_render: boolean Restrict renderability +Object.restrict_select -> hide_select: boolean Restrict selection in the viewport +Object.restrict_view -> hide: boolean Restrict visibility in the viewport Object.selected -> select: boolean Object selection state Object.shape_key_edit_mode -> use_shape_key_edit_mode: boolean Apply shape keys in edit mode (for Meshes only) Object.shape_key_lock -> show_shape_key: boolean Always show the current Shape for this Object From 02da5ecfed33139f90a8a35c37300e6d3f3034eb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Jul 2010 16:56:04 +0000 Subject: [PATCH 30/51] Apply first pass of edits to rna values from rna_booleans.txt. These are not animated and are best not change names like this too late in the release. ActionGroup.selected -> select: boolean Action Group is selected BezierSplinePoint.hidden -> hide: boolean Visibility status BezierSplinePoint.selected_control_point -> select_control_point: boolean Control point selection status BezierSplinePoint.selected_handle1 -> select_left_handle: boolean Handle 1 selection status BezierSplinePoint.selected_handle2 -> select_right_handle: boolean Handle 2 selection status Bone.restrict_select -> hide_select: boolean Bone is able to be selected Bone.selected -> select: boolean CurveMapPoint.selected -> select: boolean Selection state of the curve point EditBone.restrict_select -> hide_select: boolean Bone is able to be selected EditBone.selected -> select: boolean EditBone.selected_head -> select_head: boolean EditBone.selected_tail -> select_tail: boolean EditBone.locked -> lock: boolean Bone is not able to be transformed when in Edit Mode EditBone.hidden -> hide: boolean Bone is not visible when in Edit Mode NEGATE * FCurve.disabled -> enabled: boolean F-Curve could not be evaluated in past, so should be skipped when evaluating FCurve.locked -> lock: boolean F-Curve's settings cannot be edited FCurve.muted -> mute: boolean F-Curve is not evaluated FCurve.selected -> select: boolean F-Curve is selected for editing NEGATE * FCurve.visible -> hide: boolean F-Curve and its keyframes are shown in the Graph Editor graphs FCurveSample.selected -> select: boolean Selection status GPencilFrame.selected -> select: boolean Frame is selected for editing in the DopeSheet GPencilLayer.locked -> lock: boolean Protect layer from further editing and/or frame changes GPencilLayer.selected -> select: boolean Layer is selected for editing in the DopeSheet Keyframe.selected -> select: boolean Control point selection status Keyframe.selected_handle1 -> select_left_handle: boolean Handle 1 selection status Keyframe.selected_handle2 -> select_right_handle: boolean Handle 2 selection status MeshEdge.selected -> select: boolean MeshEdge.hidden -> hide: boolean MeshFace.hidden -> hide: boolean MeshFace.selected -> select: boolean MeshVertex.hidden -> hide: boolean MeshVertex.selected -> select: boolean MotionPathVert.selected -> select: boolean Path point is selected for editing NlaStrip.selected -> select: boolean NLA Strip is selected NlaTrack.locked -> lock: boolean NLA Track is locked NlaTrack.muted -> mute: boolean NLA Track is not evaluated NlaTrack.selected -> select: boolean NLA Track is selected Object.restrict_render -> hide_render: boolean Restrict renderability Object.restrict_select -> hide_select: boolean Restrict selection in the viewport Object.restrict_view -> hide: boolean Restrict visibility in the viewport Object.selected -> select: boolean Object selection state ObjectBase.selected -> select: boolean Object base selection state PoseBone.selected -> select: boolean Sequence.right_handle_selected -> select_right_handle: boolean Sequence.selected -> select: boolean SplinePoint.selected -> select_control_point: boolean Selection status TimelineMarker.selected -> select: boolean Marker selection state Sequence.left_handle_selected -> select_left_handle: boolean ActionGroup.locked -> lock: boolean Action Group is locked Bone.hidden -> hide: boolean Bone is not visible when it is not in Edit Mode (i.e. in Object or Pose Modes) SplinePoint.hidden -> hide: boolean Visibility status FModifier.muted -> mute: boolean F-Curve Modifier will not be evaluated note: rebaned uv_select to select_uv --- release/scripts/io/import_anim_bvh.py | 4 +- release/scripts/modules/add_object_utils.py | 6 +- release/scripts/modules/bpy_types.py | 2 +- release/scripts/modules/rigify/__init__.py | 24 +++---- release/scripts/modules/rigify/arm_biped.py | 4 +- release/scripts/op/fcurve_euler_filter.py | 2 +- release/scripts/op/mesh.py | 6 +- release/scripts/op/nla.py | 2 +- release/scripts/op/object.py | 18 ++--- release/scripts/op/sequencer.py | 10 +-- release/scripts/op/uv.py | 4 +- release/scripts/op/uvcalc_follow_active.py | 2 +- release/scripts/op/uvcalc_smart_project.py | 4 +- release/scripts/op/vertexpaint_dirt.py | 2 +- release/scripts/presets/interaction/maya.py | 6 +- release/scripts/templates/operator_uv.py | 2 +- release/scripts/ui/properties_data_bone.py | 6 +- release/scripts/ui/properties_game.py | 8 +-- .../ui/properties_object_constraint.py | 2 +- release/scripts/ui/space_time.py | 2 +- release/scripts/ui/space_view3d.py | 6 +- .../blender/editors/animation/fmodifier_ui.c | 2 +- source/blender/editors/curve/editcurve.c | 2 +- .../blender/editors/gpencil/gpencil_buttons.c | 2 +- .../editors/interface/interface_templates.c | 2 +- source/blender/editors/object/object_edit.c | 40 ++++++------ source/blender/editors/object/object_intern.h | 8 +-- source/blender/editors/object/object_ops.c | 20 +++--- .../blender/editors/space_nla/nla_buttons.c | 2 +- .../blender/editors/space_outliner/outliner.c | 6 +- source/blender/makesrna/intern/rna_action.c | 8 +-- source/blender/makesrna/intern/rna_animviz.c | 4 +- source/blender/makesrna/intern/rna_armature.c | 30 ++++----- source/blender/makesrna/intern/rna_color.c | 4 +- .../blender/makesrna/intern/rna_constraint.c | 2 +- source/blender/makesrna/intern/rna_curve.c | 18 ++--- source/blender/makesrna/intern/rna_fcurve.c | 38 +++++------ source/blender/makesrna/intern/rna_gpencil.c | 10 +-- source/blender/makesrna/intern/rna_mesh.c | 26 ++++---- source/blender/makesrna/intern/rna_nla.c | 14 ++-- source/blender/makesrna/intern/rna_object.c | 14 ++-- source/blender/makesrna/intern/rna_pose.c | 4 +- .../blender/makesrna/intern/rna_sequencer.c | 8 +-- source/blender/makesrna/intern/rna_timeline.c | 4 +- source/blender/makesrna/intern/rna_userdef.c | 4 +- .../makesrna/rna_cleanup/rna_booleans.txt | 65 ++++--------------- 46 files changed, 209 insertions(+), 250 deletions(-) diff --git a/release/scripts/io/import_anim_bvh.py b/release/scripts/io/import_anim_bvh.py index d497ac47065..89097fd53f5 100644 --- a/release/scripts/io/import_anim_bvh.py +++ b/release/scripts/io/import_anim_bvh.py @@ -347,7 +347,7 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM scn = context.scene #XXX scn.objects.selected = [] for ob in scn.objects: - ob.selected = False + ob.select = False scn.set_frame(IMPORT_START_FRAME) @@ -356,7 +356,7 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM scn.objects.link(arm_ob) - arm_ob.selected = True + arm_ob.select = True scn.objects.active = arm_ob print(scn.objects.active) diff --git a/release/scripts/modules/add_object_utils.py b/release/scripts/modules/add_object_utils.py index cef368c529d..9031121060a 100644 --- a/release/scripts/modules/add_object_utils.py +++ b/release/scripts/modules/add_object_utils.py @@ -50,12 +50,12 @@ def add_object_data(context, obdata, operator=None): # ugh, could be made nicer for ob in scene.objects: - ob.selected = False + ob.select = False obj_new = bpy.data.objects.new(obdata.name, obdata) base = scene.objects.link(obj_new) - base.selected = True + base.select = True if context.space_data and context.space_data.type == 'VIEW_3D': base.layers_from_view(context.space_data) @@ -68,7 +68,7 @@ def add_object_data(context, obdata, operator=None): if obj_act and obj_act.mode == 'EDIT' and obj_act.type == obj_new.type: bpy.ops.object.mode_set(mode='OBJECT') - obj_act.selected = True + obj_act.select = True scene.update() # apply location #scene.objects.active = obj_new diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 9d6f5ce7b2f..8cbb2bf4e80 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -444,7 +444,7 @@ class Mesh(bpy_types.ID): if not hasattr(edges, "pop"): edges = edges[:] - edge_dict = {ed.key: ed for ed in self.edges if ed.selected} + edge_dict = {ed.key: ed for ed in self.edges if ed.select} while edges: current_edge = edges.pop() diff --git a/release/scripts/modules/rigify/__init__.py b/release/scripts/modules/rigify/__init__.py index ef8f62ad058..095229016e9 100644 --- a/release/scripts/modules/rigify/__init__.py +++ b/release/scripts/modules/rigify/__init__.py @@ -191,8 +191,8 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): obj.animation_data_clear() # Select generated rig object - obj_orig.selected = False - obj.selected = True + obj_orig.select = False + obj.select = True scene.objects.active = obj # Remove all bones from the generated rig armature. @@ -212,9 +212,9 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): # Select the temp rigs for merging for objt in scene.objects: - objt.selected = False # deselect all objects - temp_rig_1.selected = True - temp_rig_2.selected = True + objt.select = False # deselect all objects + temp_rig_1.select = True + temp_rig_2.select = True scene.objects.active = temp_rig_2 # Merge the temporary rigs @@ -225,8 +225,8 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): # Select the generated rig for objt in scene.objects: - objt.selected = False # deselect all objects - obj.selected = True + objt.select = False # deselect all objects + obj.select = True scene.objects.active = obj # Copy over the pose_bone properties @@ -464,7 +464,7 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): arm.layer = layer_show - # obj.restrict_view = True + # obj.hide = True obj.data.draw_axes = False bpy.ops.object.mode_set(mode=mode_orig) @@ -490,8 +490,8 @@ def generate_test(context, metarig_type="", GENERATE_FINAL=True): scene.objects.link(obj_new) scene.objects.active = obj_new for obj in scene.objects: - obj.selected = False - obj_new.selected = True + obj.select = False + obj_new.select = True for module_name in get_submodule_types(): if (metarig_type and module_name != metarig_type): @@ -551,8 +551,8 @@ def generate_test_all(context, GRAPH=False): obj.data.drawtype = 'STICK' obj.location[1] += i obj_new.location[1] += i - obj_new.selected = False - obj.selected = True + obj_new.select = False + obj.select = True i += 4 diff --git a/release/scripts/modules/rigify/arm_biped.py b/release/scripts/modules/rigify/arm_biped.py index 7a99eb5d80a..f80a617df47 100644 --- a/release/scripts/modules/rigify/arm_biped.py +++ b/release/scripts/modules/rigify/arm_biped.py @@ -137,8 +137,8 @@ def ik(obj, definitions, base_names, options): ik.pole_vis = add_stretch_to(obj, mt.forearm, ik.pole, "VIS-%s_ik" % base_names[mt.forearm]) ik.update() - ik.hand_vis_e.restrict_select = True - ik.pole_vis_e.restrict_select = True + ik.hand_vis_e.hide_select = True + ik.pole_vis_e.hide_select = True bpy.ops.object.mode_set(mode='OBJECT') diff --git a/release/scripts/op/fcurve_euler_filter.py b/release/scripts/op/fcurve_euler_filter.py index bba4576ef73..39c226294ee 100644 --- a/release/scripts/op/fcurve_euler_filter.py +++ b/release/scripts/op/fcurve_euler_filter.py @@ -40,7 +40,7 @@ def main(context): flist = bpy.context.active_object.animation_data.action.fcurves for f in flist: - if f.selected and f.data_path.endswith("rotation_euler"): + if f.select and f.data_path.endswith("rotation_euler"): cleanupEulCurve(f) class DiscontFilterOp(bpy.types.Operator): diff --git a/release/scripts/op/mesh.py b/release/scripts/op/mesh.py index 78ca9a18cdc..b63997b8eba 100644 --- a/release/scripts/op/mesh.py +++ b/release/scripts/op/mesh.py @@ -54,9 +54,9 @@ class MeshSelectInteriorFaces(bpy.types.Operator): for index, face in enumerate(face_list): if(test_interior(index)): - face.selected = True + face.select = True else: - face.selected = False + face.select = False if is_editmode: bpy.ops.object.mode_set(mode='EDIT', toggle=False) @@ -122,7 +122,7 @@ class MeshMirrorUV(bpy.types.Operator): # as a list faces = mesh.faces[:] - fuvsel = [(False not in uv.uv_selected) for uv in active_uv_layer] + fuvsel = [(False not in uv.select_uv) for uv in active_uv_layer] fcents = [f.center for f in faces] # find mirror faces diff --git a/release/scripts/op/nla.py b/release/scripts/op/nla.py index d0c53758ba9..ceb4621d643 100644 --- a/release/scripts/op/nla.py +++ b/release/scripts/op/nla.py @@ -100,7 +100,7 @@ def bake(frame_start, frame_end, step=1, only_selected=False): pose_items = pose.bones.items() for name, pbone in pose_items: - if only_selected and not pbone.selected: + if only_selected and not pbone.select: continue for f in frame_range: diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py index b16d2b0dcf2..2df1250251e 100644 --- a/release/scripts/op/object.py +++ b/release/scripts/op/object.py @@ -52,9 +52,9 @@ class SelectPattern(bpy.types.Operator): # Can be pose bones or objects for item in items: if pattern_match(item.name, self.properties.pattern): - item.selected = True + item.select = True elif not self.properties.extend: - item.selected = False + item.select = False return {'FINISHED'} @@ -90,7 +90,7 @@ class SelectCamera(bpy.types.Operator): self.report({'WARNING'}, "Active camera is not in this scene") context.scene.objects.active = camera - camera.selected = True + camera.select = True return {'FINISHED'} @@ -121,7 +121,7 @@ class SelectHierarchy(bpy.types.Operator): if not self.properties.extend: # for obj in objs: - # obj.selected = False + # obj.select = False bpy.ops.object.select_all(action='DESELECT') if self.properties.direction == 'PARENT': @@ -135,7 +135,7 @@ class SelectHierarchy(bpy.types.Operator): if obj_act == obj: context.scene.objects.active = parent - parent.selected = True + parent.select = True if parents: return {'CANCELLED'} @@ -145,7 +145,7 @@ class SelectHierarchy(bpy.types.Operator): for obj in objs: children += list(obj.children) for obj_iter in children: - obj_iter.selected = True + obj_iter.select = True children.sort(key=lambda obj_iter: obj_iter.name) context.scene.objects.active = children[0] @@ -536,11 +536,11 @@ class IsolateTypeRender(bpy.types.Operator): for obj in context.visible_objects: - if obj.selected: - obj.restrict_render = False + if obj.select: + obj.hide_render = False else: if obj.type == act_type: - obj.restrict_render = True + obj.hide_render = True return {'FINISHED'} diff --git a/release/scripts/op/sequencer.py b/release/scripts/op/sequencer.py index 13668498aae..cf876189907 100644 --- a/release/scripts/op/sequencer.py +++ b/release/scripts/op/sequencer.py @@ -40,7 +40,7 @@ class SequencerCrossfadeSounds(bpy.types.Operator): seq1 = None seq2 = None for s in context.scene.sequence_editor.sequences: - if s.selected and s.type == 'SOUND': + if s.select and s.type == 'SOUND': if seq1 == None: seq1 = s elif seq2 == None: @@ -97,13 +97,13 @@ class SequencerCutMulticam(bpy.types.Operator): if s.multicam_source == camera: return {'FINISHED'} - if not s.selected: - s.selected = True + if not s.select: + s.select = True cfra = context.scene.frame_current bpy.ops.sequencer.cut(frame=cfra, type='SOFT', side='RIGHT') for s in context.scene.sequence_editor.sequences_all: - if s.selected and s.type == 'MULTICAM' and s.frame_final_start <= cfra and cfra < s.frame_final_end: + if s.select and s.type == 'MULTICAM' and s.frame_final_start <= cfra and cfra < s.frame_final_end: context.scene.sequence_editor.active_strip = s context.scene.sequence_editor.active_strip.multicam_source = camera @@ -125,7 +125,7 @@ class SequencerDeinterlaceSelectedMovies(bpy.types.Operator): def execute(self, context): for s in context.scene.sequence_editor.sequences_all: - if s.selected and s.type == 'MOVIE': + if s.select and s.type == 'MOVIE': s.de_interlace = True return {'FINISHED'} diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py index 51c1695677b..a7abd475b8d 100644 --- a/release/scripts/op/uv.py +++ b/release/scripts/op/uv.py @@ -85,9 +85,9 @@ class ExportUVLayout(bpy.types.Operator): for i in range(uv_layer_len): uv_elem = uv_layer[i] # context checks - if faces[i].selected and (local_image is Ellipsis or local_image == uv_elem.image): + if faces[i].select and (local_image is Ellipsis or local_image == uv_elem.image): #~ uv = uv_elem.uv - #~ if False not in uv_elem.uv_selected[:len(uv)]: + #~ if False not in uv_elem.select_uv[:len(uv)]: #~ yield (i, uv) # just write what we see. diff --git a/release/scripts/op/uvcalc_follow_active.py b/release/scripts/op/uvcalc_follow_active.py index 61c149c8735..6466d48a9fe 100644 --- a/release/scripts/op/uvcalc_follow_active.py +++ b/release/scripts/op/uvcalc_follow_active.py @@ -146,7 +146,7 @@ def extend(obj, operator, EXTEND_MODE): operator.report({'ERROR'}, "No active face.") return - face_sel = [f for f in me.faces if len(f.verts) == 4 and f.selected] + face_sel = [f for f in me.faces if len(f.verts) == 4 and f.select] face_act_local_index = -1 for i, f in enumerate(face_sel): diff --git a/release/scripts/op/uvcalc_smart_project.py b/release/scripts/op/uvcalc_smart_project.py index 13bf6244f4d..a7ef980e8c5 100644 --- a/release/scripts/op/uvcalc_smart_project.py +++ b/release/scripts/op/uvcalc_smart_project.py @@ -821,7 +821,7 @@ def main(context, island_margin, projection_limit): #XXX ob = objects.active ob= objects[0] - if ob and ob.selected == 0 and ob.type == 'MESH': + if ob and (not ob.select) and ob.type == 'MESH': # Add to the list obList =[ob] del objects @@ -899,7 +899,7 @@ def main(context, island_margin, projection_limit): me_verts = list(me.verts) if USER_ONLY_SELECTED_FACES: - meshFaces = [thickface(f, uv_layer[i], me_verts) for i, f in enumerate(me.faces) if f.selected] + meshFaces = [thickface(f, uv_layer[i], me_verts) for i, f in enumerate(me.faces) if f.select] #else: # meshFaces = map(thickface, me.faces) diff --git a/release/scripts/op/vertexpaint_dirt.py b/release/scripts/op/vertexpaint_dirt.py index c1521866a56..63a3aa3896b 100644 --- a/release/scripts/op/vertexpaint_dirt.py +++ b/release/scripts/op/vertexpaint_dirt.py @@ -127,7 +127,7 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, return('CANCELLED', ) for i, f in enumerate(me.faces): - if not me.use_paint_mask or f.selected: + if not me.use_paint_mask or f.select: f_col = active_col_layer[i] diff --git a/release/scripts/presets/interaction/maya.py b/release/scripts/presets/interaction/maya.py index 31652035dff..777dee1e563 100644 --- a/release/scripts/presets/interaction/maya.py +++ b/release/scripts/presets/interaction/maya.py @@ -244,9 +244,9 @@ kmi = km.items.add('object.location_clear', 'G', 'PRESS', alt=True) kmi = km.items.add('object.rotation_clear', 'R', 'PRESS', alt=True) kmi = km.items.add('object.scale_clear', 'S', 'PRESS', alt=True) kmi = km.items.add('object.origin_clear', 'O', 'PRESS', alt=True) -kmi = km.items.add('object.restrictview_clear', 'H', 'PRESS', alt=True) -kmi = km.items.add('object.restrictview_set', 'H', 'PRESS') -kmi = km.items.add('object.restrictview_set', 'H', 'PRESS', shift=True) +kmi = km.items.add('object.hide_clear', 'H', 'PRESS', alt=True) +kmi = km.items.add('object.hide_set', 'H', 'PRESS') +kmi = km.items.add('object.hide_set', 'H', 'PRESS', shift=True) kmi.properties.unselected = True kmi = km.items.add('object.move_to_layer', 'M', 'PRESS') kmi = km.items.add('object.delete', 'X', 'PRESS') diff --git a/release/scripts/templates/operator_uv.py b/release/scripts/templates/operator_uv.py index 1003bd6c58b..9327de33312 100644 --- a/release/scripts/templates/operator_uv.py +++ b/release/scripts/templates/operator_uv.py @@ -16,7 +16,7 @@ def main(context): for i, uv in enumerate(mesh.active_uv_texture.data): uvs = uv.uv1, uv.uv2, uv.uv3, uv.uv4 for j, v_idx in enumerate(mesh.faces[i].verts): - if uv.uv_selected[j]: + if uv.select_uv[j]: # apply the location of the vertex as a UV uvs[j][:] = mesh.verts[v_idx].co.xy diff --git a/release/scripts/ui/properties_data_bone.py b/release/scripts/ui/properties_data_bone.py index b6b638ef380..a4be7b31042 100644 --- a/release/scripts/ui/properties_data_bone.py +++ b/release/scripts/ui/properties_data_bone.py @@ -81,13 +81,13 @@ class BONE_PT_transform(BoneButtonsPanel): sub.label(text="Roll:") sub.prop(bone, "roll", text="") sub.label() - sub.prop(bone, "locked") + sub.prop(bone, "lock") else: col = layout.column() col.prop(bone, "head") col.prop(bone, "tail") col.prop(bone, "roll") - col.prop(bone, "locked") + col.prop(bone, "lock") else: pchan = ob.pose.bones[context.bone.name] @@ -231,7 +231,7 @@ class BONE_PT_display(BoneButtonsPanel): col = split.column() col.prop(bone, "draw_wire", text="Wireframe") - col.prop(bone, "hidden", text="Hide") + col.prop(bone, "hide", text="Hide") if wide_ui: col = split.column() diff --git a/release/scripts/ui/properties_game.py b/release/scripts/ui/properties_game.py index 9ec7168f834..88803993c92 100644 --- a/release/scripts/ui/properties_game.py +++ b/release/scripts/ui/properties_game.py @@ -58,7 +58,7 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel): col = split.column() col.prop(game, "actor") col.prop(game, "ghost") - col.prop(ob, "restrict_render", text="Invisible") # out of place but useful + col.prop(ob, "hide_render", text="Invisible") # out of place but useful if wide_ui: col = split.column() @@ -120,7 +120,7 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel): col = layout.column() col.prop(game, "actor") col.prop(game, "ghost") - col.prop(ob, "restrict_render", text="Invisible") + col.prop(ob, "hide_render", text="Invisible") layout.separator() @@ -156,10 +156,10 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel): col = layout.column() col.prop(game, "actor") col.prop(game, "ghost") - col.prop(ob, "restrict_render", text="Invisible") + col.prop(ob, "hide_render", text="Invisible") elif game.physics_type in ('SENSOR', 'INVISIBLE', 'NO_COLLISION', 'OCCLUDE'): - layout.prop(ob, "restrict_render", text="Invisible") + layout.prop(ob, "hide_render", text="Invisible") class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel): diff --git a/release/scripts/ui/properties_object_constraint.py b/release/scripts/ui/properties_object_constraint.py index 335bd25b501..edeadb9326b 100644 --- a/release/scripts/ui/properties_object_constraint.py +++ b/release/scripts/ui/properties_object_constraint.py @@ -523,7 +523,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): row = layout.row() if wide_ui: row.label(text="Lock:") - row.prop(con, "locked", expand=True) + row.prop(con, "lock", expand=True) def LIMIT_DISTANCE(self, context, layout, con, wide_ui): self.target_template(layout, con, wide_ui) diff --git a/release/scripts/ui/space_time.py b/release/scripts/ui/space_time.py index 042e4dbc015..8c24dbc2d9c 100644 --- a/release/scripts/ui/space_time.py +++ b/release/scripts/ui/space_time.py @@ -141,7 +141,7 @@ class TIME_MT_frame(bpy.types.Menu): # it was ok for riscos... ok TODO, operator for marker in context.scene.timeline_markers: - if marker.selected: + if marker.select: layout.separator() layout.prop(marker, "name", text="", icon='MARKER_HLT') break diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index bab3695a0b6..3ad945cd19d 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -859,9 +859,9 @@ class VIEW3D_MT_object_showhide(bpy.types.Menu): def draw(self, context): layout = self.layout - layout.operator("object.restrictview_clear", text="Show Hidden") - layout.operator("object.restrictview_set", text="Hide Selected") - layout.operator("object.restrictview_set", text="Hide Unselected").unselected = True + layout.operator("object.hide_view_clear", text="Show Hidden") + layout.operator("object.hide_view_set", text="Hide Selected") + layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True class VIEW3D_MT_make_single_user(bpy.types.Menu): diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index cd6714ec51f..8c6a81bddf4 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -633,7 +633,7 @@ void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ID *id, ListBase *modifie /* 'mute' button */ - uiItemR(subrow, &ptr, "muted", UI_ITEM_R_ICON_ONLY, "", 0); + uiItemR(subrow, &ptr, "mute", UI_ITEM_R_ICON_ONLY, "", 0); uiBlockSetEmboss(block, UI_EMBOSSN); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 186f3f20082..659ee7b9cea 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4737,7 +4737,7 @@ static int delete_invoke(bContext *C, wmOperator *op, wmEvent *event) void CURVE_OT_delete(wmOperatorType *ot) { static EnumPropertyItem type_items[] = { - {0, "SELECTED", 0, "Selected", ""}, + {0, "SELECTED", 0, "Select", ""}, {1, "SEGMENT", 0, "Segment", ""}, {2, "ALL", 0, "All", ""}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 17bafa3d399..c1ac863b362 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -126,7 +126,7 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl) /* locked */ icon= (gpl->flag & GP_LAYER_LOCKED) ? ICON_LOCKED : ICON_UNLOCKED; - uiItemR(subrow, &ptr, "locked", 0, "", icon); + uiItemR(subrow, &ptr, "lock", 0, "", icon); /* when layer is locked or hidden, only draw header */ if (gpl->flag & (GP_LAYER_LOCKED|GP_LAYER_HIDE)) { diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index f951def739f..ecbdab98257 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2049,7 +2049,7 @@ void uiTemplateTriColorSet(uiLayout *layout, PointerRNA *ptr, char *propname) csPtr= RNA_property_pointer_get(ptr, prop); uiItemR(row, &csPtr, "normal", 0, "", 0); - uiItemR(row, &csPtr, "selected", 0, "", 0); + uiItemR(row, &csPtr, "select", 0, "", 0); uiItemR(row, &csPtr, "active", 0, "", 0); } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 5fe09f0083e..78f8e0e11d3 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -135,7 +135,7 @@ Object *ED_object_active_context(bContext *C) /* ********* clear/set restrict view *********/ -static int object_restrictview_clear_exec(bContext *C, wmOperator *op) +static int object_hide_view_clear_exec(bContext *C, wmOperator *op) { ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; @@ -160,23 +160,23 @@ static int object_restrictview_clear_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void OBJECT_OT_restrictview_clear(wmOperatorType *ot) +void OBJECT_OT_hide_view_clear(wmOperatorType *ot) { /* identifiers */ ot->name= "Clear Restrict View"; - ot->description = "Reveal the object by setting the restrictview flag"; - ot->idname= "OBJECT_OT_restrictview_clear"; + ot->description = "Reveal the object by setting the hide flag"; + ot->idname= "OBJECT_OT_hide_view_clear"; /* api callbacks */ - ot->exec= object_restrictview_clear_exec; + ot->exec= object_hide_view_clear_exec; ot->poll= ED_operator_view3d_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int object_restrictview_set_exec(bContext *C, wmOperator *op) +static int object_hide_view_set_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); short changed = 0; @@ -213,15 +213,15 @@ static int object_restrictview_set_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void OBJECT_OT_restrictview_set(wmOperatorType *ot) +void OBJECT_OT_hide_view_set(wmOperatorType *ot) { /* identifiers */ ot->name= "Set Restrict View"; - ot->description = "Hide the object by setting the restrictview flag"; - ot->idname= "OBJECT_OT_restrictview_set"; + ot->description = "Hide the object by setting the hide flag"; + ot->idname= "OBJECT_OT_hide_view_set"; /* api callbacks */ - ot->exec= object_restrictview_set_exec; + ot->exec= object_hide_view_set_exec; ot->poll= ED_operator_view3d_active; /* flags */ @@ -232,7 +232,7 @@ void OBJECT_OT_restrictview_set(wmOperatorType *ot) } /* 99% same as above except no need for scene refreshing (TODO, update render preview) */ -static int object_restrictrender_clear_exec(bContext *C, wmOperator *op) +static int object_hide_render_clear_exec(bContext *C, wmOperator *op) { short changed= 0; @@ -251,23 +251,23 @@ static int object_restrictrender_clear_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void OBJECT_OT_restrictrender_clear(wmOperatorType *ot) +void OBJECT_OT_hide_render_clear(wmOperatorType *ot) { /* identifiers */ ot->name= "Clear Restrict Render"; - ot->description = "Reveal the render object by setting the restrictrender flag"; - ot->idname= "OBJECT_OT_restrictrender_clear"; + ot->description = "Reveal the render object by setting the hide render flag"; + ot->idname= "OBJECT_OT_hide_render_clear"; /* api callbacks */ - ot->exec= object_restrictrender_clear_exec; + ot->exec= object_hide_render_clear_exec; ot->poll= ED_operator_view3d_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int object_restrictrender_set_exec(bContext *C, wmOperator *op) +static int object_hide_render_set_exec(bContext *C, wmOperator *op) { int unselected= RNA_boolean_get(op->ptr, "unselected"); @@ -288,15 +288,15 @@ static int object_restrictrender_set_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void OBJECT_OT_restrictrender_set(wmOperatorType *ot) +void OBJECT_OT_hide_render_set(wmOperatorType *ot) { /* identifiers */ ot->name= "Set Restrict Render"; - ot->description = "Hide the render object by setting the restrictrender flag"; - ot->idname= "OBJECT_OT_restrictrender_set"; + ot->description = "Hide the render object by setting the hide render flag"; + ot->idname= "OBJECT_OT_hide_render_set"; /* api callbacks */ - ot->exec= object_restrictrender_set_exec; + ot->exec= object_hide_render_set_exec; ot->poll= ED_operator_view3d_active; /* flags */ diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 8bd0da3b43f..3c22ccdad8f 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -75,10 +75,10 @@ void OBJECT_OT_drop_named_material(struct wmOperatorType *ot); void OBJECT_OT_mode_set(struct wmOperatorType *ot); void OBJECT_OT_editmode_toggle(struct wmOperatorType *ot); void OBJECT_OT_posemode_toggle(struct wmOperatorType *ot); -void OBJECT_OT_restrictview_set(struct wmOperatorType *ot); -void OBJECT_OT_restrictview_clear(struct wmOperatorType *ot); -void OBJECT_OT_restrictrender_set(struct wmOperatorType *ot); -void OBJECT_OT_restrictrender_clear(struct wmOperatorType *ot); +void OBJECT_OT_hide_view_set(struct wmOperatorType *ot); +void OBJECT_OT_hide_view_clear(struct wmOperatorType *ot); +void OBJECT_OT_hide_render_set(struct wmOperatorType *ot); +void OBJECT_OT_hide_render_clear(struct wmOperatorType *ot); void OBJECT_OT_proxy_make(struct wmOperatorType *ot); void OBJECT_OT_shade_smooth(struct wmOperatorType *ot); void OBJECT_OT_shade_flat(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index ba706a0d4b9..804f4dd7704 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -72,10 +72,10 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_editmode_toggle); WM_operatortype_append(OBJECT_OT_posemode_toggle); WM_operatortype_append(OBJECT_OT_proxy_make); - WM_operatortype_append(OBJECT_OT_restrictview_clear); - WM_operatortype_append(OBJECT_OT_restrictview_set); - WM_operatortype_append(OBJECT_OT_restrictrender_clear); - WM_operatortype_append(OBJECT_OT_restrictrender_set); + WM_operatortype_append(OBJECT_OT_hide_view_clear); + WM_operatortype_append(OBJECT_OT_hide_view_set); + WM_operatortype_append(OBJECT_OT_hide_render_clear); + WM_operatortype_append(OBJECT_OT_hide_render_set); WM_operatortype_append(OBJECT_OT_shade_smooth); WM_operatortype_append(OBJECT_OT_shade_flat); WM_operatortype_append(OBJECT_OT_paths_calculate); @@ -318,14 +318,14 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_origin_clear", OKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_clear", HKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_set", HKEY, KM_PRESS, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_set", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); + WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_clear", HKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, 0, 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); /* same as above but for rendering */ - WM_keymap_add_item(keymap, "OBJECT_OT_restrictrender_clear", HKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_restrictrender_set", HKEY, KM_PRESS, KM_CTRL, 0); -// RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_restrictrender_set", HKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "unselected", 1); // conflicts, removing + WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_clear", HKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_set", HKEY, KM_PRESS, KM_CTRL, 0); +// RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_set", HKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "unselected", 1); // conflicts, removing WM_keymap_add_item(keymap, "OBJECT_OT_move_to_layer", MKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 81d4e8b6b01..494e42ea2c8 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -322,7 +322,7 @@ static void nla_panel_properties(const bContext *C, Panel *pa) column= uiLayoutColumn(layout, 1); uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "animated_influence") || RNA_boolean_get(&strip_ptr, "animated_time"))); uiItemL(column, "Playback Settings:", 0); - uiItemR(column, &strip_ptr, "muted", 0, NULL, 0); + uiItemR(column, &strip_ptr, "mute", 0, NULL, 0); uiItemR(column, &strip_ptr, "reversed", 0, NULL, 0); } diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 95e2cb920fc..3cdc2437c45 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -5115,17 +5115,17 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, - &ptr, "restrict_view", -1, 0, 0, -1, -1, NULL); + &ptr, "hide", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_view_cb, scene, ob); bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, - &ptr, "restrict_select", -1, 0, 0, -1, -1, NULL); + &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob); bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, - &ptr, "restrict_render", -1, 0, 0, -1, -1, NULL); + &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob); uiBlockSetEmboss(block, UI_EMBOSS); diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 1f542e2babe..64adb16c9c7 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -326,14 +326,14 @@ static void rna_def_action_group(BlenderRNA *brna) RNA_def_property_collection_funcs(prop, 0, "rna_ActionGroup_channels_next", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Channels", "F-Curves in this group"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_SELECTED); - RNA_def_property_ui_text(prop, "Selected", "Action Group is selected"); + RNA_def_property_ui_text(prop, "Select", "Action Group is selected"); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_SELECTED, NULL); - prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_PROTECTED); - RNA_def_property_ui_text(prop, "Locked", "Action Group is locked"); + RNA_def_property_ui_text(prop, "Lock", "Action Group is locked"); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_animviz.c b/source/blender/makesrna/intern/rna_animviz.c index 985521fe2c6..a85f19e7be4 100644 --- a/source/blender/makesrna/intern/rna_animviz.c +++ b/source/blender/makesrna/intern/rna_animviz.c @@ -104,9 +104,9 @@ static void rna_def_animviz_motionpath_vert(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Coordinates", ""); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOTIONPATH_VERT_SEL); - RNA_def_property_ui_text(prop, "Selected", "Path point is selected for editing"); + RNA_def_property_ui_text(prop, "Select", "Path point is selected for editing"); } static void rna_def_animviz_motion_path(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 9239378f496..437a22b6692 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -443,7 +443,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) RNA_def_property_ui_text(prop, "Cyclic Offset", "When bone doesn't have a parent, it receives cyclic offset effects"); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - prop= RNA_def_property(srna, "restrict_select", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_UNSELECTABLE); RNA_def_property_ui_text(prop, "Selectable", "Bone is able to be selected"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); @@ -523,14 +523,14 @@ static void rna_def_bone(BlenderRNA *brna) rna_def_bone_common(srna, 0); // XXX should we define this in PoseChannel wrapping code instead? but PoseChannels directly get some of their flags from here... - prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_P); - RNA_def_property_ui_text(prop, "Hidden", "Bone is not visible when it is not in Edit Mode (i.e. in Object or Pose Modes)"); + RNA_def_property_ui_text(prop, "Hide", "Bone is not visible when it is not in Edit Mode (i.e. in Object or Pose Modes)"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_SELECTED); - RNA_def_property_ui_text(prop, "Selected", ""); + RNA_def_property_ui_text(prop, "Select", ""); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); /* XXX better matrix descriptions possible (Arystan) */ @@ -604,29 +604,29 @@ static void rna_def_edit_bone(BlenderRNA *brna) rna_def_bone_common(srna, 1); - prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_A); - RNA_def_property_ui_text(prop, "Hidden", "Bone is not visible when in Edit Mode"); + RNA_def_property_ui_text(prop, "Hide", "Bone is not visible when in Edit Mode"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_EDITMODE_LOCKED); - RNA_def_property_ui_text(prop, "Locked", "Bone is not able to be transformed when in Edit Mode"); + RNA_def_property_ui_text(prop, "Lock", "Bone is not able to be transformed when in Edit Mode"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_SELECTED); - RNA_def_property_ui_text(prop, "Selected", ""); + RNA_def_property_ui_text(prop, "Select", ""); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "selected_head", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_head", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ROOTSEL); - RNA_def_property_ui_text(prop, "Head Selected", ""); + RNA_def_property_ui_text(prop, "Head Select", ""); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); - prop= RNA_def_property(srna, "selected_tail", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_tail", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_TIPSEL); - RNA_def_property_ui_text(prop, "Tail Selected", ""); + RNA_def_property_ui_text(prop, "Tail Select", ""); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); /* calculated and read only, not actual data access */ diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 218ca55e72d..9e004cd5946 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -305,9 +305,9 @@ static void rna_def_curvemappoint(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Handle Type", "Curve interpolation at this point: bezier or vector"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CUMA_SELECT); - RNA_def_property_ui_text(prop, "Selected", "Selection state of the curve point"); + RNA_def_property_ui_text(prop, "Select", "Selection state of the curve point"); } static void rna_def_curvemap(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index fb19e8976c3..1c6c35a88de 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1034,7 +1034,7 @@ static void rna_def_constraint_locked_track(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Track Axis", "Axis that points to the target object"); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "locked", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "lock", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "lockflag"); RNA_def_property_enum_items(prop, lock_items); RNA_def_property_ui_text(prop, "Locked Axis", "Axis that points upward"); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index d8bc683ae12..9301e8dd142 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -525,14 +525,14 @@ static void rna_def_bpoint(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "SplinePoint", "Spline point without handles"); /* Boolean values */ - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f1", 0); - RNA_def_property_ui_text(prop, "Selected", "Selection status"); + RNA_def_property_ui_text(prop, "Select", "Selection status"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "hide", 0); - RNA_def_property_ui_text(prop, "Hidden", "Visibility status"); + RNA_def_property_ui_text(prop, "Hide", "Visibility status"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Vector value */ @@ -578,24 +578,24 @@ static void rna_def_beztriple(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Bezier Curve Point", "Bezier curve point with two handles"); /* Boolean values */ - prop= RNA_def_property(srna, "selected_handle1", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f1", 0); RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "selected_handle2", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f3", 0); RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "selected_control_point", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f2", 0); RNA_def_property_ui_text(prop, "Control Point selected", "Control point selection status"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "hide", 0); - RNA_def_property_ui_text(prop, "Hidden", "Visibility status"); + RNA_def_property_ui_text(prop, "Hide", "Visibility status"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Enums */ diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index d798753d123..cd58b6574be 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -940,7 +940,7 @@ static void rna_def_fmodifier(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI"); RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); - prop= RNA_def_property(srna, "muted", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_MUTED); RNA_def_property_ui_text(prop, "Muted", "F-Curve Modifier will not be evaluated"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); @@ -1156,9 +1156,9 @@ static void rna_def_fpoint(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "F-Curve Sample", "Sample point for F-Curve"); /* Boolean values */ - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", 1); - RNA_def_property_ui_text(prop, "Selected", "Selection status"); + RNA_def_property_ui_text(prop, "Select", "Selection status"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); /* Vector value */ @@ -1183,19 +1183,19 @@ static void rna_def_fkeyframe(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Keyframe", "Bezier curve point with two handles defining a Keyframe on an F-Curve"); /* Boolean values */ - prop= RNA_def_property(srna, "selected_handle1", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f1", 0); RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); - prop= RNA_def_property(srna, "selected_handle2", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f3", 0); RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "f2", 0); - RNA_def_property_ui_text(prop, "Selected", "Control point selection status"); + RNA_def_property_ui_text(prop, "Select", "Control point selection status"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); /* Enums */ @@ -1384,17 +1384,17 @@ static void rna_def_fcurve(BlenderRNA *brna) RNA_def_property_update(prop, NC_ANIMATION, NULL); /* Flags */ - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_SELECTED); - RNA_def_property_ui_text(prop, "Selected", "F-Curve is selected for editing"); + RNA_def_property_ui_text(prop, "Select", "F-Curve is selected for editing"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); - prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_PROTECTED); - RNA_def_property_ui_text(prop, "Locked", "F-Curve's settings cannot be edited"); + RNA_def_property_ui_text(prop, "Lock", "F-Curve's settings cannot be edited"); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); - prop= RNA_def_property(srna, "muted", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_MUTED); RNA_def_property_ui_text(prop, "Muted", "F-Curve is not evaluated"); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); @@ -1404,15 +1404,15 @@ static void rna_def_fcurve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Auto Clamped Handles", "All auto-handles for F-Curve are clamped"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); - prop= RNA_def_property(srna, "visible", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_VISIBLE); - RNA_def_property_ui_text(prop, "Visible", "F-Curve and its keyframes are shown in the Graph Editor graphs"); + prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_VISIBLE); + RNA_def_property_ui_text(prop, "Hide", "F-Curve and its keyframes are hidden in the Graph Editor graphs"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL); - + /* State Info (for Debugging) */ - prop= RNA_def_property(srna, "disabled", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_DISABLED); - RNA_def_property_ui_text(prop, "Disabled", "F-Curve could not be evaluated in past, so should be skipped when evaluating"); + prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_DISABLED); + RNA_def_property_ui_text(prop, "Enabled", "False when F-Curve could not be evaluated in past, so should be skipped when evaluating"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); /* Collections */ diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index a503eab4ba9..0994f67879e 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -135,9 +135,9 @@ static void rna_def_gpencil_frame(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_FRAME_PAINT); // XXX should it be editable? RNA_def_property_ui_text(prop, "Paint Lock", "Frame is being edited (painted on)"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_FRAME_SELECT); - RNA_def_property_ui_text(prop, "Selected", "Frame is selected for editing in the DopeSheet"); + RNA_def_property_ui_text(prop, "Select", "Frame is selected for editing in the DopeSheet"); } static void rna_def_gpencil_layer(BlenderRNA *brna) @@ -203,7 +203,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Hide", "Set layer Visibility"); RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL); - prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE); + 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_text(prop, "Locked", "Protect layer from further editing and/or frame changes"); RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL); @@ -219,9 +219,9 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Active", "Set active layer for editing"); RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + 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, "Selected", "Layer is selected for editing in the DopeSheet"); + RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the DopeSheet"); RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL); // XXX keep this option? diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index b289373f349..8330e0dc32c 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1106,14 +1106,14 @@ static void rna_def_mvert(BlenderRNA *brna) RNA_def_property_float_funcs(prop, "rna_MeshVertex_normal_get", "rna_MeshVertex_normal_set", NULL); RNA_def_property_ui_text(prop, "Normal", "Vertex Normal"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); - RNA_def_property_ui_text(prop, "Selected", ""); + RNA_def_property_ui_text(prop, "Select", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); - prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE); - RNA_def_property_ui_text(prop, "Hidden", ""); + RNA_def_property_ui_text(prop, "Hide", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); prop= RNA_def_property(srna, "bevel_weight", PROP_FLOAT, PROP_NONE); @@ -1159,14 +1159,14 @@ static void rna_def_medge(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Bevel Weight", "Weight used by the Bevel modifier"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); - RNA_def_property_ui_text(prop, "Selected", ""); + RNA_def_property_ui_text(prop, "Select", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); - prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE); - RNA_def_property_ui_text(prop, "Hidden", ""); + RNA_def_property_ui_text(prop, "Hide", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); prop= RNA_def_property(srna, "seam", PROP_BOOLEAN, PROP_NONE); @@ -1226,14 +1226,14 @@ static void rna_def_mface(BlenderRNA *brna) RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MeshFace_material_index_range"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FACE_SEL); - RNA_def_property_ui_text(prop, "Selected", ""); + RNA_def_property_ui_text(prop, "Select", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); - prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE); - RNA_def_property_ui_text(prop, "Hidden", ""); + RNA_def_property_ui_text(prop, "Hide", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); prop= RNA_def_property(srna, "smooth", PROP_BOOLEAN, PROP_NONE); @@ -1383,7 +1383,7 @@ static void rna_def_mtface(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Transparency", "Transparency blending mode"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - prop= RNA_def_property(srna, "uv_selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_uv", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", TF_SEL1); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "UV Selected", ""); diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index accb40d2223..59c7607e930 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -422,11 +422,11 @@ static void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_ACTIVE); RNA_def_property_ui_text(prop, "Active", "NLA Strip is active"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_SELECT); - RNA_def_property_ui_text(prop, "Selected", "NLA Strip is selected"); + RNA_def_property_ui_text(prop, "Select", "NLA Strip is selected"); - prop= RNA_def_property(srna, "muted", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_MUTED); RNA_def_property_ui_text(prop, "Muted", "NLA Strip is not evaluated"); @@ -468,15 +468,15 @@ static void rna_def_nlatrack(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_SOLO); RNA_def_property_ui_text(prop, "Solo", "NLA Track is evaluated itself (i.e. active Action and all other NLA Tracks in the same AnimData block are disabled)"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_SELECTED); - RNA_def_property_ui_text(prop, "Selected", "NLA Track is selected"); + RNA_def_property_ui_text(prop, "Select", "NLA Track is selected"); - prop= RNA_def_property(srna, "muted", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_MUTED); RNA_def_property_ui_text(prop, "Muted", "NLA Track is not evaluated"); - prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_PROTECTED); RNA_def_property_ui_text(prop, "Locked", "NLA Track is locked"); } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index e45a776eea2..8b285c42e11 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1538,9 +1538,9 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_layer_update"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); - RNA_def_property_ui_text(prop, "Selected", "Object selection state"); + RNA_def_property_ui_text(prop, "Select", "Object selection state"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_select_update"); /* for data access */ @@ -1842,19 +1842,19 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_particle_update"); /* restrict */ - prop= RNA_def_property(srna, "restrict_view", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW); RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - prop= RNA_def_property(srna, "restrict_select", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT); RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - prop= RNA_def_property(srna, "restrict_render", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER); RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); @@ -2111,9 +2111,9 @@ static void rna_def_object_base(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Base_layer_update"); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT); - RNA_def_property_ui_text(prop, "Selected", "Object base selection state"); + RNA_def_property_ui_text(prop, "Select", "Object base selection state"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Base_select_update"); RNA_api_object_base(srna); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 211583e3df6..21ece0ac4a9 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -698,9 +698,9 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_struct_name_property(srna, prop); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "selectflag", BONE_SELECTED); - RNA_def_property_ui_text(prop, "Selected", ""); + RNA_def_property_ui_text(prop, "Select", ""); /* Baked Bone Path cache data */ rna_def_motionpath_common(srna); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index f46efb675ca..7adf4e7d35d 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -776,17 +776,17 @@ static void rna_def_sequence(BlenderRNA *brna) /* flags */ - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); - RNA_def_property_ui_text(prop, "Selected", ""); + RNA_def_property_ui_text(prop, "Select", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER|NA_SELECTED, NULL); - prop= RNA_def_property(srna, "left_handle_selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_LEFTSEL); RNA_def_property_ui_text(prop, "Left Handle Selected", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER|NA_SELECTED, NULL); - prop= RNA_def_property(srna, "right_handle_selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_RIGHTSEL); RNA_def_property_ui_text(prop, "Right Handle Selected", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER|NA_SELECTED, NULL); diff --git a/source/blender/makesrna/intern/rna_timeline.c b/source/blender/makesrna/intern/rna_timeline.c index afc1d087cf2..a436c746910 100644 --- a/source/blender/makesrna/intern/rna_timeline.c +++ b/source/blender/makesrna/intern/rna_timeline.c @@ -55,9 +55,9 @@ static void rna_def_timeline_marker(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Frame", "The frame on which the timeline marker appears"); RNA_def_property_update(prop, NC_ANIMATION, NULL); - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", 1 /*SELECT*/); - RNA_def_property_ui_text(prop, "Selected", "Marker selection state"); + RNA_def_property_ui_text(prop, "Select", "Marker selection state"); RNA_def_property_update(prop, NC_ANIMATION, NULL); #ifdef DURIAN_CAMERA_SWITCH diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index a03488d3878..32d69e48adf 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1622,10 +1622,10 @@ static void rna_def_userdef_theme_colorset(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Normal", "Color used for the surface of bones"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop= RNA_def_property(srna, "selected", PROP_FLOAT, PROP_COLOR); + prop= RNA_def_property(srna, "select", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "select"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Selected", "Color used for selected bones"); + RNA_def_property_ui_text(prop, "Select", "Color used for selected bones"); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop= RNA_def_property(srna, "active", PROP_FLOAT, PROP_COLOR); diff --git a/source/blender/makesrna/rna_cleanup/rna_booleans.txt b/source/blender/makesrna/rna_cleanup/rna_booleans.txt index 87d4f8a0736..5c98ef7b9ad 100644 --- a/source/blender/makesrna/rna_cleanup/rna_booleans.txt +++ b/source/blender/makesrna/rna_cleanup/rna_booleans.txt @@ -1,7 +1,6 @@ ActionActuator.continue_last_frame -> use_continue_last_frame: boolean Restore last frame when switching on/off, otherwise play from the start each time ActionGroup.expanded -> show_expanded: boolean Action Group is expanded -ActionGroup.locked -> lock: boolean Action Group is locked -ActionGroup.selected -> select: boolean Action Group is selected + Actuator.expanded -> show_expanded: boolean Set actuator expanded in the user interface AnimData.nla_enabled -> use_nla: boolean NLA stack is evaluated when evaluating this block AnimVizMotionPaths.highlight_keyframes -> show_keyframe_highlight: boolean Emphasize position of keyframes on Motion Paths @@ -40,10 +39,7 @@ ArrayModifier.merge_end_vertices -> use_merge_end_vertices: boolean Merge ArrayModifier.relative_offset -> use_relative_offset: boolean Add an offset relative to the object's bounding box BackgroundImage.show_expanded -> show_expanded: boolean Show the expanded in the user interface BevelModifier.only_vertices -> use_only_vertices: boolean Bevel verts/corners, not edges -BezierSplinePoint.hidden -> hide: boolean Visibility status -BezierSplinePoint.selected_control_point -> select_control_point: boolean Control point selection status -BezierSplinePoint.selected_handle1 -> select_left_handle: boolean Handle 1 selection status -BezierSplinePoint.selected_handle2 -> select_right_handle: boolean Handle 2 selection status + BoidRule.in_air -> use_in_air: boolean Use rule when boid is flying BoidRule.on_land -> use_on_land: boolean Use rule when boid is on land BoidRuleAvoid.predict -> use_predict: boolean Predict target movement @@ -58,14 +54,12 @@ Bone.connected -> use_connect: boolean, (read-only) When bone has a parent Bone.cyclic_offset -> use_cyclic_offset: boolean When bone doesn't have a parent, it receives cyclic offset effects Bone.deform -> use_deform: boolean Bone does not deform any geometry Bone.draw_wire -> show_wire: boolean Bone is always drawn as Wireframe regardless of viewport draw mode. Useful for non-obstructive custom bone shapes -Bone.hidden -> hide: boolean Bone is not visible when it is not in Edit Mode (i.e. in Object or Pose Modes) + Bone.hinge -> use_hinge: boolean Bone inherits rotation or scale from parent bone Bone.inherit_scale -> use_inherit_scale: boolean Bone inherits scaling from parent bone Bone.layer -> layer: boolean Layers bone exists in Bone.local_location -> use_local_location: boolean Bone location is set in local space Bone.multiply_vertexgroup_with_envelope -> use_envelope_multiply: boolean When deforming bone, multiply effects of Vertex Group weights with Envelope influence -Bone.restrict_select -> hide_select: boolean Bone is able to be selected -Bone.selected -> select: boolean BooleanProperty.default -> default: boolean, (read-only) Default value for this number BooleanProperty.default_array -> default_array: boolean, (read-only) Default value for this array Brush.use_accumulate -> use_accumulate: boolean Accumulate stroke dabs on top of each other @@ -180,7 +174,7 @@ Curve.use_path_follow -> use_path_follow: boolean Make curve path children Curve.use_radius -> use_radius: boolean Option for paths: apply the curve radius with path following it and deforming Curve.use_stretch -> use_stretch: boolean Option for curve-deform: makes deformed child to stretch along entire path Curve.use_time_offset -> use_time_offset: boolean Children will use Time Offset value as path distance offset -CurveMapPoint.selected -> select: boolean Selection state of the curve point + CurveMapping.clip -> use_clip: boolean Force the curve view to fit a defined boundary DelaySensor.repeat -> use_repeat: boolean Toggle repeat option. If selected, the sensor restarts after Delay+Dur logic tics DomainFluidSettings.generate_speed_vectors -> use_speed_vectors: boolean Generate speed vectors for vector blur @@ -214,17 +208,13 @@ EditBone.connected -> use_connect: boolean When bone has a parent, bone's EditBone.cyclic_offset -> use_cyclic_offset: boolean When bone doesn't have a parent, it receives cyclic offset effects EditBone.deform -> use_deform: boolean Bone does not deform any geometry EditBone.draw_wire -> show_wire: boolean Bone is always drawn as Wireframe regardless of viewport draw mode. Useful for non-obstructive custom bone shapes -EditBone.hidden -> hide: boolean Bone is not visible when in Edit Mode + EditBone.hinge -> use_hinge: boolean Bone inherits rotation or scale from parent bone EditBone.inherit_scale -> use_inherit_scale: boolean Bone inherits scaling from parent bone EditBone.layer -> layer: boolean Layers bone exists in EditBone.local_location -> use_local_location: boolean Bone location is set in local space -EditBone.locked -> lock: boolean Bone is not able to be transformed when in Edit Mode EditBone.multiply_vertexgroup_with_envelope -> use_envelope_multiply: boolean When deforming bone, multiply effects of Vertex Group weights with Envelope influence -EditBone.restrict_select -> hide_select: boolean Bone is able to be selected -EditBone.selected -> select: boolean -EditBone.selected_head -> select_head: boolean -EditBone.selected_tail -> select_tail: boolean + EditObjectActuator.enable_3d_tracking -> use_3d_tracking: boolean Enable 3D tracking EditObjectActuator.local_angular_velocity -> use_local_angular_velocity: boolean Apply the rotation locally EditObjectActuator.local_linear_velocity -> use_local_linear_velocity: boolean Apply the transformation locally @@ -257,16 +247,9 @@ ExplodeModifier.size -> use_size: boolean Use particle size for the shrapn ExplodeModifier.split_edges -> use_edge_split: boolean Split face edges for nicer shrapnel ExplodeModifier.unborn -> show_unborn: boolean Show mesh when particles are unborn FCurve.auto_clamped_handles -> use_auto_handle_clamp: boolean All auto-handles for F-Curve are clamped -NEGATE * FCurve.disabled -> enabled: boolean F-Curve could not be evaluated in past, so should be skipped when evaluating -FCurve.locked -> lock: boolean F-Curve's settings cannot be edited -FCurve.muted -> mute: boolean F-Curve is not evaluated -FCurve.selected -> select: boolean F-Curve is selected for editing -NEGATE * FCurve.visible -> hide: boolean F-Curve and its keyframes are shown in the Graph Editor graphs -FCurveSample.selected -> select: boolean Selection status FModifier.active -> active: boolean F-Curve Modifier is the one being edited NEGATE * FModifier.disabled -> enabled: boolean, (read-only) F-Curve Modifier has invalid settings and will not be evaluated FModifier.expanded -> show_expanded: boolean F-Curve Modifier's panel is expanded in UI -FModifier.muted -> mute: boolean F-Curve Modifier will not be evaluated FModifierFunctionGenerator.additive -> use_additive: boolean Values generated by this modifier are applied on top of the existing values instead of overwriting them FModifierGenerator.additive -> use_additive: boolean Values generated by this modifier are applied on top of the existing values instead of overwriting them FModifierLimits.use_maximum_x -> use_max_x: boolean Use the maximum X value @@ -314,12 +297,10 @@ FollowPathConstraint.use_fixed_position -> use_fixed_location: boolean Obj Function.registered -> is_registered: boolean, (read-only) Function is registered as callback as part of type registration Function.registered_optional -> is_registered_optional: boolean, (read-only) Function is optionally registered as callback part of type registration GPencilFrame.paint_lock -> is_edited: boolean Frame is being edited (painted on) -GPencilFrame.selected -> select: boolean Frame is selected for editing in the DopeSheet GPencilLayer.active -> active: boolean Set active layer for editing GPencilLayer.frame_lock -> lock_frame: boolean Lock current frame displayed by layer GPencilLayer.hide -> hide: boolean Set layer Visibility -GPencilLayer.locked -> lock: boolean Protect layer from further editing and/or frame changes -GPencilLayer.selected -> select: boolean Layer is selected for editing in the DopeSheet + GPencilLayer.show_points -> show_points: boolean Draw the points which make up the strokes (for debugging purposes) GPencilLayer.use_onion_skinning -> use_onion_skinning: boolean Ghost frames on either side of frame GameBooleanProperty.value -> value: boolean Property value @@ -420,9 +401,6 @@ KeyMapItem.expanded -> show_expanded: boolean Show key map event and prope KeyMapItem.oskey -> oskey: boolean Operating system key pressed KeyMapItem.shift -> shift: boolean Shift key pressed KeyboardSensor.all_keys -> use_all_keys: boolean Trigger this sensor on any keystroke -Keyframe.selected -> select: boolean Control point selection status -Keyframe.selected_handle1 -> select_left_handle: boolean Handle 1 selection status -Keyframe.selected_handle2 -> select_right_handle: boolean Handle 2 selection status KeyingSet.absolute -> use_absolute: boolean Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info) KeyingSet.insertkey_needed -> use_insertkey_needed: boolean Only insert keyframes where they're needed in the relevant F-Curves KeyingSet.insertkey_visual -> use_insertkey_visual: boolean Insert keyframes based on 'visual transforms' @@ -568,13 +546,10 @@ MeshDeformModifier.dynamic -> dynamic: boolean Recompute binding dynamical MeshDeformModifier.invert -> invert_vertex_group: boolean Invert vertex group influence MeshDeformModifier.is_bound -> is_bound: boolean, (read-only) Whether geometry has been bound to control cage MeshEdge.fgon -> is_fgon: boolean, (read-only) Fgon edge -MeshEdge.hidden -> hide: boolean MeshEdge.loose -> is_loose: boolean, (read-only) Loose edge MeshEdge.seam -> use_seam: boolean Seam edge for UV unwrapping -MeshEdge.selected -> select: boolean MeshEdge.sharp -> use_sharp: boolean Sharp edge for the EdgeSplit modifier -MeshFace.hidden -> hide: boolean -MeshFace.selected -> select: boolean + MeshFace.smooth -> use_smooth: boolean MeshTextureFace.alpha_sort -> use_alpha_sort: boolean Enable sorting of faces for correct alpha drawing (slow, use Clip Alpha instead when possible) MeshTextureFace.billboard -> use_billboard: boolean Billboard with Z-axis constraint @@ -589,12 +564,10 @@ MeshTextureFace.tex -> use_texture: boolean Render face with texture MeshTextureFace.text -> use_bitmap_text: boolean Enable bitmap text on face MeshTextureFace.twoside -> use_twoside: boolean Render face two-sided MeshTextureFace.uv_pinned -> uv_pin: boolean -MeshTextureFace.uv_selected -> uv_select: boolean +MeshTextureFace.uv_selected -> select_uv: boolean MeshTextureFaceLayer.active -> active: boolean Sets the layer as active for display and editing MeshTextureFaceLayer.active_clone -> active_clone: boolean Sets the layer as active for cloning MeshTextureFaceLayer.active_render -> active_render: boolean Sets the layer as active for rendering -MeshVertex.hidden -> hide: boolean -MeshVertex.selected -> select: boolean MetaBall.auto_texspace -> use_auto_texspace: boolean Adjusts active object's texture space automatically when transforming object MetaElement.hide -> hide: boolean Hide element MetaElement.negative -> use_negative: boolean Set metaball as negative one @@ -624,7 +597,6 @@ Modifier.realtime -> show_realtime: boolean Realtime display of a modifier Modifier.render -> use_render: boolean Use modifier during rendering MotionPath.editing -> is_edited: boolean Path is being edited MotionPath.use_bone_head -> use_bone_head: boolean, (read-only) For PoseBone paths, use the bone head location when calculating this path -MotionPathVert.selected -> select: boolean Path point is selected for editing MovieSequence.convert_float -> use_float: boolean Convert input to float data MovieSequence.de_interlace -> use_deinterlace: boolean For video movies to remove fields MovieSequence.flip_x -> use_flip_x: boolean Flip on the X axis @@ -663,11 +635,7 @@ NlaStrip.animated_time_cyclic -> use_animated_time_cyclic: boolean Cycle t NlaStrip.auto_blending -> use_auto_blend: boolean Number of frames for Blending In/Out is automatically determined from overlapping strips NlaStrip.muted -> mute: boolean NLA Strip is not evaluated NlaStrip.reversed -> use_reverse: boolean NLA Strip is played back in reverse order (only when timing is automatically determined) -NlaStrip.selected -> select: boolean NLA Strip is selected NlaTrack.active -> active: boolean, (read-only) NLA Track is active -NlaTrack.locked -> lock: boolean NLA Track is locked -NlaTrack.muted -> mute: boolean NLA Track is not evaluated -NlaTrack.selected -> select: boolean NLA Track is selected NlaTrack.solo -> is_solo: boolean, (read-only) NLA Track is evaluated itself (i.e. active Action and all other NLA Tracks in the same AnimData block are disabled) Object.draw_axis -> show_axis: boolean Displays the object's origin and axis Object.draw_bounds -> show_bounds: boolean Displays the object's bounds @@ -682,10 +650,7 @@ Object.lock_rotation -> lock_rotation: boolean Lock editing of rotation in Object.lock_rotation_w -> lock_rotation_w: boolean Lock editing of 'angle' component of four-component rotations in the interface Object.lock_rotations_4d -> lock_rotations_4d: boolean Lock editing of four component rotations by components (instead of as Eulers) Object.lock_scale -> lock_scale: boolean Lock editing of scale in the interface -Object.restrict_render -> hide_render: boolean Restrict renderability -Object.restrict_select -> hide_select: boolean Restrict selection in the viewport -Object.restrict_view -> hide: boolean Restrict visibility in the viewport -Object.selected -> select: boolean Object selection state + Object.shape_key_edit_mode -> use_shape_key_edit_mode: boolean Apply shape keys in edit mode (for Meshes only) Object.shape_key_lock -> show_shape_key: boolean Always show the current Shape for this Object Object.slow_parent -> use_slow_parent: boolean Create a delay in the parent relationship @@ -708,7 +673,6 @@ ObjectActuator.servo_limit_x -> use_servo_limit_x: boolean Set limit to fo ObjectActuator.servo_limit_y -> use_servo_limit_y: boolean Set limit to force along the Y axis ObjectActuator.servo_limit_z -> use_servo_limit_z: boolean Set limit to force along the Z axis ObjectBase.layers -> layer: boolean Layers the object base is on -ObjectBase.selected -> select: boolean Object base selection state ObstacleFluidSettings.active -> use: boolean Object contributes to the fluid simulation ObstacleFluidSettings.export_animated_mesh -> use_animated_mesh: boolean Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures or parented objects), animated pos/rot/scale IPOs do not require it Operator.has_reports -> has_reports: boolean, (read-only) Operator has a set of reports (warnings and errors) from last execution @@ -825,7 +789,7 @@ PoseBone.lock_rotation -> lock_rotation: boolean Lock editing of rotation PoseBone.lock_rotation_w -> lock_rotation_w: boolean Lock editing of 'angle' component of four-component rotations in the interface PoseBone.lock_rotations_4d -> lock_rotations_4d: boolean Lock editing of four component rotations by components (instead of as Eulers) PoseBone.lock_scale -> lock_scale: boolean Lock editing of scale in the interface -PoseBone.selected -> select: boolean + PoseTemplateSettings.generate_def_rig -> use_generate_deform_rig: boolean Create a copy of the metarig, constrainted by the generated rig Property.is_never_none -> is_never_none: boolean, (read-only) True when this value can't be set to None Property.is_readonly -> is_readonly: boolean, (read-only) Property is editable through RNA @@ -1037,11 +1001,8 @@ Sensor.pulse_false_level -> use_pulse_false_level: boolean Activate FALSE Sensor.pulse_true_level -> use_pulse_true_level: boolean Activate TRUE level triggering (pulse mode) Sensor.tap -> use_tap: boolean Trigger controllers only for an instant, even while the sensor remains true Sequence.frame_locked -> use_frame_lock: boolean Lock the animation curve to the global frame counter -Sequence.left_handle_selected -> select_left_handle: boolean Sequence.lock -> lock: boolean Lock strip so that it can't be transformed Sequence.mute -> mute: boolean -Sequence.right_handle_selected -> select_right_handle: boolean -Sequence.selected -> select: boolean Sequence.use_effect_default_fade -> use_default_fade: boolean Fade effect using the built-in default (usually make transition as long as effect strip) SequenceColorBalance.inverse_gain -> invert_gain: boolean SequenceColorBalance.inverse_gamma -> invert_gamma: boolean @@ -1208,8 +1169,7 @@ SplineIKConstraint.chain_offset -> use_chain_offset: boolean Offset the en SplineIKConstraint.even_divisions -> use_even_divisions: boolean Ignore the relative lengths of the bones when fitting to the curve SplineIKConstraint.use_curve_radius -> use_curve_radius: boolean Average radius of the endpoints is used to tweak the X and Z Scaling of the bones, on top of XZ Scale mode SplineIKConstraint.y_stretch -> use_y_stretch: boolean Stretch the Y axis of the bones to fit the curve -SplinePoint.hidden -> hide: boolean Visibility status -SplinePoint.selected -> select_control_point: boolean Selection status + SpotLamp.auto_clip_end -> use_auto_clip_end: boolean Automatic calculation of clipping-end, based on visible vertices SpotLamp.auto_clip_start -> use_auto_clip_start: boolean Automatic calculation of clipping-start, based on visible vertices SpotLamp.halo -> use_halo: boolean Renders spotlight with a volumetric halo (Buffer Shadows) @@ -1251,7 +1211,6 @@ TextureSlot.rgb_to_intensity -> use_rgb_to_intensity: boolean Converts tex TextureSlot.stencil -> use_stencil: boolean Use this texture as a blending value on the next texture ThemeBoneColorSet.colored_constraints -> show_colored_constraints: boolean Allow the use of colors indicating constraints/keyed status ThemeWidgetColors.shaded -> show_shaded: boolean -TimelineMarker.selected -> select: boolean Marker selection state ToolSettings.auto_normalize -> use_auto_normalize: boolean Ensure all bone-deforming vertex groups add up to 1.0 while weight painting ToolSettings.automerge_editing -> use_automerge_editing: boolean Automatically merge vertices moved to the same location ToolSettings.bone_sketching -> use_bone_sketching: boolean DOC BROKEN From 5ae1687bd7894e1676f1a940f71b07d8a16bf234 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Jul 2010 17:36:00 +0000 Subject: [PATCH 31/51] fix for one of the problems with [#22846] GCC 4.4.1 support in Windows --- source/blender/blenlib/intern/storage.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 3315e9645d4..4fb5ca77989 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -29,6 +29,11 @@ * Some really low-level file thingies. */ +/* needed for mingw & _stat64i32 */ +#ifdef FREE_WINDOWS +# define __MSVCRT_VERSION__ 0x0800 +#endif + #include #include #include From 68c59beefdd19fb9140852da8c879ad5d8876101 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Jul 2010 17:54:53 +0000 Subject: [PATCH 32/51] RNA cleanup: some more boolean changes based on discussion with Luca. --- .../makesrna/rna_cleanup/rna_booleans.txt | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/source/blender/makesrna/rna_cleanup/rna_booleans.txt b/source/blender/makesrna/rna_cleanup/rna_booleans.txt index 5c98ef7b9ad..ac3da595ee4 100644 --- a/source/blender/makesrna/rna_cleanup/rna_booleans.txt +++ b/source/blender/makesrna/rna_cleanup/rna_booleans.txt @@ -24,8 +24,8 @@ Armature.draw_custom_bone_shapes -> show_bone_custom_shapes: boolean Draw Armature.draw_group_colors -> show_group_colors: boolean Draw bone group colors Armature.draw_names -> show_names: boolean Draw bone names Armature.show_ghost_only_selected -> show_only_ghost_selected: boolean -Armature.layer -> layer: boolean Armature layer visibility -Armature.layer_protection -> layer_protected: boolean Protected layers in Proxy Instances are restored to Proxy settings on file reload and undo +Armature.layer -> layers: boolean Armature layer visibility +Armature.layer_protection -> layers_protected: boolean Protected layers in Proxy Instances are restored to Proxy settings on file reload and undo Armature.x_axis_mirror -> use_mirror_x: boolean Apply changes to matching bone on opposite side of X-Axis ArmatureModifier.invert -> invert_vertex_group: boolean Invert vertex group influence ArmatureModifier.multi_modifier -> use_multi_modifier: boolean Use same input as previous modifier, and mix results using overall vgroup @@ -57,7 +57,7 @@ Bone.draw_wire -> show_wire: boolean Bone is always drawn as Wireframe reg Bone.hinge -> use_hinge: boolean Bone inherits rotation or scale from parent bone Bone.inherit_scale -> use_inherit_scale: boolean Bone inherits scaling from parent bone -Bone.layer -> layer: boolean Layers bone exists in +Bone.layer -> layers: boolean Layers bone exists in Bone.local_location -> use_local_location: boolean Bone location is set in local space Bone.multiply_vertexgroup_with_envelope -> use_envelope_multiply: boolean When deforming bone, multiply effects of Vertex Group weights with Envelope influence BooleanProperty.default -> default: boolean, (read-only) Default value for this number @@ -143,7 +143,7 @@ ControlFluidSettings.active -> use: boolean Object contributes to the flui ControlFluidSettings.reverse_frames -> use_reverse_frames: boolean Reverse control object movement Controller.expanded -> show_expanded: boolean Set controller expanded in the user interface Controller.priority -> use_priority: boolean Mark controller for execution before all non-marked controllers (good for startup scripts) -Controller.state -> state: boolean, (read-only) Set Controller state index (1 to 30) +Controller.state -> states: boolean, (read-only) Set Controller state index (1 to 30) CopyLocationConstraint.invert_x -> invert_x: boolean Invert the X location CopyLocationConstraint.invert_y -> invert_y: boolean Invert the Y location CopyLocationConstraint.invert_z -> invert_z: boolean Invert the Z location @@ -211,7 +211,7 @@ EditBone.draw_wire -> show_wire: boolean Bone is always drawn as Wireframe EditBone.hinge -> use_hinge: boolean Bone inherits rotation or scale from parent bone EditBone.inherit_scale -> use_inherit_scale: boolean Bone inherits scaling from parent bone -EditBone.layer -> layer: boolean Layers bone exists in +EditBone.layer -> layers: boolean Layers bone exists in EditBone.local_location -> use_local_location: boolean Bone location is set in local space EditBone.multiply_vertexgroup_with_envelope -> use_envelope_multiply: boolean When deforming bone, multiply effects of Vertex Group weights with Envelope influence @@ -233,8 +233,8 @@ EffectSequence.use_crop -> use_crop: boolean Crop image before processing EffectSequence.use_proxy -> use_proxy: boolean Use a preview proxy for this strip EffectSequence.use_translation -> use_translation: boolean Translate image before processing EffectorWeights.do_growing_hair -> apply_to_hair_growing: boolean Use force fields when growing hair -EnvironmentMap.ignore_layers -> layer_ignore: boolean Hide objects on these layers when generating the Environment Map -EnvironmentMapTexture.use_filter_size_min -> filter_size_min: boolean Use Filter Size as a minimal filter value in pixels +EnvironmentMap.ignore_layers -> layers_ignore: boolean Hide objects on these layers when generating the Environment Map +EnvironmentMapTexture.use_filter_size_min -> use_minimum_filter_size: boolean Use Filter Size as a minimal filter value in pixels EnvironmentMapTexture.mipmap -> use_mipmap: boolean Uses auto-generated MIP maps for the image EnvironmentMapTexture.mipmap_gauss -> use_mipmap_gauss: boolean Uses Gauss filter to sample down MIP maps Event.alt -> alt: boolean, (read-only) True when the Alt/Option key is held @@ -248,7 +248,7 @@ ExplodeModifier.split_edges -> use_edge_split: boolean Split face edges fo ExplodeModifier.unborn -> show_unborn: boolean Show mesh when particles are unborn FCurve.auto_clamped_handles -> use_auto_handle_clamp: boolean All auto-handles for F-Curve are clamped FModifier.active -> active: boolean F-Curve Modifier is the one being edited -NEGATE * FModifier.disabled -> enabled: boolean, (read-only) F-Curve Modifier has invalid settings and will not be evaluated +NEGATE * FModifier.disabled -> use: boolean, (read-only) F-Curve Modifier has invalid settings and will not be evaluated FModifier.expanded -> show_expanded: boolean F-Curve Modifier's panel is expanded in UI FModifierFunctionGenerator.additive -> use_additive: boolean Values generated by this modifier are applied on top of the existing values instead of overwriting them FModifierGenerator.additive -> use_additive: boolean Values generated by this modifier are applied on top of the existing values instead of overwriting them @@ -310,7 +310,7 @@ GameObjectSettings.anisotropic_friction -> use_anisotropic_friction: boolean GameObjectSettings.collision_compound -> use_collision_compound: boolean Add children to form a compound collision object GameObjectSettings.debug_state -> show_debug_state: boolean Print state debug info in the game engine GameObjectSettings.ghost -> use_ghost: boolean Object does not restitute collisions, like a ghost -GameObjectSettings.initial_state -> state_initial: boolean Initial state when the game starts +GameObjectSettings.initial_state -> states_initial: boolean Initial state when the game starts GameObjectSettings.lock_x_axis -> lock_location_x: boolean Disable simulation of linear motion along the X axis GameObjectSettings.lock_x_rot_axis -> lock_rotation_x: boolean Disable simulation of angular motion along the X axis GameObjectSettings.lock_y_axis -> lock_location_y: boolean Disable simulation of linear motion along the Y axis @@ -326,8 +326,8 @@ GameObjectSettings.show_sensors -> show_sensors: boolean Shows sensors for GameObjectSettings.show_state_panel -> show_state_panel: boolean Show state panel GameObjectSettings.use_activity_culling -> use_activity_culling: boolean Disable simulation of angular motion along the Z axis GameObjectSettings.use_collision_bounds -> use_collision_bounds: boolean Specify a collision bounds type other than the default -GameObjectSettings.used_state -> state_used: boolean, (read-only) States which are being used by controllers -GameObjectSettings.visible_state -> state_visible: boolean State determining which controllers are displayed +GameObjectSettings.used_state -> states_used: boolean, (read-only) States which are being used by controllers +GameObjectSettings.visible_state -> states_visible: boolean State determining which controllers are displayed GameProperty.debug -> show_debug: boolean Print debug information for this property GameSoftBodySettings.bending_const -> use_bending_constraints: boolean Enable bending constraints GameSoftBodySettings.cluster_rigid_to_softbody -> use_cluster_rigid_to_softbody: boolean Enable cluster collision between soft and rigid body @@ -335,7 +335,7 @@ GameSoftBodySettings.cluster_soft_to_softbody -> use_cluster_soft_to_softbody: GameSoftBodySettings.shape_match -> use_shape_match: boolean Enable soft body shape matching goal GlowSequence.only_boost -> use_only_boost: boolean Show the glow buffer only GreasePencil.use_stroke_endpoints -> use_stroke_endpoints: boolean Only use the first and last parts of the stroke for snapping -Group.layer -> layer: boolean Layers visible when this groups is instanced as a dupli +Group.layer -> layers: boolean Layers visible when this groups is instanced as a dupli ID.fake_user -> use_fake_user: boolean Saves this datablock even if it has no users ID.tag -> tag: boolean Tools can use this to tag data, (initial state is undefined) Image.animated -> use_animation: boolean Use as animated texture in the game engine @@ -542,7 +542,7 @@ Mesh.use_paint_mask -> use_paint_mask: boolean Face selection masking for Mesh.vertex_normal_flip -> use_vertex_normal_flip: boolean Flip vertex normals towards the camera during render MeshColorLayer.active -> active: boolean Sets the layer as active for display and editing MeshColorLayer.active_render -> active_render: boolean Sets the layer as active for rendering -MeshDeformModifier.dynamic -> dynamic: boolean Recompute binding dynamically on top of other deformers (slower and more memory consuming.) +MeshDeformModifier.dynamic -> use_dynamic_bind: boolean Recompute binding dynamically on top of other deformers (slower and more memory consuming.) MeshDeformModifier.invert -> invert_vertex_group: boolean Invert vertex group influence MeshDeformModifier.is_bound -> is_bound: boolean, (read-only) Whether geometry has been bound to control cage MeshEdge.fgon -> is_fgon: boolean, (read-only) Fgon edge @@ -563,7 +563,7 @@ MeshTextureFace.shared -> use_blend_shared: boolean Blend vertex colors ac MeshTextureFace.tex -> use_texture: boolean Render face with texture MeshTextureFace.text -> use_bitmap_text: boolean Enable bitmap text on face MeshTextureFace.twoside -> use_twoside: boolean Render face two-sided -MeshTextureFace.uv_pinned -> uv_pin: boolean +MeshTextureFace.uv_pinned -> pin_uv: boolean MeshTextureFace.uv_selected -> select_uv: boolean MeshTextureFaceLayer.active -> active: boolean Sets the layer as active for display and editing MeshTextureFaceLayer.active_clone -> active_clone: boolean Sets the layer as active for cloning @@ -644,7 +644,7 @@ Object.draw_texture_space -> show_texture_space: boolean Displays the obje Object.draw_transparent -> show_transparent: boolean Enables transparent materials for the object (Mesh only) Object.draw_wire -> show_wire: boolean Adds the object's wireframe over solid drawing Object.duplis_used -> is_duplicator: boolean, (read-only) -Object.layers -> layer: boolean Layers the object is on +Object.layers -> layers: boolean Layers the object is on Object.lock_location -> lock_location: boolean Lock editing of location in the interface Object.lock_rotation -> lock_rotation: boolean Lock editing of rotation in the interface Object.lock_rotation_w -> lock_rotation_w: boolean Lock editing of 'angle' component of four-component rotations in the interface @@ -672,7 +672,7 @@ ObjectActuator.local_torque -> use_local_torque: boolean Torque is defined ObjectActuator.servo_limit_x -> use_servo_limit_x: boolean Set limit to force along the X axis ObjectActuator.servo_limit_y -> use_servo_limit_y: boolean Set limit to force along the Y axis ObjectActuator.servo_limit_z -> use_servo_limit_z: boolean Set limit to force along the Z axis -ObjectBase.layers -> layer: boolean Layers the object base is on +ObjectBase.layers -> layers: boolean Layers the object base is on ObstacleFluidSettings.active -> use: boolean Object contributes to the fluid simulation ObstacleFluidSettings.export_animated_mesh -> use_animated_mesh: boolean Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures or parented objects), animated pos/rot/scale IPOs do not require it Operator.has_reports -> has_reports: boolean, (read-only) Operator has a set of reports (warnings and errors) from last execution @@ -767,7 +767,7 @@ PointCache.baked -> is_baked: boolean, (read-only) PointCache.baking -> is_baking: boolean, (read-only) PointCache.disk_cache -> use_disk_cache: boolean Save cache files to disk (.blend file must be saved first) PointCache.external -> use_external: boolean Read cache from an external location -PointCache.has_skipped_frames-> frames_skipped: boolean, (read-only) +PointCache.has_skipped_frames-> has_skipped_frames: boolean, (read-only) PointCache.outdated -> is_outdated: boolean, (read-only) PointCache.quick_cache -> use_quick_cache: boolean Update simulation with cache steps PointCache.use_library_path -> use_library_path: boolean Use this files path when library linked into another file. @@ -839,9 +839,9 @@ RenderLayer.pass_z -> use_pass_z: boolean, (read-only) Deliver Z values pa RenderLayer.sky -> use_sky: boolean, (read-only) Render Sky in this Layer RenderLayer.solid -> use_solid: boolean, (read-only) Render Solid faces in this Layer RenderLayer.strand -> use_strand: boolean, (read-only) Render Strands in this Layer -RenderLayer.visible_layers -> layer: boolean, (read-only) Scene layers included in this render layer +RenderLayer.visible_layers -> layers: boolean, (read-only) Scene layers included in this render layer RenderLayer.zmask -> use_zmask: boolean, (read-only) Only render what's in front of the solid z values -RenderLayer.zmask_layers -> layer_zmask: boolean, (read-only) Zmask scene layers +RenderLayer.zmask_layers -> layers_zmask: boolean, (read-only) Zmask scene layers RenderLayer.zmask_negate -> invert_zmask: boolean, (read-only) For Zmask, only render what is behind solid z values instead of in front RenderLayer.ztransp -> use_ztransp: boolean, (read-only) Render Z-Transparent faces in this Layer (On top of Solid and Halos) RenderSettings.backbuf -> use_backbuf: boolean Render backbuffer image @@ -903,7 +903,7 @@ RenderSettings.use_textures -> use_textures: boolean Use textures to affec NEGATE * RigidBodyJointConstraint.disable_linked_collision -> use_linked_collision: boolean Disable collision between linked bodies RigidBodyJointConstraint.draw_pivot -> show_pivot: boolean Display the pivot point and rotation in 3D view Scene.frame_drop -> use_frame_drop: boolean Play back dropping frames if frame display is too slow -Scene.layers -> layer: boolean Layers visible when rendering the scene +Scene.layers -> layers: boolean Layers visible when rendering the scene Scene.mute_audio -> mute_audio: boolean Play back of audio from Sequence Editor will be muted Scene.nla_tweakmode_on -> use_nla_tweakmode: boolean, (read-only) Indicates whether there is any action referenced by NLA being edited. Strictly read-only Scene.pov_radio_always_sample -> use_pov_radio_always_sample: boolean Only use the data from the pretrace step and not gather any new samples during the final radiosity pass @@ -965,9 +965,9 @@ SceneRenderLayer.pass_z -> use_pass_z: boolean Deliver Z values pass SceneRenderLayer.sky -> use_sky: boolean Render Sky in this Layer SceneRenderLayer.solid -> use_solid: boolean Render Solid faces in this Layer SceneRenderLayer.strand -> use_strand: boolean Render Strands in this Layer -SceneRenderLayer.visible_layers -> layer: boolean Scene layers included in this render layer +SceneRenderLayer.visible_layers -> layers: boolean Scene layers included in this render layer SceneRenderLayer.zmask -> use_zmask: boolean Only render what's in front of the solid z values -SceneRenderLayer.zmask_layers -> layer_zmask: boolean Zmask scene layers +SceneRenderLayer.zmask_layers -> layers_zmask: boolean Zmask scene layers SceneRenderLayer.zmask_negate -> invert_zmask: boolean For Zmask, only render what is behind solid z values instead of in front SceneRenderLayer.ztransp -> use_ztransp: boolean Render Z-Transparent faces in this Layer (On top of Solid and Halos) SceneSequence.convert_float -> use_float: boolean Convert input to float data @@ -1142,7 +1142,7 @@ SpaceView3D.display_render_override -> show_only_render: boolean Display o SpaceView3D.display_x_axis -> show_axis_x: boolean Show the X axis line in perspective view SpaceView3D.display_y_axis -> show_axis_y: boolean Show the Y axis line in perspective view SpaceView3D.display_z_axis -> show_axis_z: boolean Show the Z axis line in perspective view -SpaceView3D.layers -> layer: boolean Layers visible in this 3D View +SpaceView3D.layers -> layers: boolean Layers visible in this 3D View SpaceView3D.lock_camera_and_layers -> lock_camera_and_layers: boolean Use the scene's active camera and layers in this view, rather than local layers SpaceView3D.manipulator -> use_manipulator: boolean Use a 3D manipulator widget for controlling transforms SpaceView3D.manipulator_rotate -> use_manipulator_rotate: boolean Use the manipulator for rotation transformations @@ -1153,7 +1153,7 @@ SpaceView3D.outline_selected -> show_outline_selected: boolean Show an out SpaceView3D.pivot_point_align -> use_pivot_point_align: boolean Manipulate object centers only SpaceView3D.relationship_lines -> show_relationship_lines: boolean Show dashed lines indicating parent or constraint relationships SpaceView3D.textured_solid -> show_textured_solid: boolean Display face-assigned textures in solid view -SpaceView3D.used_layers -> layer_used: boolean, (read-only) Layers that contain something +SpaceView3D.used_layers -> layers_used: boolean, (read-only) Layers that contain something SpeedControlSequence.curve_compress_y -> use_curve_compress_y: boolean Scale F-Curve value to get the target frame number, F-Curve value runs from 0.0 to 1.0 SpeedControlSequence.curve_velocity -> use_curve_velocity: boolean Interpret the F-Curve value as a velocity instead of a frame number SpeedControlSequence.frame_blending -> use_frame_blend: boolean Blend two frames into the target for a smoother result @@ -1178,7 +1178,7 @@ SpotLamp.shadow_layer -> use_shadow_layer: boolean Causes only objects on SpotLamp.show_cone -> show_cone: boolean Draw transparent cone in 3D view to visualize which objects are contained in it SpotLamp.sphere -> use_sphere: boolean Sets light intensity to zero beyond lamp distance SpotLamp.square -> use_square: boolean Casts a square spot light shape -StateActuator.state -> state: boolean +StateActuator.state -> states: boolean SubsurfModifier.optimal_display -> show_only_control_edges: boolean Skip drawing/rendering of interior subdivided edges SubsurfModifier.subsurf_uv -> use_subsurf_uv: boolean Use subsurf to subdivide UVs SunLamp.only_shadow -> use_only_shadow: boolean Causes light to cast shadows only without illuminating objects From 7df9df137391509a4795b7770e2e964379bffd15 Mon Sep 17 00:00:00 2001 From: Luca Bonavita Date: Thu, 15 Jul 2010 18:34:25 +0000 Subject: [PATCH 33/51] == rna cleanup == - after talking with brecht, changes keys prefixes with "is_pressed_alt" and so on if readonly and "pressed_alt" if not readonly - updated the rna_cleaner.py with real prefixes and keywords so it's clear what it is being used kw_prefixes = [ 'active','apply','bl','exclude','has','invert','is','lock', \ 'pressed','show','show_only','use','use_only','layers','states'] kw = ['active','hide','invert','select','layers','mute','states','use','lock'] --- .../makesrna/rna_cleanup/rna_booleans.txt | 18 +++++++++--------- .../makesrna/rna_cleanup/rna_cleaner.py | 7 +++---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/source/blender/makesrna/rna_cleanup/rna_booleans.txt b/source/blender/makesrna/rna_cleanup/rna_booleans.txt index ac3da595ee4..51be6427c88 100644 --- a/source/blender/makesrna/rna_cleanup/rna_booleans.txt +++ b/source/blender/makesrna/rna_cleanup/rna_booleans.txt @@ -237,10 +237,10 @@ EnvironmentMap.ignore_layers -> layers_ignore: boolean Hide objects on the EnvironmentMapTexture.use_filter_size_min -> use_minimum_filter_size: boolean Use Filter Size as a minimal filter value in pixels EnvironmentMapTexture.mipmap -> use_mipmap: boolean Uses auto-generated MIP maps for the image EnvironmentMapTexture.mipmap_gauss -> use_mipmap_gauss: boolean Uses Gauss filter to sample down MIP maps -Event.alt -> alt: boolean, (read-only) True when the Alt/Option key is held -Event.ctrl -> ctrl: boolean, (read-only) True when the Ctrl key is held -Event.oskey -> oskey: boolean, (read-only) True when the Cmd key is held -Event.shift -> shift: boolean, (read-only) True when the Shift key is held +Event.alt -> is_pressed_alt: boolean, (read-only) True when the Alt/Option key is held +Event.ctrl -> is_pressed_ctrl: boolean, (read-only) True when the Ctrl key is held +Event.oskey -> is_pressed_cmd: boolean, (read-only) True when the Cmd key is held +Event.shift -> is_pressed_shift: boolean, (read-only) True when the Shift key is held ExplodeModifier.alive -> show_alive: boolean Show mesh when particles are alive ExplodeModifier.dead -> show_dead: boolean Show mesh when particles are dead ExplodeModifier.size -> use_size: boolean Use particle size for the shrapnel @@ -394,12 +394,12 @@ KeyMap.items_expanded -> show_expanded_items: boolean Expanded in the user KeyMap.modal -> is_modal: boolean, (read-only) Indicates that a keymap is used for translate modal events for an operator KeyMap.user_defined -> is_user_defined: boolean Keymap is defined by the user KeyMapItem.active -> active: boolean Activate or deactivate item -KeyMapItem.alt -> alt: boolean Alt key pressed -KeyMapItem.any -> any: boolean Any modifier keys pressed -KeyMapItem.ctrl -> ctrl: boolean Control key pressed +KeyMapItem.alt -> pressed_alt: boolean Alt key pressed +KeyMapItem.any -> pressed_any: boolean Any modifier keys pressed +KeyMapItem.ctrl -> pressed_ctrl: boolean Control key pressed KeyMapItem.expanded -> show_expanded: boolean Show key map event and property details in the user interface -KeyMapItem.oskey -> oskey: boolean Operating system key pressed -KeyMapItem.shift -> shift: boolean Shift key pressed +KeyMapItem.oskey -> pressed_cmd: boolean Operating system key pressed +KeyMapItem.shift -> pressed_shift: boolean Shift key pressed KeyboardSensor.all_keys -> use_all_keys: boolean Trigger this sensor on any keystroke KeyingSet.absolute -> use_absolute: boolean Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info) KeyingSet.insertkey_needed -> use_insertkey_needed: boolean Only insert keyframes where they're needed in the relevant F-Curves diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner.py b/source/blender/makesrna/rna_cleanup/rna_cleaner.py index f39ee586237..dbc27c8e5d5 100755 --- a/source/blender/makesrna/rna_cleanup/rna_cleaner.py +++ b/source/blender/makesrna/rna_cleanup/rna_cleaner.py @@ -268,10 +268,9 @@ def main(): sort_choices = ['note','changed','class','from','to','kw'] default_sort_choice = sort_choices[0] - #kw_prefixes = ['invert','is','lock','show','show_only','use','use_only'] - #kw = ['hide','select','layer','state'] - kw_prefixes = ['has','invert','is','lock','layers','show','show_only','states','use','use_only'] - kw = ['layers','states','value'] + kw_prefixes = [ 'active','apply','bl','exclude','has','invert','is','lock', \ + 'pressed','show','show_only','use','use_only','layers','states'] + kw = ['active','hide','invert','select','layers','mute','states','use','lock'] input_filename, sort_priority = check_commandline() props_list,props_length_max = get_props(input_filename) From 7a3ff665752e04fa20285fb82a4ddbcf34c12835 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Thu, 15 Jul 2010 19:42:36 +0000 Subject: [PATCH 34/51] == installation paths == * fix case where environment variable was used without subfolder * some small cleanup --- source/blender/blenlib/intern/path_util.c | 116 ++++++++++++---------- 1 file changed, 66 insertions(+), 50 deletions(-) diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 76877198bcb..c1e0059e954 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -947,13 +947,13 @@ static int test_path(char *targetpath, char *path_base, char *path_sep, char *fo } } -static int test_env_path(char *path, char *subfolder_name, char *envvar) +static int test_env_path(char *path, char *envvar) { char *env = envvar?getenv(envvar):NULL; if (!env) return 0; if (BLI_is_dir(env)) { - BLI_make_file_string("/", path, env, subfolder_name); + BLI_strncpy(path, env, FILE_MAX); return 1; } else { path[0] = '\0'; @@ -961,10 +961,11 @@ static int test_env_path(char *path, char *subfolder_name, char *envvar) } } -static int get_path_local(char *targetpath, char *folder_name) +static int get_path_local(char *targetpath, char *folder_name, char *subfolder_name) { extern char bprogname[]; /* argv[0] from creator.c */ char bprogdir[FILE_MAX]; + char relfolder[FILE_MAX]; char cwd[FILE_MAX]; char *s; int i; @@ -973,6 +974,11 @@ static int get_path_local(char *targetpath, char *folder_name) printf("get_path_local...\n"); #endif + if (subfolder_name) { + BLI_join_dirfile(relfolder, folder_name, subfolder_name); + } else { + BLI_strncpy(relfolder, folder_name, FILE_MAX); + } /* use argv[0] (bprogname) to get the path to the executable */ s = BLI_last_slash(bprogname); @@ -980,23 +986,23 @@ static int get_path_local(char *targetpath, char *folder_name) BLI_strncpy(bprogdir, bprogname, i); /* try EXECUTABLE_DIR/folder_name */ - if(test_path(targetpath, bprogdir, "", folder_name)) + if(test_path(targetpath, bprogdir, "", relfolder)) return 1; /* try CWD/release/folder_name */ - if(test_path(targetpath, BLI_getwdN(cwd), "release", folder_name)) + if(test_path(targetpath, BLI_getwdN(cwd), "release", relfolder)) return 1; /* try EXECUTABLE_DIR/release/folder_name */ - if(test_path(targetpath, bprogdir, "release", folder_name)) + if(test_path(targetpath, bprogdir, "release", relfolder)) return 1; /* try EXECUTABLE_DIR/2.5/folder_name - new default directory for local blender installed files */ - if(test_path(targetpath, bprogdir, blender_version_decimal(), folder_name)) + if(test_path(targetpath, bprogdir, blender_version_decimal(), relfolder)) return 1; /* try ./.blender/folder_name -- DEPRECATED, need to update build systems */ - if(test_path(targetpath, bprogdir, ".blender", folder_name)) + if(test_path(targetpath, bprogdir, ".blender", relfolder)) return 1; return 0; @@ -1009,9 +1015,15 @@ static int get_path_user(char *targetpath, char *folder_name, char *subfolder_na user_path[0] = '\0'; - if (test_env_path(targetpath, subfolder_name, envvar)) - return 1; - + if (test_env_path(user_path, envvar)) { + if (subfolder_name) { + return test_path(targetpath, user_path, NULL, subfolder_name); + } else { + BLI_strncpy(targetpath, user_path, FILE_MAX); + return 1; + } + } + user_base_path = (const char *)GHOST_getUserDir(); if (user_base_path) { BLI_snprintf(user_path, FILE_MAX, BLENDER_USER_FORMAT, user_base_path, blender_version_decimal()); @@ -1024,8 +1036,13 @@ static int get_path_user(char *targetpath, char *folder_name, char *subfolder_na printf("get_path_user: %s\n", user_path); #endif - /* try $HOME/folder_name */ - return test_path(targetpath, user_path, NULL, folder_name); + if (subfolder_name) { + /* try $HOME/folder_name/subfolder_name */ + return test_path(targetpath, user_path, folder_name, subfolder_name); + } else { + /* try $HOME/folder_name */ + return test_path(targetpath, user_path, NULL, folder_name); + } } static int get_path_system(char *targetpath, char *folder_name, char *subfolder_name, char *envvar) @@ -1035,8 +1052,14 @@ static int get_path_system(char *targetpath, char *folder_name, char *subfolder_ system_path[0] = '\0'; - if (test_env_path(targetpath, subfolder_name, envvar)) - return 1; + if (test_env_path(system_path, envvar)) { + if (subfolder_name) { + return test_path(targetpath, system_path, NULL, subfolder_name); + } else { + BLI_strncpy(targetpath, system_path, FILE_MAX); + return 1; + } + } system_base_path = (const char *)GHOST_getSystemDir(); if (system_base_path) { @@ -1050,8 +1073,13 @@ static int get_path_system(char *targetpath, char *folder_name, char *subfolder_ printf("get_path_system: %s\n", system_path); #endif - /* try $BLENDERPATH/folder_name */ - return test_path(targetpath, system_path, NULL, folder_name); + if (subfolder_name) { + /* try $BLENDERPATH/folder_name/subfolder_name */ + return test_path(targetpath, system_path, folder_name, subfolder_name); + } else { + /* try $BLENDERPATH/folder_name */ + return test_path(targetpath, system_path, NULL, folder_name); + } } /* get a folder out of the 'folder_id' presets for paths */ @@ -1059,72 +1087,60 @@ static int get_path_system(char *targetpath, char *folder_name, char *subfolder_ char *BLI_get_folder(int folder_id, char *subfolder) { static char path[FILE_MAX] = ""; - char search_path[FILE_MAX]; switch (folder_id) { case BLENDER_DATAFILES: /* general case */ - BLI_join_dirfile(search_path, "datafiles", subfolder); - if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, subfolder, "BLENDER_USER_DATAFILES")) break; - if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_DATAFILES")) break; + if (get_path_local(path, "datafiles", subfolder)) break; + if (get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES")) break; + if (get_path_system(path, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES")) break; return NULL; case BLENDER_USER_DATAFILES: - BLI_join_dirfile(search_path, "datafiles", subfolder); - if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, subfolder, "BLENDER_USER_DATAFILES")) break; + if (get_path_local(path, "datafiles", subfolder)) break; + if (get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES")) break; return NULL; case BLENDER_SYSTEM_DATAFILES: - BLI_join_dirfile(search_path, "datafiles", subfolder); - if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_DATAFILES")) break; + if (get_path_system(path, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES")) break; return NULL; case BLENDER_CONFIG: /* general case */ - BLI_join_dirfile(search_path, "config", subfolder); - if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, subfolder, "BLENDER_USER_CONFIG")) break; - if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_CONFIG")) break; + if (get_path_local(path, "config", subfolder)) break; + if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG")) break; + if (get_path_system(path, "config", subfolder, "BLENDER_SYSTEM_CONFIG")) break; return NULL; case BLENDER_USER_CONFIG: - BLI_join_dirfile(search_path, "config", subfolder); - if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, subfolder, "BLENDER_USER_CONFIG")) break; + if (get_path_local(path, "config", subfolder)) break; + if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG")) break; return NULL; case BLENDER_SYSTEM_CONFIG: - BLI_join_dirfile(search_path, "config", subfolder); - if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_CONFIG")) break; + if (get_path_system(path, "config", subfolder, "BLENDER_SYSTEM_CONFIG")) break; return NULL; case BLENDER_SCRIPTS: /* general case */ - BLI_join_dirfile(search_path, "scripts", subfolder); - if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, subfolder, "BLENDER_USER_SCRIPTS")) break; - if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_SCRIPTS")) break; + if (get_path_local(path, "scripts", subfolder)) break; + if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS")) break; + if (get_path_system(path, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS")) break; return NULL; case BLENDER_USER_SCRIPTS: - BLI_join_dirfile(search_path, "scripts", subfolder); - if (get_path_local(path, search_path)) break; - if (get_path_user(path, search_path, subfolder, "BLENDER_USER_SCRIPTS")) break; + if (get_path_local(path, "scripts", subfolder)) break; + if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS")) break; return NULL; case BLENDER_SYSTEM_SCRIPTS: - BLI_join_dirfile(search_path, "scripts", subfolder); - if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_SCRIPTS")) break; + if (get_path_system(path, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS")) break; return NULL; case BLENDER_PYTHON: /* general case */ - BLI_join_dirfile(search_path, "python", subfolder); - if (get_path_local(path, search_path)) break; - if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_PYTHON")) break; + if (get_path_local(path, "python", subfolder)) break; + if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON")) break; return NULL; case BLENDER_SYSTEM_PYTHON: - BLI_join_dirfile(search_path, "python", subfolder); - if (get_path_system(path, search_path, subfolder, "BLENDER_SYSTEM_PYTHON")) break; + if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON")) break; return NULL; } From 7fc9eee08afe87f3f688e8b9e9442951d6a08590 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Jul 2010 19:58:23 +0000 Subject: [PATCH 35/51] - updated man page from --help output. - cmake now installs the man page. - added cmake_linux_install.sh, shell script which downloads and builds blender. --- .../example_scripts/cmake_linux_install.sh | 37 +++++++++++++++++++ doc/blender.1 | 14 ++++--- doc/blender.1.py | 4 +- source/creator/CMakeLists.txt | 4 ++ 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 build_files/cmake/example_scripts/cmake_linux_install.sh diff --git a/build_files/cmake/example_scripts/cmake_linux_install.sh b/build_files/cmake/example_scripts/cmake_linux_install.sh new file mode 100644 index 00000000000..7770efcf392 --- /dev/null +++ b/build_files/cmake/example_scripts/cmake_linux_install.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# This shell script checks out and compiles blender, tested on ubuntu 10.04 +# assumes you have dependancies installed alredy + +# See this page for more info: +# http://wiki.blender.org/index.php/Dev:2.5/Doc/Building_Blender/Linux/Generic_Distro/CMake + +# grab blender +mkdir ~/blender-svn +cd ~/blender-svn +svn co https://svn.blender.org/svnroot/bf-blender/trunk/blender + +# create cmake dir +mkdir ~/blender-svn/build-cmake +cd ~/blender-svn/build-cmake + +# cmake without copying files for fast rebuilds +# the files from svn will be used in place +cmake ../blender -DWITH_INSTALL:BOOL=FALSE + +# make blender, will take some time +make + +# link the binary to blenders source directory to run quickly +ln -s ~/blender-svn/build-cmake/bin/blender ~/blender-svn/blender/blender.bin + +# useful info +echo "" +echo "* Useful Commands *" +echo " Run Blender: ~/blender-svn/blender/blender.bin" +echo " Update Blender: svn up ~/blender-svn/blender" +echo " Reconfigure Blender: cd ~/blender-svn/build-cmake ; cmake ." +echo " Build Blender: cd ~/blender-svn/build-cmake ; make" +echo "" + + diff --git a/doc/blender.1 b/doc/blender.1 index 43ac5638765..dd5e60ff900 100644 --- a/doc/blender.1 +++ b/doc/blender.1 @@ -1,4 +1,4 @@ -.TH "BLENDER" "1" "June 27, 2010" "Blender Blender 2\&.52 (sub 5) " +.TH "BLENDER" "1" "July 15, 2010" "Blender Blender 2\&.52 (sub 5) " .SH NAME blender \- a 3D modelling and rendering package @@ -317,11 +317,13 @@ Arguments are executed in the order they are given. eg .br .br .SH "ENVIRONMENT VARIABLES" - \fIHOME\fR Store files such as .blender/ .B.blend .Bfs .Blog here. - \fIBLENDERPATH\fR System directory to use for data files and scripts. - For this build of blender the default \fIBLENDERPATH\fR is... - "/usr/local/share/blender/2.5" - setting the \fIBLENDERPATH\fR will override this + \fIBLENDER_USER_CONFIG\fR Directory for user configuration files. + \fIBLENDER_SYSTEM_CONFIG\fR Directory for system wide configuration files. + \fIBLENDER_USER_SCRIPTS\fR Directory for user scripts. + \fIBLENDER_SYSTEM_SCRIPTS\fR Directory for system wide scripts. + \fIBLENDER_USER_DATAFILES\fR Directory for user data files (icons, translations, ..). + \fIBLENDER_SYSTEM_DATAFILES\fR Directory for system wide data files. + \fIBLENDER_SYSTEM_PYTHON\fR Directory for system python libraries. \fITMP\fR or \fITMPDIR\fR Store temporary files here. \fIPYTHONHOME\fR Path to the python directory, eg. /usr/lib/python. .br diff --git a/doc/blender.1.py b/doc/blender.1.py index 05b491cf21e..7c7fc987c64 100644 --- a/doc/blender.1.py +++ b/doc/blender.1.py @@ -53,7 +53,7 @@ blender_version = blender_version.split("Build")[0] date_string = datetime.date.fromtimestamp(time.time()).strftime("%B %d, %Y") -filepath = os.path.splitext(__file__)[0] + ".1" +filepath = os.path.splitext(__file__)[0] file = open(filepath, "w") @@ -132,3 +132,5 @@ This manpage was written for a Debian GNU/Linux system by Daniel Mester and updated by Cyril Brulebois and Dan Eicher . ''') + +print("written:", filepath) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index e9e6c982fde..812c001a2bb 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -198,6 +198,10 @@ IF(WITH_INSTALL) INSTALL( FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/blender.svg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps + ) + INSTALL( + FILES ${CMAKE_SOURCE_DIR}/doc/blender.1 + DESTINATION ${CMAKE_INSTALL_PREFIX}/man ) INSTALL( DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/ From 05fb497f75aef331aa708945af5feb69e5169e7b Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Thu, 15 Jul 2010 20:02:53 +0000 Subject: [PATCH 36/51] == installation paths == remove deprecated python BLI_gethome_folder calls Patch by Brecht, thanks a lot --- release/scripts/modules/bpy/utils.py | 7 +- source/blender/blenlib/BLI_path_util.h | 25 ----- source/blender/blenlib/intern/path_util.c | 115 ---------------------- source/blender/python/intern/bpy.c | 30 ++---- source/creator/creator.c | 22 +---- 5 files changed, 18 insertions(+), 181 deletions(-) diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 5cde7091257..f0de31a95f5 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -19,7 +19,7 @@ # """ -This module contains utility functions spesific to blender but +This module contains utility functions specific to blender but not assosiated with blenders internal data. """ @@ -27,7 +27,8 @@ import bpy as _bpy import os as _os import sys as _sys -from _bpy import home_paths, blend_paths +from _bpy import blend_paths +from _bpy import script_paths as _bpy_script_paths def _test_import(module_name, loaded_modules): @@ -313,7 +314,7 @@ def script_paths(subdir=None, user=True): else: user_script_path = None - for path in home_paths("scripts") + (user_script_path, ): + for path in _bpy_script_paths() + (user_script_path, ): if path: path = _os.path.normpath(path) if path not in scripts and _os.path.isdir(path): diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 316b850805d..57e6d0b16d7 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -41,31 +41,6 @@ struct ListBase; struct direntry; char *BLI_gethome(void); -char *BLI_gethome_folder(char *folder_name, int flag); - -/* BLI_gethome_folder flag */ -#define BLI_GETHOME_LOCAL 1<<1 /* relative location for portable binaries */ -#define BLI_GETHOME_SYSTEM 1<<2 /* system location, or set from the BLENDERPATH env variable (UNIX only) */ -#define BLI_GETHOME_USER 1<<3 /* home folder ~/.blender */ -#define BLI_GETHOME_ALL (BLI_GETHOME_SYSTEM|BLI_GETHOME_LOCAL|BLI_GETHOME_USER) - - -#ifdef __APPLE__ -typedef enum { - BasePath_Temporary = 1, - BasePath_BlenderShared, - BasePath_BlenderUser, - BasePath_ApplicationBundle -} basePathesTypes; - -/** - * Gets the base path. The path may not exist. - * Note that return string must be copied as its persistence is not guaranteed - * - * @return base path of pathType - */ -const char* BLI_osx_getBasePath(basePathesTypes pathType); -#endif char *BLI_get_folder(int folder_id, char *subfolder); char *BLI_get_folder_create(int folder_id, char *subfolder); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index c1e0059e954..6ab7ba2a7a5 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -795,121 +795,6 @@ char *BLI_gethome(void) { #endif } -/* this function returns the path to a blender folder, if it exists - * utility functions for BLI_gethome_folder */ - -// #define PATH_DEBUG /* for testing paths that are checked */ - -static int test_data_path(char *targetpath, char *path_base, char *path_sep, char *folder_name) -{ - char tmppath[FILE_MAXDIR]; - - if(path_sep) BLI_join_dirfile(tmppath, path_base, path_sep); - else BLI_strncpy(tmppath, path_base, sizeof(tmppath)); - - BLI_make_file_string("/", targetpath, tmppath, folder_name); - - if (BLI_is_dir(targetpath)) { -#ifdef PATH_DEBUG - printf("\tpath found: %s\n", targetpath); -#endif - return 1; - } - else { -#ifdef PATH_DEBUG - printf("\tpath missing: %s\n", targetpath); -#endif - targetpath[0] = '\0'; - return 0; - } -} - -static int gethome_path_local(char *targetpath, char *folder_name) -{ - extern char bprogname[]; /* argv[0] from creator.c */ - char bprogdir[FILE_MAXDIR]; - char cwd[FILE_MAXDIR]; - char *s; - int i; - -#ifdef PATH_DEBUG - printf("gethome_path_local...\n"); -#endif - - /* try release/folder_name (binary relative) */ - /* use argv[0] (bprogname) to get the path to the executable */ - s = BLI_last_slash(bprogname); - i = s - bprogname + 1; - BLI_strncpy(bprogdir, bprogname, i); - - /* try release/folder_name (BIN relative) */ - if(test_data_path(targetpath, bprogdir, "release", folder_name)) - return 1; - - /* try release/folder_name (CWD relative) */ - if(test_data_path(targetpath, BLI_getwdN(cwd), "release", folder_name)) - return 1; - - /* try ./.blender/folder_name */ - if(test_data_path(targetpath, bprogdir, ".blender", folder_name)) - return 1; - - return 0; -} - -static int gethome_path_user(char *targetpath, char *folder_name) -{ - char *home_path= BLI_gethome(); - -#ifdef PATH_DEBUG - printf("gethome_path_user...\n"); -#endif - - /* try $HOME/folder_name */ - return test_data_path(targetpath, home_path, ".blender", folder_name); -} - -static int gethome_path_system(char *targetpath, char *folder_name) -{ - extern char blender_path[]; /* unix prefix eg. /usr/share/blender/2.5 creator.c */ - - if(!blender_path[0]) - return 0; - -#ifdef PATH_DEBUG - printf("gethome_path_system...\n"); -#endif - - /* try $BLENDERPATH/folder_name */ - return test_data_path(targetpath, blender_path, NULL, folder_name); -} - -char *BLI_gethome_folder(char *folder_name, int flag) -{ - static char fulldir[FILE_MAXDIR] = ""; - - /* first check if this is a redistributable bundle */ - if(flag & BLI_GETHOME_LOCAL) { - if (gethome_path_local(fulldir, folder_name)) - return fulldir; - } - - /* then check if the OS has blender data files installed in a global location */ - if(flag & BLI_GETHOME_SYSTEM) { - if (gethome_path_system(fulldir, folder_name)) - return fulldir; - } - - /* now check the users home dir for data files */ - if(flag & BLI_GETHOME_USER) { - if (gethome_path_user(fulldir, folder_name)) - return fulldir; - } - - return NULL; -} - - /* NEW stuff, to be cleaned up when fully migrated */ /* ************************************************************* */ /* ************************************************************* */ diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index b978e46f6da..15be6174f29 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -41,33 +41,23 @@ #include "../generic/blf_api.h" #include "../generic/IDProp.h" -static char bpy_home_paths_doc[] = -".. function:: home_paths(subfolder)\n" +static char bpy_script_paths_doc[] = +".. function:: script_paths()\n" "\n" -" Return 3 paths to blender home directories.\n" +" Return 2 paths to blender scripts directories.\n" "\n" -" :arg subfolder: The name of a subfolder to find within the blenders home directory.\n" -" :type subfolder: string\n" -" :return: (system, local, user) strings will be empty when not found.\n" +" :return: (system, user) strings will be empty when not found.\n" " :rtype: tuple of strigs\n"; -PyObject *bpy_home_paths(PyObject *self, PyObject *args) +PyObject *bpy_script_paths(PyObject *self) { - PyObject *ret= PyTuple_New(3); + PyObject *ret= PyTuple_New(2); char *path; - char *subfolder= ""; - if (!PyArg_ParseTuple(args, "|s:blender_homes", &subfolder)) - return NULL; - - path= BLI_gethome_folder(subfolder, BLI_GETHOME_SYSTEM); + path= BLI_get_folder(BLENDER_USER_SCRIPTS, NULL); PyTuple_SET_ITEM(ret, 0, PyUnicode_FromString(path?path:"")); - - path= BLI_gethome_folder(subfolder, BLI_GETHOME_LOCAL); + path= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, NULL); PyTuple_SET_ITEM(ret, 1, PyUnicode_FromString(path?path:"")); - - path= BLI_gethome_folder(subfolder, BLI_GETHOME_USER); - PyTuple_SET_ITEM(ret, 2, PyUnicode_FromString(path?path:"")); return ret; } @@ -120,7 +110,7 @@ static PyObject *bpy_blend_paths(PyObject * self, PyObject *args, PyObject *kw) return list; } -static PyMethodDef meth_bpy_home_paths[] = {{ "home_paths", (PyCFunction)bpy_home_paths, METH_VARARGS, bpy_home_paths_doc}}; +static PyMethodDef meth_bpy_script_paths[] = {{ "script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc}}; static PyMethodDef meth_bpy_blend_paths[] = {{ "blend_paths", (PyCFunction)bpy_blend_paths, METH_VARARGS|METH_KEYWORDS, bpy_blend_paths_doc}}; static void bpy_import_test(char *modname) @@ -191,7 +181,7 @@ void BPy_init_modules( void ) PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module); /* utility func's that have nowhere else to go */ - PyModule_AddObject(mod, meth_bpy_home_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_home_paths, NULL)); + PyModule_AddObject(mod, meth_bpy_script_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_script_paths, NULL)); PyModule_AddObject(mod, meth_bpy_blend_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_blend_paths, NULL)); /* add our own modules dir, this is a python package */ diff --git a/source/creator/creator.c b/source/creator/creator.c index ac79c0e6f80..283511ef3ff 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -131,14 +131,6 @@ extern int pluginapi_force_ref(void); /* from blenpluginapi:pluginapi.c */ char bprogname[FILE_MAXDIR+FILE_MAXFILE]; /* from blenpluginapi:pluginapi.c */ char btempdir[FILE_MAXDIR+FILE_MAXFILE]; -/* unix path support. - * defined by the compiler. eg "/usr/share/blender/2.5" "/opt/blender/2.5" */ -#ifndef BLENDERPATH -#define BLENDERPATH "" -#endif - -char blender_path[FILE_MAXDIR+FILE_MAXFILE] = BLENDERPATH; - /* Initialise callbacks for the modules that need them */ static void setCallbacks(void); @@ -297,14 +289,14 @@ static int print_help(int argc, char **argv, void *data) printf (" $BLENDER_SYSTEM_DATAFILES Directory for system wide data files.\n"); printf (" $BLENDER_SYSTEM_PYTHON Directory for system python libraries.\n"); #ifdef WIN32 - printf (" $TEMP Store temporary files here.\n"); + printf (" $TEMP Store temporary files here.\n"); #else - printf (" $TMP or $TMPDIR Store temporary files here.\n"); + printf (" $TMP or $TMPDIR Store temporary files here.\n"); #endif #ifndef DISABLE_SDL - printf (" $SDL_AUDIODRIVER LibSDL audio driver - alsa, esd, alsa, dma.\n"); + printf (" $SDL_AUDIODRIVER LibSDL audio driver - alsa, esd, dma.\n"); #endif - printf (" $PYTHONHOME Path to the python directory, eg. /usr/lib/python.\n\n"); + printf (" $PYTHONHOME Path to the python directory, eg. /usr/lib/python.\n\n"); exit(0); @@ -1040,12 +1032,6 @@ int main(int argc, char **argv) BLI_where_am_i(bprogname, argv[0]); - { /* override the hard coded blender path */ - char *blender_path_env = getenv("BLENDERPATH"); - if(blender_path_env) - BLI_strncpy(blender_path, blender_path_env, sizeof(blender_path)); - } - #ifdef BUILD_DATE strip_quotes(build_date); strip_quotes(build_time); From f36ab733bf2aefd1ace438170b35d846885ff058 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 15 Jul 2010 20:16:17 +0000 Subject: [PATCH 37/51] Update MSVC9 project file --- projectfiles_vc9/blender/editors/ED_editors.vcproj | 12 ++++++++---- projectfiles_vc9/blender/gpu/BL_gpu.vcproj | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/projectfiles_vc9/blender/editors/ED_editors.vcproj b/projectfiles_vc9/blender/editors/ED_editors.vcproj index 819d0ca1042..cda69b46f5e 100644 --- a/projectfiles_vc9/blender/editors/ED_editors.vcproj +++ b/projectfiles_vc9/blender/editors/ED_editors.vcproj @@ -355,10 +355,6 @@ Name="datafiles" Filter="c" > - - @@ -387,6 +383,10 @@ RelativePath="..\..\..\source\blender\editors\datafiles\splash.png.c" > + + + + Date: Thu, 15 Jul 2010 20:25:09 +0000 Subject: [PATCH 38/51] Rather then hard coded /usr/share, use CMAKE_INSTALL_PREFIX to set the PREFIX, could be added for scons/make too. --- intern/ghost/CMakeLists.txt | 3 +++ intern/ghost/intern/GHOST_SystemX11.cpp | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 1a7627c9099..c262ea8aadd 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -85,6 +85,9 @@ ELSEIF(UNIX) ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_SystemX11.cpp ${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_WindowX11.cpp ) + + ADD_DEFINITIONS(-DPREFIX="${CMAKE_INSTALL_PREFIX}") + ENDIF(APPLE) BLENDERLIB(bf_ghost "${SRC}" "${INC}") diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index c9228e68e54..961a637e616 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -67,6 +67,10 @@ #include // for fprintf only #include // for exit +#ifndef PREFIX +# define PREFIX "/usr/local" +#endif + typedef struct NDOFPlatformInfo { Display *display; Window window; @@ -1461,7 +1465,7 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const const GHOST_TUns8* GHOST_SystemX11::getSystemDir() const { - return (GHOST_TUns8*)"/usr/share"; + return (GHOST_TUns8*) PREFIX "/share"; } const GHOST_TUns8* GHOST_SystemX11::getUserDir() const From 2f96ac8b9ff6290e2a63546cdab168e4376f3128 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Thu, 15 Jul 2010 20:30:31 +0000 Subject: [PATCH 39/51] SVN maintenance. --- build_files/cmake/example_scripts/cmake_linux_install.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build_files/cmake/example_scripts/cmake_linux_install.sh diff --git a/build_files/cmake/example_scripts/cmake_linux_install.sh b/build_files/cmake/example_scripts/cmake_linux_install.sh old mode 100644 new mode 100755 From 615db01b01c4ad96d8e712aa5469d9eb3ada0d07 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Thu, 15 Jul 2010 21:39:47 +0000 Subject: [PATCH 40/51] == installation paths == * fix for autosave location -> shouldn't use BLI_gethome anymore * this frees BLI_gethome of having to emulate the local->user->system search path and can now be truly considered as 'home/default location for .blend files' * removed setting the default G.sce from read_history, was out of context there. * fix for creating user dir, leftover from previous commit. jesterKing, please review -> if there are any issues I will fix or revert. --- source/blender/blenlib/BLI_path_util.h | 1 + source/blender/blenlib/intern/path_util.c | 61 ++++++------------- source/blender/python/intern/bpy_app.c | 2 - .../blender/windowmanager/intern/wm_files.c | 14 +---- .../windowmanager/intern/wm_init_exit.c | 4 ++ 5 files changed, 26 insertions(+), 56 deletions(-) diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 57e6d0b16d7..60d35c9ecdf 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -59,6 +59,7 @@ char *BLI_get_folder_create(int folder_id, char *subfolder); #define BLENDER_USER_DATAFILES 32 #define BLENDER_USER_SCRIPTS 33 #define BLENDER_USER_PLUGINS 34 +#define BLENDER_USER_AUTOSAVE 35 /* system */ #define BLENDER_SYSTEM_CONFIG 51 /* optional */ diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 6ab7ba2a7a5..df1e2c7d590 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -732,66 +732,38 @@ void BLI_getlastdir(const char* dir, char *last, int maxlen) } } +/* This is now only used to really get the user's home folder */ +/* On Windows I chose the 'Users//Documents' since it's used + as default location to save documents */ char *BLI_gethome(void) { #if !defined(WIN32) return getenv("HOME"); #else /* Windows */ char * ret; - static char dir[512]; - static char appdatapath[MAXPATHLEN]; + static char documentfolder[MAXPATHLEN]; HRESULT hResult; /* Check for %HOME% env var */ ret = getenv("HOME"); if(ret) { - sprintf(dir, "%s\\%s", ret, blender_version_decimal()); - if (BLI_is_dir(dir)) return dir; + if (BLI_is_dir(ret)) return ret; } - - /* else, check install dir (path containing blender.exe) */ - - if(BLI_getInstallationDir(dir)) - { - sprintf(dir, "%s", dir, blender_version_decimal()); - if (BLI_is_dir(dir)) return(dir); - } - /* add user profile support for WIN 2K / NT. * This is %APPDATA%, which translates to either * %USERPROFILE%\Application Data or since Vista * to %USERPROFILE%\AppData\Roaming */ - hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath); + hResult = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, documentfolder); if (hResult == S_OK) { - if (BLI_is_dir(appdatapath)) { /* from fop, also below... */ - sprintf(dir, "%s\\Blender Foundation\\Blender", appdatapath); - BLI_recurdir_fileops(dir); - if (BLI_is_dir(dir)) { - sprintf(dir,"%s\\%s", dir, blender_version_decimal()); - if(BLI_is_dir(dir)) return(dir); - } - } - hResult = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdatapath); - if (hResult == S_OK) - { - if (BLI_is_dir(appdatapath)) - { /* from fop, also below... */ - sprintf(dir, "%s\\Blender Foundation\\Blender", appdatapath); - BLI_recurdir_fileops(dir); - if (BLI_is_dir(dir)) { - sprintf(dir,"%s\\%s", dir, blender_version_decimal()); - if(BLI_is_dir(dir)) return(dir); - } - } - } + if (BLI_is_dir(documentfolder)) return documentfolder; } - return "C:\\Temp"; /* sheesh! bad, bad, bad! (aphex) */ + return NULL; #endif } @@ -989,6 +961,11 @@ char *BLI_get_folder(int folder_id, char *subfolder) if (get_path_system(path, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES")) break; return NULL; + case BLENDER_USER_AUTOSAVE: + if (get_path_local(path, "autosave", subfolder)) break; + if (get_path_user(path, "autosave", subfolder, "BLENDER_USER_DATAFILES")) break; + return NULL; + case BLENDER_CONFIG: /* general case */ if (get_path_local(path, "config", subfolder)) break; if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG")) break; @@ -1035,16 +1012,16 @@ char *BLI_get_folder(int folder_id, char *subfolder) static char *BLI_get_user_folder_notest(int folder_id, char *subfolder) { static char path[FILE_MAX] = ""; - char search_path[FILE_MAX]; switch (folder_id) { case BLENDER_USER_DATAFILES: - BLI_join_dirfile(search_path, "datafiles", subfolder); - get_path_user(path, search_path, subfolder, "BLENDER_USER_DATAFILES"); + get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES"); break; case BLENDER_USER_CONFIG: - BLI_join_dirfile(search_path, "config", subfolder); - get_path_user(path, search_path, subfolder, "BLENDER_USER_CONFIG"); + get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG"); + break; + case BLENDER_USER_AUTOSAVE: + get_path_user(path, "autosave", subfolder, "BLENDER_USER_AUTOSAVE"); break; } if ('\0' == path[0]) { @@ -1058,7 +1035,7 @@ char *BLI_get_folder_create(int folder_id, char *subfolder) char *path; /* only for user folders */ - if (!ELEM(folder_id, BLENDER_USER_DATAFILES, BLENDER_USER_CONFIG)) + if (!ELEM3(folder_id, BLENDER_USER_DATAFILES, BLENDER_USER_CONFIG, BLENDER_USER_AUTOSAVE)) return NULL; path = BLI_get_folder(folder_id, subfolder); diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 4a2ac0c9252..78658a611a3 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -43,7 +43,6 @@ static PyTypeObject BlenderAppType; static PyStructSequence_Field app_info_fields[] = { {"version", "The Blender version as a tuple of 3 numbers. eg. (2, 50, 11)"}, {"version_string", "The Blender version formatted as a string"}, - {"home", "The blender home directory, normally matching $HOME"}, {"binary_path", "The location of blenders executable, useful for utilities that spawn new instances"}, {"debug", "Boolean, set when blender is running in debug mode (started with -d)"}, {"background", "Boolean, True when blender is running without a user interface (started with -b)"}, @@ -85,7 +84,6 @@ static PyObject *make_app_info(void) SetObjItem(Py_BuildValue("(iii)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION)); SetObjItem(PyUnicode_FromFormat("%d.%02d (sub %d)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION)); - SetStrItem(BLI_gethome()); SetStrItem(bprogname); SetObjItem(PyBool_FromLong(G.f & G_DEBUG)); SetObjItem(PyBool_FromLong(G.background)); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ff859ebe166..89b8267bb05 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -434,9 +434,6 @@ void read_history(void) num++; } } - - if(G.sce[0] == 0) - BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend"); BLI_free_file_lines(lines); @@ -686,21 +683,14 @@ void wm_autosave_location(char *filename) { char pidstr[32]; #ifdef WIN32 - char subdir[9]; - char savedir[FILE_MAXDIR]; + char *savedir; #endif sprintf(pidstr, "%d.blend", abs(getpid())); #ifdef WIN32 if (!BLI_exists(U.tempdir)) { - BLI_strncpy(subdir, "autosave", sizeof(subdir)); - BLI_make_file_string("/", savedir, BLI_gethome(), subdir); - - /* create a new autosave dir - * function already checks for existence or not */ - BLI_recurdir_fileops(savedir); - + savedir = BLI_get_folder_create(BLENDER_USER_AUTOSAVE, NULL); BLI_make_file_string("/", filename, savedir, pidstr); return; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index db668390b88..5bfaf91aa11 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -164,6 +164,10 @@ void WM_init(bContext *C, int argc, char **argv) G.ndofdevice = -1; /* XXX bad initializer, needs set otherwise buttons show! */ read_history(); + + if(G.sce[0] == 0) + BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend"); + BLI_strncpy(G.lib, G.sce, FILE_MAX); } From ccbd4f3a0f95bd3271cd925142e02f26333a7a9d Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Thu, 15 Jul 2010 22:37:07 +0000 Subject: [PATCH 41/51] path -> filepath Someone must have missed that when updating the operator properties. --- release/scripts/io/netrender/repath.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/io/netrender/repath.py b/release/scripts/io/netrender/repath.py index 7f9befd34fb..34af8e137ec 100755 --- a/release/scripts/io/netrender/repath.py +++ b/release/scripts/io/netrender/repath.py @@ -144,4 +144,4 @@ if __name__ == "__main__": process(args) - bpy.ops.wm.save_as_mainfile(path=new_path, check_existing=False) + bpy.ops.wm.save_as_mainfile(filepath=new_path, check_existing=False) From e4e80c4def0fe30ec9285cafde2fd42c5e8c09b6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Jul 2010 01:00:56 +0000 Subject: [PATCH 42/51] Blendfile thumbnail extractor, so icons can be automatically extracted from blend files as PNG's and displayed in a file browser. Runs with python 2.6 and 3.1 with no special deps. To have nautilus display thumbnails automatically. gconftool --type boolean --set /desktop/gnome/thumbnailers/application@x-blender/enable true gconftool --type string --set /desktop/gnome/thumbnailers/application@x-blender/command "blender-thumbnailer.py %i %o" --- release/freedesktop/blender-thumbnailer.py | 132 +++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100755 release/freedesktop/blender-thumbnailer.py diff --git a/release/freedesktop/blender-thumbnailer.py b/release/freedesktop/blender-thumbnailer.py new file mode 100755 index 00000000000..5274da103b9 --- /dev/null +++ b/release/freedesktop/blender-thumbnailer.py @@ -0,0 +1,132 @@ +#!/usr/bin/python + +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +""" +Thumbnailer runs with python 2.6 and 3.x. +To run automatically with nautilus: + gconftool --type boolean --set /desktop/gnome/thumbnailers/application@x-blender/enable true + gconftool --type string --set /desktop/gnome/thumbnailers/application@x-blender/command "blender-thumbnailer.py %i %o" +""" + +import os +import struct +import sys + +def blend_extract_thumb(path): + # def MAKE_ID(tag): ord(tag[0])<<24 | ord(tag[1])<<16 | ord(tag[2])<<8 | ord(tag[3]) + REND = 1145980242 # MAKE_ID(b'REND') + TEST = 1414743380 # MAKE_ID(b'TEST') + + blendfile = open(path, 'rb') + + head = blendfile.read(7) + + if head[0:2] == b'\x1f\x8b': # gzip magic + import gzip + blendfile.close() + blendfile = gzip.open(path, 'rb') + head = blendfile.read(7) + + if head != b'BLENDER': + blendfile.close() + return None, 0, 0 + + is_64_bit = (blendfile.read(1) == b'-') + + # true for PPC, false for X86 + is_big_endian = (blendfile.read(1) == b'V') + + # Now read the bhead chunk!!! + blendfile.read(3) # skip the version + + sizeof_pointer = 8 if is_64_bit else 4 + + sizeof_bhead = 24 if is_64_bit else 20 + + int_endian = '>i' if is_big_endian else ' ") + else: + file_in = sys.argv[-2] + + buf, width, height = blend_extract_thumb(file_in) + + if buf: + file_out = sys.argv[-1] + + f = open(file_out, "wb") + f.write(write_png(buf, width, height)) + f.close() From 7ba821cab384f45691bb73bc0712926ae4c819de Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Fri, 16 Jul 2010 06:49:31 +0000 Subject: [PATCH 43/51] Add comment about case where autosave can fail on Windows. --- source/blender/windowmanager/intern/wm_files.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 89b8267bb05..fc7bf9b79c7 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -689,6 +689,14 @@ void wm_autosave_location(char *filename) sprintf(pidstr, "%d.blend", abs(getpid())); #ifdef WIN32 + // XXX Need to investigate how to handle default location of '/tmp/' + // This is a relative directory on Windows, and it may be + // found. Example: + // Blender installed on D:\ drive, D:\ drive has D:\tmp\ + // Now, BLI_exists() will find '/tmp/' exists, but + // BLI_make_file_string will create string that has it most likely on C:\ + // through get_default_root(). + // If there is no C:\tmp autosave fails. if (!BLI_exists(U.tempdir)) { savedir = BLI_get_folder_create(BLENDER_USER_AUTOSAVE, NULL); BLI_make_file_string("/", filename, savedir, pidstr); From 952821dfd44ad9bbf674bbea2d7738556a46c663 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Fri, 16 Jul 2010 09:10:46 +0000 Subject: [PATCH 44/51] BGE doc updates: Fixed some typos and added docs for the following functions: startGame() endGame() restartGame() LibLoad() LibNew() LibFree() --- source/gameengine/PyDoc/bge.logic.rst | 62 ++++++++++++++++++++------ source/gameengine/PyDoc/bge.render.rst | 4 +- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/source/gameengine/PyDoc/bge.logic.rst b/source/gameengine/PyDoc/bge.logic.rst index 84b480e2ab9..a10733569f3 100644 --- a/source/gameengine/PyDoc/bge.logic.rst +++ b/source/gameengine/PyDoc/bge.logic.rst @@ -158,6 +158,48 @@ General functions Saves bge.logic.globalDict to a file. +.. function:: startGame(blend) + + Loads the blend file. + + :arg blend: The name of the blend file + :type blend: string + +.. function:: endGame() + + Ends the current game. + +.. function:: restartGame() + + Restarts the current game by reloading the .blend file (the last saved version, not what is currently running). + +.. function:: LibLoad(blend, type) + + Converts the all of the datablocks of the given type from the given blend. + + :arg blend: The path to the blend file + :type blend: string + :arg type: The datablock type (currently only "Scene" and "Mesh" are supported) + :type type: string + +.. function:: LibNew(name, type, data) + + Uses existing datablock data and loads in as a new library. + + :arg name: A unique library name used for removal later + :type name: string + :arg type: The datablock type (currently only "Mesh" is supported) + :type type: string + :arg data: A list of names of the datablocks to load + :type data: list of strings + +.. function:: LibFree(name) + + Frees a library, removing all objects and meshes from the currently active scenes. + + :arg name: The name of the library to free (the name used in LibNew) + :type name: string + .. function:: addScene(name, overlay=1) Loads a scene into the game engine. @@ -202,24 +244,24 @@ General functions .. function:: getMaxLogicFrame() - Gets the maximum number of logic frame per render frame. + Gets the maximum number of logic frames per render frame. - :return: The maximum number of logic frame per render frame + :return: The maximum number of logic frames per render frame :rtype: integer .. function:: setMaxLogicFrame(maxlogic) - Sets the maximum number of logic frame that are executed per render frame. + Sets the maximum number of logic frames that are executed per render frame. This does not affect the physic system that still runs at full frame rate. - :arg maxlogic: The new maximum number of logic frame per render frame. Valid values: 1..5 + :arg maxlogic: The new maximum number of logic frames per render frame. Valid values: 1..5 :type maxlogic: integer .. function:: getMaxPhysicsFrame() - Gets the maximum number of physics frame per render frame. + Gets the maximum number of physics frames per render frame. - :return: The maximum number of physics frame per render frame + :return: The maximum number of physics frames per render frame :rtype: integer .. function:: setMaxPhysicsFrame(maxphysics) @@ -270,14 +312,6 @@ General functions .. warning: Not implimented yet -.. function:: saveGlobalDict() - - Saves bge.logic.globalDict to a file. - -.. function:: loadGlobalDict() - - Loads bge.logic.globalDict from a file. - ***************** Utility functions ***************** diff --git a/source/gameengine/PyDoc/bge.render.rst b/source/gameengine/PyDoc/bge.render.rst index cea84f3b506..9f17455601b 100644 --- a/source/gameengine/PyDoc/bge.render.rst +++ b/source/gameengine/PyDoc/bge.render.rst @@ -230,7 +230,7 @@ Functions .. function:: enableMotionBlur(factor) - Enable the motion blue effect. + Enable the motion blur effect. :arg factor: the ammount of motion blur to display. :type factor: float [0.0 - 1.0] @@ -238,5 +238,5 @@ Functions .. function:: disableMotionBlur() - Disable the motion blue effect. + Disable the motion blur effect. From d94868f82138baedbd227c708878577061191bbe Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 16 Jul 2010 09:45:09 +0000 Subject: [PATCH 45/51] Incorrect flags were checing for cyclic in order clamping functions --- source/blender/blenkernel/intern/curve.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index aa7b44aecda..5015e0cef6c 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -3078,7 +3078,7 @@ int clamp_nurb_order_u( struct Nurb *nu ) nu->orderu= nu->pntsu; change= 1; } - if(((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { + if(((nu->flagu & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { CLAMP(nu->orderu, 3,4); change= 1; } @@ -3092,7 +3092,7 @@ int clamp_nurb_order_v( struct Nurb *nu) nu->orderv= nu->pntsv; change= 1; } - if(((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { + if(((nu->flagv & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { CLAMP(nu->orderv, 3,4); change= 1; } From f6ae7af2431a83f4492f72fd1b1df421f8675936 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 16 Jul 2010 10:13:04 +0000 Subject: [PATCH 46/51] 2.5: automatic draw method now uses overlap for Intel on all platforms. --- source/blender/gpu/GPU_extensions.h | 14 +++++++------- source/blender/gpu/intern/gpu_extensions.c | 4 ++-- source/blender/windowmanager/intern/wm_draw.c | 9 +++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index 5275f8988a8..a7f43d3b0ae 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -75,17 +75,17 @@ typedef enum GPUDeviceType { } GPUDeviceType; typedef enum GPUOSType { - GPU_OS_WIN = (1<<16), - GPU_OS_MAC = (1<<17), - GPU_OS_UNIX = (1<<18), + GPU_OS_WIN = (1<<8), + GPU_OS_MAC = (1<<9), + GPU_OS_UNIX = (1<<10), GPU_OS_ANY = (0xff00) } GPUOSType; typedef enum GPUDriverType { - GPU_DRIVER_OFFICIAL = (1<<24), - GPU_DRIVER_OPENSOURCE = (1<<25), - GPU_DRIVER_SOFTWARE = (1<<26), - GPU_DRIVER_UNKNOWN = (0xff0000) + GPU_DRIVER_OFFICIAL = (1<<16), + GPU_DRIVER_OPENSOURCE = (1<<17), + GPU_DRIVER_SOFTWARE = (1<<18), + GPU_DRIVER_ANY = (0xff0000) } GPUDriverType; int GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver); diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 0b7ea605ec8..a96920aa839 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -152,8 +152,8 @@ void GPU_extensions_init() GG.driver = GPU_DRIVER_SOFTWARE; } else { - GG.device = GPU_DEVICE_UNKNOWN; - GG.driver = GPU_DRIVER_UNKNOWN; + GG.device = GPU_DEVICE_ANY; + GG.driver = GPU_DRIVER_ANY; } GG.os = GPU_OS_UNIX; diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 38322b66bbb..7e0ee7226c5 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -677,13 +677,22 @@ static int wm_draw_update_test_window(wmWindow *win) static int wm_automatic_draw_method(wmWindow *win) { + /* Ideally all cards would work well with triple buffer, since if it works + well gives the least redraws and is considerably faster at partial redraw + for sculpting or drawing overlapping menus. For typically lower end cards + copy to texture is slow though and so we use overlap instead there. */ + if(win->drawmethod == USER_DRAW_AUTOMATIC) { /* ATI opensource driver is known to be very slow at this */ if(GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) return USER_DRAW_OVERLAP; + /* also Intel drivers don't work well with this */ + else if(GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) + return USER_DRAW_OVERLAP; /* Windows software driver darkens color on each redraw */ else if(GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_WIN, GPU_DRIVER_SOFTWARE)) return USER_DRAW_OVERLAP_FLIP; + /* drawing lower color depth again degrades colors each time */ else if(GPU_color_depth() < 24) return USER_DRAW_OVERLAP; else From dd705a25ceb0be2044f1f11055140811be892b03 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Jul 2010 13:55:22 +0000 Subject: [PATCH 47/51] fix for freeze while resizing sequencer view vertically --- source/blender/editors/space_sequencer/sequencer_draw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 4f52a17f623..e46294513e7 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -381,6 +381,8 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, SpaceSeq *sseq, Seque pixely = (v2d->cur.ymax - v2d->cur.ymin)/(v2d->mask.ymax - v2d->mask.ymin); + if(pixely <= 0) return; /* can happen when the view is split/resized */ + blendcol[0] = blendcol[1] = blendcol[2] = 120; if(seq->startofs) { From ddfdf8e1b2d3826e8dac197e81f4bad2b7c6abdd Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Fri, 16 Jul 2010 14:00:57 +0000 Subject: [PATCH 48/51] Fix for [#22668] Adding sequencer color strip fails when sound strip selected. Hi, I've written a patch to fix this issue. Since the Effect Strip "Color" doesn't need any input sequences, there is no need to output a warning when adding this effect while other sequences are selected. My fix let's all Effect Strips that don't need input sequences pass the warning "Can't apply effects to audio sequence strips". I think this is fair. -Konrad --- source/blender/editors/space_sequencer/sequencer_edit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index d3d2fd7e220..004aacb921f 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -621,7 +621,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen for(seq=ed->seqbasep->first; seq; seq=seq->next) { if(seq->flag & SELECT) { - if (seq->type == SEQ_SOUND) { + if (seq->type == SEQ_SOUND && get_sequence_effect_num_inputs(type) != 0) { *error_str= "Can't apply effects to audio sequence strips"; return 0; } From 3ef41270f96b4ee3592ec5302a5383399c38ff5d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Jul 2010 15:45:35 +0000 Subject: [PATCH 49/51] [#22880] SEQUENCER: Flip Y broken in recent builds (Windows & Linux) own fault when adding saturation. --- source/blender/blenkernel/intern/sequencer.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d97e6151a13..de4e7a5ccbe 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1800,6 +1800,10 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf if(seq->flag & SEQ_FLIPX) { IMB_flipx(se->ibuf); } + + if(seq->flag & SEQ_FLIPY) { + IMB_flipy(se->ibuf); + } if(seq->sat != 1.0f) { /* inline for now, could become an imbuf function */ @@ -2279,6 +2283,13 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int addzbuffloatImBuf(se->ibuf); memcpy(se->ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty); } + + /* { + ImBuf *imb= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); + IMB_saveiff(imb, "/tmp/foo.image", IB_rect | IB_metadata); + IMB_freeImBuf(imb); + } */ + } else if (rres.rect32) { se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); From ca3f3317b2ca16f91972f8176c2fa366f1bf5fb5 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Fri, 16 Jul 2010 16:02:07 +0000 Subject: [PATCH 50/51] == installation paths == * rename BLI_gethome to BLI_getDefaultDocumentFolder to better reflect how this function is used * replaced BLI_gethome with getenv("HOME") on Linux and Mac where it retrieves location of bookmarks that are inserted as system bookmarks. BLI_gethome was a thin wrapper around these and in this case the user's home directory is what is actually wanted. --- source/blender/blenlib/BLI_path_util.h | 4 ++-- source/blender/blenlib/intern/path_util.c | 4 ++-- source/blender/editors/space_file/file_ops.c | 2 +- source/blender/editors/space_file/fsmenu.c | 4 ++-- source/blender/windowmanager/intern/wm_init_exit.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 60d35c9ecdf..07e0da5e461 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -40,14 +40,14 @@ extern "C" { struct ListBase; struct direntry; -char *BLI_gethome(void); +char *BLI_getDefaultDocumentFolder(void); char *BLI_get_folder(int folder_id, char *subfolder); char *BLI_get_folder_create(int folder_id, char *subfolder); /* folder_id */ -/* general, will find baserd on user/local/system priority */ +/* general, will find based on user/local/system priority */ #define BLENDER_CONFIG 1 #define BLENDER_DATAFILES 2 #define BLENDER_SCRIPTS 3 diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index df1e2c7d590..2f8e4ab44b2 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -732,10 +732,10 @@ void BLI_getlastdir(const char* dir, char *last, int maxlen) } } -/* This is now only used to really get the user's home folder */ +/* This is now only used to really get the user's default document folder */ /* On Windows I chose the 'Users//Documents' since it's used as default location to save documents */ -char *BLI_gethome(void) { +char *BLI_getDefaultDocumentFolder(void) { #if !defined(WIN32) return getenv("HOME"); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 55a44b36a52..bd7be303e33 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -945,7 +945,7 @@ int file_directory_exec(bContext *C, wmOperator *unused) if ( sfile->params->dir[0] == '~' ) { char tmpstr[sizeof(sfile->params->dir)-1]; strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr)); - BLI_join_dirfile(sfile->params->dir, BLI_gethome(), tmpstr); + BLI_join_dirfile(sfile->params->dir, BLI_getDefaultDocumentFolder(), tmpstr); } #ifdef WIN32 diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 6699c0b8bc7..6603bba5a89 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -338,7 +338,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) /* As 10.4 doesn't provide proper API to retrieve the favorite places, assume they are the standard ones TODO : replace hardcoded paths with proper BLI_get_folder calls */ - home = BLI_gethome(); + home = getenv("HOME"); if(home) { BLI_snprintf(line, 256, "%s/", home); fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); @@ -458,7 +458,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) #else /* unix */ { - char *home= BLI_gethome(); + char *home= getenv("HOME"); if(home) { BLI_snprintf(line, FILE_MAXDIR, "%s/", home); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 5bfaf91aa11..558d20021ce 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -166,7 +166,7 @@ void WM_init(bContext *C, int argc, char **argv) read_history(); if(G.sce[0] == 0) - BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend"); + BLI_make_file_string("/", G.sce, BLI_getDefaultDocumentFolder(), "untitled.blend"); BLI_strncpy(G.lib, G.sce, FILE_MAX); From 6a880daa92487b7f18653c32fcfcbad11ead6b75 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Jul 2010 16:54:39 +0000 Subject: [PATCH 51/51] homekey in sequencer viewer wasnt quite setting 1:1 --- source/blender/editors/space_sequencer/sequencer_edit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 004aacb921f..b320deb85e3 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2157,7 +2157,7 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op) float facx= (v2d->mask.xmax - v2d->mask.xmin) / winx; float facy= (v2d->mask.ymax - v2d->mask.ymin) / winy; - BLI_resize_rctf(&v2d->cur, winx*facx*ratio, winy*facy*ratio); + BLI_resize_rctf(&v2d->cur, (int)(winx*facx*ratio) + 1, (int)(winy*facy*ratio) + 1); ED_region_tag_redraw(CTX_wm_region(C));