From c770439228b4f32d5d91c915278e43ff596c8fcb Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 5 May 2017 21:46:10 +0200 Subject: [PATCH] [DEV] correct some physics error --- doxy_ege.py | 2 +- ege/CollisionShapeCreator.cpp | 2 +- ege/Environement.cpp | 2 +- ege/elements/ElementPhysic.cpp | 12 ++++++++---- ege/elements/ElementPhysic.hpp | 2 +- ege/physics/Engine.cpp | 6 ++++++ ege/physics/Engine.hpp | 5 +++++ ege/physicsShape/PhysicsBox.cpp | 4 ++-- ege/physicsShape/PhysicsCapsule.cpp | 8 ++++---- ege/physicsShape/PhysicsCone.cpp | 8 ++++---- ege/physicsShape/PhysicsConvexHull.cpp | 8 ++++---- ege/physicsShape/PhysicsCylinder.cpp | 4 ++-- ege/physicsShape/PhysicsSphere.cpp | 4 ++-- ege/widget/Scene.cpp | 2 ++ lutin_ege.py | 2 +- 15 files changed, 44 insertions(+), 27 deletions(-) diff --git a/doxy_ege.py b/doxy_ege.py index 6caae0b..598c102 100644 --- a/doxy_ege.py +++ b/doxy_ege.py @@ -7,7 +7,7 @@ import doxy.tools as tools def create(target, module_name): my_module = module.Module(__file__, module_name) my_module.set_version("version.txt") - my_module.set_title("Ewol Game engine (based on bullet lib)") + my_module.set_title("Ewol Game engine") my_module.set_website("http://atria-soft.github.io/" + module_name) my_module.set_website_sources("http://github.com/atria-soft/" + module_name) my_module.add_path([ diff --git a/ege/CollisionShapeCreator.cpp b/ege/CollisionShapeCreator.cpp index b3e2b95..4ca3331 100644 --- a/ege/CollisionShapeCreator.cpp +++ b/ege/CollisionShapeCreator.cpp @@ -25,7 +25,7 @@ btCollisionShape* ege::collision::createShape(const ememory::SharedPtr& _mesh) { if (_mesh == nullptr) { EGE_ERROR("Create empty shape (no mesh)"); - return new btEmptyShape();; + return new btEmptyShape(); } const std::vector>& physiqueProperty = _mesh->getPhysicalProperties(); if (physiqueProperty.size() == 0) { diff --git a/ege/Environement.cpp b/ege/Environement.cpp index 17e776a..258fd06 100644 --- a/ege/Environement.cpp +++ b/ege/Environement.cpp @@ -310,7 +310,7 @@ void ege::Environement::getOrderedElementForDisplay(std::vectorsetUserPointer((void*)this); m_body->setAngularVelocity(vec3(0,0,0)); + if (_static == true) { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT); + } } - bool ege::ElementPhysic::setMesh(ememory::SharedPtr _mesh) { EGE_WARNING("Set Mesh"); if (m_mesh != nullptr) { removeShape(); } ege::Element::setMesh(_mesh); - // auto load the shape : + // auto load the shape: if (m_mesh == nullptr) { return true; } @@ -321,6 +323,9 @@ void ege::ElementPhysic::drawShape(const btCollisionShape* _shape, void ege::ElementPhysic::drawDebug(ememory::SharedPtr _draw, ememory::SharedPtr _camera) { ege::Element::drawDebug(_draw, _camera); btScalar mmm[16]; + if (m_body == nullptr) { + return; + } btDefaultMotionState* myMotionState = (btDefaultMotionState*)m_body->getMotionState(); myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(mmm); @@ -347,7 +352,6 @@ void ege::ElementPhysic::drawNormalDebug(ememory::SharedPtr otherwise it will be not manage with this system... public: - void createRigidBody(float _mass=400000000.0f); + void createRigidBody(float _mass=400000000.0f, bool _static=false); public: /** * @brief Constructor (when constructer is called just add element that did not change. diff --git a/ege/physics/Engine.cpp b/ege/physics/Engine.cpp index f866a48..189bc2a 100644 --- a/ege/physics/Engine.cpp +++ b/ege/physics/Engine.cpp @@ -104,6 +104,12 @@ void ege::physics::Engine::setBulletConfig(ememory::SharedPtrsetGravity(_axePower); + } +} + // some doccumantation : http://www.bulletphysics.org/mediawiki-1.5.8/index.php?title=Collision_Callbacks_and_Triggers std::vector ege::physics::Engine::getListOfCollision() { std::vector out; diff --git a/ege/physics/Engine.hpp b/ege/physics/Engine.hpp index fc7eb61..18d5ecb 100644 --- a/ege/physics/Engine.hpp +++ b/ege/physics/Engine.hpp @@ -94,6 +94,11 @@ namespace ege { * @return the requested list of points */ std::vector getListOfCollision(); + /** + * @brief Set the gravity axis of the physic engine + * @param[in] _axePower energy of this gravity + */ + void setGravity(const vec3& _axePower); }; } } diff --git a/ege/physicsShape/PhysicsBox.cpp b/ege/physicsShape/PhysicsBox.cpp index 60b9297..a8ad4b9 100644 --- a/ege/physicsShape/PhysicsBox.cpp +++ b/ege/physicsShape/PhysicsBox.cpp @@ -11,8 +11,8 @@ bool ege::PhysicsBox::parse(const char* _line) { if (ege::PhysicsShape::parse(_line) == true) { return true; } - if(strncmp(_line, "half-extents : ", 15) == 0) { - sscanf(&_line[15], "%f %f %f", &m_size.m_floats[0], &m_size.m_floats[1], &m_size.m_floats[2] ); + if(strncmp(_line, "half-extents:", 13) == 0) { + sscanf(&_line[13], "%f %f %f", &m_size.m_floats[0], &m_size.m_floats[1], &m_size.m_floats[2] ); EGE_VERBOSE(" halfSize=" << m_size); return true; } diff --git a/ege/physicsShape/PhysicsCapsule.cpp b/ege/physicsShape/PhysicsCapsule.cpp index 444dee2..f47a89b 100644 --- a/ege/physicsShape/PhysicsCapsule.cpp +++ b/ege/physicsShape/PhysicsCapsule.cpp @@ -12,13 +12,13 @@ bool ege::PhysicsCapsule::parse(const char* _line) { if (ege::PhysicsShape::parse(_line) == true) { return true; } - if(strncmp(_line, "radius : ", 9) == 0) { - sscanf(&_line[9], "%f", &m_radius ); + if(strncmp(_line, "radius:", 7) == 0) { + sscanf(&_line[7], "%f", &m_radius ); EGE_VERBOSE(" radius=" << m_radius); return true; } - if(strncmp(_line, "height : ", 9) == 0) { - sscanf(&_line[9], "%f", &m_height ); + if(strncmp(_line, "height:", 7) == 0) { + sscanf(&_line[7], "%f", &m_height ); EGE_VERBOSE(" height=" << m_height); return true; } diff --git a/ege/physicsShape/PhysicsCone.cpp b/ege/physicsShape/PhysicsCone.cpp index 3482517..4519039 100644 --- a/ege/physicsShape/PhysicsCone.cpp +++ b/ege/physicsShape/PhysicsCone.cpp @@ -12,13 +12,13 @@ bool ege::PhysicsCone::parse(const char* _line) { if (ege::PhysicsShape::parse(_line) == true) { return true; } - if(strncmp(_line, "radius : ", 9) == 0) { - sscanf(&_line[9], "%f", &m_radius ); + if(strncmp(_line, "radius:", 7) == 0) { + sscanf(&_line[7], "%f", &m_radius ); EGE_VERBOSE(" radius=" << m_radius); return true; } - if(strncmp(_line, "height : ", 9) == 0) { - sscanf(&_line[9], "%f", &m_height ); + if(strncmp(_line, "height:", 7) == 0) { + sscanf(&_line[7], "%f", &m_height ); EGE_VERBOSE(" height=" << m_height); return true; } diff --git a/ege/physicsShape/PhysicsConvexHull.cpp b/ege/physicsShape/PhysicsConvexHull.cpp index 4cc3fb4..e5b7212 100644 --- a/ege/physicsShape/PhysicsConvexHull.cpp +++ b/ege/physicsShape/PhysicsConvexHull.cpp @@ -12,9 +12,9 @@ bool ege::PhysicsConvexHull::parse(const char* _line) { if (ege::PhysicsShape::parse(_line) == true) { return true; } - if(strncmp(_line, "points : ", 8) == 0) { + if(strncmp(_line, "points:", 6) == 0) { //EGE_DEBUG("convex hull point parsing " << _line); - char* base = (char*)(&_line[8]); + char* base = (char*)(&_line[6]); char* tmp= strchr(base, '|'); vec3 pos(0,0,0); while (tmp != nullptr) { @@ -33,8 +33,8 @@ bool ege::PhysicsConvexHull::parse(const char* _line) { */ return true; } - if(strncmp(_line, "scale : ", 8) == 0) { - sscanf(&_line[8], "%f %f %f", &m_scale.m_floats[0], &m_scale.m_floats[1], &m_scale.m_floats[2] ); + if(strncmp(_line, "scale:", 6) == 0) { + sscanf(&_line[6], "%f %f %f", &m_scale.m_floats[0], &m_scale.m_floats[1], &m_scale.m_floats[2] ); EGE_VERBOSE(" scale=" << m_scale); return true; } diff --git a/ege/physicsShape/PhysicsCylinder.cpp b/ege/physicsShape/PhysicsCylinder.cpp index 44bbd31..4912951 100644 --- a/ege/physicsShape/PhysicsCylinder.cpp +++ b/ege/physicsShape/PhysicsCylinder.cpp @@ -11,8 +11,8 @@ bool ege::PhysicsCylinder::parse(const char* _line) { if (ege::PhysicsShape::parse(_line) == true) { return true; } - if(strncmp(_line, "half-extents : ", 15) == 0) { - sscanf(&_line[15], "%f %f %f", &m_size.m_floats[0], &m_size.m_floats[1], &m_size.m_floats[2] ); + if(strncmp(_line, "half-extents:", 13) == 0) { + sscanf(&_line[13], "%f %f %f", &m_size.m_floats[0], &m_size.m_floats[1], &m_size.m_floats[2] ); EGE_VERBOSE(" halfSize=" << m_size); return true; } diff --git a/ege/physicsShape/PhysicsSphere.cpp b/ege/physicsShape/PhysicsSphere.cpp index f13bf9b..30d986e 100644 --- a/ege/physicsShape/PhysicsSphere.cpp +++ b/ege/physicsShape/PhysicsSphere.cpp @@ -12,8 +12,8 @@ bool ege::PhysicsSphere::parse(const char* _line) { if (ege::PhysicsShape::parse(_line) == true) { return true; } - if(strncmp(_line, "radius : ", 9) == 0) { - sscanf(&_line[9], "%f", &m_radius ); + if(strncmp(_line, "radius:", 7) == 0) { + sscanf(&_line[7], "%f", &m_radius ); EGE_VERBOSE(" radius=" << m_radius); return true; } diff --git a/ege/widget/Scene.cpp b/ege/widget/Scene.cpp index 9b436eb..b57e043 100644 --- a/ege/widget/Scene.cpp +++ b/ege/widget/Scene.cpp @@ -129,12 +129,14 @@ void ege::widget::Scene::onDraw() { m_displayElementOrdered[iii].element->drawDebug(m_debugDrawProperty, camera); } // Draw debug ... (Camera) + /* std::map> listCamera = m_env->getCameraList(); for (auto &itCam : listCamera) { if (itCam.second != nullptr) { itCam.second->drawDebug(m_debugDrawProperty, camera); } } + */ } if (propertyDebugNormal.get() == true) { // Draw debug ... (Object) diff --git a/lutin_ege.py b/lutin_ege.py index 7a84614..3ef47d3 100644 --- a/lutin_ege.py +++ b/lutin_ege.py @@ -7,7 +7,7 @@ def get_type(): return "LIBRARY" def get_desc(): - return "Ewol Game engine (based on bullet lib)" + return "Ewol Game engine" def get_licence(): return "MPL-2"