[DEV] update change namespace rp3d in ephysics and header type
This commit is contained in:
parent
18daa6836d
commit
51d3dd80bf
@ -14,8 +14,8 @@
|
||||
#include <ege/physics/shape/Cylinder.hpp>
|
||||
#include <ege/physics/shape/Sphere.hpp>
|
||||
#include <ege/physics/shape/Concave.hpp>
|
||||
#include <ephysics/collision/shapes/ConcaveShape.h>
|
||||
#include <ephysics/collision/shapes/ConcaveMeshShape.h>
|
||||
#include <ephysics/collision/shapes/ConcaveShape.hpp>
|
||||
#include <ephysics/collision/shapes/ConcaveMeshShape.hpp>
|
||||
|
||||
const std::string& ege::physics::Component::getType() const {
|
||||
static std::string tmp("physics");
|
||||
@ -70,13 +70,13 @@ void ege::physics::Component::setType(enum ege::physics::Component::type _type)
|
||||
}
|
||||
switch(_type) {
|
||||
case ege::physics::Component::type::bodyStatic:
|
||||
m_rigidBody->setType(rp3d::STATIC);
|
||||
m_rigidBody->setType(ephysics::STATIC);
|
||||
break;
|
||||
case ege::physics::Component::type::bodyKinematic:
|
||||
m_rigidBody->setType(rp3d::KINEMATIC);
|
||||
m_rigidBody->setType(ephysics::KINEMATIC);
|
||||
break;
|
||||
case ege::physics::Component::type::bodyDynamic:
|
||||
m_rigidBody->setType(rp3d::DYNAMIC);
|
||||
m_rigidBody->setType(ephysics::DYNAMIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -115,12 +115,12 @@ void ege::physics::Component::generate() {
|
||||
tmpElement->getSize().y(),
|
||||
tmpElement->getSize().z());
|
||||
// Create the box shape
|
||||
rp3d::BoxShape* shape = new rp3d::BoxShape(halfExtents, 0.0001);
|
||||
ephysics::BoxShape* shape = new ephysics::BoxShape(halfExtents, 0.0001);
|
||||
m_listShape.push_back(shape);
|
||||
// The ephysic use Y as UP ==> ege use Z as UP
|
||||
//orientation = orientation * rp3d::Quaternion(-0.707107, 0, 0, 0.707107);
|
||||
//orientation = orientation * ephysics::Quaternion(-0.707107, 0, 0, 0.707107);
|
||||
etk::Transform3D transform(it->getOrigin(), it->getOrientation());
|
||||
rp3d::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
ephysics::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
proxyShape->setUserData(this);
|
||||
m_listProxyShape.push_back(proxyShape);
|
||||
break;
|
||||
@ -133,11 +133,11 @@ void ege::physics::Component::generate() {
|
||||
continue;
|
||||
}
|
||||
// Create the Cylinder shape
|
||||
rp3d::CylinderShape* shape = new rp3d::CylinderShape(tmpElement->getRadius(), tmpElement->getSize());
|
||||
ephysics::CylinderShape* shape = new ephysics::CylinderShape(tmpElement->getRadius(), tmpElement->getSize());
|
||||
// The ephysic use Y as UP ==> ege use Z as UP
|
||||
etk::Quaternion orientation = it->getOrientation() * etk::Quaternion(-0.707107, 0, 0, 0.707107);
|
||||
etk::Transform3D transform(it->getOrigin(), orientation);
|
||||
rp3d::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
ephysics::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
proxyShape->setUserData(this);
|
||||
m_listProxyShape.push_back(proxyShape);
|
||||
break;
|
||||
@ -150,11 +150,11 @@ void ege::physics::Component::generate() {
|
||||
continue;
|
||||
}
|
||||
// Create the Capsule shape
|
||||
rp3d::CapsuleShape* shape = new rp3d::CapsuleShape(tmpElement->getRadius(), tmpElement->getSize());
|
||||
ephysics::CapsuleShape* shape = new ephysics::CapsuleShape(tmpElement->getRadius(), tmpElement->getSize());
|
||||
// The ephysic use Y as UP ==> ege use Z as UP
|
||||
etk::Quaternion orientation = it->getOrientation() * etk::Quaternion(-0.707107, 0, 0, 0.707107);
|
||||
etk::Transform3D transform(it->getOrigin(), orientation);
|
||||
rp3d::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
ephysics::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
proxyShape->setUserData(this);
|
||||
m_listProxyShape.push_back(proxyShape);
|
||||
break;
|
||||
@ -167,11 +167,11 @@ void ege::physics::Component::generate() {
|
||||
continue;
|
||||
}
|
||||
// Create the Cone shape
|
||||
rp3d::ConeShape* shape = new rp3d::ConeShape(tmpElement->getRadius(), tmpElement->getSize());
|
||||
ephysics::ConeShape* shape = new ephysics::ConeShape(tmpElement->getRadius(), tmpElement->getSize());
|
||||
// The ephysic use Y as UP ==> ege use Z as UP
|
||||
etk::Quaternion orientation = it->getOrientation() * etk::Quaternion(-0.707107, 0, 0, 0.707107);
|
||||
etk::Transform3D transform(it->getOrigin(), orientation);
|
||||
rp3d::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
ephysics::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
proxyShape->setUserData(this);
|
||||
m_listProxyShape.push_back(proxyShape);
|
||||
break;
|
||||
@ -184,11 +184,11 @@ void ege::physics::Component::generate() {
|
||||
continue;
|
||||
}
|
||||
// Create the box shape
|
||||
rp3d::SphereShape* shape = new rp3d::SphereShape(tmpElement->getRadius());
|
||||
ephysics::SphereShape* shape = new ephysics::SphereShape(tmpElement->getRadius());
|
||||
// The ephysic use Y as UP ==> ege use Z as UP
|
||||
etk::Quaternion orientation = it->getOrientation() * etk::Quaternion(-0.707107, 0, 0, 0.707107);
|
||||
etk::Transform3D transform(it->getOrigin(), orientation);
|
||||
rp3d::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
ephysics::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
proxyShape->setUserData(this);
|
||||
m_listProxyShape.push_back(proxyShape);
|
||||
break;
|
||||
@ -217,26 +217,26 @@ void ege::physics::Component::generate() {
|
||||
// TODO : Manage memory leak ...
|
||||
//we have an error here ...
|
||||
|
||||
rp3d::TriangleVertexArray* triangleArray = new rp3d::TriangleVertexArray(nbVertices,
|
||||
ephysics::TriangleVertexArray* triangleArray = new ephysics::TriangleVertexArray(nbVertices,
|
||||
(void*)vertices,
|
||||
3 * sizeof(float),
|
||||
nbTriangles,
|
||||
(void*)indices,
|
||||
sizeof(int),
|
||||
rp3d::TriangleVertexArray::VERTEX_FLOAT_TYPE,
|
||||
rp3d::TriangleVertexArray::INDEX_INTEGER_TYPE);
|
||||
ephysics::TriangleVertexArray::VERTEX_FLOAT_TYPE,
|
||||
ephysics::TriangleVertexArray::INDEX_INTEGER_TYPE);
|
||||
// Now that we have a TriangleVertexArray, we need to create a TriangleMesh and add the TriangleVertexArray into it as a subpart.
|
||||
// Once this is done, we can create the actual ConcaveMeshShape and add it to the body we want to simulate as in the following example:
|
||||
rp3d::TriangleMesh triangleMesh;
|
||||
ephysics::TriangleMesh triangleMesh;
|
||||
// Add the triangle vertex array to the triangle mesh
|
||||
triangleMesh.addSubpart(triangleArray);
|
||||
// Create the concave mesh shape
|
||||
// TODO : Manage memory leak ...
|
||||
reactphysics3d::ConcaveShape* shape = new reactphysics3d::ConcaveMeshShape(&triangleMesh);
|
||||
ephysics::ConcaveShape* shape = new ephysics::ConcaveMeshShape(&triangleMesh);
|
||||
// The ephysic use Y as UP ==> ege use Z as UP
|
||||
//etk::Quaternion orientation = it->getOrientation() * rp3d::Quaternion(-0.707107, 0, 0, 0.707107);
|
||||
//etk::Quaternion orientation = it->getOrientation() * ephysics::Quaternion(-0.707107, 0, 0, 0.707107);
|
||||
etk::Transform3D transform(it->getOrigin(), it->getOrientation());
|
||||
rp3d::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
ephysics::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||
proxyShape->setUserData(this);
|
||||
m_listProxyShape.push_back(proxyShape);
|
||||
break;
|
||||
@ -538,7 +538,7 @@ void ege::physics::Component::drawAABB(ememory::SharedPtr<ewol::resource::Colore
|
||||
}
|
||||
mat4 transformationMatrix;
|
||||
etk::Color<float> tmpColor(0.0, 1.0, 0.0, 0.8);
|
||||
rp3d::AABB value = m_rigidBody->getAABB();
|
||||
ephysics::AABB value = m_rigidBody->getAABB();
|
||||
_draw->drawCubeLine(value.getMin(), value.getMax(), tmpColor, transformationMatrix);
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <ege/Component.hpp>
|
||||
#include <etk/math/Transform3D.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <ephysics/reactphysics3d.h>
|
||||
#include <ephysics/ephysics.hpp>
|
||||
#include <ege/resource/Mesh.hpp>
|
||||
#include <ege/camera/Camera.hpp>
|
||||
|
||||
@ -20,16 +20,16 @@ namespace ege {
|
||||
class Engine;
|
||||
class Component :
|
||||
public ege::Component/*,
|
||||
public rp3d::CollisionCallback*/ {
|
||||
public ephysics::CollisionCallback*/ {
|
||||
public:
|
||||
esignal::Signal<etk::Transform3D> signalPosition;
|
||||
protected:
|
||||
etk::Transform3D m_lastTransformEmit;
|
||||
protected:
|
||||
ememory::SharedPtr<ege::physics::Engine> m_engine;
|
||||
rp3d::RigidBody* m_rigidBody;
|
||||
std::vector<rp3d::CollisionShape*> m_listShape;
|
||||
std::vector<rp3d::ProxyShape*> m_listProxyShape;
|
||||
ephysics::RigidBody* m_rigidBody;
|
||||
std::vector<ephysics::CollisionShape*> m_listShape;
|
||||
std::vector<ephysics::ProxyShape*> m_listProxyShape;
|
||||
public:
|
||||
/**
|
||||
* @brief Create a basic position component (no orientation and position (0,0,0))
|
||||
|
@ -17,7 +17,7 @@ const std::string& ege::physics::Engine::getType() const {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void ege::physics::Engine::beginContact(const rp3d::ContactPointInfo& _contact) {
|
||||
void ege::physics::Engine::beginContact(const ephysics::ContactPointInfo& _contact) {
|
||||
ege::physics::Component* component1 = nullptr;
|
||||
ege::physics::Component* component2 = nullptr;
|
||||
// Called when a new contact point is found between two bodies that were separated before.
|
||||
@ -38,7 +38,7 @@ void ege::physics::Engine::beginContact(const rp3d::ContactPointInfo& _contact)
|
||||
}
|
||||
}
|
||||
|
||||
void ege::physics::Engine::newContact(const rp3d::ContactPointInfo& _contact) {
|
||||
void ege::physics::Engine::newContact(const ephysics::ContactPointInfo& _contact) {
|
||||
ege::physics::Component* component1 = nullptr;
|
||||
ege::physics::Component* component2 = nullptr;
|
||||
//Called when a new contact point is found between two bodies.
|
||||
@ -94,7 +94,7 @@ ege::physics::Engine::Engine(ege::Environement* _env) :
|
||||
// Start engine with no gravity
|
||||
vec3 gravity(0.0f, 0.0f, 0.0f);
|
||||
// Create the dynamics world
|
||||
m_dynamicsWorld = new rp3d::DynamicsWorld(gravity);
|
||||
m_dynamicsWorld = new ephysics::DynamicsWorld(gravity);
|
||||
if (m_dynamicsWorld != nullptr) {
|
||||
// Set the number of iterations of the constraint solver
|
||||
m_dynamicsWorld->setNbIterationsVelocitySolver(15);
|
||||
@ -172,19 +172,19 @@ void ege::physics::Engine::renderDebug(const echrono::Duration& _delta, const em
|
||||
}
|
||||
}
|
||||
|
||||
class MyCallbackClass : public rp3d::RaycastCallback {
|
||||
class MyCallbackClass : public ephysics::RaycastCallback {
|
||||
public:
|
||||
vec3 m_position;
|
||||
vec3 m_normal;
|
||||
bool m_haveImpact;
|
||||
rp3d::CollisionBody* m_body;
|
||||
ephysics::CollisionBody* m_body;
|
||||
MyCallbackClass():
|
||||
m_haveImpact(false),
|
||||
m_body(nullptr) {
|
||||
|
||||
}
|
||||
public:
|
||||
virtual float notifyRaycastHit(const rp3d::RaycastInfo& _info) {
|
||||
virtual float notifyRaycastHit(const ephysics::RaycastInfo& _info) {
|
||||
m_haveImpact = true;
|
||||
// Display the world hit point coordinates
|
||||
m_position = _info.worldPoint;
|
||||
@ -201,7 +201,7 @@ std::pair<vec3,vec3> ege::physics::Engine::testRay(const ege::Ray& _ray) {
|
||||
vec3 stop = _ray.getOrigin()+_ray.getDirection()*1000.0f;
|
||||
// Start and End are vectors
|
||||
// Create the ray
|
||||
rp3d::Ray ray(start, stop);
|
||||
ephysics::Ray ray(start, stop);
|
||||
// Create an instance of your callback class
|
||||
MyCallbackClass callbackObject;
|
||||
// Raycast test
|
||||
@ -218,7 +218,7 @@ std::pair<ememory::SharedPtr<ege::Component>, std::pair<vec3,vec3>> ege::physics
|
||||
vec3 stop = _ray.getOrigin()+_ray.getDirection()*1000.0f;
|
||||
// Start and End are vectors
|
||||
// Create the ray
|
||||
rp3d::Ray ray(start, stop);
|
||||
ephysics::Ray ray(start, stop);
|
||||
// Create an instance of your callback class
|
||||
MyCallbackClass callbackObject;
|
||||
// Raycast test
|
||||
|
@ -22,7 +22,7 @@ namespace ege {
|
||||
#include <gale/renderer/openGL/openGL.hpp>
|
||||
#include <gale/resource/Manager.hpp>
|
||||
#include <gale/Dimension.hpp>
|
||||
#include <ephysics/reactphysics3d.h>
|
||||
#include <ephysics/ephysics.hpp>
|
||||
#include <ege/physics/Component.hpp>
|
||||
#include <eproperty/Value.hpp>
|
||||
#include <ege/Ray.hpp>
|
||||
@ -33,12 +33,12 @@ namespace ege {
|
||||
namespace physics {
|
||||
class Engine:
|
||||
public ege::Engine,
|
||||
public rp3d::EventListener {
|
||||
public ephysics::EventListener {
|
||||
public:
|
||||
eproperty::Value<bool> propertyDebugAABB;
|
||||
eproperty::Value<bool> propertyDebugShape;
|
||||
private:
|
||||
rp3d::DynamicsWorld* m_dynamicsWorld;
|
||||
ephysics::DynamicsWorld* m_dynamicsWorld;
|
||||
float m_accumulator; // limit call of the step rendering
|
||||
public:
|
||||
Engine(ege::Environement* _env);
|
||||
@ -49,7 +49,7 @@ namespace ege {
|
||||
* @param[in] _axePower energy of this gravity
|
||||
*/
|
||||
void setGravity(const vec3& _axePower);
|
||||
rp3d::DynamicsWorld* getDynamicWorld() {
|
||||
ephysics::DynamicsWorld* getDynamicWorld() {
|
||||
return m_dynamicsWorld;
|
||||
}
|
||||
protected:
|
||||
@ -64,8 +64,8 @@ namespace ege {
|
||||
void renderDebug(const echrono::Duration& _delta, const ememory::SharedPtr<ege::Camera>& _camera) override;
|
||||
private:
|
||||
// herited from rp3D::EventListener
|
||||
void beginContact(const rp3d::ContactPointInfo& _contact) override;
|
||||
void newContact(const rp3d::ContactPointInfo& _contact) override;
|
||||
void beginContact(const ephysics::ContactPointInfo& _contact) override;
|
||||
void newContact(const ephysics::ContactPointInfo& _contact) override;
|
||||
public:
|
||||
/**
|
||||
* @brief Test a rayCasting on the physic engine
|
||||
|
Loading…
x
Reference in New Issue
Block a user