From 14a227e9e7b809811446c912a0002a5e9e2cd499 Mon Sep 17 00:00:00 2001 From: muiroc Date: Sun, 5 Aug 2018 00:02:14 +0200 Subject: [PATCH] fixed godotphysics sat dispatch table --- servers/physics/collision_solver_sat.cpp | 62 +++++++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp index 8f2b147460b..b059c20c954 100644 --- a/servers/physics/collision_solver_sat.cpp +++ b/servers/physics/collision_solver_sat.cpp @@ -559,6 +559,12 @@ static void _collision_sphere_capsule(const ShapeSW *p_a, const Transform &p_tra separator.generate_contacts(); } +template +static void _collision_sphere_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { + + return; +} + template static void _collision_sphere_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { @@ -850,6 +856,12 @@ static void _collision_box_capsule(const ShapeSW *p_a, const Transform &p_transf separator.generate_contacts(); } +template +static void _collision_box_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { + + return; +} + template static void _collision_box_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { @@ -1126,6 +1138,12 @@ static void _collision_capsule_capsule(const ShapeSW *p_a, const Transform &p_tr separator.generate_contacts(); } +template +static void _collision_capsule_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { + + return; +} + template static void _collision_capsule_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { @@ -1246,6 +1264,24 @@ static void _collision_capsule_face(const ShapeSW *p_a, const Transform &p_trans separator.generate_contacts(); } +template +static void _collision_cylinder_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { + + return; +} + +template +static void _collision_cylinder_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { + + return; +} + +template +static void _collision_cylinder_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { + + return; +} + template static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { @@ -1475,23 +1511,33 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_tran ERR_FAIL_COND_V(type_B == PhysicsServer::SHAPE_RAY, false); ERR_FAIL_COND_V(p_shape_B->is_concave(), false); - static const CollisionFunc collision_table[5][5] = { + static const CollisionFunc collision_table[6][6] = { { _collision_sphere_sphere, _collision_sphere_box, _collision_sphere_capsule, + _collision_sphere_cylinder, _collision_sphere_convex_polygon, _collision_sphere_face }, { 0, _collision_box_box, _collision_box_capsule, + _collision_box_cylinder, _collision_box_convex_polygon, _collision_box_face }, { 0, 0, _collision_capsule_capsule, + _collision_capsule_cylinder, _collision_capsule_convex_polygon, _collision_capsule_face }, { 0, + 0, + 0, + _collision_cylinder_cylinder, + _collision_cylinder_convex_polygon, + _collision_cylinder_face }, + { 0, + 0, 0, 0, _collision_convex_polygon_convex_polygon, @@ -1500,26 +1546,37 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_tran 0, 0, 0, + 0, 0 }, }; - static const CollisionFunc collision_table_margin[5][5] = { + static const CollisionFunc collision_table_margin[6][6] = { { _collision_sphere_sphere, _collision_sphere_box, _collision_sphere_capsule, + _collision_sphere_cylinder, _collision_sphere_convex_polygon, _collision_sphere_face }, { 0, _collision_box_box, _collision_box_capsule, + _collision_box_cylinder, _collision_box_convex_polygon, _collision_box_face }, { 0, 0, _collision_capsule_capsule, + _collision_capsule_cylinder, _collision_capsule_convex_polygon, _collision_capsule_face }, { 0, + 0, + 0, + _collision_cylinder_cylinder, + _collision_cylinder_convex_polygon, + _collision_cylinder_face }, + { 0, + 0, 0, 0, _collision_convex_polygon_convex_polygon, @@ -1528,6 +1585,7 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_tran 0, 0, 0, + 0, 0 }, };