Skip to content

Commit b26f0ac

Browse files
Added Disable Camera Nav option
1 parent e9f3fe1 commit b26f0ac

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

Preferences.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ class RightMouseNavigationPreferences(AddonPreferences):
5151
update=update_node_keymap,
5252
)
5353

54+
disable_camera_navigation: BoolProperty(
55+
name="Disable Navigation for Camera View",
56+
description="Enable if you only want to navigate your scene, and not affect Camera Transform",
57+
default=False,
58+
)
59+
5460
def draw(self, context):
5561
layout = self.layout
5662

@@ -70,6 +76,11 @@ def draw(self, context):
7076
box.label(text="View", icon="VIEW3D")
7177
box.prop(self, "return_to_ortho_on_exit")
7278

79+
row = layout.row()
80+
box = row.box()
81+
box.label(text="Camera", icon="CAMERA_DATA")
82+
box.prop(self, "disable_camera_navigation")
83+
7384
# Keymap Customization
7485
import rna_keymap_ui
7586

RightMouseNavigation.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,10 @@ def callMenu(self, context):
102102
if space_type == "NODE_EDITOR":
103103
node_tree = context.space_data.node_tree
104104
if node_tree:
105-
if (
106-
node_tree.nodes.active is not None
107-
and node_tree.nodes.active.select
108-
):
105+
if node_tree.nodes.active is not None and node_tree.nodes.active.select:
109106
bpy.ops.wm.call_menu(name="NODE_MT_context_menu")
110107
else:
111-
bpy.ops.wm.search_single_menu(
112-
"INVOKE_DEFAULT", menu_idname="NODE_MT_add"
113-
)
108+
bpy.ops.wm.search_single_menu("INVOKE_DEFAULT", menu_idname="NODE_MT_add")
114109
else:
115110
try:
116111
bpy.ops.wm.call_menu(name=self.menu_by_mode[context.mode])
@@ -130,21 +125,26 @@ def execute(self, context):
130125
preferences = context.preferences
131126
addon_prefs = preferences.addons[__package__].preferences
132127
enable_nodes = addon_prefs.enable_for_node_editors
128+
disable_camera = addon_prefs.disable_camera_navigation
133129

134130
space_type = context.space_data.type
131+
view = context.space_data.region_3d.view_perspective
135132

136133
# Execute is the first thing called in our operator, so we start by
137134
# calling Blender's built-in Walk Navigation
138135
if space_type == "VIEW_3D":
139-
try:
140-
bpy.ops.view3d.walk("INVOKE_DEFAULT")
141-
# Adding the timer and starting the loop
142-
wm = context.window_manager
143-
self._timer = wm.event_timer_add(0.1, window=context.window)
144-
wm.modal_handler_add(self)
145-
return {"RUNNING_MODAL"}
146-
except RuntimeError:
147-
self.report({"ERROR"}, "Cannot Navigate an Object with Constraints")
136+
if not (view == "CAMERA" and disable_camera):
137+
try:
138+
bpy.ops.view3d.walk("INVOKE_DEFAULT")
139+
# Adding the timer and starting the loop
140+
wm = context.window_manager
141+
self._timer = wm.event_timer_add(0.1, window=context.window)
142+
wm.modal_handler_add(self)
143+
return {"RUNNING_MODAL"}
144+
except RuntimeError:
145+
self.report({"ERROR"}, "Cannot Navigate an Object with Constraints")
146+
return {"CANCELLED"}
147+
else:
148148
return {"CANCELLED"}
149149

150150
elif space_type == "NODE_EDITOR" and enable_nodes:

blender_manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
schema_version = "1.0.0"
22

33
id = "right_mouse_navigation"
4-
version = "2.5.0"
4+
version = "2.5.1"
55
name = "Right Mouse Navigation"
66
tagline = "Game Engine Movement and Menus"
77
maintainer = "Spectral Vectors and Contributors"

0 commit comments

Comments
 (0)