Simulant
21.12-574
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
simulant
meshes
adjacency_info.h
1
#pragma once
2
3
#include <vector>
4
#include <functional>
5
#include "../math/vec3.h"
6
7
namespace
smlt
{
8
9
class
Mesh;
10
11
12
/*
13
* Describes an edge between two vertices that may be shared with up to 2 triangles.
14
*
15
* If an edge is shared by more than two triangles in a mesh then this struct will only
16
* store up to two, ignoring any others. The mesh would be weird if this was the case.
17
*/
18
struct
EdgeInfo
{
19
uint32_t indexes[2];
// The indexes that make this edge
20
uint32_t triangle_indexes[2];
// The indexes to additional vertices that make triangles
21
uint8_t triangle_count;
// Either 0, 1, 2
22
smlt::Vec3
normals[2];
// Triangle normals
23
};
24
25
class
AdjacencyInfo
{
26
public
:
27
AdjacencyInfo
(
Mesh
* mesh);
28
void
rebuild();
29
30
uint32_t edge_count()
const
{
return
edges_.size(); }
31
void
each_edge(
const
std::function<
void
(std::size_t,
const
EdgeInfo
&)> &cb);
32
private
:
33
Mesh
* mesh_ =
nullptr
;
34
std::vector<EdgeInfo> edges_;
35
36
};
37
38
}
smlt::Vec3
Definition:
vec3.h:23
smlt
Definition:
animation.cpp:25
smlt::Mesh
Definition:
mesh.h:127
smlt::AdjacencyInfo
Definition:
adjacency_info.h:25
smlt::EdgeInfo
Definition:
adjacency_info.h:18
Generated by
1.8.20