Merge branch 'main' into SP3-141-Camera-System

This commit is contained in:
maverickdgg 2023-02-04 00:32:41 +08:00
commit 63a546b7aa
61 changed files with 5663 additions and 287 deletions

View File

@ -1,16 +1,16 @@
0 1 67
1 2 65535
2 3 65534
3 4 65534
4 5 65534
5 6 65534
6 7 65535
7 8 65534
8 9 65534
9 10 65534
10 11 65534
11 12 65534
12 13 65534
13 14 65534
14 15 65534
15 16 65534
0 1 0000000000000000
1 2 0000000000000000
2 3 0000000000000000
3 4 0000000000000000
4 5 0000000000000000
5 6 0000000000000000
6 7 0000000000000000
7 8 0000000000000000
8 9 0000000000000000
9 10 0000000000000000
10 11 0000000000000000
11 12 0000000000000000
12 13 0000000000000000
13 14 0000000000000000
14 15 0000000000000000
15 16 0000000000000000

View File

@ -132,23 +132,23 @@ Size=165,120
Collapsed=0
[Table][0x9D40AE32,17]
Column 0 Weight=0.9945
Column 1 Weight=0.9945
Column 0 Weight=1.0696
Column 1 Weight=0.9194
Column 2 Weight=0.9945
Column 3 Weight=0.9945
Column 4 Weight=0.9945
Column 3 Weight=1.0320
Column 4 Weight=0.9570
Column 5 Weight=0.9945
Column 6 Weight=0.9945
Column 7 Weight=0.9945
Column 8 Weight=0.9945
Column 9 Weight=0.9945
Column 10 Weight=0.9945
Column 11 Weight=0.9945
Column 12 Weight=1.0132
Column 9 Weight=1.0320
Column 10 Weight=0.9570
Column 11 Weight=1.0133
Column 12 Weight=0.9945
Column 13 Weight=0.8444
Column 14 Weight=0.9945
Column 15 Weight=1.2009
Column 16 Weight=1.0132
Column 15 Weight=0.8632
Column 16 Weight=1.3510
[Docking][Data]
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,77 Size=1920,933 Split=X
@ -159,7 +159,7 @@ DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,77 Size=1920,933 Split
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1130,1036 Split=Y Selected=0xB41284E7
DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1501,672 Split=Y Selected=0xB41284E7
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1501,700 Split=Y Selected=0xB41284E7
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,705 CentralNode=1 Selected=0xB41284E7
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,705 CentralNode=1 Selected=0x69428B24
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,234 Selected=0xB128252A
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=1501,310 Selected=0xD446F7B6
DockNode ID=0x00000008 Parent=0x00000002 SizeRef=1501,338 Selected=0xD9F31532

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,7 @@
Name: MD_RigTest01_SkinningTest
ID: 72178939
Type: 4
Sub Assets:
Name: Cube
ID: 141097368
Type: 8

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,7 @@
Name: MD_RigTest02_HierachyTest1
ID: 80500944
Type: 4
Sub Assets:
Name: Cube.001
ID: 135102560
Type: 8

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,7 @@
Name: MD_RigTest03_HierachyTest2
ID: 72063399
Type: 4
Sub Assets:
Name: Cube.001
ID: 140361184
Type: 8

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,7 @@
Name: MD_RigTest04_BakedIKLegTest
ID: 80728853
Type: 4
Sub Assets:
Name: Cube
ID: 149723808
Type: 8

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,7 @@
Name: MD_RigTest05_MeshDeformTest
ID: 82124728
Type: 4
Sub Assets:
Name: Sphere
ID: 138773466
Type: 8

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,7 @@
Name: MD_RigTest06_Piston
ID: 76715962
Type: 4
Sub Assets:
Name: Cube
ID: 134911040
Type: 8

File diff suppressed because it is too large Load Diff

View File

@ -8432,7 +8432,7 @@
- EID: 20
Name: ===== Light =====
IsActive: true
NumberOfChildren: 2
NumberOfChildren: 3
Components: ~
Scripts: ~
- EID: 296
@ -8463,6 +8463,25 @@
Strength: 0.699999988
IsActive: true
Scripts: ~
- EID: 65674
Name: Light_Directional
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 2, y: 1.5, z: -5.5999999}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Light Component:
Position: {x: 2, y: 1.5, z: -5.5999999}
Type: Directional
Direction: {x: 1, y: 0, z: 0}
Color: {x: 0, y: 0, z: 0, w: 1}
Layer: 4294967295
Strength: 1
IsActive: true
Scripts: ~
- EID: 240
Name: ====ItemPool====
IsActive: true
@ -9493,10 +9512,14 @@
timer: 200
scoreText: 237
timeText: 206
multiplierText: 139
maxMultiplierDuration: 5
maxMultiplierCombo: 10
multiplierFont: 60
- EID: 199
Name: =====Text====
IsActive: true
NumberOfChildren: 2
NumberOfChildren: 3
Components: ~
Scripts: ~
- EID: 237
@ -9529,6 +9552,21 @@
Font: 176667660
IsActive: true
Scripts: ~
- EID: 139
Name: Multiplier
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -800, y: 300, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 60, y: 60, z: 60}
IsActive: true
Text Renderer Component:
Text: TEST
Font: 176667660
IsActive: true
Scripts: ~
- EID: 198
Name: ====Raccoon====
IsActive: true

