#ifndef GIBGENERATORNODE_H
#define GIBGENERATORNODE_H

#include "containernode.h"
#include <glm/vec3.hpp>
#include <BulletDynamics/Dynamics/btRigidBody.h>

class btCollisionShape;
class btRigidBody;
class GraphicalNode;

class GibGeneratorNode : public ContainerNode
{
    struct Gib
    {
        btRigidBody* body;
        GraphicalNode* graphics;
        unsigned int expiration;

        Gib(btRigidBody* b, GraphicalNode* g, unsigned int e) :
            body(b),
            graphics(g),
            expiration(e)
        {}

        ~Gib()
        {
            delete body;
        }
    };

    std::vector<Gib*> m_gibs;

public:
    void createGib(GraphicalNode* graphicalPart,
                   btCollisionShape *physicsShape,
                   float masses,
                   const glm::vec3 &pos = glm::vec3(0),
                   const glm::vec3 &velocity = glm::vec3(0),
                   unsigned int lifeSpan = 5000);

    virtual void update();
};

#endif // GIBGENERATORNODE_H
