From f75ca60a1c55388334a3b85934bd23a122c6b92c Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 10 Feb 2013 08:28:47 +0000 Subject: [PATCH 001/157] BGE: Make sure we are writting to the depth buffer when rendering alpha polygons for shadows. Otherwise alpha shadows won't work\! --- source/gameengine/Rasterizer/RAS_BucketManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index df72056565b..b2b766b65e8 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -148,7 +148,8 @@ void RAS_BucketManager::RenderAlphaBuckets( // Having depth masks disabled/enabled gives different artifacts in // case no sorting is done or is done inexact. For compatibility, we // disable it. - rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_DISABLED); + if (rasty->GetDrawingMode() != RAS_IRasterizer::KX_SHADOW) + rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_DISABLED); OrderBuckets(cameratrans, m_AlphaBuckets, slots, true); From 5d4df1a999d65bdfe67cec1088b34d9d47fc5412 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Feb 2013 08:54:10 +0000 Subject: [PATCH 002/157] pep8 cleanup --- release/scripts/presets/keyconfig/maya.py | 2 +- .../scripts/startup/bl_operators/rigidbody.py | 17 ++++--- .../startup/bl_ui/properties_paint_common.py | 4 +- .../startup/bl_ui/properties_particle.py | 2 +- .../bl_ui/properties_physics_common.py | 6 ++- .../bl_ui/properties_physics_rigidbody.py | 44 ++++++++++--------- ...properties_physics_rigidbody_constraint.py | 2 +- .../scripts/startup/bl_ui/properties_scene.py | 1 + release/scripts/startup/bl_ui/space_clip.py | 8 +++- release/scripts/startup/bl_ui/space_image.py | 3 +- release/scripts/startup/bl_ui/space_view3d.py | 2 +- 11 files changed, 53 insertions(+), 38 deletions(-) diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index cea2f451305..ad6a2be6cf5 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -218,7 +218,7 @@ kmi.properties.use = True kmi = km.keymap_items.new('transform.mirror', 'M', 'PRESS', ctrl=True) kmi = km.keymap_items.new('wm.context_toggle', 'TAB', 'PRESS', shift=True) kmi.properties.data_path = 'tool_settings.use_snap' -kmi = km.keymap_items.new('WM_OT_context_menu_enum', 'TAB', 'PRESS', shift=True, ctrl=True); +kmi = km.keymap_items.new('WM_OT_context_menu_enum', 'TAB', 'PRESS', shift=True, ctrl=True) kmi.properties.data_path = 'tool_settings.snap_element' kmi = km.keymap_items.new('view3d.enable_manipulator', 'W', 'PRESS') diff --git a/release/scripts/startup/bl_operators/rigidbody.py b/release/scripts/startup/bl_operators/rigidbody.py index 161349152d5..bb3a9a6330f 100644 --- a/release/scripts/startup/bl_operators/rigidbody.py +++ b/release/scripts/startup/bl_operators/rigidbody.py @@ -54,7 +54,7 @@ class CopyRigidbodySettings(Operator): for o in objects: if o.rigid_body is None: continue - + o.rigid_body.type = obj.rigid_body.type o.rigid_body.kinematic = obj.rigid_body.kinematic o.rigid_body.mass = obj.rigid_body.mass @@ -144,7 +144,7 @@ class BakeToKeyframes(Operator): # this is a little roundabout but there's no better way right now aa = mat.to_quaternion().to_axis_angle() obj.rotation_axis_angle = (aa[1], ) + aa[0][:] - else: # euler + else: # euler # make sure euler rotation is compatible to previous frame obj.rotation_euler = mat.to_euler(rot_mode, obj_prev.rotation_euler) @@ -190,7 +190,8 @@ class BakeToKeyframes(Operator): class ConnectRigidBodies(Operator): - '''Create rigid body constraints between selected and active rigid bodies''' + """Create rigid body constraints between """ \ + """selected and active rigid bodies""" bl_idname = "rigidbody.connect" bl_label = "Connect Rigid Bodies" bl_options = {'REGISTER', 'UNDO'} @@ -232,7 +233,11 @@ class ConnectRigidBodies(Operator): loc = obj.location else: loc = (obj_act.location + obj.location) / 2.0 - bpy.ops.object.add(type='EMPTY', view_align=False, enter_editmode=False, location=loc) + # TODO: use bpy.data.objects.new(...) + bpy.ops.object.add(type='EMPTY', + view_align=False, + enter_editmode=False, + location=loc) bpy.ops.rigidbody.constraint_add() con_obj = context.active_object con_obj.empty_draw_type = 'ARROWS' @@ -241,12 +246,12 @@ class ConnectRigidBodies(Operator): con.object1 = obj_act con.object2 = obj change = True - + if change: # restore selection bpy.ops.object.select_all(action='DESELECT') for obj in objects: - obj.select = True; + obj.select = True scene.objects.active = obj_act return {'FINISHED'} else: diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index 022f2500940..7c06aefe575 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -82,7 +82,7 @@ def brush_texture_settings(layout, brush, sculpt): else: layout.row().prop(tex_slot, "tex_paint_map_mode", text="") layout.separator() - + # angle and texture_angle_source col = layout.column() if sculpt: @@ -101,7 +101,7 @@ def brush_texture_settings(layout, brush, sculpt): split = layout.split() split.prop(tex_slot, "offset") split.prop(tex_slot, "scale") - + if sculpt: # texture_sample_bias col = layout.column(align=True) diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index aef860e774b..ee8c74a2cb6 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -543,7 +543,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, Panel): # spacing between particles when the fluid is at rest. This # makes it easier to set stable initial conditions. particle_volume = part.mass / fluid.rest_density - spacing = pow(particle_volume, 1/3) + spacing = pow(particle_volume, 1.0 / 3.0) sub = col.row() sub.label(text="Spacing: %g" % spacing) diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index 17a44a523dc..a640cb215ba 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -44,6 +44,7 @@ def physics_add(self, layout, md, name, type, typeicon, toggles): else: sub.operator("object.modifier_add", text=name, icon=typeicon).type = type + def physics_add_special(self, layout, data, name, addop, removeop, typeicon): sub = layout.row(align=True) if data: @@ -51,6 +52,7 @@ def physics_add_special(self, layout, data, name, addop, removeop, typeicon): else: sub.operator(addop, text=name, icon=typeicon) + class PHYSICS_PT_add(PhysicButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} @@ -86,13 +88,13 @@ class PHYSICS_PT_add(PhysicButtonsPanel, Panel): physics_add_special(self, col, ob.rigid_body, "Rigid Body", "rigidbody.object_add", "rigidbody.object_remove", - 'MESH_ICOSPHERE') # XXX: need dedicated icon + 'MESH_ICOSPHERE') # XXX: need dedicated icon # all types of objects can have rigid body constraint physics_add_special(self, col, ob.rigid_body_constraint, "Rigid Body Constraint", "rigidbody.constraint_add", "rigidbody.constraint_remove", - 'CONSTRAINT') # RB_TODO needs better icon + 'CONSTRAINT') # RB_TODO needs better icon # cache-type can be 'PSYS' 'HAIR' 'SMOKE' etc diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py index f335c560f7b..922eee66ddc 100644 --- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py +++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py @@ -32,22 +32,22 @@ class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel): @classmethod def poll(cls, context): - ob = context.object - rd = context.scene.render - return (ob and ob.rigid_body and (not rd.use_game_engine)) + obj = context.object + return (obj and obj.rigid_body and + (not context.scene.render.use_game_engine)) def draw_header(self, context): obj = context.object rbo = obj.rigid_body if rbo is not None: - self.layout.prop(rbo, "enabled", text=""); + self.layout.prop(rbo, "enabled", text="") def draw(self, context): layout = self.layout ob = context.object rbo = ob.rigid_body - + if rbo is not None: layout.prop(rbo, "type", text="Type") layout.prop(rbo, "kinematic", text="Animated") @@ -61,34 +61,35 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel): @classmethod def poll(cls, context): - return (context.object and context.object.rigid_body and + obj = context.object + return (obj and obj.rigid_body and (not context.scene.render.use_game_engine)) - + def draw(self, context): layout = self.layout ob = context.object rbo = ob.rigid_body - + layout.prop(rbo, "collision_shape", text="Shape") - + split = layout.split() - + col = split.column() col.label(text="Surface Response:") col.prop(rbo, "friction") col.prop(rbo, "restitution", text="Bounciness") - + col = split.column() col.label(text="Sensitivity:") if rbo.collision_shape in {'MESH', 'CONE'}: col.prop(rbo, "collision_margin", text="Margin") else: - col.prop(rbo, "use_margin"); + col.prop(rbo, "use_margin") sub = col.column() sub.active = rbo.use_margin sub.prop(rbo, "collision_margin", text="Margin") - + layout.prop(rbo, "collision_groups") @@ -98,22 +99,23 @@ class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel): @classmethod def poll(cls, context): - return (context.object and context.object.rigid_body and - context.object.rigid_body.type == 'ACTIVE' and + obj = context.object + return (obj and obj.rigid_body and + obj.rigid_body.type == 'ACTIVE' and (not context.scene.render.use_game_engine)) - + def draw(self, context): layout = self.layout ob = context.object rbo = ob.rigid_body - + #col = layout.column(align=1) #col.label(text="Activation:") # XXX: settings such as activate on collison/etc. - - split = layout.split(); - + + split = layout.split() + col = split.column() col.label(text="Deactivation:") col.prop(rbo, "use_deactivation") @@ -123,7 +125,7 @@ class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel): sub.prop(rbo, "deactivate_linear_velocity", text="Linear Vel") sub.prop(rbo, "deactivate_angular_velocity", text="Angular Vel") # TODO: other params such as time? - + col = split.column() col.label(text="Damping:") col.prop(rbo, "linear_damping", text="Translation") diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py index 49b760ef546..e4e5b94407d 100644 --- a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py +++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py @@ -173,7 +173,7 @@ class PHYSICS_PT_rigid_body_constraint(PHYSICS_PT_rigidbody_constraint_panel, Pa sub.prop(rbc, "limit_ang_z_lower", text="Lower") sub.prop(rbc, "limit_ang_z_upper", text="Upper") - if rbc.type == 'GENERIC_SPRING': + if rbc.type == 'GENERIC_SPRING': col = layout.column(align=True) col.label("Springs:") diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index b9b57923420..68a097e6188 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -26,6 +26,7 @@ from bl_ui.properties_physics_common import ( effector_weights_ui, ) + class SCENE_UL_keying_set_paths(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): # assert(isinstance(item, bpy.types.KeyingSetPath) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 84f26acb4cc..b61830a7527 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -28,10 +28,14 @@ class CLIP_UL_tracking_objects(UIList): # assert(isinstance(item, bpy.types.MovieTrackingObject) tobj = item if self.layout_type in {'DEFAULT', 'COMPACT'}: - layout.label(text=tobj.name, translate=False, icon='CAMERA_DATA' if tobj.is_camera else 'OBJECT_DATA') + layout.label(text=tobj.name, translate=False, + icon='CAMERA_DATA' if tobj.is_camera + else 'OBJECT_DATA') elif self.layout_type in {'GRID'}: layout.alignment = 'CENTER' - layout.label(text="", icon='CAMERA_DATA' if tobj.is_camera else 'OBJECT_DATA') + layout.label(text="", + icon='CAMERA_DATA' if tobj.is_camera + else 'OBJECT_DATA') class CLIP_HT_header(Header): diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 6d08663006f..43535eb8c2f 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -22,6 +22,7 @@ from bpy.types import Header, Menu, Panel from bl_ui.properties_paint_common import UnifiedPaintPanel from bl_ui.properties_paint_common import brush_texture_settings + class ImagePaintPanel(UnifiedPaintPanel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'UI' @@ -722,7 +723,7 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel): col = layout.column() col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8) - + brush_texture_settings(col, brush, 0) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 6a0cf44a784..fcc20243a8c 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2695,7 +2695,7 @@ class VIEW3D_PT_etch_a_ton(Panel): colsub = col.column(align=True) colsub.prop(toolsettings, "use_etch_autoname") - sub = colsub.column() + sub = colsub.column() sub.enabled = not toolsettings.use_etch_autoname sub.prop(toolsettings, "etch_number") sub.prop(toolsettings, "etch_side") From c0fa16f2c99abb3db9b4fab1a952383e6fd81167 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 10 Feb 2013 09:09:26 +0000 Subject: [PATCH 003/157] Another fix for r54414 (cleaner to "import" pgettext once at top of files, also now using usual '_' shortcut). --- .../startup/bl_ui/properties_data_modifier.py | 5 +++-- .../startup/bl_ui/properties_material.py | 5 +++-- .../startup/bl_ui/properties_particle.py | 5 +++-- .../startup/bl_ui/properties_physics_fluid.py | 5 +++-- release/scripts/startup/bl_ui/space_clip.py | 8 +++---- release/scripts/startup/bl_ui/space_image.py | 8 +++---- .../scripts/startup/bl_ui/space_sequencer.py | 22 ++++++++----------- release/scripts/startup/bl_ui/space_text.py | 5 +++-- .../scripts/startup/bl_ui/space_userpref.py | 5 +++-- .../startup/bl_ui/space_userpref_keymap.py | 5 +++-- 10 files changed, 38 insertions(+), 35 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 679b33292e5..a0909b52760 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -20,6 +20,8 @@ import bpy from bpy.types import Panel +_ = bpy.app.translations.pgettext + class ModifierButtonsPanel(): bl_space_type = 'PROPERTIES' @@ -265,8 +267,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.prop(md, "angle_limit") layout.prop(md, "use_dissolve_boundaries") - pgettext = bpy.app.translations.pgettext - layout.label(text=pgettext("Face Count: %d") % md.face_count, translate=False) + layout.label(text=_("Face Count: %d") % md.face_count, translate=False) def DISPLACE(self, layout, ob, md): has_texture = (md.texture is not None) diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 9b7cfe89a08..8c6a67ea17e 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -21,6 +21,8 @@ import bpy from bpy.types import Menu, Panel, UIList from rna_prop_ui import PropertyPanel +_ = bpy.app.translations.pgettext + def active_node_mat(mat): # TODO, 2.4x has a pipeline section, for 2.5 we need to communicate @@ -80,8 +82,7 @@ class MATERIAL_UL_matslots(UIList): if ma and not context.scene.render.use_shading_nodes: manode = ma.active_node_material if manode: - pgettext = bpy.app.translations.pgettext - layout.label(text=pgettext("Node %s") % manode.name, translate=False, icon_value=layout.icon(manode)) + layout.label(text=_("Node %s") % manode.name, translate=False, icon_value=layout.icon(manode)) elif ma.use_nodes: layout.label(text="Node ") else: diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index ee8c74a2cb6..24e65622854 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -21,6 +21,8 @@ import bpy from bpy.types import Panel from rna_prop_ui import PropertyPanel +_ = bpy.app.translations.pgettext + from bl_ui.properties_physics_common import (point_cache_ui, effector_weights_ui, basic_force_field_settings_ui, @@ -148,8 +150,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): #row.label(text="Render") if part.is_fluid: - pgettext = bpy.app.translations.pgettext - layout.label(text=pgettext("%d fluid particles for this frame") % part.count, translate=False) + layout.label(text=_("%d fluid particles for this frame") % part.count, translate=False) return row = col.row() diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index c03b5323105..623c6377954 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -20,6 +20,8 @@ import bpy from bpy.types import Panel, Menu +_ = bpy.app.translations.pgettext + class FLUID_MT_presets(Menu): bl_label = "Fluid Presets" @@ -64,8 +66,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel): if fluid.type == 'DOMAIN': # odd formatting here so translation script can extract string - pgettext = bpy.app.translations.pgettext - layout.operator("fluid.bake", text=pgettext("Bake (Req. Memory: %s)") % fluid.memory_estimate, + layout.operator("fluid.bake", text=_("Bake (Req. Memory: %s)") % fluid.memory_estimate, translate=False, icon='MOD_FLUIDSIM') split = layout.split() diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index b61830a7527..cd232fc50f3 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -21,6 +21,8 @@ import bpy from bpy.types import Panel, Header, Menu, UIList +_ = bpy.app.translations.pgettext + class CLIP_UL_tracking_objects(UIList): def draw_item(self, context, layout, data, item, icon, @@ -911,11 +913,9 @@ class CLIP_MT_view(Menu): ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1)) - text = bpy.app.translations.pgettext("Zoom %d:%d") + text = _("Zoom %d:%d") for a, b in ratios: - layout.operator("clip.view_zoom_ratio", - text=text % (a, b), - translate=False).ratio = a / b + layout.operator("clip.view_zoom_ratio", text=text % (a, b), translate=False).ratio = a / b else: if sc.view == 'GRAPH': layout.operator_context = 'INVOKE_REGION_PREVIEW' diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 43535eb8c2f..44b84eba919 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -22,6 +22,8 @@ from bpy.types import Header, Menu, Panel from bl_ui.properties_paint_common import UnifiedPaintPanel from bl_ui.properties_paint_common import brush_texture_settings +_ = bpy.app.translations.pgettext + class ImagePaintPanel(UnifiedPaintPanel): bl_space_type = 'IMAGE_EDITOR' @@ -71,10 +73,8 @@ class IMAGE_MT_view(Menu): ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1)) - pgettext = bpy.app.translations.pgettext for a, b in ratios: - layout.operator("image.view_zoom_ratio", text=pgettext("Zoom %d:%d") % (a, b), - translate=False).ratio = a / b + layout.operator("image.view_zoom_ratio", text=_("Zoom %d:%d") % (a, b), translate=False).ratio = a / b layout.separator() @@ -723,7 +723,7 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel): col = layout.column() col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8) - + brush_texture_settings(col, brush, 0) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index b8f44a621a9..5d927e6b477 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -20,6 +20,8 @@ import bpy from bpy.types import Header, Menu, Panel +_ = bpy.app.translations.pgettext + def act_strip(context): try: @@ -420,19 +422,15 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel): sub.prop(strip, "frame_start") sub.prop(strip, "frame_final_duration") - pgettext = bpy.app.translations.pgettext col = layout.column(align=True) row = col.row() - row.label(text=pgettext("Final Length: %s") % bpy.utils.smpte_from_frame(strip.frame_final_duration), - translate=False) + row.label(text=_("Final Length: %s") % bpy.utils.smpte_from_frame(strip.frame_final_duration), translate=False) row = col.row() row.active = (frame_current >= strip.frame_start and frame_current <= strip.frame_start + strip.frame_duration) - row.label(text=pgettext("Playhead: %d") % (frame_current - strip.frame_start), translate=False) + row.label(text=_("Playhead: %d") % (frame_current - strip.frame_start), translate=False) - col.label(text=pgettext("Frame Offset %d:%d") % (strip.frame_offset_start, strip.frame_offset_end), - translate=False) - col.label(text=pgettext("Frame Still %d:%d") % (strip.frame_still_start, strip.frame_still_end), - translate=False) + col.label(text=_("Frame Offset %d:%d") % (strip.frame_offset_start, strip.frame_offset_end), translate=False) + col.label(text=_("Frame Still %d:%d") % (strip.frame_still_start, strip.frame_still_end), translate=False) elem = False @@ -442,7 +440,7 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel): elem = strip.elements[0] if elem and elem.orig_width > 0 and elem.orig_height > 0: - col.label(text=pgettext("Original Dimension: %dx%d") % (elem.orig_width, elem.orig_height), translate=False) + col.label(text=_("Original Dimension: %dx%d") % (elem.orig_width, elem.orig_height), translate=False) else: col.label(text="Original Dimension: None") @@ -719,8 +717,7 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel, Panel): if scene: sta = scene.frame_start end = scene.frame_end - pgettext = bpy.app.translations.pgettext - layout.label(text=pgettext("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False) + layout.label(text=_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False) class SEQUENCER_PT_mask(SequencerButtonsPanel, Panel): @@ -749,8 +746,7 @@ class SEQUENCER_PT_mask(SequencerButtonsPanel, Panel): if mask: sta = mask.frame_start end = mask.frame_end - pgettext = bpy.app.translations.pgettext - layout.label(text=pgettext("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False) + layout.label(text=_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False) class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index b32172e25e0..53b806cc7ea 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -20,6 +20,8 @@ import bpy from bpy.types import Header, Menu, Panel +_ = bpy.app.translations.pgettext + class TEXT_HT_header(Header): bl_space_type = 'TEXT_EDITOR' @@ -71,9 +73,8 @@ class TEXT_HT_header(Header): row = layout.row() if text.filepath: - pgettext = bpy.app.translations.pgettext if text.is_dirty: - row.label(text=pgettext("File: *%r (unsaved)") % + row.label(text=_("File: *%r (unsaved)") % text.filepath, translate=False) else: row.label(text=pgettext("File: %r") % diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 5bb83e7f429..eb9446f0fd0 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -20,6 +20,8 @@ import bpy from bpy.types import Header, Menu, Panel +_ = bpy.app.translations.pgettext + def ui_style_items(col, context): """ UI Style settings """ @@ -778,10 +780,9 @@ class USERPREF_PT_theme(Panel): layout.separator() elif theme.theme_area == 'BONE_COLOR_SETS': col = split.column() - pgettext = bpy.app.translations.pgettext for i, ui in enumerate(theme.bone_color_sets): - col.label(text=pgettext("Color Set %d:") % (i + 1), translate=False) # i starts from 0 + col.label(text=_("Color Set %d:") % (i + 1), translate=False) # i starts from 0 row = col.row() diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index db78adcb576..83815366824 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -20,6 +20,8 @@ import bpy from bpy.types import Menu +_ = bpy.app.translations.pgettext + class USERPREF_MT_keyconfigs(Menu): bl_label = "KeyPresets" @@ -97,8 +99,7 @@ class InputKeyMapPanel: subcol = self.indented_layout(col, level + 1) subrow = subcol.row() subrow.prop(km, "show_expanded_items", text="", emboss=False) - pgettext = bpy.app.translations.pgettext - subrow.label(text=pgettext("%s (Global)") % km.name, translate=False) + subrow.label(text=_("%s (Global)") % km.name, translate=False) else: km.show_expanded_items = True From b5962b7ccdf2ec9dabf92df5b32302aaa1cfda0a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 10 Feb 2013 09:27:25 +0000 Subject: [PATCH 004/157] Fix #34186: VSE: Incorrect movie output when scene strip is muted by keyframe --- source/blender/render/intern/source/render_result.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 35b06385ae6..c779b01afaa 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -1094,6 +1094,10 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd) if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) { IMB_float_from_rect(ibuf); } + else { + /* ensure no float buffer remained from previous frame */ + ibuf->rect_float = NULL; + } } /* color -> grayscale */ From 3b8a0f3d674a0da3bb17cbda30f0a2dc19a40e4f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Feb 2013 09:56:05 +0000 Subject: [PATCH 005/157] use import rather then assignment for loading '_' into scripts. --- release/scripts/modules/bpy/__init__.py | 1 + release/scripts/startup/bl_ui/properties_data_modifier.py | 2 +- release/scripts/startup/bl_ui/properties_material.py | 2 +- release/scripts/startup/bl_ui/properties_particle.py | 2 +- release/scripts/startup/bl_ui/properties_physics_fluid.py | 2 +- release/scripts/startup/bl_ui/space_clip.py | 2 +- release/scripts/startup/bl_ui/space_image.py | 5 ++--- release/scripts/startup/bl_ui/space_sequencer.py | 2 +- release/scripts/startup/bl_ui/space_text.py | 2 +- release/scripts/startup/bl_ui/space_userpref.py | 2 +- release/scripts/startup/bl_ui/space_userpref_keymap.py | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py index 34b7a9ea7b6..3a2f9bde2c7 100644 --- a/release/scripts/modules/bpy/__init__.py +++ b/release/scripts/modules/bpy/__init__.py @@ -58,6 +58,7 @@ def main(): # from bpy.types import Panel sys.modules["bpy.app"] = app sys.modules["bpy.app.handlers"] = app.handlers + sys.modules["bpy.app.translations"] = app.translations sys.modules["bpy.types"] = types #~ if "-d" in sys.argv: # Enable this to measure start up speed diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index a0909b52760..303015ebac2 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -20,7 +20,7 @@ import bpy from bpy.types import Panel -_ = bpy.app.translations.pgettext +from bpy.app.translations import pgettext as _ class ModifierButtonsPanel(): diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 8c6a67ea17e..f3a83d225b9 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -21,7 +21,7 @@ import bpy from bpy.types import Menu, Panel, UIList from rna_prop_ui import PropertyPanel -_ = bpy.app.translations.pgettext +from bpy.app.translations import pgettext as _ def active_node_mat(mat): diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 24e65622854..fb930e9de5b 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -21,7 +21,7 @@ import bpy from bpy.types import Panel from rna_prop_ui import PropertyPanel -_ = bpy.app.translations.pgettext +from bpy.app.translations import pgettext as _ from bl_ui.properties_physics_common import (point_cache_ui, effector_weights_ui, diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index 623c6377954..c9eaa7a4acc 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -20,7 +20,7 @@ import bpy from bpy.types import Panel, Menu -_ = bpy.app.translations.pgettext +from bpy.app.translations import pgettext as _ class FLUID_MT_presets(Menu): diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index cd232fc50f3..e26f44675fb 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -21,7 +21,7 @@ import bpy from bpy.types import Panel, Header, Menu, UIList -_ = bpy.app.translations.pgettext +from bpy.app.translations import pgettext as _ class CLIP_UL_tracking_objects(UIList): diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 44b84eba919..ed4b28a62d7 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -19,10 +19,9 @@ # import bpy from bpy.types import Header, Menu, Panel -from bl_ui.properties_paint_common import UnifiedPaintPanel -from bl_ui.properties_paint_common import brush_texture_settings +from bl_ui.properties_paint_common import UnifiedPaintPanel, brush_texture_settings -_ = bpy.app.translations.pgettext +from bpy.app.translations import pgettext as _ class ImagePaintPanel(UnifiedPaintPanel): diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 5d927e6b477..c8d7d1e60c1 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -20,7 +20,7 @@ import bpy from bpy.types import Header, Menu, Panel -_ = bpy.app.translations.pgettext +from bpy.app.translations import pgettext as _ def act_strip(context): diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index 53b806cc7ea..089bffd7e75 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -20,7 +20,7 @@ import bpy from bpy.types import Header, Menu, Panel -_ = bpy.app.translations.pgettext +from bpy.app.translations import pgettext as _ class TEXT_HT_header(Header): diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index eb9446f0fd0..239597d54f9 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -20,7 +20,7 @@ import bpy from bpy.types import Header, Menu, Panel -_ = bpy.app.translations.pgettext +from bpy.app.translations import pgettext as _ def ui_style_items(col, context): diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index 83815366824..1c0e54c2c47 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -20,7 +20,7 @@ import bpy from bpy.types import Menu -_ = bpy.app.translations.pgettext +from bpy.app.translations import pgettext as _ class USERPREF_MT_keyconfigs(Menu): From d0f4a2396b38c122b7e56de83532515ae8fa4381 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 10 Feb 2013 10:29:38 +0000 Subject: [PATCH 006/157] Actually, UI scripts should not use directly pgettext, but rather the iface or tooltip variants. Added those to bpy.app.translations, and used pgettext_iface. (Did not add those when I created that module, because I did not thought we would actually need them in usual UI code, but turned out I was wrong). Also made some optimizations in those py gettext funcs, when i18n is disabled at build time, no need to do pyobject -> cstring -> pyobject conversions!. --- .../startup/bl_ui/properties_data_modifier.py | 5 +- .../startup/bl_ui/properties_material.py | 5 +- .../startup/bl_ui/properties_particle.py | 5 +- .../startup/bl_ui/properties_physics_fluid.py | 5 +- release/scripts/startup/bl_ui/space_clip.py | 9 +- release/scripts/startup/bl_ui/space_image.py | 5 +- .../scripts/startup/bl_ui/space_sequencer.py | 19 ++-- release/scripts/startup/bl_ui/space_text.py | 7 +- .../scripts/startup/bl_ui/space_userpref.py | 5 +- .../startup/bl_ui/space_userpref_keymap.py | 5 +- .../python/intern/bpy_app_translations.c | 93 +++++++++++++++---- 11 files changed, 106 insertions(+), 57 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 303015ebac2..7be00193fb4 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -19,8 +19,7 @@ # import bpy from bpy.types import Panel - -from bpy.app.translations import pgettext as _ +from bpy.app.translations import pgettext_iface as iface_ class ModifierButtonsPanel(): @@ -267,7 +266,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.prop(md, "angle_limit") layout.prop(md, "use_dissolve_boundaries") - layout.label(text=_("Face Count: %d") % md.face_count, translate=False) + layout.label(text=iface_("Face Count: %d") % md.face_count, translate=False) def DISPLACE(self, layout, ob, md): has_texture = (md.texture is not None) diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index f3a83d225b9..273b2450200 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -20,8 +20,7 @@ import bpy from bpy.types import Menu, Panel, UIList from rna_prop_ui import PropertyPanel - -from bpy.app.translations import pgettext as _ +from bpy.app.translations import pgettext_iface as iface_ def active_node_mat(mat): @@ -82,7 +81,7 @@ class MATERIAL_UL_matslots(UIList): if ma and not context.scene.render.use_shading_nodes: manode = ma.active_node_material if manode: - layout.label(text=_("Node %s") % manode.name, translate=False, icon_value=layout.icon(manode)) + layout.label(text=iface_("Node %s") % manode.name, translate=False, icon_value=layout.icon(manode)) elif ma.use_nodes: layout.label(text="Node ") else: diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index fb930e9de5b..0aa2c14a0c7 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -20,8 +20,7 @@ import bpy from bpy.types import Panel from rna_prop_ui import PropertyPanel - -from bpy.app.translations import pgettext as _ +from bpy.app.translations import pgettext_iface as iface_ from bl_ui.properties_physics_common import (point_cache_ui, effector_weights_ui, @@ -150,7 +149,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): #row.label(text="Render") if part.is_fluid: - layout.label(text=_("%d fluid particles for this frame") % part.count, translate=False) + layout.label(text=iface_("%d fluid particles for this frame") % part.count, translate=False) return row = col.row() diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index c9eaa7a4acc..2164b86f486 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -19,8 +19,7 @@ # import bpy from bpy.types import Panel, Menu - -from bpy.app.translations import pgettext as _ +from bpy.app.translations import pgettext_iface as iface_ class FLUID_MT_presets(Menu): @@ -66,7 +65,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel): if fluid.type == 'DOMAIN': # odd formatting here so translation script can extract string - layout.operator("fluid.bake", text=_("Bake (Req. Memory: %s)") % fluid.memory_estimate, + layout.operator("fluid.bake", text=iface_("Bake (Req. Memory: %s)") % fluid.memory_estimate, translate=False, icon='MOD_FLUIDSIM') split = layout.split() diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index e26f44675fb..bc5d89fd45b 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -20,8 +20,7 @@ import bpy from bpy.types import Panel, Header, Menu, UIList - -from bpy.app.translations import pgettext as _ +from bpy.app.translations import pgettext_iface as iface_ class CLIP_UL_tracking_objects(UIList): @@ -913,9 +912,11 @@ class CLIP_MT_view(Menu): ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1)) - text = _("Zoom %d:%d") + text = iface_("Zoom %d:%d") for a, b in ratios: - layout.operator("clip.view_zoom_ratio", text=text % (a, b), translate=False).ratio = a / b + layout.operator("clip.view_zoom_ratio", + text=text % (a, b), + translate=False).ratio = a / b else: if sc.view == 'GRAPH': layout.operator_context = 'INVOKE_REGION_PREVIEW' diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index ed4b28a62d7..01b67667cfb 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -20,8 +20,7 @@ import bpy from bpy.types import Header, Menu, Panel from bl_ui.properties_paint_common import UnifiedPaintPanel, brush_texture_settings - -from bpy.app.translations import pgettext as _ +from bpy.app.translations import pgettext_iface as iface_ class ImagePaintPanel(UnifiedPaintPanel): @@ -73,7 +72,7 @@ class IMAGE_MT_view(Menu): ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1)) for a, b in ratios: - layout.operator("image.view_zoom_ratio", text=_("Zoom %d:%d") % (a, b), translate=False).ratio = a / b + layout.operator("image.view_zoom_ratio", text=iface_("Zoom %d:%d") % (a, b), translate=False).ratio = a / b layout.separator() diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index c8d7d1e60c1..7841acf01b3 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -19,8 +19,7 @@ # import bpy from bpy.types import Header, Menu, Panel - -from bpy.app.translations import pgettext as _ +from bpy.app.translations import pgettext_iface as iface_ def act_strip(context): @@ -424,13 +423,15 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel): col = layout.column(align=True) row = col.row() - row.label(text=_("Final Length: %s") % bpy.utils.smpte_from_frame(strip.frame_final_duration), translate=False) + row.label(text=iface_("Final Length: %s") % bpy.utils.smpte_from_frame(strip.frame_final_duration), + translate=False) row = col.row() row.active = (frame_current >= strip.frame_start and frame_current <= strip.frame_start + strip.frame_duration) - row.label(text=_("Playhead: %d") % (frame_current - strip.frame_start), translate=False) + row.label(text=iface_("Playhead: %d") % (frame_current - strip.frame_start), translate=False) - col.label(text=_("Frame Offset %d:%d") % (strip.frame_offset_start, strip.frame_offset_end), translate=False) - col.label(text=_("Frame Still %d:%d") % (strip.frame_still_start, strip.frame_still_end), translate=False) + col.label(text=iface_("Frame Offset %d:%d") % (strip.frame_offset_start, strip.frame_offset_end), + translate=False) + col.label(text=iface_("Frame Still %d:%d") % (strip.frame_still_start, strip.frame_still_end), translate=False) elem = False @@ -440,7 +441,7 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel): elem = strip.elements[0] if elem and elem.orig_width > 0 and elem.orig_height > 0: - col.label(text=_("Original Dimension: %dx%d") % (elem.orig_width, elem.orig_height), translate=False) + col.label(text=iface_("Original Dimension: %dx%d") % (elem.orig_width, elem.orig_height), translate=False) else: col.label(text="Original Dimension: None") @@ -717,7 +718,7 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel, Panel): if scene: sta = scene.frame_start end = scene.frame_end - layout.label(text=_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False) + layout.label(text=iface_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False) class SEQUENCER_PT_mask(SequencerButtonsPanel, Panel): @@ -746,7 +747,7 @@ class SEQUENCER_PT_mask(SequencerButtonsPanel, Panel): if mask: sta = mask.frame_start end = mask.frame_end - layout.label(text=_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False) + layout.label(text=iface_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False) class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index 089bffd7e75..4264fc95cea 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -19,8 +19,7 @@ # import bpy from bpy.types import Header, Menu, Panel - -from bpy.app.translations import pgettext as _ +from bpy.app.translations import pgettext_iface as iface_ class TEXT_HT_header(Header): @@ -74,10 +73,10 @@ class TEXT_HT_header(Header): row = layout.row() if text.filepath: if text.is_dirty: - row.label(text=_("File: *%r (unsaved)") % + row.label(text=iface_("File: *%r (unsaved)") % text.filepath, translate=False) else: - row.label(text=pgettext("File: %r") % + row.label(text=iface_("File: %r") % text.filepath, translate=False) else: row.label(text="Text: External" diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 239597d54f9..017f75b7583 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -19,8 +19,7 @@ # import bpy from bpy.types import Header, Menu, Panel - -from bpy.app.translations import pgettext as _ +from bpy.app.translations import pgettext_iface as iface_ def ui_style_items(col, context): @@ -782,7 +781,7 @@ class USERPREF_PT_theme(Panel): col = split.column() for i, ui in enumerate(theme.bone_color_sets): - col.label(text=_("Color Set %d:") % (i + 1), translate=False) # i starts from 0 + col.label(text=iface_("Color Set %d:") % (i + 1), translate=False) # i starts from 0 row = col.row() diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index 1c0e54c2c47..e9eb2aa8b8f 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -19,8 +19,7 @@ # import bpy from bpy.types import Menu - -from bpy.app.translations import pgettext as _ +from bpy.app.translations import pgettext_iface as iface_ class USERPREF_MT_keyconfigs(Menu): @@ -99,7 +98,7 @@ class InputKeyMapPanel: subcol = self.indented_layout(col, level + 1) subrow = subcol.row() subrow.prop(km, "show_expanded_items", text="", emboss=False) - subrow.label(text=_("%s (Global)") % km.name, translate=False) + subrow.label(text=iface_("%s (Global)") % km.name, translate=False) else: km.show_expanded_items = True diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index b6d2f624229..6839c0b12a6 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -495,6 +495,37 @@ PyGetSetDef app_translations_getseters[] = { {NULL} }; +/* pgettext helper. */ +static PyObject *_py_pgettext(PyObject *args, PyObject *kw, const char *(*_pgettext)(const char *, const char *)) +{ + static const char *kwlist[] = {"msgid", "msgctxt", NULL}; + +#ifdef WITH_INTERNATIONAL + char *msgid, *msgctxt = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|z:bpy.app.translations.pgettext", (char **)kwlist, + &msgid, &msgctxt)) + { + return NULL; + } + + return PyUnicode_FromString((*_pgettext)(msgctxt ? msgctxt : BLF_I18NCONTEXT_DEFAULT, msgid)); +#else + PyObject *msgid, *msgctxt; + (void)_pgettext; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "O|O:bpy.app.translations.pgettext", (char **)kwlist, + &msgid, &msgctxt)) + { + return NULL; + } + + Py_INCREF(msgid); + + return msgid; +#endif +} + PyDoc_STRVAR(app_translations_pgettext_doc, ".. method:: pgettext(msgid, msgctxt)\n" "\n" @@ -502,7 +533,8 @@ PyDoc_STRVAR(app_translations_pgettext_doc, " NOTE: The (msgid, msgctxt) parameter orders has been switched compared to gettext function, to allow\n" " single-parameter calls (context then defaults to BLF_I18NCONTEXT_DEFAULT).\n" " NOTE: You should really rarely need to use this function in regular addon code, as all translation should be\n" -" handled by Blender internal code.\n" +" handled by Blender internal code. The only exception are string containing formatting (like \"File: %r\"),\n" +" but you should rather use pgettext_iface/_tip in those cases!\n" " Note: Does nothing when Blender is built without internationalization support (hence always returns msgid).\n" "\n" " :arg msgid: The string to translate.\n" @@ -515,26 +547,45 @@ PyDoc_STRVAR(app_translations_pgettext_doc, ); static PyObject *app_translations_pgettext(BlenderAppTranslations *UNUSED(self), PyObject *args, PyObject *kw) { - /* Note we could optimize this a bit when WITH_INTERNATIONAL is not defined, but don't think "code complexity" would - * be worth it, as this func should not often be used! - */ - /* XXX This code fails with scons when WITH_INTERNATIONAL is not defined, at link time, stating that BLF_pgettext - * is undefined... So using #ifdef after all, rather than removing scons from blender trunk! - */ - static const char *kwlist[] = {"msgid", "msgctxt", NULL}; - char *msgid, *msgctxt = NULL; + return _py_pgettext(args, kw, BLF_pgettext); +} - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|z:bpy.app.translations.pgettext", (char **)kwlist, - &msgid, &msgctxt)) - { - return NULL; - } +PyDoc_STRVAR(app_translations_pgettext_iface_doc, +".. method:: pgettext_iface(msgid, msgctxt)\n" +"\n" +" Try to translate the given msgid (with optional msgctxt), if labels' translation is enabled.\n" +" NOTE: See pgettext notes.\n" +"\n" +" :arg msgid: The string to translate.\n" +" :type msgid: string\n" +" :arg msgctxt: The translation context.\n" +" :type msgctxt: string or None\n" +" :default msgctxt: BLF_I18NCONTEXT_DEFAULT value.\n" +" :return: The translated string (or msgid if no translation was found).\n" +"\n" +); +static PyObject *app_translations_pgettext_iface(BlenderAppTranslations *UNUSED(self), PyObject *args, PyObject *kw) +{ + return _py_pgettext(args, kw, BLF_translate_do_iface); +} -#ifdef WITH_INTERNATIONAL - return PyUnicode_FromString(BLF_pgettext(msgctxt ? msgctxt : BLF_I18NCONTEXT_DEFAULT, msgid)); -#else - return PyUnicode_FromString(msgid); -#endif +PyDoc_STRVAR(app_translations_pgettext_tip_doc, +".. method:: pgettext(msgid, msgctxt)\n" +"\n" +" Try to translate the given msgid (with optional msgctxt), if tooltips' translation is enabled.\n" +" NOTE: See pgettext notes.\n" +"\n" +" :arg msgid: The string to translate.\n" +" :type msgid: string\n" +" :arg msgctxt: The translation context.\n" +" :type msgctxt: string or None\n" +" :default msgctxt: BLF_I18NCONTEXT_DEFAULT value.\n" +" :return: The translated string (or msgid if no translation was found).\n" +"\n" +); +static PyObject *app_translations_pgettext_tip(BlenderAppTranslations *UNUSED(self), PyObject *args, PyObject *kw) +{ + return _py_pgettext(args, kw, BLF_translate_do_tooltip); } PyDoc_STRVAR(app_translations_locale_explode_doc, @@ -575,6 +626,10 @@ PyMethodDef app_translations_methods[] = { app_translations_py_messages_unregister_doc}, {(char *)"pgettext", (PyCFunction)app_translations_pgettext, METH_VARARGS | METH_KEYWORDS | METH_STATIC, app_translations_pgettext_doc}, + {(char *)"pgettext_iface", (PyCFunction)app_translations_pgettext_iface, METH_VARARGS | METH_KEYWORDS | METH_STATIC, + app_translations_pgettext_iface_doc}, + {(char *)"pgettext_tip", (PyCFunction)app_translations_pgettext_tip, METH_VARARGS | METH_KEYWORDS | METH_STATIC, + app_translations_pgettext_tip_doc}, {(char *)"locale_explode", (PyCFunction)app_translations_locale_explode, METH_VARARGS | METH_KEYWORDS | METH_STATIC, app_translations_locale_explode_doc}, {NULL} From 75cbb07507fa39a1c65296321839cdfd245cc8d6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 10 Feb 2013 12:20:10 +0000 Subject: [PATCH 007/157] Added option to composite/viewer nodes which specifys whether alpha input is straight or not (premultiplied is default). This is useful in cases when you want to check on output of such nodes as keying which does have straight alpha output. Also added missing do_version code to previous compo do_versions. --- source/blender/blenloader/intern/readfile.c | 6 ++++-- .../compositor/nodes/COM_CompositorNode.cpp | 1 + .../blender/compositor/nodes/COM_ViewerNode.cpp | 1 + .../operations/COM_CompositorOperation.cpp | 6 ++++++ .../operations/COM_CompositorOperation.h | 5 +++++ .../operations/COM_ViewerBaseOperation.cpp | 1 + .../operations/COM_ViewerBaseOperation.h | 2 ++ .../operations/COM_ViewerOperation.cpp | 3 +++ source/blender/editors/space_node/drawnode.c | 16 +++++++++++++++- source/blender/editors/space_node/node_draw.c | 3 ++- source/blender/makesrna/intern/rna_nodetree.c | 15 +++++++++++++++ .../blender/makesrna/intern/rna_nodetree_types.h | 2 +- .../composite/nodes/node_composite_composite.c | 2 +- .../composite/nodes/node_composite_viewer.c | 2 +- 14 files changed, 58 insertions(+), 7 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 93bc0502b19..de5e69b741a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8795,14 +8795,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main) // add storage for compositor translate nodes when not existing if (!MAIN_VERSION_ATLEAST(main, 265, 10)) { bNodeTreeType *ntreetype; + bNodeTree *ntree; ntreetype = ntreeGetType(NTREE_COMPOSIT); if (ntreetype && ntreetype->foreach_nodetree) ntreetype->foreach_nodetree(main, NULL, do_version_node_fix_translate_wrapping); + + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + do_version_node_fix_translate_wrapping(NULL, NULL, ntree); } - - // if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 7)) { /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp index e3313750e66..e5c01c7573a 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -41,6 +41,7 @@ void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorConte compositorOperation->setSceneName(editorNode->id->name); compositorOperation->setRenderData(context->getRenderData()); compositorOperation->setbNodeTree(context->getbNodeTree()); + compositorOperation->setStraightAlpha(editorNode->custom2 & 1); imageSocket->relinkConnections(compositorOperation->getInputSocket(0), 0, graph); alphaSocket->relinkConnections(compositorOperation->getInputSocket(1)); depthSocket->relinkConnections(compositorOperation->getInputSocket(2)); diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp index f44470a9b9a..76250145214 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -47,6 +47,7 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1); viewerOperation->setCenterX(editorNode->custom3); viewerOperation->setCenterY(editorNode->custom4); + viewerOperation->setStraightAlpha(editorNode->custom2 & 1); viewerOperation->setViewSettings(context->getViewSettings()); viewerOperation->setDisplaySettings(context->getDisplaySettings()); diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index e6a49082a71..7cb3a614022 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -49,6 +49,8 @@ CompositorOperation::CompositorOperation() : NodeOperation() this->m_alphaInput = NULL; this->m_depthInput = NULL; + this->m_straightAlpha = false; + this->m_sceneName[0] = '\0'; } @@ -141,6 +143,10 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber) if (this->m_alphaInput != NULL) { this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST); } + + if (this->m_straightAlpha) + straight_to_premul_v4(color); + copy_v4_v4(buffer + offset4, color); if (this->m_depthInput != NULL) { diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h index c1d91c16a3c..e60862be410 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.h +++ b/source/blender/compositor/operations/COM_CompositorOperation.h @@ -65,6 +65,10 @@ private: * @brief local reference to the depth operation */ SocketReader *m_depthInput; + + /* node input has got straight alpha which shall be premultiplied */ + bool m_straightAlpha; + public: CompositorOperation(); void executeRegion(rcti *rect, unsigned int tileNumber); @@ -75,5 +79,6 @@ public: void deinitExecution(); const CompositorPriority getRenderPriority() const { return COM_PRIORITY_MEDIUM; } void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); + void setStraightAlpha(bool value) { this->m_straightAlpha = value; } }; #endif diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp index d5f2c283c72..87d7a810d80 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp @@ -48,6 +48,7 @@ ViewerBaseOperation::ViewerBaseOperation() : NodeOperation() this->m_doDepthBuffer = false; this->m_viewSettings = NULL; this->m_displaySettings = NULL; + this->m_straightAlpha = false; } void ViewerBaseOperation::initExecution() diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h index f7d479eb3b8..1f773c5151a 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.h +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.h @@ -39,6 +39,7 @@ protected: OrderOfChunks m_chunkOrder; bool m_doDepthBuffer; ImBuf *m_ibuf; + bool m_straightAlpha; const ColorManagedViewSettings *m_viewSettings; const ColorManagedDisplaySettings *m_displaySettings; @@ -59,6 +60,7 @@ public: OrderOfChunks getChunkOrder() { return this->m_chunkOrder; } const CompositorPriority getRenderPriority() const; bool isViewerOperation() { return true; } + void setStraightAlpha(bool value) { this->m_straightAlpha = value; } void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; } void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; } diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index d1ac7d74ead..f1ac893bd3f 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -98,6 +98,9 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) depthbuffer[offset] = depth[0]; } + if (this->m_straightAlpha) + straight_to_premul_v4(buffer + offset4); + offset ++; offset4 += 4; } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 9b342ed8f44..9dd588e77ae 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2654,10 +2654,21 @@ static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C) uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE); } +static void node_composit_buts_composite(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "use_straight_alpha", 0, NULL, ICON_NONE); +} + +static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "use_straight_alpha", 0, NULL, ICON_NONE); +} + static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; + uiItemR(layout, ptr, "use_straight_alpha", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "tile_order") == 0) { col = uiLayoutColumn(layout, TRUE); @@ -2965,10 +2976,13 @@ static void node_composit_set_butfunc(bNodeType *ntype) ntype->uifunc = node_composit_buts_bokehblur; break; case CMP_NODE_VIEWER: - ntype->uifunc = NULL; + ntype->uifunc = node_composit_buts_viewer; ntype->uifuncbut = node_composit_buts_viewer_but; ntype->uibackdropfunc = node_composit_backdrop_viewer; break; + case CMP_NODE_COMPOSITE: + ntype->uifunc = node_composit_buts_composite; + break; case CMP_NODE_MASK: ntype->uifunc = node_composit_buts_mask; break; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index d5d2ace6fa7..34f7799d47c 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -368,7 +368,8 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) } /* buttons rect? */ - if ((node->flag & NODE_OPTIONS) && node->typeinfo->uifunc) { + /* TODO: NODE_OPTION shall be cleaned up */ + if (/*(node->flag & NODE_OPTIONS) && */node->typeinfo->uifunc) { dy -= NODE_DYS / 2; /* set this for uifunc() that don't use layout engine yet */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index fee4b429a11..cf60e3bd14f 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4083,6 +4083,21 @@ static void def_cmp_viewer(StructRNA *srna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Y", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "use_straight_alpha", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); + RNA_def_property_ui_text(prop, "Straight Alpha", "Treat alpha input of this node as straight"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + +static void def_cmp_composite(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "use_straight_alpha", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); + RNA_def_property_ui_text(prop, "Straight Alpha", "Treat alpha input of this node as straight"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_cmp_keyingscreen(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index d6e0ce2f11a..35d3c32c045 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -124,7 +124,7 @@ DefNode( CompositorNode, CMP_NODE_SETALPHA, 0, "SETAL DefNode( CompositorNode, CMP_NODE_HUE_SAT, def_cmp_hue_saturation, "HUE_SAT", HueSat, "Hue Saturation Value","" ) DefNode( CompositorNode, CMP_NODE_IMAGE, def_cmp_image, "IMAGE", Image, "Image", "" ) DefNode( CompositorNode, CMP_NODE_R_LAYERS, def_cmp_render_layers, "R_LAYERS", RLayers, "Render Layers", "" ) -DefNode( CompositorNode, CMP_NODE_COMPOSITE, 0, "COMPOSITE", Composite, "Composite", "" ) +DefNode( CompositorNode, CMP_NODE_COMPOSITE, def_cmp_composite, "COMPOSITE", Composite, "Composite", "" ) DefNode( CompositorNode, CMP_NODE_OUTPUT_FILE, def_cmp_output_file, "OUTPUT_FILE", OutputFile, "File Output", "" ) DefNode( CompositorNode, CMP_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) DefNode( CompositorNode, CMP_NODE_TRANSLATE, def_cmp_translate, "TRANSLATE", Translate, "Translate", "" ) diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c index ca12b500e5b..6cff4039767 100644 --- a/source/blender/nodes/composite/nodes/node_composite_composite.c +++ b/source/blender/nodes/composite/nodes/node_composite_composite.c @@ -43,7 +43,7 @@ void register_node_type_cmp_composite(bNodeTreeType *ttype) { static bNodeType ntype; - node_type_base(ttype, &ntype, CMP_NODE_COMPOSITE, "Composite", NODE_CLASS_OUTPUT, NODE_PREVIEW); + node_type_base(ttype, &ntype, CMP_NODE_COMPOSITE, "Composite", NODE_CLASS_OUTPUT, NODE_OPTIONS | NODE_PREVIEW); node_type_socket_templates(&ntype, cmp_node_composite_in, NULL); node_type_size(&ntype, 80, 60, 200); diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index 24affc8f374..233a0627a7a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -56,7 +56,7 @@ void register_node_type_cmp_viewer(bNodeTreeType *ttype) { static bNodeType ntype; - node_type_base(ttype, &ntype, CMP_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT, NODE_PREVIEW); + node_type_base(ttype, &ntype, CMP_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT, NODE_OPTIONS | NODE_PREVIEW); node_type_socket_templates(&ntype, cmp_node_viewer_in, NULL); node_type_size(&ntype, 80, 60, 200); node_type_init(&ntype, node_composit_init_viewer); From 9a6c5d8b3ef2e2ddd444d79c384bea0eeffca71f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 10 Feb 2013 13:14:51 +0000 Subject: [PATCH 008/157] We've reconsidered previous patch in IRC. It's more useful to completely ignore alpha for display of straight colors. Supporting straight pipeline is possible, but not a topic for bcon4. --- .../compositor/nodes/COM_CompositorNode.cpp | 2 +- source/blender/compositor/nodes/COM_ViewerNode.cpp | 2 +- .../operations/COM_CompositorOperation.cpp | 14 ++++++++------ .../operations/COM_CompositorOperation.h | 6 +++--- .../operations/COM_ViewerBaseOperation.cpp | 2 +- .../operations/COM_ViewerBaseOperation.h | 4 ++-- .../compositor/operations/COM_ViewerOperation.cpp | 14 ++++++++------ source/blender/editors/space_node/drawnode.c | 4 ++-- source/blender/makesrna/intern/rna_nodetree.c | 12 ++++++------ 9 files changed, 32 insertions(+), 28 deletions(-) diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp index e5c01c7573a..fc4dea8cee3 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -41,7 +41,7 @@ void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorConte compositorOperation->setSceneName(editorNode->id->name); compositorOperation->setRenderData(context->getRenderData()); compositorOperation->setbNodeTree(context->getbNodeTree()); - compositorOperation->setStraightAlpha(editorNode->custom2 & 1); + compositorOperation->setIgnoreAlpha(editorNode->custom2 & 1); imageSocket->relinkConnections(compositorOperation->getInputSocket(0), 0, graph); alphaSocket->relinkConnections(compositorOperation->getInputSocket(1)); depthSocket->relinkConnections(compositorOperation->getInputSocket(2)); diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp index 76250145214..94f3c2ebd80 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -47,7 +47,7 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1); viewerOperation->setCenterX(editorNode->custom3); viewerOperation->setCenterY(editorNode->custom4); - viewerOperation->setStraightAlpha(editorNode->custom2 & 1); + viewerOperation->setIgnoreAlpha(editorNode->custom2 & 1); viewerOperation->setViewSettings(context->getViewSettings()); viewerOperation->setDisplaySettings(context->getDisplaySettings()); diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 7cb3a614022..43f491ad2d9 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -49,7 +49,7 @@ CompositorOperation::CompositorOperation() : NodeOperation() this->m_alphaInput = NULL; this->m_depthInput = NULL; - this->m_straightAlpha = false; + this->m_ignoreAlpha = false; this->m_sceneName[0] = '\0'; } @@ -140,12 +140,14 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber) for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2 && (!breaked); x++) { this->m_imageInput->read(color, x, y, COM_PS_NEAREST); - if (this->m_alphaInput != NULL) { - this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST); + if (this->m_ignoreAlpha) { + color[3] = 1.0f; + } + else { + if (this->m_alphaInput != NULL) { + this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST); + } } - - if (this->m_straightAlpha) - straight_to_premul_v4(color); copy_v4_v4(buffer + offset4, color); diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h index e60862be410..27d29664610 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.h +++ b/source/blender/compositor/operations/COM_CompositorOperation.h @@ -66,8 +66,8 @@ private: */ SocketReader *m_depthInput; - /* node input has got straight alpha which shall be premultiplied */ - bool m_straightAlpha; + /* Ignore any alpha input */ + bool m_ignoreAlpha; public: CompositorOperation(); @@ -79,6 +79,6 @@ public: void deinitExecution(); const CompositorPriority getRenderPriority() const { return COM_PRIORITY_MEDIUM; } void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); - void setStraightAlpha(bool value) { this->m_straightAlpha = value; } + void setIgnoreAlpha(bool value) { this->m_ignoreAlpha = value; } }; #endif diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp index 87d7a810d80..072246932db 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp @@ -48,7 +48,7 @@ ViewerBaseOperation::ViewerBaseOperation() : NodeOperation() this->m_doDepthBuffer = false; this->m_viewSettings = NULL; this->m_displaySettings = NULL; - this->m_straightAlpha = false; + this->m_ignoreAlpha = false; } void ViewerBaseOperation::initExecution() diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h index 1f773c5151a..9f7e80ad6fc 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.h +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.h @@ -39,7 +39,7 @@ protected: OrderOfChunks m_chunkOrder; bool m_doDepthBuffer; ImBuf *m_ibuf; - bool m_straightAlpha; + bool m_ignoreAlpha; const ColorManagedViewSettings *m_viewSettings; const ColorManagedDisplaySettings *m_displaySettings; @@ -60,7 +60,7 @@ public: OrderOfChunks getChunkOrder() { return this->m_chunkOrder; } const CompositorPriority getRenderPriority() const; bool isViewerOperation() { return true; } - void setStraightAlpha(bool value) { this->m_straightAlpha = value; } + void setIgnoreAlpha(bool value) { this->m_ignoreAlpha = value; } void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; } void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; } diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index f1ac893bd3f..4d10e49aeeb 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -89,18 +89,20 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2; x++) { this->m_imageInput->read(&(buffer[offset4]), x, y, COM_PS_NEAREST); - if (this->m_alphaInput != NULL) { - this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST); - buffer[offset4 + 3] = alpha[0]; + if (this->m_ignoreAlpha) { + buffer[offset4 + 3] = 1.0f; + } + else { + if (this->m_alphaInput != NULL) { + this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST); + buffer[offset4 + 3] = alpha[0]; + } } if (m_depthInput) { this->m_depthInput->read(depth, x, y, COM_PS_NEAREST); depthbuffer[offset] = depth[0]; } - if (this->m_straightAlpha) - straight_to_premul_v4(buffer + offset4); - offset ++; offset4 += 4; } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 9dd588e77ae..57851e857b8 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2656,12 +2656,12 @@ static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C) static void node_composit_buts_composite(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiItemR(layout, ptr, "use_straight_alpha", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE); } static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiItemR(layout, ptr, "use_straight_alpha", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE); } static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index cf60e3bd14f..397e05b6a97 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4084,9 +4084,9 @@ static void def_cmp_viewer(StructRNA *srna) RNA_def_property_ui_text(prop, "Y", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "use_straight_alpha", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); - RNA_def_property_ui_text(prop, "Straight Alpha", "Treat alpha input of this node as straight"); + prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "custom2", 1); + RNA_def_property_ui_text(prop, "Use Alpha", "Colors are treated alpha premultiplied, or colors output straight (alpha gets set to 1)"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -4094,9 +4094,9 @@ static void def_cmp_composite(StructRNA *srna) { PropertyRNA *prop; - prop = RNA_def_property(srna, "use_straight_alpha", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); - RNA_def_property_ui_text(prop, "Straight Alpha", "Treat alpha input of this node as straight"); + prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "custom2", 1); + RNA_def_property_ui_text(prop, "Use Alpha", "Colors are treated alpha premultiplied, or colors output straight (alpha gets set to 1)"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } From 1994ed00a388d7eed3c9d4dfda614c41693c114e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Feb 2013 13:44:18 +0000 Subject: [PATCH 009/157] add option not to calculate tessellation faces when converting an object to a mesh. (OBJ export no longer needs, so save some CPU cycles and skip tessellation) --- intern/cycles/blender/blender_util.h | 2 +- source/blender/makesrna/intern/rna_internal.h | 4 +++- source/blender/makesrna/intern/rna_main_api.c | 12 +++++++++--- source/blender/makesrna/intern/rna_object_api.c | 9 +++++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 0947b5a2e9d..976ed875211 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -41,7 +41,7 @@ CCL_NAMESPACE_BEGIN static inline BL::Mesh object_to_mesh(BL::BlendData data, BL::Object object, BL::Scene scene, bool apply_modifiers, bool render) { - return data.meshes.new_from_object(scene, object, apply_modifiers, (render)? 2: 1); + return data.meshes.new_from_object(scene, object, apply_modifiers, (render)? 2: 1, true); } static inline void colorramp_to_array(BL::ColorRamp ramp, float4 *data, int size) diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index eaa69a8124c..c1f5698016c 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -398,7 +398,9 @@ PointerRNA rna_pointer_inherit_refine(struct PointerRNA *ptr, struct StructRNA * int rna_parameter_size(struct PropertyRNA *parm); int rna_parameter_size_alloc(struct PropertyRNA *parm); -struct Mesh *rna_Main_meshes_new_from_object(struct Main *bmain, struct ReportList *reports, struct Scene *sce, struct Object *ob, int apply_modifiers, int settings); +struct Mesh *rna_Main_meshes_new_from_object( + struct Main *bmain, struct ReportList *reports, struct Scene *sce, + struct Object *ob, int apply_modifiers, int settings, int calc_tessface); /* XXX, these should not need to be defined here~! */ struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct bContext *C, struct ReportList *reports); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index ab94b88e3d7..7175c8eab78 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -37,6 +37,7 @@ #include "DNA_modifier_types.h" #include "BLI_path_util.h" +#include "BLI_utildefines.h" #include "RNA_define.h" #include "RNA_access.h" @@ -263,7 +264,9 @@ static Mesh *rna_Main_meshes_new(Main *bmain, const char *name) /* copied from Mesh_getFromObject and adapted to RNA interface */ /* settings: 1 - preview, 2 - render */ -Mesh *rna_Main_meshes_new_from_object(Main *bmain, ReportList *reports, Scene *sce, Object *ob, int apply_modifiers, int settings) +Mesh *rna_Main_meshes_new_from_object( + Main *bmain, ReportList *reports, Scene *sce, + Object *ob, int apply_modifiers, int settings, int calc_tessface) { Mesh *tmpmesh; Curve *tmpcu = NULL, *copycu; @@ -446,8 +449,10 @@ Mesh *rna_Main_meshes_new_from_object(Main *bmain, ReportList *reports, Scene *s break; } /* end copy materials */ - /* cycles and exporters rely on this still */ - BKE_mesh_tessface_ensure(tmpmesh); + if (calc_tessface) { + /* cycles and exporters rely on this still */ + BKE_mesh_tessface_ensure(tmpmesh); + } /* make sure materials get updated in objects */ test_object_materials(&tmpmesh->id); @@ -1138,6 +1143,7 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "calc_tessface", true, "Calculate Tessellation", "Calculate tessellation faces"); parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export"); RNA_def_function_return(func, parm); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 51725bda7f9..2b7df1ca317 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -34,6 +34,8 @@ #include #include +#include "BLI_utildefines.h" + #include "RNA_define.h" #include "DNA_constraint_types.h" @@ -109,9 +111,11 @@ static void rna_Scene_mat_convert_space(Object *ob, ReportList *reports, bPoseCh /* copied from Mesh_getFromObject and adapted to RNA interface */ /* settings: 0 - preview, 1 - render */ -static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_modifiers, int settings) +static Mesh *rna_Object_to_mesh( + Object *ob, ReportList *reports, Scene *sce, + int apply_modifiers, int settings, int calc_tessface) { - return rna_Main_meshes_new_from_object(G.main, reports, sce, ob, apply_modifiers, settings); + return rna_Main_meshes_new_from_object(G.main, reports, sce, ob, apply_modifiers, settings, calc_tessface); } /* mostly a copy from convertblender.c */ @@ -442,6 +446,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "calc_tessface", true, "Calculate Tessellation", "Calculate tessellation faces"); parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export"); RNA_def_function_return(func, parm); From 3778b458298b35a5b84180298cf15bc834e781aa Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 10 Feb 2013 14:52:08 +0000 Subject: [PATCH 010/157] Added initializer in channel region for file window, makes it draw on first use better (error was visible for factory startup on small screens) --- source/blender/editors/space_file/space_file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 7cc322c06bb..0a4b922bb38 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -478,6 +478,7 @@ static void file_channel_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; + ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; ED_region_panels_init(wm, ar); /* own keymaps */ From 6b2b55c45361262f7c6608d0c0f5a164f7a1928a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 10 Feb 2013 14:59:38 +0000 Subject: [PATCH 011/157] Scroller initialize for Image Window regions too. --- source/blender/editors/space_image/space_image.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 35ba83a8bc6..ca8270ba0f5 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -750,6 +750,7 @@ static void image_buttons_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; + ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; ED_region_panels_init(wm, ar); keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); @@ -789,6 +790,7 @@ static void image_scope_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; + ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; ED_region_panels_init(wm, ar); keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); From 809e37bf15568080907a008d40aed41c737c2b24 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 10 Feb 2013 15:59:29 +0000 Subject: [PATCH 012/157] Ensure that mask layer exists in sculpt mode after multires subdivide Sculpt mode requires mask customdata layer for multires and ensures it exists on entering sculpt mode. However, sculpt mode only considers multires to be active if the level of subdivision is not zero, so it does not add mask for unsubdivided multires meshes. If the multires mesh is subdivided while in sculpt mode, no mask was present leading to weird drawing and crash on use of the mask brush. Fixed by doing the same thing in multires_subdivide_exec() that is done in ED_object_modifier_add(), which is to check if sculpt mode is active and add mask layer if so. Fixes [#34190] Viewport artifacts when using Multiresolution modifier projects.blender.org/tracker/index.php?func=detail&aid=34190&group_id=9&atid=498 --- source/blender/editors/object/object_modifier.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 7d3d6861418..00082b03781 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1196,6 +1196,11 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); + + if (ob->mode & OB_MODE_SCULPT) { + /* ensure that grid paint mask layer is created */ + ED_sculpt_mask_layers_ensure(ob, mmd); + } return OPERATOR_FINISHED; } From 942ad6d9cda2439622875a7a748649a0e3451d0b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Feb 2013 17:06:05 +0000 Subject: [PATCH 013/157] style cleanup --- source/blender/blenlib/intern/scanfill.c | 9 ++-- source/blender/collada/AnimationExporter.cpp | 41 ++++++++++--------- source/blender/collada/ArmatureExporter.cpp | 2 +- source/blender/collada/ArmatureImporter.cpp | 17 ++++---- source/blender/collada/ControllerExporter.cpp | 8 ++-- source/blender/collada/DocumentImporter.cpp | 29 ++++++++----- source/blender/collada/GeometryExporter.cpp | 8 ++-- source/blender/collada/MeshImporter.h | 2 +- source/blender/collada/SceneExporter.cpp | 6 +-- source/blender/collada/TransformReader.cpp | 2 +- source/blender/collada/collada_utils.cpp | 16 ++++---- source/blender/editors/io/io_collada.c | 11 +++-- .../editors/sculpt_paint/sculpt_intern.h | 2 +- .../editors/space_view3d/view3d_edit.c | 13 +++--- source/blender/imbuf/intern/colormanagement.c | 2 +- 15 files changed, 93 insertions(+), 75 deletions(-) diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 771295b4b78..7c7edc1349d 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -325,7 +325,9 @@ static short addedgetoscanvert(ScanFillVertLink *sc, ScanFillEdge *eed) fac1 = 1.0e10f * (eed->v2->xy[0] - x); } - else fac1 = (x - eed->v2->xy[0]) / fac1; + else { + fac1 = (x - eed->v2->xy[0]) / fac1; + } for (ed = sc->edge_first; ed; ed = ed->next) { @@ -649,7 +651,9 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag) if (ed1->v1->h > 1) ed1->v1->h--; if (ed1->v2->h > 1) ed1->v2->h--; } - else ed1->v2->f = SF_VERT_UNKNOWN; + else { + ed1->v2->f = SF_VERT_UNKNOWN; + } ed1 = nexted; } @@ -682,7 +686,6 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag) if (v1 == v2 || v2 == v3) break; /* printf("test verts %x %x %x\n", v1, v2, v3); */ miny = min_ff(v1->xy[1], v3->xy[1]); - /* miny = min_ff(v1->xy[1], v3->xy[1]); */ sc1 = sc + 1; test = 0; diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 4a0696dc857..a69f7918e40 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -161,9 +161,9 @@ void AnimationExporter::export_morph_animation(Object *ob) FCurve *fcu; char *transformName; Key *key = BKE_key_from_object(ob); - if(!key) return; + if (!key) return; - if(key->adt && key->adt->action){ + if (key->adt && key->adt->action) { fcu = (FCurve *)key->adt->action->curves.first; while (fcu) { @@ -177,17 +177,17 @@ void AnimationExporter::export_morph_animation(Object *ob) } -void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector &frames ){ - +void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector &frames ) +{ ListBase *conlist = get_active_constraints(ob); - if(conlist == NULL) return; + if (conlist == NULL) return; bConstraint *con; for (con = (bConstraint*)conlist->first; con; con = con->next) { ListBase targets = {NULL, NULL}; bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con); - if(!validateConstraints(con)) continue; + if (!validateConstraints(con)) continue; if (cti && cti->get_constraint_targets) { bConstraintTarget *ct; @@ -197,8 +197,8 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vectormatrix members have not yet been calculated here! */ cti->get_constraint_targets(con, &targets); - if(cti){ - for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next){ + if (cti) { + for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next) { obtar = ct->tar; find_frames(obtar, frames); } @@ -901,7 +901,7 @@ std::string AnimationExporter::create_4x4_source(std::vector &frames, Obj bPoseChannel *parchan = NULL; bPoseChannel *pchan = NULL; - if (ob->type == OB_ARMATURE ){ + if (ob->type == OB_ARMATURE ) { bPose *pose = ob->pose; pchan = BKE_pose_channel_find_name(pose, bone->name); if (!pchan) @@ -922,15 +922,15 @@ std::string AnimationExporter::create_4x4_source(std::vector &frames, Obj //BKE_scene_update_for_newframe(G.main,scene,scene->lay); BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL); - if (bone){ - if( pchan->flag & POSE_CHAIN) - { + if (bone) { + if (pchan->flag & POSE_CHAIN) { enable_fcurves(ob->adt->action, NULL); BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); } - else - BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); + else { + BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); + } // compute bone local mat if (bone->parent) { @@ -1324,9 +1324,9 @@ bool AnimationExporter::hasAnimations(Scene *sce) } //check shape key animation - if(!fcu){ + if (!fcu) { Key *key = BKE_key_from_object(ob); - if(key && key->adt && key->adt->action) + if (key && key->adt && key->adt->action) fcu = (FCurve *)key->adt->action->curves.first; } if (fcu) @@ -1497,8 +1497,8 @@ void AnimationExporter::sample_animation(float *v, std::vector &frames, i enable_fcurves(ob_arm->adt->action, NULL); } -bool AnimationExporter::validateConstraints(bConstraint *con){ - +bool AnimationExporter::validateConstraints(bConstraint *con) +{ bool valid = true; bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con); /* these we can skip completely (invalid constraints...) */ @@ -1512,7 +1512,8 @@ bool AnimationExporter::validateConstraints(bConstraint *con){ return valid; } -void AnimationExporter::calc_ob_mat_at_time(Object *ob, float ctime , float mat[][4]){ +void AnimationExporter::calc_ob_mat_at_time(Object *ob, float ctime , float mat[][4]) +{ ListBase *conlist = get_active_constraints(ob); bConstraint *con; for (con = (bConstraint*)conlist->first; con; con = con->next) { @@ -1524,7 +1525,7 @@ void AnimationExporter::calc_ob_mat_at_time(Object *ob, float ctime , float mat[ bConstraintTarget *ct; Object *obtar; cti->get_constraint_targets(con, &targets); - for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next){ + for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next) { obtar = ct->tar; BKE_animsys_evaluate_animdata(scene, &obtar->id, obtar->adt, ctime, ADT_RECALC_ANIM); BKE_object_where_is_calc_time(scene, obtar, ctime); diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 0929bfda6e7..a56010aeb27 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -273,7 +273,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: } // SECOND_LIFE_COMPATIBILITY - if (export_settings->second_life) { + if (export_settings->second_life) { // Remove rotations vs armature from transform // parent_rest_rot * mat * irest_rot float temp[4][4]; diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 86d9de64085..6e8bf337abb 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -106,13 +106,14 @@ void ArmatureImporter::create_bone(SkinInfo* skin, COLLADAFW::Node *node, EditBo else { // bone-space get_node_mat(obmat, node, NULL, NULL); - + // get world-space - if (parent){ + if (parent) { mult_m4_m4m4(mat, parent_mat, obmat); } - else + else { copy_m4_m4(mat, obmat); + } } if (parent) bone->parent = parent; @@ -645,7 +646,8 @@ bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller) return true; } -void ArmatureImporter::make_shape_keys(){ +void ArmatureImporter::make_shape_keys() +{ std::vector::iterator mc; float weight; @@ -668,12 +670,12 @@ void ArmatureImporter::make_shape_keys(){ BKE_key_convert_from_mesh(source_me, kb); //insert other shape keys - for ( int i = 0 ; i < morphTargetIds.getCount() ; i++ ){ + for (int i = 0 ; i < morphTargetIds.getCount() ; i++ ) { //better to have a seperate map of morph objects, //This'll do for now since only mesh morphing is imported Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]); - if(me){ + if (me) { me->key = key; kb = BKE_keyblock_add_ctime(key, me->id.name, FALSE); BKE_key_convert_from_mesh(me, kb); @@ -682,8 +684,9 @@ void ArmatureImporter::make_shape_keys(){ weight = morphWeights.getFloatValues()->getData()[i]; kb->curval = weight; } - else + else { fprintf(stderr, "Morph target geometry not found.\n"); + } } } } diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp index 57047346617..41693d4d680 100644 --- a/source/blender/collada/ControllerExporter.cpp +++ b/source/blender/collada/ControllerExporter.cpp @@ -120,9 +120,10 @@ void ControllerExporter::operator()(Object *ob) Object *ob_arm = bc_get_assigned_armature(ob); Key *key = BKE_key_from_object(ob); - if (ob_arm) + if (ob_arm) { export_skin_controller(ob, ob_arm); - if(key){ + } + if (key) { export_morph_controller(ob, key); } } @@ -388,7 +389,8 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob) } //Added to implemente support for animations. -void ControllerExporter::add_weight_extras(Key *key){ +void ControllerExporter::add_weight_extras(Key *key) +{ // can also try the base element and param alternative COLLADASW::BaseExtraTechnique extra; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 7437401ed09..0436dd40744 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -100,7 +100,7 @@ extern "C" { // #define ARMATURE_TEST DocumentImporter::DocumentImporter(bContext *C, const ImportSettings *import_settings) : - import_settings(import_settings), + import_settings(import_settings), mImportStage(General), mContext(C), armature_importer(&unit_converter, &mesh_importer, &anim_importer, CTX_data_scene(C)), @@ -432,8 +432,9 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod // to create constraints off node tags. Assumes only constraint data in // current with blender profile. -void DocumentImporter::create_constraints(ExtraTags *et, Object *ob){ - if ( et && et->isProfile("blender")){ +void DocumentImporter::create_constraints(ExtraTags *et, Object *ob) +{ + if (et && et->isProfile("blender")) { std::string name; short* type = 0; et->setData("type", type); @@ -536,9 +537,12 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent // XXX empty node may not mean it is empty object, not sure about this if ( (geom_done + camera_done + lamp_done + controller_done + inst_done) < 1) { //Check if Object is armature, by checking if immediate child is a JOINT node. - if(is_armature(node)) + if (is_armature(node)) { ob = bc_add_object(sce, OB_ARMATURE, NULL); - else ob = bc_add_object(sce, OB_EMPTY, NULL); + } + else { + ob = bc_add_object(sce, OB_EMPTY, NULL); + } objects_done->push_back(ob); } @@ -1238,15 +1242,18 @@ bool DocumentImporter::addExtraTags(const COLLADAFW::UniqueId &uid, ExtraTags *e return true; } -bool DocumentImporter::is_armature(COLLADAFW::Node *node){ +bool DocumentImporter::is_armature(COLLADAFW::Node *node) +{ COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes(); - for (unsigned int i = 0; i < child_nodes.getCount(); i++) { - if(child_nodes[i]->getType() == COLLADAFW::Node::JOINT) return true; - else continue; + for (unsigned int i = 0; i < child_nodes.getCount(); i++) { + if (child_nodes[i]->getType() == COLLADAFW::Node::JOINT) { + return true; + } + else { + continue; + } } //no child is JOINT return false; - } - diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 0720c1f9b81..19d67f37476 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -53,7 +53,8 @@ extern "C" { #include "collada_utils.h" // TODO: optimize UV sets by making indexed list with duplicates removed -GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryGeometries(sw), export_settings(export_settings) { +GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryGeometries(sw), export_settings(export_settings) +{ } @@ -160,7 +161,7 @@ void GeometryExporter::operator()(Object *ob) if (this->export_settings->include_shapekeys) { Key * key = BKE_key_from_object(ob); - if(key) { + if (key) { KeyBlock * kb = (KeyBlock*)key->block.first; //skip the basis kb = kb->next; @@ -175,7 +176,8 @@ void GeometryExporter::operator()(Object *ob) #endif } -void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb){ +void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) +{ std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(kb->name); std::vector nor; std::vector norind; diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index 946f9ff99e3..5ab068160a4 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -133,7 +133,7 @@ private: CustomData create_edge_custom_data(EdgeHash *eh); - void allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris); + void allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris); // TODO: import uv set names void read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris); diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index 3a06ca3bc0e..dbf7d40b373 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -182,7 +182,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) colladaNode.end(); } - if (ob->constraints.first != NULL ){ + if (ob->constraints.first != NULL ) { bConstraint *con = (bConstraint*) ob->constraints.first; while (con) { std::string con_name(id_name(con)); @@ -208,8 +208,8 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) Object *obtar; cti->get_constraint_targets(con, &targets); - if(cti){ - for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next){ + if (cti) { + for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next) { obtar = ct->tar; std::string tar_id(id_name(obtar)); colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"target_id",tar_id); diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp index 913c0710cc6..67166d819a6 100644 --- a/source/blender/collada/TransformReader.cpp +++ b/source/blender/collada/TransformReader.cpp @@ -46,7 +46,7 @@ void TransformReader::get_node_mat(float mat[4][4], COLLADAFW::Node *node, std:: COLLADAFW::Transformation *tm = node->getTransformations()[i]; COLLADAFW::Transformation::TransformationType type = tm->getTransformationType(); - if (type == COLLADAFW::Transformation::MATRIX){ + if (type == COLLADAFW::Transformation::MATRIX) { // XXX why does this return and discard all following transformations? dae_matrix_to_mat4(tm, mat); return; diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 27af5c0aba2..ab8491dde01 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -295,11 +295,11 @@ std::string bc_url_encode(std::string data) { } std::string bc_replace_string(std::string data, const std::string& pattern, - const std::string& replacement) { - size_t pos = 0; - while((pos = data.find(pattern, pos)) != std::string::npos) { - data.replace(pos, pattern.length(), replacement); - pos += replacement.length(); - } - return data; -} \ No newline at end of file + const std::string& replacement) { + size_t pos = 0; + while ((pos = data.find(pattern, pos)) != std::string::npos) { + data.replace(pos, pattern.length(), replacement); + pos += replacement.length(); + } + return data; +} diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 2004b18adf6..d8bb372b936 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -319,14 +319,13 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) import_units = RNA_boolean_get(op->ptr, "import_units"); RNA_string_get(op->ptr, "filepath", filename); - if (collada_import( C, - filename, - import_units)) { - return OPERATOR_FINISHED; + if (collada_import(C, filename, import_units)) { + return OPERATOR_FINISHED; } else { - BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document (see console for details)"); - return OPERATOR_CANCELLED; + BKE_report(op->reports, RPT_ERROR, + "Errors found during parsing COLLADA document (see console for details)"); + return OPERATOR_CANCELLED; } } diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index e56962a3964..fa1bdd6ca82 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -73,7 +73,7 @@ void sculpt_pbvh_clear(Object *ob); void sculpt_update_after_dynamic_topology_toggle(bContext *C); void sculpt_dynamic_topology_enable(struct bContext *C); void sculpt_dynamic_topology_disable(struct bContext *C, - struct SculptUndoNode *unode); + struct SculptUndoNode *unode); /* Undo */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 5c2e75776e4..8c0a2dc4b65 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -83,6 +83,9 @@ #include "view3d_intern.h" /* own include */ +/* for ndof prints */ +// #define DEBUG_NDOF_MOTION + /* ********************** view3d_edit: view manipulations ********************* */ int ED_view3d_camera_lock_check(View3D *v3d, RegionView3D *rv3d) @@ -1043,11 +1046,10 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, wmEvent *event) float view_inv[4]; invert_qt_qt(view_inv, rv3d->viewquat); - /* #define DEBUG_NDOF_MOTION */ - #ifdef DEBUG_NDOF_MOTION +#ifdef DEBUG_NDOF_MOTION printf("ndof: T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f) dt=%.3f delivered to 3D view\n", ndof->tx, ndof->ty, ndof->tz, ndof->rx, ndof->ry, ndof->rz, ndof->dt); - #endif +#endif if (rv3d->viewlock == RV3D_LOCKED) { /* rotation not allowed -- explore panning options instead */ @@ -1204,11 +1206,10 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) float view_inv[4]; invert_qt_qt(view_inv, rv3d->viewquat); - /* #define DEBUG_NDOF_MOTION */ - #ifdef DEBUG_NDOF_MOTION +#ifdef DEBUG_NDOF_MOTION printf("ndof: T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f) dt=%.3f delivered to 3D view\n", ndof->tx, ndof->ty, ndof->tz, ndof->rx, ndof->ry, ndof->rz, ndof->dt); - #endif +#endif if (ndof->tz) { /* Zoom! diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 23804291a65..a516812eb53 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -2478,7 +2478,7 @@ void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer, cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); partial_buffer_update_rect(ibuf, display_buffer, linear_buffer, byte_buffer, buffer_width, stride, - offset_x, offset_y, cm_processor, xmin, ymin, xmax, ymax); + offset_x, offset_y, cm_processor, xmin, ymin, xmax, ymax); if (cm_processor) IMB_colormanagement_processor_free(cm_processor); From 8d4d27de9f0919c74fa629c287ba6678e79ce9a4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 10 Feb 2013 18:02:59 +0000 Subject: [PATCH 014/157] Fix #34184: cycles speed vector pass should be zero when using motion blur, instead it had value 10000. --- intern/cycles/blender/blender_session.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 951f7022a10..dfea9833287 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -410,8 +410,10 @@ void BlenderSession::do_write_update_render_result(BL::RenderResult b_rr, BL::Re int components = b_pass.channels(); /* copy pixels */ - if(buffers->get_pass_rect(pass_type, exposure, rtile.sample, components, &pixels[0])) - b_pass.rect(&pixels[0]); + if(!buffers->get_pass_rect(pass_type, exposure, rtile.sample, components, &pixels[0])) + memset(&pixels[0], 0, pixels.size()*sizeof(float)); + + b_pass.rect(&pixels[0]); } } From 14a0ff90bc8b2d376ceb0b94c6724529754616b0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 10 Feb 2013 18:03:01 +0000 Subject: [PATCH 015/157] Fix a few DPI / retina draw issues: * Color picker cursor was too small, and color cirle was not smooth enough. * Border select gesture cross before first click did not reach to the border of the window. * Buttons were not drawing emboss properly (also for non-retina actually). Note it doesn't draw entirely right for aligned buttons, but this was also the case before it got broken. --- source/blender/editors/interface/interface_widgets.c | 10 +++++----- .../blender/editors/space_buttons/buttons_header.c | 5 +++-- source/blender/windowmanager/intern/wm_gesture.c | 12 +++++++----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 142ea5128c0..6735c8b173c 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -646,8 +646,8 @@ static void widget_verts_to_quad_strip_open(uiWidgetBase *wtb, const int totvert for (a = 0; a < totvert; a++) { quad_strip[a * 2][0] = wtb->outer_v[a][0]; quad_strip[a * 2][1] = wtb->outer_v[a][1]; - quad_strip[a * 2 + 1][0] = wtb->inner_v[a][0]; - quad_strip[a * 2 + 1][1] = wtb->inner_v[a][1]; + quad_strip[a * 2 + 1][0] = wtb->outer_v[a][0]; + quad_strip[a * 2 + 1][1] = wtb->outer_v[a][1] - 1.0f; } } @@ -1900,12 +1900,12 @@ static void ui_hsv_cursor(float x, float y) glTranslatef(x, y, 0.0f); glColor3f(1.0f, 1.0f, 1.0f); - glutil_draw_filled_arc(0.0f, M_PI * 2.0, 3.0f, 8); + glutil_draw_filled_arc(0.0f, M_PI * 2.0, 3.0f * U.pixelsize, 8); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glColor3f(0.0f, 0.0f, 0.0f); - glutil_draw_lined_arc(0.0f, M_PI * 2.0, 3.0f, 12); + glutil_draw_lined_arc(0.0f, M_PI * 2.0, 3.0f * U.pixelsize, 12); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); @@ -1929,7 +1929,7 @@ void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rcti *rec static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *rect) { - const int tot = 32; + const int tot = 64; const float radstep = 2.0f * (float)M_PI / (float)tot; const float centx = BLI_rcti_cent_x_fl(rect); diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index ebba7d92819..701048cd229 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -97,14 +97,15 @@ static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event) sbuts->mainbuser = sbuts->mainb; } -#define BUT_UNIT_X (UI_UNIT_X + 2) +#define BUT_UNIT_X (UI_UNIT_X + 2*U.pixelsize) void buttons_header_buttons(const bContext *C, ARegion *ar) { SpaceButs *sbuts = CTX_wm_space_buts(C); uiBlock *block; uiBut *but; - int xco, yco = 2; + int headery = ED_area_headersize(); + int xco, yco = 0.5f*(headery - UI_UNIT_Y); buttons_context_compute(C, sbuts); diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 168c2312d9f..302bf61756a 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -309,17 +309,19 @@ static void wm_gesture_draw_lasso(wmGesture *gt) static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) { rcti *rect = (rcti *)gt->customdata; - + int winsizex = WM_window_pixels_x(win); + int winsizey = WM_window_pixels_y(win); + glEnable(GL_LINE_STIPPLE); glColor3ub(96, 96, 96); glLineStipple(1, 0xCCCC); - sdrawline(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin); - sdrawline(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey); + sdrawline(rect->xmin - winsizex, rect->ymin, rect->xmin + winsizex, rect->ymin); + sdrawline(rect->xmin, rect->ymin - winsizey, rect->xmin, rect->ymin + winsizey); glColor3ub(255, 255, 255); glLineStipple(1, 0x3333); - sdrawline(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin); - sdrawline(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey); + sdrawline(rect->xmin - winsizex, rect->ymin, rect->xmin + winsizex, rect->ymin); + sdrawline(rect->xmin, rect->ymin - winsizey, rect->xmin, rect->ymin + winsizey); glDisable(GL_LINE_STIPPLE); } From ba12c5eaeb4ea9f10f5d075eac6ac1b96feaa886 Mon Sep 17 00:00:00 2001 From: "Sv. Lockal" Date: Sun, 10 Feb 2013 18:08:51 +0000 Subject: [PATCH 016/157] Show/hide Render View should not raise temp user preferences windows --- source/blender/editors/render/render_view.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index f15f7b539f3..c53a8f68713 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -289,7 +289,9 @@ static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent /* is there another window showing result? */ for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) { - if (win->screen->temp || (win == winshow && winshow != wincur)) { + bScreen *sc = win->screen; + if ((sc->temp && ((ScrArea *)sc->areabase.first)->spacetype == SPACE_IMAGE) || + (win == winshow && winshow != wincur)) { wm_window_raise(win); return OPERATOR_FINISHED; } From 41500e28243a0395f5e5117471df4061f16b287a Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Sun, 10 Feb 2013 20:17:50 +0000 Subject: [PATCH 017/157] Fix themes for gradient. For other (contrib) theme maintainers: back property is not used for 3D viewport back colour anymore, instead use the gradient high colour, as done in this commit --- release/scripts/presets/interface_theme/back_to_black.xml | 4 ++-- release/scripts/presets/interface_theme/blender_24x.xml | 2 +- release/scripts/presets/interface_theme/elsyiun.xml | 2 +- release/scripts/presets/interface_theme/hexagon.xml | 2 +- release/scripts/presets/interface_theme/ubuntu_ambiance.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/release/scripts/presets/interface_theme/back_to_black.xml b/release/scripts/presets/interface_theme/back_to_black.xml index 3af07c0cb4e..bb625c6452c 100644 --- a/release/scripts/presets/interface_theme/back_to_black.xml +++ b/release/scripts/presets/interface_theme/back_to_black.xml @@ -296,8 +296,8 @@ + gradient="#393939" + high_gradient="#000000"> diff --git a/release/scripts/presets/interface_theme/blender_24x.xml b/release/scripts/presets/interface_theme/blender_24x.xml index 1c3df142c77..3e84d2aee41 100644 --- a/release/scripts/presets/interface_theme/blender_24x.xml +++ b/release/scripts/presets/interface_theme/blender_24x.xml @@ -297,7 +297,7 @@ + high_gradient="#757575"> diff --git a/release/scripts/presets/interface_theme/elsyiun.xml b/release/scripts/presets/interface_theme/elsyiun.xml index ef49cb31cbd..3cb75323c97 100644 --- a/release/scripts/presets/interface_theme/elsyiun.xml +++ b/release/scripts/presets/interface_theme/elsyiun.xml @@ -297,7 +297,7 @@ + high_gradient="#4b4b4b"> diff --git a/release/scripts/presets/interface_theme/hexagon.xml b/release/scripts/presets/interface_theme/hexagon.xml index 0b6e626268f..4072b36a169 100644 --- a/release/scripts/presets/interface_theme/hexagon.xml +++ b/release/scripts/presets/interface_theme/hexagon.xml @@ -297,7 +297,7 @@ + high_gradient="#7f818d"> diff --git a/release/scripts/presets/interface_theme/ubuntu_ambiance.xml b/release/scripts/presets/interface_theme/ubuntu_ambiance.xml index 9786d609983..d51d34f041d 100644 --- a/release/scripts/presets/interface_theme/ubuntu_ambiance.xml +++ b/release/scripts/presets/interface_theme/ubuntu_ambiance.xml @@ -297,7 +297,7 @@ + high_gradient="#131311"> From 50f7328fb6067cf5bf922c00a585886f9e992728 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 10 Feb 2013 20:47:44 +0000 Subject: [PATCH 018/157] Fix scons win32 link error with OSL, also fix a GLEW linker warning --- build_files/scons/config/win32-vc-config.py | 2 +- intern/cycles/SConscript | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index 21488e75f7e..95352bda8a7 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -182,7 +182,7 @@ WITH_BF_STATICOCIO = True WITH_BF_BOOST = True BF_BOOST = '${LIBDIR}/boost' BF_BOOST_INC = '${BF_BOOST}/include' -BF_BOOST_LIB = 'libboost_date_time-vc90-mt-s-1_49 libboost_filesystem-vc90-mt-s-1_49 libboost_regex-vc90-mt-s-1_49 libboost_system-vc90-mt-s-1_49 libboost_thread-vc90-mt-s-1_49' +BF_BOOST_LIB = 'libboost_date_time-vc90-mt-s-1_49 libboost_filesystem-vc90-mt-s-1_49 libboost_regex-vc90-mt-s-1_49 libboost_system-vc90-mt-s-1_49 libboost_thread-vc90-mt-s-1_49 libboost_wave-vc90-mt-s-1_49' BF_BOOST_LIB_INTERNATIONAL = 'libboost_locale-vc90-mt-s-1_49' BF_BOOST_LIBPATH = '${BF_BOOST}/lib' diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript index 8a8ef9cce39..7b4d2db6861 100644 --- a/intern/cycles/SConscript +++ b/intern/cycles/SConscript @@ -43,6 +43,8 @@ incs = [] defs = [] cxxflags = Split(env['CXXFLAGS']) +defs.append('GLEW_STATIC') + defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {') defs.append('CCL_NAMESPACE_END=}') From 1ba194aeddef7a4d2859d7587b60c70c03387b1c Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 10 Feb 2013 21:01:30 +0000 Subject: [PATCH 019/157] [#34013] [video sequence editor] Offset and crop of strips are wrong Applied patch by jehan after confirming the issue. Thanks for the patch! --- source/blender/blenkernel/intern/sequencer.c | 32 +++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index f1724bdfc6b..45393726add 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1820,8 +1820,6 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra, StripCrop c = {0}; StripTransform t = {0}; int sx, sy, dx, dy; - double xscale = 1.0; - double yscale = 1.0; if (is_proxy_image) { double f = seq_rendersize_to_scale_factor(context.preview_render_size); @@ -1838,21 +1836,23 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra, t = *seq->strip->transform; } - xscale = context.scene->r.xsch ? ((double)context.rectx / (double)context.scene->r.xsch) : 1.0; - yscale = context.scene->r.ysch ? ((double)context.recty / (double)context.scene->r.ysch) : 1.0; - - xscale /= (double)context.rectx / (double)ibuf->x; - yscale /= (double)context.recty / (double)ibuf->y; - - c.left *= xscale; c.right *= xscale; - c.top *= yscale; c.bottom *= yscale; - - t.xofs *= xscale; t.yofs *= yscale; + if (is_preprocessed) { + double xscale = context.scene->r.xsch ? ((double)context.rectx / (double)context.scene->r.xsch) : 1.0; + double yscale = context.scene->r.ysch ? ((double)context.recty / (double)context.scene->r.ysch) : 1.0; + if (seq->flag & SEQ_USE_TRANSFORM) { + t.xofs *= xscale; + t.yofs *= yscale; + } + if (seq->flag & SEQ_USE_CROP) { + c.left *= xscale; + c.right *= xscale; + c.top *= yscale; + c.bottom *= yscale; + } + } sx = ibuf->x - c.left - c.right; sy = ibuf->y - c.top - c.bottom; - dx = sx; - dy = sy; if (seq->flag & SEQ_USE_TRANSFORM) { if (is_preprocessed) { @@ -1864,6 +1864,10 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra, dy = context.scene->r.ysch; } } + else { + dx = sx; + dy = sy; + } if (c.top + c.bottom >= ibuf->y || c.left + c.right >= ibuf->x || From 22dbb675c156a24880e3b1803a0f5abde53af4b8 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Sun, 10 Feb 2013 22:14:56 +0000 Subject: [PATCH 020/157] Fix #33437 Collada: Added scale matching for Scene imports. --- source/blender/collada/DocumentImporter.cpp | 20 ++++--- source/blender/collada/DocumentImporter.h | 2 +- source/blender/collada/collada_utils.cpp | 62 ++++++++++++++++++++- source/blender/collada/collada_utils.h | 6 +- source/blender/editors/io/io_collada.c | 10 ++-- 5 files changed, 84 insertions(+), 16 deletions(-) diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 0436dd40744..88a67eebe9d 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -213,15 +213,17 @@ void DocumentImporter::finish() fprintf(stdout, "Collada: Adjusting Blender units to Importset units: %f.\n", unit_factor); } - else { - // TODO: add automatic scaling for the case when Blender units - // and import units are set to different values. - } // Write nodes to scene const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes(); for (unsigned int i = 0; i < roots.getCount(); i++) { - write_node(roots[i], NULL, sce, NULL, false); + std::vector *objects_done; + objects_done = write_node(roots[i], NULL, sce, NULL, false); + + if (!this->import_settings->import_units) { + // Match incoming scene with current unit settings + bc_match_scale(objects_done, *sce, unit_converter); + } } // update scene @@ -443,7 +445,7 @@ void DocumentImporter::create_constraints(ExtraTags *et, Object *ob) } } -void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node) +std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node) { Object *ob = NULL; bool is_joint = node->getType() == COLLADAFW::Node::JOINT; @@ -549,7 +551,8 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent // XXX: if there're multiple instances, only one is stored - if (!ob) return; + if (!ob) return objects_done; + for (std::vector::iterator it = objects_done->begin(); it != objects_done->end(); ++it) { ob = *it; std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId(); @@ -561,6 +564,7 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent libnode_ob.push_back(ob); } + //create_constraints(et,ob); } @@ -585,6 +589,8 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent write_node(child_nodes[i], node, sce, ob, is_library_node); } } + + return objects_done; } /** When this method is called, the writer must write the entire visual scene. diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h index 76d16f38a0c..ff0cbd44043 100644 --- a/source/blender/collada/DocumentImporter.h +++ b/source/blender/collada/DocumentImporter.h @@ -77,7 +77,7 @@ public: Object* create_lamp_object(COLLADAFW::InstanceLight*, Scene*); Object* create_instance_node(Object*, COLLADAFW::Node*, COLLADAFW::Node*, Scene*, bool); void create_constraints(ExtraTags *et, Object *ob); - void write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool); + std::vector *write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool); MTex* create_texture(COLLADAFW::EffectCommon*, COLLADAFW::Texture&, Material*, int, TexIndexTextureArrayMap&); void write_profile_COMMON(COLLADAFW::EffectCommon*, Material*); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index ab8491dde01..84bb33929c1 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -295,11 +295,69 @@ std::string bc_url_encode(std::string data) { } std::string bc_replace_string(std::string data, const std::string& pattern, - const std::string& replacement) { + const std::string& replacement) { size_t pos = 0; - while ((pos = data.find(pattern, pos)) != std::string::npos) { + while((pos = data.find(pattern, pos)) != std::string::npos) { data.replace(pos, pattern.length(), replacement); pos += replacement.length(); } return data; } + +/** + Calculate a rescale factor such that the imported scene's scale + is preserved. I.e. 1 meter in the import will also be + 1 meter in the curretn scene. + XXX : I am not sure if it is correct to map 1 Blender Unit + to 1 Meter for unit type NONE. But it looks reasonable to me. +*/ +void bc_match_scale(std::vector *objects_done, + Scene &sce, + UnitConverter &unit_converter) { + + Object *ob = NULL; + + PointerRNA scene_ptr, unit_settings; + PropertyRNA *system_ptr, *scale_ptr; + RNA_id_pointer_create(&sce.id, &scene_ptr); + + unit_settings = RNA_pointer_get(&scene_ptr, "unit_settings"); + system_ptr = RNA_struct_find_property(&unit_settings, "system"); + scale_ptr = RNA_struct_find_property(&unit_settings, "scale_length"); + + int type = RNA_property_enum_get(&unit_settings, system_ptr); + + float bl_scale; + + switch(type) { + case USER_UNIT_NONE : bl_scale = 1.0; // map 1 Blender unit to 1 Meter + break; + case USER_UNIT_METRIC : bl_scale = RNA_property_float_get(&unit_settings, scale_ptr); + break; + default : bl_scale = RNA_property_float_get(&unit_settings, scale_ptr); + // it looks like the conversion to Imperial is done implicitly. + // So nothing to do here. + break; + } + + float size_mat3[3][3]; + float size_mat4[4][4]; + + float scale_conv = unit_converter.getLinearMeter() / bl_scale; + + float rescale[3]; + rescale[0] = rescale[1] = rescale[2] = scale_conv; + + size_to_mat3(size_mat3, rescale); + copy_m4_m3(size_mat4, size_mat3); + + for (std::vector::iterator it = objects_done->begin(); it != objects_done->end(); ++it) { + ob = *it; + mult_m4_m4m4(ob->obmat, ob->obmat, size_mat4); + ob->obmat[3][0] = ob->loc[0] * rescale[0]; + ob->obmat[3][1] = ob->loc[1] * rescale[1]; + ob->obmat[3][2] = ob->loc[2] * rescale[2]; + BKE_object_apply_mat4(ob, ob->obmat, 0, 0); + } + +} diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index 90282d9d28f..892b57e6a4a 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -42,15 +42,19 @@ extern "C" { #include "DNA_texture_types.h" #include "DNA_scene_types.h" +#include "RNA_access.h" + #include "BLI_linklist.h" #include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_object.h" #include "BKE_DerivedMesh.h" +#include "BKE_scene.h" } #include "ExportSettings.h" +#include "collada_internal.h" typedef std::map > TexIndexTextureArrayMap; @@ -79,5 +83,5 @@ extern int bc_get_active_UVLayer(Object *ob); extern std::string bc_replace_string(std::string data, const std::string& pattern, const std::string& replacement); extern std::string bc_url_encode(std::string data); - +extern void bc_match_scale(std::vector *objects_done, Scene &sce, UnitConverter &unit_converter); #endif diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index d8bb372b936..52a585dd314 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -319,12 +319,11 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) import_units = RNA_boolean_get(op->ptr, "import_units"); RNA_string_get(op->ptr, "filepath", filename); - if (collada_import(C, filename, import_units)) { + if (collada_import( C, filename, import_units)) { return OPERATOR_FINISHED; } else { - BKE_report(op->reports, RPT_ERROR, - "Errors found during parsing COLLADA document (see console for details)"); + BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document (see console for details)"); return OPERATOR_CANCELLED; } } @@ -367,8 +366,9 @@ void WM_OT_collada_import(wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_boolean(ot->srna, "import_units", 0, "Import Units", - "If enabled use Units as defined in Collada Import, else keep Blender's current Units settings"); + RNA_def_boolean(ot->srna, + "import_units", 0, "Import Units", + "If disabled match import to Blender's current Unit settings. Otherwise use the settings from the Imported scene."); } #endif From 2005f7c6c0ee47b85bbcf5999225e86117290a65 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 00:49:00 +0000 Subject: [PATCH 021/157] style cleanup: also some typos --- intern/bsp/intern/CSG_BooleanOps.cpp | 20 +++++++++--------- intern/ghost/intern/GHOST_SystemCocoa.mm | 6 ++---- source/blender/blenlib/intern/fileops.c | 4 ++-- source/blender/blenlib/intern/math_rotation.c | 2 +- .../blenlib/intern/math_vector_inline.c | 4 ++-- source/blender/bmesh/bmesh_class.h | 2 +- source/blender/bmesh/intern/bmesh_core.c | 2 +- .../bmesh/intern/bmesh_iterators_inline.h | 2 +- source/blender/bmesh/intern/bmesh_queries.c | 2 +- .../blender/bmesh/operators/bmo_subdivide.c | 2 +- .../bmesh/tools/bmesh_decimate_unsubdivide.c | 2 +- source/blender/collada/collada_utils.cpp | 21 +++++++++++-------- source/blender/editors/io/io_collada.c | 5 +++-- source/blender/editors/render/render_view.c | 3 ++- source/blender/editors/screen/screen_ops.c | 2 +- .../editors/sculpt_paint/paint_image.c | 2 +- .../editors/space_buttons/buttons_header.c | 4 ++-- .../render/intern/source/multires_bake.c | 9 ++++---- source/blender/windowmanager/intern/wm_draw.c | 2 +- .../windowmanager/intern/wm_event_system.c | 2 +- .../windowmanager/intern/wm_operators.c | 4 ++-- source/creator/creator.c | 3 +-- .../RAS_OpenGLRasterizer/RAS_StorageIM.cpp | 4 ++-- 23 files changed, 56 insertions(+), 53 deletions(-) diff --git a/intern/bsp/intern/CSG_BooleanOps.cpp b/intern/bsp/intern/CSG_BooleanOps.cpp index 4f71e7992a1..f74dfc3c253 100644 --- a/intern/bsp/intern/CSG_BooleanOps.cpp +++ b/intern/bsp/intern/CSG_BooleanOps.cpp @@ -88,16 +88,16 @@ CSG_PerformBooleanOperation( BoolOpType boolType; - switch( op_type ) { - case e_csg_union: - boolType = BOP_UNION; - break; - case e_csg_difference: - boolType = BOP_DIFFERENCE; - break; - default: - boolType = BOP_INTERSECTION; - break; + switch (op_type) { + case e_csg_union: + boolType = BOP_UNION; + break; + case e_csg_difference: + boolType = BOP_DIFFERENCE; + break; + default: + boolType = BOP_INTERSECTION; + break; } BoolOpState boolOpResult; diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index e4245aaf095..6cf4ada6311 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1028,8 +1028,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType, if (!validWindow(window)) { return GHOST_kFailure; } - switch(eventType) - { + switch (eventType) { case GHOST_kEventWindowClose: pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) ); break; @@ -1086,8 +1085,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType if (!validWindow(window)) { return GHOST_kFailure; } - switch(eventType) - { + switch (eventType) { case GHOST_kEventDraggingEntered: case GHOST_kEventDraggingUpdated: case GHOST_kEventDraggingExited: diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 0f42fca9f12..24b3c36a329 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -111,7 +111,7 @@ int BLI_file_gzip(const char *from, const char *to) return rval; } -/* gzip the file in from_file and write it to memery to_mem, at most size bytes. +/* gzip the file in from_file and write it to memory to_mem, at most size bytes. * return the unziped size */ char *BLI_file_ungzip_to_mem(const char *from_file, int *size_r) @@ -283,7 +283,7 @@ int BLI_move(const char *file, const char *to) { int err; - /* windows doesn't support moveing to a directory + /* windows doesn't support moving to a directory * it has to be 'mv filename filename' and not * 'mv filename destdir' */ diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index e6399ed356e..c0ea817ae4a 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1662,7 +1662,7 @@ void quat_apply_track(float quat[4], short axis, short upflag) axis = axis - 3; /* there are 2 possible up-axis for each axis used, the 'quat_track' applies so the first - * up axis is used X->Y, Y->X, Z->X, if this first up axis isn used then rotate 90d + * up axis is used X->Y, Y->X, Z->X, if this first up axis isn't used then rotate 90d * the strange bit shift below just find the low axis {X:Y, Y:X, Z:X} */ if (upflag != (2 - axis) >> 1) { float q[4] = {M_SQRT1_2, 0.0, 0.0, 0.0}; /* assign 90d rotation axis */ diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index c4def539c10..48e7de43a86 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -663,7 +663,7 @@ MINLINE float normalize_v3_v3(float r[3], const float a[3]) float d = dot_v3v3(a, a); /* a larger value causes normalize errors in a - * scaled down models with camera xtreme close */ + * scaled down models with camera extreme close */ if (d > 1.0e-35f) { d = sqrtf(d); mul_v3_v3fl(r, a, 1.0f / d); @@ -681,7 +681,7 @@ MINLINE double normalize_v3_d(double n[3]) double d = n[0] * n[0] + n[1] * n[1] + n[2] * n[2]; /* a larger value causes normalize errors in a - * scaled down models with camera xtreme close */ + * scaled down models with camera extreme close */ if (d > 1.0e-35) { double mul; diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index 4fa3a69356f..e851a642b32 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -45,7 +45,7 @@ struct Object; * pointers. this is a requirement of mempool's method of * iteration. * - * hrm. it doesn't but stull works ok, remove the comment above? - campbell. + * hrm. it doesn't but still works ok, remove the comment above? - campbell. */ // #pragma GCC diagnostic error "-Wpadded" diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index a2f2a9a0dba..643e73e02b4 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -2103,7 +2103,7 @@ bool bmesh_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep) } /** - * \brief Unglue Region Make Vert (URMV) + * \brief Un-glue Region Make Vert (URMV) * * Disconnects a face from its vertex fan at loop \a sl * diff --git a/source/blender/bmesh/intern/bmesh_iterators_inline.h b/source/blender/bmesh/intern/bmesh_iterators_inline.h index d9784ac9b2a..eef6544be89 100644 --- a/source/blender/bmesh/intern/bmesh_iterators_inline.h +++ b/source/blender/bmesh/intern/bmesh_iterators_inline.h @@ -35,7 +35,7 @@ /** * \brief Iterator Step * - * Calls an iterators step fucntion to return the next element. + * Calls an iterators step function to return the next element. */ BLI_INLINE void *BM_iter_step(BMIter *iter) { diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 2284e183d97..44dc483d5a7 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -472,7 +472,7 @@ BMLoop *BM_vert_step_fan_loop(BMLoop *l, BMEdge **e_step) * The function takes a vertex at the center of a fan and returns the opposite edge in the fan. * All edges in the fan must be manifold, otherwise return NULL. * - * \note This could (probably) be done more effieiently. + * \note This could (probably) be done more efficiently. */ BMEdge *BM_vert_other_disk_edge(BMVert *v, BMEdge *e_first) { diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index c7c33aa2775..36ad8ef506b 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -165,7 +165,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar } /* apply the new difference to the rest of the shape keys, - * note that this dosn't take rotations into account, we _could_ support + * note that this doesn't take rotations into account, we _could_ support * this by getting the normals and coords for each shape key and * re-calculate the smooth value for each but this is quite involved. * for now its ok to simply apply the difference IMHO - campbell */ diff --git a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c index 9dc4b596568..7e9a5784552 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c +++ b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c @@ -189,7 +189,7 @@ void BM_mesh_decimate_unsubdivide_ex(BMesh *bm, const int iterations, const bool int iter_step; - /* if tag_only is set, we assyme the caller knows what verts to tag + /* if tag_only is set, we assume the caller knows what verts to tag * needed for the operator */ if (tag_only == false) { BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 84bb33929c1..13403555bfb 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -329,15 +329,18 @@ void bc_match_scale(std::vector *objects_done, float bl_scale; - switch(type) { - case USER_UNIT_NONE : bl_scale = 1.0; // map 1 Blender unit to 1 Meter - break; - case USER_UNIT_METRIC : bl_scale = RNA_property_float_get(&unit_settings, scale_ptr); - break; - default : bl_scale = RNA_property_float_get(&unit_settings, scale_ptr); - // it looks like the conversion to Imperial is done implicitly. - // So nothing to do here. - break; + switch (type) { + case USER_UNIT_NONE: + bl_scale = 1.0; // map 1 Blender unit to 1 Meter + break; + case USER_UNIT_METRIC: + bl_scale = RNA_property_float_get(&unit_settings, scale_ptr); + break; + default: + bl_scale = RNA_property_float_get(&unit_settings, scale_ptr); + // it looks like the conversion to Imperial is done implicitly. + // So nothing to do here. + break; } float size_mat3[3][3]; diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 52a585dd314..2003aeaa848 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -367,8 +367,9 @@ void WM_OT_collada_import(wmOperatorType *ot) WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, - "import_units", 0, "Import Units", - "If disabled match import to Blender's current Unit settings. Otherwise use the settings from the Imported scene."); + "import_units", 0, "Import Units", + "If disabled match import to Blender's current Unit settings. " + "Otherwise use the settings from the Imported scene"); } #endif diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index c53a8f68713..8b2ac740e47 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -291,7 +291,8 @@ static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) { bScreen *sc = win->screen; if ((sc->temp && ((ScrArea *)sc->areabase.first)->spacetype == SPACE_IMAGE) || - (win == winshow && winshow != wincur)) { + (win == winshow && winshow != wincur)) + { wm_window_raise(win); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index da2facc244a..11f1828ff4e 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3597,7 +3597,7 @@ static void SCENE_OT_delete(wmOperatorType *ot) /* ***************** region alpha blending ***************** */ -/* implementation note: a disapplearing region needs at least 1 last draw with 100% backbuffer +/* implementation note: a disappearing region needs at least 1 last draw with 100% backbuffer * texture over it- then triple buffer will clear it entirely. * This because flag RGN_HIDDEN is set in end - region doesnt draw at all then */ diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 74399857a97..a1b3941dd7a 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -904,7 +904,7 @@ static int project_paint_occlude_ptv_clip(const ProjPaintState *ps, const MFace /* Check if a screenspace location is occluded by any other faces * check, pixelScreenCo must be in screenspace, its Z-Depth only needs to be used for comparison - * and dosn't need to be correct in relation to X and Y coords (this is the case in perspective view) */ + * and doesn't need to be correct in relation to X and Y coords (this is the case in perspective view) */ static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *bucketFace, const int orig_face, float pixelScreenCo[4]) { MFace *mf; diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 701048cd229..ae7026a634f 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -97,7 +97,7 @@ static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event) sbuts->mainbuser = sbuts->mainb; } -#define BUT_UNIT_X (UI_UNIT_X + 2*U.pixelsize) +#define BUT_UNIT_X (UI_UNIT_X + 2 * U.pixelsize) void buttons_header_buttons(const bContext *C, ARegion *ar) { @@ -105,7 +105,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) uiBlock *block; uiBut *but; int headery = ED_area_headersize(); - int xco, yco = 0.5f*(headery - UI_UNIT_Y); + int xco, yco = 0.5f * (headery - UI_UNIT_Y); buttons_context_compute(C, sbuts); diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c index 89f67335c39..ea42049989b 100644 --- a/source/blender/render/intern/source/multires_bake.c +++ b/source/blender/render/intern/source/multires_bake.c @@ -938,17 +938,18 @@ static void build_permutation_table(unsigned short permutation[], unsigned short permutation[i] = temp_permutation[entry]; /* delete entry */ - for(k = entry; k < nr_entries_left - 1; k++) + for (k = entry; k < nr_entries_left - 1; k++) { temp_permutation[k] = temp_permutation[k + 1]; + } } /* verify permutation table * every entry must appear exactly once */ #if 0 - for(i = 0; i < number_of_rays; i++) temp_permutation[i] = 0; - for(i = 0; i < number_of_rays; i++) ++temp_permutation[permutation[i]]; - for(i = 0; i < number_of_rays; i++) BLI_assert(temp_permutation[i] == 1); + for (i = 0; i < number_of_rays; i++) temp_permutation[i] = 0; + for (i = 0; i < number_of_rays; i++) ++temp_permutation[permutation[i]]; + for (i = 0; i < number_of_rays; i++) BLI_assert(temp_permutation[i] == 1); #endif } diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 91be03986c1..6044e3fb771 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -800,7 +800,7 @@ void wm_draw_update(bContext *C) if (state == GHOST_kWindowStateMinimized) { /* do not update minimized windows, it gives issues on intel drivers (see [#33223]) - * anyway, it seems logical to skip update for invisile windows + * anyway, it seems logical to skip update for invisible windows */ continue; } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 9e3722777ba..0005c3a2230 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -3042,7 +3042,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.keymodifier = 0; /* this case happened with an external numpad, it's not really clear - * why, but it's also impossible to map a key modifier to an unknwon + * why, but it's also impossible to map a key modifier to an unknown * key, so it shouldn't harm */ if (event.keymodifier == UNKNOWNKEY) event.keymodifier = 0; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index e22694a6560..1172f66fb1b 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1341,7 +1341,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); - /* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogs have many items + /* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogues have many items * where quitting by accident is very annoying */ uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); @@ -1998,7 +1998,7 @@ static int wm_link_append_poll(bContext *C) if (WM_operator_winactive(C)) { /* linking changes active object which is pretty useful in general, * but which totally confuses edit mode (i.e. it becoming not so obvious - * to leave from edit mode and inwalid tools in toolbar might be displayed) + * to leave from edit mode and invalid tools in toolbar might be displayed) * so disable link/append when in edit mode (sergey) */ if (CTX_data_edit_object(C)) return 0; diff --git a/source/creator/creator.c b/source/creator/creator.c index 3260f0c3976..fcfec947d9f 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -499,8 +499,7 @@ static void blender_crash_handler_backtrace(FILE *fp) symbolinfo->MaxNameLen = MAXSYMBOL - 1; symbolinfo->SizeOfStruct = sizeof(SYMBOL_INFO); - for( i = 0; i < nframes; i++ ) - { + for (i = 0; i < nframes; i++) { SymFromAddr(process, ( DWORD64 )( stack[ i ] ), 0, symbolinfo); fprintf(fp, "%u: %s - 0x%0X\n", nframes - i - 1, symbolinfo->Name, symbolinfo->Address); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp index 490c26a5c3b..7bcc8dc9034 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp @@ -74,7 +74,7 @@ void RAS_StorageIM::TexCoord(const RAS_TexVert &tv) if (GLEW_ARB_multitexture) { for (unit = 0; unit < *m_texco_num; unit++) { - switch(m_texco[unit]) { + switch (m_texco[unit]) { case RAS_IRasterizer::RAS_TEXCO_ORCO: case RAS_IRasterizer::RAS_TEXCO_GLOB: glMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, tv.getXYZ()); @@ -97,7 +97,7 @@ void RAS_StorageIM::TexCoord(const RAS_TexVert &tv) if (GLEW_ARB_vertex_program) { int uv = 0; for (unit = 0; unit < *m_attrib_num; unit++) { - switch(m_attrib[unit]) { + switch (m_attrib[unit]) { case RAS_IRasterizer::RAS_TEXCO_ORCO: case RAS_IRasterizer::RAS_TEXCO_GLOB: glVertexAttrib3fvARB(unit, tv.getXYZ()); From 971fca48cadef8e746df50ff056dca6d6a1a6fc3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 01:14:45 +0000 Subject: [PATCH 022/157] supress Hectograms from being used when displaying weight units since they are not so common. --- source/blender/blenkernel/intern/unit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 84e1f29f6c0..691e40c6711 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -196,7 +196,7 @@ static struct bUnitDef buMetricMassDef[] = { {"ton", "tonnes", "ton", "t", "1000 Kilograms", UN_SC_MTON, 0.0, B_UNIT_DEF_NONE}, {"quintal", "quintals", "ql", "q", "100 Kilograms", UN_SC_QL, 0.0, B_UNIT_DEF_NONE}, {"kilogram", "kilograms", "kg", NULL, "Kilograms", UN_SC_KG, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"hectogram", "hectograms", "hg", NULL, "Hectograms", UN_SC_HG, 0.0, B_UNIT_DEF_NONE}, + {"hectogram", "hectograms", "hg", NULL, "Hectograms", UN_SC_HG, 0.0, B_UNIT_DEF_SUPPRESS}, {"dekagram", "dekagrams", "dag", NULL, "10 Grams", UN_SC_DAG, 0.0, B_UNIT_DEF_SUPPRESS}, {"gram", "grams", "g", NULL, "Grams", UN_SC_G, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} From b59ba34c37f9522fcd4066372a05a7e551e87a53 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 01:55:58 +0000 Subject: [PATCH 023/157] fix [#34152] Vertex Slide - misleading description also use C key to toggle clamping rather then alt (reported in [#33949]). --- source/blender/editors/transform/transform.c | 38 +++++++++++++------- source/blender/editors/transform/transform.h | 1 + 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 98d4c5e7b81..a76fd4a8746 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -5899,7 +5899,7 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2])) &c[0], !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF"); } else { - BLI_snprintf(str, sizeof(str), "Edge Slide: %.2f (E)ven: %s, (F)lipped: %s", + BLI_snprintf(str, sizeof(str), "Edge Slide: %.4f (E)ven: %s, (F)lipped: %s", final, !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF"); } @@ -6027,6 +6027,7 @@ static int createVertSlideVerts(TransInfo *t) } sld->is_proportional = true; + sld->is_clamp = true; sld->curr_sv_index = 0; sld->flipped_vtx = false; @@ -6220,6 +6221,16 @@ int handleEventVertSlide(struct TransInfo *t, struct wmEvent *event) } break; } + case CKEY: + { + /* use like a modifier key */ + if (event->val == KM_PRESS) { + sld->is_clamp = !sld->is_clamp; + calcVertSlideCustomPoints(t); + return 1; + } + break; + } #if 0 case EVT_MODAL_MAP: { @@ -6240,7 +6251,7 @@ int handleEventVertSlide(struct TransInfo *t, struct wmEvent *event) case MOUSEMOVE: { /* don't recalculat the best edge */ - if (!(t->flag & T_ALT_TRANSFORM)) { + if (sld->is_clamp) { calcVertSlideMouseActiveEdges(t, event->mval); } calcVertSlideCustomPoints(t); @@ -6266,7 +6277,6 @@ static void drawVertSlide(const struct bContext *C, TransInfo *t) const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f; const int alpha_shade = -30; int i; - bool is_constrained = !(t->flag & T_ALT_TRANSFORM); if (v3d && v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -6282,7 +6292,7 @@ static void drawVertSlide(const struct bContext *C, TransInfo *t) glLineWidth(line_size); UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); glBegin(GL_LINES); - if (is_constrained) { + if (sld->is_clamp) { sv = sld->sv; for (i = 0; i < sld->totsv; i++, sv++) { glVertex3fv(sv->co_orig_3d); @@ -6370,11 +6380,12 @@ static int doVertSlide(TransInfo *t, float perc) int VertSlide(TransInfo *t, const int UNUSED(mval[2])) { char str[128]; + char *str_p; float final; VertSlideData *sld = t->customData; const bool flipped = sld->flipped_vtx; const bool is_proportional = sld->is_proportional; - const bool is_constrained = !((t->flag & T_ALT_TRANSFORM) || hasNumInput(&t->num)); + const bool is_constrained = !(sld->is_clamp == false || hasNumInput(&t->num)); final = t->values[0]; @@ -6385,20 +6396,23 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2])) CLAMP(final, 0.0f, 1.0f); } + /* header string */ + str_p = str; if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - applyNumInput(&t->num, &final); - outputNumInput(&(t->num), c); - - BLI_snprintf(str, sizeof(str), "Vert Slide: %s (E)ven: %s, (F)lipped: %s, Alt Hold: %s", - &c[0], !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF", (t->flag & T_ALT_TRANSFORM) ? "ON" : "OFF"); + str_p += BLI_snprintf(str, sizeof(str), "Vert Slide: %s", &c[0]); } else { - BLI_snprintf(str, sizeof(str), "Vert Slide: %.2f (E)ven: %s, (F)lipped: %s, Alt Hold: %s", - final, !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF", (t->flag & T_ALT_TRANSFORM) ? "ON" : "OFF"); + str_p += BLI_snprintf(str_p, sizeof(str), "Vert Slide: %.4f ", final); } + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), "(E)ven: %s, ", !is_proportional ? "ON" : "OFF"); + if (!is_proportional) { + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), "(F)lipped: %s, ", flipped ? "ON" : "OFF"); + } + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), "(C)lamp: %s", sld->is_clamp ? "ON" : "OFF"); + /* done with header string */ if (is_constrained) { CLAMP(final, 0.0f, 1.0f); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index a27fe91c3c3..55b7e9fae60 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -239,6 +239,7 @@ typedef struct VertSlideData { float perc; bool is_proportional; + bool is_clamp; bool flipped_vtx; int curr_sv_index; From b2feb19c02e9efab537f849333c0b3d39188f950 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 02:06:19 +0000 Subject: [PATCH 024/157] fix for memory leak in transform when changing transform modes within transform (if you held down the R-key for example). --- .../blender/editors/transform/transform_input.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index dd1510498b0..4e9a54692a5 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -307,15 +307,8 @@ static void calcSpringFactor(MouseInput *mi) void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) { - /* may have been allocated previously */ - /* TODO, holding R-key can cause mem leak, but this causes [#28903] - * disable for now. */ -#if 0 - if (mi->data) { - MEM_freeN(mi->data); - mi->data = NULL; - } -#endif + /* incase we allocate a new value */ + void *mi_data_prev = mi->data; switch (mode) { case INPUT_VECTOR: @@ -374,6 +367,12 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) break; } + /* if we've allocated new data, free the old data + * less hassle then checking before every alloc above */ + if (mi_data_prev && (mi_data_prev != mi->data)) { + MEM_freeN(mi_data_prev); + } + /* bootstrap mouse input with initial values */ applyMouseInput(t, mi, mi->imval, t->values); } From 20139348785dcd23ebe00db25f5e5726a23c685f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 03:01:50 +0000 Subject: [PATCH 025/157] Command line argument '--python' wasn't working as documented since a long time, It wasnt checking for text-blocks. Rather then be ambiguous, add --python-text argument for executing text-blocks. --- source/creator/creator.c | 45 ++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/source/creator/creator.c b/source/creator/creator.c index fcfec947d9f..7ab5d9ff2bd 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -88,6 +88,7 @@ #include "BKE_depsgraph.h" /* for DAG_on_visible_update */ #include "BKE_font.h" #include "BKE_global.h" +#include "BKE_library.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_packedFile.h" @@ -302,6 +303,7 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data) printf("\n"); BLI_argsPrintArgDoc(ba, "--python"); + BLI_argsPrintArgDoc(ba, "--python-text"); BLI_argsPrintArgDoc(ba, "--python-console"); BLI_argsPrintArgDoc(ba, "--addons"); @@ -1089,11 +1091,11 @@ static int set_skip_frame(int argc, const char **argv, void *data) _cmd; \ } \ CTX_data_scene_set(C, prevscene); \ - } \ + } (void)0 \ #endif /* WITH_PYTHON */ -static int run_python(int argc, const char **argv, void *data) +static int run_python_file(int argc, const char **argv, void *data) { #ifdef WITH_PYTHON bContext *C = data; @@ -1105,12 +1107,42 @@ static int run_python(int argc, const char **argv, void *data) BLI_strncpy(filename, argv[1], sizeof(filename)); BLI_path_cwd(filename); - BPY_CTX_SETUP(BPY_filepath_exec(C, filename, NULL)) + BPY_CTX_SETUP(BPY_filepath_exec(C, filename, NULL)); return 1; } else { - printf("\nError: you must specify a Python script after '-P / --python'.\n"); + printf("\nError: you must specify a filepath after '%s'.\n", argv[0]); + return 0; + } +#else + (void)argc; (void)argv; (void)data; /* unused */ + printf("This blender was built without python support\n"); + return 0; +#endif /* WITH_PYTHON */ +} + +static int run_python_text(int argc, const char **argv, void *data) +{ +#ifdef WITH_PYTHON + bContext *C = data; + + /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */ + if (argc > 1) { + /* Make the path absolute because its needed for relative linked blends to be found */ + struct Text *text = (struct Text *)BKE_libblock_find_name(ID_TXT, argv[1]); + + if (text) { + BPY_CTX_SETUP(BPY_text_exec(C, text, NULL, false)); + return 1; + } + else { + printf("\nError: text block not found %s.\n", argv[1]); + return 1; + } + } + else { + printf("\nError: you must specify a text block after '%s'.\n", argv[0]); return 0; } #else @@ -1125,7 +1157,7 @@ static int run_python_console(int UNUSED(argc), const char **argv, void *data) #ifdef WITH_PYTHON bContext *C = data; - BPY_CTX_SETUP(BPY_string_exec(C, "__import__('code').interact()")) + BPY_CTX_SETUP(BPY_string_exec(C, "__import__('code').interact()")); return 0; #else @@ -1353,7 +1385,8 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 4, "-s", "--frame-start", "\n\tSet start to frame (use before the -a argument)", set_start_frame, C); BLI_argsAdd(ba, 4, "-e", "--frame-end", "\n\tSet end to frame (use before the -a argument)", set_end_frame, C); BLI_argsAdd(ba, 4, "-j", "--frame-jump", "\n\tSet number of frames to step forward after each rendered frame", set_skip_frame, C); - BLI_argsAdd(ba, 4, "-P", "--python", "\n\tRun the given Python script (filename or Blender Text)", run_python, C); + BLI_argsAdd(ba, 4, "-P", "--python", "\n\tRun the given Python script file", run_python_file, C); + BLI_argsAdd(ba, 4, NULL, "--python-text", "\n\tRun the given Python script text block", run_python_text, C); BLI_argsAdd(ba, 4, NULL, "--python-console", "\n\tRun blender with an interactive console", run_python_console, C); BLI_argsAdd(ba, 4, NULL, "--addons", "\n\tComma separated list of addons (no spaces)", set_addons, C); From 0ac2f6e7d73bda112db13205d4b91ad98fa975ee Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 04:43:49 +0000 Subject: [PATCH 026/157] fix for own bug - memory leak when cancelling weight gradient tool --- source/blender/blenkernel/BKE_deform.h | 1 + source/blender/blenkernel/intern/deform.c | 16 ++++++++++++++-- .../blender/editors/sculpt_paint/paint_vertex.c | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index ab27421b383..0fa7356b64e 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -56,6 +56,7 @@ void defvert_remove_group(struct MDeformVert *dvert, struct void defvert_clear(struct MDeformVert *dvert); int defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b); +void BKE_defvert_array_free_elems(struct MDeformVert *dvert, int totvert); void BKE_defvert_array_free(struct MDeformVert *dvert, int totvert); void BKE_defvert_array_copy(struct MDeformVert *dst, const struct MDeformVert *src, int totvert); diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index cea92d53916..de15100de0b 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -809,7 +809,7 @@ void BKE_defvert_array_copy(MDeformVert *dst, const MDeformVert *src, int copyco } -void BKE_defvert_array_free(MDeformVert *dvert, int totvert) +void BKE_defvert_array_free_elems(MDeformVert *dvert, int totvert) { /* Instead of freeing the verts directly, * call this function to delete any special @@ -823,6 +823,18 @@ void BKE_defvert_array_free(MDeformVert *dvert, int totvert) for (i = 0; i < totvert; i++) { if (dvert[i].dw) MEM_freeN(dvert[i].dw); } - MEM_freeN(dvert); } +void BKE_defvert_array_free(MDeformVert *dvert, int totvert) +{ + /* Instead of freeing the verts directly, + * call this function to delete any special + * vert data */ + if (!dvert) + return; + + /* Free any special data from the verts */ + BKE_defvert_array_free_elems(dvert, totvert); + + MEM_freeN(dvert); +} diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 956f8d2c136..326adefb4cc 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -3182,6 +3182,7 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, wmEvent *eve VPaint *wp = ts->wpaint; Object *ob = CTX_data_active_object(C); Mesh *me = ob->data; + BKE_defvert_array_free_elems(me->dvert, me->totvert); BKE_defvert_array_copy(me->dvert, wp->wpaint_prev, me->totvert); free_wpaint_prev(wp); From 48f905d806254eebe66ddbdba8e63266977e63e3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 05:55:11 +0000 Subject: [PATCH 027/157] fix for modifier keys held before a window was activated being ignored. --- source/blender/windowmanager/intern/wm_window.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index d8b987a196c..dc0c6115098 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -756,6 +756,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr GHOST_TEventKeyData kdata; wmEvent event; int wx, wy; + bool is_key; wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */ @@ -765,21 +766,21 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr /* bad ghost support for modifier keys... so on activate we set the modifiers again */ kdata.ascii = '\0'; kdata.utf8_buf[0] = '\0'; - if (win->eventstate->shift && !query_qual(SHIFT)) { + if ((win->eventstate->shift != 0) != ((is_key = query_qual(SHIFT)) != 0)) { kdata.key = GHOST_kKeyLeftShift; - wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); + wm_event_add_ghostevent(wm, win, is_key ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, time, &kdata); } - if (win->eventstate->ctrl && !query_qual(CONTROL)) { + if ((win->eventstate->ctrl != 0) != ((is_key = query_qual(CONTROL)) != 0)) { kdata.key = GHOST_kKeyLeftControl; - wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); + wm_event_add_ghostevent(wm, win, is_key ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, time, &kdata); } - if (win->eventstate->alt && !query_qual(ALT)) { + if ((win->eventstate->alt != 0) != ((is_key = query_qual(ALT)) != 0)) { kdata.key = GHOST_kKeyLeftAlt; - wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); + wm_event_add_ghostevent(wm, win, is_key ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, time, &kdata); } - if (win->eventstate->oskey && !query_qual(OS)) { + if ((win->eventstate->oskey != 0) != ((is_key = query_qual(OS)) != 0)) { kdata.key = GHOST_kKeyOS; - wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); + wm_event_add_ghostevent(wm, win, is_key ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, time, &kdata); } /* keymodifier zero, it hangs on hotkeys that open windows otherwise */ win->eventstate->keymodifier = 0; From 7687109c5973561c3d4e3144d0058d26df914c9b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 06:58:38 +0000 Subject: [PATCH 028/157] fix for weight gradient crashing on redo (wasn't possible to redo this initially). --- .../editors/sculpt_paint/paint_vertex.c | 32 +++++++++++++------ .../windowmanager/intern/wm_operators.c | 9 ++++-- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 326adefb4cc..0c0a5507594 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -3201,6 +3201,7 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, wmEvent *eve static int paint_weight_gradient_exec(bContext *C, wmOperator *op) { wmGesture *gesture = op->customdata; + DMGradient_vertStore *vert_cache; struct ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); @@ -3211,24 +3212,31 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) int y_end = RNA_int_get(op->ptr, "yend"); float sco_start[2] = {x_start, y_start}; float sco_end[2] = {x_end, y_end}; - + const bool is_interactive = (gesture != NULL); DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask); DMGradient_userData data = {0}; - if (gesture->userdata == NULL) { - VPaint *wp = scene->toolsettings->wpaint; + if (is_interactive) { + if (gesture->userdata == NULL) { + VPaint *wp = scene->toolsettings->wpaint; - gesture->userdata = MEM_mallocN(sizeof(DMGradient_vertStore) * me->totvert, __func__); - data.is_init = TRUE; + gesture->userdata = MEM_mallocN(sizeof(DMGradient_vertStore) * me->totvert, __func__); + data.is_init = true; - copy_wpaint_prev(wp, me->dvert, me->totvert); + copy_wpaint_prev(wp, me->dvert, me->totvert); - /* on init only, convert face -> vert sel */ - if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { - BKE_mesh_flush_select_from_polys(me); + /* on init only, convert face -> vert sel */ + if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { + BKE_mesh_flush_select_from_polys(me); + } } + vert_cache = gesture->userdata; + } + else { + data.is_init = true; + vert_cache = MEM_mallocN(sizeof(DMGradient_vertStore) * me->totvert, __func__); } data.ar = ar; @@ -3239,7 +3247,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) data.sco_line_div = 1.0f / len_v2v2(sco_start, sco_end); data.def_nr = ob->actdef - 1; data.use_select = (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)); - data.vert_cache = gesture->userdata; + data.vert_cache = vert_cache; data.type = RNA_enum_get(op->ptr, "type"); { @@ -3255,6 +3263,10 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + if (is_interactive == false) { + MEM_freeN(vert_cache); + } + return OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1172f66fb1b..a720d61f9d0 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1204,8 +1204,13 @@ void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor) RNA_def_int(ot->srna, "ystart", 0, INT_MIN, INT_MAX, "Y Start", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "yend", 0, INT_MIN, INT_MAX, "Y End", "", INT_MIN, INT_MAX); - if (cursor) - RNA_def_int(ot->srna, "cursor", cursor, 0, INT_MAX, "Cursor", "Mouse cursor style to use during the modal operator", 0, INT_MAX); + if (cursor) { + PropertyRNA *prop; + + prop = RNA_def_int(ot->srna, "cursor", cursor, 0, INT_MAX, + "Cursor", "Mouse cursor style to use during the modal operator", 0, INT_MAX); + RNA_def_property_flag(prop, PROP_HIDDEN); + } } From 25c9b56c5a95eb95f75172428500a279525c09c0 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Mon, 11 Feb 2013 07:12:15 +0000 Subject: [PATCH 029/157] Suppress more uncommon units. --- source/blender/blenkernel/intern/unit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 691e40c6711..dd6ed42bd92 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -142,7 +142,7 @@ static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, /* Areas */ static struct bUnitDef buMetricAreaDef[] = { {"square kilometer", "square kilometers", "km²", "km2", "Square Kilometers", UN_SC_KM * UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, - {"square hectometer", "square hectometers", "hm²", "hm2", "Square Hectometers", UN_SC_HM * UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, /* hectare */ + {"square hectometer", "square hectometers", "hm²", "hm2", "Square Hectometers", UN_SC_HM * UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS}, /* hectare */ {"square dekameter", "square dekameters", "dam²", "dam2", "Square Dekameters", UN_SC_DAM * UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, /* are */ {"square meter", "square meters", "m²", "m2", "Square Meters", UN_SC_M * UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"square decimeter", "square decimetees", "dm²", "dm2", "Square Decimeters", UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, @@ -168,7 +168,7 @@ static struct bUnitCollection buImperialAreaCollecton = {buImperialAreaDef, 4, 0 /* Volumes */ static struct bUnitDef buMetricVolDef[] = { {"cubic kilometer", "cubic kilometers", "km³", "km3", "Cubic Kilometers", UN_SC_KM * UN_SC_KM * UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, - {"cubic hectometer", "cubic hectometers", "hm³", "hm3", "Cubic Hectometers", UN_SC_HM * UN_SC_HM * UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, + {"cubic hectometer", "cubic hectometers", "hm³", "hm3", "Cubic Hectometers", UN_SC_HM * UN_SC_HM * UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS}, {"cubic dekameter", "cubic dekameters", "dam³", "dam3", "Cubic Dekameters", UN_SC_DAM * UN_SC_DAM * UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, {"cubic meter", "cubic meters", "m³", "m3", "Cubic Meters", UN_SC_M * UN_SC_M * UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"cubic decimeter", "cubic decimeters", "dm³", "dm3", "Cubic Decimeters", UN_SC_DM * UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, @@ -194,7 +194,7 @@ static struct bUnitCollection buImperialVolCollecton = {buImperialVolDef, 4, 0, /* Mass */ static struct bUnitDef buMetricMassDef[] = { {"ton", "tonnes", "ton", "t", "1000 Kilograms", UN_SC_MTON, 0.0, B_UNIT_DEF_NONE}, - {"quintal", "quintals", "ql", "q", "100 Kilograms", UN_SC_QL, 0.0, B_UNIT_DEF_NONE}, + {"quintal", "quintals", "ql", "q", "100 Kilograms", UN_SC_QL, 0.0, B_UNIT_DEF_SUPPRESS}, {"kilogram", "kilograms", "kg", NULL, "Kilograms", UN_SC_KG, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"hectogram", "hectograms", "hg", NULL, "Hectograms", UN_SC_HG, 0.0, B_UNIT_DEF_SUPPRESS}, {"dekagram", "dekagrams", "dag", NULL, "10 Grams", UN_SC_DAG, 0.0, B_UNIT_DEF_SUPPRESS}, From 8f0f7197a1988795b4d222f03a111bb79674f7e8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 07:27:20 +0000 Subject: [PATCH 030/157] fix [#34143] Can't Select Bones in Weight paint mode with Left mouse Selection enabled use action-mouse for weight-sample and weight-sample-group rather then left mouse. Alt+Left-Mouse more or less worked by accident, changing these keymaps makes it so Ctrl+LMB can be used for selection instead. --- source/blender/editors/sculpt_paint/paint_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 408572c7979..ba33ad22f92 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -721,8 +721,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0); /* these keys are from 2.4x but could be changed */ - WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample_group", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); + WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample_group", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_gradient", LEFTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "type", WPAINT_GRADIENT_TYPE_LINEAR); RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_gradient", LEFTMOUSE, KM_PRESS, KM_ALT | KM_CTRL, 0)->ptr, "type", WPAINT_GRADIENT_TYPE_RADIAL); From 53bce285ab42641959ce11095732d34a8e893f88 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 08:16:32 +0000 Subject: [PATCH 031/157] patch [#31636] no pressure with Genius Mousepen i608X tablet from Viktoria S. (viktorias) --- intern/ghost/intern/GHOST_SystemX11.cpp | 29 +++++++++++++++++++------ intern/ghost/intern/GHOST_SystemX11.h | 3 +++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 7ba8889fd1e..f8c7bf45ffc 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -133,6 +133,10 @@ GHOST_SystemX11( m_xclip_out = XInternAtom(m_display, "XCLIP_OUT", False); m_incr = XInternAtom(m_display, "INCR", False); m_utf8_string = XInternAtom(m_display, "UTF8_STRING", False); +#ifdef WITH_X11_XINPUT + m_xi_tablet = XInternAtom(m_display, XI_TABLET, False); +#endif + m_last_warp = 0; @@ -1939,7 +1943,9 @@ void GHOST_SystemX11::initXInputDevices() // printf("Tablet type:'%s', name:'%s', index:%d\n", device_type, device_info[i].name, i); - if (m_xtablet.StylusDevice == NULL && is_stylus(device_info[i].name, device_type)) { + if ((m_xtablet.StylusDevice == NULL) && + (is_stylus(device_info[i].name, device_type) || (device_info[i].type == m_xi_tablet))) + { // printf("\tfound stylus\n"); m_xtablet.StylusID = device_info[i].id; m_xtablet.StylusDevice = XOpenDevice(m_display, m_xtablet.StylusID); @@ -1952,11 +1958,18 @@ void GHOST_SystemX11::initXInputDevices() // printf("\t\tfound ValuatorClass\n"); XValuatorInfo *xvi = (XValuatorInfo *)ici; m_xtablet.PressureLevels = xvi->axes[2].max_value; - - /* this is assuming that the tablet has the same tilt resolution in both - * positive and negative directions. It would be rather weird if it didn't.. */ - m_xtablet.XtiltLevels = xvi->axes[3].max_value; - m_xtablet.YtiltLevels = xvi->axes[4].max_value; + + if (xvi->num_axes > 3) { + /* this is assuming that the tablet has the same tilt resolution in both + * positive and negative directions. It would be rather weird if it didn't.. */ + m_xtablet.XtiltLevels = xvi->axes[3].max_value; + m_xtablet.YtiltLevels = xvi->axes[4].max_value; + } + else { + m_xtablet.XtiltLevels = 0; + m_xtablet.YtiltLevels = 0; + } + break; } @@ -1967,7 +1980,9 @@ void GHOST_SystemX11::initXInputDevices() m_xtablet.StylusID = 0; } } - else if (m_xtablet.EraserDevice == NULL && is_eraser(device_info[i].name, device_type)) { + else if ((m_xtablet.EraserDevice == NULL) && + (is_eraser(device_info[i].name, device_type))) + { // printf("\tfound eraser\n"); m_xtablet.EraserID = device_info[i].id; m_xtablet.EraserDevice = XOpenDevice(m_display, m_xtablet.EraserID); diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h index 5fd494637f9..69ae634bb25 100644 --- a/intern/ghost/intern/GHOST_SystemX11.h +++ b/intern/ghost/intern/GHOST_SystemX11.h @@ -301,6 +301,9 @@ public: Atom m_xclip_out; Atom m_incr; Atom m_utf8_string; +#ifdef WITH_X11_XINPUT + Atom m_xi_tablet; +#endif #ifdef WITH_X11_XINPUT typedef struct GHOST_TabletX11 { From fb01dcea5ff167b838e25f234029f93b690954dc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 09:30:04 +0000 Subject: [PATCH 032/157] move atoms into their own struct and make all names match the original atom names, there were too many and mixed in with the classes namespace. --- intern/ghost/intern/GHOST_SystemX11.cpp | 109 ++++++++++++------------ intern/ghost/intern/GHOST_SystemX11.h | 64 +++++++------- intern/ghost/intern/GHOST_WindowX11.cpp | 44 +++++----- 3 files changed, 110 insertions(+), 107 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index f8c7bf45ffc..48fb8375303 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -109,36 +109,37 @@ GHOST_SystemX11( m_xim = NULL; #endif - m_delete_window_atom - = XInternAtom(m_display, "WM_DELETE_WINDOW", True); +#define GHOST_INTERN_ATOM_IF_EXISTS(atom) { m_atom.atom = XInternAtom(m_display, #atom , True); } (void)0 +#define GHOST_INTERN_ATOM(atom) { m_atom.atom = XInternAtom(m_display, #atom , False); } (void)0 - m_wm_protocols = XInternAtom(m_display, "WM_PROTOCOLS", False); - m_wm_take_focus = XInternAtom(m_display, "WM_TAKE_FOCUS", False); - m_wm_state = XInternAtom(m_display, "WM_STATE", False); - m_wm_change_state = XInternAtom(m_display, "WM_CHANGE_STATE", False); - m_net_state = XInternAtom(m_display, "_NET_WM_STATE", False); - m_net_max_horz = XInternAtom(m_display, - "_NET_WM_STATE_MAXIMIZED_HORZ", False); - m_net_max_vert = XInternAtom(m_display, - "_NET_WM_STATE_MAXIMIZED_VERT", False); - m_net_fullscreen = XInternAtom(m_display, - "_NET_WM_STATE_FULLSCREEN", False); - m_motif = XInternAtom(m_display, "_MOTIF_WM_HINTS", False); - m_targets = XInternAtom(m_display, "TARGETS", False); - m_string = XInternAtom(m_display, "STRING", False); - m_compound_text = XInternAtom(m_display, "COMPOUND_TEXT", False); - m_text = XInternAtom(m_display, "TEXT", False); - m_clipboard = XInternAtom(m_display, "CLIPBOARD", False); - m_primary = XInternAtom(m_display, "PRIMARY", False); - m_xclip_out = XInternAtom(m_display, "XCLIP_OUT", False); - m_incr = XInternAtom(m_display, "INCR", False); - m_utf8_string = XInternAtom(m_display, "UTF8_STRING", False); + GHOST_INTERN_ATOM_IF_EXISTS(WM_DELETE_WINDOW); + GHOST_INTERN_ATOM(WM_PROTOCOLS); + GHOST_INTERN_ATOM(WM_TAKE_FOCUS); + GHOST_INTERN_ATOM(WM_STATE); + GHOST_INTERN_ATOM(WM_CHANGE_STATE); + GHOST_INTERN_ATOM(_NET_WM_STATE); + GHOST_INTERN_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); + GHOST_INTERN_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); + + GHOST_INTERN_ATOM(_NET_WM_STATE_FULLSCREEN); + GHOST_INTERN_ATOM(_MOTIF_WM_HINTS); + GHOST_INTERN_ATOM(TARGETS); + GHOST_INTERN_ATOM(STRING); + GHOST_INTERN_ATOM(COMPOUND_TEXT); + GHOST_INTERN_ATOM(TEXT); + GHOST_INTERN_ATOM(CLIPBOARD); + GHOST_INTERN_ATOM(PRIMARY); + GHOST_INTERN_ATOM(XCLIP_OUT); + GHOST_INTERN_ATOM(INCR); + GHOST_INTERN_ATOM(UTF8_STRING); #ifdef WITH_X11_XINPUT - m_xi_tablet = XInternAtom(m_display, XI_TABLET, False); + m_atom.TABLET = XInternAtom(m_display, XI_TABLET, False); #endif - m_last_warp = 0; +#undef GHOST_INTERN_ATOM_IF_EXISTS +#undef GHOST_INTERN_ATOM + m_last_warp = 0; /* compute the initial time */ timeval tv; @@ -963,7 +964,7 @@ GHOST_SystemX11::processEvent(XEvent *xe) { XClientMessageEvent & xcme = xe->xclient; - if (((Atom)xcme.data.l[0]) == m_delete_window_atom) { + if (((Atom)xcme.data.l[0]) == m_atom.WM_DELETE_WINDOW) { g_event = new GHOST_Event( getMilliSeconds(), @@ -971,7 +972,7 @@ GHOST_SystemX11::processEvent(XEvent *xe) window ); } - else if (((Atom)xcme.data.l[0]) == m_wm_take_focus) { + else if (((Atom)xcme.data.l[0]) == m_atom.WM_TAKE_FOCUS) { XWindowAttributes attr; Window fwin; int revert_to; @@ -1524,7 +1525,7 @@ void GHOST_SystemX11::getClipboard_xcout(XEvent evt, } /* Send a selection request */ - XConvertSelection(m_display, sel, target, m_xclip_out, win, CurrentTime); + XConvertSelection(m_display, sel, target, m_atom.XCLIP_OUT, win, CurrentTime); *context = XCLIB_XCOUT_SENTCONVSEL; return; @@ -1532,28 +1533,28 @@ void GHOST_SystemX11::getClipboard_xcout(XEvent evt, if (evt.type != SelectionNotify) return; - if (target == m_utf8_string && evt.xselection.property == None) { + if (target == m_atom.UTF8_STRING && evt.xselection.property == None) { *context = XCLIB_XCOUT_FALLBACK_UTF8; return; } - else if (target == m_compound_text && evt.xselection.property == None) { + else if (target == m_atom.COMPOUND_TEXT && evt.xselection.property == None) { *context = XCLIB_XCOUT_FALLBACK_COMP; return; } - else if (target == m_text && evt.xselection.property == None) { + else if (target == m_atom.TEXT && evt.xselection.property == None) { *context = XCLIB_XCOUT_FALLBACK_TEXT; return; } /* find the size and format of the data in property */ - XGetWindowProperty(m_display, win, m_xclip_out, 0, 0, False, + XGetWindowProperty(m_display, win, m_atom.XCLIP_OUT, 0, 0, False, AnyPropertyType, &pty_type, &pty_format, &pty_items, &pty_size, &buffer); XFree(buffer); - if (pty_type == m_incr) { + if (pty_type == m_atom.INCR) { /* start INCR mechanism by deleting property */ - XDeleteProperty(m_display, win, m_xclip_out); + XDeleteProperty(m_display, win, m_atom.XCLIP_OUT); XFlush(m_display); *context = XCLIB_XCOUT_INCR; return; @@ -1568,12 +1569,12 @@ void GHOST_SystemX11::getClipboard_xcout(XEvent evt, } // not using INCR mechanism, just read the property - XGetWindowProperty(m_display, win, m_xclip_out, 0, (long) pty_size, + XGetWindowProperty(m_display, win, m_atom.XCLIP_OUT, 0, (long) pty_size, False, AnyPropertyType, &pty_type, &pty_format, &pty_items, &pty_size, &buffer); /* finished with property, delete it */ - XDeleteProperty(m_display, win, m_xclip_out); + XDeleteProperty(m_display, win, m_atom.XCLIP_OUT); /* copy the buffer to the pointer for returned data */ ltxt = (unsigned char *) malloc(pty_items); @@ -1606,7 +1607,7 @@ void GHOST_SystemX11::getClipboard_xcout(XEvent evt, return; /* check size and format of the property */ - XGetWindowProperty(m_display, win, m_xclip_out, 0, 0, False, + XGetWindowProperty(m_display, win, m_atom.XCLIP_OUT, 0, 0, False, AnyPropertyType, &pty_type, &pty_format, &pty_items, &pty_size, &buffer); @@ -1615,14 +1616,14 @@ void GHOST_SystemX11::getClipboard_xcout(XEvent evt, * to tell the other X client that we have read * it and to send the next property */ XFree(buffer); - XDeleteProperty(m_display, win, m_xclip_out); + XDeleteProperty(m_display, win, m_atom.XCLIP_OUT); return; } if (pty_size == 0) { /* no more data, exit from loop */ XFree(buffer); - XDeleteProperty(m_display, win, m_xclip_out); + XDeleteProperty(m_display, win, m_atom.XCLIP_OUT); *context = XCLIB_XCOUT_NONE; /* this means that an INCR transfer is now @@ -1634,7 +1635,7 @@ void GHOST_SystemX11::getClipboard_xcout(XEvent evt, /* if we have come this far, the property contains * text, we know the size. */ - XGetWindowProperty(m_display, win, m_xclip_out, 0, (long) pty_size, + XGetWindowProperty(m_display, win, m_atom.XCLIP_OUT, 0, (long) pty_size, False, AnyPropertyType, &pty_type, &pty_format, &pty_items, &pty_size, &buffer); @@ -1655,7 +1656,7 @@ void GHOST_SystemX11::getClipboard_xcout(XEvent evt, XFree(buffer); /* delete property to get the next item */ - XDeleteProperty(m_display, win, m_xclip_out); + XDeleteProperty(m_display, win, m_atom.XCLIP_OUT); XFlush(m_display); return; } @@ -1665,7 +1666,7 @@ void GHOST_SystemX11::getClipboard_xcout(XEvent evt, GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const { Atom sseln; - Atom target = m_utf8_string; + Atom target = m_atom.UTF8_STRING; Window owner; /* from xclip.c doOut() v0.11 */ @@ -1675,9 +1676,9 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const unsigned int context = XCLIB_XCOUT_NONE; if (selection == True) - sseln = m_primary; + sseln = m_atom.PRIMARY; else - sseln = m_clipboard; + sseln = m_atom.CLIPBOARD; vector & win_vec = m_windowManager->getWindows(); vector::iterator win_it = win_vec.begin(); @@ -1687,7 +1688,7 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const /* check if we are the owner. */ owner = XGetSelectionOwner(m_display, sseln); if (owner == win) { - if (sseln == m_clipboard) { + if (sseln == m_atom.CLIPBOARD) { sel_buf = (unsigned char *)malloc(strlen(txt_cut_buffer) + 1); strcpy((char *)sel_buf, txt_cut_buffer); return sel_buf; @@ -1712,19 +1713,19 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const /* fallback is needed. set XA_STRING to target and restart the loop. */ if (context == XCLIB_XCOUT_FALLBACK) { context = XCLIB_XCOUT_NONE; - target = m_string; + target = m_atom.STRING; continue; } else if (context == XCLIB_XCOUT_FALLBACK_UTF8) { /* utf8 fail, move to compouned text. */ context = XCLIB_XCOUT_NONE; - target = m_compound_text; + target = m_atom.COMPOUND_TEXT; continue; } else if (context == XCLIB_XCOUT_FALLBACK_COMP) { /* compouned text faile, move to text. */ context = XCLIB_XCOUT_NONE; - target = m_text; + target = m_atom.TEXT; continue; } @@ -1741,7 +1742,7 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const memcpy((char *)tmp_data, (char *)sel_buf, sel_len); tmp_data[sel_len] = '\0'; - if (sseln == m_string) + if (sseln == m_atom.STRING) XFree(sel_buf); else free(sel_buf); @@ -1762,8 +1763,8 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const if (buffer) { if (selection == False) { - XSetSelectionOwner(m_display, m_clipboard, m_window, CurrentTime); - owner = XGetSelectionOwner(m_display, m_clipboard); + XSetSelectionOwner(m_display, m_atom.CLIPBOARD, m_window, CurrentTime); + owner = XGetSelectionOwner(m_display, m_atom.CLIPBOARD); if (txt_cut_buffer) free((void *)txt_cut_buffer); @@ -1771,8 +1772,8 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const strcpy(txt_cut_buffer, buffer); } else { - XSetSelectionOwner(m_display, m_primary, m_window, CurrentTime); - owner = XGetSelectionOwner(m_display, m_primary); + XSetSelectionOwner(m_display, m_atom.PRIMARY, m_window, CurrentTime); + owner = XGetSelectionOwner(m_display, m_atom.PRIMARY); if (txt_select_buffer) free((void *)txt_select_buffer); @@ -1944,7 +1945,7 @@ void GHOST_SystemX11::initXInputDevices() if ((m_xtablet.StylusDevice == NULL) && - (is_stylus(device_info[i].name, device_type) || (device_info[i].type == m_xi_tablet))) + (is_stylus(device_info[i].name, device_type) || (device_info[i].type == m_atom.TABLET))) { // printf("\tfound stylus\n"); m_xtablet.StylusID = device_info[i].id; diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h index 69ae634bb25..a11aea240be 100644 --- a/intern/ghost/intern/GHOST_SystemX11.h +++ b/intern/ghost/intern/GHOST_SystemX11.h @@ -274,37 +274,6 @@ public: return 0; } - /** - * Atom used for ICCCM, WM-spec and Motif. - * We only need get this atom at the start, it's relative - * to the display not the window and are public for every - * window that need it. - */ - Atom m_wm_state; - Atom m_wm_change_state; - Atom m_net_state; - Atom m_net_max_horz; - Atom m_net_max_vert; - Atom m_net_fullscreen; - Atom m_motif; - Atom m_wm_take_focus; - Atom m_wm_protocols; - Atom m_delete_window_atom; - - /* Atoms for Selection, copy & paste. */ - Atom m_targets; - Atom m_string; - Atom m_compound_text; - Atom m_text; - Atom m_clipboard; - Atom m_primary; - Atom m_xclip_out; - Atom m_incr; - Atom m_utf8_string; -#ifdef WITH_X11_XINPUT - Atom m_xi_tablet; -#endif - #ifdef WITH_X11_XINPUT typedef struct GHOST_TabletX11 { XDevice *StylusDevice; @@ -326,6 +295,39 @@ public: } #endif // WITH_X11_XINPUT + struct { + /** + * Atom used for ICCCM, WM-spec and Motif. + * We only need get this atom at the start, it's relative + * to the display not the window and are public for every + * window that need it. + */ + Atom WM_STATE; + Atom WM_CHANGE_STATE; + Atom _NET_WM_STATE; + Atom _NET_WM_STATE_MAXIMIZED_HORZ; + Atom _NET_WM_STATE_MAXIMIZED_VERT; + Atom _NET_WM_STATE_FULLSCREEN; + Atom _MOTIF_WM_HINTS; + Atom WM_TAKE_FOCUS; + Atom WM_PROTOCOLS; + Atom WM_DELETE_WINDOW; + + /* Atoms for Selection, copy & paste. */ + Atom TARGETS; + Atom STRING; + Atom COMPOUND_TEXT; + Atom TEXT; + Atom CLIPBOARD; + Atom PRIMARY; + Atom XCLIP_OUT; + Atom INCR; + Atom UTF8_STRING; +#ifdef WITH_X11_XINPUT + Atom TABLET; +#endif + } m_atom; + private: Display *m_display; diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 7ef3a739b7e..50520b7eda5 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -395,16 +395,16 @@ GHOST_WindowX11( XFree(xclasshint); /* The basic for a good ICCCM "work" */ - if (m_system->m_wm_protocols) { + if (m_system->m_atom.WM_PROTOCOLS) { natom = 0; - if (m_system->m_delete_window_atom) { - atoms[natom] = m_system->m_delete_window_atom; + if (m_system->m_atom.WM_DELETE_WINDOW) { + atoms[natom] = m_system->m_atom.WM_DELETE_WINDOW; natom++; } - if (m_system->m_wm_take_focus) { - atoms[natom] = m_system->m_wm_take_focus; + if (m_system->m_atom.WM_TAKE_FOCUS) { + atoms[natom] = m_system->m_atom.WM_TAKE_FOCUS; natom++; } @@ -744,7 +744,7 @@ void GHOST_WindowX11::icccmSetState(int state) xev.xclient.display = m_display; xev.xclient.window = m_window; xev.xclient.format = 32; - xev.xclient.message_type = m_system->m_wm_change_state; + xev.xclient.message_type = m_system->m_atom.WM_CHANGE_STATE; xev.xclient.data.l[0] = state; XSendEvent(m_display, RootWindow(m_display, DefaultScreen(m_display)), False, SubstructureNotifyMask | SubstructureRedirectMask, &xev); @@ -758,8 +758,8 @@ int GHOST_WindowX11::icccmGetState(void) const int format_ret, st; prop_ret = NULL; - st = XGetWindowProperty(m_display, m_window, m_system->m_wm_state, 0, - 0x7fffffff, False, m_system->m_wm_state, &type_ret, + st = XGetWindowProperty(m_display, m_window, m_system->m_atom.WM_STATE, 0, + 0x7fffffff, False, m_system->m_atom.WM_STATE, &type_ret, &format_ret, &num_ret, &bytes_after, &prop_ret); if ((st == Success) && (prop_ret) && (num_ret == 2)) @@ -780,7 +780,7 @@ void GHOST_WindowX11::netwmMaximized(bool set) xev.xclient.serial = 0; xev.xclient.send_event = True; xev.xclient.window = m_window; - xev.xclient.message_type = m_system->m_net_state; + xev.xclient.message_type = m_system->m_atom._NET_WM_STATE; xev.xclient.format = 32; if (set == True) @@ -788,8 +788,8 @@ void GHOST_WindowX11::netwmMaximized(bool set) else xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE; - xev.xclient.data.l[1] = m_system->m_net_max_horz; - xev.xclient.data.l[2] = m_system->m_net_max_vert; + xev.xclient.data.l[1] = m_system->m_atom._NET_WM_STATE_MAXIMIZED_HORZ; + xev.xclient.data.l[2] = m_system->m_atom._NET_WM_STATE_MAXIMIZED_VERT; xev.xclient.data.l[3] = 0; xev.xclient.data.l[4] = 0; XSendEvent(m_display, RootWindow(m_display, DefaultScreen(m_display)), @@ -806,15 +806,15 @@ bool GHOST_WindowX11::netwmIsMaximized(void) const prop_ret = NULL; st = False; - ret = XGetWindowProperty(m_display, m_window, m_system->m_net_state, 0, + ret = XGetWindowProperty(m_display, m_window, m_system->m_atom._NET_WM_STATE, 0, 0x7fffffff, False, XA_ATOM, &type_ret, &format_ret, &num_ret, &bytes_after, &prop_ret); if ((ret == Success) && (prop_ret) && (format_ret == 32)) { count = 0; for (i = 0; i < num_ret; i++) { - if (((unsigned long *) prop_ret)[i] == m_system->m_net_max_horz) + if (((unsigned long *) prop_ret)[i] == m_system->m_atom._NET_WM_STATE_MAXIMIZED_HORZ) count++; - if (((unsigned long *) prop_ret)[i] == m_system->m_net_max_vert) + if (((unsigned long *) prop_ret)[i] == m_system->m_atom._NET_WM_STATE_MAXIMIZED_VERT) count++; if (count == 2) { st = True; @@ -836,7 +836,7 @@ void GHOST_WindowX11::netwmFullScreen(bool set) xev.xclient.serial = 0; xev.xclient.send_event = True; xev.xclient.window = m_window; - xev.xclient.message_type = m_system->m_net_state; + xev.xclient.message_type = m_system->m_atom._NET_WM_STATE; xev.xclient.format = 32; if (set == True) @@ -844,7 +844,7 @@ void GHOST_WindowX11::netwmFullScreen(bool set) else xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE; - xev.xclient.data.l[1] = m_system->m_net_fullscreen; + xev.xclient.data.l[1] = m_system->m_atom._NET_WM_STATE_FULLSCREEN; xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 0; xev.xclient.data.l[4] = 0; @@ -862,12 +862,12 @@ bool GHOST_WindowX11::netwmIsFullScreen(void) const prop_ret = NULL; st = False; - ret = XGetWindowProperty(m_display, m_window, m_system->m_net_state, 0, + ret = XGetWindowProperty(m_display, m_window, m_system->m_atom._NET_WM_STATE, 0, 0x7fffffff, False, XA_ATOM, &type_ret, &format_ret, &num_ret, &bytes_after, &prop_ret); if ((ret == Success) && (prop_ret) && (format_ret == 32)) { for (i = 0; i < num_ret; i++) { - if (((unsigned long *) prop_ret)[i] == m_system->m_net_fullscreen) { + if (((unsigned long *) prop_ret)[i] == m_system->m_atom._NET_WM_STATE_FULLSCREEN) { st = True; break; } @@ -889,8 +889,8 @@ void GHOST_WindowX11::motifFullScreen(bool set) else hints.decorations = 1; - XChangeProperty(m_display, m_window, m_system->m_motif, - m_system->m_motif, 32, PropModeReplace, + XChangeProperty(m_display, m_window, m_system->m_atom._MOTIF_WM_HINTS, + m_system->m_atom._MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) &hints, 4); } @@ -905,8 +905,8 @@ bool GHOST_WindowX11::motifIsFullScreen(void) const prop_ret = NULL; state = False; - st = XGetWindowProperty(m_display, m_window, m_system->m_motif, 0, - 0x7fffffff, False, m_system->m_motif, + st = XGetWindowProperty(m_display, m_window, m_system->m_atom._MOTIF_WM_HINTS, 0, + 0x7fffffff, False, m_system->m_atom._MOTIF_WM_HINTS, &type_ret, &format_ret, &num_ret, &bytes_after, &prop_ret); if ((st == Success) && (prop_ret)) { From 934fa91f75eaf5af46ed188dbf3ed50576acb81c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 09:40:33 +0000 Subject: [PATCH 033/157] patch [#34192] UTF-8 input in Python interactive console from Shinsuke Irie (irie) --- .../editors/space_console/console_draw.c | 6 ++--- .../editors/space_console/console_ops.c | 24 ++++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 22c260de1a1..c195cb39157 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -158,9 +158,9 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha if (tvc->iter_index == 0) { const SpaceConsole *sc = (SpaceConsole *)tvc->arg1; const ConsoleLine *cl = (ConsoleLine *)sc->history.last; - const int prompt_len = strlen(sc->prompt); - const int cursor_loc = cl->cursor + prompt_len; - const int line_len = cl->len + prompt_len; + const int prompt_len = BLI_strlen_utf8(sc->prompt); + const int cursor_loc = BLI_strnlen_utf8(cl->line, cl->cursor) + prompt_len; + const int line_len = BLI_strlen_utf8(cl->line) + prompt_len; int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN}; int pen[2]; xy[1] += tvc->lheight / 6; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 36716aeab95..5eed39a120e 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -36,6 +36,7 @@ #include "BLI_listbase.h" #include "BLI_string_cursor_utf8.h" +#include "BLI_string_utf8.h" #include "BLI_string.h" #include "BLI_dynstr.h" #include "BLI_utildefines.h" @@ -393,15 +394,26 @@ static int console_insert_invoke(bContext *C, wmOperator *op, wmEvent *event) { // if (!RNA_struct_property_is_set(op->ptr, "text")) { /* always set from keymap XXX */ if (!RNA_string_length(op->ptr, "text")) { - /* if alt/ctrl/super are pressed pass through */ - if (event->ctrl || event->oskey) { + /* if alt/ctrl/super are pressed pass through except for utf8 character event + * (when input method are used for utf8 inputs, the user may assign key event + * including alt/ctrl/super like ctrl+m to commit utf8 string. in such case, + * the modifiers in the utf8 character event make no sense.) */ + if ((event->ctrl || event->oskey) && !event->utf8_buf[0]) { return OPERATOR_PASS_THROUGH; } else { - char str[2]; - str[0] = event->ascii; - str[1] = '\0'; - + char str[BLI_UTF8_MAX + 1]; + size_t len; + + if (event->utf8_buf[0]) { + len = BLI_str_utf8_size_safe(event->utf8_buf); + memcpy(str, event->utf8_buf, len); + } + else { + /* in theory, ghost can set value to extended ascii here */ + len = BLI_str_utf8_from_unicode(event->ascii, str); + } + str[len] = '\0'; RNA_string_set(op->ptr, "text", str); } } From c1ca09b8c80a4fc063f7b804f68cd5c86db9f517 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 10:01:32 +0000 Subject: [PATCH 034/157] replace MEM_callocN with MEM_mallocN for events since their overwritten right after. --- source/blender/windowmanager/WM_api.h | 2 +- source/blender/windowmanager/intern/wm_event_system.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index e91d4f388af..a1437b70090 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -171,7 +171,7 @@ int WM_modal_tweak_exit(struct wmEvent *evt, int tweak_event); void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference); void WM_main_add_notifier(unsigned int type, void *reference); -void wm_event_add (struct wmWindow *win, struct wmEvent *event_to_add); /* XXX only for warning */ +void wm_event_add(struct wmWindow *win, const struct wmEvent *event_to_add); /* at maximum, every timestep seconds it triggers event_type events */ struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 0005c3a2230..3d510728684 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -91,9 +91,9 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA /* ************ event management ************** */ -void wm_event_add(wmWindow *win, wmEvent *event_to_add) +void wm_event_add(wmWindow *win, const wmEvent *event_to_add) { - wmEvent *event = MEM_callocN(sizeof(wmEvent), "wmEvent"); + wmEvent *event = MEM_mallocN(sizeof(wmEvent), "wmEvent"); *event = *event_to_add; From 3a192ca3591d0ed5a6356f791c86cbd2a3d0209a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 10:56:21 +0000 Subject: [PATCH 035/157] patch [#33697] Apply transformation added to metaballs. from Jesse Werner (vidjogamer), with own addition of RNA function, scale and rotation support. --- source/blender/editors/include/ED_mball.h | 4 +- source/blender/editors/metaball/mball_edit.c | 24 ++++++++ .../blender/editors/object/object_transform.c | 11 ++++ source/blender/makesrna/intern/CMakeLists.txt | 1 + source/blender/makesrna/intern/makesrna.c | 2 +- source/blender/makesrna/intern/rna_internal.h | 1 + source/blender/makesrna/intern/rna_meta.c | 2 + source/blender/makesrna/intern/rna_meta_api.c | 60 +++++++++++++++++++ 8 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 source/blender/makesrna/intern/rna_meta_api.c diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index 1321765588d..4655188a3dd 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -32,6 +32,7 @@ #define __ED_MBALL_H__ struct bContext; +struct MetaBall; struct Object; struct wmKeyConfig; @@ -48,5 +49,6 @@ void load_editMball(struct Object *obedit); void undo_push_mball(struct bContext *C, const char *name); -#endif +void ED_mball_transform(struct MetaBall *mb, float *mat); +#endif /* __ED_MBALL_H__ */ diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 8633a7a9b38..477a6dd815e 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -586,3 +586,27 @@ void undo_push_mball(bContext *C, const char *name) undo_editmode_push(C, name, get_data, free_undoMball, undoMball_to_editMball, editMball_to_undoMball, NULL); } +/* matrix is 4x4 */ +void ED_mball_transform(MetaBall *mb, float *mat) +{ + MetaElem *me; + float quat[4]; + const float scale = mat4_to_scale((float (*)[4])mat); + const float scale_sqrt = sqrtf(scale); + + mat4_to_quat(quat, (float (*)[4])mat); + + for (me = mb->elems.first; me; me = me->next) { + mul_m4_v3((float (*)[4])mat, &me->x); + mul_qt_qtqt(me->quat, quat, me->quat); + me->rad *= scale; + /* hrmf, probably elems shouldn't be + * treating scale differently - campbell */ + if (ELEM3(me->type, MB_CUBE, MB_PLANE, MB_TUBE)) { + mul_v3_fl(&me->expx, scale); + } + else { + mul_v3_fl(&me->expx, scale_sqrt); + } + } +} diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 68075e7b6f9..9dd34623739 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -67,6 +67,7 @@ #include "ED_armature.h" #include "ED_keyframing.h" +#include "ED_mball.h" #include "ED_mesh.h" #include "ED_screen.h" #include "ED_view3d.h" @@ -407,6 +408,12 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo change = 0; } } + else if (ob->type == OB_MBALL) { + if (ID_REAL_USERS(ob->data) > 1) { + BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user metaball, doing nothing"); + change = 0; + } + } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu; @@ -516,6 +523,10 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo bp++; } } + else if (ob->type == OB_MBALL) { + MetaBall *mb = ob->data; + ED_mball_transform(mb, (float *)mat); + } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu = ob->data; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 849c61f30b3..7b6fb30d692 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -105,6 +105,7 @@ set(APISRC rna_main_api.c rna_material_api.c rna_mesh_api.c + rna_meta_api.c rna_texture_api.c rna_object_api.c rna_pose_api.c diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index e1844faf6e9..96ca3805d3e 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3248,7 +3248,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_main.c", "rna_main_api.c", RNA_def_main}, {"rna_material.c", "rna_material_api.c", RNA_def_material}, {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh}, - {"rna_meta.c", NULL, RNA_def_meta}, + {"rna_meta.c", "rna_meta_api.c", RNA_def_meta}, {"rna_modifier.c", NULL, RNA_def_modifier}, {"rna_nla.c", NULL, RNA_def_nla}, {"rna_nodetree.c", NULL, RNA_def_nodetree}, diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index c1f5698016c..9161f7932e6 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -264,6 +264,7 @@ void RNA_api_keymapitems(struct StructRNA *srna); void RNA_api_main(struct StructRNA *srna); void RNA_api_material(StructRNA *srna); void RNA_api_mesh(struct StructRNA *srna); +void RNA_api_meta(struct StructRNA *srna); void RNA_api_object(struct StructRNA *srna); void RNA_api_object_base(struct StructRNA *srna); void RNA_api_pose(struct StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 08eefc082bf..4813f25dea7 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -351,6 +351,8 @@ static void rna_def_metaball(BlenderRNA *brna) /* anim */ rna_def_animdata_common(srna); + + RNA_api_meta(srna); } void RNA_def_meta(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_meta_api.c b/source/blender/makesrna/intern/rna_meta_api.c new file mode 100644 index 00000000000..500e202b16f --- /dev/null +++ b/source/blender/makesrna/intern/rna_meta_api.c @@ -0,0 +1,60 @@ +/* + * ***** 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) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_meta_api.c + * \ingroup RNA + */ + + +#include +#include + +#include "RNA_define.h" + +#include "BLO_sys_types.h" + +#include "BLI_utildefines.h" + +#include "ED_mball.h" + +#include "rna_internal.h" /* own include */ + +#ifdef RNA_RUNTIME +/* none */ +#else + +void RNA_api_meta(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func = RNA_def_function(srna, "transform", "ED_mball_transform"); + RNA_def_function_ui_description(func, "Transform meta elements by a matrix"); + parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f); + RNA_def_property_flag(parm, PROP_REQUIRED); +} + +#endif From 9d6210c0ed60301b618d3248ed906ff51935c39f Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Mon, 11 Feb 2013 11:12:44 +0000 Subject: [PATCH 036/157] Collada Importer: Some code cleanup and optimization of the rescale function --- source/blender/collada/collada_utils.cpp | 29 ++++++++++++------------ source/blender/editors/io/io_collada.c | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 13403555bfb..3e2d1795528 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -307,13 +307,13 @@ std::string bc_replace_string(std::string data, const std::string& pattern, /** Calculate a rescale factor such that the imported scene's scale is preserved. I.e. 1 meter in the import will also be - 1 meter in the curretn scene. + 1 meter in the current scene. XXX : I am not sure if it is correct to map 1 Blender Unit to 1 Meter for unit type NONE. But it looks reasonable to me. */ void bc_match_scale(std::vector *objects_done, Scene &sce, - UnitConverter &unit_converter) { + UnitConverter &bc_unit) { Object *ob = NULL; @@ -333,34 +333,33 @@ void bc_match_scale(std::vector *objects_done, case USER_UNIT_NONE: bl_scale = 1.0; // map 1 Blender unit to 1 Meter break; + case USER_UNIT_METRIC: bl_scale = RNA_property_float_get(&unit_settings, scale_ptr); break; - default: + + default : bl_scale = RNA_property_float_get(&unit_settings, scale_ptr); // it looks like the conversion to Imperial is done implicitly. // So nothing to do here. break; } - float size_mat3[3][3]; - float size_mat4[4][4]; - - float scale_conv = unit_converter.getLinearMeter() / bl_scale; + float scale_conv = bc_unit.getLinearMeter() / bl_scale; float rescale[3]; rescale[0] = rescale[1] = rescale[2] = scale_conv; - size_to_mat3(size_mat3, rescale); - copy_m4_m3(size_mat4, size_mat3); + float size_mat4[4][4]; + size_to_mat4(size_mat4, rescale); - for (std::vector::iterator it = objects_done->begin(); it != objects_done->end(); ++it) { + for (std::vector::iterator it = objects_done->begin(); + it != objects_done->end(); + ++it) + { ob = *it; - mult_m4_m4m4(ob->obmat, ob->obmat, size_mat4); - ob->obmat[3][0] = ob->loc[0] * rescale[0]; - ob->obmat[3][1] = ob->loc[1] * rescale[1]; - ob->obmat[3][2] = ob->loc[2] * rescale[2]; + mult_m4_m4m4(ob->obmat, size_mat4, ob->obmat); BKE_object_apply_mat4(ob, ob->obmat, 0, 0); } -} +} \ No newline at end of file diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 2003aeaa848..ca74d7aea57 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -319,7 +319,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) import_units = RNA_boolean_get(op->ptr, "import_units"); RNA_string_get(op->ptr, "filepath", filename); - if (collada_import( C, filename, import_units)) { + if (collada_import(C, filename, import_units)) { return OPERATOR_FINISHED; } else { From c4d248cc766efcbd57719e5ab9c4b2c4c0200c64 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 11 Feb 2013 12:25:54 +0000 Subject: [PATCH 037/157] Fix #34194: Render Layer node didn't initialize color management flag properly Bang! How we didn't notice this for so long -- seems scenes came from render layer node were rendering as if color management disabled (byte image wouldn't be linearized). --- source/blender/render/intern/source/pipeline.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index d2b47a7bf4d..e1024163953 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1322,6 +1322,7 @@ static void render_scene(Render *re, Scene *sce, int cfra) resc->main = re->main; resc->scene = sce; resc->lay = sce->lay; + resc->scene_color_manage = BKE_scene_check_color_management_enabled(sce); /* ensure scene has depsgraph, base flags etc OK */ BKE_scene_set_background(re->main, sce); From 0e0ea1f3052d006a299214dce26f56543c06c702 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Mon, 11 Feb 2013 12:41:57 +0000 Subject: [PATCH 038/157] Fix building with blenderplayer Add ED_mball_transform() to stubs. --- source/blenderplayer/bad_level_call_stubs/stubs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 82749ec041a..36068b01133 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -373,6 +373,8 @@ int ED_space_image_check_show_maskedit(struct Scene *scene, struct SpaceImage *s void ED_nurb_set_spline_type(struct Nurb *nu, int type) {} +void ED_mball_transform(struct MetaBall *mb, float *mat) {} + void make_editLatt(struct Object *obedit) {} void load_editLatt(struct Object *obedit) {} From 30a18589e20206cee8ec5d7e54fcdce82feb09a7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 13:07:26 +0000 Subject: [PATCH 039/157] fix [#34200] Metaball Tessellate error --- source/blender/blenkernel/intern/mball.c | 60 +++++++++----------- source/blender/editors/metaball/mball_edit.c | 2 +- source/blender/makesdna/DNA_meta_types.h | 2 + 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index d939b9cc3c0..867249c97dd 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1654,6 +1654,14 @@ static void polygonize(PROCESS *mbproc, MetaBall *mb) } } +/* could move to math api */ +BLI_INLINE void copy_v3_fl3(float v[3], float x, float y, float z) +{ + v[0] = x; + v[1] = y; + v[2] = z; +} + static float init_meta(Scene *scene, Object *ob) /* return totsize */ { Scene *sce_iter = scene; @@ -1730,6 +1738,7 @@ static float init_meta(Scene *scene, Object *ob) /* return totsize */ float temp1[4][4], temp2[4][4], temp3[4][4]; float (*mat)[4] = NULL, (*imat)[4] = NULL; float max_x, max_y, max_z, min_x, min_y, min_z; + float expx, expy, expz; max_x = max_y = max_z = -3.4e38; min_x = min_y = min_z = 3.4e38; @@ -1770,39 +1779,26 @@ static float init_meta(Scene *scene, Object *ob) /* return totsize */ G_mb.mainb[a]->mat = (float *) mat; G_mb.mainb[a]->imat = (float *) imat; + if (!MB_TYPE_SIZE_SQUARED(ml->type)) { + expx = ml->expx; + expy = ml->expy; + expz = ml->expz; + } + else { + expx = ml->expx * ml->expx; + expy = ml->expy * ml->expy; + expz = ml->expz * ml->expz; + } + /* untransformed Bounding Box of MetaElem */ - /* 0 */ - G_mb.mainb[a]->bb->vec[0][0] = -ml->expx; - G_mb.mainb[a]->bb->vec[0][1] = -ml->expy; - G_mb.mainb[a]->bb->vec[0][2] = -ml->expz; - /* 1 */ - G_mb.mainb[a]->bb->vec[1][0] = ml->expx; - G_mb.mainb[a]->bb->vec[1][1] = -ml->expy; - G_mb.mainb[a]->bb->vec[1][2] = -ml->expz; - /* 2 */ - G_mb.mainb[a]->bb->vec[2][0] = ml->expx; - G_mb.mainb[a]->bb->vec[2][1] = ml->expy; - G_mb.mainb[a]->bb->vec[2][2] = -ml->expz; - /* 3 */ - G_mb.mainb[a]->bb->vec[3][0] = -ml->expx; - G_mb.mainb[a]->bb->vec[3][1] = ml->expy; - G_mb.mainb[a]->bb->vec[3][2] = -ml->expz; - /* 4 */ - G_mb.mainb[a]->bb->vec[4][0] = -ml->expx; - G_mb.mainb[a]->bb->vec[4][1] = -ml->expy; - G_mb.mainb[a]->bb->vec[4][2] = ml->expz; - /* 5 */ - G_mb.mainb[a]->bb->vec[5][0] = ml->expx; - G_mb.mainb[a]->bb->vec[5][1] = -ml->expy; - G_mb.mainb[a]->bb->vec[5][2] = ml->expz; - /* 6 */ - G_mb.mainb[a]->bb->vec[6][0] = ml->expx; - G_mb.mainb[a]->bb->vec[6][1] = ml->expy; - G_mb.mainb[a]->bb->vec[6][2] = ml->expz; - /* 7 */ - G_mb.mainb[a]->bb->vec[7][0] = -ml->expx; - G_mb.mainb[a]->bb->vec[7][1] = ml->expy; - G_mb.mainb[a]->bb->vec[7][2] = ml->expz; + copy_v3_fl3(G_mb.mainb[a]->bb->vec[0], -expx, -expy, -expz); /* 0 */ + copy_v3_fl3(G_mb.mainb[a]->bb->vec[1], +expx, -expy, -expz); /* 1 */ + copy_v3_fl3(G_mb.mainb[a]->bb->vec[2], +expx, +expy, -expz); /* 2 */ + copy_v3_fl3(G_mb.mainb[a]->bb->vec[3], -expx, +expy, -expz); /* 3 */ + copy_v3_fl3(G_mb.mainb[a]->bb->vec[4], -expx, -expy, +expz); /* 4 */ + copy_v3_fl3(G_mb.mainb[a]->bb->vec[5], +expx, -expy, +expz); /* 5 */ + copy_v3_fl3(G_mb.mainb[a]->bb->vec[5], +expx, +expy, +expz); /* 6 */ + copy_v3_fl3(G_mb.mainb[a]->bb->vec[5], -expx, +expy, +expz); /* 7 */ /* transformation of Metalem bb */ for (i = 0; i < 8; i++) diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 477a6dd815e..6c056df5a38 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -602,7 +602,7 @@ void ED_mball_transform(MetaBall *mb, float *mat) me->rad *= scale; /* hrmf, probably elems shouldn't be * treating scale differently - campbell */ - if (ELEM3(me->type, MB_CUBE, MB_PLANE, MB_TUBE)) { + if (!MB_TYPE_SIZE_SQUARED(me->type)) { mul_v3_fl(&me->expx, scale); } else { diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h index 5b37ff523cb..56683bf4797 100644 --- a/source/blender/makesdna/DNA_meta_types.h +++ b/source/blender/makesdna/DNA_meta_types.h @@ -121,6 +121,8 @@ typedef struct MetaBall { #define MB_ELIPSOID 6 #define MB_CUBE 7 +#define MB_TYPE_SIZE_SQUARED(type) (type == MB_ELIPSOID) + /* ml->flag */ #define MB_NEGATIVE 2 #define MB_HIDE 8 From 7fcc1ac48b405f8f6ef0ab7b7cd3dba1f5c6b24d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 11 Feb 2013 13:24:35 +0000 Subject: [PATCH 040/157] Implemented delayed partial rect update for image buffers Used by image painting mode, so every brush step would mark area if affected on, but actual color space conversion would happen later when actually displaying image. Implemented as a rcti stored in ImBuf which is getting merged with partial rect passed to IMB_partial_display_buffer_update_delayed. This makes painting as fast as it currently possible and finally solves #33935: Texture painting slow down with mouse, but not with tablet --- .../editors/sculpt_paint/paint_image.c | 21 +++++++--------- source/blender/imbuf/IMB_colormanagement.h | 2 ++ source/blender/imbuf/IMB_imbuf_types.h | 3 +++ source/blender/imbuf/intern/colormanagement.c | 25 +++++++++++++++++++ 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a1b3941dd7a..b9b3b1da762 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -140,7 +140,7 @@ BLI_INLINE unsigned char f_to_char(const float val) #define IMAPAINT_TILE_SIZE (1 << IMAPAINT_TILE_BITS) #define IMAPAINT_TILE_NUMBER(size) (((size) + IMAPAINT_TILE_SIZE - 1) >> IMAPAINT_TILE_BITS) -static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint); +static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint); typedef struct ImagePaintState { @@ -3656,7 +3656,7 @@ static int project_image_refresh_tagged(ProjPaintState *ps) pr = &(projIma->partRedrawRect[i]); if (pr->x2 != -1) { /* TODO - use 'enabled' ? */ imapaintpartial = *pr; - imapaint_image_update(NULL, NULL, projIma->ima, projIma->ibuf, 1); /*last 1 is for texpaint*/ + imapaint_image_update(NULL, projIma->ima, projIma->ibuf, 1); /*last 1 is for texpaint*/ redraw = 1; } } @@ -4417,16 +4417,13 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, IMB_freeImBuf(tmpibuf); } -static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint) +static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint) { - if (scene) { - IMB_partial_display_buffer_update(ibuf, ibuf->rect_float, (unsigned char *) ibuf->rect, ibuf->x, 0, 0, - &scene->view_settings, &scene->display_settings, - imapaintpartial.x1, imapaintpartial.y1, - imapaintpartial.x2, imapaintpartial.y2, FALSE); - } - else { - ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + if (imapaintpartial.x1 != imapaintpartial.x2 && + imapaintpartial.y1 != imapaintpartial.y2) + { + IMB_partial_display_buffer_update_delayed(ibuf, imapaintpartial.x1, imapaintpartial.y1, + imapaintpartial.x2, imapaintpartial.y2); } if (ibuf->mipmap[0]) @@ -4790,7 +4787,7 @@ static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, */ if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, is_data == FALSE)) { if (update) - imapaint_image_update(s->scene, s->sima, image, ibuf, texpaint); + imapaint_image_update(s->sima, image, ibuf, texpaint); BKE_image_release_ibuf(image, ibuf, NULL); return 1; } diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h index 1e33f8da363..a05f0d5b3e6 100644 --- a/source/blender/imbuf/IMB_colormanagement.h +++ b/source/blender/imbuf/IMB_colormanagement.h @@ -133,6 +133,8 @@ void IMB_partial_display_buffer_update(struct ImBuf *ibuf, const float *linear_b int xmin, int ymin, int xmax, int ymax, int update_orig_byte_buffer); +void IMB_partial_display_buffer_update_delayed(struct ImBuf *ibuf, int xmin, int ymin, int xmax, int ymax); + /* ** Pixel processor functions ** */ struct ColormanageProcessor *IMB_colormanagement_display_processor_new(const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings); diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index e30f1618c81..dde8d4d4ab7 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -28,6 +28,8 @@ #ifndef __IMB_IMBUF_TYPES_H__ #define __IMB_IMBUF_TYPES_H__ +#include "DNA_vec_types.h" /* for rcti */ + /** * \file IMB_imbuf_types.h * \ingroup imbuf @@ -132,6 +134,7 @@ typedef struct ImBuf { unsigned int *display_buffer_flags; /* array of per-display display buffers dirty flags */ struct ColormanageCache *colormanage_cache; /* cache used by color management */ int colormanage_flag; + rcti invalid_rect; /* information for compressed textures */ struct DDSData dds_data; diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index a516812eb53..ff297d70cc3 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -57,6 +57,7 @@ #include "BLI_path_util.h" #include "BLI_string.h" #include "BLI_threads.h" +#include "BLI_rect.h" #include "BKE_colortools.h" #include "BKE_context.h" @@ -1823,6 +1824,18 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet colormanage_view_settings_to_cache(&cache_view_settings, applied_view_settings); colormanage_display_settings_to_cache(&cache_display_settings, display_settings); + if (ibuf->invalid_rect.xmin != ibuf->invalid_rect.xmax) { + if ((ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) == 0) { + IMB_partial_display_buffer_update(ibuf, ibuf->rect_float, (unsigned char *) ibuf->rect, + ibuf->x, 0, 0, applied_view_settings, display_settings, + ibuf->invalid_rect.xmin, ibuf->invalid_rect.ymin, + ibuf->invalid_rect.xmax, ibuf->invalid_rect.ymax, + FALSE); + } + + BLI_rcti_init(&ibuf->invalid_rect, 0, 0, 0, 0); + } + BLI_lock_thread(LOCK_COLORMANAGE); /* ensure color management bit fields exists */ @@ -2488,6 +2501,18 @@ void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer, } } +void IMB_partial_display_buffer_update_delayed(ImBuf *ibuf, int xmin, int ymin, int xmax, int ymax) +{ + if (ibuf->invalid_rect.xmin == ibuf->invalid_rect.xmax) { + BLI_rcti_init(&ibuf->invalid_rect, xmin, xmax, ymin, ymax); + } + else { + rcti rect; + BLI_rcti_init(&rect, xmin, xmax, ymin, ymax); + BLI_rcti_union(&ibuf->invalid_rect, &rect); + } +} + /*********************** Pixel processor functions *************************/ ColormanageProcessor *IMB_colormanagement_display_processor_new(const ColorManagedViewSettings *view_settings, From 16477259137f0e349cb9f51217543000c0ccf4c7 Mon Sep 17 00:00:00 2001 From: Miika Hamalainen Date: Mon, 11 Feb 2013 13:28:18 +0000 Subject: [PATCH 041/157] Fix: smoke simulator flow sometimes produced NaN values, causing fire to disappear from the simulation. --- source/blender/blenkernel/intern/smoke.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index f56d03bfb57..d26339680c8 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1583,7 +1583,7 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value } /* set fire reaction coordinate */ - if (fuel && fuel[index]) { + if (fuel && fuel[index] > FLT_EPSILON) { /* instead of using 1.0 for all new fuel add slight falloff * to reduce flow blockiness */ float value = 1.0f - powf(1.0f - emission_value, 2.0f); From 6888d6eac828689b8a9fb96f5b4f80f45be8301a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 11 Feb 2013 13:39:22 +0000 Subject: [PATCH 042/157] Buildbot: switch to using native toolkit again Crosscompiling of cubins doesn't work on linux with toolkit 4.2, so use native toolkit for now. Disabled sm_13 for 32bit platform for now. Would keep cudakernels build target for a while. It doesn't hurt being in the code and it could be helpful again once we'll switch to toolkit 5.x where crosscompilation works fine. Some further tweaks could probably be needed still, let's see how building goes on buildbot now :) --- build_files/buildbot/config/user-config-glibc211-i686.py | 4 +++- build_files/buildbot/config/user-config-glibc211-x86_64.py | 3 ++- build_files/buildbot/slave_compile.py | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/build_files/buildbot/config/user-config-glibc211-i686.py b/build_files/buildbot/config/user-config-glibc211-i686.py index 540416ee1fb..b2dcd40bff0 100644 --- a/build_files/buildbot/config/user-config-glibc211-i686.py +++ b/build_files/buildbot/config/user-config-glibc211-i686.py @@ -110,7 +110,9 @@ BF_JACK_LIB_STATIC = '${BF_ZLIB}/lib/libjack.a' # Cycles WITH_BF_CYCLES = True -WITH_BF_CYCLES_CUDA_BINARIES = False +WITH_BF_CYCLES_CUDA_BINARIES = True +#BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21', 'sm_30'] +BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30'] WITH_BF_OIIO = True WITH_BF_STATICOIIO = True diff --git a/build_files/buildbot/config/user-config-glibc211-x86_64.py b/build_files/buildbot/config/user-config-glibc211-x86_64.py index c0ba8060712..edd9500d88d 100644 --- a/build_files/buildbot/config/user-config-glibc211-x86_64.py +++ b/build_files/buildbot/config/user-config-glibc211-x86_64.py @@ -110,7 +110,8 @@ BF_JACK_LIB_STATIC = '${BF_ZLIB}/lib/libjack.a' # Cycles WITH_BF_CYCLES = True -WITH_BF_CYCLES_CUDA_BINARIES = False +WITH_BF_CYCLES_CUDA_BINARIES = True +BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21', 'sm_30'] WITH_BF_OIIO = True WITH_BF_STATICOIIO = True diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index dab8a8e6483..ae9a84ab22c 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -63,14 +63,14 @@ else: configs = [] if builder.endswith('linux_glibc211_x86_64_scons'): configs = ['user-config-player-glibc211-x86_64.py', - 'user-config-cuda-glibc211-x86_64.py', + #'user-config-cuda-glibc211-x86_64.py', 'user-config-glibc211-x86_64.py' ] chroot_name = 'buildbot_squeeze_x86_64' cuda_chroot = 'buildbot_squeeze_x86_64' elif builder.endswith('linux_glibc211_i386_scons'): configs = ['user-config-player-glibc211-i686.py', - 'user-config-cuda-glibc211-i686.py', + #'user-config-cuda-glibc211-i686.py', 'user-config-glibc211-i686.py'] chroot_name = 'buildbot_squeeze_i686' From eb723ad5554359fca8974fc33ac45b4a66ac3f30 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 11 Feb 2013 13:44:18 +0000 Subject: [PATCH 043/157] Buildbot: -WITHOUT_BF_OVERWRITE_INSTALL should not be needed now --- build_files/buildbot/config/user-config-glibc211-i686.py | 1 - build_files/buildbot/config/user-config-glibc211-x86_64.py | 1 - 2 files changed, 2 deletions(-) diff --git a/build_files/buildbot/config/user-config-glibc211-i686.py b/build_files/buildbot/config/user-config-glibc211-i686.py index b2dcd40bff0..97c55cafbe9 100644 --- a/build_files/buildbot/config/user-config-glibc211-i686.py +++ b/build_files/buildbot/config/user-config-glibc211-i686.py @@ -1,7 +1,6 @@ BF_BUILDDIR = '../blender-build/linux-glibc211-i686' BF_INSTALLDIR = '../blender-install/linux-glibc211-i686' BF_NUMJOBS = 4 -WITHOUT_BF_OVERWRITE_INSTALL = True # Python configuration BF_PYTHON_VERSION = '3.3' diff --git a/build_files/buildbot/config/user-config-glibc211-x86_64.py b/build_files/buildbot/config/user-config-glibc211-x86_64.py index edd9500d88d..1d43670b31d 100644 --- a/build_files/buildbot/config/user-config-glibc211-x86_64.py +++ b/build_files/buildbot/config/user-config-glibc211-x86_64.py @@ -1,7 +1,6 @@ BF_BUILDDIR = '../blender-build/linux-glibc211-x86_64' BF_INSTALLDIR = '../blender-install/linux-glibc211-x86_64' BF_NUMJOBS = 4 -WITHOUT_BF_OVERWRITE_INSTALL = True # Python configuration BF_PYTHON_VERSION = '3.3' From 203301e26ed193968fa026b63c15f0a4c6accfc9 Mon Sep 17 00:00:00 2001 From: Miika Hamalainen Date: Mon, 11 Feb 2013 15:03:22 +0000 Subject: [PATCH 044/157] Additional smoke fix for r54464: floating point precision still sometimes produced way too high values. Now values are also clamped within correct range. --- source/blender/blenkernel/intern/smoke.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index d26339680c8..248cd689258 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1591,6 +1591,7 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value if (value > react[index]) { float f = fuel_flow / fuel[index]; react[index] = value * f + (1.0f - f) * react[index]; + CLAMP(react[index], 0.0f, value); } } } From 5da828317a5e93e282a55a05630de54befa7e4c5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 15:35:38 +0000 Subject: [PATCH 045/157] error in own recent commit --- source/blender/blenkernel/intern/mball.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 867249c97dd..5cc3145213c 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1791,14 +1791,15 @@ static float init_meta(Scene *scene, Object *ob) /* return totsize */ } /* untransformed Bounding Box of MetaElem */ + /* TODO, its possible the elem type has been changed and the exp* values can use a fallback */ copy_v3_fl3(G_mb.mainb[a]->bb->vec[0], -expx, -expy, -expz); /* 0 */ copy_v3_fl3(G_mb.mainb[a]->bb->vec[1], +expx, -expy, -expz); /* 1 */ copy_v3_fl3(G_mb.mainb[a]->bb->vec[2], +expx, +expy, -expz); /* 2 */ copy_v3_fl3(G_mb.mainb[a]->bb->vec[3], -expx, +expy, -expz); /* 3 */ copy_v3_fl3(G_mb.mainb[a]->bb->vec[4], -expx, -expy, +expz); /* 4 */ copy_v3_fl3(G_mb.mainb[a]->bb->vec[5], +expx, -expy, +expz); /* 5 */ - copy_v3_fl3(G_mb.mainb[a]->bb->vec[5], +expx, +expy, +expz); /* 6 */ - copy_v3_fl3(G_mb.mainb[a]->bb->vec[5], -expx, +expy, +expz); /* 7 */ + copy_v3_fl3(G_mb.mainb[a]->bb->vec[6], +expx, +expy, +expz); /* 6 */ + copy_v3_fl3(G_mb.mainb[a]->bb->vec[7], -expx, +expy, +expz); /* 7 */ /* transformation of Metalem bb */ for (i = 0; i < 8; i++) From a867fbf02614892aaccbe610c4e2542dc01e1415 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 15:43:09 +0000 Subject: [PATCH 046/157] check for divide by zero for dynamic paint modifier. --- source/blender/blenkernel/intern/dynamicpaint.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index c92c52a7651..685d66195c7 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2379,7 +2379,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) dot11 = d2[0] * d2[0] + d2[1] * d2[1]; dot12 = d2[0] * d3[0] + d2[1] * d3[1]; - invDenom = 1 / (dot00 * dot11 - dot01 * dot01); + invDenom = (dot00 * dot11 - dot01 * dot01); + invDenom = invDenom ? 1.0f / invDenom : 1.0f; u = (dot11 * dot02 - dot01 * dot12) * invDenom; v = (dot00 * dot12 - dot01 * dot02) * invDenom; @@ -2399,7 +2400,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) dot11 = d2[0] * d2[0] + d2[1] * d2[1]; dot12 = d2[0] * d3[0] + d2[1] * d3[1]; - invDenom = 1 / (dot00 * dot11 - dot01 * dot01); + invDenom = (dot00 * dot11 - dot01 * dot01); + invDenom = invDenom ? 1.0f / invDenom : 1.0f; u = (dot11 * dot02 - dot01 * dot12) * invDenom; v = (dot00 * dot12 - dot01 * dot02) * invDenom; From 7c5e72460af9fcf0a58a5c38cbc2d0e889cf3c94 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 15:48:43 +0000 Subject: [PATCH 047/157] fix [#34169] dynamic paint bake from python + command line = segfault --- source/blender/editors/physics/dynamicpaint_ops.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index c51b3ca4c43..ecc7ea4ae00 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -304,7 +304,9 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf if (blender_test_break()) return 0; /* Update progress bar cursor */ - WM_cursor_time(win, (int)progress); + if (!G.background) { + WM_cursor_time(win, (int)progress); + } /* calculate a frame */ scene->r.cfra = (int)frame; @@ -346,6 +348,7 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf */ static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op) { + wmWindow *win = CTX_wm_window(C); DynamicPaintModifierData *pmd = NULL; DynamicPaintCanvasSettings *canvas; Object *ob = ED_object_context(C); @@ -379,7 +382,9 @@ static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op) status = dynamicPaint_bakeImageSequence(C, surface, ob); /* Clear bake */ canvas->flags &= ~MOD_DPAINT_BAKING; - WM_cursor_restore(CTX_wm_window(C)); + if (!G.background) { + WM_cursor_restore(win); + } dynamicPaint_freeSurfaceData(surface); /* Bake was successful: From 1a8dcbcb4fe9686c641167fca3b880803859c5c4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Feb 2013 16:22:20 +0000 Subject: [PATCH 048/157] quiet -Wnarrowing warning. --- intern/smoke/intern/FFT_NOISE.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intern/smoke/intern/FFT_NOISE.h b/intern/smoke/intern/FFT_NOISE.h index 8b7e4f2728b..0d8be7db602 100644 --- a/intern/smoke/intern/FFT_NOISE.h +++ b/intern/smoke/intern/FFT_NOISE.h @@ -94,9 +94,9 @@ static void generatTile_FFT(float* const noiseTileData, std::string filename) for (int x = 0; x < xRes; x++) { int index = x + y * xRes + z * xRes * yRes; - float diff[] = {abs(x - xRes/2), - abs(y - yRes/2), - abs(z - zRes/2)}; + float diff[] = {(float)abs(x - xRes / 2), + (float)abs(y - yRes / 2), + (float)abs(z - zRes / 2)}; float radius = sqrtf(diff[0] * diff[0] + diff[1] * diff[1] + diff[2] * diff[2]) / (xRes / 2); From 8997e5ae0676382b7f2afb59d04819f4c926a330 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 11 Feb 2013 18:29:19 +0000 Subject: [PATCH 049/157] BGE: Fix for issue #32606 "Raycasts are locked to the scene of calling object" reported by Josiah Lane (solarlune). The raycasting functions were using the active scene instead of the object's scene. --- source/gameengine/Ketsji/KX_GameObject.cpp | 18 ++++++++++++------ source/gameengine/Ketsji/KX_GameObject.h | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 63854c6aebd..3a60ccc85e9 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1400,6 +1400,14 @@ CListValue* KX_GameObject::GetChildrenRecursive() return list; } +KX_Scene* KX_GameObject::GetScene() +{ + SG_Node* node = this->GetSGNode(); + KX_Scene* scene = static_cast(node->GetSGClientInfo()); + + return scene; +} + /* --------------------------------------------------------------------- * Some stuff taken from the header * --------------------------------------------------------------------- */ @@ -1754,8 +1762,7 @@ PyObject *KX_GameObject::PyReplaceMesh(PyObject *args) PyObject *KX_GameObject::PyEndObject() { - SG_Node* node = this->GetSGNode(); - KX_Scene* scene = static_cast(node->GetSGClientInfo()); + KX_Scene* scene = GetScene(); scene->DelayedRemoveObject(this); @@ -2003,8 +2010,7 @@ PyObject *KX_GameObject::pyattr_get_group_members(void *self_v, const KX_PYATTRI PyObject* KX_GameObject::pyattr_get_scene(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject *self = static_cast(self_v); - SG_Node *node = self->GetSGNode(); - KX_Scene *scene = static_cast(node->GetSGClientInfo()); + KX_Scene *scene = self->GetScene(); if (scene) { return scene->GetProxy(); } @@ -3056,7 +3062,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, if (dist != 0.0f) toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized(); - PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); + PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment(); KX_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); if (!spc && parent) @@ -3202,7 +3208,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, return none_tuple_3(); } - PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); + PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment(); KX_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); if (!spc && parent) diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 253b5e26ebe..86c712ea017 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -923,6 +923,8 @@ public: CListValue* GetChildren(); CListValue* GetChildrenRecursive(); + KX_Scene* GetScene(); + #ifdef WITH_PYTHON /** * \section Python interface functions. From b063bdbb5ff78b484d60f5ac517d126c244f0235 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 11 Feb 2013 18:47:06 +0000 Subject: [PATCH 050/157] Please stop adding points in tooltips, unless it is absolutely necessary! Commas, parenthesis, en quads, etc., do exist! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I took time to add basics about our UI messages conventions in blender code style guide (http://wiki.blender.org/index.php/Dev:Doc/CodeStyle#UI_Messages), so I’d like to stop wasting time over such stupid things. Especially when I alredy did it one day ago! --- source/blender/editors/io/io_collada.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index ca74d7aea57..7703a8638c9 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -368,8 +368,8 @@ void WM_OT_collada_import(wmOperatorType *ot) RNA_def_boolean(ot->srna, "import_units", 0, "Import Units", - "If disabled match import to Blender's current Unit settings. " - "Otherwise use the settings from the Imported scene"); + "If disabled match import to Blender's current Unit settings, " + "otherwise use the settings from the Imported scene"); } #endif From 3dfd736d456c79d8ab7c517e68e990040555d223 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Mon, 11 Feb 2013 20:21:10 +0000 Subject: [PATCH 051/157] Fix: Collada Import of armatures only added the root bone --- source/blender/collada/DocumentImporter.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 88a67eebe9d..52dd587231d 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -583,11 +583,16 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA } // if node has child nodes write them COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes(); + if (objects_done->size() > 0) { ob = *objects_done->begin(); - for (unsigned int i = 0; i < child_nodes.getCount(); i++) { - write_node(child_nodes[i], node, sce, ob, is_library_node); - } + } + else { + ob = NULL; + } + + for (unsigned int i = 0; i < child_nodes.getCount(); i++) { + write_node(child_nodes[i], node, sce, ob, is_library_node); } return objects_done; From 1c4f704d5c6385c891057404fab462b5cc8121df Mon Sep 17 00:00:00 2001 From: Miika Hamalainen Date: Mon, 11 Feb 2013 20:22:47 +0000 Subject: [PATCH 052/157] Smoke simulator: add more float precision checks to make sure other data types don't get messed up either. (Relating previous fire fixes) --- intern/smoke/intern/FLUID_3D.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp index a1d39286a90..5f0b2439200 100644 --- a/intern/smoke/intern/FLUID_3D.cpp +++ b/intern/smoke/intern/FLUID_3D.cpp @@ -1654,7 +1654,7 @@ void FLUID_3D::processBurn(float *fuel, float *smoke, float *react, float *flame fuel[index] -= burning_rate * dt; if (fuel[index] < 0.0f) fuel[index] = 0.0f; /* process reaction coordinate */ - if (orig_fuel) { + if (orig_fuel > FLT_EPSILON) { react[index] *= fuel[index]/orig_fuel; react_coord = react[index]; } @@ -1681,7 +1681,7 @@ void FLUID_3D::processBurn(float *fuel, float *smoke, float *react, float *flame heat[index] = (1.0f-flame[index])*ignition_point + flame[index]*temp_max; /* mix new color */ - if (r && smoke_emit) { + if (r && smoke_emit > FLT_EPSILON) { float smoke_factor = smoke[index]/(orig_smoke+smoke_emit); r[index] = (r[index] + _flame_smoke_color[0] * smoke_emit) * smoke_factor; g[index] = (g[index] + _flame_smoke_color[1] * smoke_emit) * smoke_factor; From 9307565269055e39cd71bd2c27bc86ad8fc12b96 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 11 Feb 2013 22:41:11 +0000 Subject: [PATCH 053/157] Attempted fix for issue with latest CUDA kernel for 32 bit windows/linux/mac, there seems to be some sort of compiler bug in CUDA toolkit 4.2, uninlining a few functions seems to avoid it. --- intern/cycles/kernel/kernel_emission.h | 10 +++++----- intern/cycles/kernel/kernel_light.h | 2 +- intern/cycles/kernel/kernel_shader.h | 6 +++--- intern/cycles/kernel/kernel_types.h | 1 + intern/cycles/render/osl.h | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index 4048bbd9dfc..3b27a1f49c9 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -20,7 +20,7 @@ CCL_NAMESPACE_BEGIN /* Direction Emission */ -__device float3 direct_emissive_eval(KernelGlobals *kg, float rando, +__device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando, LightSample *ls, float u, float v, float3 I, float t, float time) { /* setup shading at emitter */ @@ -74,7 +74,7 @@ __device float3 direct_emissive_eval(KernelGlobals *kg, float rando, return eval; } -__device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex, +__device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex, float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval, bool *is_lamp) { @@ -148,7 +148,7 @@ __device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex, /* Indirect Primitive Emission */ -__device float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf) +__device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf) { /* evaluate emissive closure */ float3 L = shader_emissive_eval(kg, sd); @@ -171,7 +171,7 @@ __device float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, f /* Indirect Lamp Emission */ -__device bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission) +__device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission) { LightSample ls; int lamp = lamp_light_eval_sample(kg, randt); @@ -200,7 +200,7 @@ __device bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, /* Indirect Background */ -__device float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf) +__device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf) { #ifdef __BACKGROUND__ /* evaluate background closure */ diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h index 10a32226f17..f6fbd3599ad 100644 --- a/intern/cycles/kernel/kernel_light.h +++ b/intern/cycles/kernel/kernel_light.h @@ -454,7 +454,7 @@ __device void triangle_light_sample(KernelGlobals *kg, int prim, int object, ls->lamp = ~0; ls->shader |= SHADER_USE_MIS; ls->t = 0.0f; - ls->type = LIGHT_AREA; + ls->type = LIGHT_TRIANGLE; ls->eval_fac = 1.0f; object_transform_light_sample(kg, ls, object, time); diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index b7d87427bd3..df86b352697 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -53,7 +53,7 @@ __device_noinline void shader_setup_object_transforms(KernelGlobals *kg, ShaderD } #endif -__device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd, +__device_noinline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray) { #ifdef __INSTANCING__ @@ -160,7 +160,7 @@ __device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd, /* ShaderData setup from position sampled on mesh */ -__device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, +__device_noinline void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, const float3 P, const float3 Ng, const float3 I, int shader, int object, int prim, float u, float v, float t, float time, int segment = ~0) { @@ -283,7 +283,7 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, /* ShaderData setup for displacement */ -__device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd, +__device_noinline void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd, int object, int prim, float u, float v) { /* Note: no OSLShader::init call here, this is done in shader_setup_from_sample! */ diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 52bdddc72fb..773ea0c43fb 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -299,6 +299,7 @@ typedef enum LightType { LIGHT_AREA, LIGHT_AO, LIGHT_SPOT, + LIGHT_TRIANGLE, LIGHT_STRAND } LightType; diff --git a/intern/cycles/render/osl.h b/intern/cycles/render/osl.h index 3c599caa893..d17f4c81362 100644 --- a/intern/cycles/render/osl.h +++ b/intern/cycles/render/osl.h @@ -36,7 +36,7 @@ class Device; class DeviceScene; class ImageManager; class OSLRenderServices; -class OSLGlobals; +struct OSLGlobals; class Scene; class ShaderGraph; class ShaderNode; From eb9c3f6aecc982a7377574866110018ca8eb744f Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Mon, 11 Feb 2013 22:45:48 +0000 Subject: [PATCH 054/157] [#34062] Collada: fixed redundant transform information and order of creation for the loc/rot/trans --- source/blender/collada/TransformWriter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index fb8ba567192..fa813e0b961 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -51,10 +51,10 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[4][4], converter->mat4_to_dae_double(dmat, local); TransformBase::decompose(local, loc, rot, NULL, scale); - if (node.getType() == COLLADASW::Node::JOINT) + //if (node.getType() == COLLADASW::Node::JOINT) node.addMatrix("transform", dmat); - else - add_transform(node, loc, rot, scale); + //else + //add_transform(node, loc, rot, scale); } void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob) @@ -115,7 +115,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob) double d_obmat[4][4]; converter.mat4_to_dae_double(d_obmat, ob->obmat); node.addMatrix("transform",d_obmat); - add_transform(node, ob->loc, ob->rot, ob->size); + //add_transform(node, ob->loc, ob->rot, ob->size); } void TransformWriter::add_node_transform_identity(COLLADASW::Node& node) @@ -131,10 +131,10 @@ void TransformWriter::add_transform(COLLADASW::Node& node, float loc[3], float r node.addRotateY("rotationY", COLLADABU::Math::Utils::radToDegF(rot[1])); node.addRotateX("rotationX", COLLADABU::Math::Utils::radToDegF(rot[0])); #endif + node.addTranslate("location", loc[0], loc[1], loc[2]); node.addRotateZ("rotationZ", RAD2DEGF(rot[2])); node.addRotateY("rotationY", RAD2DEGF(rot[1])); node.addRotateX("rotationX", RAD2DEGF(rot[0])); node.addScale("scale", scale[0], scale[1], scale[2]); - node.addTranslate("location", loc[0], loc[1], loc[2]); } From fcbd9c3a332fda86c2fe9e8cf5ddfacf29b85419 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Mon, 11 Feb 2013 22:52:13 +0000 Subject: [PATCH 055/157] Old bug fix: Uv smart stitch failed to detect angle if islands were rotated close to 180 degrees and there were edges both below and above the 180 degree threshhold. Separating and averaging the negative and positive angles seems to solve the issue making the tool a bit more robust ;) --- source/blender/blenlib/BLI_math_matrix.h | 2 + source/blender/blenlib/intern/math_matrix.c | 13 +++ .../editors/uvedit/uvedit_smart_stitch.c | 84 ++++++++++++------- 3 files changed, 71 insertions(+), 28 deletions(-) diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index a5ab2373b89..97cd6a60862 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -88,6 +88,7 @@ void mul_serie_m4(float R[4][4], void mul_m4_v3(float M[4][4], float r[3]); void mul_v3_m4v3(float r[3], float M[4][4], const float v[3]); +void mul_v2_m2v2(float r[2], float M[2][2], const float v[2]); void mul_mat3_m4_v3(float M[4][4], float r[3]); void mul_m4_v4(float M[4][4], float r[4]); void mul_v4_m4v4(float r[4], float M[4][4], const float v[4]); @@ -170,6 +171,7 @@ void mat4_to_size(float r[3], float M[4][4]); void translate_m4(float mat[4][4], float tx, float ty, float tz); void rotate_m4(float mat[4][4], const char axis, const float angle); +void rotate_m2(float mat[2][2], const float angle); void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[3][3]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 5c443b9b1f3..c12588463b0 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -344,6 +344,12 @@ void mul_v3_m4v3(float in[3], float mat[4][4], const float vec[3]) in[2] = x * mat[0][2] + y * mat[1][2] + mat[2][2] * vec[2] + mat[3][2]; } +void mul_v2_m2v2(float r[2], float M[2][2], const float v[2]) +{ + r[0] = M[0][0]*v[0] + M[1][0]*v[1]; + r[1] = M[0][1]*v[0] + M[1][1]*v[1]; +} + /* same as mul_m4_v3() but doesnt apply translation component */ void mul_mat3_m4_v3(float mat[4][4], float vec[3]) { @@ -1304,6 +1310,13 @@ void rotate_m4(float mat[4][4], const char axis, const float angle) } } +void rotate_m2(float mat[2][2], const float angle) +{ + mat[0][0] = mat[1][1] = cosf(angle); + mat[0][1] = sinf(angle); + mat[1][0] = -mat[0][1]; +} + void blend_m3_m3m3(float out[3][3], float dst[3][3], float src[3][3], const float srcweight) { float srot[3][3], drot[3][3]; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 1b43d829947..b7e12dda663 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -100,11 +100,13 @@ struct IslandStitchData; typedef struct IslandStitchData { /* rotation can be used only for edges, for vertices there is no such notion */ float rotation; + float rotation_neg; float translation[2]; /* Used for rotation, the island will rotate around this point */ float medianPoint[2]; int numOfElements; int num_rot_elements; + int num_rot_elements_neg; /* flag to remember if island has been added for preview */ char addedForPreview; /* flag an island to be considered for determining static island */ @@ -286,20 +288,15 @@ static int getNumOfIslandUvs(UvElementMap *elementMap, int island) } } -static void stitch_uv_rotate(float rotation, float medianPoint[2], float uv[2], float aspect) +static void stitch_uv_rotate(float mat[2][2], float medianPoint[2], float uv[2], float aspect) { float uv_rotation_result[2]; uv[1] /= aspect; - uv[0] -= medianPoint[0]; - uv[1] -= medianPoint[1]; - - uv_rotation_result[0] = cosf(rotation) * uv[0] - sinf(rotation) * uv[1]; - uv_rotation_result[1] = sinf(rotation) * uv[0] + cosf(rotation) * uv[1]; - - uv[0] = uv_rotation_result[0] + medianPoint[0]; - uv[1] = uv_rotation_result[1] + medianPoint[1]; + sub_v2_v2(uv, medianPoint); + mul_v2_m2v2(uv_rotation_result, mat, uv); + add_v2_v2v2(uv, uv_rotation_result, medianPoint); uv[1] *= aspect; } @@ -412,17 +409,35 @@ static void stitch_calculate_island_snapping(StitchState *state, PreviewPosition for (i = 0; i < state->element_map->totalIslands; i++) { if (island_stitch_data[i].addedForPreview) { int numOfIslandUVs = 0, j; + int totelem = island_stitch_data[i].num_rot_elements_neg + island_stitch_data[i].num_rot_elements; + float rotation; + float rotation_mat[2][2]; /* check to avoid divide by 0 */ - if (island_stitch_data[i].num_rot_elements > 0) { + if (island_stitch_data[i].num_rot_elements > 1) island_stitch_data[i].rotation /= island_stitch_data[i].num_rot_elements; + + if (island_stitch_data[i].num_rot_elements_neg > 1) + island_stitch_data[i].rotation_neg /= island_stitch_data[i].num_rot_elements_neg; + + if (island_stitch_data[i].numOfElements > 1) { island_stitch_data[i].medianPoint[0] /= island_stitch_data[i].numOfElements; island_stitch_data[i].medianPoint[1] /= island_stitch_data[i].numOfElements; - island_stitch_data[i].medianPoint[1] /= state->aspect; - } - island_stitch_data[i].translation[0] /= island_stitch_data[i].numOfElements; - island_stitch_data[i].translation[1] /= island_stitch_data[i].numOfElements; + island_stitch_data[i].translation[0] /= island_stitch_data[i].numOfElements; + island_stitch_data[i].translation[1] /= island_stitch_data[i].numOfElements; + } + + island_stitch_data[i].medianPoint[1] /= state->aspect; + if ((island_stitch_data[i].rotation + island_stitch_data[i].rotation_neg < M_PI_2) || + island_stitch_data[i].num_rot_elements == 0 || island_stitch_data[i].num_rot_elements_neg == 0) + rotation = (island_stitch_data[i].rotation*island_stitch_data[i].num_rot_elements - + island_stitch_data[i].rotation_neg*island_stitch_data[i].num_rot_elements_neg)/totelem; + else + rotation = (island_stitch_data[i].rotation*island_stitch_data[i].num_rot_elements + + (2*M_PI - island_stitch_data[i].rotation_neg)*island_stitch_data[i].num_rot_elements_neg)/totelem; + + rotate_m2(rotation_mat, rotation); numOfIslandUVs = getNumOfIslandUvs(state->element_map, i); element = &state->element_map->buf[state->element_map->islandIndices[i]]; for (j = 0; j < numOfIslandUVs; j++, element++) { @@ -436,15 +451,16 @@ static void stitch_calculate_island_snapping(StitchState *state, PreviewPosition if (final) { - stitch_uv_rotate(island_stitch_data[i].rotation, island_stitch_data[i].medianPoint, luv->uv, state->aspect); + stitch_uv_rotate(rotation_mat, island_stitch_data[i].medianPoint, luv->uv, state->aspect); add_v2_v2(luv->uv, island_stitch_data[i].translation); } else { + int face_preview_pos = preview_position[BM_elem_index_get(element->l->f)].data_position; - stitch_uv_rotate(island_stitch_data[i].rotation, island_stitch_data[i].medianPoint, + stitch_uv_rotate(rotation_mat, island_stitch_data[i].medianPoint, preview->preview_polys + face_preview_pos + 2 * element->tfindex, state->aspect); add_v2_v2(preview->preview_polys + face_preview_pos + 2 * element->tfindex, @@ -500,13 +516,15 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchState *sta edgecos = dot_v2v2(uv1, uv2); edgesin = cross_v2v2(uv1, uv2); + rotation = acosf(max_ff(-1.0f, min_ff(1.0f, edgecos))); - rotation = (edgesin > 0.0f) ? - +acosf(max_ff(-1.0f, min_ff(1.0f, edgecos))) : - -acosf(max_ff(-1.0f, min_ff(1.0f, edgecos))); - - island_stitch_data[element1->island].num_rot_elements++; - island_stitch_data[element1->island].rotation += rotation; + if (edgesin > 0.0f) { + island_stitch_data[element1->island].num_rot_elements++; + island_stitch_data[element1->island].rotation += rotation; + } else { + island_stitch_data[element1->island].num_rot_elements_neg++; + island_stitch_data[element1->island].rotation_neg += rotation; + } } @@ -515,7 +533,8 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat float edgecos = 1.0f, edgesin = 0.0f; int index; UvElement *element_iter; - float rotation = 0; + float rotation = 0, rotation_neg = 0; + int rot_elem = 0, rot_elem_neg = 0; BMLoop *l; if (element->island == state->static_island && !state->midpoints) @@ -544,16 +563,25 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat negate_v2_v2(normal, state->normals + index_tmp2 * 2); edgecos = dot_v2v2(normal, state->normals + index_tmp1 * 2); edgesin = cross_v2v2(normal, state->normals + index_tmp1 * 2); - rotation += (edgesin > 0.0f) ? - +acosf(max_ff(-1.0f, min_ff(1.0f, edgecos))) : - -acosf(max_ff(-1.0f, min_ff(1.0f, edgecos))); + if (edgesin > 0.0f) { + rotation += acosf(max_ff(-1.0f, min_ff(1.0f, edgecos))); + rot_elem++; + } + else { + rotation_neg += acosf(max_ff(-1.0f, min_ff(1.0f, edgecos))); + rot_elem_neg++; + } } } - if (state->midpoints) + if (state->midpoints) { rotation /= 2.0f; - island_stitch_data[element->island].num_rot_elements++; + rotation_neg /= 2.0f; + } + island_stitch_data[element->island].num_rot_elements += rot_elem; island_stitch_data[element->island].rotation += rotation; + island_stitch_data[element->island].num_rot_elements_neg += rot_elem_neg; + island_stitch_data[element->island].rotation_neg += rotation_neg; } From 533f359c0d2587659566877fee7135d8c9828c06 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Feb 2013 00:35:31 +0000 Subject: [PATCH 056/157] code cleanup: some style edits, also allow mul_v2_m2v2() to have the same value as in-out, since this is a convention for existing matrix functions. --- source/blender/blenlib/intern/math_matrix.c | 9 +++++--- source/blender/editors/interface/interface.c | 22 +++++++++---------- .../editors/uvedit/uvedit_smart_stitch.c | 22 ++++++++++++------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index c12588463b0..9d9e3e611e1 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -344,10 +344,13 @@ void mul_v3_m4v3(float in[3], float mat[4][4], const float vec[3]) in[2] = x * mat[0][2] + y * mat[1][2] + mat[2][2] * vec[2] + mat[3][2]; } -void mul_v2_m2v2(float r[2], float M[2][2], const float v[2]) +void mul_v2_m2v2(float r[2], float mat[2][2], const float vec[2]) { - r[0] = M[0][0]*v[0] + M[1][0]*v[1]; - r[1] = M[0][1]*v[0] + M[1][1]*v[1]; + float x; + + x = vec[0]; + r[0] = mat[0][0] * x + mat[1][0] * vec[1]; + r[1] = mat[0][1] * x + mat[1][1] * vec[1]; } /* same as mul_m4_v3() but doesnt apply translation component */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 4a5f3acad4f..9cd86a2647c 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2781,21 +2781,21 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, return but; } -/* ui_def_but_rna_propname and ui_def_but_rna +static void ui_def_but_rna__disable(uiBut *but) +{ + but->flag |= UI_BUT_DISABLED; + but->lock = true; + but->lockstr = ""; +} + +/** + * ui_def_but_rna_propname and ui_def_but_rna * both take the same args except for propname vs prop, this is done so we can * avoid an extra lookup on 'prop' when its already available. * * When this kind of change won't disrupt branches, best look into making more * of our UI functions take prop rather then propname. */ - -#define UI_DEF_BUT_RNA_DISABLE(but) { \ - but->flag |= UI_BUT_DISABLED; \ - but->lock = TRUE; \ - but->lockstr = ""; \ - } (void)0 - - static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, @@ -2932,7 +2932,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s } if (!RNA_property_editable(&but->rnapoin, prop)) { - UI_DEF_BUT_RNA_DISABLE(but); + ui_def_but_rna__disable(but); } if (but->flag & UI_BUT_UNDO && (ui_but_is_rna_undo(but) == FALSE)) { @@ -2962,7 +2962,7 @@ static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, cons else { but = ui_def_but(block, type, retval, propname, x, y, width, height, NULL, min, max, a1, a2, tip); - UI_DEF_BUT_RNA_DISABLE(but); + ui_def_but_rna__disable(but); } return but; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index b7e12dda663..5bb8105cd14 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -429,13 +429,18 @@ static void stitch_calculate_island_snapping(StitchState *state, PreviewPosition } island_stitch_data[i].medianPoint[1] /= state->aspect; - if ((island_stitch_data[i].rotation + island_stitch_data[i].rotation_neg < M_PI_2) || - island_stitch_data[i].num_rot_elements == 0 || island_stitch_data[i].num_rot_elements_neg == 0) - rotation = (island_stitch_data[i].rotation*island_stitch_data[i].num_rot_elements - - island_stitch_data[i].rotation_neg*island_stitch_data[i].num_rot_elements_neg)/totelem; - else - rotation = (island_stitch_data[i].rotation*island_stitch_data[i].num_rot_elements + - (2*M_PI - island_stitch_data[i].rotation_neg)*island_stitch_data[i].num_rot_elements_neg)/totelem; + if ((island_stitch_data[i].rotation + island_stitch_data[i].rotation_neg < (float)M_PI_2) || + island_stitch_data[i].num_rot_elements == 0 || island_stitch_data[i].num_rot_elements_neg == 0) + { + rotation = (island_stitch_data[i].rotation * island_stitch_data[i].num_rot_elements - + island_stitch_data[i].rotation_neg * + island_stitch_data[i].num_rot_elements_neg) / totelem; + } + else { + rotation = (island_stitch_data[i].rotation * island_stitch_data[i].num_rot_elements + + (2.0f * (float)M_PI - island_stitch_data[i].rotation_neg) * + island_stitch_data[i].num_rot_elements_neg) / totelem; + } rotate_m2(rotation_mat, rotation); numOfIslandUVs = getNumOfIslandUvs(state->element_map, i); @@ -521,7 +526,8 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchState *sta if (edgesin > 0.0f) { island_stitch_data[element1->island].num_rot_elements++; island_stitch_data[element1->island].rotation += rotation; - } else { + } + else { island_stitch_data[element1->island].num_rot_elements_neg++; island_stitch_data[element1->island].rotation_neg += rotation; } From 5eec86c6b28539182da03bcdb65a2c96266c241c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Feb 2013 01:20:14 +0000 Subject: [PATCH 057/157] fix [#34203] Editing bones, parenting, blender quits 'Set Inverse' was mixing up pose/object constraints --- .../editors/object/object_constraint.c | 150 +++++++++--------- 1 file changed, 79 insertions(+), 71 deletions(-) diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 6cb7cd5e326..7746329c17f 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -718,81 +718,87 @@ void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot) /* ------------- Child-Of Constraint ------------------ */ -static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, float invmat[4][4]) +static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, float invmat[4][4], const int owner) { - bConstraint *lastcon = NULL; - bPoseChannel *pchan = NULL; - /* nullify inverse matrix first */ unit_m4(invmat); - /* try to find a pose channel - assume that this is the constraint owner */ - /* TODO: get from context instead? */ - if (ob && ob->pose) - pchan = BKE_pose_channel_active(ob); - - /* calculate/set inverse matrix: - * We just calculate all transform-stack eval up to but not including this constraint. - * This is because inverse should just inverse correct for just the constraint's influence - * when it gets applied; that is, at the time of application, we don't know anything about - * what follows. - */ - if (pchan) { - float imat[4][4], tmat[4][4]; - float pmat[4][4]; - - /* 1. calculate posemat where inverse doesn't exist yet (inverse was cleared above), - * to use as baseline ("pmat") to derive delta from. This extra calc saves users - * from having pressing "Clear Inverse" first - */ - BKE_pose_where_is(scene, ob); - copy_m4_m4(pmat, pchan->pose_mat); - - /* 2. knock out constraints starting from this one */ - lastcon = pchan->constraints.last; - pchan->constraints.last = con->prev; - - if (con->prev) { - /* new end must not point to this one, else this chain cutting is useless */ - con->prev->next = NULL; + if (owner == EDIT_CONSTRAINT_OWNER_BONE) { + bPoseChannel *pchan; + /* try to find a pose channel - assume that this is the constraint owner */ + /* TODO: get from context instead? */ + if (ob && ob->pose && (pchan = BKE_pose_channel_active(ob))) { + bConstraint *con_last; + /* calculate/set inverse matrix: + * We just calculate all transform-stack eval up to but not including this constraint. + * This is because inverse should just inverse correct for just the constraint's influence + * when it gets applied; that is, at the time of application, we don't know anything about + * what follows. + */ + float imat[4][4], tmat[4][4]; + float pmat[4][4]; + + /* make sure we passed the correct constraint */ + BLI_assert(BLI_findindex(&pchan->constraints, con) != -1); + + /* 1. calculate posemat where inverse doesn't exist yet (inverse was cleared above), + * to use as baseline ("pmat") to derive delta from. This extra calc saves users + * from having pressing "Clear Inverse" first + */ + BKE_pose_where_is(scene, ob); + copy_m4_m4(pmat, pchan->pose_mat); + + /* 2. knock out constraints starting from this one */ + con_last = pchan->constraints.last; + pchan->constraints.last = con->prev; + + if (con->prev) { + /* new end must not point to this one, else this chain cutting is useless */ + con->prev->next = NULL; + } + else { + /* constraint was first */ + pchan->constraints.first = NULL; + } + + /* 3. solve pose without disabled constraints */ + BKE_pose_where_is(scene, ob); + + /* 4. determine effect of constraint by removing the newly calculated + * pchan->pose_mat from the original pchan->pose_mat, thus determining + * the effect of the constraint + */ + invert_m4_m4(imat, pchan->pose_mat); + mult_m4_m4m4(tmat, pmat, imat); + invert_m4_m4(invmat, tmat); + + /* 5. restore constraints */ + pchan->constraints.last = con_last; + + if (con->prev) { + /* hook up prev to this one again */ + con->prev->next = con; + } + else { + /* set as first again */ + pchan->constraints.first = con; + } + + /* 6. recalculate pose with new inv-mat applied */ + BKE_pose_where_is(scene, ob); } - else { - /* constraint was first */ - pchan->constraints.first = NULL; - } - - /* 3. solve pose without disabled constraints */ - BKE_pose_where_is(scene, ob); - - /* 4. determine effect of constraint by removing the newly calculated - * pchan->pose_mat from the original pchan->pose_mat, thus determining - * the effect of the constraint - */ - invert_m4_m4(imat, pchan->pose_mat); - mult_m4_m4m4(tmat, pmat, imat); - invert_m4_m4(invmat, tmat); - - /* 5. restore constraints */ - pchan->constraints.last = lastcon; - - if (con->prev) { - /* hook up prev to this one again */ - con->prev->next = con; - } - else { - /* set as first again */ - pchan->constraints.first = con; - } - - /* 6. recalculate pose with new inv-mat applied */ - BKE_pose_where_is(scene, ob); } - else if (ob) { - Object workob; - - /* use BKE_object_workob_calc_parent to find inverse - just like for normal parenting */ - BKE_object_workob_calc_parent(scene, ob, &workob); - invert_m4_m4(invmat, workob.obmat); + if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) { + if (ob) { + Object workob; + + /* make sure we passed the correct constraint */ + BLI_assert(BLI_findindex(&ob->constraints, con) != -1); + + /* use BKE_object_workob_calc_parent to find inverse - just like for normal parenting */ + BKE_object_workob_calc_parent(scene, ob, &workob); + invert_m4_m4(invmat, workob.obmat); + } } } @@ -803,6 +809,7 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; + const int owner = RNA_enum_get(op->ptr, "owner"); /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) { @@ -811,7 +818,7 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - child_get_inverse_matrix(scene, ob, con, data->invmat); + child_get_inverse_matrix(scene, ob, con, data->invmat, owner); WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); @@ -1024,6 +1031,7 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL; + const int owner = RNA_enum_get(op->ptr, "owner"); /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) { @@ -1032,7 +1040,7 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - child_get_inverse_matrix(scene, ob, con, data->invmat); + child_get_inverse_matrix(scene, ob, con, data->invmat, owner); WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); From 631f49d1280c4f87a93ff0da67f62d691a6abc64 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Feb 2013 01:52:55 +0000 Subject: [PATCH 058/157] fix for own regression [#34096] ocean sim vertex color bug Caused by my assumption that alpha wasn't used for vertex colors. Infact it is used by blender-internal rendering, but typically only for blending strand particles. Updated comments to note this. --- source/blender/makesdna/DNA_meshdata_types.h | 11 ++++++++--- source/blender/modifiers/intern/MOD_ocean.c | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index ffa5e420fca..a189219b211 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -118,9 +118,14 @@ typedef struct MLoopUV { #define MLOOPUV_VERTSEL 2 #define MLOOPUV_PINNED 4 -/* at the moment alpha is abused for vertex painting - * and not used for transparency, - * note that red and blue are _not_ swapped, as they are with #MCol */ +/** + * at the moment alpha is abused for vertex painting, + * otherwise it should _always_ be initialized to 255 + * Mostly its not used for transparency... + * (except for blender-internal rendering, see [#34096]). + * + * \note red and blue are _not_ swapped, as they are with #MCol + */ typedef struct MLoopCol { char r, g, b, a; } MLoopCol; diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index c0e529f1eae..6c5bac49188 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -486,7 +486,8 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, mlcol = &mloopcols[mp->loopstart + j]; mlcol->r = mlcol->g = mlcol->b = (char)(foam * 255); - /* mc->a = 255; */ /* no need to set */ + /* This needs to be set (render engine uses) */ + mlcol->a = 255; } while (j--); } } From 86793fec42508e0e3a6dea0ef34490fd4bfda0f8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Feb 2013 05:09:35 +0000 Subject: [PATCH 059/157] fix [#34198] Scene unit size and dyntopo detail size there were 2 bugs here. - int buttons scaling values on input but not on display. - pixel distances were using PROP_DISTANCE subtype - which isn't correct. added assert incase PROP_INT values have PROP_DISTANCE subtype applied in future. --- source/blender/editors/interface/interface.c | 4 ++-- source/blender/makesrna/RNA_types.h | 1 + source/blender/makesrna/intern/rna_brush.c | 4 ++-- source/blender/makesrna/intern/rna_define.c | 8 ++++++++ source/blender/makesrna/intern/rna_scene.c | 2 +- source/blender/makesrna/intern/rna_sculpt_paint.c | 4 ++-- source/blender/modifiers/intern/MOD_ocean.c | 6 +++++- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 9cd86a2647c..d245349f2c4 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1800,9 +1800,9 @@ int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double #ifdef WITH_PYTHON if (str[0] != '\0') { - int is_unit_but = ui_is_but_unit(but); + bool is_unit_but = (ui_is_but_float(but) && ui_is_but_unit(but)); /* only enable verbose if we won't run again with units */ - if (BPY_button_exec(C, str, value, is_unit_but == FALSE) != -1) { + if (BPY_button_exec(C, str, value, is_unit_but == false) != -1) { /* if the value parsed ok without unit conversion this button may still need a unit multiplier */ if (is_unit_but) { char str_new[128]; diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index d3cf7dc8095..54d2efcf4cf 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -120,6 +120,7 @@ typedef enum PropertySubType { PROP_FACTOR = 15, PROP_ANGLE = 16 | PROP_UNIT_ROTATION, PROP_TIME = 17 | PROP_UNIT_TIME, + /* distance in 3d space, don't use for pixel distance for eg. */ PROP_DISTANCE = 18 | PROP_UNIT_LENGTH, /* number arrays */ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 4fb26f2b007..c995d3b52c7 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -618,7 +618,7 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Brush_update"); /* number values */ - prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE); + prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE); RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL); RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10); RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0); @@ -645,7 +645,7 @@ static void rna_def_brush(BlenderRNA *brna) 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_DISTANCE); + prop = RNA_def_property(srna, "smooth_stroke_radius", PROP_INT, PROP_NONE); 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"); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index c32255ac645..97ef4dfd0a8 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -971,6 +971,14 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier { IntPropertyRNA *iprop = (IntPropertyRNA *)prop; +#ifndef RNA_RUNTIME + if (subtype == PROP_DISTANCE) { + fprintf(stderr, "%s: subtype does not apply to 'PROP_INT' \"%s.%s\"\n", __func__, + CONTAINER_RNA_ID(cont), identifier); + DefRNA.error = 1; + } +#endif + iprop->hardmin = (subtype == PROP_UNSIGNED) ? 0 : INT_MIN; iprop->hardmax = INT_MAX; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 6c8242e4333..e3fb06d18d8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1870,7 +1870,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) /* unified paint settings that override the equivalent settings * from the active brush */ - prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE); + prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE); RNA_def_property_int_funcs(prop, NULL, "rna_UnifiedPaintSettings_size_set", NULL); RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10); RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index ff0c9d9dec6..5aa4fa81076 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -378,7 +378,7 @@ static void rna_def_sculpt(BlenderRNA *brna) "Show diffuse color of object and overlay sculpt mask on top of it"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update"); - prop = RNA_def_property(srna, "detail_size", PROP_INT, PROP_DISTANCE); + prop = RNA_def_property(srna, "detail_size", PROP_INT, PROP_NONE); RNA_def_property_ui_range(prop, 2, 100, 0, 0); RNA_def_property_ui_text(prop, "Detail Size", "Maximum edge length for dynamic topology sculpting (in pixels)"); @@ -632,7 +632,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_struct_path_func(srna, "rna_ParticleBrush_path"); RNA_def_struct_ui_text(srna, "Particle Brush", "Particle editing brush"); - prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE); + prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 100, 10, 3); RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels"); diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 6c5bac49188..77250ec4025 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -1,4 +1,4 @@ -/** +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -25,6 +25,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/modifiers/intern/MOD_ocean.c + * \ingroup modifiers + */ + #include "MEM_guardedalloc.h" #include "DNA_customdata_types.h" From 63d9ace6b816641ed27fc061fb256e033ca9f5ab Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 12 Feb 2013 06:24:58 +0000 Subject: [PATCH 060/157] Added a missing space (between separator and face count in object mode) --- source/blender/editors/space_info/info_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 3f73fc2605a..b2a83b6c9aa 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -395,7 +395,7 @@ static void stats_string(Scene *scene) s += sprintf(s, "Verts:%d | Tris:%d", stats->totvert, stats->tottri); } else { - s += sprintf(s, "Verts:%d | Faces:%d| Tris:%d | Objects:%d/%d | Lamps:%d/%d%s", + s += sprintf(s, "Verts:%d | Faces:%d | Tris:%d | Objects:%d/%d | Lamps:%d/%d%s", stats->totvert, stats->totface, stats->tottri, stats->totobjsel, stats->totobj, stats->totlampsel, stats->totlamp, memstr); } From 027a426c4d4df0a2efbaa6612c78f6401b68ffd3 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 12 Feb 2013 07:32:17 +0000 Subject: [PATCH 061/157] Add translation of stats/info string. --- release/scripts/startup/bl_ui/space_info.py | 2 +- .../blender/editors/space_info/info_stats.c | 33 +++++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 47e8844742a..51c975c3e70 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -65,7 +65,7 @@ class INFO_HT_header(Header): row = layout.row(align=True) row.operator("wm.splash", text="", icon='BLENDER', emboss=False) - row.label(text=scene.statistics()) + row.label(text=scene.statistics(), translate=False) # XXX: BEFORE RELEASE, MOVE FILE MENU OUT OF INFO!!! """ diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index b2a83b6c9aa..976769752f9 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -41,6 +41,8 @@ #include "BLI_utildefines.h" #include "BLI_math.h" +#include "BLF_translation.h" + #include "BKE_anim.h" #include "BKE_blender.h" #include "BKE_curve.h" @@ -166,8 +168,11 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) if (ebo->flag & BONE_SELECTED) stats->totbonesel++; /* if this is a connected child and it's parent is being moved, remove our root */ - if ((ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL)) + if ((ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL) && + ebo->parent && (ebo->parent->flag & BONE_TIPSEL)) + { stats->totvertsel--; + } stats->totvert += 2; } @@ -362,9 +367,9 @@ static void stats_string(Scene *scene) mmap_in_use = MEM_get_mapped_memory_in_use(); /* get memory statistics */ - s = memstr + sprintf(memstr, " | Mem:%.2fM", (double)((mem_in_use - mmap_in_use) >> 10) / 1024.0); + s = memstr + sprintf(memstr, IFACE_(" | Mem:%.2fM"), (double)((mem_in_use - mmap_in_use) >> 10) / 1024.0); if (mmap_in_use) - sprintf(s, " (%.2fM)", (double)((mmap_in_use) >> 10) / 1024.0); + sprintf(s, IFACE_(" (%.2fM)"), (double)((mmap_in_use) >> 10) / 1024.0); s = stats->infostr; @@ -372,31 +377,34 @@ static void stats_string(Scene *scene) if (scene->obedit) { if (BKE_keyblock_from_object(scene->obedit)) - s += sprintf(s, "(Key) "); + s += sprintf(s, IFACE_("(Key) ")); if (scene->obedit->type == OB_MESH) { - s += sprintf(s, "Verts:%d/%d | Edges:%d/%d | Faces:%d/%d | Tris:%d", - stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface, stats->tottri); + s += sprintf(s, IFACE_("Verts:%d/%d | Edges:%d/%d | Faces:%d/%d | Tris:%d"), + stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, stats->totfacesel, + stats->totface, stats->tottri); } else if (scene->obedit->type == OB_ARMATURE) { - s += sprintf(s, "Verts:%d/%d | Bones:%d/%d", stats->totvertsel, stats->totvert, stats->totbonesel, stats->totbone); + s += sprintf(s, IFACE_("Verts:%d/%d | Bones:%d/%d"), stats->totvertsel, stats->totvert, stats->totbonesel, + stats->totbone); } else { - s += sprintf(s, "Verts:%d/%d", stats->totvertsel, stats->totvert); + s += sprintf(s, IFACE_("Verts:%d/%d"), stats->totvertsel, stats->totvert); } strcat(s, memstr); } else if (ob && (ob->mode & OB_MODE_POSE)) { - s += sprintf(s, "Bones:%d/%d %s", + s += sprintf(s, IFACE_("Bones:%d/%d %s"), stats->totbonesel, stats->totbone, memstr); } else if (stats_is_object_dynamic_topology_sculpt(ob)) { - s += sprintf(s, "Verts:%d | Tris:%d", stats->totvert, stats->tottri); + s += sprintf(s, IFACE_("Verts:%d | Tris:%d"), stats->totvert, stats->tottri); } else { - s += sprintf(s, "Verts:%d | Faces:%d | Tris:%d | Objects:%d/%d | Lamps:%d/%d%s", - stats->totvert, stats->totface, stats->tottri, stats->totobjsel, stats->totobj, stats->totlampsel, stats->totlamp, memstr); + s += sprintf(s, IFACE_("Verts:%d | Faces:%d | Tris:%d | Objects:%d/%d | Lamps:%d/%d%s"), + stats->totvert, stats->totface, stats->tottri, stats->totobjsel, stats->totobj, stats->totlampsel, + stats->totlamp, memstr); } if (ob) @@ -419,4 +427,3 @@ const char *ED_info_stats_string(Scene *scene) return scene->stats->infostr; } - From a85a0f57bc09b66509bbe4c6b72d23efcf7f515f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Feb 2013 08:30:12 +0000 Subject: [PATCH 062/157] Buildbot: revert r54465 and r54466 -- issue was not caused by crosscompilation, but was caused by some bugs in toolkit itself. Shall be all fine now (at least it is on my laptop now). Let give it another try! --- build_files/buildbot/config/user-config-glibc211-i686.py | 5 ++--- build_files/buildbot/config/user-config-glibc211-x86_64.py | 4 ++-- build_files/buildbot/slave_compile.py | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/build_files/buildbot/config/user-config-glibc211-i686.py b/build_files/buildbot/config/user-config-glibc211-i686.py index 97c55cafbe9..540416ee1fb 100644 --- a/build_files/buildbot/config/user-config-glibc211-i686.py +++ b/build_files/buildbot/config/user-config-glibc211-i686.py @@ -1,6 +1,7 @@ BF_BUILDDIR = '../blender-build/linux-glibc211-i686' BF_INSTALLDIR = '../blender-install/linux-glibc211-i686' BF_NUMJOBS = 4 +WITHOUT_BF_OVERWRITE_INSTALL = True # Python configuration BF_PYTHON_VERSION = '3.3' @@ -109,9 +110,7 @@ BF_JACK_LIB_STATIC = '${BF_ZLIB}/lib/libjack.a' # Cycles WITH_BF_CYCLES = True -WITH_BF_CYCLES_CUDA_BINARIES = True -#BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21', 'sm_30'] -BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30'] +WITH_BF_CYCLES_CUDA_BINARIES = False WITH_BF_OIIO = True WITH_BF_STATICOIIO = True diff --git a/build_files/buildbot/config/user-config-glibc211-x86_64.py b/build_files/buildbot/config/user-config-glibc211-x86_64.py index 1d43670b31d..c0ba8060712 100644 --- a/build_files/buildbot/config/user-config-glibc211-x86_64.py +++ b/build_files/buildbot/config/user-config-glibc211-x86_64.py @@ -1,6 +1,7 @@ BF_BUILDDIR = '../blender-build/linux-glibc211-x86_64' BF_INSTALLDIR = '../blender-install/linux-glibc211-x86_64' BF_NUMJOBS = 4 +WITHOUT_BF_OVERWRITE_INSTALL = True # Python configuration BF_PYTHON_VERSION = '3.3' @@ -109,8 +110,7 @@ BF_JACK_LIB_STATIC = '${BF_ZLIB}/lib/libjack.a' # Cycles WITH_BF_CYCLES = True -WITH_BF_CYCLES_CUDA_BINARIES = True -BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21', 'sm_30'] +WITH_BF_CYCLES_CUDA_BINARIES = False WITH_BF_OIIO = True WITH_BF_STATICOIIO = True diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index ae9a84ab22c..dab8a8e6483 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -63,14 +63,14 @@ else: configs = [] if builder.endswith('linux_glibc211_x86_64_scons'): configs = ['user-config-player-glibc211-x86_64.py', - #'user-config-cuda-glibc211-x86_64.py', + 'user-config-cuda-glibc211-x86_64.py', 'user-config-glibc211-x86_64.py' ] chroot_name = 'buildbot_squeeze_x86_64' cuda_chroot = 'buildbot_squeeze_x86_64' elif builder.endswith('linux_glibc211_i386_scons'): configs = ['user-config-player-glibc211-i686.py', - #'user-config-cuda-glibc211-i686.py', + 'user-config-cuda-glibc211-i686.py', 'user-config-glibc211-i686.py'] chroot_name = 'buildbot_squeeze_i686' From 261295180c13f613df32a0ae6496486096b532e7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Feb 2013 10:07:37 +0000 Subject: [PATCH 063/157] Fix #34209: Texture preview in brush settings does not update Was a regression since Cycles preview implementation. Texture preview would be fine now if Blender Internal render is used, but seems it's not impossible to support textures preview if Cycles is set as render engine. Would check on this a bit further. --- source/blender/editors/render/render_preview.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 994c7275ecd..22650df94fa 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1019,6 +1019,7 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short sp->pr_method = PR_ICON_RENDER; sp->pr_rect = cur_size->rect; sp->id = ip->id; + sp->pr_main = pr_main; common_preview_startjob(sp, stop, do_update, progress); shader_preview_free(sp); From ddf1d987e51fee773c9004ce9a09210678f92a3d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Feb 2013 10:33:04 +0000 Subject: [PATCH 064/157] fix for own commit r54482, PROP_DISTANCE was being checked for by radial control operator. now allow PROP_NONE and treat it as a distance. --- source/blender/windowmanager/intern/wm_operators.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a720d61f9d0..41dd618caa5 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3261,6 +3261,7 @@ static void radial_control_set_initial_mouse(RadialControl *rc, wmEvent *event) rc->initial_mouse[1] = event->y; switch (rc->subtype) { + case PROP_NONE: case PROP_DISTANCE: d[0] = rc->initial_value; break; @@ -3360,6 +3361,7 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd float zoom[2], col[3] = {1, 1, 1}; switch (rc->subtype) { + case PROP_NONE: case PROP_DISTANCE: r1 = rc->current_value; r2 = rc->initial_value; @@ -3598,8 +3600,8 @@ static int radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) /* get subtype of property */ rc->subtype = RNA_property_subtype(rc->prop); - if (!ELEM3(rc->subtype, PROP_DISTANCE, PROP_FACTOR, PROP_ANGLE)) { - BKE_report(op->reports, RPT_ERROR, "Property must be a distance, a factor, or an angle"); + if (!ELEM4(rc->subtype, PROP_NONE, PROP_DISTANCE, PROP_FACTOR, PROP_ANGLE)) { + BKE_report(op->reports, RPT_ERROR, "Property must be a none, distance, a factor, or an angle"); MEM_freeN(rc); return OPERATOR_CANCELLED; } @@ -3683,6 +3685,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) /* calculate new value and apply snapping */ switch (rc->subtype) { + case PROP_NONE: case PROP_DISTANCE: new_value = dist; if (snap) new_value = ((int)new_value + 5) / 10 * 10; From 42feb45c5fad1e0fbfe16e21b9df04ada0b045f6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Feb 2013 11:04:52 +0000 Subject: [PATCH 065/157] report [#33731] Fastorigin addon crashes on mesh.update() add a warning when python leaves the modified mesh without calling bmesh.update_edit_mesh()s. this doesn't fix the crash but points to the likely cause. --- source/blender/python/bmesh/bmesh_py_types.c | 54 ++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index a573c4ae75f..2d6f5ddfbed 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -50,6 +50,8 @@ #include "bmesh_py_types_customdata.h" #include "bmesh_py_types_meshdata.h" +static void bm_dealloc_editmode_warn(BPy_BMesh *self); + /* Common Flags * ************ */ @@ -832,6 +834,8 @@ static PyObject *bpy_bmesh_free(BPy_BMesh *self) if (self->bm) { BMesh *bm = self->bm; + bm_dealloc_editmode_warn(self); + if ((self->flag & BPY_BMFLAG_IS_WRAPPED) == 0) { BM_mesh_free(bm); } @@ -2813,6 +2817,8 @@ static void bpy_bmesh_dealloc(BPy_BMesh *self) /* have have been freed by bmesh */ if (bm) { + bm_dealloc_editmode_warn(self); + BM_data_layer_free(bm, &bm->vdata, CD_BM_ELEM_PYPTR); BM_data_layer_free(bm, &bm->edata, CD_BM_ELEM_PYPTR); BM_data_layer_free(bm, &bm->pdata, CD_BM_ELEM_PYPTR); @@ -3623,3 +3629,51 @@ char *BPy_BMElem_StringFromHType(const char htype) static char ret[32]; return BPy_BMElem_StringFromHType_ex(htype, ret); } + + +/* -------------------------------------------------------------------- */ +/* keep at bottom */ +/* BAD INCLUDES */ + +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_tessmesh.h" +#include "DNA_scene_types.h" +#include "DNA_object_types.h" +#include "DNA_mesh_types.h" +#include "MEM_guardedalloc.h" + +/* there are cases where this warning isnt needed, otherwise it could be made into an error */ +static void bm_dealloc_warn(const char *mesh_name) +{ + PySys_WriteStdout("Modified BMesh '%.200s' from a wrapped editmesh is freed without a call " + "to bmesh.update_edit_mesh(mesh, destructive=True), this is will likely cause a crash\n", + mesh_name); +} + +/* this function is called on free, it should stay quite fast */ +static void bm_dealloc_editmode_warn(BPy_BMesh *self) +{ + if (self->flag & BPY_BMFLAG_IS_WRAPPED) { + /* likely editmesh */ + BMesh *bm = self->bm; + Scene *scene; + for(scene = G.main->scene.first; scene; scene = scene->id.next) { + Base *base = scene->basact; + if (base && base->object->type == OB_MESH) { + Mesh *me = base->object->data; + BMEditMesh *em = me->edit_btmesh; + if (em && em->bm == bm) { + /* not foolproof, scripter may have added/removed verts */ + if (((em->vert_index && (MEM_allocN_len(em->vert_index) / sizeof(*em->vert_index)) != bm->totvert)) || + ((em->edge_index && (MEM_allocN_len(em->edge_index) / sizeof(*em->edge_index)) != bm->totedge)) || + ((em->face_index && (MEM_allocN_len(em->face_index) / sizeof(*em->face_index)) != bm->totface))) + { + bm_dealloc_warn(me->id.name + 2); + break; + } + } + } + } + } +} From a9cebb2555e18741f5fe218034036a31f69439ea Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Feb 2013 11:44:02 +0000 Subject: [PATCH 066/157] SCons: no need to do data-to-c when building cudakernels only --- SConstruct | 153 +++++++++++++++++++++++++++-------------------------- 1 file changed, 77 insertions(+), 76 deletions(-) diff --git a/SConstruct b/SConstruct index acf948fe970..648d04e9ccd 100644 --- a/SConstruct +++ b/SConstruct @@ -517,88 +517,89 @@ def data_to_c_simple(FILE_FROM): data_to_c(FILE_FROM, FILE_TO, VAR_NAME) -data_to_c("source/blender/compositor/operations/COM_OpenCLKernels.cl", - B.root_build_dir + "data_headers/COM_OpenCLKernels.cl.h", - "datatoc_COM_OpenCLKernels_cl") +if B.targets != ['cudakernels']: + data_to_c("source/blender/compositor/operations/COM_OpenCLKernels.cl", + B.root_build_dir + "data_headers/COM_OpenCLKernels.cl.h", + "datatoc_COM_OpenCLKernels_cl") -data_to_c_simple("release/datafiles/startup.blend") -data_to_c_simple("release/datafiles/preview.blend") -data_to_c_simple("release/datafiles/preview_cycles.blend") + data_to_c_simple("release/datafiles/startup.blend") + data_to_c_simple("release/datafiles/preview.blend") + data_to_c_simple("release/datafiles/preview_cycles.blend") -# --- glsl --- -data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl") -data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vertex.glsl") -data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl") -data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl") -data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl") -data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl") -data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl") + # --- glsl --- + data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl") + data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vertex.glsl") + data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl") + data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl") + data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl") + data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl") + data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl") -# --- blender --- -data_to_c_simple("release/datafiles/bfont.pfb") -data_to_c_simple("release/datafiles/bfont.ttf") -data_to_c_simple("release/datafiles/bmonofont.ttf") + # --- blender --- + data_to_c_simple("release/datafiles/bfont.pfb") + data_to_c_simple("release/datafiles/bfont.ttf") + data_to_c_simple("release/datafiles/bmonofont.ttf") -data_to_c_simple("release/datafiles/splash.png") -data_to_c_simple("release/datafiles/blender_icons16.png") -data_to_c_simple("release/datafiles/blender_icons32.png") -data_to_c_simple("release/datafiles/prvicons.png") + data_to_c_simple("release/datafiles/splash.png") + data_to_c_simple("release/datafiles/blender_icons16.png") + data_to_c_simple("release/datafiles/blender_icons32.png") + data_to_c_simple("release/datafiles/prvicons.png") -data_to_c_simple("release/datafiles/brushicons/add.png") -data_to_c_simple("release/datafiles/brushicons/blob.png") -data_to_c_simple("release/datafiles/brushicons/blur.png") -data_to_c_simple("release/datafiles/brushicons/clay.png") -data_to_c_simple("release/datafiles/brushicons/claystrips.png") -data_to_c_simple("release/datafiles/brushicons/clone.png") -data_to_c_simple("release/datafiles/brushicons/crease.png") -data_to_c_simple("release/datafiles/brushicons/darken.png") -data_to_c_simple("release/datafiles/brushicons/draw.png") -data_to_c_simple("release/datafiles/brushicons/fill.png") -data_to_c_simple("release/datafiles/brushicons/flatten.png") -data_to_c_simple("release/datafiles/brushicons/grab.png") -data_to_c_simple("release/datafiles/brushicons/inflate.png") -data_to_c_simple("release/datafiles/brushicons/layer.png") -data_to_c_simple("release/datafiles/brushicons/lighten.png") -data_to_c_simple("release/datafiles/brushicons/mask.png") -data_to_c_simple("release/datafiles/brushicons/mix.png") -data_to_c_simple("release/datafiles/brushicons/multiply.png") -data_to_c_simple("release/datafiles/brushicons/nudge.png") -data_to_c_simple("release/datafiles/brushicons/pinch.png") -data_to_c_simple("release/datafiles/brushicons/scrape.png") -data_to_c_simple("release/datafiles/brushicons/smear.png") -data_to_c_simple("release/datafiles/brushicons/smooth.png") -data_to_c_simple("release/datafiles/brushicons/snake_hook.png") -data_to_c_simple("release/datafiles/brushicons/soften.png") -data_to_c_simple("release/datafiles/brushicons/subtract.png") -data_to_c_simple("release/datafiles/brushicons/texdraw.png") -data_to_c_simple("release/datafiles/brushicons/thumb.png") -data_to_c_simple("release/datafiles/brushicons/twist.png") -data_to_c_simple("release/datafiles/brushicons/vertexdraw.png") + data_to_c_simple("release/datafiles/brushicons/add.png") + data_to_c_simple("release/datafiles/brushicons/blob.png") + data_to_c_simple("release/datafiles/brushicons/blur.png") + data_to_c_simple("release/datafiles/brushicons/clay.png") + data_to_c_simple("release/datafiles/brushicons/claystrips.png") + data_to_c_simple("release/datafiles/brushicons/clone.png") + data_to_c_simple("release/datafiles/brushicons/crease.png") + data_to_c_simple("release/datafiles/brushicons/darken.png") + data_to_c_simple("release/datafiles/brushicons/draw.png") + data_to_c_simple("release/datafiles/brushicons/fill.png") + data_to_c_simple("release/datafiles/brushicons/flatten.png") + data_to_c_simple("release/datafiles/brushicons/grab.png") + data_to_c_simple("release/datafiles/brushicons/inflate.png") + data_to_c_simple("release/datafiles/brushicons/layer.png") + data_to_c_simple("release/datafiles/brushicons/lighten.png") + data_to_c_simple("release/datafiles/brushicons/mask.png") + data_to_c_simple("release/datafiles/brushicons/mix.png") + data_to_c_simple("release/datafiles/brushicons/multiply.png") + data_to_c_simple("release/datafiles/brushicons/nudge.png") + data_to_c_simple("release/datafiles/brushicons/pinch.png") + data_to_c_simple("release/datafiles/brushicons/scrape.png") + data_to_c_simple("release/datafiles/brushicons/smear.png") + data_to_c_simple("release/datafiles/brushicons/smooth.png") + data_to_c_simple("release/datafiles/brushicons/snake_hook.png") + data_to_c_simple("release/datafiles/brushicons/soften.png") + data_to_c_simple("release/datafiles/brushicons/subtract.png") + data_to_c_simple("release/datafiles/brushicons/texdraw.png") + data_to_c_simple("release/datafiles/brushicons/thumb.png") + data_to_c_simple("release/datafiles/brushicons/twist.png") + data_to_c_simple("release/datafiles/brushicons/vertexdraw.png") -data_to_c_simple("release/datafiles/matcaps/mc01.jpg") -data_to_c_simple("release/datafiles/matcaps/mc02.jpg") -data_to_c_simple("release/datafiles/matcaps/mc03.jpg") -data_to_c_simple("release/datafiles/matcaps/mc04.jpg") -data_to_c_simple("release/datafiles/matcaps/mc05.jpg") -data_to_c_simple("release/datafiles/matcaps/mc06.jpg") -data_to_c_simple("release/datafiles/matcaps/mc07.jpg") -data_to_c_simple("release/datafiles/matcaps/mc08.jpg") -data_to_c_simple("release/datafiles/matcaps/mc09.jpg") -data_to_c_simple("release/datafiles/matcaps/mc10.jpg") -data_to_c_simple("release/datafiles/matcaps/mc11.jpg") -data_to_c_simple("release/datafiles/matcaps/mc12.jpg") -data_to_c_simple("release/datafiles/matcaps/mc13.jpg") -data_to_c_simple("release/datafiles/matcaps/mc14.jpg") -data_to_c_simple("release/datafiles/matcaps/mc15.jpg") -data_to_c_simple("release/datafiles/matcaps/mc16.jpg") -data_to_c_simple("release/datafiles/matcaps/mc17.jpg") -data_to_c_simple("release/datafiles/matcaps/mc18.jpg") -data_to_c_simple("release/datafiles/matcaps/mc19.jpg") -data_to_c_simple("release/datafiles/matcaps/mc20.jpg") -data_to_c_simple("release/datafiles/matcaps/mc21.jpg") -data_to_c_simple("release/datafiles/matcaps/mc22.jpg") -data_to_c_simple("release/datafiles/matcaps/mc23.jpg") -data_to_c_simple("release/datafiles/matcaps/mc24.jpg") + data_to_c_simple("release/datafiles/matcaps/mc01.jpg") + data_to_c_simple("release/datafiles/matcaps/mc02.jpg") + data_to_c_simple("release/datafiles/matcaps/mc03.jpg") + data_to_c_simple("release/datafiles/matcaps/mc04.jpg") + data_to_c_simple("release/datafiles/matcaps/mc05.jpg") + data_to_c_simple("release/datafiles/matcaps/mc06.jpg") + data_to_c_simple("release/datafiles/matcaps/mc07.jpg") + data_to_c_simple("release/datafiles/matcaps/mc08.jpg") + data_to_c_simple("release/datafiles/matcaps/mc09.jpg") + data_to_c_simple("release/datafiles/matcaps/mc10.jpg") + data_to_c_simple("release/datafiles/matcaps/mc11.jpg") + data_to_c_simple("release/datafiles/matcaps/mc12.jpg") + data_to_c_simple("release/datafiles/matcaps/mc13.jpg") + data_to_c_simple("release/datafiles/matcaps/mc14.jpg") + data_to_c_simple("release/datafiles/matcaps/mc15.jpg") + data_to_c_simple("release/datafiles/matcaps/mc16.jpg") + data_to_c_simple("release/datafiles/matcaps/mc17.jpg") + data_to_c_simple("release/datafiles/matcaps/mc18.jpg") + data_to_c_simple("release/datafiles/matcaps/mc19.jpg") + data_to_c_simple("release/datafiles/matcaps/mc20.jpg") + data_to_c_simple("release/datafiles/matcaps/mc21.jpg") + data_to_c_simple("release/datafiles/matcaps/mc22.jpg") + data_to_c_simple("release/datafiles/matcaps/mc23.jpg") + data_to_c_simple("release/datafiles/matcaps/mc24.jpg") ##### END DATAFILES ########## From 7c3ce049ed55a756fbec1943bb5b7615a74f6c9c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Feb 2013 11:45:16 +0000 Subject: [PATCH 067/157] Fix incorrect display of Sequence layer when rendering animation and float/byte render results were mixed. --- source/blender/blenkernel/intern/image.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 018cd25187a..de85cb54cfd 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2737,6 +2737,14 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ if (rres.have_combined && layer == 0) { /* pass */ } + else if (rect && layer == 0) { + /* rect32 is set when there's a Sequence pass, this pass seems + * to have layer=0 (this is from image_buttons.c) + * in this case we ignore float buffer, because it could have + * hung from previous pass which was float + */ + rectf = NULL; + } else if (rres.layers.first) { RenderLayer *rl = BLI_findlink(&rres.layers, layer - (rres.have_combined ? 1 : 0)); if (rl) { From b3b993127681eac85c88d1cd7ceb0e235b54bdb8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Feb 2013 13:06:52 +0000 Subject: [PATCH 068/157] Fix #34205: Cycles: Zooming in rendered mode during update out of sync with intended zoom Made sure no pause_cond.wait() happens at the same time as session as resetting. --- intern/cycles/render/session.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 94cb69102d2..7a40e0d04b6 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -132,6 +132,8 @@ bool Session::ready_to_reset() void Session::reset_gpu(BufferParams& buffer_params, int samples) { + thread_scoped_lock pause_lock(pause_mutex); + /* block for buffer acces and reset immediately. we can't do this * in the thread, because we need to allocate an OpenGL buffer, and * that only works in the main thread */ @@ -295,6 +297,7 @@ void Session::run_gpu() void Session::reset_cpu(BufferParams& buffer_params, int samples) { thread_scoped_lock reset_lock(delayed_reset.mutex); + thread_scoped_lock pause_lock(pause_mutex); display_outdated = true; reset_time = time_dt(); @@ -484,7 +487,16 @@ void Session::run_cpu() * wait for pause condition notify to wake up again */ thread_scoped_lock pause_lock(pause_mutex); - if(pause || no_tiles) { + if(!pause && delayed_reset.do_reset) { + /* reset once to start */ + thread_scoped_lock reset_lock(delayed_reset.mutex); + thread_scoped_lock buffers_lock(buffers_mutex); + thread_scoped_lock display_lock(display_mutex); + + reset_(delayed_reset.params, delayed_reset.samples); + delayed_reset.do_reset = false; + } + else if(pause || no_tiles) { update_status_time(pause, no_tiles); while(1) { From 45c70acd2772fa9716b3116dbe2ffba5aab42cd3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Feb 2013 13:48:04 +0000 Subject: [PATCH 069/157] Fix some (quite harmless) use of uninitialized memory reported by valgrind. --- intern/cycles/bvh/bvh.cpp | 6 +++++- intern/cycles/render/buffers.cpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 011406344ea..500b07f755b 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -340,6 +340,10 @@ void BVH::pack_primitives() Object *ob = objects[tob]; pack.prim_visibility[i] = ob->visibility; } + else { + memset(&pack.tri_woop[i * nsize], 0, sizeof(float4)*3); + pack.prim_visibility[i] = 0; + } } } @@ -476,7 +480,7 @@ void BVH::pack_instances(size_t nodes_size) } /* merge nodes */ - if( bvh->pack.nodes.size()) { + if(bvh->pack.nodes.size()) { size_t nsize_bbox = (use_qbvh)? nsize-2: nsize-1; int4 *bvh_nodes = &bvh->pack.nodes[0]; size_t bvh_nodes_size = bvh->pack.nodes.size(); diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index 3b61ccd176d..572cfae45cd 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -83,6 +83,7 @@ RenderTile::RenderTile() w = 0; h = 0; + sample = 0; start_sample = 0; num_samples = 0; resolution = 0; From 08cf8865aa8d38f6e7a298ab02428cade19dc50f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 12 Feb 2013 14:36:08 +0000 Subject: [PATCH 070/157] And we now have a valid korean translation! --- release/scripts/modules/bl_i18n_utils/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index d9e0de64622..9fdff5e8a76 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -93,7 +93,7 @@ LANGUAGES_FILE = "languages" IMPORT_MIN_LEVEL = -1 # Languages in /branches we do not want to import in /trunk currently... -IMPORT_LANGUAGES_SKIP = {'am', 'bg', 'fi', 'el', 'et', 'ko', 'ne', 'pl', 'ro', 'uz', 'uz@cyrillic'} +IMPORT_LANGUAGES_SKIP = {'am', 'bg', 'fi', 'el', 'et', 'ne', 'pl', 'ro', 'uz', 'uz@cyrillic'} # The comment prefix used in generated messages.txt file. MSG_COMMENT_PREFIX = "#~ " From 7dbce1930ab6a15d7e936e06f734b3fab6a5a56b Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 12 Feb 2013 14:42:46 +0000 Subject: [PATCH 071/157] Reports #34042 and #33749 Tweak for new option for Relative Bone parenting (which transforms child object based on rest pose, so you can change bones in editmode to define pivot) In the original commit it was made default, but that was too invisble for users. Now it's an option in the Make Parent menu to choose. Communicates a new feature better. --- source/blender/editors/armature/editarmature.c | 4 ++-- source/blender/editors/include/ED_object.h | 1 + source/blender/editors/object/object_relations.c | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 3bcb4002ece..06e00cd02c1 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -2268,7 +2268,7 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) BLI_addtail(arm->edbo, bone); - bone->flag |= BONE_TIPSEL | BONE_RELATIVE_PARENTING; + bone->flag |= BONE_TIPSEL; bone->weight = 1.0f; bone->dist = 0.25f; bone->xwidth = 0.1f; @@ -3422,7 +3422,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) copy_v3_v3(newbone->tail, ebone->head); newbone->parent = ebone->parent; - newbone->flag = BONE_TIPSEL | BONE_RELATIVE_PARENTING; + newbone->flag = BONE_TIPSEL; if (newbone->parent && (ebone->flag & BONE_CONNECTED)) { newbone->flag |= BONE_CONNECTED; diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 533bfe2fa20..e212f2cc17d 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -83,6 +83,7 @@ typedef enum eParentType { PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO, PAR_BONE, + PAR_BONE_RELATIVE, PAR_CURVE, PAR_FOLLOW, PAR_PATH_CONST, diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 33b159f3cf2..ce37fd79d55 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -35,6 +35,7 @@ #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" +#include "DNA_armature_types.h" #include "DNA_mesh_types.h" #include "DNA_constraint_types.h" #include "DNA_group_types.h" @@ -578,6 +579,7 @@ EnumPropertyItem prop_make_parent_types[] = { {PAR_ARMATURE_AUTO, "ARMATURE_AUTO", 0, " With Automatic Weights", ""}, {PAR_ARMATURE_ENVELOPE, "ARMATURE_ENVELOPE", 0, " With Envelope Weights", ""}, {PAR_BONE, "BONE", 0, "Bone", ""}, + {PAR_BONE_RELATIVE, "BONE_RELATIVE", 0, "Bone Relative", ""}, {PAR_CURVE, "CURVE", 0, "Curve Deform", ""}, {PAR_FOLLOW, "FOLLOW", 0, "Follow Path", ""}, {PAR_PATH_CONST, "PATH_CONST", 0, "Path Constraint", ""}, @@ -624,7 +626,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object partype = PAR_OBJECT; } } - else if (partype == PAR_BONE) { + else if (ELEM(partype, PAR_BONE, PAR_BONE_RELATIVE)) { pchan = BKE_pose_channel_active(par); if (pchan == NULL) { @@ -705,8 +707,16 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object } } } - else if (partype == PAR_BONE) + else if (partype == PAR_BONE) { ob->partype = PARBONE; /* note, dna define, not operator property */ + if (pchan->bone) + pchan->bone->flag &= ~BONE_RELATIVE_PARENTING; + } + else if (partype == PAR_BONE_RELATIVE) { + ob->partype = PARBONE; /* note, dna define, not operator property */ + if (pchan->bone) + pchan->bone->flag |= BONE_RELATIVE_PARENTING; + } else ob->partype = PAROBJECT; /* note, dna define, not operator property */ @@ -815,6 +825,7 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSE uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_ENVELOPE); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_AUTO); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_BONE); + uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_BONE_RELATIVE); } else if (ob->type == OB_CURVE) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_CURVE); From ca0e18f88b7628a44251761bc5b012ebd7bd19f7 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Tue, 12 Feb 2013 14:45:55 +0000 Subject: [PATCH 072/157] rigidbody: Clean up wm notifiers in rigid body operators Remore group notifiers, they're already sent by add/remove group operators. Add pointcache notifiers. Fixes UI not being updated properly in some cases. --- source/blender/editors/physics/rigidbody_constraint.c | 2 -- source/blender/editors/physics/rigidbody_object.c | 7 ++----- source/blender/editors/physics/rigidbody_world.c | 3 --- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index b2f53379090..a72a409f277 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -133,7 +133,6 @@ static int rigidbody_con_add_exec(bContext *C, wmOperator *op) DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -181,7 +180,6 @@ static int rigidbody_con_remove_exec(bContext *C, wmOperator *op) DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index 9ce4656d4cd..092c3370dbf 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -154,7 +154,6 @@ static int rigidbody_ob_add_exec(bContext *C, wmOperator *op) DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -201,7 +200,6 @@ static int rigidbody_ob_remove_exec(bContext *C, wmOperator *op) DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -247,7 +245,7 @@ static int rigidbody_obs_add_exec(bContext *C, wmOperator *op) DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL); /* done */ return OPERATOR_FINISHED; @@ -293,8 +291,7 @@ static int rigidbody_obs_remove_exec(bContext *C, wmOperator *UNUSED(op)) /* send updates */ DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL); /* done */ return OPERATOR_FINISHED; diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c index 5ab8e7697c5..babe32c74b2 100644 --- a/source/blender/editors/physics/rigidbody_world.c +++ b/source/blender/editors/physics/rigidbody_world.c @@ -128,9 +128,6 @@ static int rigidbody_world_remove_exec(bContext *C, wmOperator *op) BKE_rigidbody_free_world(rbw); scene->rigidbody_world = NULL; - /* send updates */ - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); - /* done */ return OPERATOR_FINISHED; } From 92b6a54e5036db83146a3e28de78b65d5c4cffc5 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Tue, 12 Feb 2013 14:45:57 +0000 Subject: [PATCH 073/157] rigidbody: Don't cancel add operator if rigid body already exists In some cases objects might have rigid bodies but aren't in the rigid body group, just add objects to the group then. Also allow changing the rigid body type by using the add acive/passive buttons. This avoids having to remove objects just to change type. --- source/blender/editors/physics/rigidbody_object.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index 092c3370dbf..2bf962f4f4a 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -93,11 +93,6 @@ void ED_rigidbody_ob_add(wmOperator *op, Scene *scene, Object *ob, int type) { RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene); - /* check that object doesn't already belong to the current simulation */ - if (ob->rigidbody_object) { - BKE_reportf(op->reports, RPT_INFO, "Object '%s' already has a Rigid Body", ob->id.name + 2); - return; - } if (ob->type != OB_MESH) { BKE_report(op->reports, RPT_ERROR, "Can't add Rigid Body to non mesh object"); return; @@ -118,11 +113,16 @@ void ED_rigidbody_ob_add(wmOperator *op, Scene *scene, Object *ob, int type) } /* make rigidbody object settings */ - ob->rigidbody_object = BKE_rigidbody_create_object(scene, ob, type); + if (ob->rigidbody_object == NULL) { + ob->rigidbody_object = BKE_rigidbody_create_object(scene, ob, type); + } + ob->rigidbody_object->type = type; ob->rigidbody_object->flag |= RBO_FLAG_NEEDS_VALIDATE; /* add object to rigid body group */ add_to_group(rbw->group, ob, scene, NULL); + + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } void ED_rigidbody_ob_remove(Scene *scene, Object *ob) From c3c4ef3c6f09f10b29074225e412ae7ce67e8955 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Tue, 12 Feb 2013 14:45:59 +0000 Subject: [PATCH 074/157] rigidbody: No need to update mass when changing rigid body type --- source/blender/makesrna/intern/rna_rigidbody.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c index b737410bbab..7270ccadb81 100644 --- a/source/blender/makesrna/intern/rna_rigidbody.c +++ b/source/blender/makesrna/intern/rna_rigidbody.c @@ -163,13 +163,6 @@ static void rna_RigidBodyOb_type_set(PointerRNA *ptr, int value) rbo->type = value; rbo->flag |= RBO_FLAG_NEEDS_VALIDATE; - -#ifdef WITH_BULLET - /* do physics sim updates */ - if (rbo->physics_object) { - RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo)); - } -#endif } static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, int value) From d095bcc8aa9ec60e537ed86b48f1025623cb2b38 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Feb 2013 14:58:46 +0000 Subject: [PATCH 075/157] Fix cycles not using SSE3 kernel after recent, order with SSE2 should be switched, pointed out by Chad Fraleigh. --- intern/cycles/device/device_cpu.cpp | 62 ++++++++++++++--------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 1915245bb55..c2ba91faf69 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -171,26 +171,7 @@ public: int end_sample = tile.start_sample + tile.num_samples; #ifdef WITH_OPTIMIZED_KERNEL - if(system_cpu_support_sse2()) { - for(int sample = start_sample; sample < end_sample; sample++) { - if (task.get_cancel() || task_pool.cancelled()) { - if(task.need_finish_queue == false) - break; - } - - for(int y = tile.y; y < tile.y + tile.h; y++) { - for(int x = tile.x; x < tile.x + tile.w; x++) { - kernel_cpu_sse2_path_trace(&kg, render_buffer, rng_state, - sample, x, y, tile.offset, tile.stride); - } - } - - tile.sample = sample + 1; - - task.update_progress(tile); - } - } - else if(system_cpu_support_sse3()) { + if(system_cpu_support_sse3()) { for(int sample = start_sample; sample < end_sample; sample++) { if (task.get_cancel() || task_pool.cancelled()) { if(task.need_finish_queue == false) @@ -209,6 +190,25 @@ public: task.update_progress(tile); } } + else if(system_cpu_support_sse2()) { + for(int sample = start_sample; sample < end_sample; sample++) { + if (task.get_cancel() || task_pool.cancelled()) { + if(task.need_finish_queue == false) + break; + } + + for(int y = tile.y; y < tile.y + tile.h; y++) { + for(int x = tile.x; x < tile.x + tile.w; x++) { + kernel_cpu_sse2_path_trace(&kg, render_buffer, rng_state, + sample, x, y, tile.offset, tile.stride); + } + } + + tile.sample = sample + 1; + + task.update_progress(tile); + } + } else #endif { @@ -247,18 +247,18 @@ public: void thread_tonemap(DeviceTask& task) { #ifdef WITH_OPTIMIZED_KERNEL - if(system_cpu_support_sse2()) { - for(int y = task.y; y < task.y + task.h; y++) - for(int x = task.x; x < task.x + task.w; x++) - kernel_cpu_sse2_tonemap(&kernel_globals, (uchar4*)task.rgba, (float*)task.buffer, - task.sample, task.resolution, x, y, task.offset, task.stride); - } - else if(system_cpu_support_sse3()) { + if(system_cpu_support_sse3()) { for(int y = task.y; y < task.y + task.h; y++) for(int x = task.x; x < task.x + task.w; x++) kernel_cpu_sse3_tonemap(&kernel_globals, (uchar4*)task.rgba, (float*)task.buffer, task.sample, task.resolution, x, y, task.offset, task.stride); } + else if(system_cpu_support_sse2()) { + for(int y = task.y; y < task.y + task.h; y++) + for(int x = task.x; x < task.x + task.w; x++) + kernel_cpu_sse2_tonemap(&kernel_globals, (uchar4*)task.rgba, (float*)task.buffer, + task.sample, task.resolution, x, y, task.offset, task.stride); + } else #endif { @@ -278,17 +278,17 @@ public: #endif #ifdef WITH_OPTIMIZED_KERNEL - if(system_cpu_support_sse2()) { + if(system_cpu_support_sse3()) { for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) { - kernel_cpu_sse2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x); + kernel_cpu_sse3_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x); if(task_pool.cancelled()) break; } } - else if(system_cpu_support_sse3()) { + else if(system_cpu_support_sse2()) { for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) { - kernel_cpu_sse3_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x); + kernel_cpu_sse2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x); if(task_pool.cancelled()) break; From 5354998a215ec1900ec401ecdb01aae61fa02f5e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Feb 2013 14:58:58 +0000 Subject: [PATCH 076/157] Fix #34213: crash loading openexr multilayer with use alpha disabled. --- source/blender/imbuf/intern/rectop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index d2b0645cf93..cae705ae798 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -594,11 +594,17 @@ void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, i void IMB_rectfill_alpha(ImBuf *ibuf, const float value) { int i; + if (ibuf->rect_float) { - float *fbuf = ibuf->rect_float + 3; + float *fbuf; + + if (ibuf->channels != 4) return; + + fbuf = ibuf->rect_float + 3; for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf += 4) { *fbuf = value; } } - else { + + if (ibuf->rect) { const unsigned char cvalue = value * 255; unsigned char *cbuf = ((unsigned char *)ibuf->rect) + 3; for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf += 4) { *cbuf = cvalue; } From 4f1cf942592c0baba3283ebf5400d126cadd0cc6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Feb 2013 14:59:00 +0000 Subject: [PATCH 077/157] Fix render layer previous/next buttons not respecting DPI. --- source/blender/editors/space_image/image_buttons.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index afae9535fee..6a0f413b4fe 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -498,17 +498,17 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, } /* decrease, increase arrows */ - but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 17, 20, NULL, 0, 0, 0, 0, TIP_("Previous Layer")); + but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 0.85*UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Layer")); uiButSetFunc(but, image_multi_declay_cb, rr, iuser); - but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 18, 20, NULL, 0, 0, 0, 0, TIP_("Next Layer")); + but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 0.90*UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Layer")); uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); uiblock_layer_pass_buttons(row, rr, iuser, 230 * dpi_fac, render_slot); /* decrease, increase arrows */ - but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 17, 20, NULL, 0, 0, 0, 0, TIP_("Previous Pass")); + but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 0.85*UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Pass")); uiButSetFunc(but, image_multi_decpass_cb, rr, iuser); - but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 18, 20, NULL, 0, 0, 0, 0, TIP_("Next Pass")); + but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 0.90*UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Pass")); uiButSetFunc(but, image_multi_incpass_cb, rr, iuser); uiBlockEndAlign(block); From 6886ad268088a92fb8f9e694f9068dbfd75b06a4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Feb 2013 15:49:48 +0000 Subject: [PATCH 078/157] Preview image render was missing image buffer release Reported by Ton in IRC, thanks! Was hunting this one for ages! --- source/blender/editors/render/render_preview.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 22650df94fa..80dcb93a7a2 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -926,8 +926,10 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat * already there. Very expensive for large images. Need to find a way to * only get existing ibuf */ ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL); - if (ibuf == NULL || ibuf->rect == NULL) + if (ibuf == NULL || ibuf->rect == NULL) { + BKE_image_release_ibuf(ima, ibuf, NULL); return; + } icon_copy_rect(ibuf, sp->sizex, sp->sizey, sp->pr_rect); From 58a6f0764916adecb71385cd43b917f1b708b334 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 12 Feb 2013 15:51:05 +0000 Subject: [PATCH 079/157] Bug fix #34213 (2) Adding non-RGBA float buffers as texture crashes MipMap code. Images with less than 4 channels not supported (yet). Not sure if we ever should even... normals, Z, vectors, UV, Index, all don't like downsampling. --- source/blender/imbuf/intern/filter.c | 4 ++++ source/blender/render/intern/source/imagetexture.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 51fee232034..9193954f1d6 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -506,6 +506,10 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter) imb_freemipmapImBuf(ibuf); + /* no mipmap for non RGBA images */ + if (ibuf->rect_float && ibuf->channels < 4) + return; + ibuf->miptot = 1; while (curmap < IB_MIPMAP_LEVELS) { diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 55dadc14989..2827f90e4b6 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -1042,6 +1042,9 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf) IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP); BLI_unlock_thread(LOCK_IMAGE); } + /* if no mipmap could be made, fall back on non-mipmap render */ + if (ibuf->mipmap[0] == NULL) + if (tex->imaflag &= ~TEX_MIPMAP); } } From cdb8e3956517cf3bb6a4de5e6b0884cb28bd98ee Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Feb 2013 15:58:06 +0000 Subject: [PATCH 080/157] Fix for own multilayer EXR fix, should not have caused any issues might as well make sure it works if this function gets called from other places. --- source/blender/imbuf/intern/rectop.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index cae705ae798..0b739b9fe92 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -595,12 +595,8 @@ void IMB_rectfill_alpha(ImBuf *ibuf, const float value) { int i; - if (ibuf->rect_float) { - float *fbuf; - - if (ibuf->channels != 4) return; - - fbuf = ibuf->rect_float + 3; + if (ibuf->rect_float && (ibuf->channels == 4)) { + float *fbuf = ibuf->rect_float + 3; for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf += 4) { *fbuf = value; } } From e1419a5bea6fb9c4ad35689919833e9ce731edaa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Feb 2013 16:04:58 +0000 Subject: [PATCH 081/157] Fix #34126: report list memory leak when calling operator from python and the operator context poll failing. --- .../blender/windowmanager/intern/wm_event_system.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 3d510728684..7862d6286cf 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -590,6 +590,9 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) } if (wm_operator_register_check(wm, op->type)) { + /* take ownership of reports (in case python provided own) */ + op->reports->flag |= RPT_FREE; + wm_operator_register(C, op); WM_operator_region_active_win_set(C); } @@ -935,6 +938,9 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, wm_operator_finished(C, op, 0); } else if (retval & OPERATOR_RUNNING_MODAL) { + /* take ownership of reports (in case python provided own) */ + op->reports->flag |= RPT_FREE; + /* grab cursor during blocking modal ops (X11) * Also check for macro */ @@ -1170,13 +1176,6 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, short context, if (!is_undo && wm && (wm == CTX_wm_manager(C))) wm->op_undo_depth--; - /* keep the reports around if needed later */ - if ((retval & OPERATOR_RUNNING_MODAL) || - ((retval & OPERATOR_FINISHED) && wm_operator_register_check(CTX_wm_manager(C), ot))) - { - reports->flag |= RPT_FREE; /* let blender manage freeing */ - } - return retval; } From dcea2800a74ea2112e3cda5b3ff3035752ecb7ee Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Feb 2013 17:09:02 +0000 Subject: [PATCH 082/157] Fix file editor not properly scaling with DPI, this was not implemented yet. Still todo is high resolution file icons as they look a bit pixelated now. --- source/blender/editors/space_file/file_draw.c | 37 ++++++++-------- source/blender/editors/space_file/filesel.c | 43 ++++++++++--------- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 08f01b47b52..ad76fbf9200 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -335,7 +335,7 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int float scale; int ex, ey; - if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) { + if ( (imb->x*UI_DPI_FAC > layout->prv_w) || (imb->y*UI_DPI_FAC > layout->prv_h) ) { if (imb->x > imb->y) { scaledx = (float)layout->prv_w; scaledy = ( (float)imb->y / (float)imb->x) * layout->prv_w; @@ -348,10 +348,11 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int } } else { - scaledx = (float)imb->x; - scaledy = (float)imb->y; - scale = 1.0; + scaledx = (float)imb->x * UI_DPI_FAC; + scaledy = (float)imb->y * UI_DPI_FAC; + scale = UI_DPI_FAC; } + ex = (int)scaledx; ey = (int)scaledy; fx = ((float)layout->prv_w - (float)ex) / 2.0f; @@ -461,7 +462,7 @@ void file_draw_list(const bContext *C, ARegion *ar) int i; short is_icon; short align; - + int column_space = 0.6f*UI_UNIT_X; numfiles = filelist_numfiles(files); @@ -492,7 +493,7 @@ void file_draw_list(const bContext *C, ARegion *ar) for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) { ED_fileselect_layout_tilepos(layout, i, &sx, &sy); - sx += (int)(v2d->tot.xmin + 2.0f); + sx += (int)(v2d->tot.xmin + 0.1f*UI_UNIT_X); sy = (int)(v2d->tot.ymax - sy); file = filelist_file(files, i); @@ -521,13 +522,13 @@ void file_draw_list(const bContext *C, ARegion *ar) } else { file_draw_icon(block, file->path, sx, sy - (UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE); - sx += ICON_DEFAULT_WIDTH_SCALE + 4; + sx += ICON_DEFAULT_WIDTH_SCALE + 0.2f*UI_UNIT_X; } UI_ThemeColor4(TH_TEXT); if (file->selflag & EDITING_FILE) { - uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy - layout->tile_h - 3, + uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy - layout->tile_h - 0.15*UI_UNIT_X, textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, ""); uiButSetRenameFunc(but, renamebutton_cb, file); uiButSetFlag(but, UI_BUT_NO_UTF8); /* allow non utf8 names */ @@ -543,39 +544,39 @@ void file_draw_list(const bContext *C, ARegion *ar) } if (params->display == FILE_SHORTDISPLAY) { - sx += (int)layout->column_widths[COLUMN_NAME] + 12; + sx += (int)layout->column_widths[COLUMN_NAME] + column_space; if (!(file->type & S_IFDIR)) { file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); - sx += (int)layout->column_widths[COLUMN_SIZE] + 12; + sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; } } else if (params->display == FILE_LONGDISPLAY) { - sx += (int)layout->column_widths[COLUMN_NAME] + 12; + sx += (int)layout->column_widths[COLUMN_NAME] + column_space; #ifndef WIN32 /* rwx rwx rwx */ file_draw_string(sx, sy, file->mode1, layout->column_widths[COLUMN_MODE1], layout->tile_h, align); - sx += layout->column_widths[COLUMN_MODE1] + 12; + sx += layout->column_widths[COLUMN_MODE1] + column_space; file_draw_string(sx, sy, file->mode2, layout->column_widths[COLUMN_MODE2], layout->tile_h, align); - sx += layout->column_widths[COLUMN_MODE2] + 12; + sx += layout->column_widths[COLUMN_MODE2] + column_space; file_draw_string(sx, sy, file->mode3, layout->column_widths[COLUMN_MODE3], layout->tile_h, align); - sx += layout->column_widths[COLUMN_MODE3] + 12; + sx += layout->column_widths[COLUMN_MODE3] + column_space; file_draw_string(sx, sy, file->owner, layout->column_widths[COLUMN_OWNER], layout->tile_h, align); - sx += layout->column_widths[COLUMN_OWNER] + 12; + sx += layout->column_widths[COLUMN_OWNER] + column_space; #endif file_draw_string(sx, sy, file->date, layout->column_widths[COLUMN_DATE], layout->tile_h, align); - sx += (int)layout->column_widths[COLUMN_DATE] + 12; + sx += (int)layout->column_widths[COLUMN_DATE] + column_space; file_draw_string(sx, sy, file->time, layout->column_widths[COLUMN_TIME], layout->tile_h, align); - sx += (int)layout->column_widths[COLUMN_TIME] + 12; + sx += (int)layout->column_widths[COLUMN_TIME] + column_space; if (!(file->type & S_IFDIR)) { file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); - sx += (int)layout->column_widths[COLUMN_SIZE] + 12; + sx += (int)layout->column_widths[COLUMN_SIZE] + column_space; } } } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 8c45b161d26..aed7fc45e95 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -500,12 +500,12 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->textheight = textheight; if (params->display == FILE_IMGDISPLAY) { - layout->prv_w = 96; - layout->prv_h = 96; - layout->tile_border_x = 6; - layout->tile_border_y = 6; - layout->prv_border_x = 6; - layout->prv_border_y = 6; + layout->prv_w = 4.8f*UI_UNIT_X; + layout->prv_h = 4.8f*UI_UNIT_Y; + layout->tile_border_x = 0.3f*UI_UNIT_X; + layout->tile_border_y = 0.3f*UI_UNIT_X; + layout->prv_border_x = 0.3f*UI_UNIT_X; + layout->prv_border_y = 0.3f*UI_UNIT_Y; layout->tile_w = layout->prv_w + 2 * layout->prv_border_x; layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight; layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x); @@ -520,10 +520,13 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->flag = FILE_LAYOUT_VER; } else { + int column_space = 0.6f*UI_UNIT_X; + int column_icon_space = 0.2f*UI_UNIT_X; + layout->prv_w = 0; layout->prv_h = 0; - layout->tile_border_x = 8; - layout->tile_border_y = 2; + layout->tile_border_x = 0.4f*UI_UNIT_X; + layout->tile_border_y = 0.1f*UI_UNIT_Y; layout->prv_border_x = 0; layout->prv_border_y = 0; layout->tile_h = textheight * 3 / 2; @@ -533,22 +536,22 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) column_widths(sfile->files, layout); if (params->display == FILE_SHORTDISPLAY) { - maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + - (int)layout->column_widths[COLUMN_NAME] + 12 + - (int)layout->column_widths[COLUMN_SIZE] + 12; + maxlen = ICON_DEFAULT_WIDTH_SCALE + column_icon_space + + (int)layout->column_widths[COLUMN_NAME] + column_space + + (int)layout->column_widths[COLUMN_SIZE] + column_space; } else { - maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + - (int)layout->column_widths[COLUMN_NAME] + 12 + + maxlen = ICON_DEFAULT_WIDTH_SCALE + column_icon_space + + (int)layout->column_widths[COLUMN_NAME] + column_space + #ifndef WIN32 - (int)layout->column_widths[COLUMN_MODE1] + 12 + - (int)layout->column_widths[COLUMN_MODE2] + 12 + - (int)layout->column_widths[COLUMN_MODE3] + 12 + - (int)layout->column_widths[COLUMN_OWNER] + 12 + + (int)layout->column_widths[COLUMN_MODE1] + column_space + + (int)layout->column_widths[COLUMN_MODE2] + column_space + + (int)layout->column_widths[COLUMN_MODE3] + column_space + + (int)layout->column_widths[COLUMN_OWNER] + column_space + #endif - (int)layout->column_widths[COLUMN_DATE] + 12 + - (int)layout->column_widths[COLUMN_TIME] + 12 + - (int)layout->column_widths[COLUMN_SIZE] + 12; + (int)layout->column_widths[COLUMN_DATE] + column_space + + (int)layout->column_widths[COLUMN_TIME] + column_space + + (int)layout->column_widths[COLUMN_SIZE] + column_space; } layout->tile_w = maxlen; From f2d9fc7e25e4eb45e42469f8b9d143ceb70e3c3c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 12 Feb 2013 17:32:54 +0000 Subject: [PATCH 083/157] Update to how similar messages matching is handled when updating po files from pot one (gain something like 20% in heavy update situations, and save a nice bunch of memory!). --- .../modules/bl_i18n_utils/bl_process_msg.py | 2 +- .../bl_i18n_utils/spell_check_utils.py | 1 + .../modules/bl_i18n_utils/update_po.py | 11 +- .../scripts/modules/bl_i18n_utils/utils.py | 111 ++++++++++++++---- 4 files changed, 96 insertions(+), 29 deletions(-) diff --git a/release/scripts/modules/bl_i18n_utils/bl_process_msg.py b/release/scripts/modules/bl_i18n_utils/bl_process_msg.py index f0adc700a45..5381af8d543 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_process_msg.py +++ b/release/scripts/modules/bl_i18n_utils/bl_process_msg.py @@ -387,7 +387,7 @@ def dump_py_messages_from_files(messages, check_ctxt, files): estr_ls.append(estr) nds_ls.extend(nds) ret = _extract_string_merge(estr_ls, nds_ls) - print(ret) + #print(ret) return ret def extract_strings_split(node): diff --git a/release/scripts/modules/bl_i18n_utils/spell_check_utils.py b/release/scripts/modules/bl_i18n_utils/spell_check_utils.py index 2aa3598e4a1..f2d777d22f1 100644 --- a/release/scripts/modules/bl_i18n_utils/spell_check_utils.py +++ b/release/scripts/modules/bl_i18n_utils/spell_check_utils.py @@ -225,6 +225,7 @@ dict_uimsgs = { "loc", "rot", "pos", "lorem", "luma", + "mem", "multicam", "num", "ok", diff --git a/release/scripts/modules/bl_i18n_utils/update_po.py b/release/scripts/modules/bl_i18n_utils/update_po.py index 6e03226f6d3..eb12782264a 100755 --- a/release/scripts/modules/bl_i18n_utils/update_po.py +++ b/release/scripts/modules/bl_i18n_utils/update_po.py @@ -97,10 +97,13 @@ def main(): if os.path.exists(po): pool_data.append((po, lang, pot_msgs)) - with concurrent.futures.ProcessPoolExecutor() as executor: - for r in executor.map(process_po, pool_data, timeout=600): - if r != 0: - ret = r + for r in map(process_po, pool_data): + if r != 0: + ret = r + #with concurrent.futures.ProcessPoolExecutor() as executor: + #for r in executor.map(process_po, pool_data, timeout=600): + #if r != 0: + #ret = r return ret diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index d04e8bead7a..e74400775ae 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -21,6 +21,7 @@ # Some misc utilities... import collections +import concurrent.futures import copy import os import re @@ -61,6 +62,35 @@ def is_valid_po_path(path): return bool(_valid_po_path_re.match(path)) +def get_best_similar(data): + import difflib + key, use_similar, similar_pool = data + + # try to find some close key in existing messages... + # Optimized code inspired by difflib.get_close_matches (as we only need the best match). + # We also consider to never make a match when len differs more than -len_key / 2, +len_key * 2 (which is valid + # as long as use_similar is not below ~0.7). + # Gives an overall ~20% of improvement! + #tmp = difflib.get_close_matches(key[1], similar_pool, n=1, cutoff=use_similar) + #if tmp: + #tmp = tmp[0] + tmp = None + s = difflib.SequenceMatcher() + s.set_seq2(key[1]) + len_key = len(key[1]) + min_len = len_key // 2 + max_len = len_key * 2 + for x in similar_pool: + if min_len < len(x) < max_len: + s.set_seq1(x) + if s.real_quick_ratio() >= use_similar and s.quick_ratio() >= use_similar: + sratio = s.ratio() + if sratio >= use_similar: + tmp = x + use_similar = sratio + return key, tmp + + class I18nMessage: """ Internal representation of a message. @@ -233,40 +263,73 @@ class I18nMessages: existing one. Messages no more found in ref will be marked as commented if keep_old_commented is True, or removed. """ - import difflib similar_pool = {} if use_similar > 0.0: for key, msg in self.msgs.items(): if msg.msgstr: # No need to waste time with void translations! similar_pool.setdefault(key[1], set()).add(key) - msgs = self._new_messages() - for (key, msg) in ref.msgs.items(): - if key in self.msgs: - msgs[key] = self.msgs[key] - msgs[key].sources = msg.sources - else: - skey = None - if use_similar > 0.0: - # try to find some close key in existing messages... - tmp = difflib.get_close_matches(key[1], similar_pool, n=1, cutoff=use_similar) - if tmp: - tmp = tmp[0] + msgs = self._new_messages().fromkeys(ref.msgs.keys()) + ref_keys = set(ref.msgs.keys()) + org_keys = set(self.msgs.keys()) + new_keys = ref_keys - org_keys + removed_keys = org_keys - ref_keys + + print(new_keys, "\n\n", removed_keys) + + # First process keys present in both org and ref messages. + for key in ref_keys - new_keys: + msg, refmsg = self.msgs[key], ref.msgs[key] + msg.sources = refmsg.sources + msg.is_commented = refmsg.is_commented + msg.is_fuzzy = refmsg.is_fuzzy + msgs[key] = msg + + # Next process new keys. + if use_similar > 0.0: + with concurrent.futures.ProcessPoolExecutor() as exctr: + for key, msgid in exctr.map(get_best_similar, + tuple((nk, use_similar, tuple(similar_pool.keys())) for nk in new_keys)): + if msgid: # Try to get the same context, else just get one... - skey = (key[0], tmp) - if skey not in similar_pool[tmp]: - skey = tuple(similar_pool[tmp])[0] - msgs[key] = msg - if skey: - msgs[key].msgstr = self.msgs[skey].msgstr - msgs[key].is_fuzzy = True + skey = (key[0], msgid) + if skey not in similar_pool[msgid]: + skey = tuple(similar_pool[msgid])[0] + # We keep org translation and comments, and mark message as fuzzy. + msg, refmsg = copy.deepcopy(self.msgs[skey]), ref.msgs[key] + msg.msgctxt = refmsg.msgctxt + msg.msgid = refmsg.msgid + msg.sources = refmsg.sources + msg.is_fuzzy = True + msg.is_commented = refmsg.is_commented + msgs[key] = msg + else: + msgs[key] = ref.msgs[key] + else: + for key in new_keys: + msgs[key] = ref.msgs[key] + # Add back all "old" and already commented messages as commented ones, if required # (and translation was not void!). if keep_old_commented: - for key, msg in self.msgs.items(): - if key not in msgs and msg.msgstr: - msgs[key] = msg - msgs[key].is_commented = True + for key in removed_keys: + msgs[key] = self.msgs[key] + msgs[key].is_commented = True + msgs[key].sources = [] + + # Special 'meta' message, change project ID version and pot creation date... + key = ("", "") + rep = [] + markers = ("Project-Id-Version:", "POT-Creation-Date:") + for mrk in markers: + for rl in ref.msgs[key].msgstr_lines: + if rl.startswith(mrk): + for idx, ml in enumerate(msgs[key].msgstr_lines): + if ml.startswith(mrk): + rep.append((idx, rl)) + for idx, txt in rep: + msgs[key].msgstr_lines[idx] = txt + # And finalize the update! self.msgs = msgs From 751bee184598859d99922d228e0de4a0df96de26 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 12 Feb 2013 17:39:44 +0000 Subject: [PATCH 084/157] Composite node "Alpha over" didn't allow to be dragged wide enough. --- source/blender/nodes/composite/nodes/node_composite_alphaOver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index 2654aa94be0..3722ad179d0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -54,7 +54,7 @@ void register_node_type_cmp_alphaover(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_ALPHAOVER, "Alpha Over", NODE_CLASS_OP_COLOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_alphaover_in, cmp_node_alphaover_out); - node_type_size(&ntype, 80, 40, 120); + node_type_size(&ntype, 80, 40, 160); node_type_init(&ntype, node_alphaover_init); node_type_storage(&ntype, "NodeTwoFloats", node_free_standard_storage, node_copy_standard_storage); From 8996184ac4e96af4c7e2e46d3f836c962ccdb0b0 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Tue, 12 Feb 2013 17:52:18 +0000 Subject: [PATCH 085/157] Fixed importing of shapekey names: name is now taken from geometry name instead of deriving it from the mesh name --- source/blender/collada/ArmatureImporter.cpp | 5 ++++- source/blender/collada/GeometryExporter.cpp | 2 +- source/blender/collada/MeshImporter.cpp | 11 ++++++++++- source/blender/collada/MeshImporter.h | 4 +++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 6e8bf337abb..fefad7dd8ec 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -673,11 +673,14 @@ void ArmatureImporter::make_shape_keys() for (int i = 0 ; i < morphTargetIds.getCount() ; i++ ) { //better to have a seperate map of morph objects, //This'll do for now since only mesh morphing is imported + Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]); if (me) { me->key = key; - kb = BKE_keyblock_add_ctime(key, me->id.name, FALSE); + std::string morph_name = *this->mesh_importer->get_geometry_name(me->id.name); + + kb = BKE_keyblock_add_ctime(key, morph_name.c_str(), FALSE); BKE_key_convert_from_mesh(me, kb); //apply weights diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 19d67f37476..4a6c5b43ce2 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -187,7 +187,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) return; } - std::string geom_name = id_name(ob) + "_morph_" + kb->name; + std::string geom_name = kb->name; exportedGeometry.insert(geom_id); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index bf5a39cfae8..26915f37002 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -952,6 +952,13 @@ Mesh *MeshImporter::get_mesh_by_geom_uid(const COLLADAFW::UniqueId& mesh_uid) return NULL; } +std::string *MeshImporter::get_geometry_name(const std::string &mesh_name) +{ + if (this->mesh_geom_map.find(mesh_name) != this->mesh_geom_map.end()) + return &this->mesh_geom_map[mesh_name]; + return NULL; +} + MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture, Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map, MTex *color_texture) @@ -1300,7 +1307,9 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom) // store the Mesh pointer to link it later with an Object this->uid_mesh_map[mesh->getUniqueId()] = me; - + // needed to map mesh to its geometry name (needed for shape key naming) + this->mesh_geom_map[std::string(me->id.name)] = str_geom_id; + int new_tris = 0; read_vertices(mesh, me); diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index 5ab068160a4..d0412985540 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -60,6 +60,7 @@ class MeshImporterBase public: virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid) = 0; virtual Mesh *get_mesh_by_geom_uid(const COLLADAFW::UniqueId& mesh_uid) = 0; + virtual std::string *get_geometry_name(const std::string &mesh_name) = 0; }; class UVDataWrapper @@ -84,6 +85,7 @@ private: Scene *scene; ArmatureImporter *armature_importer; + std::map mesh_geom_map; // needed for correct shape key naming std::map uid_mesh_map; // geometry unique id-to-mesh map std::map uid_object_map; // geom uid-to-object std::vector imported_objects; // list of imported objects @@ -175,7 +177,7 @@ public: // create a mesh storing a pointer in a map so it can be retrieved later by geometry UID bool write_geometry(const COLLADAFW::Geometry* geom); - + std::string *MeshImporter::get_geometry_name(const std::string &mesh_name); }; #endif From e672e7a070e698c819a9520f7db4f3d57508c5c2 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 12 Feb 2013 19:08:04 +0000 Subject: [PATCH 086/157] Small tweak in event debug printing: - missing print for case event gets handled AND passed on (selecting) --- source/blender/windowmanager/intern/wm_event_system.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 7862d6286cf..206297d2c95 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1765,6 +1765,10 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers break; } else { + if (action & WM_HANDLER_HANDLED) + if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS)) + printf("%s: handled - and pass on! '%s'\n", __func__, kmi->idname); + #ifndef NDEBUG if (do_debug_handler) { printf("%s: un-handled '%s'...", __func__, kmi->idname); From 0e740f58bae428616d369c9e361641588f143cc7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2013 03:13:12 +0000 Subject: [PATCH 087/157] make is_quad_convex_v3() more strict, check if normal is OK before using as a rotation axis. make is_quad_convex_v2,3() check for ISECT_LINE_LINE_CROSS intersection (that the lines actually cross each other). --- source/blender/blenlib/intern/math_geom.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index ac9534dac25..618c237c8ba 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -3583,8 +3583,12 @@ int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], c /* define projection, do both trias apart, quad is undefined! */ - normal_tri_v3(nor1, v1, v2, v3); - normal_tri_v3(nor2, v1, v3, v4); + /* check normal length incase one size is zero area */ + if (UNLIKELY((normal_tri_v3(nor1, v1, v2, v3) <= FLT_EPSILON) || + (normal_tri_v3(nor2, v1, v3, v4) <= FLT_EPSILON))) + { + return false; + } /* when the face is folded over as 2 tris we probably don't want to create * a quad from it, but go ahead with the intersection test since this @@ -3606,12 +3610,12 @@ int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], c mul_v2_m3v3(vec[3], mat, v4); /* linetests, the 2 diagonals have to instersect to be convex */ - return (isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) > 0) ? TRUE : FALSE; + return (isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) == ISECT_LINE_LINE_CROSS); } int is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]) { /* linetests, the 2 diagonals have to instersect to be convex */ - return (isect_line_line_v2(v1, v3, v2, v4) > 0) ? TRUE : FALSE; + return (isect_line_line_v2(v1, v3, v2, v4) == ISECT_LINE_LINE_CROSS); } From b6a60fc6b885541733b23852cf67b74d3ad0143a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2013 03:20:30 +0000 Subject: [PATCH 088/157] revert own commit, caused regression - hanging on triangulation [#34214]. Postponing further changes for now, too risky before release when unexpected cases can cause eternal loop. --- .../blender/bmesh/operators/bmo_triangulate.c | 48 +++++++------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c index 3d78ff64876..1f04c7ce845 100644 --- a/source/blender/bmesh/operators/bmo_triangulate.c +++ b/source/blender/bmesh/operators/bmo_triangulate.c @@ -75,9 +75,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) stop = 1; BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - float v1_xy[2], v2_xy[2], v3_xy[2], v4_xy[2]; - float no[3]; - float axis_mat[3][3]; + BMVert *v1, *v2, *v3, *v4; if (!BM_edge_is_manifold(e) || !BMO_elem_flag_test(bm, e, EDGE_MARK)) { continue; @@ -88,45 +86,31 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) { continue; } - - { - float *v1, *v2, *v3, *v4; - float no_a[3], no_b[3]; - v1 = e->l->prev->v->co; - v2 = e->l->v->co; - v3 = e->l->radial_next->prev->v->co; - v4 = e->l->next->v->co; - normal_tri_v3(no_a, v1, v2, v3); - normal_tri_v3(no_b, v1, v3, v4); - add_v3_v3v3(no, no_a, no_b); - normalize_v3(no); - axis_dominant_v3_to_m3(axis_mat, no); - mul_v2_m3v3(v1_xy, axis_mat, v1); - mul_v2_m3v3(v2_xy, axis_mat, v2); - mul_v2_m3v3(v3_xy, axis_mat, v3); - mul_v2_m3v3(v4_xy, axis_mat, v4); - } + v1 = e->l->prev->v; + v2 = e->l->v; + v3 = e->l->radial_next->prev->v; + v4 = e->l->next->v; - if (is_quad_convex_v2(v1_xy, v2_xy, v3_xy, v4_xy)) { + if (is_quad_convex_v3(v1->co, v2->co, v3->co, v4->co)) { float len1, len2, len3, len4, len5, len6, opp1, opp2, fac1, fac2; /* testing rule: * the area divided by the total edge lengths */ - len1 = len_v2v2(v1_xy, v2_xy); - len2 = len_v2v2(v2_xy, v3_xy); - len3 = len_v2v2(v3_xy, v4_xy); - len4 = len_v2v2(v4_xy, v1_xy); - len5 = len_v2v2(v1_xy, v3_xy); - len6 = len_v2v2(v2_xy, v4_xy); + len1 = len_v3v3(v1->co, v2->co); + len2 = len_v3v3(v2->co, v3->co); + len3 = len_v3v3(v3->co, v4->co); + len4 = len_v3v3(v4->co, v1->co); + len5 = len_v3v3(v1->co, v3->co); + len6 = len_v3v3(v2->co, v4->co); - opp1 = area_tri_v2(v1_xy, v2_xy, v3_xy); - opp2 = area_tri_v2(v1_xy, v3_xy, v4_xy); + opp1 = area_tri_v3(v1->co, v2->co, v3->co); + opp2 = area_tri_v3(v1->co, v3->co, v4->co); fac1 = opp1 / (len1 + len2 + len5) + opp2 / (len3 + len4 + len5); - opp1 = area_tri_v2(v2_xy, v3_xy, v4_xy); - opp2 = area_tri_v2(v2_xy, v4_xy, v1_xy); + opp1 = area_tri_v3(v2->co, v3->co, v4->co); + opp2 = area_tri_v3(v2->co, v4->co, v1->co); fac2 = opp1 / (len2 + len3 + len6) + opp2 / (len4 + len1 + len6); From 0b8bfbebc8b7a90c1c2ac6d63efa64b28aa0d571 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2013 04:04:14 +0000 Subject: [PATCH 089/157] correct rna identifiers - compositor viewer: use_straight_alpha -> use_alpha - bevel tool: percent -> offset --- source/blender/editors/mesh/editmesh_tools.c | 2 +- source/blender/editors/space_node/drawnode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 6d5c4910630..45d0d097733 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4977,7 +4977,7 @@ static float edbm_bevel_mval_factor(wmOperator *op, wmEvent *event) if (event->shift) { if (opdata->shift_factor < 0.0f) { #ifdef NEW_BEVEL - opdata->shift_factor = RNA_float_get(op->ptr, "percent"); + opdata->shift_factor = RNA_float_get(op->ptr, "offset"); #else opdata->shift_factor = RNA_float_get(op->ptr, "factor"); #endif diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 57851e857b8..f303bba9886 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2668,7 +2668,7 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), { uiLayout *col; - uiItemR(layout, ptr, "use_straight_alpha", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "tile_order") == 0) { col = uiLayoutColumn(layout, TRUE); From 0ec23efbf27354a410ce162b6d3f2ba0fa5e86a7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2013 04:55:05 +0000 Subject: [PATCH 090/157] bmesh operators exceptions were not cleared after raising as a python exception. also clear before calling the operator. --- source/blender/python/bmesh/bmesh_py_ops_call.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c index d4c8033589a..fad3e4a35cd 100644 --- a/source/blender/python/bmesh/bmesh_py_ops_call.c +++ b/source/blender/python/bmesh/bmesh_py_ops_call.c @@ -48,11 +48,13 @@ static int bpy_bm_op_as_py_error(BMesh *bm) { if (BMO_error_occurred(bm)) { + /* note: we could have multiple errors */ const char *errmsg; if (BMO_error_get(bm, &errmsg, NULL)) { PyErr_Format(PyExc_RuntimeError, "bmesh operator: %.200s", errmsg); + BMO_error_clear(bm); return -1; } } @@ -692,6 +694,9 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw) { BPY_BM_CHECK_OBJ(py_bm); bm = py_bm->bm; + + /* could complain about entering with exceptions... */ + BMO_error_clear(bm); } else { PyErr_SetString(PyExc_TypeError, From 5d6f83b179826d142b049985323490adbba790d6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2013 05:07:46 +0000 Subject: [PATCH 091/157] remove redundant if statement. --- source/blender/render/intern/source/imagetexture.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 2827f90e4b6..12286fc9999 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -1043,8 +1043,9 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf) BLI_unlock_thread(LOCK_IMAGE); } /* if no mipmap could be made, fall back on non-mipmap render */ - if (ibuf->mipmap[0] == NULL) - if (tex->imaflag &= ~TEX_MIPMAP); + if (ibuf->mipmap[0] == NULL) { + tex->imaflag &= ~TEX_MIPMAP; + } } } From 00cad3034924d08f18779ff4ba12fd3587568d71 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2013 05:10:38 +0000 Subject: [PATCH 092/157] style cleanup --- source/blender/editors/space_file/file_draw.c | 12 ++++++----- source/blender/editors/space_file/filesel.c | 20 +++++++++---------- .../editors/space_image/image_buttons.c | 8 ++++---- .../editors/space_outliner/outliner_draw.c | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index ad76fbf9200..afe32ec0b85 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -335,7 +335,9 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int float scale; int ex, ey; - if ( (imb->x*UI_DPI_FAC > layout->prv_w) || (imb->y*UI_DPI_FAC > layout->prv_h) ) { + if ((imb->x * UI_DPI_FAC > layout->prv_w) || + (imb->y * UI_DPI_FAC > layout->prv_h)) + { if (imb->x > imb->y) { scaledx = (float)layout->prv_w; scaledy = ( (float)imb->y / (float)imb->x) * layout->prv_w; @@ -462,7 +464,7 @@ void file_draw_list(const bContext *C, ARegion *ar) int i; short is_icon; short align; - int column_space = 0.6f*UI_UNIT_X; + int column_space = 0.6f * UI_UNIT_X; numfiles = filelist_numfiles(files); @@ -493,7 +495,7 @@ void file_draw_list(const bContext *C, ARegion *ar) for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) { ED_fileselect_layout_tilepos(layout, i, &sx, &sy); - sx += (int)(v2d->tot.xmin + 0.1f*UI_UNIT_X); + sx += (int)(v2d->tot.xmin + 0.1f * UI_UNIT_X); sy = (int)(v2d->tot.ymax - sy); file = filelist_file(files, i); @@ -522,13 +524,13 @@ void file_draw_list(const bContext *C, ARegion *ar) } else { file_draw_icon(block, file->path, sx, sy - (UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE); - sx += ICON_DEFAULT_WIDTH_SCALE + 0.2f*UI_UNIT_X; + sx += ICON_DEFAULT_WIDTH_SCALE + 0.2f * UI_UNIT_X; } UI_ThemeColor4(TH_TEXT); if (file->selflag & EDITING_FILE) { - uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy - layout->tile_h - 0.15*UI_UNIT_X, + uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy - layout->tile_h - 0.15f * UI_UNIT_X, textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, ""); uiButSetRenameFunc(but, renamebutton_cb, file); uiButSetFlag(but, UI_BUT_NO_UTF8); /* allow non utf8 names */ diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index aed7fc45e95..3c6f6358171 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -500,12 +500,12 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->textheight = textheight; if (params->display == FILE_IMGDISPLAY) { - layout->prv_w = 4.8f*UI_UNIT_X; - layout->prv_h = 4.8f*UI_UNIT_Y; - layout->tile_border_x = 0.3f*UI_UNIT_X; - layout->tile_border_y = 0.3f*UI_UNIT_X; - layout->prv_border_x = 0.3f*UI_UNIT_X; - layout->prv_border_y = 0.3f*UI_UNIT_Y; + layout->prv_w = 4.8f * UI_UNIT_X; + layout->prv_h = 4.8f * UI_UNIT_Y; + layout->tile_border_x = 0.3f * UI_UNIT_X; + layout->tile_border_y = 0.3f * UI_UNIT_X; + layout->prv_border_x = 0.3f * UI_UNIT_X; + layout->prv_border_y = 0.3f * UI_UNIT_Y; layout->tile_w = layout->prv_w + 2 * layout->prv_border_x; layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight; layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x); @@ -520,13 +520,13 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->flag = FILE_LAYOUT_VER; } else { - int column_space = 0.6f*UI_UNIT_X; - int column_icon_space = 0.2f*UI_UNIT_X; + int column_space = 0.6f * UI_UNIT_X; + int column_icon_space = 0.2f * UI_UNIT_X; layout->prv_w = 0; layout->prv_h = 0; - layout->tile_border_x = 0.4f*UI_UNIT_X; - layout->tile_border_y = 0.1f*UI_UNIT_Y; + layout->tile_border_x = 0.4f * UI_UNIT_X; + layout->tile_border_y = 0.1f * UI_UNIT_Y; layout->prv_border_x = 0; layout->prv_border_y = 0; layout->tile_h = textheight * 3 / 2; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 6a0f413b4fe..01364fcacf0 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -498,17 +498,17 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, } /* decrease, increase arrows */ - but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 0.85*UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Layer")); + but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 0.85f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Layer")); uiButSetFunc(but, image_multi_declay_cb, rr, iuser); - but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 0.90*UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Layer")); + but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 0.90f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Layer")); uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); uiblock_layer_pass_buttons(row, rr, iuser, 230 * dpi_fac, render_slot); /* decrease, increase arrows */ - but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 0.85*UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Pass")); + but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 0.85f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Pass")); uiButSetFunc(but, image_multi_decpass_cb, rr, iuser); - but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 0.90*UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Pass")); + but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 0.90f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Pass")); uiButSetFunc(but, image_multi_incpass_cb, rr, iuser); uiBlockEndAlign(block); diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index b64019b01be..cacbc6d6268 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1677,7 +1677,7 @@ void draw_outliner(const bContext *C) * (OL_RNA_COL_X), whichever is wider... * - column 2 is fixed at OL_RNA_COL_SIZEX * - * (*) XXX max width for now is a fixed factor of UI_UNIT_X*(max_indention+100) + * (*) XXX max width for now is a fixed factor of (UI_UNIT_X * (max_indention + 100)) */ /* get actual width of column 1 */ From bfb319925d775c08ce123567da3d857f9adf9fc8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2013 05:48:08 +0000 Subject: [PATCH 093/157] dont draw stippled lines without z-depth in vertex paint mode. (only weight paint). --- source/blender/editors/space_view3d/drawmesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 70e2e663b33..35a0111e575 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -1071,7 +1071,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, draw_mesh_face_select(rv3d, me, dm); } else if ((do_light == FALSE) || (ob->dtx & OB_DRAWWIRE)) { - const int use_depth = (v3d->flag & V3D_ZBUF_SELECT); + const int use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(ob->mode & OB_MODE_WEIGHT_PAINT); /* weight paint in solid mode, special case. focus on making the weights clear * rather than the shading, this is also forced in wire view */ From ae385fb61cd8caa1024359f71f2e77a41ddb6e58 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 13 Feb 2013 07:50:41 +0000 Subject: [PATCH 094/157] Correction for fix #34205: Zooming in rendered mode during update out of sync with intended zoom Didn't initially notice one possibility when GPU render would fail here, --- intern/cycles/render/session.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 7a40e0d04b6..6ed14452c6b 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -210,7 +210,12 @@ void Session::run_gpu() * wait for pause condition notify to wake up again */ thread_scoped_lock pause_lock(pause_mutex); - if(pause || no_tiles) { + if(!pause && !tile_manager.done()) { + /* reset could have happened after no_tiles was set, before this lock. + * in this case we shall not wait for pause condition + */ + } + else if(pause || no_tiles) { update_status_time(pause, no_tiles); while(1) { From 708b01e177fa3eed34aa89d659d7018766153f35 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 13 Feb 2013 08:11:35 +0000 Subject: [PATCH 095/157] Fix #34217: Maya keymap preset doesn't handle Shift-Click selection properly --- release/scripts/presets/keyconfig/maya.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index ad6a2be6cf5..80f3d5886ba 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -138,41 +138,49 @@ kmi.properties.extend = False kmi.properties.center = False kmi.properties.object = False kmi.properties.enumerate = False +kmi.properties.toggle = False kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', shift=True) -kmi.properties.extend = True +kmi.properties.extend = False kmi.properties.center = False kmi.properties.object = False kmi.properties.enumerate = False +kmi.properties.toggle = True kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', ctrl=True) kmi.properties.extend = False kmi.properties.center = True kmi.properties.object = False kmi.properties.enumerate = False +kmi.properties.toggle = False kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', alt=True) kmi.properties.extend = False kmi.properties.center = False kmi.properties.object = False kmi.properties.enumerate = True +kmi.properties.toggle = False kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', shift=True, ctrl=True) kmi.properties.extend = True kmi.properties.center = True kmi.properties.object = False kmi.properties.enumerate = False +kmi.properties.toggle = True kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', ctrl=True, alt=True) kmi.properties.extend = False kmi.properties.center = True kmi.properties.object = False kmi.properties.enumerate = True +kmi.properties.toggle = False kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', shift=True, alt=True) kmi.properties.extend = True kmi.properties.center = False kmi.properties.object = False kmi.properties.enumerate = True +kmi.properties.toggle = True kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', shift=True, ctrl=True, alt=True) kmi.properties.extend = True kmi.properties.center = True kmi.properties.object = False kmi.properties.enumerate = True +kmi.properties.toggle = True kmi = km.keymap_items.new('view3d.select_border', 'EVT_TWEAK_S', 'ANY') kmi.properties.extend = False kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True) From 6f4ce31320f0afc4dce3f0825dce9a75a548efa1 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Wed, 13 Feb 2013 08:53:05 +0000 Subject: [PATCH 096/157] fix: remove extra qualification in header --- source/blender/collada/MeshImporter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index d0412985540..8b0f5cdc200 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -177,7 +177,7 @@ public: // create a mesh storing a pointer in a map so it can be retrieved later by geometry UID bool write_geometry(const COLLADAFW::Geometry* geom); - std::string *MeshImporter::get_geometry_name(const std::string &mesh_name); + std::string *get_geometry_name(const std::string &mesh_name); }; #endif From 8b0e9a63e9247d1ea71fa93d08f0e4336d5425e0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 13 Feb 2013 08:55:03 +0000 Subject: [PATCH 097/157] SCons: install blender thumbnailer next to blender binary. Cmake already does this, and this will solve --- SConstruct | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SConstruct b/SConstruct index 648d04e9ccd..3f17c1c2887 100644 --- a/SConstruct +++ b/SConstruct @@ -865,6 +865,8 @@ if env['OURPLATFORM']=='linux': td, tf = os.path.split(targetdir) iconinstall.append(env.Install(dir=td, source=srcfile)) + scriptinstall.append(env.Install(dir=env['BF_INSTALLDIR'], source='release/bin/blender-thumbnailer.py')) + # dlls for linuxcross # TODO - add more libs, for now this lets blenderlite run if env['OURPLATFORM']=='linuxcross': From 3502fdea4a943ef63686ff440e9ccd7dc6132236 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 13 Feb 2013 09:07:34 +0000 Subject: [PATCH 098/157] And more mismatches between RNA struct UI names and type UI names in nodes... BSDF nodes were not translated in UI. --- .../blender/makesrna/intern/rna_nodetree_types.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 35d3c32c045..4315d24d8f2 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -68,14 +68,14 @@ DefNode( ShaderNode, SH_NODE_ATTRIBUTE, def_sh_attribute, "AT DefNode( ShaderNode, SH_NODE_AMBIENT_OCCLUSION, 0, "AMBIENT_OCCLUSION", AmbientOcclusion, "Ambient Occlusion", "" ) DefNode( ShaderNode, SH_NODE_BACKGROUND, 0, "BACKGROUND", Background, "Background", "" ) DefNode( ShaderNode, SH_NODE_HOLDOUT, 0, "HOLDOUT", Holdout, "Holdout", "" ) -DefNode( ShaderNode, SH_NODE_BSDF_ANISOTROPIC, 0, "BSDF_ANISOTROPIC", BsdfAnisotropic, "Anisotropic Bsdf", "" ) -DefNode( ShaderNode, SH_NODE_BSDF_DIFFUSE, 0, "BSDF_DIFFUSE", BsdfDiffuse, "Diffuse Bsdf", "" ) -DefNode( ShaderNode, SH_NODE_BSDF_GLOSSY, def_glossy, "BSDF_GLOSSY", BsdfGlossy, "Glossy Bsdf", "" ) -DefNode( ShaderNode, SH_NODE_BSDF_GLASS, def_glossy, "BSDF_GLASS", BsdfGlass, "Glass Bsdf", "" ) -DefNode( ShaderNode, SH_NODE_BSDF_REFRACTION, def_glossy, "BSDF_REFRACTION", BsdfRefraction, "Refraction Bsdf", "" ) -DefNode( ShaderNode, SH_NODE_BSDF_TRANSLUCENT, 0, "BSDF_TRANSLUCENT", BsdfTranslucent, "Translucent Bsdf", "" ) -DefNode( ShaderNode, SH_NODE_BSDF_TRANSPARENT, 0, "BSDF_TRANSPARENT", BsdfTransparent, "Transparent Bsdf", "" ) -DefNode( ShaderNode, SH_NODE_BSDF_VELVET, 0, "BSDF_VELVET", BsdfVelvet, "Velvet Bsdf", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_ANISOTROPIC, 0, "BSDF_ANISOTROPIC", BsdfAnisotropic, "Anisotropic BSDF", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_DIFFUSE, 0, "BSDF_DIFFUSE", BsdfDiffuse, "Diffuse BSDF", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_GLOSSY, def_glossy, "BSDF_GLOSSY", BsdfGlossy, "Glossy BSDF", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_GLASS, def_glossy, "BSDF_GLASS", BsdfGlass, "Glass BSDF", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_REFRACTION, def_glossy, "BSDF_REFRACTION", BsdfRefraction, "Refraction BSDF", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_TRANSLUCENT, 0, "BSDF_TRANSLUCENT", BsdfTranslucent, "Translucent BSDF", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_TRANSPARENT, 0, "BSDF_TRANSPARENT", BsdfTransparent, "Transparent BSDF", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_VELVET, 0, "BSDF_VELVET", BsdfVelvet, "Velvet BSDF", "" ) DefNode( ShaderNode, SH_NODE_VOLUME_TRANSPARENT, 0, "VOLUME_TRANSPARENT", VolumeTransparent,"Transparent Volume","" ) DefNode( ShaderNode, SH_NODE_VOLUME_ISOTROPIC, 0, "VOLUME_ISOTROPIC", VolumeIsotropic, "Isotropic Volume", "" ) DefNode( ShaderNode, SH_NODE_EMISSION, 0, "EMISSION", Emission, "Emission", "" ) From 35629a623ba1fb13db96209a206cc4aedbc9cf9e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Feb 2013 10:38:05 +0000 Subject: [PATCH 099/157] Fix #34216: uv unwrap with some faces pinned to point the normals down will now automatically flip the unpinned faces to point down too, instead of trying to unwrap them in the other direction and giving bad results. If there's a mix of faces pinned up and down it will pick the direction with the biggest area. --- .../editors/uvedit/uvedit_parametrizer.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 7e3302e233e..8911e227373 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -60,6 +60,7 @@ { /*printf("Assertion %s:%d\n", __FILE__, __LINE__); abort();*/ } (void)0 #define param_warning(message) \ { /*printf("Warning %s:%d: %s\n", __FILE__, __LINE__, message);*/ } (void)0 +#if 0 #define param_test_equals_ptr(str, a, b) \ if (a != b) \ { /*printf("Equals %s => %p != %p\n", str, a, b);*/ } (void)0 @@ -67,6 +68,7 @@ if (a != b) \ { /*printf("Equals %s => %d != %d\n", str, a, b);*/ } (void)0 #endif +#endif typedef enum PBool { P_TRUE = 1, P_FALSE = 0 @@ -3047,6 +3049,8 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart) PVert *v, *pin1 = chart->u.lscm.pin1, *pin2 = chart->u.lscm.pin2; PFace *f; float *alpha = chart->u.lscm.abf_alpha; + float area_pinned_up, area_pinned_down; + bool flip_faces; int row; nlMakeCurrent(chart->u.lscm.context); @@ -3085,6 +3089,26 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart) } } + /* detect up direction based on pinned vertices */ + area_pinned_up = 0.0f; + area_pinned_down = 0.0f; + + for (f = chart->faces; f; f = f->nextlink) { + PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next; + PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert; + + if ((v1->flag & PVERT_PIN) && (v2->flag & PVERT_PIN) && (v3->flag & PVERT_PIN)) { + float area = p_face_uv_area_signed(f); + + if(area > 0.0f) + area_pinned_up += area; + else + area_pinned_down -= area; + } + } + + flip_faces = (area_pinned_down > area_pinned_up); + /* construct matrix */ nlBegin(NL_MATRIX); @@ -3105,6 +3129,12 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart) else p_face_angles(f, &a1, &a2, &a3); + if (flip_faces) { + SWAP(float, a2, a3); + SWAP(PEdge*, e2, e3); + SWAP(PVert*, v2, v3); + } + sina1 = sin(a1); sina2 = sin(a2); sina3 = sin(a3); From 4061f96d94aa410dd8550bb6b3ed8f6f87beb5de Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Feb 2013 11:02:51 +0000 Subject: [PATCH 100/157] Fix cycles issue with BVH cache created with 64 bits and used for 32 bits binary, and vice versa. --- intern/cycles/bvh/bvh.cpp | 2 ++ intern/cycles/util/util_cache.h | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 500b07f755b..f11b3c4c0bc 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -30,6 +30,7 @@ #include "util_foreach.h" #include "util_map.h" #include "util_progress.h" +#include "util_system.h" #include "util_types.h" CCL_NAMESPACE_BEGIN @@ -71,6 +72,7 @@ BVH *BVH::create(const BVHParams& params, const vector& objects) bool BVH::cache_read(CacheData& key) { + key.add(system_cpu_bits()); key.add(¶ms, sizeof(params)); foreach(Object *ob, objects) { diff --git a/intern/cycles/util/util_cache.h b/intern/cycles/util/util_cache.h index e8f111a5397..deff05fff16 100644 --- a/intern/cycles/util/util_cache.h +++ b/intern/cycles/util/util_cache.h @@ -72,7 +72,7 @@ public: buffers.push_back(buffer); } - void add(void *data, size_t size) + void add(const void *data, size_t size) { if(size) { CacheBuffer buffer(data, size); @@ -80,19 +80,19 @@ public: } } - void add(int& data) + void add(const int& data) { CacheBuffer buffer(&data, sizeof(int)); buffers.push_back(buffer); } - void add(float& data) + void add(const float& data) { CacheBuffer buffer(&data, sizeof(float)); buffers.push_back(buffer); } - void add(size_t& data) + void add(const size_t& data) { CacheBuffer buffer(&data, sizeof(size_t)); buffers.push_back(buffer); From 43f4f807d986f0c50a336d73b10ebcb243b142a8 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 13 Feb 2013 11:52:01 +0000 Subject: [PATCH 101/157] Fix physics' name not translated in main physics panel (reported on bf-translations ML). This also revealed another bug, as you could not explicitely set default context to text_ctxt UI func parameter (None is not accpeted by RNA string props), so I had to change default context from py POV to "*" instead of None. Anyway, that physics UI translation remains weak, as the trick used here (helper func) prevents message extractor script to directly find them. Currently it works because specified labels are also defined elsewhere, but it would be nice to have some kind of "translation markers" in py code too (similar to our N_/CTX_N_ C macros, unfortunately python does not have preprocessing ;) )... --- .../startup/bl_ui/properties_physics_common.py | 10 ++++++---- source/blender/blenfont/BLF_translation.h | 11 ++++++++--- .../blender/blenfont/intern/blf_translation.c | 6 +++--- .../python/intern/bpy_app_translations.c | 18 +++++++----------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index a640cb215ba..90cf397f526 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -21,6 +21,8 @@ import bpy from bpy.types import Panel +i18n_default_ctxt = bpy.app.translations.contexts.default + class PhysicButtonsPanel(): bl_space_type = 'PROPERTIES' @@ -37,20 +39,20 @@ def physics_add(self, layout, md, name, type, typeicon, toggles): sub = layout.row(align=True) if md: sub.context_pointer_set("modifier", md) - sub.operator("object.modifier_remove", text=name, icon='X') + sub.operator("object.modifier_remove", text=name, text_ctxt=i18n_default_ctxt, icon='X') if(toggles): sub.prop(md, "show_render", text="") sub.prop(md, "show_viewport", text="") else: - sub.operator("object.modifier_add", text=name, icon=typeicon).type = type + sub.operator("object.modifier_add", text=name, text_ctxt=i18n_default_ctxt, icon=typeicon).type = type def physics_add_special(self, layout, data, name, addop, removeop, typeicon): sub = layout.row(align=True) if data: - sub.operator(removeop, text=name, icon='X') + sub.operator(removeop, text=name, text_ctxt=i18n_default_ctxt, icon='X') else: - sub.operator(addop, text=name, icon=typeicon) + sub.operator(addop, text=name, text_ctxt=i18n_default_ctxt, icon=typeicon) class PHYSICS_PT_add(PhysicButtonsPanel, Panel): diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h index 35ca5f19bdc..fd8b30d1d1b 100644 --- a/source/blender/blenfont/BLF_translation.h +++ b/source/blender/blenfont/BLF_translation.h @@ -112,9 +112,13 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); /* Default, void context. * WARNING! The "" context is not the same as no (NULL) context at mo/boost::locale level! + * NOTE: We translate BLF_I18NCONTEXT_DEFAULT as BLF_I18NCONTEXT_DEFAULT_BPY in Python, as we can’t use "natural" + * None value in rna string properties... :/ + * For perf reason, we only use the first char to detect this context, so other contexts should never start + * with the same char! */ -#define BLF_I18NCONTEXT_DEFAULT NULL /* Translated as None in Python. */ -#define BLF_I18NCONTEXT_DEFAULT_BPY_INTERN "" /* Only used in code, never exposed to user! */ +#define BLF_I18NCONTEXT_DEFAULT NULL +#define BLF_I18NCONTEXT_DEFAULT_BPY "*" /* Default context for operator names/labels. */ #define BLF_I18NCONTEXT_OPERATOR_DEFAULT "Operator" @@ -165,7 +169,8 @@ typedef struct #define BLF_I18NCONTEXTS_ITEM(ctxt_id, py_id) {#ctxt_id, py_id, ctxt_id} #define BLF_I18NCONTEXTS_DESC { \ - BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_DEFAULT, "default"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_DEFAULT, "default_real"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_DEFAULT_BPY, "default"), \ BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "operator_default"), \ BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_ACTION, "id_action"), \ BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_ARMATURE, "id_armature"), \ diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c index a77b464822b..b5b72b68677 100644 --- a/source/blender/blenfont/intern/blf_translation.c +++ b/source/blender/blenfont/intern/blf_translation.c @@ -94,9 +94,9 @@ const char *BLF_pgettext(const char *msgctxt, const char *msgid) const char *ret; /*if (msgctxt && !strcmp(msgctxt, BLF_I18NCONTEXT_DEFAULT_BPY_INTERN)) { */ - if (msgctxt && !msgctxt[0]) { - /* BLF_I18NCONTEXT_DEFAULT_BPY_INTERN context is reserved and considered the same as default NULL one. */ - msgctxt = NULL; + if (msgctxt && msgctxt[0] == BLF_I18NCONTEXT_DEFAULT_BPY[0]) { + /* BLF_I18NCONTEXT_DEFAULT_BPY context is reserved and considered the same as default NULL one. */ + msgctxt = BLF_I18NCONTEXT_DEFAULT; } ret = bl_locale_pgettext(msgctxt, msgid); /* We assume if the returned string is the same (memory level) as the msgid, no translation was found, diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index 6839c0b12a6..6d69e8b1592 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -74,7 +74,7 @@ typedef struct GHashKey { static GHashKey *_ghashutil_keyalloc(const void *msgctxt, const void *msgid) { GHashKey *key = MEM_mallocN(sizeof(GHashKey), "Py i18n GHashKey"); - key->msgctxt = BLI_strdup(msgctxt ? msgctxt : BLF_I18NCONTEXT_DEFAULT_BPY_INTERN); + key->msgctxt = BLI_strdup(msgctxt ? msgctxt : BLF_I18NCONTEXT_DEFAULT_BPY); key->msgid = BLI_strdup(msgid); return key; } @@ -195,7 +195,7 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale) else { PyObject *tmp = PyTuple_GET_ITEM(pykey, 0); if (tmp == Py_None) { - msgctxt = BLF_I18NCONTEXT_DEFAULT; + msgctxt = BLF_I18NCONTEXT_DEFAULT_BPY; } else if (PyUnicode_Check(tmp)) { msgctxt = _PyUnicode_AsString(tmp); @@ -288,9 +288,7 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms _ghashutil_keyfree((void *)key); - if (tmp) - return tmp; - return msgid; + return tmp ? tmp : msgid; #undef STATIC_LOCALE_SIZE } @@ -435,8 +433,8 @@ static PyObject *app_translations_contexts_make(void) PyDoc_STRVAR(app_translations_contexts_doc, "A named tuple containing all pre-defined translation contexts.\n" - "WARNING: do not use the \"" BLF_I18NCONTEXT_DEFAULT_BPY_INTERN "\" context, it is internally assimilated as the " - "default one!\n" + "WARNING: Never use a (new) context starting with \"" BLF_I18NCONTEXT_DEFAULT_BPY "\", it would be internally " + "assimilated as the default one!\n" ); PyDoc_STRVAR(app_translations_contexts_C_to_py_doc, @@ -503,8 +501,7 @@ static PyObject *_py_pgettext(PyObject *args, PyObject *kw, const char *(*_pgett #ifdef WITH_INTERNATIONAL char *msgid, *msgctxt = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|z:bpy.app.translations.pgettext", (char **)kwlist, - &msgid, &msgctxt)) + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|z:bpy.app.translations.pgettext", (char **)kwlist, &msgid, &msgctxt)) { return NULL; } @@ -514,8 +511,7 @@ static PyObject *_py_pgettext(PyObject *args, PyObject *kw, const char *(*_pgett PyObject *msgid, *msgctxt; (void)_pgettext; - if (!PyArg_ParseTupleAndKeywords(args, kw, "O|O:bpy.app.translations.pgettext", (char **)kwlist, - &msgid, &msgctxt)) + if (!PyArg_ParseTupleAndKeywords(args, kw, "O|O:bpy.app.translations.pgettext", (char **)kwlist, &msgid, &msgctxt)) { return NULL; } From 5016ea5cb296ebaaf5c89cab02fa9001e4031ae9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2013 14:11:04 +0000 Subject: [PATCH 102/157] update python module loading test. --- source/tests/bl_load_py_modules.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/source/tests/bl_load_py_modules.py b/source/tests/bl_load_py_modules.py index d65b9605d36..9677397e01d 100644 --- a/source/tests/bl_load_py_modules.py +++ b/source/tests/bl_load_py_modules.py @@ -26,6 +26,12 @@ import addon_utils import sys import os +BLACKLIST = { + "bl_i18n_utils", + "cycles", + "io_export_dxf", # TODO, check on why this fails + } + def source_list(path, filename_check=None): from os.path import join @@ -73,20 +79,26 @@ def load_modules(): for script_path in paths: for mod_dir in sys.path: if mod_dir.startswith(script_path): - module_paths.append(mod_dir) + if mod_dir not in module_paths: + if os.path.exists(mod_dir): + module_paths.append(mod_dir) # # collect modules from our paths. - module_names = set() + module_names = {} for mod_dir in module_paths: # print("mod_dir", mod_dir) for mod, mod_full in bpy.path.module_names(mod_dir): + if mod in BLACKLIST: + continue if mod in module_names: - raise Exception("Module found twice %r" % mod) + mod_dir_prev, mod_full_prev = module_names[mod] + raise Exception("Module found twice %r.\n (%r -> %r, %r -> %r)" % + (mod, mod_dir, mod_full, mod_dir_prev, mod_full_prev)) modules.append(__import__(mod)) - module_names.add(mod) + module_names[mod] = mod_dir, mod_full del module_names # @@ -128,7 +140,7 @@ def load_modules(): ignore_paths = [ os.sep + "presets" + os.sep, os.sep + "templates" + os.sep, - ] + ] + [(os.sep + f + os.sep) for f in BLACKLIST] for f in source_files: ok = False From fe855a83d7326568e413de36c79294a1843b2fa3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2013 15:03:36 +0000 Subject: [PATCH 103/157] fix for missing typecheck on hook-assign operator. fix for POSELIB_OT_pose_rename getting an enum as an int. --- source/blender/editors/armature/poselib.c | 2 +- source/blender/editors/object/object_hook.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index b2c1b7fdcd0..48c0a4a38c3 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -663,7 +663,7 @@ static int poselib_rename_exec(bContext *C, wmOperator *op) } /* get index (and pointer) of pose to remove */ - marker = BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose")); + marker = BLI_findlink(&act->markers, RNA_enum_get(op->ptr, "pose")); if (marker == NULL) { BKE_report(op->reports, RPT_ERROR, "Invalid index for pose"); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index caeff1e82a7..7060c69cb9e 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -798,7 +798,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); } - if (!ob || !hmd) { + if (!ob || !hmd || (hmd->modifier.type != eModifierType_Hook)) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } From 4fe94b2ef67f5b1d8d535b8578038866a5f5d888 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2013 15:14:29 +0000 Subject: [PATCH 104/157] there were more places hook modifier type wasn't checked and could crash - add utility function which doest this. --- source/blender/editors/object/object_hook.c | 71 ++++++++++----------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 7060c69cb9e..1387ef94091 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -386,6 +386,31 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) } } +static void object_hook_from_context(bContext *C, PointerRNA *ptr, const int num, + Object **r_ob, HookModifierData **r_hmd) +{ + Object *ob; + HookModifierData *hmd; + + if (ptr->data) { /* if modifier context is available, use that */ + ob = ptr->id.data; + hmd = ptr->data; + } + else { /* use the provided property */ + ob = CTX_data_edit_object(C); + hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); + } + + if (ob && hmd && (hmd->modifier.type == eModifierType_Hook)) { + *r_ob = ob; + *r_hmd = hmd; + } + else { + *r_ob = NULL; + *r_hmd = NULL; + } +} + static void object_hook_select(Object *ob, HookModifierData *hmd) { if (hmd->indexar == NULL) @@ -663,16 +688,9 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) int num = RNA_enum_get(op->ptr, "modifier"); Object *ob = NULL; HookModifierData *hmd = NULL; - - if (ptr.data) { /* if modifier context is available, use that */ - ob = ptr.id.data; - hmd = ptr.data; - } - else { /* use the provided property */ - ob = CTX_data_edit_object(C); - hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); - } - if (!ob || !hmd) { + + object_hook_from_context(C, &ptr, num, &ob, &hmd); + if (hmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -732,15 +750,8 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); float bmat[3][3], imat[3][3]; - if (ptr.data) { /* if modifier context is available, use that */ - ob = ptr.id.data; - hmd = ptr.data; - } - else { /* use the provided property */ - ob = CTX_data_edit_object(C); - hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); - } - if (!ob || !hmd) { + object_hook_from_context(C, &ptr, num, &ob, &hmd); + if (hmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -790,15 +801,8 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) char name[MAX_NAME]; int *indexar, tot; - if (ptr.data) { /* if modifier context is available, use that */ - ob = ptr.id.data; - hmd = ptr.data; - } - else { /* use the provided property */ - ob = CTX_data_edit_object(C); - hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); - } - if (!ob || !hmd || (hmd->modifier.type != eModifierType_Hook)) { + object_hook_from_context(C, &ptr, num, &ob, &hmd); + if (hmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -852,15 +856,8 @@ static int object_hook_select_exec(bContext *C, wmOperator *op) Object *ob = NULL; HookModifierData *hmd = NULL; - if (ptr.data) { /* if modifier context is available, use that */ - ob = ptr.id.data; - hmd = ptr.data; - } - else { /* use the provided property */ - ob = CTX_data_edit_object(C); - hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); - } - if (!ob || !hmd) { + object_hook_from_context(C, &ptr, num, &ob, &hmd); + if (hmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } From 8a20930c71dee32337cd15f3d36fa3574c6c9eea Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Wed, 13 Feb 2013 16:00:46 +0000 Subject: [PATCH 105/157] Collada: Fixed import of textures with path settings relative to main import file --- source/blender/collada/DocumentImporter.cpp | 31 +++++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 52dd587231d..8af4d0652d9 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -54,6 +54,7 @@ extern "C" { #include "BLI_math.h" #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLI_fileops.h" #include "BKE_camera.h" #include "BKE_main.h" @@ -1000,17 +1001,29 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image) if (mImportStage != General) return true; - // XXX maybe it is necessary to check if the path is absolute or relative - const std::string& filepath = image->getImageURI().toNativePath(); - const char *filename = (const char *)filepath.c_str(); + const std::string& imagepath = image->getImageURI().toNativePath(); + char dir[FILE_MAX]; - char full_path[FILE_MAX]; - - BLI_split_dir_part(filename, dir, sizeof(dir)); - BLI_join_dirfile(full_path, sizeof(full_path), dir, filepath.c_str()); - Image *ima = BKE_image_load_exists(full_path); + char absolute_path[FILE_MAX]; + const char *workpath; + + BLI_split_dir_part(this->import_settings->filepath, dir, sizeof(dir)); + BLI_join_dirfile(absolute_path, sizeof(absolute_path), dir, imagepath.c_str()); + if (BLI_exists(absolute_path)) { + workpath = absolute_path; + } + else { + // Maybe imagepath was already absolute ? + if (!BLI_exists(imagepath.c_str())) { + fprintf(stderr, "Image not found: %s.\n", imagepath.c_str() ); + return true; + } + workpath = imagepath.c_str(); + } + + Image *ima = BKE_image_load_exists(workpath); if (!ima) { - fprintf(stderr, "Cannot create image.\n"); + fprintf(stderr, "Cannot create image: %s\n", workpath); return true; } this->uid_image_map[image->getUniqueId()] = ima; From 909d64079a228dfa9cccf8ed718efc322a038e7e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Feb 2013 16:46:18 +0000 Subject: [PATCH 106/157] Fix #34226: cycles shadow pass got incorrectly influenced by world multiple importance sampleing. --- intern/cycles/device/device_cuda.cpp | 4 ++-- intern/cycles/kernel/kernel_emission.h | 2 +- intern/cycles/kernel/kernel_passes.h | 9 +-------- intern/cycles/kernel/kernel_types.h | 2 +- intern/cycles/render/light.cpp | 15 +++++++++++++++ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 0c590645808..399414d5966 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -109,11 +109,11 @@ public: } } -#ifdef NDEBUG +/*#ifdef NDEBUG #define cuda_abort() #else #define cuda_abort() abort() -#endif +#endif*/ #define cuda_assert(stmt) \ { \ diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index 3b27a1f49c9..9787af535bb 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -141,7 +141,7 @@ __device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int li } /* return if it's a lamp for shadow pass */ - *is_lamp = (ls.prim == ~0); + *is_lamp = (ls.prim == ~0 && ls.type != LIGHT_BACKGROUND); return true; } diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h index 727639386ed..57dbdc2ffc1 100644 --- a/intern/cycles/kernel/kernel_passes.h +++ b/intern/cycles/kernel/kernel_passes.h @@ -125,14 +125,7 @@ __device_inline void kernel_write_light_passes(KernelGlobals *kg, __global float kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, sample, L->color_transmission); if(flag & PASS_SHADOW) { float4 shadow = L->shadow; - - /* bit of an ugly hack to compensate for emitting triangles influencing - * amount of samples we get for this pass */ - if(kernel_data.integrator.progressive && kernel_data.integrator.pdf_triangles != 0.0f) - shadow.w = 0.5f; - else - shadow.w = 1.0f; - + shadow.w = kernel_data.film.pass_shadow_scale; kernel_write_pass_float4(buffer + kernel_data.film.pass_shadow, sample, shadow); } #endif diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 773ea0c43fb..ddbda9240fb 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -610,9 +610,9 @@ typedef struct KernelFilm { int pass_ao; int pass_shadow; + float pass_shadow_scale; int pass_pad1; int pass_pad2; - int pass_pad3; } KernelFilm; typedef struct KernelBackground { diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index e7fb9514371..ccc6c5142bd 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -143,6 +143,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen /* count */ size_t num_lights = scene->lights.size(); + size_t num_background_lights = 0; size_t num_triangles = 0; size_t num_curve_segments = 0; @@ -306,6 +307,8 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen if(light->size > 0.0f && light->use_mis) use_lamp_mis = true; + if(light->type == LIGHT_BACKGROUND) + num_background_lights++; } /* normalize cumulative distribution functions */ @@ -324,6 +327,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen /* update device */ KernelIntegrator *kintegrator = &dscene->data.integrator; + KernelFilm *kfilm = &dscene->data.film; kintegrator->use_direct_light = (totarea > 0.0f); if(kintegrator->use_direct_light) { @@ -354,6 +358,16 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen kintegrator->use_lamp_mis = use_lamp_mis; + /* bit of an ugly hack to compensate for emitting triangles influencing + * amount of samples we get for this pass */ + if(scene->integrator->progressive && kintegrator->pdf_triangles != 0.0f) + kfilm->pass_shadow_scale = 0.5f; + else + kfilm->pass_shadow_scale = 1.0f; + + if(num_background_lights < num_lights) + kfilm->pass_shadow_scale *= (float)(num_lights - num_background_lights)/(float)num_lights; + /* CDF */ device->tex_alloc("__light_distribution", dscene->light_distribution); } @@ -366,6 +380,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen kintegrator->pdf_lights = 0.0f; kintegrator->inv_pdf_lights = 0.0f; kintegrator->use_lamp_mis = false; + kfilm->pass_shadow_scale = 1.0f; } } From da4711632c729d54dc3d425d905dec926966f79c Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 13 Feb 2013 16:52:14 +0000 Subject: [PATCH 107/157] Fix for splitting startup and userpref: The do-version handling for Userdef is outside file reading, which makes it needed to store the file version in UserDef, so it gets the correct version to handle. Thanks Antonis R. for pointing at the omission! Also removed the mindboggling define. If you do such, then make it like "MAIN_VERSION_OLDER_THAN() or so. In general version hacking could be limited much better... ask me before even thinking to add one, most optimal is to do it in a way it's not depending on a version ever - forward/backward compatible. --- source/blender/blenloader/intern/readfile.c | 4 ++++ source/blender/editors/interface/resources.c | 13 ++++++++----- source/blender/makesdna/DNA_userdef_types.h | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index de5e69b741a..6fba30aa060 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8881,6 +8881,10 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) bfd->user = user= read_struct(fd, bhead, "user def"); + /* User struct has separate do-version handling */ + user->versionfile = bfd->main->versionfile; + user->subversionfile = bfd->main->subversionfile; + /* read all data into fd->datamap */ bhead = read_data_into_oldnewmap(fd, bhead, "user def"); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index e3fbbc26d0d..d0a950fb3bc 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1322,7 +1322,6 @@ void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3] void init_userdef_do_versions(void) { Main *bmain = G.main; -// countall(); /* the UserDef struct is not corrected with do_versions() .... ugh! */ if (U.wheellinescroll == 0) U.wheellinescroll = 3; @@ -2096,7 +2095,8 @@ void init_userdef_do_versions(void) } } - if (bmain->versionfile < 266) { + /* NOTE!! from now on use U.versionfile and U.subversionfile */ + if (U.versionfile < 266) { bTheme *btheme; for (btheme = U.themes.first; btheme; btheme = btheme->next) { @@ -2108,7 +2108,7 @@ void init_userdef_do_versions(void) } } - if (!MAIN_VERSION_ATLEAST(bmain, 265, 4)) { + if (U.versionfile < 265 || (U.versionfile == 265 && U.subversionfile < 4)) { bTheme *btheme; for (btheme = U.themes.first; btheme; btheme = btheme->next) { rgba_char_args_set(btheme->text.syntaxd, 50, 0, 140, 255); /* Decorator/Preprocessor Dir. Blue-purple */ @@ -2117,14 +2117,14 @@ void init_userdef_do_versions(void) } } - if (!MAIN_VERSION_ATLEAST(bmain, 265, 6)) { + if (U.versionfile < 265 || (U.versionfile == 265 && U.subversionfile < 6)) { bTheme *btheme; for (btheme = U.themes.first; btheme; btheme = btheme->next) { copy_v4_v4_char(btheme->tv3d.gradients.high_gradient, btheme->tv3d.back); } } - if (!MAIN_VERSION_ATLEAST(bmain, 265, 9)) { + if (U.versionfile < 265 || (U.versionfile == 265 && U.subversionfile < 9)) { bTheme *btheme; for (btheme = U.themes.first; btheme; btheme = btheme->next) { rgba_char_args_test_set(btheme->tnode.syntaxs, 151, 116, 116, 255); /* matte nodes */ @@ -2132,6 +2132,9 @@ void init_userdef_do_versions(void) } } + /* NOTE!! from now on use U.versionfile and U.subversionfile */ + + if (U.pixelsize == 0.0f) U.pixelsize = 1.0f; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 2d8d808198d..cc53caa4c20 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -364,6 +364,9 @@ typedef struct SolidLight { } SolidLight; typedef struct UserDef { + /* UserDef has separate do-version handling, and can be read from other files */ + int versionfile, subversionfile; + int flag, dupflag; int savetime; char tempdir[768]; /* FILE_MAXDIR length */ From 6557d336084ac58e93a8dcbbc023e0236a4937af Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 13 Feb 2013 17:43:52 +0000 Subject: [PATCH 108/157] Made maya keymad deselect everything in cases nothing was selected with LMB The way it works now is: - Border select is using TWEAK, for which you need to hold LMB down and move mouse. This prevents operators using RELEASE/CLICK events from being fired. - LMB select is using RELEASE event, this is no selection happens before border if you do border select. And this prevents any operator uses CLICK event from being fired. - Delect all happens by CLICK, which would be fired only in case no operators were handled with PRESS/RELEASE. This is a bit cards-house, but this is how events currently works and wouldn't want inventing something bigger now. --- release/scripts/presets/keyconfig/maya.py | 28 ++++++++++------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index 80f3d5886ba..d6805fb3484 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -133,49 +133,49 @@ kmi = km.keymap_items.new('wm.context_toggle_enum', 'Z', 'PRESS', alt=True) kmi.properties.data_path = 'space_data.viewport_shade' kmi.properties.value_1 = 'TEXTURED' kmi.properties.value_2 = 'SOLID' -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK') +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'RELEASE') kmi.properties.extend = False kmi.properties.center = False kmi.properties.object = False kmi.properties.enumerate = False kmi.properties.toggle = False -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', shift=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'RELEASE', shift=True) kmi.properties.extend = False kmi.properties.center = False kmi.properties.object = False kmi.properties.enumerate = False kmi.properties.toggle = True -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', ctrl=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'RELEASE', ctrl=True) kmi.properties.extend = False kmi.properties.center = True kmi.properties.object = False kmi.properties.enumerate = False kmi.properties.toggle = False -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', alt=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'RELEASE', alt=True) kmi.properties.extend = False kmi.properties.center = False kmi.properties.object = False kmi.properties.enumerate = True kmi.properties.toggle = False -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', shift=True, ctrl=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'RELEASE', shift=True, ctrl=True) kmi.properties.extend = True kmi.properties.center = True kmi.properties.object = False kmi.properties.enumerate = False kmi.properties.toggle = True -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', ctrl=True, alt=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'RELEASE', ctrl=True, alt=True) kmi.properties.extend = False kmi.properties.center = True kmi.properties.object = False kmi.properties.enumerate = True kmi.properties.toggle = False -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', shift=True, alt=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'RELEASE', shift=True, alt=True) kmi.properties.extend = True kmi.properties.center = False kmi.properties.object = False kmi.properties.enumerate = True kmi.properties.toggle = True -kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'CLICK', shift=True, ctrl=True, alt=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'RELEASE', shift=True, ctrl=True, alt=True) kmi.properties.extend = True kmi.properties.center = True kmi.properties.object = False @@ -318,10 +318,8 @@ kmi = km.keymap_items.new('object.subdivision_set', 'FOUR', 'PRESS', ctrl=True) kmi.properties.level = 4 kmi = km.keymap_items.new('object.subdivision_set', 'FIVE', 'PRESS', ctrl=True) kmi.properties.level = 5 -# TODO: only used to de-seletc everything when click outside of object, -# and that's not best way to do this and this way is completely unpredictable -#kmi = km.keymap_items.new('object.select_all', 'SELECTMOUSE', 'CLICK') -#kmi.properties.action = 'DESELECT' +kmi = km.keymap_items.new('object.select_all', 'SELECTMOUSE', 'CLICK') +kmi.properties.action = 'DESELECT' # Map Mesh km = kc.keymaps.new('Mesh', space_type='EMPTY', region_type='WINDOW', modal=False) @@ -407,10 +405,8 @@ kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True) kmi.properties.data_path = 'tool_settings.proportional_edit' kmi.properties.value_1 = 'DISABLED' kmi.properties.value_2 = 'CONNECTED' -# TODO: only used to de-seletc everything when click outside of object, -# and that's not best way to do this and this way is completely unpredictable -#kmi = km.keymap_items.new('mesh.select_all', 'SELECTMOUSE', 'CLICK') -#kmi.properties.action = 'DESELECT' +kmi = km.keymap_items.new('mesh.select_all', 'SELECTMOUSE', 'CLICK') +kmi.properties.action = 'DESELECT' kmi = km.keymap_items.new('object.subdivision_set', 'ZERO', 'PRESS', ctrl=True) kmi.properties.level = 0 kmi = km.keymap_items.new('object.subdivision_set', 'ONE', 'PRESS', ctrl=True) From 3cdda9750861324ecad1289f546088c707766c5f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Feb 2013 19:01:33 +0000 Subject: [PATCH 109/157] Fix color sampling info at the bottom of the image editor not respecting DPI. (don't bother updating the RC for this, it's not an important fix) --- .../blender/editors/space_image/image_draw.c | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 00bc3d1d26b..cae71885b87 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -185,29 +185,28 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def /* noisy, high contrast make impossible to read if lower alpha is used. */ glColor4ub(0, 0, 0, 190); - glRecti(0.0, 0.0, BLI_rcti_size_x(&ar->winrct) + 1, 20); + glRecti(0.0, 0.0, BLI_rcti_size_x(&ar->winrct) + 1, UI_UNIT_Y); glDisable(GL_BLEND); - BLF_size(blf_mono_font, 11, 72); + BLF_size(blf_mono_font, 11 * U.pixelsize, U.dpi); glColor3ub(255, 255, 255); BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y); - // UI_DrawString(6, 6, str); // works ok but fixed width is nicer. - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_Y, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); if (zp) { glColor3ub(255, 255, 255); BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f + 0.5f * (((float)*zp) / (float)0x7fffffff)); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } if (zpf) { glColor3ub(255, 255, 255); BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } @@ -220,7 +219,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), " R:%-3d", cp[0]); else BLI_snprintf(str, sizeof(str), " R:-"); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -231,7 +230,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), " G:%-3d", cp[1]); else BLI_snprintf(str, sizeof(str), " G:-"); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -242,7 +241,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), " B:%-3d", cp[2]); else BLI_snprintf(str, sizeof(str), " B:-"); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -254,7 +253,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), " A:%-3d", cp[3]); else BLI_snprintf(str, sizeof(str), "- "); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } @@ -268,7 +267,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def IMB_colormanagement_pixel_to_display_space_v4(pixel, fp, &scene->view_settings, &scene->display_settings); BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", pixel[0], pixel[1], pixel[2]); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } @@ -326,24 +325,24 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def glDisable(GL_BLEND); glColor3fv(finalcol); - dx += 5; + dx += 0.25f * UI_UNIT_X; glBegin(GL_QUADS); - glVertex2f(dx, 3); - glVertex2f(dx, 17); - glVertex2f(dx + 30, 17); - glVertex2f(dx + 30, 3); + glVertex2f(dx, 0.15f * UI_UNIT_Y); + glVertex2f(dx, 0.85f * UI_UNIT_Y); + glVertex2f(dx + 1.5f * UI_UNIT_X, 0.85 * UI_UNIT_Y); + glVertex2f(dx + 1.5f * UI_UNIT_X, 0.15f * UI_UNIT_Y); glEnd(); /* draw outline */ glColor3ub(128, 128, 128); glBegin(GL_LINE_LOOP); - glVertex2f(dx, 3); - glVertex2f(dx, 17); - glVertex2f(dx + 30, 17); - glVertex2f(dx + 30, 3); + glVertex2f(dx, 0.15f * UI_UNIT_Y); + glVertex2f(dx, 0.85f * UI_UNIT_Y); + glVertex2f(dx + 1.5f * UI_UNIT_X, 0.85f * UI_UNIT_Y); + glVertex2f(dx + 1.5f * UI_UNIT_X, 0.15f * UI_UNIT_Y); glEnd(); - dx += 35; + dx += 1.75f * UI_UNIT_X; glColor3ub(255, 255, 255); if (channels == 1) { @@ -357,12 +356,12 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def } BLI_snprintf(str, sizeof(str), "V:%-.4f", val); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); BLI_snprintf(str, sizeof(str), " L:%-.4f", lum); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } @@ -377,22 +376,22 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def } BLI_snprintf(str, sizeof(str), "H:%-.4f", hue); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); BLI_snprintf(str, sizeof(str), " S:%-.4f", sat); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); BLI_snprintf(str, sizeof(str), " V:%-.4f", val); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); BLI_snprintf(str, sizeof(str), " L:%-.4f", lum); - BLF_position(blf_mono_font, dx, 6, 0); + BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } From f6624aaacd3a8d3c5e86fc6bc09a1d14f7128012 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 13 Feb 2013 21:56:12 +0000 Subject: [PATCH 110/157] Gah, forgot some ugly print... --- release/scripts/modules/bl_i18n_utils/utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index e74400775ae..f7a74808d47 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -275,8 +275,6 @@ class I18nMessages: new_keys = ref_keys - org_keys removed_keys = org_keys - ref_keys - print(new_keys, "\n\n", removed_keys) - # First process keys present in both org and ref messages. for key in ref_keys - new_keys: msg, refmsg = self.msgs[key], ref.msgs[key] From 42f987236363b443a523e4df929b8a05a9cbb27b Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 13 Feb 2013 23:09:12 +0000 Subject: [PATCH 111/157] bugfix: [#34220] Blenderplayer no longer working after r54395 commit [segfault due to world not valid] patch by Sergey Sharybin note, I still find strange that world was valid and now it is not, but at least we no longer segfaults --- 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 6fba30aa060..94dfb0cf399 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8664,7 +8664,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if (scene->world) { World *world = blo_do_versions_newlibadr(fd, scene->id.lib, scene->world); - if (is_zero_v3(&world->horr)) { + if (world && is_zero_v3(&world->horr)) { if ((world->skytype & WO_SKYBLEND) == 0 || is_zero_v3(&world->zenr)) { set_premul = true; } From 9bd1e46b4a31ee19834b39ec997f746307486941 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 01:01:08 +0000 Subject: [PATCH 112/157] add missing NULL checks - could cause crashes in rare cases. --- source/blender/makesrna/intern/rna_sculpt_paint.c | 2 +- source/blender/windowmanager/intern/wm_keymap.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 5aa4fa81076..e0687295c70 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -236,7 +236,7 @@ static void rna_Sculpt_ShowDiffuseColor_update(Main *UNUSED(bmain), Scene *scene { Object *ob = (scene->basact) ? scene->basact->object : NULL; - if (ob) { + if (ob && ob->sculpt) { Sculpt *sd = scene->toolsettings->sculpt; ob->sculpt->show_diffuse_color = sd->flags & SCULPT_SHOW_DIFFUSE; diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 3739462ac2c..a296c742e5c 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -126,10 +126,13 @@ static int wm_keymap_item_equals(wmKeyMapItem *a, wmKeyMapItem *b) /* properties can be NULL, otherwise the arg passed is used and ownership is given to the kmi */ void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties) { - WM_operator_properties_free(kmi->ptr); - MEM_freeN(kmi->ptr); + if (LIKELY(kmi->ptr)) { + WM_operator_properties_free(kmi->ptr); + MEM_freeN(kmi->ptr); + + kmi->ptr = NULL; + } - kmi->ptr = NULL; kmi->properties = properties; wm_keymap_item_properties_set(kmi); From a59682f0b7362896ff1d7d3d6a7b107b932bc320 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 01:30:13 +0000 Subject: [PATCH 113/157] fix for crash with project paint when there is no brush (possible applying projection from the camera only) --- .../editors/sculpt_paint/paint_image.c | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index b9b3b1da762..1f8c06f6bf7 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5016,23 +5016,29 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps) { Scene *scene = CTX_data_scene(C); ToolSettings *settings = scene->toolsettings; - Brush *brush = paint_brush(&settings->imapaint.paint); /* brush */ - ps->brush = brush; - ps->tool = brush->imagepaint_tool; - ps->blend = brush->blend; + ps->brush = paint_brush(&settings->imapaint.paint); + if (ps->brush) { + Brush *brush = ps->brush; + ps->tool = brush->imagepaint_tool; + ps->blend = brush->blend; + + /* disable for 3d mapping also because painting on mirrored mesh can create "stripes" */ + ps->do_masking = (brush->flag & BRUSH_AIRBRUSH || brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW || + brush->mtex.brush_map_mode == MTEX_MAP_MODE_3D) ? false : true; + ps->is_texbrush = (brush->mtex.tex) ? 1 : 0; + } + else { + /* brush may be NULL*/ + ps->do_masking = false; + ps->is_texbrush = false; + } /* sizeof ProjPixel, since we alloc this a _lot_ */ ps->pixel_sizeof = project_paint_pixel_sizeof(ps->tool); BLI_assert(ps->pixel_sizeof >= sizeof(ProjPixel)); - /* disable for 3d mapping also because painting on mirrored mesh can create "stripes" */ - ps->do_masking = (brush->flag & BRUSH_AIRBRUSH || brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW || - brush->mtex.brush_map_mode == MTEX_MAP_MODE_3D) ? false : true; - ps->is_texbrush = (brush->mtex.tex) ? 1 : 0; - - /* these can be NULL */ ps->v3d = CTX_wm_view3d(C); ps->rv3d = CTX_wm_region_view3d(C); From db02420921781f1b9bca0e3184d1cf39d1b1cbce Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 01:55:10 +0000 Subject: [PATCH 114/157] tweak vertex group clean limit, it couldn't be set to zero, and you may want to remove only zero weights. --- source/blender/editors/object/object_vgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index a1fb0eb98d2..87ff42ef4db 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -3151,7 +3151,7 @@ void OBJECT_OT_vertex_group_clean(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_float(ot->srna, "limit", 0.01f, 0.0f, 1.0, "Limit", "Remove weights under this limit", 0.001f, 0.99f); + RNA_def_float(ot->srna, "limit", 0.0f, 0.0f, 1.0, "Limit", "Remove weights under this limit", 0.0f, 0.99f); RNA_def_boolean(ot->srna, "all_groups", FALSE, "All Groups", "Clean all vertex groups"); RNA_def_boolean(ot->srna, "keep_single", FALSE, "Keep Single", "Keep verts assigned to at least one group when cleaning"); From 12f6d3ad906924ff8a2bbae7eadae3e28ab62d83 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 02:21:12 +0000 Subject: [PATCH 115/157] fix own bug in weight gradient tool, need to check if mesh dverts will be overwritten, --- source/blender/editors/sculpt_paint/paint_vertex.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 0c0a5507594..8ff2a68013c 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -3182,9 +3182,11 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, wmEvent *eve VPaint *wp = ts->wpaint; Object *ob = CTX_data_active_object(C); Mesh *me = ob->data; - BKE_defvert_array_free_elems(me->dvert, me->totvert); - BKE_defvert_array_copy(me->dvert, wp->wpaint_prev, me->totvert); - free_wpaint_prev(wp); + if (wp->wpaint_prev) { + BKE_defvert_array_free_elems(me->dvert, me->totvert); + BKE_defvert_array_copy(me->dvert, wp->wpaint_prev, me->totvert); + free_wpaint_prev(wp); + } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); From ab7ca2dc441239686bcc44189c79e377ba4d089c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 03:03:12 +0000 Subject: [PATCH 116/157] fix for double clicking in the text editor not working usefully (double clicking a pair chars would select 3 - one to the left). --- source/blender/blenkernel/BKE_text.h | 4 ++-- source/blender/blenkernel/intern/text.c | 14 +++++++------- .../blender/blenlib/BLI_string_cursor_utf8.h | 2 +- .../blenlib/intern/string_cursor_utf8.c | 12 +++++++++--- .../editors/interface/interface_handlers.c | 6 +++--- .../editors/space_console/console_ops.c | 18 +++++++++--------- source/blender/editors/space_text/text_ops.c | 10 ++++++---- 7 files changed, 37 insertions(+), 29 deletions(-) diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index dc84bc67647..3e882a048eb 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -66,8 +66,8 @@ void txt_move_up (struct Text *text, short sel); void txt_move_down (struct Text *text, short sel); void txt_move_left (struct Text *text, short sel); void txt_move_right (struct Text *text, short sel); -void txt_jump_left (struct Text *text, short sel); -void txt_jump_right (struct Text *text, short sel); +void txt_jump_left (struct Text *text, bool sel, bool use_init_step); +void txt_jump_right (struct Text *text, bool sel, bool use_init_step); void txt_move_bof (struct Text *text, short sel); void txt_move_eof (struct Text *text, short sel); void txt_move_bol (struct Text *text, short sel); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 3be9097ce82..86e7a152a4a 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -38,12 +38,12 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "BLI_string.h" #include "BLI_string_cursor_utf8.h" #include "BLI_string_utf8.h" #include "BLI_listbase.h" -#include "BLI_utildefines.h" #include "BLI_fileops.h" #include "DNA_constraint_types.h" @@ -936,7 +936,7 @@ void txt_move_right(Text *text, short sel) if (!sel) txt_pop_sel(text); } -void txt_jump_left(Text *text, short sel) +void txt_jump_left(Text *text, bool sel, bool use_init_step) { TextLine **linep; int *charp; @@ -948,12 +948,12 @@ void txt_jump_left(Text *text, short sel) BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, charp, STRCUR_DIR_PREV, - STRCUR_JUMP_DELIM); + STRCUR_JUMP_DELIM, use_init_step); if (!sel) txt_pop_sel(text); } -void txt_jump_right(Text *text, short sel) +void txt_jump_right(Text *text, bool sel, bool use_init_step) { TextLine **linep; int *charp; @@ -965,7 +965,7 @@ void txt_jump_right(Text *text, short sel) BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, charp, STRCUR_DIR_NEXT, - STRCUR_JUMP_DELIM); + STRCUR_JUMP_DELIM, use_init_step); if (!sel) txt_pop_sel(text); } @@ -2402,7 +2402,7 @@ void txt_delete_char(Text *text) void txt_delete_word(Text *text) { - txt_jump_right(text, 1); + txt_jump_right(text, true, true); txt_delete_sel(text); } @@ -2451,7 +2451,7 @@ void txt_backspace_char(Text *text) void txt_backspace_word(Text *text) { - txt_jump_left(text, 1); + txt_jump_left(text, true, true); txt_delete_sel(text); } diff --git a/source/blender/blenlib/BLI_string_cursor_utf8.h b/source/blender/blenlib/BLI_string_cursor_utf8.h index 3c38c0380e0..04d9df2abda 100644 --- a/source/blender/blenlib/BLI_string_cursor_utf8.h +++ b/source/blender/blenlib/BLI_string_cursor_utf8.h @@ -46,6 +46,6 @@ int BLI_str_cursor_step_prev_utf8(const char *str, size_t maxlen, int *pos); void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, int *pos, strCursorJumpDirection direction, - strCursorJumpType jump); + strCursorJumpType jump, bool use_init_step); #endif /* __BLI_STRING_CURSOR_UTF8_H__ */ diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index 65763f21b0f..b8797855f17 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -139,12 +139,15 @@ int BLI_str_cursor_step_prev_utf8(const char *str, size_t UNUSED(maxlen), int *p void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, int *pos, strCursorJumpDirection direction, - strCursorJumpType jump) + strCursorJumpType jump, bool use_init_step) { const int pos_prev = *pos; if (direction == STRCUR_DIR_NEXT) { - BLI_str_cursor_step_next_utf8(str, maxlen, pos); + if (use_init_step) { + BLI_assert(jump == STRCUR_JUMP_DELIM); + BLI_str_cursor_step_next_utf8(str, maxlen, pos); + } if (jump != STRCUR_JUMP_NONE) { const strCursorDelimType delim_type = (*pos) < maxlen ? cursor_delim_type(&str[*pos]) : STRCUR_DELIM_NONE; @@ -163,7 +166,10 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, } } else if (direction == STRCUR_DIR_PREV) { - BLI_str_cursor_step_prev_utf8(str, maxlen, pos); + if (use_init_step) { + BLI_assert(jump == STRCUR_JUMP_DELIM); + BLI_str_cursor_step_prev_utf8(str, maxlen, pos); + } if (jump != STRCUR_JUMP_NONE) { const strCursorDelimType delim_type = (*pos) > 1 ? cursor_delim_type(&str[(*pos) - 1]) : STRCUR_DELIM_NONE; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index edd5b901ca1..b166e532f84 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1610,7 +1610,7 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJump } else { int pos_i = but->pos; - BLI_str_cursor_step_utf8(str, len, &pos_i, direction, jump); + BLI_str_cursor_step_utf8(str, len, &pos_i, direction, jump, true); but->pos = pos_i; if (select) { @@ -1679,7 +1679,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio else if (but->pos >= 0 && but->pos < len) { int pos = but->pos; int step; - BLI_str_cursor_step_utf8(str, len, &pos, direction, jump); + BLI_str_cursor_step_utf8(str, len, &pos, direction, jump, true); step = pos - but->pos; memmove(&str[but->pos], &str[but->pos + step], (len + 1) - but->pos); changed = 1; @@ -1694,7 +1694,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio int pos = but->pos; int step; - BLI_str_cursor_step_utf8(str, len, &pos, direction, jump); + BLI_str_cursor_step_utf8(str, len, &pos, direction, jump, true); step = but->pos - pos; memmove(&str[but->pos - step], &str[but->pos], (len + 1) - but->pos); but->pos -= step; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 5eed39a120e..1242d123a41 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -34,12 +34,12 @@ #include "DNA_userdef_types.h" +#include "BLI_utildefines.h" #include "BLI_listbase.h" #include "BLI_string_cursor_utf8.h" #include "BLI_string_utf8.h" #include "BLI_string.h" #include "BLI_dynstr.h" -#include "BLI_utildefines.h" #include "BLI_math.h" #include "BKE_context.h" @@ -284,28 +284,28 @@ static int console_move_exec(bContext *C, wmOperator *op) pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_PREV, - STRCUR_JUMP_ALL); + STRCUR_JUMP_ALL, true); done = console_line_cursor_set(ci, pos); break; case LINE_END: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_NEXT, - STRCUR_JUMP_ALL); + STRCUR_JUMP_ALL, true); done = console_line_cursor_set(ci, pos); break; case PREV_CHAR: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_PREV, - STRCUR_JUMP_NONE); + STRCUR_JUMP_NONE, true); done = console_line_cursor_set(ci, pos); break; case NEXT_CHAR: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_NEXT, - STRCUR_JUMP_NONE); + STRCUR_JUMP_NONE, true); done = console_line_cursor_set(ci, pos); break; @@ -315,14 +315,14 @@ static int console_move_exec(bContext *C, wmOperator *op) pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_PREV, - STRCUR_JUMP_DELIM); + STRCUR_JUMP_DELIM, true); done = console_line_cursor_set(ci, pos); break; case NEXT_WORD: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_NEXT, - STRCUR_JUMP_DELIM); + STRCUR_JUMP_DELIM, true); done = console_line_cursor_set(ci, pos); break; } @@ -562,7 +562,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_NEXT, - (type == DEL_NEXT_CHAR) ? STRCUR_JUMP_NONE : STRCUR_JUMP_DELIM); + (type == DEL_NEXT_CHAR) ? STRCUR_JUMP_NONE : STRCUR_JUMP_DELIM, true); stride = pos - ci->cursor; if (stride) { memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1); @@ -578,7 +578,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_PREV, - (type == DEL_PREV_CHAR) ? STRCUR_JUMP_NONE : STRCUR_JUMP_DELIM); + (type == DEL_PREV_CHAR) ? STRCUR_JUMP_NONE : STRCUR_JUMP_DELIM, true); stride = ci->cursor - pos; if (stride) { ci->cursor -= stride; /* same as above */ diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 1f209f90007..b60528bcee8 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1312,9 +1312,11 @@ void TEXT_OT_select_line(wmOperatorType *ot) static int text_select_word_exec(bContext *C, wmOperator *UNUSED(op)) { Text *text = CTX_data_edit_text(C); + /* don't advance cursor before stepping */ + const bool use_init_step = false; - txt_jump_left(text, 0); - txt_jump_right(text, 1); + txt_jump_left(text, false, use_init_step); + txt_jump_right(text, true, use_init_step); text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); @@ -1816,11 +1818,11 @@ static int text_move_cursor(bContext *C, int type, int select) break; case PREV_WORD: - txt_jump_left(text, select); + txt_jump_left(text, select, true); break; case NEXT_WORD: - txt_jump_right(text, select); + txt_jump_right(text, select, true); break; case PREV_CHAR: From 648f925017788560b7d05fab3f5f2e4e3c39c8e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 05:02:20 +0000 Subject: [PATCH 117/157] misc changes - update man page for new additions since last release. - note that --start-console argument is windows only. - correct own assertion in own recent commit. --- doc/manpage/blender.1 | 24 ++++++++++++++++--- .../blenlib/intern/string_cursor_utf8.c | 8 +++++-- .../editors/uvedit/uvedit_parametrizer.c | 4 ++-- source/creator/creator.c | 2 +- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/doc/manpage/blender.1 b/doc/manpage/blender.1 index 2addb60c5f7..9cefe7a2b24 100644 --- a/doc/manpage/blender.1 +++ b/doc/manpage/blender.1 @@ -1,4 +1,4 @@ -.TH "BLENDER" "1" "December 04, 2012" "Blender Blender 2\&.65" +.TH "BLENDER" "1" "February 14, 2013" "Blender Blender 2\&.66" .SH NAME blender \- a 3D modelling and rendering package @@ -15,7 +15,7 @@ Use Blender to create TV commercials, to make technical visualizations, business http://www.blender.org .SH OPTIONS -Blender 2.65 +Blender 2.66 Usage: blender [args ...] [file] [args ...] .br .SS "Render Options:" @@ -218,6 +218,12 @@ Turn debugging on Enable floating point exceptions .br +.TP +.B \-\-disable\-crash\-handler +.br +Disable the crash handler +.br + .IP .TP @@ -301,7 +307,13 @@ Disable automatic python script execution (pydrivers & startup scripts) .TP .B \-P or \-\-python .br -Run the given Python script (filename or Blender Text) +Run the given Python script file +.br + +.TP +.B \-\-python\-text +.br +Run the given Python script text block .br .TP @@ -398,6 +410,12 @@ Register .blend extension, then exit (Windows only) Silently register .blend extension, then exit (Windows only) .br +.TP +.B \-\-no\-native\-pixels +.br +Do not use native pixel size, for high resolution displays (MacBook 'Retina') +.br + .SS "Argument Parsing:" arguments must be separated by white space. eg diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index b8797855f17..674d5ae5c8d 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -145,9 +145,11 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, if (direction == STRCUR_DIR_NEXT) { if (use_init_step) { - BLI_assert(jump == STRCUR_JUMP_DELIM); BLI_str_cursor_step_next_utf8(str, maxlen, pos); } + else { + BLI_assert(jump == STRCUR_JUMP_DELIM); + } if (jump != STRCUR_JUMP_NONE) { const strCursorDelimType delim_type = (*pos) < maxlen ? cursor_delim_type(&str[*pos]) : STRCUR_DELIM_NONE; @@ -167,9 +169,11 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, } else if (direction == STRCUR_DIR_PREV) { if (use_init_step) { - BLI_assert(jump == STRCUR_JUMP_DELIM); BLI_str_cursor_step_prev_utf8(str, maxlen, pos); } + else { + BLI_assert(jump == STRCUR_JUMP_DELIM); + } if (jump != STRCUR_JUMP_NONE) { const strCursorDelimType delim_type = (*pos) > 1 ? cursor_delim_type(&str[(*pos) - 1]) : STRCUR_DELIM_NONE; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 8911e227373..dd4f5221003 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -3131,8 +3131,8 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart) if (flip_faces) { SWAP(float, a2, a3); - SWAP(PEdge*, e2, e3); - SWAP(PVert*, v2, v3); + SWAP(PEdge *, e2, e3); + SWAP(PVert *, v2, v3); } sina1 = sin(a1); diff --git a/source/creator/creator.c b/source/creator/creator.c index 7ab5d9ff2bd..4b74e225ec4 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1366,7 +1366,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 2, "-p", "--window-geometry", " \n\tOpen with lower left corner at , and width and height as , ", prefsize, NULL); BLI_argsAdd(ba, 2, "-w", "--window-border", "\n\tForce opening with borders (default)", with_borders, NULL); BLI_argsAdd(ba, 2, "-W", "--window-borderless", "\n\tForce opening without borders", without_borders, NULL); - BLI_argsAdd(ba, 2, "-con", "--start-console", "\n\tStart with the console window open (ignored if -b is set)", start_with_console, NULL); + BLI_argsAdd(ba, 2, "-con", "--start-console", "\n\tStart with the console window open (ignored if -b is set), (Windows only)", start_with_console, NULL); BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension, then exit (Windows only)", register_extension, NULL); BLI_argsAdd(ba, 2, "-r", NULL, "\n\tSilently register .blend extension, then exit (Windows only)", register_extension, ba); BLI_argsAdd(ba, 2, NULL, "--no-native-pixels", "\n\tDo not use native pixel size, for high resolution displays (MacBook 'Retina')", native_pixels, ba); From 3dbed0e47f30db6fd10ed8c61bbce8590acc9871 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 05:10:12 +0000 Subject: [PATCH 118/157] update to operator running test, add option to randomize order, not reset blender for each operator and set data attributes. --- source/tests/bl_run_operators.py | 173 +++++++++++++++++++++++++++++-- 1 file changed, 163 insertions(+), 10 deletions(-) diff --git a/source/tests/bl_run_operators.py b/source/tests/bl_run_operators.py index 5bb25537458..0202f7c64fb 100644 --- a/source/tests/bl_run_operators.py +++ b/source/tests/bl_run_operators.py @@ -26,6 +26,11 @@ import bpy import sys +USE_ATTRSET = False +USE_RANDOM = False +RANDOM_SEED = [1] # so we can redo crashes +RANDOM_RESET = 0.1 # 10% chance of resetting on each mew operator + op_blacklist = ( "script.reload", "export*.*", @@ -36,18 +41,40 @@ op_blacklist = ( "*.link_append", "render.render", "render.play_rendered_anim", + "sound.bake_animation", # OK but slow + "sound.mixdown", # OK but slow + "object.bake_image", # OK but slow + "object.paths_calculate", # OK but slow + "object.paths_update", # OK but slow + "ptcache.bake_all", # OK but slow + "nla.bake", # OK but slow "*.*_export", "*.*_import", + "ed.undo_push", "wm.blenderplayer_start", "wm.url_open", "wm.doc_view", + "wm.doc_edit", + "wm.doc_view_manual", "wm.path_open", "wm.theme_install", "wm.context_*", + "wm.properties_add", + "wm.properties_remove", + "wm.properties_edit", + "wm.properties_context_change", "wm.operator_cheat_sheet", - "wm.keyconfig_test", # just annoying - but harmless - "wm.memory_statistics", # another annoying one - "console.*", # just annoying - but harmless + "wm.interface_theme_*", + "wm.appconfig_*", # just annoying - but harmless + "wm.keyitem_add", # just annoying - but harmless + "wm.keyconfig_activate", # just annoying - but harmless + "wm.keyconfig_preset_add", # just annoying - but harmless + "wm.keyconfig_test", # just annoying - but harmless + "wm.memory_statistics", # another annoying one + "wm.dependency_relations", # another annoying one + "wm.keymap_restore", # another annoying one + "wm.addon_*", # harmless, but dont change state + "console.*", # just annoying - but harmless ) @@ -64,8 +91,112 @@ def filter_op_list(operators): operators[:] = [op for op in operators if is_op_ok(op[0])] +def reset_blend(): + bpy.ops.wm.read_factory_settings() + for scene in bpy.data.scenes: + # reduce range so any bake action doesnt take too long + scene.frame_start = 1 + scene.frame_end = 5 + + +if USE_ATTRSET: + def build_property_typemap(skip_classes): + + property_typemap = {} + + for attr in dir(bpy.types): + cls = getattr(bpy.types, attr) + if issubclass(cls, skip_classes): + continue + + ## to support skip-save we cant get all props + # properties = cls.bl_rna.properties.keys() + properties = [] + for prop_id, prop in cls.bl_rna.properties.items(): + if not prop.is_skip_save: + properties.append(prop_id) + + properties.remove("rna_type") + property_typemap[attr] = properties + + return property_typemap + CLS_BLACKLIST = ( + bpy.types.BrushTextureSlot, + bpy.types.Brush, + ) + property_typemap = build_property_typemap(CLS_BLACKLIST) + bpy_struct_type = bpy.types.Struct.__base__ + + def id_walk(value, parent): + value_type = type(value) + value_type_name = value_type.__name__ + + value_id = getattr(value, "id_data", Ellipsis) + value_props = property_typemap.get(value_type_name, ()) + + for prop in value_props: + subvalue = getattr(value, prop) + + if subvalue == parent: + continue + + subvalue_type = type(subvalue) + yield value, prop, subvalue_type + subvalue_id = getattr(subvalue, "id_data", Ellipsis) + + if value_id == subvalue_id: + if subvalue_type == float: + pass + elif subvalue_type == int: + pass + elif subvalue_type == bool: + pass + elif subvalue_type == str: + pass + elif hasattr(subvalue, "__len__"): + for sub_item in subvalue[:]: + if isinstance(sub_item, bpy_struct_type): + subitem_id = getattr(sub_item, "id_data", Ellipsis) + if subitem_id == subvalue_id: + yield from id_walk(sub_item, value) + + if subvalue_type.__name__ in property_typemap: + yield from id_walk(subvalue, value) + + # main function + _random_values = ( + None, object, + 1, 0.1, -1, + "", "test", b"", b"test", + (), [], {}, + (10,), (10, 20), (0, 0, 0), + {}, + ) + + def attrset_data(): + for attr in dir(bpy.data): + if attr == "window_managers": + continue + seq = getattr(bpy.data, attr) + if seq.__class__.__name__ == 'bpy_prop_collection': + for id_data in seq: + for val, prop, tp in id_walk(id_data, bpy.data): + # print(id_data) + for val_rnd in _random_values: + try: + setattr(val, prop, val_rnd) + except: + pass + + def run_ops(operators, setup_func=None, reset=True): print("\ncontext:", setup_func.__name__) + + if USE_RANDOM: + import random + if random.random() < (1.0 - RANDOM_RESET): + reset = False + # first invoke for op_id, op in operators: if op.poll(): @@ -74,9 +205,16 @@ def run_ops(operators, setup_func=None, reset=True): # disable will get blender in a bad state and crash easy! if reset: - bpy.ops.wm.read_factory_settings() + reset_blend() - setup_func() + if USE_RANDOM: + # we can't be sure it will work + try: + setup_func() + except: + pass + else: + setup_func() for mode in {'EXEC_DEFAULT', 'INVOKE_DEFAULT'}: try: @@ -86,11 +224,21 @@ def run_ops(operators, setup_func=None, reset=True): #traceback.print_exc() pass + if USE_ATTRSET: + attrset_data() + if not operators: # run test if reset: - bpy.ops.wm.read_factory_settings() - setup_func() + reset_blend() + if USE_RANDOM: + # we can't be sure it will work + try: + setup_func() + except: + pass + else: + setup_func() # contexts @@ -217,7 +365,7 @@ def main(): bpy_check_type_duplicates() - # bpy.ops.wm.read_factory_settings() + # reset_blend() import bpy operators = [] for mod_name in dir(bpy.ops): @@ -233,8 +381,10 @@ def main(): # for testing, mix the list up. #operators.reverse() - #import random - #random.shuffle(operators) + if USE_RANDOM: + import random + random.seed(RANDOM_SEED[0]) + random.shuffle(operators) # 2 passes, first just run setup_func to make sure they are ok for operators_test in ((), operators): @@ -270,4 +420,7 @@ def main(): print("Finished %r" % __file__) if __name__ == "__main__": + #~ for i in range(200): + #~ RANDOM_SEED[0] += 1 + #~ main() main() From 26704c0451a91d694d71148f06f341242785fc2c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 14 Feb 2013 07:49:50 +0000 Subject: [PATCH 119/157] More nodes UI translation fixes. I *hate* this rna_nodetree_types.h file! --- source/blender/editors/interface/interface_templates.c | 2 +- source/blender/makesrna/intern/rna_nodetree_types.h | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ff47d481fc8..57d5fd38fdc 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1846,7 +1846,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) /* use this for a fake extra empy space around the buttons */ uiDefBut(block, LABEL, 0, "", -4, 16, width + 8, 6 * UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - bt = uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, "Use Clipping", + bt = uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, IFACE_("Use Clipping"), 0, 5 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, ""); uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL); diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 4315d24d8f2..10c5a0b8819 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -31,6 +31,8 @@ #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) #endif +/* WARNING! If you edit those strings, please do the same in relevant nodes files (under blender/nodes/...)! */ + /* Tree type Node ID RNA def function Enum name Struct name UI Name UI Description */ DefNode( ShaderNode, SH_NODE_OUTPUT, 0, "OUTPUT", Output, "Output", "" ) DefNode( ShaderNode, SH_NODE_MATERIAL, def_sh_material, "MATERIAL", Material, "Material", "" ) @@ -45,8 +47,8 @@ DefNode( ShaderNode, SH_NODE_GAMMA, 0, "GAMMA DefNode( ShaderNode, SH_NODE_BRIGHTCONTRAST, 0, "BRIGHTCONTRAST", BrightContrast, "Bright Contrast", "" ) DefNode( ShaderNode, SH_NODE_GEOMETRY, def_sh_geometry, "GEOMETRY", Geometry, "Geometry", "" ) DefNode( ShaderNode, SH_NODE_MAPPING, def_sh_mapping, "MAPPING", Mapping, "Mapping", "" ) -DefNode( ShaderNode, SH_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", VectorCurve, "Vector Curve", "" ) -DefNode( ShaderNode, SH_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", RGBCurve, "RGB Curve", "" ) +DefNode( ShaderNode, SH_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", VectorCurve, "Vector Curves", "" ) +DefNode( ShaderNode, SH_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", RGBCurve, "RGB Curves", "" ) DefNode( ShaderNode, SH_NODE_CAMERA, 0, "CAMERA", CameraData, "Camera Data", "" ) DefNode( ShaderNode, SH_NODE_MATH, def_math, "MATH", Math, "Math", "" ) DefNode( ShaderNode, SH_NODE_VECT_MATH, def_vector_math, "VECT_MATH", VectorMath, "Vector Math", "" ) @@ -109,7 +111,7 @@ DefNode( CompositorNode, CMP_NODE_MIX_RGB, def_mix_rgb, "MIX_R DefNode( CompositorNode, CMP_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) DefNode( CompositorNode, CMP_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) DefNode( CompositorNode, CMP_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) -DefNode( CompositorNode, CMP_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", CurveVec, "Vector Curve", "" ) +DefNode( CompositorNode, CMP_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", CurveVec, "Vector Curves", "" ) DefNode( CompositorNode, CMP_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curves", "" ) DefNode( CompositorNode, CMP_NODE_ALPHAOVER, def_cmp_alpha_over, "ALPHAOVER", AlphaOver, "Alpha Over", "" ) DefNode( CompositorNode, CMP_NODE_BLUR, def_cmp_blur, "BLUR", Blur, "Blur", "" ) @@ -194,7 +196,7 @@ DefNode( TextureNode, TEX_NODE_MIX_RGB, def_mix_rgb, "MIX_R DefNode( TextureNode, TEX_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) DefNode( TextureNode, TEX_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) DefNode( TextureNode, TEX_NODE_IMAGE, def_tex_image, "IMAGE", Image, "Image", "" ) -DefNode( TextureNode, TEX_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curve", "" ) +DefNode( TextureNode, TEX_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curves", "" ) DefNode( TextureNode, TEX_NODE_INVERT, 0, "INVERT", Invert, "Invert", "" ) DefNode( TextureNode, TEX_NODE_HUE_SAT, 0, "HUE_SAT", HueSaturation, "Hue/Saturation", "" ) DefNode( TextureNode, TEX_NODE_CURVE_TIME, def_time, "CURVE_TIME", CurveTime, "Curve Time", "" ) From 3cf0c93be1ac52e94e772458c6d357882dc7a779 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 09:17:50 +0000 Subject: [PATCH 120/157] modify own changes to is_quad_convex_v3() to allow quads with a co-linear side to be considered convex (as it did in last release). this is needed so zero area faces be dealt with by beauty fill. --- source/blender/blenlib/intern/math_geom.c | 49 ++++++++++++++--------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 618c237c8ba..1e1d97a35a4 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -3578,29 +3578,42 @@ float form_factor_hemi_poly(float p[3], float n[3], float v1[3], float v2[3], fl /* evaluate if entire quad is a proper convex quad */ int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]) { - float nor[3], nor1[3], nor2[3], vec[4][2]; + float nor[3], nor_a[3], nor_b[3], vec[4][2]; float mat[3][3]; + const bool is_ok_a = (normal_tri_v3(nor_a, v1, v2, v3) > FLT_EPSILON); + const bool is_ok_b = (normal_tri_v3(nor_b, v1, v3, v4) > FLT_EPSILON); /* define projection, do both trias apart, quad is undefined! */ /* check normal length incase one size is zero area */ - if (UNLIKELY((normal_tri_v3(nor1, v1, v2, v3) <= FLT_EPSILON) || - (normal_tri_v3(nor2, v1, v3, v4) <= FLT_EPSILON))) - { - return false; - } + if (is_ok_a) { + if (is_ok_b) { + /* use both, most common outcome */ - /* when the face is folded over as 2 tris we probably don't want to create - * a quad from it, but go ahead with the intersection test since this - * isn't a function for degenerate faces */ - if (UNLIKELY(dot_v3v3(nor1, nor2) < 0.0f)) { - /* flip so adding normals in the opposite direction - * doesnt give a zero length vector */ - negate_v3(nor2); - } + /* when the face is folded over as 2 tris we probably don't want to create + * a quad from it, but go ahead with the intersection test since this + * isn't a function for degenerate faces */ + if (UNLIKELY(dot_v3v3(nor_a, nor_b) < 0.0f)) { + /* flip so adding normals in the opposite direction + * doesn't give a zero length vector */ + negate_v3(nor_b); + } - add_v3_v3v3(nor, nor1, nor2); - normalize_v3(nor); + add_v3_v3v3(nor, nor_a, nor_b); + normalize_v3(nor); + } + else { + copy_v3_v3(nor, nor_a); /* only 'a' */ + } + } + else { + if (is_ok_b) { + copy_v3_v3(nor, nor_b); /* only 'b' */ + } + else { + return false; /* both zero, we can't do anything useful here */ + } + } axis_dominant_v3_to_m3(mat, nor); @@ -3610,12 +3623,12 @@ int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], c mul_v2_m3v3(vec[3], mat, v4); /* linetests, the 2 diagonals have to instersect to be convex */ - return (isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) == ISECT_LINE_LINE_CROSS); + return (isect_line_line_v2(vec[0], vec[2], vec[1], vec[3]) > 0); } int is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]) { /* linetests, the 2 diagonals have to instersect to be convex */ - return (isect_line_line_v2(v1, v3, v2, v4) == ISECT_LINE_LINE_CROSS); + return (isect_line_line_v2(v1, v3, v2, v4) > 0); } From ceb3624b115848d96f11f1507474ee5a61f9e0d0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 14 Feb 2013 13:47:49 +0000 Subject: [PATCH 121/157] After scroll bar commit motrack dopesheet went out of sync vertically Shall be fine now. --- source/blender/editors/space_clip/clip_dopesheet_draw.c | 4 ++-- source/blender/editors/space_clip/space_clip.c | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index cc1b8d444bc..09d97c36436 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -159,7 +159,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) MovieTrackingDopesheetChannel *channel; float y, xscale, yscale; float strip[4], selected_strip[4]; - float height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2); + float height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT); /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) @@ -272,7 +272,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) tracking = &clip->tracking; dopesheet = &tracking->dopesheet; - height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2); + height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT); if (height > BLI_rcti_size_y(&v2d->mask)) { /* don't use totrect set, as the width stays the same diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 9d0421349d7..f0c0e7b72fd 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1282,6 +1282,9 @@ static void clip_channels_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; + /* ensure the 2d view sync works - main region has bottom scroller */ + ar->v2d.scroll = V2D_SCROLL_BOTTOM; + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); keymap = WM_keymap_find(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); @@ -1293,7 +1296,6 @@ static void clip_channels_area_draw(const bContext *C, ARegion *ar) SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; - View2DScrollers *scrollers; if (clip) BKE_tracking_dopesheet_update(&clip->tracking); @@ -1309,11 +1311,6 @@ static void clip_channels_area_draw(const bContext *C, ARegion *ar) /* reset view matrix */ UI_view2d_view_restore(C); - - /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); - UI_view2d_scrollers_draw(C, v2d, scrollers); - UI_view2d_scrollers_free(scrollers); } static void clip_channels_area_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn)) From 9449866bdca7736155b1d8a42bfb230ec3084d51 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 14:01:02 +0000 Subject: [PATCH 122/157] fix (for one case of...) [#33949] T_ALT_TRANSFORM conflicts with "emulate 3 button mouse" ShrinkFatten operator now uses scale key to toggle 'Even thickness' option. With the default keymap this is Alt+S,S. Added functionality so the header print can get the key used for the modal keymap, some other operators should make use of this too. --- source/blender/editors/metaball/mball_ops.c | 7 ++-- source/blender/editors/transform/transform.c | 34 +++++++++++++++---- source/blender/editors/transform/transform.h | 1 + source/blender/windowmanager/WM_keymap.h | 3 +- .../blender/windowmanager/intern/wm_keymap.c | 24 ++++++++++--- 5 files changed, 53 insertions(+), 16 deletions(-) diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index e98654f589a..f91d57424a1 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -28,10 +28,6 @@ * \ingroup edmeta */ - -#include "WM_api.h" -#include "WM_types.h" - #include "RNA_access.h" #include "ED_mball.h" @@ -40,6 +36,9 @@ #include "BLI_utildefines.h" +#include "WM_api.h" +#include "WM_types.h" + #include "mball_intern.h" void ED_operatortypes_metaball(void) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index a76fd4a8746..ae7e3eeba28 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -958,6 +958,10 @@ int transformEvent(TransInfo *t, wmEvent *event) initSnapping(t, NULL); // need to reinit after mode change t->redraw |= TREDRAW_HARD; } + else if (t->mode == TFM_SHRINKFATTEN) { + t->flag ^= T_ALT_TRANSFORM; + t->redraw |= TREDRAW_HARD; + } else if (t->mode == TFM_RESIZE) { if (t->options & CTX_MOVIECLIP) { restoreTransObjects(t); @@ -1920,6 +1924,8 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int } + t->keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap); + initSnapping(t, op); // Initialize snapping data AFTER mode flags /* EVIL! posemode code can switch translation to rotate when 1 bone is selected. will be removed (ton) */ @@ -4054,7 +4060,8 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { float distance; int i; - char str[64]; + char str[128]; + char *str_p; TransData *td = t->data; distance = -t->values[0]; @@ -4064,18 +4071,30 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) applyNumInput(&t->num, &distance); /* header print for NumInput */ + str_p = str; + str_p += BLI_snprintf(str_p, sizeof(str), "Shrink/Fatten:"); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c); - - sprintf(str, "Shrink/Fatten: %s %s", c, t->proptext); + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), " %s", c); } else { /* default header print */ - sprintf(str, "Shrink/Fatten: %.4f %s", distance, t->proptext); + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), " %.4f", distance); } + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), " %s, (", t->proptext); + { + wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE); + if (kmi) { + str_p += WM_keymap_item_to_string(kmi, str_p, sizeof(str) - (str_p - str)); + } + } + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), ") Even Thickness %s", + (t->flag & T_ALT_TRANSFORM) ? "ON" : "OFF"); + /* done with header string */ + + t->values[0] = -distance; for (i = 0; i < t->total; i++, td++) { @@ -6398,14 +6417,15 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2])) /* header string */ str_p = str; + str_p += BLI_snprintf(str_p, sizeof(str), "Vert Slide: "); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; applyNumInput(&t->num, &final); outputNumInput(&(t->num), c); - str_p += BLI_snprintf(str, sizeof(str), "Vert Slide: %s", &c[0]); + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), "%s", &c[0]); } else { - str_p += BLI_snprintf(str_p, sizeof(str), "Vert Slide: %.4f ", final); + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), "%.4f ", final); } str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), "(E)ven: %s, ", !is_proportional ? "ON" : "OFF"); if (!is_proportional) { diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 55b7e9fae60..78f346be2aa 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -352,6 +352,7 @@ typedef struct TransInfo { struct Scene *scene; struct ToolSettings *settings; struct wmTimer *animtimer; + struct wmKeyMap *keymap; /* so we can do lookups for header text */ int mval[2]; /* current mouse position */ struct Object *obedit; void *draw_handle_apply; diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index 43369154dbb..49ee759bbf2 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -64,7 +64,7 @@ wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const char *idname, in int val, int modifier, int keymodifier); int WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi); -char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len); +int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, const int len); wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid); wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid); @@ -81,6 +81,7 @@ wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, st wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, const char *idname); wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value); wmKeyMapItem *WM_modalkeymap_add_item_str(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value); +wmKeyMapItem *WM_modalkeymap_find_propvalue(wmKeyMap *km, const int propvalue); void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname); /* Keymap Editor */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index a296c742e5c..92a310ac34e 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -737,6 +737,24 @@ wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km, int type, int val, int m return kmi; } +wmKeyMapItem *WM_modalkeymap_find_propvalue(wmKeyMap *km, const int propvalue) +{ + + if (km->flag & KEYMAP_MODAL) { + wmKeyMapItem *kmi; + for (kmi = km->items.first; kmi; kmi = kmi->next) { + if (kmi->propvalue == propvalue) { + return kmi; + } + } + } + else { + BLI_assert(!"called with non modal keymap"); + } + + return NULL; +} + void WM_modalkeymap_assign(wmKeyMap *km, const char *opname) { wmOperatorType *ot = WM_operatortype_find(opname, 0); @@ -785,7 +803,7 @@ const char *WM_key_event_string(short type) return ""; } -char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) +int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) { char buf[128]; @@ -818,9 +836,7 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) } strcat(buf, WM_key_event_string(kmi->type)); - BLI_strncpy(str, buf, len); - - return str; + return BLI_snprintf(str, len, "%s", buf); } static wmKeyMapItem *wm_keymap_item_find_handlers( From f5398f0facb95cc5ea173c050d333beace1fae41 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 14 Feb 2013 14:01:48 +0000 Subject: [PATCH 123/157] Bug fix #34230 Error since July 2005, when DerivedMesh was introduced. Vertex and Face duplicators now work for all modifiers. (not only deformers). For example mirror and array modifier didn't work. --- source/blender/blenkernel/intern/anim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index bc9c8a7ad50..a6b3008e00a 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -967,7 +967,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl dm = editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); } else - dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH); + dm = mesh_get_derived_final(scene, par, CD_MASK_BAREMESH); if (flag & DUPLILIST_FOR_RENDER) { vdd.orco = (float(*)[3])BKE_mesh_orco_verts_get(par); @@ -1094,7 +1094,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa dm = editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); } else { - dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH); + dm = mesh_get_derived_final(scene, par, CD_MASK_BAREMESH); } totface = dm->getNumPolys(dm); From 5078174f07c41c4ab7a3f20e5e3400964f303253 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 14 Feb 2013 14:41:04 +0000 Subject: [PATCH 124/157] New Hindi translation... --- release/scripts/modules/bl_i18n_utils/settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index 9fdff5e8a76..432f25f234b 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -83,6 +83,7 @@ LANGUAGES = ( (37, "Amharic (አማርኛ)", "am_ET"), (38, "Uzbek (Oʻzbek)", "uz_UZ"), (39, "Uzbek Cyrillic (Ўзбек)", "uz_UZ@cyrillic"), + (40, "Hindi (मानक हिन्दी)", "hi_IN"), ) # Name of language file used by Blender to generate translations' menu. @@ -93,7 +94,7 @@ LANGUAGES_FILE = "languages" IMPORT_MIN_LEVEL = -1 # Languages in /branches we do not want to import in /trunk currently... -IMPORT_LANGUAGES_SKIP = {'am', 'bg', 'fi', 'el', 'et', 'ne', 'pl', 'ro', 'uz', 'uz@cyrillic'} +IMPORT_LANGUAGES_SKIP = {'am', 'bg', 'fi', 'el', 'et', 'hi', 'ne', 'pl', 'ro', 'uz', 'uz@cyrillic'} # The comment prefix used in generated messages.txt file. MSG_COMMENT_PREFIX = "#~ " From 8d339a89dbdd6fb1691efd67544c79ffb6f6a2f8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 14:50:16 +0000 Subject: [PATCH 125/157] fix [#33949] T_ALT_TRANSFORM conflicts with "emulate 3 button mouse" finally last transform tool relying on alt has an alternative. Sequencer slide which makes room for the placed strip by moving others - Pressing G a second time toggles this behavior. --- source/blender/editors/transform/transform.c | 29 ++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ae7e3eeba28..8ffa04050a2 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -894,6 +894,10 @@ int transformEvent(TransInfo *t, wmEvent *event) t->redraw |= TREDRAW_HARD; WM_event_add_mousemove(t->context); } + else if (t->mode == TFM_SEQ_SLIDE) { + t->flag ^= T_ALT_TRANSFORM; + t->redraw |= TREDRAW_HARD; + } else { if (t->obedit && t->obedit->type == OB_MESH) { if ((t->mode == TFM_TRANSLATION) && (t->spacetype == SPACE_VIEW3D)) { @@ -4083,14 +4087,18 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), " %.4f", distance); } - str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), " %s, (", t->proptext); + if (t->proptext[0]) { + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), " %s", t->proptext); + } + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), ", ("); + { wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE); if (kmi) { str_p += WM_keymap_item_to_string(kmi, str_p, sizeof(str) - (str_p - str)); } } - str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), ") Even Thickness %s", + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), " or Alt) Even Thickness %s", (t->flag & T_ALT_TRANSFORM) ? "ON" : "OFF"); /* done with header string */ @@ -6752,9 +6760,10 @@ void initSeqSlide(TransInfo *t) t->num.increment = t->snap[1]; } -static void headerSeqSlide(TransInfo *t, float val[2], char *str) +static void headerSeqSlide(TransInfo *t, float val[2], char *str, size_t str_len) { char tvec[NUM_STR_REP_LEN * 3]; + char *str_p; if (hasNumInput(&t->num)) { outputNumInput(&(t->num), tvec); @@ -6763,7 +6772,17 @@ static void headerSeqSlide(TransInfo *t, float val[2], char *str) sprintf(&tvec[0], "%.0f, %.0f", val[0], val[1]); } - sprintf(str, "Sequence Slide: %s%s", &tvec[0], t->con.text); + str_p = str; + str_p += BLI_snprintf(str, str_len, "Sequence Slide: %s%s, (", &tvec[0], t->con.text); + + { + wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_TRANSLATE); + if (kmi) { + str_p += WM_keymap_item_to_string(kmi, str_p, str_len - (str_p - str)); + } + } + str_p += BLI_snprintf(str_p, str_len - (str_p - str), " or Alt) Expand to fit %s", + (t->flag & T_ALT_TRANSFORM) ? "ON" : "OFF"); } static void applySeqSlide(TransInfo *t, float val[2]) @@ -6807,7 +6826,7 @@ int SeqSlide(TransInfo *t, const int UNUSED(mval[2])) t->values[0] = floor(t->values[0] + 0.5f); t->values[1] = floor(t->values[1] + 0.5f); - headerSeqSlide(t, t->values, str); + headerSeqSlide(t, t->values, str, sizeof(str)); applySeqSlide(t, t->values); recalcData(t); From 59a2ed19df86bcb60034af693ee8909ddc57c081 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Thu, 14 Feb 2013 15:44:09 +0000 Subject: [PATCH 126/157] Fix: Tiled image painting in image editor was broken for float canvas. The mask was initialized using texture values, while it needed to be opaque. --- source/blender/blenkernel/intern/brush.c | 7 ++++++- source/blender/editors/sculpt_paint/paint_image_2d.c | 10 ++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 2ce5053bdcc..ce838ce519e 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -588,11 +588,16 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf else if (texfall == 1) { BKE_brush_sample_tex_2D(scene, brush, xy, dstf, 0); } - else { + else if (texfall == 2){ BKE_brush_sample_tex_2D(scene, brush, xy, rgba, 0); mul_v3_v3v3(dstf, rgba, brush_rgb); dstf[3] = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); } + else { + BKE_brush_sample_tex_2D(scene, brush, xy, rgba, 0); + copy_v3_v3(dstf, brush_rgb); + dstf[3] = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); + } } } } diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 0b76c88df66..84250853f38 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -197,8 +197,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, for (x = origx; x < w; x++, bf += 4, mf += 4, tf += 4) { if (dotexold) { - copy_v3_v3(tf, otf); - tf[3] = otf[3]; + copy_v4_v4(tf, otf); otf += 4; } else { @@ -249,7 +248,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, } } -static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, const float pos[2]) +static void brush_painter_tiled_tex_partial_update(BrushPainter *painter, const float pos[2]) { const Scene *scene = painter->scene; Brush *brush = painter->brush; @@ -265,7 +264,6 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, const oldtexibuf = cache->texibuf; cache->texibuf = IMB_allocImBuf(diameter, diameter, 32, imbflag); - if (oldtexibuf) { srcx = srcy = 0; destx = (int)painter->lastpaintpos[0] - (int)pos[0]; @@ -334,7 +332,7 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 if (do_tiled) { BKE_brush_imbuf_new(scene, brush, flt, 3, size, &cache->maskibuf, use_color_correction); - brush_painter_fixed_tex_partial_update(painter, pos); + brush_painter_tiled_tex_partial_update(painter, pos); } else BKE_brush_imbuf_new(scene, brush, flt, 2, size, &cache->ibuf, use_color_correction); @@ -348,7 +346,7 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 int dy = (int)painter->lastpaintpos[1] - (int)pos[1]; if ((dx != 0) || (dy != 0)) - brush_painter_fixed_tex_partial_update(painter, pos); + brush_painter_tiled_tex_partial_update(painter, pos); } } From a47af30561ea9b0b2933a4af202a560b3576ee11 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 14 Feb 2013 16:01:34 +0000 Subject: [PATCH 127/157] Fix #34240: cycles material preview of sphere + sky had black sky, now it uses the current scene world. --- source/blender/editors/render/render_preview.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 80dcb93a7a2..33b00cbf2ea 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -360,7 +360,11 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } } } - + else { + /* use current scene world to light sphere */ + if (ma->pr_type == MA_SPHERE_A) + sce->world = scene->world; + } if (sp->pr_method == PR_ICON_RENDER) { if (mat->material_type == MA_TYPE_HALO) { From adbd84c320d8b0781e97d09055f6cde4920b79f8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 14 Feb 2013 16:11:47 +0000 Subject: [PATCH 128/157] Fix #34121: OSL + persistent images option was not freeing shader memory properly, causing memory to increase continuously during animation render. --- intern/cycles/blender/blender_sync.cpp | 5 ++++- intern/cycles/render/mesh.cpp | 8 ++++++++ intern/cycles/render/osl.cpp | 13 ++++++++++++- intern/cycles/render/osl.h | 2 ++ intern/cycles/render/scene.cpp | 14 +++++++------- intern/cycles/render/shader.h | 2 ++ intern/cycles/render/svm.cpp | 4 ++++ intern/cycles/render/svm.h | 2 ++ source/blender/editors/render/render_preview.c | 2 +- 9 files changed, 42 insertions(+), 10 deletions(-) diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 7ad663b7e26..87c4efffe6c 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -307,7 +307,10 @@ SceneParams BlenderSync::get_scene_params(BL::Scene b_scene, bool background) params.use_bvh_spatial_split = RNA_boolean_get(&cscene, "debug_use_spatial_splits"); params.use_bvh_cache = (background)? RNA_boolean_get(&cscene, "use_cache"): false; - params.persistent_images = (background)? r.use_persistent_data(): false; + if(background && params.shadingsystem != SceneParams::OSL) + params.persistent_images = r.use_persistent_data(); + else + params.persistent_images = false; return params; } diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 57776e4cfa6..3a6fba32b34 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -966,6 +966,14 @@ void MeshManager::device_free(Device *device, DeviceScene *dscene) dscene->attributes_map.clear(); dscene->attributes_float.clear(); dscene->attributes_float3.clear(); + + OSLGlobals *og = (OSLGlobals*)device->osl_memory(); + + if(og) { + og->object_name_map.clear(); + og->attribute_map.clear(); + og->object_names.clear(); + } } void MeshManager::tag_update(Scene *scene) diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index 28de56f3a72..56158278e29 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -47,17 +47,27 @@ OSLShaderManager::OSLShaderManager() { services = new OSLRenderServices(); - shading_system_init(); texture_system_init(); + shading_system_init(); } OSLShaderManager::~OSLShaderManager() { OSL::ShadingSystem::destroy(ss); OSL::TextureSystem::destroy(ts); + delete services; } +void OSLShaderManager::reset(Scene *scene) +{ + OSL::ShadingSystem::destroy(ss); + delete services; + + services = new OSLRenderServices(); + shading_system_init(); +} + void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) { if(!need_update) @@ -88,6 +98,7 @@ void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene og->ss = ss; og->ts = ts; og->services = services; + int background_id = scene->shader_manager->get_shader_id(scene->default_background); og->background_state = og->surface_state[background_id & SHADER_MASK]; og->use = true; diff --git a/intern/cycles/render/osl.h b/intern/cycles/render/osl.h index d17f4c81362..4b4ed6cba00 100644 --- a/intern/cycles/render/osl.h +++ b/intern/cycles/render/osl.h @@ -64,6 +64,8 @@ public: OSLShaderManager(); ~OSLShaderManager(); + void reset(Scene *scene); + bool use_osl() { return true; } void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress); diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index 093bfecf88e..a1fcffa94a4 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -85,6 +85,12 @@ void Scene::free_memory(bool final) foreach(ParticleSystem *p, particle_systems) delete p; + shaders.clear(); + meshes.clear(); + objects.clear(); + lights.clear(); + particle_systems.clear(); + if(device) { camera->device_free(device, &dscene); filter->device_free(device, &dscene); @@ -118,13 +124,6 @@ void Scene::free_memory(bool final) delete curve_system_manager; delete image_manager; } - else { - shaders.clear(); - meshes.clear(); - objects.clear(); - lights.clear(); - particle_systems.clear(); - } } void Scene::device_update(Device *device_, Progress& progress) @@ -257,6 +256,7 @@ bool Scene::need_reset() void Scene::reset() { + shader_manager->reset(this); shader_manager->add_default(this); /* ensure all objects are updated */ diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h index d4421002ceb..b38e098e3cb 100644 --- a/intern/cycles/render/shader.h +++ b/intern/cycles/render/shader.h @@ -110,6 +110,8 @@ public: static ShaderManager *create(Scene *scene, int shadingsystem); virtual ~ShaderManager(); + virtual void reset(Scene *scene) = 0; + virtual bool use_osl() { return false; } /* device update */ diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp index f7cb8f62247..5cb11a4ec1a 100644 --- a/intern/cycles/render/svm.cpp +++ b/intern/cycles/render/svm.cpp @@ -40,6 +40,10 @@ SVMShaderManager::~SVMShaderManager() { } +void SVMShaderManager::reset(Scene *scene) +{ +} + void SVMShaderManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) { if(!need_update) diff --git a/intern/cycles/render/svm.h b/intern/cycles/render/svm.h index 0b15c5aaa1e..c1ce619e12a 100644 --- a/intern/cycles/render/svm.h +++ b/intern/cycles/render/svm.h @@ -45,6 +45,8 @@ public: SVMShaderManager(); ~SVMShaderManager(); + void reset(Scene *scene); + void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress); void device_free(Device *device, DeviceScene *dscene); }; diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 33b00cbf2ea..dfc80e4cf51 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -362,7 +362,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } else { /* use current scene world to light sphere */ - if (ma->pr_type == MA_SPHERE_A) + if (mat->pr_type == MA_SPHERE_A) sce->world = scene->world; } From e0ca72735d586ba0abc380018bdc247199479f15 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 14 Feb 2013 16:48:43 +0000 Subject: [PATCH 129/157] Further fix for #34121: OSL + persistent images could crash in some cases still. --- intern/cycles/blender/blender_session.cpp | 3 ++- intern/cycles/blender/blender_sync.cpp | 4 ++-- intern/cycles/render/scene.cpp | 2 +- intern/cycles/render/scene.h | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index dfea9833287..98a4e5bda9f 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -128,7 +128,8 @@ void BlenderSession::reset_session(BL::BlendData b_data_, BL::Scene b_scene_) height = b_engine.resolution_y(); if(scene->params.modified(scene_params) || - session->params.modified(session_params)) + session->params.modified(session_params) || + !scene_params.persistent_data) { /* if scene or session parameters changed, it's easier to simply re-create * them rather than trying to distinguish which settings need to be updated diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 87c4efffe6c..f6ff78ab2ac 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -308,9 +308,9 @@ SceneParams BlenderSync::get_scene_params(BL::Scene b_scene, bool background) params.use_bvh_cache = (background)? RNA_boolean_get(&cscene, "use_cache"): false; if(background && params.shadingsystem != SceneParams::OSL) - params.persistent_images = r.use_persistent_data(); + params.persistent_data = r.use_persistent_data(); else - params.persistent_images = false; + params.persistent_data = false; return params; } diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index a1fcffa94a4..7b82a91cae8 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -106,7 +106,7 @@ void Scene::free_memory(bool final) particle_system_manager->device_free(device, &dscene); curve_system_manager->device_free(device, &dscene); - if(!params.persistent_images || final) + if(!params.persistent_data || final) image_manager->device_free(device, &dscene); } diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h index f6e1daea80d..fc6b538af03 100644 --- a/intern/cycles/render/scene.h +++ b/intern/cycles/render/scene.h @@ -125,7 +125,7 @@ public: bool use_bvh_cache; bool use_bvh_spatial_split; bool use_qbvh; - bool persistent_images; + bool persistent_data; SceneParams() { @@ -146,7 +146,7 @@ public: && use_bvh_cache == params.use_bvh_cache && use_bvh_spatial_split == params.use_bvh_spatial_split && use_qbvh == params.use_qbvh - && persistent_images == params.persistent_images); } + && persistent_data == params.persistent_data); } }; /* Scene */ From 7ae735dc4a9a6400ec33f01f7a409ed3710493b7 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 14 Feb 2013 17:09:19 +0000 Subject: [PATCH 130/157] Cycles UI: * "Use Nodes" for World, did not trigger Node Editor refresh. --- source/blender/editors/space_node/space_node.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index a5f6ca9ded0..264bea5f871 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -498,6 +498,7 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) case NC_SCENE: case NC_MATERIAL: case NC_TEXTURE: + case NC_WORLD: case NC_NODE: ED_region_tag_redraw(ar); break; From e3944f5bfaffebe0f55df47db76515dd0ac7426b Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Thu, 14 Feb 2013 17:35:43 +0000 Subject: [PATCH 131/157] Divide by 3 instead of multiplying by variations of 0.333 Fixes small precision problems. --- source/blender/blenkernel/intern/effect.c | 2 +- source/blender/blenkernel/intern/lattice.c | 2 +- source/blender/blenkernel/intern/object.c | 2 +- .../blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenlib/intern/math_geom.c | 6 +++--- .../blender/editors/interface/interface_panel.c | 4 ++-- source/blender/editors/physics/particle_edit.c | 2 +- source/blender/modifiers/intern/MOD_explode.c | 2 +- source/blender/nodes/shader/node_shader_util.c | 2 +- .../render/intern/source/render_texture.c | 16 ++++++++-------- source/blender/render/intern/source/voxeldata.c | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 1880cb42f4d..9e8693e957e 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -562,7 +562,7 @@ int closest_point_on_surface(SurfaceModifierData *surmd, const float co[3], floa if (mface->v4) add_v3_v3(surface_vel, surmd->v[mface->v4].co); - mul_v3_fl(surface_vel, mface->v4 ? 0.25f : 0.333f); + mul_v3_fl(surface_vel, mface->v4 ? 0.25f : (1.0f / 3.0f)); } return 1; } diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index fd57a88e279..c3e7a963c04 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -912,7 +912,7 @@ void outside_lattice(Lattice *lt) bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1]; bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2]; - mul_v3_fl(bp->vec, 0.3333333f); + mul_v3_fl(bp->vec, 1.0f / 3.0f); } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 87457621ced..0140152790c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2013,7 +2013,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4]) else { add_v3_v3v3(mat[3], v1, v2); add_v3_v3(mat[3], v3); - mul_v3_fl(mat[3], 0.3333333f); + mul_v3_fl(mat[3], 1.0f / 3.0f); } } } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index fda5f6f2ecb..6e4937d11ec 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -802,7 +802,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch if (mface->v4) psys_uv_to_w(0.5f, 0.5f, mface->v4, pa->fuv); else - psys_uv_to_w(0.33333f, 0.33333f, mface->v4, pa->fuv); + psys_uv_to_w(1.0f / 3.0f, 1.0f / 3.0f, mface->v4, pa->fuv); } else { ctx->jitoff[i] = fmod(ctx->jitoff[i],(float)ctx->jitlevel); diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 1e1d97a35a4..7337718bd3c 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -39,9 +39,9 @@ void cent_tri_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3]) { - cent[0] = 0.33333f * (v1[0] + v2[0] + v3[0]); - cent[1] = 0.33333f * (v1[1] + v2[1] + v3[1]); - cent[2] = 0.33333f * (v1[2] + v2[2] + v3[2]); + cent[0] = (v1[0] + v2[0] + v3[0]) / 3.0f; + cent[1] = (v1[1] + v2[1] + v3[1]) / 3.0f; + cent[2] = (v1[2] + v2[2] + v3[2]) / 3.0f; } void cent_quad_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3]) diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 1b2034d6e40..e466c481151 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -447,8 +447,8 @@ static void ui_draw_panel_dragwidget(const rctf *rect) ymin = rect->ymin; ymax = rect->ymax; - dx = 0.333f * (xmax - xmin); - dy = 0.333f * (ymax - ymin); + dx = (xmax - xmin) / 3.0f; + dy = (ymax - ymin) / 3.0f; glEnable(GL_BLEND); glColor4ub(255, 255, 255, 50); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 78377834b9f..31079de275e 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1112,7 +1112,7 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys) mul_v3_fl(vec, 0.25); } else - mul_v3_fl(vec, 0.3333f); + mul_v3_fl(vec, 1.0f / 3.0f); normalize_v3(nor); diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 1298d281de8..638f8f0ae01 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -161,7 +161,7 @@ static void createFacepa(ExplodeModifierData *emd, mul_v3_fl(center, 0.25); } else - mul_v3_fl(center, 0.3333f); + mul_v3_fl(center, 1.0f / 3.0f); p = BLI_kdtree_find_nearest(tree, center, NULL, NULL); diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 3eb2cdc8ab7..1123a0dc44a 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -46,7 +46,7 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) if (ns->sockettype==SOCK_FLOAT) *in= *from; else - *in= 0.333333f*(from[0]+from[1]+from[2]); + *in= (from[0]+from[1]+from[2]) / 3.0f; } else if (type_in==SOCK_VECTOR) { if (ns->sockettype==SOCK_FLOAT) { diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 3ea94981cac..15ca865643b 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -171,9 +171,9 @@ static void tex_normal_derivate(Tex *tex, TexResult *texres) do_colorband(tex->coba, texres->nor[2], col); fac3= (col[0]+col[1]+col[2]); - texres->nor[0]= 0.3333f*(fac0 - fac1); - texres->nor[1]= 0.3333f*(fac0 - fac2); - texres->nor[2]= 0.3333f*(fac0 - fac3); + texres->nor[0]= (fac0 - fac1) / 3.0f; + texres->nor[1]= (fac0 - fac2) / 3.0f; + texres->nor[2]= (fac0 - fac3) / 3.0f; return; } @@ -1754,7 +1754,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, /* center, main return value */ texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres, pool); - cd = fromrgb ? (texres->tr + texres->tg + texres->tb)*0.33333333f : texres->tin; + cd = fromrgb ? (texres->tr + texres->tg + texres->tb) / 3.0f : texres->tin; if (mtex->texco == TEXCO_UV) { /* for the uv case, use the same value for both du/dv, @@ -1768,7 +1768,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, tco[2] = 0.f; texco_mapping(shi, tex, mtex, tco, dx, dy, texv, dxt, dyt); multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr, pool); - ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); + ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb) / 3.0f : ttexr.tin)); /* +v val */ tco[0] = co[0] + compat_bump->dudnv*du; @@ -1776,7 +1776,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, tco[2] = 0.f; texco_mapping(shi, tex, mtex, tco, dx, dy, texv, dxt, dyt); multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr, pool); - vd = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); + vd = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb) / 3.0f : ttexr.tin)); } else { float tu[3], tv[3]; @@ -1810,7 +1810,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, tco[2] = co[2] + tu[2]*du; texco_mapping(shi, tex, mtex, tco, dx, dy, texv, dxt, dyt); multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr, pool); - ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); + ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb) / 3.0f : ttexr.tin)); /* +v val */ tco[0] = co[0] + tv[0]*dv; @@ -1818,7 +1818,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, tco[2] = co[2] + tv[2]*dv; texco_mapping(shi, tex, mtex, tco, dx, dy, texv, dxt, dyt); multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr, pool); - vd = idv*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); + vd = idv*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb) / 3.0f : ttexr.tin)); } /* bumped normal */ diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 77d6644479a..92099060bf5 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -185,7 +185,7 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) for (y = 0; y < ibuf->y; y++) { for (x = 0; x < ibuf->x; x++) { /* currently averaged to monchrome */ - vd->dataset[BLI_VOXEL_INDEX(x, y, z, vd->resol)] = (rf[0] + rf[1] + rf[2]) * 0.333f; + vd->dataset[BLI_VOXEL_INDEX(x, y, z, vd->resol)] = (rf[0] + rf[1] + rf[2]) / 3.0f; rf += 4; } } From 10305de3ac27ec7d247120a62d5ef7508e7a165e Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Thu, 14 Feb 2013 17:35:46 +0000 Subject: [PATCH 132/157] Fix "Origin to Center of Mass" not working well with ngons Now we do simple triangulation and calculate signed area of triangles to account for concave polygons. This only works correct for planar polygons but gives better results overall. --- source/blender/blenkernel/intern/mesh.c | 35 +++++++++++++++++++++-- source/blender/blenlib/BLI_math_geom.h | 1 + source/blender/blenlib/intern/math_geom.c | 16 +++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 21641e77b0b..c9c86e6739f 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2999,6 +2999,36 @@ float BKE_mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, } } +/* note, results won't be correct if polygon is non-planar */ +static float mesh_calc_poly_planar_area_centroid(MPoly *mpoly, MLoop *loopstart, MVert *mvarray, float cent[3]) +{ + int i; + float tri_area; + float total_area = 0.0f; + float v1[3], v2[3], v3[3], normal[3], tri_cent[3]; + + BKE_mesh_calc_poly_normal(mpoly, loopstart, mvarray, normal); + copy_v3_v3(v1, mvarray[loopstart[0].v].co); + copy_v3_v3(v2, mvarray[loopstart[1].v].co); + zero_v3(cent); + + for (i = 2; i < mpoly->totloop; i++) { + copy_v3_v3(v3, mvarray[loopstart[i].v].co); + + tri_area = area_tri_signed_v3(v1, v2, v3, normal); + total_area += tri_area; + + cent_tri_v3(tri_cent, v1, v2, v3); + madd_v3_v3fl(cent, tri_cent, tri_area); + + copy_v3_v3(v2, v3); + } + + mul_v3_fl(cent, 1.0f / total_area); + + return total_area; +} + /** * This function takes the difference between 2 vertex-coord-arrays * (\a vert_cos_src, \a vert_cos_dst), @@ -3292,9 +3322,8 @@ int BKE_mesh_center_centroid(Mesh *me, float cent[3]) /* calculate a weighted average of polygon centroids */ for (mpoly = me->mpoly; i--; mpoly++) { - BKE_mesh_calc_poly_center(mpoly, me->mloop + mpoly->loopstart, me->mvert, poly_cent); - poly_area = BKE_mesh_calc_poly_area(mpoly, me->mloop + mpoly->loopstart, me->mvert, NULL); - + poly_area = mesh_calc_poly_planar_area_centroid(mpoly, me->mloop + mpoly->loopstart, me->mvert, poly_cent); + madd_v3_v3fl(cent, poly_cent, poly_area); total_area += poly_area; } diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index a822bdb9414..c4e17b1ed48 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -51,6 +51,7 @@ float normal_quad_v3(float r[3], const float a[3], const float b[3], const float float area_tri_v2(const float a[2], const float b[2], const float c[2]); float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2]); float area_tri_v3(const float a[3], const float b[3], const float c[3]); +float area_tri_signed_v3(const float v1[3], const float v2[3], const float v3[3], const float normal[3]); float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]); float area_poly_v3(int nr, float verts[][3], const float normal[3]); float area_poly_v2(int nr, float verts[][2]); diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 7337718bd3c..810c15437dc 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -129,6 +129,22 @@ float area_tri_v3(const float v1[3], const float v2[3], const float v3[3]) return (len / 2.0f); } +float area_tri_signed_v3(const float v1[3], const float v2[3], const float v3[3], const float normal[3]) +{ + float area, vec1[3], vec2[3], n[3]; + + sub_v3_v3v3(vec1, v3, v2); + sub_v3_v3v3(vec2, v1, v2); + cross_v3_v3v3(n, vec1, vec2); + area = len_v3(n) / 2.0f; + + /* negate area for flipped triangles */ + if (dot_v3v3(n, normal) < 0.0f) + area = -area; + + return area; +} + float area_poly_v3(int nr, float verts[][3], const float normal[3]) { int a, px, py; From cb75d64f7d223e55e257278b8d0acd62ffeea882 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 14 Feb 2013 19:30:25 +0000 Subject: [PATCH 133/157] Cycles: * Compile fix when building without OSL. --- intern/cycles/render/mesh.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 3a6fba32b34..8d12ace4252 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -967,6 +967,7 @@ void MeshManager::device_free(Device *device, DeviceScene *dscene) dscene->attributes_float.clear(); dscene->attributes_float3.clear(); +#ifdef WITH_OSL OSLGlobals *og = (OSLGlobals*)device->osl_memory(); if(og) { @@ -974,6 +975,7 @@ void MeshManager::device_free(Device *device, DeviceScene *dscene) og->attribute_map.clear(); og->object_names.clear(); } +#endif } void MeshManager::tag_update(Scene *scene) From 40720fcdef87e914ff608234f39f58ff25cd73bd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 14 Feb 2013 21:40:22 +0000 Subject: [PATCH 134/157] Fix 3d view DPI issue with object name overlapping axis icon. --- source/blender/editors/space_view3d/view3d_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index ff63f16d125..768de3b06ef 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -871,7 +871,7 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect) static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) { char info[256], *markern; - short offset = 30 + rect->xmin; + short offset = 1.5f*UI_UNIT_X + rect->xmin; /* get name of marker on current frame (if available) */ markern = BKE_scene_find_marker_name(scene, CFRA); From 6e03b70def962bf4c7ee346916c7472700c7f336 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 14 Feb 2013 21:40:28 +0000 Subject: [PATCH 135/157] Fix cycles hair curves with NaN values not rendering with dynamic BVH. These NaN values were breaking the bounding box computation, now they should have no influence. --- intern/cycles/util/util_boundbox.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/intern/cycles/util/util_boundbox.h b/intern/cycles/util/util_boundbox.h index 0c857f906ee..7564c1f3c5c 100644 --- a/intern/cycles/util/util_boundbox.h +++ b/intern/cycles/util/util_boundbox.h @@ -61,15 +61,17 @@ public: __forceinline void grow(const float3& pt) { - min = ccl::min(min, pt); - max = ccl::max(max, pt); + /* the order of arguments to min is such that if pt is nan, it will not + * influence the resulting bounding box */ + min = ccl::min(pt, min); + max = ccl::max(pt, max); } __forceinline void grow(const float3& pt, float border) { float3 shift = {border, border, border, 0.0f}; - min = ccl::min(min, pt - shift); - max = ccl::max(max, pt + shift); + min = ccl::min(pt - shift, min); + max = ccl::max(pt + shift, max); } __forceinline void grow(const BoundBox& bbox) From b94993941fe5a503627b45fd55f93f3bebbad97d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 14 Feb 2013 21:40:29 +0000 Subject: [PATCH 136/157] Fix #34252: cycles rendering 16bit PNG with too light colors. --- intern/cycles/render/image.cpp | 30 +++++++++++++++++++++++++----- intern/cycles/render/image.h | 4 ++-- intern/cycles/render/nodes.cpp | 20 ++++++++++++-------- intern/cycles/render/nodes.h | 2 ++ 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 6bfaf48c0c9..8e844bc788e 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -85,9 +85,10 @@ bool ImageManager::set_animation_frame_update(int frame) return false; } -bool ImageManager::is_float_image(const string& filename, void *builtin_data) +bool ImageManager::is_float_image(const string& filename, void *builtin_data, bool& is_linear) { bool is_float = false; + is_linear = false; if(builtin_data) { if(builtin_image_info_cb) { @@ -95,6 +96,9 @@ bool ImageManager::is_float_image(const string& filename, void *builtin_data) builtin_image_info_cb(filename, builtin_data, is_float, width, height, channels); } + if(is_float) + is_linear = true; + return is_float; } @@ -106,14 +110,30 @@ bool ImageManager::is_float_image(const string& filename, void *builtin_data) if(in->open(filename, spec)) { /* check the main format, and channel formats; * if any take up more than one byte, we'll need a float texture slot */ - if(spec.format.basesize() > 1) + if(spec.format.basesize() > 1) { is_float = true; + is_linear = true; + } for(size_t channel = 0; channel < spec.channelformats.size(); channel++) { - if(spec.channelformats[channel].basesize() > 1) + if(spec.channelformats[channel].basesize() > 1) { is_float = true; + is_linear = true; + } } + /* basic color space detection, not great but better than nothing + * before we do OpenColorIO integration */ + if(is_float) { + string colorspace = spec.get_string_attribute("oiio:ColorSpace"); + + is_linear = !(colorspace == "sRGB" || + colorspace == "GammaCorrected" || + strcmp(in->format_name(), "png") == 0); + } + else + is_linear = false; + in->close(); } @@ -123,13 +143,13 @@ bool ImageManager::is_float_image(const string& filename, void *builtin_data) return is_float; } -int ImageManager::add_image(const string& filename, void *builtin_data, bool animated, bool& is_float) +int ImageManager::add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear) { Image *img; size_t slot; /* load image info and find out if we need a float texture */ - is_float = (pack_images)? false: is_float_image(filename, builtin_data); + is_float = (pack_images)? false: is_float_image(filename, builtin_data, is_linear); if(is_float) { /* find existing image */ diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index 464b87ff530..b20ff23fbbb 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -51,9 +51,9 @@ public: ImageManager(); ~ImageManager(); - int add_image(const string& filename, void *builtin_data, bool animated, bool& is_float); + int add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear); void remove_image(const string& filename, void *builtin_data); - bool is_float_image(const string& filename, void *builtin_data); + bool is_float_image(const string& filename, void *builtin_data, bool& is_linear); void device_update(Device *device, DeviceScene *dscene, Progress& progress); void device_free(Device *device, DeviceScene *dscene); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index a0a933ef682..8ac12242e15 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -141,6 +141,7 @@ ImageTextureNode::ImageTextureNode() image_manager = NULL; slot = -1; is_float = -1; + is_linear = false; filename = ""; builtin_data = NULL; color_space = ustring("Color"); @@ -165,6 +166,7 @@ ShaderNode *ImageTextureNode::clone() const node->image_manager = NULL; node->slot = -1; node->is_float = -1; + node->is_linear = false; return node; } @@ -177,7 +179,7 @@ void ImageTextureNode::compile(SVMCompiler& compiler) image_manager = compiler.image_manager; if(is_float == -1) { bool is_float_bool; - slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool); + slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear); is_float = (int)is_float_bool; } @@ -189,7 +191,7 @@ void ImageTextureNode::compile(SVMCompiler& compiler) if(slot != -1) { compiler.stack_assign(vector_in); - int srgb = (is_float || color_space != "Color")? 0: 1; + int srgb = (is_linear || color_space != "Color")? 0: 1; int vector_offset = vector_in->stack_offset; if(!tex_mapping.skip()) { @@ -238,10 +240,10 @@ void ImageTextureNode::compile(OSLCompiler& compiler) tex_mapping.compile(compiler); if(is_float == -1) - is_float = (int)image_manager->is_float_image(filename, NULL); + is_float = (int)image_manager->is_float_image(filename, NULL, is_linear); compiler.parameter("filename", filename.c_str()); - if(is_float || color_space != "Color") + if(is_linear || color_space != "Color") compiler.parameter("color_space", "Linear"); else compiler.parameter("color_space", "sRGB"); @@ -271,6 +273,7 @@ EnvironmentTextureNode::EnvironmentTextureNode() image_manager = NULL; slot = -1; is_float = -1; + is_linear = false; filename = ""; builtin_data = NULL; color_space = ustring("Color"); @@ -294,6 +297,7 @@ ShaderNode *EnvironmentTextureNode::clone() const node->image_manager = NULL; node->slot = -1; node->is_float = -1; + node->is_linear = false; return node; } @@ -306,7 +310,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler) image_manager = compiler.image_manager; if(slot == -1) { bool is_float_bool; - slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool); + slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear); is_float = (int)is_float_bool; } @@ -318,7 +322,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler) if(slot != -1) { compiler.stack_assign(vector_in); - int srgb = (is_float || color_space != "Color")? 0: 1; + int srgb = (is_linear || color_space != "Color")? 0: 1; int vector_offset = vector_in->stack_offset; if(!tex_mapping.skip()) { @@ -356,11 +360,11 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler) tex_mapping.compile(compiler); if(is_float == -1) - is_float = (int)image_manager->is_float_image(filename, NULL); + is_float = (int)image_manager->is_float_image(filename, NULL, is_linear); compiler.parameter("filename", filename.c_str()); compiler.parameter("projection", projection); - if(is_float || color_space != "Color") + if(is_linear || color_space != "Color") compiler.parameter("color_space", "Linear"); else compiler.parameter("color_space", "sRGB"); diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 66be919d098..3609497e5ce 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -69,6 +69,7 @@ public: ImageManager *image_manager; int slot; int is_float; + bool is_linear; string filename; void *builtin_data; ustring color_space; @@ -89,6 +90,7 @@ public: ImageManager *image_manager; int slot; int is_float; + bool is_linear; string filename; void *builtin_data; ustring color_space; From c6b3e0f8e466cfe3c2e31173b4c7e4399d2dc23f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Feb 2013 23:49:30 +0000 Subject: [PATCH 137/157] style cleanup --- source/blender/blenkernel/intern/brush.c | 2 +- source/blender/blenlib/intern/string_utf8.c | 2 +- .../compositor/operations/COM_InpaintOperation.cpp | 4 ++-- source/blender/editors/space_view3d/view3d_draw.c | 2 +- source/blender/editors/uvedit/uvedit_parametrizer.c | 2 +- source/blender/python/bmesh/bmesh_py_types.c | 2 +- source/blender/python/intern/bpy_app_translations.c | 8 ++++++-- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index ce838ce519e..ba69fa4336e 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -588,7 +588,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf else if (texfall == 1) { BKE_brush_sample_tex_2D(scene, brush, xy, dstf, 0); } - else if (texfall == 2){ + else if (texfall == 2) { BKE_brush_sample_tex_2D(scene, brush, xy, rgba, 0); mul_v3_v3v3(dstf, rgba, brush_rgb); dstf[3] = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index bf98f2ae77c..9e0f9197ca3 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -114,7 +114,7 @@ int BLI_utf8_invalid_byte(const char *str, int length) /* Check for valid bytes after the 2nd, if any; all must start 10 */ while (--ab > 0) { - if ((*(p+1) & 0xc0) != 0x80) goto utf8_error; + if ((*(p + 1) & 0xc0) != 0x80) goto utf8_error; p++; /* do this after so we get usable offset - campbell */ } } diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp index 81ca06cfff0..edcd1563e03 100644 --- a/source/blender/compositor/operations/COM_InpaintOperation.cpp +++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp @@ -84,8 +84,8 @@ float *InpaintSimpleOperation::get_pixel(int x, int y) ASSERT_XY_RANGE(x, y); return &this->m_cached_buffer[ - y * width * COM_NUMBER_OF_CHANNELS - + x * COM_NUMBER_OF_CHANNELS]; + y * width * COM_NUMBER_OF_CHANNELS + + x * COM_NUMBER_OF_CHANNELS]; } int InpaintSimpleOperation::mdist(int x, int y) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 768de3b06ef..2b28b958248 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -871,7 +871,7 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect) static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) { char info[256], *markern; - short offset = 1.5f*UI_UNIT_X + rect->xmin; + short offset = 1.5f * UI_UNIT_X + rect->xmin; /* get name of marker on current frame (if available) */ markern = BKE_scene_find_marker_name(scene, CFRA); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index dd4f5221003..767003bdd84 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -3100,7 +3100,7 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart) if ((v1->flag & PVERT_PIN) && (v2->flag & PVERT_PIN) && (v3->flag & PVERT_PIN)) { float area = p_face_uv_area_signed(f); - if(area > 0.0f) + if (area > 0.0f) area_pinned_up += area; else area_pinned_down -= area; diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 2d6f5ddfbed..b96c522d407 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -3658,7 +3658,7 @@ static void bm_dealloc_editmode_warn(BPy_BMesh *self) /* likely editmesh */ BMesh *bm = self->bm; Scene *scene; - for(scene = G.main->scene.first; scene; scene = scene->id.next) { + for (scene = G.main->scene.first; scene; scene = scene->id.next) { Base *base = scene->basact; if (base && base->object->type == OB_MESH) { Mesh *me = base->object->data; diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index 6d69e8b1592..7c89972b486 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -501,7 +501,9 @@ static PyObject *_py_pgettext(PyObject *args, PyObject *kw, const char *(*_pgett #ifdef WITH_INTERNATIONAL char *msgid, *msgctxt = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|z:bpy.app.translations.pgettext", (char **)kwlist, &msgid, &msgctxt)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s|z:bpy.app.translations.pgettext", + (char **)kwlist, &msgid, &msgctxt)) { return NULL; } @@ -511,7 +513,9 @@ static PyObject *_py_pgettext(PyObject *args, PyObject *kw, const char *(*_pgett PyObject *msgid, *msgctxt; (void)_pgettext; - if (!PyArg_ParseTupleAndKeywords(args, kw, "O|O:bpy.app.translations.pgettext", (char **)kwlist, &msgid, &msgctxt)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "O|O:bpy.app.translations.pgettext", + (char **)kwlist, &msgid, &msgctxt)) { return NULL; } From f46ca7836d10fa05d589faa346eac42358893f1e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Feb 2013 04:14:53 +0000 Subject: [PATCH 138/157] add debug check for mempool double free (or misuse of BLI_MEMPOOL_ALLOW_ITER), some reports in the tracker show errors on bmesh iteration which could be caused by this. --- source/blender/blenlib/intern/BLI_mempool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index bf228f7456a..7670b057a7f 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -245,6 +245,10 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr) BLI_freenode *newhead = addr; if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) { +#ifndef NDEBUG + /* this will detect double free's */ + BLI_assert(newhead->freeword != FREEWORD); +#endif newhead->freeword = FREEWORD; } From 98b9ed185febdfcde5286850b12af4bb44baedd8 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 15 Feb 2013 08:31:00 +0000 Subject: [PATCH 139/157] Translate "Set Parent To" menu (ctrl-P), reported on bf-translations ML by Satoshi Yamasaki, thanks! --- source/blender/editors/object/CMakeLists.txt | 5 +++++ source/blender/editors/object/SConscript | 5 ++++- source/blender/editors/object/object_relations.c | 9 ++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 05c042a4182..a92b25c6c85 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../include + ../../blenfont ../../blenkernel ../../blenlib ../../blenloader @@ -66,4 +67,8 @@ if(WITH_GAMEENGINE) add_definitions(-DWITH_GAMEENGINE) endif() +if(WITH_INTERNATIONAL) + add_definitions(-DWITH_INTERNATIONAL) +endif() + blender_add_lib(bf_editor_object "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/object/SConscript b/source/blender/editors/object/SConscript index df51198df92..203d7dff768 100644 --- a/source/blender/editors/object/SConscript +++ b/source/blender/editors/object/SConscript @@ -29,7 +29,7 @@ Import ('env') sources = env.Glob('*.c') -incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' +incs = '../include ../../blenlib ../../blenfont ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc ../../blenloader' incs += ' ../../makesrna ../../python ../../ikplugin ../../bmesh' incs += ' ../../render/extern/include ../../gpu' # for object_bake.c @@ -50,4 +50,7 @@ if env['WITH_BF_PYTHON']: if env['WITH_BF_GAMEENGINE']: defs.append('WITH_GAMEENGINE') +if env['WITH_BF_INTERNATIONAL']: + defs.append('WITH_INTERNATIONAL') + env.BlenderLib ( 'bf_editors_object', sources, Split(incs), defs, libtype=['core'], priority=[35] ) diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ce37fd79d55..629dba465bc 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -56,6 +56,8 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_action.h" #include "BKE_animsys.h" #include "BKE_armature.h" @@ -801,7 +803,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { Object *ob = ED_object_active_context(C); - uiPopupMenu *pup = uiPupMenuBegin(C, "Set Parent To", ICON_NONE); + uiPopupMenu *pup = uiPupMenuBegin(C, IFACE_("Set Parent To"), ICON_NONE); uiLayout *layout = uiPupMenuLayout(pup); wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_parent_set", TRUE); @@ -810,11 +812,12 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSE #if 0 uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_OBJECT); #else - opptr = uiItemFullO_ptr(layout, ot, "Object", ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + opptr = uiItemFullO_ptr(layout, ot, IFACE_("Object"), ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&opptr, "type", PAR_OBJECT); RNA_boolean_set(&opptr, "keep_transform", FALSE); - opptr = uiItemFullO_ptr(layout, ot, "Object (Keep Transform)", ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + opptr = uiItemFullO_ptr(layout, ot, IFACE_("Object (Keep Transform)"), ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, + UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&opptr, "type", PAR_OBJECT); RNA_boolean_set(&opptr, "keep_transform", TRUE); #endif From 313df262e319cac85fa904573d324c696bd80a1c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 15 Feb 2013 08:32:25 +0000 Subject: [PATCH 140/157] Fix [#34253] UIList resize, resizes wrong list I/II When using default UI_UL_list, one should always spully a custom ID, else collision inside an area are quite likely... --- release/scripts/startup/bl_ui/properties_data_armature.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index 1643210704e..0f9d525f168 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -124,7 +124,7 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel): rows = 2 if group: rows = 5 - row.template_list("UI_UL_list", "", pose, "bone_groups", pose.bone_groups, "active_index", rows=rows) + row.template_list("UI_UL_list", "bone_groups", pose, "bone_groups", pose.bone_groups, "active_index", rows=rows) col = row.column(align=True) col.active = (ob.proxy is None) From bd1c6571c9e96cef75ac30b7b8387a56497e0c2e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 15 Feb 2013 09:15:14 +0000 Subject: [PATCH 141/157] Fix #34205: Zooming in rendered mode during update out of sync with intended zoom Yes, again. There's some t within which reset is not allowed. This is so no reset happens too often for performance issues. If camera changes too often, some reset could be missed because of this timeout. For now tag engine for update, which will update viewport from blender side. Proper solution could be to detect such a changes from blender side and tag cycles for refresh instead of trying to detect changes form cycles, but that's for later. --- intern/cycles/blender/blender_session.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 98a4e5bda9f..dda7eb053c4 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -520,6 +520,9 @@ bool BlenderSession::draw(int w, int h) session->reset(buffer_params, session_params.samples); } } + else { + tag_update(); + } /* update status and progress for 3d view draw */ update_status_progress(); From 6786975f78eabe7795d4e052c43af2cc298364c9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 15 Feb 2013 11:46:31 +0000 Subject: [PATCH 142/157] Fix #34254: cycles brightness/contrast node was missing for GLSL material view. --- source/blender/gpu/shaders/gpu_shader_material.glsl | 11 +++++++++++ .../nodes/shader/nodes/node_shader_brightness.c | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 45e7831d20d..8fc18bf8726 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -390,6 +390,17 @@ void set_rgba_zero(out vec4 outval) outval = vec4(0.0); } +void brightness_contrast(vec4 col, float brightness, float contrast, out vec4 outcol) +{ + float a = 1.0 + contrast; + float b = brightness - contrast*0.5; + + outcol.r = max(a*col.r + b, 0.0); + outcol.g = max(a*col.g + b, 0.0); + outcol.b = max(a*col.b + b, 0.0); + outcol.a = col.a; +} + void mix_blend(float fac, vec4 col1, vec4 col2, out vec4 outcol) { fac = clamp(fac, 0.0, 1.0); diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c index 9c23a29cae9..2b86fa60328 100644 --- a/source/blender/nodes/shader/nodes/node_shader_brightness.c +++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c @@ -43,6 +43,11 @@ static bNodeSocketTemplate sh_node_brightcontrast_out[] = { { -1, 0, "" } }; +static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) +{ + return GPU_stack_link(mat, "brightness_contrast", in, out); +} + void register_node_type_sh_brightcontrast(bNodeTreeType *ttype) { static bNodeType ntype; @@ -54,7 +59,7 @@ void register_node_type_sh_brightcontrast(bNodeTreeType *ttype) node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); node_type_exec(&ntype, NULL); - node_type_gpu(&ntype, NULL); + node_type_gpu(&ntype, gpu_shader_brightcontrast); nodeRegisterType(ttype, &ntype); } From 4d32e9a49e910ee872143103b1d747bf9f81e029 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 15 Feb 2013 11:49:22 +0000 Subject: [PATCH 143/157] Bugfix [#33970] Background Scene does not show animation of rigid body objects This was caused by multiple instantiations of the same basic problem. The rigidbody handling code often assumed that "scene" pointers referred to the scene where an object participating in the sim resided (and where the rigidbody world for that sim lived). However, when dealing with background sets, "scene" often only refers to the active scene, and not the set that the object actually came from. Hence, the rigidbody code would often (wrongly) conclude that there was nothing to do. For example, we may have the following backgound set/scene chaining scenario: "active" <-- ... <-- set i (rigidbody objects live here) <-- ... <-- set n The fix here is a multi-part fix: 1) Moved sim-world calculation from BKE_scene_update_newframe() to scene_update_tagged_recursive() + This is currently the only way that rigidbody sims in background sets will get calculated, as part of the recursion - These checks will get run on each update. <--- FIXME!!! 2) Tweaked depsgraph code so that when checking if there are any time-dependent features on objects to tag for updating, the checking is done relative to the scene that the object actually resides in (and not the active scene). Otherwise, even if we recalculate the sim, the affected objects won't get tagged for updating. This tagging is needed to actually flush the transforms out of the RigidBodyObject structs (written by the sim/cache) and into the Object transforms (obmat's) 3) Removed the requirement for rigidbody world to actually exist before we can flush rigidbody transforms. In many cases, it should be sufficient to assume that because the object with rigidbody data attached has been tagged for updates, it should have updates to perform. Of course, we still check on this data if we've got it, but that's only if the sim is in the active scene. - TODO: if we have further problems, we should investigate passing the "actual" scene down alongside the "active" scene for BKE_object_handle_update(). --- source/blender/blenkernel/intern/depsgraph.c | 7 +++++- source/blender/blenkernel/intern/object.c | 8 +++++- source/blender/blenkernel/intern/rigidbody.c | 19 +++++++++----- source/blender/blenkernel/intern/scene.c | 26 ++++++++++++++------ 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index dab4235559a..99d0c5ed964 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2353,6 +2353,7 @@ static void dag_object_time_update_flags(Scene *scene, Object *ob) if (object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA; if ((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA; + // XXX: scene here may not be the scene that contains the rigidbody world affecting this! if (ob->rigidbody_object && BKE_scene_check_rigidbody_active(scene)) ob->recalc |= OB_RECALC_OB; @@ -2440,7 +2441,11 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s if (do_time) { /* now if DagNode were part of base, the node->lay could be checked... */ /* we do all now, since the scene_flush checks layers and clears recalc flags even */ - dag_object_time_update_flags(scene, ob); + + /* NOTE: "sce_iter" not "scene" so that rigidbodies in background scenes work + * (i.e. muting + rbw availability can be checked and tagged properly) [#33970] + */ + dag_object_time_update_flags(sce_iter, ob); } /* handled in next loop */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0140152790c..4b940fa8274 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2141,7 +2141,8 @@ void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) else { BKE_object_to_mat4(ob, ob->obmat); } - + + /* read values pushed into RBO from sim/cache... */ BKE_rigidbody_sync_transforms(scene, ob, ctime); /* solve constraints */ @@ -2617,6 +2618,11 @@ int BKE_object_parent_loop_check(const Object *par, const Object *ob) /* the main object update call, for object matrix, constraints, keys and displist (modifiers) */ /* requires flags to be set! */ + +/* WARNING: "scene" here may not be the scene object actually resides in. + * When dealing with background-sets, "scene" is actually the active scene. + * e.g. "scene" <-- set 1 <-- set 2 ("ob" lives here) <-- set 3 <-- ... <-- set n + */ void BKE_object_handle_update(Scene *scene, Object *ob) { if (ob->recalc & OB_RECALC_ALL) { diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 24355149926..055ada33867 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1136,19 +1136,25 @@ void BKE_rigidbody_sync_transforms(Scene *scene, Object *ob, float ctime) { RigidBodyWorld *rbw = scene->rigidbody_world; RigidBodyOb *rbo = ob->rigidbody_object; + bool world_ok = true; /* keep original transform for kinematic and passive objects */ - if (ELEM(NULL, rbw, rbo) || rbo->flag & RBO_FLAG_KINEMATIC || rbo->type == RBO_TYPE_PASSIVE) + if ((rbo == NULL) || (rbo->flag & RBO_FLAG_KINEMATIC) || (rbo->type == RBO_TYPE_PASSIVE)) return; + + /* "scene" may not be the one where object + rigidbody sim actually reside + * due to the quirks of how background-sets eval works [#33970] + */ + if (rbw) { + /* 1) no cache exists before startframe */ + /* 2) keep original transform when simulation is muted */ + world_ok = (ctime > rbw->pointcache->startframe) && !(rbw->flag & RBW_FLAG_MUTED); + } /* use rigid body transform after cache start frame if objects is not being transformed */ - if (ctime > rbw->pointcache->startframe && !(ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ)) { + if (world_ok && !((ob->flag & SELECT) && (G.moving & G_TRANSFORM_OBJ))) { float mat[4][4], size_mat[4][4], size[3]; - /* keep original transform when the simulation is muted */ - if (rbw->flag & RBW_FLAG_MUTED) - return; - normalize_qt(rbo->orn); // RB_TODO investigate why quaternion isn't normalized at this point quat_to_mat4(mat, rbo->orn); copy_v3_v3(mat[3], rbo->pos); @@ -1165,6 +1171,7 @@ void BKE_rigidbody_sync_transforms(Scene *scene, Object *ob, float ctime) } } +/* Used when cancelling transforms - return rigidbody and object to initial states */ void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle) { RigidBodyOb *rbo = ob->rigidbody_object; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 30550edc007..13e050f12b7 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1093,7 +1093,6 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen { Base *base; - scene->customdata_mask = scene_parent->customdata_mask; /* sets first, we allow per definition current scene to have @@ -1101,6 +1100,23 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen if (scene->set) scene_update_tagged_recursive(bmain, scene->set, scene_parent); + /* run rigidbody sim + * - calculate/read values from cache into RBO's, to get flushed + * later when objects are evaluated (if they're tagged for eval) + */ + // XXX: this position may still change, objects not being updated correctly before simulation is run + // NOTE: current position is so that rigidbody sim affects other objects + // FIXME: this now gets executed on every update, not just frame change now!!! + if (BKE_scene_check_rigidbody_active(scene)) { + /* we use frame time of parent (this is "scene" itself for top-level of sets recursion), + * as that is the active scene controlling all timing in file at the moment + */ + float ctime = BKE_scene_frame_get(scene_parent); + + /* however, "scene" contains the rigidbody world needed for eval... */ + BKE_rigidbody_do_simulation(scene, ctime); + } + /* scene objects */ for (base = scene->base.first; base; base = base->next) { Object *ob = base->object; @@ -1206,13 +1222,7 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) * such as Scene->World->MTex/Texture) can still get correctly overridden. */ BKE_animsys_evaluate_all_animation(bmain, sce, ctime); - /*...done with recusrive funcs */ - - /* run rigidbody sim */ - // XXX: this position may still change, objects not being updated correctly before simulation is run - // NOTE: current position is so that rigidbody sim affects other objects - if (BKE_scene_check_rigidbody_active(sce)) - BKE_rigidbody_do_simulation(sce, ctime); + /*...done with recursive funcs */ /* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later * when trying to find materials with drivers that need evaluating [#32017] From d5d38ef0c74150fc7945e7f49a29837bcdd1248d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 15 Feb 2013 12:08:01 +0000 Subject: [PATCH 144/157] Fix #34256: join a mesh with non-uniform scale with another mesh showed wrong normals, they need to be recalculated then. --- source/blender/editors/mesh/meshtools.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 96b8f1080b9..cb69faa5b51 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -502,6 +502,9 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* tessface data removed above, no need to update */ mesh_update_customdata_pointers(me, FALSE); + + /* update normals in case objects with non-uniform scale are joined */ + ED_mesh_calc_normals(me); /* old material array */ for (a = 1; a <= ob->totcol; a++) { From 964c35771ce3a4a15dfb96d6185b31457e1d29b3 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 15 Feb 2013 12:26:47 +0000 Subject: [PATCH 145/157] Bug fix #34177 Blender's triangulator has been rescued :) This commit fixes errors with concave holes inside polygons. Simple explanation: Blender "ScanFill" works by sorting vertices from top-left to bottom-right, and connecting these vertices with a sorted list of edges they have. The inner loop then goes over every vertex, its edges, and tries to make triangles by checking vertices that are next in the list. - if the triangle has points inside: it creates an edge to this vertex, and continues - else: add new triangle. Very simple, fast and efficient. But it needed one more check for the first step: it should check every vertex inside the triangle, and pick the best vertex for an edge based on forming the sharpest angle with the tested edge. That solves the case for concave holes. Blender ScanFill was coded 20 years ago, and is an own invention. I wanted a triangulator that just fills any collection of polygons, including with holes. No idea if this was ever published in a paper! --- source/blender/blenlib/intern/scanfill.c | 52 +++++++++++++++++------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 7c7edc1349d..ef55734d936 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -511,7 +511,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag) ScanFillVert *eve, *v1, *v2, *v3; ScanFillEdge *eed, *nexted, *ed1, *ed2, *ed3; int a, b, verts, maxface, totface; - short nr, test, twoconnected = 0; + short nr, twoconnected = 0; nr = pf->nr; @@ -567,6 +567,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag) verts++; eve->f = 0; /* flag for connectedges later on */ sc->vert = eve; + /* if (even->tmp.v == NULL) eve->tmp.u = verts; */ /* Note, debug print only will work for curve polyfill, union is in use for mesh */ sc++; } } @@ -641,7 +642,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag) sc = sf_ctx->_scdata; for (a = 0; a < verts; a++) { - /* printf("VERTEX %d %x\n", a, sc->v1); */ + /* printf("VERTEX %d index %d\n", a, sc->vert->tmp.u); */ ed1 = sc->edge_first; while (ed1) { /* set connectflags */ nexted = ed1->next; @@ -678,38 +679,62 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag) } else { /* test rest of vertices */ + ScanFillVertLink *best_sc = NULL; + float best_angle = 3.14f; float miny; + int firsttime = 0; + v1 = ed1->v2; v2 = ed1->v1; v3 = ed2->v2; + /* this happens with a serial of overlapping edges */ if (v1 == v2 || v2 == v3) break; - /* printf("test verts %x %x %x\n", v1, v2, v3); */ + + /* printf("test verts %d %d %d\n", v1->tmp.u, v2->tmp.u, v3->tmp.u); */ miny = min_ff(v1->xy[1], v3->xy[1]); sc1 = sc + 1; - test = 0; - for (b = a + 1; b < verts; b++) { + for (b = a + 1; b < verts; b++, sc1++) { if (sc1->vert->f == 0) { if (sc1->vert->xy[1] <= miny) break; if (testedgeside(v1->xy, v2->xy, sc1->vert->xy)) { if (testedgeside(v2->xy, v3->xy, sc1->vert->xy)) { if (testedgeside(v3->xy, v1->xy, sc1->vert->xy)) { - /* point in triangle */ + /* point is in triangle */ + + /* because multiple points can be inside triangle (concave holes) */ + /* we continue searching and pick the one with sharpest corner */ + + if (best_sc == NULL) + best_sc = sc1; + else { + float angle; + + /* prevent angle calc for the simple cases only 1 vertex is found */ + if (firsttime == 0) { + best_angle = angle_v2v2v2(v2->co, v1->co, best_sc->vert->co); + firsttime = 1; + } - test = 1; - break; + angle = angle_v2v2v2(v2->co, v1->co, sc1->vert->co); + if (angle < best_angle) { + best_sc = sc1; + best_angle = angle; + } + } + } } } } - sc1++; } - if (test) { + + if (best_sc) { /* make new edge, and start over */ - /* printf("add new edge %x %x and start again\n", v2, sc1->vert); */ + /* printf("add new edge %d %d and start again\n", v2->tmp.u, best_sc->vert->tmp.u); */ - ed3 = BLI_scanfill_edge_add(sf_ctx, v2, sc1->vert); + ed3 = BLI_scanfill_edge_add(sf_ctx, v2, best_sc->vert); BLI_remlink(&sf_ctx->filledgebase, ed3); BLI_insertlinkbefore((ListBase *)&(sc->edge_first), ed2, ed3); ed3->v2->f = SF_VERT_UNKNOWN; @@ -719,7 +744,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag) } else { /* new triangle */ - /* printf("add face %x %x %x\n", v1, v2, v3); */ + /* printf("add face %d %d %d\n", v1->tmp.u, v2->tmp.u, v3->tmp.u); */ addfillface(sf_ctx, v1, v2, v3); totface++; BLI_remlink((ListBase *)&(sc->edge_first), ed1); @@ -765,7 +790,6 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag) ed3 = ed3->next; } } - } } /* test for loose edges */ From 7fa256815f2aeebf9afd9b00859dcf2fa5716e2f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Feb 2013 12:57:11 +0000 Subject: [PATCH 146/157] skip fix from r54579 when holes aren't used (keeps bmesh ngon filling fast) --- source/blender/blenlib/intern/scanfill.c | 13 +++++++++---- .../nodes/shader/nodes/node_shader_brightness.c | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index ef55734d936..298e37137ce 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -682,7 +682,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag) ScanFillVertLink *best_sc = NULL; float best_angle = 3.14f; float miny; - int firsttime = 0; + bool firsttime = false; v1 = ed1->v2; v2 = ed1->v1; @@ -706,15 +706,20 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag) /* because multiple points can be inside triangle (concave holes) */ /* we continue searching and pick the one with sharpest corner */ - if (best_sc == NULL) + if (best_sc == NULL) { best_sc = sc1; + /* only need to continue checking with holes */ + if ((flag & BLI_SCANFILL_CALC_HOLES) == 0) { + break; + } + } else { float angle; /* prevent angle calc for the simple cases only 1 vertex is found */ - if (firsttime == 0) { + if (firsttime == false) { best_angle = angle_v2v2v2(v2->co, v1->co, best_sc->vert->co); - firsttime = 1; + firsttime = true; } angle = angle_v2v2v2(v2->co, v1->co, sc1->vert->co); diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c index 2b86fa60328..fa77fce4c88 100644 --- a/source/blender/nodes/shader/nodes/node_shader_brightness.c +++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c @@ -43,7 +43,7 @@ static bNodeSocketTemplate sh_node_brightcontrast_out[] = { { -1, 0, "" } }; -static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) +static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) { return GPU_stack_link(mat, "brightness_contrast", in, out); } From b948c31258a45440628ffa744ce78d35dab2ff92 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Feb 2013 13:30:30 +0000 Subject: [PATCH 147/157] revert own commit r54450, this works on X11 but not in Windows and caused bug [#34255] (which may be a bug in windows ghost?, not getting key release for modifiers). Cross platform modifier keys on activating window better be handled at ghost level anyway. --- .../blender/windowmanager/intern/wm_window.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index dc0c6115098..a1ab0de49cf 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -756,7 +756,6 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr GHOST_TEventKeyData kdata; wmEvent event; int wx, wy; - bool is_key; wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */ @@ -764,23 +763,26 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr // window_handle(win, INPUTCHANGE, win->active); /* bad ghost support for modifier keys... so on activate we set the modifiers again */ + + /* TODO: This is not correct since a modifier may be held when a window is activated... + * better solve this at ghost level. attempted fix r54450 but it caused bug [#34255] */ kdata.ascii = '\0'; kdata.utf8_buf[0] = '\0'; - if ((win->eventstate->shift != 0) != ((is_key = query_qual(SHIFT)) != 0)) { + if (win->eventstate->shift && !query_qual(SHIFT)) { kdata.key = GHOST_kKeyLeftShift; - wm_event_add_ghostevent(wm, win, is_key ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, time, &kdata); + wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); } - if ((win->eventstate->ctrl != 0) != ((is_key = query_qual(CONTROL)) != 0)) { + if (win->eventstate->ctrl && !query_qual(CONTROL)) { kdata.key = GHOST_kKeyLeftControl; - wm_event_add_ghostevent(wm, win, is_key ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, time, &kdata); + wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); } - if ((win->eventstate->alt != 0) != ((is_key = query_qual(ALT)) != 0)) { + if (win->eventstate->alt && !query_qual(ALT)) { kdata.key = GHOST_kKeyLeftAlt; - wm_event_add_ghostevent(wm, win, is_key ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, time, &kdata); + wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); } - if ((win->eventstate->oskey != 0) != ((is_key = query_qual(OS)) != 0)) { + if (win->eventstate->oskey && !query_qual(OS)) { kdata.key = GHOST_kKeyOS; - wm_event_add_ghostevent(wm, win, is_key ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, time, &kdata); + wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata); } /* keymodifier zero, it hangs on hotkeys that open windows otherwise */ win->eventstate->keymodifier = 0; From ec04f98a75d9a03fd2e817f7ed4980b82930a8a1 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 15 Feb 2013 14:30:36 +0000 Subject: [PATCH 148/157] Various fixes for UI translation issues (reported by Leon Cheung on bf-translations ML, thanks!). --- source/blender/editors/interface/interface_templates.c | 6 ++++-- source/blender/editors/mesh/editmesh_tools.c | 6 +++--- source/blender/editors/screen/screen_ops.c | 2 +- source/blender/editors/space_buttons/buttons_ops.c | 4 +++- source/blender/editors/space_node/node_header.c | 2 +- source/blender/makesrna/intern/rna_texture.c | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 57d5fd38fdc..f827da6fcc4 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -512,7 +512,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str BLF_I18NCONTEXT_ID_CAMERA, BLF_I18NCONTEXT_ID_WORLD, BLF_I18NCONTEXT_ID_SCREEN, - BLF_I18NCONTEXT_ID_TEXT); + BLF_I18NCONTEXT_ID_TEXT, + ); BLF_I18N_MSGID_MULTI_CTXT("New", BLF_I18NCONTEXT_ID_SPEAKER, BLF_I18NCONTEXT_ID_SOUND, BLF_I18NCONTEXT_ID_ARMATURE, @@ -520,7 +521,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str BLF_I18NCONTEXT_ID_NODETREE, BLF_I18NCONTEXT_ID_BRUSH, BLF_I18NCONTEXT_ID_PARTICLESETTINGS, - BLF_I18NCONTEXT_ID_GPENCIL); + BLF_I18NCONTEXT_ID_GPENCIL, + ); if (newop) { but = uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 45d0d097733..4957d498e98 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -1744,9 +1744,9 @@ void MESH_OT_vertices_smooth_laplacian(wmOperatorType *ot) "Lambda factor", "", 0.0000001f, 1000.0f); RNA_def_float(ot->srna, "lambda_border", 0.00005f, 0.0000001f, 1000.0f, "Lambda factor in border", "", 0.0000001f, 1000.0f); - RNA_def_boolean(ot->srna, "use_x", 1, "Smooth X Axis", "Smooth object along X axis"); - RNA_def_boolean(ot->srna, "use_y", 1, "Smooth Y Axis", "Smooth object along Y axis"); - RNA_def_boolean(ot->srna, "use_z", 1, "Smooth Z Axis", "Smooth object along Z axis"); + RNA_def_boolean(ot->srna, "use_x", 1, "Smooth X Axis", "Smooth object along X axis"); + RNA_def_boolean(ot->srna, "use_y", 1, "Smooth Y Axis", "Smooth object along Y axis"); + RNA_def_boolean(ot->srna, "use_z", 1, "Smooth Z Axis", "Smooth object along Z axis"); RNA_def_boolean(ot->srna, "preserve_volume", 1, "Preserve Volume", "Apply volume preservation after smooth"); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 11f1828ff4e..12a7a33c893 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2963,7 +2963,7 @@ static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *U uiPopupMenu *pup; uiLayout *layout; - pup = uiPupMenuBegin(C, N_("Header"), ICON_NONE); + pup = uiPupMenuBegin(C, IFACE_("Header"), ICON_NONE); layout = uiPupMenuLayout(pup); ED_screens_header_tools_menu_create(C, layout, NULL); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 54261974993..8b6682ff1c9 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -40,6 +40,8 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_context.h" #include "BKE_global.h" #include "BKE_main.h" @@ -70,7 +72,7 @@ static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(e RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr); - pup = uiPupMenuBegin(C, "Align", ICON_NONE); + pup = uiPupMenuBegin(C, IFACE_("Align"), ICON_NONE); layout = uiPupMenuLayout(pup); uiItemsEnumR(layout, &ptr, "align"); uiPupMenuEnd(C, pup); diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index e92d93485a1..f26b6ff0f54 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -234,7 +234,7 @@ static void node_menu_add(const bContext *C, Menu *menu) uiLayoutSetActive(layout, FALSE); uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); - uiItemO(layout, "Search ...", 0, "NODE_OT_add_search"); + uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Search ..."), 0, "NODE_OT_add_search"); if (ntreetype && ntreetype->foreach_nodeclass) ntreetype->foreach_nodeclass(scene, layout, node_menu_add_foreach_cb); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index fc67ae27387..e007fe67c0b 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1842,7 +1842,7 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna) prop = RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "file_format"); RNA_def_property_enum_items(prop, file_format_items); - RNA_def_property_ui_text(prop, "File Format", "Format of the source data set to render "); + RNA_def_property_ui_text(prop, "File Format", "Format of the source data set to render"); RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); From 313dfbe35daaba41d6410042b12d1a1b63cb31a1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 15 Feb 2013 14:54:11 +0000 Subject: [PATCH 149/157] Add some more detailed CUDA error prints to try to debug #34166. --- intern/cycles/device/device_cuda.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 399414d5966..77082006169 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -128,19 +128,21 @@ public: } \ } - bool cuda_error(CUresult result) + bool cuda_error_(CUresult result, const string& stmt) { if(result == CUDA_SUCCESS) return false; - string message = string_printf("CUDA error: %s", cuda_error_string(result)); + string message = string_printf("CUDA error at %s: %s", stmt.c_str(), cuda_error_string(result)); if(error_msg == "") error_msg = message; fprintf(stderr, "%s\n", message.c_str()); return true; } - void cuda_error(const string& message) +#define cuda_error(stmt) cuda_error_(stmt, #stmt) + + void cuda_error_message(const string& message) { if(error_msg == "") error_msg = message; @@ -187,7 +189,7 @@ public: } } - if(cuda_error(result)) + if(cuda_error_(result, "cuCtxCreate")) return; cuda_pop_context(); @@ -208,7 +210,7 @@ public: cuDeviceComputeCapability(&major, &minor, cuDevId); if(major <= 1 && minor <= 2) { - cuda_error(string_printf("CUDA device supported only with compute capability 1.3 or up, found %d.%d.", major, minor)); + cuda_error_message(string_printf("CUDA device supported only with compute capability 1.3 or up, found %d.%d.", major, minor)); return false; } } @@ -241,9 +243,9 @@ public: #ifdef _WIN32 if(cuHavePrecompiledKernels()) { if(major <= 1 && minor <= 2) - cuda_error(string_printf("CUDA device requires compute capability 1.3 or up, found %d.%d. Your GPU is not supported.", major, minor)); + cuda_error_message(string_printf("CUDA device requires compute capability 1.3 or up, found %d.%d. Your GPU is not supported.", major, minor)); else - cuda_error(string_printf("CUDA binary kernel for this graphics card compute capability (%d.%d) not found.", major, minor)); + cuda_error_message(string_printf("CUDA binary kernel for this graphics card compute capability (%d.%d) not found.", major, minor)); return ""; } #endif @@ -252,7 +254,7 @@ public: string nvcc = cuCompilerPath(); if(nvcc == "") { - cuda_error("CUDA nvcc compiler not found. Install CUDA toolkit in default location."); + cuda_error_message("CUDA nvcc compiler not found. Install CUDA toolkit in default location."); return ""; } @@ -272,13 +274,13 @@ public: nvcc.c_str(), major, minor, machine, kernel.c_str(), cubin.c_str(), maxreg, include.c_str()); if(system(command.c_str()) == -1) { - cuda_error("Failed to execute compilation command, see console for details."); + cuda_error_message("Failed to execute compilation command, see console for details."); return ""; } /* verify if compilation succeeded */ if(!path_exists(cubin)) { - cuda_error("CUDA kernel compilation failed, see console for details."); + cuda_error_message("CUDA kernel compilation failed, see console for details."); return ""; } @@ -306,8 +308,8 @@ public: cuda_push_context(); CUresult result = cuModuleLoad(&cuModule, cubin.c_str()); - if(cuda_error(result)) - cuda_error(string_printf("Failed loading CUDA kernel %s.", cubin.c_str())); + if(cuda_error_(result, "cuModuleLoad")) + cuda_error_message(string_printf("Failed loading CUDA kernel %s.", cubin.c_str())); cuda_pop_context(); @@ -737,7 +739,7 @@ public: CUresult result = cuGraphicsGLRegisterBuffer(&pmem.cuPBOresource, pmem.cuPBO, CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE); - if(!cuda_error(result)) { + if(result == CUDA_SUCCESS) { cuda_pop_context(); mem.device_pointer = pmem.cuTexId; From 9fe4dbb9f10e611d2c24eccbfbcbb9260370b8bd Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Fri, 15 Feb 2013 15:36:02 +0000 Subject: [PATCH 150/157] Fix: Collada Import files with X_UP and Y_UP axis where imported with wrong orientation --- source/blender/collada/collada.cpp | 1 - source/blender/collada/collada.h | 1 + source/blender/collada/collada_internal.cpp | 24 ++++++++++++++++++++- source/blender/collada/collada_internal.h | 9 +++++++- source/blender/collada/collada_utils.cpp | 5 +++++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index 1aff0f166ba..b3c288c8fc5 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -40,7 +40,6 @@ extern "C" /* make dummy file */ #include "BLI_fileops.h" -#include "BLI_path_util.h" #include "BLI_linklist.h" int collada_import(bContext *C, diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index 587dc37b7db..2fa5b22bb15 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -33,6 +33,7 @@ extern "C" { #endif #include "BLI_linklist.h" +#include "BLI_path_util.h" #include "RNA_types.h" typedef enum BC_export_mesh_type { diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp index 64c567384a1..85f98dad437 100644 --- a/source/blender/collada/collada_internal.cpp +++ b/source/blender/collada/collada_internal.cpp @@ -33,7 +33,14 @@ UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) { - /* pass */ + unit_m4(x_up_mat4); + rotate_m4(x_up_mat4, 'Y', -0.5 * M_PI); + + unit_m4(y_up_mat4); + rotate_m4(y_up_mat4, 'X', 0.5 * M_PI); + + unit_m4(z_up_mat4); + } void UnitConverter::read_asset(const COLLADAFW::FileInfo *asset) @@ -102,6 +109,21 @@ void UnitConverter::mat4_to_dae_double(double out[4][4], float in[4][4]) out[i][j] = mat[i][j]; } +float(&UnitConverter::get_rotation())[4][4] +{ + switch(up_axis) { + case COLLADAFW::FileInfo::X_UP: + return x_up_mat4; + break; + case COLLADAFW::FileInfo::Y_UP: + return y_up_mat4; + break; + default: + return z_up_mat4; + break; + } +} + void TransformBase::decompose(float mat[4][4], float *loc, float eul[3], float quat[4], float *size) { mat4_to_size(size, mat); diff --git a/source/blender/collada/collada_internal.h b/source/blender/collada/collada_internal.h index ba077628499..7d59932bac9 100644 --- a/source/blender/collada/collada_internal.h +++ b/source/blender/collada/collada_internal.h @@ -39,7 +39,6 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BLI_math.h" -#include "BLI_math.h" #include "BLI_linklist.h" class UnitConverter @@ -48,6 +47,10 @@ private: COLLADAFW::FileInfo::Unit unit; COLLADAFW::FileInfo::UpAxisType up_axis; + float x_up_mat4[4][4]; + float y_up_mat4[4][4]; + float z_up_mat4[4][4]; + public: enum UnitSystem { @@ -74,6 +77,10 @@ public: void mat4_to_dae(float out[4][4], float in[4][4]); void mat4_to_dae_double(double out[4][4], float in[4][4]); + + float(&get_rotation())[4][4]; + + }; class TransformBase diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 3e2d1795528..45db8510cbb 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -351,6 +351,10 @@ void bc_match_scale(std::vector *objects_done, rescale[0] = rescale[1] = rescale[2] = scale_conv; float size_mat4[4][4]; + + float axis_mat4[4][4]; + unit_m4(axis_mat4); + size_to_mat4(size_mat4, rescale); for (std::vector::iterator it = objects_done->begin(); @@ -359,6 +363,7 @@ void bc_match_scale(std::vector *objects_done, { ob = *it; mult_m4_m4m4(ob->obmat, size_mat4, ob->obmat); + mult_m4_m4m4(ob->obmat, bc_unit.get_rotation(), ob->obmat); BKE_object_apply_mat4(ob, ob->obmat, 0, 0); } From 4eb90a9d1e377d5cd2c92019e0e116d4f09c9862 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Fri, 15 Feb 2013 16:42:41 +0000 Subject: [PATCH 151/157] 'Reset to Default Theme' wasn't taking into account those themes that enable panel header/background. --- source/blender/editors/interface/resources.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index d0a950fb3bc..4e625a75db7 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -690,6 +690,7 @@ void ui_theme_init_default(void) ui_widget_color_init(&btheme->tui); btheme->tui.iconfile[0] = 0; + btheme->tui.panel.show_back = FALSE; btheme->tui.panel.show_header = FALSE; rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25); @@ -707,6 +708,8 @@ void ui_theme_init_default(void) ui_theme_init_new(btheme); /* space view3d */ + btheme->tv3d.panelcolors.show_back = FALSE; + btheme->tv3d.panelcolors.show_header = FALSE; rgba_char_args_set_fl(btheme->tv3d.back, 0.225, 0.225, 0.225, 1.0); rgba_char_args_set(btheme->tv3d.text, 0, 0, 0, 255); rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255); From bc29b766dfb0ab1710acf686a4c8e05c3a05a35e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 15 Feb 2013 16:56:42 +0000 Subject: [PATCH 152/157] Fix part of #34239: crash with cycles textured draw mode + dynamic topology sculpt. --- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 66b457ec502..7f2d9437c3d 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1431,7 +1431,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm, */ if (cddm->pbvh && cddm->pbvh_draw && BKE_pbvh_type(cddm->pbvh) == PBVH_BMESH) { if (dm->numTessFaceData) { - setMaterial(userData, 1, NULL); + setMaterial(userData, 1, &gattribs); BKE_pbvh_draw(cddm->pbvh, NULL, NULL, NULL, FALSE); } From 207dca55f46e8c9e6948adf0d45f834dced9a274 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 15 Feb 2013 18:19:20 +0000 Subject: [PATCH 153/157] =?UTF-8?q?And=20more=20UI=20messages=20issues=20f?= =?UTF-8?q?ixing...=20Thanks=20again=20to=20Gabriel=20Gazz=C3=A1n=20and=20?= =?UTF-8?q?Leon=20Cheung!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release/scripts/modules/bl_i18n_utils/settings.py | 5 ++++- release/scripts/modules/rna_prop_ui.py | 2 +- source/blender/makesrna/intern/rna_nodetree_types.h | 6 +++--- source/blender/nodes/texture/nodes/node_texture_compose.c | 2 +- source/blender/nodes/texture/nodes/node_texture_decompose.c | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index 432f25f234b..01bc925cedd 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -368,7 +368,10 @@ FILE_NAME_POT = os.path.join(TRUNK_PO_DIR, ".".join((DOMAIN, "pot"))) # Other py files that should be searched for ui strings, relative to SOURCE_DIR. # Needed for Cycles, currently... -CUSTOM_PY_UI_FILES = [os.path.join("intern", "cycles", "blender", "addon", "ui.py"),] +CUSTOM_PY_UI_FILES = [ + os.path.join("intern", "cycles", "blender", "addon", "ui.py"), + os.path.join("release", "scripts", "modules", "rna_prop_ui.py"), +] # A cache storing validated msgids, to avoid re-spellchecking them. diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index 5e8bccb815e..dd0cd632413 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -148,7 +148,7 @@ def draw(layout, context, context_member, property_type, use_edit=True): if use_edit: row = split.row(align=True) - props = row.operator("wm.properties_edit", text="edit") + props = row.operator("wm.properties_edit", text="Edit") assign_props(props, val_draw, key) props = row.operator("wm.properties_remove", text="", icon='ZOOMOUT') diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 10c5a0b8819..b7ec9235483 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -52,7 +52,7 @@ DefNode( ShaderNode, SH_NODE_CURVE_RGB, def_rgb_curve, "CURVE DefNode( ShaderNode, SH_NODE_CAMERA, 0, "CAMERA", CameraData, "Camera Data", "" ) DefNode( ShaderNode, SH_NODE_MATH, def_math, "MATH", Math, "Math", "" ) DefNode( ShaderNode, SH_NODE_VECT_MATH, def_vector_math, "VECT_MATH", VectorMath, "Vector Math", "" ) -DefNode( ShaderNode, SH_NODE_SQUEEZE, 0, "SQUEEZE", Squeeze, "Squeeze", "" ) +DefNode( ShaderNode, SH_NODE_SQUEEZE, 0, "SQUEEZE", Squeeze, "Squeeze Value", "" ) DefNode( ShaderNode, SH_NODE_MATERIAL_EXT, def_sh_material, "MATERIAL_EXT", ExtendedMaterial, "Extended Material", "" ) DefNode( ShaderNode, SH_NODE_INVERT, 0, "INVERT", Invert, "Invert", "" ) DefNode( ShaderNode, SH_NODE_SEPRGB, 0, "SEPRGB", SeparateRGB, "Separate RGB", "" ) @@ -205,8 +205,8 @@ DefNode( TextureNode, TEX_NODE_VIEWER, 0, "VIEWE DefNode( TextureNode, TEX_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" ) DefNode( TextureNode, TEX_NODE_COORD, 0, "COORD", Coordinates, "Coordinates", "" ) DefNode( TextureNode, TEX_NODE_DISTANCE, 0, "DISTANCE", Distance, "Distance", "" ) -DefNode( TextureNode, TEX_NODE_COMPOSE, 0, "COMPOSE", Compose, "Compose", "" ) -DefNode( TextureNode, TEX_NODE_DECOMPOSE, 0, "DECOMPOSE", Decompose, "Decompose", "" ) +DefNode( TextureNode, TEX_NODE_COMPOSE, 0, "COMPOSE", Compose, "Combine RGBA", "" ) +DefNode( TextureNode, TEX_NODE_DECOMPOSE, 0, "DECOMPOSE", Decompose, "Separate RGBA", "" ) DefNode( TextureNode, TEX_NODE_VALTONOR, 0, "VALTONOR", ValToNor, "Value to Normal", "" ) DefNode( TextureNode, TEX_NODE_SCALE, 0, "SCALE", Scale, "Scale", "" ) diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c index 25da4f19e52..43a8ba1babf 100644 --- a/source/blender/nodes/texture/nodes/node_texture_compose.c +++ b/source/blender/nodes/texture/nodes/node_texture_compose.c @@ -61,7 +61,7 @@ void register_node_type_tex_compose(bNodeTreeType *ttype) { static bNodeType ntype; - node_type_base(ttype, &ntype, TEX_NODE_COMPOSE, "Compose RGBA", NODE_CLASS_OP_COLOR, 0); + node_type_base(ttype, &ntype, TEX_NODE_COMPOSE, "Combine RGBA", NODE_CLASS_OP_COLOR, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_size(&ntype, 100, 60, 150); node_type_exec(&ntype, exec); diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.c b/source/blender/nodes/texture/nodes/node_texture_decompose.c index a2875c31d9e..0866428ca6c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_decompose.c +++ b/source/blender/nodes/texture/nodes/node_texture_decompose.c @@ -82,7 +82,7 @@ void register_node_type_tex_decompose(bNodeTreeType *ttype) { static bNodeType ntype; - node_type_base(ttype, &ntype, TEX_NODE_DECOMPOSE, "Decompose RGBA", NODE_CLASS_OP_COLOR, 0); + node_type_base(ttype, &ntype, TEX_NODE_DECOMPOSE, "Separate RGBA", NODE_CLASS_OP_COLOR, 0); node_type_socket_templates(&ntype, inputs, outputs); node_type_size(&ntype, 100, 60, 150); node_type_exec(&ntype, exec); From 6072322312308fe13e51ce4c394eeb79434f38f2 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Fri, 15 Feb 2013 23:48:36 +0000 Subject: [PATCH 154/157] rigidbody: Avoid unnecessary simulation updates Now we flag the world for update on frame change and only call BKE_rigidbody_do_simulation() when needed. --- source/blender/blenkernel/intern/rigidbody.c | 2 ++ source/blender/blenkernel/intern/scene.c | 15 +++++++++++++-- source/blender/makesdna/DNA_rigidbody_types.h | 4 +++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 055ada33867..9ae82422ca2 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1223,6 +1223,8 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime) BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL); cache = rbw->pointcache; + rbw->flag &= ~RBW_FLAG_FRAME_UPDATE; + /* flag cache as outdated if we don't have a world or number of objects in the simulation has changed */ if (rbw->physics_world == NULL || rbw->numbodies != BLI_countlist(&rbw->group->gobject)) { cache->flag |= PTCACHE_OUTDATED; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 13e050f12b7..269751e79d4 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1089,6 +1089,15 @@ static void scene_depsgraph_hack(Scene *scene, Scene *scene_parent) } +static void scene_flag_rbw_recursive(Scene *scene) +{ + if (scene->set) + scene_flag_rbw_recursive(scene->set); + + if (BKE_scene_check_rigidbody_active(scene)) + scene->rigidbody_world->flag |= RBW_FLAG_FRAME_UPDATE; +} + static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scene_parent) { Base *base; @@ -1106,8 +1115,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen */ // XXX: this position may still change, objects not being updated correctly before simulation is run // NOTE: current position is so that rigidbody sim affects other objects - // FIXME: this now gets executed on every update, not just frame change now!!! - if (BKE_scene_check_rigidbody_active(scene)) { + if (BKE_scene_check_rigidbody_active(scene) && scene->rigidbody_world->flag & RBW_FLAG_FRAME_UPDATE) { /* we use frame time of parent (this is "scene" itself for top-level of sets recursion), * as that is the active scene controlling all timing in file at the moment */ @@ -1230,6 +1238,9 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) tag_main_idcode(bmain, ID_MA, FALSE); tag_main_idcode(bmain, ID_LA, FALSE); + /* flag rigid body worlds for update */ + scene_flag_rbw_recursive(sce); + /* BKE_object_handle_update() on all objects, groups and sets */ scene_update_tagged_recursive(bmain, sce, sce); diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h index ca703130edc..1636f2f4e4b 100644 --- a/source/blender/makesdna/DNA_rigidbody_types.h +++ b/source/blender/makesdna/DNA_rigidbody_types.h @@ -80,7 +80,9 @@ typedef enum eRigidBodyWorld_Flag { /* sim data needs to be rebuilt */ RBW_FLAG_NEEDS_REBUILD = (1 << 1), /* usse split impulse when stepping the simulation */ - RBW_FLAG_USE_SPLIT_IMPULSE = (1 << 2) + RBW_FLAG_USE_SPLIT_IMPULSE = (1 << 2), + /* need to step simulation after frame update */ + RBW_FLAG_FRAME_UPDATE = (1 << 3) } eRigidBodyWorld_Flag; /* ******************************** */ From 8c9906eb9190b40ffec981944174e96e6a471af2 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 16 Feb 2013 04:38:53 +0000 Subject: [PATCH 155/157] BGE: Fix for issue #34242 "It does not render in "P" mode for Game engine if you UV mapa a face of a cube" reported by joaclint. Material caching can now be disabled for Multitexture and GLSL Materials. --- .../gameengine/Converter/BL_BlenderDataConversion.cpp | 8 ++------ .../gameengine/Converter/KX_BlenderSceneConverter.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index e5503dfd0a7..f7726ebaf78 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -921,9 +921,6 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace /* do Texture Face materials */ Image* bima = (tface)? (Image*)tface->tpage: NULL; STR_String imastr = (tface)? (bima? (bima)->id.name : "" ) : ""; - - if (!converter->GetCacheMaterials()) - polymat = NULL; char alpha_blend=0; short tile=0; @@ -1045,9 +1042,8 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace polymat->m_specular.setValue(0.0f,0.0f,0.0f); polymat->m_shininess = 35.0; } - - if (converter->GetCacheMaterials()) - converter->CachePolyMaterial(ma, polymat); + + converter->CachePolyMaterial(ma, polymat); } } diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 376f75959ed..cd5dec4669d 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -601,22 +601,24 @@ void KX_BlenderSceneConverter::RegisterPolyMaterial(RAS_IPolyMaterial *polymat) void KX_BlenderSceneConverter::CachePolyMaterial(struct Material *mat, RAS_IPolyMaterial *polymat) { - m_polymat_cache[mat] = polymat; + if (m_use_mat_cache) + m_polymat_cache[mat] = polymat; } RAS_IPolyMaterial *KX_BlenderSceneConverter::FindCachedPolyMaterial(struct Material *mat) { - return m_polymat_cache[mat]; + return (m_use_mat_cache) ? m_polymat_cache[mat] : NULL; } void KX_BlenderSceneConverter::CacheBlenderMaterial(struct Material *mat, BL_Material *blmat) { - m_mat_cache[mat] = blmat; + if (m_use_mat_cache) + m_mat_cache[mat] = blmat; } BL_Material *KX_BlenderSceneConverter::FindCachedBlenderMaterial(struct Material *mat) { - return m_mat_cache[mat]; + return (m_use_mat_cache) ? m_mat_cache[mat] : NULL; } void KX_BlenderSceneConverter::RegisterInterpolatorList( From d9cc542728aa45aa3615b1396e5a147ec5c08cfa Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 16 Feb 2013 06:08:07 +0000 Subject: [PATCH 156/157] Adding a missing end paren to the Use Material Caching tooltip. --- source/blender/makesrna/intern/rna_scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index e3fb06d18d8..833d8e6addb 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2803,7 +2803,7 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_NO_MATERIAL_CACHING); RNA_def_property_ui_text(prop, "Use Material Caching", "Cache materials in the converter (this is faster, but can cause problems with older " - "Singletexture and Multitexture games"); + "Singletexture and Multitexture games)"); /* obstacle simulation */ prop = RNA_def_property(srna, "obstacle_simulation", PROP_ENUM, PROP_NONE); From fda8927d01ba719963154a56b45952ee541a869d Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Sat, 16 Feb 2013 16:17:45 +0000 Subject: [PATCH 157/157] rigidbody: Further fix for background scenes Since rigid bodies need their world to be be updated correctly we now pass it alongside the parent scene in scene_update_tagged_recursive(). Add BKE_object_handle_update_ex() as well as other object functions that take a RigidBodyWorld for this. Ideally this shouldn't be needed but we'd have to restructure scene handling for that. It's not a small taks however and definitely not something that can be done before release. Thanks to Campbell for review. --- source/blender/blenkernel/BKE_object.h | 4 +++ source/blender/blenkernel/BKE_rigidbody.h | 2 +- source/blender/blenkernel/intern/object.c | 38 ++++++++++++++------ source/blender/blenkernel/intern/rigidbody.c | 22 ++++-------- source/blender/blenkernel/intern/scene.c | 2 +- 5 files changed, 40 insertions(+), 28 deletions(-) diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 54189e26c92..19c04676548 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -50,6 +50,7 @@ struct RenderData; struct rctf; struct MovieClip; struct Main; +struct RigidBodyWorld; void BKE_object_workob_clear(struct Object *workob); void BKE_object_workob_calc_parent(struct Scene *scene, struct Object *ob, struct Object *workob); @@ -100,7 +101,9 @@ int BKE_object_pose_context_check(struct Object *ob); struct Object *BKE_object_pose_armature_get(struct Object *ob); void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob); +void BKE_object_where_is_calc_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob); void BKE_object_where_is_calc_time(struct Scene *scene, struct Object *ob, float ctime); +void BKE_object_where_is_calc_time_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob, float ctime); void BKE_object_where_is_calc_simul(struct Scene *scene, struct Object *ob); void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]); @@ -146,6 +149,7 @@ void BKE_object_tfm_protected_restore(struct Object *ob, const short protectflag); void BKE_object_handle_update(struct Scene *scene, struct Object *ob); +void BKE_object_handle_update_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob); void BKE_object_sculpt_modifiers_changed(struct Object *ob); int BKE_object_obdata_texspace_get(struct Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot); diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h index 2b19f60b5e4..12779a697b6 100644 --- a/source/blender/blenkernel/BKE_rigidbody.h +++ b/source/blender/blenkernel/BKE_rigidbody.h @@ -89,7 +89,7 @@ void BKE_rigidbody_remove_constraint(struct Scene *scene, struct Object *ob); /* Simulation */ void BKE_rigidbody_aftertrans_update(struct Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle); -void BKE_rigidbody_sync_transforms(struct Scene *scene, struct Object *ob, float ctime); +void BKE_rigidbody_sync_transforms(struct RigidBodyWorld *rbw, struct Object *ob, float ctime); void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw); void BKE_rigidbody_do_simulation(struct Scene *scene, float ctime); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 4b940fa8274..117e9fe280c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -58,6 +58,7 @@ #include "DNA_world_types.h" #include "DNA_object_types.h" #include "DNA_property_types.h" +#include "DNA_rigidbody_types.h" #include "BLI_blenlib.h" #include "BLI_math.h" @@ -2116,7 +2117,8 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[ return 1; } -void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) +/* note, scene is the active scene while actual_scene is the scene the object resides in */ +void BKE_object_where_is_calc_time_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob, float ctime) { if (ob == NULL) return; @@ -2143,7 +2145,7 @@ void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) } /* read values pushed into RBO from sim/cache... */ - BKE_rigidbody_sync_transforms(scene, ob, ctime); + BKE_rigidbody_sync_transforms(rbw, ob, ctime); /* solve constraints */ if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) { @@ -2159,6 +2161,11 @@ void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) else ob->transflag &= ~OB_NEG_SCALE; } +void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) +{ + BKE_object_where_is_calc_time_ex(scene, NULL, ob, ctime); +} + /* get object transformation matrix without recalculating dependencies and * constraints -- assume dependencies are already solved by depsgraph. * no changes to object and it's parent would be done. @@ -2180,9 +2187,13 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) } } -void BKE_object_where_is_calc(struct Scene *scene, Object *ob) +void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob) { - BKE_object_where_is_calc_time(scene, ob, BKE_scene_frame_get(scene)); + BKE_object_where_is_calc_time_ex(scene, rbw, ob, BKE_scene_frame_get(scene)); +} +void BKE_object_where_is_calc(Scene *scene, Object *ob) +{ + BKE_object_where_is_calc_time_ex(scene, NULL, ob, BKE_scene_frame_get(scene)); } void BKE_object_where_is_calc_simul(Scene *scene, Object *ob) @@ -2618,12 +2629,8 @@ int BKE_object_parent_loop_check(const Object *par, const Object *ob) /* the main object update call, for object matrix, constraints, keys and displist (modifiers) */ /* requires flags to be set! */ - -/* WARNING: "scene" here may not be the scene object actually resides in. - * When dealing with background-sets, "scene" is actually the active scene. - * e.g. "scene" <-- set 1 <-- set 2 ("ob" lives here) <-- set 3 <-- ... <-- set n - */ -void BKE_object_handle_update(Scene *scene, Object *ob) +/* Ideally we shouldn't have to pass the rigid body world, but need bigger restructuring to avoid id */ +void BKE_object_handle_update_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob) { if (ob->recalc & OB_RECALC_ALL) { /* speed optimization for animation lookups */ @@ -2664,7 +2671,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) copy_m4_m4(ob->obmat, ob->proxy_from->obmat); } else - BKE_object_where_is_calc(scene, ob); + BKE_object_where_is_calc_ex(scene, rbw, ob); } if (ob->recalc & OB_RECALC_DATA) { @@ -2818,6 +2825,15 @@ void BKE_object_handle_update(Scene *scene, Object *ob) // printf("set proxy pointer for later group stuff %s\n", ob->id.name); } } +/* WARNING: "scene" here may not be the scene object actually resides in. + * When dealing with background-sets, "scene" is actually the active scene. + * e.g. "scene" <-- set 1 <-- set 2 ("ob" lives here) <-- set 3 <-- ... <-- set n + * rigid bodies depend on their world so use BKE_object_handle_update_ex() to also pass along the corrent rigid body world + */ +void BKE_object_handle_update(Scene *scene, Object *ob) +{ + BKE_object_handle_update_ex(scene, NULL, ob); +} void BKE_object_sculpt_modifiers_changed(Object *ob) { diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 9ae82422ca2..26f0c25617f 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1130,31 +1130,23 @@ static void rigidbody_update_simulation_post_step(RigidBodyWorld *rbw) } } } - /* Sync rigid body and object transformations */ -void BKE_rigidbody_sync_transforms(Scene *scene, Object *ob, float ctime) +void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime) { - RigidBodyWorld *rbw = scene->rigidbody_world; RigidBodyOb *rbo = ob->rigidbody_object; - bool world_ok = true; /* keep original transform for kinematic and passive objects */ - if ((rbo == NULL) || (rbo->flag & RBO_FLAG_KINEMATIC) || (rbo->type == RBO_TYPE_PASSIVE)) + if (ELEM(NULL, rbw, rbo) || rbo->flag & RBO_FLAG_KINEMATIC || rbo->type == RBO_TYPE_PASSIVE) return; - - /* "scene" may not be the one where object + rigidbody sim actually reside - * due to the quirks of how background-sets eval works [#33970] - */ - if (rbw) { - /* 1) no cache exists before startframe */ - /* 2) keep original transform when simulation is muted */ - world_ok = (ctime > rbw->pointcache->startframe) && !(rbw->flag & RBW_FLAG_MUTED); - } /* use rigid body transform after cache start frame if objects is not being transformed */ - if (world_ok && !((ob->flag & SELECT) && (G.moving & G_TRANSFORM_OBJ))) { + if (ctime > rbw->pointcache->startframe && !(ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ)) { float mat[4][4], size_mat[4][4], size[3]; + /* keep original transform when the simulation is muted */ + if (rbw->flag & RBW_FLAG_MUTED) + return; + normalize_qt(rbo->orn); // RB_TODO investigate why quaternion isn't normalized at this point quat_to_mat4(mat, rbo->orn); copy_v3_v3(mat[3], rbo->pos); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 269751e79d4..ede0925e01f 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1129,7 +1129,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen for (base = scene->base.first; base; base = base->next) { Object *ob = base->object; - BKE_object_handle_update(scene_parent, ob); + BKE_object_handle_update_ex(scene_parent, scene->rigidbody_world, ob); if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) group_handle_recalc_and_update(scene_parent, ob, ob->dup_group);