mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
*** empty log message ***
This commit is contained in:
parent
71ad80feff
commit
56a6cc4ca9
@ -1,75 +1,85 @@
|
||||
"""ClientDistClass module: contains the ClientDistClass class"""
|
||||
|
||||
from PandaModules import *
|
||||
import DirectNotifyGlobal
|
||||
import ClientDistUpdate
|
||||
|
||||
class ClientDistClass:
|
||||
|
||||
def __init__(self, dcClass):
|
||||
self.number = dcClass.getNumber()
|
||||
self.name = dcClass.getName()
|
||||
self.allFields = self.parseFields(dcClass)
|
||||
self.allCDU = self.createAllCDU(self.allFields)
|
||||
self.number2CDU = self.createNumber2CDUDict(self.allCDU)
|
||||
self.name2CDU = self.createName2CDUDict(self.allCDU)
|
||||
self.allRequiredCDU = self.listRequiredCDU(self.allCDU)
|
||||
# Import the class, and store the constructor
|
||||
exec("import " + self.name)
|
||||
self.constructor = eval(self.name + "." + self.name)
|
||||
return None
|
||||
|
||||
def parseFields(self, dcClass):
|
||||
fields=[]
|
||||
for i in range(0,dcClass.getNumInheritedFields()):
|
||||
fields.append(dcClass.getInheritedField(i))
|
||||
return fields
|
||||
|
||||
def createAllCDU(self, allFields):
|
||||
allCDU = []
|
||||
for i in allFields:
|
||||
allCDU.append(ClientDistUpdate.ClientDistUpdate(self, i))
|
||||
return allCDU
|
||||
|
||||
def createNumber2CDUDict(self, allCDU):
|
||||
dict={}
|
||||
for i in allCDU:
|
||||
dict[i.number] = i
|
||||
return dict
|
||||
|
||||
def createName2CDUDict(self, allCDU):
|
||||
dict={}
|
||||
for i in allCDU:
|
||||
dict[i.name] = i
|
||||
return dict
|
||||
|
||||
def listRequiredCDU(self, allCDU):
|
||||
requiredCDU = []
|
||||
for i in allCDU:
|
||||
atom = i.field.asAtomicField()
|
||||
if atom:
|
||||
if (atom.isRequired() and atom.isBroadcast()):
|
||||
requiredCDU.append(i)
|
||||
return requiredCDU
|
||||
|
||||
def updateField(self, do, di):
|
||||
# Get the update field id
|
||||
fieldId = di.getArg(STUint16)
|
||||
# look up the CDU
|
||||
assert(self.number2CDU.has_key(fieldId))
|
||||
cdu = self.number2CDU[fieldId]
|
||||
# Let the cdu finish the job
|
||||
cdu.updateField(self, do, di)
|
||||
return None
|
||||
|
||||
def sendUpdate(self, cr, do, fieldName, args):
|
||||
# Look up the cdu
|
||||
assert(self.name2CDU.has_key(fieldName))
|
||||
cdu = self.name2CDU[fieldName]
|
||||
# Let the cdu finish the job
|
||||
cdu.sendUpdate(cr, do, args)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""ClientDistClass module: contains the ClientDistClass class"""
|
||||
|
||||
from PandaModules import *
|
||||
import DirectNotifyGlobal
|
||||
import ClientDistUpdate
|
||||
|
||||
class ClientDistClass:
|
||||
|
||||
def __init__(self, dcClass):
|
||||
self.number = dcClass.getNumber()
|
||||
self.name = dcClass.getName()
|
||||
self.allFields = self.parseFields(dcClass)
|
||||
self.allCDU = self.createAllCDU(self.allFields)
|
||||
self.number2CDU = self.createNumber2CDUDict(self.allCDU)
|
||||
self.name2CDU = self.createName2CDUDict(self.allCDU)
|
||||
self.broadcastRequiredCDU = self.listBroadcastRequiredCDU(self.allCDU)
|
||||
self.allRequiredCDU = self.listRequiredCDU(self.allCDU)
|
||||
# Import the class, and store the constructor
|
||||
exec("import " + self.name)
|
||||
self.constructor = eval(self.name + "." + self.name)
|
||||
return None
|
||||
|
||||
def parseFields(self, dcClass):
|
||||
fields=[]
|
||||
for i in range(0,dcClass.getNumInheritedFields()):
|
||||
fields.append(dcClass.getInheritedField(i))
|
||||
return fields
|
||||
|
||||
def createAllCDU(self, allFields):
|
||||
allCDU = []
|
||||
for i in allFields:
|
||||
allCDU.append(ClientDistUpdate.ClientDistUpdate(self, i))
|
||||
return allCDU
|
||||
|
||||
def createNumber2CDUDict(self, allCDU):
|
||||
dict={}
|
||||
for i in allCDU:
|
||||
dict[i.number] = i
|
||||
return dict
|
||||
|
||||
def createName2CDUDict(self, allCDU):
|
||||
dict={}
|
||||
for i in allCDU:
|
||||
dict[i.name] = i
|
||||
return dict
|
||||
|
||||
def listBroadcastRequiredCDU(self, allCDU):
|
||||
requiredCDU = []
|
||||
for i in allCDU:
|
||||
atom = i.field.asAtomicField()
|
||||
if atom:
|
||||
if (atom.isRequired() and atom.isBroadcast()):
|
||||
requiredCDU.append(i)
|
||||
return requiredCDU
|
||||
|
||||
def listRequiredCDU(self, allCDU):
|
||||
requiredCDU = []
|
||||
for i in allCDU:
|
||||
atom = i.field.asAtomicField()
|
||||
if atom:
|
||||
if (atom.isRequired()):
|
||||
requiredCDU.append(i)
|
||||
return requiredCDU
|
||||
|
||||
def updateField(self, do, di):
|
||||
# Get the update field id
|
||||
fieldId = di.getArg(STUint16)
|
||||
# look up the CDU
|
||||
assert(self.number2CDU.has_key(fieldId))
|
||||
cdu = self.number2CDU[fieldId]
|
||||
# Let the cdu finish the job
|
||||
cdu.updateField(self, do, di)
|
||||
return None
|
||||
|
||||
def sendUpdate(self, cr, do, fieldName, args):
|
||||
# Look up the cdu
|
||||
assert(self.name2CDU.has_key(fieldName))
|
||||
cdu = self.name2CDU[fieldName]
|
||||
# Let the cdu finish the job
|
||||
cdu.sendUpdate(cr, do, args)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -49,12 +49,16 @@ class DistributedObject(PandaObject):
|
||||
return self.doId
|
||||
|
||||
def updateRequiredFields(self, cdc, di):
|
||||
for i in cdc.broadcastRequiredCDU:
|
||||
i.updateField(cdc, self, di)
|
||||
|
||||
def updateAllRequiredFields(self, cdc, di):
|
||||
for i in cdc.allRequiredCDU:
|
||||
i.updateField(cdc, self, di)
|
||||
|
||||
def updateRequiredOtherFields(self, cdc, di):
|
||||
# First, update the required fields
|
||||
for i in cdc.allRequiredCDU:
|
||||
for i in cdc.broadcastRequiredCDU:
|
||||
i.updateField(cdc, self, di)
|
||||
# Determine how many other fields there are
|
||||
numberOfOtherFields = di.getArg(STUint16)
|
||||
|
Loading…
x
Reference in New Issue
Block a user