source: OGRE/trunk/ogrenew/PlugIns/BSPSceneManager/src/OgreBspSceneNode.cpp @ 690

Revision 690, 3.7 KB checked in by mattausch, 18 years ago (diff)

added ogre 1.07 main

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#include "OgreBspSceneNode.h"
26#include "OgreBspSceneManager.h"
27
28namespace Ogre {
29
30
31    void BspSceneNode::_update(bool updateChildren, bool parentHasChanged)
32    {
33        bool checkMovables = false;
34
35        if (mNeedParentUpdate || parentHasChanged)
36        {
37            // This means we've moved
38            checkMovables = true;
39        }
40
41        // Call superclass
42        SceneNode::_update(updateChildren, parentHasChanged);
43
44        if (checkMovables)
45        {
46            // Check membership of attached objects
47            ObjectMap::const_iterator it, itend;
48            itend = mObjectsByName.end();
49            for (it = mObjectsByName.begin(); it != itend; ++it)
50            {
51                MovableObject* mov = it->second;
52
53                static_cast<BspSceneManager*>(mCreator)->_notifyObjectMoved(
54                    mov, this->_getDerivedPosition());
55
56            }
57        }
58
59    }
60        //-------------------------------------------------------------------------
61        MovableObject* BspSceneNode::detachObject(unsigned short index)
62        {
63                MovableObject* ret = SceneNode::detachObject(index);
64                static_cast<BspSceneManager*>(mCreator)->_notifyObjectDetached(ret);
65                return ret;
66               
67        }
68        //-------------------------------------------------------------------------
69        MovableObject* BspSceneNode::detachObject(const String& name)
70        {
71                MovableObject* ret = SceneNode::detachObject(name);
72                static_cast<BspSceneManager*>(mCreator)->_notifyObjectDetached(ret);
73                return ret;
74        }
75        //-------------------------------------------------------------------------
76        void BspSceneNode::detachAllObjects(void)
77        {
78                ObjectMap::const_iterator i, iend;
79                iend = mObjectsByName.end();
80                for (i = mObjectsByName.begin(); i != iend; ++i)
81                {
82                        static_cast<BspSceneManager*>(mCreator)
83                                ->_notifyObjectDetached(i->second);
84                }
85                SceneNode::detachAllObjects();
86        }
87        //-------------------------------------------------------------------------
88        void BspSceneNode::setInSceneGraph(bool inGraph)
89        {
90                if (mIsInSceneGraph != inGraph)
91                {
92                        ObjectMap::const_iterator i, iend;
93                        iend = mObjectsByName.end();
94                        for (i = mObjectsByName.begin(); i != iend; ++i)
95                        {
96                                if (!inGraph)
97                                {
98                                        // Equivalent to detaching
99                                        static_cast<BspSceneManager*>(mCreator)
100                                                ->_notifyObjectDetached(i->second);
101                                }
102                                else
103                                {
104                                        // move deals with re-adding
105                        static_cast<BspSceneManager*>(mCreator)->_notifyObjectMoved(
106                        i->second, this->_getDerivedPosition());
107                                }
108                        }
109                }
110        }
111
112}
113
114
115
Note: See TracBrowser for help on using the repository browser.