Added controls to adjust editor camera movement speed and turn speed #216

Merged
srishamharan merged 5 commits from SP3-4-Editor into main 2022-11-17 17:12:16 +08:00
4 changed files with 49 additions and 22 deletions
Showing only changes of commit edd44604f1 - Show all commits

View File

@ -17,6 +17,7 @@ of DigiPen Institute of Technology is prohibited.
// Project Includes
#include "Resource/SHHandle.h"
#include "SHCommonTypes.h"
#include "SH_API.h"
namespace SHADE
{
@ -35,7 +36,7 @@ namespace SHADE
Describes a Pipeline along with it's associated properties for this instance.
*/
/***********************************************************************************/
class SHMaterial
class SH_API SHMaterial
{
public:
/*-----------------------------------------------------------------------------*/

View File

@ -43,9 +43,9 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
struct OverrideData
{
size_t Index;
size_t DataSize;
size_t StoredDataOffset;
uint32_t Index;
uint32_t DataSize;
uint32_t StoredDataOffset;
};
/*-----------------------------------------------------------------------------*/

View File

@ -11,6 +11,7 @@ of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
#include "SHMaterialInstance.h"
#include "SHMaterial.h"
namespace SHADE
{
@ -34,26 +35,39 @@ namespace SHADE
dataStore.reset(new char[dataStoreSize]);
}
OverrideData od;
od.Index = SHADER_INFO->GetVariableIndex(key);
od.DataSize = sizeof(T);
if (overrideData.empty())
// Check if this was stored before
const uint32_t VAR_IDX = SHADER_INFO->GetVariableIndex(key);
auto existingOverride = std::find_if(overrideData.begin(), overrideData.end(), [&](const OverrideData& od)
{
od.StoredDataOffset = 0;
}
else
return od.Index == VAR_IDX;
});
// Otherwise, create it
if (existingOverride == overrideData.end())
{
const OverrideData& lastInsertedData = overrideData.back();
od.StoredDataOffset = lastInsertedData.StoredDataOffset + lastInsertedData.DataSize;
OverrideData od;
od.Index = VAR_IDX;
od.DataSize = sizeof(T);
if (overrideData.empty())
{
od.StoredDataOffset = 0;
}
else
{
const OverrideData& lastInsertedData = overrideData.back();
od.StoredDataOffset = lastInsertedData.StoredDataOffset + lastInsertedData.DataSize;
}
// Save the override data information
overrideData.emplace_back(std::move(od));
existingOverride = overrideData.end() - 1;
}
// Get offset and modify the memory directly
T* dataPtr = reinterpret_cast<T*>(dataStore.get() + od.StoredDataOffset);
T* dataPtr = reinterpret_cast<T*>(dataStore.get() + existingOverride->StoredDataOffset);
*dataPtr = value;
// Save the override data information
overrideData.emplace_back(std::move(od));
// Flag
dataWasChanged = true;
}
@ -70,11 +84,22 @@ namespace SHADE
// Search Override Data for the property
uint32_t PROP_IDX = SHADER_INFO->GetVariableIndex(key);
auto prop = std::find_if(overrideData.begin(), overrideData.end(), [&](const OverrideData& data)
{
return PROP_IDX == data.Index;
});
{
return PROP_IDX == data.Index;
});
// No overrides, we get from the base material instead
if (prop == overrideData.end())
throw std::invalid_argument("Attempted to get an property that was not set previously!");
{
if (baseMaterial)
{
return baseMaterial->GetProperty<T>(key);
}
else
{
throw std::invalid_argument("Attempted to get an property that was not set previously!");
}
}
// Get offset and return the memory directly
T* dataPtr = reinterpret_cast<T*>(dataStore.get() + prop->StoredDataOffset);

View File

@ -91,6 +91,7 @@ namespace SHADE
{
SHGraphicsSystem* gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
material = gfxSystem->AddMaterialInstanceCopy(sharedMaterial);
matChanged = true;
}
return material;