View File

@ -67,3 +67,4 @@
Scripts:
- Type: MainMenu
Enabled: true
sceneID: 96668835

View File

@ -13,7 +13,7 @@
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: false
Interpolate: true
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
@ -25,7 +25,7 @@
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 1
Collision Tag: 2
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
@ -52,7 +52,7 @@
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 1
Collision Tag: 5
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
@ -161,7 +161,7 @@
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 1
Collision Tag: 7
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006

View File

@ -0,0 +1,19 @@
using System;
using SHADE;
public class FixRotation : Script
{
Transform tran;
protected override void awake()
{
tran = GetComponent<Transform>();
}
protected override void update()
{
if(tran)
tran.LocalEulerAngles = Vector3.Zero;
}
}

View File

@ -0,0 +1,3 @@
Name: FixRotation
ID: 162507316
Type: 9

View File

@ -12,7 +12,6 @@ public class Breakable : Script
private Transform trans;
public bool isBreak { get; set; }
private List<GameObject> itemPieces = new List<GameObject>();
private Random ran = new Random();
protected override void awake()
{
@ -44,7 +43,7 @@ public class Breakable : Script
if (ignoreRaccoon && info.GameObject.GetScript<PlayerController>())
return;
if (rb.LinearVelocity.GetSqrMagnitude() > threshHold)
if (rb.LinearVelocity.GetSqrMagnitude() > threshHold && !info.GameObject.GetScript<PlayerController>())
{
isBreak = true;
if(GameObject.GetScript<Item>())

View File

@ -208,12 +208,23 @@ public class PickAndThrow : Script
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false, (ushort)65535);
if (rayList1.Count > 0 && rayList2.Count > 0 && rayList3.Count > 0)
if (rayList1.Count > 0)
{
RaycastHit ray1 = rayList1[0];
inRange = CheckForItem(ray1);
return;
}
else if (rayList2.Count > 0)
{
RaycastHit ray2 = rayList2[0];
inRange = CheckForItem(ray2);
return;
}
else if (rayList3.Count > 0)
{
RaycastHit ray3 = rayList3[0];
inRange = CheckForItem(ray1) || CheckForItem(ray2) || CheckForItem(ray3);
inRange = CheckForItem(ray3);
return;
}
else
{

View File

@ -371,7 +371,7 @@ public class PlayerController : Script
stateMachine.SetState(typeof(PlayerIdleState));
tranform.LocalPosition = respawnPoint.GetComponent<Transform>().LocalPosition;
if (pat && pat.item.GetScript<Item>())
if (pat && pat.item)
{
holdItem = false;
isAiming = false;

View File

@ -26,6 +26,16 @@ public class GameManager : Script
public GameObject scoreText;
public GameObject timeText;
//mulitpler info
public GameObject multiplierText;
public float maxMultiplierDuration = 5.0f;
public float currMultiplierDuration { get; set; }
public int maxMultiplierCombo = 10;
public bool itemScored {get;set;}
public int currMultiplierCombo { get; set;}
public float multiplierFont = 60.0f;
private Vector3 fontScalar;
public static GameManager Instance { get; private set; }
protected override void awake()
@ -40,12 +50,15 @@ public class GameManager : Script
totalItemCount = 0;
Score = 0;
currGameState = GameState.START;
itemScored = false;
currMultiplierCombo = 1;
currMultiplierDuration = 0;
fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration);
}
protected override void update()
{
Cheats();
if (currGameState == GameState.START)
{
timer -= Time.DeltaTimeF;
@ -54,6 +67,25 @@ public class GameManager : Script
if(timeText)
timeText.GetComponent<TextRenderable>().Text = $"Time Left: {timer.ToString("0.00")}";
if (itemScored)
{
multiplierText.GetComponent<TextRenderable>().Text = $"X {currMultiplierCombo}";
multiplierText.GetComponent<Transform>().LocalScale -= fontScalar * Time.DeltaTimeF;
currMultiplierDuration += Time.DeltaTimeF;
if (currMultiplierDuration >= maxMultiplierDuration)
{
itemScored = false;
currMultiplierCombo = 1;
currMultiplierDuration = 0;
}
}
else
{
multiplierText.GetComponent<Transform>().LocalScale = Vector3.Zero;
}
if ((timer > 0 && totalItemCount < 0) || Input.GetKeyDown(Input.KeyCode.F1))
{
currGameState = GameState.WIN;
@ -86,4 +118,14 @@ public class GameManager : Script
}
}
public void ItemScored()
{
totalItemCount -= 1;
itemScored = true;
currMultiplierDuration = 0;
multiplierText.GetComponent<Transform>().LocalScale = new Vector3(multiplierFont, multiplierFont, multiplierFont);
if (currMultiplierCombo < maxMultiplierCombo)
currMultiplierCombo += 1;
}
}

View File

@ -12,8 +12,8 @@ public class ScoringZone : Script
if (GameManager.Instance && info.GameObject.GetScript<Item>())
{
Audio.PlaySFXOnce2D("event:/Music/stingers/item_scored");
GameManager.Instance.Score += info.GameObject.GetScript<Item>().Score;
GameManager.Instance.totalItemCount -= 1;
GameManager.Instance.ItemScored();
GameManager.Instance.Score += info.GameObject.GetScript<Item>().Score * GameManager.Instance.currMultiplierCombo;
info.GameObject.SetActive(false);
}
}

