formatting
This commit is contained in:
parent
95647b0093
commit
6fe83b0c15
|
|
@ -315,7 +315,7 @@ class Actor(PandaObject, NodePath):
|
|||
|
||||
|
||||
def getLODNames(self):
|
||||
"""getLODNames(self):
|
||||
"""
|
||||
Return list of Actor LOD names. If not an LOD actor,
|
||||
returns 'lodRoot'
|
||||
Sorts them from highest lod to lowest.
|
||||
|
|
@ -326,9 +326,10 @@ class Actor(PandaObject, NodePath):
|
|||
return lodNames
|
||||
|
||||
def getPartNames(self):
|
||||
"""getPartNames(self):
|
||||
"""
|
||||
Return list of Actor part names. If not an multipart actor,
|
||||
returns 'modelRoot' NOTE: returns parts of arbitrary LOD"""
|
||||
returns 'modelRoot' NOTE: returns parts of arbitrary LOD
|
||||
"""
|
||||
return self.__partBundleDict.values()[0].keys()
|
||||
|
||||
def getGeomNode(self):
|
||||
|
|
@ -351,7 +352,8 @@ class Actor(PandaObject, NodePath):
|
|||
def setLODNode(self, node=None):
|
||||
"""
|
||||
Set the node that switches actor geometry in and out.
|
||||
If one is not supplied as an argument, make one"""
|
||||
If one is not supplied as an argument, make one
|
||||
"""
|
||||
if (node == None):
|
||||
lod = LODNode.LODNode("lod")
|
||||
self.__LODNode = self.__geomNode.attachNewNode(lod)
|
||||
|
|
@ -361,8 +363,9 @@ class Actor(PandaObject, NodePath):
|
|||
self.switches = {}
|
||||
|
||||
def useLOD(self, lodName):
|
||||
"""useLOD(self, string)
|
||||
Make the Actor ONLY display the given LOD"""
|
||||
"""
|
||||
Make the Actor ONLY display the given LOD
|
||||
"""
|
||||
# make sure we don't call this twice in a row
|
||||
# and pollute the the switches dictionary
|
||||
self.resetLOD()
|
||||
|
|
@ -405,7 +408,8 @@ class Actor(PandaObject, NodePath):
|
|||
def addLOD(self, lodName, inDist=0, outDist=0):
|
||||
"""addLOD(self, string)
|
||||
Add a named node under the LODNode to parent all geometry
|
||||
of a specific LOD under."""
|
||||
of a specific LOD under.
|
||||
"""
|
||||
self.__LODNode.attachNewNode(str(lodName))
|
||||
# save the switch distance info
|
||||
self.switches[lodName] = [inDist, outDist]
|
||||
|
|
@ -414,7 +418,8 @@ class Actor(PandaObject, NodePath):
|
|||
|
||||
def setLOD(self, lodName, inDist=0, outDist=0):
|
||||
"""setLOD(self, string)
|
||||
Set the switch distance for given LOD"""
|
||||
Set the switch distance for given LOD
|
||||
"""
|
||||
# save the switch distance info
|
||||
self.switches[lodName] = [inDist, outDist]
|
||||
# add the switch distance info
|
||||
|
|
@ -426,7 +431,8 @@ class Actor(PandaObject, NodePath):
|
|||
def getLOD(self, lodName):
|
||||
"""getLOD(self, string)
|
||||
Get the named node under the LOD to which we parent all LOD
|
||||
specific geometry to. Returns 'None' if not found"""
|
||||
specific geometry to. Returns 'None' if not found
|
||||
"""
|
||||
lod = self.__LODNode.find("**/" + str(lodName))
|
||||
if lod.isEmpty():
|
||||
return None
|
||||
|
|
@ -434,13 +440,12 @@ class Actor(PandaObject, NodePath):
|
|||
return lod
|
||||
|
||||
def hasLOD(self):
|
||||
"""hasLOD(self)
|
||||
Return 1 if the actor has LODs, 0 otherwise"""
|
||||
"""
|
||||
Return 1 if the actor has LODs, 0 otherwise
|
||||
"""
|
||||
return self.__hasLOD
|
||||
|
||||
def update(self, lod=0):
|
||||
""" update(lod)
|
||||
"""
|
||||
lodnames = self.getLODNames()
|
||||
if (lod < len(lodnames)):
|
||||
partBundles = self.__partBundleDict[lodnames[lod]].values()
|
||||
|
|
@ -455,7 +460,8 @@ class Actor(PandaObject, NodePath):
|
|||
Return actual frame rate of given anim name and given part.
|
||||
If no anim specified, use the currently playing anim.
|
||||
If no part specified, return anim durations of first part.
|
||||
NOTE: returns info only for an arbitrary LOD"""
|
||||
NOTE: returns info only for an arbitrary LOD
|
||||
"""
|
||||
lodName = self.__animControlDict.keys()[0]
|
||||
controls = self.getAnimControls(animName, partName)
|
||||
if len(controls) == 0:
|
||||
|
|
@ -476,11 +482,12 @@ class Actor(PandaObject, NodePath):
|
|||
return controls[0].getAnim().getBaseFrameRate()
|
||||
|
||||
def getPlayRate(self, animName=None, partName=None):
|
||||
"""getPlayRate(self, string=None, string=None)
|
||||
"""
|
||||
Return the play rate of given anim for a given part.
|
||||
If no part is given, assume first part in dictionary.
|
||||
If no anim is given, find the current anim for the part.
|
||||
NOTE: Returns info only for an arbitrary LOD"""
|
||||
NOTE: Returns info only for an arbitrary LOD
|
||||
"""
|
||||
# use the first lod
|
||||
lodName = self.__animControlDict.keys()[0]
|
||||
controls = self.getAnimControls(animName, partName)
|
||||
|
|
@ -504,11 +511,12 @@ class Actor(PandaObject, NodePath):
|
|||
control.setPlayRate(rate)
|
||||
|
||||
def getDuration(self, animName=None, partName=None):
|
||||
"""getDuration(self, string, string=None)
|
||||
"""
|
||||
Return duration of given anim name and given part.
|
||||
If no anim specified, use the currently playing anim.
|
||||
If no part specified, return anim duration of first part.
|
||||
NOTE: returns info for arbitrary LOD"""
|
||||
NOTE: returns info for arbitrary LOD
|
||||
"""
|
||||
lodName = self.__animControlDict.keys()[0]
|
||||
controls = self.getAnimControls(animName, partName)
|
||||
if len(controls) == 0:
|
||||
|
|
@ -525,10 +533,11 @@ class Actor(PandaObject, NodePath):
|
|||
return controls[0].getNumFrames()
|
||||
|
||||
def getCurrentAnim(self, partName=None):
|
||||
"""getCurrentAnim(self, string=None)
|
||||
"""
|
||||
Return the anim currently playing on the actor. If part not
|
||||
specified return current anim of an arbitrary part in dictionary.
|
||||
NOTE: only returns info for an arbitrary LOD"""
|
||||
NOTE: only returns info for an arbitrary LOD
|
||||
"""
|
||||
lodName, animControlDict = self.__animControlDict.items()[0]
|
||||
if partName == None:
|
||||
partName, animDict = animControlDict.items()[0]
|
||||
|
|
@ -548,11 +557,12 @@ class Actor(PandaObject, NodePath):
|
|||
return None
|
||||
|
||||
def getCurrentFrame(self, animName=None, partName=None):
|
||||
"""getCurrentAnim(self, string=None)
|
||||
"""
|
||||
Return the current frame number of the anim current playing on
|
||||
the actor. If part not specified return current anim of first
|
||||
part in dictionary.
|
||||
NOTE: only returns info for an arbitrary LOD"""
|
||||
NOTE: only returns info for an arbitrary LOD
|
||||
"""
|
||||
lodName, animControlDict = self.__animControlDict.items()[0]
|
||||
if partName == None:
|
||||
partName, animDict = animControlDict.items()[0]
|
||||
|
|
@ -575,9 +585,10 @@ class Actor(PandaObject, NodePath):
|
|||
# arranging
|
||||
|
||||
def getPart(self, partName, lodName="lodRoot"):
|
||||
"""getPart(self, string, key="lodRoot")
|
||||
"""
|
||||
Find the named part in the optional named lod and return it, or
|
||||
return None if not present"""
|
||||
return None if not present
|
||||
"""
|
||||
partBundleDict = self.__partBundleDict.get(lodName)
|
||||
if not partBundleDict:
|
||||
Actor.notify.warning("no lod named: %s" % (lodName))
|
||||
|
|
@ -585,10 +596,11 @@ class Actor(PandaObject, NodePath):
|
|||
return partBundleDict.get(partName)
|
||||
|
||||
def removePart(self, partName, lodName="lodRoot"):
|
||||
"""removePart(self, string, key="lodRoot")
|
||||
"""
|
||||
Remove the geometry and animations of the named part of the
|
||||
optional named lod if present.
|
||||
NOTE: this will remove child geometry also!"""
|
||||
NOTE: this will remove child geometry also!
|
||||
"""
|
||||
# find the corresponding part bundle dict
|
||||
partBundleDict = self.__partBundleDict.get(lodName)
|
||||
if not partBundleDict:
|
||||
|
|
@ -611,10 +623,11 @@ class Actor(PandaObject, NodePath):
|
|||
del(animControlDict[partName])
|
||||
|
||||
def hidePart(self, partName, lodName="lodRoot"):
|
||||
"""hidePart(self, string, key="lodName")
|
||||
"""
|
||||
Make the given part of the optionally given lod not render,
|
||||
even though still in the tree.
|
||||
NOTE: this will affect child geometry"""
|
||||
NOTE: this will affect child geometry
|
||||
"""
|
||||
partBundleDict = self.__partBundleDict.get(lodName)
|
||||
if not partBundleDict:
|
||||
Actor.notify.warning("no lod named: %s" % (lodName))
|
||||
|
|
@ -626,9 +639,10 @@ class Actor(PandaObject, NodePath):
|
|||
Actor.notify.warning("no part named %s!" % (partName))
|
||||
|
||||
def showPart(self, partName, lodName="lodRoot"):
|
||||
"""showPart(self, string, key="lodRoot")
|
||||
"""
|
||||
Make the given part render while in the tree.
|
||||
NOTE: this will affect child geometry"""
|
||||
NOTE: this will affect child geometry
|
||||
"""
|
||||
partBundleDict = self.__partBundleDict.get(lodName)
|
||||
if not partBundleDict:
|
||||
Actor.notify.warning("no lod named: %s" % (lodName))
|
||||
|
|
@ -640,9 +654,10 @@ class Actor(PandaObject, NodePath):
|
|||
Actor.notify.warning("no part named %s!" % (partName))
|
||||
|
||||
def showAllParts(self, partName, lodName="lodRoot"):
|
||||
"""showAllParts(self, string, key="lodRoot")
|
||||
"""
|
||||
Make the given part and all its children render while in the tree.
|
||||
NOTE: this will affect child geometry"""
|
||||
NOTE: this will affect child geometry
|
||||
"""
|
||||
partBundleDict = self.__partBundleDict.get(lodName)
|
||||
if not partBundleDict:
|
||||
Actor.notify.warning("no lod named: %s" % (lodName))
|
||||
|
|
@ -822,8 +837,8 @@ class Actor(PandaObject, NodePath):
|
|||
Takes an optional argument root as the start of the search for the
|
||||
given parts. Also takes optional lod name to refine search for the
|
||||
named parts. If root and lod are defined, we search for the given
|
||||
root under the given lod."""
|
||||
|
||||
root under the given lod.
|
||||
"""
|
||||
# check to see if we are working within an lod
|
||||
if (lodName != None):
|
||||
# find the named lod node
|
||||
|
|
@ -877,8 +892,8 @@ class Actor(PandaObject, NodePath):
|
|||
"""fixBounds(self, nodePath=None)
|
||||
Force recomputation of bounding spheres for all geoms
|
||||
in a given part. If no part specified, fix all geoms
|
||||
in this actor"""
|
||||
|
||||
in this actor
|
||||
"""
|
||||
# if no part name specified fix all parts
|
||||
if (part==None):
|
||||
part = self
|
||||
|
|
@ -904,8 +919,9 @@ class Actor(PandaObject, NodePath):
|
|||
thisGeomNode.node().markBoundStale()
|
||||
|
||||
def showAllBounds(self):
|
||||
"""showAllBounds(self)
|
||||
Show the bounds of all actor geoms"""
|
||||
"""
|
||||
Show the bounds of all actor geoms
|
||||
"""
|
||||
geomNodes = self.__geomNode.findAllMatches("**/+GeomNode")
|
||||
numGeomNodes = geomNodes.getNumPaths()
|
||||
|
||||
|
|
@ -913,8 +929,9 @@ class Actor(PandaObject, NodePath):
|
|||
geomNodes.getPath(nodeNum).showBounds()
|
||||
|
||||
def hideAllBounds(self):
|
||||
"""hideAllBounds(self)
|
||||
Hide the bounds of all actor geoms"""
|
||||
"""
|
||||
Hide the bounds of all actor geoms
|
||||
"""
|
||||
geomNodes = self.__geomNode.findAllMatches("**/+GeomNode")
|
||||
numGeomNodes = geomNodes.getNumPaths()
|
||||
|
||||
|
|
@ -957,7 +974,8 @@ class Actor(PandaObject, NodePath):
|
|||
Loop the given animation on the given part of the actor,
|
||||
restarting at zero frame if requested. If no part name
|
||||
is given then try to loop on all parts. NOTE: loops on
|
||||
all LOD's"""
|
||||
all LOD's
|
||||
"""
|
||||
if fromFrame == None:
|
||||
for control in self.getAnimControls(animName, partName):
|
||||
control.loop(restart)
|
||||
|
|
@ -1010,7 +1028,8 @@ class Actor(PandaObject, NodePath):
|
|||
Actor.notify.warning("Couldn't find part: %s" % (partName))
|
||||
|
||||
def disableBlend(self, partName = None):
|
||||
""" Restores normal one-animation-at-a-time operation after a
|
||||
"""
|
||||
Restores normal one-animation-at-a-time operation after a
|
||||
previous call to enableBlend().
|
||||
"""
|
||||
self.enableBlend(PartBundle.BTSingle, partName)
|
||||
|
|
@ -1225,8 +1244,8 @@ class Actor(PandaObject, NodePath):
|
|||
Actor anim loader. Takes an optional partName (defaults to
|
||||
'modelRoot' for non-multipart actors) and lodName (defaults
|
||||
to 'lodRoot' for non-LOD actors) and dict of corresponding
|
||||
anims in the form animName:animPath{}"""
|
||||
|
||||
anims in the form animName:animPath{}
|
||||
"""
|
||||
Actor.notify.debug("in loadAnims: %s, part: %s, lod: %s" %
|
||||
(anims, partName, lodName))
|
||||
|
||||
|
|
@ -1246,8 +1265,8 @@ class Actor(PandaObject, NodePath):
|
|||
'modelRoot' for non-multipart actors) and lodName (defaults
|
||||
to 'lodRoot' for non-LOD actors) and dict of corresponding
|
||||
anims in the form animName:animPath{}. Deletes the anim control
|
||||
for the given animation and parts/lods."""
|
||||
|
||||
for the given animation and parts/lods.
|
||||
"""
|
||||
Actor.notify.debug("in unloadAnims: %s, part: %s, lod: %s" %
|
||||
(anims, partName, lodName))
|
||||
|
||||
|
|
@ -1283,7 +1302,6 @@ class Actor(PandaObject, NodePath):
|
|||
"""bindAnim(self, string, string='modelRoot', string='lodRoot')
|
||||
Bind the named animation to the named part and lod
|
||||
"""
|
||||
|
||||
if lodName == None:
|
||||
lodNames = self.__animControl.keys()
|
||||
else:
|
||||
|
|
@ -1301,7 +1319,9 @@ class Actor(PandaObject, NodePath):
|
|||
|
||||
|
||||
def __bindAnimToPart(self, animName, partName, lodName):
|
||||
"""for internal use only!"""
|
||||
"""
|
||||
for internal use only!
|
||||
"""
|
||||
# make sure this anim is in the dict
|
||||
if not self.__animControlDict[lodName][partName].has_key(animName):
|
||||
Actor.notify.debug("actor has no animation %s", animName)
|
||||
|
|
@ -1346,7 +1366,8 @@ class Actor(PandaObject, NodePath):
|
|||
def __copyPartBundles(self, other):
|
||||
"""__copyPartBundles(self, Actor)
|
||||
Copy the part bundle dictionary from another actor as this
|
||||
instance's own. NOTE: this method does not actually copy geometry"""
|
||||
instance's own. NOTE: this method does not actually copy geometry
|
||||
"""
|
||||
for lodName in other.__partBundleDict.keys():
|
||||
self.__partBundleDict[lodName] = {}
|
||||
for partName in other.__partBundleDict[lodName].keys():
|
||||
|
|
|
|||
|
|
@ -6,11 +6,6 @@ import time
|
|||
import math
|
||||
|
||||
class Logger:
|
||||
|
||||
"""Logger class: """
|
||||
|
||||
# built-ins
|
||||
|
||||
def __init__(self, fileName="log"):
|
||||
"""__init__(self)
|
||||
Logger constructor"""
|
||||
|
|
@ -18,26 +13,26 @@ class Logger:
|
|||
self.__startTime = 0.0
|
||||
self.__logFile = None
|
||||
self.__logFileName = fileName
|
||||
|
||||
|
||||
# setters and getters
|
||||
|
||||
def setTimeStamp(self, bool):
|
||||
"""setTimeStamp(self, int)
|
||||
Toggle time stamp printing with log entries on and off"""
|
||||
"""
|
||||
Toggle time stamp printing with log entries on and off
|
||||
"""
|
||||
self.__timeStamp = bool
|
||||
|
||||
def getTimeStamp(self):
|
||||
"""getTimeStamp(self)
|
||||
Return whether or not we are printing time stamps with log entries"""
|
||||
"""
|
||||
Return whether or not we are printing time stamps with log entries
|
||||
"""
|
||||
return(self.__timeStamp)
|
||||
|
||||
|
||||
# logging control
|
||||
|
||||
def resetStartTime(self):
|
||||
"""resetStartTime()
|
||||
Reset the start time of the log file for time stamps"""
|
||||
"""
|
||||
Reset the start time of the log file for time stamps
|
||||
"""
|
||||
self.__startTime = time.time()
|
||||
|
||||
def log(self, entryString):
|
||||
|
|
@ -53,8 +48,9 @@ class Logger:
|
|||
# logging functions
|
||||
|
||||
def __openLogFile(self):
|
||||
"""__openLogFile(self)
|
||||
Open a file for logging error/warning messages"""
|
||||
"""
|
||||
Open a file for logging error/warning messages
|
||||
"""
|
||||
self.resetStartTime()
|
||||
t = time.localtime(self.__startTime)
|
||||
st = time.strftime("%m-%d-%Y-%H-%M-%S", t)
|
||||
|
|
@ -62,14 +58,16 @@ class Logger:
|
|||
self.__logFile = open(logFileName, "w")
|
||||
|
||||
def __closeLogFile(self):
|
||||
"""__closeLogFile(self)
|
||||
Close the error/warning output file"""
|
||||
"""
|
||||
Close the error/warning output file
|
||||
"""
|
||||
if (self.__logFile != None):
|
||||
self.__logFile.close()
|
||||
|
||||
def __getTimeStamp(self):
|
||||
"""__getTimeStamp(self)
|
||||
Return the offset between current time and log file startTime"""
|
||||
"""
|
||||
Return the offset between current time and log file startTime
|
||||
"""
|
||||
t = time.time()
|
||||
dt = t - self.__startTime
|
||||
if (dt >= 86400):
|
||||
|
|
|
|||
|
|
@ -121,19 +121,22 @@ class Notifier:
|
|||
return 1 # to allow assert(myNotify.warning("blah"))
|
||||
|
||||
def setWarning(self, bool):
|
||||
"""setWarning(self, int)
|
||||
Enable/Disable the printing of warning messages"""
|
||||
"""
|
||||
Enable/Disable the printing of warning messages
|
||||
"""
|
||||
self.__warning = bool
|
||||
|
||||
def getWarning(self):
|
||||
"""getWarning(self)
|
||||
Return whether the printing of warning messages is on or off"""
|
||||
"""
|
||||
Return whether the printing of warning messages is on or off
|
||||
"""
|
||||
return(self.__warning)
|
||||
|
||||
# debug funcs
|
||||
def debug(self, debugString):
|
||||
"""debug(self, string)
|
||||
Issue the debug message if debug flag is on"""
|
||||
"""
|
||||
Issue the debug message if debug flag is on
|
||||
"""
|
||||
if (self.__debug):
|
||||
string = (self.getTime() + self.__name + '(debug): ' + debugString)
|
||||
self.__log(string)
|
||||
|
|
@ -141,19 +144,22 @@ class Notifier:
|
|||
return 1 # to allow assert(myNotify.debug("blah"))
|
||||
|
||||
def setDebug(self, bool):
|
||||
"""setDebug(self, int)
|
||||
Enable/Disable the printing of debug messages"""
|
||||
"""
|
||||
Enable/Disable the printing of debug messages
|
||||
"""
|
||||
self.__debug = bool
|
||||
|
||||
def getDebug(self):
|
||||
"""getDebug(self)
|
||||
Return whether the printing of debug messages is on or off"""
|
||||
"""
|
||||
Return whether the printing of debug messages is on or off
|
||||
"""
|
||||
return(self.__debug)
|
||||
|
||||
# info funcs
|
||||
def info(self, infoString):
|
||||
"""info(self, string)
|
||||
Print the given informational string, if info flag is on"""
|
||||
"""
|
||||
Print the given informational string, if info flag is on
|
||||
"""
|
||||
if (self.__info):
|
||||
string = (self.getTime() + self.__name + '(info): ' + infoString)
|
||||
self.__log(string)
|
||||
|
|
@ -162,7 +168,8 @@ class Notifier:
|
|||
|
||||
def getInfo(self):
|
||||
"""
|
||||
Return whether the printing of info messages is on or off"""
|
||||
Return whether the printing of info messages is on or off
|
||||
"""
|
||||
return(self.__info)
|
||||
|
||||
def setInfo(self, bool):
|
||||
|
|
@ -173,19 +180,22 @@ class Notifier:
|
|||
|
||||
# log funcs
|
||||
def __log(self, logEntry):
|
||||
"""__log(self, string)
|
||||
Determine whether to send informational message to the logger"""
|
||||
"""
|
||||
Determine whether to send informational message to the logger
|
||||
"""
|
||||
if (self.__logging):
|
||||
self.__logger.log(logEntry)
|
||||
|
||||
def getLogging(self):
|
||||
"""
|
||||
Return 1 if logging enabled, 0 otherwise"""
|
||||
Return 1 if logging enabled, 0 otherwise
|
||||
"""
|
||||
return (self.__logging)
|
||||
|
||||
def setLogging(self, bool):
|
||||
"""
|
||||
Set the logging flag to int (1=on, 0=off)"""
|
||||
Set the logging flag to int (1=on, 0=off)
|
||||
"""
|
||||
self.__logging = bool
|
||||
|
||||
def __print(self, string):
|
||||
|
|
|
|||
|
|
@ -241,7 +241,6 @@ class ClockDelta(DirectObject.DirectObject):
|
|||
# by which the network time differs from 'now'.
|
||||
if bits == 16:
|
||||
diff = self.__signExtend(networkTime - ntime)
|
||||
|
||||
else:
|
||||
# Assume the bits is either 16 or 32. If it's 32, no need
|
||||
# to sign-extend. 32 bits gives us about 227 days of
|
||||
|
|
@ -273,8 +272,7 @@ class ClockDelta(DirectObject.DirectObject):
|
|||
|
||||
def getRealNetworkTime(self, bits=16,
|
||||
ticksPerSec=NetworkTimePrecision):
|
||||
"""getRealNetworkTime(self)
|
||||
|
||||
"""
|
||||
Returns the current getRealTime() expressed as a network time.
|
||||
"""
|
||||
return self.localToNetworkTime(self.globalClock.getRealTime(),
|
||||
|
|
@ -283,8 +281,7 @@ class ClockDelta(DirectObject.DirectObject):
|
|||
|
||||
def getFrameNetworkTime(self, bits=16,
|
||||
ticksPerSec=NetworkTimePrecision):
|
||||
"""getFrameNetworkTime(self)
|
||||
|
||||
"""
|
||||
Returns the current getFrameTime() expressed as a network time.
|
||||
"""
|
||||
return self.localToNetworkTime(self.globalClock.getFrameTime(),
|
||||
|
|
@ -298,7 +295,6 @@ class ClockDelta(DirectObject.DirectObject):
|
|||
Returns the amount of time elapsed (in seconds) on the client
|
||||
since the server message was sent. Negative values are
|
||||
clamped to zero.
|
||||
|
||||
"""
|
||||
now = self.globalClock.getFrameTime()
|
||||
dt = now - self.networkToLocalTime(networkTime, now, bits=bits,
|
||||
|
|
@ -306,8 +302,6 @@ class ClockDelta(DirectObject.DirectObject):
|
|||
|
||||
return max(dt, 0.0)
|
||||
|
||||
|
||||
|
||||
### Private functions ###
|
||||
|
||||
def __signExtend(self, networkTime):
|
||||
|
|
@ -316,7 +310,6 @@ class ClockDelta(DirectObject.DirectObject):
|
|||
Preserves the lower NetworkTimeBits of the networkTime value,
|
||||
and extends the sign bit all the way up.
|
||||
"""
|
||||
|
||||
return ((networkTime & NetworkTimeMask) << NetworkTimeTopBits) >> NetworkTimeTopBits
|
||||
|
||||
globalClockDelta = ClockDelta()
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ class ClassicFSM(DirectObject):
|
|||
return(self.__name)
|
||||
|
||||
def setName(self, name):
|
||||
"""setName(self, string)"""
|
||||
self.__name = name
|
||||
|
||||
def getStates(self):
|
||||
|
|
@ -135,14 +134,12 @@ class ClassicFSM(DirectObject):
|
|||
return(self.__initialState)
|
||||
|
||||
def setInitialState(self, initialStateName):
|
||||
"""setInitialState(self, string)"""
|
||||
self.__initialState = self.getStateNamed(initialStateName)
|
||||
|
||||
def getFinalState(self):
|
||||
return(self.__finalState)
|
||||
|
||||
def setFinalState(self, finalStateName):
|
||||
"""setFinalState(self, string)"""
|
||||
self.__finalState = self.getStateNamed(finalStateName)
|
||||
|
||||
def requestFinalState(self):
|
||||
|
|
@ -155,8 +152,9 @@ class ClassicFSM(DirectObject):
|
|||
# lookup funcs
|
||||
|
||||
def getStateNamed(self, stateName):
|
||||
"""getStateNamed(self, string)
|
||||
Return the state with given name if found, issue warning otherwise"""
|
||||
"""
|
||||
Return the state with given name if found, issue warning otherwise
|
||||
"""
|
||||
state = self.__states.get(stateName)
|
||||
if state:
|
||||
return state
|
||||
|
|
@ -211,7 +209,8 @@ class ClassicFSM(DirectObject):
|
|||
|
||||
def __transition(self, aState, enterArgList=[], exitArgList=[]):
|
||||
"""__transition(self, State, enterArgList, exitArgList)
|
||||
Exit currentState and enter given one"""
|
||||
Exit currentState and enter given one
|
||||
"""
|
||||
assert(not self.__internalStateInFlux)
|
||||
self.__internalStateInFlux = 1
|
||||
self.__exitCurrent(exitArgList)
|
||||
|
|
@ -220,7 +219,7 @@ class ClassicFSM(DirectObject):
|
|||
|
||||
def request(self, aStateName, enterArgList=[], exitArgList=[],
|
||||
force=0):
|
||||
"""request(self, string)
|
||||
"""
|
||||
Attempt transition from currentState to given one.
|
||||
Return true is transition exists to given state,
|
||||
false otherwise.
|
||||
|
|
@ -309,7 +308,7 @@ class ClassicFSM(DirectObject):
|
|||
self.request(aStateName, enterArgList, exitArgList, force=1)
|
||||
|
||||
def conditional_request(self, aStateName, enterArgList=[], exitArgList=[]):
|
||||
"""request(self, string)
|
||||
"""
|
||||
'if this transition is defined, do it'
|
||||
Attempt transition from currentState to given one, if it exists.
|
||||
Return true if transition exists to given state,
|
||||
|
|
@ -318,7 +317,6 @@ class ClassicFSM(DirectObject):
|
|||
ClassicFSM transitions, letting the same fn be used for different states
|
||||
that may not have the same out transitions.
|
||||
"""
|
||||
|
||||
assert(not self.__internalStateInFlux)
|
||||
if not self.__currentState:
|
||||
# Make this a warning for now
|
||||
|
|
|
|||
|
|
@ -74,8 +74,6 @@ class State(DirectObject):
|
|||
# can transition to any other state
|
||||
Any = 'ANY'
|
||||
|
||||
"""State class: """
|
||||
|
||||
def __init__(self, name, enterFunc=None, exitFunc=None,
|
||||
transitions=Any, inspectorPos = []):
|
||||
"""__init__(self, string, func, func, string[], inspectorPos = [])
|
||||
|
|
@ -92,15 +90,12 @@ class State(DirectObject):
|
|||
# setters and getters
|
||||
|
||||
def getName(self):
|
||||
"""getName(self)"""
|
||||
return(self.__name)
|
||||
|
||||
def setName(self, stateName):
|
||||
"""setName(self, string)"""
|
||||
self.__name = stateName
|
||||
|
||||
def getEnterFunc(self):
|
||||
"""getEnterFunc(self)"""
|
||||
return(self.__enterFunc)
|
||||
|
||||
if __debug__:
|
||||
|
|
@ -130,11 +125,9 @@ class State(DirectObject):
|
|||
self.__enterFunc = stateEnterFunc
|
||||
|
||||
def getExitFunc(self):
|
||||
"""getExitFunc(self)"""
|
||||
return(self.__exitFunc)
|
||||
|
||||
def setExitFunc(self, stateExitFunc):
|
||||
"""setExitFunc(self, func)"""
|
||||
if __debug__:
|
||||
self.redefineFunc(self.__exitFunc, stateExitFunc, ExitFuncRedefineMap)
|
||||
self.__exitFunc = stateExitFunc
|
||||
|
|
@ -144,7 +137,7 @@ class State(DirectObject):
|
|||
return self.__transitions is State.Any
|
||||
|
||||
def getTransitions(self):
|
||||
"""getTransitions(self)
|
||||
"""
|
||||
warning -- if the state transitions to any other state,
|
||||
returns an empty list (falsely implying that the state
|
||||
has no transitions)
|
||||
|
|
@ -188,34 +181,40 @@ class State(DirectObject):
|
|||
# support for HFSMs
|
||||
|
||||
def getChildren(self):
|
||||
"""getChildren(self)
|
||||
Return the list of child FSMs"""
|
||||
"""
|
||||
Return the list of child FSMs
|
||||
"""
|
||||
return(self.__FSMList)
|
||||
|
||||
def setChildren(self, FSMList):
|
||||
"""setChildren(self, ClassicFSM[])
|
||||
Set the children to given list of FSMs"""
|
||||
Set the children to given list of FSMs
|
||||
"""
|
||||
self.__FSMList = FSMList
|
||||
|
||||
def addChild(self, ClassicFSM):
|
||||
"""addChild(self, ClassicFSM)
|
||||
Add the given ClassicFSM to list of child FSMs"""
|
||||
"""
|
||||
Add the given ClassicFSM to list of child FSMs
|
||||
"""
|
||||
self.__FSMList.append(ClassicFSM)
|
||||
|
||||
def removeChild(self, ClassicFSM):
|
||||
"""removeChild(self, ClassicFSM)
|
||||
Remove the given ClassicFSM from list of child FSMs"""
|
||||
"""
|
||||
Remove the given ClassicFSM from list of child FSMs
|
||||
"""
|
||||
if ClassicFSM in self.__FSMList:
|
||||
self.__FSMList.remove(ClassicFSM)
|
||||
|
||||
def hasChildren(self):
|
||||
"""hasChildren(self)
|
||||
Return true if state has child FSMs"""
|
||||
"""
|
||||
Return true if state has child FSMs
|
||||
"""
|
||||
return len(self.__FSMList) > 0
|
||||
|
||||
def __enterChildren(self, argList):
|
||||
"""__enterChildren(self, argList)
|
||||
Enter all child FSMs"""
|
||||
"""
|
||||
Enter all child FSMs
|
||||
"""
|
||||
for fsm in self.__FSMList:
|
||||
# Check to see if the child fsm is already in a state
|
||||
# if it is, politely request the initial state
|
||||
|
|
@ -233,8 +232,9 @@ class State(DirectObject):
|
|||
fsm.enterInitialState()
|
||||
|
||||
def __exitChildren(self, argList):
|
||||
"""__exitChildren(self, argList)
|
||||
Exit all child FSMs"""
|
||||
"""
|
||||
Exit all child FSMs
|
||||
"""
|
||||
for fsm in self.__FSMList:
|
||||
fsm.request((fsm.getFinalState()).getName())
|
||||
|
||||
|
|
@ -242,9 +242,9 @@ class State(DirectObject):
|
|||
# basic State functionality
|
||||
|
||||
def enter(self, argList=[]):
|
||||
"""enter(self)
|
||||
Call the enter function for this state"""
|
||||
|
||||
"""
|
||||
Call the enter function for this state
|
||||
"""
|
||||
# enter child FSMs first. It is assumed these have a start
|
||||
# state that is safe to enter
|
||||
self.__enterChildren(argList)
|
||||
|
|
@ -253,8 +253,9 @@ class State(DirectObject):
|
|||
apply(self.__enterFunc, argList)
|
||||
|
||||
def exit(self, argList=[]):
|
||||
"""exit(self)
|
||||
Call the exit function for this state"""
|
||||
"""
|
||||
Call the exit function for this state
|
||||
"""
|
||||
# first exit child FSMs
|
||||
self.__exitChildren(argList)
|
||||
|
||||
|
|
@ -263,7 +264,6 @@ class State(DirectObject):
|
|||
apply(self.__exitFunc, argList)
|
||||
|
||||
def __str__(self):
|
||||
"""__str__(self)"""
|
||||
return "State: name = %s, enter = %s, exit = %s, trans = %s, children = %s" %\
|
||||
(self.__name, self.__enterFunc, self.__exitFunc, self.__transitions, self.__FSMList)
|
||||
|
||||
|
|
|
|||
|
|
@ -155,7 +155,6 @@ class ParticleEffect(NodePath):
|
|||
return self.forceGroupDict.get(name, None)
|
||||
|
||||
def getForceGroupDict(self):
|
||||
"""getForceGroup()"""
|
||||
return self.forceGroupDict
|
||||
|
||||
def saveConfig(self, filename):
|
||||
|
|
|
|||
Loading…
Reference in New Issue