Merging r49191 through r49211 from trunk into soc-2011-tomato
This commit is contained in:
@@ -38,6 +38,7 @@ _modules = (
|
||||
"properties_data_modifier",
|
||||
"properties_data_speaker",
|
||||
"properties_game",
|
||||
"properties_mask_common",
|
||||
"properties_material",
|
||||
"properties_object_constraint",
|
||||
"properties_object",
|
||||
|
||||
318
release/scripts/startup/bl_ui/properties_mask_common.py
Normal file
318
release/scripts/startup/bl_ui/properties_mask_common.py
Normal file
@@ -0,0 +1,318 @@
|
||||
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
# panels get subclassed (not registered directly)
|
||||
# menus are referenced `as is`
|
||||
|
||||
import bpy
|
||||
from bpy.types import Menu
|
||||
|
||||
|
||||
class MASK_PT_mask:
|
||||
# subclasses must define...
|
||||
#~ bl_space_type = 'CLIP_EDITOR'
|
||||
#~ bl_region_type = 'UI'
|
||||
bl_label = "Mask Settings"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
space_data = context.space_data
|
||||
return space_data.mask and space_data.mode == 'MASK'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.prop(mask, "frame_start")
|
||||
col.prop(mask, "frame_end")
|
||||
|
||||
|
||||
class MASK_PT_layers:
|
||||
# subclasses must define...
|
||||
#~ bl_space_type = 'CLIP_EDITOR'
|
||||
#~ bl_region_type = 'UI'
|
||||
bl_label = "Mask Layers"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
space_data = context.space_data
|
||||
return space_data.mask and space_data.mode == 'MASK'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
active_layer = mask.layers.active
|
||||
|
||||
rows = 5 if active_layer else 2
|
||||
|
||||
row = layout.row()
|
||||
row.template_list(mask, "layers",
|
||||
mask, "active_layer_index", rows=rows)
|
||||
|
||||
sub = row.column(align=True)
|
||||
|
||||
sub.operator("mask.layer_new", icon='ZOOMIN', text="")
|
||||
sub.operator("mask.layer_remove", icon='ZOOMOUT', text="")
|
||||
|
||||
if active_layer:
|
||||
sub.separator()
|
||||
|
||||
props = sub.operator("mask.layer_move", icon='TRIA_UP', text="")
|
||||
props.direction = 'UP'
|
||||
|
||||
props = sub.operator("mask.layer_move", icon='TRIA_DOWN', text="")
|
||||
props.direction = 'DOWN'
|
||||
|
||||
layout.prop(active_layer, "name")
|
||||
|
||||
# blending
|
||||
row = layout.row(align=True)
|
||||
row.prop(active_layer, "alpha")
|
||||
row.prop(active_layer, "invert", text="", icon='IMAGE_ALPHA')
|
||||
|
||||
layout.prop(active_layer, "blend")
|
||||
layout.prop(active_layer, "falloff")
|
||||
|
||||
|
||||
class MASK_PT_spline():
|
||||
# subclasses must define...
|
||||
#~ bl_space_type = 'CLIP_EDITOR'
|
||||
#~ bl_region_type = 'UI'
|
||||
bl_label = "Active Spline"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
|
||||
if mask and sc.mode == 'MASK':
|
||||
return mask.layers.active and mask.layers.active.splines.active
|
||||
|
||||
return False
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
spline = mask.layers.active.splines.active
|
||||
|
||||
col = layout.column()
|
||||
col.prop(spline, "weight_interpolation")
|
||||
rowsub = col.row()
|
||||
rowsub.prop(spline, "use_cyclic")
|
||||
rowsub.prop(spline, "use_fill")
|
||||
|
||||
|
||||
class MASK_PT_point():
|
||||
# subclasses must define...
|
||||
#~ bl_space_type = 'CLIP_EDITOR'
|
||||
#~ bl_region_type = 'UI'
|
||||
bl_label = "Active Point"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
|
||||
if mask and sc.mode == 'MASK':
|
||||
mask_layer_active = mask.layers.active
|
||||
return (mask_layer_active and
|
||||
mask_layer_active.splines.active_point)
|
||||
|
||||
return False
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
point = mask.layers.active.splines.active_point
|
||||
parent = point.parent
|
||||
|
||||
col = layout.column()
|
||||
col.prop(point, "handle_type")
|
||||
|
||||
col = layout.column()
|
||||
# Currently only parenting yo movie clip is allowed, so do not
|
||||
# ver-oplicate things for now and use single template_ID
|
||||
#col.template_any_ID(parent, "id", "id_type", text="")
|
||||
|
||||
col.label("Parent:")
|
||||
col.prop(parent, "id", text="")
|
||||
|
||||
if parent.id_type == 'MOVIECLIP' and parent.id:
|
||||
clip = parent.id
|
||||
tracking = clip.tracking
|
||||
|
||||
col.prop_search(parent, "parent", tracking,
|
||||
"objects", icon='OBJECT_DATA', text="Object:")
|
||||
|
||||
if parent.parent in tracking.objects:
|
||||
object = tracking.objects[parent.parent]
|
||||
col.prop_search(parent, "sub_parent", object,
|
||||
"tracks", icon='ANIM_DATA', text="Track:")
|
||||
else:
|
||||
col.prop_search(parent, "sub_parent", tracking,
|
||||
"tracks", icon='ANIM_DATA', text="Track:")
|
||||
|
||||
|
||||
class MASK_PT_display():
|
||||
# subclasses must define...
|
||||
#~ bl_space_type = 'CLIP_EDITOR'
|
||||
#~ bl_region_type = 'UI'
|
||||
bl_label = "Mask Display"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
space_data = context.space_data
|
||||
return space_data.mask and space_data.mode == 'MASK'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
space_data = context.space_data
|
||||
|
||||
layout.prop(space_data, "mask_draw_type", text="")
|
||||
layout.prop(space_data, "show_mask_smooth")
|
||||
|
||||
|
||||
class MASK_PT_tools():
|
||||
# subclasses must define...
|
||||
#~ bl_space_type = 'CLIP_EDITOR'
|
||||
#~ bl_region_type = 'TOOLS'
|
||||
bl_label = "Mask Tools"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
space_data = context.space_data
|
||||
return space_data.mask and space_data.mode == 'MASK'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Transform:")
|
||||
col.operator("transform.translate")
|
||||
col.operator("transform.rotate")
|
||||
col.operator("transform.resize", text="Scale")
|
||||
props = col.operator("transform.transform", text="Shrink/Fatten")
|
||||
props.mode = 'MASK_SHRINKFATTEN'
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Spline:")
|
||||
col.operator("mask.delete")
|
||||
col.operator("mask.cyclic_toggle")
|
||||
col.operator("mask.switch_direction")
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Parenting:")
|
||||
col.operator("mask.parent_set")
|
||||
col.operator("mask.parent_clear")
|
||||
|
||||
|
||||
class MASK_MT_mask(Menu):
|
||||
bl_label = "Mask"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("mask.delete")
|
||||
|
||||
layout.separator()
|
||||
layout.operator("mask.cyclic_toggle")
|
||||
layout.operator("mask.switch_direction")
|
||||
layout.operator("mask.normals_make_consistent")
|
||||
layout.operator("mask.feather_weight_clear") # TODO, better place?
|
||||
|
||||
layout.separator()
|
||||
layout.operator("mask.parent_clear")
|
||||
layout.operator("mask.parent_set")
|
||||
|
||||
layout.separator()
|
||||
layout.menu("MASK_MT_visibility")
|
||||
layout.menu("MASK_MT_transform")
|
||||
layout.menu("MASK_MT_animation")
|
||||
|
||||
|
||||
class MASK_MT_visibility(Menu):
|
||||
bl_label = "Show/Hide"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("mask.hide_view_clear", text="Show Hidden")
|
||||
layout.operator("mask.hide_view_set", text="Hide Selected")
|
||||
|
||||
props = layout.operator("mask.hide_view_set", text="Hide Unselected")
|
||||
props.unselected = True
|
||||
|
||||
|
||||
class MASK_MT_transform(Menu):
|
||||
bl_label = "Transform"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("transform.translate")
|
||||
layout.operator("transform.rotate")
|
||||
layout.operator("transform.resize")
|
||||
props = layout.operator("transform.transform", text="Shrink/Fatten")
|
||||
props.mode = 'MASK_SHRINKFATTEN'
|
||||
|
||||
|
||||
class MASK_MT_animation(Menu):
|
||||
bl_label = "Animation"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("mask.shape_key_clear")
|
||||
layout.operator("mask.shape_key_insert")
|
||||
layout.operator("mask.shape_key_feather_reset")
|
||||
layout.operator("mask.shape_key_rekey")
|
||||
|
||||
|
||||
class MASK_MT_select(Menu):
|
||||
bl_label = "Select"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
sc = context.space_data
|
||||
|
||||
layout.operator("mask.select_border")
|
||||
layout.operator("mask.select_circle")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("mask.select_all"
|
||||
).action = 'TOGGLE'
|
||||
layout.operator("mask.select_all",
|
||||
text="Inverse").action = 'INVERT'
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
bpy.utils.register_module(__name__)
|
||||
@@ -115,11 +115,11 @@ class CLIP_HT_header(Header):
|
||||
sub.menu("CLIP_MT_view")
|
||||
|
||||
if clip:
|
||||
sub.menu("CLIP_MT_select")
|
||||
sub.menu("CLIP_MT_clip")
|
||||
sub.menu("CLIP_MT_mask")
|
||||
sub.menu("MASK_MT_select")
|
||||
sub.menu("CLIP_MT_clip") # XXX - remove?
|
||||
sub.menu("MASK_MT_mask")
|
||||
else:
|
||||
sub.menu("CLIP_MT_clip")
|
||||
sub.menu("CLIP_MT_clip") # XXX - remove?
|
||||
|
||||
row = layout.row()
|
||||
row.template_ID(sc, "clip", open="clip.open")
|
||||
@@ -161,16 +161,6 @@ class CLIP_PT_clip_view_panel:
|
||||
return clip and sc.view == 'CLIP'
|
||||
|
||||
|
||||
class CLIP_PT_mask_view_panel:
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sc = context.space_data
|
||||
clip = sc.clip
|
||||
|
||||
return clip and sc.view == 'CLIP' and sc.mode == 'MASKEDIT'
|
||||
|
||||
|
||||
class CLIP_PT_tracking_panel:
|
||||
|
||||
@classmethod
|
||||
@@ -422,34 +412,6 @@ class CLIP_PT_tools_object(CLIP_PT_reconstruction_panel, Panel):
|
||||
col.prop(settings, "object_distance")
|
||||
|
||||
|
||||
class CLIP_PT_tools_mask(CLIP_PT_mask_view_panel, Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'TOOLS'
|
||||
bl_label = "Mask Tools"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Transform:")
|
||||
col.operator("transform.translate")
|
||||
col.operator("transform.rotate")
|
||||
col.operator("transform.resize", text="Scale")
|
||||
props = col.operator("transform.transform", text="Shrink/Fatten")
|
||||
props.mode = 'MASK_SHRINKFATTEN'
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Spline:")
|
||||
col.operator("mask.delete")
|
||||
col.operator("mask.cyclic_toggle")
|
||||
col.operator("mask.switch_direction")
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Parenting:")
|
||||
col.operator("mask.parent_set")
|
||||
col.operator("mask.parent_clear")
|
||||
|
||||
|
||||
class CLIP_PT_tools_grease_pencil(Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'TOOLS'
|
||||
@@ -465,7 +427,7 @@ class CLIP_PT_tools_grease_pencil(Panel):
|
||||
|
||||
if sc.mode == 'DISTORTION':
|
||||
return sc.view == 'CLIP'
|
||||
elif sc.mode == 'MASKEDIT':
|
||||
elif sc.mode == 'MASK':
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -661,136 +623,6 @@ class CLIP_PT_tracking_camera(Panel):
|
||||
col.prop(clip.tracking.camera, "k3")
|
||||
|
||||
|
||||
class CLIP_PT_mask_layers(Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = "Mask Layers"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sc = context.space_data
|
||||
|
||||
return sc.mask and sc.mode == 'MASKEDIT'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
active_layer = mask.layers.active
|
||||
|
||||
rows = 5 if active_layer else 2
|
||||
|
||||
row = layout.row()
|
||||
row.template_list(mask, "layers",
|
||||
mask, "active_layer_index", rows=rows)
|
||||
|
||||
sub = row.column(align=True)
|
||||
|
||||
sub.operator("mask.layer_new", icon='ZOOMIN', text="")
|
||||
sub.operator("mask.layer_remove", icon='ZOOMOUT', text="")
|
||||
|
||||
if active_layer:
|
||||
sub.separator()
|
||||
|
||||
props = sub.operator("mask.layer_move", icon='TRIA_UP', text="")
|
||||
props.direction = 'UP'
|
||||
|
||||
props = sub.operator("mask.layer_move", icon='TRIA_DOWN', text="")
|
||||
props.direction = 'DOWN'
|
||||
|
||||
layout.prop(active_layer, "name")
|
||||
|
||||
# blending
|
||||
row = layout.row(align=True)
|
||||
row.prop(active_layer, "alpha")
|
||||
row.prop(active_layer, "invert", text="", icon='IMAGE_ALPHA')
|
||||
|
||||
layout.prop(active_layer, "blend")
|
||||
layout.prop(active_layer, "falloff")
|
||||
|
||||
|
||||
class CLIP_PT_active_mask_spline(Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = "Active Spline"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
|
||||
if mask and sc.mode == 'MASKEDIT':
|
||||
return mask.layers.active and mask.layers.active.splines.active
|
||||
|
||||
return False
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
spline = mask.layers.active.splines.active
|
||||
|
||||
col = layout.column()
|
||||
col.prop(spline, "weight_interpolation")
|
||||
rowsub = col.row()
|
||||
rowsub.prop(spline, "use_cyclic")
|
||||
rowsub.prop(spline, "use_fill")
|
||||
|
||||
|
||||
class CLIP_PT_active_mask_point(Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = "Active Point"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
|
||||
if mask and sc.mode == 'MASKEDIT':
|
||||
mask_layer_active = mask.layers.active
|
||||
return (mask_layer_active and
|
||||
mask_layer_active.splines.active_point)
|
||||
|
||||
return False
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
point = mask.layers.active.splines.active_point
|
||||
parent = point.parent
|
||||
|
||||
col = layout.column()
|
||||
col.prop(point, "handle_type")
|
||||
|
||||
col = layout.column()
|
||||
# Currently only parenting yo movie clip is allowed, so do not
|
||||
# ver-oplicate things for now and use single template_ID
|
||||
#col.template_any_ID(parent, "id", "id_type", text="")
|
||||
|
||||
col.label("Parent:")
|
||||
col.prop(parent, "id", text="")
|
||||
|
||||
if parent.id_type == 'MOVIECLIP' and parent.id:
|
||||
clip = parent.id
|
||||
tracking = clip.tracking
|
||||
|
||||
col.prop_search(parent, "parent", tracking,
|
||||
"objects", icon='OBJECT_DATA', text="Object:")
|
||||
|
||||
if parent.parent in tracking.objects:
|
||||
object = tracking.objects[parent.parent]
|
||||
col.prop_search(parent, "sub_parent", object,
|
||||
"tracks", icon='ANIM_DATA', text="Track:")
|
||||
else:
|
||||
col.prop_search(parent, "sub_parent", tracking,
|
||||
"tracks", icon='ANIM_DATA', text="Track:")
|
||||
|
||||
|
||||
class CLIP_PT_display(CLIP_PT_clip_view_panel, Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
@@ -835,29 +667,6 @@ class CLIP_PT_display(CLIP_PT_clip_view_panel, Panel):
|
||||
row = col.row()
|
||||
row.prop(clip, "display_aspect", text="")
|
||||
|
||||
if sc.mode == 'MASKEDIT':
|
||||
col = layout.column()
|
||||
col.prop(sc, "mask_draw_type", text="")
|
||||
col.prop(sc, "show_mask_smooth")
|
||||
|
||||
|
||||
# TODO, move into its own file
|
||||
class CLIP_PT_mask(CLIP_PT_mask_view_panel, Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = "Mask Settings"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
sc = context.space_data
|
||||
mask = sc.mask
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.prop(mask, "frame_start")
|
||||
col.prop(mask, "frame_end")
|
||||
|
||||
|
||||
class CLIP_PT_marker_display(CLIP_PT_clip_view_panel, Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
@@ -868,7 +677,7 @@ class CLIP_PT_marker_display(CLIP_PT_clip_view_panel, Panel):
|
||||
def poll(cls, context):
|
||||
sc = context.space_data
|
||||
|
||||
return sc.mode != 'MASKEDIT'
|
||||
return sc.mode != 'MASK'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -1227,30 +1036,18 @@ class CLIP_MT_select(Menu):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
sc = context.space_data
|
||||
|
||||
if sc.mode == 'MASKEDIT':
|
||||
layout.operator("mask.select_border")
|
||||
layout.operator("mask.select_circle")
|
||||
layout.operator("clip.select_border")
|
||||
layout.operator("clip.select_circle")
|
||||
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
|
||||
layout.operator("mask.select_all"
|
||||
).action = 'TOGGLE'
|
||||
layout.operator("mask.select_all",
|
||||
text="Inverse").action = 'INVERT'
|
||||
else:
|
||||
layout.operator("clip.select_border")
|
||||
layout.operator("clip.select_circle")
|
||||
layout.operator("clip.select_all"
|
||||
).action = 'TOGGLE'
|
||||
layout.operator("clip.select_all",
|
||||
text="Inverse").action = 'INVERT'
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("clip.select_all"
|
||||
).action = 'TOGGLE'
|
||||
layout.operator("clip.select_all",
|
||||
text="Inverse").action = 'INVERT'
|
||||
|
||||
layout.menu("CLIP_MT_select_grouped")
|
||||
layout.menu("CLIP_MT_select_grouped")
|
||||
|
||||
|
||||
class CLIP_MT_select_grouped(Menu):
|
||||
@@ -1294,30 +1091,6 @@ class CLIP_MT_tracking_specials(Menu):
|
||||
props.action = 'UNLOCK'
|
||||
|
||||
|
||||
class CLIP_MT_mask(Menu):
|
||||
bl_label = "Mask"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("mask.delete")
|
||||
|
||||
layout.separator()
|
||||
layout.operator("mask.cyclic_toggle")
|
||||
layout.operator("mask.switch_direction")
|
||||
layout.operator("mask.normals_make_consistent")
|
||||
layout.operator("mask.feather_weight_clear") # TODO, better place?
|
||||
|
||||
layout.separator()
|
||||
layout.operator("mask.parent_clear")
|
||||
layout.operator("mask.parent_set")
|
||||
|
||||
layout.separator()
|
||||
layout.menu("CLIP_MT_mask_visibility")
|
||||
layout.menu("CLIP_MT_mask_transform")
|
||||
layout.menu("CLIP_MT_mask_animation")
|
||||
|
||||
|
||||
class CLIP_MT_select_mode(Menu):
|
||||
bl_label = "Select Mode"
|
||||
|
||||
@@ -1329,44 +1102,6 @@ class CLIP_MT_select_mode(Menu):
|
||||
layout.operator_enum("clip.mode_set", "mode")
|
||||
|
||||
|
||||
class CLIP_MT_mask_visibility(Menu):
|
||||
bl_label = "Show/Hide"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("mask.hide_view_clear", text="Show Hidden")
|
||||
layout.operator("mask.hide_view_set", text="Hide Selected")
|
||||
|
||||
props = layout.operator("mask.hide_view_set", text="Hide Unselected")
|
||||
props.unselected = True
|
||||
|
||||
|
||||
class CLIP_MT_mask_transform(Menu):
|
||||
bl_label = "Transform"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("transform.translate")
|
||||
layout.operator("transform.rotate")
|
||||
layout.operator("transform.resize")
|
||||
props = layout.operator("transform.transform", text="Shrink/Fatten")
|
||||
props.mode = 'MASK_SHRINKFATTEN'
|
||||
|
||||
|
||||
class CLIP_MT_mask_animation(Menu):
|
||||
bl_label = "Animation"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("mask.shape_key_clear")
|
||||
layout.operator("mask.shape_key_insert")
|
||||
layout.operator("mask.shape_key_feather_reset")
|
||||
layout.operator("mask.shape_key_rekey")
|
||||
|
||||
|
||||
class CLIP_MT_camera_presets(Menu):
|
||||
"""Predefined tracking camera intrinsics"""
|
||||
bl_label = "Camera Presets"
|
||||
@@ -1408,5 +1143,48 @@ class CLIP_MT_stabilize_2d_specials(Menu):
|
||||
|
||||
layout.operator("clip.stabilize_2d_select")
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Mask (similar code in space_image.py, keep in sync)
|
||||
|
||||
|
||||
from bl_ui.properties_mask_common import (MASK_PT_mask,
|
||||
MASK_PT_layers,
|
||||
MASK_PT_spline,
|
||||
MASK_PT_point,
|
||||
MASK_PT_display,
|
||||
MASK_PT_tools)
|
||||
|
||||
|
||||
class CLIP_PT_mask(MASK_PT_mask, Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
|
||||
|
||||
class CLIP_PT_mask_layers(MASK_PT_layers, Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
|
||||
|
||||
class CLIP_PT_mask_display(MASK_PT_display, Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
|
||||
|
||||
class CLIP_PT_active_mask_spline(MASK_PT_spline, Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
|
||||
|
||||
class CLIP_PT_active_mask_point(MASK_PT_point, Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
|
||||
class CLIP_PT_tools_mask(MASK_PT_tools, Panel):
|
||||
bl_space_type = 'CLIP_EDITOR'
|
||||
bl_region_type = 'TOOLS'
|
||||
|
||||
# --- end mask ---
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
bpy.utils.register_module(__name__)
|
||||
|
||||
@@ -27,7 +27,7 @@ class ImagePaintPanel(UnifiedPaintPanel):
|
||||
bl_region_type = 'UI'
|
||||
|
||||
|
||||
class BrushButtonsPanel():
|
||||
class BrushButtonsPanel:
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
|
||||
@@ -153,10 +153,6 @@ class IMAGE_MT_image(Menu):
|
||||
if ima.source in {'FILE', 'GENERATED'} and ima.type != 'OPEN_EXR_MULTILAYER':
|
||||
layout.operator("image.pack", text="Pack As PNG").as_png = True
|
||||
|
||||
if not context.tool_settings.use_uv_sculpt:
|
||||
layout.separator()
|
||||
layout.prop(sima, "use_image_paint")
|
||||
|
||||
layout.separator()
|
||||
|
||||
|
||||
@@ -353,6 +349,7 @@ class IMAGE_HT_header(Header):
|
||||
ima = sima.image
|
||||
iuser = sima.image_user
|
||||
toolsettings = context.tool_settings
|
||||
mode = sima.mode
|
||||
|
||||
show_render = sima.show_render
|
||||
# show_paint = sima.show_paint
|
||||
@@ -406,13 +403,16 @@ class IMAGE_HT_header(Header):
|
||||
mesh = context.edit_object.data
|
||||
layout.prop_search(mesh.uv_textures, "active", mesh, "uv_textures", text="")
|
||||
|
||||
layout.prop(sima, "mode", text="")
|
||||
|
||||
if mode == 'MASK':
|
||||
row = layout.row()
|
||||
row.template_ID(sima, "mask", new="mask.new")
|
||||
|
||||
if ima:
|
||||
# layers
|
||||
layout.template_image_layers(ima, iuser)
|
||||
|
||||
# painting
|
||||
layout.prop(sima, "use_image_paint", text="")
|
||||
|
||||
# draw options
|
||||
row = layout.row(align=True)
|
||||
row.prop(sima, "draw_channels", text="", expand=True)
|
||||
@@ -423,7 +423,7 @@ class IMAGE_HT_header(Header):
|
||||
if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
|
||||
row.operator("image.play_composite", icon='PLAY')
|
||||
|
||||
if show_uvedit or sima.use_image_paint:
|
||||
if show_uvedit or mode == 'PAINT':
|
||||
layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
|
||||
|
||||
|
||||
@@ -861,5 +861,48 @@ class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
|
||||
col.prop(toolsettings, "uv_relax_method")
|
||||
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Mask (similar code in space_clip.py, keep in sync)
|
||||
# note! - panel placement does _not_ fit well with image panels... need to fix
|
||||
|
||||
from bl_ui.properties_mask_common import (MASK_PT_mask,
|
||||
MASK_PT_layers,
|
||||
MASK_PT_spline,
|
||||
MASK_PT_point,
|
||||
MASK_PT_display,
|
||||
MASK_PT_tools)
|
||||
|
||||
|
||||
class IMAGE_PT_mask(MASK_PT_mask, Panel):
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'PREVIEW'
|
||||
|
||||
|
||||
class IMAGE_PT_mask_layers(MASK_PT_layers, Panel):
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'PREVIEW'
|
||||
|
||||
|
||||
class IMAGE_PT_mask_display(MASK_PT_display, Panel):
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'PREVIEW'
|
||||
|
||||
|
||||
class IMAGE_PT_active_mask_spline(MASK_PT_spline, Panel):
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'PREVIEW'
|
||||
|
||||
|
||||
class IMAGE_PT_active_mask_point(MASK_PT_point, Panel):
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'PREVIEW'
|
||||
|
||||
class IMAGE_PT_tools_mask(MASK_PT_tools, Panel):
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'UI' # is 'TOOLS' in the clip editor
|
||||
|
||||
# --- end mask ---
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
bpy.utils.register_module(__name__)
|
||||
|
||||
@@ -51,7 +51,7 @@ extern const char PAINT_CURSOR_VERTEX_PAINT[3];
|
||||
extern const char PAINT_CURSOR_WEIGHT_PAINT[3];
|
||||
extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
|
||||
|
||||
void paint_init(struct Paint *p, const char col[3]);
|
||||
void BKE_paint_init(struct Paint *p, const char col[3]);
|
||||
void free_paint(struct Paint *p);
|
||||
void copy_paint(struct Paint *src, struct Paint *tar);
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ int paint_vertsel_test(Object *ob)
|
||||
);
|
||||
}
|
||||
|
||||
void paint_init(Paint *p, const char col[3])
|
||||
void BKE_paint_init(Paint *p, const char col[3])
|
||||
{
|
||||
Brush *brush;
|
||||
|
||||
|
||||
@@ -87,6 +87,33 @@ float *MemoryBuffer::convertToValueBuffer()
|
||||
return result;
|
||||
}
|
||||
|
||||
float MemoryBuffer::getMaximumValue()
|
||||
{
|
||||
float result = this->m_buffer[0];
|
||||
const unsigned int size = this->determineBufferSize();
|
||||
unsigned int i;
|
||||
|
||||
const float *fp_src = this->m_buffer;
|
||||
|
||||
for (i = 0; i < size; i++, fp_src += COM_NUMBER_OF_CHANNELS) {
|
||||
float value = *fp_src;
|
||||
if (value > result) {
|
||||
result = value;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float MemoryBuffer::getMaximumValue(rcti* rect)
|
||||
{
|
||||
MemoryBuffer *temp = new MemoryBuffer(NULL, rect);
|
||||
temp->copyContentFrom(this);
|
||||
float result = temp->getMaximumValue();
|
||||
delete temp;
|
||||
return result;
|
||||
}
|
||||
|
||||
MemoryBuffer::~MemoryBuffer()
|
||||
{
|
||||
if (this->m_buffer) {
|
||||
|
||||
@@ -228,6 +228,8 @@ public:
|
||||
MemoryBuffer *duplicate();
|
||||
|
||||
float *convertToValueBuffer();
|
||||
float getMaximumValue();
|
||||
float getMaximumValue(rcti* rect);
|
||||
private:
|
||||
unsigned int determineBufferSize();
|
||||
|
||||
|
||||
@@ -61,28 +61,41 @@ void VariableSizeBokehBlurOperation::initExecution()
|
||||
#endif
|
||||
QualityStepHelper::initExecution(COM_QH_INCREASE);
|
||||
}
|
||||
struct VariableSizeBokehBlurTileData
|
||||
{
|
||||
MemoryBuffer* color;
|
||||
MemoryBuffer* bokeh;
|
||||
MemoryBuffer* size;
|
||||
int maxBlur;
|
||||
};
|
||||
|
||||
void *VariableSizeBokehBlurOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
MemoryBuffer** result = new MemoryBuffer*[3];
|
||||
result[0] = (MemoryBuffer*)this->m_inputProgram->initializeTileData(rect);
|
||||
result[1] = (MemoryBuffer*)this->m_inputBokehProgram->initializeTileData(rect);
|
||||
result[2] = (MemoryBuffer*)this->m_inputSizeProgram->initializeTileData(rect);
|
||||
return result;
|
||||
VariableSizeBokehBlurTileData *data = new VariableSizeBokehBlurTileData();
|
||||
data->color = (MemoryBuffer*)this->m_inputProgram->initializeTileData(rect);
|
||||
data->bokeh = (MemoryBuffer*)this->m_inputBokehProgram->initializeTileData(rect);
|
||||
data->size = (MemoryBuffer*)this->m_inputSizeProgram->initializeTileData(rect);
|
||||
|
||||
|
||||
rcti rect2;
|
||||
this->determineDependingAreaOfInterest(rect, (ReadBufferOperation*)this->m_inputSizeProgram, &rect2);
|
||||
data->maxBlur = (int)data->size->getMaximumValue(&rect2);
|
||||
CLAMP(data->maxBlur, 1.0f, this->m_maxBlur);
|
||||
return data;
|
||||
}
|
||||
|
||||
void VariableSizeBokehBlurOperation::deinitializeTileData(rcti *rect, void *data)
|
||||
{
|
||||
MemoryBuffer** result = (MemoryBuffer**)data;
|
||||
delete[] result;
|
||||
VariableSizeBokehBlurTileData* result = (VariableSizeBokehBlurTileData*)data;
|
||||
delete result;
|
||||
}
|
||||
|
||||
void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, void *data)
|
||||
{
|
||||
MemoryBuffer** buffers = (MemoryBuffer**)data;
|
||||
MemoryBuffer* inputProgramBuffer = buffers[0];
|
||||
MemoryBuffer* inputBokehBuffer = buffers[1];
|
||||
MemoryBuffer* inputSizeBuffer = buffers[2];
|
||||
VariableSizeBokehBlurTileData* tileData = (VariableSizeBokehBlurTileData*)data;
|
||||
MemoryBuffer* inputProgramBuffer = tileData->color;
|
||||
MemoryBuffer* inputBokehBuffer = tileData->bokeh;
|
||||
MemoryBuffer* inputSizeBuffer = tileData->size;
|
||||
float* inputSizeFloatBuffer = inputSizeBuffer->getBuffer();
|
||||
float* inputProgramFloatBuffer = inputProgramBuffer->getBuffer();
|
||||
float readColor[4];
|
||||
@@ -90,6 +103,7 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, vo
|
||||
float tempSize[4];
|
||||
float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
int maxBlur = tileData->maxBlur;
|
||||
|
||||
#ifdef COM_DEFOCUS_SEARCH
|
||||
float search[4];
|
||||
@@ -99,10 +113,10 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, vo
|
||||
int maxx = search[2];
|
||||
int maxy = search[3];
|
||||
#else
|
||||
int minx = MAX2(x - this->m_maxBlur, 0.0f);
|
||||
int miny = MAX2(y - this->m_maxBlur, 0.0f);
|
||||
int maxx = MIN2(x + this->m_maxBlur, m_width);
|
||||
int maxy = MIN2(y + this->m_maxBlur, m_height);
|
||||
int minx = MAX2(x - maxBlur, 0.0f);
|
||||
int miny = MAX2(y - maxBlur, 0.0f);
|
||||
int maxx = MIN2(x + maxBlur, m_width);
|
||||
int maxy = MIN2(y + maxBlur, m_height);
|
||||
#endif
|
||||
{
|
||||
inputSizeBuffer->readNoCheck(tempSize, x, y);
|
||||
@@ -156,9 +170,13 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice* device,
|
||||
cl_kernel defocusKernel = device->COM_clCreateKernel("defocusKernel", NULL);
|
||||
|
||||
cl_int step = this->getStep();
|
||||
cl_int maxBlur = this->m_maxBlur;
|
||||
cl_int maxBlur;
|
||||
cl_float threshold = this->m_threshold;
|
||||
|
||||
MemoryBuffer *sizeMemoryBuffer = (MemoryBuffer *)this->m_inputSizeProgram->getInputMemoryBuffer(inputMemoryBuffers);
|
||||
maxBlur = (cl_int)sizeMemoryBuffer->getMaximumValue();
|
||||
maxBlur = MIN2(maxBlur, this->m_maxBlur);
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 1, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 2, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputSizeProgram);
|
||||
|
||||
@@ -65,7 +65,7 @@ struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2]
|
||||
void ED_clip_update_frame(const struct Main *mainp, int cfra);
|
||||
int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit);
|
||||
|
||||
void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[2]);
|
||||
void ED_clip_point_undistorted_pos(struct SpaceClip *sc, const float co[2], float r_co[2]);
|
||||
void ED_clip_point_stable_pos(const struct bContext *C, float x, float y, float *xr, float *yr);
|
||||
void ED_clip_point_stable_pos__reverse(const struct bContext *C, const float co[2], float r_co[2]);
|
||||
void ED_clip_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]);
|
||||
|
||||
@@ -38,10 +38,13 @@ struct ImageUser;
|
||||
struct ToolSettings;
|
||||
struct uiBlock;
|
||||
struct wmWindowManager;
|
||||
struct ARegion;
|
||||
|
||||
/* space_image.c, exported for transform */
|
||||
/* image_edit.c, exported for transform */
|
||||
struct Image *ED_space_image(struct SpaceImage *sima);
|
||||
void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
|
||||
void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
|
||||
struct Mask *ED_space_image_get_mask(struct SpaceImage *sima);
|
||||
void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask);
|
||||
|
||||
struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r);
|
||||
void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock);
|
||||
@@ -64,6 +67,10 @@ int ED_space_image_show_paint(struct SpaceImage *sima);
|
||||
int ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit);
|
||||
int ED_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit);
|
||||
|
||||
int ED_space_image_check_show_maskedit(struct SpaceImage *sima);
|
||||
int ED_space_image_maskedit_poll(struct bContext *C);
|
||||
int ED_space_image_maskedit_mask_poll(struct bContext *C);
|
||||
|
||||
/* UI level image (texture) updating... render calls own stuff (too) */
|
||||
void ED_image_update_frame(const struct Main *mainp, int cfra);
|
||||
|
||||
|
||||
@@ -1091,7 +1091,7 @@ static int ui_id_brush_get_icon(bContext *C, ID *id)
|
||||
mode = OB_MODE_TEXTURE_PAINT;
|
||||
}
|
||||
else if ((sima = CTX_wm_space_image(C)) &&
|
||||
(sima->flag & SI_DRAWTOOL))
|
||||
(sima->mode == SI_MODE_PAINT))
|
||||
{
|
||||
mode = OB_MODE_TEXTURE_PAINT;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ int ED_maskedit_poll(bContext *C)
|
||||
return ED_space_clip_maskedit_poll(C);
|
||||
case SPACE_SEQ:
|
||||
return ED_space_sequencer_maskedit_poll(C);
|
||||
case SPACE_IMAGE:
|
||||
return ED_space_image_maskedit_poll(C);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
@@ -77,6 +79,8 @@ int ED_maskedit_mask_poll(bContext *C)
|
||||
return ED_space_clip_maskedit_mask_poll(C);
|
||||
case SPACE_SEQ:
|
||||
return ED_space_sequencer_maskedit_mask_poll(C);
|
||||
case SPACE_IMAGE:
|
||||
return ED_space_image_maskedit_mask_poll(C);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
@@ -86,14 +90,31 @@ int ED_maskedit_mask_poll(bContext *C)
|
||||
|
||||
void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
|
||||
if (sc) {
|
||||
ED_clip_mouse_pos(C, event, co);
|
||||
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa) {
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_CLIP:
|
||||
{
|
||||
SpaceClip *sc = sa->spacedata.first;
|
||||
ED_clip_mouse_pos(C, event, co);
|
||||
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ:
|
||||
zero_v2(co); /* MASKTODO */
|
||||
break;
|
||||
case SPACE_IMAGE:
|
||||
zero_v2(co); /* MASKTODO */
|
||||
break;
|
||||
default:
|
||||
/* possible other spaces from which mask editing is available */
|
||||
BLI_assert(0);
|
||||
zero_v2(co);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* possible other spaces from which mask editing is available */
|
||||
BLI_assert(0);
|
||||
zero_v2(co);
|
||||
}
|
||||
}
|
||||
@@ -102,15 +123,33 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
|
||||
* output: xr/yr - mask point space */
|
||||
void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr)
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
float co[2];
|
||||
|
||||
if (sc) {
|
||||
ED_clip_point_stable_pos(C, x, y, &co[0], &co[1]);
|
||||
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
|
||||
if (sa) {
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_CLIP:
|
||||
{
|
||||
SpaceClip *sc = sa->spacedata.first;
|
||||
ED_clip_point_stable_pos(C, x, y, &co[0], &co[1]);
|
||||
BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ:
|
||||
zero_v2(co); /* MASKTODO */
|
||||
break;
|
||||
case SPACE_IMAGE:
|
||||
zero_v2(co); /* MASKTODO */
|
||||
break;
|
||||
default:
|
||||
/* possible other spaces from which mask editing is available */
|
||||
BLI_assert(0);
|
||||
zero_v2(co);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* possible other spaces from which mask editing is available */
|
||||
BLI_assert(0);
|
||||
zero_v2(co);
|
||||
}
|
||||
|
||||
@@ -120,19 +159,35 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr
|
||||
|
||||
void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, float *yr)
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
float co[2];
|
||||
|
||||
if (sc && ar) {
|
||||
co[0] = x;
|
||||
co[1] = y;
|
||||
BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co);
|
||||
ED_clip_point_stable_pos__reverse(C, co, co);
|
||||
if (sa) {
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_CLIP:
|
||||
{
|
||||
SpaceClip *sc = sa->spacedata.first;
|
||||
co[0] = x;
|
||||
co[1] = y;
|
||||
BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co);
|
||||
ED_clip_point_stable_pos__reverse(C, co, co);
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ:
|
||||
zero_v2(co); /* MASKTODO */
|
||||
break;
|
||||
case SPACE_IMAGE:
|
||||
zero_v2(co); /* MASKTODO */
|
||||
break;
|
||||
default:
|
||||
/* possible other spaces from which mask editing is available */
|
||||
BLI_assert(0);
|
||||
zero_v2(co);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* possible other spaces from which mask editing is available */
|
||||
BLI_assert(0);
|
||||
zero_v2(co);
|
||||
}
|
||||
|
||||
@@ -148,40 +203,68 @@ void ED_mask_size(const bContext *C, int *width, int *height)
|
||||
case SPACE_CLIP:
|
||||
{
|
||||
ED_space_clip_get_size(C, width, height);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ:
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
*width = (scene->r.size * scene->r.xsch) / 100;
|
||||
*height = (scene->r.size * scene->r.ysch) / 100;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case SPACE_IMAGE:
|
||||
{
|
||||
SpaceImage *sima = sa->spacedata.first;
|
||||
ED_space_image_size(sima, width, height);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* possible other spaces from which mask editing is available */
|
||||
BLI_assert(0);
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* possible other spaces from which mask editing is available */
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
else {
|
||||
BLI_assert(0);
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ED_mask_aspect(const bContext *C, float *aspx, float *aspy)
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
|
||||
if (sc) {
|
||||
ED_space_clip_get_aspect(sc, aspx, aspy);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacedata.first) {
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_CLIP:
|
||||
{
|
||||
SpaceClip *sc = sa->spacedata.first;
|
||||
ED_space_clip_get_aspect(sc, aspx, aspy);
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ:
|
||||
{
|
||||
*aspx = *aspy = 1.0f; /* MASKTODO - render aspect? */
|
||||
break;
|
||||
}
|
||||
case SPACE_IMAGE:
|
||||
{
|
||||
// SpaceImage *sima = sa->spacedata.first;
|
||||
*aspx = *aspy = 1.0f; /* MASKTODO - image aspect? */
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* possible other spaces from which mask editing is available */
|
||||
BLI_assert(0);
|
||||
*aspx = *aspy = 1.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* possible other spaces from which mask editing is available */
|
||||
*aspx = 1.0f;
|
||||
*aspy = 1.0f;
|
||||
BLI_assert(0);
|
||||
*aspx = *aspy = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +272,8 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley)
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
|
||||
/* MASKTODO */
|
||||
|
||||
if (sc) {
|
||||
int width, height;
|
||||
float zoomx, zoomy, aspx, aspy;
|
||||
|
||||
@@ -45,10 +45,11 @@
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "ED_mask.h"
|
||||
#include "ED_clip.h"
|
||||
#include "ED_image.h"
|
||||
#include "ED_keyframing.h"
|
||||
#include "ED_mask.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
@@ -255,7 +256,7 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[
|
||||
|
||||
static int mask_new_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
Mask *mask;
|
||||
char name[MAX_ID_NAME - 2];
|
||||
|
||||
@@ -263,8 +264,27 @@ static int mask_new_exec(bContext *C, wmOperator *op)
|
||||
|
||||
mask = BKE_mask_new(name);
|
||||
|
||||
if (sc)
|
||||
ED_space_clip_set_mask(C, sc, mask);
|
||||
if (sa && sa->spacedata.first) {
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_CLIP:
|
||||
{
|
||||
SpaceClip *sc = sa->spacedata.first;
|
||||
ED_space_clip_set_mask(C, sc, mask);
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ:
|
||||
{
|
||||
/* do nothing */
|
||||
break;
|
||||
}
|
||||
case SPACE_IMAGE:
|
||||
{
|
||||
SpaceImage *sima = sa->spacedata.first;
|
||||
ED_space_image_set_mask(C, sima, mask);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -539,6 +539,7 @@ static int clip_lasso_select_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
/* MASKTODO - image space */
|
||||
void MASK_OT_select_lasso(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
@@ -638,6 +639,7 @@ static int circle_select_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
/* MASKTODO - image space */
|
||||
void MASK_OT_select_circle(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
|
||||
@@ -56,23 +56,18 @@
|
||||
/************************ add/del boid rule operators *********************/
|
||||
static int rule_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
||||
ParticleSystem *psys= ptr.data;
|
||||
Object *ob= ptr.id.data;
|
||||
ParticleSettings *part;
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
||||
ParticleSettings *part = ptr.data;
|
||||
int type= RNA_enum_get(op->ptr, "type");
|
||||
|
||||
BoidRule *rule;
|
||||
BoidState *state;
|
||||
|
||||
if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
|
||||
if (!part || part->phystype != PART_PHYS_BOIDS)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
part = psys->part;
|
||||
|
||||
state = boid_get_current_state(part->boids);
|
||||
|
||||
|
||||
for (rule=state->rules.first; rule; rule=rule->next)
|
||||
rule->flag &= ~BOIDRULE_CURRENT;
|
||||
|
||||
@@ -82,7 +77,6 @@ static int rule_add_exec(bContext *C, wmOperator *op)
|
||||
BLI_addtail(&state->rules, rule);
|
||||
|
||||
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -107,25 +101,22 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
||||
ParticleSystem *psys= ptr.data;
|
||||
Object *ob = ptr.id.data;
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
||||
ParticleSettings *part = ptr.data;
|
||||
BoidRule *rule;
|
||||
BoidState *state;
|
||||
|
||||
if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
|
||||
if (!part || part->phystype != PART_PHYS_BOIDS)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
state = boid_get_current_state(psys->part->boids);
|
||||
state = boid_get_current_state(part->boids);
|
||||
|
||||
|
||||
for (rule=state->rules.first; rule; rule=rule->next) {
|
||||
if (rule->flag & BOIDRULE_CURRENT) {
|
||||
BLI_remlink(&state->rules, rule);
|
||||
MEM_freeN(rule);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
rule = state->rules.first;
|
||||
|
||||
@@ -133,10 +124,8 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
rule->flag |= BOIDRULE_CURRENT;
|
||||
|
||||
DAG_scene_sort(bmain, scene);
|
||||
DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -157,23 +146,21 @@ void BOID_OT_rule_del(wmOperatorType *ot)
|
||||
/************************ move up/down boid rule operators *********************/
|
||||
static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
||||
ParticleSystem *psys= ptr.data;
|
||||
Object *ob = ptr.id.data;
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
||||
ParticleSettings *part = ptr.data;
|
||||
BoidRule *rule;
|
||||
BoidState *state;
|
||||
|
||||
if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
|
||||
if (!part || part->phystype != PART_PHYS_BOIDS)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
state = boid_get_current_state(psys->part->boids);
|
||||
state = boid_get_current_state(part->boids);
|
||||
for (rule = state->rules.first; rule; rule=rule->next) {
|
||||
if (rule->flag & BOIDRULE_CURRENT && rule->prev) {
|
||||
BLI_remlink(&state->rules, rule);
|
||||
BLI_insertlink(&state->rules, rule->prev->prev, rule);
|
||||
|
||||
DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
||||
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -195,23 +182,21 @@ void BOID_OT_rule_move_up(wmOperatorType *ot)
|
||||
|
||||
static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
||||
ParticleSystem *psys= ptr.data;
|
||||
Object *ob = ptr.id.data;
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
||||
ParticleSettings *part = ptr.data;
|
||||
BoidRule *rule;
|
||||
BoidState *state;
|
||||
|
||||
if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
|
||||
if (!part || part->phystype != PART_PHYS_BOIDS)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
state = boid_get_current_state(psys->part->boids);
|
||||
state = boid_get_current_state(part->boids);
|
||||
for (rule = state->rules.first; rule; rule=rule->next) {
|
||||
if (rule->flag & BOIDRULE_CURRENT && rule->next) {
|
||||
BLI_remlink(&state->rules, rule);
|
||||
BLI_insertlink(&state->rules, rule->next, rule);
|
||||
|
||||
DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
||||
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -235,17 +220,13 @@ void BOID_OT_rule_move_down(wmOperatorType *ot)
|
||||
/************************ add/del boid state operators *********************/
|
||||
static int state_add_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
||||
ParticleSystem *psys= ptr.data;
|
||||
Object *ob= ptr.id.data;
|
||||
ParticleSettings *part;
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
||||
ParticleSettings *part = ptr.data;
|
||||
BoidState *state;
|
||||
|
||||
if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
|
||||
if (!part || part->phystype != PART_PHYS_BOIDS)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
part = psys->part;
|
||||
|
||||
for (state=part->boids->states.first; state; state=state->next)
|
||||
state->flag &= ~BOIDSTATE_CURRENT;
|
||||
|
||||
@@ -254,8 +235,6 @@ static int state_add_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
BLI_addtail(&part->boids->states, state);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -276,24 +255,19 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
||||
ParticleSystem *psys= ptr.data;
|
||||
Object *ob = ptr.id.data;
|
||||
ParticleSettings *part;
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
||||
ParticleSettings *part = ptr.data;
|
||||
BoidState *state;
|
||||
|
||||
if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
|
||||
if (!part || part->phystype != PART_PHYS_BOIDS)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
part = psys->part;
|
||||
|
||||
for (state=part->boids->states.first; state; state=state->next) {
|
||||
if (state->flag & BOIDSTATE_CURRENT) {
|
||||
BLI_remlink(&part->boids->states, state);
|
||||
MEM_freeN(state);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* there must be at least one state */
|
||||
@@ -307,9 +281,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
state->flag |= BOIDSTATE_CURRENT;
|
||||
|
||||
DAG_scene_sort(bmain, scene);
|
||||
DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
||||
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -331,22 +303,20 @@ void BOID_OT_state_del(wmOperatorType *ot)
|
||||
/************************ move up/down boid state operators *********************/
|
||||
static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
||||
ParticleSystem *psys= ptr.data;
|
||||
Object *ob = ptr.id.data;
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
||||
ParticleSettings *part = ptr.data;
|
||||
BoidSettings *boids;
|
||||
BoidState *state;
|
||||
|
||||
if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
|
||||
if (!part || part->phystype != PART_PHYS_BOIDS)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
boids = psys->part->boids;
|
||||
boids = part->boids;
|
||||
|
||||
for (state = boids->states.first; state; state=state->next) {
|
||||
if (state->flag & BOIDSTATE_CURRENT && state->prev) {
|
||||
BLI_remlink(&boids->states, state);
|
||||
BLI_insertlink(&boids->states, state->prev->prev, state);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -368,21 +338,21 @@ void BOID_OT_state_move_up(wmOperatorType *ot)
|
||||
|
||||
static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
||||
ParticleSystem *psys= ptr.data;
|
||||
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
||||
ParticleSettings *part = ptr.data;
|
||||
BoidSettings *boids;
|
||||
BoidState *state;
|
||||
|
||||
if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
|
||||
if (!part || part->phystype != PART_PHYS_BOIDS)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
boids = psys->part->boids;
|
||||
boids = part->boids;
|
||||
|
||||
for (state = boids->states.first; state; state=state->next) {
|
||||
if (state->flag & BOIDSTATE_CURRENT && state->next) {
|
||||
BLI_remlink(&boids->states, state);
|
||||
BLI_insertlink(&boids->states, state->next, state);
|
||||
DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,15 +66,16 @@
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ED_util.h"
|
||||
#include "ED_image.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_object.h"
|
||||
#include "ED_armature.h"
|
||||
#include "ED_screen_types.h"
|
||||
#include "ED_keyframes_draw.h"
|
||||
#include "ED_view3d.h"
|
||||
#include "ED_clip.h"
|
||||
#include "ED_image.h"
|
||||
#include "ED_keyframes_draw.h"
|
||||
#include "ED_object.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_screen_types.h"
|
||||
#include "ED_sequencer.h"
|
||||
#include "ED_util.h"
|
||||
#include "ED_view3d.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
@@ -459,9 +460,29 @@ int ED_operator_editmball(bContext *C)
|
||||
|
||||
int ED_operator_mask(bContext *C)
|
||||
{
|
||||
SpaceClip *sc = CTX_wm_space_clip(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacedata.first) {
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_CLIP:
|
||||
{
|
||||
SpaceClip *sc = sa->spacedata.first;
|
||||
return ED_space_clip_check_show_maskedit(sc);
|
||||
}
|
||||
case SPACE_SEQ:
|
||||
{
|
||||
SpaceSeq *sseq = sa->spacedata.first;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
return ED_space_sequencer_check_show_maskedit(sseq, scene);
|
||||
}
|
||||
case SPACE_IMAGE:
|
||||
{
|
||||
SpaceImage *sima = sa->spacedata.first;
|
||||
return ED_space_image_check_show_maskedit(sima);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ED_space_clip_check_show_maskedit(sc);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* *************************** action zone operator ************************** */
|
||||
|
||||
@@ -4667,8 +4667,9 @@ static int image_paint_poll(bContext *C)
|
||||
if (sima) {
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
if ((sima->flag & SI_DRAWTOOL) && ar->regiontype == RGN_TYPE_WINDOW)
|
||||
if ((sima->mode == SI_MODE_PAINT) && ar->regiontype == RGN_TYPE_WINDOW) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5311,7 +5312,7 @@ void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings
|
||||
settings->uv_relax_method = UV_SCULPT_TOOL_RELAX_LAPLACIAN;
|
||||
}
|
||||
|
||||
paint_init(&settings->uvsculpt->paint, PAINT_CURSOR_SCULPT);
|
||||
BKE_paint_init(&settings->uvsculpt->paint, PAINT_CURSOR_SCULPT);
|
||||
|
||||
WM_paint_cursor_activate(wm, uv_sculpt_brush_poll,
|
||||
brush_drawcursor, NULL);
|
||||
@@ -5601,7 +5602,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
|
||||
me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT,
|
||||
NULL, me->totface);
|
||||
|
||||
paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
BKE_paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
|
||||
if (U.glreslimit != 0)
|
||||
GPU_free_images();
|
||||
|
||||
@@ -1997,7 +1997,7 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */
|
||||
if (wp == NULL)
|
||||
wp = scene->toolsettings->wpaint = new_vpaint(1);
|
||||
|
||||
paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT);
|
||||
BKE_paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT);
|
||||
paint_cursor_start(C, weight_paint_poll);
|
||||
|
||||
mesh_octree_table(ob, NULL, NULL, 's');
|
||||
@@ -2574,7 +2574,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
|
||||
|
||||
paint_cursor_start(C, vertex_paint_poll);
|
||||
|
||||
paint_init(&vp->paint, PAINT_CURSOR_VERTEX_PAINT);
|
||||
BKE_paint_init(&vp->paint, PAINT_CURSOR_VERTEX_PAINT);
|
||||
}
|
||||
|
||||
if (me)
|
||||
|
||||
@@ -4212,7 +4212,7 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op))
|
||||
/* Mask layer is required */
|
||||
ED_sculpt_mask_layers_ensure(ob, mmd);
|
||||
|
||||
paint_init(&ts->sculpt->paint, PAINT_CURSOR_SCULPT);
|
||||
BKE_paint_init(&ts->sculpt->paint, PAINT_CURSOR_SCULPT);
|
||||
|
||||
paint_cursor_start(C, sculpt_poll);
|
||||
}
|
||||
|
||||
@@ -683,7 +683,7 @@ const char *buttons_context_dir[] = {
|
||||
"world", "object", "mesh", "armature", "lattice", "curve",
|
||||
"meta_ball", "lamp", "speaker", "camera", "material", "material_slot",
|
||||
"texture", "texture_slot", "texture_user", "bone", "edit_bone",
|
||||
"pose_bone", "particle_system", "particle_system_editable",
|
||||
"pose_bone", "particle_system", "particle_system_editable", "particle_settings",
|
||||
"cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", NULL
|
||||
};
|
||||
|
||||
@@ -890,6 +890,27 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
|
||||
CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL);
|
||||
return 1;
|
||||
}
|
||||
else if (CTX_data_equals(member, "particle_settings")) {
|
||||
/* only available when pinned */
|
||||
PointerRNA *ptr = get_pointer_type(path, &RNA_ParticleSettings);
|
||||
|
||||
if (ptr && ptr->data) {
|
||||
CTX_data_pointer_set(result, ptr->id.data, &RNA_ParticleSettings, ptr->data);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
/* get settings from active particle system instead */
|
||||
PointerRNA *ptr = get_pointer_type(path, &RNA_ParticleSystem);
|
||||
|
||||
if (ptr && ptr->data) {
|
||||
ParticleSettings *part = ((ParticleSystem *)ptr->data)->part;
|
||||
CTX_data_pointer_set(result, ptr->id.data, &RNA_ParticleSettings, part);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
set_pointer_type(path, result, &RNA_ParticleSettings);
|
||||
return 1;
|
||||
}
|
||||
else if (CTX_data_equals(member, "cloth")) {
|
||||
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
|
||||
|
||||
|
||||
@@ -992,7 +992,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog
|
||||
break;
|
||||
|
||||
*do_update = TRUE;
|
||||
*progress = ((float) cfra) / (efra - sfra);
|
||||
*progress = ((float) cfra - sfra) / (efra - sfra);
|
||||
}
|
||||
|
||||
if (distortion)
|
||||
|
||||
@@ -395,7 +395,6 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
}
|
||||
switch (wmn->action) {
|
||||
case NA_SELECTED:
|
||||
clip_scopes_tag_refresh(sa);
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
case NA_EDITED:
|
||||
@@ -1072,6 +1071,7 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
|
||||
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
|
||||
|
||||
/* mask polls mode */
|
||||
keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0);
|
||||
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ set(INC_SYS
|
||||
set(SRC
|
||||
image_buttons.c
|
||||
image_draw.c
|
||||
image_edit.c
|
||||
image_ops.c
|
||||
space_image.c
|
||||
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
* \ingroup spimage
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -778,7 +778,7 @@ void draw_image_main(const bContext *C, ARegion *ar)
|
||||
draw_image_buffer(win, sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy);
|
||||
|
||||
/* paint helpers */
|
||||
if (sima->flag & SI_DRAWTOOL)
|
||||
if (sima->mode == SI_MODE_PAINT)
|
||||
draw_image_paint_helpers(ar, scene, zoomx, zoomy);
|
||||
|
||||
|
||||
|
||||
349
source/blender/editors/space_image/image_edit.c
Normal file
349
source/blender/editors/space_image/image_edit.c
Normal file
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* ***** 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) 2008 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file blender/editors/space_image/image_editor.c
|
||||
* \ingroup spimage
|
||||
*/
|
||||
|
||||
#include "DNA_mask_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_tessmesh.h"
|
||||
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "ED_image.h" /* own include */
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_uvedit.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
/* note; image_panel_properties() uses pointer to sima->image directly */
|
||||
Image *ED_space_image(SpaceImage *sima)
|
||||
{
|
||||
return sima->image;
|
||||
}
|
||||
|
||||
/* called to assign images to UV faces */
|
||||
void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
|
||||
{
|
||||
/* context may be NULL, so use global */
|
||||
ED_uvedit_assign_image(G.main, scene, obedit, ima, sima->image);
|
||||
|
||||
/* change the space ima after because uvedit_face_visible_test uses the space ima
|
||||
* to check if the face is displayed in UV-localview */
|
||||
sima->image = ima;
|
||||
|
||||
if (ima == NULL || ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE) {
|
||||
if (sima->mode == SI_MODE_PAINT) {
|
||||
sima->mode = SI_MODE_VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
if (sima->image)
|
||||
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
|
||||
|
||||
if (sima->image && sima->image->id.us == 0)
|
||||
sima->image->id.us = 1;
|
||||
|
||||
if (obedit)
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data);
|
||||
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
}
|
||||
|
||||
Mask *ED_space_image_get_mask(SpaceImage *sima)
|
||||
{
|
||||
return sima->mask_info.mask;
|
||||
}
|
||||
|
||||
void ED_space_image_set_mask(bContext *C, SpaceImage *sima, Mask *mask)
|
||||
{
|
||||
sima->mask_info.mask = mask;
|
||||
|
||||
if (C) {
|
||||
WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask);
|
||||
}
|
||||
}
|
||||
|
||||
ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
|
||||
if (sima && sima->image) {
|
||||
#if 0
|
||||
if (sima->image->type == IMA_TYPE_R_RESULT && BIF_show_render_spare())
|
||||
return BIF_render_spare_imbuf();
|
||||
else
|
||||
#endif
|
||||
ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, lock_r);
|
||||
|
||||
if (ibuf && (ibuf->rect || ibuf->rect_float))
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ED_space_image_release_buffer(SpaceImage *sima, void *lock)
|
||||
{
|
||||
if (sima && sima->image)
|
||||
BKE_image_release_ibuf(sima->image, lock);
|
||||
}
|
||||
|
||||
int ED_space_image_has_buffer(SpaceImage *sima)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
void *lock;
|
||||
int has_buffer;
|
||||
|
||||
ibuf = ED_space_image_acquire_buffer(sima, &lock);
|
||||
has_buffer = (ibuf != NULL);
|
||||
ED_space_image_release_buffer(sima, lock);
|
||||
|
||||
return has_buffer;
|
||||
}
|
||||
|
||||
void ED_image_size(Image *ima, int *width, int *height)
|
||||
{
|
||||
ImBuf *ibuf = NULL;
|
||||
void *lock;
|
||||
|
||||
if (ima)
|
||||
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
||||
|
||||
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
|
||||
*width = ibuf->x;
|
||||
*height = ibuf->y;
|
||||
}
|
||||
else {
|
||||
*width = 256;
|
||||
*height = 256;
|
||||
}
|
||||
|
||||
if (ima)
|
||||
BKE_image_release_ibuf(ima, lock);
|
||||
}
|
||||
|
||||
void ED_space_image_size(SpaceImage *sima, int *width, int *height)
|
||||
{
|
||||
Scene *scene = sima->iuser.scene;
|
||||
ImBuf *ibuf;
|
||||
void *lock;
|
||||
|
||||
ibuf = ED_space_image_acquire_buffer(sima, &lock);
|
||||
|
||||
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
|
||||
*width = ibuf->x;
|
||||
*height = ibuf->y;
|
||||
}
|
||||
else if (sima->image && sima->image->type == IMA_TYPE_R_RESULT && scene) {
|
||||
/* not very important, just nice */
|
||||
*width = (scene->r.xsch * scene->r.size) / 100;
|
||||
*height = (scene->r.ysch * scene->r.size) / 100;
|
||||
|
||||
if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
|
||||
*width *= (scene->r.border.xmax - scene->r.border.xmin);
|
||||
*height *= (scene->r.border.ymax - scene->r.border.ymin);
|
||||
}
|
||||
|
||||
}
|
||||
/* I know a bit weak... but preview uses not actual image size */
|
||||
// XXX else if (image_preview_active(sima, width, height));
|
||||
else {
|
||||
*width = 256;
|
||||
*height = 256;
|
||||
}
|
||||
|
||||
ED_space_image_release_buffer(sima, lock);
|
||||
}
|
||||
|
||||
void ED_image_aspect(Image *ima, float *aspx, float *aspy)
|
||||
{
|
||||
*aspx = *aspy = 1.0;
|
||||
|
||||
if ((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) ||
|
||||
(ima->aspx == 0.0f || ima->aspy == 0.0f))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* x is always 1 */
|
||||
*aspy = ima->aspy / ima->aspx;
|
||||
}
|
||||
|
||||
void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
||||
{
|
||||
ED_image_aspect(ED_space_image(sima), aspx, aspy);
|
||||
}
|
||||
|
||||
void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
ED_space_image_size(sima, &width, &height);
|
||||
|
||||
*zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width);
|
||||
*zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height);
|
||||
}
|
||||
|
||||
void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
ED_space_image_aspect(sima, aspx, aspy);
|
||||
ED_space_image_size(sima, &w, &h);
|
||||
|
||||
*aspx *= (float)w;
|
||||
*aspy *= (float)h;
|
||||
|
||||
if (*aspx < *aspy) {
|
||||
*aspy = *aspy / *aspx;
|
||||
*aspx = 1.0f;
|
||||
}
|
||||
else {
|
||||
*aspx = *aspx / *aspy;
|
||||
*aspy = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void ED_image_uv_aspect(Image *ima, float *aspx, float *aspy)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
ED_image_aspect(ima, aspx, aspy);
|
||||
ED_image_size(ima, &w, &h);
|
||||
|
||||
*aspx *= (float)w;
|
||||
*aspy *= (float)h;
|
||||
}
|
||||
|
||||
int ED_space_image_show_render(SpaceImage *sima)
|
||||
{
|
||||
return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE));
|
||||
}
|
||||
|
||||
int ED_space_image_show_paint(SpaceImage *sima)
|
||||
{
|
||||
if (ED_space_image_show_render(sima))
|
||||
return 0;
|
||||
|
||||
return (sima->mode == SI_MODE_PAINT);
|
||||
}
|
||||
|
||||
int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
|
||||
{
|
||||
if (sima && (ED_space_image_show_render(sima) || ED_space_image_show_paint(sima)))
|
||||
return 0;
|
||||
|
||||
if (obedit && obedit->type == OB_MESH) {
|
||||
struct BMEditMesh *em = BMEdit_FromObject(obedit);
|
||||
int ret;
|
||||
|
||||
ret = EDBM_mtexpoly_check(em);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
|
||||
{
|
||||
if (ED_space_image_show_render(sima))
|
||||
return 0;
|
||||
|
||||
if (ED_space_image_show_paint(sima))
|
||||
if (obedit && obedit->type == OB_MESH) {
|
||||
struct BMEditMesh *em = BMEdit_FromObject(obedit);
|
||||
int ret;
|
||||
|
||||
ret = EDBM_mtexpoly_check(em);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* matches clip function */
|
||||
int ED_space_image_check_show_maskedit(SpaceImage *sima)
|
||||
{
|
||||
return (sima->mode == SI_MODE_MASK);
|
||||
}
|
||||
|
||||
int ED_space_image_maskedit_poll(bContext *C)
|
||||
{
|
||||
SpaceImage *sima = CTX_wm_space_image(C);
|
||||
|
||||
if (sima && sima->image) {
|
||||
return ED_space_image_check_show_maskedit(sima);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int ED_space_image_maskedit_mask_poll(bContext *C)
|
||||
{
|
||||
if (ED_space_image_maskedit_poll(C)) {
|
||||
Image *ima = CTX_data_edit_image(C);
|
||||
|
||||
if (ima) {
|
||||
SpaceImage *sima = CTX_wm_space_image(C);
|
||||
|
||||
return sima->mask_info.mask != NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/******************** TODO ********************/
|
||||
|
||||
/* XXX notifier? */
|
||||
|
||||
/* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */
|
||||
|
||||
static void image_update_frame(struct Image *UNUSED(ima), struct ImageUser *iuser, void *customdata)
|
||||
{
|
||||
int cfra = *(int *)customdata;
|
||||
|
||||
BKE_image_user_check_frame_calc(iuser, cfra, 0);
|
||||
}
|
||||
|
||||
void ED_image_update_frame(const Main *mainp, int cfra)
|
||||
{
|
||||
BKE_image_walk_all_users(mainp, &cfra, image_update_frame);
|
||||
}
|
||||
@@ -2474,22 +2474,3 @@ void IMAGE_OT_cycle_render_slot(wmOperatorType *ot)
|
||||
|
||||
RNA_def_boolean(ot->srna, "reverse", 0, "Cycle in Reverse", "");
|
||||
}
|
||||
|
||||
/******************** TODO ********************/
|
||||
|
||||
/* XXX notifier? */
|
||||
|
||||
/* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */
|
||||
|
||||
static void image_update_frame(struct Image *UNUSED(ima), struct ImageUser *iuser, void *customdata)
|
||||
{
|
||||
int cfra = *(int*)customdata;
|
||||
|
||||
BKE_image_user_check_frame_calc(iuser, cfra, 0);
|
||||
}
|
||||
|
||||
void ED_image_update_frame(const Main *mainp, int cfra)
|
||||
{
|
||||
BKE_image_walk_all_users(mainp, &cfra, image_update_frame);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
* \ingroup spimage
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_mask_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
@@ -42,15 +38,10 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_tessmesh.h"
|
||||
@@ -79,238 +70,6 @@
|
||||
|
||||
/**************************** common state *****************************/
|
||||
|
||||
/* note; image_panel_properties() uses pointer to sima->image directly */
|
||||
Image *ED_space_image(SpaceImage *sima)
|
||||
{
|
||||
return sima->image;
|
||||
}
|
||||
|
||||
/* called to assign images to UV faces */
|
||||
void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
|
||||
{
|
||||
/* context may be NULL, so use global */
|
||||
ED_uvedit_assign_image(G.main, scene, obedit, ima, sima->image);
|
||||
|
||||
/* change the space ima after because uvedit_face_visible_test uses the space ima
|
||||
* to check if the face is displayed in UV-localview */
|
||||
sima->image = ima;
|
||||
|
||||
if (ima == NULL || ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE)
|
||||
sima->flag &= ~SI_DRAWTOOL;
|
||||
|
||||
if (sima->image)
|
||||
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
|
||||
|
||||
if (sima->image && sima->image->id.us == 0)
|
||||
sima->image->id.us = 1;
|
||||
|
||||
if (obedit)
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data);
|
||||
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
}
|
||||
|
||||
ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
|
||||
if (sima && sima->image) {
|
||||
#if 0
|
||||
if (sima->image->type == IMA_TYPE_R_RESULT && BIF_show_render_spare())
|
||||
return BIF_render_spare_imbuf();
|
||||
else
|
||||
#endif
|
||||
ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, lock_r);
|
||||
|
||||
if (ibuf && (ibuf->rect || ibuf->rect_float))
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ED_space_image_release_buffer(SpaceImage *sima, void *lock)
|
||||
{
|
||||
if (sima && sima->image)
|
||||
BKE_image_release_ibuf(sima->image, lock);
|
||||
}
|
||||
|
||||
int ED_space_image_has_buffer(SpaceImage *sima)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
void *lock;
|
||||
int has_buffer;
|
||||
|
||||
ibuf = ED_space_image_acquire_buffer(sima, &lock);
|
||||
has_buffer = (ibuf != NULL);
|
||||
ED_space_image_release_buffer(sima, lock);
|
||||
|
||||
return has_buffer;
|
||||
}
|
||||
|
||||
void ED_image_size(Image *ima, int *width, int *height)
|
||||
{
|
||||
ImBuf *ibuf = NULL;
|
||||
void *lock;
|
||||
|
||||
if (ima)
|
||||
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
||||
|
||||
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
|
||||
*width = ibuf->x;
|
||||
*height = ibuf->y;
|
||||
}
|
||||
else {
|
||||
*width = 256;
|
||||
*height = 256;
|
||||
}
|
||||
|
||||
if (ima)
|
||||
BKE_image_release_ibuf(ima, lock);
|
||||
}
|
||||
|
||||
void ED_space_image_size(SpaceImage *sima, int *width, int *height)
|
||||
{
|
||||
Scene *scene = sima->iuser.scene;
|
||||
ImBuf *ibuf;
|
||||
void *lock;
|
||||
|
||||
ibuf = ED_space_image_acquire_buffer(sima, &lock);
|
||||
|
||||
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
|
||||
*width = ibuf->x;
|
||||
*height = ibuf->y;
|
||||
}
|
||||
else if (sima->image && sima->image->type == IMA_TYPE_R_RESULT && scene) {
|
||||
/* not very important, just nice */
|
||||
*width = (scene->r.xsch * scene->r.size) / 100;
|
||||
*height = (scene->r.ysch * scene->r.size) / 100;
|
||||
|
||||
if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
|
||||
*width *= (scene->r.border.xmax - scene->r.border.xmin);
|
||||
*height *= (scene->r.border.ymax - scene->r.border.ymin);
|
||||
}
|
||||
|
||||
}
|
||||
/* I know a bit weak... but preview uses not actual image size */
|
||||
// XXX else if (image_preview_active(sima, width, height));
|
||||
else {
|
||||
*width = 256;
|
||||
*height = 256;
|
||||
}
|
||||
|
||||
ED_space_image_release_buffer(sima, lock);
|
||||
}
|
||||
|
||||
void ED_image_aspect(Image *ima, float *aspx, float *aspy)
|
||||
{
|
||||
*aspx = *aspy = 1.0;
|
||||
|
||||
if ((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) ||
|
||||
(ima->aspx == 0.0f || ima->aspy == 0.0f))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* x is always 1 */
|
||||
*aspy = ima->aspy / ima->aspx;
|
||||
}
|
||||
|
||||
void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
||||
{
|
||||
ED_image_aspect(ED_space_image(sima), aspx, aspy);
|
||||
}
|
||||
|
||||
void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
ED_space_image_size(sima, &width, &height);
|
||||
|
||||
*zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width);
|
||||
*zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height);
|
||||
}
|
||||
|
||||
void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
ED_space_image_aspect(sima, aspx, aspy);
|
||||
ED_space_image_size(sima, &w, &h);
|
||||
|
||||
*aspx *= (float)w;
|
||||
*aspy *= (float)h;
|
||||
|
||||
if (*aspx < *aspy) {
|
||||
*aspy = *aspy / *aspx;
|
||||
*aspx = 1.0f;
|
||||
}
|
||||
else {
|
||||
*aspx = *aspx / *aspy;
|
||||
*aspy = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void ED_image_uv_aspect(Image *ima, float *aspx, float *aspy)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
ED_image_aspect(ima, aspx, aspy);
|
||||
ED_image_size(ima, &w, &h);
|
||||
|
||||
*aspx *= (float)w;
|
||||
*aspy *= (float)h;
|
||||
}
|
||||
|
||||
int ED_space_image_show_render(SpaceImage *sima)
|
||||
{
|
||||
return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE));
|
||||
}
|
||||
|
||||
int ED_space_image_show_paint(SpaceImage *sima)
|
||||
{
|
||||
if (ED_space_image_show_render(sima))
|
||||
return 0;
|
||||
|
||||
return (sima->flag & SI_DRAWTOOL);
|
||||
}
|
||||
|
||||
int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
|
||||
{
|
||||
if (sima && (ED_space_image_show_render(sima) || ED_space_image_show_paint(sima)))
|
||||
return 0;
|
||||
|
||||
if (obedit && obedit->type == OB_MESH) {
|
||||
struct BMEditMesh *em = BMEdit_FromObject(obedit);
|
||||
int ret;
|
||||
|
||||
ret = EDBM_mtexpoly_check(em);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
|
||||
{
|
||||
if (ED_space_image_show_render(sima))
|
||||
return 0;
|
||||
|
||||
if (ED_space_image_show_paint(sima))
|
||||
if (obedit && obedit->type == OB_MESH) {
|
||||
struct BMEditMesh *em = BMEdit_FromObject(obedit);
|
||||
int ret;
|
||||
|
||||
ret = EDBM_mtexpoly_check(em);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void image_scopes_tag_refresh(ScrArea *sa)
|
||||
{
|
||||
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
|
||||
@@ -387,12 +146,12 @@ static SpaceLink *image_new(const bContext *UNUSED(C))
|
||||
|
||||
simage = MEM_callocN(sizeof(SpaceImage), "initimage");
|
||||
simage->spacetype = SPACE_IMAGE;
|
||||
simage->zoom = 1;
|
||||
simage->lock = 1;
|
||||
simage->zoom = 1.0f;
|
||||
simage->lock = TRUE;
|
||||
|
||||
BKE_color_managed_view_settings_init(&simage->view_settings);
|
||||
|
||||
simage->iuser.ok = 1;
|
||||
simage->iuser.ok = TRUE;
|
||||
simage->iuser.fie_ima = 2;
|
||||
simage->iuser.frames = 100;
|
||||
|
||||
@@ -675,6 +434,23 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
ED_area_tag_redraw(sa);
|
||||
}
|
||||
break;
|
||||
case NC_MASK:
|
||||
switch (wmn->data) {
|
||||
case ND_SELECT:
|
||||
case ND_DATA:
|
||||
case ND_DRAW:
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
}
|
||||
switch (wmn->action) {
|
||||
case NA_SELECTED:
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
case NA_EDITED:
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NC_GEOM:
|
||||
switch (wmn->data) {
|
||||
case ND_DATA:
|
||||
@@ -714,8 +490,7 @@ static int image_context(const bContext *C, const char *member, bContextDataResu
|
||||
return 1;
|
||||
}
|
||||
else if (CTX_data_equals(member, "edit_mask")) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Mask *mask = BKE_sequencer_mask_get(scene); /* XXX */
|
||||
Mask *mask = ED_space_image_get_mask(sima);
|
||||
if (mask) {
|
||||
CTX_data_id_pointer_set(result, &mask->id);
|
||||
}
|
||||
@@ -787,6 +562,10 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
// image space manages own v2d
|
||||
// UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
|
||||
|
||||
/* mask polls mode */
|
||||
keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0);
|
||||
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
||||
|
||||
/* image paint polls for mode */
|
||||
keymap = WM_keymap_find(wm->defaultconf, "Image Paint", 0, 0);
|
||||
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
||||
@@ -851,12 +630,12 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
|
||||
draw_image_grease_pencil((bContext *)C, 0);
|
||||
|
||||
{
|
||||
Mask *mask = BKE_sequencer_mask_get(scene); /* XXX */
|
||||
Mask *mask = ED_space_image_get_mask(sima);
|
||||
if (mask) {
|
||||
int width, height;
|
||||
ED_mask_size(C, &width, &height);
|
||||
ED_mask_draw_region(mask, ar,
|
||||
0, 0, /* TODO */
|
||||
sima->mask_info.draw_flag, sima->mask_info.draw_type,
|
||||
width, height,
|
||||
TRUE, FALSE,
|
||||
NULL, C);
|
||||
|
||||
@@ -849,7 +849,7 @@ void view3d_cached_text_draw_add(const float co[3],
|
||||
|
||||
BLI_addtail(strings, vos);
|
||||
copy_v3_v3(vos->vec, co);
|
||||
vos->col.pack = *((int *)col);
|
||||
copy_v4_v4_char((char *)vos->col.ub, (const char *)col);
|
||||
vos->xoffs = xoffs;
|
||||
vos->flag = flag;
|
||||
vos->str_len = alloc_len - 1;
|
||||
@@ -4287,7 +4287,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
|
||||
ParticleDrawData *pdd = psys->pdd;
|
||||
Material *ma;
|
||||
float vel[3], imat[4][4];
|
||||
float timestep, pixsize_scale, pa_size, r_tilt, r_length;
|
||||
float timestep, pixsize_scale = 1.0f, pa_size, r_tilt, r_length;
|
||||
float pa_time, pa_birthtime, pa_dietime, pa_health, intensity;
|
||||
float cfra;
|
||||
float ma_col[3] = {0.0f, 0.0f, 0.0f};
|
||||
@@ -6442,14 +6442,12 @@ static void draw_hooks(Object *ob)
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, const unsigned char ob_wire_col[4])
|
||||
static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, const short dflag, unsigned char ob_wire_col[4])
|
||||
{
|
||||
const char *axis_str[3] = {"px", "py", "pz"};
|
||||
int axis;
|
||||
float mat[4][4];
|
||||
|
||||
/* color */
|
||||
|
||||
eul_to_mat4(mat, &data->axX);
|
||||
glLineWidth(4.0f);
|
||||
setlinestyle(2);
|
||||
@@ -6459,7 +6457,7 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, const unsigne
|
||||
|
||||
copy_v3_v3(v, &data->pivX);
|
||||
|
||||
dir[axis] = 1.f;
|
||||
dir[axis] = 1.0f;
|
||||
glBegin(GL_LINES);
|
||||
mul_m4_v3(mat, dir);
|
||||
add_v3_v3(v, dir);
|
||||
@@ -6467,7 +6465,11 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, const unsigne
|
||||
glVertex3fv(v);
|
||||
glEnd();
|
||||
|
||||
view3d_cached_text_draw_add(v, axis_str[axis], 0, V3D_CACHE_TEXT_ASCII, ob_wire_col);
|
||||
/* when const color is set wirecolor is NULL - we could get the current color but
|
||||
* with selection and group instancing its not needed to draw the text */
|
||||
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
||||
view3d_cached_text_draw_add(v, axis_str[axis], 0, V3D_CACHE_TEXT_ASCII, ob_wire_col);
|
||||
}
|
||||
}
|
||||
glLineWidth(1.0f);
|
||||
setlinestyle(0);
|
||||
@@ -7067,7 +7069,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
|
||||
if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) {
|
||||
bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)con->data;
|
||||
if (data->flag & CONSTRAINT_DRAW_PIVOT)
|
||||
draw_rigid_body_pivot(data, ob_wire_col);
|
||||
draw_rigid_body_pivot(data, dflag, ob_wire_col);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
|
||||
if (sa && (sa->spacetype == SPACE_IMAGE)) {
|
||||
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
|
||||
|
||||
if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->flag & SI_DRAWTOOL)) {
|
||||
if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
|
||||
if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname)
|
||||
if (U.uiflag & USER_GLOBALUNDO)
|
||||
BKE_undo_name(C, undoname);
|
||||
@@ -238,7 +238,7 @@ int ED_undo_valid(const bContext *C, const char *undoname)
|
||||
if (sa && sa->spacetype == SPACE_IMAGE) {
|
||||
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
|
||||
|
||||
if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->flag & SI_DRAWTOOL)) {
|
||||
if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,7 +681,7 @@ typedef struct SpaceImage {
|
||||
|
||||
struct Image *image;
|
||||
struct ImageUser iuser;
|
||||
struct CurveMapping *cumap;
|
||||
struct CurveMapping *cumap;
|
||||
|
||||
struct Scopes scopes; /* histogram waveform and vectorscope */
|
||||
struct Histogram sample_line_hist; /* sample line histogram */
|
||||
@@ -693,10 +693,11 @@ typedef struct SpaceImage {
|
||||
float zoom; /* user defined zoom level */
|
||||
float centx, centy; /* storage for offset while render drawing */
|
||||
|
||||
short curtile; /* the currently active tile of the image when tile is enabled, is kept in sync with the active faces tile */
|
||||
char mode; /* view/paint/mask */
|
||||
char pin;
|
||||
short pad;
|
||||
short curtile; /* the currently active tile of the image when tile is enabled, is kept in sync with the active faces tile */
|
||||
short lock;
|
||||
short pin;
|
||||
char dt_uv; /* UV draw type */
|
||||
char sticky; /* sticky selection type */
|
||||
char dt_uvstretch;
|
||||
@@ -723,6 +724,13 @@ typedef enum eSpaceImage_UVDT_Stretch {
|
||||
SI_UVDT_STRETCH_AREA = 1,
|
||||
} eSpaceImage_UVDT_Stretch;
|
||||
|
||||
/* SpaceImage->mode */
|
||||
typedef enum eSpaceImage_Mode {
|
||||
SI_MODE_VIEW = 0,
|
||||
SI_MODE_PAINT = 1,
|
||||
SI_MODE_MASK = 2
|
||||
} eSpaceImage_Mode;
|
||||
|
||||
/* SpaceImage->sticky
|
||||
* Note DISABLE should be 0, however would also need to re-arrange icon order,
|
||||
* also, sticky loc is the default mode so this means we don't need to 'do_versons' */
|
||||
@@ -734,15 +742,15 @@ typedef enum eSpaceImage_Sticky {
|
||||
|
||||
/* SpaceImage->flag */
|
||||
typedef enum eSpaceImage_Flag {
|
||||
SI_BE_SQUARE = (1 << 0),
|
||||
SI_EDITTILE = (1 << 1),
|
||||
/* SI_BE_SQUARE = (1 << 0), */ /* deprecated */
|
||||
SI_EDITTILE = (1 << 1), /* XXX - not used but should be? */
|
||||
SI_CLIP_UV = (1 << 2),
|
||||
SI_DRAWTOOL = (1 << 3),
|
||||
/* SI_DRAWTOOL = (1 << 3), */ /* deprecated */
|
||||
SI_NO_DRAWFACES = (1 << 4),
|
||||
SI_DRAWSHADOW = (1 << 5),
|
||||
/* SI_SELACTFACE = (1 << 6), */ /* deprecated */
|
||||
SI_DEPRECATED2 = (1 << 7),
|
||||
SI_DEPRECATED3 = (1 << 8), /* stick UV selection to mesh vertex (UVs wont always be touching) */
|
||||
/* SI_SELACTFACE = (1 << 6), */ /* deprecated */
|
||||
/* SI_DEPRECATED2 = (1 << 7), */ /* deprecated */
|
||||
/* SI_DEPRECATED3 = (1 << 8), */ /* deprecated */
|
||||
SI_COORDFLOATS = (1 << 9),
|
||||
SI_PIXELSNAP = (1 << 10),
|
||||
SI_LIVE_UNWRAP = (1 << 11),
|
||||
@@ -754,8 +762,8 @@ typedef enum eSpaceImage_Flag {
|
||||
SI_PREVSPACE = (1 << 15),
|
||||
SI_FULLWINDOW = (1 << 16),
|
||||
|
||||
SI_DEPRECATED4 = (1 << 17),
|
||||
SI_DEPRECATED5 = (1 << 18),
|
||||
/* SI_DEPRECATED4 = (1 << 17), */ /* deprecated */
|
||||
/* SI_DEPRECATED5 = (1 << 18), */ /* deprecated */
|
||||
|
||||
/* this means that the image is drawn until it reaches the view edge,
|
||||
* in the image view, its unrelated to the 'tile' mode for texface
|
||||
@@ -763,7 +771,7 @@ typedef enum eSpaceImage_Flag {
|
||||
SI_DRAW_TILE = (1 << 19),
|
||||
SI_SMOOTH_UV = (1 << 20),
|
||||
SI_DRAW_STRETCH = (1 << 21),
|
||||
/* SI_DISPGP = (1 << 22), */ /* DEPRECATED */
|
||||
/* SI_DISPGP = (1 << 22), */ /* deprecated */
|
||||
SI_DRAW_OTHER = (1 << 23),
|
||||
|
||||
SI_COLOR_CORRECTION = (1 << 24),
|
||||
|
||||
@@ -123,7 +123,7 @@ EnumPropertyItem clip_editor_mode_items[] = {
|
||||
{SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction",
|
||||
"Show tracking/reconstruction tools"},
|
||||
{SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"},
|
||||
{SC_MODE_MASKEDIT, "MASKEDIT", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"},
|
||||
{SC_MODE_MASKEDIT, "MASK", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -530,11 +530,14 @@ static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr)
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_SpaceUVEditor, ptr->data);
|
||||
}
|
||||
|
||||
static void rna_SpaceImageEditor_paint_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
|
||||
static void rna_SpaceImageEditor_mode_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
SpaceImage *sima = (SpaceImage *)(ptr->data);
|
||||
if (sima->mode == SI_MODE_PAINT) {
|
||||
BKE_paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT);
|
||||
|
||||
ED_space_image_paint_update(bmain->wm.first, scene->toolsettings);
|
||||
ED_space_image_paint_update(bmain->wm.first, scene->toolsettings);
|
||||
}
|
||||
}
|
||||
|
||||
static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr)
|
||||
@@ -564,6 +567,13 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
|
||||
ED_space_image_set(sima, sc->scene, sc->scene->obedit, (Image *)value.data);
|
||||
}
|
||||
|
||||
static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value)
|
||||
{
|
||||
SpaceImage *sima = (SpaceImage *)(ptr->data);
|
||||
|
||||
ED_space_image_set_mask(NULL, sima, (Mask *)value.data);
|
||||
}
|
||||
|
||||
static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *UNUSED(C), PointerRNA *ptr,
|
||||
PropertyRNA *UNUSED(prop), int *free)
|
||||
{
|
||||
@@ -1105,7 +1115,7 @@ static void rna_def_space(BlenderRNA *brna)
|
||||
}
|
||||
|
||||
/* for all spaces that use a mask */
|
||||
void mask_space_info(StructRNA *srna, int noteflag, const char *mask_set_func)
|
||||
void rna_def_space_mask_info(StructRNA *srna, int noteflag, const char *mask_set_func)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
@@ -1246,9 +1256,6 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
|
||||
RNA_def_property_enum_items(prop, pivot_items);
|
||||
RNA_def_property_ui_text(prop, "Pivot", "Rotation/Scaling Pivot");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
|
||||
/* mask */
|
||||
mask_space_info(srna, NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
}
|
||||
|
||||
static void rna_def_space_outliner(BlenderRNA *brna)
|
||||
@@ -1957,6 +1964,13 @@ static void rna_def_space_buttons(BlenderRNA *brna)
|
||||
|
||||
static void rna_def_space_image(BlenderRNA *brna)
|
||||
{
|
||||
static EnumPropertyItem image_space_mode_items[] = {
|
||||
{SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image and UV edit in mesh editmode"},
|
||||
{SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"},
|
||||
{SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
@@ -2026,12 +2040,12 @@ static void rna_def_space_image(BlenderRNA *brna)
|
||||
RNA_def_property_pointer_funcs(prop, "rna_SpaceImageEditor_uvedit_get", NULL, NULL, NULL);
|
||||
RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings");
|
||||
|
||||
/* paint */
|
||||
prop = RNA_def_property(srna, "use_image_paint", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAWTOOL);
|
||||
RNA_def_property_ui_text(prop, "Image Painting", "Enable image painting mode");
|
||||
RNA_def_property_ui_icon(prop, ICON_TPAINT_HLT, 0);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_paint_update");
|
||||
/* mode */
|
||||
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "mode");
|
||||
RNA_def_property_enum_items(prop, image_space_mode_items);
|
||||
RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceImageEditor_mode_update");
|
||||
|
||||
/* grease pencil */
|
||||
prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
|
||||
@@ -2070,6 +2084,9 @@ static void rna_def_space_image(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "View Settings", "Color management settings used for displaying images on the display");
|
||||
|
||||
rna_def_space_image_uv(brna);
|
||||
|
||||
/* mask */
|
||||
rna_def_space_mask_info(srna, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_mask_set");
|
||||
}
|
||||
|
||||
static void rna_def_space_sequencer(BlenderRNA *brna)
|
||||
@@ -3108,7 +3125,7 @@ static void rna_def_space_clip(BlenderRNA *brna)
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
|
||||
|
||||
/* mask */
|
||||
mask_space_info(srna, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_mask_set");
|
||||
rna_def_space_mask_info(srna, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_mask_set");
|
||||
|
||||
/* mode */
|
||||
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
|
||||
|
||||
@@ -176,6 +176,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
psmd->dm->needsFree = 0;
|
||||
|
||||
/* report change in mesh structure */
|
||||
DM_ensure_tessface(psmd->dm);
|
||||
if (psmd->dm->getNumVerts(psmd->dm) != psmd->totdmvert ||
|
||||
psmd->dm->getNumEdges(psmd->dm) != psmd->totdmedge ||
|
||||
psmd->dm->getNumTessFaces(psmd->dm) != psmd->totdmface)
|
||||
|
||||
@@ -123,6 +123,8 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, con
|
||||
sockdata->format.imtype= R_IMF_IMTYPE_OPENEXR;
|
||||
}
|
||||
}
|
||||
else
|
||||
BKE_imformat_defaults(&sockdata->format);
|
||||
/* use node data format by default */
|
||||
sockdata->use_node_format = TRUE;
|
||||
|
||||
@@ -174,9 +176,14 @@ static void init_output_file(bNodeTree *ntree, bNode* node, bNodeTemplate *ntemp
|
||||
RenderData *rd = &ntemp->scene->r;
|
||||
BLI_strncpy(nimf->base_path, rd->pic, sizeof(nimf->base_path));
|
||||
nimf->format = rd->im_format;
|
||||
if (BKE_imtype_is_movie(nimf->format.imtype)) {
|
||||
nimf->format.imtype= R_IMF_IMTYPE_OPENEXR;
|
||||
}
|
||||
|
||||
format = &rd->im_format;
|
||||
format = &nimf->format;
|
||||
}
|
||||
else
|
||||
BKE_imformat_defaults(&nimf->format);
|
||||
|
||||
/* add one socket by default */
|
||||
ntreeCompositOutputFileAddSocket(ntree, node, "Image", format);
|
||||
|
||||
@@ -1664,12 +1664,24 @@ static int wm_action_not_handled(int action)
|
||||
|
||||
static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
const int do_debug_handler = (G.debug & G_DEBUG_EVENTS);
|
||||
#endif
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmEventHandler *handler, *nexthandler;
|
||||
int action = WM_HANDLER_CONTINUE;
|
||||
int always_pass;
|
||||
|
||||
if (handlers == NULL) return action;
|
||||
if (handlers == NULL) {
|
||||
return action;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (do_debug_handler) {
|
||||
printf("%s: handling event\n", __func__);
|
||||
WM_event_print(event);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* modal handlers can get removed in this loop, we keep the loop this way */
|
||||
for (handler = handlers->first; handler; handler = nexthandler) {
|
||||
@@ -1677,9 +1689,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
||||
nexthandler = handler->next;
|
||||
|
||||
/* during this loop, ui handlers for nested menus can tag multiple handlers free */
|
||||
if (handler->flag & WM_HANDLER_DO_FREE) ;
|
||||
/* optional boundbox */
|
||||
else if (handler_boundbox_test(handler, event)) {
|
||||
if (handler->flag & WM_HANDLER_DO_FREE) {
|
||||
/* pass */
|
||||
}
|
||||
else if (handler_boundbox_test(handler, event)) { /* optional boundbox */
|
||||
/* in advance to avoid access to freed event on window close */
|
||||
always_pass = wm_event_always_pass(event);
|
||||
|
||||
@@ -1690,20 +1703,60 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
||||
if (handler->keymap) {
|
||||
wmKeyMap *keymap = WM_keymap_active(wm, handler->keymap);
|
||||
wmKeyMapItem *kmi;
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (do_debug_handler) {
|
||||
printf("%s: checking '%s' ...", __func__, keymap->idname);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!keymap->poll || keymap->poll(C)) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (do_debug_handler) {
|
||||
printf("pass\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
|
||||
if (wm_eventmatch(event, kmi)) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (do_debug_handler) {
|
||||
printf("%s: item matched '%s'\n", __func__, kmi->idname);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* weak, but allows interactive callback to not use rawkey */
|
||||
event->keymap_idname = kmi->idname;
|
||||
|
||||
action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
|
||||
if (action & WM_HANDLER_BREAK) /* not always_pass here, it denotes removed handler */
|
||||
if (action & WM_HANDLER_BREAK) {
|
||||
/* not always_pass here, it denotes removed handler */
|
||||
#ifndef NDEBUG
|
||||
if (do_debug_handler) {
|
||||
printf("%s: handled! '%s'...", __func__, kmi->idname);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
else {
|
||||
#ifndef NDEBUG
|
||||
if (do_debug_handler) {
|
||||
printf("%s: un-handled '%s'...", __func__, kmi->idname);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
#ifndef NDEBUG
|
||||
if (do_debug_handler) {
|
||||
printf("fail\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (handler->ui_handle) {
|
||||
action |= wm_handler_ui_call(C, handler, event, always_pass);
|
||||
|
||||
Reference in New Issue
Block a user