[DEV] correct some physics error
This commit is contained in:
parent
39ecb28335
commit
c770439228
@ -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([
|
||||
|
@ -25,7 +25,7 @@
|
||||
btCollisionShape* ege::collision::createShape(const ememory::SharedPtr<ege::resource::Mesh>& _mesh) {
|
||||
if (_mesh == nullptr) {
|
||||
EGE_ERROR("Create empty shape (no mesh)");
|
||||
return new btEmptyShape();;
|
||||
return new btEmptyShape();
|
||||
}
|
||||
const std::vector<ememory::SharedPtr<ege::PhysicsShape>>& physiqueProperty = _mesh->getPhysicalProperties();
|
||||
if (physiqueProperty.size() == 0) {
|
||||
|
@ -310,7 +310,7 @@ void ege::Environement::getOrderedElementForDisplay(std::vector<ege::Environemen
|
||||
result.element = nullptr;
|
||||
// for all element in the game we chek if it is needed to display it ...
|
||||
for (size_t iii=0; iii<m_listElement.size() ; iii++) {
|
||||
// chack nullptr pointer
|
||||
// check nullptr pointer
|
||||
if (m_listElement[iii] == nullptr) {
|
||||
// no pointer null are set in the output list ...
|
||||
continue;
|
||||
|
@ -54,7 +54,7 @@ ege::ElementPhysic::~ElementPhysic() {
|
||||
}
|
||||
|
||||
|
||||
void ege::ElementPhysic::createRigidBody(float _mass) {
|
||||
void ege::ElementPhysic::createRigidBody(float _mass, bool _static) {
|
||||
/// Create Dynamic Objects
|
||||
btTransform startTransform;
|
||||
startTransform.setIdentity();
|
||||
@ -71,16 +71,18 @@ void ege::ElementPhysic::createRigidBody(float _mass) {
|
||||
m_body = new btRigidBody(rbInfo);
|
||||
m_body->setUserPointer((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<ege::resource::Mesh> _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<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _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<ewol::resource::Colo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ege::ElementPhysic::draw(int32_t _pass) {
|
||||
if (m_elementInPhysicsSystem == false) {
|
||||
return;
|
||||
|
@ -34,7 +34,7 @@ namespace ege {
|
||||
protected:
|
||||
btRigidBody* m_body; //!< all the element have a body == > 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.
|
||||
|
@ -104,6 +104,12 @@ void ege::physics::Engine::setBulletConfig(ememory::SharedPtr<btDefaultCollision
|
||||
//m_env.setDynamicWorld(m_dynamicsWorld);
|
||||
}
|
||||
|
||||
void ege::physics::Engine::setGravity(const vec3& _axePower) {
|
||||
if (m_dynamicsWorld != nullptr) {
|
||||
m_dynamicsWorld->setGravity(_axePower);
|
||||
}
|
||||
}
|
||||
|
||||
// some doccumantation : http://www.bulletphysics.org/mediawiki-1.5.8/index.php?title=Collision_Callbacks_and_Triggers
|
||||
std::vector<ege::physics::Engine::collisionPoints> ege::physics::Engine::getListOfCollision() {
|
||||
std::vector<collisionPoints> out;
|
||||
|
@ -94,6 +94,11 @@ namespace ege {
|
||||
* @return the requested list of points
|
||||
*/
|
||||
std::vector<ege::physics::Engine::collisionPoints> getListOfCollision();
|
||||
/**
|
||||
* @brief Set the gravity axis of the physic engine
|
||||
* @param[in] _axePower energy of this gravity
|
||||
*/
|
||||
void setGravity(const vec3& _axePower);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -129,12 +129,14 @@ void ege::widget::Scene::onDraw() {
|
||||
m_displayElementOrdered[iii].element->drawDebug(m_debugDrawProperty, camera);
|
||||
}
|
||||
// Draw debug ... (Camera)
|
||||
/*
|
||||
std::map<std::string, ememory::SharedPtr<ege::Camera>> 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)
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user