support local calls to setSm*

This commit is contained in:
Darren Ranalli 2007-08-09 23:20:17 +00:00
parent 2d2f8d7100
commit 506cf473cf

View File

@ -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)
@ -247,6 +249,18 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
# 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().
#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() now = globalClock.getFrameTime()
local = globalClockDelta.networkToLocalTime(timestamp, now) local = globalClockDelta.networkToLocalTime(timestamp, now)
realTime = globalClock.getRealTime() realTime = globalClock.getRealTime()
@ -278,6 +292,7 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
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: