mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 00:06:44 -04:00
*** empty log message ***
This commit is contained in:
parent
ae77863a93
commit
a85771f39d
@ -51,20 +51,20 @@ class ClientDistClass:
|
|||||||
|
|
||||||
def updateField(self, do, di):
|
def updateField(self, do, di):
|
||||||
# Get the update field id
|
# Get the update field id
|
||||||
fieldId = di.getArg(ST_uint8)
|
fieldId = di.getArg(STUint16)
|
||||||
# look up the CDU
|
# look up the CDU
|
||||||
assert(self.number2CDU.has_key(fieldId))
|
assert(self.number2CDU.has_key(fieldId))
|
||||||
cdu = self.number2CDU[fieldId]
|
cdu = self.number2CDU[fieldId]
|
||||||
# Let the cdu finish the job
|
# Let the cdu finish the job
|
||||||
cdu.updateField(cdc, do, di)
|
cdu.updateField(self, do, di)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def sendUpdate(self, do, fieldName, args):
|
def sendUpdate(self, cr, do, fieldName, args):
|
||||||
# Look up the cdu
|
# Look up the cdu
|
||||||
assert(self.name2CDU.has_key(fieldName))
|
assert(self.name2CDU.has_key(fieldName))
|
||||||
cdu = self.name2CDU[fieldName]
|
cdu = self.name2CDU[fieldName]
|
||||||
# Let the cdu finish the job
|
# Let the cdu finish the job
|
||||||
cdu.sendUpdate(do, args)
|
cdu.sendUpdate(cr, do, args)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
import DirectNotifyGlobal
|
import DirectNotifyGlobal
|
||||||
import Avatar
|
import Avatar
|
||||||
import DistributedToon
|
import DistributedToon
|
||||||
|
import Datagram
|
||||||
|
from MsgTypes import *
|
||||||
|
|
||||||
class ClientDistUpdate:
|
class ClientDistUpdate:
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("ClientDistUpdate")
|
notify = DirectNotifyGlobal.directNotify.newCategory("ClientDistUpdate")
|
||||||
@ -28,7 +30,7 @@ class ClientDistUpdate:
|
|||||||
componentField = dcFieldMolecular.getAtomic(i)
|
componentField = dcFieldMolecular.getAtomic(i)
|
||||||
for j in range(0, componentField.getNumElements()):
|
for j in range(0, componentField.getNumElements()):
|
||||||
self.types.append(componentField.getElementType(j))
|
self.types.append(componentField.getElementType(j))
|
||||||
self.types.append(componentField.getElementDivisor(j))
|
self.divisors.append(componentField.getElementDivisor(j))
|
||||||
else:
|
else:
|
||||||
ClientDistUpdate.notify.error("field is neither atom nor molecule")
|
ClientDistUpdate.notify.error("field is neither atom nor molecule")
|
||||||
return None
|
return None
|
||||||
@ -57,17 +59,17 @@ class ClientDistUpdate:
|
|||||||
numElems = len(args)
|
numElems = len(args)
|
||||||
assert (numElems == len(self.types))
|
assert (numElems == len(self.types))
|
||||||
for i in range(0, numElems):
|
for i in range(0, numElems):
|
||||||
datagram.addArg(args[i], self.types[i])
|
datagram.putArg(args[i], self.types[i])
|
||||||
|
|
||||||
def sendUpdate(self, do, args):
|
def sendUpdate(self, cr, do, args):
|
||||||
datagram = Datagram()
|
datagram = Datagram.Datagram()
|
||||||
# Add message type
|
# Add message type
|
||||||
datagram.addUint16(ALL_OBJECT_UPDATE_FIELD)
|
datagram.addUint16(CLIENT_OBJECT_UPDATE_FIELD)
|
||||||
# Add the DO id
|
# Add the DO id
|
||||||
datagram.addUint32(do.doId)
|
datagram.addUint32(do.doId)
|
||||||
# Add the field id
|
# Add the field id
|
||||||
datagram.addUint8(self.number)
|
datagram.addUint16(self.number)
|
||||||
# Add the arguments
|
# Add the arguments
|
||||||
self.addArgs(datagram, args)
|
self.addArgs(datagram, args)
|
||||||
# send the datagram
|
# send the datagram
|
||||||
|
cr.send(datagram)
|
||||||
|
@ -106,7 +106,7 @@ class ClientRepository(DirectObject.DirectObject):
|
|||||||
distObj.updateRequiredFields(cdc, di)
|
distObj.updateRequiredFields(cdc, di)
|
||||||
else:
|
else:
|
||||||
# Construct a new one
|
# Construct a new one
|
||||||
distObj = constructor()
|
distObj = constructor(self)
|
||||||
# Assign it an Id
|
# Assign it an Id
|
||||||
distObj.doId = doId
|
distObj.doId = doId
|
||||||
# Update the required fields
|
# Update the required fields
|
||||||
@ -119,10 +119,10 @@ class ClientRepository(DirectObject.DirectObject):
|
|||||||
|
|
||||||
def handleUpdateField(self, di):
|
def handleUpdateField(self, di):
|
||||||
# Get the DO Id
|
# Get the DO Id
|
||||||
doId = di.getArg(ST_uint32)
|
doId = di.getArg(STUint32)
|
||||||
# Find the DO
|
# Find the DO
|
||||||
assert(self.doId2do.has_key(doId))
|
assert(self.doId2do.has_key(doId))
|
||||||
do = self.doId2do(doId)
|
do = self.doId2do[doId]
|
||||||
# Find the cdc
|
# Find the cdc
|
||||||
assert(self.doId2cdc.has_key(doId))
|
assert(self.doId2cdc.has_key(doId))
|
||||||
cdc = self.doId2cdc[doId]
|
cdc = self.doId2cdc[doId]
|
||||||
@ -136,5 +136,8 @@ class ClientRepository(DirectObject.DirectObject):
|
|||||||
assert(self.doId2cdc.has_key(doId))
|
assert(self.doId2cdc.has_key(doId))
|
||||||
cdc = self.doId2cdc[doId]
|
cdc = self.doId2cdc[doId]
|
||||||
# Let the cdc finish the job
|
# Let the cdc finish the job
|
||||||
cdc.sendUpdate(do, fieldName, args)
|
cdc.sendUpdate(self, do, fieldName, args)
|
||||||
|
|
||||||
|
def send(self, datagram):
|
||||||
|
self.cw.send(datagram, self.tcpConn)
|
||||||
|
return None
|
||||||
|
@ -6,11 +6,12 @@ import Actor
|
|||||||
class DistributedActor(DistributedNode.DistributedNode, Actor.Actor):
|
class DistributedActor(DistributedNode.DistributedNode, Actor.Actor):
|
||||||
"""Distributed Actor class:"""
|
"""Distributed Actor class:"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, cr):
|
||||||
try:
|
try:
|
||||||
self.DistributedActor_initialized
|
self.DistributedActor_initialized
|
||||||
except:
|
except:
|
||||||
self.DistributedActor_initialized = 1
|
self.DistributedActor_initialized = 1
|
||||||
|
DistributedNode.DistributedNode.__init__(self, cr)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,11 +6,12 @@ import DistributedObject
|
|||||||
class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
||||||
"""Distributed Node class:"""
|
"""Distributed Node class:"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, cr):
|
||||||
try:
|
try:
|
||||||
self.DistributedNode_initialized
|
self.DistributedNode_initialized
|
||||||
except:
|
except:
|
||||||
self.DistributedNode_initialized = 1
|
self.DistributedNode_initialized = 1
|
||||||
|
DistributedObject.DistributedObject.__init__(self, cr)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def generateInit(self, di):
|
def generateInit(self, di):
|
||||||
@ -22,10 +23,10 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
|||||||
def d_setHpr(self, h, p, r):
|
def d_setHpr(self, h, p, r):
|
||||||
self.sendUpdate("setHpr", [h, p, r])
|
self.sendUpdate("setHpr", [h, p, r])
|
||||||
|
|
||||||
def d_setPosHpr(self):
|
def d_broadcastPosHpr(self):
|
||||||
|
|
||||||
self.d_setPos_Hpr(self.getX(), self.getY(), self.getZ(),
|
self.d_setPosHpr(self.getX(), self.getY(), self.getZ(),
|
||||||
self.getH(), self.getP(), self.getR())
|
self.getH(), self.getP(), self.getR())
|
||||||
|
|
||||||
def d_setPosHpr(self, x, y, z, h, p, r):
|
def d_setPosHpr(self, x, y, z, h, p, r):
|
||||||
self.sendUpdate("setPosHpr", [x, y, z, h, p, r])
|
self.sendUpdate("setPosHpr", [x, y, z, h, p, r])
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
"""DistributedObject module: contains the DistributedObject class"""
|
"""DistributedObject module: contains the DistributedObject class"""
|
||||||
|
|
||||||
from PandaObject import *
|
from PandaObject import *
|
||||||
|
from ToonBaseGlobal import *
|
||||||
|
|
||||||
class DistributedObject(PandaObject):
|
class DistributedObject(PandaObject):
|
||||||
"""Distributed Object class:"""
|
"""Distributed Object class:"""
|
||||||
def __init__(self):
|
def __init__(self, cr):
|
||||||
try:
|
try:
|
||||||
self.DistributedObject_initialized
|
self.DistributedObject_initialized
|
||||||
except:
|
except:
|
||||||
self.DistributedObject_initialized = 1
|
self.DistributedObject_initialized = 1
|
||||||
|
self.cr = cr
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getDoId(self):
|
def getDoId(self):
|
||||||
@ -22,7 +24,7 @@ class DistributedObject(PandaObject):
|
|||||||
i.updateField(cdc, self, di)
|
i.updateField(cdc, self, di)
|
||||||
|
|
||||||
def sendUpdate(self, fieldName, args):
|
def sendUpdate(self, fieldName, args):
|
||||||
cr.sendupdate(self, fieldName, args)
|
self.cr.sendUpdate(self, fieldName, args)
|
||||||
|
|
||||||
def taskName(self, taskString):
|
def taskName(self, taskString):
|
||||||
return (taskString + "-" + str(self.getDoId))
|
return (taskString + "-" + str(self.getDoId))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user