Utility/Mesh: Fix Recenter() method for other vertex layouts
This commit is contained in:
parent
613b3b8627
commit
0411271851
|
|
@ -83,6 +83,7 @@ int main()
|
||||||
|
|
||||||
Nz::MeshParams meshParams;
|
Nz::MeshParams meshParams;
|
||||||
meshParams.storage = Nz::DataStorage::Software;
|
meshParams.storage = Nz::DataStorage::Software;
|
||||||
|
meshParams.center = true;
|
||||||
meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 180.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f));
|
meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 180.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f));
|
||||||
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV);
|
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -515,15 +515,12 @@ namespace Nz
|
||||||
{
|
{
|
||||||
StaticMesh& staticMesh = static_cast<StaticMesh&>(*data.subMesh);
|
StaticMesh& staticMesh = static_cast<StaticMesh&>(*data.subMesh);
|
||||||
|
|
||||||
BufferMapper<VertexBuffer> mapper(*staticMesh.GetVertexBuffer(), BufferAccess::ReadWrite);
|
VertexMapper mapper(*staticMesh.GetVertexBuffer());
|
||||||
MeshVertex* vertices = static_cast<MeshVertex*>(mapper.GetPointer());
|
SparsePtr<Vector3f> position = mapper.GetComponentPtr<Vector3f>(VertexComponent::Position);
|
||||||
|
|
||||||
std::size_t vertexCount = staticMesh.GetVertexCount();
|
std::size_t vertexCount = staticMesh.GetVertexCount();
|
||||||
for (std::size_t i = 0; i < vertexCount; ++i)
|
for (std::size_t i = 0; i < vertexCount; ++i)
|
||||||
{
|
*position++ -= center;
|
||||||
vertices->position -= center;
|
|
||||||
vertices++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Our AABB doesn't change shape, only position
|
// Our AABB doesn't change shape, only position
|
||||||
Boxf aabb = staticMesh.GetAABB();
|
Boxf aabb = staticMesh.GetAABB();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue