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
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();

10
src/Camera.h

@ -43,19 +43,19 @@ class Camera: public Object {
*
* Calls <tt>setOrthographic(2, 1, 1000)</tt>.
*/
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();

2
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

16
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<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();
}
}

4
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;

4
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();
}

2
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;

4
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() {

Loading…
Cancel
Save