Style: Replaces uses of 0/NULL by nullptr (C++11)
Using clang-tidy's `modernize-use-nullptr`. https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
This commit is contained in:
@ -36,7 +36,7 @@ bool AreaPairSW::setup(real_t p_step) {
|
||||
|
||||
if (area->is_shape_set_as_disabled(area_shape) || body->is_shape_set_as_disabled(body_shape)) {
|
||||
result = false;
|
||||
} else if (area->test_collision_mask(body) && CollisionSolverSW::solve_static(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), NULL, this)) {
|
||||
} else if (area->test_collision_mask(body) && CollisionSolverSW::solve_static(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), nullptr, this)) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ bool Area2PairSW::setup(real_t p_step) {
|
||||
bool result = false;
|
||||
if (area_a->is_shape_set_as_disabled(shape_a) || area_b->is_shape_set_as_disabled(shape_b)) {
|
||||
result = false;
|
||||
} else if (area_a->test_collision_mask(area_b) && CollisionSolverSW::solve_static(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), NULL, this)) {
|
||||
} else if (area_a->test_collision_mask(area_b) && CollisionSolverSW::solve_static(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), nullptr, this)) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
|
||||
@ -539,7 +539,7 @@ void BodySW::integrate_forces(real_t p_step) {
|
||||
_update_shapes_with_motion(motion);
|
||||
}
|
||||
|
||||
def_area = NULL; // clear the area, so it is set in the next frame
|
||||
def_area = nullptr; // clear the area, so it is set in the next frame
|
||||
contact_count = 0;
|
||||
}
|
||||
|
||||
@ -703,7 +703,7 @@ bool BodySW::sleep_test(real_t p_step) {
|
||||
void BodySW::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) {
|
||||
if (fi_callback) {
|
||||
memdelete(fi_callback);
|
||||
fi_callback = NULL;
|
||||
fi_callback = nullptr;
|
||||
}
|
||||
|
||||
if (p_id != 0) {
|
||||
@ -736,8 +736,8 @@ BodySW::BodySW() :
|
||||
omit_force_integration = false;
|
||||
//applied_torque=0;
|
||||
island_step = 0;
|
||||
island_next = NULL;
|
||||
island_list_next = NULL;
|
||||
island_next = nullptr;
|
||||
island_list_next = nullptr;
|
||||
first_time_kinematic = false;
|
||||
first_integration = false;
|
||||
_set_static(false);
|
||||
@ -752,7 +752,7 @@ BodySW::BodySW() :
|
||||
still_time = 0;
|
||||
continuous_cd = false;
|
||||
can_sleep = true;
|
||||
fi_callback = NULL;
|
||||
fi_callback = nullptr;
|
||||
}
|
||||
|
||||
BodySW::~BodySW() {
|
||||
@ -760,7 +760,7 @@ BodySW::~BodySW() {
|
||||
memdelete(fi_callback);
|
||||
}
|
||||
|
||||
PhysicsDirectBodyStateSW *PhysicsDirectBodyStateSW::singleton = NULL;
|
||||
PhysicsDirectBodyStateSW *PhysicsDirectBodyStateSW::singleton = nullptr;
|
||||
|
||||
PhysicsDirectSpaceState *PhysicsDirectBodyStateSW::get_space_state() {
|
||||
return body->get_space()->get_direct_state();
|
||||
|
||||
@ -451,7 +451,7 @@ public:
|
||||
virtual real_t get_step() const { return step; }
|
||||
PhysicsDirectBodyStateSW() {
|
||||
singleton = this;
|
||||
body = NULL;
|
||||
body = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include "core/print_string.h"
|
||||
|
||||
BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subindex, const AABB &p_aabb) {
|
||||
ERR_FAIL_COND_V(p_object == NULL, 0);
|
||||
ERR_FAIL_COND_V(p_object == nullptr, 0);
|
||||
|
||||
current++;
|
||||
|
||||
@ -80,7 +80,7 @@ void BroadPhaseBasic::remove(ID p_id) {
|
||||
|
||||
CollisionObjectSW *BroadPhaseBasic::get_object(ID p_id) const {
|
||||
const Map<ID, Element>::Element *E = element_map.find(p_id);
|
||||
ERR_FAIL_COND_V(!E, NULL);
|
||||
ERR_FAIL_COND_V(!E, nullptr);
|
||||
return E->get().owner;
|
||||
}
|
||||
bool BroadPhaseBasic::is_static(ID p_id) const {
|
||||
@ -176,7 +176,7 @@ void BroadPhaseBasic::update() {
|
||||
}
|
||||
|
||||
if (pair_ok && !E) {
|
||||
void *data = NULL;
|
||||
void *data = nullptr;
|
||||
if (pair_callback) {
|
||||
data = pair_callback(elem_A->owner, elem_A->subindex, elem_B->owner, elem_B->subindex, unpair_userdata);
|
||||
if (data) {
|
||||
@ -194,8 +194,8 @@ BroadPhaseSW *BroadPhaseBasic::_create() {
|
||||
|
||||
BroadPhaseBasic::BroadPhaseBasic() {
|
||||
current = 1;
|
||||
unpair_callback = NULL;
|
||||
unpair_userdata = NULL;
|
||||
pair_callback = NULL;
|
||||
pair_userdata = NULL;
|
||||
unpair_callback = nullptr;
|
||||
unpair_userdata = nullptr;
|
||||
pair_callback = nullptr;
|
||||
pair_userdata = nullptr;
|
||||
}
|
||||
|
||||
@ -89,9 +89,9 @@ public:
|
||||
virtual bool is_static(ID p_id) const;
|
||||
virtual int get_subindex(ID p_id) const;
|
||||
|
||||
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
|
||||
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
|
||||
virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
|
||||
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr);
|
||||
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr);
|
||||
virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr);
|
||||
|
||||
virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata);
|
||||
virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata);
|
||||
|
||||
@ -51,7 +51,7 @@ void BroadPhaseBVH::remove(ID p_id) {
|
||||
|
||||
CollisionObjectSW *BroadPhaseBVH::get_object(ID p_id) const {
|
||||
CollisionObjectSW *it = bvh.get(p_id - 1);
|
||||
ERR_FAIL_COND_V(!it, NULL);
|
||||
ERR_FAIL_COND_V(!it, nullptr);
|
||||
return it;
|
||||
}
|
||||
bool BroadPhaseBVH::is_static(ID p_id) const {
|
||||
@ -76,7 +76,7 @@ int BroadPhaseBVH::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results,
|
||||
void *BroadPhaseBVH::_pair_callback(void *self, uint32_t p_A, CollisionObjectSW *p_object_A, int subindex_A, uint32_t p_B, CollisionObjectSW *p_object_B, int subindex_B) {
|
||||
BroadPhaseBVH *bpo = (BroadPhaseBVH *)(self);
|
||||
if (!bpo->pair_callback)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return bpo->pair_callback(p_object_A, subindex_A, p_object_B, subindex_B, bpo->pair_userdata);
|
||||
}
|
||||
@ -109,7 +109,7 @@ BroadPhaseSW *BroadPhaseBVH::_create() {
|
||||
BroadPhaseBVH::BroadPhaseBVH() {
|
||||
bvh.set_pair_callback(_pair_callback, this);
|
||||
bvh.set_unpair_callback(_unpair_callback, this);
|
||||
pair_callback = NULL;
|
||||
pair_userdata = NULL;
|
||||
unpair_userdata = NULL;
|
||||
pair_callback = nullptr;
|
||||
pair_userdata = nullptr;
|
||||
unpair_userdata = nullptr;
|
||||
}
|
||||
|
||||
@ -56,9 +56,9 @@ public:
|
||||
virtual bool is_static(ID p_id) const;
|
||||
virtual int get_subindex(ID p_id) const;
|
||||
|
||||
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
|
||||
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
|
||||
virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
|
||||
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr);
|
||||
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr);
|
||||
virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr);
|
||||
|
||||
virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata);
|
||||
virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata);
|
||||
|
||||
@ -50,7 +50,7 @@ void BroadPhaseOctree::remove(ID p_id) {
|
||||
|
||||
CollisionObjectSW *BroadPhaseOctree::get_object(ID p_id) const {
|
||||
CollisionObjectSW *it = octree.get(p_id);
|
||||
ERR_FAIL_COND_V(!it, NULL);
|
||||
ERR_FAIL_COND_V(!it, nullptr);
|
||||
return it;
|
||||
}
|
||||
bool BroadPhaseOctree::is_static(ID p_id) const {
|
||||
@ -75,7 +75,7 @@ int BroadPhaseOctree::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_result
|
||||
void *BroadPhaseOctree::_pair_callback(void *self, OctreeElementID p_A, CollisionObjectSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObjectSW *p_object_B, int subindex_B) {
|
||||
BroadPhaseOctree *bpo = (BroadPhaseOctree *)(self);
|
||||
if (!bpo->pair_callback)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return bpo->pair_callback(p_object_A, subindex_A, p_object_B, subindex_B, bpo->pair_userdata);
|
||||
}
|
||||
@ -108,7 +108,7 @@ BroadPhaseSW *BroadPhaseOctree::_create() {
|
||||
BroadPhaseOctree::BroadPhaseOctree() {
|
||||
octree.set_pair_callback(_pair_callback, this);
|
||||
octree.set_unpair_callback(_unpair_callback, this);
|
||||
pair_callback = NULL;
|
||||
pair_userdata = NULL;
|
||||
unpair_userdata = NULL;
|
||||
pair_callback = nullptr;
|
||||
pair_userdata = nullptr;
|
||||
unpair_userdata = nullptr;
|
||||
}
|
||||
|
||||
@ -56,9 +56,9 @@ public:
|
||||
virtual bool is_static(ID p_id) const;
|
||||
virtual int get_subindex(ID p_id) const;
|
||||
|
||||
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
|
||||
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
|
||||
virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
|
||||
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr);
|
||||
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr);
|
||||
virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr);
|
||||
|
||||
virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata);
|
||||
virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata);
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
#include "broad_phase_sw.h"
|
||||
|
||||
BroadPhaseSW::CreateFunction BroadPhaseSW::create_func = NULL;
|
||||
BroadPhaseSW::CreateFunction BroadPhaseSW::create_func = nullptr;
|
||||
|
||||
BroadPhaseSW::~BroadPhaseSW() {
|
||||
}
|
||||
|
||||
@ -57,9 +57,9 @@ public:
|
||||
virtual bool is_static(ID p_id) const = 0;
|
||||
virtual int get_subindex(ID p_id) const = 0;
|
||||
|
||||
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
|
||||
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
|
||||
virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
|
||||
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr) = 0;
|
||||
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr) = 0;
|
||||
virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = nullptr) = 0;
|
||||
|
||||
virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata) = 0;
|
||||
virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) = 0;
|
||||
|
||||
@ -212,7 +212,7 @@ CollisionObjectSW::CollisionObjectSW(Type p_type) :
|
||||
pending_shape_update_list(this) {
|
||||
_static = true;
|
||||
type = p_type;
|
||||
space = NULL;
|
||||
space = nullptr;
|
||||
instance_id = 0;
|
||||
collision_layer = 1;
|
||||
collision_mask = 1;
|
||||
|
||||
@ -550,21 +550,21 @@ static void _generate_contacts_from_supports(const Vector3 *p_points_A, int p_po
|
||||
_generate_contacts_point_circle,
|
||||
},
|
||||
{
|
||||
0,
|
||||
nullptr,
|
||||
_generate_contacts_edge_edge,
|
||||
_generate_contacts_face_face,
|
||||
_generate_contacts_edge_circle,
|
||||
},
|
||||
{
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
_generate_contacts_face_face,
|
||||
_generate_contacts_face_circle,
|
||||
},
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
_generate_contacts_circle_circle,
|
||||
},
|
||||
};
|
||||
@ -2109,36 +2109,36 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_tran
|
||||
_collision_sphere_cylinder<false>,
|
||||
_collision_sphere_convex_polygon<false>,
|
||||
_collision_sphere_face<false> },
|
||||
{ 0,
|
||||
{ nullptr,
|
||||
_collision_box_box<false>,
|
||||
_collision_box_capsule<false>,
|
||||
_collision_box_cylinder<false>,
|
||||
_collision_box_convex_polygon<false>,
|
||||
_collision_box_face<false> },
|
||||
{ 0,
|
||||
0,
|
||||
{ nullptr,
|
||||
nullptr,
|
||||
_collision_capsule_capsule<false>,
|
||||
_collision_capsule_cylinder<false>,
|
||||
_collision_capsule_convex_polygon<false>,
|
||||
_collision_capsule_face<false> },
|
||||
{ 0,
|
||||
0,
|
||||
0,
|
||||
{ nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
_collision_cylinder_cylinder<false>,
|
||||
_collision_cylinder_convex_polygon<false>,
|
||||
_collision_cylinder_face<false> },
|
||||
{ 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{ nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
_collision_convex_polygon_convex_polygon<false>,
|
||||
_collision_convex_polygon_face<false> },
|
||||
{ 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0 },
|
||||
{ nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr },
|
||||
};
|
||||
|
||||
static const CollisionFunc collision_table_margin[6][6] = {
|
||||
@ -2148,36 +2148,36 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_tran
|
||||
_collision_sphere_cylinder<true>,
|
||||
_collision_sphere_convex_polygon<true>,
|
||||
_collision_sphere_face<true> },
|
||||
{ 0,
|
||||
{ nullptr,
|
||||
_collision_box_box<true>,
|
||||
_collision_box_capsule<true>,
|
||||
_collision_box_cylinder<true>,
|
||||
_collision_box_convex_polygon<true>,
|
||||
_collision_box_face<true> },
|
||||
{ 0,
|
||||
0,
|
||||
{ nullptr,
|
||||
nullptr,
|
||||
_collision_capsule_capsule<true>,
|
||||
_collision_capsule_cylinder<true>,
|
||||
_collision_capsule_convex_polygon<true>,
|
||||
_collision_capsule_face<true> },
|
||||
{ 0,
|
||||
0,
|
||||
0,
|
||||
{ nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
_collision_cylinder_cylinder<true>,
|
||||
_collision_cylinder_convex_polygon<true>,
|
||||
_collision_cylinder_face<true> },
|
||||
{ 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{ nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
_collision_convex_polygon_convex_polygon<true>,
|
||||
_collision_convex_polygon_face<true> },
|
||||
{ 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0 },
|
||||
{ nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr },
|
||||
};
|
||||
|
||||
_CollectorCallback callback;
|
||||
|
||||
@ -33,6 +33,6 @@
|
||||
|
||||
#include "collision_solver_sw.h"
|
||||
|
||||
bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false, Vector3 *r_prev_axis = NULL, real_t p_margin_a = 0, real_t p_margin_b = 0);
|
||||
bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false, Vector3 *r_prev_axis = nullptr, real_t p_margin_a = 0, real_t p_margin_b = 0);
|
||||
|
||||
#endif // COLLISION_SOLVER_SAT_H
|
||||
|
||||
@ -137,7 +137,7 @@ void CollisionSolverSW::concave_callback(void *p_userdata, ShapeSW *p_convex) {
|
||||
_ConcaveCollisionInfo &cinfo = *(_ConcaveCollisionInfo *)(p_userdata);
|
||||
cinfo.aabb_tests++;
|
||||
|
||||
bool collided = collision_solver(cinfo.shape_A, *cinfo.transform_A, p_convex, *cinfo.transform_B, cinfo.result_callback, cinfo.userdata, cinfo.swap_result, NULL, cinfo.margin_A, cinfo.margin_B);
|
||||
bool collided = collision_solver(cinfo.shape_A, *cinfo.transform_A, p_convex, *cinfo.transform_B, cinfo.result_callback, cinfo.userdata, cinfo.swap_result, nullptr, cinfo.margin_A, cinfo.margin_B);
|
||||
if (!collided)
|
||||
return;
|
||||
|
||||
@ -331,8 +331,8 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform
|
||||
cinfo.transform_A = &p_transform_A;
|
||||
cinfo.shape_A = p_shape_A;
|
||||
cinfo.transform_B = &p_transform_B;
|
||||
cinfo.result_callback = NULL;
|
||||
cinfo.userdata = NULL;
|
||||
cinfo.result_callback = nullptr;
|
||||
cinfo.userdata = nullptr;
|
||||
cinfo.swap_result = false;
|
||||
cinfo.collided = false;
|
||||
cinfo.collisions = 0;
|
||||
|
||||
@ -46,8 +46,8 @@ private:
|
||||
static bool solve_distance_plane(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B);
|
||||
|
||||
public:
|
||||
static bool solve_static(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis = NULL, real_t p_margin_A = 0, real_t p_margin_B = 0);
|
||||
static bool solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis = NULL);
|
||||
static bool solve_static(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis = nullptr, real_t p_margin_A = 0, real_t p_margin_B = 0);
|
||||
static bool solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis = nullptr);
|
||||
};
|
||||
|
||||
#endif // COLLISION_SOLVER__SW_H
|
||||
|
||||
@ -45,7 +45,7 @@ class ConstraintSW : public RID_Data {
|
||||
RID self;
|
||||
|
||||
protected:
|
||||
ConstraintSW(BodySW **p_body_ptr = NULL, int p_body_count = 0) {
|
||||
ConstraintSW(BodySW **p_body_ptr = nullptr, int p_body_count = 0) {
|
||||
_body_ptr = p_body_ptr;
|
||||
_body_count = p_body_count;
|
||||
island_step = 0;
|
||||
|
||||
@ -552,14 +552,14 @@ struct GJK
|
||||
{
|
||||
sFace* root;
|
||||
U count;
|
||||
sList() : root(0),count(0) {}
|
||||
sList() : root(nullptr),count(0) {}
|
||||
};
|
||||
struct sHorizon
|
||||
{
|
||||
sFace* cf;
|
||||
sFace* ff;
|
||||
U nf;
|
||||
sHorizon() : cf(0),ff(0),nf(0) {}
|
||||
sHorizon() : cf(nullptr),ff(nullptr),nf(0) {}
|
||||
};
|
||||
struct eStatus { enum _ {
|
||||
Valid,
|
||||
@ -596,7 +596,7 @@ struct GJK
|
||||
}
|
||||
static inline void append(sList& list,sFace* face)
|
||||
{
|
||||
face->l[0] = 0;
|
||||
face->l[0] = nullptr;
|
||||
face->l[1] = list.root;
|
||||
if(list.root) list.root->l[0]=face;
|
||||
list.root = face;
|
||||
@ -796,13 +796,13 @@ struct GJK
|
||||
} else m_status=eStatus::Degenerated;
|
||||
remove(m_hull,face);
|
||||
append(m_stock,face);
|
||||
return(0);
|
||||
return(nullptr);
|
||||
}
|
||||
// -- GODOT start --
|
||||
//m_status=m_stock.root?eStatus::OutOfVertices:eStatus::OutOfFaces;
|
||||
m_status=eStatus::OutOfFaces;
|
||||
// -- GODOT end --
|
||||
return(0);
|
||||
return(nullptr);
|
||||
}
|
||||
sFace* findbest()
|
||||
{
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
class JointSW : public ConstraintSW {
|
||||
public:
|
||||
virtual PhysicsServer::JointType get_type() const = 0;
|
||||
_FORCE_INLINE_ JointSW(BodySW **p_body_ptr = NULL, int p_body_count = 0) :
|
||||
_FORCE_INLINE_ JointSW(BodySW **p_body_ptr = nullptr, int p_body_count = 0) :
|
||||
ConstraintSW(p_body_ptr, p_body_count) {
|
||||
}
|
||||
};
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.");
|
||||
|
||||
RID PhysicsServerSW::shape_create(ShapeType p_shape) {
|
||||
ShapeSW *shape = NULL;
|
||||
ShapeSW *shape = nullptr;
|
||||
switch (p_shape) {
|
||||
case SHAPE_PLANE: {
|
||||
shape = memnew(PlaneShapeSW);
|
||||
@ -174,8 +174,8 @@ real_t PhysicsServerSW::space_get_param(RID p_space, SpaceParameter p_param) con
|
||||
|
||||
PhysicsDirectSpaceState *PhysicsServerSW::space_get_direct_state(RID p_space) {
|
||||
SpaceSW *space = space_owner.get(p_space);
|
||||
ERR_FAIL_COND_V(!space, NULL);
|
||||
ERR_FAIL_COND_V_MSG(space->is_locked(), NULL, "Space state is inaccessible right now, wait for iteration or physics process notification.");
|
||||
ERR_FAIL_COND_V(!space, nullptr);
|
||||
ERR_FAIL_COND_V_MSG(space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification.");
|
||||
|
||||
return space->get_direct_state();
|
||||
}
|
||||
@ -209,7 +209,7 @@ void PhysicsServerSW::area_set_space(RID p_area, RID p_space) {
|
||||
AreaSW *area = area_owner.get(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
|
||||
SpaceSW *space = NULL;
|
||||
SpaceSW *space = nullptr;
|
||||
if (p_space.is_valid()) {
|
||||
space = space_owner.get(p_space);
|
||||
ERR_FAIL_COND(!space);
|
||||
@ -439,7 +439,7 @@ void PhysicsServerSW::body_set_space(RID p_body, RID p_space) {
|
||||
BodySW *body = body_owner.get(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
|
||||
SpaceSW *space = NULL;
|
||||
SpaceSW *space = nullptr;
|
||||
if (p_space.is_valid()) {
|
||||
space = space_owner.get(p_space);
|
||||
ERR_FAIL_COND(!space);
|
||||
@ -875,8 +875,8 @@ int PhysicsServerSW::body_test_ray_separation(RID p_body, const Transform &p_tra
|
||||
|
||||
PhysicsDirectBodyState *PhysicsServerSW::body_get_direct_state(RID p_body) {
|
||||
BodySW *body = body_owner.get(p_body);
|
||||
ERR_FAIL_COND_V(!body, NULL);
|
||||
ERR_FAIL_COND_V_MSG(body->get_space()->is_locked(), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification.");
|
||||
ERR_FAIL_COND_V(!body, nullptr);
|
||||
ERR_FAIL_COND_V_MSG(body->get_space()->is_locked(), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
|
||||
|
||||
direct_state->body = body;
|
||||
return direct_state;
|
||||
@ -1208,7 +1208,7 @@ void PhysicsServerSW::free(RID p_rid) {
|
||||
_clear_query(body->get_direct_state_query());
|
||||
*/
|
||||
|
||||
body->set_space(NULL);
|
||||
body->set_space(nullptr);
|
||||
|
||||
while (body->get_shape_count()) {
|
||||
body->remove_shape(0);
|
||||
@ -1225,7 +1225,7 @@ void PhysicsServerSW::free(RID p_rid) {
|
||||
_clear_query(area->get_monitor_query());
|
||||
*/
|
||||
|
||||
area->set_space(NULL);
|
||||
area->set_space(nullptr);
|
||||
|
||||
while (area->get_shape_count()) {
|
||||
area->remove_shape(0);
|
||||
@ -1238,7 +1238,7 @@ void PhysicsServerSW::free(RID p_rid) {
|
||||
|
||||
while (space->get_objects().size()) {
|
||||
CollisionObjectSW *co = (CollisionObjectSW *)space->get_objects().front()->get();
|
||||
co->set_space(NULL);
|
||||
co->set_space(nullptr);
|
||||
}
|
||||
|
||||
active_spaces.erase(space);
|
||||
@ -1405,7 +1405,7 @@ void PhysicsServerSW::_shape_col_cbk(const Vector3 &p_point_A, const Vector3 &p_
|
||||
}
|
||||
}
|
||||
|
||||
PhysicsServerSW *PhysicsServerSW::singleton = NULL;
|
||||
PhysicsServerSW *PhysicsServerSW::singleton = nullptr;
|
||||
PhysicsServerSW::PhysicsServerSW() {
|
||||
singleton = this;
|
||||
|
||||
|
||||
@ -233,7 +233,7 @@ public:
|
||||
virtual void body_set_ray_pickable(RID p_body, bool p_enable);
|
||||
virtual bool body_is_ray_pickable(RID p_body) const;
|
||||
|
||||
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);
|
||||
|
||||
// this function only works on physics process, errors and returns null otherwise
|
||||
|
||||
@ -1460,8 +1460,8 @@ _VolumeSW_BVH *_volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements, int p_siz
|
||||
if (p_size == 1) {
|
||||
//leaf
|
||||
bvh->aabb = p_elements[0].aabb;
|
||||
bvh->left = NULL;
|
||||
bvh->right = NULL;
|
||||
bvh->left = nullptr;
|
||||
bvh->right = nullptr;
|
||||
bvh->face_index = p_elements->face_index;
|
||||
count++;
|
||||
return bvh;
|
||||
|
||||
@ -80,7 +80,7 @@ int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResu
|
||||
if (r_results[cc].collider_id != 0)
|
||||
r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id);
|
||||
else
|
||||
r_results[cc].collider = NULL;
|
||||
r_results[cc].collider = nullptr;
|
||||
r_results[cc].rid = col_obj->get_self();
|
||||
r_results[cc].shape = shape_idx;
|
||||
|
||||
@ -155,7 +155,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto
|
||||
if (r_result.collider_id != 0)
|
||||
r_result.collider = ObjectDB::get_instance(r_result.collider_id);
|
||||
else
|
||||
r_result.collider = NULL;
|
||||
r_result.collider = nullptr;
|
||||
r_result.normal = res_normal;
|
||||
r_result.position = res_point;
|
||||
r_result.rid = res_obj->get_self();
|
||||
@ -194,7 +194,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo
|
||||
const CollisionObjectSW *col_obj = space->intersection_query_results[i];
|
||||
int shape_idx = space->intersection_query_subindex_results[i];
|
||||
|
||||
if (!CollisionSolverSW::solve_static(shape, p_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), NULL, NULL, NULL, p_margin, 0))
|
||||
if (!CollisionSolverSW::solve_static(shape, p_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), nullptr, nullptr, nullptr, p_margin, 0))
|
||||
continue;
|
||||
|
||||
if (r_results) {
|
||||
@ -202,7 +202,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo
|
||||
if (r_results[cc].collider_id != 0)
|
||||
r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id);
|
||||
else
|
||||
r_results[cc].collider = NULL;
|
||||
r_results[cc].collider = nullptr;
|
||||
r_results[cc].rid = col_obj->get_self();
|
||||
r_results[cc].shape = shape_idx;
|
||||
}
|
||||
@ -350,7 +350,7 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CollisionSolverSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
|
||||
if (CollisionSolverSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, nullptr, p_margin)) {
|
||||
collided = true;
|
||||
}
|
||||
}
|
||||
@ -401,7 +401,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_
|
||||
|
||||
_RestCallbackData rcd;
|
||||
rcd.best_len = 0;
|
||||
rcd.best_object = NULL;
|
||||
rcd.best_object = nullptr;
|
||||
rcd.best_shape = 0;
|
||||
rcd.min_allowed_depth = space->test_motion_min_contact_depth;
|
||||
|
||||
@ -417,7 +417,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_
|
||||
|
||||
rcd.object = col_obj;
|
||||
rcd.shape = shape_idx;
|
||||
bool sc = CollisionSolverSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, NULL, p_margin);
|
||||
bool sc = CollisionSolverSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, nullptr, p_margin);
|
||||
if (!sc)
|
||||
continue;
|
||||
}
|
||||
@ -482,7 +482,7 @@ Vector3 PhysicsDirectSpaceStateSW::get_closest_point_to_object_volume(RID p_obje
|
||||
}
|
||||
|
||||
PhysicsDirectSpaceStateSW::PhysicsDirectSpaceStateSW() {
|
||||
space = NULL;
|
||||
space = nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -595,7 +595,7 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo
|
||||
}
|
||||
|
||||
ShapeSW *against_shape = col_obj->get_shape(shape_idx);
|
||||
if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, against_shape, col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
|
||||
if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, against_shape, col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, nullptr, p_margin)) {
|
||||
if (cbk.amount > 0) {
|
||||
collided = true;
|
||||
}
|
||||
@ -748,7 +748,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
|
||||
const CollisionObjectSW *col_obj = intersection_query_results[i];
|
||||
int shape_idx = intersection_query_subindex_results[i];
|
||||
|
||||
if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
|
||||
if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, nullptr, p_margin)) {
|
||||
collided = cbk.amount > 0;
|
||||
}
|
||||
}
|
||||
@ -906,7 +906,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
|
||||
|
||||
_RestCallbackData rcd;
|
||||
rcd.best_len = 0;
|
||||
rcd.best_object = NULL;
|
||||
rcd.best_object = nullptr;
|
||||
rcd.best_shape = 0;
|
||||
|
||||
// Allowed depth can't be lower than motion length, in order to handle contacts at low speed.
|
||||
@ -937,7 +937,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
|
||||
rcd.object = col_obj;
|
||||
rcd.shape = shape_idx;
|
||||
rcd.local_shape = j;
|
||||
bool sc = CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, NULL, p_margin);
|
||||
bool sc = CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, nullptr, p_margin);
|
||||
if (!sc)
|
||||
continue;
|
||||
}
|
||||
@ -1009,7 +1009,7 @@ void *SpaceSW::_broadphase_pair(CollisionObjectSW *A, int p_subindex_A, Collisio
|
||||
return b;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SpaceSW::_broadphase_unpair(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_data, void *p_self) {
|
||||
@ -1205,7 +1205,7 @@ SpaceSW::SpaceSW() {
|
||||
broadphase = BroadPhaseSW::create_func();
|
||||
broadphase->set_pair_callback(_broadphase_pair, this);
|
||||
broadphase->set_unpair_callback(_broadphase_unpair, this);
|
||||
area = NULL;
|
||||
area = nullptr;
|
||||
|
||||
direct_access = memnew(PhysicsDirectSpaceStateSW);
|
||||
direct_access->space = this;
|
||||
|
||||
@ -50,7 +50,7 @@ public:
|
||||
virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), 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<RID> &p_exclude = Set<RID>(), 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, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), 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, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), 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, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr);
|
||||
virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), 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, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
|
||||
virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const;
|
||||
|
||||
@ -82,7 +82,7 @@ void StepSW::_solve_island(ConstraintSW *p_island, int p_iterations, real_t p_de
|
||||
|
||||
{
|
||||
ConstraintSW *ci = p_island;
|
||||
ConstraintSW *prev = NULL;
|
||||
ConstraintSW *prev = nullptr;
|
||||
while (ci) {
|
||||
if (ci->get_priority() < at_priority) {
|
||||
if (prev) {
|
||||
@ -165,8 +165,8 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
|
||||
|
||||
/* GENERATE CONSTRAINT ISLANDS */
|
||||
|
||||
BodySW *island_list = NULL;
|
||||
ConstraintSW *constraint_island_list = NULL;
|
||||
BodySW *island_list = nullptr;
|
||||
ConstraintSW *constraint_island_list = nullptr;
|
||||
b = body_list->first();
|
||||
|
||||
int island_count = 0;
|
||||
@ -175,8 +175,8 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
|
||||
BodySW *body = b->self();
|
||||
|
||||
if (body->get_island_step() != _step) {
|
||||
BodySW *island = NULL;
|
||||
ConstraintSW *constraint_island = NULL;
|
||||
BodySW *island = nullptr;
|
||||
ConstraintSW *constraint_island = nullptr;
|
||||
_populate_island(body, &island, &constraint_island);
|
||||
|
||||
island->set_island_list_next(island_list);
|
||||
@ -201,7 +201,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) {
|
||||
if (c->get_island_step() == _step)
|
||||
continue;
|
||||
c->set_island_step(_step);
|
||||
c->set_island_next(NULL);
|
||||
c->set_island_next(nullptr);
|
||||
c->set_island_list_next(constraint_island_list);
|
||||
constraint_island_list = c;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user