Corrected normals for KRMeshSphere so the sphere will have a smooth surface.
Disabled KRMesh::optimizeIndexes as it is crashing with certain meshes, such as those generated by KRMeshSphere
This commit is contained in:
@@ -1581,6 +1581,9 @@ int KRMesh::getTriangleVertexIndex(int submesh, int index) const
|
|||||||
|
|
||||||
void KRMesh::optimizeIndexes()
|
void KRMesh::optimizeIndexes()
|
||||||
{
|
{
|
||||||
|
// TODO - Re-enable this once crash with KRMeshSphere vertices is corrected
|
||||||
|
return;
|
||||||
|
|
||||||
m_pData->lock();
|
m_pData->lock();
|
||||||
// TODO - Implement optimization for indexed strips
|
// TODO - Implement optimization for indexed strips
|
||||||
if(getModelFormat() == ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) {
|
if(getModelFormat() == ModelFormat::KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) {
|
||||||
|
|||||||
@@ -113,6 +113,12 @@ KRMeshSphere::KRMeshSphere(KRContext &context) : KRMesh(context, "__sphere")
|
|||||||
|
|
||||||
|
|
||||||
mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||||
|
|
||||||
|
// Generate normals pointing away from center of sphere.
|
||||||
|
for (int vertex_index = 0; vertex_index < mi.vertices.size(); vertex_index++) {
|
||||||
|
mi.normals.push_back(Vector3::Normalize(mi.vertices[vertex_index] - Vector3::Zero()));
|
||||||
|
}
|
||||||
|
|
||||||
LoadData(mi, true, true);
|
LoadData(mi, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user