Bullets and destroyable objects now are deleted when they fall below a certain height.
Bullets and destroyable objects now are deleted when they fall below a certain height.

--- a/CannonSceneNode.cpp
+++ b/CannonSceneNode.cpp
@@ -10,10 +10,15 @@
   _barrel->setScale(vector3df(0.2,0.2,2));
   setYRotation(0);
   setXRotation(45);
+  
+  // Prepare height checker
+  _heightTest=new HeightDeletionAffector();
 }
 
 CannonSceneNode::~CannonSceneNode()
-{ }
+{
+  delete _heightTest;
+}
 
 void CannonSceneNode::render()
 { }
@@ -81,5 +86,6 @@
   ICollisionShape *bulletShape=new ISphereShape(bullet,20,false);
   IRigidBody *bulletBody=_bullet->addRigidBody(bulletShape);
   bulletBody->setLinearVelocity(_power*dir);
+  bulletBody->addAffector(_heightTest);
 }
 

--- a/CannonSceneNode.h
+++ b/CannonSceneNode.h
@@ -8,6 +8,8 @@
 using namespace irr::core;
 using namespace irr::video;
 using namespace irr::scene;
+
+#include "HeightDeletionAffector.h"
 
 class CannonSceneNode : public ISceneNode
 {
@@ -33,6 +35,8 @@
 
   ISceneNode *_barrel;
 
+  HeightDeletionAffector *_heightTest;
+
   double _power;
   double _xRotation,_yRotation;
 

--- a/DestroyableObject.cpp
+++ b/DestroyableObject.cpp
@@ -2,11 +2,15 @@
 
 DestroyableObject::DestroyableObject()
   : _life(100),_sceneNode(0),_rigidBody(0)
-{ }
+{
+  // Prepare height checker
+  _heightTest=new HeightDeletionAffector();
+}
 
 DestroyableObject::~DestroyableObject()
 {
   _rigidBody->remove();
+  delete _heightTest;
 }
 
 void DestroyableObject::setLife(double life)
@@ -52,9 +56,13 @@
 
 void DestroyableObject::setRigidBody(IRigidBody *rigidBody)
 {
+  if(_rigidBody)
+    _rigidBody->removeAffector(_heightTest);
+
   _rigidBody=rigidBody;
 
   _rigidBody->getAttributes()->setAttribute("destroyable",true);
   _rigidBody->getAttributes()->setAttribute("control",this);
+  _rigidBody->addAffector(_heightTest);
 }
 

--- a/DestroyableObject.h
+++ b/DestroyableObject.h
@@ -8,6 +8,8 @@
 using namespace irr::core;
 using namespace irr::video;
 using namespace irr::scene;
+
+#include "HeightDeletionAffector.h"
 
 class DestroyableObject
 {
@@ -31,6 +33,8 @@
   double _life;
   ISceneNode *_sceneNode;
   IRigidBody *_rigidBody;
+
+  HeightDeletionAffector *_heightTest;
 };
 
 #endif // DESTROYABLEOBJECT_H_

--- /dev/null
+++ b/HeightDeletionAffector.cpp
@@ -1,1 +1,18 @@
+#include "HeightDeletionAffector.h"
 
+HeightDeletionAffector::HeightDeletionAffector()
+{ }
+
+HeightDeletionAffector::~HeightDeletionAffector()
+{ }
+
+void HeightDeletionAffector::affectObject(ICollisionObject *object,u32 timeMS)
+{
+  matrix4 transform=object->getWorldTransform();
+  vector3df translation=transform.getTranslation();
+  if(translation.Y<-10)
+    {
+      object->remove();
+    }
+}
+

--- /dev/null
+++ b/HeightDeletionAffector.h
@@ -1,1 +1,19 @@
+#ifndef HEIGHTDELETIONAFFECTOR_H_
+#define HEIGHTDELETIONAFFECTOR_H_
 
+#include <irrbullet.h>
+#include <irrlicht.h>
+using namespace irr;
+using namespace irr::core;
+
+class HeightDeletionAffector : public ICollisionObjectAffector
+{
+public:
+  HeightDeletionAffector();
+  ~HeightDeletionAffector();
+
+  virtual void affectObject(ICollisionObject *object, u32 timeMS);
+};
+
+#endif // HEIGHTDELETIONAFFECTOR_H_
+

file:a/Makefile -> file:b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-OBJS=main.o App.o CannonSceneNode.o CannonSceneNodeAnimator.o DestroyableObject.o CrateObject.o Level.o WallLevel.o
+OBJS=main.o App.o CannonSceneNode.o CannonSceneNodeAnimator.o DestroyableObject.o CrateObject.o Level.o WallLevel.o HeightDeletionAffector.o
 APP=cannon
 
 CFLAGS=-I/home/kkrizka/dev/irrlicht-svn/include/irrlicht -I/home/kkrizka/dev/irrbullet-svn/include/irrBullet -g `pkg-config bullet --cflags`