grease-pencil-tools: add local camera for rotate canvas and flip canvas. #104567

Closed
casey-bianco-davis wants to merge 1 commits from casey-bianco-davis/blender-addons:temp-greasepenciltools-local-camera into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 15 additions and 4 deletions
Showing only changes of commit e9695231b6 - Show all commits

View File

@ -2,6 +2,8 @@
import bpy
from .ui_panels import get_camera
class GP_OT_camera_flip_x(bpy.types.Operator):
bl_idname = "gp.camera_flip_x"
bl_label = "Camera Flip X"
@ -14,7 +16,7 @@ class GP_OT_camera_flip_x(bpy.types.Operator):
and context.space_data.region_3d.view_perspective == 'CAMERA'
def execute(self, context):
context.scene.camera.scale.x *= -1
get_camera().scale.x *= -1
return {"FINISHED"}
def register():

View File

@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
from .prefs import get_addon_prefs
from .ui_panels import get_camera
import bpy
import math
@ -215,8 +216,7 @@ class RC_OT_RotateCanvas(bpy.types.Operator):
self.ratio_inv = w / h
if self.in_cam:
# Get camera from scene
self.cam = bpy.context.scene.camera
self.cam = get_camera()
#return if one element is locked (else bypass location)
if self.cam.lock_rotation[:] != (False, False, False):

View File

@ -2,6 +2,14 @@
import bpy
def get_camera():
if bpy.context.area.type == 'VIEW_3D' and bpy.context.space_data.use_local_camera:
# Get camera from area's local camera
return bpy.context.space_data.camera
else:
# Get camera from scene
return bpy.context.scene.camera
class GP_PT_sidebarPanel(bpy.types.Panel):
bl_label = "Grease Pencil Tools"
bl_space_type = "VIEW_3D"
@ -30,8 +38,9 @@ class GP_PT_sidebarPanel(bpy.types.Panel):
row.operator('view3d.rotate_canvas_reset', text = 'Reset Rotation', icon = 'FILE_REFRESH')
row.operator('view3d.rotate_canvas_set', text = 'Save Rotation', icon = 'DRIVER_ROTATIONAL_DIFFERENCE')
cam = get_camera()
# View flip
if context.scene.camera and context.scene.camera.scale.x < 0:
if cam and cam.scale.x < 0:
row = layout.row(align=True)
row.operator('gp.camera_flip_x', text = 'Camera Mirror Flip', icon = 'MOD_MIRROR')
row.label(text='', icon='LOOP_BACK')