View File

@ -82,7 +82,7 @@ public class PhysicsTestObj : Script
{
Ray colliderRay = new Ray();
colliderRay.Direction = Vector3.Right;
Physics.ColliderRaycast(collider.Owner, colliderRay, false, 8);
Physics.ColliderRaycast(collider.Owner, colliderRay, false, (ushort)64);
for (int i = 0; i < 6; ++i)
{

View File

@ -3,6 +3,7 @@ using SHADE;
public class MainMenu : Script
{
public uint sceneID;
protected override void awake()
{
Audio.PlayBGMOnce2D("event:/Music/main_menu");
@ -17,7 +18,7 @@ public class MainMenu : Script
if (Input.GetKeyUp(Input.KeyCode.Space))
{
Audio.PlaySFXOnce2D("event:/UI/success");
SceneManager.ChangeScene(86098106);
SceneManager.ChangeScene(sceneID);
Audio.StopAllSounds();
}

View File

@ -60,7 +60,7 @@ float CalcShadowValue (sampler2D shadowMap, vec4 worldSpaceFragPos, mat4 lightPV
if (fragPosLightPOV.z > sampledDepth && fragPosLightPOV.w > 0.0f)
{
return 0.0f;
return 0.7f;
}
else
return 1.0f;

View File

@ -0,0 +1,10 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
#extension GL_EXT_nonuniform_qualifier : require
void main()
{
}

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: ShadowMap_FS
ID: 45925790
Type: 2

View File

@ -5,6 +5,7 @@
//#define SHEDITOR
#ifdef SHEDITOR
#include "Editor/SHEditor.h"
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
//#include "Scenes/SBEditorScene.h"
#endif // SHEDITOR
@ -31,7 +32,6 @@
#include "Input/SHInputManager.h"
#include "Math/Transform/SHTransformSystem.h"
#include "Physics/System/SHPhysicsSystem.h"
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
#include "Scripting/SHScriptEngine.h"
#include "UI/SHUISystem.h"
#include "Animation/SHAnimationSystem.h"
@ -74,12 +74,15 @@ namespace Sandbox
#endif
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow, wndData);
SHAssetManager::Load();
// Create Systems
SHSystemManager::CreateSystem<SHScriptEngine>();
SHSystemManager::CreateSystem<SHTransformSystem>();
SHSystemManager::CreateSystem<SHPhysicsSystem>();
#ifndef _PUBLISH
#ifdef SHEDITOR
SHSystemManager::CreateSystem<SHPhysicsDebugDrawSystem>();
#endif
@ -122,7 +125,7 @@ namespace Sandbox
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsUpdate>();
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsPostUpdate>();
#ifndef _PUBLISH
#ifdef SHEDITOR
SHSystemManager::RegisterRoutine<SHPhysicsDebugDrawSystem, SHPhysicsDebugDrawSystem::PhysicsDebugDraw>();
#endif
@ -155,7 +158,6 @@ namespace Sandbox
SHComponentManager::CreateComponentSparseSet<SHAnimatorComponent>();
//SHComponentManager::CreateComponentSparseSet<SHCameraComponent>();
SHAssetManager::Load();
//auto font = SHAssetManager::GetData<SHFontAsset>(176667660);
SHSystemManager::RegisterRoutine<SHAudioSystem, SHAudioSystem::AudioRoutine>();

View File

@ -200,7 +200,9 @@ namespace SHADE
void SHAudioSystem::ErrorCheck() const
{
if (result != FMOD_OK)
std::cerr << "Audio system error: " << FMOD_ErrorString(result) << std::endl;
{
SHLOG_ERROR( "Audio system error: {}", FMOD_ErrorString(result))
}
}
void SHAudioSystem::PlayEventOnce(const char* path, bool isSFX, EntityID eid, bool spatial)
@ -319,6 +321,15 @@ namespace SHADE
if (channel->isPlaying(&isPlaying) == FMOD_OK && isPlaying)
channel->stop();
}
auto [begin, end] = audioClipLibrary.GetDenseAccess();
for (auto it = begin; it != end; ++it)
{
if (it->instance)
{
it->instance->stop(FMOD_STUDIO_STOP_MODE::FMOD_STUDIO_STOP_IMMEDIATE);
it->instance->release();
}
}
masterGroup->stop();
}
@ -349,6 +360,10 @@ namespace SHADE
audioClipHandle = audioClipLibrary.Create();
it->second->createInstance(&audioClipHandle->instance);
}
else
{
SHLOG_ERROR("FMOD: Failed to find event path: {}", path)
}
return audioClipHandle;
}
@ -487,10 +502,12 @@ namespace SHADE
}
void SHAudioSystem::SetBgmVolume(float const bgmvol)
{
bgmVolume = bgmvol;
bgmChannelGroup->setVolume(bgmvol);
}
void SHAudioSystem::SetSfxVolume(float const sfxvol)
{
sfxVolume = sfxvol;
sfxChannelGroup->setVolume(sfxvol);
}
void SHAudioSystem::SetMasterVolume(float const mastervol)
@ -506,15 +523,12 @@ namespace SHADE
{
channel->setPaused(paused);
}
for (auto const& event : eventMap)
auto [begin, end] = audioClipLibrary.GetDenseAccess();
for (auto it = begin; it != end; ++it)
{
int instanceCount = 0;
event.second->getInstanceCount(&instanceCount);
std::vector<FMOD::Studio::EventInstance*> instances(instanceCount);
event.second->getInstanceList(instances.data(), static_cast<int>(instances.size()), &instanceCount);
for (auto const& instance : instances)
if (it->instance)
{
instance->setPaused(pause);
it->SetPause(pause);
}
}
}
@ -546,6 +560,7 @@ namespace SHADE
bank->loadSampleData();
int numOfEvents;
bank->getEventCount(&numOfEvents);
if (numOfEvents > 0)
{
std::vector<FMOD::Studio::EventDescription*> events(numOfEvents);
@ -560,11 +575,71 @@ namespace SHADE
}
}
float SHAudioSystem::GetVCAVolume(const char* path)
{
FMOD::Studio::VCA* vca = nullptr;
result = fmodStudioSystem->getVCA(path, &vca);
float volume = 0.0f;
if (result != FMOD_OK)
{
ErrorCheck();
return volume;
}
result = vca->getVolume(&volume);
if (result != FMOD_OK)
{
ErrorCheck();
return volume;
}
return volume;
}
void SHAudioSystem::SetVCAVolume(const char* path, float value)
{
FMOD::Studio::VCA* vca = nullptr;
result = fmodStudioSystem->getVCA(path, &vca);
if (result != FMOD_OK)
{
ErrorCheck();
return;
}
result = vca->setVolume(std::clamp(value, 0.0f, 1.0f));
if (result != FMOD_OK)
{
ErrorCheck();
return;
}
}
float SHAudioSystem::GetParameterValue(const char* path)
{
float value = {};
result = fmodStudioSystem->getParameterByName(path, &value);
if(result != FMOD_OK)
{
ErrorCheck();
}
return value;
}
void SHAudioSystem::SetParameter(const char* path, float value)
{
result = fmodStudioSystem->setParameterByName(path, value);
if (result != FMOD_OK)
{
ErrorCheck();
}
}
void AudioClip::Play()
{
if(!instance)
return;
instance->start();
FMOD_RESULT result = instance->start();
if (result != FMOD_OK)
{
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
}
}
//void AudioClip::Play(bool isSfx)
@ -598,7 +673,11 @@ namespace SHADE
{
if (!instance)
return;
instance->stop(fadeOut ? FMOD_STUDIO_STOP_ALLOWFADEOUT : FMOD_STUDIO_STOP_IMMEDIATE);
FMOD_RESULT result = instance->stop(fadeOut ? FMOD_STUDIO_STOP_ALLOWFADEOUT : FMOD_STUDIO_STOP_IMMEDIATE);
if (result != FMOD_OK)
{
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
}
}
void AudioClip::SetPause(bool pause)
@ -623,7 +702,11 @@ namespace SHADE
{
if (!instance)
return;
instance->setParameterByName(paramName, value);
FMOD_RESULT result = instance->setParameterByName(paramName, value);
if (result != FMOD_OK)
{
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
}
}
//void AudioClip::SetParameterLabel(const char* paramName, const char* label)
@ -635,11 +718,31 @@ namespace SHADE
float AudioClip::GetParameterValue(const char* paramName)
{
if (!instance)
return {};
float value{};
instance->getParameterByName(paramName, &value);
if (!instance)
return value;
auto result = instance->getParameterByName(paramName, &value);
if (result != FMOD_OK)
{
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
}
return value;
}
float AudioClip::GetVolume()
{
float volume{};
if(!instance)
return volume;
instance->getVolume(&volume);
return volume;
}
void AudioClip::SetVolume(float volume)
{
if(!instance)
return;
instance->setVolume(volume);
}
SHEventHandle SHAudioSystem::onStop(SHEventPtr onStopEvent)

View File

@ -35,6 +35,8 @@ namespace SHADE
void SetParameter(const char* paramName, float value);
//void SetParameterLabel(const char* paramName, const char* label);
float GetParameterValue(const char* paramName);
float GetVolume();
void SetVolume(float volume);
friend class SHAudioSystem;
private:
FMOD::Studio::EventInstance* instance = nullptr;
@ -85,7 +87,13 @@ namespace SHADE
void SetPaused(bool pause);
bool GetPaused() const;
SHVec3 GetListenerPosition();
void LoadBank(const char* path);
float GetVCAVolume(const char* path);
void SetVCAVolume(const char* path, float value);
float GetParameterValue(const char* path);
void SetParameter(const char* path, float value);
private:
FMOD::Studio::System* fmodStudioSystem;

View File

@ -94,7 +94,7 @@ namespace SHADE
if (systemContainer.find(id) == systemContainer.end())
{
std::cout << "System Manager error: System Version "<< typeid(T).name()<<" " << version << " does not exist." << std::endl;
std::cout << "System Manager error: System Version " << typeid(T).name() << ", " << version << " does not exist." << std::endl;
return nullptr;
}

View File

@ -11,52 +11,60 @@ namespace SHADE
{
if (Begin())
{
DrawMenuBar();
ImGui::BeginTable("CollisionMtxTable", SHCollisionTag::NUM_LAYERS + 1, ImGuiTableRowFlags_Headers);
ImGui::TableNextRow();
ImGui::PushID("CollisionTagNames");
for (int i = SHCollisionTag::NUM_LAYERS; i >= 1; --i)
// Draw Layers
// We have 16 layers for each tag
ImGui::TableNextColumn();
for (int i = 1; i <= SHCollisionTag::NUM_LAYERS; ++i)
{
ImGui::TableNextColumn();
if(i == SHCollisionTag::NUM_LAYERS) continue;
std::string const& tagName = SHCollisionTagMatrix::GetTagName(i);
auto tag = SHCollisionTagMatrix::GetTag(i);
if (!tag)
continue;
//ImGui::Text(tagName.data());
ImGui::PushID(i);
SHEditorWidgets::InputText("##", [i]{return SHCollisionTagMatrix::GetTagName(i);}, [i](std::string const& value){SHCollisionTagMatrix::GetTag(i)->SetName(value);}, tagName.data(), ImGuiInputTextFlags_EnterReturnsTrue);
ImGui::PopID();
// Show the layer number
ImGui::Text(std::to_string(i).c_str());
}
ImGui::PopID();
// Draw the table
// Convenient how we have 16 layers & 16 tags huh?
for (int i = 0; i < SHCollisionTag::NUM_LAYERS - 1; ++i)
{
std::string tagName = SHCollisionTagMatrix::GetTagName(i);
auto tag = SHCollisionTagMatrix::GetTag(i);
if(!tag)
continue;
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text(tagName.data());
for (int j = (SHCollisionTag::NUM_LAYERS) - 1; j >= i; --j)
ImGui::PushID(i);
SHEditorWidgets::InputText("##", [i]{return SHCollisionTagMatrix::GetTagName(i);}, [i](std::string const& value){SHCollisionTagMatrix::GetTag(i)->SetName(value);}, tagName.data(), ImGuiInputTextFlags_EnterReturnsTrue);
ImGui::PopID();
// The checkboxes are just to set the layers of each tag
// Nothing else should be altered.
for (int j = 0; j < SHCollisionTag::NUM_LAYERS; ++j)
{
int idx = j;
std::string tagName2 = SHCollisionTagMatrix::GetTagName(idx);
auto tag2 = SHCollisionTagMatrix::GetTag(idx);
if(!tag2)
continue;
if(tagName.empty())
tagName = std::to_string(i);
if(tagName2.empty())
tagName2 = std::to_string(idx);
ImGui::TableNextColumn();
if(i == idx)
continue;
std::string label = std::format("##{} vs {}", tagName, tagName2);
SHEditorWidgets::CheckBox(label, [tag, &idx]{return tag->GetLayerState(idx);}, [tag, i, idx](bool const& value){tag->SetLayerState(idx, value); SHCollisionTagMatrix::GetTag(idx)->SetLayerState(i, value);}, label.substr(2));
std::string label = std::format("##{}, Layer {}", tagName, j);
if (SHEditorWidgets::CheckBox(label, [tag, &j] {return tag->GetLayerState(j); }, [tag, j](bool const& value) {tag->SetLayerState(j, value); }, label.substr(2)))
{
isDirty = true;
}
}
}
ImGui::EndTable();
@ -64,4 +72,21 @@ namespace SHADE
ImGui::End();
}
void SHColliderTagPanel::DrawMenuBar()
{
if (ImGui::BeginMenuBar())
{
ImGui::BeginDisabled(!isDirty);
if (ImGui::Button("Save"))
{
std::filesystem::path defaultCollisionTagNameFilePath{ ASSET_ROOT };
defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig");
SHCollisionTagMatrix::SaveToFile(defaultCollisionTagNameFilePath);
isDirty = false;
}
ImGui::EndDisabled();
ImGui::EndMenuBar();
}
}
}

