Fixed mesh centering

Former-commit-id: d27dc7f0734d6a5bf0ecd6d36ede2f11cbff7c9c
This commit is contained in:
Lynix
2015-01-17 00:37:47 +01:00
parent 22791ecaf4
commit 2fed71cc3a
3 changed files with 26 additions and 7 deletions

View File

@@ -294,12 +294,20 @@ namespace
subMesh->GenerateNormalsAndTangents();
subMesh->SetMaterialIndex(i);
if (parameters.center)
subMesh->Center();
mesh->AddSubMesh(subMesh.get());
subMesh.release();
}
if (parameters.center)
{
for (unsigned int i = 0; i < meshCount; ++i)
{
NzStaticMesh* subMesh = static_cast<NzStaticMesh*>(mesh->GetSubMesh(i));
subMesh->Center();
}
mesh->InvalidateAABB();
}
}
return true;

View File

@@ -23,7 +23,9 @@ NzStaticMesh::~NzStaticMesh()
void NzStaticMesh::Center()
{
NzVector3f offset(m_aabb.x + m_aabb.width/2.f, m_aabb.y + m_aabb.height/2.f, m_aabb.z + m_aabb.depth/2.f);
///DOC: Invalider l'AABB après ça
NzBoxf aabb(m_parent->GetAABB());
NzVector3f offset(aabb.x + aabb.width/2.f, aabb.y + aabb.height/2.f, aabb.z + aabb.depth/2.f);
NzVertexMapper mapper(this);
NzSparsePtr<NzVector3f> position = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Position);