-
Notifications
You must be signed in to change notification settings - Fork 4
/
mantis.h
66 lines (46 loc) · 1.85 KB
/
mantis.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
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include <array>
namespace mantis {
enum PrimitiveType {
Vertex = 0,
Edge = 1,
Face = 2
};
struct Result {
float distance_squared = -1.f;
int primitive_index = 0;
float closest_point[3] = {};
PrimitiveType type{};
};
struct Impl;
struct AccelerationStructure {
AccelerationStructure(const float *points, size_t num_points, const uint32_t *indices, size_t num_faces,
float limit_cube_len = 1e3f);
AccelerationStructure(const std::vector<std::array<float, 3>>& points, const std::vector<std::array<uint32_t, 3>>& triangles, float limit_cube_len = 1e3f);
// no copying
AccelerationStructure(const AccelerationStructure&) = delete;
AccelerationStructure& operator=(const AccelerationStructure&) = delete;
AccelerationStructure(AccelerationStructure&&) noexcept;
AccelerationStructure& operator=(AccelerationStructure&&) noexcept;
Result calc_closest_point(float x, float y, float z) const;
Result calc_closest_point(std::array<float, 3> q) const;
size_t num_edges() const;
size_t num_faces() const;
size_t num_vertices() const;
// For each face returns the indices of the three edges bordering
// the face
std::vector<std::array<uint32_t, 3>> get_face_edges() const;
// For each edge returns the indices of the two vertices that make up the edge
std::vector<std::pair<uint32_t, uint32_t>> get_edge_vertices() const;
// For each face returns the indices of the three vertices that make up the face
std::vector<std::array<uint32_t, 3>> get_faces() const;
// Returns the positions of the vertices
std::vector<std::array<float, 3>> get_positions() const;
std::pair<uint32_t, uint32_t> get_edge(size_t index) const;
~AccelerationStructure();
Impl *impl = nullptr;
};
}