|
|
|
|
@ -24,11 +24,11 @@ void Object::setParent(Object* parent) {
|
|
|
|
|
if(_parent == parent) return; |
|
|
|
|
|
|
|
|
|
/* Set new parent and add the object to new parent children list */ |
|
|
|
|
if(parent != 0) { |
|
|
|
|
if(parent != nullptr) { |
|
|
|
|
|
|
|
|
|
/* Only Fry can be his own grandfather */ |
|
|
|
|
Object* p = parent; |
|
|
|
|
while(p != 0 && p->parent() != p) { |
|
|
|
|
while(p != nullptr && p->parent() != p) { |
|
|
|
|
if(p == this) return; |
|
|
|
|
p = p->parent(); |
|
|
|
|
} |
|
|
|
|
@ -37,7 +37,7 @@ void Object::setParent(Object* parent) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Remove the object from old parent children list */ |
|
|
|
|
if(_parent != 0) |
|
|
|
|
if(_parent != nullptr) |
|
|
|
|
_parent->_children.erase(this); |
|
|
|
|
|
|
|
|
|
_parent = parent; |
|
|
|
|
@ -51,7 +51,7 @@ Matrix4 Object::transformation(bool absolute) {
|
|
|
|
|
Matrix4 t = _transformation; |
|
|
|
|
|
|
|
|
|
Object* p = parent(); |
|
|
|
|
while(p != 0) { |
|
|
|
|
while(p != nullptr) { |
|
|
|
|
t = p->transformation()*t; |
|
|
|
|
|
|
|
|
|
/* We got to the scene, multiply with camera matrix */ |
|
|
|
|
@ -70,7 +70,7 @@ Matrix4 Object::transformation(bool absolute) {
|
|
|
|
|
|
|
|
|
|
Object::~Object() { |
|
|
|
|
/* Remove the object from parent's children */ |
|
|
|
|
setParent(0); |
|
|
|
|
setParent(nullptr); |
|
|
|
|
|
|
|
|
|
/* Delete all children */ |
|
|
|
|
for(set<Object*>::const_iterator it = _children.begin(); it != _children.end(); ++it) |
|
|
|
|
@ -81,12 +81,12 @@ Scene* Object::scene() const {
|
|
|
|
|
/* Goes up the family tree until it finds object which is parent of itself
|
|
|
|
|
(that's the scene) */ |
|
|
|
|
Object* p = parent(); |
|
|
|
|
while(p != 0) { |
|
|
|
|
while(p != nullptr) { |
|
|
|
|
if(p->parent() == p) return static_cast<Scene*>(p); |
|
|
|
|
p = p->parent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
return nullptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Object::setDirty() { |
|
|
|
|
@ -107,7 +107,7 @@ void Object::setClean() {
|
|
|
|
|
dirty = false; |
|
|
|
|
|
|
|
|
|
/* Make all parents clean */ |
|
|
|
|
if(_parent != 0 && _parent != this) _parent->setClean(); |
|
|
|
|
if(_parent != nullptr && _parent != this) _parent->setClean(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|