summaryrefslogtreecommitdiff
path: root/thirdparty/thekla_atlas/nvmesh/geometry/Bounds.cpp
blob: 69fd1deb24f5dde9c1bde77773668e8c83418929 (plain)
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
// This code is in the public domain -- Ignacio Castaño <castano@gmail.com>

#include "nvmesh.h" // pch

#include "Bounds.h"

#include "nvmesh/BaseMesh.h"
#include "nvmesh/halfedge/Mesh.h"
#include "nvmesh/halfedge/Vertex.h"

#include "nvmath/Box.inl"

using namespace nv;

Box MeshBounds::box(const BaseMesh * mesh)
{
    nvCheck(mesh != NULL);

    Box bounds;
    bounds.clearBounds();

    const uint vertexCount = mesh->vertexCount();
    for (uint v = 0; v < vertexCount; v++)
    {
        const BaseMesh::Vertex & vertex = mesh->vertexAt(v);
        bounds.addPointToBounds( vertex.pos );
    }

    return bounds;
}

Box MeshBounds::box(const HalfEdge::Mesh * mesh)
{
    nvCheck(mesh != NULL);

    Box bounds;
    bounds.clearBounds();

    const uint vertexCount = mesh->vertexCount();
    for (uint v = 0; v < vertexCount; v++)
    {
        const HalfEdge::Vertex * vertex = mesh->vertexAt(v);
        nvDebugCheck(vertex != NULL);
        bounds.addPointToBounds( vertex->pos );
    }

    return bounds;
}

/*Sphere MeshBounds::sphere(const HalfEdge::Mesh * mesh)
{
    // @@ TODO
    return Sphere();
}*/