Index: /trunk/src/lib/particles/particle_system.cc
===================================================================
--- /trunk/src/lib/particles/particle_system.cc	(revision 7332)
+++ /trunk/src/lib/particles/particle_system.cc	(revision 7333)
@@ -202,6 +202,6 @@
 void ParticleSystem::setRadius(float lifeCycleTime, float radius, float randRadius)
 {
-  this->radiusAnim.changeEntry(lifeCycleTime, radius);
-  this->randRadiusAnim.changeEntry(lifeCycleTime, randRadius);
+  this->radiusAnim.changeValue(lifeCycleTime, radius);
+  this->randRadiusAnim.changeValue(lifeCycleTime, randRadius);
 
   PRINTF(4)("Radius of %s::%s at timeSlice %f is %f with a Random of %f\n",
@@ -217,6 +217,6 @@
 void ParticleSystem::setMass(float lifeCycleTime, float mass, float randMass)
 {
-  this->massAnim.changeEntry(lifeCycleTime, mass);
-  this->randMassAnim.changeEntry(lifeCycleTime, randMass);
+  this->massAnim.changeValue(lifeCycleTime, mass);
+  this->randMassAnim.changeValue(lifeCycleTime, randMass);
 }
 
@@ -231,8 +231,8 @@
 void ParticleSystem::setColor(float lifeCycleTime, float red, float green, float blue, float alpha)
 {
-  this->colorAnim[0].changeEntry(lifeCycleTime, red);
-  this->colorAnim[1].changeEntry(lifeCycleTime, green);
-  this->colorAnim[2].changeEntry(lifeCycleTime, blue);
-  this->colorAnim[3].changeEntry(lifeCycleTime, alpha);
+  this->colorAnim[0].changeValue(lifeCycleTime, red);
+  this->colorAnim[1].changeValue(lifeCycleTime, green);
+  this->colorAnim[2].changeValue(lifeCycleTime, blue);
+  this->colorAnim[3].changeValue(lifeCycleTime, alpha);
 
   PRINTF(4)("Color of %s::%s on timeslice %f is r:%f g:%f b:%f a:%f\n",
@@ -310,8 +310,8 @@
 
     // applying Color
-    tickPart->color[0] = this->colorAnim[0].getValue(tickPart->lifeCycle);
-    tickPart->color[1] = this->colorAnim[1].getValue(tickPart->lifeCycle);
-    tickPart->color[2] = this->colorAnim[2].getValue(tickPart->lifeCycle);
-    tickPart->color[3] = this->colorAnim[3].getValue(tickPart->lifeCycle);
+    this->colorAnim[0].getValue(tickPart->color[0], tickPart->lifeCycle);
+    this->colorAnim[1].getValue(tickPart->color[1], tickPart->lifeCycle);
+    this->colorAnim[2].getValue(tickPart->color[2], tickPart->lifeCycle);
+    this->colorAnim[3].getValue(tickPart->color[3], tickPart->lifeCycle);
 
     // rendering new position.
Index: /trunk/src/lib/particles/quick_animation.cc
===================================================================
--- /trunk/src/lib/particles/quick_animation.cc	(revision 7332)
+++ /trunk/src/lib/particles/quick_animation.cc	(revision 7333)
@@ -18,226 +18,283 @@
 #include "quick_animation.h"
 
-#include "compiler.h"
-#include "debug.h"
-#ifndef NULL
-#define NULL 0
-#endif
-
+#include <algorithm>
 
 using namespace std;
 
 /**
- *  standard constructor
-*/
-QuickAnimation::QuickAnimation ()
-{
-   this->setClassID(CL_QUICK_ANIMATION, "QuickAnimation");
-
-   // initialize the First KeyFrame (will be deleted if a new one gets created)
-   this->count = 0;
-   this->first = this->current = new QuickKeyFrame;
-   this->first->next = this->first->prev = this->first;
-   this->first->position = 0.0;
-   this->first->value = 0.0;
-}
-
-/**
- *  deletes all the deconstructor stuff
-*/
+ * @brief standard constructor
+ * @param resolution the Resolution of the LookupTable
+ */
+QuickAnimation::QuickAnimation (unsigned int resolution)
+{
+  this->lookupValues.resize(resolution, 0.0f);
+}
+
+/**
+ * @brief deletes all the deconstructor stuff
+ */
 QuickAnimation::~QuickAnimation ()
-{
-  this->current = this->first;
-  QuickKeyFrame* delKF = this->first;
-
-  do
-  {
-    delKF = this->current;
-    this->current = this->current->next;
-    delete delKF;
-  }  while (this->current != this->first);
-
-}
-
-/**
- *  adds a new entry to the list of keyframes
+{ }
+
+/**
+ * @brief adds a new entry to the list of keyframes
  * @param position the position to add the key to
  * @param value the Value to set for the position
  * @returns false if the key existed already for a given position
-*/
-void QuickAnimation::addEntry(float position, float value)
-{
-  // create the new KeyFrame
-  QuickKeyFrame* newKey = new QuickKeyFrame;
-  newKey->position = position;
-  newKey->value = value;
-
-  // if we add a KeyFrame for the first Time:
-  if (unlikely (this->count == 0))
-  {
-    delete this->first;
-
-    newKey->next  = newKey;
-    newKey->prev  = newKey;
-    this->first   = newKey;
-    this->current = newKey;
-  }
-  // if the KeyFrame is in front of the FIRST keyFrame
-  else if (this->first->position > position)
-  {
-    newKey->next = this->first;
-    newKey->prev = this->first->prev;
-    newKey->prev->next = newKey;
-    newKey->next->prev = newKey;
-
-    this->first = newKey; // the new Key becomes the FIRST.
-  }
-  // if the KeyFrame is at the End of the Animation
-  else if (this->first->prev->position < position)
-  {
-    newKey->next = this->first;
-    newKey->prev = this->first->prev;
-    newKey->prev->next = newKey;
-    newKey->next->prev = newKey;
-  }
-  // if the Key is between two frames.
-  else
-  {
-    this->current = this->first;
-    do
+ */
+bool QuickAnimation::addKey(float position, float value)
+{
+  if (position > 1.0f || position < 0.0f)
+  {
+    printf("QuickAnimation::Position MUST BE between 0.0f and 1.0f\n");
+    return false;
+  }
+  this->keyFrames.push_back(QuickKeyFrame(position, value));
+
+  this->rebuild();
+  return true;
+}
+
+
+/**
+ * @brief changes an entry in the region of position
+ * @param position the Position of an existing keyframe
+ * @param region a deviation of the existing keyframe (like a delta in witch to search for)
+ * @param value the new Value
+ */
+bool QuickAnimation::changeValueKey(unsigned int keyFrameNumber, float newValue)
+{
+  if (keyFrameNumber < this->keyFrames.size())
+  {
+    this->keyFrames[keyFrameNumber].value = newValue;
+    this->rebuild();
+    return true;
+  }
+  else
+    return false;
+}
+
+/**
+ * @brief changes an entry in the region of position
+ * @param position the Position of an existing keyframe
+ * @param region a deviation of the existing keyframe (like a delta in witch to search for)
+ * @param value the new Value
+ *
+ * This Function adds a new KeyFrame at position with newValue, if none was found in region of position.
+ */
+bool QuickAnimation::changeValue(float position, float newValue, float region)
+{
+  int keyFrame = this->getKeyAt(position, region);
+  if (keyFrame == -1)
+    return this->addKey(position, newValue);
+  else
+    return this->changeValueKey(keyFrame, newValue);
+}
+
+
+/**
+ * @brief removes the keyFrameNumber'th entry.
+ * @param keyFrameNumber the n'th Keyframe to remove.
+ * @returns true on success, false if keyFrameNumber did not exist.
+ */
+bool QuickAnimation::removeKey(unsigned int keyFrameNumber)
+{
+  if (keyFrameNumber < this->keyFrames.size())
+  {
+    this->keyFrames.erase(this->keyFrames.begin() + keyFrameNumber);
+    this->rebuild();
+    return true;
+  }
+  else
+    return false;
+}
+
+
+/**
+ * @brief removes a KeyFrame from the List.
+ * @param position the Keyframe at position position will be erased.
+ * @param region a deviation of the existing keyframe (like a delta in witch to search for)
+ * @returns true on success, false if no KeyFrame was found.
+ */
+bool QuickAnimation::remove(float position, float region)
+{
+  int keyFrame = this->getKeyAt(position, region);
+  if (keyFrame == -1)
+    return false;
+  else
+    return this->removeKey(keyFrame);
+}
+
+/**
+ * @brief moves the keyFrame keyFrameNumber to newPosition/newValue.
+ * @param keyFrameNumber the n'th KeyFrame to move.
+ * @param newPosition the new Position for the KeyFrame.
+ * @param newValue the new Value for the KeyFrame.
+ * @returns true on success, false if the KeyFrame did not exist.
+ */
+bool QuickAnimation::moveKey(unsigned int keyFrameNumber, float newPosition, float newValue)
+{
+  if (keyFrameNumber < this->keyFrames.size())
+  {
+    this->keyFrames[keyFrameNumber].position = newPosition;
+    this->keyFrames[keyFrameNumber].value = newValue;
+    this->rebuild();
+    return true;
+  }
+  else
+    return false;
+}
+
+/**
+ * @brief moves the keyFrame keyFrameNumber to newPosition/value.
+ * @param keyFrameNumber the n'th KeyFrame to move.
+ * @param newPosition the new Position for the KeyFrame.
+ * @returns true on success, false if the KeyFrame did not exist.
+ */
+bool QuickAnimation::moveKey(unsigned int keyFrameNumber, float newPosition)
+{
+  if (keyFrameNumber < this->keyFrames.size())
+  {
+    this->keyFrames[keyFrameNumber].position = newPosition;
+    this->rebuild();
+    return true;
+  }
+  else
+    return false;
+}
+
+/**
+ * @brief moves the keyFrame in the region of oldPosition to newPosition/newValue.
+ * @param oldPosition the old Position for the KeyFrame.
+ * @param newPosition the new Position for the KeyFrame.
+ * @param newValue the new Value for the KeyFrame.
+ * @param region the region around oldPosition to search for the KeyFrame.
+ * @returns true on success, false if the KeyFrame was not found within the region of oldPosition.
+ */
+bool QuickAnimation::move(float oldPosition, float newPosition, float newValue, float region)
+{
+  int keyFrame = this->getKeyAt(oldPosition, region);
+  if (keyFrame == -1)
+    return false;
+  else
+    return this->moveKey(keyFrame, newPosition, newValue);
+}
+
+/**
+ * @brief moves the keyFrame in the region of oldPosition to newPosition/Value.
+ * @param oldPosition the old Position for the KeyFrame.
+ * @param newPosition the new Position for the KeyFrame.
+ * @param region the region around oldPosition to search for the KeyFrame.
+ * @returns true on success, false if the KeyFrame was not found within the region of oldPosition.
+ */
+bool QuickAnimation::move(float oldPosition, float newPosition, float region)
+{
+  int keyFrame = this->getKeyAt(oldPosition, region);
+  if (keyFrame == -1)
+    return false;
+  else
+    return this->moveKey(keyFrame, newPosition);
+}
+
+
+/**
+ * @brief searches for a Keyframe in the region of position
+ * @param position the Keyframe at position position will searched for.
+ * @param region a deviation of the existing keyframe (like a delta in witch to search for)
+ * @returns the keyFrame on success, -1 on fault.
+ */
+int QuickAnimation::getKeyAt(float position, float region)
+{
+  for (unsigned int i = 0; i < this->keyFrames.size(); i++)
+  {
+    if (this->keyFrames[i].position + region/2.0 > position && this->keyFrames[i].position - region/2.0 < position)
+      return i;
+  }
+  return -1;
+}
+
+
+/**
+ * @brief rebuilds the QuickAnimation.
+ */
+void QuickAnimation::rebuild()
+{
+  // if we do not have any KeyFrames
+  if (this->keyFrames.empty())
+  {
+    for (unsigned int i = 0; i < this->lookupValues.size(); i++)
+      this->lookupValues[i] = 0.0f;
+    return;
+  }
+
+  // Sort the List.
+  std::sort(this->keyFrames.begin(), this->keyFrames.end(), QuickKeyFrame::sortPositionPredicate);
+
+  // rebuild the lookup-table
+  float sliceSize = 1.0f / this->lookupValues.size();
+  unsigned int key = 0;
+  float preVal = this->keyFrames[0].value;
+  float prePos = this->keyFrames[0].position;
+
+  float postVal = preVal;
+  float postPos = 1.0;
+
+  if (this->keyFrames.size() > 1)
+  {
+    postVal = this->keyFrames[1].value;
+    postPos = this->keyFrames[1].position;
+  }
+
+
+  for (unsigned int i = 0; i < this->lookupValues.size(); i++)
+  {
+    float position = (float)i * sliceSize;
+
+    // if we reach the Next KeyFrame
+    if (position > postPos)
     {
-      if (this->current->position < position && this->current->next->position > position)
-        break;
-      // if it is the same as an already existing keyframe
-      else if (this->current->position == position)
+      // if we have more KeyFrames.
+      if (this->keyFrames.size() > ++key + 1)
       {
-        this->current->value = value;
-        delete newKey;
-        return;
+        preVal = this->keyFrames[key].value;
+        prePos = this->keyFrames[key].position;
+        postVal = this->keyFrames[key+1].value;
+        postPos = this->keyFrames[key+1].position;
       }
-      this->current = this->current->next;
-    } while (this->current != this->first);
-
-    newKey->next = this->current->next;
-    newKey->prev = this->current;
-    newKey->next->prev = newKey;
-    newKey->prev->next = newKey;
-  }
-  this->current = this->first;
-  ++this->count;
-}
-
-/**
- *  changes an entry in the region of position
- * @param position the Position of an existing keyframe
- * @param region a deviation of the existing keyframe (like a delta in witch to search for
- * @param value the new Value
-
-   if the Entry at the in the region of the specified position is found, it will be changed.
-    Otherwise a new KeyFrame will be created with value at position.
-   @todo rimplement
-*/
-void QuickAnimation::changeEntry(float position, float value, float region)
-{
-
-  if ((this->first->position > position + region) || this->first->prev->position < position - region || this->count == 0)
-    this->addEntry(position, value);
-  else
-  {
-    this->current = this->first;
-    do
-    {
-      if (this->current->position > position + region)
+      // otherwise we reached the last KeyFrame
+      else
       {
-        this->addEntry(position, value);
-        return;
+        preVal = postVal;
+        prePos = postPos;
+        postPos = 1.0;
       }
-      if (this->current->position < position+region && this->current->position > position-region)
-      {
-        this->current->value = value;
-        return;
-      }
-      this->current = this->current->next;
-    }  while (this->current != this->first);
-  }
-}
-
-
-/**
- * removes a KeyFrame from the List.
- * @param position
- * @return
- */
-void QuickAnimation::removeEntry(float position)
-{
-  this->current = this->first;
-
-  if (this->count <= 0)
-  {
-    this->current->value = 0.0;
-    this->current->position = 0.0;
-    count = 0;
-    return;
-  }
-  else
-  {
-    do
-    {
-      if (this->current->position == position)
-      {
-        if (this->current == this->first)
-          this->first = this->first->next;
-        this->current->next->prev = this->current->prev;
-        this->current->prev->next = this->current->next;
-        delete this->current;
-        break;
-      }
-      this->current = this->current->next;
-    } while (this->current != this->first);
-
-    count --;
-    this->current = this->first;
-  }
-}
-
-
-/**
- *  returns the value of the animation at a certain position
- * @param position the position to get the value from :)
-*/
-float QuickAnimation::getValue(float position)
-{
-  while (true)
-  {
-    // if we have a match
-    if (likely(this->current->position <= position && this->current->next->position >= position))
-      return this->current->value + (this->current->next->value - this->current->value)
-          * ((position-this->current->position) / (this->current->next->position -this->current->position));
-
-    else if (unlikely(this->first->prev->position < position))
-      return this->first->prev->value;
-    else if (unlikely(this->first->position > position))
-      return this->first->value;
-    else if(likely(this->current->next->position < position))
-      this->current = this->current->next;
-    else if (likely(this->current->position > position))
-      this->current = this->current->prev;
-  }
-}
-
-/**
- *  outputs some nice information about this class
-*/
-void QuickAnimation::debug()
-{
-  this->current = this->first;
-
-  PRINT(0)("QuickAnim(entries:%d)::(position, value)", this->count);
-  do
-    {
-      PRINT(0)("->(%f, %f)", this->current->position, this->current->value);
-      this->current = this->current->next;
-    } while(this->current != this->first);
-
-  PRINT(0)("\n");
-  this->current = this->first;
-}
+    }
+    this->lookupValues[i] = preVal + ( postVal - preVal) / (postPos - prePos) * (position - prePos);
+  }
+}
+
+/**
+ * @brief outputs some nice information about this class
+ */
+void QuickAnimation::debug() const
+{
+  printf("QuickAnim(KeyFrames:%d, Resolution:%d)::(position, value) ", this->keyFrames.size(), this->lookupValues.size());
+
+  for (unsigned int i = 0; i < this->keyFrames.size(); i++)
+    printf("(%f, %f)->", this->keyFrames[i].position, this->keyFrames[i].value);
+  printf("\n");
+}
+
+
+
+
+bool QuickAnimation::QuickKeyFrame::sortPositionPredicate(const QuickKeyFrame& key1, const QuickKeyFrame& key2)
+{
+  return (key1.position < key2.position);
+}
+
+bool QuickAnimation::QuickKeyFrame::sortValuePredicate(const QuickKeyFrame& key1, const QuickKeyFrame& key2)
+{
+  return (key1.value < key2.value);
+}
+
Index: /trunk/src/lib/particles/quick_animation.h
===================================================================
--- /trunk/src/lib/particles/quick_animation.h	(revision 7332)
+++ /trunk/src/lib/particles/quick_animation.h	(revision 7333)
@@ -8,51 +8,73 @@
 #define _QUICK_ANIMATION_H
 
-#include "base_object.h"
-
+#include <vector>
 // FORWARD DECLARATION
-
-
-
 
 //! A class for that linearely interpolates between multiple values.
 /**
-   to be quick this only has the capability to store very little date
+ * QuickAnimation is a Class that creates a LookupTable with
+ * position between [0.0f - 1.0f] so that one can resolve the
+ * given Value.
+ */
+class QuickAnimation
+{
+public:
+  QuickAnimation(unsigned int resolution = 100);
+  virtual ~QuickAnimation();
 
-   this class is optimized for a raising value. eg. 100 particles sorted
-   by age.
-*/
-class QuickAnimation : public BaseObject {
+  bool addKey(float position, float value);
 
- public:
+  bool changeValueKey(unsigned int keyFrameNumber, float newValue);
+  bool changeValue(float position, float newValue, float region = 0.04f);
 
+  bool removeKey(unsigned int keyFrameNumber);
+  bool remove(float position, float region = 0.04f);
+
+  bool moveKey(unsigned int keyFrameNumber, float newPosition, float newValue);
+  bool moveKey(unsigned int keyFrameNumber, float newPosition);
+  bool move(float oldPosition, float newPosition, float newValue, float region = 0.04f);
+  bool move(float oldPosition, float newPosition, float region = 0.04f);
+
+  int getKeyAt(float position, float region = 0.04f);
+
+  /**
+   * @brief returns the value of the animation at a certain position
+   * @param value returns the calculated value.
+   * @param position The position to get the Value from.
+   */
+  void QuickAnimation::getValue(float& value, float position) const
+  {
+    value = this->lookupValues[int(position*this->lookupValues.size())];
+  }
+
+/**
+   * @brief returns the value of the animation at a certain position
+   * @param position the position to get the value from :)
+   * @returns the calculated Value.
+ */
+  float QuickAnimation::getValue(float position) const
+  {
+    return this->lookupValues[int(position*this->lookupValues.size())];
+  }
+
+  void debug() const;
+private:
+  void rebuild();
+
+private:
   //! a simple struct that stores keyframes for the QuickAnimation-Class.
   struct QuickKeyFrame
   {
-    float            value;             //!< The starting value of this KeyFrame
-    float            position;          //!< The end position of thies KeyFrame
+    //! Creates a new QuickKeyFrame with @param position position @param value value */
+    QuickKeyFrame(float position, float value) :  position(position), value(value) {};
+    float            value;             //!< The value of this KeyFrame
+    float            position;          //!< The position of thies KeyFrame
 
-    QuickKeyFrame*   next;              //!< The next Animation
-    QuickKeyFrame*   prev;              //!< The previous QuickKeyFrame
+    static bool sortPositionPredicate(const QuickKeyFrame& key1, const QuickKeyFrame& key2);
+    static bool sortValuePredicate(const QuickKeyFrame& key1, const QuickKeyFrame& key2);
   };
 
-  QuickAnimation();
-  virtual ~QuickAnimation();
-
-  void addEntry(float position, float value);
-  void changeEntry(float position, float value, float region = .04);
-
-  void removeEntry(float position);
-  /** @todo implemente those functions
-      bool moveEntry(float position);
-  */
-
-  float getValue(float position);
-
-  void debug();
-
- private:
-  QuickKeyFrame*       first;          //!< The first KeyFrame in a Sequence of Keyframes.
-  QuickKeyFrame*       current;        //!< The currently selected KeyFrame.
-  unsigned int         count;          //!< How many Keyframes the QuickAnimation has.
+  std::vector<QuickKeyFrame>    keyFrames;              //!< An Array of KeyFrames.
+  std::vector<float>            lookupValues;           //!< The lookup-table where the values are stored.
 };
 
