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