MeshLib C++ Docs
Loading...
Searching...
No Matches
MRAABBTreeSimd.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRBox.h"
4#include "MRPch/MRBindingMacros.h"
5#include <limits>
6
7namespace MR
8{
9
12
15struct MR_BIND_IGNORE AABBTreeSimdBoxes
16{
17 alignas( 16 ) float box[6][4];
18
19 AABBTreeSimdBoxes() = default;
20 explicit AABBTreeSimdBoxes( NoInit ) noexcept {}
21
23 [[nodiscard]] Box3f get( int i ) const { return { { box[0][i], box[1][i], box[2][i] }, { box[3][i], box[4][i], box[5][i] } }; }
24
26 void set( int i, const Box3f & b )
27 {
28 for ( int c = 0; c < 3; ++c )
29 {
30 box[c][i] = b.min[c];
31 box[c + 3][i] = b.max[c];
32 }
33 }
34
36 void setEmpty( int i )
37 {
38 constexpr float inf = std::numeric_limits<float>::infinity();
39 for ( int c = 0; c < 3; ++c )
40 {
41 box[c][i] = inf;
42 box[c + 3][i] = -inf;
43 }
44 }
45
47 [[nodiscard]] Box3f getUnion() const
48 {
49 Box3f res;
50 for ( int i = 0; i < 4; ++i )
51 res.include( get( i ) );
52 return res;
53 }
54};
55
58struct MR_BIND_IGNORE AABBTreeSimdNode : AABBTreeSimdBoxes
59{
61 int child[4];
62
63 AABBTreeSimdNode() = default;
64 explicit AABBTreeSimdNode( NoInit ) noexcept : AABBTreeSimdBoxes( noInit ) {}
65};
66
68
69}
constexpr NoInit noInit
Definition MRMeshFwd.h:103
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
void set(int i, const Box3f &b)
sets i-th box
Definition MRAABBTreeSimd.h:26
Box3f get(int i) const
returns i-th box
Definition MRAABBTreeSimd.h:23
AABBTreeSimdBoxes()=default
Box3f getUnion() const
returns the union of all four boxes (as Box3f::include of them in their order)
Definition MRAABBTreeSimd.h:47
float box[6][4]
Definition MRAABBTreeSimd.h:17
void setEmpty(int i)
makes i-th box empty
Definition MRAABBTreeSimd.h:36
AABBTreeSimdBoxes(NoInit) noexcept
Definition MRAABBTreeSimd.h:20
AABBTreeSimdNode()=default
AABBTreeSimdNode(NoInit) noexcept
Definition MRAABBTreeSimd.h:64
int child[4]
i-th child: the index in simdNodes() if > 0, otherwise ~(the index of the leaf); 0 in unused slots (t...
Definition MRAABBTreeSimd.h:61
Definition MRMeshFwd.h:102