diff --git a/include/zenkit-capi/Boxes.h b/include/zenkit-capi/Boxes.h index 3927301..a51ab47 100644 --- a/include/zenkit-capi/Boxes.h +++ b/include/zenkit-capi/Boxes.h @@ -7,16 +7,24 @@ #ifdef __cplusplus #include "zenkit/Boxes.hh" -using ZkAxisAlignedBoundingBox = zenkit::AxisAlignedBoundingBox; using ZkOrientedBoundingBox = zenkit::OrientedBoundingBox; #else -typedef struct { +typedef struct ZkInternal_OrientedBoundingBox ZkOrientedBoundingBox; +#endif + +typedef struct ZkInternal_AxisAlignedBoundingBox { ZkVec3f min; ZkVec3f max; -} ZkAxisAlignedBoundingBox; -typedef struct ZkInternal_OrientedBoundingBox ZkOrientedBoundingBox; +#ifdef __cplusplus + ZkInternal_AxisAlignedBoundingBox() : min(), max() {} + ZkInternal_AxisAlignedBoundingBox(zenkit::AxisAlignedBoundingBox const& bbox) : min(bbox.min), max(bbox.max) {} + + operator zenkit::AxisAlignedBoundingBox() const { + return {min, max}; + } #endif +} ZkAxisAlignedBoundingBox; typedef ZkBool (*ZkOrientedBoundingBoxEnumerator)(void*, ZkOrientedBoundingBox const* box); diff --git a/include/zenkit-capi/Mesh.h b/include/zenkit-capi/Mesh.h index 23f1b64..bc13ac4 100644 --- a/include/zenkit-capi/Mesh.h +++ b/include/zenkit-capi/Mesh.h @@ -11,21 +11,26 @@ #ifdef __cplusplus #include using ZkMesh = zenkit::Mesh; -using ZkVertex = zenkit::VertexFeature; using ZkLightMap = zenkit::LightMap; using ZkPolygon = zenkit::Polygon; #else typedef struct ZkInternal_Mesh ZkMesh; typedef struct ZkInternal_LightMap ZkLightMap; typedef struct ZkInternal_Polygon ZkPolygon; +#endif -typedef struct { +typedef struct ZkInternal_Vertex { ZkVec2f texture; uint32_t light; ZkVec3f normal; -} ZkVertex; + +#ifdef __cplusplus + ZkInternal_Vertex() : texture(), light(0), normal() {} + ZkInternal_Vertex(zenkit::VertexFeature const& v) : texture(v.texture), light(v.light), normal(v.normal) {} #endif +} ZkVertex; +typedef ZkBool (*ZkVertexEnumerator)(void* ctx, ZkVertex* vertex); typedef ZkBool (*ZkLightMapEnumerator)(void* ctx, ZkLightMap const* lightMap); typedef ZkBool (*ZkPolygonEnumerator)(void* ctx, ZkPolygon const* polygon); @@ -43,8 +48,13 @@ ZKC_API ZkSize ZkMesh_getMaterialCount(ZkMesh const* slf); ZKC_API ZkMaterial const* ZkMesh_getMaterial(ZkMesh const* slf, ZkSize i); ZKC_API void ZkMesh_enumerateMaterials(ZkMesh const* slf, ZkMaterialEnumerator cb, void* ctx); -ZKC_API ZkVec3f const* ZkMesh_getPositions(ZkMesh const* slf, ZkSize* count); -ZKC_API ZkVertex const* ZkMesh_getVertices(ZkMesh const* slf, ZkSize* count); +ZKC_API ZkSize ZkMesh_getPositionCount(ZkMesh const* slf); +ZKC_API ZkVec3f ZkMesh_getPosition(ZkMesh const* slf, ZkSize i); +ZKC_API void ZkMesh_enumeratePositions(ZkMesh const* slf, ZkVec3fEnumerator cb, void* ctx); + +ZKC_API ZkSize ZkMesh_getVertexCount(ZkMesh const* slf); +ZKC_API ZkVertex ZkMesh_getVertex(ZkMesh const* slf, ZkSize i); +ZKC_API void ZkMesh_enumerateVertices(ZkMesh const* slf, ZkVertexEnumerator cb, void* ctx); ZKC_API ZkSize ZkMesh_getLightMapCount(ZkMesh const* slf); ZKC_API ZkLightMap const* ZkMesh_getLightMap(ZkMesh const* slf, ZkSize i); diff --git a/include/zenkit-capi/ModelAnimation.h b/include/zenkit-capi/ModelAnimation.h index 4d07b72..df7f863 100644 --- a/include/zenkit-capi/ModelAnimation.h +++ b/include/zenkit-capi/ModelAnimation.h @@ -11,15 +11,19 @@ #ifdef __cplusplus #include using ZkModelAnimation = zenkit::ModelAnimation; -using ZkAnimationSample = zenkit::AnimationSample; #else typedef struct ZkInternal_ModelAnimation ZkModelAnimation; +#endif -typedef struct { +typedef struct ZkInternal_AnimationSample { ZkVec3f position; ZkQuat rotation; -} ZkAnimationSample; + +#ifdef __cplusplus + ZkInternal_AnimationSample() : position(), rotation() {} + ZkInternal_AnimationSample(zenkit::AnimationSample const& v) : position(v.position), rotation(v.rotation) {} #endif +} ZkAnimationSample; typedef ZkBool (*ZkAnimationSampleEnumerator)(void* ctx, ZkAnimationSample* sample); diff --git a/include/zenkit-capi/MorphMesh.h b/include/zenkit-capi/MorphMesh.h index 967f332..7eb7597 100644 --- a/include/zenkit-capi/MorphMesh.h +++ b/include/zenkit-capi/MorphMesh.h @@ -28,7 +28,10 @@ ZKC_API void ZkMorphMesh_del(ZkMorphMesh* slf); ZKC_API ZkString ZkMorphMesh_getName(ZkMorphMesh const* slf); ZKC_API ZkMultiResolutionMesh const* ZkMorphMesh_getMesh(ZkMorphMesh const* slf); -ZKC_API ZkVec3f const* ZkMorphMesh_getMorphPositions(ZkMorphMesh const* slf, ZkSize* count); + +ZKC_API ZkSize ZkMorphMesh_getMorphPositionCount(ZkMorphMesh const* slf); +ZKC_API ZkVec3f ZkMorphMesh_getMorphPosition(ZkMorphMesh const* slf, ZkSize i); +ZKC_API void ZkMorphMesh_enumerateMorphPositions(ZkMorphMesh const* slf, ZkVec3fEnumerator cb, void* ctx); ZKC_API ZkSize ZkMorphMesh_getAnimationCount(ZkMorphMesh const* slf); ZKC_API ZkMorphAnimation const* ZkMorphMesh_getAnimation(ZkMorphMesh const* slf, ZkSize i); @@ -47,7 +50,10 @@ ZKC_API float ZkMorphAnimation_getSpeed(ZkMorphAnimation const* slf); ZKC_API uint8_t ZkMorphAnimation_getFlags(ZkMorphAnimation const* slf); ZKC_API uint32_t ZkMorphAnimation_getFrameCount(ZkMorphAnimation const* slf); ZKC_API uint32_t const* ZkMorphAnimation_getVertices(ZkMorphAnimation const* slf, ZkSize* count); -ZKC_API ZkVec3f const* ZkMorphAnimation_getSamples(ZkMorphAnimation const* slf, ZkSize* count); + +ZKC_API ZkSize ZkMorphAnimation_getSampleCount(ZkMorphAnimation const* slf); +ZKC_API ZkVec3f ZkMorphAnimation_getSample(ZkMorphAnimation const* slf, ZkSize i); +ZKC_API void ZkMorphAnimation_enumerateSamples(ZkMorphAnimation const* slf, ZkVec3fEnumerator cb, void* ctx); ZKC_API ZkDate ZkMorphSource_getFileDate(ZkMorphSource const* slf); ZKC_API ZkString ZkMorphSource_getFileName(ZkMorphSource const* slf); diff --git a/include/zenkit-capi/MultiResolutionMesh.h b/include/zenkit-capi/MultiResolutionMesh.h index 53d6d44..7c1ea8c 100644 --- a/include/zenkit-capi/MultiResolutionMesh.h +++ b/include/zenkit-capi/MultiResolutionMesh.h @@ -14,8 +14,6 @@ using ZkMultiResolutionMesh = zenkit::MultiResolutionMesh; using ZkSubMesh = zenkit::SubMesh; using ZkMeshTriangle = zenkit::MeshTriangle; -using ZkMeshWedge = zenkit::MeshWedge; -using ZkMeshPlane = zenkit::MeshPlane; using ZkMeshTriangleEdge = zenkit::MeshTriangleEdge; using ZkMeshEdge = zenkit::MeshEdge; @@ -28,34 +26,52 @@ typedef struct { } ZkMeshTriangle; typedef struct { + uint16_t edges[3]; +} ZkMeshTriangleEdge; + +typedef struct { + uint16_t edges[2]; +} ZkMeshEdge; +#endif + +typedef struct ZkInternal_MeshWedge { ZkVec3f normal; ZkVec2f texture; uint16_t index; + +#ifdef __cplusplus + ZkInternal_MeshWedge() : normal(), texture(), index(0) {} + ZkInternal_MeshWedge(zenkit::MeshWedge const& v) : normal(v.normal), texture(v.texture), index(v.index) {} +#endif } ZkMeshWedge; -typedef struct { +typedef struct ZkInternal_MeshPlane { float distance; ZkVec3f normal; -} ZkMeshPlane; - -typedef struct { - uint16_t edges[3]; -} ZkMeshTriangleEdge; -typedef struct { - uint16_t edges[2]; -} ZkMeshEdge; +#ifdef __cplusplus + ZkInternal_MeshPlane() : distance(0), normal() {} + ZkInternal_MeshPlane(zenkit::MeshPlane const& v) : distance(v.distance), normal(v.normal) {} #endif +} ZkMeshPlane; typedef ZkBool (*ZkSubMeshEnumerator)(void*, ZkSubMesh const*); +typedef ZkBool (*ZkMeshWedgeEnumerator)(void*, ZkMeshWedge*); +typedef ZkBool (*ZkMeshPlaneEnumerator)(void*, ZkMeshPlane*); ZKC_API ZkMultiResolutionMesh* ZkMultiResolutionMesh_load(ZkRead* buf); ZKC_API ZkMultiResolutionMesh* ZkMultiResolutionMesh_loadPath(ZkString path); ZKC_API ZkMultiResolutionMesh* ZkMultiResolutionMesh_loadVfs(ZkVfs* vfs, ZkString name); ZKC_API void ZkMultiResolutionMesh_del(ZkMultiResolutionMesh* slf); -ZKC_API ZkVec3f const* ZkMultiResolutionMesh_getPositions(ZkMultiResolutionMesh const* slf, ZkSize* count); -ZKC_API ZkVec3f const* ZkMultiResolutionMesh_getNormals(ZkMultiResolutionMesh const* slf, ZkSize* count); +ZKC_API ZkSize ZkMultiResolutionMesh_getPositionCount(ZkMultiResolutionMesh const* slf); +ZKC_API ZkVec3f ZkMultiResolutionMesh_getPosition(ZkMultiResolutionMesh const* slf, ZkSize i); +ZKC_API void +ZkMultiResolutionMesh_enumeratePositions(ZkMultiResolutionMesh const* slf, ZkVec3fEnumerator cb, void* ctx); + +ZKC_API ZkSize ZkMultiResolutionMesh_getNormalCount(ZkMultiResolutionMesh const* slf); +ZKC_API ZkVec3f ZkMultiResolutionMesh_getNormal(ZkMultiResolutionMesh const* slf, ZkSize i); +ZKC_API void ZkMultiResolutionMesh_enumerateNormals(ZkMultiResolutionMesh const* slf, ZkVec3fEnumerator cb, void* ctx); ZKC_API ZkSize ZkMultiResolutionMesh_getSubMeshCount(ZkMultiResolutionMesh const* slf); ZKC_API ZkSubMesh const* ZkMultiResolutionMesh_getSubMesh(ZkMultiResolutionMesh const* slf, ZkSize i); @@ -73,10 +89,18 @@ ZKC_API ZkOrientedBoundingBox const* ZkMultiResolutionMesh_getOrientedBbox(ZkMul ZKC_API ZkMaterial const* ZkSubMesh_getMaterial(ZkSubMesh const* slf); ZKC_API ZkMeshTriangle const* ZkSubMesh_getTriangles(ZkSubMesh const* slf, ZkSize* count); -ZKC_API ZkMeshWedge const* ZkSubMesh_getWedges(ZkSubMesh const* slf, ZkSize* count); + +ZKC_API ZkSize ZkSubMesh_getWedgeCount(ZkSubMesh const* slf); +ZKC_API ZkMeshWedge ZkSubMesh_getWedge(ZkSubMesh const* slf, ZkSize i); +ZKC_API void ZkSubMesh_enumerateWedges(ZkSubMesh const* slf, ZkMeshWedgeEnumerator cb, void* ctx); + ZKC_API float const* ZkSubMesh_getColors(ZkSubMesh const* slf, ZkSize* count); ZKC_API uint16_t const* ZkSubMesh_getTrianglePlaneIndices(ZkSubMesh const* slf, ZkSize* count); -ZKC_API ZkMeshPlane const* ZkSubMesh_getTrianglePlanes(ZkSubMesh const* slf, ZkSize* count); + +ZKC_API ZkSize ZkSubMesh_getTrianglePlaneCount(ZkSubMesh const* slf); +ZKC_API ZkMeshPlane ZkSubMesh_getTrianglePlane(ZkSubMesh const* slf, ZkSize i); +ZKC_API void ZkSubMesh_enumerateTrianglePlanes(ZkSubMesh const* slf, ZkMeshPlaneEnumerator cb, void* ctx); + ZKC_API ZkMeshTriangleEdge const* ZkSubMesh_getTriangleEdges(ZkSubMesh const* slf, ZkSize* count); ZKC_API ZkMeshEdge const* ZkSubMesh_getEdges(ZkSubMesh const* slf, ZkSize* count); ZKC_API float const* ZkSubMesh_getEdgeScores(ZkSubMesh const* slf, ZkSize* count); diff --git a/include/zenkit-capi/SoftSkinMesh.h b/include/zenkit-capi/SoftSkinMesh.h index 97c248e..c16e946 100644 --- a/include/zenkit-capi/SoftSkinMesh.h +++ b/include/zenkit-capi/SoftSkinMesh.h @@ -4,37 +4,57 @@ #include "Date.h" #include "Library.h" #include "MultiResolutionMesh.h" +#include "SoftSkinMesh.h" #include "Vector.h" #ifdef __cplusplus #include using ZkSoftSkinMesh = zenkit::SoftSkinMesh; -using ZkSoftSkinWedgeNormal = zenkit::SoftSkinWedgeNormal; -using ZkSoftSkinWeightEntry = zenkit::SoftSkinWeightEntry; #else typedef struct ZkInternal_SoftSkinMesh ZkSoftSkinMesh; +#endif -typedef struct { +typedef struct ZkInternal_SoftSkinWedgeNormal { ZkVec3f normal; uint32_t index; + +#ifdef __cplusplus + ZkInternal_SoftSkinWedgeNormal() : normal(), index(0) {} + ZkInternal_SoftSkinWedgeNormal(zenkit::SoftSkinWedgeNormal const& v) : normal(v.normal), index(v.index) {} +#endif } ZkSoftSkinWedgeNormal; -typedef struct { +typedef struct ZkInternal_SoftSkinWeightEntry { float weight; ZkVec3f position; uint8_t node_index; -} ZkSoftSkinWeightEntry; + +#ifdef __cplusplus + ZkInternal_SoftSkinWeightEntry() : weight(0), position(), node_index(0) {} + ZkInternal_SoftSkinWeightEntry(zenkit::SoftSkinWeightEntry const& v) + : weight(v.weight), position(v.position), node_index(v.node_index) {} #endif +} ZkSoftSkinWeightEntry; typedef ZkBool (*ZkSoftSkinMeshEnumerator)(void* ctx, ZkSoftSkinMesh const* mesh); -typedef ZkBool (*ZkSoftSkinWeightEnumerator)(void* ctx, ZkSoftSkinWeightEntry const* entry, ZkSize count); +typedef ZkBool (*ZkSoftSkinWeightEnumerator)(void* ctx, ZkSoftSkinWeightEntry* entry); +typedef ZkBool (*ZkSoftSkinWedgeNormalEnumerator)(void* ctx, ZkSoftSkinWedgeNormal normal); ZKC_API ZkSize ZkSoftSkinMesh_getNodeCount(ZkSoftSkinMesh const* slf); ZKC_API ZkMultiResolutionMesh const* ZkSoftSkinMesh_getMesh(ZkSoftSkinMesh const* slf); ZKC_API ZkOrientedBoundingBox const* ZkSoftSkinMesh_getBbox(ZkSoftSkinMesh const* slf, ZkSize node); ZKC_API void ZkSoftSkinMesh_enumerateBoundingBoxes(ZkSoftSkinMesh const* slf, ZkOrientedBoundingBoxEnumerator cb, void* ctx); -ZKC_API ZkSoftSkinWeightEntry const* ZkSoftSkinMesh_getWeights(ZkSoftSkinMesh const* slf, ZkSize node, ZkSize* count); -ZKC_API void ZkSoftSkinMesh_enumerateWeights(ZkSoftSkinMesh const* slf, ZkSoftSkinWeightEnumerator cb, void* ctx); -ZKC_API ZkSoftSkinWedgeNormal const* ZkSoftSkinMesh_getWedgeNormals(ZkSoftSkinMesh const* slf, ZkSize* count); + +ZKC_API ZkSize ZkSoftSkinMesh_getWeightTotal(ZkSoftSkinMesh const* slf); +ZKC_API ZkSize ZkSoftSkinMesh_getWeightCount(ZkSoftSkinMesh const* slf, ZkSize node); +ZKC_API ZkSoftSkinWeightEntry ZkSoftSkinMesh_getWeight(ZkSoftSkinMesh const* slf, ZkSize node, ZkSize i); +ZKC_API void +ZkSoftSkinMesh_enumerateWeights(ZkSoftSkinMesh const* slf, ZkSize node, ZkSoftSkinWeightEnumerator cb, void* ctx); + +ZKC_API ZkSize ZkSoftSkinMesh_getWedgeNormalCount(ZkSoftSkinMesh const* slf); +ZKC_API ZkSoftSkinWedgeNormal ZkSoftSkinMesh_getWedgeNormal(ZkSoftSkinMesh const* slf, ZkSize i); +ZKC_API void +ZkSoftSkinMesh_enumerateWedgeNormals(ZkSoftSkinMesh const* slf, ZkSoftSkinWedgeNormalEnumerator cb, void* ctx); + ZKC_API int32_t const* ZkSoftSkinMesh_getNodes(ZkSoftSkinMesh const* slf, ZkSize* count); diff --git a/include/zenkit-capi/Texture.h b/include/zenkit-capi/Texture.h index ed79ca5..95a197f 100644 --- a/include/zenkit-capi/Texture.h +++ b/include/zenkit-capi/Texture.h @@ -46,7 +46,11 @@ ZKC_API uint32_t ZkTexture_getWidthRef(ZkTexture const* slf); ZKC_API uint32_t ZkTexture_getHeightRef(ZkTexture const* slf); ZKC_API uint32_t ZkTexture_getMipmapCount(ZkTexture const* slf); ZKC_API uint32_t ZkTexture_getAverageColor(ZkTexture const* slf); -ZKC_API ZkColorArgb const* ZkTexture_getPalette(ZkTexture const* slf, ZkSize* size); + +ZKC_API ZkSize ZkTexture_getPaletteSize(ZkTexture const* slf); +ZKC_API ZkColor ZkTexture_getPaletteItem(ZkTexture const* slf, ZkSize i); +ZKC_API void ZkTexture_enumeratePaletteItems(ZkTexture const* slf, ZkColorEnumerator cb, void* ctx); + ZKC_API uint8_t const* ZkTexture_getMipmapRaw(ZkTexture const* slf, ZkSize level, ZkSize* size); ZKC_API ZkSize ZkTexture_getMipmapRgba(ZkTexture const* slf, ZkSize level, uint8_t* buf, ZkSize size); diff --git a/include/zenkit-capi/Vector.h b/include/zenkit-capi/Vector.h index 36be2e7..ea52cef 100644 --- a/include/zenkit-capi/Vector.h +++ b/include/zenkit-capi/Vector.h @@ -7,39 +7,78 @@ #include #include #include - #include + #include #include +#endif -using ZkVec2f = glm::vec2; -using ZkVec3f = glm::vec3; -using ZkVec4f = glm::vec4; -using ZkQuat = glm::quat; -using ZkColor = glm::u8vec4; -using ZkColorArgb = zenkit::ColorARGB; -#else - -typedef struct { +typedef struct ZkInternal_Vec2 { float x, y; + +#ifdef __cplusplus + ZkInternal_Vec2() : x(0), y(0) {} + ZkInternal_Vec2(glm::vec2 v) : x(v.x), y(v.y) {} + + operator glm::vec2() const { + return {x, y}; + } +#endif } ZkVec2f; -typedef struct { +typedef struct ZkInternal_Vec3 { float x, y, z; + +#ifdef __cplusplus + ZkInternal_Vec3() : x(0), y(0), z(0) {} + ZkInternal_Vec3(glm::vec3 v) : x(v.x), y(v.y), z(v.z) {} + + operator glm::vec3() const { + return {x, y, z}; + } +#endif } ZkVec3f; -typedef struct { +typedef struct ZkInternal_Vec4 { float x, y, z, w; + +#ifdef __cplusplus + ZkInternal_Vec4() : x(0), y(0), z(0), w(0) {} + ZkInternal_Vec4(glm::vec4 v) : x(v.x), y(v.y), z(v.z), w(v.w) {} + + operator glm::vec4() const { + return {x, y, z, w}; + } +#endif } ZkVec4f; -typedef struct { +typedef struct ZkInternal_Quat { float x, y, z, w; + +#ifdef __cplusplus + ZkInternal_Quat() : x(0), y(0), z(0), w(0) {} + ZkInternal_Quat(glm::quat v) : x(v.x), y(v.y), z(v.z), w(v.w) {} + + operator glm::quat() const { + return {w, x, y, z}; + } +#endif } ZkQuat; -typedef struct { +typedef struct ZkInternal_Color { uint8_t r, g, b, a; -} ZkColor; -typedef struct { - uint8_t a, r, g, b; -} ZkColorArgb; +#ifdef __cplusplus + ZkInternal_Color() : r(0), g(0), b(0), a(255) {} + ZkInternal_Color(glm::u8vec4 v) : r(v.r), g(v.g), b(v.b), a(v.a) {} + ZkInternal_Color(zenkit::ColorARGB v) : r(v.r), g(v.g), b(v.b), a(v.a) {} + operator glm::u8vec4() const { + return {r, g, b, a}; + } #endif +} ZkColor; + +typedef ZkBool (*ZkVec2fEnumerator)(void* ctx, ZkVec2f v); +typedef ZkBool (*ZkVec3fEnumerator)(void* ctx, ZkVec3f v); +typedef ZkBool (*ZkVec4fEnumerator)(void* ctx, ZkVec4f v); +typedef ZkBool (*ZkQuatEnumerator)(void* ctx, ZkQuat v); +typedef ZkBool (*ZkColorEnumerator)(void* ctx, ZkColor v); diff --git a/include/zenkit-capi/vobs/Light.h b/include/zenkit-capi/vobs/Light.h index cae77c5..90dc088 100644 --- a/include/zenkit-capi/vobs/Light.h +++ b/include/zenkit-capi/vobs/Light.h @@ -55,7 +55,11 @@ ZKC_API float ZkLightPreset_getRangeAnimationFps(ZkLightPreset const* slf); ZKC_API void ZkLightPreset_setRangeAnimationFps(ZkLightPreset* slf, float rangeAnimationFps); ZKC_API ZkBool ZkLightPreset_getRangeAnimationSmooth(ZkLightPreset const* slf); ZKC_API void ZkLightPreset_setRangeAnimationSmooth(ZkLightPreset* slf, ZkBool rangeAnimationSmooth); -ZKC_API ZkColor const* ZkLightPreset_getColorAnimationList(ZkLightPreset const* slf, ZkSize* count); + +ZKC_API ZkSize ZkLightPreset_getColorAnimationCount(ZkLightPreset const* slf); +ZKC_API ZkColor ZkLightPreset_getColorAnimationItem(ZkLightPreset const* slf, ZkSize i); +ZKC_API void ZkLightPreset_enumerateColorAnimationItems(ZkLightPreset const* slf, ZkColorEnumerator cb, void* ctx); + ZKC_API void ZkLightPreset_setColorAnimationList(ZkLightPreset* slf, ZkColor const* list, ZkSize count); ZKC_API float ZkLightPreset_getColorAnimationFps(ZkLightPreset const* slf); ZKC_API void ZkLightPreset_setColorAnimationFps(ZkLightPreset* slf, float colorAnimationFps); @@ -92,7 +96,11 @@ ZKC_API float ZkLight_getRangeAnimationFps(ZkLight const* slf); ZKC_API void ZkLight_setRangeAnimationFps(ZkLight* slf, float rangeAnimationFps); ZKC_API ZkBool ZkLight_getRangeAnimationSmooth(ZkLight const* slf); ZKC_API void ZkLight_setRangeAnimationSmooth(ZkLight* slf, ZkBool rangeAnimationSmooth); -ZKC_API ZkColor const* ZkLight_getColorAnimationList(ZkLight const* slf, ZkSize* count); + +ZKC_API ZkSize ZkLight_getColorAnimationCount(ZkLight const* slf); +ZKC_API ZkColor ZkLight_getColorAnimationItem(ZkLight const* slf, ZkSize i); +ZKC_API void ZkLight_enumerateColorAnimationItems(ZkLight const* slf, ZkColorEnumerator cb, void* ctx); + ZKC_API void ZkLight_setColorAnimationList(ZkLight* slf, ZkColor const* list, ZkSize count); ZKC_API float ZkLight_getColorAnimationFps(ZkLight const* slf); ZKC_API void ZkLight_setColorAnimationFps(ZkLight* slf, float colorAnimationFps); diff --git a/include/zenkit-capi/vobs/Trigger.h b/include/zenkit-capi/vobs/Trigger.h index 3a24ed1..1d8d05b 100644 --- a/include/zenkit-capi/vobs/Trigger.h +++ b/include/zenkit-capi/vobs/Trigger.h @@ -96,7 +96,11 @@ ZKC_API ZkMoverLerpType ZkMover_getLerpType(ZkMover const* slf); ZKC_API void ZkMover_setLerpType(ZkMover* slf, ZkMoverLerpType lerpType); ZKC_API ZkMoverSpeedType ZkMover_getSpeedType(ZkMover const* slf); ZKC_API void ZkMover_setSpeedType(ZkMover* slf, ZkMoverSpeedType speedType); -ZKC_API ZkAnimationSample const* ZkMover_getKeyframes(ZkMover const* slf, ZkSize* count); + +ZKC_API ZkSize ZkMover_getKeyframeCount(ZkMover const* slf); +ZKC_API ZkAnimationSample ZkMover_getKeyframe(ZkMover const* slf, ZkSize i); +ZKC_API void ZkMover_enumerateKeyframes(ZkMover const* slf, ZkAnimationSampleEnumerator cb, void* ctx); + ZKC_API ZkString ZkMover_getSfxOpenStart(ZkMover const* slf); ZKC_API void ZkMover_setSfxOpenStart(ZkMover* slf, ZkString sfxOpenStart); ZKC_API ZkString ZkMover_getSfxOpenEnd(ZkMover const* slf); diff --git a/include/zenkit-capi/world/BspTree.h b/include/zenkit-capi/world/BspTree.h index a9138dc..5377125 100644 --- a/include/zenkit-capi/world/BspTree.h +++ b/include/zenkit-capi/world/BspTree.h @@ -8,13 +8,13 @@ #ifdef __cplusplus #include using ZkBspTree = zenkit::BspTree; -using ZkBspNode = zenkit::BspNode; using ZkBspSector = zenkit::BspSector; #else typedef struct ZkInternal_BspTree ZkBspTree; typedef struct ZkInternal_BspSector ZkBspSector; +#endif -typedef struct { +typedef struct ZkInternal_BspNode { ZkVec4f plane; ZkAxisAlignedBoundingBox bbox; uint32_t polygonIndex; @@ -23,23 +23,39 @@ typedef struct { int32_t frontIndex; int32_t backIndex; int32_t parentIndex; -} ZkBspNode; + +#ifdef __cplusplus + ZkInternal_BspNode() + : plane(), bbox(), polygonIndex(0), polygonCount(0), frontIndex(-1), backIndex(-1), parentIndex(-1) {} + + ZkInternal_BspNode(zenkit::BspNode const& node) + : plane(node.plane), bbox(node.bbox), polygonIndex(node.polygon_index), polygonCount(node.polygon_count), + frontIndex(node.front_index), backIndex(node.back_index), parentIndex(node.parent_index) {} #endif +} ZkBspNode; typedef enum { ZkBspTreeType_INDOOR = 0, ZkBspTreeType_OUTDOOR = 1, } ZkBspTreeType; -typedef ZkByte (*ZkBspSectorEnumerator)(void* ctx, ZkBspSector const* sector); +typedef ZkBool (*ZkBspSectorEnumerator)(void* ctx, ZkBspSector const* sector); +typedef ZkBool (*ZkBspNodeEnumerator)(void* ctx, ZkBspNode* node); ZKC_API ZkBspTreeType ZkBspTree_getType(ZkBspTree const* slf); ZKC_API uint32_t const* ZkBspTree_getPolygonIndices(ZkBspTree const* slf, ZkSize* count); ZKC_API uint32_t const* ZkBspTree_getLeafPolygonIndices(ZkBspTree const* slf, ZkSize* count); ZKC_API uint32_t const* ZkBspTree_getPortalPolygonIndices(ZkBspTree const* slf, ZkSize* count); -ZKC_API ZkVec3f const* ZkBspTree_getLightPoints(ZkBspTree const* slf, ZkSize* count); + +ZKC_API ZkSize ZkBspTree_getLightPointCount(ZkBspTree const* slf); +ZKC_API ZkVec3f ZkBspTree_getLightPoint(ZkBspTree const* slf, ZkSize i); +ZKC_API void ZkBspTree_enumerateLightPoints(ZkBspTree const* slf, ZkVec3fEnumerator cb, void* ctx); + ZKC_API uint64_t const* ZkBspTree_getLeafNodeIndices(ZkBspTree const* slf, ZkSize* count); -ZKC_API ZkBspNode const* ZkBspTree_getNodes(ZkBspTree const* slf, ZkSize* count); + +ZKC_API ZkSize ZkBspTree_getNodeCount(ZkBspTree const* slf); +ZKC_API ZkBspNode ZkBspTree_getNode(ZkBspTree const* slf, ZkSize i); +ZKC_API void ZkBspTree_enumerateNodes(ZkBspTree const* slf, ZkBspNodeEnumerator cb, void* ctx); ZKC_API ZkSize ZkBspTree_getSectorCount(ZkBspTree const* slf); ZKC_API ZkBspSector const* ZkBspTree_getSector(ZkBspTree const* slf, ZkSize i); diff --git a/src/Font.cc b/src/Font.cc index 76e3734..2b3e029 100644 --- a/src/Font.cc +++ b/src/Font.cc @@ -93,16 +93,16 @@ ZkFontGlyph ZkFont_getGlyph(ZkFont const* slf, ZkSize i) { ZKC_TRACE_FN(); if (slf == nullptr) { ZKC_LOG_WARN_NULL("ZkFont_getGlyph"); - return {0, ZkVec2f {0, 0}, ZkVec2f {0, 0}}; + return {0, {}, {}}; } if (i >= slf->glyphs.size()) { ZKC_LOG_ERROR("ZkFont_getGlyph() failed: index out of range"); - return {0, ZkVec2f {0, 0}, ZkVec2f {0, 0}}; + return {0, {}, {}}; } auto& glyph = slf->glyphs[i]; - return {glyph.width, ZkVec2f {glyph.uv[0]}, ZkVec2f {glyph.uv[1]}}; + return {glyph.width, glyph.uv[0], glyph.uv[1]}; } void ZkFont_enumerateGlyphs(ZkFont const* slf, ZkFontGlyphEnumerator cb, void* ctx) { @@ -112,7 +112,7 @@ void ZkFont_enumerateGlyphs(ZkFont const* slf, ZkFontGlyphEnumerator cb, void* c return; } - ZkFontGlyph fg {0, ZkVec2f {0, 0}, ZkVec2f {0, 0}}; + ZkFontGlyph fg {0, {}, {}}; for (auto& glyph : slf->glyphs) { fg.width = glyph.width; fg.topLeft = glyph.uv[0]; diff --git a/src/Internal.hh b/src/Internal.hh index 9406efc..61468e7 100644 --- a/src/Internal.hh +++ b/src/Internal.hh @@ -179,4 +179,4 @@ inline bool zk_any_nullptr(T*... args) { } \ } while (false) -#define ZKC_TRACE_FN() ZKC_LOG_TRACE("%s()", __func__)\ +#define ZKC_TRACE_FN() ZKC_LOG_TRACE("%s()", __func__) diff --git a/src/Mesh.cc b/src/Mesh.cc index 77ac558..a50e345 100644 --- a/src/Mesh.cc +++ b/src/Mesh.cc @@ -135,26 +135,50 @@ void ZkMesh_enumerateMaterials(ZkMesh const* slf, ZkMaterialEnumerator cb, void* } } -ZkVec3f const* ZkMesh_getPositions(ZkMesh const* slf, ZkSize* count) { +ZkSize ZkMesh_getPositionCount(ZkMesh const* slf) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkMesh_getPositions"); - return nullptr; - } + ZKC_CHECK_NULL(slf); + return slf->vertices.size(); +} - *count = slf->vertices.size(); - return slf->vertices.data(); +ZkVec3f ZkMesh_getPosition(ZkMesh const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->vertices, i); + return slf->vertices[i]; } -ZkVertex const* ZkMesh_getVertices(ZkMesh const* slf, ZkSize* count) { +void ZkMesh_enumeratePositions(ZkMesh const* slf, ZkVec3fEnumerator cb, void* ctx) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkMesh_getVertices"); - return nullptr; + ZKC_CHECK_NULLV(slf, cb); + + for (auto& v : slf->vertices) { + if (cb(ctx, v)) break; } +} - *count = slf->features.size(); - return slf->features.data(); +ZkSize ZkMesh_getVertexCount(ZkMesh const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return slf->features.size(); +} + +ZkVertex ZkMesh_getVertex(ZkMesh const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->vertices, i); + return slf->features[i]; +} + +void ZkMesh_enumerateVertices(ZkMesh const* slf, ZkVertexEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + ZkVertex cVertex; + for (auto& v : slf->features) { + cVertex = v; + if (cb(ctx, &cVertex)) break; + } } ZkSize ZkMesh_getLightMapCount(ZkMesh const* slf) { diff --git a/src/ModelAnimation.cc b/src/ModelAnimation.cc index 11d470a..176f6d3 100644 --- a/src/ModelAnimation.cc +++ b/src/ModelAnimation.cc @@ -133,7 +133,7 @@ ZkAxisAlignedBoundingBox ZkModelAnimation_getBbox(ZkModelAnimation const* slf) { ZKC_TRACE_FN(); if (slf == nullptr) { ZKC_LOG_WARN_NULL("ZkModelAnimation_getBbox"); - return {ZkVec3f {0, 0, 0}, ZkVec3f {0, 0, 0}}; + return {}; } return slf->bbox; diff --git a/src/MorphMesh.cc b/src/MorphMesh.cc index b0b4100..a8593de 100644 --- a/src/MorphMesh.cc +++ b/src/MorphMesh.cc @@ -79,15 +79,26 @@ ZkMultiResolutionMesh const* ZkMorphMesh_getMesh(ZkMorphMesh const* slf) { return &slf->mesh; } -ZkVec3f const* ZkMorphMesh_getMorphPositions(ZkMorphMesh const* slf, ZkSize* count) { +ZkSize ZkMorphMesh_getMorphPositionCount(ZkMorphMesh const* slf) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkMorphMesh_getMorphPositions"); - return nullptr; - } + ZKC_CHECK_NULL(slf); + return slf->morph_positions.size(); +} + +ZkVec3f ZkMorphMesh_getMorphPosition(ZkMorphMesh const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->morph_positions, i); + return slf->morph_positions[i]; +} - *count = slf->morph_positions.size(); - return slf->morph_positions.data(); +void ZkMorphMesh_enumerateMorphPositions(ZkMorphMesh const* slf, ZkVec3fEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + for (auto& v : slf->morph_positions) { + if (cb(ctx, v)) break; + } } ZkSize ZkMorphMesh_getAnimationCount(ZkMorphMesh const* slf) { @@ -255,15 +266,26 @@ uint32_t const* ZkMorphAnimation_getVertices(ZkMorphAnimation const* slf, ZkSize return slf->vertices.data(); } -ZkVec3f const* ZkMorphAnimation_getSamples(ZkMorphAnimation const* slf, ZkSize* count) { +ZkSize ZkMorphAnimation_getSampleCount(ZkMorphAnimation const* slf) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkMorphAnimation_getSamples"); - return nullptr; - } + ZKC_CHECK_NULL(slf); + return slf->samples.size(); +} + +ZkVec3f ZkMorphAnimation_getSample(ZkMorphAnimation const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->samples, i); + return slf->samples[i]; +} - *count = slf->samples.size(); - return slf->samples.data(); +void ZkMorphAnimation_enumerateSamples(ZkMorphAnimation const* slf, ZkVec3fEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + for (auto& v : slf->samples) { + if (cb(ctx, v)) break; + } } ZkDate ZkMorphSource_getFileDate(ZkMorphSource const* slf) { diff --git a/src/MultiResolutionMesh.cc b/src/MultiResolutionMesh.cc index 3ef0968..8a3a0ae 100644 --- a/src/MultiResolutionMesh.cc +++ b/src/MultiResolutionMesh.cc @@ -59,26 +59,48 @@ void ZkMultiResolutionMesh_del(ZkMultiResolutionMesh* slf) { delete slf; } -ZkVec3f const* ZkMultiResolutionMesh_getPositions(ZkMultiResolutionMesh const* slf, ZkSize* count) { +ZkSize ZkMultiResolutionMesh_getPositionCount(ZkMultiResolutionMesh const* slf) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkMultiResolutionMesh_getPositions"); - return nullptr; - } + ZKC_CHECK_NULL(slf); + return slf->positions.size(); +} - *count = slf->positions.size(); - return slf->positions.data(); +ZkVec3f ZkMultiResolutionMesh_getPosition(ZkMultiResolutionMesh const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->positions, i); + return slf->positions[i]; } -ZkVec3f const* ZkMultiResolutionMesh_getNormals(ZkMultiResolutionMesh const* slf, ZkSize* count) { +void ZkMultiResolutionMesh_enumeratePositions(ZkMultiResolutionMesh const* slf, ZkVec3fEnumerator cb, void* ctx) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkMultiResolutionMesh_getNormals"); - return nullptr; + ZKC_CHECK_NULLV(slf, cb); + + for (auto& v : slf->positions) { + if (cb(ctx, v)) break; } +} - *count = slf->normals.size(); - return slf->normals.data(); +ZkSize ZkMultiResolutionMesh_getNormalCount(ZkMultiResolutionMesh const* slf) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + return slf->normals.size(); +} + +ZkVec3f ZkMultiResolutionMesh_getNormal(ZkMultiResolutionMesh const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->normals, i); + return slf->normals[i]; +} + +void ZkMultiResolutionMesh_enumerateNormals(ZkMultiResolutionMesh const* slf, ZkVec3fEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + for (auto& v : slf->normals) { + if (cb(ctx, v)) break; + } } ZkSize ZkMultiResolutionMesh_getSubMeshCount(ZkMultiResolutionMesh const* slf) { @@ -206,15 +228,28 @@ ZkMeshTriangle const* ZkSubMesh_getTriangles(ZkSubMesh const* slf, ZkSize* count return slf->triangles.data(); } -ZkMeshWedge const* ZkSubMesh_getWedges(ZkSubMesh const* slf, ZkSize* count) { +ZkSize ZkSubMesh_getWedgeCount(ZkSubMesh const* slf) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkSubMesh_getWedges"); - return nullptr; - } + ZKC_CHECK_NULL(slf); + return slf->wedges.size(); +} + +ZkMeshWedge ZkSubMesh_getWedge(ZkSubMesh const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->wedges, i); + return slf->wedges[i]; +} + +void ZkSubMesh_enumerateWedges(ZkSubMesh const* slf, ZkMeshWedgeEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); - *count = slf->wedges.size(); - return slf->wedges.data(); + ZkMeshWedge cWedge; + for (auto& v : slf->wedges) { + cWedge = v; + if (cb(ctx, &cWedge)) break; + } } float const* ZkSubMesh_getColors(ZkSubMesh const* slf, ZkSize* count) { @@ -239,15 +274,28 @@ uint16_t const* ZkSubMesh_getTrianglePlaneIndices(ZkSubMesh const* slf, ZkSize* return slf->triangle_plane_indices.data(); } -ZkMeshPlane const* ZkSubMesh_getTrianglePlanes(ZkSubMesh const* slf, ZkSize* count) { +ZkSize ZkSubMesh_getTrianglePlaneCount(ZkSubMesh const* slf) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkSubMesh_getTrianglePlanes"); - return nullptr; - } + ZKC_CHECK_NULL(slf); + return slf->triangle_planes.size(); +} - *count = slf->triangle_planes.size(); - return slf->triangle_planes.data(); +ZkMeshPlane ZkSubMesh_getTrianglePlane(ZkSubMesh const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->triangle_planes, i); + return slf->triangle_planes[i]; +} + +void ZkSubMesh_enumerateTrianglePlanes(ZkSubMesh const* slf, ZkMeshPlaneEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + ZkMeshPlane cPlane; + for (auto& v : slf->triangle_planes) { + cPlane = v; + if (cb(ctx, &cPlane)) break; + } } ZkMeshTriangleEdge const* ZkSubMesh_getTriangleEdges(ZkSubMesh const* slf, ZkSize* count) { diff --git a/src/SoftSkinMesh.cc b/src/SoftSkinMesh.cc index 69e78eb..e12bfa9 100644 --- a/src/SoftSkinMesh.cc +++ b/src/SoftSkinMesh.cc @@ -51,43 +51,59 @@ void ZkSoftSkinMesh_enumerateBoundingBoxes(ZkSoftSkinMesh const* slf, ZkOriented } } -ZkSoftSkinWeightEntry const* ZkSoftSkinMesh_getWeights(ZkSoftSkinMesh const* slf, ZkSize node, ZkSize* count) { +ZkSize ZkSoftSkinMesh_getWeightTotal(ZkSoftSkinMesh const* slf) { ZKC_TRACE_FN(); - if (slf == nullptr) { - ZKC_LOG_WARN_NULL("ZkSoftSkinMesh_getWeights"); - return nullptr; - } + ZKC_CHECK_NULL(slf); + return slf->weights.size(); +} - if (node >= slf->weights.size()) { - ZKC_LOG_ERROR("ZkSoftSkinMesh_getWeights() failed: index out of range"); - return nullptr; - } +ZkSize ZkSoftSkinMesh_getWeightCount(ZkSoftSkinMesh const* slf, ZkSize node) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->weights, node); + return slf->weights[node].size(); +} - *count = slf->weights[node].size(); - return slf->weights[node].data(); +ZkSoftSkinWeightEntry ZkSoftSkinMesh_getWeight(ZkSoftSkinMesh const* slf, ZkSize node, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->weights, node); + ZKC_CHECK_LEN(slf->weights[node], i); + return slf->weights[node][i]; } -void ZkSoftSkinMesh_enumerateWeights(ZkSoftSkinMesh const* slf, ZkSoftSkinWeightEnumerator cb, void* ctx) { +void ZkSoftSkinMesh_enumerateWeights(ZkSoftSkinMesh const* slf, ZkSize node, ZkSoftSkinWeightEnumerator cb, void* ctx) { ZKC_TRACE_FN(); - if (slf == nullptr || cb == nullptr) { - ZKC_LOG_WARN_NULL("ZkSoftSkinMesh_enumerateWeights"); - return; - } + ZKC_CHECK_NULLV(slf, cb); + ZKC_CHECK_LENV(slf->weights, node); - for (auto& weights : slf->weights) { - if (cb(ctx, weights.data(), weights.size())) break; + ZkSoftSkinWeightEntry cWeight; + for (auto& w : slf->weights[node]) { + cWeight = w; + if (cb(ctx, &cWeight)) break; } } -ZkSoftSkinWedgeNormal const* ZkSoftSkinMesh_getWedgeNormals(ZkSoftSkinMesh const* slf, ZkSize* count) { +ZkSize ZkSoftSkinMesh_getWedgeNormalCount(ZkSoftSkinMesh const* slf) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkSoftSkinMesh_getWedgeNormals"); - return nullptr; - } + ZKC_CHECK_NULL(slf); + return slf->wedge_normals.size(); +} - *count = slf->weights.size(); - return slf->wedge_normals.data(); +ZkSoftSkinWedgeNormal ZkSoftSkinMesh_getWedgeNormal(ZkSoftSkinMesh const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->wedge_normals, i); + return slf->wedge_normals[i]; +} + +void ZkSoftSkinMesh_enumerateWedgeNormals(ZkSoftSkinMesh const* slf, ZkSoftSkinWedgeNormalEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + for (auto& n : slf->wedge_normals) { + if (cb(ctx, n)) break; + } } int32_t const* ZkSoftSkinMesh_getNodes(ZkSoftSkinMesh const* slf, ZkSize* count) { diff --git a/src/Texture.cc b/src/Texture.cc index b20c569..4e4621a 100644 --- a/src/Texture.cc +++ b/src/Texture.cc @@ -159,15 +159,26 @@ uint32_t ZkTexture_getAverageColor(ZkTexture const* slf) { return slf->average_color(); } -ZkColorArgb const* ZkTexture_getPalette(ZkTexture const* slf, ZkSize* size) { +ZkSize ZkTexture_getPaletteSize(ZkTexture const*) { ZKC_TRACE_FN(); - if (slf == nullptr || size == nullptr) { - ZKC_LOG_WARN_NULL("ZkTexture_getPalette"); - return nullptr; - } + return zenkit::ZTEX_PALETTE_ENTRIES; +} + +ZkColor ZkTexture_getPaletteItem(ZkTexture const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LENA(zenkit::ZTEX_PALETTE_ENTRIES, i); + return slf->palette()[i]; +} - *size = zenkit::ZTEX_PALETTE_ENTRIES; - return slf->palette(); +void ZkTexture_enumeratePaletteItems(ZkTexture const* slf, ZkColorEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + auto const* pal = slf->palette(); + for (int i = 0; i < zenkit::ZTEX_PALETTE_ENTRIES; ++i) { + if (cb(ctx, pal[i])) break; + } } uint8_t const* ZkTexture_getMipmapRaw(ZkTexture const* slf, ZkSize level, ZkSize* size) { diff --git a/src/vobs/Light.cc b/src/vobs/Light.cc index e1fd7be..cc20846 100644 --- a/src/vobs/Light.cc +++ b/src/vobs/Light.cc @@ -159,11 +159,26 @@ void ZkLightPreset_setRangeAnimationSmooth(ZkLightPreset* slf, ZkBool rangeAnima slf->range_animation_smooth = rangeAnimationSmooth; } -ZkColor const* ZkLightPreset_getColorAnimationList(ZkLightPreset const* slf, ZkSize* count) { +ZkSize ZkLightPreset_getColorAnimationCount(ZkLightPreset const* slf) { ZKC_TRACE_FN(); - ZKC_CHECK_NULL(slf, count); - *count = slf->color_animation_list.size(); - return slf->color_animation_list.data(); + ZKC_CHECK_NULL(slf); + return slf->color_animation_list.size(); +} + +ZkColor ZkLightPreset_getColorAnimationItem(ZkLightPreset const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->color_animation_list, i); + return slf->color_animation_list[i]; +} + +void ZkLightPreset_enumerateColorAnimationItems(ZkLightPreset const* slf, ZkColorEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + for (auto& i : slf->color_animation_list) { + if (cb(ctx, i)) break; + } } void ZkLightPreset_setColorAnimationList(ZkLightPreset* slf, ZkColor const* list, ZkSize count) { @@ -353,11 +368,26 @@ void ZkLight_setRangeAnimationSmooth(ZkLight* slf, ZkBool rangeAnimationSmooth) slf->range_animation_smooth = rangeAnimationSmooth; } -ZkColor const* ZkLight_getColorAnimationList(ZkLight const* slf, ZkSize* count) { +ZkSize ZkLight_getColorAnimationCount(ZkLight const* slf) { ZKC_TRACE_FN(); - ZKC_CHECK_NULL(slf, count); - *count = slf->color_animation_list.size(); - return slf->color_animation_list.data(); + ZKC_CHECK_NULL(slf); + return slf->color_animation_list.size(); +} + +ZkColor ZkLight_getColorAnimationItem(ZkLight const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->color_animation_list, i); + return slf->color_animation_list[i]; +} + +void ZkLight_enumerateColorAnimationItems(ZkLight const* slf, ZkColorEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + for (auto& i : slf->color_animation_list) { + if (cb(ctx, i)) break; + } } void ZkLight_setColorAnimationList(ZkLight* slf, ZkColor const* list, ZkSize count) { diff --git a/src/vobs/Trigger.cc b/src/vobs/Trigger.cc index 5f29f01..47f6be5 100644 --- a/src/vobs/Trigger.cc +++ b/src/vobs/Trigger.cc @@ -215,12 +215,28 @@ void ZkMover_setSpeedType(ZkMover* slf, ZkMoverSpeedType speedType) { slf->speed_mode = static_cast(speedType); } -ZkAnimationSample const* ZkMover_getKeyframes(ZkMover const* slf, ZkSize* count) { +ZkSize ZkMover_getKeyframeCount(ZkMover const* slf) { ZKC_TRACE_FN(); - ZKC_CHECK_NULL(slf, count); + ZKC_CHECK_NULL(slf); + return slf->keyframes.size(); +} + +ZkAnimationSample ZkMover_getKeyframe(ZkMover const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->keyframes, i); + return slf->keyframes[i]; +} - *count = slf->keyframes.size(); - return slf->keyframes.data(); +void ZkMover_enumerateKeyframes(ZkMover const* slf, ZkAnimationSampleEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + ZkAnimationSample sample; + for (auto& k : slf->keyframes) { + sample = k; + if (cb(ctx, &sample)) break; + } } ZkString ZkMover_getSfxOpenStart(ZkMover const* slf) { diff --git a/src/world/BspTree.cc b/src/world/BspTree.cc index 9033c65..e26f89f 100644 --- a/src/world/BspTree.cc +++ b/src/world/BspTree.cc @@ -47,15 +47,26 @@ uint32_t const* ZkBspTree_getPortalPolygonIndices(ZkBspTree const* slf, ZkSize* return slf->portal_polygon_indices.data(); } -ZkVec3f const* ZkBspTree_getLightPoints(ZkBspTree const* slf, ZkSize* count) { +ZkSize ZkBspTree_getLightPointCount(ZkBspTree const* slf) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkBspTree_getLightPoints"); - return nullptr; - } + ZKC_CHECK_NULL(slf); + return slf->light_points.size(); +} - *count = slf->light_points.size(); - return slf->light_points.data(); +ZkVec3f ZkBspTree_getLightPoint(ZkBspTree const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->light_points, i); + return slf->light_points[i]; +} + +void ZkBspTree_enumerateLightPoints(ZkBspTree const* slf, ZkVec3fEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); + + for (auto& point : slf->light_points) { + if (cb(ctx, point)) break; + } } uint64_t const* ZkBspTree_getLeafNodeIndices(ZkBspTree const* slf, ZkSize* count) { @@ -69,15 +80,29 @@ uint64_t const* ZkBspTree_getLeafNodeIndices(ZkBspTree const* slf, ZkSize* count return slf->leaf_node_indices.data(); } -ZkBspNode const* ZkBspTree_getNodes(ZkBspTree const* slf, ZkSize* count) { +ZkSize ZkBspTree_getNodeCount(ZkBspTree const* slf) { ZKC_TRACE_FN(); - if (slf == nullptr || count == nullptr) { - ZKC_LOG_WARN_NULL("ZkBspTree_getNodes"); - return nullptr; - } + ZKC_CHECK_NULL(slf); + return slf->nodes.size(); +} + +ZkBspNode ZkBspTree_getNode(ZkBspTree const* slf, ZkSize i) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULL(slf); + ZKC_CHECK_LEN(slf->nodes, i); + return slf->nodes[i]; +} + +void ZkBspTree_enumerateNodes(ZkBspTree const* slf, ZkBspNodeEnumerator cb, void* ctx) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, cb); - *count = slf->nodes.size(); - return slf->nodes.data(); + ZkBspNode cNode; + for (auto& node : slf->nodes) { + cNode = node; + + if (cb(ctx, &cNode)) break; + } } ZkSize ZkBspTree_getSectorCount(ZkBspTree const* slf) {