mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 11:28:17 -04:00
vfs, make globalClock builtin
This commit is contained in:
parent
5f6cc0d434
commit
aadae70a6a
@ -22,7 +22,9 @@
|
|||||||
#include "hashGenerator.h"
|
#include "hashGenerator.h"
|
||||||
|
|
||||||
#ifdef WITHIN_PANDA
|
#ifdef WITHIN_PANDA
|
||||||
#include <filename.h>
|
#include "filename.h"
|
||||||
|
#include "config_express.h"
|
||||||
|
#include "virtualFileSystem.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -66,6 +68,17 @@ read(Filename filename) {
|
|||||||
|
|
||||||
#ifdef WITHIN_PANDA
|
#ifdef WITHIN_PANDA
|
||||||
filename.set_text();
|
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);
|
filename.open_read(in);
|
||||||
#else
|
#else
|
||||||
in.open(filename.c_str());
|
in.open(filename.c_str());
|
||||||
|
@ -5,8 +5,6 @@ from ClockDelta import *
|
|||||||
import DistributedNode
|
import DistributedNode
|
||||||
import Task
|
import Task
|
||||||
|
|
||||||
globalClock = ClockObject.getGlobalClock()
|
|
||||||
|
|
||||||
# This number defines our tolerance for out-of-sync telemetry packets.
|
# This number defines our tolerance for out-of-sync telemetry packets.
|
||||||
# If a packet appears to have originated from more than MaxFuture
|
# If a packet appears to have originated from more than MaxFuture
|
||||||
# seconds in the future, assume we're out of sync with the other
|
# seconds in the future, assume we're out of sync with the other
|
||||||
|
@ -291,7 +291,7 @@
|
|||||||
functor = task.functorFunc()
|
functor = task.functorFunc()
|
||||||
task.lerp = Lerp(functor, task.duration, task.blendType)
|
task.lerp = Lerp(functor, task.duration, task.blendType)
|
||||||
task.init = 0
|
task.init = 0
|
||||||
dt = ClockObject.getGlobalClock().getDt()
|
dt = globalClock.getDt()
|
||||||
task.lerp.setStepSize(dt)
|
task.lerp.setStepSize(dt)
|
||||||
task.lerp.step()
|
task.lerp.step()
|
||||||
if (task.lerp.isDone()):
|
if (task.lerp.isDone()):
|
||||||
|
@ -17,8 +17,6 @@ class Interval(DirectObject):
|
|||||||
|
|
||||||
playbackCounter = 0
|
playbackCounter = 0
|
||||||
|
|
||||||
clock = ClockObject.getGlobalClock()
|
|
||||||
|
|
||||||
# Class methods
|
# Class methods
|
||||||
def __init__(self, name, duration, openEnded=1, reverse=0):
|
def __init__(self, name, duration, openEnded=1, reverse=0):
|
||||||
"""__init__(name, duration, openEnded, reverse)
|
"""__init__(name, duration, openEnded, reverse)
|
||||||
@ -96,7 +94,7 @@ class Interval(DirectObject):
|
|||||||
taskMgr.remove(self.name + '-play')
|
taskMgr.remove(self.name + '-play')
|
||||||
# Start new one
|
# Start new one
|
||||||
self.offset = t0
|
self.offset = t0
|
||||||
self.startT = self.clock.getFrameTime()
|
self.startT = globalClock.getFrameTime()
|
||||||
assert(scale > 0.0)
|
assert(scale > 0.0)
|
||||||
self.scale = scale
|
self.scale = scale
|
||||||
self.firstTime = 1
|
self.firstTime = 1
|
||||||
@ -135,7 +133,7 @@ class Interval(DirectObject):
|
|||||||
def __playTask(self, task):
|
def __playTask(self, task):
|
||||||
""" __playTask(task)
|
""" __playTask(task)
|
||||||
"""
|
"""
|
||||||
t = self.clock.getFrameTime()
|
t = globalClock.getFrameTime()
|
||||||
te = self.offset + ((t - self.startT) * self.scale)
|
te = self.offset + ((t - self.startT) * self.scale)
|
||||||
if (te < self.endTime):
|
if (te < self.endTime):
|
||||||
if (self.firstTime):
|
if (self.firstTime):
|
||||||
|
@ -211,6 +211,9 @@ class ParticleEffect(NodePath):
|
|||||||
|
|
||||||
def loadConfig(self, filename):
|
def loadConfig(self, filename):
|
||||||
"""loadConfig(filename)"""
|
"""loadConfig(filename)"""
|
||||||
|
if vfs:
|
||||||
|
exec vfs.readFile(filename)
|
||||||
|
else:
|
||||||
execfile(filename.toOsSpecific())
|
execfile(filename.toOsSpecific())
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import __builtin__
|
|||||||
__builtin__.FADE_SORT_INDEX = 1000
|
__builtin__.FADE_SORT_INDEX = 1000
|
||||||
__builtin__.NO_FADE_SORT_INDEX = 2000
|
__builtin__.NO_FADE_SORT_INDEX = 2000
|
||||||
|
|
||||||
globalClock = ClockObject.getGlobalClock()
|
|
||||||
class ShowBase:
|
class ShowBase:
|
||||||
|
|
||||||
notify = directNotify.newCategory("ShowBase")
|
notify = directNotify.newCategory("ShowBase")
|
||||||
@ -36,6 +35,14 @@ class ShowBase:
|
|||||||
# Get the dconfig object
|
# Get the dconfig object
|
||||||
self.config = ConfigConfigureGetConfigConfigShowbase
|
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
|
# Store dconfig variables
|
||||||
self.wantTk = self.config.GetBool('want-tk', 0)
|
self.wantTk = self.config.GetBool('want-tk', 0)
|
||||||
self.sfxActive = self.config.GetBool('audio-sfx-active', 1)
|
self.sfxActive = self.config.GetBool('audio-sfx-active', 1)
|
||||||
@ -147,6 +154,8 @@ class ShowBase:
|
|||||||
__builtin__.run = self.run
|
__builtin__.run = self.run
|
||||||
__builtin__.ostream = Notify.out()
|
__builtin__.ostream = Notify.out()
|
||||||
__builtin__.directNotify = directNotify
|
__builtin__.directNotify = directNotify
|
||||||
|
__builtin__.globalClock = ClockObject.getGlobalClock()
|
||||||
|
__builtin__.vfs = vfs
|
||||||
|
|
||||||
# Transition effects (fade, iris, etc)
|
# Transition effects (fade, iris, etc)
|
||||||
import Transitions
|
import Transitions
|
||||||
|
@ -15,6 +15,10 @@ exit = -1
|
|||||||
done = 0
|
done = 0
|
||||||
cont = 1
|
cont = 1
|
||||||
|
|
||||||
|
# Task needs this because it might run before __builtin__.globalClock
|
||||||
|
# can be set.
|
||||||
|
globalClock = ClockObject.getGlobalClock()
|
||||||
|
|
||||||
def print_exc_plus():
|
def print_exc_plus():
|
||||||
"""
|
"""
|
||||||
Print the usual traceback information, followed by a listing of all the
|
Print the usual traceback information, followed by a listing of all the
|
||||||
@ -51,11 +55,6 @@ def print_exc_plus():
|
|||||||
except:
|
except:
|
||||||
print "<ERROR WHILE PRINTING VALUE>"
|
print "<ERROR WHILE PRINTING VALUE>"
|
||||||
|
|
||||||
|
|
||||||
# Store the global clock
|
|
||||||
globalClock = ClockObject.getGlobalClock()
|
|
||||||
|
|
||||||
|
|
||||||
class Task:
|
class Task:
|
||||||
count = 0
|
count = 0
|
||||||
def __init__(self, callback, priority = 0):
|
def __init__(self, callback, priority = 0):
|
||||||
|
@ -8,7 +8,6 @@ class Timer:
|
|||||||
def __init__(self, name=None):
|
def __init__(self, name=None):
|
||||||
""" __init__()
|
""" __init__()
|
||||||
"""
|
"""
|
||||||
self.clock = ClockObject.getGlobalClock()
|
|
||||||
self.finalT = 0.0
|
self.finalT = 0.0
|
||||||
self.currT = 0.0
|
self.currT = 0.0
|
||||||
if (name == None):
|
if (name == None):
|
||||||
@ -26,7 +25,7 @@ class Timer:
|
|||||||
self.callback = None
|
self.callback = None
|
||||||
self.finalT = t
|
self.finalT = t
|
||||||
self.name = name
|
self.name = name
|
||||||
self.startT = self.clock.getFrameTime()
|
self.startT = globalClock.getFrameTime()
|
||||||
self.currT = 0.0
|
self.currT = 0.0
|
||||||
taskMgr.add(self.__timerTask, self.name + '-run')
|
taskMgr.add(self.__timerTask, self.name + '-run')
|
||||||
self.started = 1
|
self.started = 1
|
||||||
@ -38,7 +37,7 @@ class Timer:
|
|||||||
self.stop()
|
self.stop()
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.finalT = t
|
self.finalT = t
|
||||||
self.startT = self.clock.getFrameTime()
|
self.startT = globalClock.getFrameTime()
|
||||||
self.currT = 0.0
|
self.currT = 0.0
|
||||||
taskMgr.add(self.__timerTask, self.name + '-run')
|
taskMgr.add(self.__timerTask, self.name + '-run')
|
||||||
self.started = 1
|
self.started = 1
|
||||||
@ -88,7 +87,7 @@ class Timer:
|
|||||||
return (self.finalT - self.currT)
|
return (self.finalT - self.currT)
|
||||||
|
|
||||||
def __timerTask(self, task):
|
def __timerTask(self, task):
|
||||||
t = self.clock.getFrameTime()
|
t = globalClock.getFrameTime()
|
||||||
te = t - self.startT
|
te = t - self.startT
|
||||||
self.currT = te
|
self.currT = te
|
||||||
if (te >= self.finalT):
|
if (te >= self.finalT):
|
||||||
|
@ -19,8 +19,6 @@ INNER_SF = 0.2
|
|||||||
DIAL_FULL_SIZE = 45
|
DIAL_FULL_SIZE = 45
|
||||||
DIAL_MINI_SIZE = 30
|
DIAL_MINI_SIZE = 30
|
||||||
|
|
||||||
globalClock = ClockObject.getGlobalClock()
|
|
||||||
|
|
||||||
class Dial(Valuator):
|
class Dial(Valuator):
|
||||||
"""
|
"""
|
||||||
Valuator widget which includes an angle dial and an entry for setting
|
Valuator widget which includes an angle dial and an entry for setting
|
||||||
|
@ -10,8 +10,6 @@ import Task
|
|||||||
import math
|
import math
|
||||||
import string
|
import string
|
||||||
|
|
||||||
globalClock = ClockObject.getGlobalClock()
|
|
||||||
|
|
||||||
FLOATER_WIDTH = 22
|
FLOATER_WIDTH = 22
|
||||||
FLOATER_HEIGHT = 18
|
FLOATER_HEIGHT = 18
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@ import string
|
|||||||
import operator
|
import operator
|
||||||
from PandaModules import ClockObject
|
from PandaModules import ClockObject
|
||||||
|
|
||||||
globalClock = ClockObject.getGlobalClock()
|
|
||||||
|
|
||||||
class Slider(Valuator):
|
class Slider(Valuator):
|
||||||
"""
|
"""
|
||||||
Valuator widget which includes an min/max slider and an entry for setting
|
Valuator widget which includes an min/max slider and an entry for setting
|
||||||
|
Loading…
x
Reference in New Issue
Block a user