JPL Spatial
Sound spatialization and propagation library
Loading...
Searching...
No Matches
Vec3Traits.h
Go to the documentation of this file.
1//
2// ██╗██████╗ ██╗ ██╗██████╗ ███████╗
3// ██║██╔══██╗ ██║ ██║██╔══██╗██╔════╝ ** JPLSpatial **
4// ██║██████╔╝ ██║ ██║██████╔╝███████╗
5// ██ ██║██╔═══╝ ██║ ██║██╔══██╗╚════██║ https://github.com/Jaytheway/JPLSpatial
6// ╚█████╔╝██║ ███████╗██║██████╔╝███████║
7// ╚════╝ ╚═╝ ╚══════╝╚═╝╚═════╝ ╚══════╝
8//
9// Copyright 2024 Jaroslav Pevno, JPLSpatial is offered under the terms of the ISC license:
10//
11// Permission to use, copy, modify, and/or distribute this software for any purpose with or
12// without fee is hereby granted, provided that the above copyright notice and this permission
13// notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
14// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
16// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
17// WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#pragma once
21
22#include "JPLSpatial/Core.h"
23
24#include <concepts>
25
26namespace JPL
27{
28 // Specialization of this has to be provided for custom vec3 type
29 template<class Vec3Type>
30 struct Vec3Access{};
31
32 template<class Vec3Type>
33 using Vec3FloatType = std::remove_cvref_t<decltype(Vec3Access<Vec3Type>::GetX(std::declval<Vec3Type>()))>;
34
35 template<class Vec3Type> [[nodiscard]] JPL_INLINE auto GetX(const Vec3Type& v) noexcept { return Vec3Access<Vec3Type>::GetX(v); }
36 template<class Vec3Type> [[nodiscard]] JPL_INLINE auto GetY(const Vec3Type& v) noexcept { return Vec3Access<Vec3Type>::GetY(v); }
37 template<class Vec3Type> [[nodiscard]] JPL_INLINE auto GetZ(const Vec3Type& v) noexcept { return Vec3Access<Vec3Type>::GetZ(v); }
38
39 template<class Vec3Type> JPL_INLINE void SetX(Vec3Type& v, Vec3FloatType<Vec3Type> value) noexcept { Vec3Access<Vec3Type>::SetX(v, value); }
40 template<class Vec3Type> JPL_INLINE void SetY(Vec3Type& v, Vec3FloatType<Vec3Type> value) noexcept { Vec3Access<Vec3Type>::SetY(v, value); }
41 template<class Vec3Type> JPL_INLINE void SetZ(Vec3Type& v, Vec3FloatType<Vec3Type> value) noexcept { Vec3Access<Vec3Type>::SetZ(v, value); }
42
43 template<class T>
44 concept CVec3 = requires (T& v)
45 {
46 // Note: Getters and Setters should be noexcept
47
48 { Vec3Access<T>::GetX(v) } noexcept;
49 { Vec3Access<T>::GetY(v) } noexcept;
50 { Vec3Access<T>::GetZ(v) } noexcept;
51
52 { Vec3Access<T>::SetX(v, std::remove_cvref_t<decltype(Vec3Access<T>::GetX(v))>(0.0)) } noexcept;
53 { Vec3Access<T>::SetY(v, std::remove_cvref_t<decltype(Vec3Access<T>::GetX(v))>(0.0)) } noexcept;
54 { Vec3Access<T>::SetZ(v, std::remove_cvref_t<decltype(Vec3Access<T>::GetX(v))>(0.0)) } noexcept;
55 };
56} // namespace JPL
Definition Vec3Traits.h:44
Definition AcousticMaterial.h:36
std::remove_cvref_t< decltype(Vec3Access< Vec3Type >::GetX(std::declval< Vec3Type >()))> Vec3FloatType
Definition Vec3Traits.h:33
JPL_INLINE void SetZ(Vec3Type &v, Vec3FloatType< Vec3Type > value) noexcept
Definition Vec3Traits.h:41
JPL_INLINE auto GetX(const Vec3Type &v) noexcept
Definition Vec3Traits.h:35
JPL_INLINE void SetY(Vec3Type &v, Vec3FloatType< Vec3Type > value) noexcept
Definition Vec3Traits.h:40
JPL_INLINE auto GetZ(const Vec3Type &v) noexcept
Definition Vec3Traits.h:37
JPL_INLINE auto GetY(const Vec3Type &v) noexcept
Definition Vec3Traits.h:36
JPL_INLINE void SetX(Vec3Type &v, Vec3FloatType< Vec3Type > value) noexcept
Definition Vec3Traits.h:39
JPL_INLINE simd min(const simd &a, const simd &b) noexcept
Element-wise min.
Definition SIMD.h:1813
Definition Vec3Traits.h:30