Fix dramatically overallocated normal weights

The weight is per-attribute scalar (X, Y, Z), not per-vertex; this was
the case even before the library update so this appears to be an
oversight.
This commit is contained in:
Arseny Kapoulkine 2023-11-02 14:17:41 -07:00
parent be2b0fcddc
commit 2b8215a196
1 changed files with 5 additions and 6 deletions

View File

@ -418,11 +418,10 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
} }
} }
LocalVector<float> normal_weights; const float normal_weights[3] = {
normal_weights.resize(merged_vertex_count); // Give some weight to normal preservation, may be worth exposing as an import setting
for (unsigned int j = 0; j < merged_vertex_count; j++) { 2.0f, 2.0f, 2.0f
normal_weights[j] = 2.0; // Give some weight to normal preservation, may be worth exposing as an import setting };
}
Vector<float> merged_vertices_f32 = vector3_to_float32_array(merged_vertices_ptr, merged_vertex_count); Vector<float> merged_vertices_f32 = vector3_to_float32_array(merged_vertices_ptr, merged_vertex_count);
float scale = SurfaceTool::simplify_scale_func(merged_vertices_f32.ptr(), merged_vertex_count, sizeof(float) * 3); float scale = SurfaceTool::simplify_scale_func(merged_vertices_f32.ptr(), merged_vertex_count, sizeof(float) * 3);
@ -462,7 +461,7 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
sizeof(float) * 3, // Vertex stride sizeof(float) * 3, // Vertex stride
merged_normals_f32.ptr(), merged_normals_f32.ptr(),
sizeof(float) * 3, // Attribute stride sizeof(float) * 3, // Attribute stride
normal_weights.ptr(), 3, normal_weights, 3,
index_target, index_target,
max_mesh_error, max_mesh_error,
simplify_options, simplify_options,