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
c9cbb60c2a
commit
c91d322a3b
@ -21,8 +21,8 @@ class ClusterConfigItem:
|
||||
class DisplayConnection:
|
||||
def __init__(self,qcm,serverName,port,msgHandler):
|
||||
self.msgHandler = msgHandler
|
||||
gameServerTimeoutMs = base.config.GetInt("game-server-timeout-ms",
|
||||
20000)
|
||||
gameServerTimeoutMs = base.config.GetInt(
|
||||
"game-server-timeout-ms", 20000)
|
||||
# A big old 20 second timeout.
|
||||
self.tcpConn = qcm.openTCPClientConnection(
|
||||
serverName, port, gameServerTimeoutMs)
|
||||
@ -60,7 +60,9 @@ class DisplayConnection:
|
||||
|
||||
# the following should only be called by a synchronized cluster manger
|
||||
def sendSwapNow(self):
|
||||
ClusterManager.notify.debug( ("dispaly connect send swap now, packet %d" % self.msgHandler.packetNumber))
|
||||
ClusterManager.notify.debug(
|
||||
"display connect send swap now, packet %d" %
|
||||
self.msgHandler.packetNumber)
|
||||
datagram = self.msgHandler.makeSwapNowDatagram()
|
||||
self.cw.send(datagram, self.tcpConn)
|
||||
|
||||
@ -68,27 +70,26 @@ class ClusterManager(DirectObject.DirectObject):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("ClusterClient")
|
||||
MGR_NUM = 1000000
|
||||
|
||||
def __init__(self, dispConfigs):
|
||||
def __init__(self, configList):
|
||||
self.qcm=QueuedConnectionManager()
|
||||
self.dispList = []
|
||||
self.serverList = []
|
||||
self.msgHandler = MsgHandler(ClusterManager.MGR_NUM,self.notify)
|
||||
for dispConfig in dispConfigs:
|
||||
thisDisp = DisplayConnection(self.qcm,dispConfig.serverName,
|
||||
dispConfig.port,self.msgHandler)
|
||||
if thisDisp == None:
|
||||
for serverConfig in configList:
|
||||
server = DisplayConnection(self.qcm,serverConfig.serverName,
|
||||
serverConfig.port,self.msgHandler)
|
||||
if server == None:
|
||||
self.notify.error( ('Could not open %s on %s port %d' %
|
||||
(dispConfig.serverFunction,
|
||||
dispConfig.serverName,
|
||||
dispConfig.port)) )
|
||||
(serverConfig.serverFunction,
|
||||
serverConfig.serverName,
|
||||
serverConfig.port)) )
|
||||
else:
|
||||
self.dispList.append(thisDisp)
|
||||
self.dispList[len(self.dispList)-1].sendCamOffset(
|
||||
dispConfig.xyz,dispConfig.hpr)
|
||||
server.sendCamOffset(serverConfig.xyz,serverConfig.hpr)
|
||||
self.serverList.append(server)
|
||||
self.startMoveCamTask()
|
||||
|
||||
def moveCamera(self, xyz, hpr):
|
||||
for disp in self.dispList:
|
||||
disp.sendMoveCam(xyz,hpr)
|
||||
for server in self.serverList:
|
||||
server.sendMoveCam(xyz,hpr)
|
||||
|
||||
def startMoveCamTask(self):
|
||||
task = Task.Task(self.moveCameraTask,49)
|
||||
@ -104,8 +105,8 @@ class ClusterManager(DirectObject.DirectObject):
|
||||
|
||||
class ClusterManagerSync(ClusterManager):
|
||||
|
||||
def __init__(self, dispConfigs):
|
||||
ClusterManager.__init__(self, dispConfigs)
|
||||
def __init__(self, configList):
|
||||
ClusterManager.__init__(self, configList)
|
||||
#I probably don't need this
|
||||
self.waitForSwap = 0
|
||||
self.ready = 0
|
||||
@ -120,20 +121,24 @@ class ClusterManagerSync(ClusterManager):
|
||||
self.ready = 1
|
||||
if self.waitForSwap:
|
||||
self.waitForSwap=0
|
||||
self.notify.debug("START get swaps----------------------------------")
|
||||
self.notify.debug(
|
||||
"START get swaps----------------------------------")
|
||||
localClock = ClockObject()
|
||||
t1 = localClock.getRealTime()
|
||||
for disp in self.dispList:
|
||||
disp.getSwapReady()
|
||||
self.notify.debug("----------------START swap now--------------------")
|
||||
for server in self.serverList:
|
||||
server.getSwapReady()
|
||||
self.notify.debug(
|
||||
"----------------START swap now--------------------")
|
||||
t2 = localClock.getRealTime()
|
||||
for disp in self.dispList:
|
||||
disp.sendSwapNow()
|
||||
self.notify.debug("------------------------------START swap----------")
|
||||
for server in self.serverList:
|
||||
server.sendSwapNow()
|
||||
self.notify.debug(
|
||||
"------------------------------START swap----------")
|
||||
t3 = localClock.getRealTime()
|
||||
base.win.swap()
|
||||
t4 = localClock.getRealTime()
|
||||
self.notify.debug("------------------------------------------END swap")
|
||||
self.notify.debug(
|
||||
"------------------------------------------END swap")
|
||||
self.notify.debug( ("times=%f %f %f %f" % (t1,t2,t3,t4)) )
|
||||
self.notify.debug( ("deltas=%f %f %f" % (t2-t1,t3-t2,t4-t3)) )
|
||||
return Task.cont
|
||||
|
@ -7,46 +7,67 @@ import string
|
||||
# For mono-modelcave-pipe0, I decided to set the offsets in the
|
||||
# actual configuration for the display.
|
||||
|
||||
ClientConfigs = {'mono-modelcave-pipe0': [ [Vec3(0,0,0),Vec3(0,0,0)] ],
|
||||
'single': [ [Vec3(0,0,0),Vec3(0,0,0)] ]}
|
||||
# Specify offset from client for each server's camera group
|
||||
# Note: If server chan-config consists of multiple display regions
|
||||
# each display region can have an additional offset as specified in
|
||||
# DirectCamConfig.py
|
||||
ClientConfigs = {'mono-modelcave-pipe0': [ [Vec3(0),Vec3(0)] ],
|
||||
'single-server': [ [Vec3(0),Vec3(0)] ],
|
||||
'two-server' : [ [Vec3(0),Vec3(-60,0,0)],
|
||||
[Vec3(0),Vec3(60,0,0)]
|
||||
],
|
||||
'cavetest' : [ [Vec3(0), Vec3(0)],
|
||||
[Vec3(0), Vec3(0)],
|
||||
[Vec3(0), Vec3(0)],
|
||||
[Vec3(0), Vec3(0)]
|
||||
],
|
||||
}
|
||||
|
||||
# The following is a fake configuration to show an example with two servers.
|
||||
# 'two-server' : [ [Vec3(0,0,0),Vec3(-60,0,0)],
|
||||
# [Vec3(0,0,0),Vec3(60,0,0) ] ]
|
||||
|
||||
def createCluster():
|
||||
# setup camera offsets based on chanconfig
|
||||
# This should ideally be independent of chan-config. In other
|
||||
# words, there might be some other configuration for clustering,
|
||||
# from which the number and offset of the servers' cameras are set.
|
||||
chanConfig = base.config.GetString('chan-config', 'single')
|
||||
|
||||
if base.config.GetBool('display-client'):
|
||||
if not ClientConfigs.has_key(chanConfig):
|
||||
base.notify.warning('Display Client flag set, but %s is not a display client configuration.' % chanConfig)
|
||||
return None
|
||||
thisClientConfig = ClientConfigs[chanConfig]
|
||||
displayConfigs = []
|
||||
for i in range(len(thisClientConfig)):
|
||||
configString = 'display%d' % i
|
||||
serverString = base.config.GetString(configString, '')
|
||||
if serverString == '':
|
||||
base.notify.warning('%s should be defined in Configrc to use %s as display client.' % [configString,chanConfig])
|
||||
base.notify.warning('%s will not be used.' % configString)
|
||||
else:
|
||||
serverInfo = string.split(serverString)
|
||||
if len(serverInfo) > 1:
|
||||
port = int(serverInfo[1])
|
||||
else:
|
||||
port = CLUSTER_PORT
|
||||
displayConfigs.append(ClusterConfigItem(configString,
|
||||
serverInfo[0], thisClientConfig[i][0], thisClientConfig[i][1],port))
|
||||
|
||||
synced = base.config.GetBool('sync-display',0)
|
||||
if synced:
|
||||
base.win.setSync(1)
|
||||
return ClusterManagerSync(displayConfigs)
|
||||
def createClusterManager():
|
||||
# setup camera offsets based on cluster-config
|
||||
clusterConfig = base.config.GetString('cluster-config', 'single-server')
|
||||
# No cluster config specified!
|
||||
if not ClientConfigs.has_key(clusterConfig):
|
||||
base.notify.warning(
|
||||
'display-client flag set, but %s cluster-config is undefined.' %
|
||||
clusterConfig)
|
||||
return None
|
||||
# Get display config for each server in the cluster
|
||||
displayConfigs = []
|
||||
configData = ClientConfigs[clusterConfig]
|
||||
numConfigs = len(configData)
|
||||
for i in range(numConfigs):
|
||||
serverConfigName = 'display%d' % i
|
||||
serverString = base.config.GetString(serverConfigName, '')
|
||||
if serverString == '':
|
||||
base.notify.warning(
|
||||
'%s undefined in Configrc: expected by %s display client.' %
|
||||
(serverConfigName,clusterConfig))
|
||||
base.notify.warning('%s will not be used.' % serverConfigName)
|
||||
else:
|
||||
serverInfo = string.split(serverString)
|
||||
serverName = serverInfo[0]
|
||||
if len(serverInfo) > 1:
|
||||
port = int(serverInfo[1])
|
||||
else:
|
||||
# Use default port
|
||||
port = CLUSTER_PORT
|
||||
displayConfigs.append(ClusterConfigItem(
|
||||
serverConfigName,
|
||||
serverName,
|
||||
# Pos Offset
|
||||
configData[i][0],
|
||||
# Hpr Offset
|
||||
configData[i][1],
|
||||
port))
|
||||
# Create Cluster Managers (opening connections to servers)
|
||||
# Are the servers going to be synced?
|
||||
synced = base.config.GetBool('sync-display', 0)
|
||||
if synced:
|
||||
base.win.setSync(1)
|
||||
return ClusterManagerSync(displayConfigs)
|
||||
else:
|
||||
return ClusterManager(displayConfigs)
|
||||
|
||||
|
||||
|
@ -35,7 +35,10 @@ class DirectSession(PandaObject):
|
||||
"models/fonts/Comic",
|
||||
priority = 100)
|
||||
self.iAmAClient = base.config.GetBool("display-client",0)
|
||||
self.clusterManager = createCluster()
|
||||
if self.iAmAClient:
|
||||
self.clusterManager = createClusterManager()
|
||||
else:
|
||||
self.clusterManager = None
|
||||
self.iAmAServer = base.config.GetBool("display-server",0)
|
||||
self.fEnabled = 0
|
||||
self.drList = DisplayRegionList()
|
||||
|
Loading…
x
Reference in New Issue
Block a user