-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a custom mesh to the example models/mesh_generation #462
Conversation
This is probably related to #303, what you are clearing there doesn't look like is doing anything at all. |
Well, try it out yourself. Remove the call to the clearCustomMesh function, and the program will panic in rl.UnloadModel(models[i]). I don't understand why it works to set these values to nil, but it did on my machine... |
Did you check the issue? |
I have now skimmed through it, but I still not sure what I am supposed to do differently?
|
No idea, I was just pointing out that it is probably related as you are using the custom mesh. There is an explanation there and a workaround implemented. Sorry, I don't have time to go through all that now. |
No problem, I will look into it a little bit more, but that might take a couple of days... |
Vertices, Normals and Texcoords of your custom mesh are Go slices. free is a C function and it expects to free C memory and not a Go slice. |
Ok, now I understand the problem, but what is the solution then? To just do what I did, and Or to not call UnloadModel/UnloadMesh at all for Custom Models? |
Yes. Setting the Go slices to Nil (like you already did) is fine. |
Then I guess this can be merged now, I added your explanation to my clearCustomMesh function as a comment. |
This example at raylib.com has a custom mesh, which was missing in the golang example. So I added it...
However, the program panics when unloading the custom model. So I had to create the following function to clear the mesh before calling unload, and now it does not panic.
I don't know if this is something that I don't understand, or if it is because of some underlying problem in the
Mesh
type, orUnloadModel
function? Someone who knows more about the C code than me, might want to take a look at that.