|
|
@@ -26,24 +26,22 @@ from BulletinBoardGlobal import bulletinBoard
|
|
|
from direct.task.TaskManagerGlobal import taskMgr
|
|
|
from JobManagerGlobal import jobMgr
|
|
|
from EventManagerGlobal import eventMgr
|
|
|
-from PythonUtil import *
|
|
|
-from direct.showbase import PythonUtil
|
|
|
-#from direct.interval.IntervalManager import ivalMgr
|
|
|
+#from PythonUtil import *
|
|
|
from direct.interval import IntervalManager
|
|
|
from direct.showbase.BufferViewer import BufferViewer
|
|
|
from direct.task import Task
|
|
|
-from direct.directutil import Verify
|
|
|
-from direct.showbase import GarbageReport
|
|
|
import sys
|
|
|
import Loader
|
|
|
import time
|
|
|
import atexit
|
|
|
+import importlib
|
|
|
from direct.showbase import ExceptionVarDump
|
|
|
import DirectObject
|
|
|
import SfxPlayer
|
|
|
if __debug__:
|
|
|
+ from direct.showbase import GarbageReport
|
|
|
from direct.directutil import DeltaProfiler
|
|
|
-import OnScreenDebug
|
|
|
+ import OnScreenDebug
|
|
|
import AppRunnerGlobal
|
|
|
|
|
|
def legacyRun():
|
|
|
@@ -73,7 +71,8 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
if logStackDump or uploadStackDump:
|
|
|
ExceptionVarDump.install(logStackDump, uploadStackDump)
|
|
|
|
|
|
- self.__autoGarbageLogging = self.__dev__ and self.config.GetBool('auto-garbage-logging', False)
|
|
|
+ if __debug__:
|
|
|
+ self.__autoGarbageLogging = self.__dev__ and self.config.GetBool('auto-garbage-logging', False)
|
|
|
|
|
|
## The directory containing the main Python file of this application.
|
|
|
self.mainDir = ExecutionEnvironment.getEnvironmentVariable("MAIN_DIR")
|
|
|
@@ -88,9 +87,6 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
#debug running multiplier
|
|
|
self.debugRunningMultiplier = 4
|
|
|
|
|
|
- # Setup wantVerifyPdb as soon as reasonable:
|
|
|
- Verify.wantVerifyPdb = self.config.GetBool('want-verify-pdb', 0)
|
|
|
-
|
|
|
# [gjeon] to disable sticky keys
|
|
|
if self.config.GetBool('disable-sticky-keys', 0):
|
|
|
storeAccessibilityShortcutKeys()
|
|
|
@@ -373,8 +369,8 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
builtins.wantUberdog = self.config.GetBool('want-uberdog', 1)
|
|
|
if __debug__:
|
|
|
builtins.deltaProfiler = DeltaProfiler.DeltaProfiler("ShowBase")
|
|
|
- self.onScreenDebug = OnScreenDebug.OnScreenDebug()
|
|
|
- builtins.onScreenDebug = self.onScreenDebug
|
|
|
+ self.onScreenDebug = OnScreenDebug.OnScreenDebug()
|
|
|
+ builtins.onScreenDebug = self.onScreenDebug
|
|
|
|
|
|
if self.wantRender2dp:
|
|
|
builtins.render2dp = self.render2dp
|
|
|
@@ -388,10 +384,6 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
|
|
|
self.createBaseAudioManagers()
|
|
|
|
|
|
- # set up recording of Functor creation stacks in __dev__
|
|
|
- if self.__dev__ and self.config.GetBool('record-functor-creation-stacks', False):
|
|
|
- PythonUtil.recordFunctorCreationStacks()
|
|
|
-
|
|
|
if self.__dev__ or self.config.GetBool('want-e3-hacks', False):
|
|
|
if self.config.GetBool('track-gui-items', True):
|
|
|
# dict of guiId to gui item, for tracking down leaks
|
|
|
@@ -465,7 +457,8 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
some Panda config settings. """
|
|
|
|
|
|
try:
|
|
|
- import profile, pstats
|
|
|
+ profile = importlib.import_module('profile')
|
|
|
+ pstats = importlib.import_module('pstats')
|
|
|
except ImportError:
|
|
|
return
|
|
|
|
|
|
@@ -1647,23 +1640,26 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
|
|
|
def addAngularIntegrator(self):
|
|
|
if not self.physicsMgrAngular:
|
|
|
- from panda3d.physics import AngularEulerIntegrator
|
|
|
+ physics = importlib.import_module('panda3d.physics')
|
|
|
self.physicsMgrAngular = 1
|
|
|
- integrator = AngularEulerIntegrator()
|
|
|
+ integrator = physics.AngularEulerIntegrator()
|
|
|
self.physicsMgr.attachAngularIntegrator(integrator)
|
|
|
|
|
|
def enableParticles(self):
|
|
|
if not self.particleMgrEnabled:
|
|
|
+ # Use importlib to prevent this import from being picked up
|
|
|
+ # by modulefinder when packaging an application.
|
|
|
+
|
|
|
if not self.particleMgr:
|
|
|
- from direct.particles.ParticleManagerGlobal import particleMgr
|
|
|
- self.particleMgr = particleMgr
|
|
|
+ PMG = importlib.import_module('direct.particles.ParticleManagerGlobal')
|
|
|
+ self.particleMgr = PMG.particleMgr
|
|
|
self.particleMgr.setFrameStepping(1)
|
|
|
|
|
|
if not self.physicsMgr:
|
|
|
- from PhysicsManagerGlobal import physicsMgr
|
|
|
- from panda3d.physics import LinearEulerIntegrator
|
|
|
- self.physicsMgr = physicsMgr
|
|
|
- integrator = LinearEulerIntegrator()
|
|
|
+ PMG = importlib.import_module('direct.showbase.PhysicsManagerGlobal')
|
|
|
+ physics = importlib.import_module('panda3d.physics')
|
|
|
+ self.physicsMgr = PMG.physicsMgr
|
|
|
+ integrator = physics.LinearEulerIntegrator()
|
|
|
self.physicsMgr.attachLinearIntegrator(integrator)
|
|
|
|
|
|
self.particleMgrEnabled = 1
|
|
|
@@ -1886,9 +1882,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
return Task.cont
|
|
|
|
|
|
def __igLoop(self, state):
|
|
|
- # We render the watch variables for the onScreenDebug as soon
|
|
|
- # as we reasonably can before the renderFrame().
|
|
|
- self.onScreenDebug.render()
|
|
|
+ if __debug__:
|
|
|
+ # We render the watch variables for the onScreenDebug as soon
|
|
|
+ # as we reasonably can before the renderFrame().
|
|
|
+ self.onScreenDebug.render()
|
|
|
|
|
|
if self.recorder:
|
|
|
self.recorder.recordFrame()
|
|
|
@@ -1900,9 +1897,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
if self.multiClientSleep:
|
|
|
time.sleep(0)
|
|
|
|
|
|
- # We clear the text buffer for the onScreenDebug as soon
|
|
|
- # as we reasonably can after the renderFrame().
|
|
|
- self.onScreenDebug.clear()
|
|
|
+ if __debug__:
|
|
|
+ # We clear the text buffer for the onScreenDebug as soon
|
|
|
+ # as we reasonably can after the renderFrame().
|
|
|
+ self.onScreenDebug.clear()
|
|
|
|
|
|
if self.recorder:
|
|
|
self.recorder.playFrame()
|
|
|
@@ -1925,9 +1923,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
|
|
|
|
|
|
def __igLoopSync(self, state):
|
|
|
- # We render the watch variables for the onScreenDebug as soon
|
|
|
- # as we reasonably can before the renderFrame().
|
|
|
- self.onScreenDebug.render()
|
|
|
+ if __debug__:
|
|
|
+ # We render the watch variables for the onScreenDebug as soon
|
|
|
+ # as we reasonably can before the renderFrame().
|
|
|
+ self.onScreenDebug.render()
|
|
|
|
|
|
if self.recorder:
|
|
|
self.recorder.recordFrame()
|
|
|
@@ -1941,9 +1940,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
if self.multiClientSleep:
|
|
|
time.sleep(0)
|
|
|
|
|
|
- # We clear the text buffer for the onScreenDebug as soon
|
|
|
- # as we reasonably can after the renderFrame().
|
|
|
- self.onScreenDebug.clear()
|
|
|
+ if __debug__:
|
|
|
+ # We clear the text buffer for the onScreenDebug as soon
|
|
|
+ # as we reasonably can after the renderFrame().
|
|
|
+ self.onScreenDebug.clear()
|
|
|
|
|
|
if self.recorder:
|
|
|
self.recorder.playFrame()
|
|
|
@@ -2178,8 +2178,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
self.texmem = None
|
|
|
return
|
|
|
|
|
|
- from direct.showutil.TexMemWatcher import TexMemWatcher
|
|
|
- self.texmem = TexMemWatcher()
|
|
|
+ # Use importlib to prevent this import from being picked up
|
|
|
+ # by modulefinder when packaging an application.
|
|
|
+ TMW = importlib.import_module('direct.showutil.TexMemWatcher')
|
|
|
+ self.texmem = TMW.TexMemWatcher()
|
|
|
|
|
|
def toggleShowVertices(self):
|
|
|
""" Toggles a mode that visualizes vertex density per screen
|
|
|
@@ -2675,16 +2677,18 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
if not properties.getOpen():
|
|
|
# If the user closes the main window, we should exit.
|
|
|
self.notify.info("User closed main window.")
|
|
|
- if self.__autoGarbageLogging:
|
|
|
- GarbageReport.b_checkForGarbageLeaks()
|
|
|
+ if __debug__:
|
|
|
+ if self.__autoGarbageLogging:
|
|
|
+ GarbageReport.b_checkForGarbageLeaks()
|
|
|
self.userExit()
|
|
|
|
|
|
if properties.getForeground() and not self.mainWinForeground:
|
|
|
self.mainWinForeground = 1
|
|
|
elif not properties.getForeground() and self.mainWinForeground:
|
|
|
self.mainWinForeground = 0
|
|
|
- if self.__autoGarbageLogging:
|
|
|
- GarbageReport.b_checkForGarbageLeaks()
|
|
|
+ if __debug__:
|
|
|
+ if self.__autoGarbageLogging:
|
|
|
+ GarbageReport.b_checkForGarbageLeaks()
|
|
|
|
|
|
if properties.getMinimized() and not self.mainWinMinimized:
|
|
|
# If the main window is minimized, throw an event to
|
|
|
@@ -2814,7 +2818,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
|
|
|
init_app_for_gui()
|
|
|
|
|
|
- import wx
|
|
|
+ # Use importlib to prevent this import from being picked up
|
|
|
+ # by modulefinder when packaging an application.
|
|
|
+ wx = importlib.import_module('wx')
|
|
|
+
|
|
|
# Create a new base.wxApp.
|
|
|
self.wxApp = wx.PySimpleApp(redirect = False)
|
|
|
|
|
|
@@ -2889,8 +2896,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
# Don't do this twice.
|
|
|
return
|
|
|
|
|
|
- from Tkinter import tkinter
|
|
|
- import Pmw
|
|
|
+ # Use importlib to prevent this import from being picked up
|
|
|
+ # by modulefinder when packaging an application.
|
|
|
+ tkinter = importlib.import_module('Tkinter').tkinter
|
|
|
+ Pmw = importlib.import_module('Pmw')
|
|
|
|
|
|
# Create a new Tk root.
|
|
|
self.tkRoot = Pmw.initialise()
|
|
|
@@ -2953,8 +2962,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
self.startWx(fWantWx)
|
|
|
self.wantDirect = fWantDirect
|
|
|
if self.wantDirect:
|
|
|
- from direct.directtools.DirectSession import DirectSession
|
|
|
- self.direct = DirectSession()
|
|
|
+ # Use importlib to prevent this import from being picked up
|
|
|
+ # by modulefinder when packaging an application.
|
|
|
+ DirectSession = importlib.import_module('direct.directtools.DirectSession')
|
|
|
+ self.direct = DirectSession.DirectSession()
|
|
|
self.direct.enable()
|
|
|
builtins.direct = self.direct
|
|
|
else:
|