diff --git a/src/ogt_vox.h b/src/ogt_vox.h index 5a68286..087768d 100644 --- a/src/ogt_vox.h +++ b/src/ogt_vox.h @@ -227,6 +227,7 @@ #define _vox_le32toh(x) (x) #endif +extern "C" { // denotes an invalid group index. Usually this is only applicable to the scene's root group's parent. static const uint32_t k_invalid_group_index = UINT32_MAX; @@ -495,6 +496,7 @@ // ogt_vox_sample_group_transform_local returns the transform relative to its parent group ogt_vox_transform ogt_vox_sample_group_transform_global(const ogt_vox_group* group, uint32_t frame_index, const ogt_vox_scene* scene); ogt_vox_transform ogt_vox_sample_group_transform_local(const ogt_vox_group* group, uint32_t frame_index); +} // extern "C" #endif // OGT_VOX_H__ diff --git a/src/ogt_voxel_meshify.h b/src/ogt_voxel_meshify.h index da6919e..8c44dd6 100644 --- a/src/ogt_voxel_meshify.h +++ b/src/ogt_voxel_meshify.h @@ -143,36 +143,37 @@ struct ogt_voxel_meshify_context void* alloc_free_user_data; // alloc/free user-data (passed to alloc_func / free_func ) }; -// returns the number of quad faces that would be generated by tessellating the specified voxel field using the simple algorithm. Useful for preallocating memory. -// number of vertices needed would 4x this value, and number of indices needed would be 6x this value. -uint32_t ogt_face_count_from_paletted_voxels_simple(const uint8_t* voxels, uint32_t size_x, uint32_t size_y, uint32_t size_z); +extern "C" { + // returns the number of quad faces that would be generated by tessellating the specified voxel field using the simple algorithm. Useful for preallocating memory. + // number of vertices needed would 4x this value, and number of indices needed would be 6x this value. + uint32_t ogt_face_count_from_paletted_voxels_simple(const uint8_t* voxels, uint32_t size_x, uint32_t size_y, uint32_t size_z); -// The simple meshifier returns the most naieve mesh possible, which will be tessellated at voxel granularity. -ogt_mesh* ogt_mesh_from_paletted_voxels_simple(const ogt_voxel_meshify_context* ctx, const uint8_t* voxels, uint32_t size_x, uint32_t size_y, uint32_t size_z, const ogt_mesh_rgba* palette); + // The simple meshifier returns the most naieve mesh possible, which will be tessellated at voxel granularity. + ogt_mesh* ogt_mesh_from_paletted_voxels_simple(const ogt_voxel_meshify_context* ctx, const uint8_t* voxels, uint32_t size_x, uint32_t size_y, uint32_t size_z, const ogt_mesh_rgba* palette); -// The greedy meshifier will use a greedy box-expansion pass to replace the polygons of adjacent voxels of the same color with a larger polygon that covers the box. -// It will generally produce t-junctions which can make rasterization not water-tight based on your camera/project/distances. -ogt_mesh* ogt_mesh_from_paletted_voxels_greedy(const ogt_voxel_meshify_context* ctx, const uint8_t* voxels, uint32_t size_x, uint32_t size_y, uint32_t size_z, const ogt_mesh_rgba* palette); + // The greedy meshifier will use a greedy box-expansion pass to replace the polygons of adjacent voxels of the same color with a larger polygon that covers the box. + // It will generally produce t-junctions which can make rasterization not water-tight based on your camera/project/distances. + ogt_mesh* ogt_mesh_from_paletted_voxels_greedy(const ogt_voxel_meshify_context* ctx, const uint8_t* voxels, uint32_t size_x, uint32_t size_y, uint32_t size_z, const ogt_mesh_rgba* palette); -// The polygon meshifier will polygonize and triangulate connected voxels that are of the same color. The boundary of the polygon -// will be tessellated only to the degree that is necessary to there are tessellations at color discontinuities. -// This will mostly be water-tight, except for a very small number of cases. -ogt_mesh* ogt_mesh_from_paletted_voxels_polygon(const ogt_voxel_meshify_context* ctx, const uint8_t* voxels, uint32_t size_x, uint32_t size_y, uint32_t size_z, const ogt_mesh_rgba* palette); + // The polygon meshifier will polygonize and triangulate connected voxels that are of the same color. The boundary of the polygon + // will be tessellated only to the degree that is necessary to there are tessellations at color discontinuities. + // This will mostly be water-tight, except for a very small number of cases. + ogt_mesh* ogt_mesh_from_paletted_voxels_polygon(const ogt_voxel_meshify_context* ctx, const uint8_t* voxels, uint32_t size_x, uint32_t size_y, uint32_t size_z, const ogt_mesh_rgba* palette); -// ogt_mesh_remove_duplicate_vertices will in-place remove identical vertices and remap indices to produce an identical mesh. -// Use this after a call to ogt_mesh_from_paletted_voxels_* functions to remove duplicate vertices with the same attributes. -void ogt_mesh_remove_duplicate_vertices(const ogt_voxel_meshify_context* ctx, ogt_mesh* mesh); + // ogt_mesh_remove_duplicate_vertices will in-place remove identical vertices and remap indices to produce an identical mesh. + // Use this after a call to ogt_mesh_from_paletted_voxels_* functions to remove duplicate vertices with the same attributes. + void ogt_mesh_remove_duplicate_vertices(const ogt_voxel_meshify_context* ctx, ogt_mesh* mesh); -// Removes faceted normals on the mesh and averages vertex normals based on the faces that are adjacent. -// It is recommended only to call this on ogt_mesh_from_paletted_voxels_simple. -void ogt_mesh_smooth_normals(const ogt_voxel_meshify_context* ctx, ogt_mesh* mesh); + // Removes faceted normals on the mesh and averages vertex normals based on the faces that are adjacent. + // It is recommended only to call this on ogt_mesh_from_paletted_voxels_simple. + void ogt_mesh_smooth_normals(const ogt_voxel_meshify_context* ctx, ogt_mesh* mesh); -// destroys the mesh returned by ogt_mesh_from_paletted_voxels* functions. -void ogt_mesh_destroy(const ogt_voxel_meshify_context* ctx, ogt_mesh* mesh ); - -// The simple stream function will stream geometry for the specified voxel field, to the specified stream function, which will be invoked on each voxel that requires geometry. -void ogt_stream_from_paletted_voxels_simple(const uint8_t* voxels, uint32_t size_x, uint32_t size_y, uint32_t size_z, const ogt_mesh_rgba* palette, ogt_voxel_simple_stream_func stream_func, void* stream_func_data); + // destroys the mesh returned by ogt_mesh_from_paletted_voxels* functions. + void ogt_mesh_destroy(const ogt_voxel_meshify_context* ctx, ogt_mesh* mesh ); + // The simple stream function will stream geometry for the specified voxel field, to the specified stream function, which will be invoked on each voxel that requires geometry. + void ogt_stream_from_paletted_voxels_simple(const uint8_t* voxels, uint32_t size_x, uint32_t size_y, uint32_t size_z, const ogt_mesh_rgba* palette, ogt_voxel_simple_stream_func stream_func, void* stream_func_data); +} // extern "C" #endif // OGT_VOXEL_MESHIFY_H__