text: //
  //  PhysicsEntity.h
  //  libraries/physics/src
  //
  //  Created by Andrew Meadows 2014.05.30
  //  Copyright 2014 High Fidelity, Inc.
  //
  //  Distributed under the Apache License, Version 2.0.
  //  See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
  //
  
  #ifndef hifi_PhysicsEntity_h
  #define hifi_PhysicsEntity_h
  
  #include <QVector>
  #include <QSet>
  
  #include <glm/glm.hpp>
  #include <glm/gtc/quaternion.hpp>
  
  #include <CollisionInfo.h>
  #include <RayIntersectionInfo.h>
  
  class Shape;
  class PhysicsSimulation;
  
  // PhysicsEntity is the base class for anything that owns one or more Shapes that collide in a 
  // PhysicsSimulation.  Each CollisionInfo generated by a PhysicsSimulation has back pointers to the 
  // two Shapes involved, and those Shapes may (optionally) have valid back pointers to their PhysicsEntity.
  
  class PhysicsEntity {
  
  public:
      PhysicsEntity();
      virtual ~PhysicsEntity();
  
      virtual void stepForward(float deltaTime) { }
  
      void setTranslation(const glm::vec3& translation);
      void setRotation(const glm::quat& rotation);
  
      const glm::vec3& getTranslation() const { return _translation; }
      const glm::quat& getRotation() const { return _rotation; }
      float getBoundingRadius() const { return _boundingRadius; }
  
      void setShapeBackPointers();
  
      void setEnableShapes(bool enable);
  
      virtual void buildShapes() = 0;
      virtual void clearShapes();
      const QVector<Shape*> getShapes() const { return _shapes; }
  
      PhysicsSimulation* getSimulation() const { return _simulation; }
  
      bool findRayIntersection(RayIntersectionInfo& intersection) const;
      bool findCollisions(const QVector<const Shape*> shapes, CollisionList& collisions);
      bool findSphereCollisions(const glm::vec3& sphereCenter, float sphereRadius, CollisionList& collisions);
      bool findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions);
  
      void disableCollisions(int shapeIndexA, int shapeIndexB);
      bool collisionsAreEnabled(int shapeIndexA, int shapeIndexB) const;
  
      void disableCurrentSelfCollisions();
  
  protected:
      glm::vec3 _translation;
      glm::quat _rotation;
      float _boundingRadius;
      bool _shapesAreDirty;
      bool _enableShapes;
      QVector<Shape*> _shapes;
      QSet<int> _disabledCollisions;
  
  private:
      // PhysicsSimulation is a friend so that it can set the protected _simulation backpointer
      friend class PhysicsSimulation; 
      PhysicsSimulation* _simulation;
  };
  
  #endif // hifi_PhysicsEntity_h
  