View File

@ -14,6 +14,7 @@ namespace SHADE
//void Exit();
private:
void DrawMenuBar();
bool isDirty;
};
}

View File

@ -128,6 +128,7 @@ namespace SHADE
SHFreetypeInstance::Init();
//SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/ShadowMap_FS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/SSAO_CS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/SSAOBlur_CS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/PureCopy_CS.glsl", false);
@ -137,6 +138,7 @@ namespace SHADE
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false);
// Load Built In Shaders
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
static constexpr AssetID VS_ANIM = 47911992; animtVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_ANIM);
@ -152,6 +154,7 @@ namespace SHADE
static constexpr AssetID RENDER_SC_VS = 48082949; renderToSwapchainVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(RENDER_SC_VS);
static constexpr AssetID RENDER_SC_FS = 36869006; renderToSwapchainFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(RENDER_SC_FS);
static constexpr AssetID SHADOW_MAP_VS = 44646107; shadowMapVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_VS);
static constexpr AssetID SHADOW_MAP_FS = 45925790; shadowMapFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_FS);
}
@ -583,14 +586,21 @@ namespace SHADE
#endif
}
//if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::B))
//{
// auto& lightComps = SHComponentManager::GetDense<SHLightComponent>();
static bool shadowAdded = false;
if (shadowAdded == false/* && SHInputManager::GetKey(SHInputManager::SH_KEYCODE::B)*/)
{
shadowAdded = true;
auto& lightComps = SHComponentManager::GetDense<SHLightComponent>();
if (lightComps.size() > 2)
{
lightComps[2].SetEnableShadow(true);
}
//for (auto& comp : lightComps)
//{
// comp.SetEnableShadow(true);
//}
//}
}
renderGraph->Begin(frameIndex);
auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex);
@ -809,11 +819,11 @@ namespace SHADE
tempLibrary.Init(device);
tempLibrary.CreateGraphicsPipelines
(
{ shadowMapVS, {} }, shadowMapNode->GetRenderpass(), newSubpass,
{ shadowMapVS, shadowMapFS }, shadowMapNode->GetRenderpass(), newSubpass,
SHGraphicsPredefinedData::SystemType::BATCHING,
SHGraphicsPredefinedData::GetShadowMapViState(), rasterState
);
shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, {} });
shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, shadowMapFS });
}
newSubpass->SetCompanionSubpass(companionSubpass, shadowMapPipeline); // set companion subpass and pipeline

