From 80788a419850b79fa66787c9284d7a6bbfc5cfa9 Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 27 Apr 2023 12:58:55 +0000 Subject: [PATCH] More fixes for CCubeSceneNode with multi-material cube CCubeSceneNode::getMaterialCount now returning correct count CCubeSceneNode::clone now cloning all materials git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6474 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CCubeSceneNode.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/Irrlicht/CCubeSceneNode.cpp b/source/Irrlicht/CCubeSceneNode.cpp index 63a4115d..a72d3be5 100644 --- a/source/Irrlicht/CCubeSceneNode.cpp +++ b/source/Irrlicht/CCubeSceneNode.cpp @@ -202,7 +202,9 @@ video::SMaterial& CCubeSceneNode::getMaterial(u32 i) //! returns amount of materials used by this scene node. u32 CCubeSceneNode::getMaterialCount() const { - return 1; + if ( Mesh ) + return Mesh->getMeshBufferCount(); + return 0; } @@ -245,7 +247,8 @@ ISceneNode* CCubeSceneNode::clone(ISceneNode* newParent, ISceneManager* newManag newManager, ID, RelativeTranslation, RelativeRotation, RelativeScale, MeshType); nb->cloneMembers(this, newManager); - nb->getMaterial(0) = getMaterial(0); + for ( irr::u32 i=0; i < getMaterialCount(); ++i ) + nb->getMaterial(i) = getMaterial(i); nb->Shadow = Shadow; if ( nb->Shadow ) nb->Shadow->grab();