Skip to content
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

feat: identify overlapping vertices at UV seams #4

Merged
merged 7 commits into from
Nov 17, 2023

Conversation

TechyDaniel
Copy link
Contributor

  • Introduce get_overlapping_vertices for vertex grouping.
  • Account for floating-point imprecision in vertex positions.
  • Ensure accurate identification without false positives.
  • Function returns a list of arrays with vertex indices.

test: ensure accurate overlapping vertex identification

  • Verify accurate detection of overlapping vertices.
  • Confirm no false positives are returned.
  • Test with varying mesh complexities.
  • Check for match detection within a few milliseconds.

Description

We need to group the vertices that share the same 3D Position so we ca blend the vertex color.
This function is vital for the vertex color blending.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [ x] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Test Configuration:

  • Did you use the test environment provided by the project (e.g. a hatch action)?
  • YES

Checklist

  • I confirm that the changes meet the user experience and goals outlined in the design plan (if there is one).
  • [x ] My code follows the style guidelines of this project
  • [x ] I have performed a self-review of my code
  • [x ] I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have updated any version info, if necessary.
  • [x ] My changes generate no new warnings
  • [x ] I have added tests that prove my fix is effective or that my feature works
  • [x ] New and existing unit tests pass locally with my changes

- Introduce `get_overlapping_vertices` for vertex grouping.
- Account for floating-point imprecision in vertex positions.
- Ensure accurate identification without false positives.
- Function returns a list of arrays with vertex indices.

test: ensure accurate overlapping vertex identification

- Verify accurate detection of overlapping vertices.
- Confirm no false positives are returned.
- Test with varying mesh complexities.
- Check for match detection within a few milliseconds.
@TechyDaniel TechyDaniel self-assigned this Nov 15, 2023
@TechyDaniel TechyDaniel marked this pull request as ready for review November 15, 2023 17:45
- Update function to process all vertices if indices are not provided.
- Handle cases with 'None' or empty list for indices.
- Improve function's flexibility and robustness for various cases.

test: add new cases for get_overlapping_vertices function

- Include unit tests for scenarios with 'None' or empty indices.
- Ensure function behaves as expected in these special cases.
- Enhance reliability and test coverage.
imprecision test is failing with current implementation
Copy link
Collaborator

@Olaf-Wolf3D Olaf-Wolf3D left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comments

- Implement a tolerance parameter in get_overlapping_vertices for better vertex grouping.
- Add tests to verify the new functionality.
@TechyDaniel TechyDaniel marked this pull request as draft November 17, 2023 15:58
@TechyDaniel TechyDaniel marked this pull request as ready for review November 17, 2023 15:59
Copy link
Collaborator

@Olaf-Wolf3D Olaf-Wolf3D left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still missing a test for expected IndexError

tests/readyplayerme/meshops/unit/test_mesh.py Show resolved Hide resolved
Add test for IndexError in get_overlapping_vertices
@Olaf-Wolf3D Olaf-Wolf3D marked this pull request as draft November 17, 2023 17:07
fix type of expected in test_get_overlapping_vertices to IndexGroups
@Olaf-Wolf3D Olaf-Wolf3D marked this pull request as ready for review November 17, 2023 17:11
@Olaf-Wolf3D Olaf-Wolf3D self-requested a review November 17, 2023 17:13
- Handle empty and negative indices in get_overlapping_vertices.
- Include additional tests to cover new checks.
@TechyDaniel TechyDaniel merged commit 19855ca into main Nov 17, 2023
@TechyDaniel TechyDaniel deleted the feat/group-seam-vertices branch November 17, 2023 19:55
Comment on lines +63 to +77
# Not using try / except because when using an index of -1 gets the last element and creates a false positive
if indices is None:
selected_vertices = vertices_pos
else:
if len(indices) == 0:
return []
if np.any(indices < 0):
msg = "Negative index value is not allowed."
raise IndexError(msg)

if np.max(indices) >= len(vertices_pos):
msg = "Index is out of bounds."
raise IndexError(msg)

selected_vertices = vertices_pos[indices]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnnessary and pushed after approval.

# Case with index out of bounds (higher than max)
np.array([0, 3], dtype=np.uint16),
# Case with index out of bounds (negative index)
np.array([0, -1], dtype=np.int32), # Using int32 to allow negative values
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should still be valid. Only negative indices that are out of bounds should raise. -1 is not out of bounds in this example, neither is -2, but -3 would be out of bounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants