#include "glm/glm.hpp"
#include "DeerStudio/EditorEngine/API/Math.h"

namespace Deer {
    namespace EditorEngine {
        void vec3_constructor(void* mem) {
            new (mem) glm::vec3(0, 0, 0);
        }
        void vec3_constructor_params(float x, float y, float z, void* mem) {
            new (mem) glm::vec3(x, y, z);
        }
        glm::vec3 vec3_add(glm::vec3& value, glm::vec3& self) {
            return self + value;
        }
        glm::vec3 vec3_sub(const glm::vec3& value, glm::vec3& self) {
            return self - value;
        }
        glm::vec3 vec3_neg(glm::vec3& self) {
            return -self;
        }
        glm::vec3 vec3_mult(float value, glm::vec3& self) {
            return self * value;
        }

        void quat_construct(glm::quat* mem) {
            new (mem) glm::quat();
        }
        void quat_copyConstruct(glm::quat* data, glm::quat* mem) {
            new (mem) glm::quat(*data);
        }
        void quat_destruct(glm::quat* mem) {
        }
        void quat_constructFromValue(float x, float y, float z, float w, glm::quat* mem) {
            new (mem) glm::quat(x, y, z, w);
        }

        glm::vec3 quat_getEuler(glm::quat* mem) {
            return glm::degrees(glm::eulerAngles(*mem));
        }
        void quat_setEuler(glm::vec3 euler, glm::quat* mem) {
            new (mem) glm::quat(glm::radians(euler));
        }
        glm::quat quat_multiply(glm::quat* data, glm::quat* mem) {
            return *mem * *data;
        }

        glm::vec3 transform_relative(glm::vec3 pos, TransformComponent* transform) {
            return transform->getMatrix() * glm::vec4(pos, 1.0f);
        }

        void transform_construct(TransformComponent* mem) {
            new (mem) TransformComponent();
        }
        void camera_construct(CameraComponent* mem) {
            new (mem) CameraComponent();
        }
        void sceneCamera_Construct(SceneCamera* mem) {
            new (mem) SceneCamera();
        }

    }
}