vfs, make globalClock builtin

This commit is contained in:
David Rose 2002-08-06 16:05:45 +00:00
parent 5f6cc0d434
commit aadae70a6a
11 changed files with 38 additions and 25 deletions

View File

@ -22,7 +22,9 @@
#include "hashGenerator.h"
#ifdef WITHIN_PANDA
#include <filename.h>
#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());

View File

@ -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

View File

@ -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()):

View File

@ -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):

View File

@ -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())

View File

@ -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

View File

@ -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 "<ERROR WHILE PRINTING VALUE>"
# Store the global clock
globalClock = ClockObject.getGlobalClock()
class Task:
count = 0
def __init__(self, callback, priority = 0):

View File

@ -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):

View File

@ -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

View File

@ -10,8 +10,6 @@ import Task
import math
import string
globalClock = ClockObject.getGlobalClock()
FLOATER_WIDTH = 22
FLOATER_HEIGHT = 18

View File

@ -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