VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
defines.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// Created by Arnis Lektauers on 31.08.2025
5//
6#pragma once
7
8#include <ostream>
9#include <numbers>
10
11#if defined(__SSE__) || defined(__SSE2__)
12 #include <immintrin.h>
13#endif
14#if defined(__ARM_NEON)
15 #include <arm_neon.h>
16#endif
17#if defined(__APPLE__)
18 #include <simd/simd.h>
19#endif
20
21#define USE_SIMD_MATH
22
23// SIMD backend selection priority:
24// 1. USE_SIMD_PREFER_NEON — force NEON on ARM (including Apple Silicon), useful for testing
25// 2. SSE on x86
26// 3. Apple SIMD on Apple platforms (preferred on Apple Silicon — uses Accelerate framework)
27// 4. NEON on non-Apple ARM (e.g., Android, Linux ARM)
28#if defined(USE_SIMD_MATH) && defined(USE_SIMD_PREFER_NEON) && defined(__ARM_NEON)
29 #define USE_SIMD_NEON
30#elif defined(USE_SIMD_MATH) && defined(__SSE__)
31 #define USE_SIMD_SSE
32#elif defined(USE_SIMD_MATH) && defined(__APPLE__)
33 #define USE_SIMD_APPLE
34#elif defined(USE_SIMD_MATH) && defined(__ARM_NEON)
35 #define USE_SIMD_NEON
36#else
37 #undef USE_SIMD_MATH
38#endif
39
40namespace visutwin::canvas
41{
42 // Archimedes' constant (π)
43 constexpr float PI = std::numbers::pi;
44
45 // The full circle constant (τ)
46 constexpr float TAU = std::numbers::pi * 2;
47
48 constexpr float RAD_TO_DEG = 180.0f / PI;
49 constexpr float DEG_TO_RAD = PI / 180.0f;
50
51 constexpr float degToRad(const float degrees) {
52 return degrees * DEG_TO_RAD;
53 }
54}
constexpr float PI
Definition defines.h:43
constexpr float degToRad(const float degrees)
Definition defines.h:51
constexpr float RAD_TO_DEG
Definition defines.h:48
constexpr float TAU
Definition defines.h:46
constexpr float DEG_TO_RAD
Definition defines.h:49