From 2391338b5759160abe01532e225c17ca9fb8e3a3 Mon Sep 17 00:00:00 2001 From: cutealien Date: Wed, 10 Jun 2009 20:13:37 +0000 Subject: [PATCH] - Fix bug in CSceneNodeAnimatorCollisionResponse::setWorld as found by Quillraven. - Fix simliar bugs where object have been dropped accidentally in set functions in many places git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2417 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CGUIButton.cpp | 21 +++--- source/Irrlicht/CGUIContextMenu.cpp | 3 +- source/Irrlicht/CGUIListBox.cpp | 2 + source/Irrlicht/CGUIMeshViewer.cpp | 6 +- source/Irrlicht/CGUISkin.cpp | 11 ++-- source/Irrlicht/CGUISpriteBank.cpp | 6 +- source/Irrlicht/CGUITreeView.cpp | 64 ++++++++++--------- source/Irrlicht/CIrrDeviceStub.cpp | 13 ++-- source/Irrlicht/CMeshSceneNode.cpp | 32 +++++----- source/Irrlicht/COctTreeSceneNode.cpp | 10 +-- source/Irrlicht/CParticleSystemSceneNode.cpp | 4 +- source/Irrlicht/CSceneManager.cpp | 14 ++-- .../CSceneNodeAnimatorCollisionResponse.cpp | 17 +++-- source/Irrlicht/CShadowVolumeSceneNode.cpp | 2 + tests/tests-last-passed-at.txt | 2 +- 15 files changed, 104 insertions(+), 103 deletions(-) diff --git a/source/Irrlicht/CGUIButton.cpp b/source/Irrlicht/CGUIButton.cpp index 798504b6..962fe3c1 100644 --- a/source/Irrlicht/CGUIButton.cpp +++ b/source/Irrlicht/CGUIButton.cpp @@ -305,6 +305,8 @@ void CGUIButton::setOverrideFont(IGUIFont* font) //! Sets an image which should be displayed on the button when it is in normal state. void CGUIButton::setImage(video::ITexture* image) { + if (image) + image->grab(); if (Image) Image->drop(); @@ -315,9 +317,6 @@ void CGUIButton::setImage(video::ITexture* image) ImageRect = core::rect(core::position2d(0,0), signedSize); } - if (Image) - Image->grab(); - if (!PressedImage) setPressedImage(Image); } @@ -326,15 +325,14 @@ void CGUIButton::setImage(video::ITexture* image) //! Sets the image which should be displayed on the button when it is in its normal state. void CGUIButton::setImage(video::ITexture* image, const core::rect& pos) { + if (image) + image->grab(); if (Image) Image->drop(); Image = image; ImageRect = pos; - if (Image) - Image->grab(); - if (!PressedImage) setPressedImage(Image, pos); } @@ -343,6 +341,9 @@ void CGUIButton::setImage(video::ITexture* image, const core::rect& pos) //! Sets an image which should be displayed on the button when it is in pressed state. void CGUIButton::setPressedImage(video::ITexture* image) { + if (image) + image->grab(); + if (PressedImage) PressedImage->drop(); @@ -352,23 +353,19 @@ void CGUIButton::setPressedImage(video::ITexture* image) core::dimension2di signedSize(image->getOriginalSize()); PressedImageRect = core::rect(core::position2d(0,0), signedSize); } - - if (PressedImage) - PressedImage->grab(); } //! Sets the image which should be displayed on the button when it is in its pressed state. void CGUIButton::setPressedImage(video::ITexture* image, const core::rect& pos) { + if (image) + image->grab(); if (PressedImage) PressedImage->drop(); PressedImage = image; PressedImageRect = pos; - - if (PressedImage) - PressedImage->grab(); } diff --git a/source/Irrlicht/CGUIContextMenu.cpp b/source/Irrlicht/CGUIContextMenu.cpp index cf03ace7..36323c08 100644 --- a/source/Irrlicht/CGUIContextMenu.cpp +++ b/source/Irrlicht/CGUIContextMenu.cpp @@ -90,6 +90,8 @@ void CGUIContextMenu::setSubMenu(u32 index, CGUIContextMenu* menu) if (index >= Items.size()) return; + if (menu) + menu->grab(); if (Items[index].SubMenu) Items[index].SubMenu->drop(); @@ -98,7 +100,6 @@ void CGUIContextMenu::setSubMenu(u32 index, CGUIContextMenu* menu) if (Items[index].SubMenu) { - menu->grab(); menu->AllowFocus = false; if ( Environment->getFocus() == menu ) { diff --git a/source/Irrlicht/CGUIListBox.cpp b/source/Irrlicht/CGUIListBox.cpp index 711d6d54..d3bbec78 100644 --- a/source/Irrlicht/CGUIListBox.cpp +++ b/source/Irrlicht/CGUIListBox.cpp @@ -597,6 +597,8 @@ u32 CGUIListBox::addItem(const wchar_t* text, s32 icon) void CGUIListBox::setSpriteBank(IGUISpriteBank* bank) { + if ( bank == IconBank ) + return; if (IconBank) IconBank->drop(); diff --git a/source/Irrlicht/CGUIMeshViewer.cpp b/source/Irrlicht/CGUIMeshViewer.cpp index 501218dc..b7f11919 100644 --- a/source/Irrlicht/CGUIMeshViewer.cpp +++ b/source/Irrlicht/CGUIMeshViewer.cpp @@ -40,14 +40,12 @@ CGUIMeshViewer::~CGUIMeshViewer() //! sets the mesh to be shown void CGUIMeshViewer::setMesh(scene::IAnimatedMesh* mesh) { + if (mesh) + mesh->grab(); if (Mesh) Mesh->drop(); Mesh = mesh; - if (!Mesh) - return; - else - Mesh->grab(); /* This might be used for proper transformation etc. core::vector3df center(0.0f,0.0f,0.0f); diff --git a/source/Irrlicht/CGUISkin.cpp b/source/Irrlicht/CGUISkin.cpp index 95edab88..03e1bb5e 100644 --- a/source/Irrlicht/CGUISkin.cpp +++ b/source/Irrlicht/CGUISkin.cpp @@ -205,13 +205,12 @@ void CGUISkin::setFont(IGUIFont* font, EGUI_DEFAULT_FONT which) if ((u32)which >= EGDS_COUNT) return; + if (font) + font->grab(); if (Fonts[which]) Fonts[which]->drop(); Fonts[which] = font; - - if (Fonts[which]) - Fonts[which]->grab(); } @@ -225,12 +224,12 @@ IGUISpriteBank* CGUISkin::getSpriteBank() const //! set a new sprite bank or remove one by passing 0 void CGUISkin::setSpriteBank(IGUISpriteBank* bank) { - if (SpriteBank) - SpriteBank->drop(); - if (bank) bank->grab(); + if (SpriteBank) + SpriteBank->drop(); + SpriteBank = bank; } diff --git a/source/Irrlicht/CGUISpriteBank.cpp b/source/Irrlicht/CGUISpriteBank.cpp index fca57d00..6c8f13f7 100644 --- a/source/Irrlicht/CGUISpriteBank.cpp +++ b/source/Irrlicht/CGUISpriteBank.cpp @@ -80,12 +80,12 @@ void CGUISpriteBank::setTexture(u32 index, video::ITexture* texture) while (index >= Textures.size()) Textures.push_back(0); - if (Textures[index]) - Textures[index]->drop(); - if (texture) texture->grab(); + if (Textures[index]) + Textures[index]->drop(); + Textures[index] = texture; } diff --git a/source/Irrlicht/CGUITreeView.cpp b/source/Irrlicht/CGUITreeView.cpp index 1abc56d5..fe41ae10 100644 --- a/source/Irrlicht/CGUITreeView.cpp +++ b/source/Irrlicht/CGUITreeView.cpp @@ -74,8 +74,8 @@ void CGUITreeViewNode::clearChilds() } IGUITreeViewNode* CGUITreeViewNode::addChildBack( - const wchar_t* text, - const wchar_t* icon /*= 0*/, + const wchar_t* text, + const wchar_t* icon /*= 0*/, s32 imageIndex /*= -1*/, s32 selectedImageIndex /*= -1*/, void* data /*= 0*/, @@ -97,9 +97,9 @@ IGUITreeViewNode* CGUITreeViewNode::addChildBack( return newChild; } -IGUITreeViewNode* CGUITreeViewNode::addChildFront( - const wchar_t* text, - const wchar_t* icon /*= 0*/, +IGUITreeViewNode* CGUITreeViewNode::addChildFront( + const wchar_t* text, + const wchar_t* icon /*= 0*/, s32 imageIndex /*= -1*/, s32 selectedImageIndex /*= -1*/, void* data /*= 0*/, @@ -121,10 +121,10 @@ IGUITreeViewNode* CGUITreeViewNode::addChildFront( return newChild; } -IGUITreeViewNode* CGUITreeViewNode::insertChildAfter( - IGUITreeViewNode* other, - const wchar_t* text, - const wchar_t* icon /*= 0*/, +IGUITreeViewNode* CGUITreeViewNode::insertChildAfter( + IGUITreeViewNode* other, + const wchar_t* text, + const wchar_t* icon /*= 0*/, s32 imageIndex /*= -1*/, s32 selectedImageIndex /*= -1*/, void* data /*= 0*/, @@ -155,10 +155,10 @@ IGUITreeViewNode* CGUITreeViewNode::insertChildAfter( return newChild; } -IGUITreeViewNode* CGUITreeViewNode::insertChildBefore( - IGUITreeViewNode* other, - const wchar_t* text, - const wchar_t* icon /*= 0*/, +IGUITreeViewNode* CGUITreeViewNode::insertChildBefore( + IGUITreeViewNode* other, + const wchar_t* text, + const wchar_t* icon /*= 0*/, s32 imageIndex /*= -1*/, s32 selectedImageIndex /*= -1*/, void* data /*= 0*/, @@ -421,10 +421,10 @@ bool CGUITreeViewNode::isVisible() const //! constructor -CGUITreeView::CGUITreeView(IGUIEnvironment* environment, IGUIElement* parent, +CGUITreeView::CGUITreeView(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle, bool clip, bool drawBack,bool scrollBarVertical, bool scrollBarHorizontal) - : IGUITreeView( environment, parent, id, rectangle ), + : IGUITreeView( environment, parent, id, rectangle ), Root(0), Selected(0), ItemHeight( 0 ), IndentWidth( 0 ), @@ -452,7 +452,7 @@ CGUITreeView::CGUITreeView(IGUIEnvironment* environment, IGUIElement* parent, if ( scrollBarVertical ) { ScrollBarV = new CGUIScrollBar( false, Environment, this, 0, - core::rect( RelativeRect.getWidth() - s, + core::rect( RelativeRect.getWidth() - s, 0, RelativeRect.getWidth(), RelativeRect.getHeight() - (scrollBarHorizontal ? s : 0 ) @@ -539,7 +539,7 @@ void CGUITreeView::recalculateItemHeight() if( IconFont ) { - s32 height = IconFont->getDimension( L" " ).Height; + s32 height = IconFont->getDimension( L" " ).Height; if( height > ItemHeight ) { ItemHeight = height; @@ -658,7 +658,7 @@ bool CGUITreeView::OnEvent( const SEvent &event ) } Selecting = false; - Environment->removeFocus( this ); + Environment->removeFocus( this ); mouseAction( event.MouseInput.X, event.MouseInput.Y ); return true; break; @@ -728,7 +728,7 @@ void CGUITreeView::mouseAction( s32 xpos, s32 ypos, bool onlyHover /*= false*/ ) Selected = hitNode; } - if( hitNode && !onlyHover + if( hitNode && !onlyHover && xpos < hitNode->getLevel() * IndentWidth && xpos > ( hitNode->getLevel() - 1 ) * IndentWidth && hitNode->hasChilds() ) @@ -804,7 +804,7 @@ void CGUITreeView::draw() clipRect ); } - // draw the border + // draw the border frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + 1; driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), frameRect, clipRect ); @@ -953,10 +953,10 @@ void CGUITreeView::draw() index = node->getImageIndex(); } ImageList->draw( - index, - core::position2d( - textRect.UpperLeftCorner.X, - textRect.UpperLeftCorner.Y + ( ( textRect.getHeight() - ImageList->getImageSize().Height ) >> 1 ) ), + index, + core::position2d( + textRect.UpperLeftCorner.X, + textRect.UpperLeftCorner.Y + ( ( textRect.getHeight() - ImageList->getImageSize().Height ) >> 1 ) ), &clientClip ); iconWidth += ImageList->getImageSize().Width + 3; textRect.UpperLeftCorner.X += ImageList->getImageSize().Width + 3; @@ -976,7 +976,7 @@ void CGUITreeView::draw() textRect.UpperLeftCorner.X -= iconWidth; } - // draw the lines if neccessary + // draw the lines if neccessary if( LinesVisible ) { core::rect rc; @@ -997,7 +997,7 @@ void CGUITreeView::draw() clipRect ); if( node->getParent() != Root ) - { + { // vertical line if( node == node->getParent()->getFirstChild() ) { @@ -1012,7 +1012,7 @@ void CGUITreeView::draw() clipRect ); // the vertical lines of all parents - IGUITreeViewNode* nodeTmp = node->getParent(); + IGUITreeViewNode* nodeTmp = node->getParent(); rc.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - ( frameRect.getHeight() >> 1 ); for( s32 n = 0; n < node->getLevel() - 2; ++n ) { @@ -1046,7 +1046,9 @@ void CGUITreeView::setIconFont( IGUIFont* font ) { s32 height; - if( IconFont ) + if ( font ) + font->grab(); + if ( IconFont ) { IconFont->drop(); } @@ -1054,12 +1056,11 @@ void CGUITreeView::setIconFont( IGUIFont* font ) IconFont = font; if( IconFont ) { - height = IconFont->getDimension( L" " ).Height; + height = IconFont->getDimension( L" " ).Height; if( height > ItemHeight ) { ItemHeight = height; } - IconFont->grab(); } } @@ -1067,6 +1068,8 @@ void CGUITreeView::setIconFont( IGUIFont* font ) //! The default is 0 (no images). void CGUITreeView::setImageList( IGUIImageList* imageList ) { + if (imageList ) + imageList->grab(); if( ImageList ) { ImageList->drop(); @@ -1079,7 +1082,6 @@ void CGUITreeView::setImageList( IGUIImageList* imageList ) { ItemHeight = ImageList->getImageSize().Height + 1; } - ImageList->grab(); } } diff --git a/source/Irrlicht/CIrrDeviceStub.cpp b/source/Irrlicht/CIrrDeviceStub.cpp index 63df16a1..b5f98c29 100644 --- a/source/Irrlicht/CIrrDeviceStub.cpp +++ b/source/Irrlicht/CIrrDeviceStub.cpp @@ -18,7 +18,7 @@ namespace irr //! constructor CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters& params) -: IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0), +: IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0), Timer(0), CursorControl(0), UserReceiver(params.EventReceiver), Logger(0), Operator(0), FileSystem(0), InputReceivingSceneManager(0), CreationParams(params) { @@ -82,7 +82,7 @@ void CIrrDeviceStub::createGUIAndScene() #ifdef _IRR_COMPILE_WITH_GUI_ // create gui environment GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator); - #endif + #endif // create Scene manager SceneManager = scene::createSceneManager(VideoDriver, FileSystem, CursorControl, GUIEnvironment); @@ -130,7 +130,7 @@ ITimer* CIrrDeviceStub::getTimer() } -//! Returns the version of the engine. +//! Returns the version of the engine. const char* CIrrDeviceStub::getVersion() const { return IRRLICHT_SDK_VERSION; @@ -225,16 +225,15 @@ IOSOperator* CIrrDeviceStub::getOSOperator() } -//! Sets the input receiving scene manager. +//! Sets the input receiving scene manager. void CIrrDeviceStub::setInputReceivingSceneManager(scene::ISceneManager* sceneManager) { + if (sceneManager) + sceneManager->grab(); if (InputReceivingSceneManager) InputReceivingSceneManager->drop(); InputReceivingSceneManager = sceneManager; - - if (InputReceivingSceneManager) - InputReceivingSceneManager->grab(); } diff --git a/source/Irrlicht/CMeshSceneNode.cpp b/source/Irrlicht/CMeshSceneNode.cpp index 1d303bcf..0beda916 100644 --- a/source/Irrlicht/CMeshSceneNode.cpp +++ b/source/Irrlicht/CMeshSceneNode.cpp @@ -48,8 +48,8 @@ void CMeshSceneNode::OnRegisterSceneNode() { if (IsVisible) { - // because this node supports rendering of mixed mode meshes consisting of - // transparent and solid material at the same time, we need to go through all + // because this node supports rendering of mixed mode meshes consisting of + // transparent and solid material at the same time, we need to go through all // materials, check of what type they are and register this node for the right // render pass according to that. @@ -62,16 +62,16 @@ void CMeshSceneNode::OnRegisterSceneNode() // count transparent and solid materials in this scene node if (ReadOnlyMaterials && Mesh) { - // count mesh materials + // count mesh materials for (u32 i=0; igetMeshBufferCount(); ++i) { scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); video::IMaterialRenderer* rnd = mb ? driver->getMaterialRenderer(mb->getMaterial().MaterialType) : 0; - if (rnd && rnd->isTransparent()) + if (rnd && rnd->isTransparent()) ++transparentCount; - else + else ++solidCount; if (solidCount && transparentCount) @@ -80,21 +80,21 @@ void CMeshSceneNode::OnRegisterSceneNode() } else { - // count copied materials + // count copied materials for (u32 i=0; igetMaterialRenderer(Materials[i].MaterialType); - if (rnd && rnd->isTransparent()) + if (rnd && rnd->isTransparent()) ++transparentCount; - else + else ++solidCount; if (solidCount && transparentCount) break; - } + } } // register according to material types counted @@ -119,7 +119,7 @@ void CMeshSceneNode::render() if (!Mesh || !driver) return; - bool isTransparentPass = + bool isTransparentPass = SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; ++PassCount; @@ -162,7 +162,7 @@ void CMeshSceneNode::render() // only render transparent buffer if this is the transparent render pass // and solid only in solid pass - if (transparent == isTransparentPass) + if (transparent == isTransparentPass) { driver->setMaterial(material); driver->drawMeshBuffer(mb); @@ -295,14 +295,12 @@ void CMeshSceneNode::setMesh(IMesh* mesh) if (!mesh) return; // won't set null mesh + mesh->grab(); if (Mesh) Mesh->drop(); Mesh = mesh; copyMaterials(); - - if (Mesh) - Mesh->grab(); } @@ -358,7 +356,7 @@ void CMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeRe } //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. -/* In this way it is possible to change the materials a mesh causing all mesh scene nodes +/* In this way it is possible to change the materials a mesh causing all mesh scene nodes referencing this mesh to change too. */ void CMeshSceneNode::setReadOnlyMaterials(bool readonly) { @@ -378,7 +376,7 @@ ISceneNode* CMeshSceneNode::clone(ISceneNode* newParent, ISceneManager* newManag if (!newParent) newParent = Parent; if (!newManager) newManager = SceneManager; - CMeshSceneNode* nb = new CMeshSceneNode(Mesh, newParent, + CMeshSceneNode* nb = new CMeshSceneNode(Mesh, newParent, newManager, ID, RelativeTranslation, RelativeRotation, RelativeScale); nb->cloneMembers(this, newManager); diff --git a/source/Irrlicht/COctTreeSceneNode.cpp b/source/Irrlicht/COctTreeSceneNode.cpp index 2fd575f6..0a217160 100644 --- a/source/Irrlicht/COctTreeSceneNode.cpp +++ b/source/Irrlicht/COctTreeSceneNode.cpp @@ -286,10 +286,10 @@ bool COctTreeSceneNode::createTree(IMesh* mesh) MeshName = SceneManager->getMeshCache()->getMeshFilename( mesh ); + mesh->grab(); deleteTree(); Mesh = mesh; - Mesh->grab(); u32 beginTime = os::Timer::getRealTime(); @@ -311,7 +311,7 @@ bool COctTreeSceneNode::createTree(IMesh* mesh) { IMeshBuffer* b = mesh->getMeshBuffer(i); - if (b->getVertexCount() && b->getIndexCount()) + if (b->getVertexCount() && b->getIndexCount()) { Materials.push_back(b->getMaterial()); @@ -343,7 +343,7 @@ bool COctTreeSceneNode::createTree(IMesh* mesh) for ( i=0; i < mesh->getMeshBufferCount(); ++i) { b = mesh->getMeshBuffer(i); - if (b->getVertexCount() && b->getIndexCount()) + if (b->getVertexCount() && b->getIndexCount()) { meshReserve += 1; } @@ -355,7 +355,7 @@ bool COctTreeSceneNode::createTree(IMesh* mesh) { b = mesh->getMeshBuffer(i); - if (b->getVertexCount() && b->getIndexCount()) + if (b->getVertexCount() && b->getIndexCount()) { Materials.push_back(b->getMaterial()); LightMapMeshes.push_back(OctTree::SMeshChunk()); @@ -388,7 +388,7 @@ bool COctTreeSceneNode::createTree(IMesh* mesh) { IMeshBuffer* b = mesh->getMeshBuffer(i); - if (b->getVertexCount() && b->getIndexCount()) + if (b->getVertexCount() && b->getIndexCount()) { Materials.push_back(b->getMaterial()); TangentsMeshes.push_back(OctTree::SMeshChunk()); diff --git a/source/Irrlicht/CParticleSystemSceneNode.cpp b/source/Irrlicht/CParticleSystemSceneNode.cpp index c9ebd662..24ad0f16 100644 --- a/source/Irrlicht/CParticleSystemSceneNode.cpp +++ b/source/Irrlicht/CParticleSystemSceneNode.cpp @@ -72,6 +72,8 @@ IParticleEmitter* CParticleSystemSceneNode::getEmitter() //! Sets the particle emitter, which creates the particles. void CParticleSystemSceneNode::setEmitter(IParticleEmitter* emitter) { + if (emitter == Emitter) + return; if (Emitter) Emitter->drop(); @@ -161,7 +163,7 @@ IParticleCylinderEmitter* CParticleSystemSceneNode::createCylinderEmitter( bool outlineOnly, const core::vector3df& direction, u32 minParticlesPerSecond, u32 maxParticlesPerSecond, const video::SColor& minStartColor, const video::SColor& maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, + u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, const core::dimension2df& minStartSize, const core::dimension2df& maxStartSize ) { diff --git a/source/Irrlicht/CSceneManager.cpp b/source/Irrlicht/CSceneManager.cpp index 2c078d59..763ae939 100644 --- a/source/Irrlicht/CSceneManager.cpp +++ b/source/Irrlicht/CSceneManager.cpp @@ -493,8 +493,8 @@ IMeshSceneNode* CSceneManager::addQuake3SceneNode(IMeshBuffer* meshBuffer, if (!parent) parent = this; - CQuake3ShaderSceneNode* node = new CQuake3ShaderSceneNode( parent, - this, id, FileSystem, + CQuake3ShaderSceneNode* node = new CQuake3ShaderSceneNode( parent, + this, id, FileSystem, meshBuffer, shader ); node->drop(); @@ -1095,13 +1095,12 @@ ICameraSceneNode* CSceneManager::getActiveCamera() const //! \param camera: The new camera which should be active. void CSceneManager::setActiveCamera(ICameraSceneNode* camera) { + if (camera) + camera->grab(); if (ActiveCamera) ActiveCamera->drop(); ActiveCamera = camera; - - if (ActiveCamera) - ActiveCamera->grab(); } @@ -1579,13 +1578,12 @@ void CSceneManager::drawAll() void CSceneManager::setLightManager(ILightManager* lightManager) { + if ( lightManager ) + lightManager->grab(); if(LightManager) LightManager->drop(); LightManager = lightManager; - - if(LightManager) - LightManager->grab(); } diff --git a/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp b/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp index d1e23d9a..5c1fad73 100644 --- a/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp +++ b/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp @@ -118,15 +118,15 @@ core::vector3df CSceneNodeAnimatorCollisionResponse::getEllipsoidTranslation() c //! the scene node may collide. void CSceneNodeAnimatorCollisionResponse::setWorld(ITriangleSelector* newWorld) { - if (World) - World->drop(); + if (newWorld) + newWorld->grab(); - World = newWorld; - if (World) - World->grab(); + if (World) + World->drop(); + + World = newWorld; FirstUpdate = true; - } @@ -188,7 +188,7 @@ void CSceneNodeAnimatorCollisionResponse::animateNode(ISceneNode* node, u32 time CollisionResultPosition = SceneManager->getSceneCollisionManager()->getCollisionResultPosition( World, LastPosition-Translation, - Radius, vel, CollisionTriangle, CollisionPoint, f, + Radius, vel, CollisionTriangle, CollisionPoint, f, CollisionNode, SlidingSpeed, FallingVelocity); CollisionOccurred = (CollisionTriangle != RefTriangle); @@ -273,6 +273,9 @@ ISceneNodeAnimator* CSceneNodeAnimatorCollisionResponse::createClone(ISceneNode* void CSceneNodeAnimatorCollisionResponse::setCollisionCallback(ICollisionCallback* callback) { + if ( CollisionCallback == callback ) + return; + if (CollisionCallback) CollisionCallback->drop(); diff --git a/source/Irrlicht/CShadowVolumeSceneNode.cpp b/source/Irrlicht/CShadowVolumeSceneNode.cpp index 8ca6c4d8..56008375 100644 --- a/source/Irrlicht/CShadowVolumeSceneNode.cpp +++ b/source/Irrlicht/CShadowVolumeSceneNode.cpp @@ -253,6 +253,8 @@ void CShadowVolumeSceneNode::createZPassVolume(s32 faceCount, void CShadowVolumeSceneNode::setShadowMesh(const IMesh* mesh) { + if ( ShadowMesh == mesh ) + return; if (ShadowMesh) ShadowMesh->drop(); ShadowMesh = mesh; diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 9baf5ee3..ae0b2976 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,2 +1,2 @@ -Test suite pass at GMT Tue Jun 9 00:45:13 2009 +Test suite pass at GMT Wed Jun 10 20:04:22 2009