Make adjust length threshold configurable
This commit is contained in:
parent
fe805abc09
commit
ff71592d49
@ -20,6 +20,20 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
SmoothNetworkBody::SmoothNetworkBody(bool enable)
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
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;
|
||||||
|
m_adjust_length_threshold = 2.0f;
|
||||||
|
} // SmoothNetworkBody
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void SmoothNetworkBody::prepareSmoothing(const btTransform& current_transform,
|
void SmoothNetworkBody::prepareSmoothing(const btTransform& current_transform,
|
||||||
const Vec3& current_velocity)
|
const Vec3& current_velocity)
|
||||||
@ -58,7 +72,7 @@ void SmoothNetworkBody::checkSmoothing(const btTransform& current_transform,
|
|||||||
if (speed < m_min_adjust_speed)
|
if (speed < m_min_adjust_speed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float adjust_time = (adjust_length * 2.0f) / speed;
|
float adjust_time = (adjust_length * m_adjust_length_threshold) / speed;
|
||||||
if (adjust_time > m_max_adjust_time)
|
if (adjust_time > m_max_adjust_time)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -68,20 +68,10 @@ private:
|
|||||||
bool m_adjust_vertical_offset;
|
bool m_adjust_vertical_offset;
|
||||||
|
|
||||||
float m_min_adjust_length, m_max_adjust_length, m_min_adjust_speed,
|
float m_min_adjust_length, m_max_adjust_length, m_min_adjust_speed,
|
||||||
m_max_adjust_time;
|
m_max_adjust_time, m_adjust_length_threshold;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SmoothNetworkBody(bool enable = false)
|
SmoothNetworkBody(bool enable = false);
|
||||||
{
|
|
||||||
reset();
|
|
||||||
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() {}
|
virtual ~SmoothNetworkBody() {}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -128,6 +118,9 @@ public:
|
|||||||
void setMinAdjustSpeed(float val) { m_min_adjust_speed = val; }
|
void setMinAdjustSpeed(float val) { m_min_adjust_speed = val; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setMaxAdjustTime(float val) { m_max_adjust_time = val; }
|
void setMaxAdjustTime(float val) { m_max_adjust_time = val; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
void setAdjustLengthThreshold(float val)
|
||||||
|
{ m_adjust_length_threshold = val; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user