mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
*** empty log message ***
This commit is contained in:
parent
cb167c9867
commit
bd9709a8a4
@ -45,7 +45,7 @@ class ClientDistClass:
|
|||||||
for i in allCDU:
|
for i in allCDU:
|
||||||
atom = i.field.asAtomicField()
|
atom = i.field.asAtomicField()
|
||||||
if atom:
|
if atom:
|
||||||
if atom.isRequired():
|
if (atom.isRequired() and atom.isBroadcast()):
|
||||||
requiredCDU.append(i)
|
requiredCDU.append(i)
|
||||||
return requiredCDU
|
return requiredCDU
|
||||||
|
|
||||||
|
@ -36,23 +36,17 @@ class ClientDistUpdate:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def updateField(self, cdc, do, di):
|
def updateField(self, cdc, do, di):
|
||||||
# Look up the class
|
|
||||||
#aClass = eval(cdc.name + "." + cdc.name)
|
|
||||||
# Look up the function
|
|
||||||
#assert(aClass.__dict__.has_key(self.name))
|
|
||||||
#func = aClass.__dict__[self.name]
|
|
||||||
|
|
||||||
# HACK HACK HACK HACK!!!!!
|
func = eval(cdc.name + "." + cdc.name + "." + self.name)
|
||||||
try:
|
#print("Calling: " + cdc.name + "." + cdc.name + "." + self.name +
|
||||||
do.LocalToon_initialized
|
# " for do " + str(do.getDoId()))
|
||||||
except:
|
|
||||||
func = eval(cdc.name + "." + cdc.name + "." + self.name)
|
# Get the arguments into a list
|
||||||
print("Calling: " + cdc.name + "." + cdc.name + "." + self.name +
|
args = self.extractArgs(di)
|
||||||
" for do " + str(do.getDoId()))
|
|
||||||
# Get the arguments into a list
|
# Apply the function to the object with the arguments
|
||||||
args = self.extractArgs(di)
|
apply(func, [do] + args)
|
||||||
# Apply the function to the object with the arguments
|
|
||||||
apply(func, [do] + args)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def extractArgs(self, di):
|
def extractArgs(self, di):
|
||||||
|
@ -45,10 +45,15 @@ class ClientRepository(DirectObject.DirectObject):
|
|||||||
self.qcm=QueuedConnectionManager()
|
self.qcm=QueuedConnectionManager()
|
||||||
self.tcpConn = self.qcm.openTCPClientConnection(
|
self.tcpConn = self.qcm.openTCPClientConnection(
|
||||||
serverName, serverPort, 1000)
|
serverName, serverPort, 1000)
|
||||||
self.qcr=QueuedConnectionReader(self.qcm, 0)
|
# Test for bad connection
|
||||||
self.qcr.addConnection(self.tcpConn)
|
if self.tcpConn == None:
|
||||||
self.cw=ConnectionWriter(self.qcm, 0)
|
return None
|
||||||
self.startReaderPollTask()
|
else:
|
||||||
|
self.qcr=QueuedConnectionReader(self.qcm, 0)
|
||||||
|
self.qcr.addConnection(self.tcpConn)
|
||||||
|
self.cw=ConnectionWriter(self.qcm, 0)
|
||||||
|
self.startReaderPollTask()
|
||||||
|
return self.tcpConn
|
||||||
|
|
||||||
def startReaderPollTask(self):
|
def startReaderPollTask(self):
|
||||||
task = Task.Task(self.readerPollUntilEmpty)
|
task = Task.Task(self.readerPollUntilEmpty)
|
||||||
@ -92,14 +97,22 @@ class ClientRepository(DirectObject.DirectObject):
|
|||||||
doId, di)
|
doId, di)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def generateWithRequiredFields(self, cdc, constructor, doId, di):
|
def handleGenerateWithRequiredOther(self, di):
|
||||||
# Someday, this function will look in a cache of old distributed
|
# Get the class Id
|
||||||
# objects to see if this object is in there, and pull it
|
classId = di.getArg(STUint16);
|
||||||
# out if necessary. For now, we'll just check to see if
|
# Get the DO Id
|
||||||
# it is in the standard dictionary, and ignore this update
|
doId = di.getArg(STUint32)
|
||||||
# if it is there. The right thing to do would be to update
|
# Look up the cdc
|
||||||
# all the required fields, but that will come later, too.
|
cdc = self.number2cdc[classId]
|
||||||
|
# Create a new distributed object, and put it in the dictionary
|
||||||
|
distObj = self.generateWithRequiredOtherFields(cdc,
|
||||||
|
eval(cdc.name + \
|
||||||
|
"." + \
|
||||||
|
cdc.name),
|
||||||
|
doId, di)
|
||||||
|
return None
|
||||||
|
|
||||||
|
def generateWithRequiredFields(self, cdc, constructor, doId, di):
|
||||||
# Is it in our dictionary?
|
# Is it in our dictionary?
|
||||||
if self.doId2do.has_key(doId):
|
if self.doId2do.has_key(doId):
|
||||||
# If so, just update it.
|
# If so, just update it.
|
||||||
@ -131,6 +144,39 @@ class ClientRepository(DirectObject.DirectObject):
|
|||||||
|
|
||||||
return distObj
|
return distObj
|
||||||
|
|
||||||
|
def generateWithRequiredOtherFields(self, cdc, constructor, doId, di):
|
||||||
|
# Is it in our dictionary?
|
||||||
|
if self.doId2do.has_key(doId):
|
||||||
|
# If so, just update it.
|
||||||
|
distObj = self.doId2do[doId]
|
||||||
|
distObj.updateRequiredOtherFields(cdc, di)
|
||||||
|
|
||||||
|
# Is it in the cache? If so, pull it out, put it in the dictionaries,
|
||||||
|
# and update it.
|
||||||
|
elif self.cache.contains(doId):
|
||||||
|
# If so, pull it out of the cache...
|
||||||
|
distObj = self.cache.retrieve(doId)
|
||||||
|
# put it in both dictionaries...
|
||||||
|
self.doId2do[doId] = distObj
|
||||||
|
self.doId2cdc[doId] = cdc
|
||||||
|
# and update it.
|
||||||
|
distObj.updateRequiredOtherFields(cdc, di)
|
||||||
|
|
||||||
|
# If it is not in the dictionary or the cache, then...
|
||||||
|
else:
|
||||||
|
# Construct a new one
|
||||||
|
distObj = constructor(self)
|
||||||
|
# Assign it an Id
|
||||||
|
distObj.doId = doId
|
||||||
|
# Update the required fields
|
||||||
|
distObj.updateRequiredOtherFields(cdc, di)
|
||||||
|
# Put the new do in both dictionaries
|
||||||
|
self.doId2do[doId] = distObj
|
||||||
|
self.doId2cdc[doId] = cdc
|
||||||
|
|
||||||
|
return distObj
|
||||||
|
|
||||||
|
|
||||||
def handleDisable(self, di):
|
def handleDisable(self, di):
|
||||||
# Get the DO Id
|
# Get the DO Id
|
||||||
doId = di.getArg(STUint32)
|
doId = di.getArg(STUint32)
|
||||||
|
@ -16,9 +16,13 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self.reparent(hidden)
|
self.reparentTo(hidden)
|
||||||
DistributedObject.DistributedObject.disable(self)
|
DistributedObject.DistributedObject.disable(self)
|
||||||
|
|
||||||
|
def delete(self):
|
||||||
|
self.reparentTo(hidden)
|
||||||
|
DistributedObject.DistributedObject.delete(self)
|
||||||
|
|
||||||
def d_setPos(self, x, y, z):
|
def d_setPos(self, x, y, z):
|
||||||
self.sendUpdate("setPos", [x, y, z])
|
self.sendUpdate("setPos", [x, y, z])
|
||||||
|
|
||||||
|
@ -35,6 +35,17 @@ class DistributedObject(PandaObject):
|
|||||||
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):
|
||||||
|
# First, update the required fields
|
||||||
|
for i in cdc.allRequiredCDU:
|
||||||
|
i.updateField(cdc, self, di)
|
||||||
|
# Determine how many other fields there are
|
||||||
|
numberOfOtherFields = di.getArg(STUint16)
|
||||||
|
# Update each of the other fields
|
||||||
|
for i in range(numberOfOtherFields):
|
||||||
|
cdc.updateField(self, di)
|
||||||
|
return None
|
||||||
|
|
||||||
def sendUpdate(self, fieldName, args):
|
def sendUpdate(self, fieldName, args):
|
||||||
self.cr.sendUpdate(self, fieldName, args)
|
self.cr.sendUpdate(self, fieldName, args)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user