-
Notifications
You must be signed in to change notification settings - Fork 24
Introduce VHACD based convex decomposition #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b6355d6 to
0f2ac93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Co-authored-by: Liru Færs <[email protected]>
Co-authored-by: Liru Færs <[email protected]>
Co-authored-by: Liru Færs <[email protected]>
…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