View File

@ -469,6 +469,7 @@ namespace SHADE
Handle<SHVkShaderModule> renderToSwapchainVS;
Handle<SHVkShaderModule> renderToSwapchainFS;
Handle<SHVkShaderModule> shadowMapVS;
Handle<SHVkShaderModule> shadowMapFS;
// Fonts
Handle<SHFont> testFont;

View File

@ -166,7 +166,7 @@ namespace SHADE
/* Public Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
void SHCollisionTagMatrix::Init(const std::filesystem::path& tagNameFilePath) noexcept
void SHCollisionTagMatrix::LoadFromFile(const std::filesystem::path& tagNameFilePath) noexcept
{
/**
* I HATE FILE IO
@ -240,13 +240,17 @@ namespace SHADE
, linesRead + 1
, tagIndex
)
collisionTags[tagIndex].SetMask(mask);
}
else
{
mask = static_cast<uint16_t>(std::stoi(maskString));
for (int i = 0; i < SHCollisionTag::NUM_LAYERS; ++i)
{
const bool LAYER_STATE = maskString[i] == '1';
collisionTags[tagIndex].SetLayerState(i, LAYER_STATE);
}
}
collisionTags[tagIndex].SetMask(mask);
ss.clear();
}
@ -254,7 +258,7 @@ namespace SHADE
collisionTagNamesFile.close();
}
void SHCollisionTagMatrix::Exit(const std::filesystem::path& tagNameFilePath) noexcept
void SHCollisionTagMatrix::SaveToFile(const std::filesystem::path& tagNameFilePath) noexcept
{
std::ofstream collisionTagNamesFile { tagNameFilePath };
@ -266,7 +270,15 @@ namespace SHADE
// Index Name Mask
for (int i = 0; i < SHCollisionTag::NUM_LAYERS; ++i)
collisionTagNamesFile << i << " " << collisionTags[i].GetName() << " " << collisionTags[i].GetMask() << std::endl;
{
collisionTagNamesFile << i << " " << collisionTags[i].GetName() << " ";
// Write 1 or 0 for each layer for improved clarity
for (int j = 0; j < SHCollisionTag::NUM_LAYERS; ++j)
collisionTagNamesFile << (collisionTags[i].GetMask() & 1U << j ? 1 : 0);
collisionTagNamesFile << std::endl;
}
collisionTagNamesFile.close();
}

View File

@ -55,8 +55,8 @@ namespace SHADE
/* Function Members */
/*---------------------------------------------------------------------------------*/
static void Init (const std::filesystem::path& tagNameFilePath) noexcept;
static void Exit (const std::filesystem::path& tagNameFilePath) noexcept;
static void LoadFromFile (const std::filesystem::path& tagNameFilePath) noexcept;
static void SaveToFile (const std::filesystem::path& tagNameFilePath) noexcept;
/**
* @brief

View File

@ -120,8 +120,11 @@ namespace SHADE
collisionTag = newCollisionTag;
if (rp3dCollider)
{
rp3dCollider->setCollisionCategoryBits(collisionTag->GetMask());
rp3dCollider->setCollideWithMaskBits(collisionTag->GetMask());
}
}
void SHCollisionShape::SetFriction(float friction) noexcept
{
@ -144,7 +147,12 @@ namespace SHADE
material.SetDensity(density);
if (rp3dCollider)
{
rp3dCollider->getMaterial().setMassDensity(material.GetDensity());
// Recompute the bodies' mass
dynamic_cast<rp3d::RigidBody*>(collider->collisionBody)->updateMassPropertiesFromColliders();
}
}
void SHCollisionShape::SetMaterial(const SHPhysicsMaterial& newMaterial) noexcept
@ -157,6 +165,9 @@ namespace SHADE
rp3dMaterial.setFrictionCoefficient(material.GetFriction());
rp3dMaterial.setBounciness(material.GetBounciness());
rp3dMaterial.setMassDensity(material.GetDensity());
// Recompute the bodies' mass
dynamic_cast<rp3d::RigidBody*>(collider->collisionBody)->updateMassPropertiesFromColliders();
}
}
@ -180,7 +191,13 @@ namespace SHADE
isTrigger ? flags |= FLAG_VALUE : flags &= ~FLAG_VALUE;
if (rp3dCollider)
{
rp3dCollider->setIsTrigger(isTrigger);
// Recompute the bodies' mass
dynamic_cast<rp3d::RigidBody*>(collider->collisionBody)->updateMassPropertiesFromColliders();
}
}
/*-----------------------------------------------------------------------------------*/
@ -189,9 +206,12 @@ namespace SHADE
void SHCollisionShape::UpdateCollisionTags() noexcept
{
if (collisionTag->IsDirty())
if (rp3dCollider && collisionTag->IsDirty())
{
rp3dCollider->setCollisionCategoryBits(collisionTag->GetMask());
rp3dCollider->setCollideWithMaskBits(collisionTag->GetMask());
}
}
void SHCollisionShape::Update() noexcept

