Collision Tags autosave on change, fixed serialisation bug with collision tags #342

Merged
direnbharwani merged 2 commits from SP3-2-Physics into main 2023-02-04 01:02:25 +08:00
85 changed files with 419 additions and 249 deletions
Showing only changes of commit d517a98bab - Show all commits

1
.gitignore vendored
View File

@ -366,3 +366,4 @@ MigrationBackup/
JSON/Schemas/Catalog/
Assets/Editor/Editor.SHConfig
Assets/Editor/Layouts/UserLayout.ini

View File

@ -1,4 +1,4 @@
Start Maximized: true
Working Scene ID: 97086054
Working Scene ID: 91685359
Window Size: {x: 1920, y: 1013}
Style: 0

View File

@ -1,167 +0,0 @@
[Window][MainStatusBar]
Pos=0,989
Size=1920,20
Collapsed=0
[Window][SHEditorMenuBar]
Pos=0,48
Size=1920,941
Collapsed=0
[Window][Hierarchy Panel]
Pos=0,187
Size=300,802
Collapsed=0
DockId=0x00000004,0
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Inspector]
Pos=1434,48
Size=486,941
Collapsed=0
DockId=0x00000006,0
[Window][Profiler]
Pos=0,48
Size=300,137
Collapsed=0
DockId=0x00000003,0
[Window][Viewport]
Pos=227,48
Size=1457,1012
Collapsed=0
DockId=0x0000000B,0
[Window][ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌð‡Žoû]
Pos=60,60
Size=32,64
Collapsed=0
[Window][ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ]
Pos=60,60
Size=999,581
Collapsed=0
[Window][ð‡]
Pos=60,60
Size=32,64
Collapsed=0
[Window][ÌÌÌÌ]
Pos=60,60
Size=553,422
Collapsed=0
[Window][]
Pos=60,60
Size=770,394
Collapsed=0
[Window][ Viewport]
Pos=227,48
Size=1457,1012
Collapsed=0
DockId=0x0000000B,0
[Window][ Viewport]
Pos=227,48
Size=1457,1012
Collapsed=0
DockId=0x0000000B,0
[Window][î<> Viewport]
Pos=302,48
Size=1130,705
Collapsed=0
DockId=0x0000000B,0
[Window][V]
Pos=310,722
Size=1501,338
Collapsed=0
DockId=0x00000008,0
[Window][p£€Ê]
Pos=310,750
Size=1501,310
Collapsed=0
DockId=0x0000000A,0
[Window][ Asset Browser]
Pos=302,755
Size=1130,234
Collapsed=0
DockId=0x0000000C,0
[Window][Material Inspector]
Pos=1434,48
Size=486,941
Collapsed=0
DockId=0x00000006,1
[Window][Save scene as...]
Pos=1197,693
Size=165,120
Collapsed=0
[Window][Create New Asset]
Pos=896,472
Size=464,144
Collapsed=0
[Window][Collider Tag Panel]
Pos=302,48
Size=1130,705
Collapsed=0
DockId=0x0000000B,1
[Window][Input Bindings Panel]
Pos=1434,48
Size=486,941
Collapsed=0
DockId=0x00000006,2
[Window][Save Scene As]
Pos=877,444
Size=165,120
Collapsed=0
[Table][0x9D40AE32,17]
Column 0 Weight=1.0696
Column 1 Weight=0.9194
Column 2 Weight=0.9945
Column 3 Weight=1.0320
Column 4 Weight=0.9570
Column 5 Weight=0.9945
Column 6 Weight=0.9945
Column 7 Weight=0.9945
Column 8 Weight=0.9945
Column 9 Weight=1.0320
Column 10 Weight=0.9570
Column 11 Weight=1.0133
Column 12 Weight=0.9945
Column 13 Weight=0.8444
Column 14 Weight=0.9945
Column 15 Weight=0.8632
Column 16 Weight=1.3510
[Docking][Data]
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,71 Size=1920,941 Split=X
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1432,1036 Split=X
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=300,1036 Split=Y Selected=0x1E6EB881
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,147 Selected=0x1E6EB881
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,863 Selected=0xE096E5AE
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1130,1036 Split=Y Selected=0xB41284E7
DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1501,672 Split=Y Selected=0xB41284E7
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1501,700 Split=Y Selected=0xB41284E7
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,705 CentralNode=1 Selected=0x69428B24
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,234 Selected=0xB128252A
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=1501,310 Selected=0xD446F7B6
DockNode ID=0x00000008 Parent=0x00000002 SizeRef=1501,338 Selected=0xD9F31532
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=486,1036 Selected=0xE7039252

View File

@ -1,8 +1,8 @@
- VertexShader: 46580970
FragmentShader: 35983630
SubPass: G-Buffer Write
SubPass: UI
Properties:
data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 54429632
data.textureIndex: 51995224
data.alpha: 0
data.beta: {x: 1, y: 1, z: 1}

View File

@ -15,7 +15,7 @@
- EID: 1
Name: Canvas
IsActive: true
NumberOfChildren: 1
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
@ -23,7 +23,7 @@
IsActive: true
Scripts: ~
- EID: 2
Name: Default
Name: Back Ground
IsActive: true
NumberOfChildren: 0
Components:
@ -36,7 +36,61 @@
Mesh: 141771688
Material: 123313564
IsActive: true
UI Component:
Canvas ID: 1
IsActive: true
Scripts: ~
- EID: 5
Name: Main Menu Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 65788519
Hovered Texture: 55999018
Clicked Texture: 66382894
IsActive: true
UI Component:
Canvas ID: 1
IsActive: true
Scripts:
- Type: ChangeSceneButton
Enabled: true
sceneID: 97158628
- EID: 6
Name: Quit Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 66477839
Hovered Texture: 65045286
Clicked Texture: 58607560
IsActive: true
UI Component:
Canvas ID: 1
IsActive: true
Scripts:
- Type: QuitButton
Enabled: true
- EID: 3
Name: Camera
IsActive: true

View File

@ -1,7 +1,7 @@
- EID: 0
Name: Canvas
IsActive: true
NumberOfChildren: 1
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
@ -9,7 +9,7 @@
IsActive: true
Scripts: ~
- EID: 1
Name: Default
Name: Background
IsActive: true
NumberOfChildren: 0
Components:
@ -22,7 +22,61 @@
Mesh: 141771688
Material: 121834459
IsActive: true
UI Component:
Canvas ID: 0
IsActive: true
Scripts: ~
- EID: 5
Name: Start Game Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 52901020
Hovered Texture: 62235279
Clicked Texture: 64722619
IsActive: true
UI Component:
Canvas ID: 0
IsActive: true
Scripts:
- Type: ChangeSceneButton
Enabled: true
sceneID: 96668835
- EID: 6
Name: Quit Game Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 66477839
Hovered Texture: 65045286
Clicked Texture: 58607560
IsActive: true
UI Component:
Canvas ID: 0
IsActive: true
Scripts:
- Type: QuitButton
Enabled: true
- EID: 2
Name: Light
IsActive: true

View File

@ -15,7 +15,7 @@
- EID: 1
Name: Canvas
IsActive: true
NumberOfChildren: 1
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
@ -23,7 +23,7 @@
IsActive: true
Scripts: ~
- EID: 2
Name: Default
Name: Background
IsActive: true
NumberOfChildren: 0
Components:
@ -37,6 +37,51 @@
Material: 129138332
IsActive: true
Scripts: ~
- EID: 5
Name: Main Menu Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 65788519
Hovered Texture: 55999018
Clicked Texture: 66382894
IsActive: true
Scripts:
- Type: ChangeSceneButton
Enabled: true
sceneID: 97158628
- EID: 6
Name: Quit Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 66477839
Hovered Texture: 65045286
Clicked Texture: 58607560
IsActive: true
Scripts:
- Type: QuitButton
Enabled: true
- EID: 3
Name: Camera
IsActive: true

View File

@ -0,0 +1,33 @@
using System;
using SHADE;
public class ChangeSceneButton : Script
{
public uint sceneID = 0;
protected override void start()
{
UIElement ui = GetComponent<UIElement>();
if (ui != null)
{
ui.OnClick.RegisterAction(() =>
{
if (sceneID != 0)
{
Audio.PlaySFXOnce2D("event:/UI/success");
SceneManager.ChangeScene(sceneID);
Audio.StopAllSounds();
}
});
}
else
{
Debug.LogError("Failed to register button action for ChangeSceneButton.");
}
}
protected override void update()
{
}
}

