Make adjust length threshold configurable

This commit is contained in:
Benau 2018-11-12 15:39:01 +08:00
parent fe805abc09
commit ff71592d49
2 changed files with 20 additions and 13 deletions

View File

@ -20,6 +20,20 @@
#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,
const Vec3& current_velocity)
@ -58,7 +72,7 @@ void SmoothNetworkBody::checkSmoothing(const btTransform& current_transform,
if (speed < m_min_adjust_speed)
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)
return;

View File

@ -68,20 +68,10 @@ private:
bool m_adjust_vertical_offset;
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:
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;
}
SmoothNetworkBody(bool enable = false);
// ------------------------------------------------------------------------
virtual ~SmoothNetworkBody() {}
// ------------------------------------------------------------------------
@ -128,6 +118,9 @@ public:
void setMinAdjustSpeed(float val) { m_min_adjust_speed = val; }
// ------------------------------------------------------------------------
void setMaxAdjustTime(float val) { m_max_adjust_time = val; }
// ------------------------------------------------------------------------
void setAdjustLengthThreshold(float val)
{ m_adjust_length_threshold = val; }
};