diff --git a/direct/src/dcparser/dcFile.cxx b/direct/src/dcparser/dcFile.cxx index 93f836337e..4432e9b56a 100644 --- a/direct/src/dcparser/dcFile.cxx +++ b/direct/src/dcparser/dcFile.cxx @@ -22,7 +22,9 @@ #include "hashGenerator.h" #ifdef WITHIN_PANDA -#include +#include "filename.h" +#include "config_express.h" +#include "virtualFileSystem.h" #endif @@ -66,6 +68,17 @@ read(Filename filename) { #ifdef WITHIN_PANDA filename.set_text(); + if (use_vfs) { + VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); + istream *in = vfs->open_read_file(filename); + if (in == (istream *)NULL) { + cerr << "Cannot open " << filename << " for reading.\n"; + return false; + } + bool okflag = read(*in, filename); + delete in; + return okflag; + } filename.open_read(in); #else in.open(filename.c_str()); diff --git a/direct/src/distributed/DistributedSmoothNode.py b/direct/src/distributed/DistributedSmoothNode.py index 7d6b332051..7f6ff779a6 100644 --- a/direct/src/distributed/DistributedSmoothNode.py +++ b/direct/src/distributed/DistributedSmoothNode.py @@ -5,8 +5,6 @@ from ClockDelta import * import DistributedNode import Task -globalClock = ClockObject.getGlobalClock() - # This number defines our tolerance for out-of-sync telemetry packets. # If a packet appears to have originated from more than MaxFuture # seconds in the future, assume we're out of sync with the other diff --git a/direct/src/extensions/NodePath-extensions.py b/direct/src/extensions/NodePath-extensions.py index 325cf64b2e..58b40b6b34 100644 --- a/direct/src/extensions/NodePath-extensions.py +++ b/direct/src/extensions/NodePath-extensions.py @@ -291,7 +291,7 @@ functor = task.functorFunc() task.lerp = Lerp(functor, task.duration, task.blendType) task.init = 0 - dt = ClockObject.getGlobalClock().getDt() + dt = globalClock.getDt() task.lerp.setStepSize(dt) task.lerp.step() if (task.lerp.isDone()): diff --git a/direct/src/interval/Interval.py b/direct/src/interval/Interval.py index fc7ef49249..629855a002 100644 --- a/direct/src/interval/Interval.py +++ b/direct/src/interval/Interval.py @@ -17,8 +17,6 @@ class Interval(DirectObject): playbackCounter = 0 - clock = ClockObject.getGlobalClock() - # Class methods def __init__(self, name, duration, openEnded=1, reverse=0): """__init__(name, duration, openEnded, reverse) @@ -96,7 +94,7 @@ class Interval(DirectObject): taskMgr.remove(self.name + '-play') # Start new one self.offset = t0 - self.startT = self.clock.getFrameTime() + self.startT = globalClock.getFrameTime() assert(scale > 0.0) self.scale = scale self.firstTime = 1 @@ -135,7 +133,7 @@ class Interval(DirectObject): def __playTask(self, task): """ __playTask(task) """ - t = self.clock.getFrameTime() + t = globalClock.getFrameTime() te = self.offset + ((t - self.startT) * self.scale) if (te < self.endTime): if (self.firstTime): diff --git a/direct/src/particles/ParticleEffect.py b/direct/src/particles/ParticleEffect.py index 1a85a6c13a..4dd124ba4d 100644 --- a/direct/src/particles/ParticleEffect.py +++ b/direct/src/particles/ParticleEffect.py @@ -211,7 +211,10 @@ class ParticleEffect(NodePath): def loadConfig(self, filename): """loadConfig(filename)""" - execfile(filename.toOsSpecific()) + if vfs: + exec vfs.readFile(filename) + else: + execfile(filename.toOsSpecific()) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 179d9ad375..68b6fdb3f0 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -26,7 +26,6 @@ import __builtin__ __builtin__.FADE_SORT_INDEX = 1000 __builtin__.NO_FADE_SORT_INDEX = 2000 -globalClock = ClockObject.getGlobalClock() class ShowBase: notify = directNotify.newCategory("ShowBase") @@ -36,6 +35,14 @@ class ShowBase: # Get the dconfig object self.config = ConfigConfigureGetConfigConfigShowbase + if self.config.GetBool('use-vfs', 1): + try: # temporary try .. except for old Pandas + vfs = VirtualFileSystem.getGlobalPtr() + except: + vfs = None + else: + vfs = None + # Store dconfig variables self.wantTk = self.config.GetBool('want-tk', 0) self.sfxActive = self.config.GetBool('audio-sfx-active', 1) @@ -147,6 +154,8 @@ class ShowBase: __builtin__.run = self.run __builtin__.ostream = Notify.out() __builtin__.directNotify = directNotify + __builtin__.globalClock = ClockObject.getGlobalClock() + __builtin__.vfs = vfs # Transition effects (fade, iris, etc) import Transitions diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index 06d8b51a4c..af986b761a 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -15,6 +15,10 @@ exit = -1 done = 0 cont = 1 +# Task needs this because it might run before __builtin__.globalClock +# can be set. +globalClock = ClockObject.getGlobalClock() + def print_exc_plus(): """ Print the usual traceback information, followed by a listing of all the @@ -51,11 +55,6 @@ def print_exc_plus(): except: print "" - -# Store the global clock -globalClock = ClockObject.getGlobalClock() - - class Task: count = 0 def __init__(self, callback, priority = 0): diff --git a/direct/src/task/Timer.py b/direct/src/task/Timer.py index 2161347cc1..3ec3e843be 100644 --- a/direct/src/task/Timer.py +++ b/direct/src/task/Timer.py @@ -8,7 +8,6 @@ class Timer: def __init__(self, name=None): """ __init__() """ - self.clock = ClockObject.getGlobalClock() self.finalT = 0.0 self.currT = 0.0 if (name == None): @@ -26,7 +25,7 @@ class Timer: self.callback = None self.finalT = t self.name = name - self.startT = self.clock.getFrameTime() + self.startT = globalClock.getFrameTime() self.currT = 0.0 taskMgr.add(self.__timerTask, self.name + '-run') self.started = 1 @@ -38,7 +37,7 @@ class Timer: self.stop() self.callback = callback self.finalT = t - self.startT = self.clock.getFrameTime() + self.startT = globalClock.getFrameTime() self.currT = 0.0 taskMgr.add(self.__timerTask, self.name + '-run') self.started = 1 @@ -88,7 +87,7 @@ class Timer: return (self.finalT - self.currT) def __timerTask(self, task): - t = self.clock.getFrameTime() + t = globalClock.getFrameTime() te = t - self.startT self.currT = te if (te >= self.finalT): diff --git a/direct/src/tkwidgets/Dial.py b/direct/src/tkwidgets/Dial.py index 9e3ec7aeb7..27ac1e8d6a 100644 --- a/direct/src/tkwidgets/Dial.py +++ b/direct/src/tkwidgets/Dial.py @@ -19,8 +19,6 @@ INNER_SF = 0.2 DIAL_FULL_SIZE = 45 DIAL_MINI_SIZE = 30 -globalClock = ClockObject.getGlobalClock() - class Dial(Valuator): """ Valuator widget which includes an angle dial and an entry for setting diff --git a/direct/src/tkwidgets/Floater.py b/direct/src/tkwidgets/Floater.py index 7644ada2f3..6ef5043abf 100644 --- a/direct/src/tkwidgets/Floater.py +++ b/direct/src/tkwidgets/Floater.py @@ -10,8 +10,6 @@ import Task import math import string -globalClock = ClockObject.getGlobalClock() - FLOATER_WIDTH = 22 FLOATER_HEIGHT = 18 diff --git a/direct/src/tkwidgets/Slider.py b/direct/src/tkwidgets/Slider.py index e3ca05d140..5c16f152e5 100644 --- a/direct/src/tkwidgets/Slider.py +++ b/direct/src/tkwidgets/Slider.py @@ -11,8 +11,6 @@ import string import operator from PandaModules import ClockObject -globalClock = ClockObject.getGlobalClock() - class Slider(Valuator): """ Valuator widget which includes an min/max slider and an entry for setting