]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
moved Overlap to own file
authorPeter Schaefer <schaeferpm@gmail.com>
Mon, 11 May 2015 18:22:21 +0000 (20:22 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Mon, 11 May 2015 18:22:21 +0000 (20:22 +0200)
new BBoxTree
moved GLM out of Graphix

38 files changed:
Weave/BBoxTree.cpp [new file with mode: 0644]
Weave/BBoxTree.h [new file with mode: 0644]
Weave/Events.cpp
Weave/GLM.cpp [new file with mode: 0644]
Weave/GLM.h [new file with mode: 0644]
Weave/Game.cpp
Weave/Graphix/GLM.cpp [deleted file]
Weave/Graphix/GLM.h [deleted file]
Weave/Graphix/Graphix.cpp
Weave/Graphix/Graphix.h
Weave/Graphix/Model/BBox.cpp
Weave/Graphix/Model/BBox.h
Weave/Graphix/Model/IMesh.cpp
Weave/Graphix/Model/IMesh.h
Weave/Graphix/Model/IMetaMesh.cpp
Weave/Graphix/Model/IMetaMesh.h
Weave/Graphix/Model/Model.cpp
Weave/Graphix/Model/Model.h
Weave/Graphix/Model/SkyBox.cpp
Weave/Graphix/Model/SkyBox.h
Weave/Graphix/Texture.cpp
Weave/Graphix/Texture.h
Weave/Graphix/ViewPort.cpp
Weave/Graphix/ViewPort.h
Weave/Overlap.cpp [new file with mode: 0644]
Weave/Overlap.h [new file with mode: 0644]
Weave/Scene/EventBox.cpp
Weave/Scene/EventBox.h
Weave/Scene/Marvin.cpp
Weave/Scene/Marvin.h
Weave/Scene/Scene.cpp
Weave/Scene/Scene.h
Weave/Scene/SceneObject.cpp
Weave/Scene/SceneObject.h
Weave/Scene/Sky.cpp
Weave/Scene/Sky.h
Weave/Weave.vcxproj
Weave/Weave.vcxproj.filters

diff --git a/Weave/BBoxTree.cpp b/Weave/BBoxTree.cpp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Weave/BBoxTree.h b/Weave/BBoxTree.h
new file mode 100644 (file)
index 0000000..e69de29
index 6c31b0e20da9ffe1e6865ac10f3bea73bec84755..dae30aa5ca34027ffe36b7efc833121487ffd943 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "Graphix\Graphix.h"
 
-#include "Graphix\GLM.h"
+#include "GLM.h"
 
 #include <iostream>
 using std::cout;
diff --git a/Weave/GLM.cpp b/Weave/GLM.cpp
new file mode 100644 (file)
index 0000000..b405afd
--- /dev/null
@@ -0,0 +1,34 @@
+#include "GLM.h"
+
+float VektorAbs(const vec3& vek)
+{
+       return sqrt(vek.x*vek.x + vek.y*vek.y + vek.z*vek.z);
+}
+
+
+mat4 removeScale(const mat4& matrix)
+{
+       mat3 scalingM = transpose((mat3)matrix) * (mat3)matrix;
+
+       vec3 scalingV;
+       for (int i = 0; i < 3; ++i)
+               scalingV[i] = 1.f / sqrt(scalingM[i][i]);
+
+       return matrix * scale(scalingV);
+}
+
+vec3 getScale(const mat4& matrix)
+{
+       mat3 scalingM = transpose((mat3)matrix) * (mat3)matrix;
+
+       vec3 scalingV;
+       for (int i = 0; i < 3; ++i)
+               scalingV[i] =  sqrt(scalingM[i][i]);
+
+       return scalingV;
+}
+
+vec3 orthoVec(const vec3& _direction, const vec3& _vec)
+{
+       return normalize(_vec + _direction * dot(_direction, _vec));
+}
\ No newline at end of file
diff --git a/Weave/GLM.h b/Weave/GLM.h
new file mode 100644 (file)
index 0000000..b70bbd2
--- /dev/null
@@ -0,0 +1,48 @@
+#pragma once
+
+#include "glm\glm.hpp"
+#include "glm\gtx\transform.hpp"
+#include "glm\gtc\type_ptr.hpp"
+#include "glm\gtx\rotate_vector.hpp"
+#include "glm\gtx\vector_angle.hpp"
+
+using glm::mat3;
+using glm::vec3;
+using glm::mat4;
+using glm::vec4;
+
+using glm::translate;
+using glm::rotate;
+//using glm::scale;
+using glm::determinant;
+using glm::perspective;
+using glm::normalize;
+using glm::inverse;
+using glm::transpose;
+using glm::dot;
+using glm::cross;
+
+using glm::angle;
+using glm::orientedAngle;
+
+using glm::value_ptr;
+
+using glm::sign;
+using glm::min;
+using glm::max;
+
+#define M_PI        3.14159265358979323846264338327950288   /* pi */
+#define M_PI_2      1.57079632679489661923132169163975144   /* pi/2 */
+#define M_PI_4      0.785398163397448309615660845819875721  /* pi/4 */
+#define M_1_PI      0.318309886183790671537767526745028724  /* 1/pi */
+#define M_2_PI      0.636619772367581343075535053490057448  /* 2/pi */
+#define M_D_R       57.2957795131                                                      /* 180/pi */
+
+__declspec(deprecated)
+float VektorAbs(const vec3& vek);
+
+mat4 removeScale(const mat4& matrix);
+vec3 getScale(const mat4& matrix);
+
+vec3 orthoVec(const vec3& direction, const vec3& vec);
+
index badaf127711aac8bf6118b7d968f361a67a35cc8..f3bee9b39ff0239fd1580421232735891e6de914 100644 (file)
@@ -2,7 +2,7 @@
 
 #include <string>
 
-#include "Graphix\GLM.h"
+#include "GLM.h"
 #include <Windows.h>
 
 #include <assimp/Importer.hpp>
diff --git a/Weave/Graphix/GLM.cpp b/Weave/Graphix/GLM.cpp
deleted file mode 100644 (file)
index b405afd..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "GLM.h"
-
-float VektorAbs(const vec3& vek)
-{
-       return sqrt(vek.x*vek.x + vek.y*vek.y + vek.z*vek.z);
-}
-
-
-mat4 removeScale(const mat4& matrix)
-{
-       mat3 scalingM = transpose((mat3)matrix) * (mat3)matrix;
-
-       vec3 scalingV;
-       for (int i = 0; i < 3; ++i)
-               scalingV[i] = 1.f / sqrt(scalingM[i][i]);
-
-       return matrix * scale(scalingV);
-}
-
-vec3 getScale(const mat4& matrix)
-{
-       mat3 scalingM = transpose((mat3)matrix) * (mat3)matrix;
-
-       vec3 scalingV;
-       for (int i = 0; i < 3; ++i)
-               scalingV[i] =  sqrt(scalingM[i][i]);
-
-       return scalingV;
-}
-
-vec3 orthoVec(const vec3& _direction, const vec3& _vec)
-{
-       return normalize(_vec + _direction * dot(_direction, _vec));
-}
\ No newline at end of file
diff --git a/Weave/Graphix/GLM.h b/Weave/Graphix/GLM.h
deleted file mode 100644 (file)
index b70bbd2..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#pragma once
-
-#include "glm\glm.hpp"
-#include "glm\gtx\transform.hpp"
-#include "glm\gtc\type_ptr.hpp"
-#include "glm\gtx\rotate_vector.hpp"
-#include "glm\gtx\vector_angle.hpp"
-
-using glm::mat3;
-using glm::vec3;
-using glm::mat4;
-using glm::vec4;
-
-using glm::translate;
-using glm::rotate;
-//using glm::scale;
-using glm::determinant;
-using glm::perspective;
-using glm::normalize;
-using glm::inverse;
-using glm::transpose;
-using glm::dot;
-using glm::cross;
-
-using glm::angle;
-using glm::orientedAngle;
-
-using glm::value_ptr;
-
-using glm::sign;
-using glm::min;
-using glm::max;
-
-#define M_PI        3.14159265358979323846264338327950288   /* pi */
-#define M_PI_2      1.57079632679489661923132169163975144   /* pi/2 */
-#define M_PI_4      0.785398163397448309615660845819875721  /* pi/4 */
-#define M_1_PI      0.318309886183790671537767526745028724  /* 1/pi */
-#define M_2_PI      0.636619772367581343075535053490057448  /* 2/pi */
-#define M_D_R       57.2957795131                                                      /* 180/pi */
-
-__declspec(deprecated)
-float VektorAbs(const vec3& vek);
-
-mat4 removeScale(const mat4& matrix);
-vec3 getScale(const mat4& matrix);
-
-vec3 orthoVec(const vec3& direction, const vec3& vec);
-
index f6dfb75d05ed5fd95437abacec76bf4af5e70fbb..ba41cebc02eb19dfe14c82a9bf5c0c0f3252e68d 100644 (file)
@@ -6,7 +6,6 @@
 
 using std::string;
 
-
 void Graphix::setWindowSize(unsigned int _width, unsigned int _height)
 {
        width = _width;
index 7a9f23b47baf0eb83be0eeca8049f7f67f088a16..d45b642bb33f9a10ad7b013d5d155355bcf3a343 100644 (file)
@@ -1,15 +1,10 @@
 #pragma once
 
-#include <string>
 #include <SDL2\SDL.h>
 #include <GL\glew.h>
-//#include <unordered_map>
 
-//#include "Drawable.h"
-//#include "Scene.h"
+#include <string>
 
-using std::string;
-//using std::unordered_map;
 
 class Shader;
 
@@ -41,7 +36,7 @@ private:
        static unsigned int xpos;
        static unsigned int ypos;
 
-       static string windowTitle;
+       static std::string windowTitle;
 
        static Uint32 windowFlags;
        static Uint32 sdlFlags;
index 70a74781fc88b0140407254f6c607d80891f5fab..7ec7e53577e59c28c753daa9abad6b5b41e3c1b0 100644 (file)
@@ -1,5 +1,7 @@
 #include "BBox.h"
+
 #include "GL\glew.h"
+#include "../../GLM.h"
 
 
 BBox::BBox()
index 35f8d92da8b0d9d1ac4e62174bff771ebe074c95..a9a7c5cfb81a617a3de1464b2624018795e64d1f 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
+
 #include "Model.h"
+
 class BBox :
        public Model
 {
index bb20144f92422956dba7d06422496fdd56e1d310..6445c7777159972603088f213ffeb1d7d4703f4e 100644 (file)
@@ -5,6 +5,8 @@
 #include <assimp/scene.h>
 #include <assimp/postprocess.h>
 
+#include "../../GLM.h"
+
 #include "../Shader.h"
 #include "../Texture.h"
 #include "../../Message.h"
@@ -147,7 +149,21 @@ Overlap IMesh::checkColS2O(const mat4& _mMat, const Model* _model, const mat4& _
                return firstBB;
 
        //Inner Mesh
-
+       //call _model->checkColO2STriangle
+       //vec3 pos;
+       //mat3 direction;
+       //Overlap secondT,tmp;
+       //for (uint i = 0; i < numfaces; ++i)
+       //{
+       //      pos = vec3(vertex[3 * index[3 * i]], vertex[3 * index[3 * i] + 1], vertex[3 * index[3 * i] + 2]);
+       //      direction[1] = vec3(vertex[3 * index[3 * i + 1]], vertex[3 * index[3 * i + 1] + 1], vertex[3 * index[3 * i + 1] + 2]) - pos;
+       //      direction[2] = vec3(vertex[3 * index[3 * i + 2]], vertex[3 * index[3 * i + 2] + 1], vertex[3 * index[3 * i + 2] + 2]) - pos;
+       //      direction[0] = normalize(cross(direction[1], direction[2]));
+       //      tmp = _model->checkColO2STriangle(_modelMat, pos, direction);
+       //      if (tmp)
+       //              secondT.update(tmp);
+ //    }
+       //return secondT;
 }
 
 Overlap IMesh::checkColO2SBox(const mat4& _mMat, const vec3& _pos, const vec3& _size, const mat4& _modelMat) const
@@ -158,9 +174,20 @@ Overlap IMesh::checkColO2SBox(const mat4& _mMat, const vec3& _pos, const vec3& _
                return firstBB;
 
        //Inner Mesh
+       //call checkColO2STriangle
 
 }
 
+Overlap IMesh::checkColO2STriangle(const mat4& _mMat, const vec3& _posB, const mat3& _directionsB) const
+{
+       Overlap firstBB = Model::checkColO2STriangle(_mMat, _posB, _directionsB);
+       //if (!firstBB)
+               return firstBB;
+
+       //Inner Mesh
+               
+}
+
 IMesh::operator string() const
 {
        return "IMesh";
index 155b867474643eec99adad96fe1623084f0d9935..d04f166eb3a5450385161ab30ead469da88a5653 100644 (file)
@@ -1,7 +1,8 @@
 #pragma once
 
 #include <string>
-#include "../GLM.h"
+#include "../../GLM.h"
+#include "../../Overlap.h"
 
 #include "Model.h"
 
@@ -25,6 +26,7 @@ public:
 
        Overlap checkColS2O(const mat4& mMat, const Model* model, const mat4& modelMat) const override;
        Overlap checkColO2SBox(const mat4& mMat, const vec3& pos, const vec3& size, const mat4& modelMat) const override;
+       Overlap checkColO2STriangle(const mat4& mMat, const vec3& pos, const mat3& directions) const override;
 
        operator std::string() const override;
 
index 052b1b438bf3905c5808dcbb1792e54f1c1405bd..7e7f14b4200b9a1b022280dabacc6a909241b535 100644 (file)
@@ -4,6 +4,8 @@
 #include <assimp/scene.h>
 #include <assimp/postprocess.h>
 
+#include "../../GLM.h"
+
 #include "IMesh.h"
 #include "../Shader.h"
 #include "../../Message.h"
index 8cedb2508af0495bfdda917f3fb0e9ddcb6ad8e8..ac9987b3128fe25f337783eac7698ff43d39ed37 100644 (file)
@@ -4,7 +4,8 @@
 
 #include <string>
 #include <list>
-#include "../GLM.h"
+#include "../../GLM.h"
+#include "../../Overlap.h"
 
 class IMesh;
 class Shader;
index b4473074c8916465bdc147828b8b6ac1d7709740..412bbc082909941939924bbecc3e9f6e47f5e017 100644 (file)
@@ -290,7 +290,7 @@ Overlap Model::checkColS2O(const mat4& _mMat, const Model* _model, const mat4& _
        return stepBB;
 }
 
-Overlap Model::checkColO2SBox(const mat4& _mMat, const vec3& _posB, const vec3& _sizeB, const mat4& _modelMat) const
+Overlap Model::checkColO2SBox(const mat4& _mMat, const vec3& _posB, const vec3& _sizeB, const mat4& _modelMatB) const
 {
        vec3 scale = getScale(_mMat);
        vec3 posA = BBposition;
@@ -300,8 +300,8 @@ Overlap Model::checkColO2SBox(const mat4& _mMat, const vec3& _posB, const vec3&
 
        mat4 mMat = removeScale(_mMat);
 
-       mat4 modelAR = glm::inverse(_modelMat)*mMat;
-       mat4 modelBR = glm::inverse(mMat)*_modelMat;
+       mat4 modelAR = glm::inverse(_modelMatB)*mMat;
+       mat4 modelBR = glm::inverse(mMat)*_modelMatB;
 
        vec3 posAR = (vec3)(modelAR*vec4(posA, 1.f));
        vec3 posBR = (vec3)(modelBR*vec4(_posB, 1.f));
@@ -321,21 +321,82 @@ Overlap Model::checkColO2SBox(const mat4& _mMat, const vec3& _posB, const vec3&
        return ret;
 }
 
-void Model::checkCollideByAxis(float& _overlap, float& _inside, uint dim, const float* posA, const float* posB, const float* sizeA,const float* sizeB)
+Overlap Model::checkColO2STriangle(const mat4& _mMat, const vec3& _posB, const mat3& _directionsB) const
 {
-       _overlap = INFINITY;
-       _inside = INFINITY;
+
+       vec3 posA = BBposition;
+       vec3 sizeA = BBsize;
+
+       vec3 scale = getScale(_mMat);
+       scaleVec3(posA, scale);
+       scaleVec3(sizeA, scale);
+
+       mat4 invmMat = glm::inverse(removeScale(_mMat));
+
+       vec3 posBR = (vec3)(invmMat*vec4(_posB, 1.f));
+       mat3 directionsBR = (mat3)invmMat*_directionsB;
+
+
+       //Triangle Face Distance
+       float nDist = (posA-posBR).length();
+       float nSize = directSize(sizeA,_directionsB[0]);
+       float overlap = nSize - nDist;
+       Overlap ret(overlap,overlap);
+       if (!ret)
+               return ret;
+
+
+       //Box to Triangle Distance
+       vec3 sizeBRP(0.f), sizeBRM(0.f);
+       for (int i = 0; i < 3; ++i)
+       {
+               sizeBRP[i] = max(-directionsBR[i][1],-directionsBR[i][2]);
+               sizeBRM[i] = max(directionsBR[i][1], directionsBR[i][2]);
+               if (sizeBRP[i] < 0)
+                       sizeBRP[i] = 0;
+               if (sizeBRM[i] < 0)
+                       sizeBRM[i] = 0;
+       }
+       overlap = sizeBRM[0] + sizeA[0] + sizeBRP[0];
+       for (int i = 0; i < 3; ++i)
+       {
+               if (posBR[i]>=0)
+               {
+                       overlap = min(sizeBRP[i] + sizeA[i] - posBR[i],overlap);
+               }
+               else
+               {
+                       overlap = min(sizeBRM[i] + sizeA[i] + posBR[i],overlap);
+               }
+               if (overlap < 0)
+               {
+                       overlap = -1;
+                       break;
+               }
+       }
+
+       return Overlap(overlap, overlap);
+
+}
+
+void Model::checkCollideByAxis(float& _overlap, float& _inside, uint dim, const float* posA, const float* posB, const float* sizeA, const float* sizeB)
+{
+       _overlap = sizeA[0] + sizeB[0];
+       _inside = sizeA[0] + sizeB[0];
        for (uint i = 0; i < dim; ++i)
        {
+
                _overlap = min(sizeA[i] + sizeB[i] - abs(posA[i] - posB[i]), _overlap);
-               if (_inside >= 0)
-                       _inside = min(abs(sizeA[i] - sizeB[i]) - abs(posA[i] - posB[i]), _inside);
+
                if (_overlap < 0)
                {
                        _overlap = -1;
                        _inside = -1;
                        return;
-               }
+               }       
+               if (_inside >= 0)
+                       _inside = min(abs(sizeA[i] - sizeB[i]) - abs(posA[i] - posB[i]), _inside);
+
        }
        if (_inside < 0)
                _inside = -1;
@@ -355,6 +416,16 @@ vec3 Model::rotateSize(const vec3& _size, const mat4& _modelMat)
        return Size;
 }
 
+float Model::directSize(const vec3& _size, const vec3& _direction)
+{
+       float ret(0.f);
+       for (auto i = 0; i < 3; ++i)
+       {
+               ret += abs(_size[i]*_direction[i]);
+       }
+       return ret;
+}
+
 void Model::scaleVec3(vec3& _vec, const vec3& _scale)
 {
        for (uint i = 0; i < 3; ++i)
@@ -423,7 +494,7 @@ void Model::deleteIMetaModel(const string& _modelpath)
                delete ptr;
                ptr = nullptr;
        }
-               
+
 
 }
 
@@ -437,7 +508,7 @@ float Model::getPDistHit(const vec3& _P, const vec3& _direction) const
        //vec3 posAR = (vec3)(modelAR*vec4(posA, 1.f));
        //vec3 posBR = (vec3)(modelBR*vec4(posB, 1.f));
 
-       
+
        return 1;
 }
 
@@ -445,87 +516,3 @@ Model* Model::BoundingBox = nullptr;
 Model* Model::SkyBoxModel = nullptr;
 std::unordered_map<string, Model*> Model::IMetaModel;
 std::unordered_map<string, uint> Model::IMetaModel_count;
-
-
-
-Overlap::Overlap() : unset(true)
-{
-}
-
-Overlap::Overlap(float _over, float _in) : in(_in), over(_over), unset(false)
-{
-}
-
-Overlap::~Overlap()
-{
-}
-
-float Overlap::overlap() const
-{
-       if (unset)
-               return -1;
-       else
-               return over;
-}
-
-float Overlap::inside() const
-{
-       if (unset)
-               return -1;
-       else
-               return in;
-}
-
-Overlap::operator bool() const
-{
-       if (unset)
-               return false;
-       else
-               return over>=0;
-}
-
-void Overlap::update(float _over, float _in)
-{
-       if (unset)
-       {
-               over = _over;
-               in = _in;
-               unset = true;
-               return;
-       }
-
-       // select closest distance
-       if (over > _over)
-       {
-               over = _over;
-       }
-
-       //sync inside
-       in = min(in, _in);
-}
-
-void Overlap::update(const Overlap& _other)
-{
-       if (unset)
-       {
-               *this = _other;
-               return;
-       }
-
-       // select closest distance
-       if (over > _other.over)
-       {
-               over = _other.over;
-       }
-
-       //sync inside
-       in = min(in, _other.in);
-}
-
-Overlap Overlap::merge(const Overlap& _first, const Overlap& _second)
-{
-       // select closest distance
-       Overlap ret = _first;
-       ret.update(_second);
-       return ret;
-}
\ No newline at end of file
index 02b207656223c82ad1e43774674a5ffc4db6b69c..b7f2cdce3cfd5278ae40b02569abfc28b64f6528 100644 (file)
@@ -1,9 +1,11 @@
 #pragma once
 
-#include "../GLM.h"
+#include "../../GLM.h"
 #include <unordered_map>
 #include <string>
 
+#include "../../Overlap.h"
+
 class Shader;
 class Texture;
 class Overlap;
@@ -35,7 +37,7 @@ public:
        /* test self against other*/
        virtual Overlap checkColS2O(const mat4& mMat, const Model* model, const mat4& modelMat) const;
        virtual Overlap checkColO2SBox(const mat4& mMat, const vec3& pos, const vec3& size, const mat4& modelMat) const;
-       //virtual void checkColO2STriangle() const;
+       virtual Overlap checkColO2STriangle(const mat4& mMat, const vec3& pos, const mat3& directions) const;
 
        static Model* getBBoxModel();
        static Model* getSkyBoxModel();
@@ -75,37 +77,14 @@ protected:
        static std::unordered_map<std::string, Model*> IMetaModel;
        static std::unordered_map<std::string, uint> IMetaModel_count;
 
-       static vec3 rotateSize(const vec3& size, const mat4& modelMat);
+       
        static void checkCollideByAxis(float& overlap, float& inside, uint dim, const float* posA, const float* posB, const float* sizeA, const float* sizeB);
        static void scaleVec3(vec3& vec, const vec3& scale);
+       static vec3 rotateSize(const vec3& size, const mat4& modelMat);
+       static float directSize(const vec3& size, const vec3& direction);
 
 private:
        vec3 BBmin, BBmax;
        vec3 BBsize, BBposition;
 
-};
-
-class Overlap
-{
-public:
-       Overlap();
-       Overlap(float over, float in);
-       ~Overlap();
-
-       float overlap() const;
-       float inside() const;
-
-       operator bool() const;
-
-       static Overlap merge(const Overlap& first, const Overlap& second);
-       void update(float over, float in);
-       void update(const Overlap& other);
-
-protected:
-       bool unset;
-       float over;
-       float in;
-
-       vec3 center;
-       vec3 normal;
 };
\ No newline at end of file
index c91970ca18ffbc2700cfd72f1cba4abbc394deff..ab1a57d0198cd1cd9ac62308d95fdf4d5af44a9d 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "GL/glew.h"
 #include "../Graphix.h"
+#include "../../GLM.h"
 
 
 SkyBox::SkyBox()
index 1b56702e530112f1e242b039c18a8e8620c4b97f..0941718fe456cd5a8fd63a5737b96d4c4dce0e33 100644 (file)
@@ -1,6 +1,7 @@
 #pragma once
 
 #include "Model.h"
+#include "../../GLM.h"
 
 class SkyBox :
        public Model
index 23e37824a2bdcb3036c3dde78a3ab3332cac3cbd..2793649e312b35368df5421df7da9a57aa5b3c19 100644 (file)
@@ -2,7 +2,7 @@
 #include <GL\glew.h>
 #include "FreeImage.h"
 #include <iostream>
-#include "GLM.h"
+#include "../GLM.h"
 
 #include "../Message.h"
 #include "Graphix.h"
index f0eaa10d91588671c8edf9df1fd53f0d7ccab5f9..d8847131417372d44a45127cdcefeb24d80c466b 100644 (file)
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "GLM.h"
+#include "../GLM.h"
 
 #include <string>
 #include <unordered_map>
index c9ce4a73523b75bb7f30c589f478bd274edba954..904f4bb5df304f8cf198be336759ac11b5f67bc7 100644 (file)
@@ -1,7 +1,7 @@
 #include "ViewPort.h"
 
 #include <GL\glew.h>
-#include "GLM.h"
+#include "../GLM.h"
 
 #include "Shader.h"
 
index fdb0a4ecea16c1c31d7291c5385dfac40a4e577e..a4c28f47ea3cf263acd59e812f2065c9f1490665 100644 (file)
@@ -1,7 +1,7 @@
 #pragma once
 
 //#include "Drawable.h"
-#include "GLM.h"
+#include "../GLM.h"
 
 class Shader;
 
diff --git a/Weave/Overlap.cpp b/Weave/Overlap.cpp
new file mode 100644 (file)
index 0000000..4c4f772
--- /dev/null
@@ -0,0 +1,84 @@
+
+#include "Overlap.h"
+
+Overlap::Overlap() : unset(true)
+{
+}
+
+Overlap::Overlap(float _over, float _in) : in(_in), over(_over), unset(false)
+{
+}
+
+Overlap::~Overlap()
+{
+}
+
+float Overlap::overlap() const
+{
+       if (unset)
+               return -1;
+       else
+               return over;
+}
+
+float Overlap::inside() const
+{
+       if (unset)
+               return -1;
+       else
+               return in;
+}
+
+Overlap::operator bool() const
+{
+       if (unset)
+               return false;
+       else
+               return over >= 0;
+}
+
+void Overlap::update(float _over, float _in)
+{
+       if (unset)
+       {
+               over = _over;
+               in = _in;
+               unset = true;
+               return;
+       }
+
+       // select closest distance
+       if (over > _over)
+       {
+               over = _over;
+       }
+
+       //sync inside
+       in = min(in, _in);
+}
+
+void Overlap::update(const Overlap& _other)
+{
+       if (unset)
+       {
+               *this = _other;
+               return;
+       }
+
+       // select closest distance
+       if (over > _other.over)
+       {
+               over = _other.over;
+       }
+
+       //sync inside
+       in = min(in, _other.in);
+}
+
+Overlap Overlap::merge(const Overlap& _first, const Overlap& _second)
+{
+       // select closest distance
+       Overlap ret = _first;
+       ret.update(_second);
+       return ret;
+}
\ No newline at end of file
diff --git a/Weave/Overlap.h b/Weave/Overlap.h
new file mode 100644 (file)
index 0000000..079e7e9
--- /dev/null
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "GLM.h"
+
+class Overlap
+{
+public:
+       Overlap();
+       Overlap(float over, float in);
+       ~Overlap();
+
+       float overlap() const;
+       float inside() const;
+
+       operator bool() const;
+
+       static Overlap merge(const Overlap& first, const Overlap& second);
+       void update(float over, float in);
+       void update(const Overlap& other);
+
+protected:
+       bool unset;
+       float over;
+       float in;
+
+       vec3 center;
+       vec3 normal;
+};
\ No newline at end of file
index 420d66c35db234fc11ea2cfc8824c7a2c53dc3cd..ceeed9cb2c5166ffe662ac7d3c115e22ab484423 100644 (file)
@@ -8,6 +8,8 @@
 
 #include "../Message.h"
 
+#include "../GLM.h"
+
 
 EventBox::EventBox(const mat4& _modelMat, uint _EB_TYPE) : 
        SceneObject(Graphix::shader_BBox, _modelMat, vec4(0.f), Model::getBBoxModel(), ""), 
index d7e5d68874c6f743834369aa9ad7d44687dc95d0..dd8fc497fdc98dd4de3e357d8cd14155febcd3fb 100644 (file)
@@ -1,5 +1,7 @@
 #pragma once
+
 #include "SceneObject.h"
+#include "../GLM.h"
 
 
 #define EB_WINZONE 1
index e0ec59d85c45824fc817e00aeb137fa8f23d0822..1f0c1410f854b7b39b8f8d86f723c56b3d1b952f 100644 (file)
@@ -1,6 +1,7 @@
 #include "Marvin.h"
 
 #include "../Graphix/Shader.h"
+#include "../GLM.h"
 
 
 Marvin::Marvin(Shader* _shader, const mat4& _modelMat) : SceneObject(_shader, _modelMat, vec4(7.0f, 0.7f, 1.0f, 3.0f), "Player.dae", "model_player_2D.png")
index ed44973e75aa60d59d957b9f3b5e3396aef1111b..3493a97d1ca0abc027a7ba66db97c2c932f39fb9 100644 (file)
@@ -1,7 +1,7 @@
 #pragma once
 #include "SceneObject.h"
 
-#include "../Graphix/GLM.h"
+#include "../GLM.h"
 
 class Shader;
 
index d12e815d894c024771f115ec5cd8fe9f630ba0be..3f6ef29226aab284703d5666f7b1de6b028b6d0e 100644 (file)
@@ -3,7 +3,7 @@
 #include "Sky.h"
 #include <GL\glew.h>
 
-#include "../Graphix/GLM.h"
+#include "../GLM.h"
 #include "../Graphix/Graphix.h"
 
 #include "../Graphix/Shader.h"
@@ -12,6 +12,8 @@
 #include "../Message.h"
 #include "../Events.h"
 
+#include "../Overlap.h"
+
 #include <iostream>
 
 using std::list;
index ae2402c1a5e19ef72da9e434f8cd72db2f1c934c..827e74a381abb356099bdc7b71980afcfd78fe2d 100644 (file)
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "../Graphix/GLM.h"
+#include "../GLM.h"
 
 #include "../Graphix/ViewPort.h"
 #include "Sky.h"
index 4784e5b86a44b88893b5d6e85c0935a524e66370..e0b99edfc43b36f9fac8b37fef00160b814bb44d 100644 (file)
@@ -3,7 +3,8 @@
 
 #include <gl/glew.h>
 
-#include "../Graphix/GLM.h"
+#include "../GLM.h"
+#include "../Overlap.h"
 
 #include "../Graphix/Graphix.h"
 #include "../Graphix/Shader.h"
index f1290770c3f988ca251bb70be7785c1bcb012392..4cc765f5ff8993179f79b3dc4dadb77ec76667cf 100644 (file)
@@ -1,7 +1,6 @@
 #pragma once
 
-#include "../Graphix/GLM.h"
-
+#include "../GLM.h"
 #include <string>
 
 using std::string;
index b71400c0f3e6b050422d8537e99f1c1320b63258..b27ceba1fe28247bac7ec52b015b9ba1b149353b 100644 (file)
@@ -3,6 +3,8 @@
 #include "../Graphix/Shader.h"
 #include "../Graphix/Model.h"
 
+#include "../GLM.h"
+
 
 Sky::Sky() : SceneObject(new Shader("skybox_VS.hlsl","skybox_color_FS.hlsl"), mat4(1.f), vec4(1.f), Model::getSkyBoxModel(), "")
 {      
index 0156bb2c601dca904cb6e1bb6016d01aaba9bd23..7b108ede96c699bf3fcb62d72d86a9db9f5bd2b7 100644 (file)
@@ -1,7 +1,7 @@
 #pragma once
 #include "SceneObject.h"
 
-#include "../Graphix/GLM.h"
+#include "../GLM.h"
 
 class Shader;
 
index 968c17cf326785ee3ace1b2324243e0917e60b17..be339e20776e910ab513a0c2adf9531ee52bf34f 100644 (file)
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="BBoxTree.cpp" />
     <ClCompile Include="Events.cpp" />
     <ClCompile Include="Fps.cpp" />
     <ClCompile Include="Game.cpp" />
-    <ClCompile Include="Graphix\GLM.cpp" />
+    <ClCompile Include="GLM.cpp" />
     <ClCompile Include="Graphix\Graphix.cpp" />
     <ClCompile Include="Graphix\Model\BBox.cpp" />
     <ClCompile Include="Graphix\Model\IMesh.cpp" />
     <ClCompile Include="Graphix\Model\IMetaMesh.cpp" />
     <ClCompile Include="Graphix\Model\Model.cpp" />
     <ClCompile Include="Graphix\Model\SkyBox.cpp" />
+    <ClCompile Include="Overlap.cpp" />
     <ClCompile Include="Scene\EventBox.cpp" />
     <ClCompile Include="Scene\Marvin.cpp" />
     <ClCompile Include="Scene\Scene.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Average.h" />
+    <ClInclude Include="BBoxTree.h" />
     <ClInclude Include="Graphix\Model.h" />
     <ClInclude Include="Events.h" />
     <ClInclude Include="Fps.h" />
     <ClInclude Include="Game.h" />
-    <ClInclude Include="Graphix\GLM.h" />
+    <ClInclude Include="GLM.h" />
     <ClInclude Include="Graphix\Graphix.h" />
     <ClInclude Include="Graphix\Model\BBox.h" />
     <ClInclude Include="Graphix\Model\IMesh.h" />
     <ClInclude Include="Graphix\Model\IMetaMesh.h" />
     <ClInclude Include="Graphix\Model\Model.h" />
     <ClInclude Include="Graphix\Model\SkyBox.h" />
+    <ClInclude Include="Overlap.h" />
     <ClInclude Include="Scene.h" />
     <ClInclude Include="Scene\EventBox.h" />
     <ClInclude Include="Scene\Marvin.h" />
index 509b1b4d7d707c424da0817f25127c06c2305867..db09c283d594caecc34f8eecec99f13298040d25 100644 (file)
@@ -30,9 +30,6 @@
     <ClCompile Include="Events.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Graphix\GLM.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Graphix\Shader.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="Graphix\Model\SkyBox.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Overlap.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="BBoxTree.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="GLM.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Fps.h">
@@ -92,9 +98,6 @@
     <ClInclude Include="Events.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Graphix\GLM.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Graphix\Shader.h">
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="Graphix\Model\SkyBox.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Overlap.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="BBoxTree.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="GLM.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
\ No newline at end of file