View File

@ -210,9 +210,6 @@ namespace SHADE
{
.entityID = rigidBody->GetEID()
, .bodyType = rigidBody->type
, .interpolate = rigidBody->interpolate
, .drag = rigidBody->drag
, .angularDrag = rigidBody->angularDrag
};
rigidBodyQueue.push(RIGID_BODY_DEF);
@ -232,22 +229,8 @@ namespace SHADE
SHColliderDef::ShapeDef shapeDef
{
.type = shape->GetType()
, .posOffset = shape->GetPositionOffset()
, .rotOffset = shape->GetRotationOffset()
};
switch (shape->GetType())
{
case SHCollisionShape::Type::SPHERE:
shapeDef.size.x = dynamic_cast<const SHSphere*>(shape)->GetWorldRadius();
break;
case SHCollisionShape::Type::BOX:
shapeDef.size = dynamic_cast<const SHBox*>(shape)->GetWorldExtents();
break;
default:
break;
}
colliderDef.shapes.emplace_back(shapeDef);
}
@ -311,9 +294,9 @@ namespace SHADE
rigidBodyComponent->SetFreezeRotationY (rigidBodyComponent->GetFreezeRotationY());
rigidBodyComponent->SetFreezeRotationZ (rigidBodyComponent->GetFreezeRotationZ());
rigidBodyComponent->SetInterpolate (DEF.interpolate);
rigidBodyComponent->SetDrag (DEF.drag);
rigidBodyComponent->SetAngularDrag (DEF.angularDrag);
rigidBodyComponent->SetInterpolate (rigidBodyComponent->IsInterpolating());
rigidBodyComponent->SetDrag (rigidBodyComponent->GetDrag());
rigidBodyComponent->SetAngularDrag (rigidBodyComponent->GetAngularDrag());
rigidBodyQueue.pop();
}

View File

@ -47,9 +47,6 @@ namespace SHADE
{
EntityID entityID = MAX_EID;
SHRigidBodyComponent::Type bodyType = SHRigidBodyComponent::Type::STATIC;
bool interpolate = true;
float drag = 0.0f;
float angularDrag = 0.0f;
};
struct SHColliderDef
@ -57,9 +54,6 @@ namespace SHADE
struct ShapeDef
{
SHCollisionShape::Type type = SHCollisionShape::Type::SPHERE;
SHVec3 posOffset = SHVec3::Zero;
SHVec3 rotOffset = SHVec3::Zero;
SHVec3 size = SHVec3::Zero; // x for sphere radius, all 3 for box extents
};
EntityID entityID = MAX_EID;

View File

@ -42,6 +42,7 @@ namespace SHADE
/* Friends */
/*---------------------------------------------------------------------------------*/
friend class SHCollisionShape;
friend class SHPhysicsSystem;
friend class SHPhysicsObjectManager;

View File

