Skip to content

Commit

Permalink
Incomplete MetaData reading
Browse files Browse the repository at this point in the history
Signed-off-by: matt rice <[email protected]>
  • Loading branch information
ratmice committed Apr 12, 2024
1 parent 32c57d6 commit b5d25c4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ptex-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
}

Expand Down
17 changes: 17 additions & 0 deletions ptex-sys/src/ptex-sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PtexTexture *>(texture)->getMetaData();
}

inline DataType ptextexture_get_datatype(PtexTexture const *texture)
{
if (texture) {
Expand Down Expand Up @@ -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

0 comments on commit b5d25c4

Please sign in to comment.