diff --git a/src/Camera.cpp b/src/Camera.cpp index 6cebf1ff3..2955bdca4 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -33,7 +33,7 @@ void Camera::setActive(Scene* _scene) { /* Remove the camera from current active scene, if the camera is still active there */ - if(oldActive && oldActive->camera() == this) oldActive->setCamera(0); + if(oldActive && oldActive->camera() == this) oldActive->setCamera(nullptr); /* Clean the path to scene */ setClean(); @@ -101,7 +101,7 @@ void Camera::setDirty() { Scene* currentScene = scene(); /* Camera is not part of the scene anymore, remove it from there */ - if(!currentScene) _active->setCamera(0); + if(!currentScene) _active->setCamera(nullptr); /* Otherwise set the scene dirty */ else _active->setDirty(); diff --git a/src/Camera.h b/src/Camera.h index ea44a34f6..0d6ee7e1c 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -43,19 +43,19 @@ class Camera: public Object { * * Calls setOrthographic(2, 1, 1000). */ - Camera(Object* parent = 0); + Camera(Object* parent = nullptr); /** * @brief Scene in which the camera is active - * @return If the camera is not active anywhere, returns 0. + * @return If the camera is not active anywhere, returns nullptr. */ inline Scene* active() const { return _active; } /** * @brief Make camera active in given scene * - * If passed 0 as @c scene and this camera is active in an scene, the - * camera will be removed from that scene. + * If passed nullptr as @c scene and this camera is active in an scene, + * the camera will be removed from that scene. */ void setActive(Scene* scene); @@ -127,7 +127,7 @@ class Camera: public Object { /** * If the camera was active before and is still active, calls * setDirty() on the scene, if is not part of the scene anymore, calls - * setCamera(0) on the scene. + * setCamera(nullptr) on the scene. */ virtual void setDirty(); diff --git a/src/Light.h b/src/Light.h index 86325b035..05ee85886 100644 --- a/src/Light.h +++ b/src/Light.h @@ -34,7 +34,7 @@ class Light: public Object { * @brief Constructor * @param parent Parent object */ - inline Light(Object* parent = 0): Object(parent) {} + inline Light(Object* parent = nullptr): Object(parent) {} /** * @brief Light position relative to the camera diff --git a/src/Object.cpp b/src/Object.cpp index bd8ad0d45..0969ebb12 100644 --- a/src/Object.cpp +++ b/src/Object.cpp @@ -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::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(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(); } } diff --git a/src/Object.h b/src/Object.h index 2c08fb77f..28ce2e1c4 100644 --- a/src/Object.h +++ b/src/Object.h @@ -45,7 +45,7 @@ class Object { * * Sets all transformations to their default values. */ - inline Object(Object* parent = 0): _parent(0), dirty(true) { + inline Object(Object* parent = nullptr): _parent(nullptr), dirty(true) { setParent(parent); } @@ -59,7 +59,7 @@ class Object { /** * @brief Scene - * @return If the object is not assigned to any scene, returns 0. + * @return If the object is not assigned to any scene, returns nullptr. */ Scene* scene() const; diff --git a/src/Scene.cpp b/src/Scene.cpp index 8c15d2f80..291a25285 100644 --- a/src/Scene.cpp +++ b/src/Scene.cpp @@ -19,7 +19,7 @@ using namespace std; namespace Magnum { -Scene::Scene(): Object(0), _features(0), _camera(0) { +Scene::Scene(): Object(nullptr), _features(0), _camera(nullptr) { _parent = this; setClearColor(0.1f, 0.1f, 0.1f, 1.0f); @@ -59,7 +59,7 @@ void Scene::setCamera(Camera* camera) { } /* Set old camera inactive, if it is still active in this scene */ - if(oldCamera && oldCamera->active() == this) oldCamera->setActive(0); + if(oldCamera && oldCamera->active() == this) oldCamera->setActive(nullptr); setDirty(); } diff --git a/src/Shader.h b/src/Shader.h index 0d5845367..1da54dae6 100644 --- a/src/Shader.h +++ b/src/Shader.h @@ -106,7 +106,7 @@ class Shader { Shader* s = new Shader(type); if(!s->addFile(filename)) { delete s; - return 0; + return nullptr; } return s; diff --git a/src/Test/ObjectTest.cpp b/src/Test/ObjectTest.cpp index 46fbdba93..46976f9a7 100644 --- a/src/Test/ObjectTest.cpp +++ b/src/Test/ObjectTest.cpp @@ -37,7 +37,7 @@ void ObjectTest::parenting() { /* In fact, cyclic dependencies are not allowed at all */ root.setParent(childTwo); - QVERIFY(root.parent() == 0); + QVERIFY(root.parent() == nullptr); /* Reparent to another */ childTwo->setParent(childOne); @@ -59,7 +59,7 @@ void ObjectTest::scene() { Object* childOfOrphan = new Object(orphan); QVERIFY(childTwo->scene() == &scene); - QVERIFY(childOfOrphan->scene() == 0); + QVERIFY(childOfOrphan->scene() == nullptr); } void ObjectTest::dirty() {