Skip to content

Commit

Permalink
Merge branch '212-2-1-pre-release-4-contin-edit-issues' into 'main'
Browse files Browse the repository at this point in the history
Resolve "2.1 pre release 4 - Contin Edit Issues"

Closes #212

See merge request blender/public-projects/shotmanager-addon!120
  • Loading branch information
jatubi committed Oct 21, 2022
2 parents 1199885 + c791564 commit 4663bf3
Show file tree
Hide file tree
Showing 13 changed files with 305 additions and 172 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-----
## 2.1.32 (2022-10-21)
- Continuous editing stabilization and exposition of properties

-----
## 2.1.31 (2022-10-17)
- Bug fix when duplicating cameras that had animation data but no action
Expand Down
11 changes: 5 additions & 6 deletions doc/devnotes_addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ Terminology:

## Shot select, set current, set to Draw Mode

[Switch to Draw Mode functions](ux/switch_to_draw_mode_functions.md)

[Set Current functions](ux/set_current_functions.md)

The manipulation behaviors are defined in the Shot Manipulations rollout of the add-on Preferences.
They are all part of the add-on preferences settings, so any change is applied to every scenes.

Expand All @@ -91,10 +95,5 @@ Key functions and operators to manage those manipulations are:
- The fact that a shot that has just been selected should be made as the current one is defined by the
function props.selectedShotShouldBecomeCurrent()

### When a shot becomes current
- *In shots.py:* The operator uas_shot_manager.set_current_shot holds all the actions done when a shot is
made current
- In props.setCurrentShotByIndex()

### When a shot has to be set to Draw mode
- To set the draw mode of a shot, when in Continuous mode: uas_shot_manager.greasepencil_select_and_draw

16 changes: 16 additions & 0 deletions doc/ux/set_current_functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# When a shot becomes current
- *In shots.py:* The operator uas_shot_manager.set_current_shot holds all the actions done when a shot is
made current

- In props.setCurrentShotByIndex()


## uas_shot_manager.set_current_shot

Calls:
props.setCurrentShotByIndex()

Does:
change time
setCameraToViewport
32 changes: 28 additions & 4 deletions doc/ux/switch_to_draw_mode_functions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Switch to Draw Mode functions

List of all the functions used to change the drawing mode of a grease pencil object.

# switchToDrawMode( gpencil ): function in utils_greasepencil
### When a shot has to be set to Draw mode
- To set the draw mode of a shot, when in Continuous mode: uas_shot_manager.greasepencil_select_and_draw is the prefered operator


## switchToDrawMode( gpencil ): function in utils_greasepencil

Change the current object to be the specified one.
If the previous object was in a sub-object mode it is set back to object mode.
Expand All @@ -16,21 +22,39 @@ Change the drawing stroke placement and axis
Called by uas_shot_manager.toggle_grease_pencil_draw_mode


# uas_shot_manager.toggle_grease_pencil_draw_mode
*** commented bpy.ops.object.select_all(action="DESELECT")


## uas_shot_manager.toggle_grease_pencil_draw_mode

Calling switchToDrawMode

Calls place3DCursor


# uas_shot_manager.greasepencil_select_and_draw
## uas_shot_manager.greasepencil_select_and_draw

**Called in the UI when pressing the GP icon button**
Calling switchToDrawMode

Called by
Called by:
- uas_shot_manager.stb_frame_drawing
- drawStoryboardRow
- setCurrentShotByIndex
called by uas_shot_manager.set_current_shot
called by _update_selected_shot_index when the selected item is changed in the templateList


## uas_shot_manager.draw_on_grease_pencil
*** Removed in V.2.1.31 ***

Called by:
- devDebug_displayAdv in storyboard_ui.py
- drawGpToolbar in storyboard_drawing_ui.py

Does:
gp.setInkLayerReadyToDraw(gp_child)
utils_greasepencil.switchToDrawMode(context, gp_child)
props.isEditingStoryboardFrame = True
utils.setPropertyPanelContext(context, "DATA")

2 changes: 1 addition & 1 deletion shotmanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"author": "Ubisoft - Julien Blervaque (aka Werwack), Romain Carriquiry Borchiari",
"description": "Easily manage shots and cameras in the 3D View and see the resulting edit in real-time",
"blender": (3, 1, 0),
"version": (2, 1, 31),
"version": (2, 1, 32),
"location": "View3D > Shot Mng",
"doc_url": "https://ubisoft-shotmanager.readthedocs.io",
"tracker_url": "https://github.com/ubisoft/shotmanager/issues",
Expand Down
224 changes: 112 additions & 112 deletions shotmanager/features/greasepencil/greasepencil_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,117 +239,6 @@ def execute(self, context):
return {"FINISHED"}


class UAS_ShotManager_OT_ToggleGreasePencilDrawMode(Operator):
bl_idname = "uas_shot_manager.toggle_grease_pencil_draw_mode"
bl_label = ""
bl_description = "Toggle Grease Pencil Draw Mode"
bl_options = {"INTERNAL", "UNDO"}

gpName: StringProperty(default="")

layerName: StringProperty(
name="Layer Name",
default="",
)

def execute(self, context):
gp = None
if "" == self.gpName:
# NOTE: we use context.object here instead of context.active_object because
# when the eye icon of the object is closed (meaning object.hide_get() == True)
# then context.active_object is None
gp = context.object
else:
if self.gpName in context.scene.objects:
gp = context.scene.objects[self.gpName]

if gp is not None:
props = context.scene.UAS_shot_manager_props
if "OBJECT" != gp.mode:
# if context.active_object.mode == "PAINT_GPENCIL":
# bpy.ops.object.mode_set(mode="OBJECT")
utils_greasepencil.switchToObjectMode()
else:
utils_greasepencil.switchToDrawMode(context, gp)
props.isEditingStoryboardFrame = True

if props.shotsGlobalSettings.stb_camPOV_forFreeGP:
props.getCurrentShot().setCameraToViewport()
context.scene.tool_settings.gpencil_stroke_placement_view3d = (
props.shotsGlobalSettings.stb_strokePlacement_forFreeGP
)
context.scene.tool_settings.gpencil_sculpt.lock_axis = "VIEW"

if "" != self.layerName:
if props.shotsGlobalSettings.stb_changeCursorPlacement_forFreeGP:
layerName = self.layerName
utils_greasepencil.place3DCursor(gp, context.scene.frame_current, layerName)

return {"FINISHED"}


# wkip toto 2022_10_14
class UAS_ShotManager_OT_DrawOnGreasePencil(Operator):
bl_idname = "uas_shot_manager.draw_on_grease_pencil"
bl_label = "Draw on Grease Pencil"
bl_description = "Draw on the Grease Pencil of the specified shot"
bl_options = {"INTERNAL"}

def execute(self, context):
scene = context.scene
props = scene.UAS_shot_manager_props

shot = None
gp_child = None
if not ("SELECTED" == props.current_shot_properties_mode):
shot = props.getCurrentShot()
else:
shot = props.getShotByIndex(props.selected_shot_index)

if shot is not None:
gp_child = utils_greasepencil.get_greasepencil_child(shot.camera)

props.setCurrentShotByIndex(props.selected_shot_index, changeTime=False)

if gp_child is None:
print("Grease Pencil Child is invalid for grease pencil parenting - Cancelling...")
return {"CANCELLED"}
elif not gp_child.visible_get():
print("Grease Pencil cannot be applied on hidden objects - Cancelling...")
return {"CANCELLED"}
else:
# if context.active_object.mode == "PAINT_GPENCIL":
# if gp_child != context.active_object:
# # we change the current object
# bpy.ops.gpencil.paintmode_toggle()
# return {"FINISHED"}

# if context.active_object is not None and context.active_object.mode != "OBJECT":
# bpy.ops.object.mode_set(mode="OBJECT")
# bpy.ops.object.select_all(action="DESELECT")
# bpy.context.view_layer.objects.active = gp_child

# shot.updateGreasePencils()
# set ink layer, else topmost layer
gp.setInkLayerReadyToDraw(gp_child)

utils_greasepencil.switchToDrawMode(context, gp_child)
props.isEditingStoryboardFrame = True

# gp_child.select_set(True)
# gp_child.hide_select = False
# gp_child.hide_viewport = False
# gp_child.hide_render = False
# bpy.ops.gpencil.paintmode_toggle()

# context.scene.tool_settings.gpencil_stroke_placement_view3d = "ORIGIN"
# context.scene.tool_settings.gpencil_sculpt.lock_axis = "VIEW"

utils.setPropertyPanelContext(context, "DATA")

return {"FINISHED"}


class UAS_ShotManager_OT_UpdateGreasePencil(Operator):
bl_idname = "uas_shot_manager.update_grease_pencil"
bl_label = "Update Grease Pencil"
Expand Down Expand Up @@ -592,6 +481,117 @@ def execute(self, context):
return {"FINISHED"}


class UAS_ShotManager_OT_ToggleGreasePencilDrawMode(Operator):
bl_idname = "uas_shot_manager.toggle_grease_pencil_draw_mode"
bl_label = ""
bl_description = "Toggle Grease Pencil Draw Mode"
bl_options = {"INTERNAL", "UNDO"}

gpName: StringProperty(default="")

layerName: StringProperty(
name="Layer Name",
default="",
)

def execute(self, context):
gp = None
if "" == self.gpName:
# NOTE: we use context.object here instead of context.active_object because
# when the eye icon of the object is closed (meaning object.hide_get() == True)
# then context.active_object is None
gp = context.object
else:
if self.gpName in context.scene.objects:
gp = context.scene.objects[self.gpName]

if gp is not None:
props = context.scene.UAS_shot_manager_props
if "OBJECT" != gp.mode:
# if context.active_object.mode == "PAINT_GPENCIL":
# bpy.ops.object.mode_set(mode="OBJECT")
utils_greasepencil.switchToObjectMode()
else:
utils_greasepencil.switchToDrawMode(context, gp)
props.isEditingStoryboardFrame = True

