Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 167 vs 168 for /trunk/Source Code/Graphs/SceneGraphNode.cpp

Diff revisions: vs.
  @@ -1,6 +1,7 @@
1 1 #include "Headers/SceneGraph.h"
2 2 #include "Headers/SceneGraphNode.h"
3 3
4 + #include "Scenes/Headers/SceneState.h"
4 5 #include "Core/Math/Headers/Transform.h"
5 6 #include "Geometry/Shapes/Headers/Object3D.h"
6 7 #include "Geometry/Material/Headers/Material.h"
  @@ -12,8 +13,10 @@
12 13 _parent(NULL),
13 14 _grandParent(NULL),
14 15 _transform(NULL),
16 + _currentSceneState(NULL),
15 17 _wasActive(true),
16 18 _active(true),
19 + _selected(false),
17 20 _noDefaultTransform(false),
18 21 _inView(true),
19 22 _sorted(false),
  @@ -44,25 +47,29 @@
44 47 }
45 48
46 49 void SceneGraphNode::addBoundingBox(const BoundingBox& bb, const SceneNodeType& type) {
47 - if(!bitCompare(_bbAddExclusionList, type)){
50 + if(!bitCompare(_bbAddExclusionList, type))
48 51 _boundingBox.Add(bb);
49 - }
50 52 }
51 53
52 - SceneGraphNode* SceneGraphNode::getRoot() const {
54 + SceneGraphNode* SceneGraphNode::getRoot() const {
53 55 return _sceneGraph->getRoot();
54 56 }
55 57
56 58 vectorImpl<BoundingBox >& SceneGraphNode::getBBoxes(vectorImpl<BoundingBox >& boxes ){
57 - //Unload every sub node recursively
58 59 for_each(NodeChildren::value_type& it, _children){
59 60 it.second->getBBoxes(boxes);
60 61 }
62 +
61 63 ReadLock r_lock(_queryLock);
62 64 boxes.push_back(_boundingBox);
63 65 return boxes;
64 66 }
65 67
68 + const BoundingBox& SceneGraphNode::getBoundingBoxTransformed() {
69 + if(_transform)
70 + updateBoundingBoxTransform(_transform->getGlobalMatrix());
71 + return _boundingBox;
72 + }
66 73 ///When unloading the current graph node
67 74 bool SceneGraphNode::unload(){
68 75 //Unload every sub node recursively
  @@ -156,29 +163,20 @@
156 163 //Validate it to be safe
157 164 assert(sceneGraphNode);
158 165 //We need to name the new SceneGraphNode
159 - //We start off with the name passed as a parameter as it has a higher priority
160 - std::string sgName(name);
161 - //If we did not supply a custom name
162 - if(sgName.empty()){
163 - //Use the SceneNode's name
164 - sgName = node->getName();
165 - }
166 + //If we did not supply a custom name use the SceneNode's name
167 + std::string sgName(name.empty() ? node->getName() : name);
166 168 //Name the new SceneGraphNode
167 169 sceneGraphNode->setName(sgName);
168 -
169 - //Get our current's node parent
170 - SceneGraphNode* parentNode = getParent();
171 170 //Set the current node's parent as the new node's grandparent
172 - sceneGraphNode->setGrandParent(parentNode);
171 + sceneGraphNode->setGrandParent(getParent());
173 172 //Get the new node's transform
174 173 Transform* nodeTransform = sceneGraphNode->getTransform();
175 174 //If the current node and the new node have transforms,
176 175 //Update the relationship between the 2
177 176 if(nodeTransform && getTransform()){
178 - //The child node's parentMatrix is our current transform matrix
179 - nodeTransform->setParentMatrix(getTransform()->getMatrix());
177 + //The child node's parent transform is our current transform matrix
178 + nodeTransform->setParentTransform(getTransform());
180 179 }
181 -
182 180 //Set the current node as the new node's parrent
183 181 sceneGraphNode->setParent(this);
184 182 sceneGraphNode->setSceneGraph(_sceneGraph);
  @@ -198,9 +196,8 @@
198 196 //Remove it from the map
199 197 _children.erase(it);
200 198 }else{
201 - for_each(NodeChildren::value_type& childIt, _children){
199 + for(U8 i = 0; i < _children.size(); ++i)
202 200 removeNode(node);
203 - }
204 201 }
205 202 //Beware. Removing a node, does no unload it!
206 203 //Call delete on the SceneGraphNode's pointer to do that
  @@ -247,11 +244,14 @@
247 244 SceneGraphNode* SceneGraphNode::Intersect(const Ray& ray, F32 start, F32 end){
248 245 //Null return value as default
249 246 SceneGraphNode* returnValue = NULL;
250 - ReadLock r_lock(_queryLock);
251 - if(_boundingBox.Intersect(ray,start,end)){
252 - return this;
247 +
248 + if(_node->isSelectable()){
249 + ReadLock r_lock(_queryLock);
250 + if(_boundingBox.Intersect(ray,start,end)){
251 + return this;
252 + }
253 + r_lock.unlock();
253 254 }
254 - r_lock.unlock();
255 255
256 256 for_each(NodeChildren::value_type& it, _children){
257 257 returnValue = it.second->Intersect(ray,start,end);