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

MarchingCubes: Migrate to Mesh. #22642

Merged
merged 1 commit into from
Oct 5, 2021
Merged

MarchingCubes: Migrate to Mesh. #22642

merged 1 commit into from
Oct 5, 2021

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Oct 5, 2021

Related issue: -

Description

MarchingCubes is now derived from Mesh.

In order to retain the functionality which was previously based on ImmediateRenderObject, it is now necessary to specify the maximum expected triangle/poly count when creating an instance of MarchingCubes.

The logic that updates the geometry buffers is now implemented in onBeforeRender(). If it detects too small buffers, it notifies the user with a warning.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Oct 5, 2021

@Mugen87 Mugen87 marked this pull request as draft October 5, 2021 14:20
@Mugen87 Mugen87 marked this pull request as ready for review October 5, 2021 14:58

this.generateGeometry = function () {
this.positionArray[ i ] = 0.0;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Instead of resetting the vertices like before, I was trying to use setDrawRange() to limit the rendered data, However, this introduces strange flickering (it seems the number of rendered triangles varies from frame to frame). Hence, I've sticked to the previous approach for now.

@mrdoob
Copy link
Owner

mrdoob commented Oct 5, 2021

Yay! This code was always so hard to deal with.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Oct 5, 2021

It seems the new approach is at least as fast as the previous approach. I was not able to detect a performance regression.

@mrdoob mrdoob added this to the r134 milestone Oct 5, 2021
@mrdoob mrdoob merged commit df7c403 into mrdoob:dev Oct 5, 2021
@mrdoob
Copy link
Owner

mrdoob commented Oct 5, 2021

Thanks!

@joshuaellis joshuaellis mentioned this pull request Nov 2, 2021
12 tasks
@gkjohnson
Copy link
Collaborator

Is it no longer possible to "bake" the geometry to a static BufferGeometry any more? I just upgraded one of my bvh demos and saw this changed. In terms of performance it's significantly faster if you don't have a dynamic marching cubes geometry to generate a static geometry to render.

I think it might be nice if the marching cubes logic were more separated from a "Mesh" instance and could serve more as a utility that something like a mesh class uses. Maybe I'll look into that at some point.

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.

None yet

3 participants