summaryrefslogtreecommitdiff
path: root/servers/physics_3d
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 14:29:06 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit07bc4e2f96f8f47991339654ff4ab16acc19d44f (patch)
tree43cdc7cfe8239c23065616a931de3769d2db1e86 /servers/physics_3d
parent0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (diff)
Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
Diffstat (limited to 'servers/physics_3d')
-rw-r--r--servers/physics_3d/area_3d_sw.cpp1
-rw-r--r--servers/physics_3d/area_3d_sw.h2
-rw-r--r--servers/physics_3d/body_3d_sw.cpp3
-rw-r--r--servers/physics_3d/broad_phase_3d_basic.cpp6
-rw-r--r--servers/physics_3d/broad_phase_octree.cpp4
-rw-r--r--servers/physics_3d/collision_object_3d_sw.cpp1
-rw-r--r--servers/physics_3d/gjk_epa.cpp2
-rw-r--r--servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp1
-rw-r--r--servers/physics_3d/joints/hinge_joint_3d_sw.cpp3
-rw-r--r--servers/physics_3d/physics_server_3d_sw.cpp14
-rw-r--r--servers/physics_3d/shape_3d_sw.cpp3
-rw-r--r--servers/physics_3d/space_3d_sw.cpp5
12 files changed, 45 insertions, 0 deletions
diff --git a/servers/physics_3d/area_3d_sw.cpp b/servers/physics_3d/area_3d_sw.cpp
index 59041cb5e0..de4399330d 100644
--- a/servers/physics_3d/area_3d_sw.cpp
+++ b/servers/physics_3d/area_3d_sw.cpp
@@ -38,6 +38,7 @@ Area3DSW::BodyKey::BodyKey(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_a
body_shape = p_body_shape;
area_shape = p_area_shape;
}
+
Area3DSW::BodyKey::BodyKey(Area3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
rid = p_body->get_self();
instance_id = p_body->get_instance_id();
diff --git a/servers/physics_3d/area_3d_sw.h b/servers/physics_3d/area_3d_sw.h
index f64c84b5ab..d85a7fc509 100644
--- a/servers/physics_3d/area_3d_sw.h
+++ b/servers/physics_3d/area_3d_sw.h
@@ -170,6 +170,7 @@ void Area3DSW::add_body_to_query(Body3DSW *p_body, uint32_t p_body_shape, uint32
if (!monitor_query_list.in_list())
_queue_monitor_update();
}
+
void Area3DSW::remove_body_from_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
BodyKey bk(p_body, p_body_shape, p_area_shape);
monitored_bodies[bk].dec();
@@ -183,6 +184,7 @@ void Area3DSW::add_area_to_query(Area3DSW *p_area, uint32_t p_area_shape, uint32
if (!monitor_query_list.in_list())
_queue_monitor_update();
}
+
void Area3DSW::remove_area_from_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
BodyKey bk(p_area, p_area_shape, p_self_shape);
monitored_areas[bk].dec();
diff --git a/servers/physics_3d/body_3d_sw.cpp b/servers/physics_3d/body_3d_sw.cpp
index c8a6a2303e..c01e55c4dd 100644
--- a/servers/physics_3d/body_3d_sw.cpp
+++ b/servers/physics_3d/body_3d_sw.cpp
@@ -254,6 +254,7 @@ void Body3DSW::set_mode(PhysicsServer3D::BodyMode p_mode) {
_update_queries();
*/
}
+
PhysicsServer3D::BodyMode Body3DSW::get_mode() const {
return mode;
}
@@ -331,6 +332,7 @@ void Body3DSW::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_va
} break;
}
}
+
Variant Body3DSW::get_state(PhysicsServer3D::BodyState p_state) const {
switch (p_state) {
case PhysicsServer3D::BODY_STATE_TRANSFORM: {
@@ -635,6 +637,7 @@ void BodySW::simulate_motion(const Transform& p_xform,real_t p_step) {
}
+
*/
void Body3DSW::wakeup_neighbours() {
diff --git a/servers/physics_3d/broad_phase_3d_basic.cpp b/servers/physics_3d/broad_phase_3d_basic.cpp
index 6a679a1040..68bf0da53e 100644
--- a/servers/physics_3d/broad_phase_3d_basic.cpp
+++ b/servers/physics_3d/broad_phase_3d_basic.cpp
@@ -51,11 +51,13 @@ void BroadPhase3DBasic::move(ID p_id, const AABB &p_aabb) {
ERR_FAIL_COND(!E);
E->get().aabb = p_aabb;
}
+
void BroadPhase3DBasic::set_static(ID p_id, bool p_static) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
E->get()._static = p_static;
}
+
void BroadPhase3DBasic::remove(ID p_id) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
@@ -83,11 +85,13 @@ CollisionObject3DSW *BroadPhase3DBasic::get_object(ID p_id) const {
ERR_FAIL_COND_V(!E, nullptr);
return E->get().owner;
}
+
bool BroadPhase3DBasic::is_static(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, false);
return E->get()._static;
}
+
int BroadPhase3DBasic::get_subindex(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, -1);
@@ -127,6 +131,7 @@ int BroadPhase3DBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to,
return rc;
}
+
int BroadPhase3DBasic::cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
int rc = 0;
@@ -148,6 +153,7 @@ void BroadPhase3DBasic::set_pair_callback(PairCallback p_pair_callback, void *p_
pair_userdata = p_userdata;
pair_callback = p_pair_callback;
}
+
void BroadPhase3DBasic::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
unpair_userdata = p_userdata;
unpair_callback = p_unpair_callback;
diff --git a/servers/physics_3d/broad_phase_octree.cpp b/servers/physics_3d/broad_phase_octree.cpp
index b81ce31ef3..ffa1802bc8 100644
--- a/servers/physics_3d/broad_phase_octree.cpp
+++ b/servers/physics_3d/broad_phase_octree.cpp
@@ -44,6 +44,7 @@ void BroadPhaseOctree::set_static(ID p_id, bool p_static) {
CollisionObject3DSW *it = octree.get(p_id);
octree.set_pairable(p_id, !p_static, 1 << it->get_type(), p_static ? 0 : 0xFFFFF); //pair everything, don't care 1?
}
+
void BroadPhaseOctree::remove(ID p_id) {
octree.erase(p_id);
}
@@ -53,9 +54,11 @@ CollisionObject3DSW *BroadPhaseOctree::get_object(ID p_id) const {
ERR_FAIL_COND_V(!it, nullptr);
return it;
}
+
bool BroadPhaseOctree::is_static(ID p_id) const {
return !octree.is_pairable(p_id);
}
+
int BroadPhaseOctree::get_subindex(ID p_id) const {
return octree.get_subindex(p_id);
}
@@ -92,6 +95,7 @@ void BroadPhaseOctree::set_pair_callback(PairCallback p_pair_callback, void *p_u
pair_callback = p_pair_callback;
pair_userdata = p_userdata;
}
+
void BroadPhaseOctree::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
unpair_callback = p_unpair_callback;
unpair_userdata = p_userdata;
diff --git a/servers/physics_3d/collision_object_3d_sw.cpp b/servers/physics_3d/collision_object_3d_sw.cpp
index f7e3b507ca..22a8235744 100644
--- a/servers/physics_3d/collision_object_3d_sw.cpp
+++ b/servers/physics_3d/collision_object_3d_sw.cpp
@@ -61,6 +61,7 @@ void CollisionObject3DSW::set_shape(int p_index, Shape3DSW *p_shape) {
//_update_shapes();
//_shapes_changed();
}
+
void CollisionObject3DSW::set_shape_transform(int p_index, const Transform &p_transform) {
ERR_FAIL_INDEX(p_index, shapes.size());
diff --git a/servers/physics_3d/gjk_epa.cpp b/servers/physics_3d/gjk_epa.cpp
index a937ebc426..7f7fc0f55b 100644
--- a/servers/physics_3d/gjk_epa.cpp
+++ b/servers/physics_3d/gjk_epa.cpp
@@ -847,6 +847,7 @@ bool Distance( const Shape3DSW* shape0,
}
}
+
//
bool Penetration( const Shape3DSW* shape0,
const Transform& wtrs0,
@@ -891,6 +892,7 @@ bool Penetration( const Shape3DSW* shape0,
}
+
/* Symbols cleanup */
#undef GJK_MAX_ITERATIONS
diff --git a/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp
index 77e6eacb69..97310a5924 100644
--- a/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp
+++ b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp
@@ -623,6 +623,7 @@ void Generic6DOFJoint3DSW::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOF
break; // Can't happen, but silences warning
}
}
+
bool Generic6DOFJoint3DSW::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {
ERR_FAIL_INDEX_V(p_axis, 3, 0);
switch (p_flag) {
diff --git a/servers/physics_3d/joints/hinge_joint_3d_sw.cpp b/servers/physics_3d/joints/hinge_joint_3d_sw.cpp
index a77d78ccaa..a879b4ca7f 100644
--- a/servers/physics_3d/joints/hinge_joint_3d_sw.cpp
+++ b/servers/physics_3d/joints/hinge_joint_3d_sw.cpp
@@ -360,12 +360,14 @@ void HingeJoint3DSW::solve(real_t p_step) {
}
}
}
+
/*
void HingeJointSW::updateRHS(real_t timeStep)
{
(void)timeStep;
}
+
*/
static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) {
@@ -459,6 +461,7 @@ void HingeJoint3DSW::set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_val
break; // Can't happen, but silences warning
}
}
+
bool HingeJoint3DSW::get_flag(PhysicsServer3D::HingeJointFlag p_flag) const {
switch (p_flag) {
case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT:
diff --git a/servers/physics_3d/physics_server_3d_sw.cpp b/servers/physics_3d/physics_server_3d_sw.cpp
index d2856829ed..d05001e636 100644
--- a/servers/physics_3d/physics_server_3d_sw.cpp
+++ b/servers/physics_3d/physics_server_3d_sw.cpp
@@ -278,6 +278,7 @@ int PhysicsServer3DSW::area_get_shape_count(RID p_area) const {
return area->get_shape_count();
}
+
RID PhysicsServer3DSW::area_get_shape(RID p_area, int p_shape_idx) const {
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
@@ -287,6 +288,7 @@ RID PhysicsServer3DSW::area_get_shape(RID p_area, int p_shape_idx) const {
return shape->get_self();
}
+
Transform PhysicsServer3DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform());
@@ -326,6 +328,7 @@ void PhysicsServer3DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id
ERR_FAIL_COND(!area);
area->set_instance_id(p_id);
}
+
ObjectID PhysicsServer3DSW::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
Space3DSW *space = space_owner.getornull(p_area);
@@ -494,6 +497,7 @@ void PhysicsServer3DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape)
body->set_shape(p_shape_idx, shape);
}
+
void PhysicsServer3DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) {
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -507,6 +511,7 @@ int PhysicsServer3DSW::body_get_shape_count(RID p_body) const {
return body->get_shape_count();
}
+
RID PhysicsServer3DSW::body_get_shape(RID p_body, int p_shape_idx) const {
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -909,6 +914,7 @@ void PhysicsServer3DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param,
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
pin_joint->set_param(p_param, p_value);
}
+
real_t PhysicsServer3DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
@@ -924,6 +930,7 @@ void PhysicsServer3DSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
pin_joint->set_pos_a(p_A);
}
+
Vector3 PhysicsServer3DSW::pin_joint_get_local_a(RID p_joint) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
@@ -939,6 +946,7 @@ void PhysicsServer3DSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
pin_joint->set_pos_b(p_B);
}
+
Vector3 PhysicsServer3DSW::pin_joint_get_local_b(RID p_joint) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
@@ -994,6 +1002,7 @@ void PhysicsServer3DSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_par
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
hinge_joint->set_param(p_param, p_value);
}
+
real_t PhysicsServer3DSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
@@ -1009,6 +1018,7 @@ void PhysicsServer3DSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag,
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
hinge_joint->set_flag(p_flag, p_value);
}
+
bool PhysicsServer3DSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, false);
@@ -1089,6 +1099,7 @@ void PhysicsServer3DSW::slider_joint_set_param(RID p_joint, SliderJointParam p_p
SliderJoint3DSW *slider_joint = static_cast<SliderJoint3DSW *>(joint);
slider_joint->set_param(p_param, p_value);
}
+
real_t PhysicsServer3DSW::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
@@ -1124,6 +1135,7 @@ void PhysicsServer3DSW::cone_twist_joint_set_param(RID p_joint, ConeTwistJointPa
ConeTwistJoint3DSW *cone_twist_joint = static_cast<ConeTwistJoint3DSW *>(joint);
cone_twist_joint->set_param(p_param, p_value);
}
+
real_t PhysicsServer3DSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
@@ -1159,6 +1171,7 @@ void PhysicsServer3DSW::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
generic_6dof_joint->set_param(p_axis, p_param, p_value);
}
+
real_t PhysicsServer3DSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
@@ -1174,6 +1187,7 @@ void PhysicsServer3DSW::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
generic_6dof_joint->set_flag(p_axis, p_flag, p_enable);
}
+
bool PhysicsServer3DSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, false);
diff --git a/servers/physics_3d/shape_3d_sw.cpp b/servers/physics_3d/shape_3d_sw.cpp
index 2c248a4d38..a44244f7d5 100644
--- a/servers/physics_3d/shape_3d_sw.cpp
+++ b/servers/physics_3d/shape_3d_sw.cpp
@@ -1380,12 +1380,15 @@ ConcavePolygonShape3DSW::ConcavePolygonShape3DSW() {
Vector<real_t> HeightMapShape3DSW::get_heights() const {
return heights;
}
+
int HeightMapShape3DSW::get_width() const {
return width;
}
+
int HeightMapShape3DSW::get_depth() const {
return depth;
}
+
real_t HeightMapShape3DSW::get_cell_size() const {
return cell_size;
}
diff --git a/servers/physics_3d/space_3d_sw.cpp b/servers/physics_3d/space_3d_sw.cpp
index 9193e6cbdd..066945d808 100644
--- a/servers/physics_3d/space_3d_sw.cpp
+++ b/servers/physics_3d/space_3d_sw.cpp
@@ -386,6 +386,7 @@ static void _rest_cbk_result(const Vector3 &p_point_A, const Vector3 &p_point_B,
rd->best_object = rd->object;
rd->best_shape = rd->shape;
}
+
bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
@@ -990,9 +991,11 @@ void Space3DSW::_broadphase_unpair(CollisionObject3DSW *A, int p_subindex_A, Col
const SelfList<Body3DSW>::List &Space3DSW::get_active_body_list() const {
return active_list;
}
+
void Space3DSW::body_add_to_active_list(SelfList<Body3DSW> *p_body) {
active_list.add(p_body);
}
+
void Space3DSW::body_remove_from_active_list(SelfList<Body3DSW> *p_body) {
active_list.remove(p_body);
}
@@ -1026,6 +1029,7 @@ const Set<CollisionObject3DSW *> &Space3DSW::get_objects() const {
void Space3DSW::body_add_to_state_query_list(SelfList<Body3DSW> *p_body) {
state_query_list.add(p_body);
}
+
void Space3DSW::body_remove_from_state_query_list(SelfList<Body3DSW> *p_body) {
state_query_list.remove(p_body);
}
@@ -1033,6 +1037,7 @@ void Space3DSW::body_remove_from_state_query_list(SelfList<Body3DSW> *p_body) {
void Space3DSW::area_add_to_monitor_query_list(SelfList<Area3DSW> *p_area) {
monitor_query_list.add(p_area);
}
+
void Space3DSW::area_remove_from_monitor_query_list(SelfList<Area3DSW> *p_area) {
monitor_query_list.remove(p_area);
}