From d4f9e8444be5bd9acdc14a6d8f5b599f6cff9ce7 Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Thu, 25 Jun 2015 22:01:42 +0200 Subject: [PATCH] added Margin -> doesnt fix glitches --- Weave/Graphix/Graphix.cpp | 2 +- Weave/Graphix/Model/IMetaMesh.cpp | 8 ++++++++ Weave/Graphix/Model/IMetaMesh.h | 2 ++ Weave/Graphix/Model/Model.cpp | 5 +++++ Weave/Graphix/Model/Model.h | 2 +- Weave/Scene/Marvin.cpp | 1 + Weave/Scene/SceneObject.cpp | 5 +++++ Weave/Scene/SceneObject.h | 2 ++ 8 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Weave/Graphix/Graphix.cpp b/Weave/Graphix/Graphix.cpp index 5f5d40a..cfe9e34 100644 --- a/Weave/Graphix/Graphix.cpp +++ b/Weave/Graphix/Graphix.cpp @@ -251,6 +251,6 @@ SDL_Window* Graphix::sdl_window; SDL_GLContext Graphix::sdl_glcontext; -short Graphix::effects = EF_NOTHING; +short Graphix::effects = EF_TRANSPARENCY; Shader* Graphix::shader_BBox; diff --git a/Weave/Graphix/Model/IMetaMesh.cpp b/Weave/Graphix/Model/IMetaMesh.cpp index ee47474..9308f4a 100644 --- a/Weave/Graphix/Model/IMetaMesh.cpp +++ b/Weave/Graphix/Model/IMetaMesh.cpp @@ -117,4 +117,12 @@ void IMetaMesh::drawBBox(const mat4& _modelMat,const vec4& _color) const IMetaMesh::operator string() const { return modelpath; +} + +void IMetaMesh::setMargin(btScalar _margin) +{ + for (auto i = models.begin(); i != models.end(); ++i) + { + i->first->setMargin(_margin); + } } \ No newline at end of file diff --git a/Weave/Graphix/Model/IMetaMesh.h b/Weave/Graphix/Model/IMetaMesh.h index 50a2b1f..b7363e9 100644 --- a/Weave/Graphix/Model/IMetaMesh.h +++ b/Weave/Graphix/Model/IMetaMesh.h @@ -25,6 +25,8 @@ public: operator std::string() const override; + void setMargin(btScalar margin) override; + protected: std::string modelpath; diff --git a/Weave/Graphix/Model/Model.cpp b/Weave/Graphix/Model/Model.cpp index c1244e0..5068375 100644 --- a/Weave/Graphix/Model/Model.cpp +++ b/Weave/Graphix/Model/Model.cpp @@ -379,6 +379,11 @@ bool Model::import(const aiMesh* mesh, uint& numvertices, uint& numfaces, float* return true; } +void Model::setMargin(btScalar _margin) +{ + bt_collision_shape->setMargin(_margin); +} + Model* Model::BoundingBox = nullptr; Model* Model::SkyBoxModel = nullptr; diff --git a/Weave/Graphix/Model/Model.h b/Weave/Graphix/Model/Model.h index 499d2a1..ff7a4cb 100644 --- a/Weave/Graphix/Model/Model.h +++ b/Weave/Graphix/Model/Model.h @@ -33,7 +33,7 @@ public: /* Get size&position from BBox */ void getBBcs(vec3& center, vec3& size) const; - class Triangle; + virtual void setMargin(btScalar margin); static Model* getBBoxModel(); static Model* getSkyBoxModel(); diff --git a/Weave/Scene/Marvin.cpp b/Weave/Scene/Marvin.cpp index 1d4bbd6..f8b314a 100644 --- a/Weave/Scene/Marvin.cpp +++ b/Weave/Scene/Marvin.cpp @@ -17,6 +17,7 @@ SceneObject(_shader, _modelMat, vec4(7.0f, 0.7f, 1.0f, 3.0f), "Player.dae", "mod { collide_group = COL_MARVIN; collide_with = COL_LEVEL | COL_ENEMY | COL_EVENT; + } diff --git a/Weave/Scene/SceneObject.cpp b/Weave/Scene/SceneObject.cpp index cd2a3cf..f1ba7fa 100644 --- a/Weave/Scene/SceneObject.cpp +++ b/Weave/Scene/SceneObject.cpp @@ -174,6 +174,11 @@ void SceneObject::update(float deltaT) yFloorDist = 100; } +void SceneObject::setMargin(btScalar _margin) +{ + model->setMargin(_margin); +} + void SceneObject::draw() const { // useModel(shader); diff --git a/Weave/Scene/SceneObject.h b/Weave/Scene/SceneObject.h index ba15fbe..358d3e6 100644 --- a/Weave/Scene/SceneObject.h +++ b/Weave/Scene/SceneObject.h @@ -49,6 +49,8 @@ public: virtual void turnTo(vec3& direction, float speed = 1); virtual void move(vec3& dist); + void setMargin(btScalar margin); + //virtual bool operator==(SceneObject); __declspec(deprecated) -- 2.47.3