Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Get all mdm attachment keys via iterator.
Browse files Browse the repository at this point in the history
  • Loading branch information
JaXt0r committed Aug 27, 2023
1 parent 222b8cd commit b5d43c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/phoenix/cffi/ModelMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ PXC_API void pxMdmDestroy(PxModelMesh* mdm);

PXC_API uint32_t pxMdmGetMeshCount(PxModelMesh const* mdm);
PXC_API PxSoftSkinMesh const* pxMdmGetMesh(PxModelMesh const* mdm, uint32_t i);
PXC_API PxMultiResolutionMesh const* pxMdmGetAttachment(PxModelMesh const* mdm, char const* name);
PXC_API uint32_t pxMdmGetAttachmentCount(PxModelMesh const* mdm);
PXC_API char const* pxMdmGetAttachmentKey(PxModelMesh const* mdm, uint32_t index);
PXC_API PxMultiResolutionMesh const* pxMdmGetAttachmentValue(PxModelMesh const* mdm, char const* name);
PXC_API uint32_t pxMdmGetChecksum(PxModelMesh const* mdm);

PXC_API PxMultiResolutionMesh const* pxSsmGetMesh(PxSoftSkinMesh const* ssm);
Expand Down
21 changes: 19 additions & 2 deletions src/ModelMesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,28 @@ PxSoftSkinMesh const* pxMdmGetMesh(PxModelMesh const* mdm, uint32_t i) {
return &mdm->meshes[i];
}

PxMultiResolutionMesh const* pxMdmGetAttachment(PxModelMesh const* mdm, char const* name) {
uint32_t pxMdmGetAttachmentCount(PxModelMesh const* mdm) {
return mdm->attachments.size();
}

char const* pxMdmGetAttachmentKey(PxModelMesh const* mdm, uint32_t index) {
auto& attachments = mdm->attachments;
uint32_t currentIndex = 0;

for (auto i = attachments.begin(); i != attachments.end(); i++) {
if (currentIndex++ == index)
return i->first.c_str();
}

return nullptr;
}

PxMultiResolutionMesh const* pxMdmGetAttachmentValue(PxModelMesh const* mdm, char const* name) {
auto& attachments = mdm->attachments;
auto rv = attachments.find(name);
if (rv == attachments.end()) return nullptr;

if (rv == attachments.end())
return nullptr;

return &rv->second;
}
Expand Down

0 comments on commit b5d43c3

Please sign in to comment.