summaryrefslogtreecommitdiff
path: root/modules/fbx
diff options
context:
space:
mode:
Diffstat (limited to 'modules/fbx')
-rw-r--r--modules/fbx/README.md30
-rw-r--r--modules/fbx/data/fbx_bone.h2
-rw-r--r--modules/fbx/data/fbx_material.cpp12
-rw-r--r--modules/fbx/data/fbx_material.h6
-rw-r--r--modules/fbx/data/fbx_mesh_data.cpp12
-rw-r--r--modules/fbx/data/fbx_mesh_data.h4
-rw-r--r--modules/fbx/data/fbx_node.h2
-rw-r--r--modules/fbx/data/fbx_skeleton.h4
-rw-r--r--modules/fbx/data/pivot_transform.cpp90
-rw-r--r--modules/fbx/data/pivot_transform.h30
-rw-r--r--modules/fbx/editor_scene_importer_fbx.cpp90
-rw-r--r--modules/fbx/fbx_parser/FBXDeformer.cpp2
-rw-r--r--modules/fbx/fbx_parser/FBXDocument.cpp2
-rw-r--r--modules/fbx/fbx_parser/FBXDocument.h20
-rw-r--r--modules/fbx/fbx_parser/FBXMeshGeometry.cpp8
-rw-r--r--modules/fbx/fbx_parser/FBXMeshGeometry.h4
-rw-r--r--modules/fbx/fbx_parser/FBXParser.cpp8
-rw-r--r--modules/fbx/fbx_parser/FBXParser.h4
-rw-r--r--modules/fbx/register_types.cpp2
-rw-r--r--modules/fbx/tools/import_utils.cpp12
-rw-r--r--modules/fbx/tools/import_utils.h18
-rw-r--r--modules/fbx/tools/validation_tools.h5
22 files changed, 183 insertions, 184 deletions
diff --git a/modules/fbx/README.md b/modules/fbx/README.md
index 2a2f186463..8eca4bd3c9 100644
--- a/modules/fbx/README.md
+++ b/modules/fbx/README.md
@@ -15,7 +15,7 @@ functionality. If anything we should give this parser back to assimp at some poi
# Updating assimp fbx parser
-Don't. it's not possible the code is rewritten in many areas to remove thirdparty deps and various bugs are fixed.
+Don't. It's not possible the code is rewritten in many areas to remove thirdparty deps and various bugs are fixed.
Many days were put into rewriting the parser to use safe code and safe memory accessors.
@@ -79,23 +79,23 @@ enum RotOrder {
// references: ComputePivotTransform / run the calculation
// This is the local pivot transform for the node, not the global transforms
Transform ComputePivotTransform(
- Transform chain[TransformationComp_MAXIMUM],
- Transform &geometric_transform) {
+ Transform3D chain[TransformationComp_MAXIMUM],
+ Transform3D &geometric_transform) {
// Maya pivots
- Transform T = chain[TransformationComp_Translation];
- Transform Roff = chain[TransformationComp_RotationOffset];
- Transform Rp = chain[TransformationComp_RotationPivot];
- Transform Rpre = chain[TransformationComp_PreRotation];
- Transform R = chain[TransformationComp_Rotation];
- Transform Rpost = chain[TransformationComp_PostRotation];
- Transform Soff = chain[TransformationComp_ScalingOffset];
- Transform Sp = chain[TransformationComp_ScalingPivot];
- Transform S = chain[TransformationComp_Scaling];
+ Transform3D T = chain[TransformationComp_Translation];
+ Transform3D Roff = chain[TransformationComp_RotationOffset];
+ Transform3D Rp = chain[TransformationComp_RotationPivot];
+ Transform3D Rpre = chain[TransformationComp_PreRotation];
+ Transform3D R = chain[TransformationComp_Rotation];
+ Transform3D Rpost = chain[TransformationComp_PostRotation];
+ Transform3D Soff = chain[TransformationComp_ScalingOffset];
+ Transform3D Sp = chain[TransformationComp_ScalingPivot];
+ Transform3D S = chain[TransformationComp_Scaling];
// 3DS Max Pivots
- Transform OT = chain[TransformationComp_GeometricTranslation];
- Transform OR = chain[TransformationComp_GeometricRotation];
- Transform OS = chain[TransformationComp_GeometricScaling];
+ Transform3D OT = chain[TransformationComp_GeometricTranslation];
+ Transform3D OR = chain[TransformationComp_GeometricRotation];
+ Transform3D OS = chain[TransformationComp_GeometricScaling];
// Calculate 3DS max pivot transform - use geometric space (e.g doesn't effect children nodes only the current node)
geometric_transform = OT * OR * OS;
diff --git a/modules/fbx/data/fbx_bone.h b/modules/fbx/data/fbx_bone.h
index efba147b89..83918ad1e2 100644
--- a/modules/fbx/data/fbx_bone.h
+++ b/modules/fbx/data/fbx_bone.h
@@ -38,7 +38,7 @@
struct PivotTransform;
-struct FBXBone : public Reference {
+struct FBXBone : public RefCounted {
uint64_t parent_bone_id = 0;
uint64_t bone_id = 0;
diff --git a/modules/fbx/data/fbx_material.cpp b/modules/fbx/data/fbx_material.cpp
index d54ac86e9f..cf5d70fa5b 100644
--- a/modules/fbx/data/fbx_material.cpp
+++ b/modules/fbx/data/fbx_material.cpp
@@ -160,7 +160,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
const String p_fbx_current_directory = state.path;
Ref<StandardMaterial3D> spatial_material;
- spatial_material.instance();
+ spatial_material.instantiate();
// read the material file
// is material two sided
@@ -223,7 +223,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
} else if (fbx_texture_data != nullptr && fbx_texture_data->Media() != nullptr && fbx_texture_data->Media()->IsEmbedded()) {
// This is an embedded texture. Extract it.
Ref<Image> image;
- //image.instance(); // oooo double instance bug? why make Image::_png_blah call
+ //image.instantiate(); // oooo double instance bug? why make Image::_png_blah call
const String extension = texture_name.get_extension().to_upper();
if (extension == "PNG") {
@@ -256,7 +256,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
}
Ref<ImageTexture> image_texture;
- image_texture.instance();
+ image_texture.instantiate();
image_texture->create_from_image(image);
texture = image_texture;
@@ -324,7 +324,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
if (spatial_material.is_null()) {
// Done here so if no data no material is created.
- spatial_material.instance();
+ spatial_material.instantiate();
}
const FBXDocParser::TypedProperty<real_t> *real_value = dynamic_cast<const FBXDocParser::TypedProperty<real_t> *>(prop);
@@ -420,7 +420,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
} break;
case PROPERTY_DESC_COAT_ROUGHNESS: {
// meaning is that approx equal to zero is disabled not actually zero. ;)
- if (real_value && Math::is_equal_approx(real_value->Value(), 0.0f)) {
+ if (real_value && Math::is_zero_approx(real_value->Value())) {
print_verbose("clearcoat real value: " + rtos(real_value->Value()));
spatial_material->set_clearcoat_gloss(1.0 - real_value->Value());
} else {
@@ -428,7 +428,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
}
} break;
case PROPERTY_DESC_EMISSIVE: {
- if (real_value && Math::is_equal_approx(real_value->Value(), 0.0f)) {
+ if (real_value && Math::is_zero_approx(real_value->Value())) {
print_verbose("Emissive real value: " + rtos(real_value->Value()));
spatial_material->set_emission_energy(real_value->Value());
} else if (vector_value && !vector_value->Value().is_equal_approx(Vector3(0, 0, 0))) {
diff --git a/modules/fbx/data/fbx_material.h b/modules/fbx/data/fbx_material.h
index 23310b8e1d..5fd4d9212b 100644
--- a/modules/fbx/data/fbx_material.h
+++ b/modules/fbx/data/fbx_material.h
@@ -33,10 +33,10 @@
#include "tools/import_utils.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/string/ustring.h"
-struct FBXMaterial : public Reference {
+struct FBXMaterial : public RefCounted {
String material_name = String();
bool warning_non_pbr_material = false;
FBXDocParser::Material *material = nullptr;
@@ -266,7 +266,7 @@ struct FBXMaterial : public Reference {
/* storing the texture properties like color */
template <class T>
- struct TexturePropertyMapping : Reference {
+ struct TexturePropertyMapping : RefCounted {
StandardMaterial3D::TextureParam map_mode = StandardMaterial3D::TextureParam::TEXTURE_ALBEDO;
const T property = T();
};
diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp
index 304d1598f6..0d33b8e7c6 100644
--- a/modules/fbx/data/fbx_mesh_data.cpp
+++ b/modules/fbx/data/fbx_mesh_data.cpp
@@ -211,7 +211,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s
const int surface_id = polygon_surfaces[*polygon_id];
if (surfaces.has(surface_id) == false) {
SurfaceData sd;
- sd.surface_tool.instance();
+ sd.surface_tool.instantiate();
sd.surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
if (surface_id < 0) {
@@ -316,7 +316,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s
Vector3 *normals_ptr = morph_data->normals.ptrw();
Ref<SurfaceTool> morph_st;
- morph_st.instance();
+ morph_st.instantiate();
morph_st->begin(Mesh::PRIMITIVE_TRIANGLES);
for (unsigned int vi = 0; vi < surface->vertices_map.size(); vi += 1) {
@@ -345,7 +345,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s
// Phase 6. Compose the mesh and return it.
Ref<EditorSceneImporterMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
// Add blend shape info.
for (const String *morph_name = morphs.next(nullptr); morph_name != nullptr; morph_name = morphs.next(morph_name)) {
@@ -945,7 +945,7 @@ void FBXMeshData::triangulate_polygon(SurfaceData *surface, const Vector<int> &p
for (List<TPPLPoly>::Element *I = out_poly.front(); I; I = I->next()) {
TPPLPoly &tp = I->get();
- ERR_FAIL_COND_MSG(tp.GetNumPoints() != 3, "The triangulator retuned more points, how this is possible?");
+ ERR_FAIL_COND_MSG(tp.GetNumPoints() != 3, "The triangulator returned more points, how this is possible?");
// Find Index
for (int i = 2; i >= 0; i -= 1) {
const Vector2 vertex = tp.GetPoint(i);
@@ -1126,8 +1126,8 @@ HashMap<int, R> FBXMeshData::extract_per_vertex_data(
}
const int vertex_index = get_vertex_from_polygon_vertex(p_mesh_indices, polygon_vertex_index);
ERR_FAIL_COND_V_MSG(vertex_index < 0, (HashMap<int, R>()), "FBX file corrupted: #ERR8");
- ERR_FAIL_COND_V_MSG(vertex_index >= p_vertex_count, (HashMap<int, R>()), "FBX file seems corrupted: #ERR9.");
- ERR_FAIL_COND_V_MSG(p_mapping_data.index[polygon_vertex_index] < 0, (HashMap<int, R>()), "FBX file seems corrupted: #ERR10.");
+ ERR_FAIL_COND_V_MSG(vertex_index >= p_vertex_count, (HashMap<int, R>()), "FBX file seems corrupted: #ERR9.");
+ ERR_FAIL_COND_V_MSG(p_mapping_data.index[polygon_vertex_index] < 0, (HashMap<int, R>()), "FBX file seems corrupted: #ERR10.");
ERR_FAIL_COND_V_MSG(p_mapping_data.index[polygon_vertex_index] >= (int)p_mapping_data.data.size(), (HashMap<int, R>()), "FBX file seems corrupted: #ERR11.");
aggregate_vertex_data[vertex_index].push_back({ polygon_id, p_mapping_data.data[p_mapping_data.index[polygon_vertex_index]] });
}
diff --git a/modules/fbx/data/fbx_mesh_data.h b/modules/fbx/data/fbx_mesh_data.h
index 575f833584..7486c5c59c 100644
--- a/modules/fbx/data/fbx_mesh_data.h
+++ b/modules/fbx/data/fbx_mesh_data.h
@@ -78,7 +78,7 @@ struct VertexData {
};
// Caches mesh information and instantiates meshes for you using helper functions.
-struct FBXMeshData : Reference {
+struct FBXMeshData : RefCounted {
struct MorphVertexData {
// TODO we have only these??
/// Each element is a vertex. Not supposed to be void.
@@ -156,7 +156,7 @@ private:
/// [0, 2, 1, 3, 4]
/// The negative values are computed using this formula: `(-value) - 1`
///
- /// Returns the vertex index from the poligon vertex.
+ /// Returns the vertex index from the polygon vertex.
/// Returns -1 if `p_index` is invalid.
int get_vertex_from_polygon_vertex(const std::vector<int> &p_face_indices, int p_index) const;
diff --git a/modules/fbx/data/fbx_node.h b/modules/fbx/data/fbx_node.h
index a6f62f3388..75461e397d 100644
--- a/modules/fbx/data/fbx_node.h
+++ b/modules/fbx/data/fbx_node.h
@@ -40,7 +40,7 @@
class Node3D;
struct PivotTransform;
-struct FBXNode : Reference, ModelAbstraction {
+struct FBXNode : RefCounted, ModelAbstraction {
uint64_t current_node_id = 0;
String node_name = String();
Node3D *godot_node = nullptr;
diff --git a/modules/fbx/data/fbx_skeleton.h b/modules/fbx/data/fbx_skeleton.h
index df937cde49..b6103df949 100644
--- a/modules/fbx/data/fbx_skeleton.h
+++ b/modules/fbx/data/fbx_skeleton.h
@@ -35,14 +35,14 @@
#include "fbx_node.h"
#include "model_abstraction.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "scene/3d/skeleton_3d.h"
struct FBXNode;
struct ImportState;
struct FBXBone;
-struct FBXSkeleton : Reference {
+struct FBXSkeleton : RefCounted {
Ref<FBXNode> fbx_node = Ref<FBXNode>();
Vector<Ref<FBXBone>> skeleton_bones = Vector<Ref<FBXBone>>();
Skeleton3D *skeleton = nullptr;
diff --git a/modules/fbx/data/pivot_transform.cpp b/modules/fbx/data/pivot_transform.cpp
index f4055c830f..4cf42257a4 100644
--- a/modules/fbx/data/pivot_transform.cpp
+++ b/modules/fbx/data/pivot_transform.cpp
@@ -90,7 +90,7 @@ void PivotTransform::ReadTransformChain() {
if (ok) {
geometric_rotation = ImportUtils::EulerToQuaternion(rot, ImportUtils::deg2rad(GeometricRotation));
} else {
- geometric_rotation = Quat();
+ geometric_rotation = Quaternion();
}
const Vector3 &GeometricTranslation = ImportUtils::safe_import_vector3(FBXDocParser::PropertyGet<Vector3>(props, "GeometricTranslation", ok));
@@ -100,7 +100,7 @@ void PivotTransform::ReadTransformChain() {
geometric_translation = Vector3(0, 0, 0);
}
- if (geometric_rotation != Quat()) {
+ if (geometric_rotation != Quaternion()) {
print_error("geometric rotation is unsupported!");
//CRASH_COND(true);
}
@@ -116,8 +116,8 @@ void PivotTransform::ReadTransformChain() {
}
}
-Transform PivotTransform::ComputeLocalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const {
- Transform T, Roff, Rp, Soff, Sp, S;
+Transform3D PivotTransform::ComputeLocalTransform(Vector3 p_translation, Quaternion p_rotation, Vector3 p_scaling) const {
+ Transform3D T, Roff, Rp, Soff, Sp, S;
// Here I assume this is the operation which needs done.
// Its WorldTransform * V
@@ -132,29 +132,29 @@ Transform PivotTransform::ComputeLocalTransform(Vector3 p_translation, Quat p_ro
// Scaling node
S.scale(p_scaling);
// Rotation pivots
- Transform Rpre = Transform(pre_rotation);
- Transform R = Transform(p_rotation);
- Transform Rpost = Transform(post_rotation);
+ Transform3D Rpre = Transform3D(pre_rotation);
+ Transform3D R = Transform3D(p_rotation);
+ Transform3D Rpost = Transform3D(post_rotation);
return T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse();
}
-Transform PivotTransform::ComputeGlobalTransform(Transform t) const {
+Transform3D PivotTransform::ComputeGlobalTransform(Transform3D t) const {
Vector3 pos = t.origin;
Vector3 scale = t.basis.get_scale();
- Quat rot = t.basis.get_rotation_quat();
+ Quaternion rot = t.basis.get_rotation_quaternion();
return ComputeGlobalTransform(pos, rot, scale);
}
-Transform PivotTransform::ComputeLocalTransform(Transform t) const {
+Transform3D PivotTransform::ComputeLocalTransform(Transform3D t) const {
Vector3 pos = t.origin;
Vector3 scale = t.basis.get_scale();
- Quat rot = t.basis.get_rotation_quat();
+ Quaternion rot = t.basis.get_rotation_quaternion();
return ComputeLocalTransform(pos, rot, scale);
}
-Transform PivotTransform::ComputeGlobalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const {
- Transform T, Roff, Rp, Soff, Sp, S;
+Transform3D PivotTransform::ComputeGlobalTransform(Vector3 p_translation, Quaternion p_rotation, Vector3 p_scaling) const {
+ Transform3D T, Roff, Rp, Soff, Sp, S;
// Here I assume this is the operation which needs done.
// Its WorldTransform * V
@@ -170,26 +170,26 @@ Transform PivotTransform::ComputeGlobalTransform(Vector3 p_translation, Quat p_r
S.scale(p_scaling);
// Rotation pivots
- Transform Rpre = Transform(pre_rotation);
- Transform R = Transform(p_rotation);
- Transform Rpost = Transform(post_rotation);
+ Transform3D Rpre = Transform3D(pre_rotation);
+ Transform3D R = Transform3D(p_rotation);
+ Transform3D Rpost = Transform3D(post_rotation);
- Transform parent_global_xform;
- Transform parent_local_scaling_m;
+ Transform3D parent_global_xform;
+ Transform3D parent_local_scaling_m;
if (parent_transform.is_valid()) {
parent_global_xform = parent_transform->GlobalTransform;
parent_local_scaling_m = parent_transform->Local_Scaling_Matrix;
}
- Transform local_rotation_m, parent_global_rotation_m;
- Quat parent_global_rotation = parent_global_xform.basis.get_rotation_quat();
- parent_global_rotation_m.basis.set_quat(parent_global_rotation);
+ Transform3D local_rotation_m, parent_global_rotation_m;
+ Quaternion parent_global_rotation = parent_global_xform.basis.get_rotation_quaternion();
+ parent_global_rotation_m.basis.set_quaternion(parent_global_rotation);
local_rotation_m = Rpre * R * Rpost;
- //Basis parent_global_rotation = Basis(parent_global_xform.get_basis().get_rotation_quat().normalized());
+ //Basis parent_global_rotation = Basis(parent_global_xform.get_basis().get_rotation_quaternion().normalized());
- Transform local_shear_scaling, parent_shear_scaling, parent_shear_rotation, parent_shear_translation;
+ Transform3D local_shear_scaling, parent_shear_scaling, parent_shear_rotation, parent_shear_translation;
Vector3 parent_translation = parent_global_xform.get_origin();
parent_shear_translation.origin = parent_translation;
parent_shear_rotation = parent_shear_translation.affine_inverse() * parent_global_xform;
@@ -197,26 +197,26 @@ Transform PivotTransform::ComputeGlobalTransform(Vector3 p_translation, Quat p_r
local_shear_scaling = S;
// Inherit type handler - we don't care about T here, just reordering RSrs etc.
- Transform global_rotation_scale;
+ Transform3D global_rotation_scale;
if (inherit_type == FBXDocParser::Transform_RrSs) {
global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_shear_scaling * local_shear_scaling;
} else if (inherit_type == FBXDocParser::Transform_RSrs) {
global_rotation_scale = parent_global_rotation_m * parent_shear_scaling * local_rotation_m * local_shear_scaling;
} else if (inherit_type == FBXDocParser::Transform_Rrs) {
- Transform parent_global_shear_m_noLocal = parent_shear_scaling * parent_local_scaling_m.affine_inverse();
+ Transform3D parent_global_shear_m_noLocal = parent_shear_scaling * parent_local_scaling_m.affine_inverse();
global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_global_shear_m_noLocal * local_shear_scaling;
}
- Transform local_transform = T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse();
- //Transform local_translation_pivoted = Transform(Basis(), LocalTransform.origin);
+ Transform3D local_transform = T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse();
+ //Transform3D local_translation_pivoted = Transform3D(Basis(), LocalTransform.origin);
- ERR_FAIL_COND_V_MSG(local_transform.basis.determinant() == 0, Transform(), "Det == 0 prevented in scene file");
+ ERR_FAIL_COND_V_MSG(local_transform.basis.determinant() == 0, Transform3D(), "Det == 0 prevented in scene file");
// manual hack to force SSC not to be compensated for - until we can handle it properly with tests
return parent_global_xform * local_transform;
}
void PivotTransform::ComputePivotTransform() {
- Transform T, Roff, Rp, Soff, Sp, S;
+ Transform3D T, Roff, Rp, Soff, Sp, S;
// Here I assume this is the operation which needs done.
// Its WorldTransform * V
@@ -237,26 +237,26 @@ void PivotTransform::ComputePivotTransform() {
Local_Scaling_Matrix = S; // copy for when node / child is looking for the value of this.
// Rotation pivots
- Transform Rpre = Transform(pre_rotation);
- Transform R = Transform(rotation);
- Transform Rpost = Transform(post_rotation);
+ Transform3D Rpre = Transform3D(pre_rotation);
+ Transform3D R = Transform3D(rotation);
+ Transform3D Rpost = Transform3D(post_rotation);
- Transform parent_global_xform;
- Transform parent_local_scaling_m;
+ Transform3D parent_global_xform;
+ Transform3D parent_local_scaling_m;
if (parent_transform.is_valid()) {
parent_global_xform = parent_transform->GlobalTransform;
parent_local_scaling_m = parent_transform->Local_Scaling_Matrix;
}
- Transform local_rotation_m, parent_global_rotation_m;
- Quat parent_global_rotation = parent_global_xform.basis.get_rotation_quat();
- parent_global_rotation_m.basis.set_quat(parent_global_rotation);
+ Transform3D local_rotation_m, parent_global_rotation_m;
+ Quaternion parent_global_rotation = parent_global_xform.basis.get_rotation_quaternion();
+ parent_global_rotation_m.basis.set_quaternion(parent_global_rotation);
local_rotation_m = Rpre * R * Rpost;
- //Basis parent_global_rotation = Basis(parent_global_xform.get_basis().get_rotation_quat().normalized());
+ //Basis parent_global_rotation = Basis(parent_global_xform.get_basis().get_rotation_quaternion().normalized());
- Transform local_shear_scaling, parent_shear_scaling, parent_shear_rotation, parent_shear_translation;
+ Transform3D local_shear_scaling, parent_shear_scaling, parent_shear_rotation, parent_shear_translation;
Vector3 parent_translation = parent_global_xform.get_origin();
parent_shear_translation.origin = parent_translation;
parent_shear_rotation = parent_shear_translation.affine_inverse() * parent_global_xform;
@@ -264,24 +264,24 @@ void PivotTransform::ComputePivotTransform() {
local_shear_scaling = S;
// Inherit type handler - we don't care about T here, just reordering RSrs etc.
- Transform global_rotation_scale;
+ Transform3D global_rotation_scale;
if (inherit_type == FBXDocParser::Transform_RrSs) {
global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_shear_scaling * local_shear_scaling;
} else if (inherit_type == FBXDocParser::Transform_RSrs) {
global_rotation_scale = parent_global_rotation_m * parent_shear_scaling * local_rotation_m * local_shear_scaling;
} else if (inherit_type == FBXDocParser::Transform_Rrs) {
- Transform parent_global_shear_m_noLocal = parent_shear_scaling * parent_local_scaling_m.inverse();
+ Transform3D parent_global_shear_m_noLocal = parent_shear_scaling * parent_local_scaling_m.inverse();
global_rotation_scale = parent_global_rotation_m * local_rotation_m * parent_global_shear_m_noLocal * local_shear_scaling;
}
- LocalTransform = Transform();
+ LocalTransform = Transform3D();
LocalTransform = T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse();
ERR_FAIL_COND_MSG(LocalTransform.basis.determinant() == 0, "invalid scale reset");
- Transform local_translation_pivoted = Transform(Basis(), LocalTransform.origin);
- GlobalTransform = Transform();
+ Transform3D local_translation_pivoted = Transform3D(Basis(), LocalTransform.origin);
+ GlobalTransform = Transform3D();
//GlobalTransform = parent_global_xform * LocalTransform;
- Transform global_origin = Transform(Basis(), parent_translation);
+ Transform3D global_origin = Transform3D(Basis(), parent_translation);
GlobalTransform = (global_origin * local_translation_pivoted) * global_rotation_scale;
ImportUtils::debug_xform("local xform calculation", LocalTransform);
diff --git a/modules/fbx/data/pivot_transform.h b/modules/fbx/data/pivot_transform.h
index 9996027870..099b268075 100644
--- a/modules/fbx/data/pivot_transform.h
+++ b/modules/fbx/data/pivot_transform.h
@@ -31,8 +31,8 @@
#ifndef PIVOT_TRANSFORM_H
#define PIVOT_TRANSFORM_H
-#include "core/math/transform.h"
-#include "core/object/reference.h"
+#include "core/math/transform_3d.h"
+#include "core/object/ref_counted.h"
#include "model_abstraction.h"
@@ -55,13 +55,13 @@ enum TransformationComp {
TransformationComp_MAXIMUM
};
// Abstract away pivot data so its simpler to handle
-struct PivotTransform : Reference, ModelAbstraction {
+struct PivotTransform : RefCounted, ModelAbstraction {
// at the end we want to keep geometric_ everything, post and pre rotation
// these are used during animation data processing / keyframe ingestion the rest can be simplified down / out.
- Quat pre_rotation = Quat();
- Quat post_rotation = Quat();
- Quat rotation = Quat();
- Quat geometric_rotation = Quat();
+ Quaternion pre_rotation = Quaternion();
+ Quaternion post_rotation = Quaternion();
+ Quaternion rotation = Quaternion();
+ Quaternion geometric_rotation = Quaternion();
Vector3 rotation_pivot = Vector3();
Vector3 rotation_offset = Vector3();
Vector3 scaling_offset = Vector3(1.0, 1.0, 1.0);
@@ -85,10 +85,10 @@ struct PivotTransform : Reference, ModelAbstraction {
print_verbose("raw post_rotation " + raw_post_rotation * (180 / Math_PI));
}
- Transform ComputeGlobalTransform(Transform t) const;
- Transform ComputeLocalTransform(Transform t) const;
- Transform ComputeGlobalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const;
- Transform ComputeLocalTransform(Vector3 p_translation, Quat p_rotation, Vector3 p_scaling) const;
+ Transform3D ComputeGlobalTransform(Transform3D t) const;
+ Transform3D ComputeLocalTransform(Transform3D t) const;
+ Transform3D ComputeGlobalTransform(Vector3 p_translation, Quaternion p_rotation, Vector3 p_scaling) const;
+ Transform3D ComputeLocalTransform(Vector3 p_translation, Quaternion p_rotation, Vector3 p_scaling) const;
/* Extract into xforms and calculate once */
void ComputePivotTransform();
@@ -105,10 +105,10 @@ struct PivotTransform : Reference, ModelAbstraction {
//Transform chain[TransformationComp_MAXIMUM];
// cached for later use
- Transform GlobalTransform = Transform();
- Transform LocalTransform = Transform();
- Transform Local_Scaling_Matrix = Transform(); // used for inherit type.
- Transform GeometricTransform = Transform(); // 3DS max only
+ Transform3D GlobalTransform = Transform3D();
+ Transform3D LocalTransform = Transform3D();
+ Transform3D Local_Scaling_Matrix = Transform3D(); // used for inherit type.
+ Transform3D GeometricTransform = Transform3D(); // 3DS max only
FBXDocParser::TransformInheritance inherit_type = FBXDocParser::TransformInheritance_MAX; // maya fbx requires this - sorry <3
};
diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp
index ccbea21541..e3f36ef3e3 100644
--- a/modules/fbx/editor_scene_importer_fbx.cpp
+++ b/modules/fbx/editor_scene_importer_fbx.cpp
@@ -102,7 +102,7 @@ Node3D *EditorSceneImporterFBX::import_scene(const String &p_path, uint32_t p_fl
FBXDocParser::TokenList tokens;
bool is_binary = false;
- data.resize(f->get_len());
+ data.resize(f->get_length());
ERR_FAIL_COND_V(data.size() < 64, nullptr);
@@ -258,24 +258,24 @@ struct EditorSceneImporterAssetImportInterpolate {
//thank you for existing, partial specialization
template <>
-struct EditorSceneImporterAssetImportInterpolate<Quat> {
- Quat lerp(const Quat &a, const Quat &b, float c) const {
- ERR_FAIL_COND_V(!a.is_normalized(), Quat());
- ERR_FAIL_COND_V(!b.is_normalized(), Quat());
+struct EditorSceneImporterAssetImportInterpolate<Quaternion> {
+ Quaternion lerp(const Quaternion &a, const Quaternion &b, float c) const {
+ ERR_FAIL_COND_V(!a.is_normalized(), Quaternion());
+ ERR_FAIL_COND_V(!b.is_normalized(), Quaternion());
return a.slerp(b, c).normalized();
}
- Quat catmull_rom(const Quat &p0, const Quat &p1, const Quat &p2, const Quat &p3, float c) {
- ERR_FAIL_COND_V(!p1.is_normalized(), Quat());
- ERR_FAIL_COND_V(!p2.is_normalized(), Quat());
+ Quaternion catmull_rom(const Quaternion &p0, const Quaternion &p1, const Quaternion &p2, const Quaternion &p3, float c) {
+ ERR_FAIL_COND_V(!p1.is_normalized(), Quaternion());
+ ERR_FAIL_COND_V(!p2.is_normalized(), Quaternion());
return p1.slerp(p2, c).normalized();
}
- Quat bezier(Quat start, Quat control_1, Quat control_2, Quat end, float t) {
- ERR_FAIL_COND_V(!start.is_normalized(), Quat());
- ERR_FAIL_COND_V(!end.is_normalized(), Quat());
+ Quaternion bezier(Quaternion start, Quaternion control_1, Quaternion control_2, Quaternion end, float t) {
+ ERR_FAIL_COND_V(!start.is_normalized(), Quaternion());
+ ERR_FAIL_COND_V(!end.is_normalized(), Quaternion());
return start.slerp(end, t).normalized();
}
@@ -373,7 +373,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
scene_root->add_child(state.root);
state.root->set_owner(scene_root);
- state.fbx_root_node.instance();
+ state.fbx_root_node.instantiate();
state.fbx_root_node->godot_node = state.root;
// Size relative to cm.
@@ -389,11 +389,11 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
// Enabled by default.
state.enable_animation_import = true;
Ref<FBXNode> root_node;
- root_node.instance();
+ root_node.instantiate();
// make sure fake noFBXDocParser::PropertyPtr ptrde always has a transform too ;)
Ref<PivotTransform> pivot_transform;
- pivot_transform.instance();
+ pivot_transform.instantiate();
root_node->pivot_transform = pivot_transform;
root_node->node_name = "root node";
root_node->current_node_id = 0;
@@ -479,7 +479,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
if (state.renderer_mesh_data.has(mesh_id)) {
mesh_vertex_data = state.renderer_mesh_data[mesh_id];
} else {
- mesh_vertex_data.instance();
+ mesh_vertex_data.instantiate();
state.renderer_mesh_data.insert(mesh_id, mesh_vertex_data);
}
@@ -535,7 +535,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
ERR_CONTINUE_MSG(!mat, "Could not convert fbx material by id: " + itos(material_id));
Ref<FBXMaterial> material;
- material.instance();
+ material.instantiate();
material->set_imported_material(mat);
Ref<StandardMaterial3D> godot_material = material->import_material(state);
@@ -575,7 +575,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
if (state.skeleton_map.has(armature_id)) {
fbx_skeleton_inst = state.skeleton_map[armature_id];
} else {
- fbx_skeleton_inst.instance();
+ fbx_skeleton_inst.instantiate();
state.skeleton_map.insert(armature_id, fbx_skeleton_inst);
}
@@ -650,7 +650,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
if (state.renderer_mesh_data.has(mesh_id)) {
mesh_data_precached = state.renderer_mesh_data[mesh_id];
} else {
- mesh_data_precached.instance();
+ mesh_data_precached.instantiate();
state.renderer_mesh_data.insert(mesh_id, mesh_data_precached);
}
@@ -735,7 +735,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
Ref<Skin> skin;
if (!state.MeshSkins.has(mesh_id)) {
print_verbose("Created new skin");
- skin.instance();
+ skin.instantiate();
state.MeshSkins.insert(mesh_id, skin);
} else {
print_verbose("Grabbed skin");
@@ -848,7 +848,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
}
Ref<Animation> animation;
- animation.instance();
+ animation.instantiate();
animation->set_name(animation_name);
animation->set_length(duration);
@@ -888,7 +888,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
// we need to know what object the curves are for.
// we need the target ID and the target name for the track reduction.
- FBXDocParser::Model::RotOrder quat_rotation_order = FBXDocParser::Model::RotOrder_EulerXYZ;
+ FBXDocParser::Model::RotOrder quaternion_rotation_order = FBXDocParser::Model::RotOrder_EulerXYZ;
// T:: R:: S:: Visible:: Custom::
for (const FBXDocParser::AnimationCurveNode *curve_node : node_list) {
@@ -910,7 +910,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
continue;
} else {
//print_verbose("[doc] applied rotation order: " + itos(target->RotationOrder()));
- quat_rotation_order = target->RotationOrder();
+ quaternion_rotation_order = target->RotationOrder();
}
uint64_t target_id = target->ID();
@@ -1011,7 +1011,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
// track count is 5.
// next track id is 5.
const uint64_t target_id = track->key();
- int track_idx = animation->add_track(Animation::TYPE_TRANSFORM);
+ int track_idx = animation->add_track(Animation::TYPE_TRANSFORM3D);
// animation->track_set_path(track_idx, node_path);
Ref<FBXBone> bone;
@@ -1023,7 +1023,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
bone = state.fbx_bone_map[target_id];
}
- Transform target_transform;
+ Transform3D target_transform;
if (state.fbx_target_map.has(target_id)) {
Ref<FBXNode> node_ref = state.fbx_target_map[target_id];
@@ -1056,7 +1056,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
//print_verbose("[doc] node animation path: " + node_path);
}
} else {
- // note: this could actually be unsafe this means we should be careful about continuing here, if we see bizzare effects later we should disable this.
+ // note: this could actually be unsafe this means we should be careful about continuing here, if we see bizarre effects later we should disable this.
// I am not sure if this is unsafe or not, testing will tell us this.
print_error("[doc] invalid fbx target detected for this track");
continue;
@@ -1086,7 +1086,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
Vector<float> pos_times;
Vector<Vector3> scale_values;
Vector<float> scale_times;
- Vector<Quat> rot_values;
+ Vector<Quaternion> rot_values;
Vector<float> rot_times;
double max_duration = 0;
@@ -1122,8 +1122,8 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
bool got_pre = false;
bool got_post = false;
- Quat post_rotation;
- Quat pre_rotation;
+ Quaternion post_rotation;
+ Quaternion pre_rotation;
// Rotation matrix
const Vector3 &PreRotation = FBXDocParser::PropertyGet<Vector3>(props, "PreRotation", got_pre);
@@ -1137,24 +1137,24 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
post_rotation = ImportUtils::EulerToQuaternion(rot_order, ImportUtils::deg2rad(PostRotation));
}
- Quat lastQuat = Quat();
+ Quaternion lastQuaternion = Quaternion();
for (std::pair<int64_t, Vector3> rotation_key : rotation_keys.keyframes) {
double animation_track_time = CONVERT_FBX_TIME(rotation_key.first);
//print_verbose("euler rotation key: " + rotation_key.second);
- Quat rot_key_value = ImportUtils::EulerToQuaternion(quat_rotation_order, ImportUtils::deg2rad(rotation_key.second));
+ Quaternion rot_key_value = ImportUtils::EulerToQuaternion(quaternion_rotation_order, ImportUtils::deg2rad(rotation_key.second));
- if (lastQuat != Quat() && rot_key_value.dot(lastQuat) < 0) {
+ if (lastQuaternion != Quaternion() && rot_key_value.dot(lastQuaternion) < 0) {
rot_key_value.x = -rot_key_value.x;
rot_key_value.y = -rot_key_value.y;
rot_key_value.z = -rot_key_value.z;
rot_key_value.w = -rot_key_value.w;
}
// pre_post rotation possibly could fix orientation
- Quat final_rotation = pre_rotation * rot_key_value * post_rotation;
+ Quaternion final_rotation = pre_rotation * rot_key_value * post_rotation;
- lastQuat = final_rotation;
+ lastQuaternion = final_rotation;
if (animation_track_time > max_duration) {
max_duration = animation_track_time;
@@ -1165,7 +1165,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
}
bool valid_rest = false;
- Transform bone_rest;
+ Transform3D bone_rest;
int skeleton_bone = -1;
if (state.fbx_bone_map.has(target_id)) {
if (bone.is_valid() && bone->fbx_skeleton.is_valid()) {
@@ -1182,13 +1182,13 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
}
const Vector3 def_pos = translation_keys.has_default ? (translation_keys.default_value * state.scale) : bone_rest.origin;
- const Quat def_rot = rotation_keys.has_default ? ImportUtils::EulerToQuaternion(quat_rotation_order, ImportUtils::deg2rad(rotation_keys.default_value)) : bone_rest.basis.get_rotation_quat();
+ const Quaternion def_rot = rotation_keys.has_default ? ImportUtils::EulerToQuaternion(quaternion_rotation_order, ImportUtils::deg2rad(rotation_keys.default_value)) : bone_rest.basis.get_rotation_quaternion();
const Vector3 def_scale = scale_keys.has_default ? scale_keys.default_value : bone_rest.basis.get_scale();
print_verbose("track defaults: p(" + def_pos + ") s(" + def_scale + ") r(" + def_rot + ")");
while (true) {
Vector3 pos = def_pos;
- Quat rot = def_rot;
+ Quaternion rot = def_rot;
Vector3 scale = def_scale;
if (pos_values.size()) {
@@ -1197,7 +1197,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
}
if (rot_values.size()) {
- rot = _interpolate_track<Quat>(rot_times, rot_values, time,
+ rot = _interpolate_track<Quaternion>(rot_times, rot_values, time,
AssetImportAnimation::INTERP_LINEAR);
}
@@ -1208,13 +1208,13 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
// node animations must also include pivots
if (skeleton_bone >= 0) {
- Transform xform = Transform();
- xform.basis.set_quat_scale(rot, scale);
+ Transform3D xform = Transform3D();
+ xform.basis.set_quaternion_scale(rot, scale);
xform.origin = pos;
- const Transform t = bone_rest.affine_inverse() * xform;
+ const Transform3D t = bone_rest.affine_inverse() * xform;
// populate this again
- rot = t.basis.get_rotation_quat();
+ rot = t.basis.get_rotation_quaternion();
rot.normalize();
scale = t.basis.get_scale();
pos = t.origin;
@@ -1312,7 +1312,7 @@ void EditorSceneImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,
// declare our bone element reference (invalid, unless we create a bone in this step)
// this lets us pass valid armature information into children objects and this is why we moved this up here
- // previously this was created .instanced() on the same line.
+ // previously this was created .instantiated() on the same line.
Ref<FBXBone> bone_element;
if (model != nullptr) {
@@ -1324,7 +1324,7 @@ void EditorSceneImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,
ERR_FAIL_COND_MSG(state.fbx_bone_map.has(limb_node->ID()), "[serious] duplicate LimbNode detected");
bool parent_is_bone = state.fbx_bone_map.find(p_id);
- bone_element.instance();
+ bone_element.instantiate();
// used to build the bone hierarchy in the skeleton
bone_element->parent_bone_id = parent_is_bone ? p_id : 0;
@@ -1404,12 +1404,12 @@ void EditorSceneImporterFBX::BuildDocumentNodes(
uint64_t current_node_id = model->ID();
Ref<FBXNode> new_node;
- new_node.instance();
+ new_node.instantiate();
new_node->current_node_id = current_node_id;
new_node->node_name = ImportUtils::FBXNodeToName(model->Name());
Ref<PivotTransform> fbx_transform;
- fbx_transform.instance();
+ fbx_transform.instantiate();
fbx_transform->set_parent(parent_transform);
fbx_transform->set_model(model);
fbx_transform->debug_pivot_xform("name: " + new_node->node_name);
diff --git a/modules/fbx/fbx_parser/FBXDeformer.cpp b/modules/fbx/fbx_parser/FBXDeformer.cpp
index 039718ae15..4220ba62a7 100644
--- a/modules/fbx/fbx_parser/FBXDeformer.cpp
+++ b/modules/fbx/fbx_parser/FBXDeformer.cpp
@@ -78,7 +78,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXMeshGeometry.h"
#include "FBXParser.h"
#include "core/math/math_funcs.h"
-#include "core/math/transform.h"
+#include "core/math/transform_3d.h"
#include <iostream>
diff --git a/modules/fbx/fbx_parser/FBXDocument.cpp b/modules/fbx/fbx_parser/FBXDocument.cpp
index bb85d6ff7c..89c69d2ee8 100644
--- a/modules/fbx/fbx_parser/FBXDocument.cpp
+++ b/modules/fbx/fbx_parser/FBXDocument.cpp
@@ -487,7 +487,7 @@ const std::vector<const AnimationStack *> &Document::AnimationStacks() const {
const AnimationStack *stack = lazy->Get<AnimationStack>();
ERR_CONTINUE_MSG(!stack, "invalid ptr to AnimationStack - conversion failure");
- // We push back the weak reference :) to keep things simple, as ownership is on the parser side so it wont be cleaned up.
+ // We push back the weak reference :) to keep things simple, as ownership is on the parser side so it won't be cleaned up.
animationStacksResolved.push_back(stack);
}
diff --git a/modules/fbx/fbx_parser/FBXDocument.h b/modules/fbx/fbx_parser/FBXDocument.h
index 9664cd763a..885ff8fca4 100644
--- a/modules/fbx/fbx_parser/FBXDocument.h
+++ b/modules/fbx/fbx_parser/FBXDocument.h
@@ -37,7 +37,7 @@
#include "FBXCommon.h"
#include "FBXParser.h"
#include "FBXProperties.h"
-#include "core/math/transform.h"
+#include "core/math/transform_3d.h"
#include "core/math/vector2.h"
#include "core/math/vector3.h"
#include "core/string/print_string.h"
@@ -242,13 +242,13 @@ public:
return target_id;
}
- Transform GetBindPose() const {
+ Transform3D GetBindPose() const {
return transform;
}
private:
uint64_t target_id = 0;
- Transform transform;
+ Transform3D transform;
};
/** DOM base class for FBX cameras attached to a node */
@@ -699,7 +699,7 @@ private:
typedef std::vector<int64_t> KeyTimeList;
typedef std::vector<float> KeyValueList;
-/** Represents a FBX animation curve (i.e. a 1-dimensional set of keyframes and values therefor) */
+/** Represents a FBX animation curve (i.e. a 1-dimensional set of keyframes and values therefore) */
class AnimationCurve : public Object {
public:
AnimationCurve(uint64_t id, const ElementPtr element, const std::string &name, const Document &doc);
@@ -905,11 +905,11 @@ public:
}
/** */
- const Transform &GetTransform() const {
+ const Transform3D &GetTransform() const {
return transform;
}
- const Transform &TransformLink() const {
+ const Transform3D &TransformLink() const {
return transformLink;
}
@@ -917,7 +917,7 @@ public:
return node;
}
- const Transform &TransformAssociateModel() const {
+ const Transform3D &TransformAssociateModel() const {
return transformAssociateModel;
}
@@ -941,9 +941,9 @@ private:
std::vector<float> weights;
std::vector<unsigned int> indices;
- Transform transform;
- Transform transformLink;
- Transform transformAssociateModel;
+ Transform3D transform;
+ Transform3D transformLink;
+ Transform3D transformAssociateModel;
SkinLinkMode link_mode;
bool valid_transformAssociateModel = false;
const Model *node = nullptr;
diff --git a/modules/fbx/fbx_parser/FBXMeshGeometry.cpp b/modules/fbx/fbx_parser/FBXMeshGeometry.cpp
index a28e7565c6..2cc25a0690 100644
--- a/modules/fbx/fbx_parser/FBXMeshGeometry.cpp
+++ b/modules/fbx/fbx_parser/FBXMeshGeometry.cpp
@@ -125,7 +125,7 @@ MeshGeometry::MeshGeometry(uint64_t id, const ElementPtr element, const std::str
ScopePtr sc = element->Compound();
ERR_FAIL_COND_MSG(sc == nullptr, "failed to read geometry, prevented crash");
- ERR_FAIL_COND_MSG(!HasElement(sc, "Vertices"), "Detected mesh with no vertexes, didn't populate the mesh");
+ ERR_FAIL_COND_MSG(!HasElement(sc, "Vertices"), "Detected mesh with no vertices, didn't populate the mesh");
// must have Mesh elements:
const ElementPtr Vertices = GetRequiredElement(sc, "Vertices", element);
@@ -140,7 +140,7 @@ MeshGeometry::MeshGeometry(uint64_t id, const ElementPtr element, const std::str
ParseVectorDataArray(m_vertices, Vertices);
ParseVectorDataArray(m_face_indices, PolygonVertexIndex);
- ERR_FAIL_COND_MSG(m_vertices.empty(), "mesh with no vertexes in FBX file, did you mean to delete it?");
+ ERR_FAIL_COND_MSG(m_vertices.empty(), "mesh with no vertices in FBX file, did you mean to delete it?");
ERR_FAIL_COND_MSG(m_face_indices.empty(), "mesh has no faces, was this intended?");
// Retrieve layer elements, for all of the mesh
@@ -278,7 +278,7 @@ MeshGeometry::MeshGeometry(uint64_t id, const ElementPtr element, const std::str
}
}
// As the algorithm above, this check is useless. Because the first
- // ever vertex is always considered the begining of a polygon.
+ // ever vertex is always considered the beginning of a polygon.
ERR_FAIL_COND_MSG(found_it == false, "Was not possible to find the first vertex of this polygon. FBX file is corrupted.");
} else {
@@ -418,7 +418,7 @@ MeshGeometry::MappingData<T> MeshGeometry::resolve_vertex_data_array(
// parse data into array
ParseVectorDataArray(tempData.data, GetRequiredElement(source, dataElementName));
- // index array wont always exist
+ // index array won't always exist
const ElementPtr element = GetOptionalElement(source, indexDataElementName);
if (element) {
ParseVectorDataArray(tempData.index, element);
diff --git a/modules/fbx/fbx_parser/FBXMeshGeometry.h b/modules/fbx/fbx_parser/FBXMeshGeometry.h
index 05493c4aec..c9b25f008d 100644
--- a/modules/fbx/fbx_parser/FBXMeshGeometry.h
+++ b/modules/fbx/fbx_parser/FBXMeshGeometry.h
@@ -122,7 +122,7 @@ typedef std::vector<int> MatIndexArray;
/// ## Map Type:
/// * None The mapping is undetermined.
/// * ByVertex There will be one mapping coordinate for each surface control point/vertex (ControlPoint is a vertex).
-/// * If you have direct reference type verticies[x]
+/// * If you have direct reference type vertices[x]
/// * If you have IndexToDirect reference type the UV
/// * ByPolygonVertex There will be one mapping coordinate for each vertex, for every polygon of which it is a part. This means that a vertex will have as many mapping coordinates as polygons of which it is a part. (Sorted by polygon, referencing vertex)
/// * ByPolygon There can be only one mapping coordinate for the whole polygon.
@@ -186,7 +186,7 @@ public:
/// Returns -1 if the vertices doesn't form an edge. Vertex order, doesn't
// matter.
static int get_edge_id(const std::vector<Edge> &p_map, int p_vertex_a, int p_vertex_b);
- // Retuns the edge point bu that ID, or the edge with -1 vertices if the
+ // Returns the edge point bu that ID, or the edge with -1 vertices if the
// id is not valid.
static Edge get_edge(const std::vector<Edge> &p_map, int p_id);
diff --git a/modules/fbx/fbx_parser/FBXParser.cpp b/modules/fbx/fbx_parser/FBXParser.cpp
index 98435b5c0f..a92b23f4ee 100644
--- a/modules/fbx/fbx_parser/FBXParser.cpp
+++ b/modules/fbx/fbx_parser/FBXParser.cpp
@@ -82,7 +82,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXParser.h"
#include "FBXTokenizer.h"
#include "core/math/math_defs.h"
-#include "core/math/transform.h"
+#include "core/math/transform_3d.h"
#include "core/math/vector3.h"
#include "core/string/print_string.h"
@@ -1157,7 +1157,7 @@ void ParseVectorDataArray(std::vector<int64_t> &out, const ElementPtr el) {
}
// ------------------------------------------------------------------------------------------------
-Transform ReadMatrix(const ElementPtr element) {
+Transform3D ReadMatrix(const ElementPtr element) {
std::vector<float> values;
ParseVectorDataArray(values, element);
@@ -1167,12 +1167,12 @@ Transform ReadMatrix(const ElementPtr element) {
// clean values to prevent any IBM damage on inverse() / affine_inverse()
for (float &value : values) {
- if (::Math::is_equal_approx(0, value)) {
+ if (::Math::is_zero_approx(value)) {
value = 0;
}
}
- Transform xform;
+ Transform3D xform;
Basis basis;
basis.set(
diff --git a/modules/fbx/fbx_parser/FBXParser.h b/modules/fbx/fbx_parser/FBXParser.h
index 8b248e8791..93836c2205 100644
--- a/modules/fbx/fbx_parser/FBXParser.h
+++ b/modules/fbx/fbx_parser/FBXParser.h
@@ -81,7 +81,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory>
#include "core/math/color.h"
-#include "core/math/transform.h"
+#include "core/math/transform_3d.h"
#include "core/math/vector2.h"
#include "core/math/vector3.h"
@@ -264,7 +264,7 @@ TokenPtr GetRequiredToken(const ElementPtr el, unsigned int index);
// ------------------------------------------------------------------------------------------------
// read a 4x4 matrix from an array of 16 floats
-Transform ReadMatrix(const ElementPtr element);
+Transform3D ReadMatrix(const ElementPtr element);
} // namespace FBXDocParser
#endif // FBX_PARSER_H
diff --git a/modules/fbx/register_types.cpp b/modules/fbx/register_types.cpp
index c0591dbc77..b615c91cd2 100644
--- a/modules/fbx/register_types.cpp
+++ b/modules/fbx/register_types.cpp
@@ -36,7 +36,7 @@
#ifdef TOOLS_ENABLED
static void _editor_init() {
Ref<EditorSceneImporterFBX> import_fbx;
- import_fbx.instance();
+ import_fbx.instantiate();
ResourceImporterScene::get_singleton()->add_importer(import_fbx);
}
#endif
diff --git a/modules/fbx/tools/import_utils.cpp b/modules/fbx/tools/import_utils.cpp
index c87dd1fd3a..66b0153308 100644
--- a/modules/fbx/tools/import_utils.cpp
+++ b/modules/fbx/tools/import_utils.cpp
@@ -80,7 +80,7 @@ Basis ImportUtils::EulerToBasis(FBXDocParser::Model::RotOrder mode, const Vector
return ret;
}
-Quat ImportUtils::EulerToQuaternion(FBXDocParser::Model::RotOrder mode, const Vector3 &p_rotation) {
+Quaternion ImportUtils::EulerToQuaternion(FBXDocParser::Model::RotOrder mode, const Vector3 &p_rotation) {
return ImportUtils::EulerToBasis(mode, p_rotation);
}
@@ -117,18 +117,18 @@ Vector3 ImportUtils::BasisToEuler(FBXDocParser::Model::RotOrder mode, const Basi
}
}
-Vector3 ImportUtils::QuaternionToEuler(FBXDocParser::Model::RotOrder mode, const Quat &p_rotation) {
+Vector3 ImportUtils::QuaternionToEuler(FBXDocParser::Model::RotOrder mode, const Quaternion &p_rotation) {
return BasisToEuler(mode, p_rotation);
}
-Transform get_unscaled_transform(const Transform &p_initial, real_t p_scale) {
- Transform unscaled = Transform(p_initial.basis, p_initial.origin * p_scale);
- ERR_FAIL_COND_V_MSG(unscaled.basis.determinant() == 0, Transform(), "det is zero unscaled?");
+Transform3D get_unscaled_transform(const Transform3D &p_initial, real_t p_scale) {
+ Transform3D unscaled = Transform3D(p_initial.basis, p_initial.origin * p_scale);
+ ERR_FAIL_COND_V_MSG(unscaled.basis.determinant() == 0, Transform3D(), "det is zero unscaled?");
return unscaled;
}
Vector3 get_poly_normal(const std::vector<Vector3> &p_vertices) {
- ERR_FAIL_COND_V_MSG(p_vertices.size() < 3, Vector3(0, 0, 0), "At least 3 vertices are necesary");
+ ERR_FAIL_COND_V_MSG(p_vertices.size() < 3, Vector3(0, 0, 0), "At least 3 vertices are necessary");
// Using long double to make sure that normal is computed for even really tiny objects.
typedef long double ldouble;
ldouble x = 0.0;
diff --git a/modules/fbx/tools/import_utils.h b/modules/fbx/tools/import_utils.h
index cf0f811e35..fbe7dbd82f 100644
--- a/modules/fbx/tools/import_utils.h
+++ b/modules/fbx/tools/import_utils.h
@@ -56,15 +56,15 @@ public:
static Basis EulerToBasis(FBXDocParser::Model::RotOrder mode, const Vector3 &p_rotation);
/// Converts rotation order vector (in rad) to quaternion.
- static Quat EulerToQuaternion(FBXDocParser::Model::RotOrder mode, const Vector3 &p_rotation);
+ static Quaternion EulerToQuaternion(FBXDocParser::Model::RotOrder mode, const Vector3 &p_rotation);
/// Converts basis into rotation order vector (in rad).
static Vector3 BasisToEuler(FBXDocParser::Model::RotOrder mode, const Basis &p_rotation);
/// Converts quaternion into rotation order vector (in rad).
- static Vector3 QuaternionToEuler(FBXDocParser::Model::RotOrder mode, const Quat &p_rotation);
+ static Vector3 QuaternionToEuler(FBXDocParser::Model::RotOrder mode, const Quaternion &p_rotation);
- static void debug_xform(String name, const Transform &t) {
+ static void debug_xform(String name, const Transform3D &t) {
print_verbose(name + " " + t.origin + " rotation: " + (t.basis.get_euler() * (180 / Math_PI)));
}
@@ -137,15 +137,15 @@ public:
static Vector3 safe_import_vector3(const Vector3 &p_vec) {
Vector3 vector = p_vec;
- if (Math::is_equal_approx(0, vector.x)) {
+ if (Math::is_zero_approx(vector.x)) {
vector.x = 0;
}
- if (Math::is_equal_approx(0, vector.y)) {
+ if (Math::is_zero_approx(vector.y)) {
vector.y = 0;
}
- if (Math::is_equal_approx(0, vector.z)) {
+ if (Math::is_zero_approx(vector.z)) {
vector.z = 0;
}
return vector;
@@ -317,7 +317,7 @@ public:
// }
// } else {
// Ref<Image> img;
- // img.instance();
+ // img.instantiate();
// PoolByteArray arr;
// uint32_t size = tex->mWidth * tex->mHeight;
// arr.resize(size);
@@ -362,7 +362,7 @@ public:
// if (found) {
// image_state.raw_image = AssimpUtils::load_image(state, state.assimp_scene, path);
// if (image_state.raw_image.is_valid()) {
- // image_state.texture.instance();
+ // image_state.texture.instantiate();
// image_state.texture->create_from_image(image_state.raw_image);
// image_state.texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY);
// return true;
@@ -391,7 +391,7 @@ public:
};
// Apply the transforms so the basis will have scale 1.
-Transform get_unscaled_transform(const Transform &p_initial, real_t p_scale);
+Transform3D get_unscaled_transform(const Transform3D &p_initial, real_t p_scale);
/// Uses the Newell's method to compute any polygon normal.
/// The polygon must be at least size of 3 or bigger.
diff --git a/modules/fbx/tools/validation_tools.h b/modules/fbx/tools/validation_tools.h
index fe0c92b22f..906a721045 100644
--- a/modules/fbx/tools/validation_tools.h
+++ b/modules/fbx/tools/validation_tools.h
@@ -33,9 +33,8 @@
#ifdef TOOLS_ENABLED
-#include "core/io/json.h"
-#include "core/os/file_access.h"
-#include "core/string/ustring.h"
+#include "core/io/file_access.h"
+#include "core/string/print_string.h"
#include "core/templates/local_vector.h"
#include "core/templates/map.h"