diff --git a/ege/CollisionShapeCreator.cpp b/ege/CollisionShapeCreator.cpp index 4ca3331..861517f 100644 --- a/ege/CollisionShapeCreator.cpp +++ b/ege/CollisionShapeCreator.cpp @@ -6,11 +6,6 @@ #include #include - -#include -#include -#include -#include #include #include #include @@ -21,7 +16,7 @@ // Documentetion of bullet library : // http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Shapes - +/* btCollisionShape* ege::collision::createShape(const ememory::SharedPtr& _mesh) { if (_mesh == nullptr) { EGE_ERROR("Create empty shape (no mesh)"); @@ -181,5 +176,5 @@ btCollisionShape* ege::collision::createShape(const ememory::SharedPtr #include -#include namespace ege { namespace collision { - btCollisionShape* createShape(const ememory::SharedPtr& _mesh); + //btCollisionShape* createShape(const ememory::SharedPtr& _mesh); } } diff --git a/ege/Environement.cpp b/ege/Environement.cpp index 7ef4b58..241f200 100644 --- a/ege/Environement.cpp +++ b/ege/Environement.cpp @@ -10,19 +10,7 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include ememory::SharedPtr ege::Environement::getElementNearest(ememory::SharedPtr _sourceRequest, float& _distance) { if (_sourceRequest == nullptr) { diff --git a/ege/Environement.hpp b/ege/Environement.hpp index 6fa8e4c..cc439fb 100644 --- a/ege/Environement.hpp +++ b/ege/Environement.hpp @@ -11,11 +11,7 @@ namespace ege { }; #include #include - #include -#include -class btDynamicsWorld; - #include #include #include diff --git a/ege/Ray.cpp b/ege/Ray.cpp index 4b69768..289d638 100644 --- a/ege/Ray.cpp +++ b/ege/Ray.cpp @@ -8,8 +8,6 @@ #include #include -#include -#include ege::Ray::Ray(const vec3& _origin, const vec3& _direction) : m_origin(_origin), @@ -41,6 +39,7 @@ std::pair ege::Ray::testRay(ege::physics::Engine& _engine) { vec3 start = m_origin; vec3 stop = m_origin+m_direction*1000.0f; // Start and End are vectors + /* btCollisionWorld::ClosestRayResultCallback rayCallback(start, stop); EGE_VERBOSE("Process Raycast :"); // Perform raycast @@ -51,6 +50,7 @@ std::pair ege::Ray::testRay(ege::physics::Engine& _engine) { EGE_VERBOSE(" hit at point=" << end << " normal=" << normal); return std::pair(end,normal); } + */ EGE_VERBOSE(" No Hit"); return std::pair(vec3(0,0,0),vec3(0,0,0)); } @@ -60,6 +60,7 @@ std::pair, std::pair> ege::Ray::test vec3 start = m_origin; vec3 stop = m_origin+m_direction*1000.0f; // Start and End are vectors + /* btCollisionWorld::ClosestRayResultCallback rayCallback(start, stop); EGE_VERBOSE("Process Raycast :"); // Perform raycast @@ -74,9 +75,9 @@ std::pair, std::pair> ege::Ray::test } EGE_VERBOSE(" Can not get the element pointer"); return std::pair, std::pair>(nullptr, std::pair(end,normal)); - } else { - EGE_VERBOSE(" No Hit"); } + */ + EGE_VERBOSE(" No Hit"); return std::pair, std::pair>(nullptr, std::pair(vec3(0,0,0),vec3(0,0,0))); } diff --git a/ege/camera/Camera.hpp b/ege/camera/Camera.hpp index d166c90..c68ee83 100644 --- a/ege/camera/Camera.hpp +++ b/ege/camera/Camera.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include diff --git a/ege/elements/Element.cpp b/ege/elements/Element.cpp index 837d9ff..75ae853 100644 --- a/ege/elements/Element.cpp +++ b/ege/elements/Element.cpp @@ -8,19 +8,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include diff --git a/ege/elements/Element.hpp b/ege/elements/Element.hpp index c4f6039..fa1709c 100644 --- a/ege/elements/Element.hpp +++ b/ege/elements/Element.hpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include diff --git a/ege/elements/ElementPhysic.cpp b/ege/elements/ElementPhysic.cpp index 32cebad..b4d3afb 100644 --- a/ege/elements/ElementPhysic.cpp +++ b/ege/elements/ElementPhysic.cpp @@ -8,18 +8,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include @@ -32,7 +20,7 @@ const std::string& ege::ElementPhysic::getType() const { ege::ElementPhysic::ElementPhysic(const ememory::SharedPtr& _env, bool _autoRigidBody) ://, float _mass) : ege::Element(_env), m_body(nullptr), - m_shape(nullptr), + //m_shape(nullptr), m_elementInPhysicsSystem(false), m_IA(nullptr), m_detectCollisionEnable(false) { @@ -45,12 +33,12 @@ ege::ElementPhysic::ElementPhysic(const ememory::SharedPtr& _ ege::ElementPhysic::~ElementPhysic() { // in every case remove IA - iaDisable(); + //iaDisable(); // same ... - dynamicDisable(); - removeShape(); + //dynamicDisable(); + //removeShape(); // Destroy the rigid body - m_dynamicsWorld->destroyRigidBody(m_body); + //m_dynamicsWorld->destroyRigidBody(m_body); m_body = nullptr; } @@ -62,8 +50,8 @@ void ege::ElementPhysic::createRigidBody(float _mass, bool _static) { rp3d::Transform transform(initPosition, initOrientation); // Create a rigid body in the world - m_body = m_dynamicsWorld->createRigidBody(transform); - + m_body = nullptr;//m_dynamicsWorld->createRigidBody(transform); + /* if (_static = true) { m_body->setType(STATIC); //m_body->setType(KINEMATIC); @@ -72,18 +60,20 @@ void ege::ElementPhysic::createRigidBody(float _mass, bool _static) { } else { m_body->setType(DYNAMIC); } + */ } bool ege::ElementPhysic::setMesh(ememory::SharedPtr _mesh) { EGE_WARNING("Set Mesh"); if (m_mesh != nullptr) { - removeShape(); + //removeShape(); } ege::Element::setMesh(_mesh); // auto load the shape: if (m_mesh == nullptr) { return true; } + /* if (m_mesh->getShape() != nullptr) { EGE_WARNING("create shape whith mesh internal shape ..."); m_shape = static_cast(m_mesh->getShape()); @@ -96,10 +86,11 @@ bool ege::ElementPhysic::setMesh(ememory::SharedPtr _mesh) m_shape = static_cast(m_mesh->getShape()); vec3 localInertia(0,0,0); m_shape->calculateLocalInertia(50000000, localInertia); // TODO : BETTER /// + */ return true; } - +/* bool ege::ElementPhysic::setShape(btCollisionShape* _shape) { EGE_DEBUG("Set Shape"); removeShape(); @@ -140,47 +131,55 @@ void ege::ElementPhysic::FunctionFreeShape(void* _pointer) { } delete(static_cast(_pointer)); } - +*/ void ege::ElementPhysic::setPosition(const vec3& _pos) { if (m_body != nullptr) { + /* btTransform transformation = m_body->getCenterOfMassTransform(); transformation.setOrigin(_pos); m_body->setCenterOfMassTransform(transformation); + */ } } const vec3& ege::ElementPhysic::getPosition() { + /* if (m_body != nullptr) { return m_body->getCenterOfMassPosition(); } + */ return ege::Element::getPosition(); }; const vec3& ege::ElementPhysic::getSpeed() { static vec3 emptySpeed(0,0,0); + /* if (m_body != nullptr) { return m_body->getLinearVelocity(); } + */ return emptySpeed; }; const float ege::ElementPhysic::getInvMass() { + /* if (m_body != nullptr) { return m_body->getInvMass(); } + */ return 0.0000000001f; }; -void ege::ElementPhysic::drawShape(const btCollisionShape* _shape, +void ege::ElementPhysic::drawShape(/*const btCollisionShape* _shape,*/ ememory::SharedPtr _draw, mat4 _transformationMatrix, std::vector _tmpVertices) { + #if 0 if( _draw == nullptr || _shape == nullptr) { return; } etk::Color tmpColor(1.0, 0.0, 0.0, 0.3); - //EGE_DEBUG(" draw (6): !btIDebugDraw::DBG_DrawWireframe"); int shapetype=_shape->getShapeType(); switch (shapetype) { @@ -316,10 +315,12 @@ void ege::ElementPhysic::drawShape(const btCollisionShape* _shape, EGE_DEBUG(" draw (09): default"); } } + #endif } void ege::ElementPhysic::drawDebug(ememory::SharedPtr _draw, ememory::SharedPtr _camera) { ege::Element::drawDebug(_draw, _camera); + /* btScalar mmm[16]; if (m_body == nullptr) { return; @@ -333,9 +334,11 @@ void ege::ElementPhysic::drawDebug(ememory::SharedPtr EwolVertices; drawShape(m_shape, _draw, transformationMatrix, EwolVertices); + */ } void ege::ElementPhysic::drawNormalDebug(ememory::SharedPtr _draw, ememory::SharedPtr _camera) { + /* if( m_body != nullptr && m_mesh != nullptr && m_body->getMotionState() ) { @@ -348,12 +351,14 @@ void ege::ElementPhysic::drawNormalDebug(ememory::SharedPtrdrawNormal(transformationMatrix, _draw); } + */ } void ege::ElementPhysic::draw(int32_t _pass) { if (m_elementInPhysicsSystem == false) { return; } + /* //EGE_INFO("draw : " << _pass ); if (_pass == 0) { if( m_body != nullptr @@ -372,6 +377,7 @@ void ege::ElementPhysic::draw(int32_t _pass) { m_mesh->draw(transformationMatrix); } } + */ } void ege::ElementPhysic::dynamicEnable() { @@ -438,12 +444,14 @@ void ege::ElementPhysic::setMass(float _value) { if (m_body == nullptr) { return; } + /* vec3 localInertia(0,0,0); if (_value != 0.0f && getShape()!=nullptr) { //getShape()->calculateLocalInertia(_value, localInertia); EWOL_ERROR("Update inertia calculated : " << localInertia); } - //m_body->setMassProps(_value, localInertia); + m_body->setMassProps(_value, localInertia); + */ } void ege::ElementPhysic::setLinearVelocity(const vec3& _value) { @@ -454,7 +462,7 @@ void ege::ElementPhysic::setLinearVelocity(const vec3& _value) { // Force vector (in Newton) rp3d::Vector3 force(_value.x(), _value.y(), _value.z()); // Apply a force to the center of the body - m_body->applyForceToCenter(force); + m_body->applyForceToCenterOfMass(force); } void ege::ElementPhysic::setTorqueImpulse(const vec3& _value) { @@ -475,7 +483,7 @@ void ege::ElementPhysic::setAngularVelocity(const vec3& _value) { } //m_body->setAngularVelocity(_value); } - +/* btQuaternion ege::ElementPhysic::getOrientation() const { if (m_body == nullptr) { EGE_WARNING("no body"); @@ -484,6 +492,7 @@ btQuaternion ege::ElementPhysic::getOrientation() const { //return m_body->getOrientation(); return btQuaternion(0,0,0,0); } +*/ void ege::ElementPhysic::setCollisionDetectionStatus(bool _status) { if (m_body == nullptr) { diff --git a/ege/elements/ElementPhysic.hpp b/ege/elements/ElementPhysic.hpp index 25830ef..74c08fd 100644 --- a/ege/elements/ElementPhysic.hpp +++ b/ege/elements/ElementPhysic.hpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include @@ -53,7 +53,7 @@ namespace ege { */ virtual const std::string& getType() const; protected: - btCollisionShape* m_shape; //!< shape of the element (set a copy here to have the debug display of it) + //btCollisionShape* m_shape; //!< shape of the element (set a copy here to have the debug display of it) public: /** * @brief set the shape properties. @@ -61,19 +61,21 @@ namespace ege { * @note : this remove the shape properties. * @return true if no error occured */ - bool setShape(btCollisionShape* _shape); + //bool setShape(btCollisionShape* _shape); /** * @brief get a pointer on the bullet collision shape. * @return the collision pointer. */ + /* inline btCollisionShape* getShape() { return m_shape; }; + */ private: /** * @brief remove the curent selected shape. */ - void removeShape(); + //void removeShape(); public: virtual bool setMesh(ememory::SharedPtr _mesh); /** @@ -121,7 +123,7 @@ namespace ege { virtual void setTorqueImpulse(const vec3& _value); virtual void setAngularVelocity(const vec3& _value); - btQuaternion getOrientation() const; + //btQuaternion getOrientation() const; protected: bool m_elementInPhysicsSystem; @@ -129,7 +131,7 @@ namespace ege { virtual void dynamicEnable(); virtual void dynamicDisable(); private: - class localIA : public btActionInterface { + class localIA { private: ege::ElementPhysic& m_element; public: @@ -147,12 +149,14 @@ namespace ege { }; public: // herited function + /* void debugDraw(btIDebugDraw* _debugDrawer) { }; void updateAction(btCollisionWorld* _collisionWorld, btScalar _step) { m_element.iaAction(_step); }; + */ }; localIA* m_IA; public: @@ -177,7 +181,7 @@ namespace ege { virtual void setPosition(const vec3& _pos); virtual void drawDebug(ememory::SharedPtr _draw, ememory::SharedPtr _camera); protected: - void drawShape(const btCollisionShape* _shape, + void drawShape(/*const btCollisionShape* _shape,*/ ememory::SharedPtr _draw, mat4 _transformationMatrix, std::vector _tmpVertices); diff --git a/ege/physics/Engine.cpp b/ege/physics/Engine.cpp index 64f3cf0..0581dfe 100644 --- a/ege/physics/Engine.cpp +++ b/ege/physics/Engine.cpp @@ -9,24 +9,13 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include // unique callback function : +/* extern ContactProcessedCallback gContactProcessedCallback; // TODO : remove double collision call ... @@ -47,7 +36,7 @@ static bool handleContactsProcess(btManifoldPoint& _point, btCollisionObject* _b } return true; } - +*/ ege::physics::Engine::Engine(): m_dynamicsWorld(nullptr), @@ -68,7 +57,8 @@ ege::physics::Engine::~Engine() { void ege::physics::Engine::setGravity(const vec3& _axePower) { if (m_dynamicsWorld != nullptr) { - m_dynamicsWorld->setGravity(rp3d::Vector3(_axePower.x(), _axePower.y(), _axePower.z())); + rp3d::Vector3 gravity(_axePower.x(), _axePower.y(), _axePower.z()); + m_dynamicsWorld->setGravity(gravity); } } diff --git a/ege/physics/Engine.hpp b/ege/physics/Engine.hpp index 01054d9..2f41fe9 100644 --- a/ege/physics/Engine.hpp +++ b/ege/physics/Engine.hpp @@ -12,7 +12,7 @@ namespace ege { }; #include #include -#include +#include #include #include #include @@ -20,6 +20,7 @@ namespace ege { #include #include #include +#include namespace ege { diff --git a/ege/widget/Scene.cpp b/ege/widget/Scene.cpp index f989cb2..89399c7 100644 --- a/ege/widget/Scene.cpp +++ b/ege/widget/Scene.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace etk { template<> std::string to_string >(const ememory::SharedPtr& _value) { diff --git a/ege/widget/Scene.hpp b/ege/widget/Scene.hpp index 6458a89..bddd064 100644 --- a/ege/widget/Scene.hpp +++ b/ege/widget/Scene.hpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include