Browse Source

*** empty log message ***

Joe Shochet 24 years ago
parent
commit
e134c8bb13

+ 3 - 3
direct/src/directtools/DirectSession.py

@@ -698,9 +698,9 @@ class DisplayRegionContext:
         self.mouseLastY = self.mouseY
         self.mouseLastY = self.mouseY
         # Values for this frame
         # Values for this frame
         # This ranges from -1 to 1
         # 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
         # Delta percent of window the mouse moved
         self.mouseDeltaX = self.mouseX - self.mouseLastX
         self.mouseDeltaX = self.mouseX - self.mouseLastX
         self.mouseDeltaY = self.mouseY - self.mouseLastY
         self.mouseDeltaY = self.mouseY - self.mouseLastY

+ 6 - 2
direct/src/ffi/FFIExternalObject.py

@@ -84,7 +84,6 @@ class FFIExternalObject:
             fromClass = lineage[top - i]
             fromClass = lineage[top - i]
             downcastFuncName = ('downcastTo' + toClass.__name__
             downcastFuncName = ('downcastTo' + toClass.__name__
                                 + 'From' + fromClass.__name__)
                                 + 'From' + fromClass.__name__)
-            print downcastFuncName
             # Look over this classes global modules dictionaries
             # Look over this classes global modules dictionaries
             # for the downcast function name
             # for the downcast function name
             for globmod in toClass.__CModuleDowncasts__:
             for globmod in toClass.__CModuleDowncasts__:
@@ -99,7 +98,12 @@ class FFIExternalObject:
     def setPointer(self):
     def setPointer(self):
         # See what type it really is and downcast to that type (if necessary)
         # 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
         # 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
         # We do not need to downcast if we already have the same class
         if (exactWrapperClass and (exactWrapperClass != self.__class__)):
         if (exactWrapperClass and (exactWrapperClass != self.__class__)):
             # Create a new wrapper class instance
             # Create a new wrapper class instance

+ 2 - 2
direct/src/gui/OnscreenPanel.py

@@ -221,7 +221,7 @@ class OnscreenPanel(PandaObject.PandaObject, NodePath):
                                 button.func, [button.button])
                                 button.func, [button.button])
                 button.startBehavior()
                 button.startBehavior()
                 
                 
-        base.mouseWatcher.node().addRegion(self.panelRegion)
+        base.mouseWatcherNode.addRegion(self.panelRegion)
         
         
     def hide(self):
     def hide(self):
         """hide(self):
         """hide(self):
@@ -241,7 +241,7 @@ class OnscreenPanel(PandaObject.PandaObject, NodePath):
             if button.panelManage:
             if button.panelManage:
                 button.unmanage()
                 button.unmanage()
                 
                 
-        base.mouseWatcher.node().removeRegion(self.panelRegion)
+        base.mouseWatcherNode.removeRegion(self.panelRegion)
 
 
     def makeButton(self, name,
     def makeButton(self, name,
                    func = None,
                    func = None,

+ 5 - 17
direct/src/showbase/EventManager.py

@@ -12,13 +12,10 @@ class EventManager:
         """
         """
         Create a C++ event queue and handler
         Create a C++ event queue and handler
         """
         """
-
         # Make a notify category for this class (unless there already is one)
         # Make a notify category for this class (unless there already is one)
         if (EventManager.notify == None):
         if (EventManager.notify == None):
             EventManager.notify = directNotify.newCategory("EventManager")
             EventManager.notify = directNotify.newCategory("EventManager")
 
 
-        # EventManager.notify.setDebug(1)
-
         self.eventQueue = EventQueue.getGlobalEventQueue()
         self.eventQueue = EventQueue.getGlobalEventQueue()
         self.eventHandler = EventHandler(self.eventQueue)
         self.eventHandler = EventHandler(self.eventQueue)
 
 
@@ -27,8 +24,7 @@ class EventManager:
         Process all the events on the C++ event queue
         Process all the events on the C++ event queue
         """
         """
         while (not self.eventQueue.isQueueEmpty()):
         while (not self.eventQueue.isQueueEmpty()):
-            event = self.eventQueue.dequeueEvent()
-            self.processEvent(event)
+            self.processEvent(self.eventQueue.dequeueEvent())
         return Task.cont
         return Task.cont
 
 
     def parseEventParameter(self, eventParameter):
     def parseEventParameter(self, eventParameter):
@@ -46,36 +42,28 @@ class EventManager:
         else:
         else:
             return eventParameter.getPtr()
             return eventParameter.getPtr()
         
         
-            
-
     def processEvent(self, event):
     def processEvent(self, event):
         """
         """
         Process a C++ 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 = []
             paramList = []
-            for i in range(numParameters):
+            for i in range(event.getNumParameters()):
                 eventParameter = event.getParameter(i)
                 eventParameter = event.getParameter(i)
                 eventParameterData = self.parseEventParameter(eventParameter)
                 eventParameterData = self.parseEventParameter(eventParameter)
                 paramList.append(eventParameterData)
                 paramList.append(eventParameterData)
-
             # Do not print the new frame debug, it is too noisy!
             # Do not print the new frame debug, it is too noisy!
             if (eventName != 'NewFrame'):
             if (eventName != 'NewFrame'):
                 EventManager.notify.debug('received C++ event named: ' + eventName +
                 EventManager.notify.debug('received C++ event named: ' + eventName +
                                           ' parameters: ' + `paramList`)
                                           ' parameters: ' + `paramList`)
-
-
             # Send the event, we used to send it with the event 
             # Send the event, we used to send it with the event 
             # name as a parameter, but now you can use extraArgs for that
             # name as a parameter, but now you can use extraArgs for that
             if paramList:
             if paramList:
                 messenger.send(eventName, paramList)
                 messenger.send(eventName, paramList)
             else:
             else:
                 messenger.send(eventName)
                 messenger.send(eventName)
-
             # Also send the event down into C++ land
             # Also send the event down into C++ land
             self.eventHandler.dispatchEvent(event)
             self.eventHandler.dispatchEvent(event)
             
             

+ 5 - 2
direct/src/showbase/ShowBase.py

@@ -85,7 +85,9 @@ class ShowBase:
             self.camList.append( camera.find('**/+Camera') )
             self.camList.append( camera.find('**/+Camera') )
         # Set the default camera
         # Set the default camera
         self.cam = self.camera.find('**/+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.
         # Set up a 2-d layer for drawing things behind Gui labels.
         self.render2d = NodePath(setupPanda2d(self.win, "render2d"))
         self.render2d = NodePath(setupPanda2d(self.win, "render2d"))
 
 
@@ -128,7 +130,8 @@ class ShowBase:
         # mouseWatcher, while objects that want events in all cases, like the
         # mouseWatcher, while objects that want events in all cases, like the
         # chat interface, should be parented to mak.
         # chat interface, should be parented to mak.
         self.mak = self.dataRoot.attachNewNode(MouseAndKeyboard(self.win, 0, '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
         # We also create a DataValve object above the trackball/drive
         # interface, which will allow us to switch some of the mouse
         # interface, which will allow us to switch some of the mouse