1) Improved rubber ball handling, which should work better in tunnels
and inclines now. 2) Added --debug=flyable debug option to use print plenty of debug output for rubber balls (needs to be compiled with -DDEBUG to work). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9762 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
78eac6b7ce
commit
13de49b5ee
@ -632,7 +632,7 @@ bool UserConfig::loadConfig()
|
||||
} // loadConfig
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Write settings to config file. */
|
||||
void UserConfig::saveConfig()
|
||||
{
|
||||
@ -670,10 +670,23 @@ void UserConfig::saveConfig()
|
||||
|
||||
} // saveConfig
|
||||
|
||||
bool UserConfigParams::logMemory() { return (m_verbosity&LOG_MEMORY) == LOG_MEMORY;}
|
||||
// ----------------------------------------------------------------------------
|
||||
bool UserConfigParams::logMemory()
|
||||
{ return (m_verbosity&LOG_MEMORY) == LOG_MEMORY;}
|
||||
|
||||
bool UserConfigParams::logGUI () { return (m_verbosity&LOG_GUI) == LOG_GUI; }
|
||||
// ----------------------------------------------------------------------------
|
||||
bool UserConfigParams::logGUI ()
|
||||
{ return (m_verbosity&LOG_GUI) == LOG_GUI; }
|
||||
|
||||
bool UserConfigParams::logAddons() { return (m_verbosity&LOG_ADDONS) == LOG_ADDONS;}
|
||||
// ----------------------------------------------------------------------------
|
||||
bool UserConfigParams::logAddons()
|
||||
{ return (m_verbosity&LOG_ADDONS) == LOG_ADDONS;}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
bool UserConfigParams::logFlyable()
|
||||
{ return (m_verbosity&LOG_FLYABLE) == LOG_FLYABLE; }
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
bool UserConfigParams::logMisc()
|
||||
{ return (m_verbosity&LOG_MISC) == LOG_MISC; }
|
||||
|
||||
bool UserConfigParams::logMisc () { return (m_verbosity&LOG_MISC) == LOG_MISC; }
|
||||
|
@ -518,11 +518,12 @@ namespace UserConfigParams
|
||||
PARAM_PREFIX PtrVector<PlayerProfile> m_all_players;
|
||||
|
||||
/** Some constants to bitmask to enable various messages to be printed. */
|
||||
enum { LOG_MEMORY = 0x0001,
|
||||
LOG_GUI = 0x0002,
|
||||
LOG_ADDONS = 0x0004,
|
||||
LOG_MISC = 0x0008,
|
||||
LOG_ALL = 0xffff };
|
||||
enum { LOG_MEMORY = 0x0001,
|
||||
LOG_GUI = 0x0002,
|
||||
LOG_ADDONS = 0x0004,
|
||||
LOG_MISC = 0x0008,
|
||||
LOG_FLYABLE = 0x0010,
|
||||
LOG_ALL = 0xffff };
|
||||
|
||||
/** Returns true if the user want additional messages for memory usage. */
|
||||
bool logMemory();
|
||||
@ -530,6 +531,8 @@ namespace UserConfigParams
|
||||
bool logGUI ();
|
||||
/** Returns true if the user want additional messages related to addons. */
|
||||
bool logAddons();
|
||||
/** Returns true if the user want additional debug info for flyables */
|
||||
bool logFlyable();
|
||||
/** Returns true if the user want additional messages for general items. */
|
||||
bool logMisc ();
|
||||
|
||||
|
@ -147,7 +147,14 @@ void Flyable::createPhysics(float forw_offset, const Vec3 &velocity,
|
||||
btCollisionObject::CF_NO_CONTACT_RESPONSE);
|
||||
|
||||
} // createPhysics
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Initialises the static members of this class for a certain type with
|
||||
* default values and with settings from powerup.xml.
|
||||
* \param The xml node containing settings.
|
||||
* \param model The mesh to use.
|
||||
* \param type The type of flyable.
|
||||
*/
|
||||
void Flyable::init(const XMLNode &node, scene::IMesh *model,
|
||||
PowerupManager::PowerupType type)
|
||||
{
|
||||
|
@ -32,15 +32,22 @@ float RubberBall::m_st_min_interpolation_distance;
|
||||
float RubberBall::m_st_squash_duration;
|
||||
float RubberBall::m_st_squash_slowdown;
|
||||
float RubberBall::m_st_target_distance;
|
||||
#ifdef DEBUG
|
||||
int RubberBall::m_next_id = 0;
|
||||
#endif
|
||||
|
||||
RubberBall::RubberBall(Kart *kart)
|
||||
: Flyable(kart, PowerupManager::POWERUP_RUBBERBALL, 0.0f /* mass */),
|
||||
TrackSector()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
m_next_id++;
|
||||
m_id = m_next_id;
|
||||
#endif
|
||||
// The rubber ball often misses the terrain on steep uphill slopes, e.g.
|
||||
// the ramp in sand track. Add an Y offset so that the terrain raycast
|
||||
// will always be done from a position high enough to avoid this.
|
||||
setPositionOffset(Vec3(0, 1.0f, 0));
|
||||
setPositionOffset(Vec3(0, 0.5f, 0));
|
||||
float forw_offset = 0.5f*kart->getKartLength() + m_extend.getZ()*0.5f+5.0f;
|
||||
|
||||
createPhysics(forw_offset, btVector3(0.0f, 0.0f, m_speed*2),
|
||||
@ -240,6 +247,19 @@ const core::stringw RubberBall::getHitString(const Kart *kart) const
|
||||
*/
|
||||
bool RubberBall::updateAndDelete(float dt)
|
||||
{
|
||||
// We have to adjust the offset used in the height of terrain computation:
|
||||
// If the ball is close to the ground, we have to start the raycast
|
||||
// slightly higher (to avoid that the ball tunnels through the floor).
|
||||
// But if the ball is close to the ceiling of a tunnel and we would
|
||||
// start the raycast slightly higher, the ball might end up on top
|
||||
// of the ceiling.
|
||||
// The ball is considered close to the ground if the height above the
|
||||
// terrain is less than half the current maximum height.
|
||||
bool close_to_ground = 2.0*(getXYZ().getY() - getHoT())
|
||||
< m_current_max_height;
|
||||
Vec3 offset(0, close_to_ground ? 1.0f : 0.0f, 0);
|
||||
Flyable::setPositionOffset(offset);
|
||||
|
||||
if(Flyable::updateAndDelete(dt))
|
||||
return true;
|
||||
|
||||
@ -274,6 +294,11 @@ bool RubberBall::updateAndDelete(float dt)
|
||||
m_timer += dt;
|
||||
float height = updateHeight();
|
||||
float new_y = getHoT()+height;
|
||||
#ifdef DEBUG
|
||||
if(UserConfigParams::logFlyable())
|
||||
printf("ball %d: height %f new_y %f gethot %f ",
|
||||
m_id, height, new_y, getHoT());
|
||||
#endif
|
||||
// No need to check for terrain height if the ball is low to the ground
|
||||
if(height > 0.5f)
|
||||
{
|
||||
@ -281,6 +306,11 @@ bool RubberBall::updateAndDelete(float dt)
|
||||
if(new_y>terrain_height)
|
||||
new_y = terrain_height;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if(UserConfigParams::logFlyable())
|
||||
printf("newy2 %f gmth %f\n", new_y,getMaxTerrainHeight());
|
||||
#endif
|
||||
|
||||
next_xyz.setY(new_y);
|
||||
|
||||
// Determine new distance along track
|
||||
@ -391,9 +421,9 @@ float RubberBall::updateHeight()
|
||||
// with f(0) = 0, f(m_intervall)=0. We then scale this function to
|
||||
// fulfill: f(m_intervall/2) = max_height, or:
|
||||
// f(m_interval/2) = s*(-m_interval^2)/4 = max_height
|
||||
// --> s = max_height / -m_interval^2/4
|
||||
float f = m_current_max_height / (-0.25f*m_interval*m_interval);
|
||||
return m_timer * (m_timer-m_interval) * f;
|
||||
// --> s = 4*max_height / -m_interval^2
|
||||
float s = 4.0f * m_current_max_height / (-m_interval*m_interval);
|
||||
return m_timer * (m_timer-m_interval) * s;
|
||||
} // updateHeight
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -35,6 +35,14 @@ class SFXBase;
|
||||
class RubberBall: public Flyable, public TrackSector
|
||||
{
|
||||
private:
|
||||
#ifdef DEBUG
|
||||
/** Used in case of flyable debugging so that each output line gets
|
||||
* a unique number for each ball. */
|
||||
int m_id;
|
||||
|
||||
/** A class variable which stores the next id number to use. */
|
||||
static int m_next_id;
|
||||
#endif
|
||||
/** A class variable to store the default interval size. */
|
||||
static float m_st_interval;
|
||||
|
||||
@ -87,7 +95,7 @@ private:
|
||||
* to 1). */
|
||||
float m_t;
|
||||
|
||||
/** How much m_tt must increase per second in order to maintain a
|
||||
/** How much m_t must increase per second in order to maintain a
|
||||
* constant speed, i.e. the speed of the ball divided by the
|
||||
* distance between the control points. See m_t for more details. */
|
||||
float m_t_increase;
|
||||
|
15
src/main.cpp
15
src/main.cpp
@ -324,6 +324,10 @@ int handleCmdLinePreliminary(int argc, char **argv)
|
||||
{
|
||||
UserConfigParams::m_verbosity |= UserConfigParams::LOG_GUI;
|
||||
}
|
||||
else if ( !strcmp(argv[i], "--debug=flyable") )
|
||||
{
|
||||
UserConfigParams::m_verbosity |= UserConfigParams::LOG_FLYABLE;
|
||||
}
|
||||
else if ( !strcmp(argv[i], "--debug=misc") )
|
||||
{
|
||||
UserConfigParams::m_verbosity |= UserConfigParams::LOG_MISC;
|
||||
@ -754,11 +758,12 @@ int handleCmdLine(int argc, char **argv)
|
||||
else if( !strcmp(argv[i], "--trackdir") && i+1<argc ) { i++; }
|
||||
else if( !strcmp(argv[i], "--kartdir") && i+1<argc ) { i++; }
|
||||
else if( !strcmp(argv[i], "--renderer") && i+1<argc ) { i++; }
|
||||
else if( !strcmp(argv[i], "--debug=memory") ) {}
|
||||
else if( !strcmp(argv[i], "--debug=addons") ) {}
|
||||
else if( !strcmp(argv[i], "--debug=gui" ) ) {}
|
||||
else if( !strcmp(argv[i], "--debug=misc" ) ) {}
|
||||
else if( !strcmp(argv[i], "--debug=all" ) ) {}
|
||||
else if( !strcmp(argv[i], "--debug=memory" ) ) {}
|
||||
else if( !strcmp(argv[i], "--debug=addons" ) ) {}
|
||||
else if( !strcmp(argv[i], "--debug=gui" ) ) {}
|
||||
else if( !strcmp(argv[i], "--debug=flyable") ) {}
|
||||
else if( !strcmp(argv[i], "--debug=misc" ) ) {}
|
||||
else if( !strcmp(argv[i], "--debug=all" ) ) {}
|
||||
else if( !strcmp(argv[i], "--screensize") || !strcmp(argv[i], "-s")) {i++;}
|
||||
else if( !strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f")) {}
|
||||
else if( !strcmp(argv[i], "--windowed") || !strcmp(argv[i], "-w")) {}
|
||||
|
Loading…
Reference in New Issue
Block a user