mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
wake up rigid bodies when changeing linear/angular velocity
- #864 - fixed usage of `can sleep` flag
This commit is contained in:
@@ -27,8 +27,8 @@ fyrox-graphics-gl = { path = "../fyrox-graphics-gl", version = "1.0.0-rc.1" }
|
||||
fyrox-texture = { path = "../fyrox-texture", version = "1.0.0-rc.1" }
|
||||
fyrox-autotile = { path = "../fyrox-autotile", version = "1.0.0-rc.1" }
|
||||
fyrox-material = { path = "../fyrox-material", version = "1.0.0-rc.2" }
|
||||
rapier2d = { version = "0.29", features = ["debug-render"] }
|
||||
rapier3d = { version = "0.29", features = ["debug-render"] }
|
||||
rapier2d = { version = "0.30", features = ["debug-render"] }
|
||||
rapier3d = { version = "0.30", features = ["debug-render"] }
|
||||
image = { version = "0.25.1", default-features = false, features = ["gif", "jpeg", "png", "tga", "tiff", "bmp"] }
|
||||
inflate = "0.4.5"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
||||
@@ -976,10 +976,10 @@ impl PhysicsWorld {
|
||||
.try_sync_model(|v| native.set_body_type(v.into(), false));
|
||||
rigid_body_node
|
||||
.lin_vel
|
||||
.try_sync_model(|v| native.set_linvel(v, false));
|
||||
.try_sync_model(|v| native.set_linvel(v, true));
|
||||
rigid_body_node
|
||||
.ang_vel
|
||||
.try_sync_model(|v| native.set_angvel(v, false));
|
||||
.try_sync_model(|v| native.set_angvel(v, true));
|
||||
rigid_body_node.mass.try_sync_model(|v| {
|
||||
native.set_additional_mass(v, true);
|
||||
});
|
||||
@@ -993,16 +993,10 @@ impl PhysicsWorld {
|
||||
.ccd_enabled
|
||||
.try_sync_model(|v| native.enable_ccd(v));
|
||||
rigid_body_node.can_sleep.try_sync_model(|v| {
|
||||
let activation = native.activation_mut();
|
||||
if v {
|
||||
activation.normalized_linear_threshold =
|
||||
RigidBodyActivation::default_normalized_linear_threshold();
|
||||
activation.angular_threshold =
|
||||
RigidBodyActivation::default_angular_threshold();
|
||||
*native.activation_mut() = RigidBodyActivation::active();
|
||||
} else {
|
||||
activation.sleeping = false;
|
||||
activation.normalized_linear_threshold = -1.0;
|
||||
activation.angular_threshold = -1.0;
|
||||
*native.activation_mut() = RigidBodyActivation::cannot_sleep();
|
||||
};
|
||||
});
|
||||
rigid_body_node
|
||||
@@ -1072,7 +1066,6 @@ impl PhysicsWorld {
|
||||
.linear_damping(*rigid_body_node.lin_damping)
|
||||
.angular_damping(*rigid_body_node.ang_damping)
|
||||
.can_sleep(rigid_body_node.is_can_sleep())
|
||||
.sleeping(rigid_body_node.is_sleeping())
|
||||
.dominance_group(rigid_body_node.dominance())
|
||||
.gravity_scale(rigid_body_node.gravity_scale());
|
||||
|
||||
|
||||
@@ -1466,10 +1466,10 @@ impl PhysicsWorld {
|
||||
.try_sync_model(|v| native.set_body_type(v.into(), false));
|
||||
rigid_body_node
|
||||
.lin_vel
|
||||
.try_sync_model(|v| native.set_linvel(v, false));
|
||||
.try_sync_model(|v| native.set_linvel(v, true));
|
||||
rigid_body_node
|
||||
.ang_vel
|
||||
.try_sync_model(|v| native.set_angvel(v, false));
|
||||
.try_sync_model(|v| native.set_angvel(v, true));
|
||||
rigid_body_node.mass.try_sync_model(|v| {
|
||||
match *rigid_body_node.mass_properties_type {
|
||||
RigidBodyMassPropertiesType::Default => {
|
||||
@@ -1520,16 +1520,10 @@ impl PhysicsWorld {
|
||||
.ccd_enabled
|
||||
.try_sync_model(|v| native.enable_ccd(v));
|
||||
rigid_body_node.can_sleep.try_sync_model(|v| {
|
||||
let activation = native.activation_mut();
|
||||
if v {
|
||||
activation.normalized_linear_threshold =
|
||||
RigidBodyActivation::default_normalized_linear_threshold();
|
||||
activation.angular_threshold =
|
||||
RigidBodyActivation::default_angular_threshold();
|
||||
*native.activation_mut() = RigidBodyActivation::active();
|
||||
} else {
|
||||
activation.sleeping = false;
|
||||
activation.normalized_linear_threshold = -1.0;
|
||||
activation.angular_threshold = -1.0;
|
||||
*native.activation_mut() = RigidBodyActivation::cannot_sleep();
|
||||
};
|
||||
});
|
||||
rigid_body_node
|
||||
@@ -1620,7 +1614,6 @@ impl PhysicsWorld {
|
||||
.linear_damping(*rigid_body_node.lin_damping)
|
||||
.angular_damping(*rigid_body_node.ang_damping)
|
||||
.can_sleep(rigid_body_node.is_can_sleep())
|
||||
.sleeping(rigid_body_node.is_sleeping())
|
||||
.dominance_group(rigid_body_node.dominance())
|
||||
.gravity_scale(rigid_body_node.gravity_scale())
|
||||
.enabled_rotations(
|
||||
|
||||
Reference in New Issue
Block a user