Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*
   Copyright (c) 2018 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _CORE_MATH_BOUNDINGVOLUMES_BOUNDINGBOX_INL_
#define _CORE_MATH_BOUNDINGVOLUMES_BOUNDINGBOX_INL_

namespace Divide {

inline bool BoundingBox::containsPoint(const vec3<F32>& point) const {
    // const ReadLock r_lock(_lock);
    return (IS_GEQUAL(point.x, _min.x) && IS_GEQUAL(point.y, _min.y) && IS_GEQUAL(point.z, _min.z) &&
            IS_LEQUAL(point.x, _max.x) && IS_LEQUAL(point.y, _max.y) && IS_LEQUAL(point.z, _max.z));
}

inline bool BoundingBox::compare(const BoundingBox& bb) const  noexcept {
    /*ReadLock r_lock(_lock);*/
    return _min == bb._min &&
           _max == bb._max;
}

inline bool BoundingBox::operator==(const BoundingBox& B) const {
    return compare(B);
}

inline bool BoundingBox::operator!=(const BoundingBox& B) const {
    return !compare(B);
}

inline void BoundingBox::createFromPoints(const vectorImpl<vec3<F32>>& points) {
    for (const vec3<F32>& p : points) {
        add(p);
    }
}

inline void BoundingBox::createFromSphere(const vec3<F32>& center, F32 radius) {
    _max.set(center + radius);
    _min.set(center - radius);
}

inline void BoundingBox::add(const vec3<F32>& v) noexcept {
    // WriteLock w_lock(_lock);
    if (v.x > _max.x) {
        _max.x = v.x;
    }
    if (v.x < _min.x) {
        _min.x = v.x;
    }
    if (v.y > _max.y) {
        _max.y = v.y;
    }
    if (v.y < _min.y) {
        _min.y = v.y;
    }
    if (v.z > _max.z) {
        _max.z = v.z;
    }
    if (v.z < _min.z) {
        _min.z = v.z;
    }
};

inline void BoundingBox::add(const BoundingBox& bb) noexcept {
    // WriteLock w_lock(_lock);
    _max.set(std::max(bb._max.x, _max.x),
             std::max(bb._max.y, _max.y),
             std::max(bb._max.z, _max.z));

    _min.set(std::min(bb._min.x, _min.x),
             std::min(bb._min.y, _min.y),
             std::min(bb._min.z, _min.z));
}

inline void BoundingBox::translate(const vec3<F32>& v) noexcept {
    // WriteLock w_lock(_lock);
    _min += v;
    _max += v;
}

inline void BoundingBox::multiply(F32 factor) noexcept {
    // WriteLock w_lock(_lock);
    _min *= factor;
    _max *= factor;
}

inline void BoundingBox::multiply(const vec3<F32>& v) noexcept {
    // WriteLock w_lock(_lock);
    _min.x *= v.x;
    _min.y *= v.y;
    _min.z *= v.z;
    _max.x *= v.x;
    _max.y *= v.y;
    _max.z *= v.z;
}

inline void BoundingBox::multiplyMax(const vec3<F32>& v) noexcept {
    // WriteLock w_lock(_lock);
    _max.x *= v.x;
    _max.y *= v.y;
    _max.z *= v.z;
}

inline void BoundingBox::multiplyMin(const vec3<F32>& v) noexcept {
    // WriteLock w_lock(_lock);
    _min.x *= v.x;
    _min.y *= v.y;
    _min.z *= v.z;
}

inline const vec3<F32>& BoundingBox::getMin() const noexcept {
    /*ReadLock r_lock(_lock);*/
    return _min;
}

inline const vec3<F32>& BoundingBox::getMax() const noexcept {
    /*ReadLock r_lock(_lock);*/
    return _max;
}

inline vec3<F32> BoundingBox::getCenter() const noexcept {
    /*ReadLock r_lock(_lock);*/
    return (_max + _min) * 0.5f;
}

inline vec3<F32> BoundingBox::getExtent() const noexcept {
    /*ReadLock r_lock(_lock);*/
    return _max - _min;
}

inline vec3<F32> BoundingBox::getHalfExtent() const noexcept {
    /*ReadLock r_lock(_lock);*/
    return (_max - _min) * 0.5f;
}

inline F32 BoundingBox::getWidth() const noexcept {
    /*ReadLock r_lock(_lock);*/
    return _max.x - _min.x;
}

inline F32 BoundingBox::getHeight() const noexcept {
    /*ReadLock r_lock(_lock);*/
    return _max.y - _min.y;
}

inline F32 BoundingBox::getDepth() const noexcept {
    /*ReadLock r_lock(_lock);*/
    return _max.z - _min.z;
}

inline void BoundingBox::setMin(const vec3<F32>& min) noexcept {
    setMin(min.x, min.y, min.z);
}

inline void BoundingBox::setMax(const vec3<F32>& max) noexcept {
    setMax(max.x, max.y, max.z);
}

inline void BoundingBox::set(const BoundingBox& bb) noexcept {
    set(bb._min, bb._max); 
}

inline void BoundingBox::set(F32 min, F32 max) noexcept {
    _min.set(min);
    _max.set(max);
}

inline void BoundingBox::set(F32 minX, F32 minY, F32 minZ, F32 maxX, F32 maxY, F32 maxZ) noexcept {
    _min.set(minX, minY, minZ);
    _max.set(maxX, maxY, maxZ);
}

inline void BoundingBox::setMin(F32 min) noexcept {
    _min.set(min);
}

inline void BoundingBox::setMin(F32 minX, F32 minY, F32 minZ) noexcept {
    _min.set(minX, minY, minZ);
}

inline void BoundingBox::setMax(F32 max) noexcept {
    _max.set(max);
}

inline void BoundingBox::setMax(F32 maxX, F32 maxY, F32 maxZ) noexcept {
    _max.set(maxX, maxY, maxZ);
}

inline void BoundingBox::set(const vec3<F32>& min, const vec3<F32>& max) noexcept {
    /*WriteLock w_lock(_lock);*/
    _min = min;
    _max = max;
}

inline void BoundingBox::reset() noexcept {
    /*WriteLock w_lock(_lock);*/
    _min.set( std::numeric_limits<F32>::max());
    _max.set(-std::numeric_limits<F32>::max());
}

inline std::array<vec3<F32>, 8> BoundingBox::getPoints() const noexcept {
    return std::array<vec3<F32>, 8>
    {
        (_min.x, _min.y, _min.z),
        (_min.x, _min.y, _max.z),
        (_min.x, _max.y, _min.z),
        (_min.x, _max.y, _max.z),
        (_max.x, _min.y, _min.z),
        (_max.x, _min.y, _max.z),
        (_max.x, _max.y, _min.z),
        (_max.x, _max.y, _max.z)
    };
}

inline F32 BoundingBox::nearestDistanceFromPoint(const vec3<F32>& pos) const {
    return Divide::Sqrt(nearestDistanceFromPointSquared(pos));
}

inline vec3<F32> BoundingBox::getPVertex(const vec3<F32>& normal) const {
    return vec3<F32>(IS_GEQUAL(normal.x, 0.0f) ? _max.x : _min.x,
                     IS_GEQUAL(normal.y, 0.0f) ? _max.y : _min.y,
                     IS_GEQUAL(normal.z, 0.0f) ? _max.z : _min.z);
}

inline vec3<F32> BoundingBox::getNVertex(const vec3<F32>& normal) const {
    return vec3<F32>(IS_GEQUAL(normal.x, 0.0f) ? _min.x : _max.x,
                     IS_GEQUAL(normal.y, 0.0f) ? _min.y : _max.y,
                     IS_GEQUAL(normal.z, 0.0f) ? _min.z : _max.z);
}

};  // namespace Divide

