@@ -719,6 +719,12 @@ pub fn init_colliders(
719
719
let context = & mut * context;
720
720
let physics_scale = context. physics_scale ;
721
721
722
+ #[ cfg( feature = "enhanced-determinism" ) ]
723
+ {
724
+ let mut colliders: Vec < ColliderComponents > = colliders. iter ( ) . collect ( ) ;
725
+ colliders. sort_by_key ( |f| f. 0 ) ;
726
+ }
727
+
722
728
for (
723
729
entity,
724
730
shape,
@@ -836,6 +842,12 @@ pub fn init_rigid_bodies(
836
842
) {
837
843
let physics_scale = context. physics_scale ;
838
844
845
+ #[ cfg( feature = "enhanced-determinism" ) ]
846
+ {
847
+ let mut rigid_bodies: Vec < RigidBodyComponents > = rigid_bodies. iter ( ) . collect ( ) ;
848
+ rigid_bodies. sort_by_key ( |f| f. 0 ) ;
849
+ }
850
+
839
851
for (
840
852
entity,
841
853
rb,
@@ -979,6 +991,12 @@ pub fn init_joints(
979
991
let context = & mut * context;
980
992
let scale = context. physics_scale ;
981
993
994
+ #[ cfg( feature = "enhanced-determinism" ) ]
995
+ {
996
+ let mut impulse_joints: Vec < ( Entity , & ImpulseJoint ) > = impulse_joints. iter ( ) . collect ( ) ;
997
+ impulse_joints. sort_by_key ( |f| f. 0 ) ;
998
+ }
999
+
982
1000
for ( entity, joint) in impulse_joints. iter ( ) {
983
1001
let mut target = None ;
984
1002
let mut body_entity = entity;
@@ -1003,6 +1021,13 @@ pub fn init_joints(
1003
1021
}
1004
1022
}
1005
1023
1024
+ #[ cfg( feature = "enhanced-determinism" ) ]
1025
+ {
1026
+ let mut multibody_joints: Vec < ( Entity , & MultibodyJoint ) > =
1027
+ multibody_joints. iter ( ) . collect ( ) ;
1028
+ multibody_joints. sort_by_key ( |f| f. 0 ) ;
1029
+ }
1030
+
1006
1031
for ( entity, joint) in multibody_joints. iter ( ) {
1007
1032
let target = context. entity2body . get ( & entity) ;
1008
1033
@@ -1081,6 +1106,12 @@ pub fn sync_removals(
1081
1106
/*
1082
1107
* Collider removal detection.
1083
1108
*/
1109
+ #[ cfg( feature = "enhanced-determinism" ) ]
1110
+ {
1111
+ let mut removed_colliders: Vec < Entity > = removed_colliders. iter ( ) . collect ( ) ;
1112
+ removed_colliders. sort ( ) ;
1113
+ }
1114
+
1084
1115
for entity in removed_colliders. iter ( ) {
1085
1116
if let Some ( handle) = context. entity2collider . remove ( & entity) {
1086
1117
context
@@ -1090,6 +1121,12 @@ pub fn sync_removals(
1090
1121
}
1091
1122
}
1092
1123
1124
+ #[ cfg( feature = "enhanced-determinism" ) ]
1125
+ {
1126
+ let mut orphan_colliders: Vec < Entity > = orphan_colliders. iter ( ) . collect ( ) ;
1127
+ orphan_colliders. sort ( ) ;
1128
+ }
1129
+
1093
1130
for entity in orphan_colliders. iter ( ) {
1094
1131
if let Some ( handle) = context. entity2collider . remove ( & entity) {
1095
1132
context
0 commit comments