[DEV] add debug

This commit is contained in:
Edouard DUPIN 2014-11-18 21:02:28 +01:00
parent b980581156
commit b402fc8253
9 changed files with 49 additions and 26 deletions

View File

@ -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 ...
{

View File

@ -5,8 +5,9 @@
*
* @license BSD v3 (see license file)
*/
#include <etk/types.h>
#include <ege/Ray.h>
#include <etk/math/Vector3D.h>
#include <ege/debug.h>
#undef __class__
#define __class__ "Ray"

View File

@ -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

View File

@ -101,12 +101,12 @@ const vec3& ege::Element::getPosition() {
return emptyPosition;
};
static void drawSphere(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw,
btScalar _radius,
int _lats,
int _longs,
mat4& _transformationMatrix,
etk::Color<float>& _tmpColor) {
void ege::Element::drawSphere(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw,
btScalar _radius,
int _lats,
int _longs,
mat4& _transformationMatrix,
etk::Color<float>& _tmpColor) {
int i, j;
std::vector<vec3> 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<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera) {
void ege::Element::drawLife(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw, const std::shared_ptr<ege::Camera>& _camera) {
if (nullptr == _draw) {
return;
}
@ -188,7 +188,7 @@ void ege::Element::drawLife(const std::shared_ptr<ewol::resource::Colored3DObjec
#endif
}
void ege::Element::drawDebug(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera) {
void ege::Element::drawDebug(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw, const std::shared_ptr<ege::Camera>& _camera) {
m_debugText.clear();
m_debugText.setColor(etk::Color<>(0x00, 0xFF, 0x00, 0xFF));
m_debugText.setPos(vec3(-20,32,0));

View File

@ -163,7 +163,7 @@ namespace ege {
* @brief draw the current life of the element
*/
// TODO : Remove this ...
virtual void drawLife(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera);
virtual void drawLife(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw, const std::shared_ptr<ege::Camera>& _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<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera);
virtual void drawDebug(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw, const std::shared_ptr<ege::Camera>& _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<ewol::resource::Colored3DObject>& _draw,
btScalar _radius,
int _lats,
int _longs,
mat4& _transformationMatrix,
etk::Color<float>& _tmpColor);
};
};

View File

@ -162,10 +162,10 @@ const float ege::ElementPhysic::getInvMass() {
return 0.0000000001f;
};
static void drawShape(const btCollisionShape* _shape,
const std::shared_ptr<ewol::resource::Colored3DObject>& _draw,
mat4 _transformationMatrix,
std::vector<vec3> _tmpVertices) {
void ege::ElementPhysic::drawShape(const btCollisionShape* _shape,
const std::shared_ptr<ewol::resource::Colored3DObject>& _draw,
mat4 _transformationMatrix,
std::vector<vec3> _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<const btSphereShape*>(_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<const btBoxShape*>(_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<const btCompoundShape*>(_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<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera) {
void ege::ElementPhysic::drawDebug(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw, const std::shared_ptr<ege::Camera>& _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);

View File

@ -90,7 +90,7 @@ namespace ege {
/**
* @brief draw the current life of the element
*/
// virtual void drawLife(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera);
// virtual void drawLife(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw, const std::shared_ptr<ege::Camera>& _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<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera);
virtual void drawDebug(const std::shared_ptr<ewol::resource::Colored3DObject>& _draw, const std::shared_ptr<ege::Camera>& _camera);
protected:
void drawShape(const btCollisionShape* _shape,
const std::shared_ptr<ewol::resource::Colored3DObject>& _draw,
mat4 _transformationMatrix,
std::vector<vec3> _tmpVertices);
};
};

View File

@ -41,6 +41,7 @@ void ege::widget::Scene::init(std::shared_ptr<ege::Environement> _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 ...");
}

View File

@ -38,6 +38,7 @@ namespace ege {
class Scene : public ewol::Widget {
protected:
std::shared_ptr<ege::Environement> m_env;
std::shared_ptr<ewol::resource::Colored3DObject> m_debugDrawProperty;
protected:
/**
* @brief Constructor of the widget classes