View File

@ -0,0 +1,3 @@
Name: SC_ChangeSceneButton
ID: 155329160
Type: 9

View File

@ -0,0 +1,31 @@
using System;
using SHADE;
public class QuitButton : Script
{
protected override void start()
{
UIElement ui = GetComponent<UIElement>();
if (ui != null)
{
ui.OnClick.RegisterAction(() =>
{
ui.OnClick.RegisterAction(() =>
{
Audio.StopAllSounds();
Application.Quit();
});
});
}
else
{
Debug.LogError("Failed to register button action for QuitButton.");
}
}
protected override void update()
{
}
}

View File

@ -0,0 +1,3 @@
Name: SC_QuitButton
ID: 163136401
Type: 9

View File

@ -39,5 +39,10 @@ layout(location = 1) out uint outEntityID;
void main()
{
fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
if (fragColor.a < 0.01f)
{
discard;
}
outEntityID = In2.eid;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: howToPlay_default
ID: 65084899
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: howToPlay_hover
ID: 58647112
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: howToPlay_pressed
ID: 55758383
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: mainMenu_default
ID: 65788519
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: mainMenu_hover
ID: 55999018
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: mainMenu_pressed
ID: 66382894
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: quit_default
ID: 66477839
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: quit_hover
ID: 65045286
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: quit_pressed
ID: 58607560
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: retry_default
ID: 55782622
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: retry_hover
ID: 58972174
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: retry_pressed
ID: 55224464
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: settings_default
ID: 58593104
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: settings_hover
ID: 64495732
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: settings_pressed
ID: 63138015
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: startGame_default
ID: 52901020
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: startGame_hover
ID: 62235279
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: startGame_pressed
ID: 64722619
Type: 3

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -117,10 +117,11 @@ namespace SHADE
/// </summary>
public void Invoke()
{
foreach (CallbackAction action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction;
action.Invoke();
}
catch (Exception e)
@ -203,10 +204,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1)
{
foreach (CallbackAction<T1> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1>;
action.Invoke(t1);
}
catch (Exception e)
@ -289,10 +291,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2)
{
foreach (CallbackAction<T1, T2> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2>;
action.Invoke(t1, t2);
}
catch (Exception e)
@ -375,10 +378,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3)
{
foreach (CallbackAction<T1, T2, T3> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3>;
action.Invoke(t1, t2, t3);
}
catch (Exception e)
@ -461,10 +465,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4)
{
foreach (CallbackAction<T1, T2, T3, T4> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4>;
action.Invoke(t1, t2, t3, t4);
}
catch (Exception e)
@ -547,10 +552,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
{
foreach (CallbackAction<T1, T2, T3, T4, T5> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5>;
action.Invoke(t1, t2, t3, t4, t5);
}
catch (Exception e)
@ -633,10 +639,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
{
foreach (CallbackAction<T1, T2, T3, T4, T5, T6> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6>;
action.Invoke(t1, t2, t3, t4, t5, t6);
}
catch (Exception e)
@ -719,10 +726,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
{
foreach (CallbackAction<T1, T2, T3, T4, T5, T6, T7> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6, T7>;
action.Invoke(t1, t2, t3, t4, t5, t6, t7);
}
catch (Exception e)
@ -805,10 +813,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
{
foreach (CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8>;
action.Invoke(t1, t2, t3, t4, t5, t6, t7, t8);
}
catch (Exception e)
@ -891,10 +900,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9)
{
foreach (CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9>;
action.Invoke(t1, t2, t3, t4, t5, t6, t7, t8, t9);
}
catch (Exception e)
@ -977,10 +987,11 @@ namespace SHADE
/// </summary>
public void Invoke(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10)
{
foreach (CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>;
action.Invoke(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
}
catch (Exception e)

View File

@ -134,10 +134,11 @@ namespace SHADE
/// </summary>
public void Invoke(<# if (i != 0) { for (int t = 1; t < i + 1; ++t) { #>T<#=t#> t<#=t#><# if (t != i) { #>, <# } #><# } } #>)
{
foreach (CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #> action in actions)
for (int i = 0; i < actions.Count; ++i)
{
try
{
var action = actions[i] as CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #>;
action.Invoke(<# for (int t = 1; t < i + 1; ++t) { #>t<#=t#><# if (t != i) { #>, <# } #><# } #>);
}
catch (Exception e)

View File

@ -199,7 +199,7 @@ namespace SHADE
// Check material usage
for (const auto& rendId : sb.Renderables)
{
auto rend = SHComponentManager::GetComponent<SHRenderable>(rendId);
auto rend = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (rend)
{
if (rend->GetMaterial() == matToCheck)
@ -210,7 +210,7 @@ namespace SHADE
}
else
{
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!");
SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
}
}
}
@ -290,20 +290,20 @@ namespace SHADE
// Build CPU Buffer
char* propsCurrPtr = matPropsData.get();
for (auto& subBatch : subBatches)
for (auto rendId : subBatch.Renderables)
for (auto rendId : subBatch.Renderables)
{
const SHRenderable* renderable = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (renderable)
{
const SHRenderable* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId);
if (renderable)
{
renderable->GetMaterial()->ExportProperties(propsCurrPtr);
}
else
{
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!");
}
//propsCurrPtr += singleMatPropAlignedSize;
propsCurrPtr += singleMatPropSize;
renderable->GetMaterial()->ExportProperties(propsCurrPtr);
}
else
{
SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
}
//propsCurrPtr += singleMatPropAlignedSize;
propsCurrPtr += singleMatPropSize;
}
// Transfer to GPU
rebuildDescriptorSetBuffers(frameIndex, descPool);
@ -328,7 +328,7 @@ namespace SHADE
for (auto rendId : subBatch.Renderables)
{
// Transform
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(rendId);
auto transform = SHComponentManager::GetComponent_s<SHTransformComponent>(rendId);
if (transform)
{
if (SHSceneManager::CheckNodeAndComponentsActive<SHRenderable>(rendId))
@ -357,7 +357,7 @@ namespace SHADE
}
else
{
SHLOG_WARNING("[SHBatch] Entity contianing a SHRenderable with no SHTransformComponent found!");
SHLOG_WARNING("[SHBatch] Entity #{} containing a SHRenderable with no SHTransformComponent found!", rendId);
transformData.emplace_back();
}
}
@ -382,12 +382,15 @@ namespace SHADE
for (auto& subBatch : subBatches)
for (auto rendId : subBatch.Renderables)
{
auto* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId);
instancedIntegerData.emplace_back(SHInstancedIntegerData
auto* renderable = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (renderable)
{
rendId,
renderable->GetLightLayer()
});
instancedIntegerData.emplace_back(SHInstancedIntegerData
{
rendId,
renderable->GetLightLayer()
});
}
}
// Transfer to GPU
@ -575,17 +578,21 @@ namespace SHADE
}
else
{
SHLOG_WARNING("[SHBatch] Entity contianing a SHRenderable with no SHTransformComponent found!");
SHLOG_WARNING("[SHBatch] Entity #{} contianing a SHRenderable with no SHTransformComponent found!", rendId);
transformData.emplace_back();
}
const SHRenderable* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId);
instancedIntegerData.emplace_back(SHInstancedIntegerData
{
rendId,
renderable->GetLightLayer()
}
);
const SHRenderable* renderable = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (renderable)
{
instancedIntegerData.emplace_back(SHInstancedIntegerData
{
rendId,
renderable->GetLightLayer()
}
);
}
// Material Properties
if (!EMPTY_MAT_PROPS)
@ -596,7 +603,7 @@ namespace SHADE
}
else
{
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!");
SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
}
propsCurrPtr += singleMatPropSize;
}

View File

@ -1065,7 +1065,7 @@ namespace SHADE
for (auto& renderable : renderables)
{
// Check if the material instance is now unused
renderable.CleanUpMaterials();
renderable.CleanUpMaterials();
if (!renderable.HasChanged())
continue;

View File

@ -99,6 +99,8 @@ namespace SHADE
{
SHGraphicsSystem* gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
material = gfxSystem->AddMaterialInstanceCopy(sharedMaterial);
oldMaterial = sharedMaterial;
oldMatIsShared = true;
matChanged = true;
}

View File

@ -205,6 +205,7 @@ namespace SHADE
AddComponentToComponentNode<SHTextRenderableComponent>(components, eid);
AddComponentToComponentNode<SHAnimatorComponent>(components, eid);
AddComponentToComponentNode<SHUIComponent>(components, eid);
node[ComponentsNode] = components;
@ -263,6 +264,7 @@ namespace SHADE
AddComponentID<SHToggleButtonComponent>(componentIDList, componentsNode);
AddComponentID<SHTextRenderableComponent>(componentIDList, componentsNode);
AddComponentID<SHAnimatorComponent>(componentIDList, componentsNode);
AddComponentID<SHUIComponent>(componentIDList, componentsNode);
return componentIDList;
}
@ -347,5 +349,6 @@ namespace SHADE
SHSerializationHelper::InitializeComponentFromNode<SHTextRenderableComponent>(componentsNode, eid);
SHSerializationHelper::InitializeComponentFromNode<SHLightComponent>(componentsNode, eid);
SHSerializationHelper::InitializeComponentFromNode<SHAnimatorComponent>(componentsNode, eid);
SHSerializationHelper::InitializeComponentFromNode<SHUIComponent>(componentsNode, eid);
}
}

View File

@ -1,12 +1,13 @@
#include "SHpch.h"
#include "SHButtonComponent.h"
#include "Resource/SHResourceManager.h"
#include "Graphics/MiddleEnd/Textures/SHTextureLibrary.h"
namespace SHADE
{
SHButtonComponent::SHButtonComponent()
:size(1.0f), isHovered(false), isClicked(false),
defaultTexture(0), hoveredTexture(0), clickedTexture(0)
defaultTexture(0), hoveredTexture(0), clickedTexture(0), currentTexture(0)
{
}

View File

@ -40,6 +40,8 @@ namespace SHADE
AssetID defaultTexture;
AssetID hoveredTexture;
AssetID clickedTexture;
AssetID currentTexture;
RTTR_ENABLE()

View File

@ -6,7 +6,7 @@ namespace SHADE
{
SHToggleButtonComponent::SHToggleButtonComponent()
:size(1.0f), isHovered(false), isClicked(false), value(false),
defaultTexture(0), toggledTexture(0)
defaultTexture(0), toggledTexture(0), currentTexture(0)
{
}

View File

@ -41,6 +41,8 @@ namespace SHADE
bool value;
AssetID defaultTexture;
AssetID toggledTexture;
AssetID currentTexture;

View File

@ -28,6 +28,8 @@ namespace SHADE
SHComponentManager::CreateComponentSparseSet<SHCanvasComponent>();
SHComponentManager::CreateComponentSparseSet<SHUIComponent>();
SHComponentManager::CreateComponentSparseSet<SHButtonComponent>();
SHComponentManager::CreateComponentSparseSet<SHToggleButtonComponent>();
SHComponentManager::CreateComponentSparseSet<SHSliderComponent>();
}
void SHUISystem::Exit()
@ -234,18 +236,23 @@ namespace SHADE
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial();
if(!comp.isHovered && !comp.isClicked)
if (comp.GetDefaultTexture() != 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE)
AssetID textureID = 0;
if (!comp.isHovered && !comp.isClicked)
{
material->SetProperty("data.textureIndex", comp.GetDefaultTexture());
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
if (comp.GetDefaultTexture() != 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE)
{
textureID = comp.GetDefaultTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetDefaultTexture()));
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
}
else if (comp.isClicked)
{
if (comp.GetClickedTexture() != 0 && SHAssetManager::GetType(comp.GetClickedTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", comp.GetClickedTexture());
textureID = comp.GetClickedTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetClickedTexture()));
//SHLOG_INFO("SETTING CLICKED TEXTURE")
}
}
@ -253,10 +260,17 @@ namespace SHADE
{
if (comp.GetHoveredTexture() != 0 && SHAssetManager::GetType(comp.GetHoveredTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", comp.GetHoveredTexture());
textureID = comp.GetHoveredTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>( comp.GetHoveredTexture()));
//SHLOG_INFO("SETTING HOVERED TEXTURE")
}
}
if (textureID != 0 && textureID != comp.currentTexture)
{
auto material = renderable->GetModifiableMaterial();
comp.currentTexture = textureID;
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
}
@ -272,6 +286,7 @@ namespace SHADE
}
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
auto uiComp = SHComponentManager::GetComponent<SHUIComponent>(comp.GetEID());
//auto canvasComp = SHComponentManager::GetComponent_s<SHCanvasComponent>(uiComp->canvasID);
SHVec4 topExtent4 = SHMatrix::Translate(-comp.size.x * 0.5f, comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f);
SHVec4 btmExtent4 = SHMatrix::Translate(comp.size.x * 0.5f, -comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f);
@ -280,15 +295,15 @@ namespace SHADE
SHVec2 topExtent{ topExtent4.x,topExtent4.y };
SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };
SHVec2 mousePos;
SHVec2 windowSize;
#ifdef SHEDITOR
windowSize = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->beginContentRegionAvailable;
mousePos = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>()->viewportMousePos;
//mousePos.y = windowSize.y - mousePos.y;
//SHLOG_INFO("mouse pos: {}, {}", mousePos.x, mousePos.y)
mousePos /= windowSize;
mousePos /= windowSize;
//SHLOG_INFO("mouse pos normalized: {}, {}", mousePos.x, mousePos.y)
@ -305,21 +320,20 @@ namespace SHADE
#endif
SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) };
//SHLOG_INFO("TopExtent: {}, {}", topExtent.x, topExtent.y)
topExtent = CanvasToScreenPoint(topExtent,true);
topExtent = CanvasToScreenPoint(topExtent, true);
btmExtent = CanvasToScreenPoint(btmExtent, true);
//SHLOG_INFO("TopExtent: {}, {} Btm Extent: {}, {}", topExtent.x, topExtent.y, btmExtent.x, btmExtent.y)
comp.isClicked = false;
//comp.isClicked = false;
if (mousePos.x >= topExtent.x && mousePos.x <= btmExtent.x
&& mousePos.y >= topExtent.y && mousePos.y <= btmExtent.y)
{
comp.isHovered = true;
#ifdef SHEDITOR
if (SHSystemManager::GetSystem<SHEditor>()->editorState == SHEditor::State::PLAY)
//if (SHSystemManager::GetSystem<SHEditor>()->editorState == SHEditor::State::PLAY)
{
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB))
{
@ -330,22 +344,22 @@ namespace SHADE
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB))
{
comp.isClicked = true;
}
}
#endif
}
//SHLOG_INFO("HOVERED")
}
else
{
comp.isHovered = false;
//SHLOG_INFO("NOT HOVERED")
}
if (comp.isClicked && SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
{
comp.isClicked = false;
comp.value = !comp.value;
SHButtonClickEvent clickEvent;
clickEvent.EID = comp.GetEID();
clickEvent.value = comp.value;
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_CLICK_EVENT);
}
@ -354,12 +368,14 @@ namespace SHADE
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial();
//auto material = renderable->GetModifiableMaterial();
AssetID textureID = 0;
if (comp.GetValue() == false)
{
if (comp.GetDefaultTexture()!= 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", comp.GetDefaultTexture());
textureID = comp.GetDefaultTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetDefaultTexture()));
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
}
@ -367,11 +383,20 @@ namespace SHADE
{
if (comp.GetToggledTexture() != 0 && SHAssetManager::GetType(comp.GetToggledTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", comp.GetToggledTexture());
textureID = comp.GetToggledTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetToggledTexture()));
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
}
if (textureID != 0 && textureID != comp.currentTexture)
{
auto material = renderable->GetModifiableMaterial();
comp.currentTexture = textureID;
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
}
}
}

View File

@ -103,19 +103,19 @@ project "SHADE_Managed"
filter "configurations:Debug"
symbols "On"
defines {"_DEBUG"}
defines {"_DEBUG", "SHEDITOR"}
links{"librttr_core_d.lib"}
links{"fmodstudioL_vc.lib", "fmodL_vc.lib"}
filter "configurations:Release"
optimize "On"
defines{"_RELEASE"}
defines{"_RELEASE", "SHEDITOR"}
links{"librttr_core.lib"}
links{"fmodstudio_vc.lib", "fmod_vc.lib"}
filter "configurations:Publish"
optimize "On"
defines{"_RELEASE"}
defines{"_RELEASE", "_PUBLISH"}
links{"librttr_core.lib"}
links{"fmodstudio_vc.lib", "fmod_vc.lib"}