From b402fc82539d7ea4609ee2129647559fb0fb2877 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 18 Nov 2014 21:02:28 +0100 Subject: [PATCH] [DEV] add debug --- ege/Environement.cpp | 5 +++++ ege/Ray.cpp | 3 ++- ege/Ray.h | 3 +-- ege/elements/Element.cpp | 16 ++++++++-------- ege/elements/Element.h | 11 +++++++++-- ege/elements/ElementPhysic.cpp | 22 +++++++++++----------- ege/elements/ElementPhysic.h | 9 +++++++-- ege/widget/Scene.cpp | 5 +++++ ege/widget/Scene.h | 1 + 9 files changed, 49 insertions(+), 26 deletions(-) diff --git a/ege/Environement.cpp b/ege/Environement.cpp index a8997c2..ac83cf9 100644 --- a/ege/Environement.cpp +++ b/ege/Environement.cpp @@ -312,6 +312,7 @@ void ege::Environement::clear() { void ege::Environement::periodicCall(const ewol::event::Time& _event) { float curentDelta = _event.getDeltaCall(); + EGE_INFO("periodic call : " << _event); // small hack to change speed ... curentDelta *= m_ratio; // check if the processing is availlable @@ -322,6 +323,7 @@ void ege::Environement::periodicCall(const ewol::event::Time& _event) { int32_t lastGameTime = m_gameTime*0.000001f; m_gameTime += curentDelta; if (lastGameTime != (int32_t)(m_gameTime*0.000001f)) { + EGE_INFO(" Emit Signal"); signalPlayTimeChange.emit(m_gameTime*0.000001f); } @@ -330,16 +332,19 @@ void ege::Environement::periodicCall(const ewol::event::Time& _event) { // update camera positions: for (auto &it : m_listCamera) { if (it.second != nullptr) { + EGE_INFO(" update camera : '" << it.first << "'"); it.second->periodicCall(curentDelta); } } //EGE_DEBUG("stepSimulation (start)"); ///step the simulation if (m_physicEngine.getDynamicWorld() != nullptr) { + EGE_INFO(" step simulation : " << curentDelta); m_physicEngine.getDynamicWorld()->stepSimulation(curentDelta); //optional but useful: debug drawing m_physicEngine.getDynamicWorld()->debugDrawWorld(); } + EGE_INFO(" Update particule engine"); m_particuleEngine.update(curentDelta); // remove all element that requested it ... { diff --git a/ege/Ray.cpp b/ege/Ray.cpp index c322827..37d2d63 100644 --- a/ege/Ray.cpp +++ b/ege/Ray.cpp @@ -5,8 +5,9 @@ * * @license BSD v3 (see license file) */ +#include #include -#include +#include #undef __class__ #define __class__ "Ray" diff --git a/ege/Ray.h b/ege/Ray.h index 026aedb..4e84f27 100644 --- a/ege/Ray.h +++ b/ege/Ray.h @@ -62,8 +62,7 @@ namespace ege { */ void set(const vec3& _origin, const vec3& _direction); }; - std::ostream& operator <<(std::ostream& _os, const ege::Ray& _obj); -} +}; #endif diff --git a/ege/elements/Element.cpp b/ege/elements/Element.cpp index 2999140..3ba6d62 100644 --- a/ege/elements/Element.cpp +++ b/ege/elements/Element.cpp @@ -101,12 +101,12 @@ const vec3& ege::Element::getPosition() { return emptyPosition; }; -static void drawSphere(const std::shared_ptr& _draw, - btScalar _radius, - int _lats, - int _longs, - mat4& _transformationMatrix, - etk::Color& _tmpColor) { +void ege::Element::drawSphere(const std::shared_ptr& _draw, + btScalar _radius, + int _lats, + int _longs, + mat4& _transformationMatrix, + etk::Color& _tmpColor) { int i, j; std::vector EwolVertices; for(i = 0; i <= _lats; i++) { @@ -149,7 +149,7 @@ const float lifeHeight = 0.3f; const float lifeWidth = 2.0f; const float lifeYPos = 1.7f; -void ege::Element::drawLife(const std::shared_ptr& _draw, const ege::Camera& _camera) { +void ege::Element::drawLife(const std::shared_ptr& _draw, const std::shared_ptr& _camera) { if (nullptr == _draw) { return; } @@ -188,7 +188,7 @@ void ege::Element::drawLife(const std::shared_ptr& _draw, const ege::Camera& _camera) { +void ege::Element::drawDebug(const std::shared_ptr& _draw, const std::shared_ptr& _camera) { m_debugText.clear(); m_debugText.setColor(etk::Color<>(0x00, 0xFF, 0x00, 0xFF)); m_debugText.setPos(vec3(-20,32,0)); diff --git a/ege/elements/Element.h b/ege/elements/Element.h index b1a8afb..e13a54d 100644 --- a/ege/elements/Element.h +++ b/ege/elements/Element.h @@ -163,7 +163,7 @@ namespace ege { * @brief draw the current life of the element */ // TODO : Remove this ... - virtual void drawLife(const std::shared_ptr& _draw, const ege::Camera& _camera); + virtual void drawLife(const std::shared_ptr& _draw, const std::shared_ptr& _camera); protected: // For debug only ... @@ -173,7 +173,7 @@ namespace ege { * @brief Debug display of the current element * @param[in,out] draw Basic system to draw the debug shape and informations */ - virtual void drawDebug(const std::shared_ptr& _draw, const ege::Camera& _camera); + virtual void drawDebug(const std::shared_ptr& _draw, const std::shared_ptr& _camera); /** * @brief get the theoric position. Sometimes, the element has move due to an explosion or something else, then its real position in not the one that woult it be at the end ... @@ -229,6 +229,13 @@ namespace ege { * @brief remove this element from the physique engine */ virtual void dynamicDisable() {}; + protected: + void drawSphere(const std::shared_ptr& _draw, + btScalar _radius, + int _lats, + int _longs, + mat4& _transformationMatrix, + etk::Color& _tmpColor); }; }; diff --git a/ege/elements/ElementPhysic.cpp b/ege/elements/ElementPhysic.cpp index f974baf..08376a4 100644 --- a/ege/elements/ElementPhysic.cpp +++ b/ege/elements/ElementPhysic.cpp @@ -162,10 +162,10 @@ const float ege::ElementPhysic::getInvMass() { return 0.0000000001f; }; -static void drawShape(const btCollisionShape* _shape, - const std::shared_ptr& _draw, - mat4 _transformationMatrix, - std::vector _tmpVertices) { +void ege::ElementPhysic::drawShape(const btCollisionShape* _shape, + const std::shared_ptr& _draw, + mat4 _transformationMatrix, + std::vector _tmpVertices) { if( _draw == nullptr || _shape == nullptr) { return; @@ -177,15 +177,15 @@ static void drawShape(const btCollisionShape* _shape, switch (shapetype) { case SPHERE_SHAPE_PROXYTYPE: { // Sphere collision shape ... - //EGE_DEBUG(" draw (01): SPHERE_SHAPE_PROXYTYPE"); + EGE_DEBUG(" draw (01): SPHERE_SHAPE_PROXYTYPE"); const btSphereShape* sphereShape = static_cast(_shape); float radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin - // TODO : drawSphere(_draw, radius, 10, 10, _transformationMatrix, tmpColor); + drawSphere(_draw, radius, 10, 10, _transformationMatrix, tmpColor); break; } case BOX_SHAPE_PROXYTYPE: { // Box collision shape ... - //EGE_DEBUG(" draw (02): BOX_SHAPE_PROXYTYPE"); + EGE_DEBUG(" draw (02): BOX_SHAPE_PROXYTYPE"); const btBoxShape* boxShape = static_cast(_shape); btVector3 halfExtent = boxShape->getHalfExtentsWithMargin(); static int indices[36] = { 0,1,2, 3,2,1, 4,0,6, @@ -303,7 +303,7 @@ static void drawShape(const btCollisionShape* _shape, } case COMPOUND_SHAPE_PROXYTYPE: { // Multiple sub element collision shape ... - //EGE_DEBUG(" draw (07): COMPOUND_SHAPE_PROXYTYPE"); + EGE_DEBUG(" draw (07): COMPOUND_SHAPE_PROXYTYPE"); const btCompoundShape* compoundShape = static_cast(_shape); for (int32_t iii=compoundShape->getNumChildShapes()-1;iii >= 0;iii--) { btTransform childTrans = compoundShape->getChildTransform(iii); @@ -319,7 +319,7 @@ static void drawShape(const btCollisionShape* _shape, } case EMPTY_SHAPE_PROXYTYPE: { // No collision shape ... - //EGE_DEBUG(" draw (08): EMPTY_SHAPE_PROXYTYPE"); + EGE_DEBUG(" draw (08): EMPTY_SHAPE_PROXYTYPE"); // nothing to display ... break; } @@ -330,7 +330,7 @@ static void drawShape(const btCollisionShape* _shape, } } -void ege::ElementPhysic::drawDebug(const std::shared_ptr& _draw, const ege::Camera& _camera) { +void ege::ElementPhysic::drawDebug(const std::shared_ptr& _draw, const std::shared_ptr& _camera) { ege::Element::drawDebug(_draw, _camera); btScalar mmm[16]; btDefaultMotionState* myMotionState = (btDefaultMotionState*)m_body->getMotionState(); @@ -353,7 +353,7 @@ void ege::ElementPhysic::draw(int32_t _pass) { if( m_body != nullptr && m_mesh != nullptr && m_body->getMotionState() ) { - //EGE_INFO(" plop "); + //EGE_INFO("element pos = " << getPosition()); btScalar mmm[16]; btDefaultMotionState* myMotionState = (btDefaultMotionState*)m_body->getMotionState(); myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(mmm); diff --git a/ege/elements/ElementPhysic.h b/ege/elements/ElementPhysic.h index b4c90b3..1cc9721 100644 --- a/ege/elements/ElementPhysic.h +++ b/ege/elements/ElementPhysic.h @@ -90,7 +90,7 @@ namespace ege { /** * @brief draw the current life of the element */ - // virtual void drawLife(const std::shared_ptr& _draw, const ege::Camera& _camera); + // virtual void drawLife(const std::shared_ptr& _draw, const std::shared_ptr& _camera); /** * @brief get the theoric position. Sometimes, the element has move due to an explosion or something else, then its real position in not the one that woult it be at the end ... @@ -176,7 +176,12 @@ namespace ege { virtual void onDestroy() {}; virtual const vec3& getPosition(); virtual void setPosition(const vec3& _pos); - virtual void drawDebug(const std::shared_ptr& _draw, const ege::Camera& _camera); + virtual void drawDebug(const std::shared_ptr& _draw, const std::shared_ptr& _camera); + protected: + void drawShape(const btCollisionShape* _shape, + const std::shared_ptr& _draw, + mat4 _transformationMatrix, + std::vector _tmpVertices); }; }; diff --git a/ege/widget/Scene.cpp b/ege/widget/Scene.cpp index c485f7b..349a53d 100644 --- a/ege/widget/Scene.cpp +++ b/ege/widget/Scene.cpp @@ -41,6 +41,7 @@ void ege::widget::Scene::init(std::shared_ptr _env) { setKeyboardRepeate(false); setCanHaveFocus(true); periodicCallEnable(); + m_debugDrawProperty = ewol::resource::Colored3DObject::create(); } ege::widget::Scene::~Scene() { @@ -109,6 +110,10 @@ void ege::widget::Scene::onDraw() { m_displayElementOrdered[iii].element->draw(pass); } } + // Draw debug ... + for (int32_t iii=m_displayElementOrdered.size()-1; iii >= 0; iii--) { + m_displayElementOrdered[iii].element->drawDebug(m_debugDrawProperty, camera); + } } else { EGE_WARNING("No Dynamic world ..."); } diff --git a/ege/widget/Scene.h b/ege/widget/Scene.h index 12da304..0c3b942 100644 --- a/ege/widget/Scene.h +++ b/ege/widget/Scene.h @@ -38,6 +38,7 @@ namespace ege { class Scene : public ewol::Widget { protected: std::shared_ptr m_env; + std::shared_ptr m_debugDrawProperty; protected: /** * @brief Constructor of the widget classes