From d8aa3b32c907c4e3633d02156242fe5146a26325 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Mon, 28 Nov 2022 18:59:46 -0600 Subject: [PATCH] [3.x] GLTF: Organize structures and extensions into subfolders --- modules/gltf/README.md | 10 +++++++++ modules/gltf/SCsub | 2 ++ modules/gltf/extensions/SCsub | 9 ++++++++ modules/gltf/{ => extensions}/gltf_light.cpp | 0 modules/gltf/{ => extensions}/gltf_light.h | 1 + .../gltf/{ => extensions}/gltf_spec_gloss.cpp | 0 .../gltf/{ => extensions}/gltf_spec_gloss.h | 1 + modules/gltf/gltf_document.cpp | 2 +- modules/gltf/gltf_document.h | 3 +-- modules/gltf/gltf_state.h | 22 +++++++++---------- modules/gltf/register_types.cpp | 2 +- .../gltf/{ => structures}/gltf_accessor.cpp | 0 modules/gltf/{ => structures}/gltf_accessor.h | 2 +- .../gltf/{ => structures}/gltf_animation.cpp | 0 .../gltf/{ => structures}/gltf_animation.h | 0 .../{ => structures}/gltf_buffer_view.cpp | 0 .../gltf/{ => structures}/gltf_buffer_view.h | 2 +- modules/gltf/{ => structures}/gltf_camera.cpp | 0 modules/gltf/{ => structures}/gltf_camera.h | 0 modules/gltf/{ => structures}/gltf_mesh.cpp | 0 modules/gltf/{ => structures}/gltf_mesh.h | 0 modules/gltf/{ => structures}/gltf_node.cpp | 0 modules/gltf/{ => structures}/gltf_node.h | 2 +- .../gltf/{ => structures}/gltf_skeleton.cpp | 2 +- modules/gltf/{ => structures}/gltf_skeleton.h | 2 +- modules/gltf/{ => structures}/gltf_skin.cpp | 2 +- modules/gltf/{ => structures}/gltf_skin.h | 2 +- .../gltf/{ => structures}/gltf_texture.cpp | 0 modules/gltf/{ => structures}/gltf_texture.h | 2 +- .../{ => structures}/gltf_texture_sampler.cpp | 0 .../{ => structures}/gltf_texture_sampler.h | 0 31 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 modules/gltf/README.md create mode 100644 modules/gltf/extensions/SCsub rename modules/gltf/{ => extensions}/gltf_light.cpp (100%) rename modules/gltf/{ => extensions}/gltf_light.h (99%) rename modules/gltf/{ => extensions}/gltf_spec_gloss.cpp (100%) rename modules/gltf/{ => extensions}/gltf_spec_gloss.h (99%) rename modules/gltf/{ => structures}/gltf_accessor.cpp (100%) rename modules/gltf/{ => structures}/gltf_accessor.h (99%) rename modules/gltf/{ => structures}/gltf_animation.cpp (100%) rename modules/gltf/{ => structures}/gltf_animation.h (100%) rename modules/gltf/{ => structures}/gltf_buffer_view.cpp (100%) rename modules/gltf/{ => structures}/gltf_buffer_view.h (99%) rename modules/gltf/{ => structures}/gltf_camera.cpp (100%) rename modules/gltf/{ => structures}/gltf_camera.h (100%) rename modules/gltf/{ => structures}/gltf_mesh.cpp (100%) rename modules/gltf/{ => structures}/gltf_mesh.h (100%) rename modules/gltf/{ => structures}/gltf_node.cpp (100%) rename modules/gltf/{ => structures}/gltf_node.h (99%) rename modules/gltf/{ => structures}/gltf_skeleton.cpp (99%) rename modules/gltf/{ => structures}/gltf_skeleton.h (99%) rename modules/gltf/{ => structures}/gltf_skin.cpp (99%) rename modules/gltf/{ => structures}/gltf_skin.h (99%) rename modules/gltf/{ => structures}/gltf_texture.cpp (100%) rename modules/gltf/{ => structures}/gltf_texture.h (98%) rename modules/gltf/{ => structures}/gltf_texture_sampler.cpp (100%) rename modules/gltf/{ => structures}/gltf_texture_sampler.h (100%) diff --git a/modules/gltf/README.md b/modules/gltf/README.md new file mode 100644 index 00000000000..f6e433ec367 --- /dev/null +++ b/modules/gltf/README.md @@ -0,0 +1,10 @@ +# Godot GLTF import and export module + +In a nutshell, the GLTF module works like this: + +* The [`structures/`](structures/) folder contains GLTF structures, the + small pieces that make up a GLTF file, represented as C++ classes. +* The [`extensions/`](extensions/) folder contains GLTF extensions, which + are optional features that build on top of the base GLTF spec. +* [`GLTFState`](gltf_state.h) holds collections of structures and extensions. +* [`GLTFDocument`](gltf_document.h) operates on GLTFState and its elements. diff --git a/modules/gltf/SCsub b/modules/gltf/SCsub index ad214bb79c8..3db3e6bfa32 100644 --- a/modules/gltf/SCsub +++ b/modules/gltf/SCsub @@ -7,3 +7,5 @@ env_gltf = env_modules.Clone() # Godot source files env_gltf.add_source_files(env.modules_sources, "*.cpp") +env_gltf.add_source_files(env.modules_sources, "structures/*.cpp") +SConscript("extensions/SCsub") diff --git a/modules/gltf/extensions/SCsub b/modules/gltf/extensions/SCsub new file mode 100644 index 00000000000..ad214bb79c8 --- /dev/null +++ b/modules/gltf/extensions/SCsub @@ -0,0 +1,9 @@ +#!/usr/bin/env python + +Import("env") +Import("env_modules") + +env_gltf = env_modules.Clone() + +# Godot source files +env_gltf.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/gltf/gltf_light.cpp b/modules/gltf/extensions/gltf_light.cpp similarity index 100% rename from modules/gltf/gltf_light.cpp rename to modules/gltf/extensions/gltf_light.cpp diff --git a/modules/gltf/gltf_light.h b/modules/gltf/extensions/gltf_light.h similarity index 99% rename from modules/gltf/gltf_light.h rename to modules/gltf/extensions/gltf_light.h index e3513f317d7..e0cc89f1904 100644 --- a/modules/gltf/gltf_light.h +++ b/modules/gltf/extensions/gltf_light.h @@ -31,6 +31,7 @@ #ifndef GLTF_LIGHT_H #define GLTF_LIGHT_H +#include "../gltf_defines.h" #include "core/resource.h" class GLTFLight : public Resource { diff --git a/modules/gltf/gltf_spec_gloss.cpp b/modules/gltf/extensions/gltf_spec_gloss.cpp similarity index 100% rename from modules/gltf/gltf_spec_gloss.cpp rename to modules/gltf/extensions/gltf_spec_gloss.cpp diff --git a/modules/gltf/gltf_spec_gloss.h b/modules/gltf/extensions/gltf_spec_gloss.h similarity index 99% rename from modules/gltf/gltf_spec_gloss.h rename to modules/gltf/extensions/gltf_spec_gloss.h index c1911fc3ba4..18d5bea7bae 100644 --- a/modules/gltf/gltf_spec_gloss.h +++ b/modules/gltf/extensions/gltf_spec_gloss.h @@ -31,6 +31,7 @@ #ifndef GLTF_SPEC_GLOSS_H #define GLTF_SPEC_GLOSS_H +#include "../gltf_defines.h" #include "core/image.h" #include "core/resource.h" diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 5c9500fb5e3..ac81bc2d3e5 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -30,7 +30,7 @@ #include "gltf_document.h" -#include "gltf_spec_gloss.h" +#include "extensions/gltf_spec_gloss.h" #include "gltf_state.h" #include "core/bind/core_bind.h" // FIXME: Shouldn't use _Directory but DirAccess. diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index 576de123cd3..df8dca1c971 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -32,6 +32,7 @@ #define GLTF_DOCUMENT_H #include "gltf_defines.h" +#include "structures/gltf_animation.h" #include "scene/3d/bone_attachment.h" #include "scene/3d/camera.h" @@ -43,8 +44,6 @@ #include "scene/resources/material.h" #include "scene/resources/texture.h" -#include "gltf_animation.h" - #include "modules/modules_enabled.gen.h" // For csg, gridmap. #ifdef MODULE_CSG_ENABLED diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index fa96d20f485..3087a77751e 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -31,18 +31,18 @@ #ifndef GLTF_STATE_H #define GLTF_STATE_H -#include "gltf_accessor.h" -#include "gltf_animation.h" -#include "gltf_buffer_view.h" -#include "gltf_camera.h" -#include "gltf_light.h" -#include "gltf_mesh.h" -#include "gltf_node.h" -#include "gltf_skeleton.h" -#include "gltf_skin.h" +#include "extensions/gltf_light.h" #include "gltf_template_convert.h" -#include "gltf_texture.h" -#include "gltf_texture_sampler.h" +#include "structures/gltf_accessor.h" +#include "structures/gltf_animation.h" +#include "structures/gltf_buffer_view.h" +#include "structures/gltf_camera.h" +#include "structures/gltf_mesh.h" +#include "structures/gltf_node.h" +#include "structures/gltf_skeleton.h" +#include "structures/gltf_skin.h" +#include "structures/gltf_texture.h" +#include "structures/gltf_texture_sampler.h" class GLTFState : public Resource { GDCLASS(GLTFState, Resource); diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp index ec7df2ddb1d..57556ed9890 100644 --- a/modules/gltf/register_types.cpp +++ b/modules/gltf/register_types.cpp @@ -32,7 +32,7 @@ #include "register_types.h" -#include "gltf_spec_gloss.h" +#include "extensions/gltf_spec_gloss.h" #include "gltf_state.h" #ifdef TOOLS_ENABLED diff --git a/modules/gltf/gltf_accessor.cpp b/modules/gltf/structures/gltf_accessor.cpp similarity index 100% rename from modules/gltf/gltf_accessor.cpp rename to modules/gltf/structures/gltf_accessor.cpp diff --git a/modules/gltf/gltf_accessor.h b/modules/gltf/structures/gltf_accessor.h similarity index 99% rename from modules/gltf/gltf_accessor.h rename to modules/gltf/structures/gltf_accessor.h index 46c83d5c2c6..c9fb5992389 100644 --- a/modules/gltf/gltf_accessor.h +++ b/modules/gltf/structures/gltf_accessor.h @@ -31,8 +31,8 @@ #ifndef GLTF_ACCESSOR_H #define GLTF_ACCESSOR_H +#include "../gltf_defines.h" #include "core/resource.h" -#include "gltf_defines.h" struct GLTFAccessor : public Resource { GDCLASS(GLTFAccessor, Resource); diff --git a/modules/gltf/gltf_animation.cpp b/modules/gltf/structures/gltf_animation.cpp similarity index 100% rename from modules/gltf/gltf_animation.cpp rename to modules/gltf/structures/gltf_animation.cpp diff --git a/modules/gltf/gltf_animation.h b/modules/gltf/structures/gltf_animation.h similarity index 100% rename from modules/gltf/gltf_animation.h rename to modules/gltf/structures/gltf_animation.h diff --git a/modules/gltf/gltf_buffer_view.cpp b/modules/gltf/structures/gltf_buffer_view.cpp similarity index 100% rename from modules/gltf/gltf_buffer_view.cpp rename to modules/gltf/structures/gltf_buffer_view.cpp diff --git a/modules/gltf/gltf_buffer_view.h b/modules/gltf/structures/gltf_buffer_view.h similarity index 99% rename from modules/gltf/gltf_buffer_view.h rename to modules/gltf/structures/gltf_buffer_view.h index 4f11ca589c1..15c208e0221 100644 --- a/modules/gltf/gltf_buffer_view.h +++ b/modules/gltf/structures/gltf_buffer_view.h @@ -31,8 +31,8 @@ #ifndef GLTF_BUFFER_VIEW_H #define GLTF_BUFFER_VIEW_H +#include "../gltf_defines.h" #include "core/resource.h" -#include "gltf_defines.h" class GLTFBufferView : public Resource { GDCLASS(GLTFBufferView, Resource); diff --git a/modules/gltf/gltf_camera.cpp b/modules/gltf/structures/gltf_camera.cpp similarity index 100% rename from modules/gltf/gltf_camera.cpp rename to modules/gltf/structures/gltf_camera.cpp diff --git a/modules/gltf/gltf_camera.h b/modules/gltf/structures/gltf_camera.h similarity index 100% rename from modules/gltf/gltf_camera.h rename to modules/gltf/structures/gltf_camera.h diff --git a/modules/gltf/gltf_mesh.cpp b/modules/gltf/structures/gltf_mesh.cpp similarity index 100% rename from modules/gltf/gltf_mesh.cpp rename to modules/gltf/structures/gltf_mesh.cpp diff --git a/modules/gltf/gltf_mesh.h b/modules/gltf/structures/gltf_mesh.h similarity index 100% rename from modules/gltf/gltf_mesh.h rename to modules/gltf/structures/gltf_mesh.h diff --git a/modules/gltf/gltf_node.cpp b/modules/gltf/structures/gltf_node.cpp similarity index 100% rename from modules/gltf/gltf_node.cpp rename to modules/gltf/structures/gltf_node.cpp diff --git a/modules/gltf/gltf_node.h b/modules/gltf/structures/gltf_node.h similarity index 99% rename from modules/gltf/gltf_node.h rename to modules/gltf/structures/gltf_node.h index e774c17cd7d..63593d1ec40 100644 --- a/modules/gltf/gltf_node.h +++ b/modules/gltf/structures/gltf_node.h @@ -31,8 +31,8 @@ #ifndef GLTF_NODE_H #define GLTF_NODE_H +#include "../gltf_defines.h" #include "core/resource.h" -#include "gltf_defines.h" class GLTFNode : public Resource { GDCLASS(GLTFNode, Resource); diff --git a/modules/gltf/gltf_skeleton.cpp b/modules/gltf/structures/gltf_skeleton.cpp similarity index 99% rename from modules/gltf/gltf_skeleton.cpp rename to modules/gltf/structures/gltf_skeleton.cpp index 57f871c7831..6243e5c9622 100644 --- a/modules/gltf/gltf_skeleton.cpp +++ b/modules/gltf/structures/gltf_skeleton.cpp @@ -30,7 +30,7 @@ #include "gltf_skeleton.h" -#include "gltf_template_convert.h" +#include "../gltf_template_convert.h" #include "scene/3d/bone_attachment.h" void GLTFSkeleton::_bind_methods() { diff --git a/modules/gltf/gltf_skeleton.h b/modules/gltf/structures/gltf_skeleton.h similarity index 99% rename from modules/gltf/gltf_skeleton.h rename to modules/gltf/structures/gltf_skeleton.h index 21b1044b0ce..cdca72172d3 100644 --- a/modules/gltf/gltf_skeleton.h +++ b/modules/gltf/structures/gltf_skeleton.h @@ -31,8 +31,8 @@ #ifndef GLTF_SKELETON_H #define GLTF_SKELETON_H +#include "../gltf_defines.h" #include "core/resource.h" -#include "gltf_defines.h" class GLTFSkeleton : public Resource { GDCLASS(GLTFSkeleton, Resource); diff --git a/modules/gltf/gltf_skin.cpp b/modules/gltf/structures/gltf_skin.cpp similarity index 99% rename from modules/gltf/gltf_skin.cpp rename to modules/gltf/structures/gltf_skin.cpp index d48c449d162..0a5ee7c4252 100644 --- a/modules/gltf/gltf_skin.cpp +++ b/modules/gltf/structures/gltf_skin.cpp @@ -30,7 +30,7 @@ #include "gltf_skin.h" -#include "gltf_template_convert.h" +#include "../gltf_template_convert.h" #include "scene/resources/skin.h" void GLTFSkin::_bind_methods() { diff --git a/modules/gltf/gltf_skin.h b/modules/gltf/structures/gltf_skin.h similarity index 99% rename from modules/gltf/gltf_skin.h rename to modules/gltf/structures/gltf_skin.h index f918b6607d3..68fdb6d3023 100644 --- a/modules/gltf/gltf_skin.h +++ b/modules/gltf/structures/gltf_skin.h @@ -31,8 +31,8 @@ #ifndef GLTF_SKIN_H #define GLTF_SKIN_H +#include "../gltf_defines.h" #include "core/resource.h" -#include "gltf_defines.h" class GLTFSkin : public Resource { GDCLASS(GLTFSkin, Resource); diff --git a/modules/gltf/gltf_texture.cpp b/modules/gltf/structures/gltf_texture.cpp similarity index 100% rename from modules/gltf/gltf_texture.cpp rename to modules/gltf/structures/gltf_texture.cpp diff --git a/modules/gltf/gltf_texture.h b/modules/gltf/structures/gltf_texture.h similarity index 98% rename from modules/gltf/gltf_texture.h rename to modules/gltf/structures/gltf_texture.h index 66874ad489f..0fc731438a6 100644 --- a/modules/gltf/gltf_texture.h +++ b/modules/gltf/structures/gltf_texture.h @@ -31,8 +31,8 @@ #ifndef GLTF_TEXTURE_H #define GLTF_TEXTURE_H +#include "../gltf_defines.h" #include "core/resource.h" -#include "gltf_defines.h" class GLTFTexture : public Resource { GDCLASS(GLTFTexture, Resource); diff --git a/modules/gltf/gltf_texture_sampler.cpp b/modules/gltf/structures/gltf_texture_sampler.cpp similarity index 100% rename from modules/gltf/gltf_texture_sampler.cpp rename to modules/gltf/structures/gltf_texture_sampler.cpp diff --git a/modules/gltf/gltf_texture_sampler.h b/modules/gltf/structures/gltf_texture_sampler.h similarity index 100% rename from modules/gltf/gltf_texture_sampler.h rename to modules/gltf/structures/gltf_texture_sampler.h