Fixed mesh centering
Former-commit-id: d27dc7f0734d6a5bf0ecd6d36ede2f11cbff7c9c
This commit is contained in:
parent
22791ecaf4
commit
2fed71cc3a
|
|
@ -170,9 +170,6 @@ namespace
|
||||||
subMesh->SetMaterialIndex(meshes[i].material);
|
subMesh->SetMaterialIndex(meshes[i].material);
|
||||||
subMesh->SetPrimitiveMode(nzPrimitiveMode_TriangleList);
|
subMesh->SetPrimitiveMode(nzPrimitiveMode_TriangleList);
|
||||||
|
|
||||||
if (parameters.mesh.center)
|
|
||||||
subMesh->Center();
|
|
||||||
|
|
||||||
// Ce que nous pouvons générer dépend des données à disposition (par exemple les tangentes nécessitent des coordonnées de texture)
|
// Ce que nous pouvons générer dépend des données à disposition (par exemple les tangentes nécessitent des coordonnées de texture)
|
||||||
if (hasNormals && hasTexCoords)
|
if (hasNormals && hasTexCoords)
|
||||||
subMesh->GenerateTangents();
|
subMesh->GenerateTangents();
|
||||||
|
|
@ -185,6 +182,18 @@ namespace
|
||||||
subMesh.release();
|
subMesh.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parameters.mesh.center)
|
||||||
|
{
|
||||||
|
unsigned int subMeshCount = mesh->GetSubMeshCount();
|
||||||
|
for (unsigned int i = 0; i < subMeshCount; ++i)
|
||||||
|
{
|
||||||
|
NzStaticMesh* subMesh = static_cast<NzStaticMesh*>(mesh->GetSubMesh(i));
|
||||||
|
subMesh->Center();
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh->InvalidateAABB();
|
||||||
|
}
|
||||||
|
|
||||||
mesh->SetMaterialCount(parser.GetMaterialCount());
|
mesh->SetMaterialCount(parser.GetMaterialCount());
|
||||||
|
|
||||||
model->SetMesh(mesh.get());
|
model->SetMesh(mesh.get());
|
||||||
|
|
|
||||||
|
|
@ -294,12 +294,20 @@ namespace
|
||||||
subMesh->GenerateNormalsAndTangents();
|
subMesh->GenerateNormalsAndTangents();
|
||||||
subMesh->SetMaterialIndex(i);
|
subMesh->SetMaterialIndex(i);
|
||||||
|
|
||||||
if (parameters.center)
|
|
||||||
subMesh->Center();
|
|
||||||
|
|
||||||
mesh->AddSubMesh(subMesh.get());
|
mesh->AddSubMesh(subMesh.get());
|
||||||
subMesh.release();
|
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;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,9 @@ NzStaticMesh::~NzStaticMesh()
|
||||||
|
|
||||||
void NzStaticMesh::Center()
|
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);
|
NzVertexMapper mapper(this);
|
||||||
NzSparsePtr<NzVector3f> position = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Position);
|
NzSparsePtr<NzVector3f> position = mapper.GetComponentPtr<NzVector3f>(nzVertexComponent_Position);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue