69 r.
x = u3 * p0.
x + 3.0 * u2 * t * p1.
x + 3.0 * u * t2 * p2.
x + t3 * p3.
x;
70 r.
y = u3 * p0.
y + 3.0 * u2 * t * p1.
y + 3.0 * u * t2 * p2.
y + t3 * p3.
y;
71 r.
z = u3 * p0.
z + 3.0 * u2 * t * p1.
z + 3.0 * u * t2 * p2.
z + t3 * p3.
z;
136 switch (entity->
algo) {
#define Malloc(__ptr, __struct, __size)
Malloc Handler to get errors and set to 0.
#define __n_assert(__ptr, __ret)
macro to assert things
#define Free(__ptr)
Free Handler to get errors.
double blend_start
Timestamp when blending started.
DR_VEC3 bezier_p2
Control point 2.
DR_VEC3 bezier_p3
End point (extrapolated last_known at blend_time)
DR_ALGO algo
Extrapolation algorithm.
DR_VEC3 bezier_p1
Control point 1.
double blend_time
Duration of convergence blend in seconds.
DR_STATE prev_predicted
Where we THOUGHT entity was when update arrived (P0, V0)
double time
Timestamp (seconds) when this state was captured.
bool blending
True if currently blending toward last_known.
DR_VEC3 display_vel
Current blended/rendered velocity.
DR_VEC3 bezier_p0
Start point (previous predicted position)
DR_STATE last_known
Most recent authoritative state (P0', V0', A0')
DR_BLEND blend_mode
Convergence blending mode.
double pos_threshold
Position error threshold for sending updates (distance)
DR_VEC3 display_pos
Current blended/rendered position.
int update_count
Number of state updates received.
static DR_VEC3 dr_vec3_scale(DR_VEC3 v, double s)
Scalar multiplication: v * s.
void dr_entity_destroy(DR_ENTITY **entity_ptr)
Destroy a dead reckoning entity and set the pointer to NULL.
static DR_VEC3 dr_vec3_lerp(DR_VEC3 a, DR_VEC3 b, double t)
Linear interpolation: a + (b - a) * t.
void dr_entity_set_threshold(DR_ENTITY *entity, double threshold)
Set the position error threshold for triggering network updates.
void dr_entity_compute(DR_ENTITY *entity, double time, DR_VEC3 *out_pos)
Compute the dead reckoned display position at a given time.
DR_ENTITY * dr_entity_create(DR_ALGO algo, DR_BLEND blend_mode, double pos_threshold, double blend_time)
Create a new dead reckoning entity.
void dr_entity_set_blend_time(DR_ENTITY *entity, double blend_time)
Set the convergence blend duration.
DR_BLEND
Dead reckoning convergence/blending mode.
void dr_entity_set_blend_mode(DR_ENTITY *entity, DR_BLEND blend_mode)
Set the convergence blending mode.
static DR_VEC3 dr_vec3_sub(DR_VEC3 a, DR_VEC3 b)
Vector subtraction: a - b.
bool dr_entity_check_threshold(const DR_ENTITY *entity, const DR_VEC3 *true_pos, const DR_VEC3 *true_vel, const DR_VEC3 *true_acc, double time)
Check whether the owner's true state has diverged from the dead reckoned prediction beyond the config...
DR_ALGO
Dead reckoning extrapolation algorithm.
void dr_entity_set_algo(DR_ENTITY *entity, DR_ALGO algo)
Set the extrapolation algorithm.
static DR_VEC3 dr_vec3_zero(void)
Zero vector.
static DR_VEC3 dr_vec3_add(DR_VEC3 a, DR_VEC3 b)
Vector addition: a + b.
static double dr_vec3_distance(DR_VEC3 a, DR_VEC3 b)
Distance between two points.
void dr_entity_receive_state(DR_ENTITY *entity, const DR_VEC3 *pos, const DR_VEC3 *vel, const DR_VEC3 *acc, double time)
Receive a new authoritative state update from the network.
void dr_entity_set_position(DR_ENTITY *entity, const DR_VEC3 *pos, const DR_VEC3 *vel, const DR_VEC3 *acc, double time)
Force-set entity position without triggering convergence blending.
DR_VEC3 dr_entity_extrapolate(const DR_ENTITY *entity, const DR_STATE *state, double dt)
Extrapolate a kinematic state forward by dt seconds.
@ DR_BLEND_CUBIC
Cubic Bezier spline convergence.
@ DR_BLEND_PVB
Projective Velocity Blending (recommended)
@ DR_BLEND_SNAP
Snap instantly to new state (no smoothing)
@ DR_ALGO_VEL_ACC
Velocity + acceleration: P(t) = P0 + V0*t + 0.5*A0*t^2.
@ DR_ALGO_VEL
Velocity only: P(t) = P0 + V0*t.
@ DR_ALGO_STATIC
No extrapolation; entity stays at last position.
Dead reckoned entity with extrapolation and convergence state.
A snapshot of entity kinematic state at a point in time.
3D vector used for position, velocity, and acceleration
Common headers and low-level functions & define.
static DR_VEC3 cubic_bezier(DR_VEC3 p0, DR_VEC3 p1, DR_VEC3 p2, DR_VEC3 p3, double t)
Evaluate a cubic Bezier curve at parameter t in [0, 1].
Dead Reckoning API for latency hiding in networked games.