From 73455cc61be78fd2a76466fb8c6a1aaabe68bf61 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 30 May 2014 23:20:09 +0200 Subject: [PATCH] [DEV] update new version of ewol API 0.9 --- ege/CollisionShapeCreator.cpp | 48 +++++++------- ege/CollisionShapeCreator.h | 2 +- ege/ElementGame.cpp | 81 ++++++++++++----------- ege/ElementGame.h | 12 ++-- ege/Environement.cpp | 58 ++++++++--------- ege/Environement.h | 6 +- ege/Light.cpp | 6 +- ege/Light.h | 4 +- ege/Material.cpp | 22 +++---- ege/Material.h | 14 ++-- ege/Particule.h | 4 +- ege/ParticuleEngine.cpp | 40 ++++++------ ege/ParticuleEngine.h | 4 +- ege/physicsShape/PhysicsConvexHull.cpp | 2 +- ege/physicsShape/PhysicsShape.cpp | 6 +- ege/physicsShape/PhysicsShape.h | 24 +++---- ege/resource/Mesh.cpp | 89 +++++++++++--------------- ege/resource/Mesh.h | 15 ++--- ege/resource/ParticuleMesh.cpp | 25 +++----- ege/resource/ParticuleMesh.h | 11 +--- ege/widget/Mesh.cpp | 13 ++-- ege/widget/Mesh.h | 2 +- ege/widget/Scene.cpp | 27 ++++---- ege/widget/Scene.h | 14 ++-- 24 files changed, 245 insertions(+), 284 deletions(-) diff --git a/ege/CollisionShapeCreator.cpp b/ege/CollisionShapeCreator.cpp index c1c207d..5ac4183 100644 --- a/ege/CollisionShapeCreator.cpp +++ b/ege/CollisionShapeCreator.cpp @@ -27,8 +27,8 @@ #undef __class__ #define __class__ "CollisionShapeCreator" -btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) { - if (NULL == _mesh) { +btCollisionShape* ege::collision::createShape(const ewol::object::Shared& _mesh) { + if (nullptr == _mesh) { return new btEmptyShape();; } const std::vector& physiqueProperty = _mesh->getPhysicalProperties(); @@ -37,29 +37,29 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) } int32_t count = 0; for (size_t iii=0; iii1) { outputShape = new btCompoundShape(); } for (size_t iii=0; iiigetType()) { case ege::PhysicsShape::box : { const ege::PhysicsBox* tmpElement = physiqueProperty[iii]->toBox(); - if (NULL == tmpElement) { + if (nullptr == tmpElement) { // ERROR ... continue; } btCollisionShape* tmpShape = new btBoxShape(tmpElement->getSize()); - if (NULL != tmpShape) { - if (outputShape == NULL) { + if (nullptr != tmpShape) { + if (outputShape == nullptr) { return tmpShape; } else { vec4 qqq = tmpElement->getQuaternion(); @@ -71,13 +71,13 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) } case ege::PhysicsShape::cylinder : { const ege::PhysicsCylinder* tmpElement = physiqueProperty[iii]->toCylinder(); - if (NULL == tmpElement) { + if (nullptr == tmpElement) { // ERROR ... continue; } btCollisionShape* tmpShape = new btCylinderShape(tmpElement->getSize()); - if (NULL != tmpShape) { - if (outputShape == NULL) { + if (nullptr != tmpShape) { + if (outputShape == nullptr) { return tmpShape; } else { vec4 qqq = tmpElement->getQuaternion(); @@ -89,13 +89,13 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) } case ege::PhysicsShape::capsule : { const ege::PhysicsCapsule* tmpElement = physiqueProperty[iii]->toCapsule(); - if (NULL == tmpElement) { + if (nullptr == tmpElement) { // ERROR ... continue; } btCollisionShape* tmpShape = new btCapsuleShape(tmpElement->getRadius(), tmpElement->getHeight()); - if (NULL != tmpShape) { - if (outputShape == NULL) { + if (nullptr != tmpShape) { + if (outputShape == nullptr) { return tmpShape; } else { vec4 qqq = tmpElement->getQuaternion(); @@ -107,13 +107,13 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) } case ege::PhysicsShape::cone : { const ege::PhysicsCone* tmpElement = physiqueProperty[iii]->toCone(); - if (NULL == tmpElement) { + if (nullptr == tmpElement) { // ERROR ... continue; } btCollisionShape* tmpShape = new btConeShape(tmpElement->getRadius(), tmpElement->getHeight()); - if (NULL != tmpShape) { - if (outputShape == NULL) { + if (nullptr != tmpShape) { + if (outputShape == nullptr) { return tmpShape; } else { vec4 qqq = tmpElement->getQuaternion(); @@ -125,13 +125,13 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) } case ege::PhysicsShape::sphere : { const ege::PhysicsSphere* tmpElement = physiqueProperty[iii]->toSphere(); - if (NULL == tmpElement) { + if (nullptr == tmpElement) { // ERROR ... continue; } btCollisionShape* tmpShape = new btSphereShape(tmpElement->getRadius()); - if (NULL != tmpShape) { - if (outputShape == NULL) { + if (nullptr != tmpShape) { + if (outputShape == nullptr) { return tmpShape; } else { vec4 qqq = tmpElement->getQuaternion(); @@ -143,13 +143,13 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) } case ege::PhysicsShape::convexHull : { const ege::PhysicsConvexHull* tmpElement = physiqueProperty[iii]->toConvexHull(); - if (NULL == tmpElement) { + if (nullptr == tmpElement) { // ERROR ... continue; } btConvexHullShape* tmpShape = new btConvexHullShape(&(tmpElement->getPointList()[0].x()), tmpElement->getPointList().size()); - if (NULL != tmpShape) { - if (outputShape == NULL) { + if (nullptr != tmpShape) { + if (outputShape == nullptr) { return tmpShape; } else { vec4 qqq = tmpElement->getQuaternion(); @@ -164,7 +164,7 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) break; } } - if (NULL == outputShape) { + if (nullptr == outputShape) { return new btEmptyShape(); } return outputShape; diff --git a/ege/CollisionShapeCreator.h b/ege/CollisionShapeCreator.h index 1c0ce01..03226fb 100644 --- a/ege/CollisionShapeCreator.h +++ b/ege/CollisionShapeCreator.h @@ -16,7 +16,7 @@ namespace ege { namespace collision { - btCollisionShape* createShape(const ege::resource::Mesh* _mesh); + btCollisionShape* createShape(const ewol::object::Shared& _mesh); }; }; #endif diff --git a/ege/ElementGame.cpp b/ege/ElementGame.cpp index c52d9df..f0c3659 100644 --- a/ege/ElementGame.cpp +++ b/ege/ElementGame.cpp @@ -36,17 +36,17 @@ const std::string& ege::ElementGame::getType() const { ege::ElementGame::ElementGame(ege::Environement& _env) : m_env(_env), - m_body(NULL), + m_body(nullptr), m_uID(0), - m_mesh(NULL), - m_shape(NULL), + m_mesh(nullptr), + m_shape(nullptr), m_life(100), m_lifeMax(100), m_group(0), m_fixe(true), m_radius(0), m_elementInPhysicsSystem(false), - m_IA(NULL) { + m_IA(nullptr) { static uint32_t unique=0; m_uID = unique; EGE_DEBUG("Create element : uId=" << m_uID); @@ -60,61 +60,60 @@ ege::ElementGame::~ElementGame() { // same ... dynamicDisable(); removeShape(); - ege::resource::Mesh::release(m_mesh); - if (NULL != m_body) { + if (nullptr != m_body) { delete(m_body); - m_body = NULL; + m_body = nullptr; } EGE_DEBUG("Destroy element : uId=" << m_uID); } void ege::ElementGame::removeShape() { // no shape - if (NULL == m_shape) { + if (nullptr == m_shape) { return; } // need to chek if the shape is the same as the mesh shape ... - if (m_mesh == NULL) { + if (m_mesh == nullptr) { // no mesh == > standalone shape delete(m_shape); - m_shape=NULL; + m_shape=nullptr; return; } if (m_shape != m_mesh->getShape()) { delete(m_shape); - m_shape=NULL; + m_shape=nullptr; return; } // otherwise : the shape is auto remove by the resources when no more needed ... } void ege::ElementGame::FunctionFreeShape(void* _pointer) { - if (NULL == _pointer) { + if (nullptr == _pointer) { return; } delete(static_cast(_pointer)); } bool ege::ElementGame::loadMesh(const std::string& _meshFileName) { - ege::resource::Mesh* tmpMesh = ege::resource::Mesh::keep(_meshFileName); - if(NULL == tmpMesh) { + ewol::object::Shared tmpMesh = ege::resource::Mesh::keep(_meshFileName); + if(nullptr == tmpMesh) { EGE_ERROR("can not load the resources : " << _meshFileName); return false; } return setMesh(tmpMesh); } -bool ege::ElementGame::setMesh(ege::resource::Mesh* _mesh) { - if (NULL!=m_mesh) { +bool ege::ElementGame::setMesh(const ewol::object::Shared& _mesh) { + if (nullptr!=m_mesh) { removeShape(); - ege::resource::Mesh::release(m_mesh); + m_mesh.reset(); } m_mesh = _mesh; // auto load the shape : - if (NULL == m_mesh) { + if (m_mesh == nullptr) { return true; } - if (NULL != m_mesh->getShape()) { + if (m_mesh->getShape() != nullptr) { m_shape = static_cast(m_mesh->getShape()); return true; } @@ -150,7 +149,7 @@ void ege::ElementGame::setFireOn(int32_t _groupIdSource, int32_t _type, float _p } void ege::ElementGame::setPosition(const vec3& _pos) { - if (NULL!=m_body) { + if (nullptr!=m_body) { btTransform transformation = m_body->getCenterOfMassTransform(); transformation.setOrigin(_pos); m_body->setCenterOfMassTransform(transformation); @@ -160,7 +159,7 @@ void ege::ElementGame::setPosition(const vec3& _pos) { const vec3& ege::ElementGame::getPosition() { // this is to prevent error like segmentation fault ... static vec3 emptyPosition(-1000000,-1000000,-1000000); - if (NULL!=m_body) { + if (nullptr!=m_body) { return m_body->getCenterOfMassPosition(); } return emptyPosition; @@ -169,20 +168,20 @@ const vec3& ege::ElementGame::getPosition() { const vec3& ege::ElementGame::getSpeed() { // this is to prevent error like segmentation fault ... static vec3 emptySpeed(0,0,0); - if (NULL!=m_body) { + if (nullptr!=m_body) { return m_body->getLinearVelocity(); } return emptySpeed; }; const float ege::ElementGame::getInvMass() { - if (NULL!=m_body) { + if (nullptr!=m_body) { return m_body->getInvMass(); } return 0.0000000001f; }; -static void drawSphere(ewol::resource::Colored3DObject* _draw, +static void drawSphere(const ewol::object::Shared& _draw, btScalar _radius, int _lats, int _longs, @@ -230,8 +229,8 @@ const float lifeHeight = 0.3f; const float lifeWidth = 2.0f; const float lifeYPos = 1.7f; -void ege::ElementGame::drawLife(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera) { - if (NULL == _draw) { +void ege::ElementGame::drawLife(const ewol::object::Shared& _draw, const ege::Camera& _camera) { + if (nullptr == _draw) { return; } float ratio = getLifeRatio(); @@ -268,11 +267,11 @@ void ege::ElementGame::drawLife(ewol::resource::Colored3DObject* _draw, const eg } static void drawShape(const btCollisionShape* _shape, - ewol::resource::Colored3DObject* _draw, + const ewol::object::Shared& _draw, mat4 _transformationMatrix, std::vector _tmpVertices) { - if( NULL == _draw - || NULL == _shape) { + if( nullptr == _draw + || nullptr == _shape) { return; } etk::Color tmpColor(1.0, 0.0, 0.0, 0.3); @@ -338,7 +337,7 @@ static void drawShape(const btCollisionShape* _shape, if (_shape->isConvex()) { EGE_DEBUG(" shape->isConvex()"); const btConvexPolyhedron* poly = _shape->isPolyhedral() ? ((btPolyhedralConvexShape*) _shape)->getConvexPolyhedron() : 0; - if (NULL!=poly) { + if (nullptr!=poly) { EGE_DEBUG(" have poly"); /* glBegin(GL_TRIANGLES); @@ -435,7 +434,7 @@ static void drawShape(const btCollisionShape* _shape, } } -void ege::ElementGame::drawDebug(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera) { +void ege::ElementGame::drawDebug(const ewol::object::Shared& _draw, const ege::Camera& _camera) { m_debugText.clear(); m_debugText.setColor(0x00FF00FF); m_debugText.setPos(vec3(-20,32,0)); @@ -465,8 +464,8 @@ void ege::ElementGame::draw(int32_t _pass) { return; } if (_pass == 0) { - if( NULL != m_body - && NULL != m_mesh + if( nullptr != m_body + && nullptr != m_mesh && m_body->getMotionState() ) { btScalar mmm[16]; btDefaultMotionState* myMotionState = (btDefaultMotionState*)m_body->getMotionState(); @@ -483,10 +482,10 @@ void ege::ElementGame::dynamicEnable() { if (true == m_elementInPhysicsSystem) { return; } - if(NULL!=m_body) { + if(nullptr!=m_body) { m_env.getDynamicWorld()->addRigidBody(m_body); } - if(NULL!=m_IA) { + if(nullptr!=m_IA) { m_env.getDynamicWorld()->addAction(m_IA); } m_elementInPhysicsSystem = true; @@ -496,10 +495,10 @@ void ege::ElementGame::dynamicDisable() { if (false == m_elementInPhysicsSystem) { return; } - if(NULL!=m_IA) { + if(nullptr!=m_IA) { m_env.getDynamicWorld()->removeAction(m_IA); } - if(NULL!=m_body) { + if(nullptr!=m_body) { // Unlink element from the engine m_env.getDynamicWorld()->removeRigidBody(m_body); m_env.getDynamicWorld()->removeCollisionObject(m_body); @@ -508,12 +507,12 @@ void ege::ElementGame::dynamicDisable() { } void ege::ElementGame::iaEnable() { - if (NULL != m_IA) { + if (nullptr != m_IA) { // IA already started ... return; } m_IA = new localIA(*this); - if (NULL == m_IA) { + if (nullptr == m_IA) { EGE_ERROR("Can not start the IA == > allocation error"); return; } @@ -523,7 +522,7 @@ void ege::ElementGame::iaEnable() { } void ege::ElementGame::iaDisable() { - if (NULL == m_IA) { + if (nullptr == m_IA) { // IA already stopped ... return; } @@ -532,7 +531,7 @@ void ege::ElementGame::iaDisable() { } // remove IA : delete(m_IA); - m_IA = NULL; + m_IA = nullptr; } diff --git a/ege/ElementGame.h b/ege/ElementGame.h index de9450a..f72c77f 100644 --- a/ege/ElementGame.h +++ b/ege/ElementGame.h @@ -75,7 +75,7 @@ namespace ege { return m_uID; }; private: - ege::resource::Mesh* m_mesh; //!< Mesh of the Element (can be NULL) + ewol::object::Shared m_mesh; //!< Mesh of the Element (can be nullptr) btCollisionShape* m_shape; //!< shape of the element (set a copy here to have the debug display of it) public: /** @@ -87,11 +87,11 @@ namespace ege { bool loadMesh(const std::string& _meshFileName); /** * @brief set the the Mesh properties. - * @param[in] _mesh The mesh pointer. (NULL to force the mesh remove ...) + * @param[in] _mesh The mesh pointer. (nullptr to force the mesh remove ...) * @note : this remove the shape and the mesh properties. * @return true if no error occured */ - bool setMesh(ege::resource::Mesh* _mesh); + bool setMesh(const ewol::object::Shared& _mesh); /** * @brief set the shape properties. * @param[in] _shape The shape pointer. @@ -103,7 +103,7 @@ namespace ege { * @brief get a pointer on the Mesh file. * @return the mesh pointer. */ - inline ege::resource::Mesh* getMesh() { + inline const ewol::object::Shared& getMesh() { return m_mesh; }; /** @@ -186,7 +186,7 @@ namespace ege { /** * @brief draw the current life of the element */ - virtual void drawLife(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera); + virtual void drawLife(const ewol::object::Shared& _draw, const ege::Camera& _camera); protected: // For debug only ... @@ -196,7 +196,7 @@ namespace ege { * @brief Debug display of the current element * @param[in,out] draw Basic system to draw the debug shape and informations */ - virtual void drawDebug(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera); + virtual void drawDebug(const ewol::object::Shared& _draw, const ege::Camera& _camera); /** * @brief get the theoric position. Sometimes, the element has move due to an explosion or something else, then its real position in not the one that woult it be at the end ... diff --git a/ege/Environement.cpp b/ege/Environement.cpp index ad13245..828c1b6 100644 --- a/ege/Environement.cpp +++ b/ege/Environement.cpp @@ -16,14 +16,14 @@ ege::ElementGame* ege::Environement::getElementNearest(ege::ElementGame* _sourceRequest, float& _distance) { - if (NULL == _sourceRequest) { - return NULL; + if (nullptr == _sourceRequest) { + return nullptr; } vec3 sourcePosition = _sourceRequest->getPosition(); - ege::ElementGame* result = NULL; + ege::ElementGame* result = nullptr; for (size_t iii=0; iiigetGroup() <= 0) { @@ -52,11 +52,11 @@ void ege::Environement::getElementNearest(const vec3& _sourcePosition, _resultList.clear(); ege::Environement::ResultNearestElement result; result.dist = 99999999999.0f; - result.element = NULL; + result.element = nullptr; for (size_t iii=0; iiiisFixed()) { @@ -116,7 +116,7 @@ static etk::Hash& getHachTableCreating() { } void ege::Environement::addCreator(const std::string& _type, ege::createElement_tf _creator) { - if (NULL == _creator) { + if (nullptr == _creator) { EGE_ERROR("Try to add an empty CREATOR ..."); return; } @@ -128,23 +128,23 @@ void ege::Environement::addCreator(const std::string& _type, ege::createElement_ ege::ElementGame* ege::Environement::createElement(const std::string& _type, bool _autoAddElement, enum ege::property _property, void* _value) { if (false == getHachTableCreating().exist(_type)) { EGE_ERROR("Request creating of an type that is not known '" << _type << "'"); - return NULL; + return nullptr; } ege::createElement_tf creatorPointer = getHachTableCreating()[_type]; - if (NULL == creatorPointer) { - EGE_ERROR("NULL pointer creator == > internal error... '" << _type << "'"); - return NULL; + if (nullptr == creatorPointer) { + EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'"); + return nullptr; } ege::ElementGame* tmpElement = creatorPointer(*this); - if (NULL == tmpElement) { + if (nullptr == tmpElement) { EGE_ERROR("allocation error '" << _type << "'"); - return NULL; + return nullptr; } if (false == tmpElement->init(_property, _value)) { EGE_ERROR("Init error ... '" << _type << "'"); // remove created element ... delete(tmpElement); - return NULL; + return nullptr; } if (_autoAddElement == true) { addElementGame(tmpElement); @@ -167,11 +167,11 @@ ege::ElementGame* ege::Environement::createElement(const std::string& _type, exm void ege::Environement::addElementGame(ege::ElementGame* _newElement) { // prevent memory allocation and un allocation ... - if (NULL == _newElement) { + if (nullptr == _newElement) { return; } for (size_t iii=0; iiidynamicEnable(); return; @@ -182,12 +182,12 @@ void ege::Environement::addElementGame(ege::ElementGame* _newElement) { } void ege::Environement::rmElementGame(ege::ElementGame* _removeElement) { - if (NULL == _removeElement) { + if (nullptr == _removeElement) { return; } // inform the element that an element has been removed == > this permit to keep pointer on elements ... for (size_t iii=0; iiielementIsRemoved(_removeElement); } } @@ -198,7 +198,7 @@ void ege::Environement::rmElementGame(ege::ElementGame* _removeElement) { m_listElementGame[iii]->dynamicDisable(); m_listElementGame[iii]->unInit(); delete(m_listElementGame[iii]); - m_listElementGame[iii] = NULL; + m_listElementGame[iii] = nullptr; } } } @@ -212,11 +212,11 @@ void ege::Environement::getOrderedElementForDisplay(std::vector this permit to keep pointer on elements ... for (size_t iii=0; iii no more action ... - * @return NULL if an error occured OR the pointer on the element and it is already added on the system. + * @return nullptr if an error occured OR the pointer on the element and it is already added on the system. * @note Pointer is return in case of setting properties on it... */ - ege::ElementGame* createElement(const std::string& _type, bool _autoAddElement=true, enum ege::property _property=ege::typeNone, void* _value=NULL); + ege::ElementGame* createElement(const std::string& _type, bool _autoAddElement=true, enum ege::property _property=ege::typeNone, void* _value=nullptr); ege::ElementGame* createElement(const std::string& _type, std::string& _description, bool _autoAddElement=true); ege::ElementGame* createElement(const std::string& _type, ejson::Value* _value, bool _autoAddElement=true); ege::ElementGame* createElement(const std::string& _type, exml::Node* _node, bool _autoAddElement=true); @@ -129,7 +129,7 @@ namespace ege { * @brief get the nearest Element * @param[in] _sourceRequest Pointer on the element that request this. * @param[in] _distance Maximum distance search == > return the element distance - * @return Pointer on the neares element OR NULL + * @return Pointer on the neares element OR nullptr */ ege::ElementGame* getElementNearest(ege::ElementGame* _sourceRequest, float& _distance); diff --git a/ege/Light.cpp b/ege/Light.cpp index 105b59b..cbd4cfc 100644 --- a/ege/Light.cpp +++ b/ege/Light.cpp @@ -27,8 +27,8 @@ ege::Light::~Light() { } -void ege::Light::link(ewol::resource::Program* _prog, const std::string& _baseName) { - if (NULL == _prog) { +void ege::Light::link(const ewol::object::Shared& _prog, const std::string& _baseName) { + if (nullptr == _prog) { return; } m_GL_direction = _prog->getUniform(_baseName+".direction"); @@ -38,7 +38,7 @@ void ege::Light::link(ewol::resource::Program* _prog, const std::string& _baseNa m_GL_specularColor = _prog->getUniform(_baseName+".specularColor"); } -void ege::Light::draw(ewol::resource::Program* _prog) { +void ege::Light::draw(const ewol::object::Shared& _prog) { _prog->uniform3(m_GL_direction, m_direction); _prog->uniform3(m_GL_halfplane, m_halfplane); _prog->uniform4(m_GL_ambientColor, m_ambientColor); diff --git a/ege/Light.h b/ege/Light.h index d2cad31..50386d9 100644 --- a/ege/Light.h +++ b/ege/Light.h @@ -33,8 +33,8 @@ namespace ege { public: Light(); ~Light(); - void link(ewol::resource::Program* _prog, const std::string& _baseName); - void draw(ewol::resource::Program* _prog); + void link(const ewol::object::Shared& _prog, const std::string& _baseName); + void draw(const ewol::object::Shared& _prog); void setDirection(const vec3& val) { m_direction = val; } diff --git a/ege/Material.cpp b/ege/Material.cpp index 973ebd5..13cce1e 100644 --- a/ege/Material.cpp +++ b/ege/Material.cpp @@ -20,8 +20,8 @@ ege::MaterialGlId::MaterialGlId() : } -void ege::MaterialGlId::link(ewol::resource::Program* _prog, const std::string& _baseName) { - if (NULL == _prog) { +void ege::MaterialGlId::link(const ewol::object::Shared& _prog, const std::string& _baseName) { + if (nullptr == _prog) { return; } m_GL_ambientFactor = _prog->getUniform(_baseName+".ambientFactor"); @@ -36,21 +36,19 @@ ege::Material::Material() : m_diffuseFactor(0,0,0,1), m_specularFactor(0,0,0,1), m_shininess(1), - m_texture0(NULL) { + m_texture0(nullptr) { // nothing to do else ... } ege::Material::~Material() { - if(NULL!=m_texture0) { - ewol::resource::TextureFile::release(m_texture0); - } + } -void ege::Material::draw(ewol::resource::Program* _prog, const MaterialGlId& _glID) { +void ege::Material::draw(const ewol::object::Shared& _prog, const MaterialGlId& _glID) { _prog->uniform4(_glID.m_GL_ambientFactor, m_ambientFactor); _prog->uniform4(_glID.m_GL_diffuseFactor, m_diffuseFactor); _prog->uniform4(_glID.m_GL_specularFactor, m_specularFactor); _prog->uniform1f(_glID.m_GL_shininess, m_shininess); - if (NULL != m_texture0) { + if (nullptr != m_texture0) { _prog->setTexture0(_glID.m_GL_texture0, m_texture0->getId()); } } @@ -58,18 +56,14 @@ void ege::Material::draw(ewol::resource::Program* _prog, const MaterialGlId& _gl void ege::Material::setTexture0(const std::string& _filename) { ivec2 tmpSize(256, 256); // prevent overloard error : - ewol::resource::TextureFile* tmpCopy = m_texture0; + ewol::object::Shared tmpCopy = m_texture0; m_texture0 = ewol::resource::TextureFile::keep(_filename, tmpSize); - if (NULL == m_texture0 ) { + if (m_texture0 == nullptr) { EGE_ERROR("Can not load specific texture : " << _filename); // retreave previous texture: m_texture0 = tmpCopy; return; } - if (NULL != tmpCopy) { - // really release previous texture. In case of same texture loading, then we did not have reload it .. just increase and decrease index... - ewol::resource::TextureFile::release(tmpCopy); - } } diff --git a/ege/Material.h b/ege/Material.h index 0ae667e..300471b 100644 --- a/ege/Material.h +++ b/ege/Material.h @@ -28,7 +28,7 @@ namespace ege { int32_t m_GL_shininess; int32_t m_GL_texture0; MaterialGlId(); - void link(ewol::resource::Program* _prog, const std::string& _baseName); + void link(const ewol::object::Shared& _prog, const std::string& _baseName); }; class Material { private: @@ -37,13 +37,13 @@ namespace ege { vec4 m_diffuseFactor; vec4 m_specularFactor; float m_shininess; - ewol::resource::TextureFile* m_texture0; + ewol::object::Shared m_texture0; public: std::vector m_listIndexFaces; public: Material(); ~Material(); - void draw(ewol::resource::Program* _prog, const ege::MaterialGlId& _glID); + void draw(const ewol::object::Shared& _prog, const ege::MaterialGlId& _glID); void setAmbientFactor(const vec4& _val) { m_ambientFactor = _val; } @@ -59,21 +59,21 @@ namespace ege { void setTexture0(const std::string& _filename); void setImageSize(const ivec2& _newSize) { - if (m_texture0 == NULL){ + if (m_texture0 == nullptr){ return; } m_texture0->setImageSize(_newSize); }; // get the reference on this image to draw nomething on it ... egami::Image* get() { - if (m_texture0 == NULL){ - return NULL; + if (m_texture0 == nullptr){ + return nullptr; } return &m_texture0->get(); }; // flush the data to send it at the openGl system void flush() { - if (m_texture0 == NULL){ + if (m_texture0 == nullptr){ return; } m_texture0->flush(); diff --git a/ege/Particule.h b/ege/Particule.h index 0dd9ec7..eda487d 100644 --- a/ege/Particule.h +++ b/ege/Particule.h @@ -32,9 +32,9 @@ namespace ege { /** * @brief Constructor. * @param[in] _particuleEngine reference on the particule engine ... - * @param[in] _particuleType Type of the particule (set NULL if you did not want to use the respowner ...) + * @param[in] _particuleType Type of the particule (set nullptr if you did not want to use the respowner ...) */ - Particule(ege::ParticuleEngine& _particuleEngine, const char* _particuleType = NULL); + Particule(ege::ParticuleEngine& _particuleEngine, const char* _particuleType = nullptr); /** * @brief Destructor. */ diff --git a/ege/ParticuleEngine.cpp b/ege/ParticuleEngine.cpp index 2928622..5bff0f4 100644 --- a/ege/ParticuleEngine.cpp +++ b/ege/ParticuleEngine.cpp @@ -22,12 +22,12 @@ ege::ParticuleEngine::~ParticuleEngine() { } void ege::ParticuleEngine::add(Particule* _particule) { - if (_particule == NULL) { - EGE_ERROR("Try to add particule NULL"); + if (_particule == nullptr) { + EGE_ERROR("Try to add particule nullptr"); return; } for (size_t iii=0; iiigetParticuleType() == _particuleType) { add(m_particuleRemoved[iii]); ege::Particule* tmpParticule = m_particuleRemoved[iii]; - m_particuleRemoved[iii]=NULL; + m_particuleRemoved[iii]=nullptr; tmpParticule->init(); return tmpParticule; } } - return NULL; + return nullptr; } void ege::ParticuleEngine::update(float _deltaTime) { @@ -76,31 +76,31 @@ void ege::ParticuleEngine::update(float _deltaTime) { _deltaTime = (1.0f/60.0f); } for (size_t iii=0; iiiupdate(_deltaTime); } // check removing elements for (size_t iii=0; iiineedRemove()) { m_particuleList[iii]->onEnd(); - if (m_particuleList[iii]->getParticuleType() == NULL) { + if (m_particuleList[iii]->getParticuleType() == nullptr) { // Real remove particule ... delete (m_particuleList[iii]); } else { addRemoved(m_particuleList[iii]); } - m_particuleList[iii] = NULL; + m_particuleList[iii] = nullptr; } } /* int32_t nbParticule = 0; for (int32_t iii=0; iiidraw(_camera); @@ -121,20 +121,20 @@ void ege::ParticuleEngine::draw(const ege::Camera& _camera) { void ege::ParticuleEngine::clear() { // clear element not removed for (size_t iii=0; iiigetAttribute("EW_coord3d"); m_GLtexture = m_GLprogram->getAttribute("EW_texture2d"); m_GLNormal = m_GLprogram->getAttribute("EW_normal"); @@ -67,11 +67,9 @@ ege::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _shad ege::resource::Mesh::~Mesh() { // remove dynamics dependencies : - ewol::resource::Program::release(m_GLprogram); - ewol::resource::VirtualBufferObject::release(m_verticesVBO); - if (m_functionFreeShape!=NULL) { + if (m_functionFreeShape!=nullptr) { m_functionFreeShape(m_pointerShape); - m_pointerShape = NULL; + m_pointerShape = nullptr; } } @@ -80,7 +78,7 @@ ege::resource::Mesh::~Mesh() { void ege::resource::Mesh::draw(mat4& _positionMatrix, bool _enableDepthTest, bool _enableDepthUpdate) { - if (m_GLprogram == NULL) { + if (m_GLprogram == nullptr) { EGE_ERROR("No shader ..."); return; } @@ -394,7 +392,7 @@ bool ege::resource::Mesh::loadOBJ(const std::string& _fileName) { char inputDataLine[2048]; int32_t lineID = 0; - while (NULL != fileName.fileGets(inputDataLine, 2048) ) + while (nullptr != fileName.fileGets(inputDataLine, 2048) ) { lineID++; if (inputDataLine[0] == 'v') { @@ -552,7 +550,7 @@ char* loadNextData(char* _elementLine, /* if (m_zipReadingOffset >= m_zipContent->size()) { element[0] = '\0'; - return NULL; + return nullptr; } */ char current = _file.fileGet(); @@ -585,12 +583,12 @@ char* loadNextData(char* _elementLine, current = _file.fileGet(); } if (outSize == 0) { - return NULL; + return nullptr; } else { // send last line return _elementLine; } - return NULL; + return nullptr; } void removeEndLine(char* _val) { @@ -659,14 +657,14 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { int32_t meshFaceMaterialID = -1; // material global param : std::string materialName = ""; - ege::Material* material = NULL; + ege::Material* material = nullptr; // physical shape: - ege::PhysicsShape* physics = NULL; + ege::PhysicsShape* physics = nullptr; while(1) { int32_t level = countIndent(fileName); if (level == 0) { // new section ... - if (NULL == loadNextData(inputDataLine, 2048, fileName)) { + if (nullptr == loadNextData(inputDataLine, 2048, fileName)) { // reach end of file ... break; } @@ -683,7 +681,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { if (currentMode >= EMFModuleMesh && currentMode <= EMFModuleMesh_END) { if (level == 1) { //Find mesh name ... - if (NULL == loadNextData(inputDataLine, 2048, fileName, true)) { + if (nullptr == loadNextData(inputDataLine, 2048, fileName, true)) { // reach end of file ... break; } @@ -695,7 +693,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { } if (level == 2) { // In the mesh level 2 the line size must not exced 2048 - if (NULL == loadNextData(inputDataLine, 2048, fileName, true)) { + if (nullptr == loadNextData(inputDataLine, 2048, fileName, true)) { // reach end of file ... break; } @@ -732,7 +730,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { break; case EMFModuleMeshVertex: { vec3 vertex(0,0,0); - while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) { + while (nullptr != loadNextData(inputDataLine, 2048, fileName, true, true) ) { if (inputDataLine[0] == '\0') { break; } @@ -749,7 +747,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { } case EMFModuleMeshUVMapping: { vec2 uvMap(0,0); - while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) { + while (nullptr != loadNextData(inputDataLine, 2048, fileName, true, true) ) { if (inputDataLine[0] == '\0') { break; } @@ -768,7 +766,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { m_normalMode = normalModeVertex; vec3 normal(0,0,0); // find the vertex Normal list. - while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) { + while (nullptr != loadNextData(inputDataLine, 2048, fileName, true, true) ) { if (inputDataLine[0] == '\0') { break; } @@ -787,7 +785,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { m_normalMode = normalModeFace; vec3 normal(0,0,0); // find the face Normal list. - while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) { + while (nullptr != loadNextData(inputDataLine, 2048, fileName, true, true) ) { if (inputDataLine[0] == '\0') { break; } @@ -806,7 +804,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { case EMFModuleMeshFaceMaterial: if (level == 3) { //Find mesh name ... - if (NULL == loadNextData(inputDataLine, 2048, fileName, true)) { + if (nullptr == loadNextData(inputDataLine, 2048, fileName, true)) { // reach end of file ... break; } @@ -818,7 +816,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { meshFaceMaterialID = m_listFaces.getId(inputDataLine); EGE_VERBOSE(" " << inputDataLine); } else if (currentMode == EMFModuleMeshFaceMaterial) { - while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) { + while (nullptr != loadNextData(inputDataLine, 2048, fileName, true, true) ) { if (inputDataLine[0] == '\0') { // end of line break; @@ -863,14 +861,14 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { break; case EMFModuleMeshPhysics: case EMFModuleMeshPhysicsNamed: - if (NULL == loadNextData(inputDataLine, 2048, fileName, true, false, false)) { + if (nullptr == loadNextData(inputDataLine, 2048, fileName, true, false, false)) { // reach end of file ... break; } removeEndLine(inputDataLine); if (level == 3) { physics = ege::PhysicsShape::create(inputDataLine); - if (physics == NULL) { + if (physics == nullptr) { EGE_ERROR("Allocation error when creating physical shape ..."); continue; } @@ -878,7 +876,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { EGE_VERBOSE(" " << m_physics.size() << " " << inputDataLine); currentMode = EMFModuleMeshPhysicsNamed; } else if (currentMode == EMFModuleMeshPhysicsNamed) { - if (physics == NULL) { + if (physics == nullptr) { EGE_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ..."); continue; } @@ -891,7 +889,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { continue; } else if (currentMode >= EMFModuleMaterial && currentMode <= EMFModuleMaterial_END) { // all material element is stored on 1 line (size < 2048) - if (NULL == loadNextData(inputDataLine, 2048, fileName, true)) { + if (nullptr == loadNextData(inputDataLine, 2048, fileName, true)) { // reach end of file ... break; } @@ -899,10 +897,10 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { if (level == 1) { // add previous material : if( materialName != "" - && material!=NULL) { + && material!=nullptr) { m_materials.add(materialName, material); materialName = ""; - material = NULL; + material = nullptr; } material = new ege::Material(); materialName = inputDataLine; @@ -916,7 +914,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { jumpEndLine(fileName); continue; } - if (NULL == material) { + if (nullptr == material) { EGE_ERROR("material allocation error"); jumpEndLine(fileName); continue; @@ -980,10 +978,10 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { } // add last material ... if( materialName != "" - && material!=NULL) { + && material!=nullptr) { m_materials.add(materialName, material); materialName = ""; - material = NULL; + material = nullptr; } EGE_VERBOSE("Stop parsing Mesh file"); @@ -993,7 +991,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { } void ege::resource::Mesh::addMaterial(const std::string& _name, ege::Material* _data) { - if (NULL == _data) { + if (nullptr == _data) { EGE_ERROR(" can not add material with null pointer"); return; } @@ -1006,33 +1004,24 @@ void ege::resource::Mesh::addMaterial(const std::string& _name, ege::Material* _ } void ege::resource::Mesh::setShape(void* _shape) { - if (m_functionFreeShape!=NULL) { + if (m_functionFreeShape!=nullptr) { m_functionFreeShape(m_pointerShape); - m_pointerShape = NULL; + m_pointerShape = nullptr; } m_pointerShape=_shape; } -ege::resource::Mesh* ege::resource::Mesh::keep(const std::string& _meshName) { - ege::resource::Mesh* object = static_cast(getManager().localKeep(_meshName)); - if (NULL != object) { +ewol::object::Shared ege::resource::Mesh::keep(const std::string& _meshName) { + ewol::object::Shared object = ewol::dynamic_pointer_cast(getManager().localKeep(_meshName)); + if (object != nullptr) { return object; } EGE_DEBUG("CREATE: Mesh: '" << _meshName << "'"); - object = new ege::resource::Mesh(_meshName); - if (NULL == object) { + object = ewol::object::makeShared(new ege::resource::Mesh(_meshName)); + if (object == nullptr) { EGE_ERROR("allocation error of a resource : ??Mesh??" << _meshName); - return NULL; + return nullptr; } getManager().localAdd(object); return object; } - -void ege::resource::Mesh::release(ege::resource::Mesh*& _object) { - if (NULL == _object) { - return; - } - ewol::Resource* object2 = static_cast(_object); - getManager().release(object2); - _object = NULL; -} diff --git a/ege/resource/Mesh.h b/ege/resource/Mesh.h index 3a6e080..2e12a77 100644 --- a/ege/resource/Mesh.h +++ b/ege/resource/Mesh.h @@ -91,7 +91,7 @@ namespace ege { enum normalMode m_normalMode; // select the normal mode of display bool m_checkNormal; //!< when enable, this check the normal of the mesh before sending it at the 3d card protected: - ewol::resource::Program* m_GLprogram; + ewol::object::Shared m_GLprogram; int32_t m_GLPosition; int32_t m_GLMatrix; int32_t m_GLMatrixPosition; @@ -110,8 +110,8 @@ namespace ege { etk::Hash m_materials; std::vector m_physics; //!< collision shape module ... (independent of bullet lib) protected: - ewol::resource::VirtualBufferObject* m_verticesVBO; - protected: + ewol::object::Shared m_verticesVBO; + public: Mesh(const std::string& _fileName, const std::string& _shaderName="DATA:textured3D2.prog"); virtual ~Mesh(); public: @@ -177,14 +177,9 @@ namespace ege { * @brief keep the resource pointer. * @note Never free this pointer by your own... * @param[in] _filename Name of the ewol mesh file. - * @return pointer on the resource or NULL if an error occured. + * @return pointer on the resource or nullptr if an error occured. */ - static ege::resource::Mesh* keep(const std::string& _meshname); - /** - * @brief release the keeped resources - * @param[in,out] reference on the object pointer - */ - static void release(ege::resource::Mesh*& _object); + static ewol::object::Shared keep(const std::string& _meshname); }; }; }; diff --git a/ege/resource/ParticuleMesh.cpp b/ege/resource/ParticuleMesh.cpp index f7c0bdf..f38a08f 100644 --- a/ege/resource/ParticuleMesh.cpp +++ b/ege/resource/ParticuleMesh.cpp @@ -13,7 +13,7 @@ ege::resource::ParticuleMesh::ParticuleMesh(const std::string& _fileName, const std::string& _shaderName) : ege::resource::Mesh(_fileName, _shaderName) { - if (m_GLprogram != NULL) { + if (m_GLprogram != nullptr) { m_GLMainColor = m_GLprogram->getUniform("EW_mainColor"); } } @@ -28,7 +28,7 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix, bool _enableDepthTest, bool _enableDepthUpdate) { - if (m_GLprogram == NULL) { + if (m_GLprogram == nullptr) { EGE_ERROR("No shader ..."); return; } @@ -126,27 +126,18 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix, glBindBuffer(GL_ARRAY_BUFFER,0); } -ege::resource::ParticuleMesh* ege::resource::ParticuleMesh::keep(const std::string& _meshName, const std::string& _shaderName) +ewol::object::Shared ege::resource::ParticuleMesh::keep(const std::string& _meshName, const std::string& _shaderName) { - ege::resource::ParticuleMesh* object = static_cast(getManager().localKeep(_meshName)); - if (NULL != object) { + ewol::object::Shared object = ewol::dynamic_pointer_cast(getManager().localKeep(_meshName)); + if (object != nullptr) { return object; } - object = new ege::resource::ParticuleMesh(_meshName, _shaderName); - if (object == NULL) { + object = ewol::object::makeShared(new ege::resource::ParticuleMesh(_meshName, _shaderName)); + if (object == nullptr) { EGE_ERROR("allocation error of a resource : ??Mesh??" << _meshName); - return NULL; + return nullptr; } getManager().localAdd(object); return object; } -void ege::resource::ParticuleMesh::release(ege::resource::ParticuleMesh*& _object) -{ - if (_object == NULL) { - return; - } - ewol::Resource* object2 = static_cast(_object); - getManager().release(object2); - _object = NULL; -} diff --git a/ege/resource/ParticuleMesh.h b/ege/resource/ParticuleMesh.h index ed0c21f..be2beaa 100644 --- a/ege/resource/ParticuleMesh.h +++ b/ege/resource/ParticuleMesh.h @@ -16,7 +16,7 @@ namespace ege { class ParticuleMesh : public ege::resource::Mesh { protected: int32_t m_GLMainColor; - protected: + public: ParticuleMesh(const std::string& _fileName, const std::string& _shaderName); virtual ~ParticuleMesh(); public: @@ -29,14 +29,9 @@ namespace ege { * @brief keep the resource pointer. * @note Never free this pointer by your own... * @param[in] _filename Name of the ewol mesh file. - * @return pointer on the resource or NULL if an error occured. + * @return pointer on the resource or nullptr if an error occured. */ - static ege::resource::ParticuleMesh* keep(const std::string& _meshName, const std::string& _shaderName="DATA:ParticuleMesh.prog"); - /** - * @brief release the keeped resources - * @param[in,out] reference on the object pointer - */ - static void release(ege::resource::ParticuleMesh*& _object); + static ewol::object::Shared keep(const std::string& _meshName, const std::string& _shaderName="DATA:ParticuleMesh.prog"); }; }; }; diff --git a/ege/widget/Mesh.cpp b/ege/widget/Mesh.cpp index 3545f03..6959035 100644 --- a/ege/widget/Mesh.cpp +++ b/ege/widget/Mesh.cpp @@ -21,7 +21,6 @@ extern const char * const ewolEventMeshPressed = "ewol-mesh-Pressed"; ege::widget::Mesh::Mesh(const std::string& _filename) : m_meshName(_filename), - m_object(NULL), m_position(0,0,0), m_angle(0,0,0), m_angleSpeed(0,0,0), @@ -32,14 +31,14 @@ ege::widget::Mesh::Mesh(const std::string& _filename) : setMouseLimit(1); if (_filename!="") { m_object = ege::resource::Mesh::keep(m_meshName); - if (NULL == m_object) { + if (nullptr == m_object) { EGE_ERROR("Can not load the resource : \"" << m_meshName << "\""); } } } ege::widget::Mesh::~Mesh() { - ege::resource::Mesh::release(m_object); + } void ege::widget::Mesh::onDraw() { @@ -48,7 +47,7 @@ void ege::widget::Mesh::onDraw() { * etk::matRotate(vec3(1,0,0),m_angle.x()) * etk::matRotate(vec3(0,1,0),m_angle.y()) * etk::matRotate(vec3(0,0,1),m_angle.z()); - if (NULL != m_object) { + if (nullptr != m_object) { m_object->draw(transformationMatrix); } } @@ -97,10 +96,9 @@ bool ege::widget::Mesh::onEventInput(const ewol::event::Input& _event) { void ege::widget::Mesh::setFile(const std::string& _filename) { if( _filename!="" && m_meshName != _filename ) { - ege::resource::Mesh::release(m_object); m_meshName = _filename; m_object = ege::resource::Mesh::keep(m_meshName); - if (NULL == m_object) { + if (nullptr == m_object) { EGE_ERROR("Can not load the resource : \"" << m_meshName << "\""); } } @@ -127,8 +125,7 @@ void ege::widget::Mesh::setAngleSpeed(const vec3& _speed) { markToRedraw(); } -void ege::widget::Mesh::setDistance(float _distance) -{ +void ege::widget::Mesh::setDistance(float _distance) { m_cameraDistance = _distance; markToRedraw(); } diff --git a/ege/widget/Mesh.h b/ege/widget/Mesh.h index 0b77c63..13abfad 100644 --- a/ege/widget/Mesh.h +++ b/ege/widget/Mesh.h @@ -25,7 +25,7 @@ namespace ege { private: // mesh name : std::string m_meshName; - ege::resource::Mesh* m_object; + ewol::object::Shared m_object; // mesh display properties: vec3 m_position; vec3 m_angle; diff --git a/ege/widget/Scene.cpp b/ege/widget/Scene.cpp index 8b94895..9e9b450 100644 --- a/ege/widget/Scene.cpp +++ b/ege/widget/Scene.cpp @@ -39,11 +39,12 @@ const char * const ege::widget::Scene::eventKillEnemy = "event-scene-kill-ennemy ege::widget::Scene::Scene(bool _setAutoBullet, bool _setAutoCamera) : m_gameTime(0), m_angleView(M_PI/3.0), - m_dynamicsWorld(NULL), - m_camera(NULL), + m_dynamicsWorld(nullptr), + m_camera(nullptr), m_isRunning(true), m_debugMode(false), - m_debugDrawing(NULL) { + m_debugDrawing(nullptr) { + addObjectType("ege::widget::Scene"); setKeyboardRepeate(false); setCanHaveFocus(true); periodicCallEnable(); @@ -66,31 +67,31 @@ void ege::widget::Scene::setBulletConfig(btDefaultCollisionConfiguration* _colli btBroadphaseInterface* _broadphase, btConstraintSolver* _solver, btDynamicsWorld* _dynamicsWorld) { - if (NULL != _collisionConfiguration) { + if (nullptr != _collisionConfiguration) { m_collisionConfiguration = _collisionConfiguration; } else { m_collisionConfiguration = new btDefaultCollisionConfiguration(); } ///use the default collision dispatcher. - if (NULL != _dispatcher) { + if (nullptr != _dispatcher) { m_dispatcher = _dispatcher; } else { m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); } - if (NULL != _broadphase) { + if (nullptr != _broadphase) { m_broadphase = _broadphase; } else { m_broadphase = new btDbvtBroadphase(); } ///the default constraint solver. - if (NULL != _solver) { + if (nullptr != _solver) { m_solver = _solver; } else { m_solver = new btSequentialImpulseConstraintSolver(); } - if (NULL != _dynamicsWorld) { + if (nullptr != _dynamicsWorld) { m_dynamicsWorld = _dynamicsWorld; } else { m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration); @@ -103,7 +104,7 @@ void ege::widget::Scene::setBulletConfig(btDefaultCollisionConfiguration* _colli } void ege::widget::Scene::setCamera(ege::Camera* _camera) { - if (NULL != _camera) { + if (nullptr != _camera) { m_camera = _camera; } else { m_camera = new ege::Camera(vec3(0,0,0), 0, DEG_TO_RAD(45) ,50); @@ -113,7 +114,7 @@ void ege::widget::Scene::setCamera(ege::Camera* _camera) { } ege::widget::Scene::~Scene() { - ewol::resource::Colored3DObject::release(m_debugDrawing); + /* ewol::resource::release(m_directDrawObject); //cleanup in the reverse order of creation/initialization @@ -215,7 +216,7 @@ void ege::widget::Scene::onDraw() { } #endif } - if (NULL!=m_camera) { + if (nullptr!=m_camera) { m_env.getParticuleEngine().draw(*m_camera); } #ifdef SCENE_DISPLAY_SPEED @@ -257,7 +258,7 @@ void ege::widget::Scene::periodicCall(const ewol::event::Time& _event) { //EWOL_DEBUG("Time: m_lastCallTime=" << m_lastCallTime << " deltaTime=" << deltaTime); // update camera positions: - if (NULL != m_camera) { + if (nullptr != m_camera) { m_camera->periodicCall(curentDelta); } //EGE_DEBUG("stepSimulation (start)"); @@ -274,7 +275,7 @@ void ege::widget::Scene::periodicCall(const ewol::event::Time& _event) { int32_t victoryPoint=0; std::vector& elementList = m_env.getElementGame(); for (int32_t iii=elementList.size()-1; iii >= 0; --iii) { - if(NULL != elementList[iii]) { + if(nullptr != elementList[iii]) { if (true == elementList[iii]->needToRemove()) { if (elementList[iii]->getGroup() > 1) { numberEnnemyKilled++; diff --git a/ege/widget/Scene.h b/ege/widget/Scene.h index b986ec1..61f89a9 100644 --- a/ege/widget/Scene.h +++ b/ege/widget/Scene.h @@ -51,12 +51,12 @@ namespace ege { * @brief Destructor of the widget classes */ virtual ~Scene(); - void setBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration=NULL, - btCollisionDispatcher* _dispatcher=NULL, - btBroadphaseInterface* _broadphase=NULL, - btConstraintSolver* _solver=NULL, - btDynamicsWorld* _dynamicsWorld=NULL); - void setCamera(ege::Camera* _camera=NULL); + void setBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration=nullptr, + btCollisionDispatcher* _dispatcher=nullptr, + btBroadphaseInterface* _broadphase=nullptr, + btConstraintSolver* _solver=nullptr, + btDynamicsWorld* _dynamicsWorld=nullptr); + void setCamera(ege::Camera* _camera=nullptr); private: float m_gameTime; //!< time of the game running protected: @@ -89,7 +89,7 @@ namespace ege { void pauseToggle(); protected: bool m_debugMode; - ewol::resource::Colored3DObject* m_debugDrawing; //!< for the debug draw elements + ewol::object::Shared m_debugDrawing; //!< for the debug draw elements public: /** * @brief Toggle the debug mode == > usefull for DEBUG only ...