Revert old workaround, fix the original issue in a cleaner way
This commit is contained in:
parent
673a9f39c6
commit
12c54cb92b
@ -779,10 +779,10 @@ void KartModel::update(float dt, float rotation_dt, float steer, float speed)
|
||||
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
if(!m_wheel_node[i]) continue;
|
||||
if (!m_kart || !m_wheel_node[i]) continue;
|
||||
const btWheelInfo &wi = m_kart->getVehicle()->getWheelInfo(i);
|
||||
#ifdef DEBUG
|
||||
if(UserConfigParams::m_physics_debug && m_kart)
|
||||
if(UserConfigParams::m_physics_debug)
|
||||
{
|
||||
// Make wheels that are not touching the ground invisible
|
||||
m_wheel_node[i]->setVisible(wi.m_raycastInfo.m_isInContact);
|
||||
@ -816,54 +816,57 @@ void KartModel::update(float dt, float rotation_dt, float steer, float speed)
|
||||
if (m_animated_node == NULL) return;
|
||||
|
||||
// Update the speed-weighted objects' animations
|
||||
for(size_t i=0 ; i < m_speed_weighted_objects.size() ; i++)
|
||||
if (m_kart != NULL)
|
||||
{
|
||||
SpeedWeightedObject& obj = m_speed_weighted_objects[i];
|
||||
for (size_t i = 0; i < m_speed_weighted_objects.size(); i++)
|
||||
{
|
||||
SpeedWeightedObject& obj = m_speed_weighted_objects[i];
|
||||
|
||||
#define GET_VALUE(obj, value_name) \
|
||||
obj.m_properties.value_name > SPEED_WEIGHTED_OBJECT_PROPERTY_UNDEFINED ? obj.m_properties.value_name : \
|
||||
m_kart->getKartProperties()->getSpeedWeightedObjectProperties().value_name
|
||||
|
||||
// Animation strength
|
||||
float strength = 1.0f;
|
||||
const float strength_factor = GET_VALUE(obj, m_strength_factor);
|
||||
if(strength_factor >= 0.0f)
|
||||
{
|
||||
strength = speed * strength_factor;
|
||||
btClamp<float>(strength, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
// Animation speed
|
||||
const float speed_factor = GET_VALUE(obj, m_speed_factor);
|
||||
if(speed_factor >= 0.0f)
|
||||
{
|
||||
float anim_speed = speed * speed_factor;
|
||||
obj.m_node->setAnimationSpeed(anim_speed);
|
||||
}
|
||||
|
||||
// Texture animation
|
||||
core::vector2df tex_speed;
|
||||
tex_speed.X = GET_VALUE(obj, m_texture_speed.X);
|
||||
tex_speed.Y = GET_VALUE(obj, m_texture_speed.Y);
|
||||
if(tex_speed != core::vector2df(0.0f, 0.0f))
|
||||
{
|
||||
obj.m_texture_cur_offset += speed * tex_speed * dt;
|
||||
if(obj.m_texture_cur_offset.X > 1.0f) obj.m_texture_cur_offset.X = fmod(obj.m_texture_cur_offset.X, 1.0f);
|
||||
if(obj.m_texture_cur_offset.Y > 1.0f) obj.m_texture_cur_offset.Y = fmod(obj.m_texture_cur_offset.Y, 1.0f);
|
||||
|
||||
for(unsigned int i=0; i<obj.m_node->getMaterialCount(); i++)
|
||||
// Animation strength
|
||||
float strength = 1.0f;
|
||||
const float strength_factor = GET_VALUE(obj, m_strength_factor);
|
||||
if (strength_factor >= 0.0f)
|
||||
{
|
||||
video::SMaterial &irrMaterial=obj.m_node->getMaterial(i);
|
||||
for(unsigned int j=0; j<video::MATERIAL_MAX_TEXTURES; j++)
|
||||
strength = speed * strength_factor;
|
||||
btClamp<float>(strength, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
// Animation speed
|
||||
const float speed_factor = GET_VALUE(obj, m_speed_factor);
|
||||
if (speed_factor >= 0.0f)
|
||||
{
|
||||
float anim_speed = speed * speed_factor;
|
||||
obj.m_node->setAnimationSpeed(anim_speed);
|
||||
}
|
||||
|
||||
// Texture animation
|
||||
core::vector2df tex_speed;
|
||||
tex_speed.X = GET_VALUE(obj, m_texture_speed.X);
|
||||
tex_speed.Y = GET_VALUE(obj, m_texture_speed.Y);
|
||||
if (tex_speed != core::vector2df(0.0f, 0.0f))
|
||||
{
|
||||
obj.m_texture_cur_offset += speed * tex_speed * dt;
|
||||
if (obj.m_texture_cur_offset.X > 1.0f) obj.m_texture_cur_offset.X = fmod(obj.m_texture_cur_offset.X, 1.0f);
|
||||
if (obj.m_texture_cur_offset.Y > 1.0f) obj.m_texture_cur_offset.Y = fmod(obj.m_texture_cur_offset.Y, 1.0f);
|
||||
|
||||
for (unsigned int i = 0; i < obj.m_node->getMaterialCount(); i++)
|
||||
{
|
||||
video::ITexture* t=irrMaterial.getTexture(j);
|
||||
if(!t) continue;
|
||||
core::matrix4 *m = &irrMaterial.getTextureMatrix(j);
|
||||
m->setTextureTranslate(obj.m_texture_cur_offset.X, obj.m_texture_cur_offset.Y);
|
||||
} // for j<MATERIAL_MAX_TEXTURES
|
||||
} // for i<getMaterialCount
|
||||
}
|
||||
video::SMaterial &irrMaterial = obj.m_node->getMaterial(i);
|
||||
for (unsigned int j = 0; j < video::MATERIAL_MAX_TEXTURES; j++)
|
||||
{
|
||||
video::ITexture* t = irrMaterial.getTexture(j);
|
||||
if (!t) continue;
|
||||
core::matrix4 *m = &irrMaterial.getTextureMatrix(j);
|
||||
m->setTextureTranslate(obj.m_texture_cur_offset.X, obj.m_texture_cur_offset.Y);
|
||||
} // for j<MATERIAL_MAX_TEXTURES
|
||||
} // for i<getMaterialCount
|
||||
}
|
||||
#undef GET_VALUE
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the end animation is being played, if so, don't
|
||||
|
@ -300,7 +300,7 @@ void FeatureUnlockedCutScene::init()
|
||||
m_unlocked_stuff[n].m_root_gift_node = kart_model->attachModel(true, false);
|
||||
m_unlocked_stuff[n].m_scale = 5.0f;
|
||||
kart_model->setAnimation(KartModel::AF_DEFAULT);
|
||||
//kart_model->update(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
kart_model->update(0.0f, 0.0f, 0.0f, 0.0f); // set model current frame to "center"
|
||||
|
||||
#ifdef DEBUG
|
||||
m_unlocked_stuff[n].m_root_gift_node->setName("unlocked kart");
|
||||
|
Loading…
Reference in New Issue
Block a user