From 95a1400a2ac9de1a29fa305f45b928ce8e3044bd Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Thu, 2 Apr 2020 01:20:12 +0200 Subject: Replace NULL with nullptr --- modules/bullet/area_bullet.h | 2 +- modules/bullet/bullet_physics_server.cpp | 34 +++++++------- modules/bullet/bullet_physics_server.h | 2 +- modules/bullet/bullet_utilities.h | 2 +- modules/bullet/collision_object_bullet.cpp | 12 ++--- modules/bullet/collision_object_bullet.h | 8 ++-- modules/bullet/constraint_bullet.cpp | 4 +- modules/bullet/constraint_bullet.h | 2 +- modules/bullet/godot_collision_configuration.cpp | 4 +- modules/bullet/godot_result_callbacks.cpp | 4 +- modules/bullet/rigid_body_bullet.cpp | 20 ++++----- modules/bullet/rigid_body_bullet.h | 4 +- modules/bullet/shape_bullet.cpp | 8 ++-- modules/bullet/soft_body_bullet.cpp | 6 +-- modules/bullet/space_bullet.cpp | 56 ++++++++++++------------ modules/bullet/space_bullet.h | 10 ++--- 16 files changed, 89 insertions(+), 89 deletions(-) (limited to 'modules/bullet') diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h index 56977d4451..0272350510 100644 --- a/modules/bullet/area_bullet.h +++ b/modules/bullet/area_bullet.h @@ -65,7 +65,7 @@ public: OverlapState state; OverlappingObjectData() : - object(NULL), + object(nullptr), state(OVERLAP_STATE_ENTER) {} OverlappingObjectData(CollisionObjectBullet *p_object, OverlapState p_state) : object(p_object), diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index 5f7860e797..2705c749a2 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -86,7 +86,7 @@ BulletPhysicsServer3D::BulletPhysicsServer3D() : BulletPhysicsServer3D::~BulletPhysicsServer3D() {} RID BulletPhysicsServer3D::shape_create(ShapeType p_shape) { - ShapeBullet *shape = NULL; + ShapeBullet *shape = nullptr; switch (p_shape) { case SHAPE_PLANE: { @@ -216,7 +216,7 @@ real_t BulletPhysicsServer3D::space_get_param(RID p_space, SpaceParameter p_para PhysicsDirectSpaceState3D *BulletPhysicsServer3D::space_get_direct_state(RID p_space) { SpaceBullet *space = space_owner.getornull(p_space); - ERR_FAIL_COND_V(!space, NULL); + ERR_FAIL_COND_V(!space, nullptr); return space->get_direct_state(); } @@ -252,7 +252,7 @@ RID BulletPhysicsServer3D::area_create() { void BulletPhysicsServer3D::area_set_space(RID p_area, RID p_space) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); - SpaceBullet *space = NULL; + SpaceBullet *space = nullptr; if (p_space.is_valid()) { space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); @@ -463,7 +463,7 @@ RID BulletPhysicsServer3D::body_create(BodyMode p_mode, bool p_init_sleeping) { void BulletPhysicsServer3D::body_set_space(RID p_body, RID p_space) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - SpaceBullet *space = NULL; + SpaceBullet *space = nullptr; if (p_space.is_valid()) { space = space_owner.getornull(p_space); @@ -861,7 +861,7 @@ bool BulletPhysicsServer3D::body_is_ray_pickable(RID p_body) const { PhysicsDirectBodyState3D *BulletPhysicsServer3D::body_get_direct_state(RID p_body) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, NULL); + ERR_FAIL_COND_V(!body, nullptr); return BulletPhysicsDirectBodyState3D::get_singleton(body); } @@ -900,7 +900,7 @@ void BulletPhysicsServer3D::soft_body_update_rendering_server(RID p_body, class void BulletPhysicsServer3D::soft_body_set_space(RID p_body, RID p_space) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - SpaceBullet *space = NULL; + SpaceBullet *space = nullptr; if (p_space.is_valid()) { space = space_owner.getornull(p_space); @@ -1214,7 +1214,7 @@ RID BulletPhysicsServer3D::joint_create_pin(RID p_body_A, const Vector3 &p_local JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1282,7 +1282,7 @@ RID BulletPhysicsServer3D::joint_create_hinge(RID p_body_A, const Transform &p_h ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1302,7 +1302,7 @@ RID BulletPhysicsServer3D::joint_create_hinge_simple(RID p_body_A, const Vector3 ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1354,7 +1354,7 @@ RID BulletPhysicsServer3D::joint_create_slider(RID p_body_A, const Transform &p_ ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1390,7 +1390,7 @@ RID BulletPhysicsServer3D::joint_create_cone_twist(RID p_body_A, const Transform ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1424,7 +1424,7 @@ RID BulletPhysicsServer3D::joint_create_generic_6dof(RID p_body_A, const Transfo ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1503,7 +1503,7 @@ void BulletPhysicsServer3D::free(RID p_rid) { RigidBodyBullet *body = rigid_body_owner.getornull(p_rid); - body->set_space(NULL); + body->set_space(nullptr); body->remove_all_shapes(true, true); @@ -1514,7 +1514,7 @@ void BulletPhysicsServer3D::free(RID p_rid) { SoftBodyBullet *body = soft_body_owner.getornull(p_rid); - body->set_space(NULL); + body->set_space(nullptr); soft_body_owner.free(p_rid); bulletdelete(body); @@ -1523,7 +1523,7 @@ void BulletPhysicsServer3D::free(RID p_rid) { AreaBullet *area = area_owner.getornull(p_rid); - area->set_space(NULL); + area->set_space(nullptr); area->remove_all_shapes(true, true); @@ -1592,7 +1592,7 @@ CollisionObjectBullet *BulletPhysicsServer3D::get_collisin_object(RID p_object) if (soft_body_owner.owns(p_object)) { return soft_body_owner.getornull(p_object); } - return NULL; + return nullptr; } RigidCollisionObjectBullet *BulletPhysicsServer3D::get_rigid_collisin_object(RID p_object) const { @@ -1602,5 +1602,5 @@ RigidCollisionObjectBullet *BulletPhysicsServer3D::get_rigid_collisin_object(RID if (area_owner.owns(p_object)) { return area_owner.getornull(p_object); } - return NULL; + return nullptr; } diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h index 1269dac78b..ea9c5e589e 100644 --- a/modules/bullet/bullet_physics_server.h +++ b/modules/bullet/bullet_physics_server.h @@ -254,7 +254,7 @@ public: // this function only works on physics process, errors and returns null otherwise virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body); - virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true); + virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true); virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001); /* SOFT BODY API */ diff --git a/modules/bullet/bullet_utilities.h b/modules/bullet/bullet_utilities.h index 968cb38ba2..a5e33d9829 100644 --- a/modules/bullet/bullet_utilities.h +++ b/modules/bullet/bullet_utilities.h @@ -41,6 +41,6 @@ #define bulletdelete(cl) \ { \ delete cl; \ - cl = NULL; \ + cl = nullptr; \ } #endif diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index 0ce57811d7..1b72c2f577 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -96,10 +96,10 @@ CollisionObjectBullet::CollisionObjectBullet(Type p_type) : collisionsEnabled(true), m_isStatic(false), ray_pickable(false), - bt_collision_object(NULL), + bt_collision_object(nullptr), body_scale(1., 1., 1.), force_shape_reset(false), - space(NULL), + space(nullptr), isTransformChanged(false) {} CollisionObjectBullet::~CollisionObjectBullet() { @@ -227,7 +227,7 @@ void CollisionObjectBullet::notify_transform_changed() { RigidCollisionObjectBullet::RigidCollisionObjectBullet(Type p_type) : CollisionObjectBullet(p_type), - mainShape(NULL) { + mainShape(nullptr) { } RigidCollisionObjectBullet::~RigidCollisionObjectBullet() { @@ -332,7 +332,7 @@ bool RigidCollisionObjectBullet::is_shape_disabled(int p_index) { void RigidCollisionObjectBullet::shape_changed(int p_shape_index) { ShapeWrapper &shp = shapes.write[p_shape_index]; if (shp.bt_shape == mainShape) { - mainShape = NULL; + mainShape = nullptr; } bulletdelete(shp.bt_shape); reload_shapes(); @@ -345,7 +345,7 @@ void RigidCollisionObjectBullet::reload_shapes() { bulletdelete(mainShape); } - mainShape = NULL; + mainShape = nullptr; ShapeWrapper *shpWrapper; const int shape_count = shapes.size(); @@ -398,7 +398,7 @@ void RigidCollisionObjectBullet::internal_shape_destroy(int p_index, bool p_perm ShapeWrapper &shp = shapes.write[p_index]; shp.shape->remove_owner(this, p_permanentlyFromThisBody); if (shp.bt_shape == mainShape) { - mainShape = NULL; + mainShape = nullptr; } bulletdelete(shp.bt_shape); } diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h index 42ba4aa907..25176458a7 100644 --- a/modules/bullet/collision_object_bullet.h +++ b/modules/bullet/collision_object_bullet.h @@ -76,20 +76,20 @@ public: bool active; ShapeWrapper() : - shape(NULL), - bt_shape(NULL), + shape(nullptr), + bt_shape(nullptr), active(true) {} ShapeWrapper(ShapeBullet *p_shape, const btTransform &p_transform, bool p_active) : shape(p_shape), - bt_shape(NULL), + bt_shape(nullptr), active(p_active) { set_transform(p_transform); } ShapeWrapper(ShapeBullet *p_shape, const Transform &p_transform, bool p_active) : shape(p_shape), - bt_shape(NULL), + bt_shape(nullptr), active(p_active) { set_transform(p_transform); } diff --git a/modules/bullet/constraint_bullet.cpp b/modules/bullet/constraint_bullet.cpp index 7e90e2b488..469b58521e 100644 --- a/modules/bullet/constraint_bullet.cpp +++ b/modules/bullet/constraint_bullet.cpp @@ -38,8 +38,8 @@ */ ConstraintBullet::ConstraintBullet() : - space(NULL), - constraint(NULL), + space(nullptr), + constraint(nullptr), disabled_collisions_between_bodies(true) {} void ConstraintBullet::setup(btTypedConstraint *p_constraint) { diff --git a/modules/bullet/constraint_bullet.h b/modules/bullet/constraint_bullet.h index 89ad150257..1946807bad 100644 --- a/modules/bullet/constraint_bullet.h +++ b/modules/bullet/constraint_bullet.h @@ -64,7 +64,7 @@ public: public: virtual ~ConstraintBullet() { bulletdelete(constraint); - constraint = NULL; + constraint = nullptr; } _FORCE_INLINE_ btTypedConstraint *get_bt_constraint() { return constraint; } diff --git a/modules/bullet/godot_collision_configuration.cpp b/modules/bullet/godot_collision_configuration.cpp index f3e3a01a52..8e29845a36 100644 --- a/modules/bullet/godot_collision_configuration.cpp +++ b/modules/bullet/godot_collision_configuration.cpp @@ -42,7 +42,7 @@ GodotCollisionConfiguration::GodotCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) : btDefaultCollisionConfiguration(constructionInfo) { - void *mem = NULL; + void *mem = nullptr; mem = btAlignedAlloc(sizeof(GodotRayWorldAlgorithm::CreateFunc), 16); m_rayWorldCF = new (mem) GodotRayWorldAlgorithm::CreateFunc(world); @@ -98,7 +98,7 @@ btCollisionAlgorithmCreateFunc *GodotCollisionConfiguration::getClosestPointsAlg GodotSoftCollisionConfiguration::GodotSoftCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) : btSoftBodyRigidBodyCollisionConfiguration(constructionInfo) { - void *mem = NULL; + void *mem = nullptr; mem = btAlignedAlloc(sizeof(GodotRayWorldAlgorithm::CreateFunc), 16); m_rayWorldCF = new (mem) GodotRayWorldAlgorithm::CreateFunc(world); diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp index ad054e3027..ad20a7e451 100644 --- a/modules/bullet/godot_result_callbacks.cpp +++ b/modules/bullet/godot_result_callbacks.cpp @@ -112,7 +112,7 @@ btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalCo result.shape = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID result.rid = gObj->get_self(); result.collider_id = gObj->get_instance_id(); - result.collider = result.collider_id.is_null() ? NULL : ObjectDB::get_instance(result.collider_id); + result.collider = result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(result.collider_id); ++count; return 1; // not used by bullet @@ -220,7 +220,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con } result.collider_id = colObj->get_instance_id(); - result.collider = result.collider_id.is_null() ? NULL : ObjectDB::get_instance(result.collider_id); + result.collider = result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(result.collider_id); result.rid = colObj->get_self(); ++m_count; } diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 6f799843de..fc4e1d57de 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -48,7 +48,7 @@ @author AndreaCatania */ -BulletPhysicsDirectBodyState3D *BulletPhysicsDirectBodyState3D::singleton = NULL; +BulletPhysicsDirectBodyState3D *BulletPhysicsDirectBodyState3D::singleton = nullptr; Vector3 BulletPhysicsDirectBodyState3D::get_total_gravity() const { Vector3 gVec; @@ -241,7 +241,7 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() { } break; default: WARN_PRINT("This shape is not supported for kinematic collision."); - shapes.write[i].shape = NULL; + shapes.write[i].shape = nullptr; } } } @@ -257,7 +257,7 @@ void RigidBodyBullet::KinematicUtilities::just_delete_shapes(int new_size) { RigidBodyBullet::RigidBodyBullet() : RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_RIGID_BODY), - kinematic_utilities(NULL), + kinematic_utilities(nullptr), locked_axis(0), mass(1), gravity_scale(1), @@ -274,13 +274,13 @@ RigidBodyBullet::RigidBodyBullet() : countGravityPointSpaces(0), isScratchedSpaceOverrideModificator(false), previousActiveState(true), - force_integration_callback(NULL) { + force_integration_callback(nullptr) { godotMotionState = bulletnew(GodotMotionState(this)); // Initial properties const btVector3 localInertia(0, 0, 0); - btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, NULL, localInertia); + btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, nullptr, localInertia); btBody = bulletnew(btRigidBody(cInfo)); reload_shapes(); @@ -291,7 +291,7 @@ RigidBodyBullet::RigidBodyBullet() : areasWhereIam.resize(maxAreasWhereIam); for (int i = areasWhereIam.size() - 1; 0 <= i; --i) { - areasWhereIam.write[i] = NULL; + areasWhereIam.write[i] = nullptr; } btBody->setSleepingThresholds(0.2, 0.2); @@ -315,7 +315,7 @@ void RigidBodyBullet::init_kinematic_utilities() { void RigidBodyBullet::destroy_kinematic_utilities() { if (kinematic_utilities) { memdelete(kinematic_utilities); - kinematic_utilities = NULL; + kinematic_utilities = nullptr; } } @@ -392,7 +392,7 @@ void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const String if (force_integration_callback) { memdelete(force_integration_callback); - force_integration_callback = NULL; + force_integration_callback = nullptr; } if (p_id.is_valid()) { @@ -847,7 +847,7 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) { } for (int i = 0; i < areaWhereIamCount; ++i) { - if (NULL == areasWhereIam[i]) { + if (nullptr == areasWhereIam[i]) { // This area has the highest priority areasWhereIam.write[i] = p_area; break; @@ -894,7 +894,7 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) { } --areaWhereIamCount; - areasWhereIam.write[areaWhereIamCount] = NULL; // Even if this is not required, I clear the last element to be safe + areasWhereIam.write[areaWhereIamCount] = nullptr; // Even if this is not required, I clear the last element to be safe if (PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) { scratch_space_override_modificator(); } diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h index b73e132103..95491b1e62 100644 --- a/modules/bullet/rigid_body_bullet.h +++ b/modules/bullet/rigid_body_bullet.h @@ -68,7 +68,7 @@ public: static void destroySingleton() { memdelete(singleton); - singleton = NULL; + singleton = nullptr; } static void singleton_setDeltaTime(real_t p_deltaTime) { @@ -166,7 +166,7 @@ public: btTransform transform; KinematicShape() : - shape(NULL) {} + shape(nullptr) {} bool is_active() const { return shape; } }; diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp index 6b73525d10..8ac26a0fdb 100644 --- a/modules/bullet/shape_bullet.cpp +++ b/modules/bullet/shape_bullet.cpp @@ -138,7 +138,7 @@ btScaledBvhTriangleMeshShape *ShapeBullet::create_shape_concave(btBvhTriangleMes if (p_mesh_shape) { return bulletnew(btScaledBvhTriangleMeshShape(p_mesh_shape, p_local_scaling)); } else { - return NULL; + return nullptr; } } @@ -362,7 +362,7 @@ btCollisionShape *ConvexPolygonShapeBullet::create_bt_shape(const btVector3 &p_i ConcavePolygonShapeBullet::ConcavePolygonShapeBullet() : ShapeBullet(), - meshShape(NULL) {} + meshShape(nullptr) {} ConcavePolygonShapeBullet::~ConcavePolygonShapeBullet() { if (meshShape) { @@ -425,7 +425,7 @@ void ConcavePolygonShapeBullet::setup(Vector p_faces) { btGenerateInternalEdgeInfo(meshShape, triangleInfoMap); } } else { - meshShape = NULL; + meshShape = nullptr; ERR_PRINT("The faces count are 0, the mesh shape cannot be created"); } notifyShapeChanged(); @@ -434,7 +434,7 @@ void ConcavePolygonShapeBullet::setup(Vector p_faces) { btCollisionShape *ConcavePolygonShapeBullet::create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge) { btCollisionShape *cs = ShapeBullet::create_shape_concave(meshShape); if (!cs) - // This is necessary since if 0 faces the creation of concave return NULL + // This is necessary since if 0 faces the creation of concave return null cs = ShapeBullet::create_shape_empty(); cs->setLocalScaling(p_implicit_scale); prepare(cs); diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp index 2984bf9c2b..236bdc7c8a 100644 --- a/modules/bullet/soft_body_bullet.cpp +++ b/modules/bullet/soft_body_bullet.cpp @@ -37,7 +37,7 @@ SoftBodyBullet::SoftBodyBullet() : CollisionObjectBullet(CollisionObjectBullet::TYPE_SOFT_BODY), - bt_soft_body(NULL), + bt_soft_body(nullptr), isScratched(false), simulation_precision(5), total_mass(1.), @@ -144,7 +144,7 @@ void SoftBodyBullet::destroy_soft_body() { } destroyBulletCollisionObject(); - bt_soft_body = NULL; + bt_soft_body = nullptr; } void SoftBodyBullet::set_soft_transform(const Transform &p_transform) { @@ -404,7 +404,7 @@ void SoftBodyBullet::setup_soft_body() { // Soft body setup setupBulletCollisionObject(bt_soft_body); - bt_soft_body->m_worldInfo = NULL; // Remove fake world info + bt_soft_body->m_worldInfo = nullptr; // Remove fake world info bt_soft_body->getCollisionShape()->setMargin(0.01); bt_soft_body->setCollisionFlags(bt_soft_body->getCollisionFlags() & (~(btCollisionObject::CF_KINEMATIC_OBJECT | btCollisionObject::CF_STATIC_OBJECT))); diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index b1ff418748..1659664ff9 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -108,7 +108,7 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V r_result.shape = btResult.m_shapeId; r_result.rid = gObj->get_self(); r_result.collider_id = gObj->get_instance_id(); - r_result.collider = r_result.collider_id.is_null() ? NULL : ObjectDB::get_instance(r_result.collider_id); + r_result.collider = r_result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(r_result.collider_id); } else { WARN_PRINT("The raycast performed has hit a collision object that is not part of Godot scene, please check it."); } @@ -309,7 +309,7 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_ btPointCollector result; btGjkPairDetector gjk_pair_detector(&point_shape, convex_shape, space->gjk_simplex_solver, space->gjk_epa_pen_solver); - gjk_pair_detector.getClosestPoints(input, result, 0); + gjk_pair_detector.getClosestPoints(input, result, nullptr); if (out_distance > result.m_distance) { out_distance = result.m_distance; @@ -332,14 +332,14 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_ } SpaceBullet::SpaceBullet() : - broadphase(NULL), - collisionConfiguration(NULL), - dispatcher(NULL), - solver(NULL), - dynamicsWorld(NULL), - soft_body_world_info(NULL), - ghostPairCallback(NULL), - godotFilterCallback(NULL), + broadphase(nullptr), + collisionConfiguration(nullptr), + dispatcher(nullptr), + solver(nullptr), + dynamicsWorld(nullptr), + soft_body_world_info(nullptr), + ghostPairCallback(nullptr), + godotFilterCallback(nullptr), gravityDirection(0, -1, 0), gravityMagnitude(10), contactDebugCount(0), @@ -511,7 +511,7 @@ void SpaceBullet::remove_soft_body(SoftBodyBullet *p_body) { if (is_using_soft_world()) { if (p_body->get_bt_soft_body()) { static_cast(dynamicsWorld)->removeSoftBody(p_body->get_bt_soft_body()); - p_body->get_bt_soft_body()->m_worldInfo = NULL; + p_body->get_bt_soft_body()->m_worldInfo = nullptr; } } } @@ -539,7 +539,7 @@ void SpaceBullet::remove_all_collision_objects() { for (int i = dynamicsWorld->getNumCollisionObjects() - 1; 0 <= i; --i) { btCollisionObject *btObj = dynamicsWorld->getCollisionObjectArray()[i]; CollisionObjectBullet *colObj = static_cast(btObj->getUserPointer()); - colObj->set_space(NULL); + colObj->set_space(nullptr); } } @@ -636,8 +636,8 @@ void SpaceBullet::destroy_world() { /// The world elements (like: Collision Objects, Constraints, Shapes) are managed by godot - dynamicsWorld->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(NULL); - dynamicsWorld->getPairCache()->setOverlapFilterCallback(NULL); + dynamicsWorld->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(nullptr); + dynamicsWorld->getPairCache()->setOverlapFilterCallback(nullptr); bulletdelete(ghostPairCallback); bulletdelete(godotFilterCallback); @@ -645,7 +645,7 @@ void SpaceBullet::destroy_world() { // Deallocate world dynamicsWorld->~btDiscreteDynamicsWorld(); free(dynamicsWorld); - dynamicsWorld = NULL; + dynamicsWorld = nullptr; bulletdelete(solver); bulletdelete(broadphase); @@ -741,7 +741,7 @@ void SpaceBullet::check_ghost_overlaps() { static_cast(other_body_shape), gjk_simplex_solver, gjk_epa_pen_solver); - gjk_pair_detector.getClosestPoints(gjk_input, result, 0); + gjk_pair_detector.getClosestPoints(gjk_input, result, nullptr); if (0 >= result.m_distance) { hasOverlap = true; @@ -750,10 +750,10 @@ void SpaceBullet::check_ghost_overlaps() { } else { - btCollisionObjectWrapper obA(NULL, area_shape, area->get_bt_ghost(), gjk_input.m_transformA, -1, y); - btCollisionObjectWrapper obB(NULL, other_body_shape, otherObject->get_bt_collision_object(), gjk_input.m_transformB, -1, z); + btCollisionObjectWrapper obA(nullptr, area_shape, area->get_bt_ghost(), gjk_input.m_transformA, -1, y); + btCollisionObjectWrapper obB(nullptr, other_body_shape, otherObject->get_bt_collision_object(), gjk_input.m_transformB, -1, z); - btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, NULL, BT_CONTACT_POINT_ALGORITHMS); + btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, nullptr, BT_CONTACT_POINT_ALGORITHMS); if (!algorithm) continue; @@ -885,8 +885,8 @@ void SpaceBullet::update_gravity() { #include "scene/3d/immediate_geometry.h" -static ImmediateGeometry3D *motionVec(NULL); -static ImmediateGeometry3D *normalLine(NULL); +static ImmediateGeometry3D *motionVec(nullptr); +static ImmediateGeometry3D *normalLine(nullptr); static Ref red_mat; static Ref blue_mat; #endif @@ -951,7 +951,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f Vector3 sup_line; B_TO_G(body_safe_position.getOrigin(), sup_line); motionVec->clear(); - motionVec->begin(Mesh::PRIMITIVE_LINES, NULL); + motionVec->begin(Mesh::PRIMITIVE_LINES, nullptr); motionVec->add_vertex(sup_line); motionVec->add_vertex(sup_line + p_motion * 10); motionVec->end(); @@ -1028,7 +1028,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f Vector3 sup_line2; B_TO_G(motion, sup_line2); normalLine->clear(); - normalLine->begin(Mesh::PRIMITIVE_LINES, NULL); + normalLine->begin(Mesh::PRIMITIVE_LINES, nullptr); normalLine->add_vertex(r_result->collision_point); normalLine->add_vertex(r_result->collision_point + r_result->collision_normal * 10); normalLine->end(); @@ -1124,7 +1124,7 @@ public: if (cs->getNumChildShapes() > 1) { const btDbvt *tree = cs->getDynamicAabbTree(); - ERR_FAIL_COND_V(tree == NULL, true); + ERR_FAIL_COND_V(tree == nullptr, true); // Transform bounds into compound shape local space const btTransform other_in_compound_space = co->getWorldTransform().inverse(); @@ -1275,7 +1275,7 @@ bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const bt // Perform GJK test btPointCollector result; btGjkPairDetector gjk_pair_detector(p_shapeA, p_shapeB, gjk_simplex_solver, gjk_epa_pen_solver); - gjk_pair_detector.getClosestPoints(gjk_input, result, 0); + gjk_pair_detector.getClosestPoints(gjk_input, result, nullptr); if (0 > result.m_distance) { // Has penetration r_delta_recover_movement += result.m_normalOnBInWorld * (result.m_distance * -1 * p_recover_movement_scale); @@ -1302,10 +1302,10 @@ bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btC btTransform tA(p_transformA); - btCollisionObjectWrapper obA(NULL, p_shapeA, p_objectA, tA, -1, p_shapeId_A); - btCollisionObjectWrapper obB(NULL, p_shapeB, p_objectB, p_transformB, -1, p_shapeId_B); + btCollisionObjectWrapper obA(nullptr, p_shapeA, p_objectA, tA, -1, p_shapeId_A); + btCollisionObjectWrapper obB(nullptr, p_shapeB, p_objectB, p_transformB, -1, p_shapeId_B); - btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, NULL, BT_CONTACT_POINT_ALGORITHMS); + btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, nullptr, BT_CONTACT_POINT_ALGORITHMS); if (algorithm) { GodotDeepPenetrationContactResultCallback contactPointResult(&obA, &obB); //discrete collision detection query diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h index fce715b48d..f9a8c063fd 100644 --- a/modules/bullet/space_bullet.h +++ b/modules/bullet/space_bullet.h @@ -79,7 +79,7 @@ public: virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set &p_exclude = Set(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set &p_exclude = Set(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_ray = false); virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set &p_exclude = Set(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); - virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set &p_exclude = Set(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = NULL); + virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set &p_exclude = Set(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr); /// Returns the list of contacts pairs in this order: Local contact, other body contact virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set &p_exclude = Set(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set &p_exclude = Set(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); @@ -201,17 +201,17 @@ private: pointWorld(0, 0, 0), penetration_distance(1e20), other_compound_shape_index(0), - other_collision_object(NULL), + other_collision_object(nullptr), local_shape_most_recovered(0) {} }; - bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL); + bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = nullptr); /// This is an API that recover a kinematic object from penetration /// This allow only Convex Convex test and it always use GJK algorithm, With this API we don't benefit of Bullet special accelerated functions - bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL); + bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = nullptr); /// This is an API that recover a kinematic object from penetration /// Using this we leave Bullet to select the best algorithm, For example GJK in case we have Convex Convex, or a Bullet accelerated algorithm - bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL); + bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = nullptr); int add_separation_result(PhysicsServer3D::SeparationResult *r_results, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const; int recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer3D::SeparationResult *r_results); -- cgit v1.2.3