Array Index Specification Confusion

Godot Version

4

This might be a simple one… I’m reading through the ArrayMesh tutorial https://docs.godotengine.org/en/stable/tutorials/3d/procedural_geometry/arraymesh.html

and am wondering how GDScript knows what index is being referred to here:

surface_array[Mesh.ARRAY_VERTEX] = verts
surface_array[Mesh.ARRAY_TEX_UV] = uvs
surface_array[Mesh.ARRAY_NORMAL] = normals
surface_array[Mesh.ARRAY_INDEX] = indices

# No blendshapes, lods, or compression used.
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, surface_array)

How does it know Mesh.XXX_XXXXX corresponds to an array element? I see in the C# portion these are converted to (int) which makes sense to me because array indices are ints. (I am brand new to Godot feel free to refer me to another topic)

Its part of an enumeration, i.e. they are integers.

enum ArrayType {
 ARRAY_VERTEX = 0,
 ARRAY_NORMAL = 1,
 ARRAY_TANGENT = 2,
 ARRAY_COLOR = 3,
 ARRAY_TEX_UV = 4,
 ARRAY_TEX_UV2 = 5,
 ARRAY_CUSTOM0 = 6,
 ARRAY_CUSTOM1 = 7,
 ARRAY_CUSTOM2 = 8,
 ARRAY_CUSTOM3 = 9,
 ARRAY_BONES = 10,
 ARRAY_WEIGHTS = 11,
 ARRAY_INDEX = 12,
 ARRAY_MAX
}
1 Like