Fixed active viewport transition glitches

This commit is contained in:
Gyedo Jeon 2010-02-03 21:52:28 +00:00
parent 764585f43a
commit d5cb8815ae
6 changed files with 132 additions and 41 deletions

View File

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

View File

@ -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', UNPICKABLE = ['x-disc-visible', 'y-disc-visible', 'z-disc-visible',
'GridBack', 'unpickable'] 'GridBack', 'unpickable']
@ -39,3 +39,24 @@ EDIT_TYPE_UNSCALABLE = 2
EDIT_TYPE_UNROTATABLE = 4 EDIT_TYPE_UNROTATABLE = 4
EDIT_TYPE_UNEDITABLE = EDIT_TYPE_UNMOVABLE | EDIT_TYPE_UNSCALABLE | EDIT_TYPE_UNROTATABLE 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])

View File

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

View File

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

View File

@ -39,6 +39,30 @@ class LevelEditorBase(DirectObject):
base.closeWindow(base.win) base.closeWindow(base.win)
base.win = base.winList[3] 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.cameraControl.lockRoll = True
base.direct.setFScaleWidgetByCam(1) base.direct.setFScaleWidgetByCam(1)

View File

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