diff --git a/src/graphics/shadow.cpp b/src/graphics/shadow.cpp index c42ecb83b..668d20525 100644 --- a/src/graphics/shadow.cpp +++ b/src/graphics/shadow.cpp @@ -93,8 +93,9 @@ void Shadow::update(bool enabled) const btWheelInfo& wi = m_kart.getVehicle()->getWheelInfo(i); Vec3 up_vector = kart_trans.getBasis().getColumn(1); up_vector = up_vector * (wi.m_raycastInfo.m_suspensionLength - 0.02f); - v[i].m_position = - Vec3(kart_trans(Vec3(v[i].m_position)) - up_vector).toIrrVector(); + Vec3 pos = kart_trans(Vec3(v[i].m_position)) - up_vector; + m_kart.transformSmoothedPosition(&pos); + v[i].m_position = pos.toIrrVector(); v[i].m_normal = MiniGLM::compressVector3 (Vec3(wi.m_raycastInfo.m_contactNormalWS).toIrrVector()); } diff --git a/src/graphics/skid_marks.cpp b/src/graphics/skid_marks.cpp index 35fa35ae3..d6ce1286a 100644 --- a/src/graphics/skid_marks.cpp +++ b/src/graphics/skid_marks.cpp @@ -151,10 +151,17 @@ void SkidMarks::update(float dt, bool force_skid_marks, // but it produces good enough results float distance = (newPoint - start).length(); - m_left.back()->add(raycast_left-delta, raycast_left+delta, - m_kart.getNormal(), distance); - m_right.back()->add(raycast_right-delta, raycast_right+delta, - m_kart.getNormal(), distance); + Vec3 p1 = raycast_left - delta; + Vec3 p2 = raycast_left + delta; + Vec3 p3 = raycast_right - delta; + Vec3 p4 = raycast_right + delta; + m_kart.transformSmoothedPosition(&p1); + m_kart.transformSmoothedPosition(&p2); + m_kart.transformSmoothedPosition(&p3); + m_kart.transformSmoothedPosition(&p4); + + m_left.back()->add(p1, p2, m_kart.getNormal(), distance); + m_right.back()->add(p3, p4, m_kart.getNormal(), distance); return; } @@ -184,15 +191,22 @@ void SkidMarks::update(float dt, bool force_skid_marks, m_right.erase(m_right.begin()); } + Vec3 p1 = raycast_left - delta; + Vec3 p2 = raycast_left + delta; + Vec3 p3 = raycast_right - delta; + Vec3 p4 = raycast_right + delta; + m_kart.transformSmoothedPosition(&p1); + m_kart.transformSmoothedPosition(&p2); + m_kart.transformSmoothedPosition(&p3); + m_kart.transformSmoothedPosition(&p4); + m_left.emplace_back( - new SkidMarkQuads(raycast_left-delta, raycast_left+delta, - m_kart.getNormal(), m_material, m_shader, - m_avoid_z_fighting, custom_color)); + new SkidMarkQuads(p1, p2, m_kart.getNormal(), m_material, m_shader, + m_avoid_z_fighting, custom_color)); m_right.emplace_back( - new SkidMarkQuads(raycast_right-delta, raycast_right+delta, - m_kart.getNormal(), m_material, m_shader, - m_avoid_z_fighting, custom_color)); + new SkidMarkQuads(p3, p4, m_kart.getNormal(), m_material, m_shader, + m_avoid_z_fighting, custom_color)); m_skid_marking = true; } // update diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 7795ee2aa..38cd7666a 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -2938,23 +2938,6 @@ SFXBase* Kart::getNextEmitter() */ void Kart::updateGraphics(float dt) { - static video::SColor pink(255, 255, 133, 253); - static video::SColor green(255, 61, 87, 23); - -#ifndef SERVER_ONLY - // draw skidmarks if relevant (we force pink skidmarks on when hitting - // a bubblegum) - if (m_kart_properties->getSkidEnabled() && m_skidmarks) - { - m_skidmarks->update(dt, - m_bubblegum_ticks > 0, - (m_bubblegum_ticks > 0 - ? (m_has_caught_nolok_bubblegum ? &green - : &pink) - : NULL)); - } -#endif - // Upate particle effects (creation rate, and emitter size // depending on speed) // -------------------------------------------------------- @@ -3043,6 +3026,23 @@ void Kart::updateGraphics(float dt) Moveable::updateGraphics(dt, center_shift, btQuaternion(heading, 0, -m_current_lean)); + static video::SColor pink(255, 255, 133, 253); + static video::SColor green(255, 61, 87, 23); + +#ifndef SERVER_ONLY + // draw skidmarks if relevant (we force pink skidmarks on when hitting + // a bubblegum) + if (m_kart_properties->getSkidEnabled() && m_skidmarks) + { + m_skidmarks->update(dt, + m_bubblegum_ticks > 0, + (m_bubblegum_ticks > 0 + ? (m_has_caught_nolok_bubblegum ? &green + : &pink) + : NULL)); + } +#endif + // m_speed*dt is the distance the kart has moved, which determines // how much the wheels need to rotate. m_kart_model->update(dt, m_speed*dt, getSteerPercent(), m_speed, lean_height); diff --git a/src/karts/moveable.hpp b/src/karts/moveable.hpp index d18757bf4..441a5780e 100644 --- a/src/karts/moveable.hpp +++ b/src/karts/moveable.hpp @@ -170,6 +170,12 @@ public: static std::string unused("unused"); return unused; } + // ------------------------------------------------------------------------ + void transformSmoothedPosition(Vec3* position) const + { + Vec3 p = m_transform.inverse()(*position); + *position = m_smoothed_transform(p); + } }; // class Moveable