Jump to content

Map::Reload() Re-Creates brushes?


reepblue
 Share

Go to solution Solved by Josh,

Recommended Posts

Found a new bug with the Save/Load system. I think the brushes are being re-created. This example has a transparent material in the scene, and it gets opaquer after each reload.

Load the map, Press F5, and then press F6 to see the results.

#include "UltraEngine.h"
using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a world
    auto world = CreateWorld();

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Load scene
    auto scene = LoadMap(world, "Maps/savetest3.ultra");

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        if (window->KeyHit(KEY_F5))
        {
            //Save the starting scene to a file
            scene->Save("game.sav");
        }

        //Reload the starting scene when space key is pressed
        if (window->KeyHit(KEY_F6))
        {
            scene->Reload("game.sav");
        }

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

SaveTest3.zip

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

  • Solution

I think what is probably happening is the brush is getting new faces applied to it, causing the transparent surface to become more opaque each time.

I am fixing it so the brush will clear its own geometry before loading from a map.

Currently there is no merging / collapsing of brushes when a map is loaded. It's not as important in Ultra as it was in Leadwerks, because draw calls don't slow Ultra down much. I plan to add a Map::Build() command, or add some load flag that controls whether brushes get collapsed. Once that is in, then the original brushes will be gone, so there won't be anything to reload from a game save file.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

12 minutes ago, Josh said:

Currently there is no merging / collapsing of brushes when a map is loaded. It's not as important in Ultra as it was in Leadwerks, because draw calls don't slow Ultra down much. I plan to add a Map::Build() command, or add some load flag that controls whether brushes get collapsed. Once that is in, then the original brushes will be gone, so there won't be anything to reload from a game save file.

Hmm, this does solve my problem of identifying what is level geometry and what is a decorative model. I can just use the As<Brush>() cast. I guess if brush collapsing returns, please put back the public "collapsedbrush" bool or something like you had in Leadwerks.

I also want to mention that when I loaded my save file with Map::Load(), I noticed my materials lost their normal maps. These kinds of things are hard to write examples for as it requires a lot of code and assets to showcase the problem. Maybe it's a side effect from the same problem here.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...