]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
removed collision Tree
authorPeter Schaefer <schaeferpm@gmail.com>
Tue, 9 Jun 2015 07:35:56 +0000 (09:35 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Tue, 9 Jun 2015 07:35:56 +0000 (09:35 +0200)
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/Scene/SceneObject.cpp
Weave/Scene/SceneObject.h

index a177f5bd02f969c37b92b36ce29c01b6223c738a..7c31d93c7e53232751e7c7da79b65d1608d7d85b 100644 (file)
@@ -22,16 +22,6 @@ typedef Model::Box Box;
 typedef IMesh::Node Node;
 
 
-// Vergleiche Unterbaum
-//#define COMPARE_MTREE
-//draw BBox of MTREE deep LVL -1 means all lvl's
-#define BBOX_MTREE 5
-
-// Vergleiche auch Triangles
-#define COMPARE_FACE
-// Fordere mindestens prozentuelles gleichgewicht .1 = 10%
-#define HEAP_SCALE_BOUND .1f
-
 //IMesh::IMesh(const string& _modelpath, uint _mindex) : modelpath(_modelpath), root(nullptr)
 //{
 //
@@ -60,7 +50,7 @@ typedef IMesh::Node Node;
 //
 //}
 
-IMesh::IMesh(const aiMesh* _mesh, const mat4& _transformation, const vec3& _scale) : modelpath("IMesh"), root(nullptr)
+IMesh::IMesh(const aiMesh* _mesh, const vec3& _scale) : modelpath("IMesh")
 {
        import(_mesh, numvertices, numfaces, vertex, uvs, normals, index, _scale);
 
@@ -74,26 +64,21 @@ IMesh::IMesh(const aiMesh* _mesh, const mat4& _transformation, const vec3& _scal
 
        btVector3 minB,maxB;
        btTransform t;
+       t.setIdentity();
 
        tmp_shape->getAabb(t, minB, maxB);
 
-       minB = t(minB);
-       maxB = t(maxB);
+       //minB = t(minB);
+       //maxB = t(maxB);
 
-       vec3 min = (vec3)(_transformation * vec4(minB.getX(), minB.getY(), minB.getZ(), 0.f));
-       vec3 max = (vec3)(_transformation * vec4(maxB.getX(), maxB.getY(), maxB.getZ(), 0.f));
+       vec3 min = (vec3)(vec4(minB.getX(), minB.getY(), minB.getZ(), 0.f));
+       vec3 max = (vec3)(vec4(maxB.getX(), maxB.getY(), maxB.getZ(), 0.f));
 
        vec3 size = (max - min) * .5f;
        vec3 center = (max + min) * .5f;
 
-#ifdef COMPARE_MTREE
-       root = buildMeshTree(_transformation, numvertices, numfaces, vertex, normals, index);
+       setBB(numvertices, vertex);
 
-       vec3 min, max;
-       setBB(*root);
-#else
-       setBB(numvertices, vertex, _transformation);
-#endif
 
        genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex);
        genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals);
@@ -122,317 +107,13 @@ IMesh::~IMesh()
 //}
 
 
-void drawSubBBox(const mat4& _modelMat, const vec4& _color, Node* _node, int _lvl)
-{
-       //vec3 BBsiz, BBpos;
-       //_node->getBBcs(BBpos, BBsiz);
-       Graphix::getGlError();
-       Graphix::shader_BBox->useShader();
-       int tmp = Graphix::shader_BBox->getUniformLocation("uFragmentColor");
-       if (tmp >= 0)
-               glUniform4fv(tmp, 1, value_ptr(_color));
-       Graphix::getGlError();
-       Model::getBBoxModel()->drawModel(Graphix::shader_BBox, NULL, _modelMat*translate(_node->center())*glm::scale(_node->size()*2.f));
-
-       if (_lvl == 0)
-               return;
-       if (_node->getLNode() != nullptr)
-               drawSubBBox(_modelMat, _color*.9f, _node->getLNode(), _lvl - 1);
-       if (_node->getUNode() != nullptr)
-               drawSubBBox(_modelMat, _color*.9f, _node->getUNode(), _lvl - 1);
-
-       
-}
-
 void IMesh::drawBBox(const mat4& _modelMat, const vec4& _color) const
 {
-#if !defined(COMPARE_MTREE) || !defined(BBOX_MTREE)
        Model::drawBBox(_modelMat, _color);
-#else
-       drawSubBBox(_modelMat, _color, root, BBOX_MTREE);
-#endif
 }
 
 
-Overlap IMesh::checkColNode2O(const Node* _node, const SplitMat& _mOSMat, const Model* _model, const SplitMat& _modelMat) const
-{
-       Box box(*_node);
-       //scale BoxA
-       box.scale(_mOSMat.scale);
-
-       Overlap stepNode = _model->checkColO2SBox(_modelMat, box,_mOSMat);
-
-       //Falls _node nicht overlap
-       if (!stepNode)
-               return stepNode;
-
-       //check sub _nodes
-       if (_node->getElement() == nullptr)
-       {
-               Overlap left = checkColNode2O(_node->getLNode(), _mOSMat, _model, _modelMat);
-               Overlap right = checkColNode2O(_node->getUNode(), _mOSMat, _model, _modelMat);
-               Overlap stepSub;
-               if (left)
-                       stepSub.update(left);
-               if (right)
-                       stepSub.update(right);
-
-               return stepSub;
-       }
-       else
-       {
-               //TODO ELEMENT CHECK
-               return stepNode;
-       }
-
-}
-
-Overlap IMesh::checkColO2NodeBox(const Node* _node, const SplitMat& _mOSMat, const Box& _boxB, const SplitMat& _modelMat) const
-{
-       Box boxA(*_node);
-
-       //scale BoxA
-       boxA.scale(_mOSMat.scale);
-
-       //RotateBox to other
-       Box boxAR(boxA), boxBR(_boxB);
-       boxAR.rotate(_modelMat.modelInv*_mOSMat.model);
-       boxBR.rotate(_mOSMat.modelInv*_modelMat.model);
-
-       Overlap stepNode = Box::checkCollideByAxis(boxAR, _boxB);
-       if (stepNode)
-               stepNode.update(Box::checkCollideByAxis(boxA, boxBR));
-
-       //Falls _node nicht overlap
-       if (!stepNode)
-               return stepNode;
-
-       //check sub _nodes
-       if (_node->getElement() == nullptr)
-       {
-               Overlap left = checkColO2NodeBox(_node->getLNode(), _mOSMat, _boxB, _modelMat);
-               Overlap right = checkColO2NodeBox(_node->getUNode(), _mOSMat, _boxB, _modelMat);
-               Overlap stepSub;
-               if (left)
-                       stepSub.update(left);
-               if (right)
-                       stepSub.update(right);
-
-               return stepSub;
-       }
-       else
-       {
-               //TODO ELEMENT CHECK
-               return stepNode;
-       }
-
-}
-
-
-Overlap IMesh::checkColS2O(const SplitMat& _mMat, const Model* _model, const SplitMat& _modelMat) const
-{
-       //Outer BBoxes
-#ifdef COMPARE_MTREE
-//     vec3 scale = getScale(_mMat);
-       Overlap firstBB = checkColNode2O(root, _mMat, _model, _modelMat);
-#else
-       Overlap firstBB = Model::checkColS2O(_mMat, _model, _modelMat);
-#endif
-
-       //if (!firstBB)
-       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 SplitMat& _mMat, const Box& _boxB, const SplitMat& _modelMat) const
-{
-       //Outer Mesh
-       #ifdef COMPARE_MTREE
-               //vec3 scale = getScale(_mMat);
-               Overlap firstBB = checkColO2NodeBox(root, _mMat, _boxB, _modelMat);
-       #else
-               Overlap firstBB = Model::checkColO2SBox(_mMat, _boxB, _modelMat);
-       #endif
-
-       //if (!firstBB)
-               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";
 }
-
-Box getBoxfromNodeList(const list<Node*>& _TriList)
-{
-       Box ret(*_TriList.front());
-
-       for (auto k = ++_TriList.cbegin(); k != _TriList.cend(); ++k)
-               ret.update(**k);
-
-       return ret;
-}
-
-
-Node* IMesh::buildMeshTree(const list<Node*>& _triList)
-{
-       //catch if list is empty
-       if (_triList.size() == 0)
-               return nullptr;
-       //catch if list has only one element => LEAF
-       if (_triList.size() == 1)
-               return _triList.front();
-       //catch if list has only two elements => 2 LEAFS
-       if (_triList.size() == 2)
-               return new Node(_triList.front(), _triList.back());
-       //catch if list has only three elements = 1 NODE & 3 LEAFS
-       if (_triList.size() == 3)
-       {
-               list<Node*> tmpList = _triList;
-               Node* tmpNode = tmpList.front();
-               tmpList.pop_front();
-               return new Node(tmpNode, buildMeshTree(tmpList));
-       }
-
-       Box box(getBoxfromNodeList(_triList));
-
-       //find longest dist
-       vec3 sort = sortVec3(box.size());
-
-       //SPLIT and call self
-       array<list<Node*>, 3> lower, upper;
-       vec3 tmpMin, tmpMax;
-       mat3 lMin, lMax, uMin, uMax;
-       int dim(0), bestDim;
-       float bestPerc(1), splitPerc(1);
-
-       //try different DIM
-       for (auto k = _triList.cbegin(); k != _triList.cend(); ++k)
-       {
-               vec3 mean = (*k)->getMean();
-               for (dim = 0; dim < 3; ++dim)
-               {
-                       if (mean[(int)sort[dim]] < box.center()[(int)sort[dim]])
-                               lower[dim].push_back(*k);
-                       else
-                               upper[dim].push_back(*k);
-               }
-       }
-
-       //check best Dim
-       for (dim = 0; dim < 3; ++dim)
-       {
-               splitPerc = abs(upper[dim].size() / (float)_triList.size() - .5f);
-               if (splitPerc < .4f)
-                       break;
-               if (splitPerc < bestPerc)
-               {
-                       bestDim = dim;
-                       bestPerc = splitPerc;
-               }
-
-       }
-       if (dim == 3)
-               dim = bestDim;
-
-
-       return new Node(box, buildMeshTree(lower[dim]), buildMeshTree(upper[dim]));
-}
-
-Node* IMesh::buildMeshTree(const mat4& modelMat, const uint& numvertices, const uint& numfaces, const float* vertex, const float* normals, const uint* index)
-{
-       list<Node*> node_list;
-       mat3 tmp_vert;
-       vec3 tmp_normal;
-       for (uint i = 0; i < numfaces; ++i)
-       {
-               tmp_vert[0] = (vec3)(modelMat*vec4(vertex[3 * index[3 * i]], vertex[3 * index[3 * i] + 1], vertex[3 * index[3 * i] + 2], 1.f));
-               tmp_vert[1] = (vec3)(modelMat*vec4(vertex[3 * index[3 * i + 1]], vertex[3 * index[3 * i + 1] + 1], vertex[3 * index[3 * i + 1] + 2], 1.f));
-               tmp_vert[2] = (vec3)(modelMat*vec4(vertex[3 * index[3 * i + 2]], vertex[3 * index[3 * i + 2] + 1], vertex[3 * index[3 * i + 2] + 2], 1.f));
-
-               tmp_normal = cross(tmp_vert[1] - tmp_vert[0], tmp_vert[2] - tmp_vert[0]);
-               if (0>dot(tmp_normal, vec3(normals[3 * index[3 * i]], normals[3 * index[3 * i] + 1], normals[3 * index[3 * i] + 2])))
-                       tmp_normal *= -1;
-               node_list.push_back(new Node(new Triangle(tmp_vert, tmp_normal)));
-       }
-       return buildMeshTree(node_list);
-}
-
-
-Node::Node(Triangle* tri) : element(tri), lNode(nullptr), uNode(nullptr), Box(*tri)
-{
-       mean = element->getMean();
-       //element->getBBmm(min, max);
-       //size = (max - min) / 2.f;
-       //center = (min + max) / 2.f;
-}
-
-Node::Node(const Box& _box, Node* _lower, Node* _upper)
-       : Box(_box), element(nullptr), lNode(_lower), uNode(_upper)
-{}
-
-Node::Node(Node* _lower, Node* _upper)
-       : element(nullptr), lNode(_lower), uNode(_upper), Box(merge(*_lower,*_upper))
-{
-
-}
-
-Node::~Node()
-{
-       if (element != nullptr)
-               delete element;
-       else
-               delete lNode, uNode;
-}
-
-
-vec3 Node::getMean() const
-{
-       return mean;
-}
-
-Node* Node::getLNode() const
-{
-       return lNode;
-}
-
-Node* Node::getUNode() const
-{
-       return uNode;
-}
-
-Model::Triangle* Node::getElement() const
-{
-       return element;
-}
-
index 149efb4c13d8ffbbf654057ba6c708948573fc3f..ce4f10ac7c89d828c7f2bc3f73bffece18de2d3b 100644 (file)
@@ -16,7 +16,7 @@ public:
        class Node;
 
 //     IMesh(const std::string& modelpath, uint index=0);
-       IMesh(const aiMesh* mesh, const mat4& transformation, const vec3& scale = vec3(1.f));
+       IMesh(const aiMesh* mesh, const vec3& scale = vec3(1.f));
 
        virtual ~IMesh();
 
@@ -24,39 +24,8 @@ public:
 
        void drawBBox(const mat4& modelMat, const vec4& color = vec4(0.9f, 0.f, 0.f, 1.f)) const override;
 
-       Overlap checkColS2O(const SplitMat& mMat, const Model* model, const SplitMat& modelMat) const override;
-       Overlap checkColO2SBox(const SplitMat& mMat, const Model::Box& boxB, const SplitMat& modelMat) const override;
-       //Overlap checkColO2STriangle(const mat4& mMat, const vec3& pos, const mat3& directions) const override;
-
-       Overlap checkColNode2O(const Node* node, const SplitMat& mOSMat, const Model* model, const SplitMat& modelMat) const;
-       Overlap checkColO2NodeBox(const Node* node, const SplitMat& mOSMat, const Model::Box& boxB, const SplitMat& modelMat) const;
-
        operator std::string() const override;
 
-       static Node* buildMeshTree(const mat4& modelMat, const uint& numvertices, const uint& numfaces, const float* vertex, const float* normals, const uint* index);
-       static Node* buildMeshTree(const std::list<IMesh::Node*>& triList);
-
-       class Node : public Model::Box
-       {
-       public:
-               Node(Triangle* tri);
-               Node(Node* lower, Node* upper);
-               Node(const Box& box, Node* lower, Node* upper);
-               ~Node();
-
-               vec3 getMean() const;
-
-               Node* getLNode() const;
-               Node* getUNode() const;
-               Model::Triangle* getElement() const;
-
-       private:
-               vec3 mean;
-
-               Node *lNode, *uNode;
-               Model::Triangle *element;
-       };
-
 protected:
 
        std::string modelpath;
@@ -64,6 +33,4 @@ protected:
        float *vertex = nullptr, *normals = nullptr, *uvs = nullptr;
        uint *index = nullptr;
 
-       Node* root;
-
 };
\ No newline at end of file
index 6a0b3cff431e7780e360dd640074085c0658d30a..a21fd54a4799b100c1882e027b6bef4b14079878 100644 (file)
@@ -41,7 +41,7 @@ IMetaMesh::IMetaMesh(const string& _modelpath, const vec3& _scale) : modelpath(_
                tmpModelMat = mat4(aimat->a1, aimat->c1, -aimat->b1, aimat->d1, aimat->a2, aimat->c2, -aimat->b2, aimat->d2, aimat->a3, aimat->c3, -aimat->b3, aimat->d3, aimat->a4, aimat->c4, -aimat->b4, aimat->d4);
                tmpModelMatClean = removeScale(tmpModelMat);
                tmpModelMatBT.setFromOpenGLMatrix(value_ptr(tmpModelMatClean));
-               tmpIMesh = new IMesh(scene->mMeshes[0], tmpModelMatClean, _scale* getScale(tmpModelMat));
+               tmpIMesh = new IMesh(scene->mMeshes[0], _scale* getScale(tmpModelMat));
                models.push_back(std::pair<IMesh*,mat4>(tmpIMesh,tmpModelMatClean));
                setBB(tmpIMesh->getBBox());
                tmp_shape->addChildShape(tmpModelMatBT,*tmpIMesh);
@@ -53,7 +53,7 @@ IMetaMesh::IMetaMesh(const string& _modelpath, const vec3& _scale) : modelpath(_
                        tmpModelMat = mat4(aimat->a1, aimat->c1, -aimat->b1, aimat->d1, aimat->a2, aimat->c2, -aimat->b2, aimat->d2, aimat->a3, aimat->c3, -aimat->b3, aimat->d3, aimat->a4, aimat->c4, -aimat->b4, aimat->d4);
                        tmpModelMatClean = removeScale(tmpModelMat);
                        tmpModelMatBT.setFromOpenGLMatrix(value_ptr(tmpModelMatClean));
-                       tmpIMesh = new IMesh(scene->mMeshes[i], tmpModelMatClean, _scale* getScale(tmpModelMat));
+                       tmpIMesh = new IMesh(scene->mMeshes[i], _scale* getScale(tmpModelMat));
                        models.push_back(std::pair<IMesh*, mat4>(tmpIMesh, tmpModelMatClean));
                        updateBB(tmpIMesh->getBBox());
 
@@ -110,7 +110,7 @@ void IMetaMesh::drawBBox(const mat4& _modelMat,const vec4& _color) const
        if (models.size() == 1)
        {
                auto i = models.front();
-               i.first->drawBBox(_modelMat, _color);
+               i.first->drawBBox(_modelMat* i.second, _color);
        }
        else
        {
@@ -119,56 +119,12 @@ void IMetaMesh::drawBBox(const mat4& _modelMat,const vec4& _color) const
                {
                        for (auto i = models.begin(); i != models.end(); ++i)
                        {
-                               i->first->drawBBox(_modelMat, _color*0.8f);
+                               i->first->drawBBox(_modelMat* i->second, _color*0.8f);
                        }
                }
        }
 }
 
-Overlap IMetaMesh::checkColS2O(const SplitMat& _mMat, const Model* _model, const SplitMat& _modelMat) const
-{
-       //Outer BBox
-       Overlap firstBB = Model::checkColS2O(_mMat, _model, _modelMat);
-       if (!firstBB)
-               return firstBB;
-
-       //Inner BBox
-       Overlap tmp,secondSubBB;
-       for (auto i = models.begin(); i != models.end(); ++i)
-       {
-               tmp = i->first->checkColS2O(_mMat, _model, _modelMat);
-               if (tmp)
-               {
-                       secondSubBB.update(tmp);
-               }
-                       
-       }
-       //if (!secondSubBB)
-               return secondSubBB;
-       
-}
-
-Overlap IMetaMesh::checkColO2SBox(const SplitMat& _mMat, const Box& _boxB, const SplitMat& _modelMat) const
-{
-       //Outer BBox
-       Overlap firstBB = Model::checkColO2SBox(_mMat, _boxB, _modelMat);
-       if (!firstBB)
-               return firstBB;
-
-       //Inner BBox
-       Overlap tmp, secondSubBB;
-       for (auto i = models.begin(); i != models.end(); ++i)
-       {
-               tmp = i->first->checkColO2SBox(_mMat, _boxB, _modelMat);
-               if (tmp)
-               {
-                       secondSubBB.update(tmp);
-               }
-
-       }
-       //if (!secondSubBB)
-               return secondSubBB;
-}
 
 IMetaMesh::operator string() const
 {
index b8a4bfcb3a16066cd33911a5c7139ceb8bf97711..2422aebbbab74cf18334c73bfe3219438c1f409f 100644 (file)
@@ -23,9 +23,6 @@ public:
 
        void drawBBox(const mat4& modelMat, const vec4& color = vec4(0.9f, 0.f, 0.f, 1.f)) const override;
 
-       Overlap checkColS2O(const SplitMat& mMat, const Model* model, const SplitMat& modelMat) const override;
-       Overlap checkColO2SBox(const SplitMat& mMat, const Model::Box& boxB, const SplitMat& modelMat) const override;
-
        operator std::string() const override;
 
 protected:
index b9773b2aa54a8c5f3ca24c5756f3f38116467855..7608e9c5f011118cd1224316c28266a9e692327d 100644 (file)
@@ -122,14 +122,18 @@ void Model::drawBBox(const mat4& _modelMat, const vec4& _color) const
                glUniform4fv(tmp, 1, value_ptr(_color));
        Graphix::getGlError();
 
-       btVector3 min, max;
+       btVector3 minB, maxB;
        btTransform trans;
-       bt_collision_shape->getAabb(trans, min, max);
+       trans.setIdentity();
+       bt_collision_shape->getAabb(trans, minB, maxB);
 
-       btVector3 size = (max - min) * .5f;
-       btVector3 center = trans((max + min) * .5f);
+       vec3 min = vec3(minB.getX(), minB.getY(), minB.getZ());
+       vec3 max = vec3(maxB.getX(), maxB.getY(), maxB.getZ());
 
-       getBBoxModel()->drawModel(Graphix::shader_BBox, NULL, _modelMat*translate(box.center())*glm::scale(box.size()*2.f));
+       vec3 size = (max - min);
+       vec3 center = (max + min) * .5f;
+
+       getBBoxModel()->drawModel(Graphix::shader_BBox, NULL, _modelMat*translate(center)*glm::scale(size)); //
 }
 
 void Model::setBB(const Box& _box)
@@ -267,105 +271,6 @@ Model::operator btCollisionShape*() const
        return bt_collision_shape;
 }
 
