mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Small teleporting fix for smoothing to make sure timestamps are up-to-date when smoothed object stops then starts movement.
This commit is contained in:
parent
b8523833f7
commit
bcc7ed59a8
@ -301,7 +301,9 @@ get_sample_hpr() const {
|
|||||||
INLINE void SmoothMover::
|
INLINE void SmoothMover::
|
||||||
set_phony_timestamp() {
|
set_phony_timestamp() {
|
||||||
double now = ClockObject::get_global_clock()->get_frame_time();
|
double now = ClockObject::get_global_clock()->get_frame_time();
|
||||||
_sample._timestamp = now;
|
// adjust by _delay when creating the timestamp since other
|
||||||
|
// timestamps received from network updates are adjusted by this
|
||||||
|
_sample._timestamp = now - _delay;
|
||||||
_has_most_recent_timestamp = true;
|
_has_most_recent_timestamp = true;
|
||||||
_most_recent_timestamp = now;
|
_most_recent_timestamp = now;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,9 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|||||||
# received between startSmooth() and endSmooth().
|
# received between startSmooth() and endSmooth().
|
||||||
self.localControl = False
|
self.localControl = False
|
||||||
|
|
||||||
|
# flag set when we receive a stop message
|
||||||
|
self.stopped = False
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
self.smoother = SmoothMover()
|
self.smoother = SmoothMover()
|
||||||
self.smoothStarted = 0
|
self.smoothStarted = 0
|
||||||
@ -173,46 +176,66 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|||||||
self.smoother.setPhonyTimestamp()
|
self.smoother.setPhonyTimestamp()
|
||||||
self.smoother.markPosition()
|
self.smoother.markPosition()
|
||||||
|
|
||||||
|
def _checkResume(self):
|
||||||
|
"""
|
||||||
|
Determine if we were previously stopped and now need to
|
||||||
|
resume movement by making sure any old stored positions
|
||||||
|
reflect the node's current position
|
||||||
|
"""
|
||||||
|
if (self.stopped):
|
||||||
|
self.reloadPosition()
|
||||||
|
self.stopped = False
|
||||||
|
|
||||||
# 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=None):
|
def setSmStop(self, timestamp=None):
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
|
self.stopped = True
|
||||||
def setSmH(self, h, timestamp=None):
|
def setSmH(self, h, timestamp=None):
|
||||||
|
self._checkResume()
|
||||||
self.setComponentH(h)
|
self.setComponentH(h)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmZ(self, z, timestamp=None):
|
def setSmZ(self, z, timestamp=None):
|
||||||
|
self._checkResume()
|
||||||
self.setComponentZ(z)
|
self.setComponentZ(z)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmXY(self, x, y, timestamp=None):
|
def setSmXY(self, x, y, timestamp=None):
|
||||||
|
self._checkResume()
|
||||||
self.setComponentX(x)
|
self.setComponentX(x)
|
||||||
self.setComponentY(y)
|
self.setComponentY(y)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmXZ(self, x, z, timestamp=None):
|
def setSmXZ(self, x, z, timestamp=None):
|
||||||
|
self._checkResume()
|
||||||
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=None):
|
def setSmPos(self, x, y, z, timestamp=None):
|
||||||
|
self._checkResume()
|
||||||
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=None):
|
def setSmHpr(self, h, p, r, timestamp=None):
|
||||||
|
self._checkResume()
|
||||||
self.setComponentH(h)
|
self.setComponentH(h)
|
||||||
self.setComponentP(p)
|
self.setComponentP(p)
|
||||||
self.setComponentR(r)
|
self.setComponentR(r)
|
||||||
self.setComponentTLive(timestamp)
|
self.setComponentTLive(timestamp)
|
||||||
def setSmXYH(self, x, y, h, timestamp):
|
def setSmXYH(self, x, y, h, timestamp):
|
||||||
|
self._checkResume()
|
||||||
self.setComponentX(x)
|
self.setComponentX(x)
|
||||||
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=None):
|
def setSmXYZH(self, x, y, z, h, timestamp=None):
|
||||||
|
self._checkResume()
|
||||||
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=None):
|
def setSmPosHpr(self, x, y, z, h, p, r, timestamp=None):
|
||||||
|
self._checkResume()
|
||||||
self.setComponentX(x)
|
self.setComponentX(x)
|
||||||
self.setComponentY(y)
|
self.setComponentY(y)
|
||||||
self.setComponentZ(z)
|
self.setComponentZ(z)
|
||||||
@ -256,7 +279,10 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
|
|||||||
self.smoother.clearPositions(1)
|
self.smoother.clearPositions(1)
|
||||||
self.smoother.markPosition()
|
self.smoother.markPosition()
|
||||||
|
|
||||||
self.forceToTruePosition()
|
# jbutler: took this out, appears it is not needed since
|
||||||
|
# markPosition above stored the node's position, and this
|
||||||
|
# just reapplies the poition to the node
|
||||||
|
#self.forceToTruePosition()
|
||||||
|
|
||||||
def setComponentTLive(self, timestamp):
|
def setComponentTLive(self, timestamp):
|
||||||
# This is the variant of setComponentT() that will be called
|
# This is the variant of setComponentT() that will be called
|
||||||
|
Loading…
x
Reference in New Issue
Block a user