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