Introduce VHACD based convex decomposition#253
Conversation
b6355d6 to
0f2ac93
Compare
LiruMouse
left a comment
There was a problem hiding this comment.
Most of this looks good enough to me, I just have some small suggestions.
| return LLCD_OK; | ||
| } | ||
|
|
||
| LLCDResult LLConvexDecompositionVHACD::getMeshFromStage( int stage, int hull, LLCDMeshData* meshDataOut ) |
There was a problem hiding this comment.
Both get*FromStage functions are identical, aside from the datatype, so you could add a template member function to condense the logic and just have each call the template, thereby maintaining the interface.
| const U16* index_data = static_cast<const U16*>(data); | ||
| const int stride = index_stride_bytes / sizeof(U16); | ||
| for (int i = 0; i < num_indices; ++i) | ||
| { | ||
| indices.emplace_back(index_data[i * stride + 0], | ||
| index_data[i * stride + 1], | ||
| index_data[i * stride + 2]); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| const U32* index_data = static_cast<const U32*>(data); | ||
| const int stride = index_stride_bytes / sizeof(U32); | ||
| for (int i = 0; i < num_indices; ++i) | ||
| { | ||
| indices.emplace_back(index_data[i * stride + 0], | ||
| index_data[i * stride + 1], | ||
| index_data[i * stride + 2]); | ||
| } |
There was a problem hiding this comment.
These could be condensed into a local template function, or even a lambda
auto set_indices = [&]<typename T>(){
const T* index_data = static_cast<const T*>(data);
const int stride = index_stride_bytes / sizeof(T);
for (int i = 0; i < num_indices; ++i)
{
indices.emplace_back(index_data[i * stride + 0],
index_data[i * stride + 1],
index_data[i * stride + 2]);
}
};| { | ||
| clear(); | ||
|
|
||
| if (!meshIn || !meshIn->mVertexBase || (meshIn->mNumVertices < 3) || (meshIn->mVertexStrideBytes != 12 && meshIn->mVertexStrideBytes != 16)) |
There was a problem hiding this comment.
This condition is the same as in the function above, a template function could share the logic.
| LLUUID decomp_id = decomp->mMeshID; // Copy to avoid invalidation in below deletion | ||
| decomposition_map::iterator iter = mDecompositionMap.find(decomp_id); |
There was a problem hiding this comment.
Does order matter? If it doesn't, you can do the erasure before deleting decomp, and then you don't need a copy.
Co-authored-by: Liru Færs <lirusaito@gmail.com>
Co-authored-by: Liru Færs <lirusaito@gmail.com>
Co-authored-by: Liru Færs <lirusaito@gmail.com>
Co-authored-by: Liru Færs <lirusaito@gmail.com>
…lchemy into rye/convexdecomp
Description
Introduces a convex decomposition solution based on the VHACD library
Related Issues
Issue Link:
Checklist
Please ensure the following before requesting review:
Additional Notes