Search Issue Tracker

Not Reproducible

Votes

0

Found in

2019.2

Issue ID

1245263

Regression

No

[Mesh] Crash in Mesh.SetSubMeshImpl

Graphics - General

-

MeshDataBindings::SetSubMeshImpl -> UpdateSharedDataSubMeshVertexRange

GetVertexBufferRange(::GetSubMeshBuffer32(submesh, &data), submesh.indexCount, submesh.firstVertex, lastVertex);
first parameter is null, so we have a crash inside GetVertexBufferRange

Cannot reproduce it with old SetTriangles API.

Sidenote: inside MeshScripting::InternalSetIndexBufferData

Sometimes
Mesh::IndexContainer& buffer = m->GetWritableIndexBuffer();
if (meshBufferStartBytes + countBytes > buffer.size())
{
*outException = Scripting::CreateArgumentException("Accessing %zu bytes at offset %zu for mesh index buffer of size %zu bytes is not possible.", countBytes, meshBufferStartBytes, buffer.size());
return;
}

buffer.capacity() is correct, but buffer.size() is less than capacity for unknown reason.

--------

STEPS:
1) Open attached project
2) Open the scene file inside
3) Click on the sphere and make sure DebugTestChange's changeMaterial is enabled and list of materials is not empty
HexasphereMaterialData.UseNewMeshAPI = false -- has expected behavior
HexasphereMaterialData.UseNewMeshAPI = true -- some hexes will disappear, then hard crash of Unity Editor on access violation

  1. Resolution Note (2020.2.X):

    The gotcha is, that changing mesh.subMeshCount to a smaller value than it was before will also resize the index buffer. In some cases during your script run, what used to be 3 submeshes changes to two, and the index buffer size effectively is reduced to what was the previous two submeshes (336).

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.