bevy/crates/bevy_reflect/src
Nándor Szalma 7f74e3c2f9
Fix depth_bias and build errors on less capable platforms (#17079)
# Objective

- I'm compiling (parts of) bevy for an embedded platform with no 64bit
atomic and ctrlc handler support. Some compilation errors came up. This
PR contains the fixes for those.
- Fix depth_bias casting in PBR material (Fixes #14169)
  - Negative depth_bias values were casted to 0 before this PR
  - f32::INFINITY depth_bias value was casted to -1 before this PR

## Solutions

- Restrict 64bit atomic reflection to supported platforms
- Restrict ctrlc handler to supported platforms (linux, windows or macos
instead of "not wasm")
- The depth bias value (f32) is first casted to i32 then u64 in order to
preserve negative values

## Testing
- This version compiles on a platform with no 64bit atomic support, and
no ctrlc support
- CtrlC handler still works on Linux and Windows (I can't test on Macos)
- depth_bias:
```rust
println!("{}",f32::INFINITY as u64 as i32); // Prints: -1 (old implementation)
println!("{}",f32::INFINITY as i32 as u64 as i32); // Prints: 2147483647 (expected, new implementation)
```
Also ran a modified version of 3d_scene example with the following
results:

RED cube depth_bias: -1000.0
BLUE cube depth_bias: 0.0

![image](https://github.com/user-attachments/assets/d5a96759-dd3c-4a0a-97ff-821163873a0d)

RED cube depth_bias: -INF
BLUE cube depth_bias: 0.0

![image](https://github.com/user-attachments/assets/e4de22b4-0c31-4dea-8be1-12b700e440b9)

RED cube depth_bias: INF (case reported in #14169)
BLUE cube depth_bias: 0.0
(Im not completely sure whats going on with the shadows here, it seems
like depth_bias has some affect to those aswell, if this is
unintentional this issue was not introduced by this PR)

![image](https://github.com/user-attachments/assets/52d9348f-df27-468f-a001-2d3d3ff6b553)
2025-01-06 18:39:08 +00:00
..
enums Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
func bevy_reflect: Apply #[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17092) 2025-01-03 22:22:34 +00:00
impls Fix depth_bias and build errors on less capable platforms (#17079) 2025-01-06 18:39:08 +00:00
path Update GetPath unit test and documentation for empty path usecase (#17150) 2025-01-05 02:45:26 +00:00
serde bevy_reflect: Apply #[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17092) 2025-01-03 22:22:34 +00:00
array.rs Remove all deprecated code (#16338) 2025-01-05 20:33:39 +00:00
attributes.rs bevy_reflect: Apply #[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17092) 2025-01-03 22:22:34 +00:00
fields.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
from_reflect.rs bevy_reflect: Apply #[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17092) 2025-01-03 22:22:34 +00:00
generics.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
kind.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
lib.rs Change bevy_reflect::RegisterForReflection::__register() to expect unused variables, rather than putting underscores on the parameter names (#17171) 2025-01-05 20:27:20 +00:00
list.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
map.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
reflect.rs Replace map + unwrap_or(false) with is_some_and (#17067) 2024-12-31 20:28:02 +00:00
reflectable.rs bevy_reflect: Add Reflectable trait (#5772) 2024-09-18 00:36:41 +00:00
remote.rs Add no_std support to bevy_reflect (#16256) 2024-12-05 21:15:21 +00:00
set.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
std_traits.rs Add no_std support to bevy_reflect (#16256) 2024-12-05 21:15:21 +00:00
struct_trait.rs Add no_std support to bevy_reflect (#16256) 2024-12-05 21:15:21 +00:00
tuple_struct.rs Add no_std support to bevy_reflect (#16256) 2024-12-05 21:15:21 +00:00
tuple.rs Add no_std support to bevy_reflect (#16256) 2024-12-05 21:15:21 +00:00
type_info_stack.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
type_info.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
type_path.rs Add no_std support to bevy_reflect (#16256) 2024-12-05 21:15:21 +00:00
type_registry.rs bevy_reflect: Apply #[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17092) 2025-01-03 22:22:34 +00:00
utility.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00