[DEV] continue update to the new physic engine
This commit is contained in:
parent
4a64ced041
commit
fe17517d7c
@ -6,11 +6,6 @@
|
|||||||
|
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/CollisionShapeCreator.hpp>
|
#include <ege/CollisionShapeCreator.hpp>
|
||||||
|
|
||||||
#include <btBulletCollisionCommon.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btShapeHull.h>
|
|
||||||
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
|
|
||||||
#include <ege/physicsShape/PhysicsShape.hpp>
|
#include <ege/physicsShape/PhysicsShape.hpp>
|
||||||
#include <ege/physicsShape/PhysicsBox.hpp>
|
#include <ege/physicsShape/PhysicsBox.hpp>
|
||||||
#include <ege/physicsShape/PhysicsCapsule.hpp>
|
#include <ege/physicsShape/PhysicsCapsule.hpp>
|
||||||
@ -21,7 +16,7 @@
|
|||||||
|
|
||||||
// Documentetion of bullet library :
|
// Documentetion of bullet library :
|
||||||
// http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Shapes
|
// http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Shapes
|
||||||
|
/*
|
||||||
btCollisionShape* ege::collision::createShape(const ememory::SharedPtr<ege::resource::Mesh>& _mesh) {
|
btCollisionShape* ege::collision::createShape(const ememory::SharedPtr<ege::resource::Mesh>& _mesh) {
|
||||||
if (_mesh == nullptr) {
|
if (_mesh == nullptr) {
|
||||||
EGE_ERROR("Create empty shape (no mesh)");
|
EGE_ERROR("Create empty shape (no mesh)");
|
||||||
@ -181,5 +176,5 @@ btCollisionShape* ege::collision::createShape(const ememory::SharedPtr<ege::reso
|
|||||||
}
|
}
|
||||||
return outputShape;
|
return outputShape;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ -7,11 +7,10 @@
|
|||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <ege/resource/Mesh.hpp>
|
#include <ege/resource/Mesh.hpp>
|
||||||
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
|
|
||||||
|
|
||||||
namespace ege {
|
namespace ege {
|
||||||
namespace collision {
|
namespace collision {
|
||||||
btCollisionShape* createShape(const ememory::SharedPtr<ege::resource::Mesh>& _mesh);
|
//btCollisionShape* createShape(const ememory::SharedPtr<ege::resource::Mesh>& _mesh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,19 +10,7 @@
|
|||||||
#include <ewol/object/Manager.hpp>
|
#include <ewol/object/Manager.hpp>
|
||||||
|
|
||||||
#include <gale/renderer/openGL/openGL.hpp>
|
#include <gale/renderer/openGL/openGL.hpp>
|
||||||
#include <etk/math/Matrix4.hpp>
|
#include <etk/math/Matrix4x4.hpp>
|
||||||
#include <BulletDynamics/Dynamics/btRigidBody.h>
|
|
||||||
#include <LinearMath/btDefaultMotionState.h>
|
|
||||||
#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
|
|
||||||
#include <LinearMath/btIDebugDraw.h>
|
|
||||||
#include <btBulletCollisionCommon.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btShapeHull.h>
|
|
||||||
#include <LinearMath/btTransformUtil.h>
|
|
||||||
#include <LinearMath/btIDebugDraw.h>
|
|
||||||
#include <btBulletDynamicsCommon.h>
|
|
||||||
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
|
|
||||||
|
|
||||||
ememory::SharedPtr<ege::Element> ege::Environement::getElementNearest(ememory::SharedPtr<ege::Element> _sourceRequest, float& _distance) {
|
ememory::SharedPtr<ege::Element> ege::Environement::getElementNearest(ememory::SharedPtr<ege::Element> _sourceRequest, float& _distance) {
|
||||||
if (_sourceRequest == nullptr) {
|
if (_sourceRequest == nullptr) {
|
||||||
|
@ -11,11 +11,7 @@ namespace ege {
|
|||||||
};
|
};
|
||||||
#include <ege/camera/Camera.hpp>
|
#include <ege/camera/Camera.hpp>
|
||||||
#include <ege/ParticuleEngine.hpp>
|
#include <ege/ParticuleEngine.hpp>
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <BulletDynamics/Dynamics/btActionInterface.h>
|
|
||||||
class btDynamicsWorld;
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <etk/math/Vector3D.hpp>
|
#include <etk/math/Vector3D.hpp>
|
||||||
#include <ejson/ejson.hpp>
|
#include <ejson/ejson.hpp>
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/elements/Element.hpp>
|
#include <ege/elements/Element.hpp>
|
||||||
|
|
||||||
#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
|
|
||||||
#include <BulletCollision/CollisionDispatch/btCollisionWorld.h>
|
|
||||||
|
|
||||||
ege::Ray::Ray(const vec3& _origin, const vec3& _direction) :
|
ege::Ray::Ray(const vec3& _origin, const vec3& _direction) :
|
||||||
m_origin(_origin),
|
m_origin(_origin),
|
||||||
@ -41,6 +39,7 @@ std::pair<vec3,vec3> ege::Ray::testRay(ege::physics::Engine& _engine) {
|
|||||||
vec3 start = m_origin;
|
vec3 start = m_origin;
|
||||||
vec3 stop = m_origin+m_direction*1000.0f;
|
vec3 stop = m_origin+m_direction*1000.0f;
|
||||||
// Start and End are vectors
|
// Start and End are vectors
|
||||||
|
/*
|
||||||
btCollisionWorld::ClosestRayResultCallback rayCallback(start, stop);
|
btCollisionWorld::ClosestRayResultCallback rayCallback(start, stop);
|
||||||
EGE_VERBOSE("Process Raycast :");
|
EGE_VERBOSE("Process Raycast :");
|
||||||
// Perform raycast
|
// Perform raycast
|
||||||
@ -51,6 +50,7 @@ std::pair<vec3,vec3> ege::Ray::testRay(ege::physics::Engine& _engine) {
|
|||||||
EGE_VERBOSE(" hit at point=" << end << " normal=" << normal);
|
EGE_VERBOSE(" hit at point=" << end << " normal=" << normal);
|
||||||
return std::pair<vec3,vec3>(end,normal);
|
return std::pair<vec3,vec3>(end,normal);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
EGE_VERBOSE(" No Hit");
|
EGE_VERBOSE(" No Hit");
|
||||||
return std::pair<vec3,vec3>(vec3(0,0,0),vec3(0,0,0));
|
return std::pair<vec3,vec3>(vec3(0,0,0),vec3(0,0,0));
|
||||||
}
|
}
|
||||||
@ -60,6 +60,7 @@ std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>> ege::Ray::test
|
|||||||
vec3 start = m_origin;
|
vec3 start = m_origin;
|
||||||
vec3 stop = m_origin+m_direction*1000.0f;
|
vec3 stop = m_origin+m_direction*1000.0f;
|
||||||
// Start and End are vectors
|
// Start and End are vectors
|
||||||
|
/*
|
||||||
btCollisionWorld::ClosestRayResultCallback rayCallback(start, stop);
|
btCollisionWorld::ClosestRayResultCallback rayCallback(start, stop);
|
||||||
EGE_VERBOSE("Process Raycast :");
|
EGE_VERBOSE("Process Raycast :");
|
||||||
// Perform raycast
|
// Perform raycast
|
||||||
@ -74,9 +75,9 @@ std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>> ege::Ray::test
|
|||||||
}
|
}
|
||||||
EGE_VERBOSE(" Can not get the element pointer");
|
EGE_VERBOSE(" Can not get the element pointer");
|
||||||
return std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>>(nullptr, std::pair<vec3,vec3>(end,normal));
|
return std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>>(nullptr, std::pair<vec3,vec3>(end,normal));
|
||||||
} else {
|
|
||||||
EGE_VERBOSE(" No Hit");
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
EGE_VERBOSE(" No Hit");
|
||||||
return std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>>(nullptr, std::pair<vec3,vec3>(vec3(0,0,0),vec3(0,0,0)));
|
return std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>>(nullptr, std::pair<vec3,vec3>(vec3(0,0,0),vec3(0,0,0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/math/Vector3D.hpp>
|
#include <etk/math/Vector3D.hpp>
|
||||||
#include <etk/math/Vector2D.hpp>
|
#include <etk/math/Vector2D.hpp>
|
||||||
#include <etk/math/Matrix4.hpp>
|
#include <etk/math/Matrix4x4.hpp>
|
||||||
#include <ege/Ray.hpp>
|
#include <ege/Ray.hpp>
|
||||||
#include <ewol/resource/Colored3DObject.hpp>
|
#include <ewol/resource/Colored3DObject.hpp>
|
||||||
|
|
||||||
|
@ -8,19 +8,6 @@
|
|||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/elements/Element.hpp>
|
#include <ege/elements/Element.hpp>
|
||||||
#include <ege/Environement.hpp>
|
#include <ege/Environement.hpp>
|
||||||
#include <BulletDynamics/Dynamics/btRigidBody.h>
|
|
||||||
#include <LinearMath/btDefaultMotionState.h>
|
|
||||||
#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
|
|
||||||
#include <LinearMath/btIDebugDraw.h>
|
|
||||||
#include <btBulletCollisionCommon.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btShapeHull.h>
|
|
||||||
#include <LinearMath/btTransformUtil.h>
|
|
||||||
#include <LinearMath/btIDebugDraw.h>
|
|
||||||
#include <btBulletDynamicsCommon.h>
|
|
||||||
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
|
|
||||||
|
|
||||||
#include <ege/CollisionShapeCreator.hpp>
|
#include <ege/CollisionShapeCreator.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/math/Vector3D.hpp>
|
#include <etk/math/Vector3D.hpp>
|
||||||
#include <etk/math/Matrix4.hpp>
|
#include <etk/math/Matrix4x4.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <ewol/widget/Widget.hpp>
|
#include <ewol/widget/Widget.hpp>
|
||||||
|
@ -8,18 +8,6 @@
|
|||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/elements/ElementPhysic.hpp>
|
#include <ege/elements/ElementPhysic.hpp>
|
||||||
#include <ege/Environement.hpp>
|
#include <ege/Environement.hpp>
|
||||||
#include <BulletDynamics/Dynamics/btRigidBody.h>
|
|
||||||
#include <LinearMath/btDefaultMotionState.h>
|
|
||||||
#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
|
|
||||||
#include <LinearMath/btIDebugDraw.h>
|
|
||||||
#include <btBulletCollisionCommon.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btShapeHull.h>
|
|
||||||
#include <LinearMath/btTransformUtil.h>
|
|
||||||
#include <LinearMath/btIDebugDraw.h>
|
|
||||||
#include <btBulletDynamicsCommon.h>
|
|
||||||
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
|
|
||||||
|
|
||||||
#include <ege/CollisionShapeCreator.hpp>
|
#include <ege/CollisionShapeCreator.hpp>
|
||||||
|
|
||||||
@ -32,7 +20,7 @@ const std::string& ege::ElementPhysic::getType() const {
|
|||||||
ege::ElementPhysic::ElementPhysic(const ememory::SharedPtr<ege::Environement>& _env, bool _autoRigidBody) ://, float _mass) :
|
ege::ElementPhysic::ElementPhysic(const ememory::SharedPtr<ege::Environement>& _env, bool _autoRigidBody) ://, float _mass) :
|
||||||
ege::Element(_env),
|
ege::Element(_env),
|
||||||
m_body(nullptr),
|
m_body(nullptr),
|
||||||
m_shape(nullptr),
|
//m_shape(nullptr),
|
||||||
m_elementInPhysicsSystem(false),
|
m_elementInPhysicsSystem(false),
|
||||||
m_IA(nullptr),
|
m_IA(nullptr),
|
||||||
m_detectCollisionEnable(false) {
|
m_detectCollisionEnable(false) {
|
||||||
@ -45,12 +33,12 @@ ege::ElementPhysic::ElementPhysic(const ememory::SharedPtr<ege::Environement>& _
|
|||||||
|
|
||||||
ege::ElementPhysic::~ElementPhysic() {
|
ege::ElementPhysic::~ElementPhysic() {
|
||||||
// in every case remove IA
|
// in every case remove IA
|
||||||
iaDisable();
|
//iaDisable();
|
||||||
// same ...
|
// same ...
|
||||||
dynamicDisable();
|
//dynamicDisable();
|
||||||
removeShape();
|
//removeShape();
|
||||||
// Destroy the rigid body
|
// Destroy the rigid body
|
||||||
m_dynamicsWorld->destroyRigidBody(m_body);
|
//m_dynamicsWorld->destroyRigidBody(m_body);
|
||||||
m_body = nullptr;
|
m_body = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,8 +50,8 @@ void ege::ElementPhysic::createRigidBody(float _mass, bool _static) {
|
|||||||
rp3d::Transform transform(initPosition, initOrientation);
|
rp3d::Transform transform(initPosition, initOrientation);
|
||||||
|
|
||||||
// Create a rigid body in the world
|
// Create a rigid body in the world
|
||||||
m_body = m_dynamicsWorld->createRigidBody(transform);
|
m_body = nullptr;//m_dynamicsWorld->createRigidBody(transform);
|
||||||
|
/*
|
||||||
if (_static = true) {
|
if (_static = true) {
|
||||||
m_body->setType(STATIC);
|
m_body->setType(STATIC);
|
||||||
//m_body->setType(KINEMATIC);
|
//m_body->setType(KINEMATIC);
|
||||||
@ -72,18 +60,20 @@ void ege::ElementPhysic::createRigidBody(float _mass, bool _static) {
|
|||||||
} else {
|
} else {
|
||||||
m_body->setType(DYNAMIC);
|
m_body->setType(DYNAMIC);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ege::ElementPhysic::setMesh(ememory::SharedPtr<ege::resource::Mesh> _mesh) {
|
bool ege::ElementPhysic::setMesh(ememory::SharedPtr<ege::resource::Mesh> _mesh) {
|
||||||
EGE_WARNING("Set Mesh");
|
EGE_WARNING("Set Mesh");
|
||||||
if (m_mesh != nullptr) {
|
if (m_mesh != nullptr) {
|
||||||
removeShape();
|
//removeShape();
|
||||||
}
|
}
|
||||||
ege::Element::setMesh(_mesh);
|
ege::Element::setMesh(_mesh);
|
||||||
// auto load the shape:
|
// auto load the shape:
|
||||||
if (m_mesh == nullptr) {
|
if (m_mesh == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (m_mesh->getShape() != nullptr) {
|
if (m_mesh->getShape() != nullptr) {
|
||||||
EGE_WARNING("create shape whith mesh internal shape ...");
|
EGE_WARNING("create shape whith mesh internal shape ...");
|
||||||
m_shape = static_cast<btCollisionShape*>(m_mesh->getShape());
|
m_shape = static_cast<btCollisionShape*>(m_mesh->getShape());
|
||||||
@ -96,10 +86,11 @@ bool ege::ElementPhysic::setMesh(ememory::SharedPtr<ege::resource::Mesh> _mesh)
|
|||||||
m_shape = static_cast<btCollisionShape*>(m_mesh->getShape());
|
m_shape = static_cast<btCollisionShape*>(m_mesh->getShape());
|
||||||
vec3 localInertia(0,0,0);
|
vec3 localInertia(0,0,0);
|
||||||
m_shape->calculateLocalInertia(50000000, localInertia); // TODO : BETTER ///
|
m_shape->calculateLocalInertia(50000000, localInertia); // TODO : BETTER ///
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
bool ege::ElementPhysic::setShape(btCollisionShape* _shape) {
|
bool ege::ElementPhysic::setShape(btCollisionShape* _shape) {
|
||||||
EGE_DEBUG("Set Shape");
|
EGE_DEBUG("Set Shape");
|
||||||
removeShape();
|
removeShape();
|
||||||
@ -140,47 +131,55 @@ void ege::ElementPhysic::FunctionFreeShape(void* _pointer) {
|
|||||||
}
|
}
|
||||||
delete(static_cast<btCollisionShape*>(_pointer));
|
delete(static_cast<btCollisionShape*>(_pointer));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
void ege::ElementPhysic::setPosition(const vec3& _pos) {
|
void ege::ElementPhysic::setPosition(const vec3& _pos) {
|
||||||
if (m_body != nullptr) {
|
if (m_body != nullptr) {
|
||||||
|
/*
|
||||||
btTransform transformation = m_body->getCenterOfMassTransform();
|
btTransform transformation = m_body->getCenterOfMassTransform();
|
||||||
transformation.setOrigin(_pos);
|
transformation.setOrigin(_pos);
|
||||||
m_body->setCenterOfMassTransform(transformation);
|
m_body->setCenterOfMassTransform(transformation);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const vec3& ege::ElementPhysic::getPosition() {
|
const vec3& ege::ElementPhysic::getPosition() {
|
||||||
|
/*
|
||||||
if (m_body != nullptr) {
|
if (m_body != nullptr) {
|
||||||
return m_body->getCenterOfMassPosition();
|
return m_body->getCenterOfMassPosition();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return ege::Element::getPosition();
|
return ege::Element::getPosition();
|
||||||
};
|
};
|
||||||
|
|
||||||
const vec3& ege::ElementPhysic::getSpeed() {
|
const vec3& ege::ElementPhysic::getSpeed() {
|
||||||
static vec3 emptySpeed(0,0,0);
|
static vec3 emptySpeed(0,0,0);
|
||||||
|
/*
|
||||||
if (m_body != nullptr) {
|
if (m_body != nullptr) {
|
||||||
return m_body->getLinearVelocity();
|
return m_body->getLinearVelocity();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return emptySpeed;
|
return emptySpeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
const float ege::ElementPhysic::getInvMass() {
|
const float ege::ElementPhysic::getInvMass() {
|
||||||
|
/*
|
||||||
if (m_body != nullptr) {
|
if (m_body != nullptr) {
|
||||||
return m_body->getInvMass();
|
return m_body->getInvMass();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return 0.0000000001f;
|
return 0.0000000001f;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ege::ElementPhysic::drawShape(const btCollisionShape* _shape,
|
void ege::ElementPhysic::drawShape(/*const btCollisionShape* _shape,*/
|
||||||
ememory::SharedPtr<ewol::resource::Colored3DObject> _draw,
|
ememory::SharedPtr<ewol::resource::Colored3DObject> _draw,
|
||||||
mat4 _transformationMatrix,
|
mat4 _transformationMatrix,
|
||||||
std::vector<vec3> _tmpVertices) {
|
std::vector<vec3> _tmpVertices) {
|
||||||
|
#if 0
|
||||||
if( _draw == nullptr
|
if( _draw == nullptr
|
||||||
|| _shape == nullptr) {
|
|| _shape == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
etk::Color<float> tmpColor(1.0, 0.0, 0.0, 0.3);
|
etk::Color<float> tmpColor(1.0, 0.0, 0.0, 0.3);
|
||||||
|
|
||||||
//EGE_DEBUG(" draw (6): !btIDebugDraw::DBG_DrawWireframe");
|
//EGE_DEBUG(" draw (6): !btIDebugDraw::DBG_DrawWireframe");
|
||||||
int shapetype=_shape->getShapeType();
|
int shapetype=_shape->getShapeType();
|
||||||
switch (shapetype) {
|
switch (shapetype) {
|
||||||
@ -316,10 +315,12 @@ void ege::ElementPhysic::drawShape(const btCollisionShape* _shape,
|
|||||||
EGE_DEBUG(" draw (09): default");
|
EGE_DEBUG(" draw (09): default");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::ElementPhysic::drawDebug(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera) {
|
void ege::ElementPhysic::drawDebug(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera) {
|
||||||
ege::Element::drawDebug(_draw, _camera);
|
ege::Element::drawDebug(_draw, _camera);
|
||||||
|
/*
|
||||||
btScalar mmm[16];
|
btScalar mmm[16];
|
||||||
if (m_body == nullptr) {
|
if (m_body == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -333,9 +334,11 @@ void ege::ElementPhysic::drawDebug(ememory::SharedPtr<ewol::resource::Colored3DO
|
|||||||
// note : set the vertice here to prevent multiple allocations...
|
// note : set the vertice here to prevent multiple allocations...
|
||||||
std::vector<vec3> EwolVertices;
|
std::vector<vec3> EwolVertices;
|
||||||
drawShape(m_shape, _draw, transformationMatrix, EwolVertices);
|
drawShape(m_shape, _draw, transformationMatrix, EwolVertices);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::ElementPhysic::drawNormalDebug(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera) {
|
void ege::ElementPhysic::drawNormalDebug(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera) {
|
||||||
|
/*
|
||||||
if( m_body != nullptr
|
if( m_body != nullptr
|
||||||
&& m_mesh != nullptr
|
&& m_mesh != nullptr
|
||||||
&& m_body->getMotionState() ) {
|
&& m_body->getMotionState() ) {
|
||||||
@ -348,12 +351,14 @@ void ege::ElementPhysic::drawNormalDebug(ememory::SharedPtr<ewol::resource::Colo
|
|||||||
transformationMatrix.transpose();
|
transformationMatrix.transpose();
|
||||||
m_mesh->drawNormal(transformationMatrix, _draw);
|
m_mesh->drawNormal(transformationMatrix, _draw);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::ElementPhysic::draw(int32_t _pass) {
|
void ege::ElementPhysic::draw(int32_t _pass) {
|
||||||
if (m_elementInPhysicsSystem == false) {
|
if (m_elementInPhysicsSystem == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
//EGE_INFO("draw : " << _pass );
|
//EGE_INFO("draw : " << _pass );
|
||||||
if (_pass == 0) {
|
if (_pass == 0) {
|
||||||
if( m_body != nullptr
|
if( m_body != nullptr
|
||||||
@ -372,6 +377,7 @@ void ege::ElementPhysic::draw(int32_t _pass) {
|
|||||||
m_mesh->draw(transformationMatrix);
|
m_mesh->draw(transformationMatrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::ElementPhysic::dynamicEnable() {
|
void ege::ElementPhysic::dynamicEnable() {
|
||||||
@ -438,12 +444,14 @@ void ege::ElementPhysic::setMass(float _value) {
|
|||||||
if (m_body == nullptr) {
|
if (m_body == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
vec3 localInertia(0,0,0);
|
vec3 localInertia(0,0,0);
|
||||||
if (_value != 0.0f && getShape()!=nullptr) {
|
if (_value != 0.0f && getShape()!=nullptr) {
|
||||||
//getShape()->calculateLocalInertia(_value, localInertia);
|
//getShape()->calculateLocalInertia(_value, localInertia);
|
||||||
EWOL_ERROR("Update inertia calculated : " << localInertia);
|
EWOL_ERROR("Update inertia calculated : " << localInertia);
|
||||||
}
|
}
|
||||||
//m_body->setMassProps(_value, localInertia);
|
m_body->setMassProps(_value, localInertia);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::ElementPhysic::setLinearVelocity(const vec3& _value) {
|
void ege::ElementPhysic::setLinearVelocity(const vec3& _value) {
|
||||||
@ -454,7 +462,7 @@ void ege::ElementPhysic::setLinearVelocity(const vec3& _value) {
|
|||||||
// Force vector (in Newton)
|
// Force vector (in Newton)
|
||||||
rp3d::Vector3 force(_value.x(), _value.y(), _value.z());
|
rp3d::Vector3 force(_value.x(), _value.y(), _value.z());
|
||||||
// Apply a force to the center of the body
|
// Apply a force to the center of the body
|
||||||
m_body->applyForceToCenter(force);
|
m_body->applyForceToCenterOfMass(force);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::ElementPhysic::setTorqueImpulse(const vec3& _value) {
|
void ege::ElementPhysic::setTorqueImpulse(const vec3& _value) {
|
||||||
@ -475,7 +483,7 @@ void ege::ElementPhysic::setAngularVelocity(const vec3& _value) {
|
|||||||
}
|
}
|
||||||
//m_body->setAngularVelocity(_value);
|
//m_body->setAngularVelocity(_value);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
btQuaternion ege::ElementPhysic::getOrientation() const {
|
btQuaternion ege::ElementPhysic::getOrientation() const {
|
||||||
if (m_body == nullptr) {
|
if (m_body == nullptr) {
|
||||||
EGE_WARNING("no body");
|
EGE_WARNING("no body");
|
||||||
@ -484,6 +492,7 @@ btQuaternion ege::ElementPhysic::getOrientation() const {
|
|||||||
//return m_body->getOrientation();
|
//return m_body->getOrientation();
|
||||||
return btQuaternion(0,0,0,0);
|
return btQuaternion(0,0,0,0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void ege::ElementPhysic::setCollisionDetectionStatus(bool _status) {
|
void ege::ElementPhysic::setCollisionDetectionStatus(bool _status) {
|
||||||
if (m_body == nullptr) {
|
if (m_body == nullptr) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/math/Vector3D.hpp>
|
#include <etk/math/Vector3D.hpp>
|
||||||
#include <etk/math/Matrix4.hpp>
|
#include <etk/math/Matrix4x4.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <ewol/widget/Widget.hpp>
|
#include <ewol/widget/Widget.hpp>
|
||||||
@ -53,7 +53,7 @@ namespace ege {
|
|||||||
*/
|
*/
|
||||||
virtual const std::string& getType() const;
|
virtual const std::string& getType() const;
|
||||||
protected:
|
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:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief set the shape properties.
|
* @brief set the shape properties.
|
||||||
@ -61,19 +61,21 @@ namespace ege {
|
|||||||
* @note : this remove the shape properties.
|
* @note : this remove the shape properties.
|
||||||
* @return true if no error occured
|
* @return true if no error occured
|
||||||
*/
|
*/
|
||||||
bool setShape(btCollisionShape* _shape);
|
//bool setShape(btCollisionShape* _shape);
|
||||||
/**
|
/**
|
||||||
* @brief get a pointer on the bullet collision shape.
|
* @brief get a pointer on the bullet collision shape.
|
||||||
* @return the collision pointer.
|
* @return the collision pointer.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
inline btCollisionShape* getShape() {
|
inline btCollisionShape* getShape() {
|
||||||
return m_shape;
|
return m_shape;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief remove the curent selected shape.
|
* @brief remove the curent selected shape.
|
||||||
*/
|
*/
|
||||||
void removeShape();
|
//void removeShape();
|
||||||
public:
|
public:
|
||||||
virtual bool setMesh(ememory::SharedPtr<ege::resource::Mesh> _mesh);
|
virtual bool setMesh(ememory::SharedPtr<ege::resource::Mesh> _mesh);
|
||||||
/**
|
/**
|
||||||
@ -121,7 +123,7 @@ namespace ege {
|
|||||||
virtual void setTorqueImpulse(const vec3& _value);
|
virtual void setTorqueImpulse(const vec3& _value);
|
||||||
virtual void setAngularVelocity(const vec3& _value);
|
virtual void setAngularVelocity(const vec3& _value);
|
||||||
|
|
||||||
btQuaternion getOrientation() const;
|
//btQuaternion getOrientation() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_elementInPhysicsSystem;
|
bool m_elementInPhysicsSystem;
|
||||||
@ -129,7 +131,7 @@ namespace ege {
|
|||||||
virtual void dynamicEnable();
|
virtual void dynamicEnable();
|
||||||
virtual void dynamicDisable();
|
virtual void dynamicDisable();
|
||||||
private:
|
private:
|
||||||
class localIA : public btActionInterface {
|
class localIA {
|
||||||
private:
|
private:
|
||||||
ege::ElementPhysic& m_element;
|
ege::ElementPhysic& m_element;
|
||||||
public:
|
public:
|
||||||
@ -147,12 +149,14 @@ namespace ege {
|
|||||||
|
|
||||||
};
|
};
|
||||||
public: // herited function
|
public: // herited function
|
||||||
|
/*
|
||||||
void debugDraw(btIDebugDraw* _debugDrawer) {
|
void debugDraw(btIDebugDraw* _debugDrawer) {
|
||||||
|
|
||||||
};
|
};
|
||||||
void updateAction(btCollisionWorld* _collisionWorld, btScalar _step) {
|
void updateAction(btCollisionWorld* _collisionWorld, btScalar _step) {
|
||||||
m_element.iaAction(_step);
|
m_element.iaAction(_step);
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
localIA* m_IA;
|
localIA* m_IA;
|
||||||
public:
|
public:
|
||||||
@ -177,7 +181,7 @@ namespace ege {
|
|||||||
virtual void setPosition(const vec3& _pos);
|
virtual void setPosition(const vec3& _pos);
|
||||||
virtual void drawDebug(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera);
|
virtual void drawDebug(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera);
|
||||||
protected:
|
protected:
|
||||||
void drawShape(const btCollisionShape* _shape,
|
void drawShape(/*const btCollisionShape* _shape,*/
|
||||||
ememory::SharedPtr<ewol::resource::Colored3DObject> _draw,
|
ememory::SharedPtr<ewol::resource::Colored3DObject> _draw,
|
||||||
mat4 _transformationMatrix,
|
mat4 _transformationMatrix,
|
||||||
std::vector<vec3> _tmpVertices);
|
std::vector<vec3> _tmpVertices);
|
||||||
|
@ -9,24 +9,13 @@
|
|||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
|
|
||||||
#include <gale/renderer/openGL/openGL.hpp>
|
#include <gale/renderer/openGL/openGL.hpp>
|
||||||
#include <etk/math/Matrix4.hpp>
|
#include <etk/math/Matrix4x4.hpp>
|
||||||
#include <BulletDynamics/Dynamics/btRigidBody.h>
|
|
||||||
#include <LinearMath/btDefaultMotionState.h>
|
|
||||||
#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
|
|
||||||
#include <LinearMath/btIDebugDraw.h>
|
|
||||||
#include <btBulletCollisionCommon.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btShapeHull.h>
|
|
||||||
#include <LinearMath/btTransformUtil.h>
|
|
||||||
#include <LinearMath/btIDebugDraw.h>
|
|
||||||
#include <btBulletDynamicsCommon.h>
|
|
||||||
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
|
|
||||||
|
|
||||||
#include <ege/elements/ElementPhysic.hpp>
|
#include <ege/elements/ElementPhysic.hpp>
|
||||||
|
|
||||||
|
|
||||||
// unique callback function :
|
// unique callback function :
|
||||||
|
/*
|
||||||
extern ContactProcessedCallback gContactProcessedCallback;
|
extern ContactProcessedCallback gContactProcessedCallback;
|
||||||
|
|
||||||
// TODO : remove double collision call ...
|
// TODO : remove double collision call ...
|
||||||
@ -47,7 +36,7 @@ static bool handleContactsProcess(btManifoldPoint& _point, btCollisionObject* _b
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
ege::physics::Engine::Engine():
|
ege::physics::Engine::Engine():
|
||||||
m_dynamicsWorld(nullptr),
|
m_dynamicsWorld(nullptr),
|
||||||
@ -68,7 +57,8 @@ ege::physics::Engine::~Engine() {
|
|||||||
|
|
||||||
void ege::physics::Engine::setGravity(const vec3& _axePower) {
|
void ege::physics::Engine::setGravity(const vec3& _axePower) {
|
||||||
if (m_dynamicsWorld != nullptr) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ namespace ege {
|
|||||||
};
|
};
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/math/Vector3D.hpp>
|
#include <etk/math/Vector3D.hpp>
|
||||||
#include <etk/math/Matrix4.hpp>
|
#include <etk/math/Matrix4x4.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <ege/camera/Camera.hpp>
|
#include <ege/camera/Camera.hpp>
|
||||||
@ -20,6 +20,7 @@ namespace ege {
|
|||||||
#include <gale/renderer/openGL/openGL.hpp>
|
#include <gale/renderer/openGL/openGL.hpp>
|
||||||
#include <gale/resource/Manager.hpp>
|
#include <gale/resource/Manager.hpp>
|
||||||
#include <gale/Dimension.hpp>
|
#include <gale/Dimension.hpp>
|
||||||
|
#include <ephysics/reactphysics3d.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ege {
|
namespace ege {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <ewol/ewol.hpp>
|
#include <ewol/ewol.hpp>
|
||||||
#include <ewol/object/Manager.hpp>
|
#include <ewol/object/Manager.hpp>
|
||||||
#include <gale/renderer/openGL/openGL.hpp>
|
#include <gale/renderer/openGL/openGL.hpp>
|
||||||
#include <etk/math/Matrix4.hpp>
|
#include <etk/math/Matrix4x4.hpp>
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
template<> std::string to_string<ememory::SharedPtr<ewol::resource::Colored3DObject> >(const ememory::SharedPtr<ewol::resource::Colored3DObject>& _value) {
|
template<> std::string to_string<ememory::SharedPtr<ewol::resource::Colored3DObject> >(const ememory::SharedPtr<ewol::resource::Colored3DObject>& _value) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <etk/math/Vector3D.hpp>
|
#include <etk/math/Vector3D.hpp>
|
||||||
#include <etk/math/Matrix4.hpp>
|
#include <etk/math/Matrix4x4.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <ewol/debug.hpp>
|
#include <ewol/debug.hpp>
|
||||||
#include <ege/camera/Camera.hpp>
|
#include <ege/camera/Camera.hpp>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user