New example models/mesh_picking

This commit is contained in:
Per Hultqvist 2024-11-11 16:46:28 +01:00
parent 0e82ab3a0d
commit 0ce1777bf3

View file

@ -105,22 +105,28 @@ func main() {
} }
rl.UnloadTexture(texture) rl.UnloadTexture(texture)
clearCustomMesh(models) clearCustomMesh(models[8])
for i := 0; i < numModels; i++ { for i := 0; i < numModels; i++ {
//if i == 8 {
//meshes := unsafe.Slice(models[i].Meshes, models[i].MeshCount)
//for m := range meshes {
// rl.UnloadMesh(&meshes[m])
//}
//}
rl.UnloadModel(models[i]) rl.UnloadModel(models[i])
} }
rl.CloseWindow() rl.CloseWindow()
} }
func clearCustomMesh(models []rl.Model) { func clearCustomMesh(model rl.Model) {
// For some reason the custom model // For some reason the custom model
// (id = 8) panics when unloading it. // (id = 8) panics when unloading it.
// So we clear the mesh for it manually // So we clear the mesh for it manually
// here. // here.
models[8].Meshes.Vertices = nil model.Meshes.Vertices = nil
models[8].Meshes.Normals = nil model.Meshes.Normals = nil
models[8].Meshes.Texcoords = nil model.Meshes.Texcoords = nil
} }
// GenMeshCustom generates a simple triangle mesh from code // GenMeshCustom generates a simple triangle mesh from code