mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -04:00
debugging statements and cleanup to help track down disable problems
This commit is contained in:
parent
b7380ee5e9
commit
5c328305cf
@ -16,6 +16,7 @@ class CRCache:
|
|||||||
"""
|
"""
|
||||||
Delete each item in the cache then clear all references to them
|
Delete each item in the cache then clear all references to them
|
||||||
"""
|
"""
|
||||||
|
assert(self.checkCache())
|
||||||
CRCache.notify.debug("Flushing the cache")
|
CRCache.notify.debug("Flushing the cache")
|
||||||
for distObj in self.dict.values():
|
for distObj in self.dict.values():
|
||||||
distObj.delete()
|
distObj.delete()
|
||||||
@ -26,6 +27,7 @@ class CRCache:
|
|||||||
def cache(self, distObj):
|
def cache(self, distObj):
|
||||||
# Only distributed objects are allowed in the cache
|
# Only distributed objects are allowed in the cache
|
||||||
assert(isinstance(distObj, DistributedObject.DistributedObject))
|
assert(isinstance(distObj, DistributedObject.DistributedObject))
|
||||||
|
assert(self.checkCache())
|
||||||
# Get the doId
|
# Get the doId
|
||||||
doId = distObj.getDoId()
|
doId = distObj.getDoId()
|
||||||
# Error check
|
# Error check
|
||||||
@ -53,6 +55,7 @@ class CRCache:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def retrieve(self, doId):
|
def retrieve(self, doId):
|
||||||
|
assert(self.checkCache())
|
||||||
if self.dict.has_key(doId):
|
if self.dict.has_key(doId):
|
||||||
# Find the object
|
# Find the object
|
||||||
distObj = self.dict[doId]
|
distObj = self.dict[doId]
|
||||||
@ -70,6 +73,7 @@ class CRCache:
|
|||||||
return self.dict.has_key(doId)
|
return self.dict.has_key(doId)
|
||||||
|
|
||||||
def delete(self, doId):
|
def delete(self, doId):
|
||||||
|
assert(self.checkCache())
|
||||||
assert(self.dict.has_key(doId))
|
assert(self.dict.has_key(doId))
|
||||||
# Look it up
|
# Look it up
|
||||||
distObj = self.dict[doId]
|
distObj = self.dict[doId]
|
||||||
@ -79,3 +83,11 @@ class CRCache:
|
|||||||
# and delete it
|
# and delete it
|
||||||
distObj.delete()
|
distObj.delete()
|
||||||
|
|
||||||
|
def checkCache(self):
|
||||||
|
# For debugging; this verifies that the cache is sensible and
|
||||||
|
# returns true if so.
|
||||||
|
from PandaModules import NodePath
|
||||||
|
for obj in self.dict.values():
|
||||||
|
if isinstance(obj, NodePath):
|
||||||
|
assert(not obj.isEmpty() and obj.getTopNode() == hidden.node())
|
||||||
|
return 1
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"""DistributedNode module: contains the DistributedNode class"""
|
"""DistributedNode module: contains the DistributedNode class"""
|
||||||
|
|
||||||
from ShowBaseGlobal import *
|
from ShowBaseGlobal import *
|
||||||
import NodePath
|
from PandaModules import NodePath
|
||||||
import DistributedObject
|
import DistributedObject
|
||||||
import Task
|
import Task
|
||||||
|
|
||||||
class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
class DistributedNode(DistributedObject.DistributedObject, NodePath):
|
||||||
"""Distributed Node class:"""
|
"""Distributed Node class:"""
|
||||||
|
|
||||||
def __init__(self, cr):
|
def __init__(self, cr):
|
||||||
@ -65,9 +65,10 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
|||||||
DistributedAvatar) to override the behavior of setParent if
|
DistributedAvatar) to override the behavior of setParent if
|
||||||
desired.
|
desired.
|
||||||
"""
|
"""
|
||||||
assert(self.cr.token2nodePath.has_key(parentToken))
|
if not self.disabled:
|
||||||
parent = self.cr.token2nodePath[parentToken]
|
assert(self.cr.token2nodePath.has_key(parentToken))
|
||||||
self.wrtReparentTo(parent)
|
parent = self.cr.token2nodePath[parentToken]
|
||||||
|
self.wrtReparentTo(parent)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
###### set pos and hpr functions #######
|
###### set pos and hpr functions #######
|
||||||
|
@ -34,6 +34,12 @@ class DistributedObject(PandaObject):
|
|||||||
# This flag tells whether a delete has been requested on this
|
# This flag tells whether a delete has been requested on this
|
||||||
# object.
|
# object.
|
||||||
self.deleteImminent = 0
|
self.deleteImminent = 0
|
||||||
|
|
||||||
|
# It's useful to have a "disabled" flag. This is only
|
||||||
|
# trustworthy if the inheriting class properly calls up
|
||||||
|
# the chain for disable() and generate().
|
||||||
|
self.disabled = 1
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
#def __del__(self):
|
#def __del__(self):
|
||||||
@ -118,7 +124,7 @@ class DistributedObject(PandaObject):
|
|||||||
"""disable(self)
|
"""disable(self)
|
||||||
Inheritors should redefine this to take appropriate action on disable
|
Inheritors should redefine this to take appropriate action on disable
|
||||||
"""
|
"""
|
||||||
pass
|
self.disabled = 1
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
"""delete(self)
|
"""delete(self)
|
||||||
@ -135,7 +141,7 @@ class DistributedObject(PandaObject):
|
|||||||
"""generate(self)
|
"""generate(self)
|
||||||
Inheritors should redefine this to take appropriate action on generate
|
Inheritors should redefine this to take appropriate action on generate
|
||||||
"""
|
"""
|
||||||
pass
|
self.disabled = 0
|
||||||
|
|
||||||
def generateInit(self):
|
def generateInit(self):
|
||||||
"""generateInit(self)
|
"""generateInit(self)
|
||||||
@ -177,5 +183,12 @@ class DistributedObject(PandaObject):
|
|||||||
def uniqueName(self, idString):
|
def uniqueName(self, idString):
|
||||||
return (idString + "-" + str(self.getDoId()))
|
return (idString + "-" + str(self.getDoId()))
|
||||||
|
|
||||||
|
def isLocal(self):
|
||||||
|
# This returns true if the distributed object is "local,"
|
||||||
|
# which means the client created it instead of the AI, and it
|
||||||
|
# gets some other special handling. Normally, only the local
|
||||||
|
# avatar class overrides this to return true.
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -327,8 +327,3 @@ class DistributedSmoothNode(DistributedNode.DistributedNode):
|
|||||||
self.reloadPosition()
|
self.reloadPosition()
|
||||||
else:
|
else:
|
||||||
NodePath.wrtReparentTo(self, parent)
|
NodePath.wrtReparentTo(self, parent)
|
||||||
|
|
||||||
|
|
||||||
def isLocal(self):
|
|
||||||
# Local toon will override this to return true
|
|
||||||
return 0
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user