pub struct Geometry {
trimesh: Vec<TriMesh>,
}
Expand description
Rust interface for Geometry
Trimeshes in scene geometry are lazy-loaded
Fields§
§trimesh: Vec<TriMesh>
Implementations§
source§impl Geometry
impl Geometry
sourcepub fn size(
&self,
data_cache: &Arc<Mutex<HashMap<Hash, (i64, Data)>>>,
) -> Result<usize, Error>
pub fn size( &self, data_cache: &Arc<Mutex<HashMap<Hash, (i64, Data)>>>, ) -> Result<usize, Error>
Number of all faces in Geometry
sourcepub fn hash(&self) -> Hash
pub fn hash(&self) -> Hash
Calculate hash for lazy-loading
Currently use 32-byte long hash from BLAKE3 algorithm.
sourcepub fn required_data(&self) -> HashSet<Hash>
pub fn required_data(&self) -> HashSet<Hash>
Get all hashes of lazy-loading Data
This includes all v
, vn
, and vt
sourcepub fn add_vertex_hash(
&mut self,
vertex_hash: Hash,
transform_v: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>,
transform_vt: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>,
data_cache: &Arc<Mutex<HashMap<Hash, (i64, Data)>>>,
) -> Result<Hash, Error>
pub fn add_vertex_hash( &mut self, vertex_hash: Hash, transform_v: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, transform_vt: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, data_cache: &Arc<Mutex<HashMap<Hash, (i64, Data)>>>, ) -> Result<Hash, Error>
Add a trimesh to Geometry
from hashed vertex
§Arguments
vertex_hash
- Vertex hash, generated from previousSelf::add_trimesh
orSelf::add_obj
transform_v
- Homogeneous transformation matrix for vertex coordinate 4 * 4transform_vt
- Homogeneous transformation matrix for vertex texture coordinate 3 * 3
vertex
is hashed and cached for better performance
Return vertex
hash for later use in add_vertex_hash
sourcepub fn add_trimesh(
&mut self,
vertex: ArrayBase<OwnedRepr<f32>, Dim<[usize; 3]>>,
transform_v: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>,
transform_vt: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>,
data_cache: &Arc<Mutex<HashMap<Hash, (i64, Data)>>>,
) -> Result<Hash, Error>
pub fn add_trimesh( &mut self, vertex: ArrayBase<OwnedRepr<f32>, Dim<[usize; 3]>>, transform_v: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, transform_vt: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, data_cache: &Arc<Mutex<HashMap<Hash, (i64, Data)>>>, ) -> Result<Hash, Error>
Add a trimesh to Geometry
§Arguments
vertex
- Vertex coordinate, normal, and texture coordinate (3 + 3 + 2) * 3 * Ntransform_v
- Homogeneous transformation matrix for vertex coordinate 4 * 4transform_vt
- Homogeneous transformation matrix for vertex texture coordinate 3 * 3
vertex
is hashed and cached for better performance
Return vertex
hash for later use in Self::add_vertex_hash
sourcepub fn add_obj(
&mut self,
filename: &Path,
transform_v: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>,
transform_vt: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>,
data_cache: &Arc<Mutex<HashMap<Hash, (i64, Data)>>>,
) -> Result<Hash, Error>
pub fn add_obj( &mut self, filename: &Path, transform_v: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, transform_vt: ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, data_cache: &Arc<Mutex<HashMap<Hash, (i64, Data)>>>, ) -> Result<Hash, Error>
Load Wavefront .obj trimesh to Geometry
§Arguments
filename
- Wavefront .obj file pathtransform_v
- Homogeneous transformation matrix for vertex coordinate 4 * 4transform_vt
- Homogeneous transformation matrix for vertex texture coordinate 3 * 3
vertex
is hashed and cached for better performance
Return vertex
hash for later use in add_vertex_hash
Trait Implementations§
source§impl<'de> Deserialize<'de> for Geometry
impl<'de> Deserialize<'de> for Geometry
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Geometry, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Geometry, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for Geometry
impl PartialEq for Geometry
source§impl Serialize for Geometry
impl Serialize for Geometry
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Geometry
Auto Trait Implementations§
impl Freeze for Geometry
impl RefUnwindSafe for Geometry
impl Send for Geometry
impl Sync for Geometry
impl Unpin for Geometry
impl UnwindSafe for Geometry
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.