Only cosmetic changes to adjust the files to our coding style.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9909 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2011-09-28 05:19:22 +00:00
parent 3777726596
commit 3e32b840bf
8 changed files with 192 additions and 129 deletions

View File

@@ -32,9 +32,9 @@ STKModifiedSpriteBank::STKModifiedSpriteBank(IGUIEnvironment* env) :
if (Driver)
Driver->grab();
}
}
} // STKModifiedSpriteBank
// ----------------------------------------------------------------------------
STKModifiedSpriteBank::~STKModifiedSpriteBank()
{
// drop textures
@@ -47,44 +47,45 @@ STKModifiedSpriteBank::~STKModifiedSpriteBank()
Driver->drop();
m_magic_number = 0xDEADBEEF;
}
} // ~STKModifiedSpriteBank
// ----------------------------------------------------------------------------
core::array< core::rect<s32> >& STKModifiedSpriteBank::getPositions()
{
assert( m_magic_number == 0xCAFEC001 );
copy.clear();
//FIXME: terribly unefficient, CGUIListBox will call this once for every item xD
// but I have no choice, short of re-implementing IGUIListBox too
//FIXME: terribly unefficient, CGUIListBox will call this once for every
// item xD but I have no choice, short of re-implementing
// IGUIListBox too
for (int n=0; n<(int)Rectangles.size(); n++)
{
copy.push_back(
core::rect<s32>(Rectangles[n].UpperLeftCorner,
core::dimension2d<s32>((int)(Rectangles[n].getWidth()*m_scale),
(int)(Rectangles[n].getHeight()*m_scale)) )
const int h = (int)(Rectangles[n].getHeight()*m_scale);
const int w = (int)(Rectangles[n].getWidth() *m_scale);
copy.push_back( core::rect<s32>(Rectangles[n].UpperLeftCorner,
core::dimension2d<s32>(w,h) )
);
}
return copy;
}
} // getPositions
// ----------------------------------------------------------------------------
core::array< SGUISprite >& STKModifiedSpriteBank::getSprites()
{
assert( m_magic_number == 0xCAFEC001 );
return Sprites;
}
} // getSprites
// ----------------------------------------------------------------------------
u32 STKModifiedSpriteBank::getTextureCount() const
{
assert( m_magic_number == 0xCAFEC001 );
return Textures.size();
}
} // getTextureCount
// ----------------------------------------------------------------------------
video::ITexture* STKModifiedSpriteBank::getTexture(u32 index) const
{
assert( m_magic_number == 0xCAFEC001 );
@@ -92,9 +93,9 @@ video::ITexture* STKModifiedSpriteBank::getTexture(u32 index) const
return Textures[index];
else
return 0;
}
} // getTexture
// ----------------------------------------------------------------------------
void STKModifiedSpriteBank::addTexture(video::ITexture* texture)
{
assert( m_magic_number == 0xCAFEC001 );
@@ -102,9 +103,9 @@ void STKModifiedSpriteBank::addTexture(video::ITexture* texture)
texture->grab();
Textures.push_back(texture);
}
} // addTexture
// ----------------------------------------------------------------------------
void STKModifiedSpriteBank::setTexture(u32 index, video::ITexture* texture)
{
assert( m_magic_number == 0xCAFEC001 );
@@ -118,9 +119,9 @@ void STKModifiedSpriteBank::setTexture(u32 index, video::ITexture* texture)
Textures[index]->drop();
Textures[index] = texture;
}
} // setTexture
// ----------------------------------------------------------------------------
//! clear everything
void STKModifiedSpriteBank::clear()
{
@@ -132,9 +133,11 @@ void STKModifiedSpriteBank::clear()
Textures.clear();
Sprites.clear();
Rectangles.clear();
}
} // clear
//! Add the texture and use it for a single non-animated sprite.
// ----------------------------------------------------------------------------
/** Add the texture and use it for a single non-animated sprite.
*/
s32 STKModifiedSpriteBank::addTextureAsSprite(video::ITexture* texture)
{
assert( m_magic_number == 0xCAFEC001 );
@@ -145,7 +148,9 @@ s32 STKModifiedSpriteBank::addTextureAsSprite(video::ITexture* texture)
u32 textureIndex = getTextureCount() - 1;
u32 rectangleIndex = Rectangles.size();
Rectangles.push_back( core::rect<s32>(0,0, texture->getOriginalSize().Width, texture->getOriginalSize().Height) );
Rectangles.push_back( core::rect<s32>(0,0,
texture->getOriginalSize().Width,
texture->getOriginalSize().Height) );
SGUISprite sprite;
sprite.frameTime = 0;
@@ -158,10 +163,12 @@ s32 STKModifiedSpriteBank::addTextureAsSprite(video::ITexture* texture)
Sprites.push_back( sprite );
return Sprites.size() - 1;
}
} // addTextureAsSprite
// ----------------------------------------------------------------------------
//! draws a sprite in 2d with scale and color
void STKModifiedSpriteBank::draw2DSprite(u32 index, const core::position2di& pos,
void STKModifiedSpriteBank::draw2DSprite(u32 index,
const core::position2di& pos,
const core::rect<s32>* clip, const video::SColor& color,
u32 starttime, u32 currenttime, bool loop, bool center)
{
@@ -177,10 +184,12 @@ void STKModifiedSpriteBank::draw2DSprite(u32 index, const core::position2di& pos
if (loop)
frame = f % Sprites[index].Frames.size();
else
frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size()-1 : f;
frame = (f >= Sprites[index].Frames.size())
? Sprites[index].Frames.size()-1 : f;
}
const video::ITexture* tex = Textures[Sprites[index].Frames[frame].textureNumber];
const video::ITexture* tex =
Textures[Sprites[index].Frames[frame].textureNumber];
if (!tex)
return;
@@ -192,29 +201,34 @@ void STKModifiedSpriteBank::draw2DSprite(u32 index, const core::position2di& pos
const core::dimension2d<s32>& dim = r.getSize();
core::rect<s32> dest( pos, core::dimension2d<s32>((int)(dim.Width*m_scale),
(int)(dim.Height*m_scale)) );
core::rect<s32> dest( pos,
core::dimension2d<s32>((int)(dim.Width*m_scale),
(int)(dim.Height*m_scale)) );
if (center)
{
dest -= dest.getSize() / 2;
}
/*
draw2DImage (const video::ITexture *texture, const core::rect< s32 > &destRect,
const core::rect< s32 > &sourceRect, const core::rect< s32 > *clipRect=0,
const video::SColor *const colors=0, bool useAlphaChannelOfTexture=false)=0
draw2DImage (const video::ITexture *texture,
const core::rect< s32 > &destRect,
const core::rect< s32 > &sourceRect,
const core::rect< s32 > *clipRect=0,
const video::SColor *const colors=0,
bool useAlphaChannelOfTexture=false)=0
*/
Driver->draw2DImage(tex, dest, r /* source rect */, clip, NULL /* colors */, true);
Driver->draw2DImage(tex, dest, r /* source rect */, clip,
NULL /* colors */, true);
}
} // draw2DSprite
void STKModifiedSpriteBank::draw2DSpriteBatch( const core::array<u32>& indices,
const core::array<core::position2di>& pos,
const core::rect<s32>* clip,
const video::SColor& color,
u32 starttime, u32 currenttime,
bool loop, bool center)
// ----------------------------------------------------------------------------
void STKModifiedSpriteBank::draw2DSpriteBatch(const core::array<u32>& indices,
const core::array<core::position2di>& pos,
const core::rect<s32>* clip,
const video::SColor& color,
u32 starttime, u32 currenttime,
bool loop, bool center)
{
assert( m_magic_number == 0xCAFEC001 );
const irr::u32 drawCount = core::min_<u32>(indices.size(), pos.size());
@@ -242,7 +256,8 @@ void STKModifiedSpriteBank::draw2DSpriteBatch( const core::array<u32>& indices,
if (loop)
frame = f % Sprites[index].Frames.size();
else
frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size()-1 : f;
frame = (f >= Sprites[index].Frames.size())
? Sprites[index].Frames.size()-1 : f;
}
const u32 texNum = Sprites[index].Frames[frame].textureNumber;
@@ -272,12 +287,14 @@ void STKModifiedSpriteBank::draw2DSpriteBatch( const core::array<u32>& indices,
for(u32 i = 0;i < drawBatches.size();i++)
{
if(!drawBatches[i].positions.empty() && !drawBatches[i].sourceRects.empty())
if(!drawBatches[i].positions.empty() &&
!drawBatches[i].sourceRects.empty())
Driver->draw2DImageBatch(Textures[i], drawBatches[i].positions,
drawBatches[i].sourceRects, clip, color, true);
}
}
} // draw2DSpriteBatch
// ----------------------------------------------------------------------------
} // namespace gui
} // namespace irr

