Browse Source

Fix various import issues in the direct tree

rdb 10 years ago
parent
commit
32367fcbdc
37 changed files with 96 additions and 376 deletions
  1. 1 1
      direct/src/controls/ControlManager.py
  2. 5 4
      direct/src/controls/DevWalker.py
  3. 0 2
      direct/src/controls/GhostWalker.py
  4. 1 1
      direct/src/controls/NonPhysicsWalker.py
  5. 1 2
      direct/src/controls/ObserverWalker.py
  6. 6 4
      direct/src/controls/TwoDWalker.py
  7. 1 1
      direct/src/directdevices/DirectDeviceManager.py
  8. 4 1
      direct/src/directtools/DirectLights.py
  9. 4 1
      direct/src/directtools/DirectSession.py
  10. 9 8
      direct/src/distributed/AsyncRequest.py
  11. 1 1
      direct/src/distributed/CRCache.py
  12. 3 1
      direct/src/distributed/CRDataCache.py
  13. 1 1
      direct/src/distributed/ClientRepository.py
  14. 2 2
      direct/src/distributed/ConnectionRepository.py
  15. 2 1
      direct/src/distributed/DistributedCartesianGrid.py
  16. 1 1
      direct/src/distributed/DistributedCartesianGridAI.py
  17. 1 2
      direct/src/distributed/DistributedNode.py
  18. 1 1
      direct/src/distributed/DistributedNodeUD.py
  19. 1 1
      direct/src/distributed/DistributedObjectBase.py
  20. 1 6
      direct/src/distributed/DoInterestManager.py
  21. 6 6
      direct/src/distributed/TimeManager.py
  22. 0 37
      direct/src/fsm/StatePush.py
  23. 4 3
      direct/src/gui/DirectGuiTest.py
  24. 5 4
      direct/src/leveleditor/LevelEditorStart.py
  25. 1 1
      direct/src/particles/ParticleTest.py
  26. 5 3
      direct/src/physics/FallTest.py
  27. 5 3
      direct/src/physics/RotationTest.py
  28. 1 0
      direct/src/showbase/DistancePhasedNode.py
  29. 0 66
      direct/src/showbase/ExcelHandler.py
  30. 0 201
      direct/src/showbase/LazySort.py
  31. 1 1
      direct/src/showbase/PythonUtil.py
  32. 1 0
      direct/src/showbase/ShowBase.py
  33. 5 3
      direct/src/showbase/ThreeUpShow.py
  34. 1 1
      direct/src/task/TaskTester.py
  35. 3 2
      direct/src/tkpanels/ParticlePanel.py
  36. 4 1
      direct/src/tkwidgets/MemoryExplorer.py
  37. 8 2
      direct/src/tkwidgets/SceneGraphExplorer.py

+ 1 - 1
direct/src/controls/ControlManager.py

@@ -19,7 +19,7 @@ CollisionHandlerRayStart = 4000.0 # This is a hack, it may be better to use a li
 
 
 class ControlManager:
 class ControlManager:
     notify = DirectNotifyGlobal.directNotify.newCategory("ControlManager")
     notify = DirectNotifyGlobal.directNotify.newCategory("ControlManager")
-    wantWASD = ConfigVariableBool('want-WASD', True)
+    wantWASD = ConfigVariableBool('want-WASD', False)
 
 
     def __init__(self, enable=True, passMessagesThrough = False):
     def __init__(self, enable=True, passMessagesThrough = False):
         assert self.notify.debug("init control manager %s" % (passMessagesThrough))
         assert self.notify.debug("init control manager %s" % (passMessagesThrough))

+ 5 - 4
direct/src/controls/DevWalker.py

@@ -18,13 +18,14 @@ from direct.showbase.InputStateGlobal import inputState
 from direct.directnotify import DirectNotifyGlobal
 from direct.directnotify import DirectNotifyGlobal
 from direct.showbase import DirectObject
 from direct.showbase import DirectObject
 from direct.task.Task import Task
 from direct.task.Task import Task
-from pandac.PandaModules import *
+from panda3d.core import *
+
 
 
 class DevWalker(DirectObject.DirectObject):
 class DevWalker(DirectObject.DirectObject):
 
 
     notify = DirectNotifyGlobal.directNotify.newCategory("DevWalker")
     notify = DirectNotifyGlobal.directNotify.newCategory("DevWalker")
-    wantDebugIndicator = base.config.GetBool('want-avatar-physics-indicator', 0)
-    runMultiplier = base.config.GetFloat('dev-run-multiplier', 4.0)
+    wantDebugIndicator = ConfigVariableBool('want-avatar-physics-indicator', False)
+    runMultiplier = ConfigVariableDouble('dev-run-multiplier', 4.0)
 
 
     # Ghost mode overrides this:
     # Ghost mode overrides this:
     slideName = "slide-is-disabled"
     slideName = "slide-is-disabled"
@@ -109,7 +110,7 @@ class DevWalker(DirectObject.DirectObject):
         slideRight = inputState.isSet("slideRight")
         slideRight = inputState.isSet("slideRight")
         levitateUp = inputState.isSet("levitateUp")
         levitateUp = inputState.isSet("levitateUp")
         levitateDown = inputState.isSet("levitateDown")
         levitateDown = inputState.isSet("levitateDown")
-        run = inputState.isSet("run") and self.runMultiplier or 1.0
+        run = inputState.isSet("run") and self.runMultiplier.getValue() or 1.0
 
 
         # Check for Auto-Run
         # Check for Auto-Run
         if base.localAvatar.getAutoRun():
         if base.localAvatar.getAutoRun():

+ 0 - 2
direct/src/controls/GhostWalker.py

@@ -14,8 +14,6 @@ although it does send messeges that allow a listener to play sounds or
 animations based on walker events.
 animations based on walker events.
 """
 """
 
 
-from direct.showbase.ShowBaseGlobal import *
-
 from direct.directnotify import DirectNotifyGlobal
 from direct.directnotify import DirectNotifyGlobal
 import NonPhysicsWalker
 import NonPhysicsWalker
 
 

