mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
Mesh::merge: count_vertices instead of initializing positions (#16024)
# Objective When merging two meshes, we need to find the offset of indices for the second mesh. Currently it is done by inserting empty positions if positions is not set. Although practically it is not an issue, this does not feel right: - We did not have positions before, then why we have positions after merge? - Moreover, if positions are not set, but uvs are not empty, computed offset will be zero, while it should be equal to the number of uvs. ## Solution Use `Mesh::count_vertices` to find the number of vertices. ## Testing Looking hard.
This commit is contained in:
parent
928dee830e
commit
1f69bc1f96
1 changed files with 1 additions and 4 deletions
|
@ -793,10 +793,7 @@ impl Mesh {
|
||||||
use VertexAttributeValues::*;
|
use VertexAttributeValues::*;
|
||||||
|
|
||||||
// The indices of `other` should start after the last vertex of `self`.
|
// The indices of `other` should start after the last vertex of `self`.
|
||||||
let index_offset = self
|
let index_offset = self.count_vertices();
|
||||||
.attribute(Mesh::ATTRIBUTE_POSITION)
|
|
||||||
.get_or_insert(&Float32x3(Vec::default()))
|
|
||||||
.len();
|
|
||||||
|
|
||||||
// Extend attributes of `self` with attributes of `other`.
|
// Extend attributes of `self` with attributes of `other`.
|
||||||
for (attribute, values) in self.attributes_mut() {
|
for (attribute, values) in self.attributes_mut() {
|
||||||
|
|
Loading…
Reference in a new issue