OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
spursScalar.h
1// Gamespy Technology
2// NOTE: this code has been provided by Sony for usage in Speex SPURS Manager
3
4/*
5Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
6
7This software is provided 'as-is', without any express or implied warranty.
8In no event will the authors be held liable for any damages arising from the use of this software.
9Permission is granted to anyone to use this software for any purpose,
10including commercial applications, and to alter it and redistribute it freely,
11subject to the following restrictions:
12
131. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
142. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
153. This notice may not be removed or altered from any source distribution.
16*/
17
18
19
20#ifndef SIMD___SCALAR_H
21#define SIMD___SCALAR_H
22
23#include <math.h>
24
25#include <cstdlib>
26#include <cfloat>
27#include <float.h>
28
29#define SIMD_FORCE_INLINE inline
30#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
31#ifndef assert
32#include <assert.h>
33#endif
34#define btAssert assert
35//btFullAssert is optional, slows down a lot
36#define btFullAssert(x)
37
39// removed since only ps3 used
40/*
43#if defined (__sun) || defined (__sun__) || defined (__sparc) || (defined (__APPLE__) && ! defined (__i386__))
44//use slow double float precision operation on those platforms
45#ifndef BT_USE_DOUBLE_PRECISION
46#define BT_FORCE_DOUBLE_FUNCTIONS
47#endif
48#endif
49*/
50
52// removed since only ps3 used
53/*
54#if defined(BT_USE_DOUBLE_PRECISION)
55typedef double btScalar;
56#else
57typedef float btScalar;
58#endif
59*/
60
62// removed since not needed
63/*
64#if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS)
65
66SIMD_FORCE_INLINE btScalar btSqrt(btScalar x) { return sqrt(x); }
67SIMD_FORCE_INLINE btScalar btFabs(btScalar x) { return fabs(x); }
68SIMD_FORCE_INLINE btScalar btCos(btScalar x) { return cos(x); }
69SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sin(x); }
70SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tan(x); }
71SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { return acos(x); }
72SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { return asin(x); }
73SIMD_FORCE_INLINE btScalar btAtan(btScalar x) { return atan(x); }
74SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2(x, y); }
75SIMD_FORCE_INLINE btScalar btExp(btScalar x) { return exp(x); }
76SIMD_FORCE_INLINE btScalar btLog(btScalar x) { return log(x); }
77SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return pow(x,y); }
78
79#else
80
81SIMD_FORCE_INLINE btScalar btSqrt(btScalar x) { return sqrtf(x); }
82SIMD_FORCE_INLINE btScalar btFabs(btScalar x) { return fabsf(x); }
83SIMD_FORCE_INLINE btScalar btCos(btScalar x) { return cosf(x); }
84SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sinf(x); }
85SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tanf(x); }
86SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { return acosf(x); }
87SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { return asinf(x); }
88SIMD_FORCE_INLINE btScalar btAtan(btScalar x) { return atanf(x); }
89SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2f(x, y); }
90SIMD_FORCE_INLINE btScalar btExp(btScalar x) { return expf(x); }
91SIMD_FORCE_INLINE btScalar btLog(btScalar x) { return logf(x); }
92SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return powf(x,y); }
93
94#endif
95*/
96
97
99// removed since not necessary
100/*
101#define SIMD_2_PI btScalar(6.283185307179586232)
102#define SIMD_PI (SIMD_2_PI * btScalar(0.5))
103#define SIMD_HALF_PI (SIMD_2_PI * btScalar(0.25))
104#define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0))
105#define SIMD_DEGS_PER_RAD (btScalar(360.0) / SIMD_2_PI)
106
107#ifdef BT_USE_DOUBLE_PRECISION
108#define SIMD_EPSILON DBL_EPSILON
109#define SIMD_INFINITY DBL_MAX
110#else
111#define SIMD_EPSILON FLT_EPSILON
112#define SIMD_INFINITY FLT_MAX
113#endif
114
115SIMD_FORCE_INLINE btScalar btAtan2Fast(btScalar y, btScalar x)
116{
117 btScalar coeff_1 = SIMD_PI / 4.0f;
118 btScalar coeff_2 = 3.0f * coeff_1;
119 btScalar abs_y = btFabs(y);
120 btScalar angle;
121 if (x >= 0.0f) {
122 btScalar r = (x - abs_y) / (x + abs_y);
123 angle = coeff_1 - coeff_1 * r;
124 } else {
125 btScalar r = (x + abs_y) / (abs_y - x);
126 angle = coeff_2 - coeff_1 * r;
127 }
128 return (y < 0.0f) ? -angle : angle;
129}
130
131SIMD_FORCE_INLINE bool btFuzzyZero(btScalar x) { return btFabs(x) < SIMD_EPSILON; }
132
133SIMD_FORCE_INLINE bool btEqual(btScalar a, btScalar eps) {
134 return (((a) <= eps) && !((a) < -eps));
135}
136SIMD_FORCE_INLINE bool btGreaterEqual (btScalar a, btScalar eps) {
137 return (!((a) <= eps));
138}
139*/
140
141/*SIMD_FORCE_INLINE btScalar btCos(btScalar x) { return cosf(x); }
142SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sinf(x); }
143SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tanf(x); }
144SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { return acosf(x); }
145SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { return asinf(x); }
146SIMD_FORCE_INLINE btScalar btAtan(btScalar x) { return atanf(x); }
147SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2f(x, y); }
148*/
149
150
152// removed since not necessary
153/*
154SIMD_FORCE_INLINE int btIsNegative(btScalar x) {
155 return x < btScalar(0.0) ? 1 : 0;
156}
157
158SIMD_FORCE_INLINE btScalar btRadians(btScalar x) { return x * SIMD_RADS_PER_DEG; }
159SIMD_FORCE_INLINE btScalar btDegrees(btScalar x) { return x * SIMD_DEGS_PER_RAD; }
160
161#define BT_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
162
163#ifndef btFsel
164SIMD_FORCE_INLINE btScalar btFsel(btScalar a, btScalar b, btScalar c)
165{
166 return a >= 0 ? b : c;
167}
168#endif
169#define btFsels(a,b,c) (btScalar)btFsel(a,b,c)
170*/
171
172#endif //SIMD___SCALAR_H