summaryrefslogtreecommitdiffstats
path: root/BSPTree.h
diff options
context:
space:
mode:
Diffstat (limited to 'BSPTree.h')
-rw-r--r--BSPTree.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/BSPTree.h b/BSPTree.h
index 4965318..a03327b 100644
--- a/BSPTree.h
+++ b/BSPTree.h
@@ -14,20 +14,20 @@ class BSPTree {
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 vmml::vec3f &v) {
+ bool contains(const vmml::vec3f &v) const {
return (fabsf(normal.dot(v) - d) < 1E-6);
}
- bool isBehind(const vmml::vec3f &v) {
+ bool isBehind(const vmml::vec3f &v) const {
return (normal.dot(v) - d) < 0;
}
- bool isInFront(const vmml::vec3f &v) {
+ bool isInFront(const vmml::vec3f &v) const {
return (normal.dot(v) - d) > 0;
}
- bool contains(const Triangle &t) {
+ bool contains(const Triangle &t) const {
for(int i = 0; i < 3; ++i) {
if(!contains(t.getVertex(i)))
return false;
@@ -36,7 +36,7 @@ class BSPTree {
return true;
}
- bool isBehind(const Triangle &t) {
+ bool isBehind(const Triangle &t) const {
for(int i = 0; i < 3; ++i) {
if(!isBehind(t.getVertex(i)) && !contains(t.getVertex(i)))
return false;
@@ -45,7 +45,7 @@ class BSPTree {
return true;
}
- bool isInFront(const Triangle &t) {
+ bool isInFront(const Triangle &t) const {
for(int i = 0; i < 3; ++i) {
if(!isInFront(t.getVertex(i)) && !contains(t.getVertex(i)))
return false;
@@ -55,10 +55,13 @@ class BSPTree {
}
- const vmml::vec3f& getNormal() {
+ const vmml::vec3f& getNormal() const {
return normal;
}
+ vmml::vec3f intersection(const vmml::vec3f &p, const vmml::vec3f &dir) const;
+ void partition(const Triangle &t, std::list<Triangle> *front, std::list<Triangle> *back) const;
+
private:
vmml::vec3f normal;
float d;