diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-12-10 09:43:46 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-12-10 09:43:46 +0100 |
commit | 4f2236f36446a5b097e28c0f76e4962ce7e115b1 (patch) | |
tree | 93c98d81a818844b16ae044aa9d309abd8d7c191 /BSPTree.h | |
parent | 1a321ed999334f0d9f5255249ebeeed0278871d6 (diff) | |
download | c3d-4f2236f36446a5b097e28c0f76e4962ce7e115b1.tar c3d-4f2236f36446a5b097e28c0f76e4962ce7e115b1.zip |
BSPTrees fertig
Diffstat (limited to 'BSPTree.h')
-rw-r--r-- | BSPTree.h | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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; |