1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: gfx_SceneHelper.cpp
4
5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Revision: $
14 *---------------------------------------------------------------------------*/
15
16 #include "precompiled.h"
17
18 #include <nw/gfx/gfx_SceneHelper.h>
19
20 namespace nw {
21 namespace gfx {
22
23 // 共通処理
24 void
ResolveReferenceImpl(SceneNode * parent,SceneNode * child)25 SceneHelper::ResolveReferenceImpl(SceneNode* parent, SceneNode* child)
26 {
27 NW_NULL_ASSERT(parent);
28 NW_NULL_ASSERT(child);
29
30 // 子に親がいれば、もうチェックしない
31 if (child->GetParent() != NULL)
32 {
33 return;
34 }
35
36 void* resAddr = child->GetResSceneNode().ptr();
37 const int childNum = parent->GetResSceneNode().GetChildrenCount();
38 for (int i = 0; i < childNum; ++i)
39 {
40 void* childResAddr = parent->GetResSceneNode().GetChildren(i).ptr();
41 if (ut::ComparePtr(resAddr, childResAddr) == 0)
42 {
43 // 親子
44 bool result = parent->AttachChild(child);
45 NW_ASSERT(result);
46
47 return;
48 }
49 }
50 }
51
52 } // namespace gfx
53 } // namespace nw
54