#endif  //_CORE_MATH_BOUNDINGVOLUMES_BOUNDINGBOX_INL_

Commits for Divide-Framework/trunk/Source Code/Core/Math/BoundingVolumes/Headers/BoundingBox.inl

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

993 Diff Diff IonutCava picture IonutCava Sun 10 Dec, 2017 20:07:57 +0000

[Ionut]
- Finished initial port of the old scene graph system to the new ECS based system.
- Finished converting 2 components to the new ECS system: Transform and RigidBody
- Fixed the “Deploy” build error with the CEGUI OpenGL renderer.
- Compilation now needs C++14 support (it’s sufficiently wide-spread now)

865 Diff Diff IonutCava picture IonutCava Sun 19 Feb, 2017 21:08:03 +0000

[IonutCava]
- SSE2 optimizations for float variants of mat4 and vec4
- Small bug fixed in refraction and reflection texture debug views

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

648 Diff Diff IonutCava picture IonutCava Sun 21 Feb, 2016 16:32:52 +0000

[IonutCava]
- Update copyright notice
- Move BoundingBox and BoundingSphere to a new BoundsComponent
— Add a temp hack in SceneGraphNode to update these

646 Diff Diff IonutCava picture IonutCava Tue 16 Feb, 2016 16:33:15 +0000

[IonutCava]
- Improved frustum culling performance:
— Use p & n-vertex checks
— Pass max distance from RenderPassCuller
- Add GEQUAL / LEQUAL checks that work for F32 and D32 types

640 Diff Diff IonutCava picture IonutCava Tue 09 Feb, 2016 17:18:17 +0000

[IonutCava]
- More Octree updates
- Fixed bounding box collision check
- Added initial intersection code
- Added on-demand flush call for fence locking system

600 Diff Diff IonutCava picture IonutCava Tue 08 Dec, 2015 17:22:11 +0000

[IonutCava]
- Cleanup SceneGraphNode class
- Rework AABB calculation and update system and fix various AABB problems (e.g. light AABB, parent mesh AABB, etc)
- Create a list of closest shadow casting lights for faster shadow map generation
- Texture creation bug fixed (related to descriptor enum value)
- Better FPS and Frametime calculation system

548 Diff Diff IonutCava picture IonutCava Wed 04 Nov, 2015 17:23:15 +0000

[IonutCava]
- More work on improving cascaded shadow maps

543 IonutCava picture IonutCava Fri 30 Oct, 2015 17:18:18 +0000

[IonutCava]
- More profile guided optimizations
- Attempt to render all CSM splits in a single pass using geometry shader based instancing (unfinished)