SuperDex Physics C++ API
Loading...
Searching...
No Matches
plane.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19// PLEASE DO NOT ADD OTHER INCLUDES HERE. This header is included in the mochi_physics public API.
26
27#include <type_traits>
28
29namespace superdex {
30
31/**************************************************************************************************
32 Plane
33*/
34class Plane final {
35 public:
36 Real3 normal = {0_r, 1_r, 0_r}; ///< Outward-facing plane normal (unit length).
37 real distance = {0_r}; ///< Signed distance from the origin along the normal [m].
38
41 : normal(ToReal3(normal)), distance(distFromOrigin) {}
42 MOCHI_FORCE_INLINE Plane(Real3 const& normal, real distFromOrigin)
43 : normal(normal), distance(distFromOrigin) {}
44
45 [[nodiscard]] MOCHI_FORCE_INLINE Real3 GetNormal() const {
46 return normal;
47 }
48
50 return distance;
51 }
52
53 [[nodiscard]] MOCHI_FORCE_INLINE Vec4r VGetPacked() const {
54 return ToSimd(normal, distance);
55 }
56
57 [[nodiscard]] MOCHI_FORCE_INLINE Vec4r VGetNormal() const {
58 return ToSimd(normal, 0_r);
59 }
60
61#if MOCHI_LANGUAGE_CPP20
62 bool operator==(Plane const& other) const = default;
63 bool operator!=(Plane const& other) const = default;
64#endif
65
70};
71
72namespace details {
73template <>
74inline constexpr bool IsPrimitiveShapeDef<Plane> = true;
75} // namespace details
76
77} // namespace superdex
bool operator!=(Plane const &other) const =default
Plane()=default
real GetDistanceFromOrigin() const
Definition plane.h:49
bool operator==(Plane const &other) const =default
Vec4r VGetPacked() const
Definition plane.h:53
Plane(Vec4r normal, real distFromOrigin)
Definition plane.h:40
Real3 normal
Outward-facing plane normal (unit length).
Definition plane.h:36
Real3 GetNormal() const
Definition plane.h:45
Vec4r VGetNormal() const
Definition plane.h:57
real distance
Signed distance from the origin along the normal [m].
Definition plane.h:37
Plane(Real3 const &normal, real distFromOrigin)
Definition plane.h:42
#define MOCHI_FORCE_INLINE
Simd< T, 4 > ToSimd(NdArray< T, 2 > const &v, T z=T(0), T w=T(0))
Definition vmatrix.h:413
Real3 ToReal3(Simd< T, 4 > v)
Definition vmatrix.h:354
Simd< real, 4 > Vec4r
Definition simd.h:206
NdArray< real, 3 > Real3
Definition nd_array.h:106
#define MOCHI_STRUCT_END()
Definition reflection.h:279
#define MOCHI_FIELD(name)
Definition reflection.h:293
#define MOCHI_STRUCT_BEGIN(name)
Definition reflection.h:278
#define MOCHI_ATTRIBUTE(...)
Definition reflection.h:298