2013-03-28 10:04:07 -07:00
|
|
|
// Copyright (C) 2008-2012 Colin MacDonald
|
2009-05-04 17:09:53 -07:00
|
|
|
// No rights reserved: this software is in the public domain.
|
|
|
|
|
|
|
|
#include "testUtils.h"
|
|
|
|
|
|
|
|
using namespace irr;
|
|
|
|
using namespace core;
|
|
|
|
using namespace scene;
|
|
|
|
|
|
|
|
class CustomAnimator : public ISceneNodeAnimator
|
|
|
|
{
|
|
|
|
void animateNode(ISceneNode* node, u32 timeMs)
|
|
|
|
{
|
|
|
|
// Check that I can remove myself from my node durings its animateNode() loop.
|
|
|
|
node->removeAnimator(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0) { return 0 ; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** Test that a custom animator can remove itself cleanly from an ISceneNode during its
|
2013-04-04 09:15:53 -07:00
|
|
|
* own animateNode() loop.
|
2009-05-04 17:09:53 -07:00
|
|
|
* http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=32271 */
|
|
|
|
bool removeCustomAnimator(void)
|
|
|
|
{
|
2009-07-03 02:11:53 -07:00
|
|
|
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2du(160, 120));
|
2013-04-04 09:15:53 -07:00
|
|
|
assert_log(device);
|
2009-05-04 17:09:53 -07:00
|
|
|
if(!device)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ISceneManager * smgr = device->getSceneManager();
|
|
|
|
|
|
|
|
ISceneNode * node = smgr->addEmptySceneNode();
|
|
|
|
CustomAnimator * instantlyElapsing1 = new CustomAnimator();
|
|
|
|
CustomAnimator * instantlyElapsing2 = new CustomAnimator();
|
|
|
|
node->addAnimator(instantlyElapsing1);
|
|
|
|
node->addAnimator(instantlyElapsing2);
|
|
|
|
|
|
|
|
// This should result in both custom animators being removed and
|
|
|
|
// deleted cleanly, without a crash.
|
|
|
|
node->OnAnimate(0);
|
2013-04-04 09:15:53 -07:00
|
|
|
|
2011-01-14 07:36:50 -08:00
|
|
|
device->closeDevice();
|
|
|
|
device->run();
|
2009-05-04 17:09:53 -07:00
|
|
|
device->drop();
|
|
|
|
|
|
|
|
// If we didn't crash, then the test passed.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|