Added option to disable kart animations in the user config file.
For now it also disables win/lose animations, but if it's worth keeping non-animated karts (for performance on lower end graphics card) this will be added. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5492 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
01629af9ee
commit
7c0ff2772a
@ -240,6 +240,9 @@ namespace UserConfigParams
|
||||
PARAM_PREFIX BoolUserConfigParam m_graphical_effects
|
||||
PARAM_DEFAULT( BoolUserConfigParam(true, "gfx", &m_video_group) );
|
||||
|
||||
PARAM_PREFIX BoolUserConfigParam m_show_steering_animations
|
||||
PARAM_DEFAULT( BoolUserConfigParam(true, "steering_animations", &m_video_group, "Display steering animations in race") );
|
||||
|
||||
PARAM_PREFIX BoolUserConfigParam m_display_fps
|
||||
PARAM_DEFAULT( BoolUserConfigParam(false, "show_fps", &m_video_group, "Display frame per seconds") );
|
||||
PARAM_PREFIX IntUserConfigParam m_max_fps
|
||||
|
@ -97,11 +97,24 @@ KartModel::~KartModel()
|
||||
* \param node Node to attach the models to.
|
||||
*/
|
||||
void KartModel::attachModel(scene::ISceneNode **node)
|
||||
{
|
||||
if(UserConfigParams::m_show_steering_animations)
|
||||
{
|
||||
*node = irr_driver->addAnimatedMesh(m_mesh);
|
||||
m_node = static_cast<scene::IAnimatedMeshSceneNode*>(*node);
|
||||
m_node->setAnimationSpeed(1500);
|
||||
m_node->setLoopMode(false);
|
||||
m_animated_node = static_cast<scene::IAnimatedMeshSceneNode*>(*node);
|
||||
m_animated_node->setAnimationSpeed(1500);
|
||||
m_animated_node->setLoopMode(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If no animations are shown, make sure to pick the frame
|
||||
// with a straight ahead animation (if exist).
|
||||
int straight_frame = m_animation_frame[AF_STRAIGHT]>=0
|
||||
? m_animation_frame[AF_STRAIGHT]
|
||||
: 0;
|
||||
*node = irr_driver->addMesh(m_mesh->getMesh(straight_frame));
|
||||
}
|
||||
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
m_wheel_node[i] = irr_driver->addMesh(m_wheel_model[i]);
|
||||
@ -117,6 +130,8 @@ void KartModel::loadModels(const KartProperties &kart_properties)
|
||||
{
|
||||
std::string full_path = kart_properties.getKartDir()+"/"+m_model_filename;
|
||||
m_mesh = irr_driver->getAnimatedMesh(full_path);
|
||||
if(!UserConfigParams::m_show_steering_animations)
|
||||
m_mesh->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
Vec3 min, max;
|
||||
if(!m_mesh)
|
||||
{
|
||||
@ -235,21 +250,23 @@ void KartModel::setDefaultPhysicsPosition(const Vec3 ¢er_shift,
|
||||
*/
|
||||
void KartModel::setAnimation(AnimationFrameType type)
|
||||
{
|
||||
if(!UserConfigParams::m_show_steering_animations) return;
|
||||
|
||||
m_current_animation = type;
|
||||
if(!m_current_animation==AF_DEFAULT)
|
||||
{
|
||||
m_node->setLoopMode(false);
|
||||
m_node->setFrameLoop(m_animation_frame[AF_STRAIGHT],
|
||||
m_animated_node->setLoopMode(false);
|
||||
m_animated_node->setFrameLoop(m_animation_frame[AF_STRAIGHT],
|
||||
m_animation_frame[AF_STRAIGHT] );
|
||||
}
|
||||
|
||||
if(m_current_animation!=AF_DEFAULT && m_animation_frame[type]>-1)
|
||||
{
|
||||
AnimationFrameType end = (AnimationFrameType)(type+1);
|
||||
m_node->setFrameLoop(m_animation_frame[type],
|
||||
m_animated_node->setFrameLoop(m_animation_frame[type],
|
||||
m_animation_frame[end] );
|
||||
m_node->setLoopMode(true);
|
||||
m_node->setAnimationSpeed(m_animation_speed);
|
||||
m_animated_node->setLoopMode(true);
|
||||
m_animated_node->setAnimationSpeed(m_animation_speed);
|
||||
}
|
||||
} // setEndAnimation
|
||||
|
||||
@ -303,6 +320,8 @@ void KartModel::update(float rotation, float visual_steer,
|
||||
|
||||
if(m_animation_frame[AF_LEFT]<0) return; // no animations defined
|
||||
|
||||
if(!UserConfigParams::m_show_steering_animations) return;
|
||||
|
||||
// Update animation if necessary
|
||||
// -----------------------------
|
||||
// FIXME: this implementation is currently very simple, it will always
|
||||
@ -321,19 +340,19 @@ void KartModel::update(float rotation, float visual_steer,
|
||||
// No changes to current frame loop
|
||||
if(end==last_end) return;
|
||||
|
||||
int begin = (int)m_node->getFrameNr();
|
||||
int begin = (int)m_animated_node->getFrameNr();
|
||||
last_end = end;
|
||||
// Handle reverse animation, which are done by setting
|
||||
// the animation speed to a negative number.
|
||||
if(begin<end)
|
||||
{
|
||||
m_node->setFrameLoop(begin, end);
|
||||
m_node->setAnimationSpeed(m_animation_speed);
|
||||
m_animated_node->setFrameLoop(begin, end);
|
||||
m_animated_node->setAnimationSpeed(m_animation_speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_node->setFrameLoop(begin, end);
|
||||
m_node->setAnimationSpeed(-m_animation_speed);
|
||||
m_animated_node->setFrameLoop(begin, end);
|
||||
m_animated_node->setAnimationSpeed(-m_animation_speed);
|
||||
}
|
||||
} // update
|
||||
|
||||
|
@ -67,8 +67,9 @@ private:
|
||||
scene::IAnimatedMesh *m_mesh;
|
||||
|
||||
/** This is a pointer to the scene node of the kart this model belongs
|
||||
* to. It is necessary to adjust animations. */
|
||||
scene::IAnimatedMeshSceneNode *m_node;
|
||||
* to. It is necessary to adjust animations, and it is not used
|
||||
* (i.e. neither read nor written) if animations are disabled. */
|
||||
scene::IAnimatedMeshSceneNode *m_animated_node;
|
||||
|
||||
/** Value used to indicate undefined entries. */
|
||||
static float UNDEFINED;
|
||||
|
Loading…
Reference in New Issue
Block a user