Bugfix: pitch and roll of items were not set, resulting esp. in
bananas not lying on the ground if the ground is non-horizontal. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4659 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -42,6 +42,7 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
|
||||
m_original_mesh = mesh;
|
||||
m_node = irr_driver->addMesh(mesh);
|
||||
m_node->setPosition(xyz.toIrrVector());
|
||||
m_node->setRotation(hpr.toIrrHPR());
|
||||
m_node->grab();
|
||||
} // Item
|
||||
|
||||
@@ -170,16 +171,19 @@ void Item::update(float dt)
|
||||
* has been collected, and the time to return to the parameter.
|
||||
* \param t Time till the object reappears (defaults to 2 seconds).
|
||||
*/
|
||||
void Item::collected(float t)
|
||||
void Item::collected(const Kart *kart, float t)
|
||||
{
|
||||
m_collected = true;
|
||||
m_collected = true;
|
||||
m_event_handler = kart;
|
||||
if(m_type==ITEM_BUBBLEGUM)
|
||||
{
|
||||
deactivate(0.5);
|
||||
// Deactivates the item for a certain amount of time. It is used to
|
||||
// prevent bubble gum from hitting a kart over and over again (in each
|
||||
// frame) by giving it time to drive away.
|
||||
m_deactive_time = 0.5f;
|
||||
// Set the time till reappear to -1 seconds --> the item will
|
||||
// reappear immediately.
|
||||
m_time_till_return = -1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
|
||||
/** optionally, set this if this item was laid by a particular kart. in this case,
|
||||
the 'm_deactive_time' will also be set - see below. */
|
||||
Kart* m_event_handler;
|
||||
const Kart *m_event_handler;
|
||||
/** optionally, if item was placed by a kart, a timer can be used to temporarly
|
||||
deactivate collision so a kart is not hit by its own item */
|
||||
float m_deactive_time;
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
scene::IMesh* mesh, unsigned int item_id);
|
||||
virtual ~Item ();
|
||||
void update (float delta);
|
||||
virtual void collected(float t=2.0f);
|
||||
virtual void collected(const Kart *kart, float t=2.0f);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if the Kart is close enough to hit this item, and
|
||||
@@ -99,17 +99,10 @@ public:
|
||||
*/
|
||||
bool hitKart (Kart* kart ) const
|
||||
{
|
||||
return m_deactive_time <=0 &&
|
||||
return (m_event_handler!=kart || m_deactive_time <=0) &&
|
||||
(kart->getXYZ()-m_coord.getXYZ()).length2()<0.8f;
|
||||
} // hitKart
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Deactivates the item for a certain amount of time. It is used to
|
||||
* prevent bubble gum from hitting a kart over and over again (in each
|
||||
* frame) by giving it time to drive away.
|
||||
* \param t Time the item is deactivated.
|
||||
*/
|
||||
void deactivate(float t) { m_deactive_time=t; }
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getItemId() const { return m_item_id; }
|
||||
ItemType getType() const { return m_type; }
|
||||
|
||||
@@ -156,7 +156,7 @@ Item* ItemManager::newItem(Item::ItemType type, const Vec3& xyz,
|
||||
void ItemManager::collectedItem(int item_id, Kart *kart, int add_info)
|
||||
{
|
||||
Item *item=m_all_items[item_id];
|
||||
item->collected();
|
||||
item->collected(kart);
|
||||
kart->collectedItem(*item, add_info);
|
||||
} // collectedItem
|
||||
|
||||
|
||||
Reference in New Issue
Block a user