-Overlap Model::isColliding(const Model* _modelThis, const Model* _modelOther, const mat4& _modelMatThis, const mat4& _modelMatOther)
-{
-       return _modelThis->checkColS2O(_modelMatThis, _modelOther, _modelMatOther);
-}
-
-Overlap Model::checkColS2O(const SplitMat& _mMat, const Model* _model, const SplitMat& _modelMat) const
-{
-//     vec3 scale = getScale(_mMat);
-
-       Box boxA(box);
-       boxA.scale(_mMat.scale);
-
-       Overlap stepBB = _model->checkColO2SBox(_modelMat, boxA, _mMat);
-
-       return stepBB;
-}
-
-Overlap Model::checkColO2SBox(const SplitMat& _mMat, const Box& _boxB, const SplitMat& _modelMatB) const
-{
-       //split _mMat to scale and mMat
-//     vec3 scale = getScale(_mMat);
-//     mat4 mMat = removeScale(_mMat);
-
-       Box boxA(box);
-
-       //scale BoxA
-       boxA.scale(_mMat.scale);
-
-       //RotateBox to other
-       Box boxAR(boxA), boxBR(_boxB);
-       boxAR.rotate(_modelMatB.modelInv*_mMat.model);
-       boxBR.rotate(_mMat.modelInv*_modelMatB.model);
-
-       Overlap ret = Box::checkCollideByAxis(boxAR,_boxB);
-       if (ret)
-               ret.update(Box::checkCollideByAxis(boxA, boxBR));
-
-       return ret;
-}
-
-Overlap Model::checkColO2STriangle(const SplitMat& _mMat, const Triangle& _tri) const
-{
-//     vec3 scale = getScale(_mMat);
-
-       Box boxA(box);
-       boxA.scale(_mMat.scale);
-
-//     mat4 invmMat = glm::inverse(_mMat.model);
-
-       //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();
-
-}
-
-
-
-
-
 vec3 Model::rotateSize(const vec3& _size, const mat4& _modelMat)
 {
        vec3 newSize(0.f);
@@ -740,20 +645,3 @@ Box Box::merge(const Box& _boxA, const Box& _boxB)
        }
        return Box(center,size);
 }
