From 3a3026ae5a8f866fe727d7355ec5ef1a58ec33a7 Mon Sep 17 00:00:00 2001 From: Jondolf Date: Thu, 19 Oct 2023 12:27:30 +0300 Subject: [PATCH 1/3] Improve AABB expansion Instead of always adding a uniform padding that scales with angular velocity, it now uses swept AABBs with the end position predicted based on the velocity. This way, the shape affects the padding, so e.g. rotating balls aren't expanded. --- src/plugins/collision/broad_phase.rs | 56 +++++++++++++++------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/plugins/collision/broad_phase.rs b/src/plugins/collision/broad_phase.rs index 5c727795..240f54cf 100644 --- a/src/plugins/collision/broad_phase.rs +++ b/src/plugins/collision/broad_phase.rs @@ -68,33 +68,39 @@ fn update_aabb( let safety_margin_factor = 2.0 * dt.0; for (collider, mut aabb, pos, rot, lin_vel, ang_vel) in &mut bodies { - let lin_vel = lin_vel.map_or(Vector::ZERO, |v| v.0); - - #[cfg(feature = "2d")] - let ang_vel_magnitude = ang_vel.map_or(0.0, |v| v.0.abs()); - #[cfg(feature = "3d")] - let ang_vel_magnitude = ang_vel.map_or(0.0, |v| v.0.length()); + let lin_vel = lin_vel.copied().unwrap_or_default(); + let ang_vel = ang_vel.copied().unwrap_or_default(); + + // Compute current isometry and predicted isometry for next feame + let start_iso = utils::make_isometry(*pos, *rot); + let end_iso = { + #[cfg(feature = "2d")] + { + utils::make_isometry( + pos.0 + lin_vel.0 * safety_margin_factor, + *rot + Rotation::from_radians(dt.0 * ang_vel.0), + ) + } + #[cfg(feature = "3d")] + { + let q = Quaternion::from_vec4(ang_vel.0.extend(0.0)) * rot.0; + let (x, y, z, w) = ( + rot.x + safety_margin_factor * 0.5 * q.x, + rot.y + safety_margin_factor * 0.5 * q.y, + rot.z + safety_margin_factor * 0.5 * q.z, + rot.w + safety_margin_factor * 0.5 * q.w, + ); + utils::make_isometry( + pos.0 + lin_vel.0 * safety_margin_factor, + Quaternion::from_xyzw(x, y, z, w).normalize(), + ) + } + }; - // Compute AABB half extents and center - let computed_aabb = collider + // Compute swept AABB, the space that the body would occupy if it was integrated for one frame + aabb.0 = collider .get_shape() - .compute_aabb(&utils::make_isometry(*pos, *rot)); - let half_extents = Vector::from(computed_aabb.half_extents()); - let center = Vector::from(computed_aabb.center()); - - // TODO: Somehow consider the shape of the object for the safety margin - // caused by angular velocity. For example, balls shouldn't get any safety margin. - let ang_vel_safety_margin = safety_margin_factor * ang_vel_magnitude; - - // Compute AABB mins and maxs, extending them by a safety margin that depends on the velocity - // of the body. Linear velocity only extends the AABB in the movement direction. - let mut mins = center - half_extents - ang_vel_safety_margin; - mins += safety_margin_factor * lin_vel.min(Vector::ZERO); - let mut maxs = center + half_extents + ang_vel_safety_margin; - maxs += safety_margin_factor * lin_vel.max(Vector::ZERO); - - aabb.mins.coords = mins.into(); - aabb.maxs.coords = maxs.into(); + .compute_swept_aabb(&start_iso, &end_iso); } } From d10bf27b3ded16526d0410f6814a6e3c0912dc90 Mon Sep 17 00:00:00 2001 From: Jondolf Date: Thu, 19 Oct 2023 12:31:51 +0300 Subject: [PATCH 2/3] Update snapshot --- ...tion_is_deterministic_across_machines.snap | 896 +++++++++--------- 1 file changed, 448 insertions(+), 448 deletions(-) diff --git a/crates/bevy_xpbd_3d/snapshots/bevy_xpbd_3d__tests__cubes_simulation_is_deterministic_across_machines.snap b/crates/bevy_xpbd_3d/snapshots/bevy_xpbd_3d__tests__cubes_simulation_is_deterministic_across_machines.snap index c465799e..51b0e42f 100644 --- a/crates/bevy_xpbd_3d/snapshots/bevy_xpbd_3d__tests__cubes_simulation_is_deterministic_across_machines.snap +++ b/crates/bevy_xpbd_3d/snapshots/bevy_xpbd_3d__tests__cubes_simulation_is_deterministic_across_machines.snap @@ -9,15 +9,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.8840775, - 0.49998614, - -6.3129463, + -4.659698, + 0.49996683, + -6.624021, ), rotation: Quat( - 1.021307e-5, - 0.093049645, - 6.8060144e-6, - 0.9956615, + 3.677638e-5, + 0.13293596, + 1.657351e-5, + 0.99112463, ), scale: Vec3( 1.0, @@ -32,15 +32,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.5964494, - 0.49992126, - -2.6822681, + -4.4339166, + 0.4999171, + -2.699424, ), rotation: Quat( - -1.6636792e-5, - -0.24592756, - -2.7888416e-6, - 0.96928823, + -1.2877186e-5, + -0.14227499, + -5.899492e-6, + 0.98982716, ), scale: Vec3( 1.0, @@ -55,15 +55,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.3248773, - 0.4999228, - -0.17086446, + -4.457325, + 0.49999687, + -0.42973012, ), rotation: Quat( - 2.0519221e-6, - -0.15819, - 9.042746e-6, - 0.9874087, + 2.9118917e-6, + -0.20090444, + -1.0706325e-6, + 0.97961086, ), scale: Vec3( 1.0, @@ -78,15 +78,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.4412217, - 0.49999866, - 2.6387563, + -4.458357, + 0.4999468, + 1.9495832, ), rotation: Quat( - 3.540812e-6, - -0.116961814, - -2.04861e-6, - 0.9931364, + -2.5594159e-6, + -0.12714696, + 1.0565014e-5, + 0.9918839, ), scale: Vec3( 1.0, @@ -101,15 +101,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1452253, - 0.4999498, - -5.5944157, + -1.8563004, + 0.49995825, + -5.865708, ), rotation: Quat( - 5.319262e-5, - -0.17677967, - -9.545255e-6, - 0.9842504, + 3.206302e-5, + -0.1509817, + -6.9372672e-6, + 0.98853654, ), scale: Vec3( 1.0, @@ -124,15 +124,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.0166335, - 0.49993542, - -2.4149897, + -2.0793524, + 0.4999926, + -2.4740722, ), rotation: Quat( - 2.5634718e-5, - -0.15976909, - 6.7164265e-6, - 0.9871544, + 8.377441e-6, + -0.13735676, + -3.058589e-6, + 0.99052167, ), scale: Vec3( 1.0, @@ -147,15 +147,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.2364225, - 0.4999671, - 0.30047134, + -2.19493, + 0.49994734, + -0.3657457, ), rotation: Quat( - 6.6363104e-6, - -0.15254955, - -7.864287e-6, - 0.98829585, + 2.1428166e-6, + -0.15299487, + 2.781944e-6, + 0.988227, ), scale: Vec3( 1.0, @@ -170,15 +170,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1912346, - 0.49995777, - 2.7510848, + -2.302395, + 0.49996156, + 1.9974169, ), rotation: Quat( - 2.27204e-6, - -0.058584716, - -6.692791e-6, - 0.99828243, + -6.674965e-7, + -0.088752545, + 6.3823563e-6, + 0.9960537, ), scale: Vec3( 1.0, @@ -193,15 +193,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.080052644, - 0.4999958, - -5.6150384, + 0.6481447, + 0.49996692, + -5.8864737, ), rotation: Quat( - 3.4785962e-6, - -0.058722805, - -3.4695254e-6, - 0.9982743, + 2.2352253e-5, + -0.15051419, + 3.032293e-6, + 0.9886078, ), scale: Vec3( 1.0, @@ -216,15 +216,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.13608316, - 0.499906, - -2.457428, + 0.20411971, + 0.4999955, + -2.3622103, ), rotation: Quat( - -9.838817e-7, - -0.14868803, - 1.8792523e-5, - 0.98888415, + 6.5108757e-6, + -0.06470696, + -4.2440697e-6, + 0.9979043, ), scale: Vec3( 1.0, @@ -239,15 +239,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.079418726, - 0.49993843, - 0.08562035, + 0.039667264, + 0.49994856, + -0.23463023, ), rotation: Quat( - 9.89041e-6, - -0.05644419, - -7.1605564e-6, - 0.99840575, + -6.309664e-6, + -0.12591764, + -8.955136e-7, + 0.9920407, ), scale: Vec3( 1.0, @@ -262,15 +262,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.38031706, - 0.49994525, - 2.603351, + 0.957663, + 0.4999939, + 3.9204147, ), rotation: Quat( - 3.4154615e-7, - -0.04453798, - -1.6303159e-6, - 0.9990077, + 5.589132e-6, + 0.39188477, + -8.100881e-6, + 0.9200143, ), scale: Vec3( 1.0, @@ -285,15 +285,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.9306567, - 0.5000009, - -5.4706345, + 2.581897, + 0.4999594, + -5.196156, ), rotation: Quat( - 2.3209077e-7, - -0.30563417, - -4.6851065e-7, - 0.95214903, + 1.870526e-5, + -0.16281335, + 9.098697e-6, + 0.9866569, ), scale: Vec3( 1.0, @@ -308,15 +308,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.6305487, - 0.49999875, - -2.497731, + 2.6056817, + 0.49999622, + -2.7093766, ), rotation: Quat( - 1.8066021e-6, - -0.13722269, - -7.0844806e-7, - 0.9905402, + 5.116709e-6, + -0.10914128, + -2.3940754e-6, + 0.99402624, ), scale: Vec3( 1.0, @@ -331,15 +331,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.393628, - 0.49995422, - -0.13766682, + 2.2386928, + 0.4999314, + -0.31925127, ), rotation: Quat( - 1.7823162e-5, - -0.19327234, - 1.97134e-6, - 0.98114514, + 3.8089454e-6, + -0.15655991, + -4.494476e-6, + 0.98766845, ), scale: Vec3( 1.0, @@ -354,15 +354,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.491556, - 0.499996, - 2.5504298, + 2.5478122, + 0.49998292, + 2.1956441, ), rotation: Quat( - 5.196372e-6, - -0.058466423, - -2.7348212e-6, - 0.99828935, + -1.9168383e-5, + 0.1691077, + -1.2709171e-5, + 0.98559755, ), scale: Vec3( 1.0, @@ -377,15 +377,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.662588, - 2.499905, - -4.3226237, + -4.364173, + 2.4914074, + -5.2958984, ), rotation: Quat( - 1.483363e-5, - -0.073136546, - -6.0377903e-7, - 0.99732196, + 0.012166499, + 0.14694606, + -0.0014399751, + 0.9890686, ), scale: Vec3( 1.0, @@ -400,15 +400,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.177984, - 2.4999137, - -2.125405, + -4.4509997, + 2.499912, + -2.8232255, ), rotation: Quat( - -8.976946e-6, - -0.0091114715, - -5.6848403e-6, - 0.9999585, + -1.6500564e-5, + 0.09336498, + -3.2579934e-5, + 0.99563193, ), scale: Vec3( 1.0, @@ -423,15 +423,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.3157706, - 2.4999058, - -0.051404595, + -4.1968465, + 2.4999342, + -0.47334018, ), rotation: Quat( - 1.3230207e-5, - 0.018637767, - -1.2472643e-6, - 0.9998263, + -3.1108798e-6, + 0.07123131, + 1.9267081e-7, + 0.9974598, ), scale: Vec3( 1.0, @@ -446,15 +446,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.067958, - 2.4998908, - 2.3522725, + -4.49215, + 2.4999318, + 1.7230572, ), rotation: Quat( - 4.46566e-6, - 0.03355747, - 7.713113e-6, - 0.9994368, + 2.7948454e-7, + 0.054790065, + 8.655563e-6, + 0.9984979, ), scale: Vec3( 1.0, @@ -469,15 +469,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.159903, - 2.500702, - -5.0451503, + -2.1439893, + 2.4999065, + -5.0170445, ), rotation: Quat( - 0.0008281269, - 0.11962082, - 0.00040496586, - 0.99281925, + 4.8282556e-5, + 0.12908873, + 6.385406e-6, + 0.99163306, ), scale: Vec3( 1.0, @@ -492,15 +492,15 @@ expression: bodies ), Transform { translation: Vec3( - -1.9693993, - 2.4999104, - -2.249833, + -2.2061634, + 2.4998891, + -2.665915, ), rotation: Quat( - 2.9868295e-5, - -0.00567612, - 1.45236e-5, - 0.9999839, + -1.8832934e-5, + 0.0009732904, + -9.942255e-6, + 0.9999995, ), scale: Vec3( 1.0, @@ -515,15 +515,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1200032, - 2.4990773, - 0.131278, + -1.8767838, + 2.4999545, + -0.531268, ), rotation: Quat( - -0.00017730892, - 0.06616363, - 0.00027539983, - 0.99780875, + -9.374795e-6, + 0.052264765, + 3.731715e-6, + 0.99863327, ), scale: Vec3( 1.0, @@ -538,15 +538,15 @@ expression: bodies ), Transform { translation: Vec3( - -1.7671894, - 2.499954, - 2.538702, + -2.3210013, + 2.499972, + 1.9628465, ), rotation: Quat( - 3.2592714e-6, - 0.1611022, - -7.982803e-6, - 0.9869377, + -7.6255583e-6, + 0.061430607, + -3.7284567e-6, + 0.99811137, ), scale: Vec3( 1.0, @@ -561,15 +561,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.12926933, - 2.499903, - -4.650124, + 0.4345259, + 2.4999294, + -4.9363074, ), rotation: Quat( - 4.40926e-5, - 0.11931538, - 1.5501978e-6, - 0.9928564, + 2.0741305e-5, + 0.0035000318, + 9.119101e-6, + 0.99999386, ), scale: Vec3( 1.0, @@ -584,15 +584,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.1417445, - 2.4999175, - -2.158794, + 0.3598471, + 2.4999125, + -2.3810933, ), rotation: Quat( - 2.3013969e-5, - 0.002523815, - -1.9412608e-5, - 0.99999684, + -5.983653e-6, + 0.08436151, + -1.0597717e-5, + 0.9964352, ), scale: Vec3( 1.0, @@ -607,15 +607,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.09210145, - 2.4999523, - 0.14431445, + 0.48787746, + 2.4999537, + -0.28895617, ), rotation: Quat( - 9.503883e-6, - 0.088851586, - -2.6966816e-6, - 0.9960449, + -1.7278852e-6, + 0.06435404, + -7.1637382e-6, + 0.9979271, ), scale: Vec3( 1.0, @@ -630,15 +630,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.46577328, - 2.4999602, - 2.3998425, + 0.10009907, + 2.3666153, + 2.4361153, ), rotation: Quat( - 5.8005376e-6, - 0.118931964, - -6.0612965e-6, - 0.9929024, + -0.09741758, + 0.12807043, + 0.078149624, + 0.98387015, ), scale: Vec3( 1.0, @@ -653,15 +653,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.549638, - 2.5053687, - -4.621387, + 2.5514996, + 2.499956, + -4.7903776, ), rotation: Quat( - -0.0021512546, - 0.18118577, - 0.0010396797, - 0.983446, + 4.3961563e-6, + 0.02458298, + 2.5033955e-6, + 0.9996978, ), scale: Vec3( 1.0, @@ -676,15 +676,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.6509469, - 2.4999816, - -2.3103673, + 2.359502, + 2.499925, + -2.5696142, ), rotation: Quat( - 8.812365e-7, - 0.10688069, - -1.4779067e-5, - 0.9942719, + -3.991052e-6, + 0.08268048, + -1.8053293e-5, + 0.99657613, ), scale: Vec3( 1.0, @@ -699,15 +699,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.1744192, - 2.4999044, - -0.11582472, + 2.6308439, + 2.499908, + -0.5104069, ), rotation: Quat( - 6.1420033e-6, - 0.06586435, - -3.1262243e-6, - 0.9978286, + 1.2114732e-6, + 0.05415983, + -6.755346e-6, + 0.9985323, ), scale: Vec3( 1.0, @@ -722,15 +722,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.5712745, - 2.4999385, - 1.9223919, + 2.777257, + 2.499957, + 1.772491, ), rotation: Quat( - -6.1123114e-6, - 0.095650524, - -2.5949867e-6, - 0.995415, + -2.555945e-5, + 0.13031918, + -1.2515121e-5, + 0.99147207, ), scale: Vec3( 1.0, @@ -745,15 +745,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.7222004, - 4.499917, - -4.0457153, + -4.5693417, + 4.5037913, + -4.7787576, ), rotation: Quat( - 2.3874393e-6, - -0.023879122, - -2.877863e-6, - 0.99971485, + 0.00052052154, + 0.06230477, + -0.0017269654, + 0.9980555, ), scale: Vec3( 1.0, @@ -768,15 +768,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.4281816, - 4.4999204, - -1.8141768, + -4.5485044, + 4.499937, + -2.4401755, ), rotation: Quat( - -9.476739e-6, - -0.049846936, - -8.67436e-7, - 0.9987569, + -2.3051678e-5, + -0.04206948, + -2.9859004e-5, + 0.9991147, ), scale: Vec3( 1.0, @@ -791,15 +791,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.4111433, - 4.499904, - 0.5215338, + -4.0248995, + 4.499924, + 0.3748128, ), rotation: Quat( - 5.2289547e-6, - -0.018272685, - 4.2383494e-6, - 0.99983305, + -8.885974e-6, + -0.008117991, + 9.189623e-6, + 0.99996704, ), scale: Vec3( 1.0, @@ -814,15 +814,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.1206765, - 4.499867, - 2.9368165, + -4.925541, + 4.4998975, + 2.475625, ), rotation: Quat( - -1.8833022e-6, - 0.050360065, - 8.785629e-6, - 0.99873114, + 1.5594076e-5, + 0.0032754154, + 4.2083498e-6, + 0.99999464, ), scale: Vec3( 1.0, @@ -837,15 +837,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.0982618, - 4.4999485, - -4.5954814, + -2.358332, + 4.4998765, + -4.688291, ), rotation: Quat( - 0.0008569843, - 0.07476338, - 0.0003668467, - 0.99720085, + 1.8239965e-5, + -0.04235896, + -6.8702275e-6, + 0.9991025, ), scale: Vec3( 1.0, @@ -860,15 +860,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.0418162, - 4.499855, - -1.9817297, + -2.311118, + 4.4998736, + -2.553241, ), rotation: Quat( - 3.1433286e-5, - 0.023295468, - 4.817175e-6, - 0.9997286, + -2.418213e-5, + -0.02397493, + -6.7542246e-6, + 0.9997126, ), scale: Vec3( 1.0, @@ -883,15 +883,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.2922916, - 4.4996166, - 0.123583816, + -1.479403, + 4.499921, + -0.093286425, ), rotation: Quat( - -0.00014370061, - 0.0006513288, - -5.3522206e-5, - 0.99999976, + -4.3452383e-6, + -0.073610425, + 2.5814543e-7, + 0.9972871, ), scale: Vec3( 1.0, @@ -906,15 +906,15 @@ expression: bodies ), Transform { translation: Vec3( - -1.9065185, - 4.499897, - 2.948519, + -2.3478966, + 0.49999946, + 6.976463, ), rotation: Quat( - 7.2758303e-6, - 0.16466804, - -1.0518872e-5, - 0.98634905, + 0.6988977, + -0.10743671, + 0.10743579, + 0.69889694, ), scale: Vec3( 1.0, @@ -929,15 +929,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.084558636, - 4.499845, - -4.2212543, + -0.052781336, + 4.499877, + -4.7105103, ), rotation: Quat( - 5.0826264e-5, - 0.0032887203, - -1.1353104e-6, - 0.9999946, + 1.8600136e-5, + -0.032800242, + -3.1422214e-6, + 0.99946195, ), scale: Vec3( 1.0, @@ -952,15 +952,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.046418056, - 4.4998946, - -1.9996858, + 0.19459698, + 4.4998918, + -2.4031594, ), rotation: Quat( - 1.8233854e-5, - 0.033099268, - -2.5970241e-5, - 0.99945205, + 5.3651536e-7, + -0.0051712436, + -4.4527555e-6, + 0.99998665, ), scale: Vec3( 1.0, @@ -975,15 +975,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.115307376, - 4.499905, - 0.15320742, + 0.86549866, + 4.4999075, + -0.06289241, ), rotation: Quat( - 1.3577231e-5, - 0.06730782, - -3.2129797e-6, - 0.9977323, + -1.0516512e-6, + -0.027223967, + 2.2963761e-6, + 0.9996294, ), scale: Vec3( 1.0, @@ -998,15 +998,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.1633159, - 4.4999037, - 2.5240226, + -0.37023166, + 4.436416, + 2.9562294, ), rotation: Quat( - 5.585338e-6, - 0.12953368, - -8.621638e-6, - 0.991575, + -0.084160544, + -0.025312874, + 0.09223157, + 0.9918516, ), scale: Vec3( 1.0, @@ -1021,15 +1021,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.4627173, - 4.523821, - -4.223433, + 2.5088778, + 4.49994, + -4.5091257, ), rotation: Quat( - 0.002565093, - 0.12797171, - -0.0035405958, - 0.9917682, + 3.7236066e-6, + 0.008506465, + 9.379508e-6, + 0.9999638, ), scale: Vec3( 1.0, @@ -1044,15 +1044,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.2974544, - 4.4999475, - -2.0317554, + 2.284265, + 4.499909, + -2.3440073, ), rotation: Quat( - 7.264934e-6, - 0.04885285, - -1.3812624e-5, - 0.998806, + -6.6092016e-6, + 0.0027568943, + -8.170647e-6, + 0.9999962, ), scale: Vec3( 1.0, @@ -1067,15 +1067,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.2948377, - 4.499882, - 0.19410415, + 2.9695868, + 4.499909, + 0.23960423, ), rotation: Quat( - -1.9167567e-6, - 0.07155434, - -2.2111035e-6, - 0.9974367, + -9.390599e-6, + -0.07312649, + -6.890248e-6, + 0.9973227, ), scale: Vec3( 1.0, @@ -1090,15 +1090,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.3714726, - 4.4999046, - 2.3423145, + 5.000622, + 0.49999946, + 5.5230446, ), rotation: Quat( - 3.7926222e-6, - 0.105108425, - -1.8758468e-5, - 0.99446076, + 0.44156688, + -0.4415657, + -0.5522854, + 0.5522855, ), scale: Vec3( 1.0, @@ -1113,15 +1113,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.4638953, - 6.499873, - -4.0630817, + -4.8429136, + 6.504627, + -4.6604176, ), rotation: Quat( - -1.0684977e-6, - -0.03946447, - -8.834009e-6, - 0.99922097, + 0.00038800825, + -0.012018734, + -0.0017527192, + 0.99992615, ), scale: Vec3( 1.0, @@ -1136,15 +1136,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.541287, - 6.499911, - -1.8390753, + -4.539917, + 6.499926, + -2.1285975, ), rotation: Quat( - -2.7836097e-6, - -0.07500307, - 3.1182046e-6, - 0.9971833, + -2.662724e-5, + 0.03652685, + -2.9336865e-5, + 0.99933267, ), scale: Vec3( 1.0, @@ -1159,15 +1159,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.4054413, - 6.499905, - 0.5342264, + -4.2130003, + 6.499926, + 0.19896007, ), rotation: Quat( - 1.0029094e-5, - -0.028178202, - -8.311371e-7, - 0.9996029, + -3.2488242e-6, + 0.017971558, + 9.179622e-6, + 0.9998385, ), scale: Vec3( 1.0, @@ -1182,15 +1182,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.4478917, - 6.4998593, - 2.6989908, + -4.7448273, + 6.499905, + 2.3570683, ), rotation: Quat( - 1.7115982e-6, - 0.015391452, - 6.6103903e-6, - 0.99988157, + 1.6370957e-5, + -0.110782996, + 1.2694543e-6, + 0.9938446, ), scale: Vec3( 1.0, @@ -1205,15 +1205,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.0118814, - 6.4996743, - -4.408518, + -2.709273, + 6.5005493, + -4.309162, ), rotation: Quat( - 0.0008833011, - 0.0048433905, - 0.00030778215, - 0.99998784, + 0.0003461283, + 0.021641752, + -1.5687227e-5, + 0.99976575, ), scale: Vec3( 1.0, @@ -1228,15 +1228,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.0685985, - 6.4998636, - -2.0412266, + -2.3188472, + 6.4998946, + -2.200958, ), rotation: Quat( - 3.2721695e-5, - -0.016413745, - 6.26121e-7, - 0.9998653, + -2.747678e-5, + 0.021487089, + -9.390874e-6, + 0.99976915, ), scale: Vec3( 1.0, @@ -1251,15 +1251,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1621423, - 6.4998426, - -0.009622783, + -2.0102012, + 6.4999247, + -0.16516522, ), rotation: Quat( - -6.4502156e-6, - -0.03323228, - -4.2704098e-5, - 0.99944764, + -6.4384025e-8, + 0.020120863, + -1.5064911e-6, + 0.9997976, ), scale: Vec3( 1.0, @@ -1274,15 +1274,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.4178045, - 6.4998765, - 2.3701563, + -2.1885705, + 0.49999946, + 4.258792, ), rotation: Quat( - 3.315791e-6, - 0.01670394, - -1.0139086e-5, - 0.99986047, + -0.7023954, + -0.08149227, + -0.08149336, + 0.7023949, ), scale: Vec3( 1.0, @@ -1297,15 +1297,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.15457933, - 6.4998455, - -4.2195, + -0.74335796, + 6.499874, + -5.139636, ), rotation: Quat( - 5.3893982e-5, - -0.009229558, - -5.5537885e-6, - 0.9999574, + 2.0270953e-5, + 0.021662662, + -8.436476e-6, + 0.99976534, ), scale: Vec3( 1.0, @@ -1320,15 +1320,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.020253193, - 6.4998994, - -2.1103811, + 0.03539016, + 6.499891, + -2.1587355, ), rotation: Quat( - 1.13126125e-5, - -0.008870928, - -2.4882505e-5, - 0.99996066, + -1.6123396e-6, + -0.010133911, + -8.501557e-6, + 0.9999487, ), scale: Vec3( 1.0, @@ -1343,15 +1343,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.3434779, - 6.4999046, - 0.15167767, + 0.21060899, + 6.4999166, + -0.15477571, ), rotation: Quat( - 1.3513705e-5, - 0.004419541, - -5.4249876e-6, - 0.9999902, + -3.4343857e-6, + -0.010132811, + -5.496784e-6, + 0.9999487, ), scale: Vec3( 1.0, @@ -1366,15 +1366,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.045836154, - 6.499876, - 2.372979, + -0.33169362, + 6.3365293, + 1.9888495, ), rotation: Quat( - 3.31346e-6, - 0.080713205, - -7.773753e-6, - 0.99673736, + -0.08486517, + -0.01765513, + 0.09157579, + 0.99201816, ), scale: Vec3( 1.0, @@ -1389,15 +1389,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.69063, - 6.5255804, - -4.4832582, + 1.6399827, + 6.499926, + -4.2515125, ), rotation: Quat( - 0.0036721418, - 0.35055444, - -0.0024414826, - 0.93653196, + 2.448163e-6, + -0.033288155, + 1.2957918e-5, + 0.9994458, ), scale: Vec3( 1.0, @@ -1412,15 +1412,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.4816194, - 6.5043006, - -1.9823791, + 2.236706, + 6.4999104, + -2.0474634, ), rotation: Quat( - -0.00030939886, - 0.041006003, - -0.0017860039, - 0.99915725, + -8.224734e-6, + 0.010621305, + -1.1370031e-5, + 0.9999436, ), scale: Vec3( 1.0, @@ -1435,15 +1435,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.3744953, - 6.4998674, - 0.0644396, + 2.5260873, + 6.499901, + 0.33564612, ), rotation: Quat( - 7.2211146e-6, - 0.020571178, - -3.6073593e-6, - 0.9997884, + 6.56658e-7, + 0.015421033, + -9.668843e-6, + 0.9998811, ), scale: Vec3( 1.0, @@ -1458,15 +1458,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.472841, - 6.4999046, - 2.422926, + 4.977319, + 0.49999946, + 10.015271, ), rotation: Quat( - 5.2217392e-6, - 0.17963935, - -2.0568676e-5, - 0.9837325, + 0.96112686, + -2.3246139e-7, + -0.27610722, + 8.220271e-7, ), scale: Vec3( 1.0, From 519e7ab65b719e6e197924358302152281c4175c Mon Sep 17 00:00:00 2001 From: Jondolf Date: Thu, 19 Oct 2023 12:59:09 +0300 Subject: [PATCH 3/3] Fix safety margin --- src/plugins/collision/broad_phase.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/collision/broad_phase.rs b/src/plugins/collision/broad_phase.rs index 240f54cf..dc47f1e2 100644 --- a/src/plugins/collision/broad_phase.rs +++ b/src/plugins/collision/broad_phase.rs @@ -78,7 +78,7 @@ fn update_aabb( { utils::make_isometry( pos.0 + lin_vel.0 * safety_margin_factor, - *rot + Rotation::from_radians(dt.0 * ang_vel.0), + *rot + Rotation::from_radians(safety_margin_factor * ang_vel.0), ) } #[cfg(feature = "3d")]