mojo3d:Chunks creation problems (memory access violation)

About Monkey 2 Forums Monkey 2 Programming Help mojo3d:Chunks creation problems (memory access violation)

This topic contains 5 replies, has 3 voices, and was last updated by  Mark Sibly 1 year ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #14128

    Pakz
    Participant

    I am kind of stuck with this. I changed my createcube method to having more vertices so I can put textures on them but then I got these errors thrown every time I got more or less in the center of the maps.

    I modified a example to get these errors thrown again. It seems that there is some kind of limit? in the amount of meshes that can be created? When I recreated the models without recreating the messes I could fill the screen until the fps got to 0. I have been at it all night and maybe there is something really simple wrong.

    #14130

    DruggedBunny
    Participant

    That code doesn’t seem to crash for me, though I did get a crash on the web demo once.

    I notice you’re using an older version of mojo3d, though, as the current version of Scene.Render doesn’t take a camera parameter, so it might be worth upgrading to see if that resolves it.

    #14131

    Pakz
    Participant

    I uploaded a new emscripten version yesterday evening I think after also getting a crash. Maybe that fixed it.

    Yes, I am using the current itch.io version.

    As for the new monkey version. I think I will need to learn how to update it from the github. Patreon asks for a creditcard so I can not get the 1.09 version that way.

    Maybe I can manually download the mojo3d files and rebuild? Wil try that first.

    #14132

    Pakz
    Participant

    Ok, I dowloaded a zip file from the monkey2 develop branch and unpacked it on my last monkey install. I rebuilt the desktop modules and the error has gone away.

    #14133

    Mark Sibly
    Keymaster

    Yes, it’s crashing here if I set chunk sizes to 16, 128, 16 but it is also using about 2G memory which is the 32 bit limit and is likely to be causing problems (somehow). This shouldn’t be an issue on 64 bit windows really, although it will be on emscripten which is only 32 bit. You can check how much memory the app is using by starting task manager and watching the process memory usage growing.

    Part of this is because the mojo3d vertex format is quite ‘heavyweight’ – 80 bytes per vertex. Something like minecraft really needs a very lightweight vertex format but you can’t do that in mojo3d yet. Also, Mesh really needs a Compact() method of some kind as meshes will currently be consuming about 2x what they need to be due to the internal stacks.

    I’ll keep looking into this, but there is realistically likely to be some kind of 2G limit for monkey2 apps at the moment. It does also seem to be consuming more memory than I would have thought, which I’ll also look into.

    Note that building meshes with the mesh=mesh+mesh2 will be very ineffecient. Each time you add a mesh, the old mesh must be copied, which ‘grows’ the output mesh, which gets incremental slower and slower etc. You’ll probably get much better performance if you build everything into an array first and just build the mesh once.

    #14134

    Mark Sibly
    Keymaster

    Also, note that your code is creating *every* cube face here, even the hidden ones! The way you’ve done the sides[i] check effectively means that hidden sides will end up with ‘null’ indices (or possibly even incorrect indices) but the sides are actually still there and consuming memory and will even be ‘rendered’ by the gpu, although nothing willl be drawn because they are degenerate.

    Here’s a version that skips sides properly and now works on my machine without crashing. Again, the more efficient way to do this would be to just writing the entire thing into one big array and create the mesh all at once, but this is an improvement!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.