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

Disable mesh compression if vertex position.z is always 0 #86144

Merged

Conversation

jsjtxietian
Copy link
Contributor

Fixes #85963

As #85963 (comment) mentioned, "We could detect if the z channel is used in the vertex positions, if z is always 0, we could assume the mesh is 2D and disable compression" , this pr is a brute-force way of implementing it. I'm not sure if it's the right place to insert this check, but it seems the suitable place.

Feel free to correct me!

@AThousandShips AThousandShips added this to the 4.3 milestone Dec 14, 2023
@AThousandShips AThousandShips added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Dec 14, 2023
@fire
Copy link
Member

fire commented Dec 14, 2023

Is it true that a lot of the code assumes mesh compression is on? I am not that familiar.

@jsjtxietian jsjtxietian force-pushed the disable-mesh-compression-for-2d branch from e15b4a1 to fb65ddd Compare December 15, 2023 04:30
@akien-mga akien-mga changed the title Disable mesh compression if vertex position.z is always 0 Disable mesh compression if vertex position.z is always 0 Feb 20, 2024
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

The code looks good, but it should be in the respective importers, not in the SurfaceTool.

mesh_flags = 0;
}

if (p_state->force_disable_compression || !a.has("POSITION") || !a.has("NORMAL") || p.has("targets") || (a.has("JOINTS_0") || a.has("JOINTS_1"))) {
flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
}

if (p_mesh->get_blend_shape_count() != 0 || p_skin_controller) {
// Can't compress if attributes missing or if using vertex weights.
mesh_flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
}

@jsjtxietian jsjtxietian force-pushed the disable-mesh-compression-for-2d branch from eca1125 to 6d190d8 Compare February 26, 2024 09:02
@jsjtxietian jsjtxietian requested a review from a team as a code owner February 26, 2024 09:02
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Looks great! There is just a small typo in your comment. Once that is fixed, we can merge this for 4.3!

editor/import/3d/editor_import_collada.cpp Outdated Show resolved Hide resolved
@jsjtxietian jsjtxietian force-pushed the disable-mesh-compression-for-2d branch from 6d190d8 to 077e20c Compare April 10, 2024 03:27
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you

@akien-mga akien-mga merged commit 42ab525 into godotengine:master Apr 12, 2024
16 checks passed
@jsjtxietian jsjtxietian deleted the disable-mesh-compression-for-2d branch April 12, 2024 09:28
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release regression topic:import topic:2d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing a OBJ mesh into a MeshInstance2D completely messes its transforms
7 participants