From 4f2236f36446a5b097e28c0f76e4962ce7e115b1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 10 Dec 2009 09:43:46 +0100 Subject: BSPTrees fertig --- BSPTree.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'BSPTree.h') 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 *front, std::list *back) const; + private: vmml::vec3f normal; float d; -- cgit v1.2.3