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

Compute vertex_count for indexed meshes on GpuMesh #8460

Merged
merged 1 commit into from
Apr 22, 2023

Conversation

irate-devil
Copy link
Contributor

@irate-devil irate-devil commented Apr 22, 2023

Objective

Compute the vertex_count for indexed meshes as well as non-indexed meshes.

I will need this in a future PR based on #8427 that adds a gizmo component that draws the normals of a mesh when attached to an entity (branch).

Example image

image

Solution

Move vertex_count field from GpuBufferInfo::NonIndexed to GpuMesh

Migration Guide

vertex_count is now stored directly on GpuMesh instead of GpuBufferInfo::NonIndexed.

@@ -834,9 +835,7 @@ pub enum GpuBufferInfo {
count: u32,
Copy link
Contributor

Choose a reason for hiding this comment

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

The vertex count would be stored twice (once in GpuMesh.vertex_count field, once in GpuMesh.buffer_info.Indexed.count) With this solution.

Why not define vertex_count() as a method on GpuMesh? This way you inspect the content of buffer_info and return the value of either NonIndex.vertex_count or Indexed.count.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The count stored there is the size of the index buffer, not the amount of vertices in the mesh

Copy link
Contributor

@JMS55 JMS55 Apr 22, 2023

Choose a reason for hiding this comment

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

The same thing confused me at first. Imo, we should rename Indexed.count to Indexed.index_count or something.

Copy link
Contributor

Choose a reason for hiding this comment

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

size would be appropriate then

@JMS55
Copy link
Contributor

JMS55 commented Apr 22, 2023

Oh hey, I also needed this for my path tracing stuff. I have basically the same change in my fork lol. Thanks for the PR!

@superdump superdump added this pull request to the merge queue Apr 22, 2023
Merged via the queue into bevyengine:main with commit 6b774c0 Apr 22, 2023
21 checks passed
@irate-devil irate-devil deleted the indexed-mesh-vertex-count branch April 24, 2023 10:37
@Selene-Amanita Selene-Amanita added A-Rendering Drawing game state to the screen C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide labels Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants