mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
support local calls to setSm*
This commit is contained in:
parent
2d2f8d7100
commit
506cf473cf
@ -139,6 +139,7 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|||||||
position. This may result in a pop as the node skips the last
|
position. This may result in a pop as the node skips the last
|
||||||
of its lerp points.
|
of its lerp points.
|
||||||
"""
|
"""
|
||||||
|
#printStack()
|
||||||
if (not self.isLocal()) and \
|
if (not self.isLocal()) and \
|
||||||
self.smoother.getLatestPosition():
|
self.smoother.getLatestPosition():
|
||||||
self.smoother.applySmoothMat(self)
|
self.smoother.applySmoothMat(self)
|
||||||
@ -151,6 +152,7 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|||||||
used whenever show code bangs on the node position and expects
|
used whenever show code bangs on the node position and expects
|
||||||
it to stick.
|
it to stick.
|
||||||
"""
|
"""
|
||||||
|
#printStack()
|
||||||
self.smoother.clearPositions(0)
|
self.smoother.clearPositions(0)
|
||||||
self.smoother.setMat(self.getMat())
|
self.smoother.setMat(self.getMat())
|
||||||
self.smoother.setPhonyTimestamp()
|
self.smoother.setPhonyTimestamp()
|
||||||
@ -158,28 +160,28 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|||||||
|
|
||||||
# distributed set pos and hpr functions
|
# distributed set pos and hpr functions
|
||||||
# 'send' versions are inherited from DistributedSmoothNodeBase
|
# 'send' versions are inherited from DistributedSmoothNodeBase
|
||||||
def setSmStop(self, timestamp):
|
def setSmStop(self, timestamp=None):
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmH(self, h, timestamp):
|
def setSmH(self, h, timestamp=None):
|
||||||
self.setComponentH(h)
|
self.setComponentH(h)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmZ(self, z, timestamp):
|
def setSmZ(self, z, timestamp=None):
|
||||||
self.setComponentZ(z)
|
self.setComponentZ(z)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmXY(self, x, y, timestamp):
|
def setSmXY(self, x, y, timestamp=None):
|
||||||
self.setComponentX(x)
|
self.setComponentX(x)
|
||||||
self.setComponentY(y)
|
self.setComponentY(y)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmXZ(self, x, z, timestamp):
|
def setSmXZ(self, x, z, timestamp=None):
|
||||||
self.setComponentX(x)
|
self.setComponentX(x)
|
||||||
self.setComponentZ(z)
|
self.setComponentZ(z)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmPos(self, x, y, z, timestamp):
|
def setSmPos(self, x, y, z, timestamp=None):
|
||||||
self.setComponentX(x)
|
self.setComponentX(x)
|
||||||
self.setComponentY(y)
|
self.setComponentY(y)
|
||||||
self.setComponentZ(z)
|
self.setComponentZ(z)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmHpr(self, h, p, r, timestamp):
|
def setSmHpr(self, h, p, r, timestamp=None):
|
||||||
self.setComponentH(h)
|
self.setComponentH(h)
|
||||||
self.setComponentP(p)
|
self.setComponentP(p)
|
||||||
self.setComponentR(r)
|
self.setComponentR(r)
|
||||||
@ -189,13 +191,13 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|||||||
self.setComponentY(y)
|
self.setComponentY(y)
|
||||||
self.setComponentH(h)
|
self.setComponentH(h)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmXYZH(self, x, y, z, h, timestamp):
|
def setSmXYZH(self, x, y, z, h, timestamp=None):
|
||||||
self.setComponentX(x)
|
self.setComponentX(x)
|
||||||
self.setComponentY(y)
|
self.setComponentY(y)
|
||||||
self.setComponentZ(z)
|
self.setComponentZ(z)
|
||||||
self.setComponentH(h)
|
self.setComponentH(h)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmPosHpr(self, x, y, z, h, p, r, timestamp):
|
def setSmPosHpr(self, x, y, z, h, p, r, timestamp=None):
|
||||||
self.setComponentX(x)
|
self.setComponentX(x)
|
||||||
self.setComponentY(y)
|
self.setComponentY(y)
|
||||||
self.setComponentZ(z)
|
self.setComponentZ(z)
|
||||||
@ -246,38 +248,51 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|||||||
# whenever we receive a live update directly from the other
|
# whenever we receive a live update directly from the other
|
||||||
# client. This is because the component functions, above,
|
# client. This is because the component functions, above,
|
||||||
# call this function explicitly instead of setComponentT().
|
# call this function explicitly instead of setComponentT().
|
||||||
|
|
||||||
now = globalClock.getFrameTime()
|
|
||||||
local = globalClockDelta.networkToLocalTime(timestamp, now)
|
|
||||||
realTime = globalClock.getRealTime()
|
|
||||||
chug = realTime - now
|
|
||||||
|
|
||||||
# Sanity check the timestamp from the other avatar. It should
|
#print 'setComponentTLive: %s' % timestamp
|
||||||
# be just slightly in the past, but it might be off by as much
|
|
||||||
# as this frame's amount of time forward or back.
|
if timestamp is None:
|
||||||
howFarFuture = local - now
|
# if no timestamp, re-use the most recent timestamp to keep things
|
||||||
if howFarFuture - chug >= MaxFuture:
|
# from getting out of order
|
||||||
# Too far off; advise the other client of our clock information.
|
if self.smoother.hasMostRecentTimestamp():
|
||||||
if globalClockDelta.getUncertainty() != None and \
|
self.smoother.setTimestamp(self.smoother.getMostRecentTimestamp())
|
||||||
realTime - self.lastSuggestResync >= MinSuggestResync:
|
else:
|
||||||
self.lastSuggestResync = realTime
|
# no most-recent timestamp, use current time
|
||||||
timestampB = globalClockDelta.localToNetworkTime(realTime)
|
self.smoother.setPhonyTimestamp()
|
||||||
serverTime = realTime - globalClockDelta.getDelta()
|
self.smoother.markPosition()
|
||||||
self.notify.info(
|
else:
|
||||||
"Suggesting resync for %s, with discrepency %s; local time is %s and server time is %s." % (
|
now = globalClock.getFrameTime()
|
||||||
self.doId, howFarFuture - chug,
|
local = globalClockDelta.networkToLocalTime(timestamp, now)
|
||||||
realTime, serverTime))
|
realTime = globalClock.getRealTime()
|
||||||
self.d_suggestResync(
|
chug = realTime - now
|
||||||
self.cr.localAvatarDoId, timestamp,
|
|
||||||
timestampB, serverTime,
|
# Sanity check the timestamp from the other avatar. It should
|
||||||
globalClockDelta.getUncertainty())
|
# be just slightly in the past, but it might be off by as much
|
||||||
|
# as this frame's amount of time forward or back.
|
||||||
self.smoother.setTimestamp(local)
|
howFarFuture = local - now
|
||||||
self.smoother.markPosition()
|
if howFarFuture - chug >= MaxFuture:
|
||||||
|
# Too far off; advise the other client of our clock information.
|
||||||
|
if globalClockDelta.getUncertainty() != None and \
|
||||||
|
realTime - self.lastSuggestResync >= MinSuggestResync:
|
||||||
|
self.lastSuggestResync = realTime
|
||||||
|
timestampB = globalClockDelta.localToNetworkTime(realTime)
|
||||||
|
serverTime = realTime - globalClockDelta.getDelta()
|
||||||
|
self.notify.info(
|
||||||
|
"Suggesting resync for %s, with discrepency %s; local time is %s and server time is %s." % (
|
||||||
|
self.doId, howFarFuture - chug,
|
||||||
|
realTime, serverTime))
|
||||||
|
self.d_suggestResync(
|
||||||
|
self.cr.localAvatarDoId, timestamp,
|
||||||
|
timestampB, serverTime,
|
||||||
|
globalClockDelta.getUncertainty())
|
||||||
|
|
||||||
|
self.smoother.setTimestamp(local)
|
||||||
|
self.smoother.markPosition()
|
||||||
|
|
||||||
def clearSmoothing(self, bogus = None):
|
def clearSmoothing(self, bogus = None):
|
||||||
# Call this to invalidate all the old position reports
|
# Call this to invalidate all the old position reports
|
||||||
# (e.g. just before popping to a new position).
|
# (e.g. just before popping to a new position).
|
||||||
|
#printStack()
|
||||||
self.smoother.clearPositions(1)
|
self.smoother.clearPositions(1)
|
||||||
|
|
||||||
|
|
||||||
@ -286,6 +301,7 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|||||||
# automatically reset the smoothing position when we call it.
|
# automatically reset the smoothing position when we call it.
|
||||||
if self.smoothStarted:
|
if self.smoothStarted:
|
||||||
if self._smoothWrtReparents:
|
if self._smoothWrtReparents:
|
||||||
|
#print self.getParent(), parent, self.getParent().getPos(parent)
|
||||||
self.smoother.handleWrtReparent(self.getParent(), parent)
|
self.smoother.handleWrtReparent(self.getParent(), parent)
|
||||||
NodePath.wrtReparentTo(self, parent)
|
NodePath.wrtReparentTo(self, parent)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user