From b5d25c432ced01d1c70cab0a96f4802f0cf3aeeb Mon Sep 17 00:00:00 2001 From: matt rice Date: Thu, 11 Apr 2024 19:41:44 -0700 Subject: [PATCH] Incomplete MetaData reading Signed-off-by: matt rice --- ptex-sys/src/lib.rs | 23 +++++++++++++++++++++++ ptex-sys/src/ptex-sys.h | 17 +++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/ptex-sys/src/lib.rs b/ptex-sys/src/lib.rs index 7ab0a26..cd86403 100644 --- a/ptex-sys/src/lib.rs +++ b/ptex-sys/src/lib.rs @@ -153,6 +153,9 @@ pub mod ffi { /// File-handle and memory cache for reading ptex files. type PtexCache; + /// Interface for reading metadata from a ptex texture. + type PtexMetaData; + /// Interface for reading data from a ptex file type PtexTexture; @@ -369,6 +372,12 @@ pub mod ffi { #[namespace = "Ptex::sys"] unsafe fn ptextexture_get_meshtype(cache: *const PtexTexture) -> MeshType; + /// Get the metadata for the specified PtexTexture + /// # Safety + /// This function must be called with a valid PtexTexture pointer. + #[namespace = "Ptex::sys"] + unsafe fn ptextexture_get_meta_data(cache: *const PtexTexture) -> *const PtexMetaData; + /// Get the DataType for the specified PtexCache. /// # Safety /// This function must be called with a valid PtexTexture pointer. @@ -528,6 +537,20 @@ pub mod ffi { data: *const u8, count: usize, ) -> bool; + + // struct PtexMetaData + + /// Get the number of meta data keys from a PtexMetaData pointer. + /// # Safety + /// Must only be called on valid PtexMetaData pointers. + #[namespace = "Ptex::sys"] + unsafe fn ptexmetadata_num_keys(metadata: *const PtexMetaData) -> i32; + + /// Release a PtexMetaData + /// # Safety + /// This function must be called with a valid PtexMetaData pointer. + #[namespace = "Ptex::sys"] + unsafe fn ptexmetadata_release(cache: *mut PtexMetaData); } } diff --git a/ptex-sys/src/ptex-sys.h b/ptex-sys/src/ptex-sys.h index e2476da..f9fe30a 100644 --- a/ptex-sys/src/ptex-sys.h +++ b/ptex-sys/src/ptex-sys.h @@ -350,6 +350,11 @@ inline MeshType ptextexture_get_meshtype(PtexTexture const *texture) return MeshType::mt_quad; } +inline PtexMetaData* ptextexture_get_meta_data(PtexTexture *texture) +{ + return const_cast(texture)->getMetaData(); +} + inline DataType ptextexture_get_datatype(PtexTexture const *texture) { if (texture) { @@ -412,5 +417,17 @@ inline float ptextexture_get_pixel( return result; } + +// struct PtexMetaData +inline int32_t ptexmetadata_num_keys(PtexMetaData *metadata) { + return (int32_t) metadata->numKeys(); +} + +inline void ptexmetadata_release(PtexMetaData *metadata) { + if (metadata) { + metadata->release(); + } +} + } // namespace sys } // namespace Ptex