Optimize mesh generation based on marching cubes#1350
Merged
Conversation
Fedr
reviewed
Jun 22, 2023
source/MRMesh/MRVoxelsConversions.h
Outdated
| { | ||
|
|
||
| struct BaseVolumeConversionParams | ||
| struct MRMESH_CLASS BaseVolumeConversionParams |
Contributor
There was a problem hiding this comment.
Is it really necessary to export header-only structs?
Fedr
reviewed
Jun 22, 2023
|
|
||
| namespace | ||
| { | ||
| constexpr float cQuietNan = std::numeric_limits<float>::quiet_NaN(); |
Contributor
There was a problem hiding this comment.
you can do std::bit_cast< int >( right here
Fedr
reviewed
Jun 22, 2023
| #include "MRPch/MRTBB.h" | ||
| #include "MRPch/MROpenvdb.h" | ||
|
|
||
| #include <boost/mp11/algorithm.hpp> |
Contributor
Author
There was a problem hiding this comment.
It was required for the compile-time parameters and their checks; it is reworked and removed now.
Fedr
reviewed
Jun 22, 2023
| TriangulationPlan{} | ||
| }; | ||
|
|
||
| // check if this iter is needed for config |
Fedr
reviewed
Jun 22, 2023
| if ( iterIndex == 0 ) | ||
| { | ||
| auto base = ( config & ( 1 << 0 ) ); | ||
| if ( base != ( config & ( 1 << cMapNeighborsShift[1] ) ) ) |
Contributor
There was a problem hiding this comment.
Can we prepare ( 1 << cMapNeighborsShift[1] ) beforehand to be sure it is not computed in runtime?
Fedr
reviewed
Jun 22, 2023
| inline Vector3f voxelPositionerLinearInline( const Vector3f& pos0, const Vector3f& pos1, float v0, float v1, float iso ) | ||
| { | ||
| auto ratio = std::clamp( std::abs( iso - v0 ) / std::abs( v1 - v0 ), 0.0f, 1.0f ); | ||
| const auto ratio = std::clamp( std::abs( iso - v0 ) / std::abs( v1 - v0 ), 0.0f, 1.0f ); |
Fedr
reviewed
Jun 22, 2023
Fedr
reviewed
Jun 22, 2023
Comment on lines
+614
to
+628
| OutEdge outEdge; | ||
| switch ( dir ) | ||
| { | ||
| case MR::MarchingCubesHelper::NeighborDir::X: | ||
| outEdge = OutEdge::PlusX; | ||
| break; | ||
| case MR::MarchingCubesHelper::NeighborDir::Y: | ||
| outEdge = OutEdge::PlusY; | ||
| break; | ||
| case MR::MarchingCubesHelper::NeighborDir::Z: | ||
| outEdge = OutEdge::PlusZ; | ||
| break; | ||
| default: | ||
| return false; | ||
| } |
Contributor
There was a problem hiding this comment.
Can we replace this complex switch with some simple formula like outEdge = (OutEdge)dir?
Fedr
reviewed
Jun 22, 2023
|
|
||
| float valueB = volume.data[base]; | ||
| float valueD = volume.data[indexer.getExistingNeighbor( base, outEdge ).get()]; | ||
| if constexpr ( !boost::mp11::mp_contains<Args, OmitNaNCheck>::value ) |
Contributor
There was a problem hiding this comment.
Just make function parameter F && isNan. And if you do not need to check for NaN, call with [](float){};
added 3 commits
June 23, 2023 11:41
Fedr
approved these changes
Jun 23, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.