diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-12-10 00:32:11 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-12-10 00:32:11 +0100 |
commit | 59b00645ccfbade509b1d1694c9fcfc68e013a10 (patch) | |
tree | 5df4d3b47810d2d95589f9e7c58653349578f195 /BSPTree.h | |
parent | 4731d3f4cf576d791db21ac1932fd91f9b43ff3a (diff) | |
download | c3d-59b00645ccfbade509b1d1694c9fcfc68e013a10.tar c3d-59b00645ccfbade509b1d1694c9fcfc68e013a10.zip |
Zu vmmlib migriert
Diffstat (limited to 'BSPTree.h')
-rw-r--r-- | BSPTree.h | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -4,24 +4,25 @@ #include "Triangle.h" #include <list> #include <cmath> +#include <vmmlib/vector.hpp> class BSPTree { private: class Plane { public: Plane() : d(0) {} - Plane(const Vector &n, float d0) : normal(n), d(d0) {} + Plane(const vmml::vec3f &n, float d0) : normal(n), d(d0) {} Plane(const Triangle &t) : normal(t.getNormal()), d(t.getVertex(0).dot(normal)) {} - bool contains(const Vertex &v) { + bool contains(const vmml::vec3f &v) { return (fabsf(normal.dot(v) - d) < 1E-6); } - bool isBehind(const Vertex &v) { + bool isBehind(const vmml::vec3f &v) { return (normal.dot(v) - d) < 0; } - bool isInFront(const Vertex &v) { + bool isInFront(const vmml::vec3f &v) { return (normal.dot(v) - d) > 0; } @@ -54,12 +55,12 @@ class BSPTree { } - const Vector& getNormal() { + const vmml::vec3f& getNormal() { return normal; } private: - Vector normal; + vmml::vec3f normal; float d; }; @@ -74,7 +75,7 @@ class BSPTree { } template<typename T> - void visit(const T& visitor, const Vector &v) { + void visit(const T& visitor, const vmml::vec3f &v) { if(plane.getNormal().dot(v) > 0) { if(frontTree) frontTree->visit(visitor, v); @@ -100,7 +101,7 @@ class BSPTree { } template<typename T> - void visit(T& visitor, const Vector &v) { + void visit(T& visitor, const vmml::vec3f &v) { if(plane.getNormal().dot(v) > 0) { if(frontTree) frontTree->visit(visitor, v); @@ -130,8 +131,8 @@ class BSPTree { std::list<Triangle> triangles; BSPTree *frontTree, *backTree; - static Vertex findCenter(const std::list<Triangle> &triangles); - static const Triangle* findNearestTriangle(const std::list<Triangle> &triangles, const Vertex &v); + static vmml::vec3f findCenter(const std::list<Triangle> &triangles); + static const Triangle* findNearestTriangle(const std::list<Triangle> &triangles, const vmml::vec3f &v); }; #endif /* _BSPTREE_H_ */ |