Removed support for cushioning falls, instead increase max suspensiom
force and damping compression to allow karts to fall without colliding with the terrain. Needs an increase in network protocol version.
This commit is contained in:
parent
5c14ce86d7
commit
266dc02a44
@ -35,7 +35,7 @@
|
||||
for details.
|
||||
max-force: Maximum suspension force -->
|
||||
<suspension stiffness="280" rest="0.3" travel="0.29"
|
||||
exp-spring-response="false" max-force="12000" />
|
||||
exp-spring-response="false" max-force="32000" />
|
||||
|
||||
<!-- Values related to stability of the chassis: damping, and reduced
|
||||
impact of roll.
|
||||
@ -117,7 +117,7 @@
|
||||
position of the physics raycast wheels relative to the center of
|
||||
gravity. Default is to use the corners of the chassis to attach
|
||||
the wheels to. -->
|
||||
<wheels damping-relaxation="35" damping-compression="5">
|
||||
<wheels damping-relaxation="35" damping-compression="15">
|
||||
<front-right position="0.38 0 0.6" />
|
||||
<front-left position="-0.38 0 0.6" />
|
||||
<rear-right position="0.38 0 -0.6" />
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
<!-- Minimum and maxium server versions that be be read by this binary.
|
||||
Older versions will be ignored. -->
|
||||
<server-version min="3" max="3"/>
|
||||
<server-version min="4" max="4"/>
|
||||
|
||||
<!-- Maximum number of karts to be used at the same time. This limit
|
||||
can easily be increased, but some tracks might not have valid start
|
||||
|
@ -156,7 +156,6 @@ BareNetworkString* KartRewinder::saveState(std::vector<std::string>* ru)
|
||||
buffer->add(body->getAngularVelocity());
|
||||
buffer->addFloat(m_vehicle->getTimedRotationTime());
|
||||
buffer->add(m_vehicle->getTimedRotation());
|
||||
buffer->addUInt8(m_vehicle->getCushioningDisableTime());
|
||||
|
||||
// For collision rewind
|
||||
buffer->addUInt16(m_bounce_back_ticks);
|
||||
@ -265,7 +264,6 @@ void KartRewinder::restoreState(BareNetworkString *buffer, int count)
|
||||
float time_rot = buffer->getFloat();
|
||||
// Set timed rotation divides by time_rot
|
||||
m_vehicle->setTimedRotation(time_rot, time_rot*buffer->getVec3());
|
||||
m_vehicle->setCushioningDisableTime(buffer->getUInt8());
|
||||
|
||||
// Collision rewind
|
||||
m_bounce_back_ticks = buffer->getUInt16();
|
||||
|
12
src/network/server_config.cpp
Normal file → Executable file
12
src/network/server_config.cpp
Normal file → Executable file
@ -136,18 +136,6 @@ void loadServerConfigXML(const XMLNode* root)
|
||||
return;
|
||||
}
|
||||
|
||||
/*int config_file_version = -1;
|
||||
if (root->get("version", &config_file_version) < 1 ||
|
||||
config_file_version < stk_config->m_min_server_version ||
|
||||
config_file_version > stk_config->m_max_server_version)
|
||||
{
|
||||
Log::info("ServerConfig", "Your config file was not compatible, "
|
||||
"so it was deleted and a new one will be created.");
|
||||
delete root;
|
||||
writeServerConfigToDisk();
|
||||
return;
|
||||
}*/
|
||||
|
||||
for (unsigned i = 0; i < g_server_params.size(); i++)
|
||||
g_server_params[i]->findYourDataInAChildOf(root);
|
||||
|
||||
|
@ -276,7 +276,7 @@ namespace ServerConfig
|
||||
|
||||
// ========================================================================
|
||||
/** Server version, will be advanced if there are protocol changes. */
|
||||
static const uint32_t m_server_version = 3;
|
||||
static const uint32_t m_server_version = 4;
|
||||
// ========================================================================
|
||||
void loadServerConfig(const std::string& path = "");
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -26,10 +26,6 @@
|
||||
#include "karts/kart.hpp"
|
||||
#include "karts/kart_model.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#undef DEBUG_CUSHIONING
|
||||
#ifdef DEBUG_CUSHIONING
|
||||
#include "modes/world.hpp"
|
||||
#endif
|
||||
#include "physics/triangle_mesh.hpp"
|
||||
#include "tracks/terrain_info.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
@ -129,7 +125,6 @@ void btKart::reset()
|
||||
m_time_additional_rotation = 0;
|
||||
m_max_speed = -1.0f;
|
||||
m_min_speed = 0.0f;
|
||||
m_cushioning_disable_time = 0;
|
||||
|
||||
// Set the brakes so that karts don't slide downhill
|
||||
setAllBrakes(5.0f);
|
||||
@ -449,9 +444,8 @@ void btKart::updateVehicle( btScalar step )
|
||||
if(m_num_wheels_on_ground==0)
|
||||
{
|
||||
btVector3 kart_up = getChassisWorldTransform().getBasis().getColumn(1);
|
||||
btVector3 terrain_up =
|
||||
m_kart->getMaterial() && m_kart->getMaterial()->hasGravity() ?
|
||||
m_kart->getNormal() : Vec3(0, 1, 0);
|
||||
btVector3 terrain_up = -m_chassisBody->getGravity();
|
||||
terrain_up = terrain_up.normalize();
|
||||
// Length of axis depends on the angle - i.e. the further awat
|
||||
// the kart is from being upright, the larger the applied impulse
|
||||
// will be, resulting in fast changes when the kart is on its
|
||||
@ -467,7 +461,9 @@ void btKart::updateVehicle( btScalar step )
|
||||
av.setZ(0);
|
||||
m_chassisBody->setAngularVelocity(av);
|
||||
// Give a nicely balanced feeling for rebalancing the kart
|
||||
m_chassisBody->applyTorqueImpulse(axis * m_kart->getKartProperties()->getStabilitySmoothFlyingImpulse());
|
||||
float smoothing = m_kart->getKartProperties()
|
||||
->getStabilitySmoothFlyingImpulse();
|
||||
m_chassisBody->applyTorqueImpulse(axis * smoothing);
|
||||
}
|
||||
|
||||
// Apply suspension forcen (i.e. upwards force)
|
||||
@ -494,93 +490,6 @@ void btKart::updateVehicle( btScalar step )
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Test if the kart is falling so fast
|
||||
// that the chassis might hit the track
|
||||
// ------------------------------------
|
||||
int wheel_index = 0;
|
||||
float min_susp = m_wheelInfo[0].m_raycastInfo.m_suspensionLength;
|
||||
for (int i = 1; i<m_wheelInfo.size(); i++)
|
||||
{
|
||||
btWheelInfo &wheel = m_wheelInfo[i];
|
||||
if (wheel.m_raycastInfo.m_suspensionLength < min_susp)
|
||||
{
|
||||
min_susp = wheel.m_raycastInfo.m_suspensionLength;
|
||||
wheel_index = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Cushioning test: if the kart is falling fast, the suspension might
|
||||
// not be strong enough to prevent the chassis from hitting the ground.
|
||||
// Try to detect this upcoming crash, and apply an upward impulse if
|
||||
// necessary that will slow down the falling speed.
|
||||
if(m_cushioning_disable_time>0) m_cushioning_disable_time --;
|
||||
|
||||
bool needed_cushioning = false;
|
||||
btVector3 v =
|
||||
m_chassisBody->getVelocityInLocalPoint(m_wheelInfo[wheel_index]
|
||||
.m_chassisConnectionPointCS);
|
||||
btVector3 down = -m_chassisBody->getGravity();
|
||||
down.normalize();
|
||||
btVector3 v_down = (v * down) * down;
|
||||
btScalar offset=0.1f;
|
||||
|
||||
#ifdef DEBUG_CUSHIONING
|
||||
Log::verbose("physics",
|
||||
"World %d wheel %d lsuspl %f vdown %f overall speed %f lenght %f",
|
||||
World::getWorld()->getTimeTicks(),
|
||||
wheel_index,
|
||||
m_wheelInfo[wheel_index].m_raycastInfo.m_suspensionLength,
|
||||
-v_down.getY(),
|
||||
-v_down.getY() + 9.8*step,
|
||||
step * (-v_down.getY() + 9.8*step)+offset);
|
||||
#endif
|
||||
// If the kart is falling, estimate the distance the kart will fall
|
||||
// in the next time step: the speed gets increased by the gravity*dt.
|
||||
// This approximation is still not good enough (either because of
|
||||
// kart rotation that can be changed, or perhaps because of the
|
||||
// collision threshold used by bullet) - i.e. it would sometimes not
|
||||
// predict the upcoming collision correcty - so we add an offset
|
||||
// to the predicted kart movement, which was found experimentally:
|
||||
btScalar gravity = m_chassisBody->getGravity().length();
|
||||
if (v_down.getY()<0 && m_cushioning_disable_time==0 &&
|
||||
m_wheelInfo[wheel_index].m_raycastInfo.m_suspensionLength
|
||||
< step * (-v_down.getY()+gravity*step)+offset)
|
||||
{
|
||||
// Disable more cushioning for 1 second. This avoids the problem
|
||||
// of hovering: a kart gets cushioned on a down-sloping area, still
|
||||
// moves forwards, gets cushioned again etc. --> kart is hovering
|
||||
// and not controllable.
|
||||
m_cushioning_disable_time = 120;
|
||||
|
||||
needed_cushioning = true;
|
||||
btVector3 impulse = down * (-v_down.getY() + gravity*step)
|
||||
/ m_chassisBody->getInvMass();
|
||||
#ifdef DEBUG_CUSHIONING
|
||||
float v_old = m_chassisBody->getLinearVelocity().getY();
|
||||
#endif
|
||||
m_chassisBody->applyCentralImpulse(impulse);
|
||||
#ifdef DEBUG_CUSHIONING
|
||||
Log::verbose("physics",
|
||||
"World %d Cushioning imp %f vdown %f from %f m/s to %f m/s "
|
||||
"contact %f kart %f susp %f relspeed %f",
|
||||
World::getWorld()->getTimeTicks(),
|
||||
impulse.getY(),
|
||||
-v_down.getY(),
|
||||
v_old,
|
||||
m_chassisBody->getLinearVelocity().getY(),
|
||||
m_wheelInfo[wheel_index].m_raycastInfo.m_isInContact ?
|
||||
m_wheelInfo[wheel_index].m_raycastInfo.m_contactPointWS.getY()
|
||||
: -100,
|
||||
m_chassisBody->getWorldTransform().getOrigin().getY(),
|
||||
m_wheelInfo[wheel_index].m_raycastInfo.m_suspensionLength,
|
||||
m_chassisBody->getVelocityInLocalPoint(m_wheelInfo[wheel_index]
|
||||
.m_chassisConnectionPointCS)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Update friction (i.e. forward force)
|
||||
// ------------------------------------
|
||||
updateFriction( step);
|
||||
@ -588,7 +497,7 @@ void btKart::updateVehicle( btScalar step )
|
||||
// If configured, add a force to keep karts on the track
|
||||
// -----------------------------------------------------
|
||||
float dif = m_kart->getKartProperties()->getStabilityDownwardImpulseFactor();
|
||||
if(dif!=0 && m_num_wheels_on_ground==4 && !needed_cushioning)
|
||||
if(dif!=0 && m_num_wheels_on_ground==4)
|
||||
{
|
||||
float f = -fabsf(m_kart->getSpeed()) * dif;
|
||||
btVector3 downwards_impulse = m_chassisBody->getWorldTransform().getBasis()
|
||||
|
@ -93,9 +93,6 @@ private:
|
||||
/** Number of wheels that touch the ground. */
|
||||
int m_num_wheels_on_ground;
|
||||
|
||||
/** Number of time steps during which cushioning is disabled. */
|
||||
unsigned int m_cushioning_disable_time;
|
||||
|
||||
/** Index of the right axis. */
|
||||
int m_indexRightAxis;
|
||||
/** Index of the up axis. */
|
||||
@ -252,19 +249,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
float getTimedRotationTime() const { return m_time_additional_rotation; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the time cushioning is disabled. Used for networking state
|
||||
* saving. */
|
||||
unsigned int getCushioningDisableTime() const
|
||||
{
|
||||
return m_cushioning_disable_time;
|
||||
} // getCushioningDisableTime
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the cushioning disable time. Used for networking state saving. */
|
||||
void setCushioningDisableTime(unsigned int cdt)
|
||||
{
|
||||
m_cushioning_disable_time = cdt;
|
||||
} // setCushioningDisableTime
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the maximum speed for this kart. */
|
||||
void setMaxSpeed(float new_max_speed)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user