if props.shotsGlobalSettings.stb_camPOV_forFreeGP:
props.getCurrentShot().setCameraToViewport()
context.scene.tool_settings.gpencil_stroke_placement_view3d = (
props.shotsGlobalSettings.stb_strokePlacement_forFreeGP
)
context.scene.tool_settings.gpencil_sculpt.lock_axis = "VIEW"

if "" != self.layerName:
if props.shotsGlobalSettings.stb_changeCursorPlacement_forFreeGP:
layerName = self.layerName
utils_greasepencil.place3DCursor(gp, context.scene.frame_current, layerName)

return {"FINISHED"}


# wkip toto 2022_10_14
# class UAS_ShotManager_OT_DrawOnGreasePencil(Operator):
# bl_idname = "uas_shot_manager.draw_on_grease_pencil"
# bl_label = "Draw on Grease Pencil"
# bl_description = "Draw on the Grease Pencil of the specified shot"
# bl_options = {"INTERNAL"}

# def execute(self, context):
# scene = context.scene
# props = scene.UAS_shot_manager_props

# shot = None
# gp_child = None
# if not ("SELECTED" == props.current_shot_properties_mode):
# shot = props.getCurrentShot()
# else:
# shot = props.getShotByIndex(props.selected_shot_index)

# if shot is not None:
# gp_child = utils_greasepencil.get_greasepencil_child(shot.camera)

# props.setCurrentShotByIndex(props.selected_shot_index, changeTime=False)

# if gp_child is None:
# print("Grease Pencil Child is invalid for grease pencil parenting - Cancelling...")
# return {"CANCELLED"}
# elif not gp_child.visible_get():
# print("Grease Pencil cannot be applied on hidden objects - Cancelling...")
# return {"CANCELLED"}
# else:
# # if context.active_object.mode == "PAINT_GPENCIL":
# # if gp_child != context.active_object:
# # # we change the current object
# # bpy.ops.gpencil.paintmode_toggle()
# # return {"FINISHED"}

# # if context.active_object is not None and context.active_object.mode != "OBJECT":
# # bpy.ops.object.mode_set(mode="OBJECT")
# # bpy.ops.object.select_all(action="DESELECT")
# # bpy.context.view_layer.objects.active = gp_child

# # shot.updateGreasePencils()
# # set ink layer, else topmost layer
# gp.setInkLayerReadyToDraw(gp_child)

# utils_greasepencil.switchToDrawMode(context, gp_child)
# props.isEditingStoryboardFrame = True

# # gp_child.select_set(True)
# # gp_child.hide_select = False
# # gp_child.hide_viewport = False
# # gp_child.hide_render = False
# # bpy.ops.gpencil.paintmode_toggle()

# # context.scene.tool_settings.gpencil_stroke_placement_view3d = "ORIGIN"
# # context.scene.tool_settings.gpencil_sculpt.lock_axis = "VIEW"

# utils.setPropertyPanelContext(context, "DATA")

# return {"FINISHED"}


class UAS_ShotManager_GreasePencilSelectAndDraw(Operator):
bl_idname = "uas_shot_manager.greasepencil_select_and_draw"
bl_label = " "
Expand Down Expand Up @@ -1360,7 +1360,7 @@ def invoke(self, context, event):
UAS_ShotManager_OT_SelectGreasePencilObject,
UAS_ShotManager_OT_AddCanvasToGreasePencil,
UAS_ShotManager_OT_ToggleGreasePencilDrawMode,
UAS_ShotManager_OT_DrawOnGreasePencil,
# UAS_ShotManager_OT_DrawOnGreasePencil,
UAS_ShotManager_OT_UpdateGreasePencil,
UAS_ShotManager_OT_RemoveGreasePencil,
UAS_ShotManager_OT_ShowHideGreasePencil,
Expand Down
14 changes: 13 additions & 1 deletion shotmanager/features/greasepencil/greasepencil_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,19 @@ def drawGpToolbar(context, layout, props, editedGpencil, gpIsStoryboardFrame, sh
# icon = "OUTLINER_OB_GREASEPENCIL"
icon = "GREASEPENCIL"
if gpIsStoryboardFrame:
gpToolsRow.operator("uas_shot_manager.draw_on_grease_pencil", text="", icon=icon)
# wkip operator removed ***
# gpToolsRow.operator("uas_shot_manager.draw_on_grease_pencil", text="", icon=icon)
opMode = "DRAW" if props.isContinuousGPEditingModeActive() else "SELECT"

# if gp == context.active_object and context.active_object.mode == "PAINT_GPENCIL":
# if gp.mode == "PAINT_GPENCIL":
icon = "GREASEPENCIL"
gpToolsRow.alert = True
op = gpToolsRow.operator("uas_shot_manager.greasepencil_select_and_draw", text="", icon=icon)
op.index = shotIndex
op.toggleDrawEditing = True
op.mode = opMode

else:
op = gpToolsRow.operator("uas_shot_manager.toggle_grease_pencil_draw_mode", text="", icon=icon)
op.gpName = objName
Expand Down

0 comments on commit 4663bf3

Please sign in to comment.