From a6b2fe443d7d94087b9b23dc8aaef572f9b1ff8b Mon Sep 17 00:00:00 2001 From: hikerstk Date: Wed, 19 Jan 2011 00:28:35 +0000 Subject: [PATCH] Fixed incorrect rotations of bubble gums after a switch (bug 3155867). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7482 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/items/item.cpp | 7 ++++--- src/items/item.hpp | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/items/item.cpp b/src/items/item.cpp index e8d891438..ecceac287 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -34,7 +34,7 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal, m_xyz = xyz; m_deactive_time = 0; // Sets heading to 0, and sets pitch and roll depending on the normal. */ - Vec3 hpr = Vec3(0, normal); + m_original_hpr = Vec3(0, normal); m_item_id = item_id; m_original_type = ITEM_NONE; m_collected = false; @@ -53,7 +53,7 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal, World::getWorld()->getTrack()->adjustForFog(m_node); m_node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX); m_node->setPosition(xyz.toIrrVector()); - m_node->setRotation(hpr.toIrrHPR()); + m_node->setRotation(m_original_hpr.toIrrHPR()); m_node->grab(); } // Item @@ -90,10 +90,11 @@ void Item::switchBack() // bubble gum has no original type. if(m_original_type==ITEM_NONE) return; - + setType(m_original_type); m_original_type = ITEM_NONE; m_node->setMesh(m_original_mesh); + m_node->setRotation(m_original_hpr.toIrrHPR()); } // switchBack //----------------------------------------------------------------------------- diff --git a/src/items/item.hpp b/src/items/item.hpp index 9d64ccdde..c9875d1c0 100644 --- a/src/items/item.hpp +++ b/src/items/item.hpp @@ -64,6 +64,14 @@ private: * It is ITEM_NONE if the item is not switched. */ ItemType m_original_type; + /** Stores the original rotation of an item. This is used in + * case of a switch to restore the rotation of a bubble gum + * (bubble gums don't rotate, but it will be replaced with + * a nitro which rotates, and so overwrites the original + * rotation). + */ + Vec3 m_original_hpr; + /** True if item was collected & is not displayed. */ bool m_collected;