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

Importer option for permanent scaling of the scene #60115

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

SaracenOne
Copy link
Member

@SaracenOne SaracenOne commented Apr 10, 2022

This is a draft PR tied to a proposal to replace or provide an alternative to the existing importer root_scale option (godotengine/godot-proposals#4379). The root_scale option only provides a one off modification to the root node's scale value when its instantiated, whereas this option provides a permentant modification to the underlying geometry and animations of a scene.

Left in draft while proposal is considered and the PR is being throughly tested for bugs.

Thanks to @lyuma for the original script implementation of this which I used as reference when writing this C++ version.

@fire
Copy link
Member

fire commented Apr 11, 2022

Typo on the commit message. permentant -> permanent

@SaracenOne SaracenOne changed the title Importer option for permentant scaling of the scene Importer option for permanent scaling of the scene Apr 11, 2022
Copy link
Contributor

@marstaik marstaik left a comment

Choose a reason for hiding this comment

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

I see a lot of unnecessary data copies, and a lack of const correctness. Can you go through and check on them? A lot of the data copies will not be able to be solved due to lack of move semantics however.

editor/import/resource_importer_scene.cpp Outdated Show resolved Hide resolved
editor/import/resource_importer_scene.cpp Outdated Show resolved Hide resolved
editor/import/resource_importer_scene.cpp Show resolved Hide resolved
editor/import/resource_importer_scene.cpp Outdated Show resolved Hide resolved
editor/import/resource_importer_scene.cpp Show resolved Hide resolved
editor/import/resource_importer_scene.cpp Outdated Show resolved Hide resolved
editor/import/resource_importer_scene.cpp Show resolved Hide resolved
editor/import/resource_importer_scene.cpp Show resolved Hide resolved
editor/import/resource_importer_scene.cpp Show resolved Hide resolved
editor/import/resource_importer_scene.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@lyuma lyuma left a comment

Choose a reason for hiding this comment

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

Overall looking ok.

I do wonder... do we need to consider other objects types for rescaling? For example, light attenuation? camera scale/near/far?

Comment on lines 427 to 422
while (i < current_bs_vert_arr_len) {
current_bs_vertex_array.set(i, current_bs_vertex_array[i] * p_scale);
i += 1;
}
current_bsarr[ArrayMesh::ARRAY_VERTEX] = current_bs_vertex_array;
Copy link
Contributor

Choose a reason for hiding this comment

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

This code is really messy.

I did things this way in my GDScript implementation because we do not currently have access to a better API for modifying ImporterMesh.

But since we're making a core engine change, it might be better to provide access to the vertex positions of EditorSceneImporterMesh so that they can be modified without deleting and readding everything.

Here's or chance to improve the APIs to make them less clunky.

@fire
Copy link
Member

fire commented May 10, 2022

Want to rebase and try resolving the review comments?

@fire
Copy link
Member

fire commented Jun 12, 2022

According to @lyuma this resolves the blend shape bug. Will test.

@TokageItLab
Copy link
Member

Can this function be applied to rotations as well? I was thinking of something similar in #63662. I prefer that those transformations need to be PreProcess for retargeting.

@fire
Copy link
Member

fire commented Jul 30, 2022

I want to propose to set the root transform as the default value of this importer option.

@SaracenOne SaracenOne marked this pull request as ready for review July 30, 2022 18:25
@SaracenOne SaracenOne requested review from a team as code owners July 30, 2022 18:25
@SaracenOne
Copy link
Member Author

SaracenOne commented Jul 30, 2022

I'm opening this up for review again based on the changes implemented by @lyuma and @fire. I shall check it again though since I haven't touched it for a while

@fire fire force-pushed the scene_scale branch 4 times, most recently from 800fc97 to 6cb1fdc Compare July 31, 2022 14:08
@fire
Copy link
Member

fire commented Aug 7, 2022

I'll see if I can reset the branch to avoid the big diffs.

@fire fire marked this pull request as ready for review August 7, 2022 22:56
reduz
reduz previously requested changes Sep 5, 2022
editor/import/resource_importer_scene.cpp Outdated Show resolved Hide resolved
@reduz
Copy link
Member

reduz commented Sep 5, 2022

Seems good for the most part, should be able to merge it

@fire
Copy link
Member

fire commented Sep 5, 2022

Will revise the for loop.

@fire
Copy link
Member

fire commented Sep 5, 2022

READY TO GO

  1. scaled the blends shape test by 10 and then apply
  2. check scaling on root and the animations play
  3. done

MorphStressTest.zip

image

@fire
Copy link
Member

fire commented Sep 5, 2022

Consider other objects types for rescaling? For example, light attenuation? camera scale/near/far?

Cameras and punctual lights are like points, so scaling a point doesn't do much. I don't know if scaling a light's light-units by distance-scale has a good formula since the physical light units is not default.

A camera is a node 3d, might work by chance.

tl;dr not a blocker.

@Calinou
Copy link
Member

Calinou commented Sep 5, 2022

Cameras and punctual lights are like points, so scaling a point doesn't do much. I don't know if scaling a light's light-units by distance-scale has a good formula since the physical light units is not default.

Scaling a positional light by increasing its range should work well enough in some cases. Keep the same attenuation, and keep the same spot angle.

Cameras should be kept identical – don't change their FOV depending on scale.

@fire
Copy link
Member

fire commented Sep 5, 2022

@reduz can you remove the merge block? The while loop has been removed.

@akien-mga akien-mga merged commit a49ec43 into godotengine:master Sep 6, 2022
@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.

8 participants