feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -9,4 +9,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, "physics/*.cpp")
|
||||
if not env["disable_physics_3d"]:
|
||||
env_gltf.add_source_files(env.modules_sources, "physics/*.cpp")
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_DOCUMENT_EXTENSION_H
|
||||
#define GLTF_DOCUMENT_EXTENSION_H
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_state.h"
|
||||
|
||||
|
|
@ -94,5 +93,3 @@ public:
|
|||
GDVIRTUAL4R(Error, _export_node, Ref<GLTFState>, Ref<GLTFNode>, Dictionary, Node *);
|
||||
GDVIRTUAL1R(Error, _export_post, Ref<GLTFState>);
|
||||
};
|
||||
|
||||
#endif // GLTF_DOCUMENT_EXTENSION_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_DOCUMENT_EXTENSION_CONVERT_IMPORTER_MESH_H
|
||||
#define GLTF_DOCUMENT_EXTENSION_CONVERT_IMPORTER_MESH_H
|
||||
#pragma once
|
||||
|
||||
#include "gltf_document_extension.h"
|
||||
|
||||
|
|
@ -45,5 +44,3 @@ public:
|
|||
static MeshInstance3D *convert_importer_mesh_instance_3d(ImporterMeshInstance3D *p_importer_mesh_instance_3d);
|
||||
Error import_post(Ref<GLTFState> p_state, Node *p_root) override;
|
||||
};
|
||||
|
||||
#endif // GLTF_DOCUMENT_EXTENSION_CONVERT_IMPORTER_MESH_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_DOCUMENT_EXTENSION_TEXTURE_KTX_H
|
||||
#define GLTF_DOCUMENT_EXTENSION_TEXTURE_KTX_H
|
||||
#pragma once
|
||||
|
||||
#include "gltf_document_extension.h"
|
||||
|
||||
|
|
@ -43,5 +42,3 @@ public:
|
|||
Error parse_image_data(Ref<GLTFState> p_state, const PackedByteArray &p_image_data, const String &p_mime_type, Ref<Image> r_image) override;
|
||||
Error parse_texture_json(Ref<GLTFState> p_state, const Dictionary &p_texture_json, Ref<GLTFTexture> r_gltf_texture) override;
|
||||
};
|
||||
|
||||
#endif // GLTF_DOCUMENT_EXTENSION_TEXTURE_KTX_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_DOCUMENT_EXTENSION_TEXTURE_WEBP_H
|
||||
#define GLTF_DOCUMENT_EXTENSION_TEXTURE_WEBP_H
|
||||
#pragma once
|
||||
|
||||
#include "gltf_document_extension.h"
|
||||
|
||||
|
|
@ -49,5 +48,3 @@ public:
|
|||
Error save_image_at_path(Ref<GLTFState> p_state, Ref<Image> p_image, const String &p_full_path, const String &p_image_format, float p_lossy_quality) override;
|
||||
Error serialize_texture_json(Ref<GLTFState> p_state, Dictionary p_texture_json, Ref<GLTFTexture> p_gltf_texture, const String &p_image_format) override;
|
||||
};
|
||||
|
||||
#endif // GLTF_DOCUMENT_EXTENSION_TEXTURE_WEBP_H
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ Ref<GLTFLight> GLTFLight::from_node(const Light3D *p_light) {
|
|||
Ref<GLTFLight> l;
|
||||
l.instantiate();
|
||||
ERR_FAIL_NULL_V_MSG(p_light, l, "Tried to create a GLTFLight from a Light3D node, but the given node was null.");
|
||||
l->color = p_light->get_color();
|
||||
l->color = p_light->get_color().srgb_to_linear();
|
||||
if (cast_to<DirectionalLight3D>(p_light)) {
|
||||
l->light_type = "directional";
|
||||
const DirectionalLight3D *light = cast_to<const DirectionalLight3D>(p_light);
|
||||
|
|
@ -156,33 +156,33 @@ Ref<GLTFLight> GLTFLight::from_node(const Light3D *p_light) {
|
|||
}
|
||||
|
||||
Light3D *GLTFLight::to_node() const {
|
||||
Light3D *light = nullptr;
|
||||
if (light_type == "directional") {
|
||||
DirectionalLight3D *light = memnew(DirectionalLight3D);
|
||||
light->set_param(Light3D::PARAM_ENERGY, intensity);
|
||||
light->set_color(color);
|
||||
return light;
|
||||
}
|
||||
if (light_type == "point") {
|
||||
OmniLight3D *light = memnew(OmniLight3D);
|
||||
light->set_param(OmniLight3D::PARAM_ENERGY, intensity);
|
||||
light->set_param(OmniLight3D::PARAM_RANGE, CLAMP(range, 0, 4096));
|
||||
light->set_color(color);
|
||||
return light;
|
||||
}
|
||||
if (light_type == "spot") {
|
||||
SpotLight3D *light = memnew(SpotLight3D);
|
||||
light->set_param(SpotLight3D::PARAM_ENERGY, intensity);
|
||||
light->set_param(SpotLight3D::PARAM_RANGE, CLAMP(range, 0, 4096));
|
||||
light->set_param(SpotLight3D::PARAM_SPOT_ANGLE, Math::rad_to_deg(outer_cone_angle));
|
||||
light->set_color(color);
|
||||
DirectionalLight3D *dir_light = memnew(DirectionalLight3D);
|
||||
dir_light->set_param(Light3D::PARAM_ENERGY, intensity);
|
||||
light = dir_light;
|
||||
} else if (light_type == "point") {
|
||||
OmniLight3D *omni_light = memnew(OmniLight3D);
|
||||
omni_light->set_param(OmniLight3D::PARAM_ENERGY, intensity);
|
||||
omni_light->set_param(OmniLight3D::PARAM_RANGE, CLAMP(range, 0, 4096));
|
||||
light = omni_light;
|
||||
} else if (light_type == "spot") {
|
||||
SpotLight3D *spot_light = memnew(SpotLight3D);
|
||||
spot_light->set_param(SpotLight3D::PARAM_ENERGY, intensity);
|
||||
spot_light->set_param(SpotLight3D::PARAM_RANGE, CLAMP(range, 0, 4096));
|
||||
spot_light->set_param(SpotLight3D::PARAM_SPOT_ANGLE, Math::rad_to_deg(outer_cone_angle));
|
||||
// Line of best fit derived from guessing, see https://www.desmos.com/calculator/biiflubp8b
|
||||
// The points in desmos are not exact, except for (1, infinity).
|
||||
float angle_ratio = inner_cone_angle / outer_cone_angle;
|
||||
float angle_attenuation = 0.2 / (1 - angle_ratio) - 0.1;
|
||||
light->set_param(SpotLight3D::PARAM_SPOT_ATTENUATION, angle_attenuation);
|
||||
return light;
|
||||
spot_light->set_param(SpotLight3D::PARAM_SPOT_ATTENUATION, angle_attenuation);
|
||||
light = spot_light;
|
||||
} else {
|
||||
ERR_PRINT("Failed to create a Light3D node from GLTFLight, unknown light type '" + light_type + "'.");
|
||||
return nullptr;
|
||||
}
|
||||
return memnew(Light3D);
|
||||
light->set_color(color.linear_to_srgb());
|
||||
return light;
|
||||
}
|
||||
|
||||
Ref<GLTFLight> GLTFLight::from_dictionary(const Dictionary p_dictionary) {
|
||||
|
|
@ -195,7 +195,7 @@ Ref<GLTFLight> GLTFLight::from_dictionary(const Dictionary p_dictionary) {
|
|||
if (p_dictionary.has("color")) {
|
||||
const Array &arr = p_dictionary["color"];
|
||||
if (arr.size() == 3) {
|
||||
light->color = Color(arr[0], arr[1], arr[2]).linear_to_srgb();
|
||||
light->color = Color(arr[0], arr[1], arr[2]);
|
||||
} else {
|
||||
ERR_PRINT("Error parsing glTF light: The color must have exactly 3 numbers.");
|
||||
}
|
||||
|
|
@ -232,7 +232,7 @@ Dictionary GLTFLight::to_dictionary() const {
|
|||
if (intensity != 1.0f) {
|
||||
d["intensity"] = intensity;
|
||||
}
|
||||
if (light_type != "directional" && range != INFINITY) {
|
||||
if (light_type != "directional" && range != Math::INF) {
|
||||
d["range"] = range;
|
||||
}
|
||||
if (light_type == "spot") {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_LIGHT_H
|
||||
#define GLTF_LIGHT_H
|
||||
#pragma once
|
||||
|
||||
#include "core/io/resource.h"
|
||||
|
||||
|
|
@ -49,9 +48,9 @@ private:
|
|||
Color color = Color(1.0f, 1.0f, 1.0f);
|
||||
float intensity = 1.0f;
|
||||
String light_type;
|
||||
float range = INFINITY;
|
||||
float range = Math::INF;
|
||||
float inner_cone_angle = 0.0f;
|
||||
float outer_cone_angle = Math_TAU / 8.0f;
|
||||
float outer_cone_angle = Math::TAU / 8.0f;
|
||||
Dictionary additional_data;
|
||||
|
||||
public:
|
||||
|
|
@ -84,5 +83,3 @@ public:
|
|||
Variant get_additional_data(const StringName &p_extension_name);
|
||||
void set_additional_data(const StringName &p_extension_name, Variant p_additional_data);
|
||||
};
|
||||
|
||||
#endif // GLTF_LIGHT_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_SPEC_GLOSS_H
|
||||
#define GLTF_SPEC_GLOSS_H
|
||||
#pragma once
|
||||
|
||||
#include "core/io/resource.h"
|
||||
|
||||
|
|
@ -70,5 +69,3 @@ public:
|
|||
Ref<Image> get_spec_gloss_img();
|
||||
void set_spec_gloss_img(Ref<Image> p_spec_gloss_img);
|
||||
};
|
||||
|
||||
#endif // GLTF_SPEC_GLOSS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_DOCUMENT_EXTENSION_PHYSICS_H
|
||||
#define GLTF_DOCUMENT_EXTENSION_PHYSICS_H
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_document_extension.h"
|
||||
#include "gltf_physics_body.h"
|
||||
|
|
@ -51,5 +50,3 @@ public:
|
|||
Ref<GLTFObjectModelProperty> export_object_model_property(Ref<GLTFState> p_state, const NodePath &p_node_path, const Node *p_godot_node, GLTFNodeIndex p_gltf_node_index, const Object *p_target_object, int p_target_depth) override;
|
||||
Error export_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node, Dictionary &r_node_json, Node *p_scene_node) override;
|
||||
};
|
||||
|
||||
#endif // GLTF_DOCUMENT_EXTENSION_PHYSICS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_PHYSICS_BODY_H
|
||||
#define GLTF_PHYSICS_BODY_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/3d/physics/physics_body_3d.h"
|
||||
|
||||
|
|
@ -103,5 +102,3 @@ public:
|
|||
static Ref<GLTFPhysicsBody> from_dictionary(const Dictionary p_dictionary);
|
||||
Dictionary to_dictionary() const;
|
||||
};
|
||||
|
||||
#endif // GLTF_PHYSICS_BODY_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_PHYSICS_SHAPE_H
|
||||
#define GLTF_PHYSICS_SHAPE_H
|
||||
#pragma once
|
||||
|
||||
#include "../../gltf_defines.h"
|
||||
|
||||
|
|
@ -89,5 +88,3 @@ public:
|
|||
static Ref<GLTFPhysicsShape> from_dictionary(const Dictionary p_dictionary);
|
||||
Dictionary to_dictionary() const;
|
||||
};
|
||||
|
||||
#endif // GLTF_PHYSICS_SHAPE_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue