forked from juj/MathGeoLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMathGeoLibFwd.h
196 lines (155 loc) · 4.56 KB
/
MathGeoLibFwd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/* Copyright Jukka Jylänki
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
/** @file MathFwd.h
@author Jukka Jylänki
@brief */
#pragma once
#include "MathBuildConfig.h"
#include "Math/MathNamespace.h"
#include <stddef.h>
// Very annoying to have to do this, but <iosfwd> doesn't have a fwddecl for std::vector,
// and forward-declaring it manually is not allowed, see http://stackoverflow.com/questions/307343/forward-declare-an-stl-container
#include <vector>
// The CONST_WIN32 is a #define which resolves to 'const' on Windows, and null on other
// platforms. This #define is used on Windows to detect accidental programming errors
// occurring from an expression "const float3 vec; vec[1] = 5;". Trying to return
// const float from operator[] on GCC gives a warning "type qualifiers ignored on function return type",
// so hence this is only enabled on Visual Studio.
#ifdef _MSC_VER
#define CONST_WIN32 const
#else
#define CONST_WIN32
#endif
#ifdef _MSC_VER
#define NAMELESS_UNION_BEGIN \
__pragma(warning(push)) \
__pragma(warning(disable:4201))
#define NAMELESS_UNION_END \
__pragma(warning(pop))
#else
#define NAMELESS_UNION_BEGIN union {
#define NAMELESS_UNION_END };
#endif
#if !defined(MATH_ENABLE_STL_SUPPORT) && !defined(assert)
#include <stdio.h>
#define assert(x) do { if (!(x)) { printf("Error: assert(%s) failed!\n", #x); } } while(0)
#endif
MATH_BEGIN_NAMESPACE
class float2;
class float3;
class float4;
class float2x2;
class float2x3;
class float3x3;
class float3x4;
class float4x4;
class Quat;
class TranslateOp;
class ScaleOp;
template<int N>
class PBVolume;
class AABB;
class Capsule;
class Circle;
class Cone;
class Cylinder;
class Ellipsoid;
class Frustum;
struct HitInfo;
class Line;
class LineSegment;
class OBB;
class Plane;
class Polygon;
class Polyhedron;
class Polynomial;
class Quat;
class Ray;
class Sphere;
class TranslateOp;
class Torus;
class ScaleOp;
class Triangle;
class LCG;
struct float4_storage;
#define IS16ALIGNED(x) ((((uintptr_t)(x)) & 0xF) == 0)
#define IS32ALIGNED(x) ((((uintptr_t)(x)) & 0x1F) == 0)
#define IS64ALIGNED(x) ((((uintptr_t)(x)) & 0x3F) == 0)
#ifdef MATH_SIMD
#ifdef MATH_AVX
#define ALIGN_MAT ALIGN32
#define MAT_ALIGNMENT 32
#define IS_MAT_ALIGNED(x) IS32ALIGNED(x)
#else
#define ALIGN_MAT ALIGN16
#define MAT_ALIGNMENT 16
#define IS_MAT_ALIGNED(x) IS16ALIGNED(x)
#endif
#ifdef _MSC_VER
#define ALIGN16 __declspec(align(16))
#define ALIGN32 __declspec(align(32))
#define ALIGN64 __declspec(align(64))
#else
#define ALIGN16 __attribute__((aligned(16)))
#define ALIGN32 __attribute__((aligned(32)))
#define ALIGN64 __attribute__((aligned(64)))
#endif
#else
#define ALIGN16
#define ALIGN32
#define ALIGN64
#define ALIGN_MAT
#define IS_MAT_ALIGNED(x) true
#endif
#ifdef MATH_AUTOMATIC_SSE
#ifndef MATH_VEC_IS_FLOAT4
#define MATH_VEC_IS_FLOAT4
#endif
typedef ALIGN16 float4 vec;
typedef float4_storage vec_storage;
#else
typedef float3 vec;
typedef float3 vec_storage;
#endif
template<class T, size_t Alignment>
struct AlignedAllocator;
struct Triangle_storage;
struct LineSegment_storage;
// Visual Studio will not align data to 16 bytes inside a vector, so use a custom allocator to do it.
#if defined(_MSC_VER)
typedef std::vector<Triangle_storage, AlignedAllocator<Triangle_storage, 16> > TriangleArray;
typedef std::vector<LineSegment_storage, AlignedAllocator<LineSegment_storage, 16> > LineSegmentArray;
typedef std::vector<float4_storage, AlignedAllocator<float4_storage, 16> > Float4Array;
#ifdef MATH_AUTOMATIC_SSE
typedef std::vector<float4_storage, AlignedAllocator<float4_storage, 16> > VecArray;
#endif
#else
typedef std::vector<Triangle> TriangleArray;
typedef std::vector<LineSegment> LineSegmentArray;
typedef std::vector<float4> Float4Array;
#ifdef MATH_AUTOMATIC_SSE
typedef std::vector<float4> VecArray;
#endif
#endif
#if !defined(MATH_AUTOMATIC_SSE)
typedef std::vector<float3> VecArray;
#endif
MATH_END_NAMESPACE
#ifdef MATH_GRAPHICSENGINE_INTEROP
class VertexBuffer;
#endif
#ifdef MATH_ENABLE_STL_SUPPORT
#include <iosfwd>
#endif
#if defined(_M_X64) || defined(__x86_64__)
// Are we targeting a 64-bit build?
#define MATH_64BIT
#endif