grease-pencil-tools: add local camera for rotate canvas and flip canvas. #104567
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
|
from .ui_panels import get_camera
|
||||||
|
|
||||||
class GP_OT_camera_flip_x(bpy.types.Operator):
|
class GP_OT_camera_flip_x(bpy.types.Operator):
|
||||||
bl_idname = "gp.camera_flip_x"
|
bl_idname = "gp.camera_flip_x"
|
||||||
bl_label = "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'
|
and context.space_data.region_3d.view_perspective == 'CAMERA'
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
context.scene.camera.scale.x *= -1
|
get_camera().scale.x *= -1
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
from .prefs import get_addon_prefs
|
from .prefs import get_addon_prefs
|
||||||
|
from .ui_panels import get_camera
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import math
|
import math
|
||||||
@ -215,8 +216,7 @@ class RC_OT_RotateCanvas(bpy.types.Operator):
|
|||||||
self.ratio_inv = w / h
|
self.ratio_inv = w / h
|
||||||
|
|
||||||
if self.in_cam:
|
if self.in_cam:
|
||||||
# Get camera from scene
|
self.cam = get_camera()
|
||||||
self.cam = bpy.context.scene.camera
|
|
||||||
|
|
||||||
#return if one element is locked (else bypass location)
|
#return if one element is locked (else bypass location)
|
||||||
if self.cam.lock_rotation[:] != (False, False, False):
|
if self.cam.lock_rotation[:] != (False, False, False):
|
||||||
|
@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
import bpy
|
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):
|
class GP_PT_sidebarPanel(bpy.types.Panel):
|
||||||
bl_label = "Grease Pencil Tools"
|
bl_label = "Grease Pencil Tools"
|
||||||
bl_space_type = "VIEW_3D"
|
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_reset', text = 'Reset Rotation', icon = 'FILE_REFRESH')
|
||||||
row.operator('view3d.rotate_canvas_set', text = 'Save Rotation', icon = 'DRIVER_ROTATIONAL_DIFFERENCE')
|
row.operator('view3d.rotate_canvas_set', text = 'Save Rotation', icon = 'DRIVER_ROTATIONAL_DIFFERENCE')
|
||||||
|
|
||||||
|
cam = get_camera()
|
||||||
# View flip
|
# 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 = layout.row(align=True)
|
||||||
row.operator('gp.camera_flip_x', text = 'Camera Mirror Flip', icon = 'MOD_MIRROR')
|
row.operator('gp.camera_flip_x', text = 'Camera Mirror Flip', icon = 'MOD_MIRROR')
|
||||||
row.label(text='', icon='LOOP_BACK')
|
row.label(text='', icon='LOOP_BACK')
|
||||||
|
Loading…
Reference in New Issue
Block a user