Skip to content

Move 2D and 3D resources to their own folders#50148

Merged
akien-mga merged 2 commits into
godotengine:masterfrom
aaronfranke:move-resources
Feb 26, 2024
Merged

Move 2D and 3D resources to their own folders#50148
akien-mga merged 2 commits into
godotengine:masterfrom
aaronfranke:move-resources

Conversation

@aaronfranke

@aaronfranke aaronfranke commented Jul 4, 2021

Copy link
Copy Markdown
Member

Similarly to how we have the scene/2d folder and scene/3d folder for 2D and 3D nodes, this PR moves 2D and 3D resources to scene/resources/2d and scene/resources/3d. Also, I moved the skeleton modification resources to another subfolder, scene/resources/2d/skeleton since there were 18 2D skeleton modification resource files. Resources that are shared between 2D and 3D are still in scene/resources.

  • This gives us the ability to easily exclude the resources in these folders when disabling 2D or 3D (but as of this PR, they are always included).

  • In terms of compiled size, as of the current master, the resources folder is the biggest one, so that's another reason that I think it would be nice to divide it up into 2D and 3D subfolders:

godot4-chart

@aaronfranke aaronfranke added this to the 4.0 milestone Jul 4, 2021
@aaronfranke aaronfranke requested review from a team and akien-mga July 4, 2021 04:45
@aaronfranke aaronfranke requested a review from a team as a code owner July 4, 2021 04:45
@aaronfranke aaronfranke requested a review from a team July 4, 2021 04:45
@aaronfranke aaronfranke requested review from a team as code owners July 4, 2021 04:45
@aaronfranke aaronfranke force-pushed the move-resources branch 3 times, most recently from 6e7e4bd to ded4d23 Compare August 1, 2021 16:14
@clayjohn

clayjohn commented Aug 3, 2021

Copy link
Copy Markdown
Member

SurfaceTool and MeshDataTool should be under /resources rather than /resources/3d. Both can be used in 2D as well as 3D. For example, they can be used with a MeshInstance2D or a MultiMeshInstance2D.

@aaronfranke aaronfranke force-pushed the move-resources branch 2 times, most recently from f235ec8 to c9c7dd3 Compare August 11, 2021 01:19
@aaronfranke aaronfranke force-pushed the move-resources branch 2 times, most recently from c467e7f to 23b29e1 Compare August 18, 2021 00:26
@aaronfranke aaronfranke force-pushed the move-resources branch 2 times, most recently from fd43597 to 38f7ec2 Compare August 28, 2021 03:23
@aaronfranke aaronfranke force-pushed the move-resources branch 2 times, most recently from 8658ce2 to d50b5e6 Compare September 16, 2021 04:13
@aaronfranke aaronfranke force-pushed the move-resources branch 2 times, most recently from 135e4d8 to a60b104 Compare October 3, 2021 20:37
@aaronfranke aaronfranke force-pushed the move-resources branch 2 times, most recently from 7d5a7c8 to 1854080 Compare August 3, 2022 04:19
@aaronfranke aaronfranke force-pushed the move-resources branch 2 times, most recently from 3c08ee2 to f99dc0b Compare August 16, 2022 12:23
@aaronfranke aaronfranke force-pushed the move-resources branch 2 times, most recently from 863aa06 to 9b252fa Compare September 2, 2022 05:31
@Zireael07

This comment was marked as off-topic.

@fire

fire commented Oct 17, 2022

Copy link
Copy Markdown
Member

@aaronfranke do you remember how we generated those photos?

Back to topic: I remember this was not a minor change to merge because it causes all the godot engine prs to break.

@aaronfranke

aaronfranke commented Oct 17, 2022

Copy link
Copy Markdown
Member Author

@fire https://docs.google.com/spreadsheets/d/1aWmWiA6MWoHr4Mgg22tybDFPa6BJX5oHTSjfN21plyY

The data was gathered from a debug build, I don't remember the process. Then the data was added to this chart. Since the data was gathered from a debug build it may not be 100% accurate compared to a release build but it will be very close and a release build does not have the information required to get the compiled file size.

@deralmas

Copy link
Copy Markdown
Member

What's the status of this PR? Will it be merged by the release?

@Zireael07

This comment was marked as off-topic.

@ghost

ghost commented Apr 12, 2023

Copy link
Copy Markdown

Any update on this ?

@YuriSizov

YuriSizov commented Apr 13, 2023

Copy link
Copy Markdown
Contributor

Any update on this ?

We have several reorganization PRs, from Aaron and some other contributors. These are low priority in general, unless they improve code organization (and not just file organization), because such changes have no effect on the API and the rest of the outer world. Generally speaking, I think it's safe to say that we like the idea of better organization, especially for huge folders like that. But there is no specific date on merging this (and it was definitely not a priority for 4.0).

@aaronfranke

Copy link
Copy Markdown
Member Author

Awhile ago this was brought up in a meeting (should've written this down then, but I forgot), and reduz wondered if instead we should have 2d/resources instead of resources/2d. The challenge here is that there are some resources that are neither 2D or 3D, so we would still need a resources folder. I am proposing this PR as it is because this is the path of least resistance vs the existing codebase, since these files are already in resources, this PR just adds another subfolder, but I am good with either approach, so whatever is preferred we can do that.

@akien-mga akien-mga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After discussion with maintainers, I agree with the change.

Conceptually, this is fine, a 2D/3D split marginally helps make the code organization better, but also paves the way to more possibility to decrease build size in custom 2D/3D only builds.

My main concern is with breaking compatibility on the include paths for C++ modules which use those Godot resources.

  • For modules which only track a single Godot version (like in-house C++ modules for game-specific logic, etc.), it's fine, the devs can just do the same refactoring when updating to Godot 4.3.
  • For general-purpose open source modules which aim to support multiple Godot branches, it's a bit trickier. They can still wrap things with #if VERSION_HEX >= 0x040300 checks, though that implies including core/version.h in all affected files. Thankfully with GDExtension/godot-cpp, such modules are less common than they were in 3.x, so I think the tradeoff is acceptable (compatibility is not broken for godot-cpp as their the include paths are all flattened to a single folder).

Comment thread scene/register_scene_types.cpp Outdated
Comment thread scene/register_scene_types.cpp Outdated
Comment thread scene/register_scene_types.cpp Outdated
Comment thread scene/register_scene_types.cpp Outdated
@akien-mga

Copy link
Copy Markdown
Member

Thanks for the work and your patience :)

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.

9 participants