Skip to content

Commit de2e2d8

Browse files
authored
Merge branch 'dev' into BaseID
2 parents 404fb85 + a5a7735 commit de2e2d8

File tree

10 files changed

+1303
-1040
lines changed

10 files changed

+1303
-1040
lines changed

editor/editor_system.cpp

Lines changed: 1035 additions & 1035 deletions
Large diffs are not rendered by default.

editor/gui/inspector_dock.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ void InspectorDock::draw(float deltaMilliseconds)
193193
{
194194
if (ImGui::InputText("Scene Name", &m_OpenedSceneName, ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll))
195195
{
196-
m_OpenedScene->setName(m_OpenedSceneName);
196+
if (!Scene::isReservedName(m_OpenedSceneName))
197+
{
198+
m_OpenedScene->setName(m_OpenedSceneName);
199+
}
197200
m_IsNameBeingEdited = false;
198201
}
199202
if (!ImGui::IsItemHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Left))

game/game_application.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ Ref<Application> CreateRootexApplication()
2222
Optional<String> GameApplication::getSceneNameFromCommandLine(const char* s)
2323
{
2424
String cmdLine = s;
25-
size_t found = cmdLine.find("game/assets/");
26-
if (found != String::npos)
25+
if (!Scene::isReservedName(cmdLine))
2726
{
28-
return cmdLine.substr(found, cmdLine.size() - 1);
27+
size_t found = cmdLine.find("game/assets/");
28+
if (found != String::npos)
29+
{
30+
return cmdLine.substr(found, cmdLine.size() - 1);
31+
}
2932
}
3033
return {};
3134
}
@@ -47,7 +50,11 @@ GameApplication::GameApplication()
4750
}
4851
else
4952
{
50-
SceneLoader::GetSingleton()->loadScene(m_ApplicationSettings->getJSON()["startScene"], {});
53+
String sceneName = m_ApplicationSettings->getJSON()["startScene"];
54+
if (Scene::isReservedName(sceneName))
55+
{
56+
SceneLoader::GetSingleton()->loadScene(sceneName, {});
57+
}
5158
}
5259

