summaryrefslogtreecommitdiffstats
path: root/BSPTree.h
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-12-10 00:32:11 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-12-10 00:32:11 +0100
commit59b00645ccfbade509b1d1694c9fcfc68e013a10 (patch)
tree5df4d3b47810d2d95589f9e7c58653349578f195 /BSPTree.h
parent4731d3f4cf576d791db21ac1932fd91f9b43ff3a (diff)
downloadc3d-59b00645ccfbade509b1d1694c9fcfc68e013a10.tar
c3d-59b00645ccfbade509b1d1694c9fcfc68e013a10.zip
Zu vmmlib migriert
Diffstat (limited to 'BSPTree.h')
-rw-r--r--BSPTree.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/BSPTree.h b/BSPTree.h
index 78ec81f..4965318 100644
--- a/BSPTree.h
+++ b/BSPTree.h
@@ -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_ */