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 71b08a86..164fba50 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.412756, - 0.49997884, - -5.933289, + -4.3006864, + 0.49994802, + -5.7989707, ), rotation: Quat( - 1.2488733e-5, - -0.11259509, - -1.6300339e-6, - 0.99364096, + 2.5563864e-5, + -0.13944258, + 6.5661366e-6, + 0.99023014, ), scale: Vec3( 1.0, @@ -32,15 +32,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.4563684, - 0.49993253, - -2.695925, + -4.34125, + 0.49998254, + -2.520743, ), rotation: Quat( - -1.6138076e-6, - -0.15329537, - 1.3447959e-7, - 0.9881804, + 7.254554e-6, + -0.16648017, + -4.946743e-6, + 0.9860448, ), scale: Vec3( 1.0, @@ -55,15 +55,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.4991455, - 0.49992895, - 0.075348005, + -4.4208765, + 0.49995813, + 0.065870434, ), rotation: Quat( - 8.939916e-6, - -0.037362672, - 6.6497855e-6, - 0.9993018, + 6.7530023e-6, + -0.09734187, + -4.4243625e-6, + 0.995251, ), scale: Vec3( 1.0, @@ -78,15 +78,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.4214344, - 0.49994704, - 2.3598442, + -4.44458, + 0.49998608, + 2.3962872, ), rotation: Quat( - 1.2393669e-5, - -0.118021056, - 6.7488477e-6, - 0.9930111, + -3.862845e-6, + -0.08763834, + 1.2271895e-6, + 0.99615234, ), scale: Vec3( 1.0, @@ -101,15 +101,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1447492, - 0.49994978, - -5.383051, + -1.9637036, + 0.49994987, + -5.7516756, ), rotation: Quat( - 3.4370358e-5, - 0.00452591, - -4.764018e-6, - 0.99998975, + 3.7028516e-5, + 0.010398579, + 5.0167346e-6, + 0.99994594, ), scale: Vec3( 1.0, @@ -124,15 +124,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.0498493, - 0.49993813, - -2.4912555, + -1.9832739, + 0.49993584, + -2.382758, ), rotation: Quat( - 1.703845e-5, - -0.16674739, - 3.1878487e-6, - 0.98599964, + 3.0113886e-6, + -0.12687473, + 4.0704103e-6, + 0.99191874, ), scale: Vec3( 1.0, @@ -147,15 +147,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1343985, - 0.4999466, - 0.027199415, + -2.1935527, + 0.49994648, + -0.13222764, ), rotation: Quat( - 4.0052262e-7, - -0.13359948, - 5.263204e-7, - 0.9910354, + 1.1267305e-5, + -0.15084976, + -1.4297254e-5, + 0.9885567, ), scale: Vec3( 1.0, @@ -170,15 +170,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.2457347, - 0.4999428, - 2.425038, + -2.190492, + 0.49995232, + 2.3649914, ), rotation: Quat( - 3.3158667e-6, - -0.113720566, - -3.498383e-6, - 0.99351275, + 1.0206272e-6, + -0.15634996, + 5.843247e-7, + 0.9877017, ), scale: Vec3( 1.0, @@ -193,15 +193,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.28429016, - 0.49995828, - -5.2972436, + 0.50485873, + 0.49994126, + -5.537582, ), rotation: Quat( - 1.0153456e-5, - -0.08345168, - -3.2578175e-6, - 0.9965118, + 4.887261e-5, + 0.011927954, + 9.431508e-6, + 0.99992883, ), scale: Vec3( 1.0, @@ -216,15 +216,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.17937997, - 0.49993762, - -2.4965737, + 0.28479943, + 0.4999536, + -2.253131, ), rotation: Quat( - 6.527514e-6, - -0.17080474, - -5.5886208e-6, - 0.9853049, + 8.674237e-6, + -0.045467205, + 1.5355862e-6, + 0.99896586, ), scale: Vec3( 1.0, @@ -239,15 +239,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.11769989, - 0.49994552, - 0.0904399, + 0.40823856, + 0.49993768, + 0.0067982823, ), rotation: Quat( - -1.4797135e-6, - -0.09786853, - -7.075673e-7, - 0.9951994, + 5.3277486e-6, + -0.14052378, + -2.3644911e-6, + 0.9900773, ), scale: Vec3( 1.0, @@ -262,15 +262,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.0013185797, - 0.49995637, - 2.3447027, + 0.07479347, + 0.499951, + 2.385635, ), rotation: Quat( - 4.9192317e-6, - -0.12199612, - 9.834248e-6, - 0.9925306, + -3.00183e-7, + -0.18080756, + 5.313273e-6, + 0.9835185, ), scale: Vec3( 1.0, @@ -285,15 +285,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.8134532, - 0.49995807, - -5.263498, + 2.9356205, + 0.49996716, + -5.293405, ), rotation: Quat( - 1.3468893e-5, - -0.08567302, - 6.1439237e-6, - 0.9963233, + 1.9918578e-5, + -0.18862937, + -7.567649e-6, + 0.98204833, ), scale: Vec3( 1.0, @@ -308,15 +308,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.3635142, - 0.49994224, - -2.5070152, + 2.5417275, + 0.4999344, + -2.4746914, ), rotation: Quat( - 9.810995e-6, - -0.09259103, - -9.575585e-6, - 0.99570423, + 7.780524e-6, + -0.13873443, + -2.803678e-6, + 0.9903296, ), scale: Vec3( 1.0, @@ -331,15 +331,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.4880779, - 0.49993357, - -0.15428042, + 2.4991288, + 0.49994004, + -0.020369604, ), rotation: Quat( - 1.7498725e-6, - -0.0809388, - 1.0168985e-6, - 0.99671906, + 6.169427e-6, + -0.13957575, + -2.4661904e-6, + 0.99021137, ), scale: Vec3( 1.0, @@ -354,15 +354,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.2925658, - 0.49992672, - 2.379551, + 2.222926, + 0.49993682, + 2.491799, ), rotation: Quat( - 1.5822523e-5, - -0.19126101, - -4.21922e-6, - 0.9815392, + 1.9152405e-6, + -0.12406718, + 1.5702897e-6, + 0.9922738, ), scale: Vec3( 1.0, @@ -377,15 +377,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.485228, - 2.4999545, - -4.5349884, + -4.802956, + 2.4998732, + -4.9959145, ), rotation: Quat( - 9.503106e-6, - -0.0824187, - -4.1908725e-6, - 0.99659777, + 3.4058918e-5, + -0.02808738, + 1.5389675e-6, + 0.9996055, ), scale: Vec3( 1.0, @@ -400,15 +400,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.1805987, - 2.499891, - -2.185662, + -4.1267033, + 2.4999716, + -2.1380875, ), rotation: Quat( - 1.4274107e-6, - 0.0030354005, - 5.56327e-6, - 0.9999954, + 9.902313e-6, + -0.04106795, + -4.502343e-6, + 0.99915636, ), scale: Vec3( 1.0, @@ -423,15 +423,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.765607, - 2.499879, - 0.12764001, + -4.4816256, + 2.4999707, + 0.54315186, ), rotation: Quat( - 1.5524312e-5, - 0.010079111, - -6.217295e-6, - 0.9999492, + -6.963642e-6, + 0.07485945, + -7.725867e-6, + 0.9971941, ), scale: Vec3( 1.0, @@ -446,15 +446,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.5375905, - 2.4999628, - 2.4084332, + -4.479078, + 0.49999946, + 5.250012, ), rotation: Quat( - 1.2267928e-5, - 0.03752504, - -1.9542489e-7, - 0.9992957, + 0.707078, + -0.0064172293, + 0.0064162086, + 0.7070773, ), scale: Vec3( 1.0, @@ -469,15 +469,15 @@ expression: bodies ), Transform { translation: Vec3( - -1.9963549, - 2.4999409, - -4.8419933, + -2.0833967, + 2.4998305, + -4.6686044, ), rotation: Quat( - 5.7315752e-5, - -0.0041233683, - -5.8139882e-8, - 0.9999915, + 9.812366e-5, + -0.04694147, + -8.079542e-6, + 0.9988976, ), scale: Vec3( 1.0, @@ -492,15 +492,15 @@ expression: bodies ), Transform { translation: Vec3( - -1.9898971, - 2.4999545, - -2.240143, + -1.9658682, + 2.4999316, + -2.5046182, ), rotation: Quat( - 1.186729e-5, - 0.009139982, - -3.9852152e-6, - 0.9999582, + 2.3796088e-6, + 0.00437061, + 4.3683176e-6, + 0.99999046, ), scale: Vec3( 1.0, @@ -515,15 +515,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1382337, - 2.4999456, - -0.04046893, + -1.9538839, + 2.4999335, + -0.19311312, ), rotation: Quat( - -4.6483665e-6, - -0.00073893444, - -3.4330824e-6, - 0.9999997, + 2.18081e-5, + 0.04672425, + -2.6875077e-5, + 0.9989078, ), scale: Vec3( 1.0, @@ -538,15 +538,15 @@ expression: bodies ), Transform { translation: Vec3( - -1.6241425, - 2.499912, - 2.0066845, + -1.6183211, + 2.4999154, + 2.213647, ), rotation: Quat( - 1.3614011e-5, - 0.020298816, - 1.072885e-5, - 0.99979395, + 3.5388694e-6, + -0.07203751, + 8.012456e-6, + 0.99740195, ), scale: Vec3( 1.0, @@ -561,15 +561,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.16465269, - 2.4999263, - -4.470149, + 0.24880564, + 2.4998293, + -4.4588413, ), rotation: Quat( - -6.277859e-6, - -0.017593998, - -5.2566525e-6, - 0.9998452, + 0.000113148395, + 0.04139323, + -9.658961e-6, + 0.99914294, ), scale: Vec3( 1.0, @@ -584,15 +584,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.067446426, - 2.4999304, - -2.2192078, + 0.18976483, + 2.4999537, + -2.0090744, ), rotation: Quat( - 1.8954732e-5, - 0.01897101, - -1.8210008e-5, - 0.99982005, + 1.4431914e-6, + 0.021697124, + -3.6956703e-6, + 0.99976456, ), scale: Vec3( 1.0, @@ -607,15 +607,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.27802688, - 2.499953, - -0.06706346, + 0.30283442, + 2.4999504, + 0.24991783, ), rotation: Quat( - 2.3035918e-6, - 0.0035030332, - -6.922778e-6, - 0.99999386, + -5.709594e-6, + 0.008069546, + -8.824132e-6, + 0.99996746, ), scale: Vec3( 1.0, @@ -630,15 +630,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.43624628, - 2.49993, - 1.9980785, + 0.49840316, + 2.4999552, + 2.386049, ), rotation: Quat( - 1.1533771e-5, - 0.032706574, - 5.4833986e-6, - 0.999465, + -1.9563176e-6, + -0.008069459, + 4.03903e-6, + 0.99996746, ), scale: Vec3( 1.0, @@ -653,15 +653,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.4098425, - 2.4999187, - -4.9082546, + 2.7958717, + 2.4999468, + -4.9847417, ), rotation: Quat( - 7.803006e-6, - 0.032124408, - -8.158382e-7, - 0.9994839, + 2.0935327e-5, + -0.02026101, + -1.0689646e-5, + 0.9997947, ), scale: Vec3( 1.0, @@ -676,15 +676,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.4213076, - 2.4999201, - -2.8263128, + 2.53482, + 2.499917, + -2.8631797, ), rotation: Quat( - 3.2441683e-6, - 0.01641528, - -3.5890946e-6, - 0.99986523, + -9.716486e-6, + -0.057248715, + 1.7167887e-6, + 0.9983599, ), scale: Vec3( 1.0, @@ -699,15 +699,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.7333102, - 2.4999228, - -0.44100663, + 2.4877746, + 2.4999106, + -0.6242965, ), rotation: Quat( - -1.2596856e-6, - 0.079656705, - -1.1857236e-5, - 0.99682236, + 7.5665224e-7, + -0.04872094, + 9.191748e-7, + 0.99881244, ), scale: Vec3( 1.0, @@ -722,15 +722,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.6008544, - 2.4999468, - 2.4192235, + 2.7696772, + 2.4999475, + 1.8043613, ), rotation: Quat( - 2.2856288e-5, - 0.034191635, - -1.5087057e-5, - 0.9994153, + 2.1536397e-7, + 0.090809226, + -8.4199455e-6, + 0.9958683, ), scale: Vec3( 1.0, @@ -745,15 +745,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.2971663, - 4.4999123, - -3.8432565, + -4.386225, + 4.499904, + -5.483672, ), rotation: Quat( - -5.0037324e-6, - 0.006852863, - 1.2346757e-6, - 0.9999765, + 3.1910626e-5, + 0.019788539, + 6.922895e-8, + 0.9998042, ), scale: Vec3( 1.0, @@ -768,15 +768,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.335363, - 4.4998927, - -1.7451508, + -7.7358646, + 0.49999946, + -2.0709054, ), rotation: Quat( - -1.0524934e-5, - -0.026445836, - 4.139708e-6, - 0.99965024, + -0.1501146, + -6.5004235e-7, + 0.9886686, + -5.542554e-7, ), scale: Vec3( 1.0, @@ -791,15 +791,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.7714787, - 4.499877, - 0.35351264, + -4.471921, + 4.499904, + 0.75961554, ), rotation: Quat( - 9.6044e-6, - 0.03712531, - -9.287988e-6, - 0.9993106, + -4.0262685e-6, + -0.024324974, + -6.990839e-6, + 0.9997041, ), scale: Vec3( 1.0, @@ -814,15 +814,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.7970796, - 4.4998727, - 2.772003, + -5.6175113, + 0.49999946, + 8.242992, ), rotation: Quat( - 1.42767785e-5, - 0.004501023, - -3.3988813e-6, - 0.99998987, + 0.6893942, + -0.15727805, + 0.1572772, + 0.68939334, ), scale: Vec3( 1.0, @@ -837,15 +837,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1417034, - 4.499789, - -4.267216, + -2.0943875, + 4.4998355, + -4.623846, ), rotation: Quat( - 6.6696986e-5, - 0.025581645, - 1.927695e-6, - 0.9996727, + 0.00010044623, + 0.012530968, + -8.938792e-6, + 0.9999215, ), scale: Vec3( 1.0, @@ -860,15 +860,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.026439, - 4.4998703, - -2.0626712, + -2.009536, + 4.499907, + -2.4300594, ), rotation: Quat( - 7.409019e-6, - 0.010577596, - -9.2272785e-6, - 0.99994403, + -2.0774619e-6, + 0.014378485, + -5.443816e-6, + 0.99989665, ), scale: Vec3( 1.0, @@ -883,15 +883,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1309397, - 4.4999185, - 0.07222076, + -1.9585384, + 4.499923, + -0.22404596, ), rotation: Quat( - 1.1899338e-6, - -0.00022890558, - -7.676071e-6, - 1.0, + 1.715594e-5, + 0.014164529, + -3.7965892e-5, + 0.9998997, ), scale: Vec3( 1.0, @@ -906,15 +906,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.0055707, - 4.4998903, - 2.5978162, + -1.8411386, + 4.4998856, + 2.3135095, ), rotation: Quat( - 9.862658e-6, - 0.03825622, - 6.371329e-6, - 0.99926794, + -3.3378979e-6, + -0.056289833, + 1.8587364e-6, + 0.99841446, ), scale: Vec3( 1.0, @@ -929,15 +929,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.20182578, - 4.4999266, - -4.6506033, + -0.02375713, + 4.4996953, + -4.2030654, ), rotation: Quat( - -3.3825906e-6, - 0.04204805, - -4.324491e-6, - 0.9991156, + 0.00011672663, + 0.03757818, + -1.2387409e-5, + 0.9992937, ), scale: Vec3( 1.0, @@ -952,15 +952,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.06143783, - 4.4999104, - -2.1186182, + 0.119919084, + 4.4998827, + -2.0700102, ), rotation: Quat( - 9.198389e-6, - 0.057064958, - -1.6621138e-5, - 0.99837047, + 4.0283912e-6, + 0.05287602, + -5.329639e-6, + 0.9986011, ), scale: Vec3( 1.0, @@ -975,15 +975,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.09008749, - 4.499909, - 0.4059078, + 0.19294138, + 4.499873, + 0.22602274, ), rotation: Quat( - -1.3736032e-5, - -0.04082854, - 1.8841715e-6, - 0.9991662, + 2.7269325e-6, + 0.010626739, + -1.257475e-5, + 0.99994355, ), scale: Vec3( 1.0, @@ -998,15 +998,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.10141875, - 4.499917, - 2.4459357, + 0.31366748, + 4.4999237, + 2.7180665, ), rotation: Quat( - 2.1650978e-5, - -0.02168258, - 5.229496e-6, - 0.9997649, + 5.3005783e-6, + -0.06315649, + -1.3187989e-5, + 0.99800366, ), scale: Vec3( 1.0, @@ -1021,15 +1021,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.4117937, - 4.4998984, - -4.3657637, + 2.377476, + 4.4999547, + -4.8546257, ), rotation: Quat( - -4.2042775e-6, - 0.048985492, - -6.035323e-6, - 0.9987995, + 2.7817585e-5, + 0.17257857, + -1.4667208e-5, + 0.9849958, ), scale: Vec3( 1.0, @@ -1044,15 +1044,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.2275023, - 4.499888, - -1.8621465, + 2.314021, + 4.499904, + -2.3202064, ), rotation: Quat( - 1.0838617e-5, - 0.03107816, - 2.556269e-6, - 0.99951696, + -1.2845678e-5, + 0.01641865, + -3.9993383e-6, + 0.99986523, ), scale: Vec3( 1.0, @@ -1067,15 +1067,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.3308487, - 4.49984, - 0.22742787, + 2.4601562, + 4.499923, + 0.03035463, ), rotation: Quat( - 5.771548e-6, - 0.029534405, - 2.5869722e-6, - 0.99956375, + -1.0146865e-5, + 0.042424247, + 9.197388e-8, + 0.9990997, ), scale: Vec3( 1.0, @@ -1090,15 +1090,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.3696156, - 4.4998636, - 2.8025134, + 2.5232496, + 4.499871, + 2.199358, ), rotation: Quat( - 1.5080648e-5, - -0.07724971, - -2.596575e-5, - 0.9970118, + 1.0287707e-5, + 0.027183056, + -1.0482277e-5, + 0.99963045, ), scale: Vec3( 1.0, @@ -1113,15 +1113,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.5051923, - 6.4998903, - -3.810133, + -4.798367, + 6.499823, + -4.896724, ), rotation: Quat( - 4.203818e-6, - 0.00550233, - -4.8972784e-6, - 0.99998486, + 4.156623e-5, + -0.18305051, + -4.9355835e-6, + 0.9831035, ), scale: Vec3( 1.0, @@ -1136,15 +1136,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.5689893, - 6.499893, - -1.5330108, + -13.893423, + 0.49999946, + -3.619525, ), rotation: Quat( - -1.2279531e-5, - -0.07520555, - 7.7855987e-7, - 0.99716806, + -0.51768076, + -0.517681, + 0.48167115, + 0.48166996, ), scale: Vec3( 1.0, @@ -1159,15 +1159,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.7065063, - 6.4998336, - 0.5526104, + -4.381537, + 6.4999037, + 0.48308283, ), rotation: Quat( - 1.4557541e-5, - -0.03367962, - -8.779749e-6, - 0.9994327, + -9.016728e-6, + -0.07982172, + -8.499087e-6, + 0.9968092, ), scale: Vec3( 1.0, @@ -1182,15 +1182,15 @@ expression: bodies ), Transform { translation: Vec3( - -4.6731706, - 6.499872, - 2.622469, + -8.318473, + 0.49999946, + 19.172176, ), rotation: Quat( - 1.1933248e-5, - -0.0046023433, - -7.500923e-6, - 0.9999894, + 0.6616829, + -0.24935219, + 0.24935146, + 0.66168195, ), scale: Vec3( 1.0, @@ -1205,15 +1205,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1444836, - 6.499803, - -4.349761, + -2.1034138, + 6.4998574, + -4.8453918, ), rotation: Quat( - 6.1202765e-5, - 0.0016883515, - -1.1926737e-6, - 0.99999857, + 9.41463e-5, + 0.0820297, + 6.9586326e-6, + 0.9966299, ), scale: Vec3( 1.0, @@ -1228,15 +1228,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.1940129, - 6.4998727, - -2.1784127, + -1.9645659, + 6.49991, + -2.2860827, ), rotation: Quat( - 1.1310669e-5, - -0.019140596, - -1.1338596e-5, - 0.9998168, + -1.9683644e-6, + -0.021907628, + -3.0639426e-6, + 0.99976, ), scale: Vec3( 1.0, @@ -1251,15 +1251,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.153471, - 6.499916, - -0.13986145, + -1.9352555, + 6.4999294, + -0.2553877, ), rotation: Quat( - 5.362298e-6, - -0.011965028, - -9.501719e-6, - 0.9999284, + 1.7038174e-5, + -0.035811152, + -4.1647163e-5, + 0.9993586, ), scale: Vec3( 1.0, @@ -1274,15 +1274,15 @@ expression: bodies ), Transform { translation: Vec3( - -2.0463588, - 6.499861, - 2.3378937, + -1.949988, + 6.4998813, + 2.0137444, ), rotation: Quat( - 4.03701e-6, - 0.013133474, - 5.30854e-6, - 0.99991375, + 4.7868593e-7, + -0.004052656, + -2.5726246e-8, + 0.9999918, ), scale: Vec3( 1.0, @@ -1297,15 +1297,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.45179436, - 6.499898, - -5.082483, + 0.08226854, + 6.4997396, + -4.4143085, ), rotation: Quat( - -7.7595705e-6, - 0.23150676, - 2.7409362e-6, - 0.9728333, + 0.000111104484, + -0.022358429, + -2.2984656e-5, + 0.99975, ), scale: Vec3( 1.0, @@ -1320,15 +1320,15 @@ expression: bodies ), Transform { translation: Vec3( - -0.04225794, - 6.4999123, - -2.307129, + 0.043099843, + 6.49989, + -2.2432802, ), rotation: Quat( - 1.1916372e-5, - 0.018675506, - -1.88421e-5, - 0.9998256, + -4.881092e-7, + -0.017938888, + -5.358564e-6, + 0.99983907, ), scale: Vec3( 1.0, @@ -1343,15 +1343,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.08154735, - 6.4999113, - 0.37454426, + 0.20691219, + 6.499881, + 0.23858999, ), rotation: Quat( - -1.4968491e-5, - -0.0477015, - 1.3139173e-6, - 0.9988616, + 3.7870827e-6, + -0.06124742, + -1.658932e-5, + 0.99812263, ), scale: Vec3( 1.0, @@ -1366,15 +1366,15 @@ expression: bodies ), Transform { translation: Vec3( - 0.14312406, - 6.4999194, - 2.393739, + 0.15775675, + 6.499881, + 3.053992, ), rotation: Quat( - 1.992816e-5, - -0.045010325, - 3.2358441e-6, - 0.99898654, + 7.822202e-6, + -0.11158954, + -1.5739672e-5, + 0.9937544, ), scale: Vec3( 1.0, @@ -1389,15 +1389,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.8398702, - 6.499892, - -4.350771, + 2.31714, + 6.499921, + -4.240581, ), rotation: Quat( - 1.3100966e-6, - 0.06222463, - -1.1506304e-5, - 0.9980622, + 1.8280816e-5, + 0.020745432, + -6.7741507e-6, + 0.99978477, ), scale: Vec3( 1.0, @@ -1412,15 +1412,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.064684, - 6.499893, - -2.0412836, + 2.0382423, + 6.4999146, + -2.0699782, ), rotation: Quat( - 1.0947143e-5, - 0.05536288, - 1.9659664e-7, - 0.9984663, + -1.1182783e-5, + -0.017901609, + -5.2746063e-6, + 0.9998398, ), scale: Vec3( 1.0, @@ -1435,15 +1435,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.2600605, - 6.499847, - 0.10657572, + 2.3031816, + 6.499888, + -0.0062856125, ), rotation: Quat( - 1.1522514e-5, - 0.027097696, - 9.932345e-7, - 0.9996328, + -1.2922834e-5, + -0.0152022885, + 5.0969556e-6, + 0.9998844, ), scale: Vec3( 1.0, @@ -1458,15 +1458,15 @@ expression: bodies ), Transform { translation: Vec3( - 2.5827608, - 6.4998703, - 2.3985717, + 2.482787, + 6.4998736, + 2.4378264, ), rotation: Quat( - 1.895812e-5, - 0.048459783, - -2.5742962e-5, - 0.99882513, + 7.338764e-6, + -0.144237, + -1.5116398e-5, + 0.9895432, ), scale: Vec3( 1.0, diff --git a/src/constraints/angular_constraint.rs b/src/constraints/angular_constraint.rs index a37c355a..940527f4 100644 --- a/src/constraints/angular_constraint.rs +++ b/src/constraints/angular_constraint.rs @@ -67,9 +67,18 @@ pub trait AngularConstraint: XpbdConstraint<2> { // Apply rotational updates if body1.rb.is_dynamic() { *body1.rotation += Self::get_delta_rot(rot1, inv_inertia1, p); + + // In 3D, subtracting quaternions like above can result in unnormalized rotations, + // which causes stability issues (see #235) and panics when trying to rotate unit vectors. + // TODO: It would be nice to avoid normalization if possible. + // Maybe the math above can be done in a way that keeps rotations normalized? + body1.rotation.0 = body1.rotation.0.normalize(); } if body2.rb.is_dynamic() { *body2.rotation -= Self::get_delta_rot(rot2, inv_inertia2, p); + + // See comments for `body1` above. + body2.rotation.0 = body2.rotation.0.normalize(); } p diff --git a/src/constraints/position_constraint.rs b/src/constraints/position_constraint.rs index 1740654e..b3ae7a62 100644 --- a/src/constraints/position_constraint.rs +++ b/src/constraints/position_constraint.rs @@ -34,10 +34,25 @@ pub trait PositionConstraint: XpbdConstraint<2> { if body1.rb.is_dynamic() && body1.dominance() <= body2.dominance() { body1.accumulated_translation.0 += p * inv_mass1; *body1.rotation += Self::get_delta_rot(rot1, inv_inertia1, r1, p); + + #[cfg(feature = "3d")] + { + // In 3D, subtracting quaternions like above can result in unnormalized rotations, + // which causes stability issues (see #235) and panics when trying to rotate unit vectors. + // TODO: It would be nice to avoid normalization if possible. + // Maybe the math above can be done in a way that keeps rotations normalized? + body1.rotation.0 = body1.rotation.0.normalize(); + } } if body2.rb.is_dynamic() && body2.dominance() <= body1.dominance() { body2.accumulated_translation.0 -= p * inv_mass2; *body2.rotation -= Self::get_delta_rot(rot2, inv_inertia2, r2, p); + + #[cfg(feature = "3d")] + { + // See comments for `body1` above. + body2.rotation.0 = body2.rotation.0.normalize(); + } } p