[Bf-extensions-cvs] [52d383c5] soc-2019-openxr: Always keep an active VR pose bookmark (as fallback)

Julian Eisel noreply at git.blender.org
Sun Feb 16 21:44:05 CET 2020


Commit: 52d383c574b1077c09858e865f9db9a1a7b16ba8
Author: Julian Eisel
Date:   Sun Feb 16 20:17:34 2020 +0100
Branches: soc-2019-openxr
https://developer.blender.org/rBA52d383c574b1077c09858e865f9db9a1a7b16ba8

Always keep an active VR pose bookmark (as fallback)

===================================================================

M	viewport_vr_preview.py

===================================================================

diff --git a/viewport_vr_preview.py b/viewport_vr_preview.py
index 3e5b0b9c..e5d66d34 100644
--- a/viewport_vr_preview.py
+++ b/viewport_vr_preview.py
@@ -252,9 +252,12 @@ class VIEW3D_OT_vr_pose_bookmark_remove(bpy.types.Operator):
     def execute(self, context):
         wm = context.window_manager
         bookmarks = wm.vr_pose_bookmarks
-        bookmark_active_idx = wm.vr_pose_bookmarks_active
 
-        bookmarks.remove(bookmark_active_idx)
+        if len(bookmarks) > 1:
+            bookmark_active_idx = wm.vr_pose_bookmarks_active
+            bookmarks.remove(bookmark_active_idx)
+
+            wm.vr_pose_bookmarks_active -= 1
 
         return {'FINISHED'}
 
@@ -453,6 +456,12 @@ def register():
         name="Show Virtual Camera"
     )
 
+    # Ensure there's a default bookmark (scene camera by default).
+    bookmarks = bpy.context.window_manager.vr_pose_bookmarks
+    if len(bookmarks) == 0:
+        bookmarks.add()
+        bookmarks[0].type = 'SCENE_CAMERA'
+
 
 def unregister():
     for cls in classes:



More information about the Bf-extensions-cvs mailing list