First try to prevent #1566: kart chassis appears inside of terrain.
This commit is contained in:
parent
833f162d1a
commit
5401e7f3b7
@ -155,8 +155,15 @@
|
||||
otherwise obstricts too much of the view. -->
|
||||
<camera distance="1.0" forward-up-angle="15"
|
||||
backward-up-angle="5"/>
|
||||
<!-- Additional offset to move graphical chassis with regards to the physics. -->
|
||||
<graphics y-offset="0.0"/>
|
||||
<!-- Options to affect the graphical chassis:
|
||||
y-offset: Additional offset to move graphical chassis with regards
|
||||
to the physics, used to reduce frequencey of graphical
|
||||
chassis in terrain.
|
||||
prevent-chassis-in-terrain: a hard flag to prevent nearly all instances
|
||||
of chassis in terrain. Can (atm) cause some stuttering. -->
|
||||
<graphics y-offset="0.0"
|
||||
prevent-chassis-in-terrain="true"
|
||||
/>
|
||||
|
||||
<!-- Jump animation related values:
|
||||
animation-time: only if the estimated time for a jump is larger
|
||||
|
@ -2581,6 +2581,45 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
float xx = fabsf(m_speed)* getKartProperties()->getDownwardImpulseFactor()*0.0006f;
|
||||
Vec3 center_shift = Vec3(0, m_skidding->getGraphicalJumpOffset()
|
||||
+ lean_height +m_graphical_y_offset+xx, 0);
|
||||
|
||||
// Try to prevent the graphical chassis to be inside of the terrain:
|
||||
if(m_kart_properties->getPreventChassisInTerrain())
|
||||
{
|
||||
// Get the shortest suspension length (=closest point to terrain).
|
||||
float min_susp_len = 99.9f;
|
||||
for (int i = 0; i < getVehicle()->getNumWheels(); i++)
|
||||
{
|
||||
float susp_len = getVehicle()->getWheelInfo(i).m_raycastInfo
|
||||
.m_suspensionLength;
|
||||
if (susp_len < min_susp_len)
|
||||
min_susp_len = susp_len;
|
||||
} // for i<num_wheels
|
||||
|
||||
const btWheelInfo &w = getVehicle()->getWheelInfo(0);
|
||||
// Recompute the default average suspension length, see
|
||||
// kartIsInRestNow() how to get from y-offset to susp. len.
|
||||
float av_sus_len = -m_graphical_y_offset
|
||||
+ w.m_chassisConnectionPointCS.getY()
|
||||
- w.m_wheelsRadius;
|
||||
|
||||
float delta = av_sus_len - min_susp_len;
|
||||
// If the suspension length is so short, that it is less than the
|
||||
// lowest point of the kart, it indicates that the graphical chassis
|
||||
// would be inside of the track:
|
||||
if (delta > m_kart_model->getLowestPoint())
|
||||
{
|
||||
center_shift.setY(center_shift.getY() + delta - m_kart_model->getLowestPoint());
|
||||
}
|
||||
|
||||
// FIXME: for now, debug output in case we have to debug it
|
||||
//Log::verbose("kart", "min %f y off %f overall off %f lowest %f delta %f asl %f",
|
||||
// min_susp_len, m_graphical_y_offset, center_shift.getY(),
|
||||
// m_kart_model->getLowestPoint(),
|
||||
// delta,
|
||||
// av_sus_len
|
||||
// );
|
||||
}
|
||||
|
||||
center_shift = getTrans().getBasis() * center_shift;
|
||||
|
||||
Moveable::updateGraphics(dt, center_shift,
|
||||
|
@ -101,17 +101,18 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
m_plunger_in_face_duration.resize(RaceManager::DIFFICULTY_COUNT,
|
||||
UNDEFINED);
|
||||
|
||||
m_terrain_impulse_type = IMPULSE_NONE;
|
||||
m_gravity_center_shift = Vec3(UNDEFINED);
|
||||
m_bevel_factor = Vec3(UNDEFINED);
|
||||
m_exp_spring_response = false;
|
||||
m_version = 0;
|
||||
m_color = video::SColor(255, 0, 0, 0);
|
||||
m_shape = 32; // close enough to a circle.
|
||||
m_engine_sfx_type = "engine_small";
|
||||
m_kart_model = NULL;
|
||||
m_has_rand_wheels = false;
|
||||
m_nitro_min_consumption = 0.53f;
|
||||
m_terrain_impulse_type = IMPULSE_NONE;
|
||||
m_gravity_center_shift = Vec3(UNDEFINED);
|
||||
m_bevel_factor = Vec3(UNDEFINED);
|
||||
m_exp_spring_response = false;
|
||||
m_prevent_chassis_in_terrain = false;
|
||||
m_version = 0;
|
||||
m_color = video::SColor(255, 0, 0, 0);
|
||||
m_shape = 32; // close enough to a circle.
|
||||
m_engine_sfx_type = "engine_small";
|
||||
m_kart_model = NULL;
|
||||
m_has_rand_wheels = false;
|
||||
m_nitro_min_consumption = 0.53f;
|
||||
// The default constructor for stk_config uses filename=""
|
||||
if (filename != "")
|
||||
{
|
||||
@ -617,7 +618,9 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
|
||||
if(const XMLNode *graphics_node = root->getNode("graphics"))
|
||||
{
|
||||
graphics_node->get("y-offset", &m_graphical_y_offset);
|
||||
graphics_node->get("y-offset", &m_graphical_y_offset);
|
||||
graphics_node->get("prevent-chassis-in-terrain",
|
||||
&m_prevent_chassis_in_terrain);
|
||||
}
|
||||
|
||||
if(m_kart_model)
|
||||
|
@ -208,6 +208,9 @@ private:
|
||||
* chassis. Useful for karts that don't have enough space for suspension
|
||||
* compression. */
|
||||
float m_graphical_y_offset;
|
||||
/** A hard flag that moves the graphical chassis higher if it's insde
|
||||
* the track. Might cause stuttering. */
|
||||
bool m_prevent_chassis_in_terrain;
|
||||
/** If the kart is supposed to have random wheel rotation at start. */
|
||||
bool m_has_rand_wheels;
|
||||
/** Max. length of plunger rubber band. */
|
||||
@ -578,6 +581,13 @@ public:
|
||||
* compression. */
|
||||
float getGraphicalYOffset() const {return m_graphical_y_offset; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** A hard flag that moves the graphical chassis higher if it's insde
|
||||
* the track. Might cause stuttering. */
|
||||
bool getPreventChassisInTerrain() const
|
||||
{
|
||||
return m_prevent_chassis_in_terrain;
|
||||
} // getPreventChassisInTerrain
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns parameters for the speed-weighted objects */
|
||||
const SpeedWeightedObject::Properties& getSpeedWeightedObjectProperties() const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user