Merge remote-tracking branch 'origin/main' into SP3-2-Physics

This commit is contained in:
Diren D Bharwani 2022-11-14 00:25:52 +08:00
commit 3c61b7519b
21 changed files with 1545 additions and 5027 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,55 @@
Name: HouseModular
ID: 75328301
Type: 4
Sub Assets:
Name: FloorLarge
ID: 142812576
Type: 8
Name: FloorSmall
ID: 139921228
Type: 8
Name: FloorLong
ID: 136991843
Type: 8
Name: Pillar
ID: 150352316
Type: 8
Name: WallEnd
ID: 139594893
Type: 8
Name: WallCorner
ID: 134714737
Type: 8
Name: WallDefault
ID: 140834166
Type: 8
Name: WallLarge
ID: 142689599
Type: 8
Name: WallDiagonal
ID: 144002377
Type: 8
Name: WallTBlock
ID: 149359798
Type: 8
Name: WindowLarge
ID: 148351779
Type: 8
Name: WindowSmallOpened
ID: 149786048
Type: 8
Name: WindowSmallClosed
ID: 147863396
Type: 8
Name: WindowLargeOpen
ID: 138781993
Type: 8
Name: WallDoorHole
ID: 150924328
Type: 8
Name: Door
ID: 147152385
Type: 8
Name: DoorFrame
ID: 146862321
Type: 8

View File

@ -0,0 +1,3 @@
Name: AIPrototype
ID: 163215061
Type: 9

View File

@ -0,0 +1,3 @@
Name: CameraControl
ID: 158782344
Type: 9

View File

@ -0,0 +1,3 @@
Name: CameraFix
ID: 162231964
Type: 9

View File

@ -0,0 +1,3 @@
Name: Item
ID: 163145289
Type: 9

View File

@ -0,0 +1,3 @@
Name: PhysicsTest
ID: 159771801
Type: 9

View File

@ -0,0 +1,3 @@
Name: PickAndThrow
ID: 165331952
Type: 9

View File

@ -0,0 +1,3 @@
Name: PlayerController
ID: 164563088
Type: 9

View File

@ -0,0 +1,3 @@
Name: PrintWhenActive
ID: 162536221
Type: 9

View File

@ -0,0 +1,3 @@
Name: RaccoonShowcase
ID: 159969631
Type: 9

View File

@ -0,0 +1,3 @@
Name: RaccoonSpin
ID: 157367824
Type: 9

View File

