|
|
@@ -139,6 +139,7 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|
|
position. This may result in a pop as the node skips the last
|
|
|
of its lerp points.
|
|
|
"""
|
|
|
+ #printStack()
|
|
|
if (not self.isLocal()) and \
|
|
|
self.smoother.getLatestPosition():
|
|
|
self.smoother.applySmoothMat(self)
|
|
|
@@ -151,6 +152,7 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|
|
used whenever show code bangs on the node position and expects
|
|
|
it to stick.
|
|
|
"""
|
|
|
+ #printStack()
|
|
|
self.smoother.clearPositions(0)
|
|
|
self.smoother.setMat(self.getMat())
|
|
|
self.smoother.setPhonyTimestamp()
|
|
|
@@ -158,28 +160,28 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|
|
|
|
|
# distributed set pos and hpr functions
|
|
|
# 'send' versions are inherited from DistributedSmoothNodeBase
|
|
|
- def setSmStop(self, timestamp):
|
|
|
+ def setSmStop(self, timestamp=None):
|
|
|
self.setComponentTLive(timestamp)
|
|
|
- def setSmH(self, h, timestamp):
|
|
|
+ def setSmH(self, h, timestamp=None):
|
|
|
self.setComponentH(h)
|
|
|
self.setComponentTLive(timestamp)
|
|
|
- def setSmZ(self, z, timestamp):
|
|
|
+ def setSmZ(self, z, timestamp=None):
|
|
|
self.setComponentZ(z)
|
|
|
self.setComponentTLive(timestamp)
|
|
|
- def setSmXY(self, x, y, timestamp):
|
|
|
+ def setSmXY(self, x, y, timestamp=None):
|
|
|
self.setComponentX(x)
|
|
|
self.setComponentY(y)
|
|
|
self.setComponentTLive(timestamp)
|
|
|
- def setSmXZ(self, x, z, timestamp):
|
|
|
+ def setSmXZ(self, x, z, timestamp=None):
|
|
|
self.setComponentX(x)
|
|
|
self.setComponentZ(z)
|
|
|
self.setComponentTLive(timestamp)
|
|
|
- def setSmPos(self, x, y, z, timestamp):
|
|
|
+ def setSmPos(self, x, y, z, timestamp=None):
|
|
|
self.setComponentX(x)
|
|
|
self.setComponentY(y)
|
|
|
self.setComponentZ(z)
|
|
|
self.setComponentTLive(timestamp)
|
|
|
- def setSmHpr(self, h, p, r, timestamp):
|
|
|
+ def setSmHpr(self, h, p, r, timestamp=None):
|
|
|
self.setComponentH(h)
|
|
|
self.setComponentP(p)
|
|
|
self.setComponentR(r)
|
|
|
@@ -189,13 +191,13 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|
|
self.setComponentY(y)
|
|
|
self.setComponentH(h)
|
|
|
self.setComponentTLive(timestamp)
|
|
|
- def setSmXYZH(self, x, y, z, h, timestamp):
|
|
|
+ def setSmXYZH(self, x, y, z, h, timestamp=None):
|
|
|
self.setComponentX(x)
|
|
|
self.setComponentY(y)
|
|
|
self.setComponentZ(z)
|
|
|
self.setComponentH(h)
|
|
|
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.setComponentY(y)
|
|
|
self.setComponentZ(z)
|
|
|
@@ -246,38 +248,51 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|
|
# whenever we receive a live update directly from the other
|
|
|
# client. This is because the component functions, above,
|
|
|
# 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
|
|
|
- # be just slightly in the past, but it might be off by as much
|
|
|
- # as this frame's amount of time forward or back.
|
|
|
- howFarFuture = local - now
|
|
|
- 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()
|
|
|
+
|
|
|
+ #print 'setComponentTLive: %s' % timestamp
|
|
|
+
|
|
|
+ if timestamp is None:
|
|
|
+ # if no timestamp, re-use the most recent timestamp to keep things
|
|
|
+ # from getting out of order
|
|
|
+ if self.smoother.hasMostRecentTimestamp():
|
|
|
+ self.smoother.setTimestamp(self.smoother.getMostRecentTimestamp())
|
|
|
+ else:
|
|
|
+ # no most-recent timestamp, use current time
|
|
|
+ self.smoother.setPhonyTimestamp()
|
|
|
+ self.smoother.markPosition()
|
|
|
+ else:
|
|
|
+ now = globalClock.getFrameTime()
|
|
|
+ local = globalClockDelta.networkToLocalTime(timestamp, now)
|
|
|
+ realTime = globalClock.getRealTime()
|
|
|
+ chug = realTime - now
|
|
|
+
|
|
|
+ # Sanity check the timestamp from the other avatar. It should
|
|
|
+ # be just slightly in the past, but it might be off by as much
|
|
|
+ # as this frame's amount of time forward or back.
|
|
|
+ howFarFuture = local - now
|
|
|
+ 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):
|
|
|
# Call this to invalidate all the old position reports
|
|
|
# (e.g. just before popping to a new position).
|
|
|
+ #printStack()
|
|
|
self.smoother.clearPositions(1)
|
|
|
|
|
|
|
|
|
@@ -286,6 +301,7 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|
|
# automatically reset the smoothing position when we call it.
|
|
|
if self.smoothStarted:
|
|
|
if self._smoothWrtReparents:
|
|
|
+ #print self.getParent(), parent, self.getParent().getPos(parent)
|
|
|
self.smoother.handleWrtReparent(self.getParent(), parent)
|
|
|
NodePath.wrtReparentTo(self, parent)
|
|
|
else:
|