Przeglądaj źródła

Fixed active viewport transition glitches

Gyedo Jeon 16 lat temu
rodzic
commit
d5cb8815ae

+ 1 - 1
direct/src/directtools/DirectCameraControl.py

@@ -179,7 +179,7 @@ class DirectCameraControl(DirectObject):
         # if not self.useMayaCamControls and (deltaT <= 0.25) or (deltaF <= 1):
 
         # Do this when not trying to manipulate camera
-        if not self.altDown:
+        if not self.altDown and len(base.direct.selected.getSelectedAsList()) == 0:
             # Check for a hit point based on
             # current mouse position
             # Allow intersection with unpickable objects

+ 22 - 1
direct/src/directtools/DirectGlobals.py

@@ -1,4 +1,4 @@
-from pandac.PandaModules import Vec3, Point3
+from pandac.PandaModules import Vec3, Point3, BitMask32
 
 UNPICKABLE = ['x-disc-visible', 'y-disc-visible', 'z-disc-visible',
               'GridBack', 'unpickable']
@@ -39,3 +39,24 @@ EDIT_TYPE_UNSCALABLE = 2
 EDIT_TYPE_UNROTATABLE = 4
 EDIT_TYPE_UNEDITABLE = EDIT_TYPE_UNMOVABLE | EDIT_TYPE_UNSCALABLE | EDIT_TYPE_UNROTATABLE
 
+# [gjeon] stuffs for new LE multi camera support
+LE_TOP_CAM_MASK = BitMask32.bit(0)
+LE_FRONT_CAM_MASK = BitMask32.bit(1)
+LE_LEFT_CAM_MASK = BitMask32.bit(2)
+LE_PERSP_CAM_MASK = BitMask32.bit(3)
+
+LE_CAM_MASKS = {'persp':LE_PERSP_CAM_MASK,
+                 'left':LE_LEFT_CAM_MASK,
+                 'front':LE_FRONT_CAM_MASK,
+                 'top':LE_TOP_CAM_MASK}
+
+def LE_showInAllCam(nodePath):
+    for camName in LE_CAM_MASKS.keys():
+        nodePath.show(LE_CAM_MASKS[camName])
+
+def LE_showInOneCam(nodePath, thisCamName):
+    LE_showInAllCam(nodePath)
+    for camName in LE_CAM_MASKS.keys():
+        if camName != thisCamName:
+            nodePath.hide(LE_CAM_MASKS[camName])
+    

+ 2 - 4
direct/src/directtools/DirectManipulation.py

@@ -188,10 +188,8 @@ class DirectManipulationControl(DirectObject):
         self.marquee.create()
 
         if self.fMultiView:
-            for i in range(4):
-                if i != base.camList.index(NodePath(base.direct.camNode)):
-                    self.marquee.hide(BitMask32.bit(i))
-        
+            LE_showInOneCam(self.marquee, base.direct.camera.getName())
+
     def manipulationStop(self):
         taskMgr.remove('manipulateObject')
         taskMgr.remove('manip-move-wait')

+ 73 - 9
direct/src/directtools/DirectSession.py

@@ -121,6 +121,8 @@ class DirectSession(DirectObject):
         self.fAlt = 0
         self.fShift = 0
         self.fMouse1 = 0 # [gjeon] to update alt key information while mouse1 is pressed
+        self.fMouse2 = 0
+        self.fMouse3 = 0
 
         self.pos = VBase3()
         self.hpr = VBase3()
@@ -167,9 +169,9 @@ class DirectSession(DirectObject):
             ['SGE_Place', Placer.place],
             ['SGE_Set Color', Slider.rgbPanel],
             ['SGE_Explore', SceneGraphExplorer.explore],])
