Better CMake dependency handling

This commit is contained in:
Jack Andersen 2019-06-11 16:04:52 -10:00
parent 6c13d089fe
commit c81eb93b6d
6 changed files with 16 additions and 17 deletions

View File

@ -4,11 +4,6 @@ project(zeus)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT DEFINED ATHENA_INCLUDE_DIR)
set(ATHENA_INCLUDE_DIR ../athena/include)
endif()
include_directories(include ${ATHENA_INCLUDE_DIR})
set(SOURCES
src/CVector3f.cpp
src/Math.cpp
@ -59,5 +54,11 @@ add_library(zeus
include/zeus/simd/simd_avx.hpp
include/zeus/simd/parallelism_v2_simd.hpp)
target_include_directories(zeus PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
if(TARGET athena-core)
target_link_libraries(zeus PUBLIC athena-core)
target_compile_definitions(zeus PUBLIC ZE_ATHENA_TYPES=1)
endif()
add_subdirectory(test)

View File

@ -101,9 +101,11 @@ public:
CQuaternion normalized() const { return *this / magnitude(); }
void invert();
static constexpr simd<float> InvertQuat = {1.f, -1.f, -1.f, -1.f};
CQuaternion inverse() const;
void invert() { mSimd *= InvertQuat; }
CQuaternion inverse() const { return mSimd * InvertQuat; }
/**
* @brief Set the rotation using axis angle notation

View File

@ -221,12 +221,14 @@ public:
sse_data[__index % 2] = __val;
__storage_[__index / 2] = _mm_load_pd(sse_data.data());
}
constexpr __simd_storage(double a, double b, double c, double d) : __storage_{__m128d{a, b}, __m128d{c, d}} {}
static constexpr storage_type __make_array(__m128d a, __m128d b) { return {a, b}; }
constexpr __simd_storage(double a, double b, double c, double d)
: __storage_(__make_array(__m128d{a, b}, __m128d{c, d})) {}
void __set4(double a, double b, double c, double d) noexcept {
__storage_[0] = _mm_set_pd(b, a);
__storage_[1] = _mm_set_pd(d, c);
}
constexpr __simd_storage(double rv) : __storage_{__m128d{rv, rv}, __m128d{rv, rv}} {}
constexpr __simd_storage(double rv) : __storage_(__make_array(__m128d{rv, rv}, __m128d{rv, rv})) {}
void __broadcast(double __val) noexcept {
for (int i = 0; i < 2; ++i)
__storage_[i] = _mm_set1_pd(__val);

View File

@ -149,12 +149,6 @@ const CQuaternion& CQuaternion::operator/=(float scale) {
return *this;
}
static const simd<float> InvertQuat(1.f, -1.f, -1.f, -1.f);
void CQuaternion::invert() { mSimd *= InvertQuat; }
CQuaternion CQuaternion::inverse() const { return mSimd * InvertQuat; }
CQuaternion CQuaternion::log() const {
float a = std::acos(w());
float sina = std::sin(a);

View File

@ -4,7 +4,5 @@ project(zeustest)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(../include)
add_executable(zeustest main.cpp)
target_link_libraries(zeustest zeus)

View File

@ -12,6 +12,8 @@ union Color {
zeus::Comp32 rgba;
};
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
int main() {
zeus::detectCPU();
assert(!CAABox({100, 100, 100}, {100, 100, 100}).invalid());