View File

@@ -41,11 +41,12 @@ AbstractStateManager::AbstractStateManager()
#pragma mark Game State Management
#endif
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void AbstractStateManager::enterGameState()
{
assert(!ModalDialog::isADialogActive()); // you need to close any dialog before calling this
// you need to close any dialog before calling this
assert(!ModalDialog::isADialogActive());
if (getCurrentScreen() != NULL) getCurrentScreen()->tearDown();
m_menu_stack.clear();
@@ -54,14 +55,14 @@ void AbstractStateManager::enterGameState()
GUIEngine::cleanForGame();
} // enterGameState
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
GameState AbstractStateManager::getGameState()
{
return m_game_mode;
} // getGameState
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void AbstractStateManager::setGameState(GameState state)
{
@@ -73,7 +74,7 @@ void AbstractStateManager::setGameState(GameState state)
} // setGameState
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#if 0
#pragma mark -
@@ -85,7 +86,8 @@ void AbstractStateManager::pushMenu(std::string name)
// currently, only a single in-game menu is supported
assert(m_game_mode != INGAME_MENU);
assert(!ModalDialog::isADialogActive()); // you need to close any dialog before calling this
// you need to close any dialog before calling this
assert(!ModalDialog::isADialogActive());
if (UserConfigParams::logGUI())
{
@@ -94,7 +96,8 @@ void AbstractStateManager::pushMenu(std::string name)
}
// Send tear-down event to previous menu
if (m_menu_stack.size() > 0 && m_game_mode != GAME) getCurrentScreen()->tearDown();
if (m_menu_stack.size() > 0 && m_game_mode != GAME)
getCurrentScreen()->tearDown();
m_menu_stack.push_back(name);
if (m_game_mode == GAME)
@@ -111,11 +114,12 @@ void AbstractStateManager::pushMenu(std::string name)
} // pushMenu
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void AbstractStateManager::pushScreen(Screen* screen)
{
assert(!ModalDialog::isADialogActive()); // you need to close any dialog before calling this
// you need to close any dialog before calling this
assert(!ModalDialog::isADialogActive());
if (UserConfigParams::logGUI())
{
@@ -130,20 +134,21 @@ void AbstractStateManager::pushScreen(Screen* screen)
onTopMostScreenChanged();
} // pushScreen
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void AbstractStateManager::replaceTopMostScreen(Screen* screen)
{
assert(m_game_mode != GAME);
assert(!ModalDialog::isADialogActive()); // you need to close any dialog before calling this
// you need to close any dialog before calling this
assert(!ModalDialog::isADialogActive());
if (!screen->isLoaded()) screen->loadFromFile();
std::string name = screen->getName();
if (UserConfigParams::logGUI())
{
std::cout << "[AbstractStateManager::replaceTopmostScreen] switching to screen "
<< name.c_str() << std::endl;
std::cout << "[AbstractStateManager::replaceTopmostScreen] "
"switching to screen " << name.c_str() << std::endl;
}
assert(m_menu_stack.size() > 0);
@@ -160,12 +165,13 @@ void AbstractStateManager::replaceTopMostScreen(Screen* screen)
onTopMostScreenChanged();
} // replaceTopMostScreen
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void AbstractStateManager::reshowTopMostMenu()
{
assert(m_game_mode != GAME);
assert(!ModalDialog::isADialogActive()); // you need to close any dialog before calling this
// you need to close any dialog before calling this
assert(!ModalDialog::isADialogActive());
// Send tear-down event to previous menu
if (m_menu_stack.size() > 0)
@@ -184,7 +190,7 @@ void AbstractStateManager::reshowTopMostMenu()
onTopMostScreenChanged();
} // reshowTopMostMenu
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void AbstractStateManager::popMenu()
{
@@ -224,18 +230,19 @@ void AbstractStateManager::popMenu()
onTopMostScreenChanged();
} // popMenu
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void AbstractStateManager::resetAndGoToScreen(Screen* screen)
{
assert(!ModalDialog::isADialogActive()); // you need to close any dialog before calling this
// you need to close any dialog before calling this
assert(!ModalDialog::isADialogActive());
std::string name = screen->getName();
if (UserConfigParams::logGUI())
{
std::cout << "[AbstractStateManager::resetAndGoToScreen] switching to screen "
<< name.c_str() << std::endl;
std::cout << "[AbstractStateManager::resetAndGoToScreen] "
"switching to screen " << name.c_str() << std::endl;
}
if (m_game_mode != GAME) getCurrentScreen()->tearDown();
@@ -250,13 +257,14 @@ void AbstractStateManager::resetAndGoToScreen(Screen* screen)
onTopMostScreenChanged();
} // resetAndGoToScreen
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void AbstractStateManager::resetAndSetStack(Screen* screens[])
{
assert(screens != NULL);
assert(screens[0] != NULL);
assert(!ModalDialog::isADialogActive()); // you need to close any dialog before calling this
// you need to close any dialog before calling this
assert(!ModalDialog::isADialogActive());
if (m_game_mode != GAME) getCurrentScreen()->tearDown();
m_menu_stack.clear();

View File

@@ -42,7 +42,7 @@ namespace GUIEngine
MENU,
GAME,
INGAME_MENU
};
}; // GameState
/**
* \brief Abstract base class you must override from to use the GUI engine
@@ -57,7 +57,8 @@ namespace GUIEngine
GameState m_game_mode;
/**
* This stack will contain menu names (e.g. main.stkgui), and/or 'race'.
* This stack will contain menu names (e.g. main.stkgui),
* and/or 'race'.
*/
std::vector<std::string> m_menu_stack;
@@ -110,7 +111,7 @@ namespace GUIEngine
/**
* \brief call to make the state manager enter game mode.
* Causes the menu stack to be cleared; all widgets shown on screen
* Causes the menu stack to be cleared; all widgets shown on screen
* are removed
*/
void enterGameState();
@@ -157,7 +158,7 @@ namespace GUIEngine
virtual void onGameStateChange(GameState new_state) = 0;
/**
* \brief callback invoked when the stack is emptied (all menus are
* \brief callback invoked when the stack is emptied (all menus are
* popped out). This is essentially a request to close the
* application (since a game can't run without a state)
*/
@@ -165,7 +166,7 @@ namespace GUIEngine
virtual void onTopMostScreenChanged() = 0;
};
}; // Class AbstractStateManager
}
} // GUIEngine
#endif