-        self.modifierEvents = ['control', 'control-up',
-                              'shift', 'shift-up',
-                              'alt', 'alt-up',
+        self.modifierEvents = ['control', 'control-up', 'control-repeat',
+                              'shift', 'shift-up', 'shift-repeat',
+                              'alt', 'alt-up', 'alt-repeat',
                                ]
 
         keyList = map(chr, range(97, 123))
@@ -453,10 +455,52 @@ class DirectSession(DirectObject):
             self.ignore(event)
 
     def inputHandler(self, input):
-        # [gjeon] change current camera dr, iRay, mouseWatcher accordingly to support multiple windows
         if not hasattr(self, 'oobeMode') or self.oobeMode == 0:
-            for winCtrl in base.winControls:
-                if winCtrl.mouseWatcher and winCtrl.mouseWatcher.node().hasMouse():
+            # [gjeon] change current camera dr, iRay, mouseWatcher accordingly to support multiple windows
+            if base.direct.manipulationControl.fMultiView:
+                # handling orphan events
+                if self.fMouse1 and 'mouse1' not in input or\
+                   self.fMouse2 and 'mouse2' not in input or\
+                   self.fMouse3 and 'mouse3' not in input:
+                    if input.endswith('-up') or\
+                       input not in self.modifierEvents:
+                        # to handle orphan events
+                        return                        
+
+                if (self.fMouse1 == 0 and 'mouse1-up' in input) or\
+                   (self.fMouse2 == 0 and 'mouse2-up' in input) or\
+                   (self.fMouse3 == 0 and 'mouse3-up' in input):
+                    # to handle orphan events
+                    return 
+
+                if (self.fMouse1 or self.fMouse2 or self.fMouse3) and\
+                   input[4:7] != base.direct.camera.getName()[:3] and\
+                   input.endswith('-up'):
+                    # to handle orphan events
+                    return  
+
+                winCtrl = None
+                possibleWinCtrls = []
+                for cWinCtrl in base.winControls:
+                    if cWinCtrl.mouseWatcher.node().hasMouse():
+                        possibleWinCtrls.append(cWinCtrl)
+
+                if len(possibleWinCtrls) == 1:
+                    winCtrl = possibleWinCtrls[0]
+                elif len(possibleWinCtrls) > 1:
+                    for cWinCtrl in possibleWinCtrls:
+                        if (input.endswith('-up') and\
+                            not input in self.modifierEvents and\
+                            not input in self.mouseEvents) or\
+                           (input in self.mouseEvents):
+                            if input[4:7] == cWinCtrl.camera.getName()[:3]:
+                                winCtrl = cWinCtrl
+                        else:
+                            if input[4:7] != cWinCtrl.camera.getName()[:3]:
+                                winCtrl = cWinCtrl                                
+                if winCtrl is None:
+                    return
+                if input not in self.modifierEvents:
                     self.win = winCtrl.win
                     self.camera = winCtrl.camera
                     self.trueCamera = self.camera
@@ -466,9 +510,15 @@ class DirectSession(DirectObject):
                     base.direct.iRay = base.direct.dr.iRay
                     base.mouseWatcher = winCtrl.mouseWatcher
                     base.mouseWatcherNode = winCtrl.mouseWatcher.node()
-                    if base.direct.manipulationControl.fMultiView:
-                        base.direct.widget = base.direct.manipulationControl.widgetList[base.camList.index(NodePath(winCtrl.camNode))]
-                    break
+                    base.direct.dr.mouseUpdate()
+                    LE_showInOneCam(self.selectedNPReadout, self.camera.getName())
+                    base.direct.widget = base.direct.manipulationControl.widgetList[base.camList.index(NodePath(winCtrl.camNode))]
+
+                input = input[8:] # get rid of camera prefix
+                if self.fAlt and 'alt' not in input and not input.endswith('-up'):
+                    input = 'alt-' + input
+                if input.endswith('-repeat'):
+                    input = input[:-7]
 
         # Deal with keyboard and mouse input
         if input in self.hotKeyMap.keys():
@@ -487,13 +537,17 @@ class DirectSession(DirectObject):
             modifiers = self.getModifiers(input, 'mouse1')
             messenger.send('DIRECT-mouse1', sentArgs = [modifiers])
         elif input == 'mouse2-up':
+            self.fMouse2 = 0
             messenger.send('DIRECT-mouse2Up')
         elif input.find('mouse2') != -1:
+            self.fMouse2 = 1
             modifiers = self.getModifiers(input, 'mouse2')
             messenger.send('DIRECT-mouse2', sentArgs = [modifiers])
         elif input == 'mouse3-up':
+            self.fMouse3 = 0
             messenger.send('DIRECT-mouse3Up')
         elif input.find('mouse3') != -1:
+            self.fMouse3 = 1
             modifiers = self.getModifiers(input, 'mouse3')
             messenger.send('DIRECT-mouse3', sentArgs = [modifiers])
         elif input == 'shift':
@@ -510,12 +564,22 @@ class DirectSession(DirectObject):
         elif input == 'control-up':
             self.fControl = 0
         elif input == 'alt':
+            if self.fAlt:
+                return
             self.fAlt = 1
             # [gjeon] to update alt key information while mouse1 is pressed
             if self.fMouse1:
                 modifiers = DIRECT_NO_MOD
                 modifiers |= DIRECT_ALT_MOD
                 messenger.send('DIRECT-mouse1', sentArgs = [modifiers])
+            elif self.fMouse2:
+                modifiers = DIRECT_NO_MOD
+                modifiers |= DIRECT_ALT_MOD
+                messenger.send('DIRECT-mouse2', sentArgs = [modifiers])
+            elif self.fMouse3:
+                modifiers = DIRECT_NO_MOD
+                modifiers |= DIRECT_ALT_MOD
+                messenger.send('DIRECT-mouse3', sentArgs = [modifiers])
         elif input == 'alt-up':
             self.fAlt = 0
 

+ 25 - 1
direct/src/leveleditor/LevelEditorBase.py

@@ -39,6 +39,30 @@ class LevelEditorBase(DirectObject):
         base.closeWindow(base.win)
         base.win = base.winList[3]
 
+        base.direct.disableMouseEvents()
+        newMouseEvents = map(lambda x: "_le_per_%s"%x, base.direct.mouseEvents) +\
+                         map(lambda x: "_le_fro_%s"%x, base.direct.mouseEvents) +\
+                         map(lambda x: "_le_lef_%s"%x, base.direct.mouseEvents) +\
+                         map(lambda x: "_le_top_%s"%x, base.direct.mouseEvents)
+        base.direct.mouseEvents = newMouseEvents
+        base.direct.enableMouseEvents()
+
+        base.direct.disableKeyEvents()
+        keyEvents = map(lambda x: "_le_per_%s"%x, base.direct.keyEvents) +\
+                         map(lambda x: "_le_fro_%s"%x, base.direct.keyEvents) +\
+                         map(lambda x: "_le_lef_%s"%x, base.direct.keyEvents) +\
+                         map(lambda x: "_le_top_%s"%x, base.direct.keyEvents)
+        base.direct.keyEvents = keyEvents
+        base.direct.enableKeyEvents()
+
+        base.direct.disableModifierEvents()
+        modifierEvents = map(lambda x: "_le_per_%s"%x, base.direct.modifierEvents) +\
+                         map(lambda x: "_le_fro_%s"%x, base.direct.modifierEvents) +\
+                         map(lambda x: "_le_lef_%s"%x, base.direct.modifierEvents) +\
+                         map(lambda x: "_le_top_%s"%x, base.direct.modifierEvents)
+        base.direct.modifierEvents = modifierEvents
+        base.direct.enableModifierEvents()
+
         base.direct.cameraControl.lockRoll = True
         base.direct.setFScaleWidgetByCam(1)
 
@@ -67,7 +91,7 @@ class LevelEditorBase(DirectObject):
         base.direct.manipulationControl.fAllowMarquee = 1
         base.direct.manipulationControl.supportMultiView()
         base.direct.cameraControl.useMayaCamControls = 1
-        
+
         # [gjeon] to handle delete here first
         base.direct.ignore('DIRECT-delete')
         

+ 9 - 25
direct/src/leveleditor/ViewPort.py

@@ -10,7 +10,8 @@ __all__ = ["Viewport", "ViewportManager", "ViewportMenu"]
 from direct.showbase.DirectObject import DirectObject
 from direct.directtools.DirectGrid import DirectGrid
 from direct.showbase.ShowBase import WindowControls
-from pandac.PandaModules import WindowProperties, OrthographicLens, Point3, BitMask32
+from direct.directtools.DirectGlobals import *
+from pandac.PandaModules import WindowProperties, OrthographicLens, Point3
 import wx
 
 HORIZONTAL = wx.SPLIT_HORIZONTAL
@@ -21,16 +22,6 @@ VPFRONT    = 11
 VPTOP      = 12
 VPPERSPECTIVE = 13
 
-TopCameraBitmask = BitMask32.bit(0)
-FrontCameraBitmask = BitMask32.bit(1)
-LeftCameraBitmask = BitMask32.bit(2)
-PerspCameraBitmask = BitMask32.bit(3)
-
-CameraBitmasks = {'persp':PerspCameraBitmask,
-                 'left':LeftCameraBitmask,
-                 'front':FrontCameraBitmask,
-                 'top':TopCameraBitmask}
-
 class ViewportManager:
   """Manages the global viewport stuff."""
   viewports = []
@@ -91,7 +82,7 @@ class Viewport(wx.Panel, DirectObject):
     self.win = base.openWindow(props = props, gsg = ViewportManager.gsg)
     if self.win:
       self.cam2d = base.makeCamera2d(self.win)
-      self.cam2d.node().setCameraMask(CameraBitmasks[self.name])
+      self.cam2d.node().setCameraMask(LE_CAM_MASKS[self.name])
       
     if ViewportManager.gsg == None:
       ViewportManager.gsg = self.win.getGsg()
@@ -102,9 +93,10 @@ class Viewport(wx.Panel, DirectObject):
     self.cam.reparentTo(self.camera)
     self.camNode = self.cam.node()
 
-    self.camNode.setCameraMask(CameraBitmasks[self.name])
+    self.camNode.setCameraMask(LE_CAM_MASKS[self.name])
 
     bt = base.setupMouse(self.win, True)
+    bt.node().setPrefix('_le_%s_'%self.name[:3])    
     mw = bt.getParent()
     mk = mw.getParent()
     winCtrl = WindowControls(
@@ -195,20 +187,14 @@ class Viewport(wx.Panel, DirectObject):
     if name == 'left':
       v.grid.setHpr(0, 0, 90)
       #v.grid.gridBack.findAllMatches("**/+GeomNode")[0].setName("_leftViewGridBack")
-      v.grid.hide(PerspCameraBitmask)
-      v.grid.hide(FrontCameraBitmask)
-      v.grid.hide(TopCameraBitmask)
+      LE_showInOneCam(v.grid, name)
     elif name == 'front':
       v.grid.setHpr(90, 0, 90)
       #v.grid.gridBack.findAllMatches("**/+GeomNode")[0].setName("_frontViewGridBack")
-      v.grid.hide(PerspCameraBitmask)
-      v.grid.hide(LeftCameraBitmask)
-      v.grid.hide(TopCameraBitmask)
+      LE_showInOneCam(v.grid, name)
     else:
       #v.grid.gridBack.findAllMatches("**/+GeomNode")[0].setName("_topViewGridBack")
-      v.grid.hide(PerspCameraBitmask)
-      v.grid.hide(LeftCameraBitmask)
-      v.grid.hide(FrontCameraBitmask)
+      LE_showInOneCam(v.grid, name)
     return v
   
   @staticmethod
@@ -219,9 +205,7 @@ class Viewport(wx.Panel, DirectObject):
 
     v.grid = DirectGrid(parent=render)
     #v.grid.gridBack.findAllMatches("**/+GeomNode")[0].setName("_perspViewGridBack")
-    v.grid.hide(FrontCameraBitmask)
-    v.grid.hide(LeftCameraBitmask)
-    v.grid.hide(TopCameraBitmask)
+    LE_showInOneCam(v.grid, 'persp')
     return v
   
   @staticmethod