Browse Source

Using nullptr instead of 0 everywhere.

vectorfields
Vladimír Vondruš 15 years ago
parent
commit
e5e7d95af4
  1. 4
      src/Camera.cpp
  2. 10
      src/Camera.h
  3. 2
      src/Light.h
  4. 16
      src/Object.cpp
  5. 4
      src/Object.h
  6. 4
      src/Scene.cpp
  7. 2
      src/Shader.h
  8. 4
      src/Test/ObjectTest.cpp

4
src/Camera.cpp

@ -33,7 +33,7 @@ void Camera::setActive(Scene* _scene) {
/* Remove the camera from current active scene, if the camera is still /* Remove the camera from current active scene, if the camera is still
active there */ active there */
if(oldActive && oldActive->camera() == this) oldActive->setCamera(0); if(oldActive && oldActive->camera() == this) oldActive->setCamera(nullptr);
/* Clean the path to scene */ /* Clean the path to scene */
setClean(); setClean();
@ -101,7 +101,7 @@ void Camera::setDirty() {
Scene* currentScene = scene(); Scene* currentScene = scene();
/* Camera is not part of the scene anymore, remove it from there */ /* 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 */ /* Otherwise set the scene dirty */
else _active->setDirty(); else _active->setDirty();

10
src/Camera.h

@ -43,19 +43,19 @@ class Camera: public Object {
* *
* Calls <tt>setOrthographic(2, 1, 1000)</tt>. * Calls <tt>setOrthographic(2, 1, 1000)</tt>.
*/ */
Camera(Object* parent = 0); Camera(Object* parent = nullptr);
/** /**
* @brief Scene in which the camera is active * @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; } inline Scene* active() const { return _active; }
/** /**
* @brief Make camera active in given scene * @brief Make camera active in given scene
* *
* If passed 0 as @c scene and this camera is active in an scene, the * If passed nullptr as @c scene and this camera is active in an scene,
* camera will be removed from that scene. * the camera will be removed from that scene.
*/ */
void setActive(Scene* scene); void setActive(Scene* scene);
@ -127,7 +127,7 @@ class Camera: public Object {
/** /**
* If the camera was active before and is still active, calls * If the camera was active before and is still active, calls
* setDirty() on the scene, if is not part of the scene anymore, 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(); virtual void setDirty();

2
src/Light.h

@ -34,7 +34,7 @@ class Light: public Object {
* @brief Constructor * @brief Constructor
* @param parent Parent object * @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 * @brief Light position relative to the camera

16
src/Object.cpp

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

4
src/Object.h

@ -45,7 +45,7 @@ class Object {
* *
* Sets all transformations to their default values. * 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); setParent(parent);
} }
@ -59,7 +59,7 @@ class Object {
/** /**
* @brief Scene * @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; Scene* scene() const;

4
src/Scene.cpp

@ -19,7 +19,7 @@ using namespace std;
namespace Magnum { namespace Magnum {
Scene::Scene(): Object(0), _features(0), _camera(0) { Scene::Scene(): Object(nullptr), _features(0), _camera(nullptr) {
_parent = this; _parent = this;
setClearColor(0.1f, 0.1f, 0.1f, 1.0f); 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 */ /* 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(); setDirty();
} }

2
src/Shader.h

@ -106,7 +106,7 @@ class Shader {
Shader* s = new Shader(type); Shader* s = new Shader(type);
if(!s->addFile(filename)) { if(!s->addFile(filename)) {
delete s; delete s;
return 0; return nullptr;
} }
return s; return s;

4
src/Test/ObjectTest.cpp

@ -37,7 +37,7 @@ void ObjectTest::parenting() {
/* In fact, cyclic dependencies are not allowed at all */ /* In fact, cyclic dependencies are not allowed at all */
root.setParent(childTwo); root.setParent(childTwo);
QVERIFY(root.parent() == 0); QVERIFY(root.parent() == nullptr);
/* Reparent to another */ /* Reparent to another */
childTwo->setParent(childOne); childTwo->setParent(childOne);
@ -59,7 +59,7 @@ void ObjectTest::scene() {
Object* childOfOrphan = new Object(orphan); Object* childOfOrphan = new Object(orphan);
QVERIFY(childTwo->scene() == &scene); QVERIFY(childTwo->scene() == &scene);
QVERIFY(childOfOrphan->scene() == 0); QVERIFY(childOfOrphan->scene() == nullptr);
} }
void ObjectTest::dirty() { void ObjectTest::dirty() {

Loading…
Cancel
Save