-
-Overlap Box::checkCollideByAxis(const Box& _boxA, const Box& _boxB)
-{
-       Overlap ret;
-
-       for (uint i = 0; i < 3; ++i)
-       {
-
-               ret.update(_boxA.size()[i] + _boxB.size()[i] - abs(_boxA.center()[i] - _boxB.center()[i]),
-                       abs(_boxA.size()[i] - _boxB.size()[i]) - abs(_boxA.center()[i] - _boxB.center()[i]));
-
-               if (!ret)
-                       break;
-       }
-       return ret;
-}
-
index 3b4ee4bae0e7467a0b1551af6e17c5a4c338da35..d1851d1b1099201b5511d7dc69d4086c9c4795f5 100644 (file)
@@ -39,15 +39,7 @@ public:
        /* Get center&size (BOX) */
        Box getBBox() const;
 
-       /* calls Colliding to check if self collides with model*/
-       static Overlap isColliding(const Model* modelThis, const Model* modelOther, const mat4& modelMatThis, const mat4& modelMatOther);
-       
-
-       /* test self against other*/
        class Triangle;
-       virtual Overlap checkColS2O(const SplitMat& mMat, const Model* model, const SplitMat& modelMat) const;
-       virtual Overlap checkColO2SBox(const SplitMat& mMat, const Box& box, const SplitMat& modelMat) const;
-       virtual Overlap checkColO2STriangle(const SplitMat& mMat, const Triangle& tri) const;
 
        static Model* getBBoxModel();
        static Model* getSkyBoxModel();
