From 3014c3bc831d613c2de7513aefdc7d3cb711b749 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Fri, 19 May 2017 22:49:47 +0100 Subject: Fixed cmake and making precise vector --- .dir-locals.el | 18 ++++++++++++++++++ CMakeLists.txt | 13 ++++++++++++- include/YAGE/Math/vector.hpp | 22 ++++++++++++++++++++-- src/vector2d.cpp | 2 +- test/rigid_body_test.cpp | 2 +- test/vector2d_test.cpp | 15 ++++++++++++++- 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index 4afe10c5..58153f52 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,16 +1,34 @@ ((nil . ((company-clang-arguments . ("-I../include/YAGE/" "-I../../include/YAGE/" "-I../../../include/YAGE/" + "-I../include/YAGE/Physics/" + "-I../../include/YAGE/Physics/" + "-I../../../include/YAGE/Physics/" + "-I../include/YAGE/Math/" + "-I../../include/YAGE/Math/" + "-I../../../include/YAGE/Math/" "-I/usr/include/" "-I/usr/include/SDL2/")) (company-c-headers-path-user . ("../include/YAGE/" "../../include/YAGE/" "../../../include/YAGE/" + "../include/YAGE/Physics/" + "../../include/YAGE/Physics/" + "../../../include/YAGE/Physics/" + "../include/YAGE/Math/" + "../../include/YAGE/Math/" + "../../../include/YAGE/Math/" "/usr/include/" "/usr/include/SDL2/")) (flycheck-clang-include-path . ("../include/YAGE/" "../../include/YAGE/" "../../../include/YAGE/" + "../include/YAGE/Physics/" + "../../include/YAGE/Physics/" + "../../../include/YAGE/Physics/" + "../include/YAGE/Math/" + "../../include/YAGE/Math/" + "../../../include/YAGE/Math/" "/usr/include/" "/usr/include/SDL2/"))))) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71686462..2309db4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ set(CMAKE_CXX_STANDARD 14) # set the test sources set(YAGE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src) set(YAGE_TEST_DIR ${PROJECT_SOURCE_DIR}/test) +set(YAGE_LIBRARIES yage) # add include directory set(YAGE_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include/YAGE) @@ -48,7 +49,9 @@ find_package(OpenGL REQUIRED) find_package(GLEW REQUIRED) # set include directory -include_directories(${YAGE_INCLUDE_DIR}) +include_directories(${YAGE_INCLUDE_DIR} + ${YAGE_INCLUDE_DIR}/Physics/ + ${YAGE_INCLUDE_DIR}/Math/) # make it a static library add_library(${PROJECT_NAME} ${YAGE_SOURCES}) @@ -68,6 +71,14 @@ target_link_libraries(double_size ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES}) +add_executable(vector2d_test + ${YAGE_TEST_DIR}/vector2d_test.cpp) +target_link_libraries(vector2d_test + ${YAGE_LIBRARIES} + ${OPENGL_LIBRARIES} + ${GLEW_LIBRARIES}) + enable_testing() add_test(RigidBodyTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rigid_body_test) add_test(DoubleSize ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/double_size) +add_test(Vector2DTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/double_size) diff --git a/include/YAGE/Math/vector.hpp b/include/YAGE/Math/vector.hpp index 39553a49..83c16502 100644 --- a/include/YAGE/Math/vector.hpp +++ b/include/YAGE/Math/vector.hpp @@ -1,6 +1,7 @@ #ifndef YAGE_MATH_VECTOR_HPP #define YAGE_MATH_VECTOR_HPP +#include #include namespace yage @@ -13,7 +14,7 @@ protected: public: Vector()=delete; - virtual ~Vector(); + virtual ~Vector() {} inline long double &operator[](std::size_t index) { @@ -24,6 +25,12 @@ public: { return members_[index]; } + + inline Vector &operator=(const Vector &other) + { + this->members_=other.members_; + return *this; + } inline Vector &operator+() { @@ -124,8 +131,19 @@ public: return Vector(mem); } + friend inline std::ostream &operator<<(std::ostream &os, const Vector &object) + { + os<<"("; + for(std::size_t i=0; i &members); + Vector(const std::vector &members) : members_(members) {} }; } // yage diff --git a/src/vector2d.cpp b/src/vector2d.cpp index 88e637c6..9955f12f 100644 --- a/src/vector2d.cpp +++ b/src/vector2d.cpp @@ -1,4 +1,4 @@ -#include "Math/vector2d.hpp" +#include "vector2d.hpp" namespace yage { diff --git a/test/rigid_body_test.cpp b/test/rigid_body_test.cpp index c5683697..57ba1162 100644 --- a/test/rigid_body_test.cpp +++ b/test/rigid_body_test.cpp @@ -1,4 +1,4 @@ -#include "Physics/particlebody.hpp" +#include "particlebody.hpp" #include diff --git a/test/vector2d_test.cpp b/test/vector2d_test.cpp index 2c37bba7..20a5be3e 100644 --- a/test/vector2d_test.cpp +++ b/test/vector2d_test.cpp @@ -1,2 +1,15 @@ -#include +#include "vector2d.hpp" +#include + +int main() +{ + yage::Vector2D v; + yage::Vector2D v2(1, 5); + + v=v2; + + std::cout<