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
|
|
@ -5,7 +5,7 @@
|
|||
</brief_description>
|
||||
<description>
|
||||
Imports Blender scenes in the [code].blend[/code] file format through the glTF 2.0 3D import pipeline. This importer requires Blender to be installed by the user, so that it can be used to export the scene as glTF 2.0.
|
||||
The location of the Blender binary is set via the [code]filesystem/import/blender/blender_path[/code] editor setting.
|
||||
The location of the Blender binary is set via the [member EditorSettings.filesystem/import/blender/blender_path] setting.
|
||||
This importer is only used if [member ProjectSettings.filesystem/import/blender/enabled] is enabled, otherwise [code].blend[/code] files present in the project folder are not imported.
|
||||
Blend import requires Blender 3.0.
|
||||
Internally, the EditorSceneFormatImporterBlend uses the Blender glTF "Use Original" mode to reference external textures.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
</tutorials>
|
||||
<members>
|
||||
<member name="accessor_type" type="int" setter="set_accessor_type" getter="get_accessor_type" enum="GLTFAccessor.GLTFAccessorType" default="0">
|
||||
The glTF accessor type as an enum. Possible values are 0 for "SCALAR", 1 for "VEC2", 2 for "VEC3", 3 for "VEC4", 4 for "MAT2", 5 for "MAT3", and 6 for "MAT4".
|
||||
The glTF accessor type, as an enum.
|
||||
</member>
|
||||
<member name="buffer_view" type="int" setter="set_buffer_view" getter="get_buffer_view" default="-1">
|
||||
The index of the buffer view this accessor is referencing. If [code]-1[/code], this accessor is not referencing any buffer view.
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
The offset relative to the start of the bufferView in bytes.
|
||||
</member>
|
||||
<member name="type" type="int" setter="set_type" getter="get_type" deprecated="Use [member accessor_type] instead.">
|
||||
The glTF accessor type as an enum. Use [member accessor_type] instead.
|
||||
The glTF accessor type, as an [int]. Possible values are [code]0[/code] for "SCALAR", [code]1[/code] for "VEC2", [code]2[/code] for "VEC3", [code]3[/code] for "VEC4", [code]4[/code] for "MAT2", [code]5[/code] for "MAT3", and [code]6[/code] for "MAT4".
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@
|
|||
</methods>
|
||||
<members>
|
||||
<member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)" keywords="colour">
|
||||
The [Color] of the light. Defaults to white. A black color causes the light to have no effect.
|
||||
The [Color] of the light in linear space. Defaults to white. A black color causes the light to have no effect.
|
||||
This value is linear to match glTF, but will be converted to nonlinear sRGB when creating a Godot [Light3D] node upon import, or converted to linear when exporting a Godot [Light3D] to glTF.
|
||||
</member>
|
||||
<member name="inner_cone_angle" type="float" setter="set_inner_cone_angle" getter="get_inner_cone_angle" default="0.0">
|
||||
The inner angle of the cone in a spotlight. Must be less than or equal to the outer cone angle.
|
||||
|
|
@ -70,7 +71,7 @@
|
|||
At this angle, the light drops off to zero brightness. Between the inner and outer cone angles, there is a transition from full brightness to zero brightness. If this angle is a half turn, then the spotlight emits in all directions. When creating a Godot [SpotLight3D], the outer cone angle is used as the angle of the spotlight.
|
||||
</member>
|
||||
<member name="range" type="float" setter="set_range" getter="get_range" default="inf">
|
||||
The range of the light, beyond which the light has no effect. glTF lights with no range defined behave like physical lights (which have infinite range). When creating a Godot light, the range is clamped to 4096.
|
||||
The range of the light, beyond which the light has no effect. glTF lights with no range defined behave like physical lights (which have infinite range). When creating a Godot light, the range is clamped to [code]4096.0[/code].
|
||||
</member>
|
||||
</members>
|
||||
</class>
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
</methods>
|
||||
<members>
|
||||
<member name="camera" type="int" setter="set_camera" getter="get_camera" default="-1">
|
||||
If this glTF node is a camera, the index of the [GLTFCamera] in the [GLTFState] that describes the camera's properties. If -1, this node is not a camera.
|
||||
If this glTF node is a camera, the index of the [GLTFCamera] in the [GLTFState] that describes the camera's properties. If [code]-1[/code], this node is not a camera.
|
||||
</member>
|
||||
<member name="children" type="PackedInt32Array" setter="set_children" getter="get_children" default="PackedInt32Array()">
|
||||
The indices of the child nodes in the [GLTFState]. If this glTF node has no children, this will be an empty array.
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
If set, this [Expression] will be used to convert the property value from the Godot property to the value expected by the glTF object model. This is useful when the glTF object model uses a different unit system, or when the data needs to be transformed in some way. If [code]null[/code], the value will be copied as-is.
|
||||
</member>
|
||||
<member name="json_pointers" type="PackedStringArray[]" setter="set_json_pointers" getter="get_json_pointers" default="[]">
|
||||
The glTF object model JSON pointers used to identify the property in the glTF object model. In most cases, there will be only one item in this array, but niche cases may require multiple pointers. The items are themselves arrays which represent the JSON pointer split into its components.
|
||||
The glTF object model JSON pointers used to identify the property in the glTF object model. In most cases, there will be only one item in this array, but specific cases may require multiple pointers. The items are themselves arrays which represent the JSON pointer split into its components.
|
||||
</member>
|
||||
<member name="node_paths" type="NodePath[]" setter="set_node_paths" getter="get_node_paths" default="[]">
|
||||
An array of [NodePath]s that point to a property, or multiple properties, in the Godot scene tree. On import, this will either be set by [GLTFDocument], or by a [GLTFDocumentExtension] class. For simple cases, use [method append_path_to_property] to add properties to this array.
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@
|
|||
The angular velocity of the physics body, in radians per second. This is only used when the body type is "rigid" or "vehicle".
|
||||
</member>
|
||||
<member name="body_type" type="String" setter="set_body_type" getter="get_body_type" default=""rigid"">
|
||||
The type of the body. When importing, this controls what type of [CollisionObject3D] node Godot should generate. Valid values are "static", "animatable", "character", "rigid", "vehicle", and "trigger". When exporting, this will be squashed down to one of "static", "kinematic", or "dynamic" motion types, or the "trigger" property.
|
||||
The type of the body.
|
||||
When importing, this controls what type of [CollisionObject3D] node Godot should generate. Valid values are [code]"static"[/code], [code]"animatable"[/code], [code]"character"[/code], [code]"rigid"[/code], [code]"vehicle"[/code], and [code]"trigger"[/code].
|
||||
When exporting, this will be squashed down to one of [code]"static"[/code], [code]"kinematic"[/code], or [code]"dynamic"[/code] motion types, or the [code]"trigger"[/code] property.
|
||||
</member>
|
||||
<member name="center_of_mass" type="Vector3" setter="set_center_of_mass" getter="get_center_of_mass" default="Vector3(0, 0, 0)">
|
||||
The center of mass of the body, in meters. This is in local space relative to the body. By default, the center of the mass is the body's origin.
|
||||
|
|
|
|||
|
|
@ -56,26 +56,26 @@
|
|||
</methods>
|
||||
<members>
|
||||
<member name="height" type="float" setter="set_height" getter="get_height" default="2.0">
|
||||
The height of the shape, in meters. This is only used when the shape type is "capsule" or "cylinder". This value should not be negative, and for "capsule" it should be at least twice the radius.
|
||||
The height of the shape, in meters. This is only used when the shape type is [code]"capsule"[/code] or [code]"cylinder"[/code]. This value should not be negative, and for [code]"capsule"[/code] it should be at least twice the radius.
|
||||
</member>
|
||||
<member name="importer_mesh" type="ImporterMesh" setter="set_importer_mesh" getter="get_importer_mesh">
|
||||
The [ImporterMesh] resource of the shape. This is only used when the shape type is "hull" (convex hull) or "trimesh" (concave trimesh).
|
||||
The [ImporterMesh] resource of the shape. This is only used when the shape type is [code]"hull"[/code] (convex hull) or [code]"trimesh"[/code] (concave trimesh).
|
||||
</member>
|
||||
<member name="is_trigger" type="bool" setter="set_is_trigger" getter="get_is_trigger" default="false">
|
||||
If [code]true[/code], indicates that this shape is a trigger. For Godot, this means that the shape should be a child of an Area3D node.
|
||||
If [code]true[/code], indicates that this shape is a trigger. For Godot, this means that the shape should be a child of an [Area3D] node.
|
||||
This is the only variable not used in the [method to_node] method, it's intended to be used alongside when deciding where to add the generated node as a child.
|
||||
</member>
|
||||
<member name="mesh_index" type="int" setter="set_mesh_index" getter="get_mesh_index" default="-1">
|
||||
The index of the shape's mesh in the glTF file. This is only used when the shape type is "hull" (convex hull) or "trimesh" (concave trimesh).
|
||||
The index of the shape's mesh in the glTF file. This is only used when the shape type is [code]"hull"[/code] (convex hull) or [code]"trimesh"[/code] (concave trimesh).
|
||||
</member>
|
||||
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="0.5">
|
||||
The radius of the shape, in meters. This is only used when the shape type is "capsule", "cylinder", or "sphere". This value should not be negative.
|
||||
The radius of the shape, in meters. This is only used when the shape type is [code]"capsule"[/code], [code]"cylinder"[/code], or [code]"sphere"[/code]. This value should not be negative.
|
||||
</member>
|
||||
<member name="shape_type" type="String" setter="set_shape_type" getter="get_shape_type" default="""">
|
||||
The type of shape this shape represents. Valid values are "box", "capsule", "cylinder", "sphere", "hull", and "trimesh".
|
||||
The type of shape this shape represents. Valid values are [code]"box"[/code], [code]"capsule"[/code], [code]"cylinder"[/code], [code]"sphere"[/code], [code]"hull"[/code], and [code]"trimesh"[/code].
|
||||
</member>
|
||||
<member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(1, 1, 1)">
|
||||
The size of the shape, in meters. This is only used when the shape type is "box", and it represents the "diameter" of the box. This value should not be negative.
|
||||
The size of the shape, in meters. This is only used when the shape type is [code]"box"[/code], and it represents the [code]"diameter"[/code] of the box. This value should not be negative.
|
||||
</member>
|
||||
</members>
|
||||
</class>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<param index="0" name="data" type="PackedByteArray" />
|
||||
<param index="1" name="deduplication" type="bool" />
|
||||
<description>
|
||||
Appends the given byte array data to the buffers and creates a [GLTFBufferView] for it. The index of the destination [GLTFBufferView] is returned. If [param deduplication] is [code]true[/code], the buffers will first be searched for duplicate data, otherwise new bytes will always be appended.
|
||||
Appends the given byte array [param data] to the buffers and creates a [GLTFBufferView] for it. The index of the destination [GLTFBufferView] is returned. If [param deduplication] is [code]true[/code], the buffers are first searched for duplicate data, otherwise new bytes are always appended.
|
||||
</description>
|
||||
</method>
|
||||
<method name="append_gltf_node">
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
<param index="1" name="godot_scene_node" type="Node" />
|
||||
<param index="2" name="parent_node_index" type="int" />
|
||||
<description>
|
||||
Append the given [GLTFNode] to the state, and return its new index. This can be used to export one Godot node as multiple glTF nodes, or inject new glTF nodes at import time. On import, this must be called before [method GLTFDocumentExtension._generate_scene_node] finishes for the parent node. On export, this must be called before [method GLTFDocumentExtension._export_node] runs for the parent node.
|
||||
Appends the given [GLTFNode] to the state, and returns its new index. This can be used to export one Godot node as multiple glTF nodes, or inject new glTF nodes at import time. On import, this must be called before [method GLTFDocumentExtension._generate_scene_node] finishes for the parent node. On export, this must be called before [method GLTFDocumentExtension._export_node] runs for the parent node.
|
||||
The [param godot_scene_node] parameter is the Godot scene node that corresponds to this glTF node. This is highly recommended to be set to a valid node, but may be [code]null[/code] if there is no corresponding Godot scene node. One Godot scene node may be used for multiple glTF nodes, so if exporting multiple glTF nodes for one Godot scene node, use the same Godot scene node for each.
|
||||
The [param parent_node_index] parameter is the index of the parent [GLTFNode] in the state. If [code]-1[/code], the node will be a root node, otherwise the new node will be added to the parent's list of children. The index will also be written to the [member GLTFNode.parent] property of the new node.
|
||||
</description>
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "editor_import_blend_runner.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
#include "core/io/http_client.h"
|
||||
#include "editor/editor_file_system.h"
|
||||
#include "editor/editor_node.h"
|
||||
|
|
@ -94,11 +92,10 @@ bpy.ops.export_scene.gltf(**opts['gltf_options'])
|
|||
|
||||
String dict_to_python(const Dictionary &p_dict) {
|
||||
String entries;
|
||||
Array dict_keys = p_dict.keys();
|
||||
for (int i = 0; i < dict_keys.size(); i++) {
|
||||
const String key = dict_keys[i];
|
||||
for (const KeyValue<Variant, Variant> &kv : p_dict) {
|
||||
const String &key = kv.key;
|
||||
String value;
|
||||
Variant raw_value = p_dict[key];
|
||||
const Variant &raw_value = kv.value;
|
||||
|
||||
switch (raw_value.get_type()) {
|
||||
case Variant::Type::BOOL: {
|
||||
|
|
@ -127,11 +124,10 @@ String dict_to_python(const Dictionary &p_dict) {
|
|||
|
||||
String dict_to_xmlrpc(const Dictionary &p_dict) {
|
||||
String members;
|
||||
Array dict_keys = p_dict.keys();
|
||||
for (int i = 0; i < dict_keys.size(); i++) {
|
||||
const String key = dict_keys[i];
|
||||
for (const KeyValue<Variant, Variant> &kv : p_dict) {
|
||||
const String &key = kv.key;
|
||||
String value;
|
||||
Variant raw_value = p_dict[key];
|
||||
const Variant &raw_value = kv.value;
|
||||
|
||||
switch (raw_value.get_type()) {
|
||||
case Variant::Type::BOOL: {
|
||||
|
|
@ -392,5 +388,3 @@ EditorImportBlendRunner::EditorImportBlendRunner() {
|
|||
|
||||
EditorFileSystem::get_singleton()->connect("resources_reimported", callable_mp(this, &EditorImportBlendRunner::_resources_reimported));
|
||||
}
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
|
|
|||
|
|
@ -28,10 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef EDITOR_IMPORT_BLEND_RUNNER_H
|
||||
#define EDITOR_IMPORT_BLEND_RUNNER_H
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#pragma once
|
||||
|
||||
#include "core/io/http_client.h"
|
||||
#include "core/os/os.h"
|
||||
|
|
@ -66,7 +63,3 @@ public:
|
|||
|
||||
EditorImportBlendRunner();
|
||||
};
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#endif // EDITOR_IMPORT_BLEND_RUNNER_H
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "editor_scene_exporter_gltf_plugin.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
#include "editor_scene_exporter_gltf_settings.h"
|
||||
|
||||
#include "editor/editor_file_system.h"
|
||||
|
|
@ -118,5 +116,3 @@ void SceneExporterGLTFPlugin::_export_scene_as_gltf(const String &p_file_path) {
|
|||
}
|
||||
EditorFileSystem::get_singleton()->scan_changes();
|
||||
}
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
|
|
|||
|
|
@ -28,10 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
|
||||
#define EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_document.h"
|
||||
#include "editor_scene_exporter_gltf_settings.h"
|
||||
|
|
@ -56,7 +53,3 @@ public:
|
|||
bool has_main_screen() const override;
|
||||
SceneExporterGLTFPlugin();
|
||||
};
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#endif // EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
|
||||
|
|
|
|||
|
|
@ -28,10 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef EDITOR_SCENE_EXPORTER_GLTF_SETTINGS_H
|
||||
#define EDITOR_SCENE_EXPORTER_GLTF_SETTINGS_H
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_document.h"
|
||||
|
||||
|
|
@ -63,7 +60,3 @@ public:
|
|||
double get_bake_fps() const;
|
||||
void set_bake_fps(const double p_bake_fps);
|
||||
};
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#endif // EDITOR_SCENE_EXPORTER_GLTF_SETTINGS_H
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "editor_scene_importer_blend.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
#include "../gltf_defines.h"
|
||||
#include "../gltf_document.h"
|
||||
#include "editor_import_blend_runner.h"
|
||||
|
|
@ -517,6 +515,7 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() {
|
|||
|
||||
blender_path = memnew(LineEdit);
|
||||
blender_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
blender_path->set_accessibility_name(TTRC("Path"));
|
||||
hb->add_child(blender_path);
|
||||
|
||||
blender_path_browse = memnew(Button);
|
||||
|
|
@ -595,8 +594,3 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
EditorFileSystemImportFormatSupportQueryBlend::EditorFileSystemImportFormatSupportQueryBlend() {
|
||||
}
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
|
|
|||
|
|
@ -28,10 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef EDITOR_SCENE_IMPORTER_BLEND_H
|
||||
#define EDITOR_SCENE_IMPORTER_BLEND_H
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#pragma once
|
||||
|
||||
#include "editor/editor_file_system.h"
|
||||
#include "editor/import/3d/resource_importer_scene.h"
|
||||
|
|
@ -108,10 +105,4 @@ public:
|
|||
virtual bool is_active() const override;
|
||||
virtual Vector<String> get_file_extensions() const override;
|
||||
virtual bool query() override;
|
||||
|
||||
EditorFileSystemImportFormatSupportQueryBlend();
|
||||
};
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#endif // EDITOR_SCENE_IMPORTER_BLEND_H
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "editor_scene_importer_gltf.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
#include "../gltf_defines.h"
|
||||
#include "../gltf_document.h"
|
||||
|
||||
|
|
@ -103,5 +101,3 @@ Variant EditorSceneFormatImporterGLTF::get_option_visibility(const String &p_pat
|
|||
const String &p_option, const HashMap<StringName, Variant> &p_options) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
|
|
|||
|
|
@ -28,10 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef EDITOR_SCENE_IMPORTER_GLTF_H
|
||||
#define EDITOR_SCENE_IMPORTER_GLTF_H
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#pragma once
|
||||
|
||||
#include "editor/import/3d/resource_importer_scene.h"
|
||||
|
||||
|
|
@ -52,7 +49,3 @@ public:
|
|||
virtual Variant get_option_visibility(const String &p_path, const String &p_scene_import_type,
|
||||
const String &p_option, const HashMap<StringName, Variant> &p_options) override;
|
||||
};
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#endif // EDITOR_SCENE_IMPORTER_GLTF_H
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_DEFINES_H
|
||||
#define GLTF_DEFINES_H
|
||||
#pragma once
|
||||
|
||||
// This file should only be included by other headers.
|
||||
|
||||
|
|
@ -66,5 +65,3 @@ using GLTFSkeletonIndex = int;
|
|||
using GLTFSkinIndex = int;
|
||||
using GLTFTextureIndex = int;
|
||||
using GLTFTextureSamplerIndex = int;
|
||||
|
||||
#endif // GLTF_DEFINES_H
|
||||
|
|
|
|||
|
|
@ -62,6 +62,15 @@
|
|||
#include "editor/editor_file_system.h"
|
||||
#endif
|
||||
|
||||
#include "modules/modules_enabled.gen.h" // For csg, gridmap.
|
||||
|
||||
#ifdef MODULE_CSG_ENABLED
|
||||
#include "modules/csg/csg_shape.h"
|
||||
#endif
|
||||
#ifdef MODULE_GRIDMAP_ENABLED
|
||||
#include "modules/gridmap/grid_map.h"
|
||||
#endif
|
||||
|
||||
// FIXME: Hardcoded to avoid editor dependency.
|
||||
#define GLTF_IMPORT_GENERATE_TANGENT_ARRAYS 8
|
||||
#define GLTF_IMPORT_USE_NAMED_SKIN_BINDS 16
|
||||
|
|
@ -70,7 +79,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdint>
|
||||
|
||||
constexpr int COMPONENT_COUNT_FOR_ACCESSOR_TYPE[7] = {
|
||||
1, 2, 3, 4, 4, 9, 16
|
||||
|
|
@ -291,8 +299,7 @@ Error GLTFDocument::_parse_json(const String &p_path, Ref<GLTFState> p_state) {
|
|||
Vector<uint8_t> array;
|
||||
array.resize(file->get_length());
|
||||
file->get_buffer(array.ptrw(), array.size());
|
||||
String text;
|
||||
text.parse_utf8((const char *)array.ptr(), array.size());
|
||||
String text = String::utf8((const char *)array.ptr(), array.size());
|
||||
|
||||
JSON json;
|
||||
err = json.parse(text);
|
||||
|
|
@ -322,8 +329,7 @@ Error GLTFDocument::_parse_glb(Ref<FileAccess> p_file, Ref<GLTFState> p_state) {
|
|||
uint32_t len = p_file->get_buffer(json_data.ptrw(), chunk_length);
|
||||
ERR_FAIL_COND_V(len != chunk_length, ERR_FILE_CORRUPT);
|
||||
|
||||
String text;
|
||||
text.parse_utf8((const char *)json_data.ptr(), json_data.size());
|
||||
String text = String::utf8((const char *)json_data.ptr(), json_data.size());
|
||||
|
||||
JSON json;
|
||||
Error err = json.parse(text);
|
||||
|
|
@ -525,8 +531,7 @@ String GLTFDocument::_gen_unique_animation_name(Ref<GLTFState> p_state, const St
|
|||
|
||||
String GLTFDocument::_sanitize_bone_name(const String &p_name) {
|
||||
String bone_name = p_name;
|
||||
bone_name = bone_name.replace(":", "_");
|
||||
bone_name = bone_name.replace("/", "_");
|
||||
bone_name = bone_name.replace_chars(":/", '_');
|
||||
return bone_name;
|
||||
}
|
||||
|
||||
|
|
@ -735,7 +740,7 @@ Error GLTFDocument::_encode_buffer_glb(Ref<GLTFState> p_state, const String &p_p
|
|||
if (file.is_null()) {
|
||||
return err;
|
||||
}
|
||||
if (buffer_data.size() == 0) {
|
||||
if (buffer_data.is_empty()) {
|
||||
return OK;
|
||||
}
|
||||
file->create(FileAccess::ACCESS_RESOURCES);
|
||||
|
|
@ -767,7 +772,7 @@ Error GLTFDocument::_encode_buffer_bins(Ref<GLTFState> p_state, const String &p_
|
|||
if (file.is_null()) {
|
||||
return err;
|
||||
}
|
||||
if (buffer_data.size() == 0) {
|
||||
if (buffer_data.is_empty()) {
|
||||
return OK;
|
||||
}
|
||||
file->create(FileAccess::ACCESS_RESOURCES);
|
||||
|
|
@ -806,8 +811,8 @@ Error GLTFDocument::_parse_buffers(Ref<GLTFState> p_state, const String &p_base_
|
|||
buffer_data = _parse_base64_uri(uri);
|
||||
} else { // Relative path to an external image file.
|
||||
ERR_FAIL_COND_V(p_base_path.is_empty(), ERR_INVALID_PARAMETER);
|
||||
uri = uri.uri_decode();
|
||||
uri = p_base_path.path_join(uri).replace("\\", "/"); // Fix for Windows.
|
||||
uri = uri.uri_file_decode();
|
||||
uri = p_base_path.path_join(uri).replace_char('\\', '/'); // Fix for Windows.
|
||||
ERR_FAIL_COND_V_MSG(!FileAccess::exists(uri), ERR_FILE_NOT_FOUND, "glTF: Binary file not found: " + uri);
|
||||
buffer_data = FileAccess::get_file_as_bytes(uri);
|
||||
ERR_FAIL_COND_V_MSG(buffer_data.is_empty(), ERR_PARSE_ERROR, "glTF: Couldn't load binary file as an array: " + uri);
|
||||
|
|
@ -882,6 +887,9 @@ Error GLTFDocument::_parse_buffer_views(Ref<GLTFState> p_state) {
|
|||
|
||||
if (d.has("byteStride")) {
|
||||
buffer_view->byte_stride = d["byteStride"];
|
||||
if (buffer_view->byte_stride < 4 || buffer_view->byte_stride > 252 || buffer_view->byte_stride % 4 != 0) {
|
||||
ERR_PRINT("glTF import: Invalid byte stride " + itos(buffer_view->byte_stride) + " for buffer view at index " + itos(i) + " while importing file '" + p_state->filename + "'. If defined, byte stride must be a multiple of 4 and between 4 and 252.");
|
||||
}
|
||||
}
|
||||
|
||||
if (d.has("target")) {
|
||||
|
|
@ -1023,6 +1031,9 @@ Error GLTFDocument::_parse_accessors(Ref<GLTFState> p_state) {
|
|||
accessor->component_type = (GLTFAccessor::GLTFComponentType)(int32_t)d["componentType"];
|
||||
ERR_FAIL_COND_V(!d.has("count"), ERR_PARSE_ERROR);
|
||||
accessor->count = d["count"];
|
||||
if (accessor->count <= 0) {
|
||||
ERR_PRINT("glTF import: Invalid accessor count " + itos(accessor->count) + " for accessor at index " + itos(i) + " while importing file '" + p_state->filename + "'. Accessor count must be greater than 0.");
|
||||
}
|
||||
ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR);
|
||||
accessor->accessor_type = _get_accessor_type_from_str(d["type"]);
|
||||
|
||||
|
|
@ -1426,7 +1437,7 @@ Error GLTFDocument::_decode_buffer_view(Ref<GLTFState> p_state, double *p_dst, c
|
|||
const Ref<GLTFBufferView> bv = p_state->buffer_views[p_buffer_view];
|
||||
|
||||
int stride = p_element_size;
|
||||
if (bv->byte_stride != -1) {
|
||||
if (bv->byte_stride > 0) {
|
||||
stride = bv->byte_stride;
|
||||
}
|
||||
if (p_for_vertex && stride % 4) {
|
||||
|
|
@ -1641,7 +1652,7 @@ Vector<double> GLTFDocument::_decode_accessor(Ref<GLTFState> p_state, const GLTF
|
|||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_ints(Ref<GLTFState> p_state, const Vector<int32_t> p_attribs, const bool p_for_vertex, const bool p_for_vertex_indices) {
|
||||
if (p_attribs.size() == 0) {
|
||||
if (p_attribs.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
const int element_count = 1;
|
||||
|
|
@ -1706,7 +1717,7 @@ Vector<int> GLTFDocument::_decode_accessor_as_ints(Ref<GLTFState> p_state, const
|
|||
const Vector<double> attribs = _decode_accessor(p_state, p_accessor, p_for_vertex);
|
||||
Vector<int> ret;
|
||||
|
||||
if (attribs.size() == 0) {
|
||||
if (attribs.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1731,7 +1742,7 @@ Vector<float> GLTFDocument::_decode_accessor_as_floats(Ref<GLTFState> p_state, c
|
|||
const Vector<double> attribs = _decode_accessor(p_state, p_accessor, p_for_vertex);
|
||||
Vector<float> ret;
|
||||
|
||||
if (attribs.size() == 0) {
|
||||
if (attribs.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1762,7 +1773,7 @@ void GLTFDocument::_round_min_max_components(Vector<double> &r_type_min, Vector<
|
|||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec2(Ref<GLTFState> p_state, const Vector<Vector2> p_attribs, const bool p_for_vertex) {
|
||||
if (p_attribs.size() == 0) {
|
||||
if (p_attribs.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
const int element_count = 2;
|
||||
|
|
@ -1812,7 +1823,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec2(Ref<GLTFState> p_state,
|
|||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_color(Ref<GLTFState> p_state, const Vector<Color> p_attribs, const bool p_for_vertex) {
|
||||
if (p_attribs.size() == 0) {
|
||||
if (p_attribs.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1878,7 +1889,7 @@ void GLTFDocument::_calc_accessor_min_max(int p_i, const int p_element_count, Ve
|
|||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_weights(Ref<GLTFState> p_state, const Vector<Color> p_attribs, const bool p_for_vertex) {
|
||||
if (p_attribs.size() == 0) {
|
||||
if (p_attribs.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1932,7 +1943,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_weights(Ref<GLTFState> p_sta
|
|||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_joints(Ref<GLTFState> p_state, const Vector<Color> p_attribs, const bool p_for_vertex) {
|
||||
if (p_attribs.size() == 0) {
|
||||
if (p_attribs.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1983,7 +1994,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_joints(Ref<GLTFState> p_stat
|
|||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_quaternions(Ref<GLTFState> p_state, const Vector<Quaternion> p_attribs, const bool p_for_vertex) {
|
||||
if (p_attribs.size() == 0) {
|
||||
if (p_attribs.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
const int element_count = 4;
|
||||
|
|
@ -2039,7 +2050,7 @@ Vector<Vector2> GLTFDocument::_decode_accessor_as_vec2(Ref<GLTFState> p_state, c
|
|||
const Vector<double> attribs = _decode_accessor(p_state, p_accessor, p_for_vertex);
|
||||
Vector<Vector2> ret;
|
||||
|
||||
if (attribs.size() == 0) {
|
||||
if (attribs.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -2062,7 +2073,7 @@ Vector<Vector2> GLTFDocument::_decode_accessor_as_vec2(Ref<GLTFState> p_state, c
|
|||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_floats(Ref<GLTFState> p_state, const Vector<double> p_attribs, const bool p_for_vertex) {
|
||||
if (p_attribs.size() == 0) {
|
||||
if (p_attribs.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
const int element_count = 1;
|
||||
|
|
@ -2111,7 +2122,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_floats(Ref<GLTFState> p_stat
|
|||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec3(Ref<GLTFState> p_state, const Vector<Vector3> p_attribs, const bool p_for_vertex) {
|
||||
if (p_attribs.size() == 0) {
|
||||
if (p_attribs.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
const int element_count = 3;
|
||||
|
|
@ -2161,7 +2172,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec3(Ref<GLTFState> p_state,
|
|||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_sparse_accessor_as_vec3(Ref<GLTFState> p_state, const Vector<Vector3> p_attribs, const Vector<Vector3> p_reference_attribs, const float p_reference_multiplier, const bool p_for_vertex, const GLTFAccessorIndex p_reference_accessor) {
|
||||
if (p_attribs.size() == 0) {
|
||||
if (p_attribs.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -2270,7 +2281,7 @@ GLTFAccessorIndex GLTFDocument::_encode_sparse_accessor_as_vec3(Ref<GLTFState> p
|
|||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_xform(Ref<GLTFState> p_state, const Vector<Transform3D> p_attribs, const bool p_for_vertex) {
|
||||
if (p_attribs.size() == 0) {
|
||||
if (p_attribs.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
const int element_count = 16;
|
||||
|
|
@ -2345,7 +2356,7 @@ Vector<Vector3> GLTFDocument::_decode_accessor_as_vec3(Ref<GLTFState> p_state, c
|
|||
const Vector<double> attribs = _decode_accessor(p_state, p_accessor, p_for_vertex);
|
||||
Vector<Vector3> ret;
|
||||
|
||||
if (attribs.size() == 0) {
|
||||
if (attribs.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -2371,7 +2382,7 @@ Vector<Color> GLTFDocument::_decode_accessor_as_color(Ref<GLTFState> p_state, co
|
|||
const Vector<double> attribs = _decode_accessor(p_state, p_accessor, p_for_vertex);
|
||||
Vector<Color> ret;
|
||||
|
||||
if (attribs.size() == 0) {
|
||||
if (attribs.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -2403,7 +2414,7 @@ Vector<Quaternion> GLTFDocument::_decode_accessor_as_quaternion(Ref<GLTFState> p
|
|||
const Vector<double> attribs = _decode_accessor(p_state, p_accessor, p_for_vertex);
|
||||
Vector<Quaternion> ret;
|
||||
|
||||
if (attribs.size() == 0) {
|
||||
if (attribs.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -2422,7 +2433,7 @@ Vector<Transform2D> GLTFDocument::_decode_accessor_as_xform2d(Ref<GLTFState> p_s
|
|||
const Vector<double> attribs = _decode_accessor(p_state, p_accessor, p_for_vertex);
|
||||
Vector<Transform2D> ret;
|
||||
|
||||
if (attribs.size() == 0) {
|
||||
if (attribs.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -2439,7 +2450,7 @@ Vector<Basis> GLTFDocument::_decode_accessor_as_basis(Ref<GLTFState> p_state, co
|
|||
const Vector<double> attribs = _decode_accessor(p_state, p_accessor, p_for_vertex);
|
||||
Vector<Basis> ret;
|
||||
|
||||
if (attribs.size() == 0) {
|
||||
if (attribs.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -2457,7 +2468,7 @@ Vector<Transform3D> GLTFDocument::_decode_accessor_as_xform(Ref<GLTFState> p_sta
|
|||
const Vector<double> attribs = _decode_accessor(p_state, p_accessor, p_for_vertex);
|
||||
Vector<Transform3D> ret;
|
||||
|
||||
if (attribs.size() == 0) {
|
||||
if (attribs.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -3185,9 +3196,11 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> p_state) {
|
|||
primitives.push_back(primitive);
|
||||
}
|
||||
|
||||
Dictionary e;
|
||||
e["targetNames"] = target_names;
|
||||
gltf_mesh["extras"] = e;
|
||||
if (!target_names.is_empty()) {
|
||||
Dictionary e;
|
||||
e["targetNames"] = target_names;
|
||||
gltf_mesh["extras"] = e;
|
||||
}
|
||||
_attach_meta_to_extras(import_mesh, gltf_mesh);
|
||||
|
||||
weights.resize(target_names.size());
|
||||
|
|
@ -3573,11 +3586,16 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) {
|
|||
// Compression is enabled, so let's validate that the normals and tangents are correct.
|
||||
Vector<Vector3> normals = array[Mesh::ARRAY_NORMAL];
|
||||
Vector<float> tangents = array[Mesh::ARRAY_TANGENT];
|
||||
for (int vert = 0; vert < normals.size(); vert++) {
|
||||
Vector3 tan = Vector3(tangents[vert * 4 + 0], tangents[vert * 4 + 1], tangents[vert * 4 + 2]);
|
||||
if (abs(tan.dot(normals[vert])) > 0.0001) {
|
||||
// Tangent is not perpendicular to the normal, so we can't use compression.
|
||||
flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
|
||||
if (unlikely(tangents.size() < normals.size() * 4)) {
|
||||
ERR_PRINT("glTF import: Mesh " + itos(i) + " has invalid tangents.");
|
||||
flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
|
||||
} else {
|
||||
for (int vert = 0; vert < normals.size(); vert++) {
|
||||
Vector3 tan = Vector3(tangents[vert * 4 + 0], tangents[vert * 4 + 1], tangents[vert * 4 + 2]);
|
||||
if (abs(tan.dot(normals[vert])) > 0.0001) {
|
||||
// Tangent is not perpendicular to the normal, so we can't use compression.
|
||||
flags &= ~RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3824,10 +3842,9 @@ Error GLTFDocument::_serialize_images(Ref<GLTFState> p_state) {
|
|||
if (p_state->filename.to_lower().ends_with("gltf")) {
|
||||
String img_name = p_state->images[i]->get_name();
|
||||
if (img_name.is_empty()) {
|
||||
img_name = itos(i);
|
||||
img_name = itos(i).pad_zeros(3);
|
||||
}
|
||||
img_name = _gen_unique_name(p_state, img_name);
|
||||
img_name = img_name.pad_zeros(3);
|
||||
String relative_texture_dir = "textures";
|
||||
String full_texture_dir = p_state->base_path.path_join(relative_texture_dir);
|
||||
Ref<DirAccess> da = DirAccess::open(p_state->base_path);
|
||||
|
|
@ -4116,8 +4133,8 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> p_state, const String &p_base_p
|
|||
}
|
||||
} else { // Relative path to an external image file.
|
||||
ERR_FAIL_COND_V(p_base_path.is_empty(), ERR_INVALID_PARAMETER);
|
||||
uri = uri.uri_decode();
|
||||
uri = p_base_path.path_join(uri).replace("\\", "/"); // Fix for Windows.
|
||||
uri = uri.uri_file_decode();
|
||||
uri = p_base_path.path_join(uri).replace_char('\\', '/'); // Fix for Windows.
|
||||
resource_uri = uri.simplify_path();
|
||||
// ResourceLoader will rely on the file extension to use the relevant loader.
|
||||
// The spec says that if mimeType is defined, it should take precedence (e.g.
|
||||
|
|
@ -4141,7 +4158,7 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> p_state, const String &p_base_p
|
|||
// Fallback to loading as byte array. This enables us to support the
|
||||
// spec's requirement that we honor mimetype regardless of file URI.
|
||||
data = FileAccess::get_file_as_bytes(resource_uri);
|
||||
if (data.size() == 0) {
|
||||
if (data.is_empty()) {
|
||||
WARN_PRINT(vformat("glTF: Image index '%d' couldn't be loaded as a buffer of MIME type '%s' from URI: %s because there was no data to load. Skipping it.", i, mime_type, resource_uri));
|
||||
p_state->images.push_back(Ref<Texture2D>()); // Placeholder to keep count.
|
||||
p_state->source_images.push_back(Ref<Image>());
|
||||
|
|
@ -4396,12 +4413,8 @@ Error GLTFDocument::_serialize_materials(Ref<GLTFState> p_state) {
|
|||
|
||||
Dictionary mr;
|
||||
{
|
||||
Array arr;
|
||||
const Color c = base_material->get_albedo().srgb_to_linear();
|
||||
arr.push_back(c.r);
|
||||
arr.push_back(c.g);
|
||||
arr.push_back(c.b);
|
||||
arr.push_back(c.a);
|
||||
Array arr = { c.r, c.g, c.b, c.a };
|
||||
mr["baseColorFactor"] = arr;
|
||||
}
|
||||
if (_image_format != "None") {
|
||||
|
|
@ -4607,10 +4620,7 @@ Error GLTFDocument::_serialize_materials(Ref<GLTFState> p_state) {
|
|||
|
||||
if (base_material->get_feature(BaseMaterial3D::FEATURE_EMISSION)) {
|
||||
const Color c = base_material->get_emission().linear_to_srgb();
|
||||
Array arr;
|
||||
arr.push_back(c.r);
|
||||
arr.push_back(c.g);
|
||||
arr.push_back(c.b);
|
||||
Array arr = { c.r, c.g, c.b };
|
||||
d["emissiveFactor"] = arr;
|
||||
}
|
||||
|
||||
|
|
@ -5912,10 +5922,12 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> p_state, Node *p_current,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef MODULE_CSG_ENABLED
|
||||
void GLTFDocument::_convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> p_gltf_node, Ref<GLTFState> p_state) {
|
||||
#ifndef MODULE_CSG_ENABLED
|
||||
ERR_FAIL_MSG("csg module is disabled.");
|
||||
#else
|
||||
CSGShape3D *csg = p_current;
|
||||
csg->call("_update_shape");
|
||||
csg->update_shape();
|
||||
Array meshes = csg->get_meshes();
|
||||
if (meshes.size() != 2) {
|
||||
return;
|
||||
|
|
@ -5964,8 +5976,8 @@ void GLTFDocument::_convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeInd
|
|||
p_gltf_node->transform = csg->get_transform();
|
||||
p_gltf_node->set_original_name(csg->get_name());
|
||||
p_gltf_node->set_name(_gen_unique_name(p_state, csg->get_name()));
|
||||
}
|
||||
#endif // MODULE_CSG_ENABLED
|
||||
}
|
||||
|
||||
void GLTFDocument::_check_visibility(Node *p_node, bool &r_retflag) {
|
||||
r_retflag = true;
|
||||
|
|
@ -5996,8 +6008,10 @@ void GLTFDocument::_convert_light_to_gltf(Light3D *light, Ref<GLTFState> p_state
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef MODULE_GRIDMAP_ENABLED
|
||||
void GLTFDocument::_convert_grid_map_to_gltf(GridMap *p_grid_map, GLTFNodeIndex p_parent_node_index, GLTFNodeIndex p_root_node_index, Ref<GLTFNode> p_gltf_node, Ref<GLTFState> p_state) {
|
||||
#ifndef MODULE_GRIDMAP_ENABLED
|
||||
ERR_FAIL_MSG("gridmap module is disabled.");
|
||||
#else
|
||||
Array cells = p_grid_map->get_used_cells();
|
||||
for (int32_t k = 0; k < cells.size(); k++) {
|
||||
GLTFNode *new_gltf_node = memnew(GLTFNode);
|
||||
|
|
@ -6025,8 +6039,8 @@ void GLTFDocument::_convert_grid_map_to_gltf(GridMap *p_grid_map, GLTFNodeIndex
|
|||
new_gltf_node->set_original_name(p_grid_map->get_mesh_library()->get_item_name(cell));
|
||||
new_gltf_node->set_name(_gen_unique_name(p_state, p_grid_map->get_mesh_library()->get_item_name(cell)));
|
||||
}
|
||||
}
|
||||
#endif // MODULE_GRIDMAP_ENABLED
|
||||
}
|
||||
|
||||
void GLTFDocument::_convert_multi_mesh_instance_to_gltf(
|
||||
MultiMeshInstance3D *p_multi_mesh_instance,
|
||||
|
|
@ -6959,7 +6973,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
|
|||
animation->set_loop_mode(Animation::LOOP_LINEAR);
|
||||
}
|
||||
|
||||
double anim_start = p_trimming ? INFINITY : 0.0;
|
||||
double anim_start = p_trimming ? Math::INF : 0.0;
|
||||
double anim_end = 0.0;
|
||||
|
||||
for (const KeyValue<int, GLTFAnimation::NodeTrack> &track_i : anim->get_node_tracks()) {
|
||||
|
|
@ -7646,7 +7660,7 @@ bool GLTFDocument::_convert_animation_node_track(Ref<GLTFState> p_state, GLTFAni
|
|||
} else {
|
||||
Vector3 rotation_euler = p_godot_animation->track_get_key_value(p_godot_anim_track_index, key_i);
|
||||
if (node_prop == "rotation_degrees") {
|
||||
rotation_euler *= Math_TAU / 360.0;
|
||||
rotation_euler *= Math::TAU / 360.0;
|
||||
}
|
||||
rotation_quaternion = Quaternion::from_euler(rotation_euler);
|
||||
}
|
||||
|
|
@ -8067,15 +8081,15 @@ Dictionary GLTFDocument::_serialize_texture_transform_uv2(Ref<BaseMaterial3D> p_
|
|||
|
||||
Error GLTFDocument::_serialize_asset_header(Ref<GLTFState> p_state) {
|
||||
const String version = "2.0";
|
||||
p_state->major_version = version.get_slice(".", 0).to_int();
|
||||
p_state->minor_version = version.get_slice(".", 1).to_int();
|
||||
p_state->major_version = version.get_slicec('.', 0).to_int();
|
||||
p_state->minor_version = version.get_slicec('.', 1).to_int();
|
||||
Dictionary asset;
|
||||
asset["version"] = version;
|
||||
if (!p_state->copyright.is_empty()) {
|
||||
asset["copyright"] = p_state->copyright;
|
||||
}
|
||||
String hash = String(VERSION_HASH);
|
||||
asset["generator"] = String(VERSION_FULL_NAME) + String("@") + (hash.is_empty() ? String("unknown") : hash);
|
||||
String hash = String(GODOT_VERSION_HASH);
|
||||
asset["generator"] = String(GODOT_VERSION_FULL_NAME) + String("@") + (hash.is_empty() ? String("unknown") : hash);
|
||||
p_state->json["asset"] = asset;
|
||||
ERR_FAIL_COND_V(!asset.has("version"), Error::FAILED);
|
||||
ERR_FAIL_COND_V(!p_state->json.has("asset"), Error::FAILED);
|
||||
|
|
@ -8349,8 +8363,8 @@ Error GLTFDocument::_parse_asset_header(Ref<GLTFState> p_state) {
|
|||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
String version = asset["version"];
|
||||
p_state->major_version = version.get_slice(".", 0).to_int();
|
||||
p_state->minor_version = version.get_slice(".", 1).to_int();
|
||||
p_state->major_version = version.get_slicec('.', 0).to_int();
|
||||
p_state->minor_version = version.get_slicec('.', 1).to_int();
|
||||
if (asset.has("copyright")) {
|
||||
p_state->copyright = asset["copyright"];
|
||||
}
|
||||
|
|
@ -8540,18 +8554,16 @@ Error GLTFDocument::append_from_scene(Node *p_node, Ref<GLTFState> p_state, uint
|
|||
// Add the root node(s) and their descendants to the state.
|
||||
if (_root_node_mode == RootNodeMode::ROOT_NODE_MODE_MULTI_ROOT) {
|
||||
const int child_count = p_node->get_child_count();
|
||||
if (child_count > 0) {
|
||||
for (int i = 0; i < child_count; i++) {
|
||||
_convert_scene_node(state, p_node->get_child(i), -1, -1);
|
||||
}
|
||||
state->scene_name = p_node->get_name();
|
||||
return OK;
|
||||
for (int i = 0; i < child_count; i++) {
|
||||
_convert_scene_node(state, p_node->get_child(i), -1, -1);
|
||||
}
|
||||
state->scene_name = p_node->get_name();
|
||||
} else {
|
||||
if (_root_node_mode == RootNodeMode::ROOT_NODE_MODE_SINGLE_ROOT) {
|
||||
state->extensions_used.append("GODOT_single_root");
|
||||
}
|
||||
_convert_scene_node(state, p_node, -1, -1);
|
||||
}
|
||||
if (_root_node_mode == RootNodeMode::ROOT_NODE_MODE_SINGLE_ROOT) {
|
||||
state->extensions_used.append("GODOT_single_root");
|
||||
}
|
||||
_convert_scene_node(state, p_node, -1, -1);
|
||||
// Run post-convert for each extension, in case an extension needs to do something after converting the scene.
|
||||
for (Ref<GLTFDocumentExtension> ext : document_extensions) {
|
||||
ERR_CONTINUE(ext.is_null());
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_DOCUMENT_H
|
||||
#define GLTF_DOCUMENT_H
|
||||
#pragma once
|
||||
|
||||
#include "extensions/gltf_document_extension.h"
|
||||
#include "extensions/gltf_spec_gloss.h"
|
||||
|
|
@ -39,13 +38,8 @@
|
|||
#include "scene/3d/mesh_instance_3d.h"
|
||||
#include "scene/3d/multimesh_instance_3d.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h" // For csg, gridmap.
|
||||
#ifdef MODULE_CSG_ENABLED
|
||||
#include "modules/csg/csg_shape.h"
|
||||
#endif // MODULE_CSG_ENABLED
|
||||
#ifdef MODULE_GRIDMAP_ENABLED
|
||||
#include "modules/gridmap/grid_map.h"
|
||||
#endif // MODULE_GRIDMAP_ENABLED
|
||||
class CSGShape3D;
|
||||
class GridMap;
|
||||
|
||||
class GLTFDocument : public Resource {
|
||||
GDCLASS(GLTFDocument, Resource);
|
||||
|
|
@ -340,20 +334,16 @@ public:
|
|||
const GLTFNodeIndex p_gltf_current,
|
||||
const GLTFNodeIndex p_gltf_root);
|
||||
|
||||
#ifdef MODULE_CSG_ENABLED
|
||||
void _convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> p_gltf_node, Ref<GLTFState> p_state);
|
||||
#endif // MODULE_CSG_ENABLED
|
||||
|
||||
void _check_visibility(Node *p_node, bool &r_retflag);
|
||||
void _convert_camera_to_gltf(Camera3D *p_camera, Ref<GLTFState> p_state,
|
||||
Ref<GLTFNode> p_gltf_node);
|
||||
#ifdef MODULE_GRIDMAP_ENABLED
|
||||
void _convert_grid_map_to_gltf(
|
||||
GridMap *p_grid_map,
|
||||
GLTFNodeIndex p_parent_node_index,
|
||||
GLTFNodeIndex p_root_node_index,
|
||||
Ref<GLTFNode> p_gltf_node, Ref<GLTFState> p_state);
|
||||
#endif // MODULE_GRIDMAP_ENABLED
|
||||
void _convert_multi_mesh_instance_to_gltf(
|
||||
MultiMeshInstance3D *p_multi_mesh_instance,
|
||||
GLTFNodeIndex p_parent_node_index,
|
||||
|
|
@ -388,5 +378,3 @@ public:
|
|||
};
|
||||
|
||||
VARIANT_ENUM_CAST(GLTFDocument::RootNodeMode);
|
||||
|
||||
#endif // GLTF_DOCUMENT_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_STATE_H
|
||||
#define GLTF_STATE_H
|
||||
#pragma once
|
||||
|
||||
#include "extensions/gltf_light.h"
|
||||
#include "structures/gltf_accessor.h"
|
||||
|
|
@ -252,5 +251,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_STATE_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_TEMPLATE_CONVERT_H
|
||||
#define GLTF_TEMPLATE_CONVERT_H
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "core/variant/array.h"
|
||||
|
|
@ -85,11 +84,8 @@ static Dictionary to_dictionary(const HashMap<K, V> &p_inp) {
|
|||
template <typename K, typename V>
|
||||
static void set_from_dictionary(HashMap<K, V> &r_out, const Dictionary &p_inp) {
|
||||
r_out.clear();
|
||||
Array keys = p_inp.keys();
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
r_out[keys[i]] = p_inp[keys[i]];
|
||||
for (const KeyValue<Variant, Variant> &kv : p_inp) {
|
||||
r_out[kv.key] = kv.value;
|
||||
}
|
||||
}
|
||||
} //namespace GLTFTemplateConvert
|
||||
|
||||
#endif // GLTF_TEMPLATE_CONVERT_H
|
||||
|
|
|
|||
|
|
@ -34,11 +34,14 @@
|
|||
#include "extensions/gltf_document_extension_texture_ktx.h"
|
||||
#include "extensions/gltf_document_extension_texture_webp.h"
|
||||
#include "extensions/gltf_spec_gloss.h"
|
||||
#include "extensions/physics/gltf_document_extension_physics.h"
|
||||
#include "gltf_document.h"
|
||||
#include "gltf_state.h"
|
||||
#include "structures/gltf_object_model_property.h"
|
||||
|
||||
#ifndef PHYSICS_3D_DISABLED
|
||||
#include "extensions/physics/gltf_document_extension_physics.h"
|
||||
#endif // PHYSICS_3D_DISABLED
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "editor/editor_import_blend_runner.h"
|
||||
#include "editor/editor_scene_exporter_gltf_plugin.h"
|
||||
|
|
@ -114,17 +117,21 @@ void initialize_gltf_module(ModuleInitializationLevel p_level) {
|
|||
GDREGISTER_CLASS(GLTFMesh);
|
||||
GDREGISTER_CLASS(GLTFNode);
|
||||
GDREGISTER_CLASS(GLTFObjectModelProperty);
|
||||
#ifndef PHYSICS_3D_DISABLED
|
||||
GDREGISTER_CLASS(GLTFPhysicsBody);
|
||||
GDREGISTER_CLASS(GLTFPhysicsShape);
|
||||
#endif // PHYSICS_3D_DISABLED
|
||||
GDREGISTER_CLASS(GLTFSkeleton);
|
||||
GDREGISTER_CLASS(GLTFSkin);
|
||||
GDREGISTER_CLASS(GLTFSpecGloss);
|
||||
GDREGISTER_CLASS(GLTFState);
|
||||
GDREGISTER_CLASS(GLTFTexture);
|
||||
GDREGISTER_CLASS(GLTFTextureSampler);
|
||||
// Register GLTFDocumentExtension classes with GLTFDocument.
|
||||
// Register GLTFDocumentExtension classes with GLTFDocument.
|
||||
#ifndef PHYSICS_3D_DISABLED
|
||||
// Ensure physics is first in this list so that physics nodes are created before other nodes.
|
||||
GLTF_REGISTER_DOCUMENT_EXTENSION(GLTFDocumentExtensionPhysics);
|
||||
#endif // PHYSICS_3D_DISABLED
|
||||
GLTF_REGISTER_DOCUMENT_EXTENSION(GLTFDocumentExtensionTextureKTX);
|
||||
GLTF_REGISTER_DOCUMENT_EXTENSION(GLTFDocumentExtensionTextureWebP);
|
||||
bool is_editor = Engine::get_singleton()->is_editor_hint();
|
||||
|
|
@ -135,10 +142,6 @@ void initialize_gltf_module(ModuleInitializationLevel p_level) {
|
|||
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
// Editor-specific API.
|
||||
ClassDB::APIType prev_api = ClassDB::get_current_api();
|
||||
ClassDB::set_current_api(ClassDB::API_EDITOR);
|
||||
|
||||
GDREGISTER_CLASS(EditorSceneFormatImporterGLTF);
|
||||
EditorPlugins::add_by_type<SceneExporterGLTFPlugin>();
|
||||
|
||||
|
|
@ -149,10 +152,8 @@ void initialize_gltf_module(ModuleInitializationLevel p_level) {
|
|||
GLOBAL_DEF_RST("filesystem/import/blender/enabled.android", false);
|
||||
GLOBAL_DEF_RST("filesystem/import/blender/enabled.web", false);
|
||||
|
||||
ClassDB::set_current_api(prev_api);
|
||||
EditorNode::add_init_callback(_editor_init);
|
||||
}
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,12 +28,9 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_REGISTER_TYPES_H
|
||||
#define GLTF_REGISTER_TYPES_H
|
||||
#pragma once
|
||||
|
||||
#include "modules/register_module_types.h"
|
||||
|
||||
void initialize_gltf_module(ModuleInitializationLevel p_level);
|
||||
void uninitialize_gltf_module(ModuleInitializationLevel p_level);
|
||||
|
||||
#endif // GLTF_REGISTER_TYPES_H
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ Error SkinTool::_determine_skeleton_roots(
|
|||
|
||||
skeleton->roots = roots;
|
||||
|
||||
if (roots.size() == 0) {
|
||||
if (roots.is_empty()) {
|
||||
return FAILED;
|
||||
} else if (roots.size() == 1) {
|
||||
return OK;
|
||||
|
|
@ -810,7 +810,6 @@ Error SkinTool::_asset_parse_skins(
|
|||
|
||||
String SkinTool::_sanitize_bone_name(const String &p_name) {
|
||||
String bone_name = p_name;
|
||||
bone_name = bone_name.replace(":", "_");
|
||||
bone_name = bone_name.replace("/", "_");
|
||||
bone_name = bone_name.replace_chars(":/", '_');
|
||||
return bone_name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKIN_TOOL_H
|
||||
#define SKIN_TOOL_H
|
||||
#pragma once
|
||||
|
||||
#include "gltf_defines.h"
|
||||
|
||||
|
|
@ -95,5 +94,3 @@ public:
|
|||
HashMap<GLTFNodeIndex, Node *> &r_scene_nodes);
|
||||
static Error _create_skins(Vector<Ref<GLTFSkin>> &skins, Vector<Ref<GLTFNode>> &nodes, bool use_named_skin_binds, HashSet<String> &unique_names);
|
||||
};
|
||||
|
||||
#endif // SKIN_TOOL_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_ACCESSOR_H
|
||||
#define GLTF_ACCESSOR_H
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_defines.h"
|
||||
|
||||
|
|
@ -133,5 +132,3 @@ public:
|
|||
|
||||
VARIANT_ENUM_CAST(GLTFAccessor::GLTFAccessorType);
|
||||
VARIANT_ENUM_CAST(GLTFAccessor::GLTFComponentType);
|
||||
|
||||
#endif // GLTF_ACCESSOR_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_ANIMATION_H
|
||||
#define GLTF_ANIMATION_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/animation.h"
|
||||
|
||||
|
|
@ -86,5 +85,3 @@ public:
|
|||
|
||||
GLTFAnimation();
|
||||
};
|
||||
|
||||
#endif // GLTF_ANIMATION_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_BUFFER_VIEW_H
|
||||
#define GLTF_BUFFER_VIEW_H
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_defines.h"
|
||||
|
||||
|
|
@ -80,5 +79,3 @@ public:
|
|||
|
||||
Vector<uint8_t> load_buffer_view_data(const Ref<GLTFState> p_state) const;
|
||||
};
|
||||
|
||||
#endif // GLTF_BUFFER_VIEW_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_CAMERA_H
|
||||
#define GLTF_CAMERA_H
|
||||
#pragma once
|
||||
|
||||
#include "core/io/resource.h"
|
||||
|
||||
|
|
@ -74,5 +73,3 @@ public:
|
|||
static Ref<GLTFCamera> from_dictionary(const Dictionary p_dictionary);
|
||||
virtual Dictionary to_dictionary() const;
|
||||
};
|
||||
|
||||
#endif // GLTF_CAMERA_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_MESH_H
|
||||
#define GLTF_MESH_H
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_defines.h"
|
||||
|
||||
|
|
@ -60,5 +59,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_MESH_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_NODE_H
|
||||
#define GLTF_NODE_H
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_defines.h"
|
||||
|
||||
|
|
@ -108,5 +107,3 @@ public:
|
|||
|
||||
NodePath get_scene_node_path(Ref<GLTFState> p_state, bool p_handle_skeletons = true);
|
||||
};
|
||||
|
||||
#endif // GLTF_NODE_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_OBJECT_MODEL_PROPERTY_H
|
||||
#define GLTF_OBJECT_MODEL_PROPERTY_H
|
||||
#pragma once
|
||||
|
||||
#include "core/math/expression.h"
|
||||
#include "core/variant/typed_array.h"
|
||||
|
|
@ -100,5 +99,3 @@ public:
|
|||
};
|
||||
|
||||
VARIANT_ENUM_CAST(GLTFObjectModelProperty::GLTFObjectModelType);
|
||||
|
||||
#endif // GLTF_OBJECT_MODEL_PROPERTY_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_SKELETON_H
|
||||
#define GLTF_SKELETON_H
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_defines.h"
|
||||
|
||||
|
|
@ -103,5 +102,3 @@ public:
|
|||
|
||||
int32_t get_bone_attachment_count();
|
||||
};
|
||||
|
||||
#endif // GLTF_SKELETON_H
|
||||
|
|
|
|||
|
|
@ -145,9 +145,8 @@ Dictionary GLTFSkin::get_joint_i_to_name() {
|
|||
|
||||
void GLTFSkin::set_joint_i_to_name(Dictionary p_joint_i_to_name) {
|
||||
joint_i_to_name = HashMap<int, StringName>();
|
||||
Array keys = p_joint_i_to_name.keys();
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
joint_i_to_name[keys[i]] = p_joint_i_to_name[keys[i]];
|
||||
for (const KeyValue<Variant, Variant> &kv : p_joint_i_to_name) {
|
||||
joint_i_to_name[kv.key] = kv.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,18 +204,18 @@ Error GLTFSkin::from_dictionary(const Dictionary &dict) {
|
|||
ERR_FAIL_COND_V(!dict.has("joint_i_to_bone_i"), ERR_INVALID_DATA);
|
||||
Dictionary joint_i_to_bone_i_dict = dict["joint_i_to_bone_i"];
|
||||
joint_i_to_bone_i.clear();
|
||||
for (int i = 0; i < joint_i_to_bone_i_dict.keys().size(); ++i) {
|
||||
int key = joint_i_to_bone_i_dict.keys()[i];
|
||||
int value = joint_i_to_bone_i_dict[key];
|
||||
for (const KeyValue<Variant, Variant> &kv : joint_i_to_bone_i_dict) {
|
||||
int key = kv.key;
|
||||
int value = kv.value;
|
||||
joint_i_to_bone_i[key] = value;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!dict.has("joint_i_to_name"), ERR_INVALID_DATA);
|
||||
Dictionary joint_i_to_name_dict = dict["joint_i_to_name"];
|
||||
joint_i_to_name.clear();
|
||||
for (int i = 0; i < joint_i_to_name_dict.keys().size(); ++i) {
|
||||
int key = joint_i_to_name_dict.keys()[i];
|
||||
StringName value = joint_i_to_name_dict[key];
|
||||
for (const KeyValue<Variant, Variant> &kv : joint_i_to_name_dict) {
|
||||
int key = kv.key;
|
||||
StringName value = kv.value;
|
||||
joint_i_to_name[key] = value;
|
||||
}
|
||||
if (dict.has("godot_skin")) {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_SKIN_H
|
||||
#define GLTF_SKIN_H
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_defines.h"
|
||||
|
||||
|
|
@ -116,5 +115,3 @@ public:
|
|||
Dictionary to_dictionary();
|
||||
Error from_dictionary(const Dictionary &dict);
|
||||
};
|
||||
|
||||
#endif // GLTF_SKIN_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_TEXTURE_H
|
||||
#define GLTF_TEXTURE_H
|
||||
#pragma once
|
||||
|
||||
#include "../gltf_defines.h"
|
||||
|
||||
|
|
@ -51,5 +50,3 @@ public:
|
|||
GLTFTextureSamplerIndex get_sampler() const;
|
||||
void set_sampler(GLTFTextureSamplerIndex val);
|
||||
};
|
||||
|
||||
#endif // GLTF_TEXTURE_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GLTF_TEXTURE_SAMPLER_H
|
||||
#define GLTF_TEXTURE_SAMPLER_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/material.h"
|
||||
|
||||
|
|
@ -158,5 +157,3 @@ private:
|
|||
|
||||
VARIANT_ENUM_CAST(GLTFTextureSampler::FilterMode);
|
||||
VARIANT_ENUM_CAST(GLTFTextureSampler::WrapMode);
|
||||
|
||||
#endif // GLTF_TEXTURE_SAMPLER_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_GLTF_H
|
||||
#define TEST_GLTF_H
|
||||
#pragma once
|
||||
|
||||
#include "tests/test_macros.h"
|
||||
|
||||
|
|
@ -71,8 +70,10 @@ static Node *gltf_import(const String &p_file) {
|
|||
|
||||
// Once editor import convert pngs to ctex, we will need to load it as ctex resource.
|
||||
Ref<ResourceFormatLoaderCompressedTexture2D> resource_loader_stream_texture;
|
||||
resource_loader_stream_texture.instantiate();
|
||||
ResourceLoader::add_resource_format_loader(resource_loader_stream_texture);
|
||||
if (GD_IS_CLASS_ENABLED(CompressedTexture2D)) {
|
||||
resource_loader_stream_texture.instantiate();
|
||||
ResourceLoader::add_resource_format_loader(resource_loader_stream_texture);
|
||||
}
|
||||
|
||||
HashMap<StringName, Variant> options(21);
|
||||
options["nodes/root_type"] = "";
|
||||
|
|
@ -106,7 +107,10 @@ static Node *gltf_import(const String &p_file) {
|
|||
|
||||
ResourceImporterScene::remove_scene_importer(import_gltf);
|
||||
ResourceFormatImporter::get_singleton()->remove_importer(import_texture);
|
||||
ResourceLoader::remove_resource_format_loader(resource_loader_stream_texture);
|
||||
if (GD_IS_CLASS_ENABLED(CompressedTexture2D)) {
|
||||
ResourceLoader::remove_resource_format_loader(resource_loader_stream_texture);
|
||||
resource_loader_stream_texture.unref();
|
||||
}
|
||||
return p_scene;
|
||||
}
|
||||
|
||||
|
|
@ -162,5 +166,3 @@ void init(const String &p_test, const String &p_copy_target = String()) {
|
|||
} //namespace TestGltf
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#endif // TEST_GLTF_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_GLTF_EXTRAS_H
|
||||
#define TEST_GLTF_EXTRAS_H
|
||||
#pragma once
|
||||
|
||||
#include "test_gltf.h"
|
||||
#include "tests/test_macros.h"
|
||||
|
|
@ -174,5 +173,3 @@ TEST_CASE("[SceneTree][Node] GLTF test skeleton and bone export and import") {
|
|||
} //namespace TestGltf
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#endif // TEST_GLTF_EXTRAS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEST_GLTF_IMAGES_H
|
||||
#define TEST_GLTF_IMAGES_H
|
||||
#pragma once
|
||||
|
||||
#include "test_gltf.h"
|
||||
|
||||
|
|
@ -165,5 +164,3 @@ TEST_CASE("[SceneTree][Node][Editor] Import GLTF with embedded texture, check ho
|
|||
} //namespace TestGltf
|
||||
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#endif // TEST_GLTF_IMAGES_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue