fmod/core/geometry/
mod.rs

1// Copyright (c) 2024 Melody Madeline Lyons
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
7use std::ptr::NonNull;
8
9use fmod_sys::*;
10
11mod general;
12mod polygons;
13mod spatialization;
14
15/// An interface that allows the setup and modification of geometry for occlusion.
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
17#[repr(transparent)] // so we can transmute between types
18pub struct Geometry {
19    pub(crate) inner: NonNull<FMOD_GEOMETRY>,
20}
21
22#[cfg(not(feature = "thread-unsafe"))]
23unsafe impl Send for Geometry {}
24#[cfg(not(feature = "thread-unsafe"))]
25unsafe impl Sync for Geometry {}
26
27impl Geometry {
28    /// # Safety
29    ///
30    /// `value` must be a valid pointer either aquired from [`Self::as_ptr`] or FMOD.
31    ///
32    /// # Panics
33    ///
34    /// Panics if `value` is null.
35    pub unsafe fn from_ffi(value: *mut FMOD_GEOMETRY) -> Self {
36        let inner = NonNull::new(value).unwrap();
37        Geometry { inner }
38    }
39
40    /// Converts `self` into its raw representation.
41    pub fn as_ptr(self) -> *mut FMOD_GEOMETRY {
42        self.inner.as_ptr()
43    }
44}
45
46impl From<Geometry> for *mut FMOD_GEOMETRY {
47    fn from(value: Geometry) -> Self {
48        value.inner.as_ptr()
49    }
50}