1#[cfg(feature = "rerun")]
2use std::borrow::Borrow;
3
4#[cfg(feature = "rerun")]
5use glam::{Quat, Vec2, Vec3};
6
7#[cfg(feature = "rerun")]
8pub fn vec3_array(v: impl Borrow<Vec3>) -> [f32; 3] {
9 [v.borrow().x, v.borrow().y, v.borrow().z]
10}
11
12#[cfg(feature = "rerun")]
13pub fn vec2_array(v: impl Borrow<Vec2>) -> [f32; 3] {
14 [v.borrow().x, v.borrow().y, 0.0]
15}
16
17#[cfg(feature = "rerun")]
18pub fn quat_array(q: impl Borrow<Quat>) -> [f32; 4] {
19 [q.borrow().x, q.borrow().y, q.borrow().z, q.borrow().w]
20}
21
22#[macro_export]
23macro_rules! error_none {
24 ($msg:literal) => {
25 || {
26 tracing::error!($msg);
27 None
28 }
29 };
30}
31
32macro_rules! unwrap_or_return {
33 ($code:expr, $error:expr, $ret:expr) => {
34 match $code {
35 Some(value) => value,
36 None => {
37 tracing::error!($error);
38 return $ret;
39 }
40 }
41 };
42 ($code:expr, $error:expr) => {
43 match $code {
44 Some(value) => value,
45 None => {
46 tracing::error!($error);
47 return;
48 }
49 }
50 };
51}
52
53pub(crate) use unwrap_or_return;