Utility/Mesh: Fix Recenter() method for other vertex layouts

This commit is contained in:
Jérôme Leclercq
2021-06-05 19:09:12 +02:00
parent 613b3b8627
commit 0411271851
2 changed files with 4 additions and 6 deletions

View File

@@ -515,15 +515,12 @@ namespace Nz
{
StaticMesh& staticMesh = static_cast<StaticMesh&>(*data.subMesh);
BufferMapper<VertexBuffer> mapper(*staticMesh.GetVertexBuffer(), BufferAccess::ReadWrite);
MeshVertex* vertices = static_cast<MeshVertex*>(mapper.GetPointer());
VertexMapper mapper(*staticMesh.GetVertexBuffer());
SparsePtr<Vector3f> position = mapper.GetComponentPtr<Vector3f>(VertexComponent::Position);
std::size_t vertexCount = staticMesh.GetVertexCount();
for (std::size_t i = 0; i < vertexCount; ++i)
{
vertices->position -= center;
vertices++;
}
*position++ -= center;
// Our AABB doesn't change shape, only position
Boxf aabb = staticMesh.GetAABB();