boxddd 0.3.0

Safe, ergonomic Rust bindings for Box3D
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::core::{box3d_lock, callback_state};
use boxddd_sys::ffi;

/// Reads Box3D's process-global scale without recursively taking the lock from a callback.
pub(crate) fn current_length_units() -> f32 {
    if callback_state::in_callback() {
        // Box3D invokes registered callbacks while the outer operation owns the global lock.
        unsafe { ffi::b3GetLengthUnitsPerMeter() }
    } else {
        let _guard = box3d_lock::lock();
        unsafe { ffi::b3GetLengthUnitsPerMeter() }
    }
}