From 90d05cbe30ac1fe88b2371b1f8f7ed06afa449a0 Mon Sep 17 00:00:00 2001 From: Andrea Catania Date: Mon, 18 Feb 2019 12:57:55 +0100 Subject: [PATCH] Added support to scale areas --- modules/bullet/space_bullet.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 6562b18b3c2..f657a5e4fd1 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -658,6 +658,8 @@ void SpaceBullet::check_ghost_overlaps() { for (x = areas.size() - 1; 0 <= x; --x) { area = areas[x]; + btVector3 area_scale(area->get_bt_body_scale()); + if (!area->is_monitoring()) continue; @@ -681,6 +683,7 @@ void SpaceBullet::check_ghost_overlaps() { bool hasOverlap = false; btCollisionObject *overlapped_bt_co = ghostOverlaps[i]; RigidCollisionObjectBullet *otherObject = static_cast(overlapped_bt_co->getUserPointer()); + btVector3 other_body_scale(otherObject->get_bt_body_scale()); if (!area->is_transform_changed() && !otherObject->is_transform_changed()) { hasOverlap = true; @@ -698,19 +701,35 @@ void SpaceBullet::check_ghost_overlaps() { if (!area->get_bt_shape(y)->isConvex()) continue; - gjk_input.m_transformA = area->get_transform__bullet() * area->get_bt_shape_transform(y); + btTransform area_shape_treansform(area->get_bt_shape_transform(y)); + area_shape_treansform.getOrigin() *= area_scale; + + gjk_input.m_transformA = + area->get_transform__bullet() * + area_shape_treansform; + area_shape = static_cast(area->get_bt_shape(y)); // For each other object shape for (z = otherObject->get_shape_count() - 1; 0 <= z; --z) { other_body_shape = static_cast(otherObject->get_bt_shape(z)); - gjk_input.m_transformB = otherObject->get_transform__bullet() * otherObject->get_bt_shape_transform(z); + + btTransform other_shape_transform(otherObject->get_bt_shape_transform(z)); + other_shape_transform.getOrigin() *= other_body_scale; + + gjk_input.m_transformB = + otherObject->get_transform__bullet() * + other_shape_transform; if (other_body_shape->isConvex()) { btPointCollector result; - btGjkPairDetector gjk_pair_detector(area_shape, static_cast(other_body_shape), gjk_simplex_solver, gjk_epa_pen_solver); + btGjkPairDetector gjk_pair_detector( + area_shape, + static_cast(other_body_shape), + gjk_simplex_solver, + gjk_epa_pen_solver); gjk_pair_detector.getClosestPoints(gjk_input, result, 0); if (0 >= result.m_distance) {