Make smoothing variable configurable
This commit is contained in:
parent
b979d0db71
commit
30ceb7dd4a
@ -49,16 +49,17 @@ void SmoothNetworkBody::checkSmoothing(const btTransform& current_transform,
|
||||
|
||||
float adjust_length = (current_transform.getOrigin() -
|
||||
m_prev_position_data.first.getOrigin()).length();
|
||||
if (adjust_length < 0.1f || adjust_length > 4.0f)
|
||||
if (adjust_length < m_min_adjust_length ||
|
||||
adjust_length > m_max_adjust_length)
|
||||
return;
|
||||
|
||||
float speed = m_prev_position_data.second.length();
|
||||
speed = std::max(speed, current_velocity.length());
|
||||
if (speed < 0.3f)
|
||||
if (speed < m_min_adjust_speed)
|
||||
return;
|
||||
|
||||
float adjust_time = (adjust_length * 2.0f) / speed;
|
||||
if (adjust_time > 2.0f)
|
||||
if (adjust_time > m_max_adjust_time)
|
||||
return;
|
||||
|
||||
m_smoothing = SS_TO_ADJUST;
|
||||
|
@ -58,6 +58,9 @@ private:
|
||||
|
||||
bool m_adjust_vertical_offset;
|
||||
|
||||
float m_min_adjust_length, m_max_adjust_length, m_min_adjust_speed,
|
||||
m_max_adjust_time;
|
||||
|
||||
public:
|
||||
SmoothNetworkBody(bool enable = false)
|
||||
{
|
||||
@ -65,8 +68,14 @@ public:
|
||||
m_enabled = enable;
|
||||
m_smooth_rotation = true;
|
||||
m_adjust_vertical_offset = true;
|
||||
m_min_adjust_length = 0.1f;
|
||||
m_max_adjust_length = 4.0f;
|
||||
m_min_adjust_speed = 0.3f;
|
||||
m_max_adjust_time = 2.0f;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual ~SmoothNetworkBody() {}
|
||||
// ------------------------------------------------------------------------
|
||||
void reset()
|
||||
{
|
||||
m_smoothed_transform = btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
@ -102,6 +111,14 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
const Vec3& getSmoothedXYZ() const
|
||||
{ return (Vec3&)m_smoothed_transform.getOrigin(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void setMinAdjustLength(float val) { m_min_adjust_length = val; }
|
||||
// ------------------------------------------------------------------------
|
||||
void setMaxAdjustLength(float val) { m_max_adjust_length = val; }
|
||||
// ------------------------------------------------------------------------
|
||||
void setMinAdjustSpeed(float val) { m_min_adjust_speed = val; }
|
||||
// ------------------------------------------------------------------------
|
||||
void setMaxAdjustTime(float val) { m_max_adjust_time = val; }
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user