some fixes. still cant reload scene. jesus wept

This commit is contained in:
Sri Sham Haran 2022-11-01 01:57:55 +08:00
parent 943f756721
commit 87f6252d3e
8 changed files with 199 additions and 11 deletions

View File

@ -1,4 +1,4 @@
Start in Fullscreen: false
Starting Scene ID: 0
Starting Scene ID: 85177200
Window Size: {x: 1920, y: 1080}
Window Title: SHADE Engine

View File

@ -0,0 +1,176 @@
- EID: 0
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 1, y: -2, z: -4.77791452}
Rotate: {x: 1.48352981, y: 326.085083, z: 1.48352981}
Scale: {x: 1, y: 1, z: 1}
Camera Component:
Position: {x: 1, y: -2, z: -4.77791452}
Pitch: 84.9999924
Yaw: 323.298828
Roll: 84.9999924
Width: 1920
Height: 1080
Near: 0.00999999978
Far: 10000
Perspective: true
Renderable Component:
Mesh: 0
Material: 0
Light Component:
Position: {x: 0, y: 0, z: 0}
Type: Directional
Direction: {x: 0, y: 0, z: 1}
Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295
Strength: 0
Scripts: ~
- EID: 1
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 1, y: -1.89999998, z: -5.80951977}
Rotate: {x: 79.572258, y: 328.815308, z: 348.792389}
Scale: {x: 1, y: 1, z: 1}
Renderable Component:
Mesh: 0
Material: 0
RigidBody Component:
Type: Dynamic
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Interpolate: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
Collider Component:
Colliders:
- Is Trigger: false
Type: Box
Half Extents: {x: 0.5, y: 0.5, z: 0.5}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Scripts: ~
- EID: 2
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 1, y: -1.79999995, z: -5.05146122}
Rotate: {x: 196.999405, y: 35.1145439, z: 110.940132}
Scale: {x: 1, y: 1, z: 1}
Renderable Component:
Mesh: 0
Material: 0
RigidBody Component:
Type: Dynamic
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Interpolate: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
Collider Component:
Colliders:
- Is Trigger: false
Type: Box
Half Extents: {x: 0.5, y: 0.5, z: 0.5}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Scripts: ~
- EID: 3
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -3, y: -1, z: -1}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 5, y: 5, z: 5}
Renderable Component:
Mesh: 0
Material: 0
Scripts:
- Type: RaccoonSpin
RotateSpeed: 1
- EID: 4
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -3, z: -5}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 7.5, y: 0.5, z: 7.5}
Renderable Component:
Mesh: 0
Material: 0
RigidBody Component:
Type: Static
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Interpolate: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
Collider Component:
Colliders:
- Is Trigger: false
Type: Box
Half Extents: {x: 3.75, y: 0.25, z: 3.75}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Scripts: ~
- EID: 5
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 3, y: -1, z: -1}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 5, y: 5, z: 5}
Renderable Component:
Mesh: 0
Material: 0
Scripts: ~
- EID: 6
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Light Component:
Position: {x: 0, y: 0, z: 0}
Type: Ambient
Direction: {x: 0, y: 0, z: 1}
Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295
Strength: 0.25
Scripts: ~

View File

@ -0,0 +1,3 @@
Name: TestScene
ID: 85177200
Type: 5

View File

@ -35,9 +35,6 @@ namespace Sandbox
}
void SBMainScene::Load()
{
}
void SBMainScene::Init()
{
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
// Create temp meshes
@ -61,6 +58,11 @@ namespace Sandbox
}
}
SHResourceManager::FinaliseChanges();
}
void SBMainScene::Init()
{
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
// Create Materials
auto matInst = graphicsSystem->AddOrGetBaseMaterialInstance();

View File

@ -182,7 +182,8 @@ namespace SHADE
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PLAY);
if(ImGui::SmallButton(ICON_MD_PLAY_ARROW))
{
editor->editorState = SHEditor::State::PLAY;
if(editor->SaveScene())
editor->editorState = SHEditor::State::PLAY;
}
ImGui::EndDisabled();
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PAUSE);
@ -195,6 +196,7 @@ namespace SHADE
if(ImGui::SmallButton(ICON_MD_STOP))
{
editor->editorState = SHEditor::State::STOP;
editor->LoadScene(SHSceneManager::GetCurrentSceneAssetID());
}
ImGui::EndDisabled();
ImGui::EndMenuBar();

View File

@ -447,7 +447,7 @@ namespace SHADE
}
}
void SHEditor::SaveScene(std::string const& newSceneName)
bool SHEditor::SaveScene(std::string const& newSceneName)
{
auto const data = SHAssetManager::GetData<SHSceneAsset>(SHSceneManager::GetCurrentSceneAssetID());
if (!data)
@ -456,12 +456,12 @@ namespace SHADE
{
//Prompt for scene name
isSceneNamePromptOpen = true;
return;
return false;
}
//Else We have a new name
SHSceneManager::SetCurrentSceneName(newSceneName.data());
SHSceneManager::SetCurrentSceneAssetID(SHAssetManager::CreateNewAsset(AssetType::SCENE, newSceneName.data()));
SHSceneManager::SetCurrentSceneName(newSceneName);
SHSceneManager::SetCurrentSceneAssetID(SHAssetManager::CreateNewAsset(AssetType::SCENE, newSceneName));
}
//Get data, if data is null, asset doesn't exist, prompt for a name and create a new asset with the name
@ -470,7 +470,10 @@ namespace SHADE
{
if(shWindow->IsUnsavedChanges())
shWindow->ToggleUnsavedChanges();
return true;
}
return false;
}
void SHEditor::LoadScene(AssetID const& assetID) noexcept

View File

@ -178,7 +178,7 @@ namespace SHADE
void NewScene();
void SaveScene(std::string const& newSceneName = {});
bool SaveScene(std::string const& newSceneName = {});
void LoadScene(AssetID const& assetID) noexcept;

View File

@ -111,12 +111,14 @@ namespace SHADE
{
if (currentScene->sceneAssetID != assetID)
{
cleanReload = true;
//cleanReload = true;
cleanReload = false;
//newSceneName = sceneName;
}
else
cleanReload = false;
currentScene->sceneAssetID = assetID;
nextSceneID = currentSceneID;
sceneChanged = true;
}