View File

@@ -41,7 +41,9 @@ AbstractTopLevelContainer::AbstractTopLevelContainer()
m_last_widget = NULL;
}
void AbstractTopLevelContainer::addWidgetsRecursively(PtrVector<Widget>& widgets, Widget* parent)
void AbstractTopLevelContainer::addWidgetsRecursively(
PtrVector<Widget>& widgets,
Widget* parent)
{
const unsigned short widgets_amount = widgets.size();
@@ -55,21 +57,25 @@ void AbstractTopLevelContainer::addWidgetsRecursively(PtrVector<Widget>& widgets
}
else
{
// warn if widget has no dimensions (except for ribbons and icons, where it is normal since it
// adjusts to its contents)
// warn if widget has no dimensions (except for ribbons and icons,
// where it is normal since it adjusts to its contents)
if ((widgets[n].m_w < 1 || widgets[n].m_h < 1) &&
widgets[n].getType() != WTYPE_RIBBON &&
widgets[n].getType() != WTYPE_ICON_BUTTON &&
widgets[n].getType() != WTYPE_SPACER)
{
std::cerr << "/!\\ Warning /!\\ : widget " << widgets[n].m_properties[PROP_ID].c_str()
<< " of type " << widgets[n].getType() << " has no dimensions" << std::endl;
std::cerr << "/!\\ Warning /!\\ : widget "
<< widgets[n].m_properties[PROP_ID].c_str()
<< " of type " << widgets[n].getType()
<< " has no dimensions" << std::endl;
}
if (widgets[n].m_x == -1 || widgets[n].m_y == -1)
{
std::cerr << "/!\\ Warning /!\\ : widget " << widgets[n].m_properties[PROP_ID].c_str()
<< " of type " << widgets[n].getType() << " has no position" << std::endl;
std::cerr << "/!\\ Warning /!\\ : widget "
<< widgets[n].m_properties[PROP_ID].c_str()
<< " of type " << widgets[n].getType()
<< " has no position" << std::endl;
}
widgets[n].add();
@@ -155,12 +161,15 @@ Widget* AbstractTopLevelContainer::getWidget(const int id,
{
Widget& widget = (*within_vector)[n];
if (widget.m_element != NULL && widget.getIrrlichtElement()->getID() == id) return &widget;
if (widget.m_element != NULL &&
widget.getIrrlichtElement()->getID() == id) return &widget;
if (widget.searchInsideMe() && widget.getChildren().size() > 0)
{
// std::cout << "widget = <" << widget.m_properties[PROP_ID].c_str()
// << "> widget.m_children.size()=" << widget.m_children.size() << std::endl;
// std::cout << "widget = <"
// << widget.m_properties[PROP_ID].c_str()
// << "> widget.m_children.size()="
// << widget.m_children.size() << std::endl;
Widget* el = getWidget(id, &(widget.m_children));
if(el != NULL) return el;
}
@@ -171,7 +180,8 @@ Widget* AbstractTopLevelContainer::getWidget(const int id,
// -----------------------------------------------------------------------------
Widget* AbstractTopLevelContainer::getFirstWidget(PtrVector<Widget>* within_vector)
Widget* AbstractTopLevelContainer::getFirstWidget(
PtrVector<Widget>* within_vector)
{
if (m_first_widget != NULL) return m_first_widget;
if (within_vector == NULL) within_vector = &m_widgets;
@@ -180,7 +190,8 @@ Widget* AbstractTopLevelContainer::getFirstWidget(PtrVector<Widget>* within_vect
{
if (!within_vector->get(i)->m_focusable) continue;
// if container, also checks children (FIXME: don't hardcode which types to avoid descending into)
// if container, also checks children
// (FIXME: don't hardcode which types to avoid descending into)
if (within_vector->get(i)->m_children.size() > 0 &&
within_vector->get(i)->getType() != WTYPE_RIBBON &&
within_vector->get(i)->getType() != WTYPE_SPINNER)
@@ -192,7 +203,8 @@ Widget* AbstractTopLevelContainer::getFirstWidget(PtrVector<Widget>* within_vect
Widget* item = within_vector->get(i);
if (item->getIrrlichtElement() == NULL ||
item->getIrrlichtElement()->getTabOrder() == -1 ||
item->getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */ ||
/* non-tabbing items are given such IDs */
item->getIrrlichtElement()->getTabOrder() >= 1000 ||
!item->m_focusable)
{
continue;
@@ -205,7 +217,8 @@ Widget* AbstractTopLevelContainer::getFirstWidget(PtrVector<Widget>* within_vect
// -----------------------------------------------------------------------------
Widget* AbstractTopLevelContainer::getLastWidget(PtrVector<Widget>* within_vector)
Widget* AbstractTopLevelContainer::getLastWidget(
PtrVector<Widget>* within_vector)
{
if (m_last_widget != NULL) return m_last_widget;
if (within_vector == NULL) within_vector = &m_widgets;

View File

@@ -42,22 +42,24 @@ namespace GUIEngine
PtrVector<Widget, HOLD> m_widgets;
/**
* AbstractTopLevelContainer is generally able to determine its first widget just fine,
* but in highly complex screens (e.g. multiplayer kart selection) you can help it by
* providing the first widget manually.
* AbstractTopLevelContainer is generally able to determine its first
* widget just fine, but in highly complex screens (e.g. multiplayer
* kart selection) you can help it by providing the first widget
* manually.
*/
Widget* m_first_widget;
/**
* AbstractTopLevelContainer is generally able to determine its last widget just fine,
* but in highly complex screens (e.g. multiplayer kart selection) you can help it by
* providing the first widget manually.
* AbstractTopLevelContainer is generally able to determine its last
* widget just fine, but in highly complex screens (e.g. multiplayer
* kart selection) you can help it by providing the first widget
* manually.
*/
Widget* m_last_widget;
void addWidgetsRecursively(PtrVector<Widget>& widgets, Widget* parent=NULL);
void addWidgetsRecursively(PtrVector<Widget>& widgets,
Widget* parent=NULL);
public:
AbstractTopLevelContainer();
virtual ~AbstractTopLevelContainer() {}
@@ -71,29 +73,33 @@ namespace GUIEngine
/** \return an object by irrlicht ID, or NULL if not found */
Widget* getWidget(const int id);
/** \return an object by name, casted to specified type, or NULL if not found/wrong type */
/** \return an object by name, casted to specified type, or NULL if
* not found/wrong type */
template <typename T> T* getWidget(const char* name)
{
Widget* out = getWidget(name);
T* outCasted = dynamic_cast<T*>( out );
if (out != NULL && outCasted == NULL)
{
fprintf(stderr, "Screen::getWidget : Widget '%s' of type '%s' cannot be casted to "
"requested type '%s'!\n", name, typeid(*out).name(), typeid(T).name());
fprintf(stderr, "Screen::getWidget : Widget '%s' of type '%s'"
"cannot be casted to requested type '%s'!\n", name,
typeid(*out).name(), typeid(T).name());
abort();
}
return outCasted;
}
static Widget* getWidget(const char* name, PtrVector<Widget>* within_vector);
static Widget* getWidget(const int id, PtrVector<Widget>* within_vector);
static Widget* getWidget(const char* name,
PtrVector<Widget>* within_vector);
static Widget* getWidget(const int id,
PtrVector<Widget>* within_vector);
Widget* getFirstWidget(PtrVector<Widget>* within_vector=NULL);
Widget* getLastWidget(PtrVector<Widget>* within_vector=NULL);
bool isMyChild(Widget* widget) const;
};
}; // AbstractTopLevelContainer
}
} // namespace GUIEngine
#endif

View File

@@ -80,7 +80,7 @@ RubberBall::RubberBall(Kart *kart, Track* track)
m_ping_sfx = sfx_manager->createSoundSource("ball_bounce");
} // RubberBall
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
RubberBall::~RubberBall()
{
if(m_ping_sfx->getStatus()==SFXManager::SFX_PLAYING)
@@ -88,7 +88,7 @@ RubberBall::~RubberBall()
sfx_manager->deleteSFX(m_ping_sfx);
} // ~RubberBall
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
/** Sets up the control points for the interpolation. The parameter contains
* the coordinates of the first control points (i.e. a control point that
* influences the direction the ball is flying only, not the actual
@@ -117,7 +117,7 @@ void RubberBall::initializeControlPoints(const Vec3 &xyz)
m_t_increase = m_speed/m_length_cp_1_2;
} // initialiseControlPoints
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
/** Determines the first kart. If a target has already been identified in an
* earlier call, it is tested first, avoiding a loop over all karts.
*/
@@ -140,7 +140,7 @@ void RubberBall::computeTarget()
}
} // computeTarget
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
/** Determines the successor of a graph node. For now always a successor on
* the main driveline is returned, but a more sophisticated implementation
* might check if the target kart is on a shortcut, and select the path so
@@ -199,7 +199,7 @@ void RubberBall::getNextControlPoint()
QuadGraph::get()->getQuadOfNode(m_last_aimed_graph_node).getCenter();
} // getNextControlPoint
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
/** Initialises this object with data from the power.xml file (this is a static
* function).
* \param node XML Node
@@ -285,9 +285,6 @@ bool RubberBall::updateAndDelete(float dt)
checkDistanceToTarget();
// FIXME: do we want to test if we have overtaken the target kart?
m_previous_xyz = getXYZ();
Vec3 next_xyz;
if(m_aiming_at_target)
{
@@ -356,6 +353,7 @@ bool RubberBall::updateAndDelete(float dt)
else
m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
m_previous_xyz = getXYZ();
setXYZ(next_xyz);
return false;
@@ -387,16 +385,19 @@ void RubberBall::interpolate(Vec3 *next_xyz, float dt)
m_t -= 1.0f;
}
*next_xyz = 0.5f * ((-m_control_points[0] + 3*m_control_points[1] -3*m_control_points[2] + m_control_points[3])*m_t*m_t*m_t
+ (2*m_control_points[0] -5*m_control_points[1] + 4*m_control_points[2] - m_control_points[3])*m_t*m_t
+ (-m_control_points[0]+m_control_points[2])*m_t
+ 2*m_control_points[1]);
*next_xyz = 0.5f * ((- m_control_points[0] + 3*m_control_points[1]
-3*m_control_points[2] + m_control_points[3] )
*m_t*m_t*m_t
+ ( 2*m_control_points[0] -5*m_control_points[1]
+4*m_control_points[2] - m_control_points[3])*m_t*m_t
+ (- m_control_points[0] + m_control_points[2])*m_t
+ 2*m_control_points[1] );
} // interpolate
// ----------------------------------------------------------------------------
/** Updates the height of the rubber ball, and if necessary also adjusts the
* maximum height of the ball depending on distance from the target. The
* height is decreased when the ball is getting closer to the target so it
* height is decreased when the ball is getting closer to the target so it
* hops faster and faster. This function modifies m_current_max_height.
* \return Returns the new height of the ball.
*/

View File

@@ -4,13 +4,18 @@ Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
In no event will the authors be held liable for any damages arising from the
use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a
product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
@@ -42,8 +47,9 @@ void btUprightConstraint::solveAngularLimit(
? limit->m_angle - m_loLimit
: limit->m_angle - m_hiLimit;
btScalar targetVelocity = -m_ERP*limit->m_currentLimitError/(3.1415f/8.0f*timeStep);
btScalar maxMotorForce = m_maxLimitForce;
btScalar targetVelocity = -m_ERP*limit->m_currentLimitError
/ (3.1415f/8.0f*timeStep);
btScalar maxMotorForce = m_maxLimitForce;
maxMotorForce *= timeStep;
@@ -52,7 +58,8 @@ void btUprightConstraint::solveAngularLimit(
btScalar axisAngularVelocity = limit->m_axis.dot( angularVelocity );
// correction velocity
btScalar motorVelocity = m_limitSoftness*(targetVelocity - m_damping*axisAngularVelocity);
btScalar motorVelocity = m_limitSoftness*(targetVelocity
- m_damping*axisAngularVelocity);
// correction impulse
btScalar unclippedMotorImpulse = (1+m_bounce)*motorVelocity*jacDiagABInv;
@@ -64,11 +71,13 @@ void btUprightConstraint::solveAngularLimit(
if (unclippedMotorImpulse>0.0f)
{
clippedMotorImpulse = unclippedMotorImpulse > maxMotorForce? maxMotorForce: unclippedMotorImpulse;
clippedMotorImpulse = unclippedMotorImpulse > maxMotorForce
? maxMotorForce : unclippedMotorImpulse;
}
else
{
clippedMotorImpulse = unclippedMotorImpulse < -maxMotorForce ? -maxMotorForce: unclippedMotorImpulse;
clippedMotorImpulse = unclippedMotorImpulse < -maxMotorForce
? -maxMotorForce : unclippedMotorImpulse;
}
// sort with accumulated impulses
@@ -79,7 +88,8 @@ void btUprightConstraint::solveAngularLimit(
btScalar sum = oldaccumImpulse + clippedMotorImpulse;
limit->m_accumulatedImpulse = sum > hi ? btScalar(0.) : sum < lo ? btScalar(0.) : sum;
limit->m_accumulatedImpulse = sum > hi ? btScalar(0.)
: sum < lo ? btScalar(0.) : sum;
clippedMotorImpulse = limit->m_accumulatedImpulse - oldaccumImpulse;

View File

@@ -4,13 +4,18 @@ Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
In no event will the authors be held liable for any damages arising from the
use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a
product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
@@ -101,7 +106,9 @@ public:
void setDamping( btScalar damping ) { m_damping = damping; }
void setDisableTime( btScalar t ) { m_disable_time = t; }
virtual void buildJacobian();
virtual void solveConstraintObsolete(btRigidBody& /*bodyA*/,btRigidBody& /*bodyB*/, btScalar timeStep);
virtual void solveConstraintObsolete(btRigidBody& /*bodyA*/,
btRigidBody& /*bodyB*/, btScalar
timeStep);
virtual void getInfo1 (btConstraintInfo1* info);
virtual void getInfo2 (btConstraintInfo2* info);
virtual void setParam(int num, btScalar value, int axis = -1);