@ -94,8 +94,8 @@ namespace SHADE
{
const bool CLEAR_EVENT = C_INFO.GetCollisionState() == SHCollisionInfo::State::EXIT || C_INFO.GetCollisionState() == SHCollisionInfo::State::INVALID;
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityA())
|| !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndHasComponentsActive<SHColliderComponent>(C_INFO.GetEntityA())
|| !SHSceneManager::CheckNodeAndHasComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
if (CLEAR_EVENT || INACTIVE_OBJECT)
{

View File

@ -122,7 +122,7 @@ namespace SHADE
// Initialise collision tags
std::filesystem::path defaultCollisionTagNameFilePath { ASSET_ROOT };
defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig");
SHCollisionTagMatrix::Init(defaultCollisionTagNameFilePath);
SHCollisionTagMatrix::LoadFromFile(defaultCollisionTagNameFilePath);
// Register Events
for (int i = 0; i < NUM_EVENT_FUNCTIONS; ++i)
@ -145,7 +145,7 @@ namespace SHADE
// Write collision tag names to file
std::filesystem::path defaultCollisionTagNameFilePath { ASSET_ROOT };
defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig");
SHCollisionTagMatrix::Exit(defaultCollisionTagNameFilePath);
SHCollisionTagMatrix::SaveToFile(defaultCollisionTagNameFilePath);
}
const std::vector<SHPhysicsRaycastResult>& SHPhysicsSystem::Raycast(const SHRaycaster::RaycastInfo& info) noexcept
@ -155,7 +155,7 @@ namespace SHADE
// Load start and end points into the container for debug drawing
#ifdef SHEDITOR
SHVec3 endPos = info.ray.position + info.ray.direction * SHRay::MAX_RAYCAST_DIST;
SHVec3 endPos = info.ray.position + info.ray.direction * std::clamp(info.distance, 0.0f, SHRay::MAX_RAYCAST_DIST);
if (!results.empty())
endPos = results.back().position;

View File

@ -170,10 +170,7 @@ namespace SHADE
SHCollisionListener collisionListener;
SHRaycaster raycaster;
// For the debug drawer to draw rays
#ifdef SHEDITOR
std::vector<RaycastHit> raycastHits;
#endif
/*---------------------------------------------------------------------------------*/
/* Function Members */

View File

@ -261,6 +261,7 @@ namespace SHADE
<TargetFramework>net5.0</TargetFramework>\n\
<Platforms>x64</Platforms>\n\
<Configurations>Release;Debug</Configurations>\n\
<DefaultItemExcludes>$(DefaultItemExcludes);**/*.shmeta</DefaultItemExcludes>\n\
</PropertyGroup>\n\
<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n\
<OutputPath>.\\bin\\Release</OutputPath>\n\
@ -283,7 +284,6 @@ namespace SHADE
<ItemGroup>\n\
<None Remove=\".gitignore\" />\n\
<None Remove=\".gitmodules\" />\n\
<None Remove=\"*.shmeta\" />\n\
</ItemGroup>\n\
<ItemGroup>\n\
<Reference Include=\"SHADE_Managed\">\n";

View File

@ -99,6 +99,31 @@ namespace SHADE
audioSys->StopAllSounds();
}
float Audio::GetVCAVolume(System::String^ path)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
return audioSys->GetVCAVolume(Convert::ToNative(path).data());
}
void Audio::SetVCAVolume(System::String^ path, float volume)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->SetVCAVolume(Convert::ToNative(path).data(), volume);
}
float Audio::GetParameterValue(System::String^ path)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
return audioSys->GetParameterValue(Convert::ToNative(path).data());
}
void Audio::SetParameter(System::String^ path, float value)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->SetParameter(Convert::ToNative(path).data(), value);
}
AudioClipHandler Audio::CreateAudioClip(System::String^ path)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();

View File

@ -101,6 +101,10 @@ namespace SHADE
/// </summary>
static void StopAllSounds();
static float GetVCAVolume(System::String^ path);
static void SetVCAVolume(System::String^ path, float volume);
static float GetParameterValue(System::String^ path);
static void SetParameter(System::String^ path, float value);
//to comment ltr
static AudioClipHandler CreateAudioClip(System::String^ path);

View File

@ -84,6 +84,14 @@ namespace SHADE
return NativeObject->GetParameterValue(Convert::ToNative(paramName).data());
}
float AudioClipHandler::GetVolume()
{
return NativeObject->GetVolume();
}
void AudioClipHandler::SetVolume(float volume)
{
NativeObject->SetVolume(volume);
}
}

View File

@ -72,6 +72,8 @@ namespace SHADE
bool IsPaused();
void SetParameter(System::String^ paramName, float value);
float GetParameterValue(System::String^ paramName);
float GetVolume();
void SetVolume(float volume);
protected:
/*-----------------------------------------------------------------------------*/

View File

@ -28,25 +28,32 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
bool Application::IsPlaying::get()
{
#ifdef SHEDITOR
auto editor = SHSystemManager::GetSystem<SHEditor>();
if (editor)
return editor->editorState == SHEditor::State::PLAY
||
editor->editorState == SHEditor::State::PAUSE;
#endif
return true;
}
bool Application::IsPaused::get()
{
#ifdef SHEDITOR
auto editor = SHSystemManager::GetSystem<SHEditor>();
if (editor)
return editor->editorState == SHEditor::State::PAUSE;
#endif
return false;
}
bool Application::IsEditor::get()
{
#ifdef SHEDITOR
return SHSystemManager::GetSystem<SHEditor>() != nullptr;
#else
return false;
#endif
}
int Application::WindowWidth::get()
{