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

Expose create_from_arrays in SurfaceTool and cleanup some naming #90834

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

lyuma
Copy link
Contributor

@lyuma lyuma commented Apr 18, 2024

Currently, the only user-facing API to SurfaceTool is by using ArrayMesh, which requires copying CPU -> GPU -> CPU.

The function for in-memory creation already existed internally SurfaceTool::create_from_triangle_arrays, since this is used by ImporterMesh and other import tooling, but this function was not exposed.

Furthermore, when reviewing how this function was implemented, the code sets primitive to PRIMITIVE_TRIANGLES, yet does not depend on this assumption. I believe this was caused by the fact that it calls an erroneously-named internal static SurfaceTool::create_vertex_array_from_triangle_arrays function, which is actually used internally for all types of meshes and makes no assumption about the primitive type.

In summary, I'm renaming create_vertex_array_from_triangle_arrays to create_vertex_array_from_arrays and adding a wrapper function for triangles so that SurfaceTool::create_from_arrays can be exposed.

@lyuma lyuma requested a review from a team as a code owner April 18, 2024 05:19
@lyuma lyuma force-pushed the surfacetool_create_from_arrays branch from 5a4f6ef to 09b50a5 Compare April 18, 2024 05:49
@YeldhamDev YeldhamDev added this to the 4.x milestone Apr 18, 2024
@lyuma lyuma force-pushed the surfacetool_create_from_arrays branch from 09b50a5 to 807bec6 Compare April 18, 2024 06:06
doc/classes/SurfaceTool.xml Outdated Show resolved Hide resolved
doc/classes/SurfaceTool.xml Outdated Show resolved Hide resolved
@lyuma lyuma force-pushed the surfacetool_create_from_arrays branch from 807bec6 to a99756a Compare April 20, 2024 01:45
@akien-mga akien-mga changed the title Expose create_from_arrays in SurfaceTool and cleanup some naming Expose create_from_arrays in SurfaceTool and cleanup some naming Apr 22, 2024
@akien-mga akien-mga modified the milestones: 4.x, 4.3 Apr 22, 2024
@akien-mga akien-mga merged commit ab57e8d into godotengine:master Apr 22, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

5 participants