+ 1 - 1
direct/src/controls/NonPhysicsWalker.py

@@ -23,7 +23,7 @@ from pandac.PandaModules import *
 
 
 class NonPhysicsWalker(DirectObject.DirectObject):
 class NonPhysicsWalker(DirectObject.DirectObject):
     notify = DirectNotifyGlobal.directNotify.newCategory("NonPhysicsWalker")
     notify = DirectNotifyGlobal.directNotify.newCategory("NonPhysicsWalker")
-    wantDebugIndicator = base.config.GetBool('want-avatar-physics-indicator', 0)
+    wantDebugIndicator = ConfigVariableBool('want-avatar-physics-indicator', False)
 
 
     # Ghost mode overrides this:
     # Ghost mode overrides this:
     slideName = "slide-is-disabled"
     slideName = "slide-is-disabled"

+ 1 - 2
direct/src/controls/ObserverWalker.py

@@ -14,8 +14,7 @@ although it does send messeges that allow a listener to play sounds or
 animations based on walker events.
 animations based on walker events.
 """
 """
 
 
-from direct.showbase.ShowBaseGlobal import *
-from pandac.PandaModules import *
+from panda3d.core import *
 from direct.directnotify import DirectNotifyGlobal
 from direct.directnotify import DirectNotifyGlobal
 import NonPhysicsWalker
 import NonPhysicsWalker
 
 

+ 6 - 4
direct/src/controls/TwoDWalker.py

@@ -3,6 +3,8 @@ TwoDWalker.py is for controling the avatars in a 2D Scroller game environment.
 """
 """
 
 
 from GravityWalker import *
 from GravityWalker import *
+from panda3d.core import ConfigVariableBool
+
 
 
 class TwoDWalker(GravityWalker):
 class TwoDWalker(GravityWalker):
     """
     """
@@ -14,9 +16,9 @@ class TwoDWalker(GravityWalker):
     customizable input list.
     customizable input list.
     """
     """
     notify = directNotify.newCategory("TwoDWalker")
     notify = directNotify.newCategory("TwoDWalker")
