24static const int max_position_reports = 10;
25static const int max_timestamp_delays = 10;
41class EXPCL_DIRECT_DEADREC SmoothMover {
50 INLINE
bool set_pos(
const LVecBase3 &pos);
51 INLINE
bool set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
52 INLINE
bool set_x(PN_stdfloat x);
53 INLINE
bool set_y(PN_stdfloat y);
54 INLINE
bool set_z(PN_stdfloat z);
56 INLINE
bool set_hpr(
const LVecBase3 &hpr);
57 INLINE
bool set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r);
58 INLINE
bool set_h(PN_stdfloat h);
59 INLINE
bool set_p(PN_stdfloat p);
60 INLINE
bool set_r(PN_stdfloat r);
62 INLINE
bool set_pos_hpr(
const LVecBase3 &pos,
const LVecBase3 &hpr);
63 INLINE
bool set_pos_hpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r);
106 enum PredictionMode {
140 void output(std::ostream &out)
const;
141 void write(std::ostream &out)
const;
144 void set_smooth_pos(
const LPoint3 &pos,
const LVecBase3 &hpr,
146 void linear_interpolate(
int point_before,
int point_after,
double timestamp);
147 void compute_velocity(
const LVector3 &pos_delta,
148 const LVecBase3 &hpr_delta,
151 void record_timestamp_delay(
double timestamp);
152 INLINE
double get_avg_timestamp_delay()
const;
167 LVecBase3 _smooth_hpr;
168 LVector3 _forward_axis;
169 double _smooth_timestamp;
170 bool _smooth_position_known;
171 bool _smooth_position_changed;
172 bool _computed_forward_axis;
174 double _smooth_forward_velocity;
175 double _smooth_lateral_velocity;
176 double _smooth_rotational_velocity;
178 bool _has_most_recent_timestamp;
179 double _most_recent_timestamp;
184 int _last_point_before;
185 int _last_point_after;
192 TimestampDelays _timestamp_delays;
193 int _net_timestamp_delay;
194 double _last_heard_from;
196 SmoothMode _smooth_mode;
197 PredictionMode _prediction_mode;
199 bool _accept_clock_skew;
200 double _max_position_age;
201 double _expected_broadcast_period;
202 double _reset_velocity_age;
203 bool _directional_velocity;
204 bool _default_to_standing_still;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class implements a queue of some type via a circular buffer.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
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.
bool get_latest_position()
Updates the smooth_pos (and smooth_hpr, etc.) members to reflect the absolute latest position known f...
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.
void handle_wrt_reparent(NodePath &old_parent, NodePath &new_parent)
Node is being wrtReparented, update recorded sample positions to reflect new parent.
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 clear_positions(bool reset_velocity)
Erases all the old position reports.
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.
void mark_position()
Stores the position, orientation, and timestamp (if relevant) indicated by previous calls to set_pos(...
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().
This is our own Panda specialization on the default STL deque.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.