|
@@ -5,8 +5,7 @@
|
|
|
# subset of PandaModules that we know is available immediately.
|
|
# subset of PandaModules that we know is available immediately.
|
|
|
# Methods that require more advanced C++ methods may import the
|
|
# Methods that require more advanced C++ methods may import the
|
|
|
# appropriate files within their own scope.
|
|
# appropriate files within their own scope.
|
|
|
-# from pandac.libpandaexpressModules import *
|
|
|
|
|
-from pandac.libdirectModules import *
|
|
|
|
|
|
|
+from pandac.libpandaexpressModules import *
|
|
|
|
|
|
|
|
from direct.directnotify.DirectNotifyGlobal import *
|
|
from direct.directnotify.DirectNotifyGlobal import *
|
|
|
from direct.showbase.PythonUtil import *
|
|
from direct.showbase.PythonUtil import *
|
|
@@ -64,14 +63,9 @@ def print_exc_plus():
|
|
|
except:
|
|
except:
|
|
|
print "<ERROR WHILE PRINTING VALUE>"
|
|
print "<ERROR WHILE PRINTING VALUE>"
|
|
|
|
|
|
|
|
-# Here we inherit from CTask so that we can drop the expensive work
|
|
|
|
|
-# that the task does down into C++. The main reason to do this is
|
|
|
|
|
-# to move the compare operator for the heapq data structure.
|
|
|
|
|
-
|
|
|
|
|
-class Task(CTask):
|
|
|
|
|
|
|
+class Task:
|
|
|
count = 0
|
|
count = 0
|
|
|
def __init__(self, callback, priority = 0):
|
|
def __init__(self, callback, priority = 0):
|
|
|
- CTask.__init__(self)
|
|
|
|
|
# Unique ID for each task
|
|
# Unique ID for each task
|
|
|
self.id = Task.count
|
|
self.id = Task.count
|
|
|
Task.count += 1
|
|
Task.count += 1
|
|
@@ -85,14 +79,16 @@ class Task(CTask):
|
|
|
self.runningTotal = 0.0
|
|
self.runningTotal = 0.0
|
|
|
self.pstats = None
|
|
self.pstats = None
|
|
|
self.extraArgs = None
|
|
self.extraArgs = None
|
|
|
|
|
+ # Used for doLaters
|
|
|
|
|
+ self.wakeTime = 0.0
|
|
|
|
|
|
|
|
# # Used for putting into the doLaterList
|
|
# # Used for putting into the doLaterList
|
|
|
# # the heapq calls __cmp__ via the rich compare function
|
|
# # the heapq calls __cmp__ via the rich compare function
|
|
|
# def __cmp__(self, other):
|
|
# def __cmp__(self, other):
|
|
|
# if isinstance(other, Task):
|
|
# if isinstance(other, Task):
|
|
|
-# if self.getWakeTime() < other.getWakeTime():
|
|
|
|
|
|
|
+# if self.wakeTime < other.wakeTime:
|
|
|
# return -1
|
|
# return -1
|
|
|
-# elif self.getWakeTime() > other.getWakeTime():
|
|
|
|
|
|
|
+# elif self.wakeTime > other.wakeTime:
|
|
|
# return 1
|
|
# return 1
|
|
|
# # If the wakeTimes happen to be the same, just
|
|
# # If the wakeTimes happen to be the same, just
|
|
|
# # sort them based on id
|
|
# # sort them based on id
|
|
@@ -390,7 +386,7 @@ class TaskManager:
|
|
|
continue
|
|
continue
|
|
|
# If the time now is less than the start of the doLater + delay
|
|
# If the time now is less than the start of the doLater + delay
|
|
|
# then we are not ready yet, continue to next one
|
|
# then we are not ready yet, continue to next one
|
|
|
- elif task.time < dl.getWakeTime():
|
|
|
|
|
|
|
+ elif task.time < dl.wakeTime:
|
|
|
# Since the list is sorted, the first one we get to, that
|
|
# Since the list is sorted, the first one we get to, that
|
|
|
# is not ready to go, we can return
|
|
# is not ready to go, we can return
|
|
|
break
|
|
break
|
|
@@ -427,7 +423,7 @@ class TaskManager:
|
|
|
# have been synced since the start of this frame
|
|
# have been synced since the start of this frame
|
|
|
currentTime = globalClock.getFrameTime()
|
|
currentTime = globalClock.getFrameTime()
|
|
|
# Cache the time we should wake up for easier sorting
|
|
# Cache the time we should wake up for easier sorting
|
|
|
- task.setWakeTime(currentTime + delayTime)
|
|
|
|
|
|
|
+ task.wakeTime = currentTime + delayTime
|
|
|
# Push this onto the doLaterList. The heap maintains the sorting.
|
|
# Push this onto the doLaterList. The heap maintains the sorting.
|
|
|
heappush(self.__doLaterList, task)
|
|
heappush(self.__doLaterList, task)
|
|
|
if self.fVerbose:
|
|
if self.fVerbose:
|
|
@@ -854,10 +850,10 @@ class TaskManager:
|
|
|
# The priority heap is not actually in order - it is a tree
|
|
# The priority heap is not actually in order - it is a tree
|
|
|
# Make a shallow copy so we can sort it
|
|
# Make a shallow copy so we can sort it
|
|
|
sortedDoLaterList = self.__doLaterList[:]
|
|
sortedDoLaterList = self.__doLaterList[:]
|
|
|
- sortedDoLaterList.sort(lambda a,b: cmp(a.getWakeTime(), b.getWakeTime()))
|
|
|
|
|
|
|
+ sortedDoLaterList.sort(lambda a,b: cmp(a.wakeTime, b.wakeTime))
|
|
|
sortedDoLaterList.reverse()
|
|
sortedDoLaterList.reverse()
|
|
|
for task in sortedDoLaterList:
|
|
for task in sortedDoLaterList:
|
|
|
- remainingTime = ((task.getWakeTime()) - self.currentTime)
|
|
|
|
|
|
|
+ remainingTime = ((task.wakeTime) - self.currentTime)
|
|
|
if task.isRemoved():
|
|
if task.isRemoved():
|
|
|
taskName = '(R)' + task.name
|
|
taskName = '(R)' + task.name
|
|
|
else:
|
|
else:
|