-    wantDebugIndicator = base.config.GetBool('want-avatar-physics-indicator', 0)
-    wantFloorSphere = base.config.GetBool('want-floor-sphere', 0)
-    earlyEventSphere = base.config.GetBool('early-event-sphere', 0)
+    wantDebugIndicator = ConfigVariableBool('want-avatar-physics-indicator', False)
+    wantFloorSphere = ConfigVariableBool('want-floor-sphere', False)
+    earlyEventSphere = ConfigVariableBool('early-event-sphere', False)
 
 
     # special methods
     # special methods
     def __init__(self, gravity = -32.1740, standableGround=0.707,
     def __init__(self, gravity = -32.1740, standableGround=0.707,
@@ -55,4 +57,4 @@ class TwoDWalker(GravityWalker):
                     self.lifter.addVelocity(self.avatarControlJumpForce)
                     self.lifter.addVelocity(self.avatarControlJumpForce)
                     messenger.send("jumpStart")
                     messenger.send("jumpStart")
                     self.isAirborne = 1
                     self.isAirborne = 1
-                    assert self.debugPrint("isAirborne 1 due to jump")
+                    assert self.debugPrint("isAirborne 1 due to jump")

+ 1 - 1
direct/src/directdevices/DirectDeviceManager.py

@@ -23,7 +23,7 @@ class DirectDeviceManager(VrpnClient, DirectObject):
             self.server = server
             self.server = server
         else:
         else:
             # Check config file, if that fails, use default
             # Check config file, if that fails, use default
-            self.server = myBase.config.GetString('vrpn-server', 'spacedyne')
+            self.server = ConfigVariableString('vrpn-server', 'spacedyne').getValue()
 
 
         # Create a vrpn client
         # Create a vrpn client
         VrpnClient.__init__(self, self.server)
         VrpnClient.__init__(self, self.server)

+ 4 - 1
direct/src/directtools/DirectLights.py

@@ -18,7 +18,10 @@ class DirectLight(NodePath):
         return self.light
         return self.light
 
 
 class DirectLights(NodePath):
 class DirectLights(NodePath):
-    def __init__(self, parent = render):
+    def __init__(self, parent = None):
+        if parent is None:
+            parent = base.render
+
         # Initialize the superclass
         # Initialize the superclass
         NodePath.__init__(self)
         NodePath.__init__(self)
         # Create a node for the lights
         # Create a node for the lights

+ 4 - 1
direct/src/directtools/DirectSession.py

@@ -907,8 +907,11 @@ class DirectSession(DirectObject):
     def removeAllSelected(self):
     def removeAllSelected(self):
         self.selected.removeAll()
         self.selected.removeAll()
 
 
-    def showAllDescendants(self, nodePath = render):
+    def showAllDescendants(self, nodePath = None):
         """ Show the level and its descendants """
         """ Show the level and its descendants """
+        if nodePath is None:
+            nodePath = base.render
+
         if not isinstance(nodePath, CollisionNode):
         if not isinstance(nodePath, CollisionNode):
             nodePath.show()
             nodePath.show()
 
 

+ 9 - 8
direct/src/distributed/AsyncRequest.py

@@ -1,16 +1,17 @@
-from otp.ai.AIBaseGlobal import *
+#from otp.ai.AIBaseGlobal import *
 from direct.directnotify import DirectNotifyGlobal
 from direct.directnotify import DirectNotifyGlobal
 from direct.showbase.DirectObject import DirectObject
 from direct.showbase.DirectObject import DirectObject
 from ConnectionRepository import *
 from ConnectionRepository import *
+from panda3d.core import ConfigVariableDouble, ConfigVariableInt, ConfigVariableBool
 
 
 ASYNC_REQUEST_DEFAULT_TIMEOUT_IN_SECONDS = 8.0
 ASYNC_REQUEST_DEFAULT_TIMEOUT_IN_SECONDS = 8.0
 ASYNC_REQUEST_INFINITE_RETRIES = -1
 ASYNC_REQUEST_INFINITE_RETRIES = -1
 ASYNC_REQUEST_DEFAULT_NUM_RETRIES = 0
 ASYNC_REQUEST_DEFAULT_NUM_RETRIES = 0
 
 
 if __debug__:
 if __debug__:
-    _overrideTimeoutTimeForAllAsyncRequests = config.GetFloat("async-request-timeout", -1.0)
-    _overrideNumRetriesForAllAsyncRequests = config.GetInt("async-request-num-retries", -1)
-    _breakOnTimeout = config.GetBool("async-request-break-on-timeout", False)
+    _overrideTimeoutTimeForAllAsyncRequests = ConfigVariableDouble("async-request-timeout", -1.0)
+    _overrideNumRetriesForAllAsyncRequests = ConfigVariableInt("async-request-num-retries", -1)
+    _breakOnTimeout = ConfigVariableBool("async-request-break-on-timeout", False)
 
 
 class AsyncRequest(DirectObject):
 class AsyncRequest(DirectObject):
     """
     """
@@ -51,10 +52,10 @@ class AsyncRequest(DirectObject):
         """
         """
         assert AsyncRequest.notify.debugCall()
         assert AsyncRequest.notify.debugCall()
         if __debug__:
         if __debug__:
-            if _overrideTimeoutTimeForAllAsyncRequests >= 0.0:
-                timeoutTime = _overrideTimeoutTimeForAllAsyncRequests
-            if _overrideNumRetriesForAllAsyncRequests >= 0:
-                numRetries = _overrideNumRetriesForAllAsyncRequests
+            if _overrideTimeoutTimeForAllAsyncRequests.getValue() >= 0.0:
+                timeoutTime = _overrideTimeoutTimeForAllAsyncRequests.getValue()
+            if _overrideNumRetriesForAllAsyncRequests.getValue() >= 0:
+                numRetries = _overrideNumRetriesForAllAsyncRequests.getValue()
         AsyncRequest._asyncRequests[id(self)] = self
         AsyncRequest._asyncRequests[id(self)] = self
         self.deletingMessage = "AsyncRequest-deleting-%s"%(id(self,))
         self.deletingMessage = "AsyncRequest-deleting-%s"%(id(self,))
         self.air = air
         self.air = air

+ 1 - 1
direct/src/distributed/CRCache.py

@@ -122,7 +122,7 @@ class CRCache:
     def checkCache(self):
     def checkCache(self):
         # For debugging; this verifies that the cache is sensible and
         # For debugging; this verifies that the cache is sensible and
         # returns true if so.
         # returns true if so.
-        from pandac.PandaModules import NodePath
+        from panda3d.core import NodePath
         for obj in self.dict.values():
         for obj in self.dict.values():
             if isinstance(obj, NodePath):
             if isinstance(obj, NodePath):
                 assert not obj.isEmpty() and obj.getTopNode() != render.node()
                 assert not obj.isEmpty() and obj.getTopNode() != render.node()

+ 3 - 1
direct/src/distributed/CRDataCache.py

@@ -1,4 +1,6 @@
 from direct.distributed.CachedDOData import CachedDOData
 from direct.distributed.CachedDOData import CachedDOData
+from panda3d.core import ConfigVariableInt
+
 
 
 class CRDataCache:
 class CRDataCache:
     # Stores cached data for DistributedObjects between instantiations on the client
     # Stores cached data for DistributedObjects between instantiations on the client
@@ -6,7 +8,7 @@ class CRDataCache:
     def __init__(self):
     def __init__(self):
         self._doId2name2data = {}
         self._doId2name2data = {}
         # maximum # of objects we will cache data for
         # maximum # of objects we will cache data for
-        self._size = config.GetInt('crdatacache-size', 10)
+        self._size = ConfigVariableInt('crdatacache-size', 10).getValue()
         assert self._size > 0
         assert self._size > 0
         # used to preserve the cache size
         # used to preserve the cache size
         self._junkIndex = 0
         self._junkIndex = 0

+ 1 - 1
direct/src/distributed/ClientRepository.py

@@ -5,7 +5,7 @@ from direct.directnotify import DirectNotifyGlobal
 from MsgTypesCMU import *
 from MsgTypesCMU import *
 from PyDatagram import PyDatagram
 from PyDatagram import PyDatagram
 from PyDatagramIterator import PyDatagramIterator
 from PyDatagramIterator import PyDatagramIterator
-from pandac.PandaModules import UniqueIdAllocator
+from panda3d.core import UniqueIdAllocator
 import types
 import types
 
 
 class ClientRepository(ClientRepositoryBase):
 class ClientRepository(ClientRepositoryBase):

+ 2 - 2
direct/src/distributed/ConnectionRepository.py

@@ -1,6 +1,6 @@
 from pandac.PandaModules import *
 from pandac.PandaModules import *
 from direct.task import Task
 from direct.task import Task
-from direct.directnotify import DirectNotifyGlobal
+from direct.directnotify.DirectNotifyGlobal import directNotify
 from direct.distributed.DoInterestManager import DoInterestManager
 from direct.distributed.DoInterestManager import DoInterestManager
 from direct.distributed.DoCollectionManager import DoCollectionManager
 from direct.distributed.DoCollectionManager import DoCollectionManager
 from direct.showbase import GarbageReport
 from direct.showbase import GarbageReport
@@ -20,7 +20,7 @@ class ConnectionRepository(
     connection (and exchange datagrams) with a gameserver.  This
     connection (and exchange datagrams) with a gameserver.  This
     includes ClientRepository and AIRepository.
     includes ClientRepository and AIRepository.
     """
     """
-    notify = DirectNotifyGlobal.directNotify.newCategory("ConnectionRepository")
+    notify = directNotify.newCategory("ConnectionRepository")
     taskPriority = -30
     taskPriority = -30
     taskChain = None
     taskChain = None
 
 

+ 2 - 1
direct/src/distributed/DistributedCartesianGrid.py

@@ -1,6 +1,7 @@
 
 
 from pandac.PandaModules import *
 from pandac.PandaModules import *
 from direct.interval.IntervalGlobal import *
 from direct.interval.IntervalGlobal import *
+from direct.directnotify.DirectNotifyGlobal import directNotify
 
 
 from direct.distributed.DistributedNode import DistributedNode
 from direct.distributed.DistributedNode import DistributedNode
 from direct.task import Task
 from direct.task import Task
@@ -24,7 +25,7 @@ class DistributedCartesianGrid(DistributedNode, CartesianGridBase):
     notify = directNotify.newCategory("DistributedCartesianGrid")
     notify = directNotify.newCategory("DistributedCartesianGrid")
     notify.setDebug(0)
     notify.setDebug(0)
     
     
-    VisualizeGrid = config.GetBool("visualize-cartesian-grid", 0)
+    VisualizeGrid = ConfigVariableBool("visualize-cartesian-grid", False)
 
 
     RuleSeparator = ":"
     RuleSeparator = ":"
 
 

+ 1 - 1
direct/src/distributed/DistributedCartesianGridAI.py

@@ -1,6 +1,6 @@
 
 
 from pandac.PandaModules import *
 from pandac.PandaModules import *
-
+from direct.directnotify.DirectNotifyGlobal import directNotify
 from direct.task import Task
 from direct.task import Task
 from DistributedNodeAI import DistributedNodeAI
 from DistributedNodeAI import DistributedNodeAI
 from CartesianGridBase import CartesianGridBase
 from CartesianGridBase import CartesianGridBase

+ 1 - 2
direct/src/distributed/DistributedNode.py

@@ -1,7 +1,6 @@
 """DistributedNode module: contains the DistributedNode class"""
 """DistributedNode module: contains the DistributedNode class"""
 
 
-from pandac.PandaModules import NodePath
-from direct.showbase.ShowBaseGlobal import *
+from panda3d.core import NodePath
 from direct.task import Task
 from direct.task import Task
 import GridParent
 import GridParent
 import DistributedObject
 import DistributedObject

+ 1 - 1
direct/src/distributed/DistributedNodeUD.py

@@ -1,4 +1,4 @@
-from otp.ai.AIBaseGlobal import *
+#from otp.ai.AIBaseGlobal import *
 from DistributedObjectUD import DistributedObjectUD
 from DistributedObjectUD import DistributedObjectUD
 
 
 class DistributedNodeUD(DistributedObjectUD):
 class DistributedNodeUD(DistributedObjectUD):

+ 1 - 1
direct/src/distributed/DistributedObjectBase.py

@@ -1,6 +1,6 @@
 
 
 from direct.showbase.DirectObject import DirectObject
 from direct.showbase.DirectObject import DirectObject
-#from direct.directnotify.DirectNotifyGlobal import directNotify
+from direct.directnotify.DirectNotifyGlobal import directNotify
 
 
 class DistributedObjectBase(DirectObject):
 class DistributedObjectBase(DirectObject):
     """
     """

+ 1 - 6
direct/src/distributed/DoInterestManager.py

@@ -78,12 +78,7 @@ class DoInterestManager(DirectObject.DirectObject):
     Top level Interest Manager
     Top level Interest Manager
     """
     """
     notify = directNotify.newCategory("DoInterestManager")
     notify = directNotify.newCategory("DoInterestManager")
-    try:
-        tempbase = base
-    except:
-        tempbase = simbase
-    InterestDebug = tempbase.config.GetBool('interest-debug', False)
-    del tempbase
+    InterestDebug = ConfigVariableBool('interest-debug', False)
 
 
     # 'handle' is a number that represents a single interest set that the
     # 'handle' is a number that represents a single interest set that the
     # client has requested; the interest set may be modified
     # client has requested; the interest set may be modified

+ 6 - 6
direct/src/distributed/TimeManager.py

@@ -21,29 +21,29 @@ class TimeManager(DistributedObject.DistributedObject):
     # The number of seconds to wait between automatic
     # The number of seconds to wait between automatic
     # synchronizations.  Set to 0 to disable auto sync after
     # synchronizations.  Set to 0 to disable auto sync after
     # startup.
     # startup.
-    updateFreq = base.config.GetFloat('time-manager-freq', 1800)
+    updateFreq = ConfigVariableDouble('time-manager-freq', 1800).getValue()
 
 
     # The minimum number of seconds to wait between two unrelated
     # The minimum number of seconds to wait between two unrelated
     # synchronization attempts.  Increasing this number cuts down
     # synchronization attempts.  Increasing this number cuts down
     # on frivolous synchronizations.
     # on frivolous synchronizations.
-    minWait = base.config.GetFloat('time-manager-min-wait', 10)
+    minWait = ConfigVariableDouble('time-manager-min-wait', 10).getValue()
 
 
     # The maximum number of seconds of uncertainty to tolerate in
     # The maximum number of seconds of uncertainty to tolerate in
     # the clock delta without trying again.
     # the clock delta without trying again.
-    maxUncertainty = base.config.GetFloat('time-manager-max-uncertainty', 1)
+    maxUncertainty = ConfigVariableDouble('time-manager-max-uncertainty', 1).getValue()
 
 
     # The maximum number of attempts to try to get a low-latency
     # The maximum number of attempts to try to get a low-latency
     # time measurement before giving up and accepting whatever we
     # time measurement before giving up and accepting whatever we
     # get.
     # get.
-    maxAttempts = base.config.GetInt('time-manager-max-attempts', 5)
+    maxAttempts = ConfigVariableInt('time-manager-max-attempts', 5).getValue()
 
 
     # A simulated clock skew for debugging, in seconds.
     # A simulated clock skew for debugging, in seconds.
-    extraSkew = base.config.GetInt('time-manager-extra-skew', 0)
+    extraSkew = ConfigVariableInt('time-manager-extra-skew', 0).getValue()
 
 
     if extraSkew != 0:
     if extraSkew != 0:
         notify.info("Simulating clock skew of %0.3f s" % extraSkew)
         notify.info("Simulating clock skew of %0.3f s" % extraSkew)
 
 
-    reportFrameRateInterval = base.config.GetDouble('report-frame-rate-interval', 300.0)
+    reportFrameRateInterval = ConfigVariableDouble('report-frame-rate-interval', 300.0).getValue()
 
 
     def __init__(self, cr):
     def __init__(self, cr):
         DistributedObject.DistributedObject.__init__(self, cr)
         DistributedObject.DistributedObject.__init__(self, cr)

+ 0 - 37
direct/src/fsm/StatePush.py

@@ -382,24 +382,6 @@ class EventPulse(Pulse, DirectObject):
         self.ignoreAll()
         self.ignoreAll()
         Pulse.destroy(self)
         Pulse.destroy(self)
 
 
-if __debug__:
-    l = []
-    def handler(value, l=l):
-        l.append(value)
-    ep = EventPulse('testEvent')
-    fc = FunctionCall(handler, ep)
-    assert l == []
-    messenger.send('testEvent')
-    assert l == [True, False, ]
-    messenger.send('testEvent')
-    assert l == [True, False, True, False, ]
-    fc.destroy()
-    ep.destroy()
-    del fc
-    del ep
-    del l
-    del handler
-    
 class EventArgument(PushesStateChanges, DirectObject):
 class EventArgument(PushesStateChanges, DirectObject):
     # tracks a particular argument to a particular messenger event
     # tracks a particular argument to a particular messenger event
     def __init__(self, event, index=0):
     def __init__(self, event, index=0):
@@ -415,25 +397,6 @@ class EventArgument(PushesStateChanges, DirectObject):
     def _handleEvent(self, *args):
     def _handleEvent(self, *args):
         self._handlePotentialStateChange(args[self._index])
         self._handlePotentialStateChange(args[self._index])
 
 
-if __debug__:
-    l = []
-    def handler(value, l=l):
-        l.append(value)
-    ea = EventArgument('testEvent', index=1)
-    fc = FunctionCall(handler, ea)
-    assert l == []
-    fc.pushCurrentState()
-    assert l == [None, ]
-    messenger.send('testEvent', ['a', 'b'])
-    assert l == [None, 'b', ]
-    messenger.send('testEvent', [1, 2, 3, ])
-    assert l == [None, 'b', 2, ]
-    fc.destroy()
-    ea.destroy()
-    del fc
-    del ea
-    del l
-
 class AttrSetter(StateChangeNode):
 class AttrSetter(StateChangeNode):
     def __init__(self, source, object, attrName):
     def __init__(self, source, object, attrName):
         self._object = object
         self._object = object

+ 4 - 3
direct/src/gui/DirectGuiTest.py

@@ -5,6 +5,7 @@ __all__ = []
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     from direct.showbase.ShowBase import ShowBase
     from direct.showbase.ShowBase import ShowBase
+    import DirectGuiGlobals
     from DirectGui import *
     from DirectGui import *
     #from whrandom import *
     #from whrandom import *
     from random import *
     from random import *
@@ -46,7 +47,7 @@ if __name__ == "__main__":
         db.component('geom0').setScale(db.component('geom2').getScale()[0])
         db.component('geom0').setScale(db.component('geom2').getScale()[0])
         db.component('geom1').setScale(db.component('geom2').getScale()[0])
         db.component('geom1').setScale(db.component('geom2').getScale()[0])
         db['text2_text'] = 'Ouch!'
         db['text2_text'] = 'Ouch!'
-        db['geom2_color'] = Vec4(1, 0, 0, 1)
+        db['geom2_color'] = (1, 0, 0, 1)
         newX = -1.0 + random() * 2.0
         newX = -1.0 + random() * 2.0
         newZ = -1.0 + random() * 2.0
         newZ = -1.0 + random() * 2.0
         db.lerpPos(Point3(newX, 0, newZ), 1.0, task = 'runAway',
         db.lerpPos(Point3(newX, 0, newZ), 1.0, task = 'runAway',
@@ -66,7 +67,7 @@ if __name__ == "__main__":
                           text = ('Hi!', 'Ouch!', 'Bye!', 'ZZZZ!'),
                           text = ('Hi!', 'Ouch!', 'Bye!', 'ZZZZ!'),
                           scale = .15, relief = 'raised',
                           scale = .15, relief = 'raised',
                           # Here we set an option for a component of the button
                           # Here we set an option for a component of the button
-                          geom1_color = Vec4(1, 0, 0, 1),
+                          geom1_color = (1, 0, 0, 1),
                           # Here is an example of a component group option
                           # Here is an example of a component group option
                           text_pos = (.6, -.8),
                           text_pos = (.6, -.8),
                           # Set audio characteristics
                           # Set audio characteristics
@@ -140,4 +141,4 @@ if __name__ == "__main__":
     print 'HEIGHT:', de1.getHeight()
     print 'HEIGHT:', de1.getHeight()
     print 'CENTER:', de1.getCenter()
     print 'CENTER:', de1.getCenter()
 
 
-    run()
+    base.run()

+ 5 - 4
direct/src/leveleditor/LevelEditorStart.py

@@ -1,7 +1,8 @@
 import LevelEditor
 import LevelEditor
 
 
-base.le = LevelEditor.LevelEditor()
-# You should define LevelEditor instance as
-# base.le so it can be reached in global scope
+if __name__ == '__main__':
+    base.le = LevelEditor.LevelEditor()
+    # You should define LevelEditor instance as
+    # base.le so it can be reached in global scope
 
 
-run()
+    base.run()

+ 1 - 1
direct/src/particles/ParticleTest.py

@@ -30,4 +30,4 @@ if __name__ == "__main__":
     # Particle Panel
     # Particle Panel
     pp = ParticlePanel.ParticlePanel(pe)
     pp = ParticlePanel.ParticlePanel(pe)
 
 
-    run()
+    base.run()

+ 5 - 3
direct/src/physics/FallTest.py

@@ -1,3 +1,5 @@
+from panda3d.core import NodePath
+from panda3d.physics import *
 
 
 class FallTest(NodePath):
 class FallTest(NodePath):
     def __init__(self):
     def __init__(self):
@@ -79,7 +81,7 @@ class FallTest(NodePath):
 if __name__ == "__main__":
 if __name__ == "__main__":
     from direct.directbase.ThreeUpStart import *
     from direct.directbase.ThreeUpStart import *
     test=FallTest()
     test=FallTest()
-    test.reparentTo(render)
+    test.reparentTo(base.render)
     test.setup()
     test.setup()
-    camera.setY(-10.0)
-    run()
+    base.camera.setY(-10.0)
+    base.run()

+ 5 - 3
direct/src/physics/RotationTest.py

@@ -1,3 +1,5 @@
+from panda3d.core import NodePath
+from panda3d.physics import *
 
 
 class RotationTest(NodePath):
 class RotationTest(NodePath):
     def __init__(self):
     def __init__(self):
@@ -89,7 +91,7 @@ class RotationTest(NodePath):
 if __name__ == "__main__":
 if __name__ == "__main__":
     from direct.directbase.ThreeUpStart import *
     from direct.directbase.ThreeUpStart import *
     test=RotationTest()
     test=RotationTest()
-    test.reparentTo(render)
+    test.reparentTo(base.render)
     test.setup()
     test.setup()
-    camera.setY(-10.0)
-    run()
+    base.camera.setY(-10.0)
+    base.run()

+ 1 - 0
direct/src/showbase/DistancePhasedNode.py

@@ -1,4 +1,5 @@
 from direct.showbase.DirectObject import DirectObject
 from direct.showbase.DirectObject import DirectObject
+from direct.directnotify.DirectNotifyGlobal import directNotify
 from panda3d.core import *
 from panda3d.core import *
 from PhasedObject import PhasedObject
 from PhasedObject import PhasedObject
 
 

+ 0 - 66
direct/src/showbase/ExcelHandler.py

@@ -1,66 +0,0 @@
-"""Undocumented Module"""
-
-__all__ = ['ExcelHandler']
-
-"""
-A simple XML parser for Excel XML data. Built on top of xml.sax
-
-Example use:
-e=ExcelHandler()
-parse('myData.xml', e)
-print e.tables
-
-"""
-
-from xml.sax import saxutils
-
-class ExcelHandler(saxutils.DefaultHandler):
-    def __init__(self):
-        self.chars=[]
-        self.isNumber = 0
-        self.cells=[]
-        self.rows=[]
-        self.tables=[]
-        
-    def characters(self, content):
-        self.chars.append(content)
-        
-    def startElement(self, name, attrs):
-        if name=="Data":
-            if attrs.get('ss:Type') == "Number":
-                self.isNumber = 1
-            else:
-                self.isNumber = 0
-        elif name=="Cell":
-            self.chars=[]
-        elif name=="Row":
-            self.cells=[]
-        elif name=="Table":
-            self.rows=[]
-            
-    def endElement(self, name):
-        if name=="Data":
-            pass
-        elif name=="Cell":
-            s = ''.join(self.chars)
-            if s:
-                if self.isNumber:
-                    # Determine if it is an int or float and use
-                    # return the best fit
-                    floatVersion = float(s)
-                    intVersion = int(floatVersion)
-                    if floatVersion == intVersion:
-                        # If the float is equal to the int, it must be an int
-                        s = intVersion
-                    else:
-                        # Keep the precision and return a float
-                        s = floatVersion
-                # Convert the string "None" to the python object None
-                elif s == "None":
-                    s = None
-                self.cells.append(s)
-        elif name=="Row":
-            self.rows.append(self.cells)
-        elif name=="Table":
-            self.tables.append(self.rows)
-

+ 0 - 201
direct/src/showbase/LazySort.py

@@ -1,201 +0,0 @@
-from itertools import tee
-
-def itersorted(iterable, cmp = cmp, key = lambda x: x, reverse = False):
-    """
-    This function returns a generator object that yields sorted items from
-    'iterable'.
-
-    It implements a form of lazy sorting that's most useful in two cases:
-    1) When you only need the first few values in the sorted data.
-    2) When you want to amortize the cost of the sort over the time
-       you use the data.
-
-    It is to be considered a 'stable sort', where values with equivalent
-    sorting criteria maintain their relative order as it is in the input
-    data set.
-
-    'cmp' MUST return values in [-1,0,1]. Otherwise, behavior is
-    undefined, and will most likely be very incorrect.
-    """
-
-    # Notes:
-    # Understanding the concepts of 'left' and 'right' here is important.
-    # 'left' values are those that are yielded earlier in the sort. So
-    # each subsequent value yielded is 'to the right' of the previous one.
-    # A stack is used to maintain sets of values who share the same key
-    # value.  Each layer corresponds to one key.  During the traversals of
-    # the input data, values are added to each layer in such a way that
-    # they maintain their relative position (to others in the same layer)
-    # from the original data.  This ensures a 'stable sort'.
-    
-    # Create our working structures
-    stack = []      # holds a stack of 'layers'.
-                    # 'left' value layers are above 'right' ones.
-    layer = ()      # A 3-tuple of the form:
-                    # (key, data iterator, [values])
-    init = True     # Is set to true for the first pass through
-                    # the data.
-    if reverse:     # Use this to easily switch the direction of the sort.
-        rev = -1
-    else:
-        rev = 1
-
-    # Create the base iterator that will track our
-    # main progress through the data.
-    a = ((key(x),x) for x in iterable)
-        
-    # Begin the main loop
-    while 1:
-        # If the stack is empty, we must now seed it.
-        # Advance the base iterator until we find a value 'to the right' of
-        # anything we've yielded so far. (All values 'to the left' have
-        # already been yielded)
-        if not stack:
-            # pull next value off the base iterator
-            k,val = a.next()
-
-            # If init, get the first value and stop.
-            # Otherwise, find the first value 'to the right'
-            # of the most recently yielded value.
-            while (not init) and (cmp(k,lLimit) != rev):
-                k,val = a.next()
-                pass
-
-            # Place the found value as the initial stack value
-            # (and store its iteration progress as well).
-            a,b = tee(a)
-            stack.append([k, b, [val]])
-            pass
-
-
-        # We now iterate through the data, starting where the value
-        # at the top of the stack left off.
-        layer = stack[-1]
-        b = layer[1]
-        for k,val in b:
-            # If the next data element is 'to the left' of (or equal to)
-            # the top off the stack and 'to the right' of the last element
-            # yielded, add it to the stack.
-            if cmp(k,layer[0]) != rev and (init or cmp(k,lLimit) == rev):
-                # If it's 'to the left' of the current stack value,
-                # make a new layer and add it to the top of the stack.
-                # Otherwise, it's equivalent so we'll just append it
-                # to the values in the top layer of the stack.
-                if cmp(k,layer[0]) == -rev:
-                    b,layer[1] = tee(b)
-                    stack.append([k, b, []])
-                    layer = stack[-1]
-                    pass
-                layer[2].append(val)
-                pass
-            pass
-        # Remove the initialization condition to enable lLimit checking.
-        init = False
-
-        # Whatever values that are on the top stack at this point are
-        # the 'left-most' we've found that we haven't yet yielded. Yield
-        # them in the order that we discovered them in the source data.
-        # Define lLimit as the right-most limit for values that have not
-        # yet been yielded.  This will allow us to ignore these values
-        # on future iterations.
-        lLimit, b, vals = stack.pop()
-        for val in vals:
-            yield val
-            pass
-
-if __debug__:
-    def P(i):
-        for x in reversed(i):
-            print x
-
-    def test():
-        from itertools import islice
-
-        control = sorted(data, key = lambda x: x[0])
-        variable = itersorted(data, key = lambda x: x[0])
-        
-        print control[:10] == [x for x in islice(variable,10)]
-        print data
-        print control
-
-        variable = itersorted(data, key = lambda x: x[0])
-        print [x for x in islice(variable,10)]
-
-    from unittest import TestCase, main
-    from random import shuffle
-    from itertools import islice
-    
-    class LazySortTest(TestCase):
-        """
-        Run these tests with:
-        > python LazySort.py
-        """
-        
-        TESTLEN = 10
-        RANGELEN = max(TESTLEN, 10)
-
-        a = range(RANGELEN/2)*2
-        b = range(RANGELEN/2)*2
-        shuffle(a)
-        shuffle(b)
-        DATA = zip(a,b)
-        shuffle(DATA)
-        del a
-        del b
-        
-        def testRange(self):
-            control = sorted(self.DATA)
-            variable = itersorted(self.DATA)
-            self.assertEqual(control[:10], [x for x in islice(variable, self.TESTLEN)])
-            
-        def testRangeCompare(self):
-            control = sorted(self.DATA, cmp = lambda a,b: -cmp(a,b))
-            variable = itersorted(self.DATA, cmp = lambda a,b: -cmp(a,b))
-            self.assertEqual(control[:10], [x for x in islice(variable, self.TESTLEN)])
-
-        def testRangeKey(self):
-            control = sorted(self.DATA, key = lambda x: x[0])
-            variable = itersorted(self.DATA, key = lambda x: x[0])
-            self.assertEqual(control[:10], [x for x in islice(variable, self.TESTLEN)])
-        
-        def testRangeReverse(self):
-            control = sorted(self.DATA, reverse = True)
-            variable = itersorted(self.DATA, reverse = True)
-            self.assertEqual(control[:10], [x for x in islice(variable, self.TESTLEN)])
-
-        def testRangeCompareKey(self):
-            control = sorted(self.DATA, cmp = lambda a,b: -cmp(a,b),
-                             key = lambda x: x[0])
-            variable = itersorted(self.DATA, cmp = lambda a,b: -cmp(a,b),
-                                  key = lambda x: x[0])
-            self.assertEqual(control[:10], [x for x in islice(variable, self.TESTLEN)])
-        
-        def testRangeCompareReverse(self):
-            control = sorted(self.DATA, cmp = lambda a,b: -cmp(a,b),
-                             reverse = True)
-            variable = itersorted(self.DATA, cmp = lambda a,b: -cmp(a,b),
-                                  reverse = True)
-            self.assertEqual(control[:10], [x for x in islice(variable, self.TESTLEN)])
-            
-        def testRangeKeyReverse(self):
-            control = sorted(self.DATA, key = lambda x: x[0], reverse = True)
-            variable = itersorted(self.DATA, key = lambda x: x[0], reverse = True)
-            self.assertEqual(control[:10], [x for x in islice(variable, self.TESTLEN)])
-            
-            control = sorted(self.DATA, key = lambda x: x[1], reverse = True)
-            variable = itersorted(self.DATA, key = lambda x: x[1], reverse = True)
-            self.assertEqual(control[:10], [x for x in islice(variable, self.TESTLEN)])
-
-        def testRangeCompareKeyReverse(self):
-            control = sorted(self.DATA, cmp = lambda a,b: -cmp(a,b),
-                             key = lambda x: x[0],
-                             reverse = True)
-            variable = itersorted(self.DATA, cmp = lambda a,b: -cmp(a,b),
-                                  key = lambda x: x[0],
-                                  reverse = True)
-            self.assertEqual(control[:10], [x for x in islice(variable, self.TESTLEN)])
-        
-
-    if __name__ == '__main__':
-        main() # unittest.main
-    

+ 1 - 1
direct/src/showbase/PythonUtil.py

@@ -1303,7 +1303,7 @@ class Enum:
         _checkValidIdentifier = staticmethod(_checkValidIdentifier)
         _checkValidIdentifier = staticmethod(_checkValidIdentifier)
 
 
     def __init__(self, items, start=0):
     def __init__(self, items, start=0):
-        if type(items) == types.StringType:
+        if isinstance(items, str):
             items = items.split(',')
             items = items.split(',')
 
 
         self._stringTable = {}
         self._stringTable = {}

+ 1 - 0
direct/src/showbase/ShowBase.py

@@ -1641,6 +1641,7 @@ class ShowBase(DirectObject.DirectObject):
 
 
     def addAngularIntegrator(self):
     def addAngularIntegrator(self):
         if not self.physicsMgrAngular:
         if not self.physicsMgrAngular:
+            from panda3d.physics import AngularEulerIntegrator
             self.physicsMgrAngular = 1
             self.physicsMgrAngular = 1
             integrator = AngularEulerIntegrator()
             integrator = AngularEulerIntegrator()
             self.physicsMgr.attachAngularIntegrator(integrator)
             self.physicsMgr.attachAngularIntegrator(integrator)

+ 5 - 3
direct/src/showbase/ThreeUpShow.py

@@ -9,9 +9,11 @@ class ThreeUpShow(ShowBase.ShowBase):
     def __init__(self):
     def __init__(self):
         ShowBase.ShowBase.__init__(self)
         ShowBase.ShowBase.__init__(self)
 
 
-    def makeCamera(self, win, chan = None, layer = None, layerSort = 0,
-                   scene = None,
-                   displayRegion = (0, 1, 0, 1), aspectRatio = None):
+    def makeCamera(self, win, sort = 0, scene = None,
+                   displayRegion = (0, 1, 0, 1), stereo = None,
+                   aspectRatio = None, clearDepth = 0, clearColor = None,
+                   lens = None, camName = 'cam', mask = None,
+                   useCamera = None):
         self.camRS=ShowBase.ShowBase.makeCamera(
         self.camRS=ShowBase.ShowBase.makeCamera(
                 self, win, displayRegion = (.5, 1, 0, 1), aspectRatio=.67, camName='camRS')
                 self, win, displayRegion = (.5, 1, 0, 1), aspectRatio=.67, camName='camRS')
         self.camLL=ShowBase.ShowBase.makeCamera(
         self.camLL=ShowBase.ShowBase.makeCamera(

+ 1 - 1
direct/src/task/TaskTester.py

@@ -3,7 +3,7 @@
 __all__ = []
 __all__ = []
 
 
 from direct.task.TaskManagerGlobal import *
 from direct.task.TaskManagerGlobal import *
-import direct.task.Task
+from direct.task import Task
 import random
 import random
 
 
 numTasks = 10000
 numTasks = 10000

+ 3 - 2
direct/src/tkpanels/ParticlePanel.py

@@ -11,11 +11,12 @@ from direct.tkwidgets import Dial
 from direct.tkwidgets import Floater
 from direct.tkwidgets import Floater
 from direct.tkwidgets import Slider
 from direct.tkwidgets import Slider
 from direct.tkwidgets import VectorWidgets
 from direct.tkwidgets import VectorWidgets
+from direct.tkpanels import Placer
 from direct.particles import ForceGroup
 from direct.particles import ForceGroup
 from direct.particles import Particles
 from direct.particles import Particles
 from direct.particles import ParticleEffect
 from direct.particles import ParticleEffect
 from Tkinter import *
 from Tkinter import *
-import Pmw, os,Placer
+import Pmw, os
 
 
 from panda3d.core import *
 from panda3d.core import *
 from panda3d.physics import *
 from panda3d.physics import *
@@ -2789,4 +2790,4 @@ if __name__ == '__main__':
     base.pp=pp
     base.pp=pp
     #ve = VectorEntry(Toplevel(), relief = GROOVE)
     #ve = VectorEntry(Toplevel(), relief = GROOVE)
     #ve.pack()
     #ve.pack()
-    run()
+    base.run()

+ 4 - 1
direct/src/tkwidgets/MemoryExplorer.py

@@ -15,7 +15,10 @@ class MemoryExplorer(Pmw.MegaWidget, DirectObject):
     #--------------------------------------------------------------------------
     #--------------------------------------------------------------------------
     # Init
     # Init
     #--------------------------------------------------------------------------    
     #--------------------------------------------------------------------------    
-    def __init__(self, parent = None, nodePath = render, **kw):
+    def __init__(self, parent = None, nodePath = None, **kw):
+        if nodePath is None:
+            nodePath = render
+
         optiondefs = (('menuItems',   [],   Pmw.INITOPT),)
         optiondefs = (('menuItems',   [],   Pmw.INITOPT),)
         self.defineoptions(kw, optiondefs)
         self.defineoptions(kw, optiondefs)
         Pmw.MegaWidget.__init__(self, parent)
         Pmw.MegaWidget.__init__(self, parent)

+ 8 - 2
direct/src/tkwidgets/SceneGraphExplorer.py

@@ -27,7 +27,10 @@ DEFAULT_MENU_ITEMS = [
 
 
 class SceneGraphExplorer(Pmw.MegaWidget, DirectObject):
 class SceneGraphExplorer(Pmw.MegaWidget, DirectObject):
     "Graphical display of a scene graph"
     "Graphical display of a scene graph"
-    def __init__(self, parent = None, nodePath = render, isItemEditable = True, **kw):
+    def __init__(self, parent = None, nodePath = None, isItemEditable = True, **kw):
+        if nodePath is None:
+            nodePath = base.render
+
         # Define the megawidget options.
         # Define the megawidget options.
         optiondefs = (
         optiondefs = (
             ('menuItems',   [],   Pmw.INITOPT),
             ('menuItems',   [],   Pmw.INITOPT),
@@ -188,7 +191,10 @@ class SceneGraphExplorerItem(TreeItem):
         messenger.send('SGE_' + command, [self.nodePath])
         messenger.send('SGE_' + command, [self.nodePath])
 
 
 
 
-def explore(nodePath = render):
+def explore(nodePath = None):
+    if nodePath is None:
+        nodePath = base.render
+
     tl = Toplevel()
     tl = Toplevel()
     tl.title('Explore: ' + nodePath.getName())
     tl.title('Explore: ' + nodePath.getName())
     sge = SceneGraphExplorer(parent = tl, nodePath = nodePath)
     sge = SceneGraphExplorer(parent = tl, nodePath = nodePath)