@@ -122,7 +114,7 @@ public:
                float getDist(const vec3& pos, const vec3& direc) const;
 
                static Box merge(const Box& boxA, const Box& boxB);
-               static Overlap checkCollideByAxis(const Box& boxA, const Box& boxB);
+
        protected:
                vec3 cen;
                vec3 siz;
index ee9afe48e8b170b336350281bc2b00a2eb2c6b63..4fe73ed43395bb3ab54852e7dbce11fd0d1dc513 100644 (file)
@@ -171,22 +171,6 @@ void SceneObject::draw() const
                model->drawBBox(modelMat);
 }
 
-void SceneObject::checkCollision(SceneObject* _first, SceneObject* _second)
-{
-       if (_first->collision_ignore || _second->collision_ignore)
-               return;
-
-
-       Overlap over = Model::isColliding(_first->model,_second->model, _first->modelMat, _second->modelMat);
-       /* overlapping 1 yes, 0 touch, -1 no*/
-       /* inside 1 yes, 0 touch, -1 no*/
-       if (over.overlap() >= 0)
-       {
-               _first->collides(_second);
-               _second->collides(_first);
-       }
-
-}
 
 void SceneObject::collides(SceneObject* _other, btPersistentManifold* _contactManifold)
 {
index 51d13a73f8a2789805780e6368547c9fdffabf23..f49c4e66778fbc74f92ad56d953811dbac4762f7 100644 (file)
@@ -36,8 +36,6 @@ public:
        virtual void update(float);
        virtual void draw() const;
 
-       static void checkCollision(SceneObject* first, SceneObject* second);
-
        virtual void collides(SceneObject* other, btPersistentManifold* contactManifold = nullptr);
 
        virtual vec3 getPosition() const;