@ -0,0 +1,3 @@
Name: ThirdPersonCamera
ID: 154161201
Type: 9

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -83,7 +83,7 @@ namespace SHADE
AssetPath SHAssetManager::GenerateLocalPath(AssetPath path) noexcept
{
if (!IsRecognised(path.extension().string().c_str()))
if (!SHFileSystem::IsRecognised(path.extension().string().c_str()))
{
//TODO:ASSERT UNRECOGNISED FILE TYPE
return std::filesystem::path();
@ -380,19 +380,6 @@ namespace SHADE
BuildAssetCollection();
}
bool SHAssetManager::IsRecognised(char const* ext) noexcept
{
for (auto const& e : EXTENSIONS)
{
if (strcmp(ext, e.data()) == 0)
{
return true;
}
}
return false;
}
SHAsset SHAssetManager::CreateAssetFromPath(AssetPath path) noexcept
{
SHAsset result;
@ -500,7 +487,7 @@ namespace SHADE
{
}
void SHAssetManager::GenerateNewMeta(AssetPath path) noexcept
std::optional<AssetID> SHAssetManager::GenerateNewMeta(AssetPath path) noexcept
{
auto const ext = path.extension().string();
if (ext == SHADER_BUILT_IN_EXTENSION.data())
@ -561,11 +548,32 @@ namespace SHADE
SHAssetMetaHandler::WriteMetaData(assetCollection[newAsset.id]);
}
else if (ext == SCRIPT_EXTENSION)
{
SHAsset newAsset{
path.stem().string(),
GenerateAssetID(AssetType::SCRIPT),
AssetType::SCRIPT,
path,
false
};
assetCollection.emplace(newAsset.id, newAsset);
SHAssetMetaHandler::WriteMetaData(newAsset);
return newAsset.id;
}
}
void SHAssetManager::BuildAssetCollection() noexcept
{
SHFileSystem::BuildDirectory(ASSET_ROOT.data(), folderRoot, assetCollection);
std::vector<SHFile*> toGenNew;
SHFileSystem::BuildDirectory(ASSET_ROOT.data(), folderRoot, assetCollection, toGenNew);
for (auto& file : toGenNew)
{
auto newID{ GenerateNewMeta(file->path).value() };
file->assetMeta = &assetCollection[newID];
}
for (auto& asset : std::ranges::views::values(assetCollection))
{

View File

@ -99,12 +99,10 @@ namespace SHADE
static SHAssetData* LoadData(SHAsset const& asset) noexcept;
static SHAssetData* LoadSubData(SHAsset const& asset) noexcept;
static void LoadNewData(AssetPath path) noexcept;
static void GenerateNewMeta(AssetPath path) noexcept;
static std::optional<AssetID> GenerateNewMeta(AssetPath path) noexcept;
inline static void BuildAssetCollection() noexcept;
static bool IsRecognised(char const*) noexcept;
static SHAsset CreateAssetFromPath(AssetPath path) noexcept;
static bool DeleteLocalFile(AssetPath path) noexcept;

View File

@ -25,6 +25,19 @@ namespace SHADE
return true;
}
bool SHFileSystem::IsRecognised(char const* ext) noexcept
{
for (auto const& e : EXTENSIONS)
{
if (strcmp(ext, e.data()) == 0)
{
return true;
}
}
return false;
}
bool SHFileSystem::IsCompilable(std::string ext) noexcept
{
for (auto const& external : EXTERNALS)
@ -73,7 +86,11 @@ namespace SHADE
return false;
}
void SHFileSystem::BuildDirectory(FolderPath path, FolderPointer& root, std::unordered_map<AssetID, SHAsset>& assetCollection) noexcept
void SHFileSystem::BuildDirectory(
FolderPath path,
FolderPointer& root,
std::unordered_map<AssetID, SHAsset>& assetCollection,
std::vector<SHFile*>& toGenerate) noexcept
{
std::stack<FolderPointer> folderStack;
root = new SHFolder("root");
@ -117,22 +134,50 @@ namespace SHADE
folderStack.push(newFolder);
}
for (auto const& asset : assets)
for (auto& file : folder->files)
{
assetCollection.emplace(asset.id, asset);
for(auto& file : folder->files)
if (!IsRecognised(file.ext.c_str()))
{
continue;
}
bool found{ false };
for (auto const& asset : assets)
{
assetCollection.emplace(asset.id, asset);
if (file.name == asset.name)
{
AssetPath path{ file.path };
if (SHAssetMetaHandler::GetTypeFromExtension(path.extension().string()) == asset.type)
{
file.assetMeta = &assetCollection[asset.id];
found = true;
break;
}
}
}
if (!found)
{
toGenerate.push_back(&file);
}
}
//for (auto const& asset : assets)
//{
// assetCollection.emplace(asset.id, asset);
// for(auto& file : folder->files)
// {
// if (file.name == asset.name)
// {
// AssetPath path{ file.path };
// if (SHAssetMetaHandler::GetTypeFromExtension(path.extension().string()) == asset.type)
// {
// file.assetMeta = &assetCollection[asset.id];
// break;
// }
// }
// }
//}
for (auto i {0}; i < folder->files.size(); ++i)
{

View File

@ -19,8 +19,14 @@ namespace SHADE
class SHFileSystem
{
public:
static void BuildDirectory(FolderPath path, FolderPointer& root, std::unordered_map<AssetID, SHAsset>& assetCollection) noexcept;
static void BuildDirectory(
FolderPath path,
FolderPointer& root,
std::unordered_map<AssetID, SHAsset>& assetCollection,
std::vector<SHFile*>& toGenerate) noexcept;
static void DestroyDirectory(FolderPointer root) noexcept;
static bool IsRecognised(char const*) noexcept;
private:
static bool DeleteFolder(FolderPointer location) noexcept;
static bool IsCompilable(std::string ext) noexcept;

View File

@ -238,8 +238,13 @@ namespace SHADE
void SHScriptEngine::GenerateScriptsCsProjFile(const std::filesystem::path& path) const
{
// Compute relative path
const std::filesystem::path EXE_DIR = std::filesystem::current_path();
const std::filesystem::path MANAGED_DLL_DIR = EXE_DIR / "SHADE_Managed.dll";
const std::filesystem::path CS_DLL_DIR = EXE_DIR / "SHADE_CSharp.dll";
// Sample
static std::string_view FILE_CONTENTS =
static std::string_view FILE_CONTENTS_BEGIN =
"<Project Sdk=\"Microsoft.NET.Sdk\">\n\
<PropertyGroup>\n\
<TargetFramework>net5.0</TargetFramework>\n\
@ -269,14 +274,12 @@ namespace SHADE
<None Remove=\".gitmodules\" />\n\
</ItemGroup>\n\
<ItemGroup>\n\
<Reference Include=\"SHADE_Managed\">\n\
<HintPath Condition=\"Exists('..\\..\\bin\\Debug\\SHADE_Managed.dll')\">..\\..\\bin\\Debug\\SHADE_Managed.dll</HintPath>\n\
<HintPath Condition=\"Exists('..\\..\\bin\\Release\\SHADE_Managed.dll')\">..\\..\\bin\\Release\\SHADE_Managed.dll</HintPath>\n\
</Reference>\n\
<Reference Include=\"SHADE_CSharp\">\n\
<HintPath Condition=\"Exists('..\\..\\bin\\Debug\\SHADE_Managed.dll')\">..\\..\\bin\\Debug\\SHADE_CSharp.dll</HintPath>\n\
<HintPath Condition=\"Exists('..\\..\\bin\\Release\\SHADE_Managed.dll')\">..\\..\\bin\\Release\\SHADE_CSharp.dll</HintPath>\n\
</Reference>\n\
<Reference Include=\"SHADE_Managed\">\n";
static std::string_view FILE_CONTENTS_MID =
" </Reference>\n\
<Reference Include=\"SHADE_CSharp\">\n";
static std::string_view FILE_CONTENTS_END =
" </Reference>\n\
</ItemGroup>\n\
</Project>";
@ -286,7 +289,12 @@ namespace SHADE
throw std::runtime_error("Unable to create CsProj file!");
// Fill the file
file << FILE_CONTENTS;
const std::filesystem::path CSPROJ_DIR = path.parent_path();
file << FILE_CONTENTS_BEGIN
<< " <HintPath>" << std::filesystem::relative(MANAGED_DLL_DIR, CSPROJ_DIR).string() << "</HintPath>\n"
<< FILE_CONTENTS_MID
<< " <HintPath>" << std::filesystem::relative(CS_DLL_DIR, CSPROJ_DIR).string() << "</HintPath>\n"
<< FILE_CONTENTS_END;
// Close
file.close();