26 return set_pos(pos[0], pos[1], pos[2]);
40set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
41 bool x_changed =
set_x(x);
42 bool y_changed =
set_y(y);
43 bool z_changed =
set_z(z);
44 return x_changed || y_changed || z_changed;
52 bool result = (x != _sample._pos[0]);
67 bool result = (y != _sample._pos[1]);
82 bool result = (z != _sample._pos[2]);
104 return set_hpr(hpr[0], hpr[1], hpr[2]);
118set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
119 bool h_changed =
set_h(h);
120 bool p_changed =
set_p(p);
121 bool r_changed =
set_r(r);
122 return h_changed || p_changed || r_changed;
129set_h(PN_stdfloat h) {
130 bool result = (h != _sample._hpr[0]);
144set_p(PN_stdfloat p) {
145 bool result = (p != _sample._hpr[1]);
159set_r(PN_stdfloat r) {
160 bool result = (r != _sample._hpr[2]);
181set_pos_hpr(
const LVecBase3 &pos,
const LVecBase3 &hpr) {
182 bool pos_changed =
set_pos(pos);
183 bool hpr_changed =
set_hpr(hpr);
184 return pos_changed || hpr_changed;
198set_pos_hpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
199 bool pos_changed =
set_pos(x, y, z);
200 bool hpr_changed =
set_hpr(h, p, r);
201 return pos_changed || hpr_changed;
233 if (timestamp != 0.0)
240 _sample._timestamp = now - _expected_broadcast_period;
243 _sample._timestamp = now;
245 _has_most_recent_timestamp =
true;
246 _most_recent_timestamp = _sample._timestamp;
262 _sample._timestamp = timestamp;
263 _has_most_recent_timestamp =
true;
264 _most_recent_timestamp = timestamp;
265 record_timestamp_delay(timestamp);
273 return _has_most_recent_timestamp;
281 return _most_recent_timestamp;
313 return _forward_axis;
404 return _smooth_forward_velocity;
415 return _smooth_lateral_velocity;
425 return _smooth_rotational_velocity;
454 _prediction_mode = mode;
463 return _prediction_mode;
501 _accept_clock_skew = flag;
510 return _accept_clock_skew;
519 _max_position_age = age;
528 return _max_position_age;
539 _expected_broadcast_period = period;
548 return _expected_broadcast_period;
559 _reset_velocity_age = age;
568 return _reset_velocity_age;
580 _directional_velocity = flag;
589 return _directional_velocity;
600 _default_to_standing_still = flag;
609 return _default_to_standing_still;
619INLINE
double SmoothMover::
620get_avg_timestamp_delay()
const {
621 nassertr(!_timestamp_delays.
empty(), 0.0);
622 return (
double)_net_timestamp_delay / (double)_timestamp_delays.
size() / 1000.0;
int size() const
Returns the number of items currently in the buffer.
bool empty() const
Returns true if the buffer is empty.
get_frame_time
Returns the time in seconds as of the last time tick() was called (typically, this will be as of the ...
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
void set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r)
Sets the rotation component of the transform, leaving translation and scale untouched.
const LPoint3 & get_sample_pos() const
Returns the current position of the working sample point.
void set_expected_broadcast_period(double period)
Sets the interval at which we expect the SmoothNodes to broadcast their position, in elapsed seconds.
double get_delay()
Returns the amount of time, in seconds, to delay the computed position of a SmoothMover.
bool get_directional_velocity()
Returns the current state of the 'directional velocity' flag.
bool get_default_to_standing_still()
Returns the current state of the 'default to standing still' flag.
void set_prediction_mode(PredictionMode mode)
Sets the predictioning mode of all SmoothMovers in the world.
bool compute_smooth_position()
Computes the smoothed position (and orientation) of the mover at the indicated point in time,...
bool set_y(PN_stdfloat y)
Sets the Y position only.
void apply_smooth_hpr(NodePath &node) const
Applies the smoothed orientation to the indicated NodePath.
const LVecBase3 & get_sample_hpr() const
Returns the current orientation of the working sample point.
void set_max_position_age(double age)
Sets the maximum amount of time a position is allowed to remain unchanged before assuming it represen...
void compute_and_apply_smooth_hpr(NodePath &hpr_node)
A further optimization to reduce Python calls.
bool set_pos(const LVecBase3 &pos)
Specifies the position of the SmoothMover at a particular time in the past.
void set_timestamp(double timestamp)
Specifies the time that the current position report applies.
bool set_pos_hpr(const LVecBase3 &pos, const LVecBase3 &hpr)
Specifies the position and orientation of the SmoothMover at a particular time in the past.
SmoothMode get_smooth_mode()
Returns the smoothing mode of all SmoothMovers in the world.
bool set_hpr(const LVecBase3 &hpr)
Specifies the orientation of the SmoothMover at a particular time in the past.
bool has_most_recent_timestamp() const
Returns true if we have most recently recorded timestamp.
double get_most_recent_timestamp() const
Returns most recently recorded timestamp.
void set_delay(double delay)
Sets the amount of time, in seconds, to delay the computed position of a SmoothMover.
PN_stdfloat get_smooth_lateral_velocity() const
Returns the speed at which the avatar is moving, in feet per second, along its own lateral axis (afte...
void apply_smooth_pos(NodePath &node) const
Applies the smoothed position to the indicated NodePath.
double get_reset_velocity_age()
Returns the amount of time that should elapse after the last position report before the velocity is r...
bool set_h(PN_stdfloat h)
Sets the heading only.
PN_stdfloat get_smooth_rotational_velocity() const
Returns the speed at which the avatar is rotating in the horizontal plane (i.e.
double get_expected_broadcast_period()
Returns the interval at which we expect the SmoothNodes to broadcast their position,...
bool set_z(PN_stdfloat z)
Sets the Z position only.
void set_phony_timestamp(double timestamp=0.0, bool period_adjust=false)
Lies and specifies that the current position report was received now.
void apply_smooth_pos_hpr(NodePath &pos_node, NodePath &hpr_node) const
Applies the smoothed position and orientation to the indicated NodePath.
void compute_and_apply_smooth_pos_hpr(NodePath &pos_node, NodePath &hpr_node)
A further optimization to reduce Python calls.
bool set_x(PN_stdfloat x)
Sets the X position only.
PredictionMode get_prediction_mode()
Returns the predictioning mode of all SmoothMovers in the world.
const LVecBase3 & get_smooth_hpr() const
Returns the smoothed orientation as computed by a previous call to compute_smooth_position().
void set_directional_velocity(bool flag)
Sets the flag that indicates whether the avatar's direction is considered in computing the velocity.
void set_default_to_standing_still(bool flag)
Sets the flag that indicates whether to assume that the node stopped moving during periods when we do...
void set_smooth_mode(SmoothMode mode)
Sets the smoothing mode of all SmoothMovers in the world.
bool set_r(PN_stdfloat r)
Sets the roll only.
void compute_and_apply_smooth_pos(NodePath &node)
A further optimization to reduce Python calls.
bool set_p(PN_stdfloat p)
Sets the pitch only.
void set_accept_clock_skew(bool flag)
Sets the 'accept clock skew' flag.
const LVecBase3 & get_forward_axis() const
Returns the smoothed position as computed by a previous call to compute_smooth_position().
bool get_accept_clock_skew()
Returns the current state of the 'accept clock skew' flag.
double get_max_position_age()
Returns the maximum amount of time a position is allowed to remain unchanged before assuming it repre...
PN_stdfloat get_smooth_forward_velocity() const
Returns the speed at which the avatar is moving, in feet per second, along its own forward axis (afte...
void set_reset_velocity_age(double age)
Sets the amount of time that should elapse after the last position report before the velocity is rese...
const LPoint3 & get_smooth_pos() const
Returns the smoothed position as computed by a previous call to compute_smooth_position().