Various errors are thrown when when trying to query or use a DynamicMesh with no vertices, or no triangles. Some of these errors shouldn’t be thrown, and some should, but the error message is confusing.
Example 1
local mesh = Instance.new("DynamicMesh")
mesh.Parent = workspace
local meshPart = mesh:CreateMeshPartAsync(Enum.CollisionFidelity.Default)
Result: :CreateMeshPartAsync() call throws error “Mesh not Editable”. This is misleading.
Expected: should throw a more descriptive error, like “Cannot create mesh part from empty DynamicMesh” or “Cannot create mesh part from DynamicMesh with no vertices” or “Cannot create mesh part from DynamicMesh with no triangles” (unless it does make sense to make an empty meshpart?)
Example 2
local mesh = Instance.new("DynamicMesh")
print(mesh:GetVertices())
Result: :GetVertices() call throws error “Invalid mesh”. This shouldn’t error.
Expected: Should return {}.
Note: I would use this (or :GetTriangles()) to check whether the mesh is empty before creating a meshpart with it.
Example 3
local mesh = Instance.new("DynamicMesh")
print(mesh:GetTriangles())
Result: :GetTriangles() call throws error “Invalid mesh”. This shouldn’t error.
Expected: Should return {}.
Note: I would use this (or :GetVertices()) to check whether the mesh is empty before creating a meshpart with it.
Example 4
local mesh = Instance.new("DynamicMesh")
local index1 = mesh:AddVertex(Vector3.new(0,0,0))
local index2 = mesh:AddVertex(Vector3.new(1,1,1))
local index3 = mesh:AddVertex(Vector3.new(1,0,1))
mesh.Parent = workspace
local meshPart = mesh:CreateMeshPartAsync(Enum.CollisionFidelity.Default)
Result: :CreateMeshPartAsync() call throws error “Error during conversion”.
Expected: Should throw more descriptive error (or no error?), like Example 1.
Info
Where: I don’t know if this is a studio bug or engine bug, since I can only test DynamicMesh in studio.
I am testing on an M2 mac, with Roblox Studio Version 0.583.3.5831076 (it is the native apple silicon app)
When: I first observed this yesterday, July 18.