RavEngine
Loading...
Searching...
No Matches
PxWindowsMathIntrinsics.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_WINDOWS_MATH_INTRINSICS_H
30#define PX_WINDOWS_MATH_INTRINSICS_H
31
32#include "foundation/Px.h"
33#include "foundation/PxAssert.h"
34
35#if !PX_WINDOWS_FAMILY
36#error "This file should only be included by Windows builds!!"
37#endif
38
39#include <math.h>
40#include <float.h>
41
42#if !PX_DOXYGEN
43namespace physx
44{
45namespace intrinsics
46{
47#endif
48
50PX_CUDA_CALLABLE PX_FORCE_INLINE float abs(float a)
51{
52 return ::fabsf(a);
53}
54
56PX_CUDA_CALLABLE PX_FORCE_INLINE float fsel(float a, float b, float c)
57{
58 return (a >= 0.0f) ? b : c;
59}
60
62PX_CUDA_CALLABLE PX_FORCE_INLINE float sign(float a)
63{
64 return (a >= 0.0f) ? 1.0f : -1.0f;
65}
66
68PX_CUDA_CALLABLE PX_FORCE_INLINE float recip(float a)
69{
70 return 1.0f / a;
71}
72
74PX_CUDA_CALLABLE PX_FORCE_INLINE float recipFast(float a)
75{
76 return 1.0f / a;
77}
78
80PX_CUDA_CALLABLE PX_FORCE_INLINE float sqrt(float a)
81{
82 return ::sqrtf(a);
83}
84
86PX_CUDA_CALLABLE PX_FORCE_INLINE float recipSqrt(float a)
87{
88 return 1.0f / ::sqrtf(a);
89}
90
92PX_CUDA_CALLABLE PX_FORCE_INLINE float recipSqrtFast(float a)
93{
94 return 1.0f / ::sqrtf(a);
95}
96
98PX_CUDA_CALLABLE PX_FORCE_INLINE float sin(float a)
99{
100 return ::sinf(a);
101}
102
104PX_CUDA_CALLABLE PX_FORCE_INLINE float cos(float a)
105{
106 return ::cosf(a);
107}
108
110PX_CUDA_CALLABLE PX_FORCE_INLINE float selectMin(float a, float b)
111{
112 return a < b ? a : b;
113}
114
116PX_CUDA_CALLABLE PX_FORCE_INLINE float selectMax(float a, float b)
117{
118 return a > b ? a : b;
119}
120
122PX_CUDA_CALLABLE PX_FORCE_INLINE bool isFinite(float a)
123{
124#ifdef __CUDACC__
125 return !!isfinite(a);
126#else
127 return (0 == ((_FPCLASS_SNAN | _FPCLASS_QNAN | _FPCLASS_NINF | _FPCLASS_PINF) & _fpclass(a)));
128#endif
129}
130
132PX_CUDA_CALLABLE PX_FORCE_INLINE bool isFinite(double a)
133{
134#ifdef __CUDACC__
135 return !!isfinite(a);
136#else
137 return (0 == ((_FPCLASS_SNAN | _FPCLASS_QNAN | _FPCLASS_NINF | _FPCLASS_PINF) & _fpclass(a)));
138#endif
139}
140
144PX_FORCE_INLINE void* memZero(void* dest, uint32_t count)
145{
146 return memset(dest, 0, count);
147}
148
152PX_FORCE_INLINE void* memSet(void* dest, int32_t c, uint32_t count)
153{
154 return memset(dest, c, count);
155}
156
160PX_FORCE_INLINE void* memCopy(void* dest, const void* src, uint32_t count)
161{
162 return memcpy(dest, src, count);
163}
164
168PX_FORCE_INLINE void* memMove(void* dest, const void* src, uint32_t count)
169{
170 return memmove(dest, src, count);
171}
172
173#if !PX_DOXYGEN
174} // namespace intrinsics
175} // namespace physx
176#endif
177
178#endif
179
GLM_FUNC_QUALIFIER vec< L, T, Q > sqrt(vec< L, T, Q > const &x)
Definition func_exponential.inl:128
GLM_FUNC_QUALIFIER vec< L, T, Q > sin(vec< L, T, Q > const &v)
Definition func_trigonometric.inl:41
GLM_FUNC_QUALIFIER vec< L, T, Q > cos(vec< L, T, Q > const &v)
Definition func_trigonometric.inl:50
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39