You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Merge pull request #44305 from RevoluPowered/fbx-update-plugin
[fbx] Implement ColorIndex for Vertex Colors to ensure they are correct and duplicate vertexes correctly for multiple color attributes.
This commit is contained in:
@@ -211,7 +211,33 @@ MeshGeometry::MeshGeometry(uint64_t id, const ElementPtr element, const std::str
|
||||
} else if (layer_type_name == "LayerElementNormal") {
|
||||
m_normals = resolve_vertex_data_array<Vector3>(layer_scope, MappingInformationType, ReferenceInformationType, "Normals");
|
||||
} else if (layer_type_name == "LayerElementColor") {
|
||||
m_colors = resolve_vertex_data_array<Color>(layer_scope, MappingInformationType, ReferenceInformationType, "Colors");
|
||||
m_colors = resolve_vertex_data_array<Color>(layer_scope, MappingInformationType, ReferenceInformationType, "Colors", "ColorIndex");
|
||||
// NOTE: this is a useful sanity check to ensure you're getting any color data which is not default.
|
||||
// const Color first_color_check = m_colors.data[0];
|
||||
// bool colors_are_all_the_same = true;
|
||||
// size_t i = 1;
|
||||
// for(i = 1; i < m_colors.data.size(); i++)
|
||||
// {
|
||||
// const Color current_color = m_colors.data[i];
|
||||
// if(current_color.is_equal_approx(first_color_check))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// colors_are_all_the_same = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(colors_are_all_the_same)
|
||||
// {
|
||||
// print_error("Color serialisation is not working for vertex colors some should be different in the test asset.");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// print_verbose("Color array has unique colors at index: " + itos(i));
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,12 +361,22 @@ MeshGeometry::MappingData<T> MeshGeometry::resolve_vertex_data_array(
|
||||
const ScopePtr source,
|
||||
const std::string &MappingInformationType,
|
||||
const std::string &ReferenceInformationType,
|
||||
const std::string &dataElementName) {
|
||||
const std::string &dataElementName,
|
||||
const std::string &indexOverride) {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(source == nullptr, MappingData<T>(), "Invalid scope operator preventing memory corruption");
|
||||
|
||||
// UVIndex, MaterialIndex, NormalIndex, etc..
|
||||
std::string indexDataElementName = dataElementName + "Index";
|
||||
std::string indexDataElementName;
|
||||
|
||||
if (indexOverride != "") {
|
||||
// Colors should become ColorIndex
|
||||
indexDataElementName = indexOverride;
|
||||
} else {
|
||||
// Some indexes will exist.
|
||||
indexDataElementName = dataElementName + "Index";
|
||||
}
|
||||
|
||||
// goal: expand everything to be per vertex
|
||||
|
||||
ReferenceType l_ref_type = ReferenceType::direct;
|
||||
|
||||
Reference in New Issue
Block a user