]> git.localhorst.tv Git - blank.git/blobdiff - src/world/Entity.hpp
configurable asset and save path
[blank.git] / src / world / Entity.hpp
index 48646e80ddd656b353e7f105cab6a6ebc34621eb..f60bf4cc6e01c2537a8c3c0927292e867a743e79 100644 (file)
@@ -22,7 +22,7 @@ public:
 
        bool HasShape() const noexcept { return shape; }
        const Shape *GetShape() const noexcept { return shape; }
-       void SetShape(const Shape *, const glm::vec3 &color);
+       void SetShape(const Shape *, const glm::vec3 &color, float texture);
        void SetShapeless() noexcept;
 
        const std::string &Name() const noexcept { return name; }
@@ -38,6 +38,7 @@ public:
        void Velocity(const glm::vec3 &) noexcept;
 
        const Block::Pos &Position() const noexcept { return position; }
+       void Position(const Chunk::Pos &, const Block::Pos &) noexcept;
        void Position(const Block::Pos &) noexcept;
        void Move(const glm::vec3 &delta) noexcept;
 
@@ -46,12 +47,16 @@ public:
        glm::vec3 AbsolutePosition() const noexcept {
                return glm::vec3(chunk * Chunk::Extent()) + position;
        }
+       glm::vec3 AbsoluteDifference(const Entity &other) const noexcept {
+               return glm::vec3((chunk - other.chunk) * Chunk::Extent()) + position - other.position;
+       }
 
-       const glm::quat &AngularVelocity() const noexcept { return angular_velocity; }
-       void AngularVelocity(const glm::quat &) noexcept;
+       /// direction is rotation axis, magnitude is speed in rad/ms
+       const glm::vec3 &AngularVelocity() const noexcept { return angular_velocity; }
+       void AngularVelocity(const glm::vec3 &) noexcept;
 
-       const glm::mat4 &Rotation() const noexcept { return rotation; }
-       void Rotation(const glm::mat4 &) noexcept;
+       const glm::quat &Rotation() const noexcept { return rotation; }
+       void Rotation(const glm::quat &) noexcept;
        void Rotate(const glm::quat &delta) noexcept;
 
        glm::mat4 Transform(const Chunk::Pos &chunk_offset) const noexcept;
@@ -62,7 +67,9 @@ public:
 
        void Update(int dt) noexcept;
 
-       void Draw() noexcept;
+       void Draw() noexcept {
+               model.Draw();
+       }
 
 private:
        const Shape *shape;
@@ -76,8 +83,8 @@ private:
        Block::Pos position;
        Chunk::Pos chunk;
 
-       glm::quat angular_velocity;
-       glm::mat4 rotation;
+       glm::vec3 angular_velocity;
+       glm::quat rotation;
 
        bool world_collision;
        bool remove;