summaryrefslogtreecommitdiff
path: root/modules/fbx/data
diff options
context:
space:
mode:
Diffstat (limited to 'modules/fbx/data')
-rw-r--r--modules/fbx/data/fbx_material.h5
-rw-r--r--modules/fbx/data/fbx_mesh_data.cpp25
-rw-r--r--modules/fbx/data/fbx_skeleton.cpp2
-rw-r--r--modules/fbx/data/pivot_transform.cpp15
4 files changed, 30 insertions, 17 deletions
diff --git a/modules/fbx/data/fbx_material.h b/modules/fbx/data/fbx_material.h
index e974a256f6..23310b8e1d 100644
--- a/modules/fbx/data/fbx_material.h
+++ b/modules/fbx/data/fbx_material.h
@@ -217,9 +217,6 @@ struct FBXMaterial : public Reference {
{ "TransparencyFactor", PROPERTY_DESC_TRANSPARENT },
{ "Maya|opacity", PROPERTY_DESC_TRANSPARENT },
- /* Metallic */
- { "Shininess", PROPERTY_DESC_METALLIC },
- { "Reflectivity", PROPERTY_DESC_METALLIC },
{ "Maya|metalness", PROPERTY_DESC_METALLIC },
{ "Maya|metallic", PROPERTY_DESC_METALLIC },
@@ -241,6 +238,8 @@ struct FBXMaterial : public Reference {
{ "Maya|emissionColor", PROPERTY_DESC_EMISSIVE_COLOR },
/* Ignore */
+ { "Shininess", PROPERTY_DESC_IGNORE },
+ { "Reflectivity", PROPERTY_DESC_IGNORE },
{ "Maya|diffuseRoughness", PROPERTY_DESC_IGNORE },
{ "Maya", PROPERTY_DESC_IGNORE },
{ "Diffuse", PROPERTY_DESC_ALBEDO_COLOR },
diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp
index 963a815896..b088dd8640 100644
--- a/modules/fbx/data/fbx_mesh_data.cpp
+++ b/modules/fbx/data/fbx_mesh_data.cpp
@@ -34,7 +34,7 @@
#include "scene/resources/mesh.h"
#include "scene/resources/surface_tool.h"
-#include "thirdparty/misc/triangulator.h"
+#include "thirdparty/misc/polypartition.h"
template <class T>
T collect_first(const Vector<VertexData<T>> *p_data, T p_fall_back) {
@@ -417,6 +417,7 @@ void FBXMeshData::sanitize_vertex_weights(const ImportState &state) {
int bind_id = 0;
for (const FBXDocParser::Cluster *cluster : fbx_skin->Clusters()) {
+ ERR_CONTINUE_MSG(!state.fbx_bone_map.has(cluster->TargetNode()->ID()), "Missing bone map for cluster target node with id " + uitos(cluster->TargetNode()->ID()) + ".");
Ref<FBXBone> bone = state.fbx_bone_map[cluster->TargetNode()->ID()];
skeleton_to_skin_bind_id.insert(bone->godot_bone_id, bind_id);
bind_id++;
@@ -930,30 +931,30 @@ void FBXMeshData::triangulate_polygon(Ref<SurfaceTool> st, Vector<int> p_polygon
}
}
- TriangulatorPoly triangulator_poly;
- triangulator_poly.Init(polygon_vertex_count);
+ TPPLPoly tppl_poly;
+ tppl_poly.Init(polygon_vertex_count);
std::vector<Vector2> projected_vertices(polygon_vertex_count);
for (int i = 0; i < polygon_vertex_count; i += 1) {
const Vector2 pv(poly_vertices[i][axis_1_coord], poly_vertices[i][axis_2_coord]);
projected_vertices[i] = pv;
- triangulator_poly.GetPoint(i) = pv;
+ tppl_poly.GetPoint(i) = pv;
}
- triangulator_poly.SetOrientation(TRIANGULATOR_CCW);
+ tppl_poly.SetOrientation(TPPL_ORIENTATION_CCW);
- List<TriangulatorPoly> out_poly;
+ List<TPPLPoly> out_poly;
- TriangulatorPartition triangulator_partition;
- if (triangulator_partition.Triangulate_OPT(&triangulator_poly, &out_poly) == 0) { // Good result.
- if (triangulator_partition.Triangulate_EC(&triangulator_poly, &out_poly) == 0) { // Medium result.
- if (triangulator_partition.Triangulate_MONO(&triangulator_poly, &out_poly) == 0) { // Really poor result.
+ TPPLPartition tppl_partition;
+ if (tppl_partition.Triangulate_OPT(&tppl_poly, &out_poly) == 0) { // Good result.
+ if (tppl_partition.Triangulate_EC(&tppl_poly, &out_poly) == 0) { // Medium result.
+ if (tppl_partition.Triangulate_MONO(&tppl_poly, &out_poly) == 0) { // Really poor result.
ERR_FAIL_MSG("The triangulation of this polygon failed, please try to triangulate your mesh or check if it has broken polygons.");
}
}
}
std::vector<Vector2> tris(out_poly.size());
- for (List<TriangulatorPoly>::Element *I = out_poly.front(); I; I = I->next()) {
- TriangulatorPoly &tp = I->get();
+ 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?");
// Find Index
diff --git a/modules/fbx/data/fbx_skeleton.cpp b/modules/fbx/data/fbx_skeleton.cpp
index 622b589feb..1ac4922acf 100644
--- a/modules/fbx/data/fbx_skeleton.cpp
+++ b/modules/fbx/data/fbx_skeleton.cpp
@@ -69,7 +69,7 @@ void FBXSkeleton::init_skeleton(const ImportState &state) {
// Make sure the bone name is unique.
const String bone_name = bone->bone_name;
int same_name_count = 0;
- for (int y = x; y < skeleton_bone_count; y++) {
+ for (int y = x + 1; y < skeleton_bone_count; y++) {
Ref<FBXBone> other_bone = skeleton_bones[y];
if (other_bone.is_valid()) {
if (other_bone->bone_name == bone_name) {
diff --git a/modules/fbx/data/pivot_transform.cpp b/modules/fbx/data/pivot_transform.cpp
index 7a56074bc5..1895af6f9f 100644
--- a/modules/fbx/data/pivot_transform.cpp
+++ b/modules/fbx/data/pivot_transform.cpp
@@ -76,12 +76,14 @@ void PivotTransform::ReadTransformChain() {
const Vector3 &Scaling = ImportUtils::safe_import_vector3(FBXDocParser::PropertyGet<Vector3>(props, "Lcl Scaling", ok));
if (ok) {
scaling = Scaling;
+ } else {
+ scaling = Vector3(1, 1, 1);
}
const Vector3 &GeometricScaling = ImportUtils::safe_import_vector3(FBXDocParser::PropertyGet<Vector3>(props, "GeometricScaling", ok));
if (ok) {
geometric_scaling = GeometricScaling;
} else {
- geometric_scaling = Vector3(0, 0, 0);
+ geometric_scaling = Vector3(1, 1, 1);
}
const Vector3 &GeometricRotation = ImportUtils::safe_import_vector3(FBXDocParser::PropertyGet<Vector3>(props, "GeometricRotation", ok));
@@ -207,6 +209,8 @@ Transform PivotTransform::ComputeGlobalTransform(Vector3 p_translation, Quat p_r
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);
+ ERR_FAIL_COND_V_MSG(local_transform.basis.determinant() == 0, Transform(), "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;
}
@@ -290,5 +294,14 @@ void PivotTransform::Execute() {
ComputePivotTransform();
ImportUtils::debug_xform("global xform: ", GlobalTransform);
+
+ if (LocalTransform.basis.determinant() == 0) {
+ print_error("Serious det == 0!");
+ }
+
+ if (GlobalTransform.basis.determinant() == 0) {
+ print_error("Serious! node has det == 0!");
+ }
+
computed_global_xform = true;
}