5360
GameRenderSystem::GetSingleton()->initialize({});
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include "register_locations_pixel_shader.h"
2+
Texture2D InputTexture : register(t0);
3+
SamplerState AnisotropicSampler : register(s0);
4+
5+
cbuffer PerFrame : register(CUSTOM_PER_FRAME_PS_HLSL)
6+
{
7+
float timeMs;
8+
float deltaTimeMs;
9+
float2 resolution;
10+
float2 mouse;
11+
};
12+
13+
struct DamageVSOutput
14+
{
15+
float4 pos : SV_POSITION;
16+
float2 tex : TEXCOORD;
17+
};
18+
19+
float4 closest(float r,float g, float b) {
20+
r=round( r * 31.0f ) / 31.0f;
21+
b=round( b * 31.0f ) / 31.0f;
22+
g=round( g * 63.0f ) / 63.0f;
23+
24+
return float4( r, g, b, 1.0f );
25+
}
26+
27+
float dithering(in float2 coord, inout float v)
28+
{
29+
int ordered_matrix[8][8] = {
30+
{ 0, 32, 8, 40, 2, 34, 10, 42 },
31+
{ 48, 16, 56, 24, 50, 18, 58, 26 },
32+
{ 12, 44, 4, 36, 14, 46, 6, 38 },
33+
{ 60, 28, 52, 20, 62, 30, 54, 22 },
34+
{ 3, 35, 11, 43, 1, 33, 9, 41 },
35+
{ 51, 19, 59, 27, 49, 17, 57, 25 },
36+
{ 15, 47, 7, 39, 13, 45, 5, 37 },
37+
{ 63, 31, 55, 23, 61, 29, 53, 21 }
38+
};
39+
float offset = (float(ordered_matrix[(int)(coord.x) & 7][(int)(coord.y) & 7] ) + 1 ) / 64.0f - 0.5;
40+
v = v + offset * 0.4;
41+
42+
return v;
43+
}
44+
45+
46+
float4 main(DamageVSOutput input) : SV_TARGET
47+
{
48+
float4 rgbl = InputTexture.Sample(AnisotropicSampler, input.tex);
49+
float2 uv=float2( input.tex * resolution / 3.0f );
50+
float r=dithering( uv, rgbl.r );
51+
float b=dithering( uv, rgbl.b );
52+
float g=dithering( uv, rgbl.g );
53+
rgbl = closest( r, g, b );
54+
55+
return rgbl;
56+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "register_locations_pixel_shader.h"
2+
Texture2D InputTexture : register(t0);
3+
SamplerState AnisotropicSampler : register(s0);
4+
5+
struct DamageVSOutput
6+
{
7+
float4 pos : SV_POSITION;
8+
float2 tex : TEXCOORD;
9+
};
10+
11+
float4 main(DamageVSOutput input) : SV_TARGET
12+
{
13+
float4 rgbl = InputTexture.Sample(AnisotropicSampler, input.tex);
14+
rgbl = ( float4( rgbl.r, rgbl.g, rgbl.b, 1.0f ) );
15+
16+
return rgbl;
17+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#include "register_locations_pixel_shader.h"
2+
Texture2D InputTexture : register(t0);
3+
SamplerState AnisotropicSampler : register(s0);
4+
5+
cbuffer PerFrame : register(CUSTOM_PER_FRAME_PS_HLSL)
6+
{
7+
float timeMs;
8+
float deltaTimeMs;
9+
float2 resolution;
10+
float2 mouse;
11+
};
12+
13+
struct DamageVSOutput
14+
{
15+
float4 pos : SV_POSITION;
16+
float2 tex : TEXCOORD;
17+
};
18+
19+
float4 closest(float r,float g, float b) {
20+
float Palette[8][3]=
21+
{
22+
{ 0.0f, 0.0f, 0.0f },
23+
{ 0.0f, 0.0f, 1.0f },
24+
{ 0.0f, 1.0f, 0.0f },
25+
{ 0.0f, 1.0f, 1.0f },
26+
{ 1.0f, 0.0f, 0.0f },
27+
{ 1.0f, 0.0f, 1.0f },
28+
{ 1.0f, 1.0f, 0.0f },
29+
{ 1.0f, 1.0f, 1.0f }
30+
};
31+
float m = 999999999.0f;
32+
float3 closest = { 1.0f, 1.0f, 1.0f };
33+
float3 curr = float3( r, g, b );
34+
for (int i = 0; i < 8; i++) {
35+
float3 tr = float3( Palette[i] );
36+
float3 error = tr - curr;
37+
float err = dot( error, error );
38+
if ( err < m ) {
39+
m = err;
40+
closest = tr;
41+
}
42+
}
43+
44+
return float4( closest, 1.0f );
45+
};
46+
47+
float dithering(in float2 coord, inout float v)
48+
{
49+
int ordered_matrix[8][8] = {
50+
{ 0, 32, 8, 40, 2, 34, 10, 42 },
51+
{ 48, 16, 56, 24, 50, 18, 58, 26 },
52+
{ 12, 44, 4, 36, 14, 46, 6, 38 },
53+
{ 60, 28, 52, 20, 62, 30, 54, 22 },
54+
{ 3, 35, 11, 43, 1, 33, 9, 41 },
55+
{ 51, 19, 59, 27, 49, 17, 57, 25 },
56+
{ 15, 47, 7, 39, 13, 45, 5, 37 },
57+
{ 63, 31, 55, 23, 61, 29, 53, 21 }
58+
};
59+
float offset = (float(ordered_matrix[(int)(coord.x) & 7][(int)( coord.y ) & 7 ]) + 1 ) / 64.0f - 0.5;
60+
v = v + offset * 0.4;
61+
62+
return v;
63+
}
64+
65+
66+
float4 main(DamageVSOutput input) : SV_TARGET
67+
{
68+
float4 rgbl = InputTexture.Sample(AnisotropicSampler, input.tex);
69+
float2 uv=float2( input.tex * resolution / 3.0f );
70+
float r=dithering( uv, rgbl.r );
71+
float b=dithering( uv, rgbl.b );
72+
float g=dithering( uv, rgbl.g );
73+
rgbl = closest( r, g, b );
74+
75+
return rgbl;
76+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include "register_locations_pixel_shader.h"
2+
Texture2D InputTexture : register(t0);
3+
SamplerState AnisotropicSampler : register(s0);
4+
5+
cbuffer PerFrame : register(CUSTOM_PER_FRAME_PS_HLSL)
6+
{
7+
float timeMs;
8+
float deltaTimeMs;
9+
float2 resolution;
10+
float2 mouse;
11+
};
12+
13+
struct DamageVSOutput
14+
{
15+
float4 pos : SV_POSITION;
16+
float2 tex : TEXCOORD;
17+
};
18+
19+
float4 closest(float r,float g, float b) {
20+
21+
r = round( r * 7.0f ) / 7.0f;
22+
g = round( g * 7.0f )/7.0f;
23+
b = round( b * 3.0f ) / 3.0f;
24+
25+
return float4( r, g, b, 1.0f );
26+
};
27+
28+
float dithering(in float2 coord, inout float v)
29+
{
30+
int ordered_matrix[8][8] = {
31+
{ 0, 32, 8, 40, 2, 34, 10, 42 },
32+
{ 48, 16, 56, 24, 50, 18, 58, 26 },
33+
{ 12, 44, 4, 36, 14, 46, 6, 38 },
34+
{ 60, 28, 52, 20, 62, 30, 54, 22 },
35+
{ 3, 35, 11, 43, 1, 33, 9, 41 },
36+
{ 51, 19, 59, 27, 49, 17, 57, 25 },
37+
{ 15, 47, 7, 39, 13, 45, 5, 37 },
38+
{ 63, 31, 55, 23, 61, 29, 53, 21 }
39+
};
40+
float offset = (float(ordered_matrix[(int)(coord.x) & 7][(int)(coord.y) & 7]) + 1 ) / 64.0f - 0.5;
41+
v = v + offset * 0.4;
42+
43+
return v;
44+
}
45+
46+
float4 main(DamageVSOutput input) : SV_TARGET
47+
{
48+
float4 rgbl = InputTexture.Sample(AnisotropicSampler, input.tex);
49+
float2 uv=float2( input.tex * resolution / 3.0f );
50+
float r=dithering( uv, rgbl.r );
51+
float b=dithering( uv, rgbl.b );
52+
float g=dithering( uv, rgbl.g );
53+
rgbl = closest( r, g, b );
54+
55+
return rgbl;
56+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "register_locations_pixel_shader.h"
2+
Texture2D InputTexture : register(t0);
3+
SamplerState AnisotropicSampler : register(s0);
4+
5+
cbuffer PerFrame : register(CUSTOM_PER_FRAME_PS_HLSL)
6+
{
7+
float timeMs;
8+
float deltaTimeMs;
9+
float2 resolution;
10+
float2 mouse;
11+
};
12+
13+
struct DamageVSOutput
14+
{
15+
float4 pos : SV_POSITION;
16+
float2 tex : TEXCOORD;
17+
};
18+
19+
float4 main(DamageVSOutput input) : SV_TARGET
20+
{
21+
float4 rgbl = InputTexture.Sample(AnisotropicSampler, input.tex);
22+
float2 uv = ( input.tex - 0.5 );
23+
float time = timeMs * 0.006;
24+
float freq = 0.5;
25+
float intensity = max( abs(uv.x), abs(uv.y) );
26+
intensity = max( intensity, (abs(uv.x) + abs(uv.y)) * 0.66667);
27+
float sinTime = abs( sin( time ) );
28+
float div = ( sinTime + 1.0f );
29+
float3 col = float3( ( (intensity) * sinTime + rgbl.r ) / div, rgbl.g / div, rgbl.b / div);
30+
rgbl = ( float4( col, 1.0f ) );
31+
32+
return rgbl;
33+
}

rootex/framework/scene.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,20 @@ bool Scene::removeChild(Scene* toRemove)
317317
return false;
318318
}
319319

320+
bool Scene::isReservedName(const String& sceneName)
321+
{
322+
static Vector<String> reservedNames { "pause", "pauseUI" };
323+
for (auto& reservedName : reservedNames)
324+
{
325+
if (reservedName == sceneName)
326+
{
327+
WARN("Cannot use reserved scene names");
328+
return true;
329+
}
330+
}
331+
return false;
332+
}
333+
320334
void Scene::setName(const String& name)
321335
{
322336
m_Name = name;

rootex/framework/scene.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class Scene
6565
static Ptr<Scene> CreateEmpty();
6666
static Ptr<Scene> CreateEmptyAtPath(const String& sceneFile);
6767
static Ptr<Scene> CreateRootScene();
68+
static bool isReservedName(const String& sceneName);
6869

6970
static Vector<Scene*> FindScenesByName(const String& name);
7071
static Scene* FindSceneByID(const SceneID& id);

0 commit comments

Comments
 (0)