Skip to content

Commit

Permalink
Bug fix while importing scene
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpect committed Sep 21, 2022
1 parent 1b14649 commit 102652b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion editor/editor_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ void EditorSystem::drawDefaultUI(float deltaMilliseconds)
ImGui::Separator();
if (ImGui::BeginMenu("Create Scene"))
{
static SceneID inputBaseID = 0;
SceneID inputBaseID = 0;
ImGui::InputText("Scene Name", &newSceneName, ImGuiInputTextFlags_AlwaysInsertMode);
ImGui::InputScalar("Scene BaseID", ImGuiDataType_U32, &inputBaseID);
Scene::SetBaseID(inputBaseID);
Expand Down
9 changes: 7 additions & 2 deletions rootex/framework/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ void Scene::ResetNextID()
NextSceneID = ROOT_SCENE_ID + 1;
}

void Scene::SetBaseID(const SceneID& inputBaseID)
{
BaseID = inputBaseID;
SceneID SceneIDOffset = 4;
NextSceneID = std::max(std::max(BaseID, NextSceneID), SceneIDOffset);
}

Ptr<Scene> Scene::Create(const JSON::json& sceneData, const bool assignNewIDs)
{
// Decide ID
Expand All @@ -69,8 +76,6 @@ Ptr<Scene> Scene::Create(const JSON::json& sceneData, const bool assignNewIDs)
}
else
{
SceneID SceneIDOffset = 4;
NextSceneID = std::max(std::max(BaseID, NextSceneID), SceneIDOffset);
thisSceneID = NextSceneID;
}
NextSceneID++;
Expand Down
2 changes: 1 addition & 1 deletion rootex/framework/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Scene

public:
static void ResetNextID();
static void SetBaseID(const SceneID& inputBaseID) { BaseID = inputBaseID; }
static void SetBaseID(const SceneID& inputBaseID);

static Ptr<Scene> Create(const JSON::json& sceneData, const bool assignNewIDs);
static Ptr<Scene> CreateFromFile(const String& sceneFile);
Expand Down

0 comments on commit 102652b

Please sign in to comment.