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: add range option to MeshBVH #660

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

minitoine
Copy link
Contributor

  • Adds a new range option that acts "as drawRange"
  • Should allow multiple BVH on the same geometry with different ranges (useful for Three BatchedMesh)

Closes #513

@minitoine
Copy link
Contributor Author

Will the index rearrangement only occur for the given range ? Or do I need to put restriction there as well ?

Copy link
Owner

@gkjohnson gkjohnson left a comment

Choose a reason for hiding this comment

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

Great, thanks! Can we update the README, as well?

Will the index rearrangement only occur for the given range ? Or do I need to put restriction there as well ?

Yeah the indices are only arranged within the necessary range.

One memory issue currently, though, is that the "indirect" buffer is created for the full length of the geometry buffers even if a small subset is needed. But we can track that in another issue.

Another thing we may want to consider for the future is keeping an "offset" field on the BVH so that it can be retained if the subgeometry in the BatchedMesh is moved (ie when "optimizing" or repacking the BatchedMesh).

Comment on lines +357 to +360
// If given, the MeshBVH will be computed for the given range on the geometry.
// Default range is { start: 0, count: Infinity }
range: { start: number, count: number }

Copy link
Owner

Choose a reason for hiding this comment

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

nit: Can we fix the indentation here

let workingRange = geo.drawRange;
if ( range ) {

workingRange = getRangesIntersection( workingRange, range );
Copy link
Owner

Choose a reason for hiding this comment

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

I think it's okay if we just use the passed in "range" here instead of trying to find the intersection of drawRange and the passed in range. It's simpler and in this way a user can override the use of draw range if needed, as well.

That means we'd also have to default the "range" option to null. Or we could default "range" to the geometries draw range to be more clear. What do you think?


} );

it( 'should respect the range option without groups.', () => {
Copy link
Owner

Choose a reason for hiding this comment

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

I think we'll want to make sure this works with the indirect argument, as well. Do you mind adding another test or two for that case?

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.

MeshBVH index offset for merged geometries into one buffer
2 participants