-
Notifications
You must be signed in to change notification settings - Fork 3
/
mesh.cpp
48 lines (41 loc) · 889 Bytes
/
mesh.cpp
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
#include <QFile>
#include <QDataStream>
#include <QVector3D>
#include <cmath>
#include "mesh.h"
////////////////////////////////////////////////////////////////////////////////
Mesh::Mesh(std::vector<GLfloat>&& v, std::vector<GLuint>&& i)
: vertices(std::move(v)), indices(std::move(i))
{
// Nothing to do here
}
float Mesh::min(size_t start) const
{
if (start >= vertices.size())
{
return -1;
}
float v = vertices[start];
for (size_t i=start; i < vertices.size(); i += 3)
{
v = fmin(v, vertices[i]);
}
return v;
}
float Mesh::max(size_t start) const
{
if (start >= vertices.size())
{
return 1;
}
float v = vertices[start];
for (size_t i=start; i < vertices.size(); i += 3)
{
v = fmax(v, vertices[i]);
}
return v;
}
bool Mesh::empty() const
{
return vertices.size() == 0;
}