diff --git a/direct/src/directtools/DirectSession.py b/direct/src/directtools/DirectSession.py index 2a19f5c6b0..ad3e95f6c6 100644 --- a/direct/src/directtools/DirectSession.py +++ b/direct/src/directtools/DirectSession.py @@ -698,9 +698,9 @@ class DisplayRegionContext: self.mouseLastY = self.mouseY # Values for this frame # This ranges from -1 to 1 - if (base.mouseWatcher.node().hasMouse()): - self.mouseX = base.mouseWatcher.node().getMouseX() - self.mouseY = base.mouseWatcher.node().getMouseY() + if (base.mouseWatcherNode.hasMouse()): + self.mouseX = base.mouseWatcherNode.getMouseX() + self.mouseY = base.mouseWatcherNode.getMouseY() # Delta percent of window the mouse moved self.mouseDeltaX = self.mouseX - self.mouseLastX self.mouseDeltaY = self.mouseY - self.mouseLastY diff --git a/direct/src/ffi/FFIExternalObject.py b/direct/src/ffi/FFIExternalObject.py index 5ec311ab57..7e9f8f3eeb 100644 --- a/direct/src/ffi/FFIExternalObject.py +++ b/direct/src/ffi/FFIExternalObject.py @@ -84,7 +84,6 @@ class FFIExternalObject: fromClass = lineage[top - i] downcastFuncName = ('downcastTo' + toClass.__name__ + 'From' + fromClass.__name__) - print downcastFuncName # Look over this classes global modules dictionaries # for the downcast function name for globmod in toClass.__CModuleDowncasts__: @@ -99,7 +98,12 @@ class FFIExternalObject: def setPointer(self): # See what type it really is and downcast to that type (if necessary) # Look up the TypeHandle in the dict. get() returns None if it is not there - exactWrapperClass = WrapperClassMap.get(self.getType().getIndex()) + try: + index = self.getTypeIndex() + except: + # Remove this after everybody builds their panda + index = self.getType().getIndex() + exactWrapperClass = WrapperClassMap.get(index) # We do not need to downcast if we already have the same class if (exactWrapperClass and (exactWrapperClass != self.__class__)): # Create a new wrapper class instance diff --git a/direct/src/gui/OnscreenPanel.py b/direct/src/gui/OnscreenPanel.py index bf14a216e0..5d03999909 100644 --- a/direct/src/gui/OnscreenPanel.py +++ b/direct/src/gui/OnscreenPanel.py @@ -221,7 +221,7 @@ class OnscreenPanel(PandaObject.PandaObject, NodePath): button.func, [button.button]) button.startBehavior() - base.mouseWatcher.node().addRegion(self.panelRegion) + base.mouseWatcherNode.addRegion(self.panelRegion) def hide(self): """hide(self): @@ -241,7 +241,7 @@ class OnscreenPanel(PandaObject.PandaObject, NodePath): if button.panelManage: button.unmanage() - base.mouseWatcher.node().removeRegion(self.panelRegion) + base.mouseWatcherNode.removeRegion(self.panelRegion) def makeButton(self, name, func = None, diff --git a/direct/src/showbase/EventManager.py b/direct/src/showbase/EventManager.py index 6457b0acb1..a863b74427 100644 --- a/direct/src/showbase/EventManager.py +++ b/direct/src/showbase/EventManager.py @@ -12,13 +12,10 @@ class EventManager: """ Create a C++ event queue and handler """ - # Make a notify category for this class (unless there already is one) if (EventManager.notify == None): EventManager.notify = directNotify.newCategory("EventManager") - # EventManager.notify.setDebug(1) - self.eventQueue = EventQueue.getGlobalEventQueue() self.eventHandler = EventHandler(self.eventQueue) @@ -27,8 +24,7 @@ class EventManager: Process all the events on the C++ event queue """ while (not self.eventQueue.isQueueEmpty()): - event = self.eventQueue.dequeueEvent() - self.processEvent(event) + self.processEvent(self.eventQueue.dequeueEvent()) return Task.cont def parseEventParameter(self, eventParameter): @@ -46,36 +42,28 @@ class EventManager: else: return eventParameter.getPtr() - - def processEvent(self, event): """ Process a C++ event """ - # If the event has a name, throw a Python event with the Pythonified name - if event.hasName(): - # Get the event name - eventName = event.getName() - numParameters = event.getNumParameters() + # Get the event name + eventName = event.getName() + if eventName: paramList = [] - for i in range(numParameters): + for i in range(event.getNumParameters()): eventParameter = event.getParameter(i) eventParameterData = self.parseEventParameter(eventParameter) paramList.append(eventParameterData) - # Do not print the new frame debug, it is too noisy! if (eventName != 'NewFrame'): EventManager.notify.debug('received C++ event named: ' + eventName + ' parameters: ' + `paramList`) - - # Send the event, we used to send it with the event # name as a parameter, but now you can use extraArgs for that if paramList: messenger.send(eventName, paramList) else: messenger.send(eventName) - # Also send the event down into C++ land self.eventHandler.dispatchEvent(event) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 6904845f1c..949c725203 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -85,7 +85,9 @@ class ShowBase: self.camList.append( camera.find('**/+Camera') ) # Set the default camera self.cam = self.camera.find('**/+Camera') - + # If you need to use the camera node, use camNode instead + # of calling cam.node() to save the FFI overhead + self.camNode = self.cam.node() # Set up a 2-d layer for drawing things behind Gui labels. self.render2d = NodePath(setupPanda2d(self.win, "render2d")) @@ -128,7 +130,8 @@ class ShowBase: # mouseWatcher, while objects that want events in all cases, like the # chat interface, should be parented to mak. self.mak = self.dataRoot.attachNewNode(MouseAndKeyboard(self.win, 0, 'mak')) - self.mouseWatcher = self.mak.attachNewNode(MouseWatcher('mouseWatcher')) + self.mouseWatcherNode = MouseWatcher('mouseWatcher') + self.mouseWatcher = self.mak.attachNewNode(self.mouseWatcherNode) # We also create a DataValve object above the trackball/drive # interface, which will allow us to switch some of the mouse