28#ifndef HEADER_SMOOTH_NETWORK_BODY_HPP
29#define HEADER_SMOOTH_NETWORK_BODY_HPP
31#include "utils/log.hpp"
32#include "utils/vec3.hpp"
34#include "LinearMath/btTransform.h"
54 Vec3 m_adjust_control_point;
56 std::pair<btTransform, Vec3> m_prev_position_data;
58 btTransform m_smoothed_transform;
60 float m_adjust_time, m_adjust_time_dt;
62 SmoothingState m_smoothing;
66 bool m_smooth_rotation;
68 bool m_adjust_vertical_offset;
70 float m_min_adjust_length, m_max_adjust_length, m_min_adjust_speed,
71 m_max_adjust_time, m_adjust_length_threshold;
80 m_smoothed_transform = btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f));
82 std::make_pair(
Vec3(0.0f, 0.0f, 0.0f),
83 btQuaternion(0.0f, 0.0f, 0.0f, 1.0f));
84 m_prev_position_data = std::make_pair(m_smoothed_transform,
Vec3());
85 m_smoothing = SS_NONE;
86 m_adjust_time = m_adjust_time_dt = 0.0f;
89 void setEnable(
bool val) { m_enabled = val; }
91 bool isEnabled()
const {
return m_enabled; }
93 void setSmoothRotation(
bool val) { m_smooth_rotation = val; }
95 void setAdjustVerticalOffset(
bool val) { m_adjust_vertical_offset = val; }
97 void prepareSmoothing(
const btTransform& current_transform,
98 const Vec3& current_velocity);
101 const Vec3& current_velocity);
103 void updateSmoothedGraphics(
const btTransform& current_transform,
104 const Vec3& current_velocity,
107 void setSmoothedTransform(
const btTransform& t)
108 { m_smoothed_transform = t; }
110 const btTransform& getSmoothedTrans()
const
111 {
return m_smoothed_transform; }
113 const Vec3& getSmoothedXYZ()
const
114 {
return (
Vec3&)m_smoothed_transform.getOrigin(); }
116 void setMinAdjustLength(
float val) { m_min_adjust_length = val; }
118 void setMaxAdjustLength(
float val) { m_max_adjust_length = val; }
120 void setMinAdjustSpeed(
float val) { m_min_adjust_speed = val; }
122 void setMaxAdjustTime(
float val) { m_max_adjust_time = val; }
124 void setAdjustLengthThreshold(
float val)
125 { m_adjust_length_threshold = val; }
Definition: smooth_network_body.hpp:39
std::pair< Vec3, btQuaternion > m_start_smoothing_postion
Client prediction in networked games might cause the visual and physical position to be different.
Definition: smooth_network_body.hpp:51
void checkSmoothing(const btTransform ¤t_transform, const Vec3 ¤t_velocity)
Adds a new error between graphical and physical position/rotation.
Definition: smooth_network_body.cpp:57
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35