Added display of editor camera position #368
|
@ -0,0 +1,8 @@
|
||||||
|
- VertexShader: 37048829
|
||||||
|
FragmentShader: 45685219
|
||||||
|
SubPass: G-Buffer Write
|
||||||
|
Properties:
|
||||||
|
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
data.textureIndex: 57342922
|
||||||
|
data.alpha: 0
|
||||||
|
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: ShinyHightlight
|
||||||
|
ID: 122370915
|
||||||
|
Type: 7
|
|
@ -0,0 +1,8 @@
|
||||||
|
- VertexShader: 38847805
|
||||||
|
FragmentShader: 42962441
|
||||||
|
SubPass: Object VFX Subpass No Depth
|
||||||
|
Properties:
|
||||||
|
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
data.textureIndex: 0
|
||||||
|
data.alpha: 0
|
||||||
|
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: Silhouette
|
||||||
|
ID: 126391182
|
||||||
|
Type: 7
|
|
@ -8599,7 +8599,7 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Renderable Component:
|
Renderable Component:
|
||||||
Mesh: 136892700
|
Mesh: 136892700
|
||||||
Material: 131956078
|
Material: 122370915
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
RigidBody Component:
|
||||||
Type: Dynamic
|
Type: Dynamic
|
||||||
|
@ -9594,6 +9594,9 @@
|
||||||
Text: My name is Brandon.
|
Text: My name is Brandon.
|
||||||
Font: 176667660
|
Font: 176667660
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
UI Component:
|
||||||
|
Canvas ID: 199
|
||||||
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 206
|
- EID: 206
|
||||||
Name: Timer
|
Name: Timer
|
||||||
|
@ -9609,6 +9612,9 @@
|
||||||
Text: My name is Brandon.
|
Text: My name is Brandon.
|
||||||
Font: 176667660
|
Font: 176667660
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
UI Component:
|
||||||
|
Canvas ID: 199
|
||||||
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 139
|
- EID: 139
|
||||||
Name: Multiplier
|
Name: Multiplier
|
||||||
|
@ -9624,6 +9630,9 @@
|
||||||
Text: TEST
|
Text: TEST
|
||||||
Font: 176667660
|
Font: 176667660
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
UI Component:
|
||||||
|
Canvas ID: 199
|
||||||
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 11
|
- EID: 11
|
||||||
Name: GamePause
|
Name: GamePause
|
||||||
|
|
|
@ -113,8 +113,7 @@
|
||||||
Pitch: 0
|
Pitch: 0
|
||||||
Yaw: 0
|
Yaw: 0
|
||||||
Roll: 0
|
Roll: 0
|
||||||
Width: 1319
|
Width: 1175
|
||||||
Height: 622
|
|
||||||
Near: 0.00999999978
|
Near: 0.00999999978
|
||||||
Far: 10000
|
Far: 10000
|
||||||
Perspective: true
|
Perspective: true
|
||||||
|
|
|
@ -11,8 +11,9 @@ public class ChangeSceneButton : Script
|
||||||
UIElement ui = GetComponent<UIElement>();
|
UIElement ui = GetComponent<UIElement>();
|
||||||
if (ui != null)
|
if (ui != null)
|
||||||
{
|
{
|
||||||
ui.OnClick.RegisterAction(() =>
|
ui.OnRelease.RegisterAction(() =>
|
||||||
{
|
{
|
||||||
|
|
||||||
if (sceneID != 0)
|
if (sceneID != 0)
|
||||||
{
|
{
|
||||||
Audio.PlaySFXOnce2D("event:/UI/success");
|
Audio.PlaySFXOnce2D("event:/UI/success");
|
||||||
|
|
|
@ -26,6 +26,7 @@ layout(set = 3, binding = 3, r32ui) uniform uimage2D lightLayerData;
|
||||||
layout(set = 3, binding = 4, r8) uniform image2D ssaoBlurredImage;
|
layout(set = 3, binding = 4, r8) uniform image2D ssaoBlurredImage;
|
||||||
layout(set = 3, binding = 5, rgba8) uniform image2D positionWorldSpace;
|
layout(set = 3, binding = 5, rgba8) uniform image2D positionWorldSpace;
|
||||||
layout(set = 3, binding = 6, rgba8) uniform image2D targetImage;
|
layout(set = 3, binding = 6, rgba8) uniform image2D targetImage;
|
||||||
|
layout(set = 3, binding = 7, rgba8) uniform image2D objectVFXImage;
|
||||||
|
|
||||||
layout (set = 4, binding = 0) uniform sampler2D shadowMaps[]; // for textures (global)
|
layout (set = 4, binding = 0) uniform sampler2D shadowMaps[]; // for textures (global)
|
||||||
|
|
||||||
|
@ -141,6 +142,9 @@ void main()
|
||||||
float ssaoVal = imageLoad (ssaoBlurredImage, globalThread).r;
|
float ssaoVal = imageLoad (ssaoBlurredImage, globalThread).r;
|
||||||
fragColor *= ssaoVal;
|
fragColor *= ssaoVal;
|
||||||
|
|
||||||
|
vec4 objectVFXColor = imageLoad (objectVFXImage, globalThread);
|
||||||
|
fragColor += objectVFXColor.rgb * objectVFXColor.a;
|
||||||
|
|
||||||
// store result into result image
|
// store result into result image
|
||||||
imageStore(targetImage, ivec2(gl_GlobalInvocationID.xy), vec4(fragColor.rgb, 1.0f));
|
imageStore(targetImage, ivec2(gl_GlobalInvocationID.xy), vec4(fragColor.rgb, 1.0f));
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,97 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_ARB_separate_shader_objects : enable
|
||||||
|
#extension GL_ARB_shading_language_420pack : enable
|
||||||
|
#extension GL_EXT_nonuniform_qualifier : require
|
||||||
|
|
||||||
|
struct MatPropData
|
||||||
|
{
|
||||||
|
int textureIndex;
|
||||||
|
float highlightPosition;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GenericData
|
||||||
|
{
|
||||||
|
//! Delta time
|
||||||
|
float dt;
|
||||||
|
|
||||||
|
//! Elapsed time of the application
|
||||||
|
float elapsedTime;
|
||||||
|
|
||||||
|
//! Viewport width of the scene (excluding imgui, that means smaller than window)
|
||||||
|
uint viewportWidth;
|
||||||
|
|
||||||
|
//! Ditto but for height
|
||||||
|
uint viewportHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
layout(location = 0) in struct
|
||||||
|
{
|
||||||
|
vec4 vertPos; // location 0
|
||||||
|
vec2 uv; // location = 1
|
||||||
|
vec4 normal; // location = 2
|
||||||
|
vec4 worldPos; // location = 3
|
||||||
|
} In;
|
||||||
|
|
||||||
|
// material stuff
|
||||||
|
layout(location = 4) flat in struct
|
||||||
|
{
|
||||||
|
int materialIndex;
|
||||||
|
uint eid;
|
||||||
|
uint lightLayerIndex;
|
||||||
|
vec3 screenSpacePos;
|
||||||
|
|
||||||
|
} In2;
|
||||||
|
|
||||||
|
layout (set = 0, binding = 0) uniform GenericDataBuffer
|
||||||
|
{
|
||||||
|
GenericData data;
|
||||||
|
} genericDataBuffer;
|
||||||
|
|
||||||
|
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
|
||||||
|
layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
|
||||||
|
{
|
||||||
|
MatPropData data[];
|
||||||
|
} MatProp;
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 position;
|
||||||
|
layout(location = 1) out uint outEntityID;
|
||||||
|
layout(location = 2) out uint lightLayerIndices;
|
||||||
|
layout(location = 3) out vec4 normals;
|
||||||
|
layout(location = 4) out vec4 albedo;
|
||||||
|
layout(location = 5) out vec4 worldSpacePosition;
|
||||||
|
layout(location = 6) out vec4 objectVFX;
|
||||||
|
|
||||||
|
float map (float value, float srcLow, float srcHigh, float dstLow, float dstHigh)
|
||||||
|
{
|
||||||
|
return dstLow + (value - srcLow) * (dstHigh - dstLow) / (srcHigh - srcLow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
position = In.vertPos;
|
||||||
|
normals = In.normal;
|
||||||
|
albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
|
||||||
|
worldSpacePosition = In.worldPos;
|
||||||
|
|
||||||
|
outEntityID = In2.eid;
|
||||||
|
lightLayerIndices = In2.lightLayerIndex;
|
||||||
|
|
||||||
|
float vpHeight = (float (In2.screenSpacePos.y) - (genericDataBuffer.data.elapsedTime * 4000.0f * (1.0f - In2.screenSpacePos.z)));
|
||||||
|
vpHeight = float (int (vpHeight) % genericDataBuffer.data.viewportHeight);
|
||||||
|
float scanlineScale = 2500.0f * (1.0f - In2.screenSpacePos.z);
|
||||||
|
|
||||||
|
float lowerLimit = vpHeight - scanlineScale;
|
||||||
|
float upperLimit = vpHeight + scanlineScale;
|
||||||
|
if (gl_FragCoord.y > lowerLimit && gl_FragCoord.y < upperLimit)
|
||||||
|
{
|
||||||
|
float opacity = 0.0f;
|
||||||
|
opacity = map (abs (gl_FragCoord.y - vpHeight), 0.0f, upperLimit - vpHeight, 0.0f, 1.0f);
|
||||||
|
opacity = 1.0f - clamp (opacity, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
|
||||||
|
objectVFX = vec4(opacity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
objectVFX = vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: ShinyHighlight_FS
|
||||||
|
ID: 45685219
|
||||||
|
Type: 2
|
|
@ -0,0 +1,99 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_KHR_vulkan_glsl : enable
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 aVertexPos;
|
||||||
|
layout(location = 1) in vec2 aUV;
|
||||||
|
layout(location = 2) in vec3 aNormal;
|
||||||
|
layout(location = 3) in vec3 aTangent;
|
||||||
|
layout(location = 4) in mat4 worldTransform;
|
||||||
|
layout(location = 8) in uvec2 integerData;
|
||||||
|
layout(location = 9) in uvec4 aBoneIndices;
|
||||||
|
layout(location = 10) in vec4 aBoneWeights;
|
||||||
|
layout(location = 11) in uint firstBoneIndex;
|
||||||
|
|
||||||
|
layout(location = 0) out struct
|
||||||
|
{
|
||||||
|
vec4 vertPos; // location 0
|
||||||
|
vec2 uv; // location = 1
|
||||||
|
vec4 normal; // location = 2
|
||||||
|
vec4 worldPos; // location = 3
|
||||||
|
|
||||||
|
} Out;
|
||||||
|
|
||||||
|
struct GenericData
|
||||||
|
{
|
||||||
|
//! Delta time
|
||||||
|
float dt;
|
||||||
|
|
||||||
|
//! Elapsed time of the application
|
||||||
|
float elapsedTime;
|
||||||
|
|
||||||
|
//! Viewport width of the scene (excluding imgui, that means smaller than window)
|
||||||
|
uint viewportWidth;
|
||||||
|
|
||||||
|
//! Ditto but for height
|
||||||
|
uint viewportHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
// material stuff
|
||||||
|
layout(location = 4) out struct
|
||||||
|
{
|
||||||
|
int materialIndex;
|
||||||
|
uint eid;
|
||||||
|
uint lightLayerIndex;
|
||||||
|
vec3 screenSpacePos;
|
||||||
|
|
||||||
|
|
||||||
|
} Out2;
|
||||||
|
|
||||||
|
layout(set = 1, binding = 0) uniform CameraData
|
||||||
|
{
|
||||||
|
vec4 position;
|
||||||
|
mat4 vpMat;
|
||||||
|
mat4 viewMat;
|
||||||
|
mat4 projMat;
|
||||||
|
} cameraData;
|
||||||
|
|
||||||
|
layout (set = 0, binding = 0) uniform GenericDataBuffer
|
||||||
|
{
|
||||||
|
GenericData data;
|
||||||
|
} genericDataBuffer;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Out2.materialIndex = gl_InstanceIndex;
|
||||||
|
Out2.eid = integerData[0];
|
||||||
|
Out2.lightLayerIndex = integerData[1];
|
||||||
|
|
||||||
|
// for transforming gBuffer position and normal data
|
||||||
|
mat4 modelViewMat = cameraData.viewMat * worldTransform;
|
||||||
|
|
||||||
|
// gBuffer position will be in view space
|
||||||
|
Out.vertPos = modelViewMat * vec4(aVertexPos, 1.0f);
|
||||||
|
|
||||||
|
Out.worldPos = worldTransform * vec4 (aVertexPos, 1.0f);
|
||||||
|
|
||||||
|
// uvs for texturing in fragment shader
|
||||||
|
Out.uv = aUV;
|
||||||
|
|
||||||
|
mat3 transposeInv = mat3 (transpose(inverse(modelViewMat)));
|
||||||
|
|
||||||
|
// normals are also in view space
|
||||||
|
Out.normal.rgb = transposeInv * aNormal.rgb;
|
||||||
|
Out.normal.rgb = normalize (Out.normal.rgb);
|
||||||
|
|
||||||
|
// Get center of object in world position
|
||||||
|
vec4 worldPos = vec4(worldTransform[3][0], worldTransform[3][1], worldTransform[3][2], 1.0f);
|
||||||
|
|
||||||
|
// transform to clip space
|
||||||
|
worldPos = cameraData.vpMat * worldPos;
|
||||||
|
worldPos.xyz /= worldPos.w;
|
||||||
|
|
||||||
|
// transform to screen space
|
||||||
|
worldPos.xy = ((worldPos.xy + vec2(1.0f)) * vec2 (0.5f)) * vec2 (genericDataBuffer.data.viewportWidth, genericDataBuffer.data.viewportHeight);
|
||||||
|
|
||||||
|
Out2.screenSpacePos = worldPos.xyz;
|
||||||
|
|
||||||
|
// clip space for rendering
|
||||||
|
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: ShinyHighlight_VS
|
||||||
|
ID: 37048829
|
||||||
|
Type: 2
|
|
@ -0,0 +1,67 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_ARB_separate_shader_objects : enable
|
||||||
|
#extension GL_ARB_shading_language_420pack : enable
|
||||||
|
#extension GL_EXT_nonuniform_qualifier : require
|
||||||
|
|
||||||
|
struct MatPropData
|
||||||
|
{
|
||||||
|
vec4 color;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GenericData
|
||||||
|
{
|
||||||
|
//! Delta time
|
||||||
|
float dt;
|
||||||
|
|
||||||
|
//! Elapsed time of the application
|
||||||
|
float elapsedTime;
|
||||||
|
|
||||||
|
//! Viewport width of the scene (excluding imgui, that means smaller than window)
|
||||||
|
uint viewportWidth;
|
||||||
|
|
||||||
|
//! Ditto but for height
|
||||||
|
uint viewportHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(location = 0) in struct
|
||||||
|
{
|
||||||
|
vec4 vertPos; // location 0
|
||||||
|
vec2 uv; // location = 1
|
||||||
|
vec4 normal; // location = 2
|
||||||
|
vec4 worldPos; // location = 3
|
||||||
|
} In;
|
||||||
|
|
||||||
|
// material stuff
|
||||||
|
layout(location = 4) flat in struct
|
||||||
|
{
|
||||||
|
int materialIndex;
|
||||||
|
uint eid;
|
||||||
|
uint lightLayerIndex;
|
||||||
|
} In2;
|
||||||
|
|
||||||
|
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
|
||||||
|
layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
|
||||||
|
{
|
||||||
|
MatPropData data[];
|
||||||
|
} MatProp;
|
||||||
|
|
||||||
|
layout (set = 0, binding = 0) uniform GenericDataBuffer
|
||||||
|
{
|
||||||
|
GenericData data;
|
||||||
|
} genericDataBuffer;
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 objectVFX;
|
||||||
|
layout(input_attachment_index = 0, set = 3, binding = 0) uniform subpassInput depthBuffer;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// Sample depth buffer using UV and save it
|
||||||
|
float currentDepth = subpassLoad (depthBuffer).r;
|
||||||
|
|
||||||
|
// Use depth buffer to check against current fragment's depth. If fragment is behind depth buffer, render fragment.
|
||||||
|
if (currentDepth > gl_FragCoord.z)
|
||||||
|
discard;
|
||||||
|
|
||||||
|
objectVFX = MatProp.data[In2.materialIndex].color;
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: Silhouette_FS
|
||||||
|
ID: 42962441
|
||||||
|
Type: 2
|
|
@ -0,0 +1,68 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_KHR_vulkan_glsl : enable
|
||||||
|
|
||||||
|
//#include "ShaderDescriptorDefinitions.glsl"
|
||||||
|
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 aVertexPos;
|
||||||
|
layout(location = 1) in vec2 aUV;
|
||||||
|
layout(location = 2) in vec3 aNormal;
|
||||||
|
layout(location = 3) in vec3 aTangent;
|
||||||
|
layout(location = 4) in mat4 worldTransform;
|
||||||
|
layout(location = 8) in uvec2 integerData;
|
||||||
|
layout(location = 9) in uvec4 aBoneIndices;
|
||||||
|
layout(location = 10) in vec4 aBoneWeights;
|
||||||
|
layout(location = 11) in uint firstBoneIndex;
|
||||||
|
|
||||||
|
layout(location = 0) out struct
|
||||||
|
{
|
||||||
|
vec4 vertPos; // location 0
|
||||||
|
vec2 uv; // location = 1
|
||||||
|
vec4 normal; // location = 2
|
||||||
|
vec4 worldPos; // location = 3
|
||||||
|
|
||||||
|
} Out;
|
||||||
|
|
||||||
|
// material stuff
|
||||||
|
layout(location = 4) out struct
|
||||||
|
{
|
||||||
|
int materialIndex;
|
||||||
|
uint eid;
|
||||||
|
uint lightLayerIndex;
|
||||||
|
|
||||||
|
} Out2;
|
||||||
|
|
||||||
|
layout(set = 1, binding = 0) uniform CameraData
|
||||||
|
{
|
||||||
|
vec4 position;
|
||||||
|
mat4 vpMat;
|
||||||
|
mat4 viewMat;
|
||||||
|
mat4 projMat;
|
||||||
|
} cameraData;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Out2.materialIndex = gl_InstanceIndex;
|
||||||
|
Out2.eid = integerData[0];
|
||||||
|
Out2.lightLayerIndex = integerData[1];
|
||||||
|
|
||||||
|
// for transforming gBuffer position and normal data
|
||||||
|
mat4 modelViewMat = cameraData.viewMat * worldTransform;
|
||||||
|
|
||||||
|
// gBuffer position will be in view space
|
||||||
|
Out.vertPos = modelViewMat * vec4(aVertexPos, 1.0f);
|
||||||
|
|
||||||
|
Out.worldPos = worldTransform * vec4 (aVertexPos, 1.0f);
|
||||||
|
|
||||||
|
// uvs for texturing in fragment shader
|
||||||
|
Out.uv = aUV;
|
||||||
|
|
||||||
|
mat3 transposeInv = mat3 (transpose(inverse(modelViewMat)));
|
||||||
|
|
||||||
|
// normals are also in view space
|
||||||
|
Out.normal.rgb = transposeInv * aNormal.rgb;
|
||||||
|
Out.normal.rgb = normalize (Out.normal.rgb);
|
||||||
|
|
||||||
|
// clip space for rendering
|
||||||
|
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: Silhouette_VS
|
||||||
|
ID: 38847805
|
||||||
|
Type: 2
|
|
@ -3,7 +3,7 @@
|
||||||
#extension GL_ARB_shading_language_420pack : enable
|
#extension GL_ARB_shading_language_420pack : enable
|
||||||
#extension GL_EXT_nonuniform_qualifier : require
|
#extension GL_EXT_nonuniform_qualifier : require
|
||||||
|
|
||||||
layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput sceneTexture;
|
layout (input_attachment_index = 0, set = 3, binding = 0) uniform subpassInput sceneTexture;
|
||||||
|
|
||||||
|
|
||||||
layout(location = 0) out vec4 fragColor;
|
layout(location = 0) out vec4 fragColor;
|
||||||
|
|
Binary file not shown.
|
@ -132,16 +132,19 @@ namespace Sandbox
|
||||||
SHSystemManager::RegisterRoutine<SHTransformSystem, SHTransformSystem::TransformPostPhysicsUpdate>();
|
SHSystemManager::RegisterRoutine<SHTransformSystem, SHTransformSystem::TransformPostPhysicsUpdate>();
|
||||||
SHSystemManager::RegisterRoutine<SHDebugDrawSystem, SHDebugDrawSystem::ProcessPointsRoutine>();
|
SHSystemManager::RegisterRoutine<SHDebugDrawSystem, SHDebugDrawSystem::ProcessPointsRoutine>();
|
||||||
|
|
||||||
SHSystemManager::RegisterRoutine<SHScriptEngine, SHScriptEngine::GizmosDrawRoutine>();
|
|
||||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::PrepareRenderRoutine>();
|
|
||||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BatcherDispatcherRoutine>();
|
|
||||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BeginRoutine>();
|
|
||||||
|
|
||||||
//SHSystemManager::RegisterRoutine<SHCameraSystem, SHCameraSystem::EditorCameraUpdate>();
|
//SHSystemManager::RegisterRoutine<SHCameraSystem, SHCameraSystem::EditorCameraUpdate>();
|
||||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::AddUIComponentRoutine>();
|
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::AddUIComponentRoutine>();
|
||||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateCanvasMatrixRoutine>();
|
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateCanvasMatrixRoutine>();
|
||||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateUIMatrixRoutine>();
|
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateUIMatrixRoutine>();
|
||||||
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateButtonsRoutine>();
|
SHSystemManager::RegisterRoutine<SHUISystem, SHUISystem::UpdateButtonsRoutine>();
|
||||||
|
|
||||||
|
SHSystemManager::RegisterRoutine<SHScriptEngine, SHScriptEngine::GizmosDrawRoutine>();
|
||||||
|
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::PrepareRenderRoutine>();
|
||||||
|
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BatcherDispatcherRoutine>();
|
||||||
|
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BeginRoutine>();
|
||||||
|
|
||||||
|
|
||||||
SHSystemManager::RegisterRoutine<SHCameraSystem, SHCameraSystem::CameraSystemUpdate>();
|
SHSystemManager::RegisterRoutine<SHCameraSystem, SHCameraSystem::CameraSystemUpdate>();
|
||||||
|
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
struct SHCompileAssetEvent
|
||||||
|
{
|
||||||
|
//! Name of the asset (where applicable)
|
||||||
|
std::string assetName;
|
||||||
|
|
||||||
|
//! asset ID of the asset
|
||||||
|
AssetID assetID;
|
||||||
|
|
||||||
|
//! type of the asset
|
||||||
|
AssetType assetType;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
#include "SHShaderSourceCompiler.h"
|
#include "SHShaderSourceCompiler.h"
|
||||||
#include "shaderc/shaderc.hpp"
|
#include "shaderc/shaderc.hpp"
|
||||||
|
#include "Events/SHEventManager.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "Filesystem/SHFileSystem.h"
|
#include "Filesystem/SHFileSystem.h"
|
||||||
#include <rttr/registration.h>
|
#include <rttr/registration.h>
|
||||||
|
#include "Assets/Events/SHAssetManagerEvents.h"
|
||||||
|
#include "Events/SHEventManager.hpp"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -39,7 +41,7 @@ namespace SHADE
|
||||||
std::vector<SHAssetLoader*> SHAssetManager::loaders(TYPE_COUNT);
|
std::vector<SHAssetLoader*> SHAssetManager::loaders(TYPE_COUNT);
|
||||||
|
|
||||||
std::unordered_map<AssetID, SHAsset> SHAssetManager::assetCollection;
|
std::unordered_map<AssetID, SHAsset> SHAssetManager::assetCollection;
|
||||||
std::unordered_map<AssetID, SHAssetData * const> SHAssetManager::assetData;
|
std::unordered_map<AssetID, SHAssetData *> SHAssetManager::assetData;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -167,6 +169,17 @@ namespace SHADE
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AssetID SHAssetManager::GetAssetIDFromPath(AssetPath const& path) noexcept
|
||||||
|
{
|
||||||
|
for (auto const& pair : assetCollection)
|
||||||
|
{
|
||||||
|
if (pair.second.path.stem() == path.stem())
|
||||||
|
return pair.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* \brief Create record for new asset. CAN ONLY CREATE FOR CUSTOM
|
* \brief Create record for new asset. CAN ONLY CREATE FOR CUSTOM
|
||||||
* ASSETS CREATED BY THE ENGINE.
|
* ASSETS CREATED BY THE ENGINE.
|
||||||
|
@ -438,10 +451,39 @@ namespace SHADE
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AssetID target{ 0 };
|
||||||
if (genMeta)
|
if (genMeta)
|
||||||
{
|
{
|
||||||
GenerateNewMeta(newPath);
|
auto result = GenerateNewMeta(newPath);
|
||||||
|
target = result.has_value() ? result.value() : 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
target = GetAssetIDFromPath(path);
|
||||||
|
|
||||||
|
//Reload data
|
||||||
|
auto result = GetAsset(target);
|
||||||
|
if (result.has_value())
|
||||||
|
{
|
||||||
|
auto const& asset{ result.value() };
|
||||||
|
auto newData = loaders[static_cast<size_t>(asset.type)]->Load(asset.path);
|
||||||
|
delete assetData[target];
|
||||||
|
assetData[target] = newData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SHLOG_ERROR("[Asset Manager] Critical: reload of existing compiled data failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// send compile asset event
|
||||||
|
SHCompileAssetEvent compileShaderEvent
|
||||||
|
{
|
||||||
|
.assetName = newPath.filename().stem().string(),
|
||||||
|
.assetID = target,
|
||||||
|
.assetType = AssetType::SHADER,
|
||||||
|
};
|
||||||
|
SHEventManager::BroadcastEvent<SHCompileAssetEvent>(compileShaderEvent, SH_ASSET_COMPILE_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderPointer SHAssetManager::GetRootFolder() noexcept
|
FolderPointer SHAssetManager::GetRootFolder() noexcept
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace SHADE
|
||||||
* \return const& to unordered_map<AssetName, AssetID>
|
* \return const& to unordered_map<AssetName, AssetID>
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static std::vector<SHAsset> GetAllAssets() noexcept;
|
static std::vector<SHAsset> GetAllAssets() noexcept;
|
||||||
static std::optional<SHAsset> GetAsset(AssetID id) noexcept;
|
static std::optional<SHAsset> GetAsset(AssetID id) noexcept;
|
||||||
|
|
||||||
static AssetType GetType(AssetID id) noexcept;
|
static AssetType GetType(AssetID id) noexcept;
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ namespace SHADE
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
static AssetID GetAssetIDFromPath(AssetPath const& path) noexcept;
|
||||||
static void InitLoaders() noexcept;
|
static void InitLoaders() noexcept;
|
||||||
static void LoadAllData() noexcept;
|
static void LoadAllData() noexcept;
|
||||||
static SHAssetData* LoadData(SHAsset const& asset) noexcept;
|
static SHAssetData* LoadData(SHAsset const& asset) noexcept;
|
||||||
|
@ -122,7 +123,7 @@ namespace SHADE
|
||||||
|
|
||||||
// For all resources
|
// For all resources
|
||||||
static std::unordered_map<AssetID, SHAsset> assetCollection;
|
static std::unordered_map<AssetID, SHAsset> assetCollection;
|
||||||
static std::unordered_map<AssetID, SHAssetData * const> assetData;
|
static std::unordered_map<AssetID, SHAssetData *> assetData;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SHCameraComponent::SHCameraComponent()
|
SHCameraComponent::SHCameraComponent()
|
||||||
:yaw(0.0f), pitch(0.0f), roll(0.0f)
|
:yaw(0.0f), pitch(0.0f), roll(0.0f)
|
||||||
, width(1920.0f), height(1080.0f), zNear(0.01f), zFar(10000.0f), fov(90.0f), movementSpeed(1.0f), turnSpeed(0.5f)
|
, width(1920.0f), zNear(0.01f), zFar(10000.0f), fov(90.0f), movementSpeed(1.0f), turnSpeed(0.5f)
|
||||||
, perspProj(true), dirtyView(true), dirtyProj(true)
|
, perspProj(true), dirtyView(true), dirtyProj(true), followScreenAR(true)
|
||||||
, viewMatrix(), perspProjMatrix(), orthoProjMatrix()
|
, viewMatrix(), perspProjMatrix(), orthoProjMatrix()
|
||||||
, position(), offset()
|
, position(), offset()
|
||||||
{
|
{
|
||||||
|
@ -122,11 +122,6 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHCameraComponent::SetHeight(float height) noexcept
|
|
||||||
{
|
|
||||||
this->height = height;
|
|
||||||
dirtyProj = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SHCameraComponent::SetNear(float znear) noexcept
|
void SHCameraComponent::SetNear(float znear) noexcept
|
||||||
{
|
{
|
||||||
|
@ -176,10 +171,7 @@ namespace SHADE
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SHCameraComponent::GetHeight() const noexcept
|
|
||||||
{
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
float SHCameraComponent::GetNear() const noexcept
|
float SHCameraComponent::GetNear() const noexcept
|
||||||
{
|
{
|
||||||
|
@ -191,10 +183,7 @@ namespace SHADE
|
||||||
return zFar;
|
return zFar;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SHCameraComponent::GetAspectRatio() const noexcept
|
|
||||||
{
|
|
||||||
return width/height;
|
|
||||||
}
|
|
||||||
|
|
||||||
float SHCameraComponent::GetFOV() const noexcept
|
float SHCameraComponent::GetFOV() const noexcept
|
||||||
{
|
{
|
||||||
|
@ -251,11 +240,11 @@ RTTR_REGISTRATION
|
||||||
.property("Yaw", &SHCameraComponent::GetYaw, &SHCameraComponent::SetYaw)
|
.property("Yaw", &SHCameraComponent::GetYaw, &SHCameraComponent::SetYaw)
|
||||||
.property("Roll", &SHCameraComponent::GetRoll, &SHCameraComponent::SetRoll)
|
.property("Roll", &SHCameraComponent::GetRoll, &SHCameraComponent::SetRoll)
|
||||||
.property("Width", &SHCameraComponent::GetWidth, &SHCameraComponent::SetWidth)
|
.property("Width", &SHCameraComponent::GetWidth, &SHCameraComponent::SetWidth)
|
||||||
.property("Height", &SHCameraComponent::GetHeight, &SHCameraComponent::SetHeight)
|
|
||||||
.property("Near", &SHCameraComponent::GetNear, &SHCameraComponent::SetNear)
|
.property("Near", &SHCameraComponent::GetNear, &SHCameraComponent::SetNear)
|
||||||
.property("Far", &SHCameraComponent::GetFar, &SHCameraComponent::SetFar)
|
.property("Far", &SHCameraComponent::GetFar, &SHCameraComponent::SetFar)
|
||||||
.property("Perspective", &SHCameraComponent::GetIsPerspective, &SHCameraComponent::SetIsPerspective)
|
.property("Perspective", &SHCameraComponent::GetIsPerspective, &SHCameraComponent::SetIsPerspective)
|
||||||
.property("FOV",&SHCameraComponent::GetFOV, &SHCameraComponent::SetFOV);
|
.property("FOV", &SHCameraComponent::GetFOV, &SHCameraComponent::SetFOV);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ namespace SHADE
|
||||||
float roll;
|
float roll;
|
||||||
|
|
||||||
float width;
|
float width;
|
||||||
float height;
|
|
||||||
float zNear;
|
float zNear;
|
||||||
float zFar;
|
float zFar;
|
||||||
float fov;
|
float fov;
|
||||||
|
@ -27,7 +26,6 @@ namespace SHADE
|
||||||
bool dirtyView;
|
bool dirtyView;
|
||||||
bool dirtyProj;
|
bool dirtyProj;
|
||||||
|
|
||||||
|
|
||||||
SHMatrix viewMatrix;
|
SHMatrix viewMatrix;
|
||||||
SHMatrix perspProjMatrix;
|
SHMatrix perspProjMatrix;
|
||||||
SHMatrix orthoProjMatrix;
|
SHMatrix orthoProjMatrix;
|
||||||
|
@ -45,6 +43,8 @@ namespace SHADE
|
||||||
SHCameraComponent();
|
SHCameraComponent();
|
||||||
virtual ~SHCameraComponent();
|
virtual ~SHCameraComponent();
|
||||||
|
|
||||||
|
bool followScreenAR;
|
||||||
|
|
||||||
|
|
||||||
//Getters and setters.
|
//Getters and setters.
|
||||||
void SetYaw(float yaw) noexcept;
|
void SetYaw(float yaw) noexcept;
|
||||||
|
@ -57,7 +57,6 @@ namespace SHADE
|
||||||
void SetPosition(SHVec3 pos) noexcept;
|
void SetPosition(SHVec3 pos) noexcept;
|
||||||
|
|
||||||
void SetWidth(float width) noexcept;
|
void SetWidth(float width) noexcept;
|
||||||
void SetHeight(float height) noexcept;
|
|
||||||
void SetNear(float znear) noexcept;
|
void SetNear(float znear) noexcept;
|
||||||
void SetFar(float zfar) noexcept;
|
void SetFar(float zfar) noexcept;
|
||||||
void SetFOV(float fov) noexcept;
|
void SetFOV(float fov) noexcept;
|
||||||
|
@ -70,11 +69,9 @@ namespace SHADE
|
||||||
float GetRoll() const noexcept;
|
float GetRoll() const noexcept;
|
||||||
|
|
||||||
float GetWidth() const noexcept;
|
float GetWidth() const noexcept;
|
||||||
float GetHeight() const noexcept;
|
|
||||||
float GetNear() const noexcept;
|
float GetNear() const noexcept;
|
||||||
float GetFar() const noexcept;
|
float GetFar() const noexcept;
|
||||||
|
|
||||||
float GetAspectRatio() const noexcept;
|
|
||||||
float GetFOV() const noexcept;
|
float GetFOV() const noexcept;
|
||||||
bool GetIsPerspective() const noexcept;
|
bool GetIsPerspective() const noexcept;
|
||||||
|
|
||||||
|
|
|
@ -99,13 +99,13 @@ namespace SHADE
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SHCameraDirector::GetHeight() noexcept
|
//float SHCameraDirector::GetHeight() noexcept
|
||||||
{
|
//{
|
||||||
SHCameraComponent* camComponent = GetMainCameraComponent();
|
// SHCameraComponent* camComponent = GetMainCameraComponent();
|
||||||
if (camComponent)
|
// if (camComponent)
|
||||||
return camComponent->GetHeight();
|
// return camComponent->GetHeight();
|
||||||
else
|
// else
|
||||||
return 0.0f;
|
// return 0.0f;
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace SHADE
|
||||||
SHMatrix const& GetOrthoMatrix() noexcept;
|
SHMatrix const& GetOrthoMatrix() noexcept;
|
||||||
SHMatrix const& GetPerspectiveMatrix() noexcept;
|
SHMatrix const& GetPerspectiveMatrix() noexcept;
|
||||||
float GetWidth() noexcept;
|
float GetWidth() noexcept;
|
||||||
float GetHeight() noexcept;
|
//float GetHeight() noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SHMatrix viewMatrix;
|
SHMatrix viewMatrix;
|
||||||
|
|
|
@ -116,7 +116,6 @@ namespace SHADE
|
||||||
editorCamera.SetYaw(0.0f);
|
editorCamera.SetYaw(0.0f);
|
||||||
editorCamera.SetRoll(0.0f);
|
editorCamera.SetRoll(0.0f);
|
||||||
editorCamera.SetWidth(1080.0f);
|
editorCamera.SetWidth(1080.0f);
|
||||||
editorCamera.SetHeight(720.0f);
|
|
||||||
editorCamera.SetFar(10000000.0f);
|
editorCamera.SetFar(10000000.0f);
|
||||||
editorCamera.movementSpeed = 2.0f;
|
editorCamera.movementSpeed = 2.0f;
|
||||||
editorCamera.perspProj = true;
|
editorCamera.perspProj = true;
|
||||||
|
@ -144,20 +143,25 @@ namespace SHADE
|
||||||
|
|
||||||
//std::cout << EVENT_DATA->resizeWidth << std::endl;
|
//std::cout << EVENT_DATA->resizeWidth << std::endl;
|
||||||
//std::cout << EVENT_DATA->resizeHeight << std::endl;
|
//std::cout << EVENT_DATA->resizeHeight << std::endl;
|
||||||
|
screenAspectRatio = (float)EVENT_DATA->resizeWidth / (float)EVENT_DATA->resizeHeight;
|
||||||
|
|
||||||
|
#ifdef SHEDITOR
|
||||||
|
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
|
if (editor->editorState != SHEditor::State::PLAY)
|
||||||
|
return eventPtr->handle;
|
||||||
|
|
||||||
|
|
||||||
for (auto director : directorHandleList)
|
#endif // SHEDITOR
|
||||||
|
|
||||||
|
for (auto& director : directorHandleList)
|
||||||
{
|
{
|
||||||
auto camera = SHComponentManager::GetComponent_s<SHCameraComponent>(director->mainCameraEID);
|
auto camera = SHComponentManager::GetComponent_s<SHCameraComponent>(director->mainCameraEID);
|
||||||
if (camera)
|
if (camera)
|
||||||
{
|
{
|
||||||
camera->SetWidth(EVENT_DATA->resizeWidth);
|
camera->SetWidth(EVENT_DATA->resizeWidth);
|
||||||
camera->SetHeight(EVENT_DATA->resizeHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return eventPtr->handle;
|
return eventPtr->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +344,7 @@ namespace SHADE
|
||||||
if (camera.dirtyProj == true)
|
if (camera.dirtyProj == true)
|
||||||
{
|
{
|
||||||
//Perspective projection matrix.
|
//Perspective projection matrix.
|
||||||
const float ASPECT_RATIO = (camera.GetAspectRatio());
|
const float ASPECT_RATIO = (screenAspectRatio);
|
||||||
const float TAN_HALF_FOV = tan(SHMath::DegreesToRadians(camera.fov) * 0.5f);
|
const float TAN_HALF_FOV = tan(SHMath::DegreesToRadians(camera.fov) * 0.5f);
|
||||||
camera.perspProjMatrix = SHMatrix::Identity;
|
camera.perspProjMatrix = SHMatrix::Identity;
|
||||||
camera.perspProjMatrix(0, 0) = 1.0f / (ASPECT_RATIO * TAN_HALF_FOV);
|
camera.perspProjMatrix(0, 0) = 1.0f / (ASPECT_RATIO * TAN_HALF_FOV);
|
||||||
|
@ -357,7 +361,7 @@ namespace SHADE
|
||||||
|
|
||||||
const float right = camera.GetWidth() * 0.5f;
|
const float right = camera.GetWidth() * 0.5f;
|
||||||
const float left = -right;
|
const float left = -right;
|
||||||
const float top = camera.GetHeight() * 0.5f;
|
const float top = camera.GetWidth() / screenAspectRatio * 0.5f;
|
||||||
const float btm = -top;
|
const float btm = -top;
|
||||||
const float n = camera.GetNear();
|
const float n = camera.GetNear();
|
||||||
const float f = camera.GetFar();
|
const float f = camera.GetFar();
|
||||||
|
@ -574,11 +578,11 @@ namespace SHADE
|
||||||
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
if (editor->editorState != SHEditor::State::PLAY)
|
if (editor->editorState != SHEditor::State::PLAY)
|
||||||
{
|
{
|
||||||
return SHVec2{ GetEditorCamera()->GetWidth(), GetEditorCamera()->GetHeight() };
|
return SHVec2{ GetEditorCamera()->GetWidth(), GetEditorCamera()->GetWidth() / screenAspectRatio };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return SHVec2{ GetDirector(index)->GetWidth(),GetDirector(index)->GetHeight() };
|
return SHVec2{ GetDirector(index)->GetWidth(),GetDirector(index)->GetWidth() / screenAspectRatio };
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -586,4 +590,9 @@ namespace SHADE
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntityID SHCameraSystem::GetMainCameraEID() const noexcept
|
||||||
|
{
|
||||||
|
return directorHandleList[0]->mainCameraEID;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ namespace SHADE
|
||||||
SHCameraComponent editorCamera;
|
SHCameraComponent editorCamera;
|
||||||
SHCameraArmComponent editorCameraArm;
|
SHCameraArmComponent editorCameraArm;
|
||||||
|
|
||||||
|
float screenAspectRatio{16.0f/9.0f};
|
||||||
|
|
||||||
SHResourceLibrary<SHCameraDirector> directorLibrary;
|
SHResourceLibrary<SHCameraDirector> directorLibrary;
|
||||||
std::vector<DirectorHandle> directorHandleList;
|
std::vector<DirectorHandle> directorHandleList;
|
||||||
|
|
||||||
|
@ -63,6 +65,7 @@ namespace SHADE
|
||||||
void SetCameraViewMatrix(SHCameraComponent& camera, SHMatrix const& viewMatrix, bool takePos) noexcept;
|
void SetCameraViewMatrix(SHCameraComponent& camera, SHMatrix const& viewMatrix, bool takePos) noexcept;
|
||||||
void CameraLookAt(SHCameraComponent& camera, SHVec3 target) noexcept;
|
void CameraLookAt(SHCameraComponent& camera, SHVec3 target) noexcept;
|
||||||
void UpdateEditorArm(double dt,bool active ,SHVec3 const& targetPos) noexcept;
|
void UpdateEditorArm(double dt,bool active ,SHVec3 const& targetPos) noexcept;
|
||||||
|
EntityID GetMainCameraEID() const noexcept;
|
||||||
|
|
||||||
SHVec2 GetCameraWidthHeight(size_t index) noexcept;
|
SHVec2 GetCameraWidthHeight(size_t index) noexcept;
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace SHADE
|
||||||
if (SHEditorWindow::Begin())
|
if (SHEditorWindow::Begin())
|
||||||
{
|
{
|
||||||
//ImGui::ShowDemoWindow();
|
//ImGui::ShowDemoWindow();
|
||||||
|
if (bindingRenames.size() != SHInputManager::CountBindings())
|
||||||
|
resizeVectors(SHInputManager::CountBindings());
|
||||||
|
|
||||||
//Binding count
|
//Binding count
|
||||||
ImGui::Text("Binding Count: %d", SHInputManager::CountBindings());
|
ImGui::Text("Binding Count: %d", SHInputManager::CountBindings());
|
||||||
|
@ -127,6 +129,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SHInputManager::RenameBinding(binding.first, bindingRenames[entryNumber]);
|
SHInputManager::RenameBinding(binding.first, bindingRenames[entryNumber]);
|
||||||
bindingRenames[entryNumber].clear();
|
bindingRenames[entryNumber].clear();
|
||||||
|
ImGui::End();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::Button(labelConcat("Delete Binding##", entryNumber).c_str()))
|
if (ImGui::Button(labelConcat("Delete Binding##", entryNumber).c_str()))
|
||||||
|
|
|
@ -121,12 +121,22 @@ namespace SHADE
|
||||||
|
|
||||||
//auto pos = ImGui::GetCursorPos();
|
//auto pos = ImGui::GetCursorPos();
|
||||||
//windowCursorPos = {}
|
//windowCursorPos = {}
|
||||||
|
|
||||||
if (beginContentRegionAvailable.x == 0 || beginContentRegionAvailable.y == 0)
|
if (beginContentRegionAvailable.x == 0 || beginContentRegionAvailable.y == 0)
|
||||||
{
|
{
|
||||||
beginContentRegionAvailable = windowSize;
|
beginContentRegionAvailable = windowSize;
|
||||||
}
|
}
|
||||||
gfxSystem->PrepareResize(static_cast<uint32_t>(beginContentRegionAvailable.x), static_cast<uint32_t>(beginContentRegionAvailable.y));
|
|
||||||
|
//beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||||
|
SHVec2 viewportSize = CalculateWindowSize(beginContentRegionAvailable);
|
||||||
|
gfxSystem->PrepareResize(static_cast<uint32_t>(viewportSize.x), static_cast<uint32_t>(viewportSize.y));
|
||||||
shouldUpdateCamera = true;
|
shouldUpdateCamera = true;
|
||||||
|
//if (aspectRatio != AspectRatio::FREE && (ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseReleased(ImGuiMouseButton_Left)))
|
||||||
|
//{
|
||||||
|
// windowSize = CalculateWindowSize(windowSize);
|
||||||
|
// beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||||
|
// ImGui::SetWindowSize(windowName.data(), CalculateWindowSize(windowSize));
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditorViewport::OnPosChange()
|
void SHEditorViewport::OnPosChange()
|
||||||
|
@ -194,13 +204,73 @@ namespace SHADE
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
|
//TODO: Shift to constructor
|
||||||
|
auto arRTTRtype = rttr::type::get<SHEditorViewport::AspectRatio>();
|
||||||
|
auto enumAlign = arRTTRtype.get_enumeration();
|
||||||
|
auto names = enumAlign.get_names();
|
||||||
|
std::vector<const char*> arNames;
|
||||||
|
for (auto const& name : names)
|
||||||
|
{
|
||||||
|
arNames.push_back(name.data());
|
||||||
|
}
|
||||||
|
int currentAR = static_cast<int>(aspectRatio);
|
||||||
|
ImGui::SetNextItemWidth(80.0f);
|
||||||
|
if (ImGui::Combo("Aspect Ratio", ¤tAR, arNames.data(), arNames.size()))
|
||||||
|
{
|
||||||
|
aspectRatio = static_cast<AspectRatio>(currentAR);
|
||||||
|
windowSize = CalculateWindowSize(windowSize);
|
||||||
|
ImGui::SetWindowSize(windowSize);
|
||||||
|
//beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||||
|
//OnResize();
|
||||||
|
}
|
||||||
|
|
||||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
auto editorCamera = camSystem->GetEditorCamera();
|
auto editorCamera = camSystem->GetEditorCamera();
|
||||||
//ImGui::SetNextItemWidth(10.0f);
|
//ImGui::SetNextItemWidth(10.0f);
|
||||||
SHEditorWidgets::SliderFloat("CamSpeed", 0.0f, 5.0f, [editorCamera] {return editorCamera->movementSpeed; }, [editorCamera](float const& value) {editorCamera->movementSpeed = value; });
|
SHEditorWidgets::SliderFloat("CamSpeed", 0.0f, 5.0f, [editorCamera] {return editorCamera->movementSpeed; }, [editorCamera](float const& value) {editorCamera->movementSpeed = value; });
|
||||||
SHEditorWidgets::DragVec3("TurnSpeed", { "X", "Y", "Z" }, [editorCamera] {return editorCamera->turnSpeed; }, [editorCamera](SHVec3 const& value) {editorCamera->turnSpeed = value; });
|
SHEditorWidgets::DragVec3("TurnSpeed", { "X", "Y", "Z" }, [editorCamera] {return editorCamera->turnSpeed; }, [editorCamera](SHVec3 const& value) {editorCamera->turnSpeed = value; });
|
||||||
|
|
||||||
|
//if(ImGui::BeginCombo("Aspect Ratio", arNames[(uint8_t)aspectRatio].data()))
|
||||||
|
//{
|
||||||
|
// auto nameIt = names.begin();
|
||||||
|
// auto valueIt = values.end();
|
||||||
|
// while(nameIt != names.end() && valueIt != values.end())
|
||||||
|
// {
|
||||||
|
// if ImGui::Beg
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHVec2 SHEditorViewport::CalculateWindowSize(SHVec2 const& rhs) noexcept
|
||||||
|
{
|
||||||
|
switch (aspectRatio)
|
||||||
|
{
|
||||||
|
case SHADE::SHEditorViewport::AspectRatio::FREE:
|
||||||
|
return rhs;
|
||||||
|
case SHADE::SHEditorViewport::AspectRatio::AR16_9:
|
||||||
|
return SHVec2(rhs.x, rhs.x * 0.5625f);
|
||||||
|
case SHADE::SHEditorViewport::AspectRatio::AR21_9:
|
||||||
|
return SHVec2(rhs.x, rhs.x * 0.42857f);
|
||||||
|
case SHADE::SHEditorViewport::AspectRatio::AR21_10:
|
||||||
|
return SHVec2(rhs.x, rhs.x * 0.47619f);
|
||||||
|
default:
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
||||||
|
RTTR_REGISTRATION
|
||||||
|
{
|
||||||
|
using namespace rttr;
|
||||||
|
using namespace SHADE;
|
||||||
|
registration::enumeration<SHEditorViewport::AspectRatio>("AspectRatio")(
|
||||||
|
value("FREE", SHEditorViewport::AspectRatio::FREE),
|
||||||
|
value("16:9", SHEditorViewport::AspectRatio::AR16_9),
|
||||||
|
value("21:9", SHEditorViewport::AspectRatio::AR21_9),
|
||||||
|
value("21:10", SHEditorViewport::AspectRatio::AR21_10)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -16,7 +16,15 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
class SHEditorViewport final : public SHEditorWindow
|
class SHEditorViewport final : public SHEditorWindow
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum class AspectRatio : uint8_t
|
||||||
|
{
|
||||||
|
FREE,
|
||||||
|
AR16_9,
|
||||||
|
AR21_9,
|
||||||
|
AR21_10
|
||||||
|
};
|
||||||
SHEditorViewport();
|
SHEditorViewport();
|
||||||
void Init() override;
|
void Init() override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
|
@ -27,9 +35,12 @@ namespace SHADE
|
||||||
void OnPosChange() override;
|
void OnPosChange() override;
|
||||||
private:
|
private:
|
||||||
void DrawMenuBar() noexcept;
|
void DrawMenuBar() noexcept;
|
||||||
SHVec2 beginCursorPos;
|
SHVec2 CalculateWindowSize(SHVec2 const& rhs) noexcept;
|
||||||
|
|
||||||
bool shouldUpdateCamera = false;
|
bool shouldUpdateCamera = false;
|
||||||
bool shouldUpdateCamArm = false;
|
bool shouldUpdateCamArm = false;
|
||||||
|
AspectRatio aspectRatio {AspectRatio::FREE};
|
||||||
|
SHVec2 beginCursorPos;
|
||||||
SHVec3 targetPos;
|
SHVec3 targetPos;
|
||||||
};//class SHEditorViewport
|
};//class SHEditorViewport
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
|
@ -29,4 +29,5 @@ constexpr SHEventIdentifier SH_WINDOW_RESIZE_EVENT { 20 };
|
||||||
constexpr SHEventIdentifier SH_BUTTON_RELEASE_EVENT { 21 };
|
constexpr SHEventIdentifier SH_BUTTON_RELEASE_EVENT { 21 };
|
||||||
constexpr SHEventIdentifier SH_BUTTON_HOVER_ENTER_EVENT { 22 };
|
constexpr SHEventIdentifier SH_BUTTON_HOVER_ENTER_EVENT { 22 };
|
||||||
constexpr SHEventIdentifier SH_BUTTON_HOVER_EXIT_EVENT { 23 };
|
constexpr SHEventIdentifier SH_BUTTON_HOVER_EXIT_EVENT { 23 };
|
||||||
|
constexpr SHEventIdentifier SH_ASSET_COMPILE_EVENT { 24 };
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include "SHpch.h"
|
||||||
|
#include "SHGraphicsGenericData.h"
|
||||||
|
#include "Graphics/Devices/SHVkLogicalDevice.h"
|
||||||
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h"
|
||||||
|
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
|
||||||
|
#include "Graphics/Buffers/SHVkBuffer.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
void SHGraphicsGenericData::Init(Handle<SHVkLogicalDevice> logicalDevice, Handle<SHVkDescriptorSetGroup> descSet) noexcept
|
||||||
|
{
|
||||||
|
alignedGpuStructSize = logicalDevice->PadUBOSize(sizeof (GpuStruct));
|
||||||
|
|
||||||
|
gpuBuffer = logicalDevice->CreateBuffer(alignedGpuStructSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, nullptr, alignedGpuStructSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, "Generic Data");
|
||||||
|
|
||||||
|
std::array gpuBufferArray{ gpuBuffer };
|
||||||
|
|
||||||
|
// We use index 0 because the descriptor set is standalone created from a single desc set layout. What the driver sees is that this set is at index 0 during updating.
|
||||||
|
static constexpr uint8_t SET_0 = 0;
|
||||||
|
|
||||||
|
descSet->ModifyWriteDescBuffer(SET_0, SHGraphicsConstants::DescriptorSetBindings::GENERIC_DATA, std::span<Handle<SHVkBuffer>>{ gpuBufferArray.data(), gpuBufferArray.size()}, 0, sizeof(GpuStruct));
|
||||||
|
|
||||||
|
descSet->UpdateDescriptorSetBuffer(SET_0, SHGraphicsConstants::DescriptorSetBindings::GENERIC_DATA);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsGenericData::UpdateBuffer(uint32_t frameIndex) noexcept
|
||||||
|
{
|
||||||
|
gpuBuffer->WriteToMemory(&data, sizeof(GpuStruct), 0, alignedGpuStructSize * frameIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsGenericData::SetDt(float dt) noexcept
|
||||||
|
{
|
||||||
|
data.dt = dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsGenericData::UpdateElapsedTime(float dt) noexcept
|
||||||
|
{
|
||||||
|
data.elapsedTime += dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsGenericData::SetViewportWidth(uint32_t width) noexcept
|
||||||
|
{
|
||||||
|
data.viewportWidth = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsGenericData::SetViewportHeight(uint32_t height) noexcept
|
||||||
|
{
|
||||||
|
data.viewportHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include "Resource/SHHandle.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
class SHVkDescriptorSetGroup;
|
||||||
|
class SHVkBuffer;
|
||||||
|
class SHVkLogicalDevice;
|
||||||
|
|
||||||
|
class SHGraphicsGenericData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct GpuStruct
|
||||||
|
{
|
||||||
|
//! Delta time
|
||||||
|
float dt{ 0.0f };
|
||||||
|
|
||||||
|
//! Elapsed time of the application
|
||||||
|
float elapsedTime{ 0.0f };
|
||||||
|
|
||||||
|
//! Viewport width of the scene (excluding imgui, that means smaller than window)
|
||||||
|
uint32_t viewportWidth{ 0 };
|
||||||
|
|
||||||
|
//! Ditto but for height
|
||||||
|
uint32_t viewportHeight{ 0 };
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
|
||||||
|
//! This will be access
|
||||||
|
GpuStruct data;
|
||||||
|
|
||||||
|
//! Buffer to hold the generic data
|
||||||
|
Handle<SHVkBuffer> gpuBuffer;
|
||||||
|
|
||||||
|
//! gpu struct size for GPU to use
|
||||||
|
uint32_t alignedGpuStructSize;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Init (Handle<SHVkLogicalDevice> logicalDevice, Handle<SHVkDescriptorSetGroup> descSet) noexcept;
|
||||||
|
void UpdateBuffer(uint32_t frameIndex) noexcept;
|
||||||
|
|
||||||
|
void SetDt (float dt) noexcept;
|
||||||
|
void UpdateElapsedTime (float dt) noexcept;
|
||||||
|
void SetViewportWidth(uint32_t width) noexcept;
|
||||||
|
void SetViewportHeight(uint32_t height) noexcept;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
#include "SHGlobalDescriptorSets.h"
|
#include "SHGlobalDescriptorSets.h"
|
||||||
#include "Graphics/MiddleEnd/Lights/SHLightingSubSystem.h"
|
#include "Graphics/MiddleEnd/Lights/SHLightingSubSystem.h"
|
||||||
#include "Graphics/Commands/SHVkCommandBuffer.h"
|
#include "Graphics/Commands/SHVkCommandBuffer.h"
|
||||||
|
#include "Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.h"
|
||||||
|
#include "Graphics/Devices/SHVkLogicalDevice.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
||||||
Handle<SHVkDescriptorSetGroup> SHGlobalDescriptorSets::staticGlobalDataDescriptorSet;
|
Handle<SHVkDescriptorSetGroup> SHGlobalDescriptorSets::genericAndTextureDataDescSet;
|
||||||
Handle<SHLightingSubSystem> SHGlobalDescriptorSets::lightingSubSystem;
|
Handle<SHLightingSubSystem> SHGlobalDescriptorSets::lightingSubSystem;
|
||||||
|
|
||||||
//void SHGlobalDescriptorSets::BindLightingData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t firstSet) noexcept
|
//void SHGlobalDescriptorSets::BindLightingData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t firstSet) noexcept
|
||||||
|
@ -20,11 +22,13 @@ namespace SHADE
|
||||||
lightingSubSystem->BindDescSet(cmdBuffer, setIndex, frameIndex);
|
lightingSubSystem->BindDescSet(cmdBuffer, setIndex, frameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHGlobalDescriptorSets::BindStaticGlobalData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept
|
void SHGlobalDescriptorSets::BindGenericAndTextureData(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept
|
||||||
{
|
{
|
||||||
|
uint32_t alignedGenericStructSize = device->PadUBOSize(sizeof(SHGraphicsGenericData::GpuStruct));
|
||||||
|
|
||||||
// Bind descriptor set for static global data
|
// Bind descriptor set for static global data
|
||||||
static std::array<uint32_t, 1> TEX_DYNAMIC_OFFSET{ 0 };
|
static std::array TEX_DYNAMIC_OFFSET = { alignedGenericStructSize, };
|
||||||
cmdBuffer->BindDescriptorSet(staticGlobalDataDescriptorSet, pipelineType, setIndex, std::span{ TEX_DYNAMIC_OFFSET.data(), 1 });
|
cmdBuffer->BindDescriptorSet(genericAndTextureDataDescSet, pipelineType, setIndex, std::span{ TEX_DYNAMIC_OFFSET.data(), 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
@ -43,9 +47,9 @@ namespace SHADE
|
||||||
lightingSubSystem = system;
|
lightingSubSystem = system;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(Handle<SHVkDescriptorSetGroup> staticGlobalDescSet) noexcept
|
void SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(Handle<SHVkDescriptorSetGroup> descSet) noexcept
|
||||||
{
|
{
|
||||||
staticGlobalDataDescriptorSet = staticGlobalDescSet;
|
genericAndTextureDataDescSet = descSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ namespace SHADE
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Static global descriptor sets for miscellaneous data and textures
|
//! Static global descriptor sets for miscellaneous data and textures
|
||||||
static Handle<SHVkDescriptorSetGroup> staticGlobalDataDescriptorSet;
|
static Handle<SHVkDescriptorSetGroup> genericAndTextureDataDescSet;
|
||||||
|
|
||||||
//! Lighting sub system required to get information to bind descriptor sets for light data
|
//! Lighting sub system required to get information to bind descriptor sets for light data
|
||||||
static Handle<SHLightingSubSystem> lightingSubSystem;
|
static Handle<SHLightingSubSystem> lightingSubSystem;
|
||||||
|
@ -25,7 +25,7 @@ namespace SHADE
|
||||||
/* PUBLIC MEMBER FUNCTIONS */
|
/* PUBLIC MEMBER FUNCTIONS */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
static void BindLightingData (Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept;
|
static void BindLightingData (Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept;
|
||||||
static void BindStaticGlobalData (Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept;
|
static void BindGenericAndTextureData (Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* SETTERS AND GETTERS */
|
/* SETTERS AND GETTERS */
|
||||||
|
|
|
@ -25,9 +25,10 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descMappings.AddMappings
|
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descMappings.AddMappings
|
||||||
({
|
({
|
||||||
{SHPredefinedDescriptorTypes::STATIC_DATA, 0},
|
{SHPredefinedDescriptorTypes::STATIC_DATA, 0},
|
||||||
{SHPredefinedDescriptorTypes::CAMERA, 1},
|
{SHPredefinedDescriptorTypes::CAMERA, 1},
|
||||||
{SHPredefinedDescriptorTypes::PER_INSTANCE_BATCH, 2},
|
{SHPredefinedDescriptorTypes::PER_INSTANCE_BATCH, 2},
|
||||||
|
{SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE, 3},
|
||||||
});
|
});
|
||||||
|
|
||||||
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING_ANIM)].descMappings.AddMappings
|
perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING_ANIM)].descMappings.AddMappings
|
||||||
|
|
|
@ -129,11 +129,13 @@ namespace SHADE
|
||||||
static constexpr std::string_view GBUFFER_WRITE_SUBPASS = "G-Buffer Write";
|
static constexpr std::string_view GBUFFER_WRITE_SUBPASS = "G-Buffer Write";
|
||||||
static constexpr std::string_view UI_SUBPASS = "UI";
|
static constexpr std::string_view UI_SUBPASS = "UI";
|
||||||
static constexpr std::string_view VFX_SUBPASS = "VFX";
|
static constexpr std::string_view VFX_SUBPASS = "VFX";
|
||||||
|
static constexpr std::string_view OBJ_VFX_SUBPASS = "Object VFX Subpass No Depth";
|
||||||
|
|
||||||
static constexpr std::array USABLE_SUBPASSES =
|
static constexpr std::array USABLE_SUBPASSES =
|
||||||
{
|
{
|
||||||
GBUFFER_WRITE_SUBPASS,
|
GBUFFER_WRITE_SUBPASS,
|
||||||
UI_SUBPASS
|
UI_SUBPASS,
|
||||||
|
OBJ_VFX_SUBPASS
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Events/SHEvent.h"
|
#include "Events/SHEvent.h"
|
||||||
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
|
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
|
||||||
#include "Input/SHInputManager.h"
|
#include "Input/SHInputManager.h"
|
||||||
|
#include "Assets/Events/SHAssetManagerEvents.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -210,10 +211,11 @@ namespace SHADE
|
||||||
renderGraph->Init("World Render Graph", device, swapchain, &resourceManager, renderContextCmdPools);
|
renderGraph->Init("World Render Graph", device, swapchain, &resourceManager, renderContextCmdPools);
|
||||||
renderGraph->AddResource("Position", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
renderGraph->AddResource("Position", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
||||||
renderGraph->AddResource("Position World Space", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
renderGraph->AddResource("Position World Space", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
||||||
|
renderGraph->AddResource("Object VFX", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
||||||
renderGraph->AddResource("Normals", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
renderGraph->AddResource("Normals", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
||||||
//worldRenderGraph->AddResource("Tangents", { SH_ATT_DESC_TYPE_FLAGS::COLOR, SH_ATT_DESC_TYPE_FLAGS::INPUT, SH_ATT_DESC_TYPE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
//worldRenderGraph->AddResource("Tangents", { SH_ATT_DESC_TYPE_FLAGS::COLOR, SH_ATT_DESC_TYPE_FLAGS::INPUT, SH_ATT_DESC_TYPE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
||||||
renderGraph->AddResource("Albedo", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second);
|
renderGraph->AddResource("Albedo", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second);
|
||||||
renderGraph->AddResource("Depth Buffer", { SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL }, true, windowDims.first, windowDims.second, vk::Format::eD32SfloatS8Uint);
|
renderGraph->AddResource("Depth Buffer", { SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT }, true, windowDims.first, windowDims.second, vk::Format::eD32SfloatS8Uint);
|
||||||
renderGraph->AddResource("Entity ID", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc);
|
renderGraph->AddResource("Entity ID", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc);
|
||||||
renderGraph->AddResource("Light Layer Indices", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc);
|
renderGraph->AddResource("Light Layer Indices", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc);
|
||||||
renderGraph->AddResource("Scene", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second);
|
renderGraph->AddResource("Scene", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second);
|
||||||
|
@ -235,7 +237,8 @@ namespace SHADE
|
||||||
"Depth Buffer",
|
"Depth Buffer",
|
||||||
"SSAO",
|
"SSAO",
|
||||||
"SSAO Blur",
|
"SSAO Blur",
|
||||||
"Position World Space"
|
"Position World Space",
|
||||||
|
"Object VFX"
|
||||||
},
|
},
|
||||||
{}); // no predecessors
|
{}); // no predecessors
|
||||||
|
|
||||||
|
@ -249,9 +252,16 @@ namespace SHADE
|
||||||
gBufferSubpass->AddColorOutput("Normals");
|
gBufferSubpass->AddColorOutput("Normals");
|
||||||
gBufferSubpass->AddColorOutput("Albedo");
|
gBufferSubpass->AddColorOutput("Albedo");
|
||||||
gBufferSubpass->AddColorOutput("Position World Space");
|
gBufferSubpass->AddColorOutput("Position World Space");
|
||||||
|
gBufferSubpass->AddColorOutput("Object VFX");
|
||||||
gBufferSubpass->AddDepthOutput("Depth Buffer", SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL);
|
gBufferSubpass->AddDepthOutput("Depth Buffer", SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL);
|
||||||
|
|
||||||
usableSubpassesMapping.emplace (std::string (SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data()), gBufferSubpass);
|
// We add the object VFX render target and depth buffer as input just in case we want to make comparisons
|
||||||
|
auto objectVfxSubpassNoDepth = gBufferNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::OBJ_VFX_SUBPASS.data(), worldViewport, worldRenderer);
|
||||||
|
objectVfxSubpassNoDepth->AddColorOutput("Object VFX");
|
||||||
|
objectVfxSubpassNoDepth->AddInput ("Depth Buffer");
|
||||||
|
|
||||||
|
usableSubpassesMapping.emplace(std::string(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data()), gBufferSubpass);
|
||||||
|
usableSubpassesMapping.emplace(std::string(SHGraphicsConstants::RenderGraphEntityNames::OBJ_VFX_SUBPASS.data()), objectVfxSubpassNoDepth);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* SSAO PASS AND DATA INIT */
|
/* SSAO PASS AND DATA INIT */
|
||||||
|
@ -297,15 +307,15 @@ namespace SHADE
|
||||||
"Albedo",
|
"Albedo",
|
||||||
"Scene",
|
"Scene",
|
||||||
"SSAO Blur",
|
"SSAO Blur",
|
||||||
"Position World Space"
|
"Position World Space",
|
||||||
|
"Object VFX"
|
||||||
},
|
},
|
||||||
{ SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS .data()});
|
{ SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS .data()});
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* DEFERRED COMPOSITE SUBPASS INIT */
|
/* DEFERRED COMPOSITE SUBPASS INIT */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
auto deferredCompositeCompute = deferredCompositeNode->AddNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_COMPUTE.data(), deferredCompositeShader, {"Position", "Normals", "Albedo", "Light Layer Indices", "SSAO Blur", "Position World Space", "Scene"}, {}, SHLightingSubSystem::MAX_SHADOWS);
|
auto deferredCompositeCompute = deferredCompositeNode->AddNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_COMPUTE.data(), deferredCompositeShader, {"Position", "Normals", "Albedo", "Light Layer Indices", "SSAO Blur", "Position World Space", "Scene", "Object VFX"}, {}, SHLightingSubSystem::MAX_SHADOWS);
|
||||||
deferredCompositeCompute->AddPreComputeFunction([=](Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex)
|
deferredCompositeCompute->AddPreComputeFunction([=](Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex)
|
||||||
{
|
{
|
||||||
lightingSubSystem->PrepareShadowMapsForRead(cmdBuffer);
|
lightingSubSystem->PrepareShadowMapsForRead(cmdBuffer);
|
||||||
|
@ -409,7 +419,6 @@ namespace SHADE
|
||||||
|
|
||||||
InitRenderGraph();
|
InitRenderGraph();
|
||||||
|
|
||||||
|
|
||||||
// Create Semaphore
|
// Create Semaphore
|
||||||
for (auto& semaHandle : graphSemaphores)
|
for (auto& semaHandle : graphSemaphores)
|
||||||
{
|
{
|
||||||
|
@ -491,12 +500,34 @@ namespace SHADE
|
||||||
|
|
||||||
void SHGraphicsSystem::InitEvents(void) noexcept
|
void SHGraphicsSystem::InitEvents(void) noexcept
|
||||||
{
|
{
|
||||||
std::shared_ptr<SHEventReceiverSpec<SHGraphicsSystem>> thisReceiver
|
std::shared_ptr<SHEventReceiverSpec<SHGraphicsSystem>> lightEnableShadowReceiver
|
||||||
{
|
{
|
||||||
std::make_shared<SHEventReceiverSpec<SHGraphicsSystem>>(this, &SHGraphicsSystem::ReceiveLightEnableShadowEvent)
|
std::make_shared<SHEventReceiverSpec<SHGraphicsSystem>>(this, &SHGraphicsSystem::ReceiveLightEnableShadowEvent)
|
||||||
};
|
};
|
||||||
ReceiverPtr receiver = std::dynamic_pointer_cast<SHEventReceiver>(thisReceiver);
|
ReceiverPtr lightEnableShadowReceivePtr = std::dynamic_pointer_cast<SHEventReceiver>(lightEnableShadowReceiver);
|
||||||
SHEventManager::SubscribeTo(SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT, receiver);
|
SHEventManager::SubscribeTo(SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT, lightEnableShadowReceivePtr);
|
||||||
|
|
||||||
|
std::shared_ptr<SHEventReceiverSpec<SHGraphicsSystem>> compileAssetReceiever
|
||||||
|
{
|
||||||
|
std::make_shared<SHEventReceiverSpec<SHGraphicsSystem>>(this, &SHGraphicsSystem::ReceiveCompileAssetEvent)
|
||||||
|
};
|
||||||
|
ReceiverPtr compileAssetReceivePtr = std::dynamic_pointer_cast<SHEventReceiver>(compileAssetReceiever);
|
||||||
|
SHEventManager::SubscribeTo(SH_ASSET_COMPILE_EVENT, compileAssetReceivePtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsSystem::InitGenericDataAndTexturesDescSet(void) noexcept
|
||||||
|
{
|
||||||
|
// descriptor set for generic data and textures
|
||||||
|
genericAndTextureDescSet = descPool->Allocate(SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA), { SHTextureLibrary::DEFAULT_MAX_TEXTURES });
|
||||||
|
|
||||||
|
for (auto set : genericAndTextureDescSet->GetVkHandle())
|
||||||
|
SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals");
|
||||||
|
|
||||||
|
SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(genericAndTextureDescSet);
|
||||||
|
|
||||||
|
// Create buffer for generic data and attach to descriptor set
|
||||||
|
graphicsGenericData.Init(device, genericAndTextureDescSet);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -507,6 +538,7 @@ namespace SHADE
|
||||||
InitBoilerplate();
|
InitBoilerplate();
|
||||||
InitMiddleEnd();
|
InitMiddleEnd();
|
||||||
InitSubsystems();
|
InitSubsystems();
|
||||||
|
InitGenericDataAndTexturesDescSet();
|
||||||
InitBuiltInResources();
|
InitBuiltInResources();
|
||||||
InitEvents();
|
InitEvents();
|
||||||
}
|
}
|
||||||
|
@ -536,7 +568,7 @@ namespace SHADE
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
void SHGraphicsSystem::Run(double) noexcept
|
void SHGraphicsSystem::Run(double dt) noexcept
|
||||||
{
|
{
|
||||||
if (window->IsMinimized() || renderContext.GetWindowIsDead())
|
if (window->IsMinimized() || renderContext.GetWindowIsDead())
|
||||||
{
|
{
|
||||||
|
@ -572,6 +604,9 @@ namespace SHADE
|
||||||
|
|
||||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
|
|
||||||
|
graphicsGenericData.SetDt(dt);
|
||||||
|
graphicsGenericData.UpdateElapsedTime(dt);
|
||||||
|
graphicsGenericData.UpdateBuffer(frameIndex);
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
|
@ -860,6 +895,29 @@ namespace SHADE
|
||||||
return eventPtr->handle;
|
return eventPtr->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHEventHandle SHGraphicsSystem::ReceiveCompileAssetEvent(SHEventPtr eventPtr) noexcept
|
||||||
|
{
|
||||||
|
auto const& EVENT_DATA = reinterpret_cast<const SHEventSpec<SHCompileAssetEvent>*>(eventPtr.get())->data;
|
||||||
|
|
||||||
|
// check for asset type
|
||||||
|
if (EVENT_DATA->assetType == AssetType::SHADER)
|
||||||
|
{
|
||||||
|
// loop through all shaders
|
||||||
|
auto denseIterators = SHVkInstance::GetResourceManager().GetDenseAccess<SHVkShaderModule>();
|
||||||
|
for (auto it = denseIterators.first; it != denseIterators.second; ++it)
|
||||||
|
{
|
||||||
|
if (it->GetName() == EVENT_DATA->assetName)
|
||||||
|
{
|
||||||
|
auto* shaderAsset = SHAssetManager::GetData<SHShaderAsset>(EVENT_DATA->assetID);
|
||||||
|
it->OnChange(shaderAsset->spirvBinary);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return eventPtr->handle;
|
||||||
|
}
|
||||||
|
|
||||||
Handle<SHMaterial> SHGraphicsSystem::AddMaterial(Handle<SHVkShaderModule> vertShader, Handle<SHVkShaderModule> fragShader, Handle<SHSubpass> subpass)
|
Handle<SHMaterial> SHGraphicsSystem::AddMaterial(Handle<SHVkShaderModule> vertShader, Handle<SHVkShaderModule> fragShader, Handle<SHSubpass> subpass)
|
||||||
{
|
{
|
||||||
// Retrieve pipeline from pipeline storage or create if unavailable
|
// Retrieve pipeline from pipeline storage or create if unavailable
|
||||||
|
@ -980,12 +1038,11 @@ namespace SHADE
|
||||||
device->WaitIdle();
|
device->WaitIdle();
|
||||||
texLibrary.BuildTextures
|
texLibrary.BuildTextures
|
||||||
(
|
(
|
||||||
device, graphicsTexCmdBuffer, graphicsQueue, descPool
|
device, graphicsTexCmdBuffer, graphicsQueue, genericAndTextureDescSet
|
||||||
);
|
);
|
||||||
device->WaitIdle();
|
device->WaitIdle();
|
||||||
graphicsTexCmdBuffer.Free(); graphicsTexCmdBuffer = {};
|
graphicsTexCmdBuffer.Free(); graphicsTexCmdBuffer = {};
|
||||||
SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(texLibrary.GetTextureDescriptorSetGroup());
|
//SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(texLibrary.GetTextureDescriptorSetGroup());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle<SHTexture> SHGraphicsSystem::GetTextureHandle(SHTexture::Index textureId) const
|
Handle<SHTexture> SHGraphicsSystem::GetTextureHandle(SHTexture::Index textureId) const
|
||||||
|
@ -1134,6 +1191,10 @@ namespace SHADE
|
||||||
resizeWidth = newWidth;
|
resizeWidth = newWidth;
|
||||||
resizeHeight = newHeight;
|
resizeHeight = newHeight;
|
||||||
|
|
||||||
|
graphicsGenericData.SetViewportWidth(resizeWidth);
|
||||||
|
graphicsGenericData.SetViewportHeight(resizeHeight);
|
||||||
|
|
||||||
|
|
||||||
renderContext.SetIsResized(true);
|
renderContext.SetIsResized(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1177,7 +1238,7 @@ namespace SHADE
|
||||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
cameraSystem->GetEditorCamera()->SetWidth(static_cast<float>(resizeWidth));
|
cameraSystem->GetEditorCamera()->SetWidth(static_cast<float>(resizeWidth));
|
||||||
cameraSystem->GetEditorCamera()->SetHeight(static_cast<float>(resizeHeight));
|
//cameraSystem->GetEditorCamera()->SetAspectRatio(static_cast<float>(resizeWidth) / static_cast<float>(resizeHeight));
|
||||||
|
|
||||||
// Create new event and broadcast it
|
// Create new event and broadcast it
|
||||||
SHWindowResizeEvent newEvent;
|
SHWindowResizeEvent newEvent;
|
||||||
|
@ -1186,8 +1247,14 @@ namespace SHADE
|
||||||
|
|
||||||
SHEventManager::BroadcastEvent<SHWindowResizeEvent>(newEvent, SH_WINDOW_RESIZE_EVENT);
|
SHEventManager::BroadcastEvent<SHWindowResizeEvent>(newEvent, SH_WINDOW_RESIZE_EVENT);
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
// Create new event and broadcast it
|
||||||
|
SHWindowResizeEvent newEvent;
|
||||||
|
newEvent.resizeWidth = resizeWidth;
|
||||||
|
newEvent.resizeHeight = resizeHeight;
|
||||||
|
|
||||||
|
SHEventManager::BroadcastEvent<SHWindowResizeEvent>(newEvent, SH_WINDOW_RESIZE_EVENT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
||||||
#include "Graphics/Events/SHGraphicsEvents.h"
|
#include "Graphics/Events/SHGraphicsEvents.h"
|
||||||
#include "Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.h"
|
#include "Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.h"
|
||||||
|
#include "Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -106,6 +107,7 @@ namespace SHADE
|
||||||
void InitSubsystems (void) noexcept;
|
void InitSubsystems (void) noexcept;
|
||||||
void InitBuiltInResources (void);
|
void InitBuiltInResources (void);
|
||||||
void InitEvents (void) noexcept;
|
void InitEvents (void) noexcept;
|
||||||
|
void InitGenericDataAndTexturesDescSet (void) noexcept;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class SH_API BeginRoutine final : public SHSystemRoutine
|
class SH_API BeginRoutine final : public SHSystemRoutine
|
||||||
|
@ -181,6 +183,11 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
SHEventHandle ReceiveLightEnableShadowEvent (SHEventPtr eventPtr) noexcept;
|
SHEventHandle ReceiveLightEnableShadowEvent (SHEventPtr eventPtr) noexcept;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Asset Events */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
SHEventHandle ReceiveCompileAssetEvent (SHEventPtr eventPtr) noexcept;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Material Functions */
|
/* Material Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -433,6 +440,7 @@ namespace SHADE
|
||||||
SHResourceHub resourceManager;
|
SHResourceHub resourceManager;
|
||||||
SHMeshLibrary meshLibrary;
|
SHMeshLibrary meshLibrary;
|
||||||
SHTextureLibrary texLibrary;
|
SHTextureLibrary texLibrary;
|
||||||
|
SHGraphicsGenericData graphicsGenericData;
|
||||||
SHFontLibrary fontLibrary;
|
SHFontLibrary fontLibrary;
|
||||||
SHSamplerCache samplerCache;
|
SHSamplerCache samplerCache;
|
||||||
SHMaterialInstanceCache materialInstanceCache;
|
SHMaterialInstanceCache materialInstanceCache;
|
||||||
|
@ -490,6 +498,8 @@ namespace SHADE
|
||||||
Handle<SHVkPipeline> debugDrawFilledDepthPipeline;
|
Handle<SHVkPipeline> debugDrawFilledDepthPipeline;
|
||||||
Handle<SHVkPipeline> shadowMapPipeline; // initialized only when a shadow map is needed
|
Handle<SHVkPipeline> shadowMapPipeline; // initialized only when a shadow map is needed
|
||||||
|
|
||||||
|
Handle<SHVkDescriptorSetGroup> genericAndTextureDescSet;
|
||||||
|
|
||||||
// Built-In Textures
|
// Built-In Textures
|
||||||
Handle<SHTexture> defaultTexture;
|
Handle<SHTexture> defaultTexture;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h"
|
#include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h"
|
||||||
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
||||||
#include "Scene/SHSceneManager.h"
|
#include "Scene/SHSceneManager.h"
|
||||||
|
#include "UI/SHUIComponent.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -197,7 +198,7 @@ namespace SHADE
|
||||||
cmdBuffer->BindPipeline(pipeline);
|
cmdBuffer->BindPipeline(pipeline);
|
||||||
|
|
||||||
// Bind global data
|
// Bind global data
|
||||||
SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex);
|
SHGlobalDescriptorSets::BindGenericAndTextureData(logicalDevice, cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex, frameIndex);
|
||||||
|
|
||||||
// Bind camera data
|
// Bind camera data
|
||||||
renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex);
|
renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex);
|
||||||
|
@ -209,7 +210,12 @@ namespace SHADE
|
||||||
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::CALCULATED_GLYPH_POSITION, comp.charPositionDataBuffer, 0);
|
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::CALCULATED_GLYPH_POSITION, comp.charPositionDataBuffer, 0);
|
||||||
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::GLYPH_INDEX, comp.indexingDataBuffer, 0);
|
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::GLYPH_INDEX, comp.indexingDataBuffer, 0);
|
||||||
|
|
||||||
cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", transform->GetTRS(), SH_PIPELINE_TYPE::GRAPHICS);
|
if (auto* uiComp = SHComponentManager::GetComponent_s<SHUIComponent>(comp.GetEID()))
|
||||||
|
cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", uiComp->GetMatrix(), SH_PIPELINE_TYPE::GRAPHICS);
|
||||||
|
else
|
||||||
|
cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", transform->GetTRS(), SH_PIPELINE_TYPE::GRAPHICS);
|
||||||
|
|
||||||
|
|
||||||
cmdBuffer->SetPushConstantVariable("TestPushConstant.eid", comp.GetEID(), SH_PIPELINE_TYPE::GRAPHICS);
|
cmdBuffer->SetPushConstantVariable("TestPushConstant.eid", comp.GetEID(), SH_PIPELINE_TYPE::GRAPHICS);
|
||||||
cmdBuffer->SetPushConstantVariable("TestPushConstant.textColor", SHVec3 (1.0f, 1.0f, 1.0f), SH_PIPELINE_TYPE::GRAPHICS);
|
cmdBuffer->SetPushConstantVariable("TestPushConstant.textColor", SHVec3 (1.0f, 1.0f, 1.0f), SH_PIPELINE_TYPE::GRAPHICS);
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace SHADE
|
||||||
isDirty = true;
|
isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHTextureLibrary::BuildTextures(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkQueue> graphicsQueue, Handle<SHVkDescriptorPool> descPool)
|
void SHTextureLibrary::BuildTextures(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkQueue> graphicsQueue, Handle<SHVkDescriptorSetGroup> descSet/*, Handle<SHVkDescriptorPool> descPool*/)
|
||||||
{
|
{
|
||||||
// Don't do anything if there are no updates
|
// Don't do anything if there are no updates
|
||||||
if (!isDirty)
|
if (!isDirty)
|
||||||
|
@ -162,27 +162,28 @@ namespace SHADE
|
||||||
/* Build Descriptor Set with all the Textures only if there are textures */
|
/* Build Descriptor Set with all the Textures only if there are textures */
|
||||||
if (!texOrder.empty())
|
if (!texOrder.empty())
|
||||||
{
|
{
|
||||||
if (texDescriptors)
|
|
||||||
{
|
// if (descSet)
|
||||||
texDescriptors.Free();
|
// {
|
||||||
}
|
// descSet.Free();
|
||||||
texDescriptors = descPool->Allocate
|
// }
|
||||||
(
|
// descSet = descPool->Allocate
|
||||||
{ SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA) },
|
// (
|
||||||
{ static_cast<uint32_t>(texOrder.size()) }
|
// { SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA) },
|
||||||
);
|
// { static_cast<uint32_t>(texOrder.size()) }
|
||||||
#ifdef _DEBUG
|
// );
|
||||||
for (auto set : texDescriptors->GetVkHandle())
|
//#ifdef _DEBUG
|
||||||
SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals");
|
// for (auto set : descSet->GetVkHandle())
|
||||||
#endif
|
// SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals");
|
||||||
|
//#endif
|
||||||
static constexpr uint32_t TEX_DESCRIPTOR_SET_INDEX = 0;
|
static constexpr uint32_t TEX_DESCRIPTOR_SET_INDEX = 0;
|
||||||
texDescriptors->ModifyWriteDescImage
|
descSet->ModifyWriteDescImage
|
||||||
(
|
(
|
||||||
TEX_DESCRIPTOR_SET_INDEX,
|
TEX_DESCRIPTOR_SET_INDEX,
|
||||||
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA,
|
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA,
|
||||||
combinedImageSamplers
|
combinedImageSamplers
|
||||||
);
|
);
|
||||||
texDescriptors->UpdateDescriptorSetImages
|
descSet->UpdateDescriptorSetImages
|
||||||
(
|
(
|
||||||
TEX_DESCRIPTOR_SET_INDEX,
|
TEX_DESCRIPTOR_SET_INDEX,
|
||||||
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA
|
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA
|
||||||
|
|
|
@ -66,6 +66,13 @@ namespace SHADE
|
||||||
class SHTextureLibrary
|
class SHTextureLibrary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! This exists because a poor decision was made to place the textures and
|
||||||
|
//! generic data as 2 bindings in a single layout. Because of this, the recreation
|
||||||
|
//! of the texture library would mean the recreation of the desc set that also
|
||||||
|
//! involves the generic data, which is bad bad bad. Solution is to separate the
|
||||||
|
//! 2 desc sets.
|
||||||
|
static constexpr uint32_t DEFAULT_MAX_TEXTURES = 2000;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -112,7 +119,7 @@ namespace SHADE
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
\brief
|
\brief
|
||||||
Finalises all changes to the Texture Library into the GPU buffers.
|
Finalizes all changes to the Texture Library into the GPU buffers.
|
||||||
|
|
||||||
\param device
|
\param device
|
||||||
Device used to create and update the buffers.
|
Device used to create and update the buffers.
|
||||||
|
@ -123,12 +130,12 @@ namespace SHADE
|
||||||
queue.
|
queue.
|
||||||
*/
|
*/
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
void BuildTextures(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkQueue> graphicsQueue, Handle<SHVkDescriptorPool> descPool);
|
void BuildTextures(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkQueue> graphicsQueue, Handle<SHVkDescriptorSetGroup> descSet/*, Handle<SHVkDescriptorPool> descPool*/);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Getter Functions */
|
/* Getter Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
Handle<SHVkDescriptorSetGroup> GetTextureDescriptorSetGroup() const noexcept { return texDescriptors; }
|
//Handle<SHVkDescriptorSetGroup> GetTextureDescriptorSetGroup() const noexcept { return descSet; }
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
|
@ -173,8 +180,8 @@ namespace SHADE
|
||||||
std::vector<Handle<SHTexture>> texOrder;
|
std::vector<Handle<SHTexture>> texOrder;
|
||||||
// CPU Storage
|
// CPU Storage
|
||||||
std::vector<std::tuple<Handle<SHVkImageView>, Handle<SHVkSampler>, vk::ImageLayout>> combinedImageSamplers;
|
std::vector<std::tuple<Handle<SHVkImageView>, Handle<SHVkSampler>, vk::ImageLayout>> combinedImageSamplers;
|
||||||
// GPU Storage
|
//// GPU Storage
|
||||||
Handle<SHVkDescriptorSetGroup> texDescriptors;
|
//Handle<SHVkDescriptorSetGroup> descSet;
|
||||||
// Flags
|
// Flags
|
||||||
bool isDirty = true;
|
bool isDirty = true;
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ namespace SHADE
|
||||||
cmdBuffer->BindPipeline(pipeline);
|
cmdBuffer->BindPipeline(pipeline);
|
||||||
|
|
||||||
// Bind global data
|
// Bind global data
|
||||||
SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex);
|
SHGlobalDescriptorSets::BindGenericAndTextureData(logicalDevice, cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex, frameIndex);
|
||||||
|
|
||||||
// Bind camera data
|
// Bind camera data
|
||||||
renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex);
|
renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex);
|
||||||
|
|
|
@ -235,6 +235,9 @@ namespace SHADE
|
||||||
, pipelineLayout { inPipelineLayout }
|
, pipelineLayout { inPipelineLayout }
|
||||||
, created {false}
|
, created {false}
|
||||||
{
|
{
|
||||||
|
if (pipelineLayout)
|
||||||
|
pipelineLayout->AddCallback([this]() {ConstructPipeline();});
|
||||||
|
|
||||||
// We want to create a pipeline
|
// We want to create a pipeline
|
||||||
if (state != nullptr)
|
if (state != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -359,7 +362,10 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
// if it was created before, destroy it
|
// if it was created before, destroy it
|
||||||
if (created)
|
if (created)
|
||||||
|
{
|
||||||
|
logicalDeviceHdl->WaitIdle();
|
||||||
logicalDeviceHdl->GetVkLogicalDevice().destroyPipeline(vkPipeline, nullptr);
|
logicalDeviceHdl->GetVkLogicalDevice().destroyPipeline(vkPipeline, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
// Set to false again. If creation succeeds after this, this will be true
|
// Set to false again. If creation succeeds after this, this will be true
|
||||||
created = false;
|
created = false;
|
||||||
|
|
|
@ -298,6 +298,10 @@ namespace SHADE
|
||||||
|
|
||||||
descriptorSetLayoutsAllocate.clear();
|
descriptorSetLayoutsAllocate.clear();
|
||||||
|
|
||||||
|
dynamicBufferBindings.clear();
|
||||||
|
|
||||||
|
descriptorSetLayoutsPipeline.clear();
|
||||||
|
|
||||||
// We don't need to use vulkan to destroy descriptor sets here since they are just owned by the container with handles
|
// We don't need to use vulkan to destroy descriptor sets here since they are just owned by the container with handles
|
||||||
vkDescriptorSetLayoutsAllocate.clear();
|
vkDescriptorSetLayoutsAllocate.clear();
|
||||||
vkDescriptorSetLayoutsPipeline.clear();
|
vkDescriptorSetLayoutsPipeline.clear();
|
||||||
|
@ -450,6 +454,15 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SHVulkanDebugUtil::ReportVkSuccess("Successfully created Pipeline Layout. ");
|
SHVulkanDebugUtil::ReportVkSuccess("Successfully created Pipeline Layout. ");
|
||||||
|
|
||||||
|
// Call callbacks
|
||||||
|
for (auto& callback : onChangeCallbacks)
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHVkPipelineLayout::AddCallback(ChangeCallback&& callback) noexcept
|
||||||
|
{
|
||||||
|
onChangeCallbacks.emplace_back(std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Handle<SHVkShaderModule>> const& SHVkPipelineLayout::GetShaderModules(void) const noexcept
|
std::vector<Handle<SHVkShaderModule>> const& SHVkPipelineLayout::GetShaderModules(void) const noexcept
|
||||||
|
|
|
@ -10,6 +10,9 @@ namespace SHADE
|
||||||
|
|
||||||
class SHVkPipelineLayout
|
class SHVkPipelineLayout
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
using ChangeCallback = std::function<void()>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* PRIVATE MEMBER VARIABLES */
|
/* PRIVATE MEMBER VARIABLES */
|
||||||
|
@ -51,6 +54,12 @@ namespace SHADE
|
||||||
//! Store for pipeline layout recreation
|
//! Store for pipeline layout recreation
|
||||||
std::vector<vk::DescriptorSetLayout> vkDescriptorSetLayoutsPipeline;
|
std::vector<vk::DescriptorSetLayout> vkDescriptorSetLayoutsPipeline;
|
||||||
|
|
||||||
|
//! When pipeline layout needs to be recreated, this container could serve as an event
|
||||||
|
//! response to call all the functions that need to be called. Specifically
|
||||||
|
//! pipelines that need to use the new pipeline layout
|
||||||
|
std::vector<ChangeCallback> onChangeCallbacks;
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* PRIVATE MEMBER FUNCTIONS */
|
/* PRIVATE MEMBER FUNCTIONS */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
@ -73,6 +82,7 @@ namespace SHADE
|
||||||
/* PUBLIC MEMBER FUNCTIONS */
|
/* PUBLIC MEMBER FUNCTIONS */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
void RecreateIfNeeded (void) noexcept;
|
void RecreateIfNeeded (void) noexcept;
|
||||||
|
void AddCallback(ChangeCallback&& callback) noexcept;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* SETTERS AND GETTERS */
|
/* SETTERS AND GETTERS */
|
||||||
|
|
|
@ -512,8 +512,9 @@ namespace SHADE
|
||||||
uint32_t h = static_cast<uint32_t>(resource->GetHeight());
|
uint32_t h = static_cast<uint32_t>(resource->GetHeight());
|
||||||
cmdBuffer->SetViewportScissor(static_cast<float>(w), static_cast<float>(h), w, h);
|
cmdBuffer->SetViewportScissor(static_cast<float>(w), static_cast<float>(h), w, h);
|
||||||
|
|
||||||
static constexpr uint32_t INPUT_IMAGE_SET_INDEX = 0;
|
//static constexpr uint32_t INPUT_IMAGE_SET_INDEX = 0;
|
||||||
newSubpass->BindInputDescriptorSets (cmdBuffer, INPUT_IMAGE_SET_INDEX, frameIndex);
|
auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
|
||||||
|
newSubpass->BindInputDescriptorSets (cmdBuffer, mappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE), frameIndex);
|
||||||
|
|
||||||
// draw a quad.
|
// draw a quad.
|
||||||
cmdBuffer->DrawArrays(4, 1, 0, 0);
|
cmdBuffer->DrawArrays(4, 1, 0, 0);
|
||||||
|
@ -570,7 +571,8 @@ namespace SHADE
|
||||||
auto cmdBuffer = commandBuffers[frameIndex];
|
auto cmdBuffer = commandBuffers[frameIndex];
|
||||||
cmdBuffer->BeginLabeledSegment(name);
|
cmdBuffer->BeginLabeledSegment(name);
|
||||||
|
|
||||||
auto batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING);
|
auto const& batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING);
|
||||||
|
|
||||||
|
|
||||||
// Force bind pipeline layout
|
// Force bind pipeline layout
|
||||||
cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS);
|
cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS);
|
||||||
|
@ -584,7 +586,7 @@ namespace SHADE
|
||||||
if (node->renderpass)
|
if (node->renderpass)
|
||||||
{
|
{
|
||||||
// bind static global data
|
// bind static global data
|
||||||
SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA));
|
SHGlobalDescriptorSets::BindGenericAndTextureData(renderGraphStorage->logicalDevice, cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA), frameIndex);
|
||||||
|
|
||||||
// Bind all the buffers required for meshes
|
// Bind all the buffers required for meshes
|
||||||
for (auto& [buffer, bindingPoint] : MESH_DATA)
|
for (auto& [buffer, bindingPoint] : MESH_DATA)
|
||||||
|
|
|
@ -184,12 +184,13 @@ namespace SHADE
|
||||||
for (auto& inputAtt : subpass->inputReferences)
|
for (auto& inputAtt : subpass->inputReferences)
|
||||||
{
|
{
|
||||||
auto resource = attResources[inputAtt.attachment];
|
auto resource = attResources[inputAtt.attachment];
|
||||||
if (resource->resourceTypeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT))
|
auto typeFlags = resource->resourceTypeFlags;
|
||||||
|
if (typeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT))
|
||||||
{
|
{
|
||||||
if (resource->resourceTypeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR) ||
|
if (typeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR) ||
|
||||||
resource->resourceTypeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT))
|
typeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT))
|
||||||
colorRead |= (1 << i);
|
colorRead |= (1 << i);
|
||||||
else if (resource->resourceTypeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL))
|
else if (typeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL) || typeFlags & static_cast<uint32_t>(SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH))
|
||||||
depthRead |= (1 << i);
|
depthRead |= (1 << i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -265,6 +266,7 @@ namespace SHADE
|
||||||
|
|
||||||
// initialize input descriptors
|
// initialize input descriptors
|
||||||
subpasses[i]->CreateInputDescriptors();
|
subpasses[i]->CreateInputDescriptors();
|
||||||
|
subpasses[i]->GenerateDummyPipielineLayout();
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
@ -664,7 +666,7 @@ namespace SHADE
|
||||||
commandBuffer->ForceSetPipelineLayout(SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE);
|
commandBuffer->ForceSetPipelineLayout(SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE);
|
||||||
|
|
||||||
// bind static global data
|
// bind static global data
|
||||||
SHGlobalDescriptorSets::BindStaticGlobalData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA));
|
SHGlobalDescriptorSets::BindGenericAndTextureData(graphStorage->logicalDevice, commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA), frameIndex);
|
||||||
|
|
||||||
// bind lighting data
|
// bind lighting data
|
||||||
SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::LIGHTS), frameIndex);
|
SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::LIGHTS), frameIndex);
|
||||||
|
|
|
@ -226,11 +226,15 @@ namespace SHADE
|
||||||
commandBuffer->SetViewportScissor(static_cast<float>(w), static_cast<float>(h), w, h);
|
commandBuffer->SetViewportScissor(static_cast<float>(w), static_cast<float>(h), w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commandBuffer->ForceSetPipelineLayout(dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS);
|
||||||
|
|
||||||
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
|
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
|
||||||
|
|
||||||
if (renderer)
|
if (renderer)
|
||||||
renderer->BindDescriptorSet(commandBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::CAMERA), frameIndex);
|
renderer->BindDescriptorSet(commandBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::CAMERA), frameIndex);
|
||||||
|
|
||||||
|
BindInputDescriptorSets (commandBuffer, descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE), frameIndex);
|
||||||
|
|
||||||
// If companion subpass is not a valid handle, render super batch normally
|
// If companion subpass is not a valid handle, render super batch normally
|
||||||
if (!companionSubpass.companion)
|
if (!companionSubpass.companion)
|
||||||
{
|
{
|
||||||
|
@ -439,6 +443,33 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
/*!
|
||||||
|
|
||||||
|
\brief
|
||||||
|
Generates the dummy pipeline layout for subpass; specifically add the
|
||||||
|
input descriptor set layout if it exists.
|
||||||
|
|
||||||
|
|
||||||
|
\return
|
||||||
|
|
||||||
|
*/
|
||||||
|
/***************************************************************************/
|
||||||
|
void SHSubpass::GenerateDummyPipielineLayout(void) noexcept
|
||||||
|
{
|
||||||
|
auto const& batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING);
|
||||||
|
std::vector newLayouts = batchingSystemData.descSetLayouts;
|
||||||
|
if (inputDescriptorLayout)
|
||||||
|
{
|
||||||
|
newLayouts.push_back(inputDescriptorLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
dummyPipelineLayout = graphStorage->logicalDevice->CreatePipelineLayoutDummy
|
||||||
|
(
|
||||||
|
SHPipelineLayoutParamsDummy{ newLayouts }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace SHADE
|
||||||
class SHRenderer;
|
class SHRenderer;
|
||||||
class SHViewport;
|
class SHViewport;
|
||||||
class SHVkPipeline;
|
class SHVkPipeline;
|
||||||
|
class SHVkPipelineLayout;
|
||||||
|
|
||||||
class SH_API SHSubpass : public ISelfHandle<SHSubpass>
|
class SH_API SHSubpass : public ISelfHandle<SHSubpass>
|
||||||
{
|
{
|
||||||
|
@ -87,6 +88,12 @@ namespace SHADE
|
||||||
|
|
||||||
std::vector<Handle<SHVkSampler>> inputSamplers;
|
std::vector<Handle<SHVkSampler>> inputSamplers;
|
||||||
|
|
||||||
|
//! Dummy pipeline layout for subpass to bind before draw.
|
||||||
|
//! // IMPORTANT NOTE: After implementing input descriptors, every subpass differs in number input descriptors.
|
||||||
|
//! Before binding the input descriptors, a pipeline layout containing the desc set layouts
|
||||||
|
//! for the input descriptors is required, making this umbrella initial dummy bind invalid.
|
||||||
|
Handle<SHVkPipelineLayout> dummyPipelineLayout;
|
||||||
|
|
||||||
|
|
||||||
////! subpass compute image barriers. We do this because every frame has a different
|
////! subpass compute image barriers. We do this because every frame has a different
|
||||||
////! swapchain image. If the resource we want to transition is not a swapchain image,
|
////! swapchain image. If the resource we want to transition is not a swapchain image,
|
||||||
|
@ -146,6 +153,7 @@ namespace SHADE
|
||||||
//void InitComputeBarriers (void) noexcept;
|
//void InitComputeBarriers (void) noexcept;
|
||||||
void CreateInputDescriptors (void) noexcept;
|
void CreateInputDescriptors (void) noexcept;
|
||||||
void UpdateWriteDescriptors (void) noexcept;
|
void UpdateWriteDescriptors (void) noexcept;
|
||||||
|
void GenerateDummyPipielineLayout (void) noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
|
@ -7,20 +7,16 @@
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
||||||
SHVkShaderModule::SHVkShaderModule(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, std::vector<uint32_t> const& binaryData, std::string inEntryPoint, vk::ShaderStageFlagBits stage, std::string const& name) noexcept
|
void SHVkShaderModule::Recompile(void) noexcept
|
||||||
: logicalDeviceHdl {inLogicalDeviceHdl}
|
|
||||||
, shaderStage {stage}
|
|
||||||
, entryPoint {inEntryPoint}
|
|
||||||
, vkShaderModule {nullptr}
|
|
||||||
, spirvBinary{}
|
|
||||||
, shaderName {name}
|
|
||||||
, reflectedData {}
|
|
||||||
{
|
{
|
||||||
|
if (vkShaderModule)
|
||||||
|
logicalDeviceHdl->GetVkLogicalDevice().destroyShaderModule(vkShaderModule, nullptr);
|
||||||
|
|
||||||
// Prepare the create info
|
// Prepare the create info
|
||||||
vk::ShaderModuleCreateInfo moduleCreateInfo
|
vk::ShaderModuleCreateInfo moduleCreateInfo
|
||||||
{
|
{
|
||||||
.codeSize = binaryData.size() * sizeof (uint32_t),
|
.codeSize = spirvBinary.size() * sizeof(uint32_t),
|
||||||
.pCode = binaryData.data(),
|
.pCode = spirvBinary.data(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (auto result = logicalDeviceHdl->GetVkLogicalDevice().createShaderModule(&moduleCreateInfo, nullptr, &vkShaderModule); result != vk::Result::eSuccess)
|
if (auto result = logicalDeviceHdl->GetVkLogicalDevice().createShaderModule(&moduleCreateInfo, nullptr, &vkShaderModule); result != vk::Result::eSuccess)
|
||||||
|
@ -30,10 +26,18 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SHVulkanDebugUtil::ReportVkSuccess("Successfully created shader module.");
|
SHVulkanDebugUtil::ReportVkSuccess("Successfully created shader module.");
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Right now, this is doing a copy, we need to figure out if its better to just move from the resource management (source library) instead. The hope is that
|
SHVkShaderModule::SHVkShaderModule(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, std::vector<uint32_t> const& binaryData, std::string inEntryPoint, vk::ShaderStageFlagBits stage, std::string const& name) noexcept
|
||||||
// shader modules only need 1 of themselves.
|
: logicalDeviceHdl {inLogicalDeviceHdl}
|
||||||
spirvBinary = binaryData;
|
, shaderStage {stage}
|
||||||
|
, entryPoint {inEntryPoint}
|
||||||
|
, vkShaderModule {nullptr}
|
||||||
|
, spirvBinary{binaryData}
|
||||||
|
, shaderName {name}
|
||||||
|
, reflectedData {}
|
||||||
|
{
|
||||||
|
Recompile();
|
||||||
}
|
}
|
||||||
|
|
||||||
SHVkShaderModule::SHVkShaderModule(SHVkShaderModule&& rhs) noexcept
|
SHVkShaderModule::SHVkShaderModule(SHVkShaderModule&& rhs) noexcept
|
||||||
|
@ -81,13 +85,18 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHVkShaderModule::OnChange(void) noexcept
|
void SHVkShaderModule::OnChange(std::vector<uint32_t> const& newBinaryData) noexcept
|
||||||
{
|
{
|
||||||
|
// assign new binary data and recompile shader
|
||||||
|
spirvBinary = newBinaryData;
|
||||||
|
|
||||||
|
Recompile();
|
||||||
|
|
||||||
for (auto& callback : onChangeCallbacks)
|
for (auto& callback : onChangeCallbacks)
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHVkShaderModule::AddCallback(SHShaderChangeCallback&& callback) noexcept
|
void SHVkShaderModule::AddCallback(ChangeCallback&& callback) noexcept
|
||||||
{
|
{
|
||||||
onChangeCallbacks.emplace_back(std::move(callback));
|
onChangeCallbacks.emplace_back(std::move(callback));
|
||||||
}
|
}
|
||||||
|
@ -112,4 +121,9 @@ namespace SHADE
|
||||||
return reflectedData;
|
return reflectedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SHVkShaderModule::GetName(void) const noexcept
|
||||||
|
{
|
||||||
|
return shaderName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* TYPE DEFINITIONS */
|
/* TYPE DEFINITIONS */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
using SHShaderChangeCallback = std::function<void()>;
|
using ChangeCallback = std::function<void()>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
@ -47,12 +47,13 @@ namespace SHADE
|
||||||
//! response to call all the functions that need to be called. Specifically
|
//! response to call all the functions that need to be called. Specifically
|
||||||
//! pipeline layouts that need to re-parse the newly reflected data and create
|
//! pipeline layouts that need to re-parse the newly reflected data and create
|
||||||
//! descriptor set layouts and push constant ranges.
|
//! descriptor set layouts and push constant ranges.
|
||||||
std::vector<SHShaderChangeCallback> onChangeCallbacks;
|
std::vector<ChangeCallback> onChangeCallbacks;
|
||||||
|
|
||||||
// #NoteToSelf: From Tomas module, pipeline shader stage create info isn't created here
|
// #NoteToSelf: From Tomas module, pipeline shader stage create info isn't created here
|
||||||
// because the struct allows specialization info which should not be part of a module itself.
|
// because the struct allows specialization info which should not be part of a module itself.
|
||||||
// This struct should be created in the pipeline instead.
|
// This struct should be created in the pipeline instead.
|
||||||
|
|
||||||
|
void Recompile (void) noexcept;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
@ -67,8 +68,8 @@ namespace SHADE
|
||||||
/* PUBLIC MEMBER FUNCTIONS */
|
/* PUBLIC MEMBER FUNCTIONS */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
void Reflect (void) noexcept;
|
void Reflect (void) noexcept;
|
||||||
void OnChange (void) noexcept;
|
void OnChange (std::vector<uint32_t> const& newBinaryData) noexcept;
|
||||||
void AddCallback (SHShaderChangeCallback&& callback) noexcept;
|
void AddCallback (ChangeCallback&& callback) noexcept;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* SETTERS AND GETTERS */
|
/* SETTERS AND GETTERS */
|
||||||
|
@ -77,6 +78,7 @@ namespace SHADE
|
||||||
vk::ShaderStageFlagBits GetShaderStageFlagBits (void) const noexcept;
|
vk::ShaderStageFlagBits GetShaderStageFlagBits (void) const noexcept;
|
||||||
vk::ShaderModule GetVkShaderModule (void) const noexcept;
|
vk::ShaderModule GetVkShaderModule (void) const noexcept;
|
||||||
SHShaderReflected const& GetReflectedData (void) const noexcept;
|
SHShaderReflected const& GetReflectedData (void) const noexcept;
|
||||||
|
std::string GetName (void) const noexcept;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "SHInputManager.h"
|
#include "SHInputManager.h"
|
||||||
#include "../Tools/SHException.h"
|
#include "../Tools/SHException.h"
|
||||||
|
#include <Graphics/Windowing/SHWindow.h>
|
||||||
|
#include <Graphics/MiddleEnd/Interface/SHGraphicsSystem.h>
|
||||||
|
#include <Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.h>
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -21,6 +24,7 @@ namespace SHADE
|
||||||
/* Static defines */
|
/* Static defines */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
bool SHInputManager::mouseCentering = false;
|
||||||
bool SHInputManager::controllerInUse = false;
|
bool SHInputManager::controllerInUse = false;
|
||||||
|
|
||||||
std::map<std::string, SHInputManager::SHLogicalBindingData> SHInputManager::bindings;
|
std::map<std::string, SHInputManager::SHLogicalBindingData> SHInputManager::bindings;
|
||||||
|
@ -751,6 +755,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
++keyCount;
|
++keyCount;
|
||||||
keys[i] = true;
|
keys[i] = true;
|
||||||
|
controllerInUse = false;
|
||||||
}
|
}
|
||||||
else keys[i] = false;
|
else keys[i] = false;
|
||||||
|
|
||||||
|
@ -801,6 +806,25 @@ namespace SHADE
|
||||||
mouseVelocityX = static_cast<double>(mouseScreenX - mouseScreenXLast) / dt;
|
mouseVelocityX = static_cast<double>(mouseScreenX - mouseScreenXLast) / dt;
|
||||||
mouseVelocityY = static_cast<double>(mouseScreenY - mouseScreenYLast) / dt;
|
mouseVelocityY = static_cast<double>(mouseScreenY - mouseScreenYLast) / dt;
|
||||||
|
|
||||||
|
|
||||||
|
//Mouse Centering
|
||||||
|
if (mouseCentering)
|
||||||
|
{
|
||||||
|
uint32_t width = SHADE::SHGraphicsSystemInterface::GetWindowWidth();
|
||||||
|
uint32_t height = SHADE::SHGraphicsSystemInterface::GetWindowHeight();
|
||||||
|
SetMouseWindowPosition(width / 2, height / 2);
|
||||||
|
|
||||||
|
//These four lines help a lot
|
||||||
|
POINT p;
|
||||||
|
GetCursorPos(&p);
|
||||||
|
mouseVelocityX -= static_cast<double>(p.x - mouseScreenX) / dt;
|
||||||
|
mouseVelocityY -= static_cast<double>(p.y - mouseScreenY) / dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mouseVelocityX != 0.0 || mouseVelocityY != 0.0)
|
||||||
|
controllerInUse = false;
|
||||||
|
|
||||||
|
|
||||||
//Mouse wheel vertical delta updating
|
//Mouse wheel vertical delta updating
|
||||||
mouseWheelVerticalDelta = 0;
|
mouseWheelVerticalDelta = 0;
|
||||||
mouseWheelVerticalDelta = mouseWheelVerticalDeltaPoll;
|
mouseWheelVerticalDelta = mouseWheelVerticalDeltaPoll;
|
||||||
|
|
|
@ -1074,6 +1074,18 @@ namespace SHADE
|
||||||
SetCursorPos(p.x, p.y);
|
SetCursorPos(p.x, p.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Call to set the flag to start mouse centering every frame
|
||||||
|
static inline void SetMouseCentering(bool state) noexcept
|
||||||
|
{
|
||||||
|
mouseCentering = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the flag whether mouse centering is on or not
|
||||||
|
static inline bool GetMouseCentering() noexcept
|
||||||
|
{
|
||||||
|
return mouseCentering;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Constants */
|
/* Constants */
|
||||||
|
@ -1097,6 +1109,9 @@ namespace SHADE
|
||||||
/* Data Members */
|
/* Data Members */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
//Whether mouse centering will be called every frame or not
|
||||||
|
static bool mouseCentering;
|
||||||
|
|
||||||
//If the last input is from controller(s) or KB/M
|
//If the last input is from controller(s) or KB/M
|
||||||
//True if from controller(s), False if from KB/M
|
//True if from controller(s), False if from KB/M
|
||||||
//Useful for switching control hints between controllers and KB/M
|
//Useful for switching control hints between controllers and KB/M
|
||||||
|
|
|
@ -369,6 +369,27 @@ namespace SHADE
|
||||||
return eventData->handle;
|
return eventData->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHEventHandle SHScriptEngine::onUIElementReleased(SHEventPtr eventPtr)
|
||||||
|
{
|
||||||
|
auto eventData = reinterpret_cast<const SHEventSpec<SHButtonClickEvent>*>(eventPtr.get());
|
||||||
|
csUIElementOnReleased(eventData->data->EID);
|
||||||
|
return eventData->handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHEventHandle SHScriptEngine::onUIElementOnHoverEntered(SHEventPtr eventPtr)
|
||||||
|
{
|
||||||
|
auto eventData = reinterpret_cast<const SHEventSpec<SHButtonClickEvent>*>(eventPtr.get());
|
||||||
|
csUIElementOnHoverEntered(eventData->data->EID);
|
||||||
|
return eventData->handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHEventHandle SHScriptEngine::onUIElementOnHoverExited(SHEventPtr eventPtr)
|
||||||
|
{
|
||||||
|
auto eventData = reinterpret_cast<const SHEventSpec<SHButtonClickEvent>*>(eventPtr.get());
|
||||||
|
csUIElementOnHoverExited(eventData->data->EID);
|
||||||
|
return eventData->handle;
|
||||||
|
}
|
||||||
|
|
||||||
SHEventHandle SHScriptEngine::onSceneNodeChildrenAdded(SHEventPtr eventPtr)
|
SHEventHandle SHScriptEngine::onSceneNodeChildrenAdded(SHEventPtr eventPtr)
|
||||||
{
|
{
|
||||||
auto eventData = reinterpret_cast<const SHEventSpec<SHSceneGraphAddChildEvent>*>(eventPtr.get());
|
auto eventData = reinterpret_cast<const SHEventSpec<SHSceneGraphAddChildEvent>*>(eventPtr.get());
|
||||||
|
@ -539,6 +560,24 @@ namespace SHADE
|
||||||
DEFAULT_CSHARP_NAMESPACE + ".UIElement",
|
DEFAULT_CSHARP_NAMESPACE + ".UIElement",
|
||||||
"OnClicked"
|
"OnClicked"
|
||||||
);
|
);
|
||||||
|
csUIElementOnReleased = dotNet.GetFunctionPtr<CsEventRelayFuncPtr>
|
||||||
|
(
|
||||||
|
DEFAULT_CSHARP_LIB_NAME,
|
||||||
|
DEFAULT_CSHARP_NAMESPACE + ".UIElement",
|
||||||
|
"OnReleased"
|
||||||
|
);
|
||||||
|
csUIElementOnHoverEntered = dotNet.GetFunctionPtr<CsEventRelayFuncPtr>
|
||||||
|
(
|
||||||
|
DEFAULT_CSHARP_LIB_NAME,
|
||||||
|
DEFAULT_CSHARP_NAMESPACE + ".UIElement",
|
||||||
|
"OnHoverEntered"
|
||||||
|
);
|
||||||
|
csUIElementOnHoverExited = dotNet.GetFunctionPtr<CsEventRelayFuncPtr>
|
||||||
|
(
|
||||||
|
DEFAULT_CSHARP_LIB_NAME,
|
||||||
|
DEFAULT_CSHARP_NAMESPACE + ".UIElement",
|
||||||
|
"OnHoverExited"
|
||||||
|
);
|
||||||
csEditorRenderScripts = dotNet.GetFunctionPtr<CsScriptEditorFuncPtr>
|
csEditorRenderScripts = dotNet.GetFunctionPtr<CsScriptEditorFuncPtr>
|
||||||
(
|
(
|
||||||
DEFAULT_CSHARP_LIB_NAME,
|
DEFAULT_CSHARP_LIB_NAME,
|
||||||
|
@ -608,6 +647,21 @@ namespace SHADE
|
||||||
std::make_shared<SHEventReceiverSpec<SHScriptEngine>>(this, &SHScriptEngine::onUIElementClicked)
|
std::make_shared<SHEventReceiverSpec<SHScriptEngine>>(this, &SHScriptEngine::onUIElementClicked)
|
||||||
};
|
};
|
||||||
SHEventManager::SubscribeTo(SH_BUTTON_CLICK_EVENT, std::dynamic_pointer_cast<SHEventReceiver>(clickedUIElementEventReceiver));
|
SHEventManager::SubscribeTo(SH_BUTTON_CLICK_EVENT, std::dynamic_pointer_cast<SHEventReceiver>(clickedUIElementEventReceiver));
|
||||||
|
std::shared_ptr<SHEventReceiverSpec<SHScriptEngine>> releasedUIElementEventReceiver
|
||||||
|
{
|
||||||
|
std::make_shared<SHEventReceiverSpec<SHScriptEngine>>(this, &SHScriptEngine::onUIElementReleased)
|
||||||
|
};
|
||||||
|
SHEventManager::SubscribeTo(SH_BUTTON_RELEASE_EVENT, std::dynamic_pointer_cast<SHEventReceiver>(releasedUIElementEventReceiver));
|
||||||
|
std::shared_ptr<SHEventReceiverSpec<SHScriptEngine>> hoverEnterUIElementEventReceiver
|
||||||
|
{
|
||||||
|
std::make_shared<SHEventReceiverSpec<SHScriptEngine>>(this, &SHScriptEngine::onUIElementOnHoverEntered)
|
||||||
|
};
|
||||||
|
SHEventManager::SubscribeTo(SH_BUTTON_HOVER_ENTER_EVENT, std::dynamic_pointer_cast<SHEventReceiver>(hoverEnterUIElementEventReceiver));
|
||||||
|
std::shared_ptr<SHEventReceiverSpec<SHScriptEngine>> hoverExitedUIElementEventReceiver
|
||||||
|
{
|
||||||
|
std::make_shared<SHEventReceiverSpec<SHScriptEngine>>(this, &SHScriptEngine::onUIElementOnHoverExited)
|
||||||
|
};
|
||||||
|
SHEventManager::SubscribeTo(SH_BUTTON_HOVER_EXIT_EVENT, std::dynamic_pointer_cast<SHEventReceiver>(hoverExitedUIElementEventReceiver));
|
||||||
|
|
||||||
/* SceneGraph */
|
/* SceneGraph */
|
||||||
// Register for SceneNode child added event
|
// Register for SceneNode child added event
|
||||||
|
|
|
@ -292,6 +292,9 @@ namespace SHADE
|
||||||
CsEventRelayFuncPtr csSceneNodeChildrenChanged = nullptr;
|
CsEventRelayFuncPtr csSceneNodeChildrenChanged = nullptr;
|
||||||
CsEventRelayFuncPtr csUIElementOnRemoved = nullptr;
|
CsEventRelayFuncPtr csUIElementOnRemoved = nullptr;
|
||||||
CsEventRelayFuncPtr csUIElementOnClicked = nullptr;
|
CsEventRelayFuncPtr csUIElementOnClicked = nullptr;
|
||||||
|
CsEventRelayFuncPtr csUIElementOnReleased = nullptr;
|
||||||
|
CsEventRelayFuncPtr csUIElementOnHoverEntered = nullptr;
|
||||||
|
CsEventRelayFuncPtr csUIElementOnHoverExited = nullptr;
|
||||||
// - Editor
|
// - Editor
|
||||||
CsScriptEditorFuncPtr csEditorRenderScripts = nullptr;
|
CsScriptEditorFuncPtr csEditorRenderScripts = nullptr;
|
||||||
CsFuncPtr csEditorUndo = nullptr;
|
CsFuncPtr csEditorUndo = nullptr;
|
||||||
|
@ -306,6 +309,9 @@ namespace SHADE
|
||||||
SHEventHandle onColliderComponentRemoved(SHEventPtr eventPtr);
|
SHEventHandle onColliderComponentRemoved(SHEventPtr eventPtr);
|
||||||
SHEventHandle onUIElementRemoved(SHEventPtr eventPtr);
|
SHEventHandle onUIElementRemoved(SHEventPtr eventPtr);
|
||||||
SHEventHandle onUIElementClicked(SHEventPtr eventPtr);
|
SHEventHandle onUIElementClicked(SHEventPtr eventPtr);
|
||||||
|
SHEventHandle onUIElementReleased(SHEventPtr eventPtr);
|
||||||
|
SHEventHandle onUIElementOnHoverEntered(SHEventPtr eventPtr);
|
||||||
|
SHEventHandle onUIElementOnHoverExited(SHEventPtr eventPtr);
|
||||||
SHEventHandle onSceneNodeChildrenAdded(SHEventPtr eventPtr);
|
SHEventHandle onSceneNodeChildrenAdded(SHEventPtr eventPtr);
|
||||||
SHEventHandle onSceneNodeChildrenRemoved(SHEventPtr eventPtr);
|
SHEventHandle onSceneNodeChildrenRemoved(SHEventPtr eventPtr);
|
||||||
SHEventHandle onSceneDestroyed(SHEventPtr eventPtr);
|
SHEventHandle onSceneDestroyed(SHEventPtr eventPtr);
|
||||||
|
|
|
@ -28,16 +28,19 @@ namespace SHADE
|
||||||
void SHButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
void SHButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
||||||
{
|
{
|
||||||
defaultTexture = texture;
|
defaultTexture = texture;
|
||||||
|
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHButtonComponent::SetHoveredTexture(AssetID texture) noexcept
|
void SHButtonComponent::SetHoveredTexture(AssetID texture) noexcept
|
||||||
{
|
{
|
||||||
hoveredTexture = texture;
|
hoveredTexture = texture;
|
||||||
|
SHResourceManager::LoadOrGet<SHTexture>(texture);\
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHButtonComponent::SetClickedTexture(AssetID texture) noexcept
|
void SHButtonComponent::SetClickedTexture(AssetID texture) noexcept
|
||||||
{
|
{
|
||||||
clickedTexture = texture;
|
clickedTexture = texture;
|
||||||
|
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
#include "SHToggleButtonComponent.h"
|
#include "SHToggleButtonComponent.h"
|
||||||
|
#include "Resource/SHResourceManager.h"
|
||||||
|
#include "Graphics/MiddleEnd/Textures/SHTextureLibrary.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -28,11 +29,13 @@ namespace SHADE
|
||||||
void SHToggleButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
void SHToggleButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
||||||
{
|
{
|
||||||
defaultTexture = texture;
|
defaultTexture = texture;
|
||||||
|
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHToggleButtonComponent::SetToggledTexture(AssetID texture) noexcept
|
void SHToggleButtonComponent::SetToggledTexture(AssetID texture) noexcept
|
||||||
{
|
{
|
||||||
toggledTexture = texture;
|
toggledTexture = texture;
|
||||||
|
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHToggleButtonComponent::SetValue(bool value) noexcept
|
void SHToggleButtonComponent::SetValue(bool value) noexcept
|
||||||
|
|
|
@ -204,6 +204,7 @@ namespace SHADE
|
||||||
SHButtonClickEvent clickEvent;
|
SHButtonClickEvent clickEvent;
|
||||||
clickEvent.EID = comp.GetEID();
|
clickEvent.EID = comp.GetEID();
|
||||||
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_HOVER_ENTER_EVENT);
|
SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_HOVER_ENTER_EVENT);
|
||||||
|
//SHLOG_INFO("C++ BROADCASTED HOVER ENTER EVENT EID: {}", clickEvent.EID);
|
||||||
}
|
}
|
||||||
comp.isHovered = true;
|
comp.isHovered = true;
|
||||||
|
|
||||||
|
@ -312,7 +313,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
auto material = renderable->GetModifiableMaterial();
|
auto material = renderable->GetModifiableMaterial();
|
||||||
comp.currentTexture = textureID;
|
comp.currentTexture = textureID;
|
||||||
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
|
material->SetProperty("data.textureIndex", SHResourceManager::Get<SHTexture>(textureID)->TextureArrayIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -366,7 +368,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
auto material = renderable->GetModifiableMaterial();
|
auto material = renderable->GetModifiableMaterial();
|
||||||
comp.currentTexture = textureID;
|
comp.currentTexture = textureID;
|
||||||
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
|
material->SetProperty("data.textureIndex", SHResourceManager::Get<SHTexture>(textureID)->TextureArrayIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -378,6 +381,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SHUISystem* system = (SHUISystem*)GetSystem();
|
SHUISystem* system = (SHUISystem*)GetSystem();
|
||||||
auto& dense = SHComponentManager::GetDense<SHButtonComponent>();
|
auto& dense = SHComponentManager::GetDense<SHButtonComponent>();
|
||||||
|
//We ensure that the textures are loaded before we do the update.
|
||||||
|
SHResourceManager::FinaliseChanges();
|
||||||
for (auto& comp : dense)
|
for (auto& comp : dense)
|
||||||
{
|
{
|
||||||
if (SHSceneManager::CheckNodeAndComponentsActive<SHButtonComponent>(comp.GetEID()))
|
if (SHSceneManager::CheckNodeAndComponentsActive<SHButtonComponent>(comp.GetEID()))
|
||||||
|
|
|
@ -68,6 +68,8 @@ namespace SHADE
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool loadTexture{false};
|
||||||
|
|
||||||
void UpdateUIComponent(SHUIComponent& comp) noexcept;
|
void UpdateUIComponent(SHUIComponent& comp) noexcept;
|
||||||
void UpdateButtonComponent(SHButtonComponent& comp) noexcept;
|
void UpdateButtonComponent(SHButtonComponent& comp) noexcept;
|
||||||
void UpdateToggleButtonComponent(SHToggleButtonComponent& comp) noexcept;
|
void UpdateToggleButtonComponent(SHToggleButtonComponent& comp) noexcept;
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace SHADE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float Camera::Pitch::get()
|
float Camera::Pitch::get()
|
||||||
{
|
{
|
||||||
return (GetNativeComponent()->GetPitch());
|
return (GetNativeComponent()->GetPitch());
|
||||||
|
@ -50,15 +49,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
GetNativeComponent()->SetWidth(val);
|
GetNativeComponent()->SetWidth(val);
|
||||||
}
|
}
|
||||||
float Camera::Height::get()
|
|
||||||
{
|
|
||||||
return (GetNativeComponent()->GetHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Camera::Height::set(float val)
|
|
||||||
{
|
|
||||||
GetNativeComponent()->SetHeight(val);
|
|
||||||
}
|
|
||||||
float Camera::Near::get()
|
float Camera::Near::get()
|
||||||
{
|
{
|
||||||
return (GetNativeComponent()->GetNear());
|
return (GetNativeComponent()->GetNear());
|
||||||
|
@ -133,4 +125,10 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Camera^ Camera::GetMainCamera()
|
||||||
|
{
|
||||||
|
auto system = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
|
return ECS::GetComponent<Camera^>(system->GetMainCameraEID());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,6 +15,9 @@ namespace SHADE
|
||||||
Camera(Entity entity);
|
Camera(Entity entity);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
property float Pitch
|
property float Pitch
|
||||||
{
|
{
|
||||||
float get();
|
float get();
|
||||||
|
@ -35,11 +38,7 @@ namespace SHADE
|
||||||
float get();
|
float get();
|
||||||
void set(float val);
|
void set(float val);
|
||||||
}
|
}
|
||||||
property float Height
|
|
||||||
{
|
|
||||||
float get();
|
|
||||||
void set(float val);
|
|
||||||
}
|
|
||||||
property float Near
|
property float Near
|
||||||
{
|
{
|
||||||
float get();
|
float get();
|
||||||
|
@ -62,11 +61,15 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SetMainCamera(size_t directorIndex);
|
void SetMainCamera(size_t directorIndex);
|
||||||
void SetMainCamera();
|
void SetMainCamera();
|
||||||
void LookAt(Vector3 targetPosition);
|
void LookAt(Vector3 targetPosition);
|
||||||
Vector3 GetForward();
|
Vector3 GetForward();
|
||||||
Vector3 GetRight();
|
Vector3 GetRight();
|
||||||
|
|
||||||
|
|
||||||
|
static Camera^ GetMainCamera();
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -47,11 +47,16 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SHADE::Material Renderable::Material::get()
|
SHADE::Material Renderable::Material::get()
|
||||||
|
{
|
||||||
|
auto mat = GetNativeComponent()->GetModifiableMaterial();
|
||||||
|
return mat ? SHADE::Material(mat) : SHADE::Material();
|
||||||
|
}
|
||||||
|
SHADE::Material Renderable::SharedMaterial::get()
|
||||||
{
|
{
|
||||||
auto mat = GetNativeComponent()->GetMaterial();
|
auto mat = GetNativeComponent()->GetMaterial();
|
||||||
return mat ? SHADE::Material(mat) : SHADE::Material();
|
return mat ? SHADE::Material(mat) : SHADE::Material();
|
||||||
}
|
}
|
||||||
void Renderable::Material::set(SHADE::Material value)
|
void Renderable::SharedMaterial::set(SHADE::Material value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,9 +55,19 @@ namespace SHADE
|
||||||
void set(MeshAsset value);
|
void set(MeshAsset value);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Material used to render this Renderable.
|
/// Special instance of the shared Material for this Renderable. When accessing
|
||||||
|
/// this property, a new instance of the shared Material is created and assigned
|
||||||
|
/// to this Renderable. Hence, changes will only affect this Renderable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
property SHADE::Material Material
|
property SHADE::Material Material
|
||||||
|
{
|
||||||
|
SHADE::Material get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The shared Material used to render this Renderable and other Renderables
|
||||||
|
/// using the same base Material.
|
||||||
|
/// </summary>
|
||||||
|
property SHADE::Material SharedMaterial
|
||||||
{
|
{
|
||||||
SHADE::Material get();
|
SHADE::Material get();
|
||||||
void set(SHADE::Material value);
|
void set(SHADE::Material value);
|
||||||
|
|
|
@ -28,6 +28,18 @@ namespace SHADE
|
||||||
: Component(entity)
|
: Component(entity)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void UIElement::ClearStaticEventData()
|
||||||
|
{
|
||||||
|
if (onClickEventMap != nullptr)
|
||||||
|
onClickEventMap->Clear();
|
||||||
|
if (onReleasedEventMap != nullptr)
|
||||||
|
onReleasedEventMap->Clear();
|
||||||
|
if (onHoverEnterEventMap != nullptr)
|
||||||
|
onHoverEnterEventMap->Clear();
|
||||||
|
if (onHoverExitEventMap != nullptr)
|
||||||
|
onHoverExitEventMap->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Properties */
|
/* Properties */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -48,6 +60,57 @@ namespace SHADE
|
||||||
// Return the event
|
// Return the event
|
||||||
return onClickEventMap[owner.EntityId];
|
return onClickEventMap[owner.EntityId];
|
||||||
}
|
}
|
||||||
|
CallbackEvent^ UIElement::OnRelease::get()
|
||||||
|
{
|
||||||
|
// Create map if it wasn't before
|
||||||
|
if (onReleasedEventMap == nullptr)
|
||||||
|
{
|
||||||
|
onReleasedEventMap = gcnew System::Collections::Generic::Dictionary<Entity, CallbackEvent ^>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create event if it wasn't before
|
||||||
|
if (!onReleasedEventMap->ContainsKey(owner.EntityId))
|
||||||
|
{
|
||||||
|
onReleasedEventMap->Add(owner.EntityId, gcnew CallbackEvent());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the event
|
||||||
|
return onReleasedEventMap[owner.EntityId];
|
||||||
|
}
|
||||||
|
CallbackEvent^ UIElement::OnHoverEnter::get()
|
||||||
|
{
|
||||||
|
// Create map if it wasn't before
|
||||||
|
if (onHoverEnterEventMap == nullptr)
|
||||||
|
{
|
||||||
|
onHoverEnterEventMap = gcnew System::Collections::Generic::Dictionary<Entity, CallbackEvent ^>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create event if it wasn't before
|
||||||
|
if (!onHoverEnterEventMap->ContainsKey(owner.EntityId))
|
||||||
|
{
|
||||||
|
onHoverEnterEventMap->Add(owner.EntityId, gcnew CallbackEvent());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the event
|
||||||
|
return onHoverEnterEventMap[owner.EntityId];
|
||||||
|
}
|
||||||
|
CallbackEvent^ UIElement::OnHoverExit::get()
|
||||||
|
{
|
||||||
|
// Create map if it wasn't before
|
||||||
|
if (onHoverExitEventMap == nullptr)
|
||||||
|
{
|
||||||
|
onHoverExitEventMap = gcnew System::Collections::Generic::Dictionary<Entity, CallbackEvent ^>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create event if it wasn't before
|
||||||
|
if (!onHoverExitEventMap->ContainsKey(owner.EntityId))
|
||||||
|
{
|
||||||
|
onHoverExitEventMap->Add(owner.EntityId, gcnew CallbackEvent());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the event
|
||||||
|
return onHoverExitEventMap[owner.EntityId];
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Event Handling Functions */
|
/* Event Handling Functions */
|
||||||
|
@ -60,6 +123,18 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
onClickEventMap->Remove(entity);
|
onClickEventMap->Remove(entity);
|
||||||
}
|
}
|
||||||
|
if (onReleasedEventMap != nullptr && onReleasedEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onReleasedEventMap->Remove(entity);
|
||||||
|
}
|
||||||
|
if (onHoverEnterEventMap != nullptr && onHoverEnterEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onHoverEnterEventMap->Remove(entity);
|
||||||
|
}
|
||||||
|
if (onHoverExitEventMap != nullptr && onHoverExitEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onHoverExitEventMap->Remove(entity);
|
||||||
|
}
|
||||||
SAFE_NATIVE_CALL_END("UIElement.OnComponentRemoved")
|
SAFE_NATIVE_CALL_END("UIElement.OnComponentRemoved")
|
||||||
}
|
}
|
||||||
void UIElement::OnClicked(EntityID entity)
|
void UIElement::OnClicked(EntityID entity)
|
||||||
|
@ -72,4 +147,34 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
SAFE_NATIVE_CALL_END("UIElement.OnClicked")
|
SAFE_NATIVE_CALL_END("UIElement.OnClicked")
|
||||||
}
|
}
|
||||||
|
void UIElement::OnReleased(EntityID entity)
|
||||||
|
{
|
||||||
|
SAFE_NATIVE_CALL_BEGIN
|
||||||
|
// Remove the event if it contained an event
|
||||||
|
if (onReleasedEventMap != nullptr && onReleasedEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onReleasedEventMap[entity]->Invoke();
|
||||||
|
}
|
||||||
|
SAFE_NATIVE_CALL_END("UIElement.OnReleased")
|
||||||
|
}
|
||||||
|
void UIElement::OnHoverEntered(EntityID entity)
|
||||||
|
{
|
||||||
|
SAFE_NATIVE_CALL_BEGIN
|
||||||
|
// Remove the event if it contained an event
|
||||||
|
if (onHoverEnterEventMap != nullptr && onHoverEnterEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onHoverEnterEventMap[entity]->Invoke();
|
||||||
|
}
|
||||||
|
SAFE_NATIVE_CALL_END("UIElement.OnHoverEntered")
|
||||||
|
}
|
||||||
|
void UIElement::OnHoverExited(EntityID entity)
|
||||||
|
{
|
||||||
|
SAFE_NATIVE_CALL_BEGIN
|
||||||
|
// Remove the event if it contained an event
|
||||||
|
if (onHoverExitEventMap != nullptr && onHoverExitEventMap->ContainsKey(entity))
|
||||||
|
{
|
||||||
|
onHoverExitEventMap[entity]->Invoke();
|
||||||
|
}
|
||||||
|
SAFE_NATIVE_CALL_END("UIElement.OnHoverExited")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,37 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
CallbackEvent^ get();
|
CallbackEvent^ get();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is raised when this UIElement is released.
|
||||||
|
/// </summary>
|
||||||
|
property CallbackEvent^ OnRelease
|
||||||
|
{
|
||||||
|
CallbackEvent^ get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is raised on the first frame when this UIElement is hovered over.
|
||||||
|
/// </summary>
|
||||||
|
property CallbackEvent^ OnHoverEnter
|
||||||
|
{
|
||||||
|
CallbackEvent^ get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is raised on the first frame when this UIElement is no longer
|
||||||
|
/// hovered over.
|
||||||
|
/// </summary>
|
||||||
|
property CallbackEvent^ OnHoverExit
|
||||||
|
{
|
||||||
|
CallbackEvent^ get();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Static Clear Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Disposes static event data which may contains data from SHADE_Scripting.
|
||||||
|
/// </summary>
|
||||||
|
static void ClearStaticEventData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -65,11 +96,32 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity">The entity which was clicked.</param>
|
/// <param name="entity">The entity which was clicked.</param>
|
||||||
static void OnClicked(EntityID entity);
|
static void OnClicked(EntityID entity);
|
||||||
|
/// <summary>
|
||||||
|
/// To be called from native code when this component is released from clicking.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity which was clicked.</param>
|
||||||
|
static void OnReleased(EntityID entity);
|
||||||
|
/// <summary>
|
||||||
|
/// To be called from native code on the first frame that this component is
|
||||||
|
/// hovered on.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity which was clicked.</param>
|
||||||
|
static void OnHoverEntered(EntityID entity);
|
||||||
|
/// <summary>
|
||||||
|
/// To be called from native code on the first frame that this component is
|
||||||
|
/// no longer hovered on.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity which was clicked.</param>
|
||||||
|
static void OnHoverExited(EntityID entity);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Static Data Members */
|
/* Static Data Members */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
// As these hold references to code in SHADE_Scripting, we must remember to dispose of them when changing scenes
|
||||||
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onClickEventMap;
|
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onClickEventMap;
|
||||||
|
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onReleasedEventMap;
|
||||||
|
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onHoverEnterEventMap;
|
||||||
|
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onHoverExitEventMap;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace SHADE
|
||||||
/// specified Component.
|
/// specified Component.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
generic<typename T> where T : BaseComponent
|
generic<typename T> where T : BaseComponent
|
||||||
static T GetComponent(EntityID entity);
|
static T GetComponent(EntityID entity);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the first Component from the specified GameObject's children that
|
/// Retrieves the first Component from the specified GameObject's children that
|
||||||
/// matches the specified type.
|
/// matches the specified type.
|
||||||
|
|
|
@ -21,6 +21,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Utility/Convert.hxx"
|
#include "Utility/Convert.hxx"
|
||||||
#include "Utility/Debug.hxx"
|
#include "Utility/Debug.hxx"
|
||||||
#include "Scripts/ScriptStore.hxx"
|
#include "Scripts/ScriptStore.hxx"
|
||||||
|
#include "Components/UIElement.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -43,6 +44,9 @@ namespace SHADE
|
||||||
oss << "[EngineInterface] Unloading " << Convert::ToNative(ManagedLibraryName) << ".dll";
|
oss << "[EngineInterface] Unloading " << Convert::ToNative(ManagedLibraryName) << ".dll";
|
||||||
ScriptStore::Exit();
|
ScriptStore::Exit();
|
||||||
|
|
||||||
|
// Unload static data of components that have access to the assembly
|
||||||
|
UIElement::ClearStaticEventData();
|
||||||
|
|
||||||
// Unload the script
|
// Unload the script
|
||||||
scriptContext->Unload();
|
scriptContext->Unload();
|
||||||
scriptContext = nullptr;
|
scriptContext = nullptr;
|
||||||
|
|
|
@ -30,10 +30,29 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
return SHInputManager::GetMouseWheelVerticalDelta();
|
return SHInputManager::GetMouseWheelVerticalDelta();
|
||||||
}
|
}
|
||||||
|
bool Input::ControllerInUse::get()
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInUse();
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
bool Input::AnyKey()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Input::AnyKeyDown()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyKeyDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Input::AnyKeyUp()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyKeyUp();
|
||||||
|
}
|
||||||
|
|
||||||
bool Input::GetKey(KeyCode key)
|
bool Input::GetKey(KeyCode key)
|
||||||
{
|
{
|
||||||
return SHInputManager::GetKey(static_cast<SHInputManager::SH_KEYCODE>(key));
|
return SHInputManager::GetKey(static_cast<SHInputManager::SH_KEYCODE>(key));
|
||||||
|
@ -64,6 +83,50 @@ namespace SHADE
|
||||||
return SHInputManager::GetKeyUp(static_cast<SHInputManager::SH_KEYCODE>(mouseButton));
|
return SHInputManager::GetKeyUp(static_cast<SHInputManager::SH_KEYCODE>(mouseButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Input::AnyControllerInput()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerInput();
|
||||||
|
}
|
||||||
|
bool Input::AnyControllerInputDown()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerInputDown();
|
||||||
|
}
|
||||||
|
bool Input::AnyControllerInputUp()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerInputUp();
|
||||||
|
}
|
||||||
|
bool Input::AnyControllerButton()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerButton();
|
||||||
|
}
|
||||||
|
bool Input::AnyControllerButtonDown()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerButtonDown();
|
||||||
|
}
|
||||||
|
bool Input::AnyControllerButtonUp()
|
||||||
|
{
|
||||||
|
return SHInputManager::AnyControllerButtonUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Input::GetControllerInput(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInput(static_cast<SHInputManager::SH_CONTROLLERCODE>(code));
|
||||||
|
}
|
||||||
|
double Input::GetControllerInputNormalisedValue(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
double toReturn = 0.0;
|
||||||
|
SHInputManager::GetControllerInput(static_cast<SHInputManager::SH_CONTROLLERCODE>(code), &toReturn);
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
bool Input::GetControllerInputDown(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInputDown(static_cast<SHInputManager::SH_CONTROLLERCODE>(code));
|
||||||
|
}
|
||||||
|
bool Input::GetControllerInputUp(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInputUp(static_cast<SHInputManager::SH_CONTROLLERCODE>(code));
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Cursor Functions */
|
/* Cursor Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -76,6 +139,24 @@ namespace SHADE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 Input::GetMousePosition()
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
SHInputManager::GetMouseWindowPosition(&x, &y);
|
||||||
|
return Convert::ToCLI(SHVec2{ (float)x,(float)y });
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::SetMouseCentering(bool state)
|
||||||
|
{
|
||||||
|
SHInputManager::SetMouseCentering(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Input::GetMouseCentering()
|
||||||
|
{
|
||||||
|
return SHInputManager::GetMouseCentering();
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Time Functions */
|
/* Time Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -106,4 +187,220 @@ namespace SHADE
|
||||||
|
|
||||||
return Convert::ToCLI(SHVec2{ (float)velX,(float)velY });
|
return Convert::ToCLI(SHVec2{ (float)velX,(float)velY });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Input::GetControllerInputHeldTime(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInputHeldTime(static_cast<SHInputManager::SH_CONTROLLERCODE>(code));
|
||||||
|
}
|
||||||
|
double Input::GetControllerInputReleasedTime(Input::ControllerCode code)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetControllerInputReleasedTime(static_cast<SHInputManager::SH_CONTROLLERCODE>(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Binding Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
void Input::SaveBindings()
|
||||||
|
{
|
||||||
|
SHInputManager::SaveBindings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::SaveBindings(System::String^ targetFile)
|
||||||
|
{
|
||||||
|
SHInputManager::SaveBindings(Convert::ToNative(targetFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::LoadBindings()
|
||||||
|
{
|
||||||
|
SHInputManager::LoadBindings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::LoadBindings(System::String^ sourceFile)
|
||||||
|
{
|
||||||
|
SHInputManager::LoadBindings(Convert::ToNative(sourceFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Input::GetBindingInverted(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingInverted(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
void Input::SetBindingInverted(System::String^ bindingName, bool newValue)
|
||||||
|
{
|
||||||
|
SHInputManager::SetBindingInverted(Convert::ToNative(bindingName), newValue);
|
||||||
|
}
|
||||||
|
double Input::GetBindingGravity(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingGravity(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
void Input::SetBindingGravity(System::String^ bindingName, double newValue)
|
||||||
|
{
|
||||||
|
SHInputManager::SetBindingGravity(Convert::ToNative(bindingName), newValue);
|
||||||
|
}
|
||||||
|
double Input::GetBindingDead(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingDead(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
void Input::SetBindingDead(System::String^ bindingName, double newValue)
|
||||||
|
{
|
||||||
|
SHInputManager::SetBindingDead(Convert::ToNative(bindingName), newValue);
|
||||||
|
}
|
||||||
|
double Input::GetBindingSensitivity(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingSensitivity(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
void Input::SetBindingSensitivity(System::String^ bindingName, double newValue)
|
||||||
|
{
|
||||||
|
SHInputManager::SetBindingSensitivity(Convert::ToNative(bindingName), newValue);
|
||||||
|
}
|
||||||
|
bool Input::GetBindingSnap(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingSnap(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
void Input::SetBindingSnap(System::String^ bindingName, bool newValue)
|
||||||
|
{
|
||||||
|
SHInputManager::SetBindingSnap(Convert::ToNative(bindingName), newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
System::Collections::Generic::HashSet<Input::KeyCode>^ Input::GetBindingPositiveKeyCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
System::Collections::Generic::HashSet<Input::KeyCode>^ toReturn = gcnew System::Collections::Generic::HashSet<Input::KeyCode>();
|
||||||
|
std::set<SHInputManager::SH_KEYCODE> list = SHInputManager::GetBindingPositiveKeyCodes(Convert::ToNative(bindingName));
|
||||||
|
for (auto kc : list)
|
||||||
|
{
|
||||||
|
toReturn->Add(static_cast<Input::KeyCode>(kc));
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
void Input::AddBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toAdd)
|
||||||
|
{
|
||||||
|
SHInputManager::AddBindingPositiveKeyCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_KEYCODE>(toAdd));
|
||||||
|
}
|
||||||
|
void Input::RemoveBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toRemove)
|
||||||
|
{
|
||||||
|
SHInputManager::RemoveBindingPositiveKeyCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_KEYCODE>(toRemove));
|
||||||
|
}
|
||||||
|
void Input::ClearBindingPositiveKeyCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
SHInputManager::ClearBindingPositiveKeyCodes(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
System::Collections::Generic::HashSet<Input::KeyCode>^ Input::GetBindingNegativeKeyCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
System::Collections::Generic::HashSet<Input::KeyCode>^ toReturn = gcnew System::Collections::Generic::HashSet<Input::KeyCode>();
|
||||||
|
std::set<SHInputManager::SH_KEYCODE> list = SHInputManager::GetBindingNegativeKeyCodes(Convert::ToNative(bindingName));
|
||||||
|
for (auto kc : list)
|
||||||
|
{
|
||||||
|
toReturn->Add(static_cast<Input::KeyCode>(kc));
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
void Input::AddBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toAdd)
|
||||||
|
{
|
||||||
|
SHInputManager::AddBindingNegativeKeyCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_KEYCODE>(toAdd));
|
||||||
|
}
|
||||||
|
void Input::RemoveBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toRemove)
|
||||||
|
{
|
||||||
|
SHInputManager::RemoveBindingNegativeKeyCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_KEYCODE>(toRemove));
|
||||||
|
}
|
||||||
|
void Input::ClearBindingNegativeKeyCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
SHInputManager::ClearBindingNegativeKeyCodes(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
System::Collections::Generic::HashSet<Input::ControllerCode>^ Input::GetBindingPositiveControllerCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
System::Collections::Generic::HashSet<Input::ControllerCode>^ toReturn = gcnew System::Collections::Generic::HashSet<Input::ControllerCode>();
|
||||||
|
std::set<SHInputManager::SH_CONTROLLERCODE> list = SHInputManager::GetBindingPositiveControllerCodes(Convert::ToNative(bindingName));
|
||||||
|
for (auto kc : list)
|
||||||
|
{
|
||||||
|
toReturn->Add(static_cast<Input::ControllerCode>(kc));
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
void Input::AddBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toAdd)
|
||||||
|
{
|
||||||
|
SHInputManager::AddBindingPositiveControllerCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_CONTROLLERCODE>(toAdd));
|
||||||
|
}
|
||||||
|
void Input::RemoveBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toRemove)
|
||||||
|
{
|
||||||
|
SHInputManager::RemoveBindingPositiveControllerCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_CONTROLLERCODE>(toRemove));
|
||||||
|
}
|
||||||
|
void Input::ClearBindingPositiveControllerCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
SHInputManager::ClearBindingPositiveControllerCodes(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
System::Collections::Generic::HashSet<Input::ControllerCode>^ Input::GetBindingNegativeControllerCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
System::Collections::Generic::HashSet<Input::ControllerCode>^ toReturn = gcnew System::Collections::Generic::HashSet<Input::ControllerCode>();
|
||||||
|
std::set<SHInputManager::SH_CONTROLLERCODE> list = SHInputManager::GetBindingNegativeControllerCodes(Convert::ToNative(bindingName));
|
||||||
|
for (auto kc : list)
|
||||||
|
{
|
||||||
|
toReturn->Add(static_cast<Input::ControllerCode>(kc));
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
void Input::AddBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toAdd)
|
||||||
|
{
|
||||||
|
SHInputManager::AddBindingNegativeControllerCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_CONTROLLERCODE>(toAdd));
|
||||||
|
}
|
||||||
|
void Input::RemoveBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toRemove)
|
||||||
|
{
|
||||||
|
SHInputManager::RemoveBindingNegativeControllerCode(Convert::ToNative(bindingName), static_cast<SHInputManager::SH_CONTROLLERCODE>(toRemove));
|
||||||
|
}
|
||||||
|
void Input::ClearBindingNegativeControllerCodes(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
SHInputManager::ClearBindingNegativeControllerCodes(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
double Input::GetBindingAxis(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingAxis(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
double Input::GetBindingAxisRaw(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingAxisRaw(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingPositiveButton(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingPositiveButton(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingNegativeButton(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingNegativeButton(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingPositiveButtonDown(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingPositiveButtonDown(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingNegativeButtonDown(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingNegativeButtonDown(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingPositiveButtonUp(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingPositiveButtonUp(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
bool Input::GetBindingNegativeButtonUp(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingNegativeButtonUp(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
|
||||||
|
double Input::GetBindingPositiveHeldTime(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingPositiveHeldTime(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
double Input::GetBindingNegativeHeldTime(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingNegativeHeldTime(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
double Input::GetBindingPositiveReleasedTime(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingPositiveReleasedTime(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
|
double Input::GetBindingNegativeReleasedTime(System::String^ bindingName)
|
||||||
|
{
|
||||||
|
return SHInputManager::GetBindingNegativeReleasedTime(Convert::ToNative(bindingName));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -181,7 +181,6 @@ namespace SHADE
|
||||||
//Break
|
//Break
|
||||||
//Menu
|
//Menu
|
||||||
//Mouse buttons use mouse codes, which are enums declared later
|
//Mouse buttons use mouse codes, which are enums declared later
|
||||||
//TODO Controller input
|
|
||||||
#if 0
|
#if 0
|
||||||
Space = static_cast<int>(SHInputManager::SH_KEYCODE::SPACE),
|
Space = static_cast<int>(SHInputManager::SH_KEYCODE::SPACE),
|
||||||
//Apostrophe = static_cast<int>(SHInputManager::SH_KEYCODE::APOSTROPHE),
|
//Apostrophe = static_cast<int>(SHInputManager::SH_KEYCODE::APOSTROPHE),
|
||||||
|
@ -355,6 +354,35 @@ namespace SHADE
|
||||||
Button3 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB1),
|
Button3 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB1),
|
||||||
Button4 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB2)
|
Button4 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB2)
|
||||||
};
|
};
|
||||||
|
enum class ControllerCode : int
|
||||||
|
{
|
||||||
|
DpadUp = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::DPAD_UP),
|
||||||
|
DpadDown = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::DPAD_DOWN),
|
||||||
|
DpadLeft = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::DPAD_LEFT),
|
||||||
|
DpadRight = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::DPAD_RIGHT),
|
||||||
|
Start = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::START),
|
||||||
|
Back = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::BACK),
|
||||||
|
LeftThumbstickButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK),
|
||||||
|
RightThumbstickButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::RIGHT_THUMBSTICK),
|
||||||
|
LeftShoulder = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::LEFT_SHOULDER),
|
||||||
|
RightShoulder = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::RIGHT_SHOULDER),
|
||||||
|
AButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::A),
|
||||||
|
BButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::B),
|
||||||
|
XButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::X),
|
||||||
|
YButton = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::Y),
|
||||||
|
LeftTrigger = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::LEFT_TRIGGER),
|
||||||
|
RightTrigger = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::RIGHT_TRIGGER),
|
||||||
|
LeftThumbStickX = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK_X),
|
||||||
|
LeftThumbStickY = static_cast<int>(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK_Y)
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class BindingType : int
|
||||||
|
{
|
||||||
|
KbMbController = static_cast<int>(SHInputManager::SH_BINDINGTYPE::KB_MB_CONTROLLER),
|
||||||
|
mouseX = static_cast<int>(SHInputManager::SH_BINDINGTYPE::MOUSE_X),
|
||||||
|
mouseY = static_cast<int>(SHInputManager::SH_BINDINGTYPE::MOUSE_Y),
|
||||||
|
mouseScroll = static_cast<int>(SHInputManager::SH_BINDINGTYPE::MOUSE_SCROLL)
|
||||||
|
};
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Properites */
|
/* Properites */
|
||||||
|
@ -376,9 +404,25 @@ namespace SHADE
|
||||||
int get();
|
int get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static property bool ControllerInUse
|
||||||
|
{
|
||||||
|
bool get();
|
||||||
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if any key is being held down.
|
||||||
|
/// This will also be true if GetKeyDown() is true.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="firstKey">KeyCode of the first key that was detected to be pressed.</param>
|
||||||
|
/// <returns>True while the user holds down the key specified.</returns>
|
||||||
|
static bool AnyKey();
|
||||||
|
static bool AnyKeyDown();
|
||||||
|
static bool AnyKeyUp();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if a specified key is being held down.
|
/// Checks if a specified key is being held down.
|
||||||
/// This will also be true if GetKeyDown() is true.
|
/// This will also be true if GetKeyDown() is true.
|
||||||
|
@ -428,6 +472,20 @@ namespace SHADE
|
||||||
/// </returns>
|
/// </returns>
|
||||||
static bool GetMouseButtonUp(MouseCode mouseButton);
|
static bool GetMouseButtonUp(MouseCode mouseButton);
|
||||||
|
|
||||||
|
//For controller
|
||||||
|
|
||||||
|
static bool AnyControllerInput();
|
||||||
|
static bool AnyControllerInputDown();
|
||||||
|
static bool AnyControllerInputUp();
|
||||||
|
static bool AnyControllerButton();
|
||||||
|
static bool AnyControllerButtonDown();
|
||||||
|
static bool AnyControllerButtonUp();
|
||||||
|
|
||||||
|
static bool GetControllerInput(ControllerCode code);
|
||||||
|
static double GetControllerInputNormalisedValue(ControllerCode code);
|
||||||
|
static bool GetControllerInputDown(ControllerCode code);
|
||||||
|
static bool GetControllerInputUp(ControllerCode code);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Cursor Functions */
|
/* Cursor Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -440,6 +498,11 @@ namespace SHADE
|
||||||
/// </param>
|
/// </param>
|
||||||
static void SetMousePosition(Vector2 pos);
|
static void SetMousePosition(Vector2 pos);
|
||||||
|
|
||||||
|
static Vector2 GetMousePosition();
|
||||||
|
|
||||||
|
static void SetMouseCentering(bool state);
|
||||||
|
static bool GetMouseCentering();
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Timing Functions */
|
/* Timing Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -472,6 +535,66 @@ namespace SHADE
|
||||||
/// <returns>Time in seconds that the key was held.</returns>
|
/// <returns>Time in seconds that the key was held.</returns>
|
||||||
static double GetMouseReleasedTime(MouseCode mouseButton);
|
static double GetMouseReleasedTime(MouseCode mouseButton);
|
||||||
|
|
||||||
|
static double GetControllerInputHeldTime(ControllerCode code);
|
||||||
|
static double GetControllerInputReleasedTime(ControllerCode code);
|
||||||
|
|
||||||
static Vector2 GetMouseVelocity();
|
static Vector2 GetMouseVelocity();
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Binding Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
static void SaveBindings(); //To default file
|
||||||
|
static void SaveBindings(System::String^ targetFile);
|
||||||
|
static void LoadBindings(); //From default file
|
||||||
|
static void LoadBindings(System::String^ sourceFile);
|
||||||
|
|
||||||
|
static bool GetBindingInverted(System::String^ bindingName);
|
||||||
|
static void SetBindingInverted(System::String^ bindingName, bool newValue);
|
||||||
|
static double GetBindingGravity(System::String^ bindingName);
|
||||||
|
static void SetBindingGravity(System::String^ bindingName, double newValue);
|
||||||
|
static double GetBindingDead(System::String^ bindingName);
|
||||||
|
static void SetBindingDead(System::String^ bindingName, double newValue);
|
||||||
|
static double GetBindingSensitivity(System::String^ bindingName);
|
||||||
|
static void SetBindingSensitivity(System::String^ bindingName, double newValue);
|
||||||
|
static bool GetBindingSnap(System::String^ bindingName);
|
||||||
|
static void SetBindingSnap(System::String^ bindingName, bool newValue);
|
||||||
|
|
||||||
|
static System::Collections::Generic::HashSet<KeyCode>^ GetBindingPositiveKeyCodes(System::String^ bindingName);
|
||||||
|
static void AddBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toAdd);
|
||||||
|
static void RemoveBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toRemove);
|
||||||
|
static void ClearBindingPositiveKeyCodes(System::String^ bindingName);
|
||||||
|
|
||||||
|
static System::Collections::Generic::HashSet<KeyCode>^ GetBindingNegativeKeyCodes(System::String^ bindingName);
|
||||||
|
static void AddBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toAdd);
|
||||||
|
static void RemoveBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toRemove);
|
||||||
|
static void ClearBindingNegativeKeyCodes(System::String^ bindingName);
|
||||||
|
|
||||||
|
static System::Collections::Generic::HashSet<ControllerCode>^ GetBindingPositiveControllerCodes(System::String^ bindingName);
|
||||||
|
static void AddBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toAdd);
|
||||||
|
static void RemoveBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toRemove);
|
||||||
|
static void ClearBindingPositiveControllerCodes(System::String^ bindingName);
|
||||||
|
|
||||||
|
static System::Collections::Generic::HashSet<ControllerCode>^ GetBindingNegativeControllerCodes(System::String^ bindingName);
|
||||||
|
static void AddBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toAdd);
|
||||||
|
static void RemoveBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toRemove);
|
||||||
|
static void ClearBindingNegativeControllerCodes(System::String^ bindingName);
|
||||||
|
|
||||||
|
//Binding states
|
||||||
|
|
||||||
|
static double GetBindingAxis(System::String^ bindingName);
|
||||||
|
static double GetBindingAxisRaw(System::String^ bindingName);
|
||||||
|
static bool GetBindingPositiveButton(System::String^ bindingName);
|
||||||
|
static bool GetBindingNegativeButton(System::String^ bindingName);
|
||||||
|
static bool GetBindingPositiveButtonDown(System::String^ bindingName);
|
||||||
|
static bool GetBindingNegativeButtonDown(System::String^ bindingName);
|
||||||
|
static bool GetBindingPositiveButtonUp(System::String^ bindingName);
|
||||||
|
static bool GetBindingNegativeButtonUp(System::String^ bindingName);
|
||||||
|
|
||||||
|
//Binding times
|
||||||
|
|
||||||
|
static double GetBindingPositiveHeldTime(System::String^ bindingName);
|
||||||
|
static double GetBindingNegativeHeldTime(System::String^ bindingName);
|
||||||
|
static double GetBindingPositiveReleasedTime(System::String^ bindingName);
|
||||||
|
static double GetBindingNegativeReleasedTime(System::String^ bindingName);
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue