From 62433d1a5360d060679681aeb6fb71d70c651326 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Sun, 20 Nov 2022 02:35:02 +0800 Subject: [PATCH 1/7] Added Collision Tags --- .../src/Physics/Collision/SHCollisionTags.cpp | 176 ++++++++++++++++++ .../src/Physics/Collision/SHCollisionTags.h | 125 +++++++++++++ .../Physics/Interface/SHCollisionShape.cpp | 17 ++ .../src/Physics/Interface/SHCollisionShape.h | 6 + .../Physics/PhysicsObject/SHPhysicsObject.cpp | 8 + .../Physics/PhysicsObject/SHPhysicsObject.h | 1 + 6 files changed, 333 insertions(+) create mode 100644 SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp create mode 100644 SHADE_Engine/src/Physics/Collision/SHCollisionTags.h diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp new file mode 100644 index 00000000..fdcf72c6 --- /dev/null +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp @@ -0,0 +1,176 @@ +/**************************************************************************************** + * \file SHCollisionTags.cpp + * \author Diren D Bharwani, diren.dbharwani, 390002520 + * \brief Implementation for Collision Tags for filtering collisions. + * + * \copyright Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or + * disclosure of this file or its contents without the prior written consent + * of DigiPen Institute of Technology is prohibited. +****************************************************************************************/ + +#include + +// Primary Header +#include "SHCollisionTags.h" +// Project Headers +#include "SHCollisionTags.h" + +#include "Tools/Utilities/SHUtilities.h" + +namespace SHADE +{ + /*-----------------------------------------------------------------------------------*/ + /* Static Data Member Definitions */ + /*-----------------------------------------------------------------------------------*/ + + std::string SHCollisionTag::tagNames[NUM_TAGS]; + + /*-----------------------------------------------------------------------------------*/ + /* Constructors & Destructor Definitions */ + /*-----------------------------------------------------------------------------------*/ + + SHCollisionTag::SHCollisionTag() noexcept + : mask { SHUtilities::ConvertEnum(eTag::ALL_TAGS) } + {} + + SHCollisionTag::SHCollisionTag(uint16_t tagValue) noexcept + : mask { tagValue } + {} + + SHCollisionTag::SHCollisionTag(eTag tagValue) noexcept + : mask { SHUtilities::ConvertEnum(tagValue) } + {} + + /*-----------------------------------------------------------------------------------*/ + /* Operator Overload Definitions */ + /*-----------------------------------------------------------------------------------*/ + + bool SHCollisionTag::operator==(const SHCollisionTag& rhs) const noexcept + { + return mask == rhs.mask; + } + + bool SHCollisionTag::operator!=(const SHCollisionTag& rhs) const noexcept + { + return mask != rhs.mask; + } + + SHCollisionTag::operator uint16_t() const noexcept + { + return mask; + } + + /*-----------------------------------------------------------------------------------*/ + /* Getter Function Definitions */ + /*-----------------------------------------------------------------------------------*/ + + uint16_t SHCollisionTag::GetTagValue() const noexcept + { + return mask; + } + + bool SHCollisionTag::GetTagState(eTag tag) const noexcept + { + return (mask & SHUtilities::ConvertEnum(tag)) > 0; + } + + bool SHCollisionTag::GetTagState(int tagIndex) const + { + if (tagIndex < 0 || tagIndex > NUM_TAGS) + throw std::invalid_argument("Index out of range!"); + + return (mask & (1U << tagIndex)) > 0; + } + + + /*-----------------------------------------------------------------------------------*/ + /* Setter Function Definitions */ + /*-----------------------------------------------------------------------------------*/ + + void SHCollisionTag::SetValue(uint16_t tagValue) noexcept + { + mask = tagValue; + } + + void SHCollisionTag::SetTagState(eTag tag, bool tagState) noexcept + { + const auto VALUE = SHUtilities::ConvertEnum(tag); + tagState ? mask |= VALUE : mask &= ~(VALUE); + } + + void SHCollisionTag::SetTagState(const std::string& tagName, bool tagState) noexcept + { + // This find is expensive. + int tagIndex = -1; + for (int i = 0; i < NUM_TAGS; ++i) + { + if (tagNames[i] != tagName) + continue; + + tagIndex = i; + break; + } + + if (tagIndex < 0) + { + SHLOGV_WARNING("Parameter tagName {} not found in list of tag names. Tag unmodified.", tagName) + return; + } + + const auto VALUE = 1U << tagIndex; + tagState ? mask |= (VALUE) : mask &= ~(VALUE); + } + + void SHCollisionTag::SetTagState(int tagIndex, bool tagState) + { + if (tagIndex < 0 || tagIndex > NUM_TAGS) + throw std::invalid_argument("Index out of range!"); + + const auto VALUE = 1U << tagIndex; + tagState ? mask |= (VALUE) : mask &= ~(VALUE); + } + + /*-----------------------------------------------------------------------------------*/ + /* Public Function Member Definitions */ + /*-----------------------------------------------------------------------------------*/ + + void SHCollisionTag::Init(const std::filesystem::path& tagNameFilePath) noexcept + { + // Read tag names from given file. + } + + void SHCollisionTag::Exit(const std::filesystem::path& tagNameFilePath) noexcept + { + // Write current set of names to file. + // This ensures any names changed is reflected on the file for the next run of the application. + } + + void SHCollisionTag::RemoveTagName(int tagIndex) + { + if (tagIndex < 0 || tagIndex > NUM_TAGS) + throw std::invalid_argument("Index out of range!"); + + tagNames[tagIndex].clear(); + } + + void SHCollisionTag::SetTagName(const std::string& newTagName, int tagIndex) + { + if (tagIndex < 0 || tagIndex > NUM_TAGS) + throw std::invalid_argument("Index out of range!"); + + tagNames[tagIndex] = newTagName; + } + + const std::string& SHCollisionTag::GetTagName(int tagIndex) + { + if (tagIndex < 0 || tagIndex > NUM_TAGS) + throw std::invalid_argument("Index out of range!"); + + return tagNames[tagIndex]; + } +} // namespace SHADE + +SHADE::SHCollisionTag::eTag operator|(SHADE::SHCollisionTag::eTag lhs, SHADE::SHCollisionTag::eTag rhs) noexcept +{ + return static_cast(SHADE::SHUtilities::ConvertEnum(lhs) | SHADE::SHUtilities::ConvertEnum(rhs)); +} \ No newline at end of file diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h new file mode 100644 index 00000000..e43aae2d --- /dev/null +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h @@ -0,0 +1,125 @@ +/**************************************************************************************** + * \file SHCollisionTags.h + * \author Diren D Bharwani, diren.dbharwani, 390002520 + * \brief Interface for Collision Tags for filtering collisions. + * + * \copyright Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or + * disclosure of this file or its contents without the prior written consent + * of DigiPen Institute of Technology is prohibited. +****************************************************************************************/ + +#pragma once + +#include + +// Project Headers +#include "SH_API.h" + +namespace SHADE +{ + /*-----------------------------------------------------------------------------------*/ + /* Type Definitions */ + /*-----------------------------------------------------------------------------------*/ + + class SH_API SHCollisionTag + { + public: + /*---------------------------------------------------------------------------------*/ + /* Type Definitions */ + /*---------------------------------------------------------------------------------*/ + + enum class eTag : uint16_t + { + TAG_1 = 0x0001 + , TAG_2 = 0x0002 + , TAG_3 = 0x0004 + , TAG_4 = 0x0008 + , TAG_5 = 0x0010 + , TAG_6 = 0x0020 + , TAG_7 = 0x0040 + , TAG_8 = 0x0080 + , TAG_9 = 0x0100 + , TAG_10 = 0x0200 + , TAG_11 = 0x0400 + , TAG_12 = 0x0800 + , TAG_13 = 0x1000 + , TAG_14 = 0x2000 + , TAG_15 = 0x4000 + , TAG_16 = 0x8000 + , ALL_TAGS = 0xFFFF + }; + + /*---------------------------------------------------------------------------------*/ + /* Constructors & Destructor */ + /*---------------------------------------------------------------------------------*/ + + SHCollisionTag () noexcept; + SHCollisionTag (uint16_t tagValue) noexcept; + SHCollisionTag (eTag tagValue) noexcept; + + SHCollisionTag (const SHCollisionTag&) noexcept = default; + SHCollisionTag (SHCollisionTag&&) noexcept = default; + ~SHCollisionTag () = default; + + /*---------------------------------------------------------------------------------*/ + /* Operator Overloads */ + /*---------------------------------------------------------------------------------*/ + + SHCollisionTag& operator=(const SHCollisionTag&) noexcept = default; + SHCollisionTag& operator=(SHCollisionTag&&) noexcept = default; + + [[nodiscard]] bool operator==(const SHCollisionTag& rhs) const noexcept; + [[nodiscard]] bool operator!=(const SHCollisionTag& rhs) const noexcept; + + operator uint16_t() const noexcept; + + /*---------------------------------------------------------------------------------*/ + /* Getter Functions */ + /*---------------------------------------------------------------------------------*/ + + [[nodiscard]] uint16_t GetTagValue () const noexcept; + [[nodiscard]] bool GetTagState (eTag tag) const noexcept; + [[nodiscard]] bool GetTagState (int tagIndex) const; + + /*---------------------------------------------------------------------------------*/ + /* Setter Functions */ + /*---------------------------------------------------------------------------------*/ + + void SetValue (uint16_t tagValue) noexcept; + + void SetTagState (eTag tag, bool tagState) noexcept; + void SetTagState (const std::string& tagName, bool tagState) noexcept; + void SetTagState (int tagIndex, bool tagState); + + /*---------------------------------------------------------------------------------*/ + /* Function Members */ + /*---------------------------------------------------------------------------------*/ + + static void Init (const std::filesystem::path& tagNameFilePath) noexcept; + static void Exit (const std::filesystem::path& tagNameFilePath) noexcept; + + static void SetTagName (const std::string& newTagName, int tagIndex); + static void RemoveTagName (int tagIndex); + + [[nodiscard]] static const std::string& GetTagName (int tagIndex); + + private: + /*---------------------------------------------------------------------------------*/ + /* Static Data Members */ + /*---------------------------------------------------------------------------------*/ + + static constexpr int NUM_TAGS = 16; + static std::string tagNames[NUM_TAGS]; + + /*---------------------------------------------------------------------------------*/ + /* Data Members */ + /*---------------------------------------------------------------------------------*/ + + uint16_t mask; + }; + +} // namespace SHADE + +SHADE::SHCollisionTag::eTag SH_API operator|(SHADE::SHCollisionTag::eTag lhs, SHADE::SHCollisionTag::eTag rhs) noexcept; + + diff --git a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp index 14743845..46348c19 100644 --- a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp +++ b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp @@ -134,6 +134,11 @@ namespace SHADE return type; } + const SHCollisionTag& SHCollisionShape::GetCollisionTags() const noexcept + { + return collisionTags; + } + float SHCollisionShape::GetFriction() const noexcept { return material.GetFriction(); @@ -240,6 +245,18 @@ namespace SHADE isTrigger = trigger; } + void SHCollisionShape::SetCollisionTags(const SHCollisionTag& newCollisionTag) noexcept + { + dirty = true; + collisionTags = newCollisionTag; + } + + void SHCollisionShape::SetCollisionTags(SHCollisionTag::eTag newCollisionTag) noexcept + { + dirty = true; + collisionTags = SHCollisionTag{ newCollisionTag }; + } + void SHCollisionShape::SetFriction(float friction) noexcept { dirty = true; diff --git a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h index 526428fd..7cd8528a 100644 --- a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h +++ b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h @@ -17,6 +17,7 @@ #include "Math/Geometry/SHShape.h" #include "Math/SHQuaternion.h" #include "SHPhysicsMaterial.h" +#include "Physics/Collision/SHCollisionTags.h" namespace SHADE { @@ -74,6 +75,8 @@ namespace SHADE [[nodiscard]] Type GetType () const noexcept; + [[nodiscard]] const SHCollisionTag& GetCollisionTags () const noexcept; + [[nodiscard]] float GetFriction () const noexcept; [[nodiscard]] float GetBounciness () const noexcept; [[nodiscard]] float GetDensity () const noexcept; @@ -92,6 +95,8 @@ namespace SHADE void SetBoundingSphere (float radius); void SetIsTrigger (bool isTrigger) noexcept; + void SetCollisionTags (const SHCollisionTag& newCollisionTag) noexcept; + void SetCollisionTags (SHCollisionTag::eTag newCollisionTag) noexcept; void SetFriction (float friction) noexcept; void SetBounciness (float bounciness) noexcept; void SetDensity (float density) noexcept; @@ -109,6 +114,7 @@ namespace SHADE EntityID entityID; // The entity this collider belongs to bool isTrigger; bool dirty; + SHCollisionTag collisionTags; SHShape* shape; SHPhysicsMaterial material; SHVec3 positionOffset; diff --git a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp index 3cfa3ec9..6ce8e9d3 100644 --- a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp +++ b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp @@ -311,6 +311,9 @@ namespace SHADE syncMaterial(i, collisionShape); + // Sync tags + + collisionShape.dirty = false; } } @@ -327,6 +330,11 @@ namespace SHADE rp3dMaterial.setMassDensity(collisionShape.GetDensity()); } + void SHPhysicsObject::syncTags(int colliderIndex, SHCollisionShape& collisionShape) const noexcept + { + + } + void SHPhysicsObject::addBoxShape(SHCollisionShape& boxShape) const noexcept { const rp3d::Transform OFFSETS diff --git a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.h b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.h index 5a0e62ac..a5e8a53c 100644 --- a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.h +++ b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.h @@ -97,6 +97,7 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ void syncMaterial (int colliderIndex, SHCollisionShape& collisionShape) const noexcept; + void syncTags (int colliderIndex, SHCollisionShape& collisionShape) const noexcept; // Box Shapes -- 2.40.1 From 7226ccf27998a9222bad29cc0804453aa48e7b95 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Sun, 20 Nov 2022 03:16:49 +0800 Subject: [PATCH 2/7] Tested Collision Tags --- .../src/Application/SBApplication.cpp | 1 + .../src/Physics/Collision/SHCollisionTags.cpp | 2 +- .../Physics/Interface/SHCollisionShape.cpp | 6 ---- .../src/Physics/Interface/SHCollisionShape.h | 1 - .../Physics/PhysicsObject/SHPhysicsObject.cpp | 35 +++++++++---------- .../Physics/PhysicsObject/SHPhysicsObject.h | 3 -- 6 files changed, 19 insertions(+), 29 deletions(-) diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index 0fb8adf9..cf5a9277 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -174,6 +174,7 @@ namespace Sandbox SHSystemManager::RunRoutines(editor->editorState != SHEditor::State::PLAY, 0.016f); editor->PollPicking(); + // TODO: Move into an Editor menu static bool drawColliders = false; if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::F10)) { diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp index fdcf72c6..85072e5e 100644 --- a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp @@ -30,7 +30,7 @@ namespace SHADE /*-----------------------------------------------------------------------------------*/ SHCollisionTag::SHCollisionTag() noexcept - : mask { SHUtilities::ConvertEnum(eTag::ALL_TAGS) } + : mask { SHUtilities::ConvertEnum(eTag::TAG_1) } {} SHCollisionTag::SHCollisionTag(uint16_t tagValue) noexcept diff --git a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp index 46348c19..745d64c5 100644 --- a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp +++ b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp @@ -251,12 +251,6 @@ namespace SHADE collisionTags = newCollisionTag; } - void SHCollisionShape::SetCollisionTags(SHCollisionTag::eTag newCollisionTag) noexcept - { - dirty = true; - collisionTags = SHCollisionTag{ newCollisionTag }; - } - void SHCollisionShape::SetFriction(float friction) noexcept { dirty = true; diff --git a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h index 7cd8528a..fd08e55d 100644 --- a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h +++ b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h @@ -96,7 +96,6 @@ namespace SHADE void SetIsTrigger (bool isTrigger) noexcept; void SetCollisionTags (const SHCollisionTag& newCollisionTag) noexcept; - void SetCollisionTags (SHCollisionTag::eTag newCollisionTag) noexcept; void SetFriction (float friction) noexcept; void SetBounciness (float bounciness) noexcept; void SetDensity (float density) noexcept; diff --git a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp index 6ce8e9d3..ea3d5996 100644 --- a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp +++ b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp @@ -254,6 +254,10 @@ namespace SHADE } case 9: // Mass { + rp3dBody->setMass(component.mass); + rp3dBody->updateLocalCenterOfMassFromColliders(); + rp3dBody->updateLocalInertiaTensorFromColliders(); + //if (component.GetAutoMass()) //{ // rp3dBody->updateMassPropertiesFromColliders(); @@ -261,9 +265,9 @@ namespace SHADE //} //else //{ - rp3dBody->setMass(component.mass); - rp3dBody->updateLocalCenterOfMassFromColliders(); - rp3dBody->updateLocalInertiaTensorFromColliders(); + // rp3dBody->setMass(component.mass); + // rp3dBody->updateLocalCenterOfMassFromColliders(); + // rp3dBody->updateLocalInertiaTensorFromColliders(); //} break; @@ -309,10 +313,18 @@ namespace SHADE default: break; } - syncMaterial(i, collisionShape); + // Sync material + auto* rp3dCollider = rp3dBody->getCollider(i); + auto& rp3dMaterial = rp3dCollider->getMaterial(); + + rp3dMaterial.setFrictionCoefficient(collisionShape.GetFriction()); + rp3dMaterial.setBounciness(collisionShape.GetBounciness()); + rp3dMaterial.setMassDensity(collisionShape.GetDensity()); // Sync tags - + const unsigned short MASK_BITS = collisionShape.GetCollisionTags(); + rp3dCollider->setCollisionCategoryBits(MASK_BITS); + rp3dCollider->setCollideWithMaskBits(MASK_BITS); collisionShape.dirty = false; } @@ -322,19 +334,6 @@ namespace SHADE /* Private Function Member Definitions */ /*-----------------------------------------------------------------------------------*/ - void SHPhysicsObject::syncMaterial(int colliderIndex, SHCollisionShape& collisionShape) const noexcept - { - auto& rp3dMaterial = rp3dBody->getCollider(colliderIndex)->getMaterial(); - rp3dMaterial.setFrictionCoefficient(collisionShape.GetFriction()); - rp3dMaterial.setBounciness(collisionShape.GetBounciness()); - rp3dMaterial.setMassDensity(collisionShape.GetDensity()); - } - - void SHPhysicsObject::syncTags(int colliderIndex, SHCollisionShape& collisionShape) const noexcept - { - - } - void SHPhysicsObject::addBoxShape(SHCollisionShape& boxShape) const noexcept { const rp3d::Transform OFFSETS diff --git a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.h b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.h index a5e8a53c..fefc983f 100644 --- a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.h +++ b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.h @@ -96,9 +96,6 @@ namespace SHADE /* Function Members */ /*---------------------------------------------------------------------------------*/ - void syncMaterial (int colliderIndex, SHCollisionShape& collisionShape) const noexcept; - void syncTags (int colliderIndex, SHCollisionShape& collisionShape) const noexcept; - // Box Shapes void addBoxShape (SHCollisionShape& boxShape) const noexcept; -- 2.40.1 From a0f4f3b00a84417bdab9e991f0c3265861c704d4 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Sun, 20 Nov 2022 15:32:33 +0800 Subject: [PATCH 3/7] Added collision tag names file --- Assets/CollisionTags.SHConfig | 20 +++ .../src/Physics/Collision/SHCollisionTags.cpp | 135 +++++++++++++++++- .../src/Physics/Collision/SHCollisionTags.h | 9 +- .../src/Physics/System/SHPhysicsSystem.cpp | 11 ++ .../src/Physics/System/SHPhysicsSystem.h | 1 + 5 files changed, 167 insertions(+), 9 deletions(-) create mode 100644 Assets/CollisionTags.SHConfig diff --git a/Assets/CollisionTags.SHConfig b/Assets/CollisionTags.SHConfig new file mode 100644 index 00000000..18a339dd --- /dev/null +++ b/Assets/CollisionTags.SHConfig @@ -0,0 +1,20 @@ +0 1 +1 2 +2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +10 11 +11 12 +12 13 +13 14 +14 15 +15 16 + +note: +All collision tags should follow the above format "indextag name". +If it fails to follow this, the default tag names will be used. \ No newline at end of file diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp index 85072e5e..7275b618 100644 --- a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp @@ -9,12 +9,12 @@ ****************************************************************************************/ #include +#include // Primary Header #include "SHCollisionTags.h" // Project Headers -#include "SHCollisionTags.h" - +#include "Tools/FileIO/SHFileIO.h" #include "Tools/Utilities/SHUtilities.h" namespace SHADE @@ -136,15 +136,140 @@ namespace SHADE void SHCollisionTag::Init(const std::filesystem::path& tagNameFilePath) noexcept { - // Read tag names from given file. + /** + * I HATE FILE IO + * + * Each line in the file should be "indextag name". + * If the line fails to follow this format, use the default tag name (index + 1) + */ + + // Populate tag names with default + for (int i = 0; i < NUM_TAGS; ++i) + tagNames[i] = std::to_string(i + 1); + + std::ifstream collisionTagNamesFile { tagNameFilePath }; + + if (!collisionTagNamesFile.is_open()) + { + SHLOG_ERROR("Failed to open file for Collision Tag Names! Default tag names used!") + return; + } + + std::stringstream ss; + std::string line; + + int linesRead = 0; + while (std::getline(collisionTagNamesFile, line)) + { + // Do not read anything beyond the first 16 lines + if (linesRead >= 16) + break; + + ss << line; + ++linesRead; + + // First element is index. + int tagIndex; + ss >> tagIndex; + + // Next element is name of the tag + std::string tagName; + ss >> tagName; + + // If no tag name read, use default. + if (tagName.empty()) + { + SHLOG_ERROR + ( + "Collision tag file line {} does not match the required format of 'indextag name'. Default tag used for index {}" + , linesRead + 1 + , tagIndex + ) + + // Use default since + tagNames[tagIndex] = std::to_string(tagIndex + 1); + continue; + } + + tagNames[tagIndex] = tagName; + + ss.clear(); + } + + collisionTagNamesFile.close(); } void SHCollisionTag::Exit(const std::filesystem::path& tagNameFilePath) noexcept { - // Write current set of names to file. - // This ensures any names changed is reflected on the file for the next run of the application. + std::ofstream collisionTagNamesFile { tagNameFilePath }; + + if (!collisionTagNamesFile.is_open()) + { + SHLOG_ERROR("Failed to open file for Collision Tag Names! Tag names not saved!") + return; + } + + for (int i = 0; i < NUM_TAGS; ++i) + collisionTagNamesFile << i << " " << tagNames[i] << std::endl; + + collisionTagNamesFile.close(); } + void SHCollisionTag::UpdateTagNamesFromFile(const std::filesystem::path& tagNameFilePath) noexcept + { + std::ifstream collisionTagNamesFile { tagNameFilePath }; + + if (!collisionTagNamesFile.is_open()) + { + SHLOG_ERROR("Failed to open file for Collision Tag Names! Default tag names used!") + return; + } + + std::stringstream ss; + std::string line; + + int linesRead = 0; + while (std::getline(collisionTagNamesFile, line)) + { + // Do not read anything beyond the first 16 lines + if (linesRead >= 16) + break; + + ss << line; + ++linesRead; + + // First element is index. + int tagIndex; + ss >> tagIndex; + + // Next element is name of the tag + std::string tagName; + ss >> tagName; + + // If no tag name read, use default. + if (tagName.empty()) + { + SHLOG_ERROR + ( + "Collision tag file line {} does not match the required format of 'indextag name'. Name left unchanged for index {}" + , linesRead + 1 + , tagIndex + ) + + // Use default since + tagNames[tagIndex] = std::to_string(tagIndex + 1); + continue; + } + + tagNames[tagIndex] = tagName; + + ss.clear(); + } + + collisionTagNamesFile.close(); + } + + void SHCollisionTag::RemoveTagName(int tagIndex) { if (tagIndex < 0 || tagIndex > NUM_TAGS) diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h index e43aae2d..1b709837 100644 --- a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h @@ -95,11 +95,12 @@ namespace SHADE /* Function Members */ /*---------------------------------------------------------------------------------*/ - static void Init (const std::filesystem::path& tagNameFilePath) noexcept; - static void Exit (const std::filesystem::path& tagNameFilePath) noexcept; + static void Init (const std::filesystem::path& tagNameFilePath) noexcept; + static void Exit (const std::filesystem::path& tagNameFilePath) noexcept; + static void UpdateTagNamesFromFile(const std::filesystem::path& tagNameFilePath) noexcept; - static void SetTagName (const std::string& newTagName, int tagIndex); - static void RemoveTagName (int tagIndex); + static void SetTagName (const std::string& newTagName, int tagIndex); + static void RemoveTagName (int tagIndex); [[nodiscard]] static const std::string& GetTagName (int tagIndex); diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp index f3513ffb..c343d506 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp @@ -14,6 +14,7 @@ #include "SHPhysicsSystem.h" // Project Headers +#include "Assets/SHAssetMacros.h" #include "ECS_Base/Managers/SHComponentManager.h" #include "ECS_Base/Managers/SHEntityManager.h" #include "ECS_Base/Managers/SHSystemManager.h" @@ -90,6 +91,11 @@ namespace SHADE void SHPhysicsSystem::Init() { + // Initialise collision tags + std::filesystem::path defaultCollisionTagNameFilePath { ASSET_ROOT }; + defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig"); + SHCollisionTag::Init(defaultCollisionTagNameFilePath); + // Subscribe to component events const std::shared_ptr ADD_COMPONENT_RECEIVER { std::make_shared>(this, &SHPhysicsSystem::addPhysicsComponent) }; const ReceiverPtr ADD_COMPONENT_RECEIVER_PTR = std::dynamic_pointer_cast(ADD_COMPONENT_RECEIVER); @@ -122,6 +128,11 @@ namespace SHADE void SHPhysicsSystem::Exit() { worldState.DestroyWorld(factory); + + // Write collision tag names to file + std::filesystem::path defaultCollisionTagNameFilePath { ASSET_ROOT }; + defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig"); + SHCollisionTag::Exit(defaultCollisionTagNameFilePath); } void SHPhysicsSystem::ForceUpdate() diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.h b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.h index f92be4cd..89ecb51e 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.h +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.h @@ -69,6 +69,7 @@ namespace SHADE void SetFixedUpdateRate (double fixedUpdateRate) noexcept; void SetWorldSettings (const SHPhysicsWorldState::WorldSettings& settings) noexcept; + void SetCollisionTagFile (const std::filesystem::path& tagNamesFilePath) noexcept; /*---------------------------------------------------------------------------------*/ /* Function Members */ -- 2.40.1 From 4198310b7a8f24fbe917b377ccb7862ad44e0384 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Sun, 20 Nov 2022 15:34:34 +0800 Subject: [PATCH 4/7] Missing implementation for updating all tag names through the physics system --- SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp index c343d506..17f27eaf 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp @@ -85,6 +85,12 @@ namespace SHADE worldState.UpdateSettings(); } + void SHPhysicsSystem::SetCollisionTagFile(const std::filesystem::path& tagNamesFilePath) noexcept + { + SHCollisionTag::UpdateTagNamesFromFile(tagNamesFilePath); + } + + /*-----------------------------------------------------------------------------------*/ /* Public Function Member Definitions */ /*-----------------------------------------------------------------------------------*/ -- 2.40.1 From 4ebc16564ae61126321a3850d842e08fd98052c0 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Sun, 20 Nov 2022 17:23:28 +0800 Subject: [PATCH 5/7] Added collision matrix for configurating individual collision tags --- .../Collision/SHCollisionTagMatrix.cpp | 255 ++++++++++++++++++ .../Physics/Collision/SHCollisionTagMatrix.h | 65 +++++ .../src/Physics/Collision/SHCollisionTags.cpp | 243 ++--------------- .../src/Physics/Collision/SHCollisionTags.h | 90 +++---- .../Physics/Interface/SHCollisionShape.cpp | 8 +- .../src/Physics/Interface/SHCollisionShape.h | 6 +- .../Physics/PhysicsObject/SHPhysicsObject.cpp | 2 +- .../src/Physics/System/SHPhysicsSystem.cpp | 7 +- 8 files changed, 399 insertions(+), 277 deletions(-) create mode 100644 SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.cpp create mode 100644 SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.h diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.cpp b/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.cpp new file mode 100644 index 00000000..ce6cd900 --- /dev/null +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.cpp @@ -0,0 +1,255 @@ +/**************************************************************************************** + * \file SHCollisionTagMatrix.cpp + * \author Diren D Bharwani, diren.dbharwani, 390002520 + * \brief Implementation for Collision Tag Matrix for handling sets of Collision Tags. + * + * \copyright Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or + * disclosure of this file or its contents without the prior written consent + * of DigiPen Institute of Technology is prohibited. +****************************************************************************************/ + +#include +#include + +// Primary Header +#include "SHCollisionTagMatrix.h" + +namespace SHADE +{ + /*-----------------------------------------------------------------------------------*/ + /* Static Data Member Definitions */ + /*-----------------------------------------------------------------------------------*/ + + SHCollisionTag SHCollisionTagMatrix::collisionTags[SHCollisionTag::NUM_LAYERS]; + + /*-----------------------------------------------------------------------------------*/ + /* Getter Function Definitions */ + /*-----------------------------------------------------------------------------------*/ + + const std::string& SHCollisionTagMatrix::GetTagName(int tagIndex) + { + if (tagIndex < 0 || tagIndex > SHCollisionTag::NUM_LAYERS) + throw std::invalid_argument("Index out of range!"); + + return collisionTags[tagIndex].GetName(); + } + + int SHCollisionTagMatrix::GetTagIndex(const std::string& tagName) noexcept + { + for (int i = 0; i < SHCollisionTag::NUM_LAYERS; ++i) + { + if (collisionTags[i].GetName() == tagName) + return i; + } + + SHLOGV_WARNING("Collision Tag {} cannot be found!", tagName) + return -1; + } + + /*-----------------------------------------------------------------------------------*/ + /* Setter Function Definitions */ + /*-----------------------------------------------------------------------------------*/ + + void SHCollisionTagMatrix::SetTagName(const std::string& oldTagName, const std::string& newTagName) noexcept + { + for (auto& collisionTag : collisionTags) + { + if (collisionTag.GetName() != oldTagName) + continue; + + collisionTag.SetName(newTagName); + return; + } + + SHLOGV_WARNING("Collision tag {} cannot be found!", oldTagName) + } + + void SHCollisionTagMatrix::SetTag(const std::string& tagName, const SHCollisionTag& newTag) noexcept + { + for (auto& collisionTag : collisionTags) + { + if (collisionTag.GetName() != tagName) + continue; + + collisionTag = newTag; + return; + } + + SHLOGV_WARNING("Collision tag {} cannot be found!", tagName) + } + + void SHCollisionTagMatrix::SetTag(const std::string& tagName, uint16_t mask) noexcept + { + for (auto& collisionTag : collisionTags) + { + if (collisionTag.GetName() != tagName) + continue; + + collisionTag.SetMask(mask); + return; + } + + SHLOGV_WARNING("Collision tag {} cannot be found!", tagName) + } + + void SHCollisionTagMatrix::SetTagName(int tagIndex, const std::string& newTagName) + { + if (tagIndex < 0 || tagIndex > SHCollisionTag::NUM_LAYERS) + throw std::invalid_argument("Index out of range!"); + + collisionTags[tagIndex].SetName(newTagName); + } + + void SHCollisionTagMatrix::SetTag(int tagIndex, const SHCollisionTag& newTag) + { + if (tagIndex < 0 || tagIndex > SHCollisionTag::NUM_LAYERS) + throw std::invalid_argument("Index out of range!"); + + collisionTags[tagIndex] = newTag; + } + + void SHCollisionTagMatrix::SetTag(int tagIndex, uint16_t mask) + { + if (tagIndex < 0 || tagIndex > SHCollisionTag::NUM_LAYERS) + throw std::invalid_argument("Index out of range!"); + + collisionTags[tagIndex].SetMask(mask); + } + + /*-----------------------------------------------------------------------------------*/ + /* Public Function Member Definitions */ + /*-----------------------------------------------------------------------------------*/ + + void SHCollisionTagMatrix::Init(const std::filesystem::path& tagNameFilePath) noexcept + { + /** + * I HATE FILE IO + * + * Each line in the file should be "indextag name". + * If the line fails to follow this format, use the default tag name (index + 1) + */ + + // Populate tag names with default + for (int i = 0; i < SHCollisionTag::NUM_LAYERS; ++i) + collisionTags[i].SetName(std::to_string(i + 1)); + + std::ifstream collisionTagNamesFile { tagNameFilePath }; + + if (!collisionTagNamesFile.is_open()) + { + SHLOG_ERROR("Failed to open file for Collision Tag Names! Default tag names used!") + return; + } + + std::stringstream ss; + std::string line; + + int linesRead = 0; + while (std::getline(collisionTagNamesFile, line)) + { + // Do not read anything beyond the first 16 lines + if (linesRead >= 16) + break; + + ss << line; + ++linesRead; + + // First element is index. + int tagIndex; + ss >> tagIndex; + + // Next element is name of the tag + std::string tagName; + ss >> tagName; + + // If no tag name read, use default. + if (tagName.empty()) + { + SHLOG_ERROR + ( + "Collision tag file line {} does not match the required format of 'indextag name'. Default tag used for index {}" + , linesRead + 1 + , tagIndex + ) + + // Use default + collisionTags[tagIndex].SetName(std::to_string(tagIndex + 1)); + continue; + } + + collisionTags[tagIndex].SetName(tagName); + + ss.clear(); + } + + collisionTagNamesFile.close(); + } + + void SHCollisionTagMatrix::Exit(const std::filesystem::path& tagNameFilePath) noexcept + { + std::ofstream collisionTagNamesFile { tagNameFilePath }; + + if (!collisionTagNamesFile.is_open()) + { + SHLOG_ERROR("Failed to open file for Collision Tag Names! Tag names not saved!") + return; + } + + for (int i = 0; i < SHCollisionTag::NUM_LAYERS; ++i) + collisionTagNamesFile << i << " " << collisionTags[i].GetName() << std::endl; + + collisionTagNamesFile.close(); + } + + void SHCollisionTagMatrix::UpdateTagNamesFromFile(const std::filesystem::path& tagNameFilePath) noexcept + { + std::ifstream collisionTagNamesFile { tagNameFilePath }; + + if (!collisionTagNamesFile.is_open()) + { + SHLOG_ERROR("Failed to open file for Collision Tag Names! Default tag names used!") + return; + } + + std::stringstream ss; + std::string line; + + int linesRead = 0; + while (std::getline(collisionTagNamesFile, line)) + { + // Do not read anything beyond the first 16 lines + if (linesRead >= 16) + break; + + ss << line; + ++linesRead; + + // First element is index. + int tagIndex; + ss >> tagIndex; + + // Next element is name of the tag + std::string tagName; + ss >> tagName; + + // If no tag name read, use default. + if (tagName.empty()) + { + SHLOG_ERROR + ( + "Collision tag file line {} does not match the required format of 'indextag name'. Name left unchanged for index {}" + , linesRead + 1 + , tagIndex + ) + + continue; + } + + collisionTags[tagIndex].SetName(tagName); + + ss.clear(); + } + + collisionTagNamesFile.close(); + } +} // namespace SHADE \ No newline at end of file diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.h b/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.h new file mode 100644 index 00000000..eac23ebb --- /dev/null +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.h @@ -0,0 +1,65 @@ +/**************************************************************************************** + * \file SHCollisionTagMatrix.h + * \author Diren D Bharwani, diren.dbharwani, 390002520 + * \brief Interface for Collision Tag Matrix for handling sets of Collision Tags. + * + * \copyright Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or + * disclosure of this file or its contents without the prior written consent + * of DigiPen Institute of Technology is prohibited. +****************************************************************************************/ + +#pragma once + +#include + +// Project Includes +#include "SH_API.h" +#include "SHCollisionTags.h" + +namespace SHADE +{ + /*-----------------------------------------------------------------------------------*/ + /* Type Definitions */ + /*-----------------------------------------------------------------------------------*/ + + class SH_API SHCollisionTagMatrix + { + public: + /*---------------------------------------------------------------------------------*/ + /* Getter Functions */ + /*---------------------------------------------------------------------------------*/ + + [[nodiscard]] static const std::string& GetTagName (int tagIndex); + [[nodiscard]] static int GetTagIndex (const std::string& tagName) noexcept; + + /*---------------------------------------------------------------------------------*/ + /* Setter Functions */ + /*---------------------------------------------------------------------------------*/ + + static void SetTagName (const std::string& oldTagName, const std::string& newTagName) noexcept; + static void SetTag (const std::string& tagName, const SHCollisionTag& newTag) noexcept; + static void SetTag (const std::string& tagName, uint16_t mask) noexcept; + + // Unsafe Setters: Can throw exceptions + + static void SetTagName (int tagIndex, const std::string& newTagName); + static void SetTag (int tagIndex, const SHCollisionTag& newTag); + static void SetTag (int tagIndex, uint16_t mask); + + + /*---------------------------------------------------------------------------------*/ + /* Function Members */ + /*---------------------------------------------------------------------------------*/ + + static void Init (const std::filesystem::path& tagNameFilePath) noexcept; + static void Exit (const std::filesystem::path& tagNameFilePath) noexcept; + static void UpdateTagNamesFromFile (const std::filesystem::path& tagNameFilePath) noexcept; + + private: + /*---------------------------------------------------------------------------------*/ + /* Data Members */ + /*---------------------------------------------------------------------------------*/ + + static SHCollisionTag collisionTags[SHCollisionTag::NUM_LAYERS]; + }; +} \ No newline at end of file diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp index 7275b618..b1d2d5fc 100644 --- a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.cpp @@ -14,31 +14,24 @@ // Primary Header #include "SHCollisionTags.h" // Project Headers -#include "Tools/FileIO/SHFileIO.h" #include "Tools/Utilities/SHUtilities.h" namespace SHADE { - /*-----------------------------------------------------------------------------------*/ - /* Static Data Member Definitions */ - /*-----------------------------------------------------------------------------------*/ - - std::string SHCollisionTag::tagNames[NUM_TAGS]; - /*-----------------------------------------------------------------------------------*/ /* Constructors & Destructor Definitions */ /*-----------------------------------------------------------------------------------*/ SHCollisionTag::SHCollisionTag() noexcept - : mask { SHUtilities::ConvertEnum(eTag::TAG_1) } + : mask { SHUtilities::ConvertEnum(Layer::ALL) } {} - SHCollisionTag::SHCollisionTag(uint16_t tagValue) noexcept - : mask { tagValue } + SHCollisionTag::SHCollisionTag(uint16_t _mask) noexcept + : mask { _mask } {} - SHCollisionTag::SHCollisionTag(eTag tagValue) noexcept - : mask { SHUtilities::ConvertEnum(tagValue) } + SHCollisionTag::SHCollisionTag(Layer layer) noexcept + : mask { SHUtilities::ConvertEnum(layer) } {} /*-----------------------------------------------------------------------------------*/ @@ -64,238 +57,60 @@ namespace SHADE /* Getter Function Definitions */ /*-----------------------------------------------------------------------------------*/ - uint16_t SHCollisionTag::GetTagValue() const noexcept + uint16_t SHCollisionTag::GetMask() const noexcept { return mask; } - bool SHCollisionTag::GetTagState(eTag tag) const noexcept + const std::string& SHCollisionTag::GetName() const noexcept { - return (mask & SHUtilities::ConvertEnum(tag)) > 0; + return name; } - bool SHCollisionTag::GetTagState(int tagIndex) const + bool SHCollisionTag::GetLayerState(Layer layer) const noexcept { - if (tagIndex < 0 || tagIndex > NUM_TAGS) + return (mask & SHUtilities::ConvertEnum(layer)) > 0; + } + + bool SHCollisionTag::GetLayerState(int layerIndex) const + { + if (layerIndex < 0 || layerIndex > NUM_LAYERS) throw std::invalid_argument("Index out of range!"); - return (mask & (1U << tagIndex)) > 0; + return (mask & (1U << layerIndex)) > 0; } - /*-----------------------------------------------------------------------------------*/ /* Setter Function Definitions */ /*-----------------------------------------------------------------------------------*/ - void SHCollisionTag::SetValue(uint16_t tagValue) noexcept + void SHCollisionTag::SetMask(uint16_t newMask) noexcept { - mask = tagValue; + mask = newMask; } - void SHCollisionTag::SetTagState(eTag tag, bool tagState) noexcept + void SHCollisionTag::SetName(const std::string_view& newName) noexcept { - const auto VALUE = SHUtilities::ConvertEnum(tag); - tagState ? mask |= VALUE : mask &= ~(VALUE); + name = newName; } - void SHCollisionTag::SetTagState(const std::string& tagName, bool tagState) noexcept + void SHCollisionTag::SetLayerState(Layer layer, bool state) noexcept { - // This find is expensive. - int tagIndex = -1; - for (int i = 0; i < NUM_TAGS; ++i) - { - if (tagNames[i] != tagName) - continue; - - tagIndex = i; - break; - } - - if (tagIndex < 0) - { - SHLOGV_WARNING("Parameter tagName {} not found in list of tag names. Tag unmodified.", tagName) - return; - } - - const auto VALUE = 1U << tagIndex; - tagState ? mask |= (VALUE) : mask &= ~(VALUE); + const auto VALUE = SHUtilities::ConvertEnum(layer); + state ? mask |= VALUE : mask &= ~(VALUE); } - void SHCollisionTag::SetTagState(int tagIndex, bool tagState) + void SHCollisionTag::SetLayerState(int layerIndex, bool state) { - if (tagIndex < 0 || tagIndex > NUM_TAGS) + if (layerIndex < 0 || layerIndex > NUM_LAYERS) throw std::invalid_argument("Index out of range!"); - const auto VALUE = 1U << tagIndex; - tagState ? mask |= (VALUE) : mask &= ~(VALUE); - } - - /*-----------------------------------------------------------------------------------*/ - /* Public Function Member Definitions */ - /*-----------------------------------------------------------------------------------*/ - - void SHCollisionTag::Init(const std::filesystem::path& tagNameFilePath) noexcept - { - /** - * I HATE FILE IO - * - * Each line in the file should be "indextag name". - * If the line fails to follow this format, use the default tag name (index + 1) - */ - - // Populate tag names with default - for (int i = 0; i < NUM_TAGS; ++i) - tagNames[i] = std::to_string(i + 1); - - std::ifstream collisionTagNamesFile { tagNameFilePath }; - - if (!collisionTagNamesFile.is_open()) - { - SHLOG_ERROR("Failed to open file for Collision Tag Names! Default tag names used!") - return; - } - - std::stringstream ss; - std::string line; - - int linesRead = 0; - while (std::getline(collisionTagNamesFile, line)) - { - // Do not read anything beyond the first 16 lines - if (linesRead >= 16) - break; - - ss << line; - ++linesRead; - - // First element is index. - int tagIndex; - ss >> tagIndex; - - // Next element is name of the tag - std::string tagName; - ss >> tagName; - - // If no tag name read, use default. - if (tagName.empty()) - { - SHLOG_ERROR - ( - "Collision tag file line {} does not match the required format of 'indextag name'. Default tag used for index {}" - , linesRead + 1 - , tagIndex - ) - - // Use default since - tagNames[tagIndex] = std::to_string(tagIndex + 1); - continue; - } - - tagNames[tagIndex] = tagName; - - ss.clear(); - } - - collisionTagNamesFile.close(); - } - - void SHCollisionTag::Exit(const std::filesystem::path& tagNameFilePath) noexcept - { - std::ofstream collisionTagNamesFile { tagNameFilePath }; - - if (!collisionTagNamesFile.is_open()) - { - SHLOG_ERROR("Failed to open file for Collision Tag Names! Tag names not saved!") - return; - } - - for (int i = 0; i < NUM_TAGS; ++i) - collisionTagNamesFile << i << " " << tagNames[i] << std::endl; - - collisionTagNamesFile.close(); - } - - void SHCollisionTag::UpdateTagNamesFromFile(const std::filesystem::path& tagNameFilePath) noexcept - { - std::ifstream collisionTagNamesFile { tagNameFilePath }; - - if (!collisionTagNamesFile.is_open()) - { - SHLOG_ERROR("Failed to open file for Collision Tag Names! Default tag names used!") - return; - } - - std::stringstream ss; - std::string line; - - int linesRead = 0; - while (std::getline(collisionTagNamesFile, line)) - { - // Do not read anything beyond the first 16 lines - if (linesRead >= 16) - break; - - ss << line; - ++linesRead; - - // First element is index. - int tagIndex; - ss >> tagIndex; - - // Next element is name of the tag - std::string tagName; - ss >> tagName; - - // If no tag name read, use default. - if (tagName.empty()) - { - SHLOG_ERROR - ( - "Collision tag file line {} does not match the required format of 'indextag name'. Name left unchanged for index {}" - , linesRead + 1 - , tagIndex - ) - - // Use default since - tagNames[tagIndex] = std::to_string(tagIndex + 1); - continue; - } - - tagNames[tagIndex] = tagName; - - ss.clear(); - } - - collisionTagNamesFile.close(); - } - - - void SHCollisionTag::RemoveTagName(int tagIndex) - { - if (tagIndex < 0 || tagIndex > NUM_TAGS) - throw std::invalid_argument("Index out of range!"); - - tagNames[tagIndex].clear(); - } - - void SHCollisionTag::SetTagName(const std::string& newTagName, int tagIndex) - { - if (tagIndex < 0 || tagIndex > NUM_TAGS) - throw std::invalid_argument("Index out of range!"); - - tagNames[tagIndex] = newTagName; - } - - const std::string& SHCollisionTag::GetTagName(int tagIndex) - { - if (tagIndex < 0 || tagIndex > NUM_TAGS) - throw std::invalid_argument("Index out of range!"); - - return tagNames[tagIndex]; + const auto VALUE = 1U << layerIndex; + state ? mask |= (VALUE) : mask &= ~(VALUE); } } // namespace SHADE -SHADE::SHCollisionTag::eTag operator|(SHADE::SHCollisionTag::eTag lhs, SHADE::SHCollisionTag::eTag rhs) noexcept +SHADE::SHCollisionTag::Layer operator|(SHADE::SHCollisionTag::Layer lhs, SHADE::SHCollisionTag::Layer rhs) noexcept { - return static_cast(SHADE::SHUtilities::ConvertEnum(lhs) | SHADE::SHUtilities::ConvertEnum(rhs)); + return static_cast(SHADE::SHUtilities::ConvertEnum(lhs) | SHADE::SHUtilities::ConvertEnum(rhs)); } \ No newline at end of file diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h index 1b709837..9c7b4364 100644 --- a/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTags.h @@ -10,7 +10,7 @@ #pragma once -#include +#include // Project Headers #include "SH_API.h" @@ -28,34 +28,39 @@ namespace SHADE /* Type Definitions */ /*---------------------------------------------------------------------------------*/ - enum class eTag : uint16_t + enum class Layer : uint16_t { - TAG_1 = 0x0001 - , TAG_2 = 0x0002 - , TAG_3 = 0x0004 - , TAG_4 = 0x0008 - , TAG_5 = 0x0010 - , TAG_6 = 0x0020 - , TAG_7 = 0x0040 - , TAG_8 = 0x0080 - , TAG_9 = 0x0100 - , TAG_10 = 0x0200 - , TAG_11 = 0x0400 - , TAG_12 = 0x0800 - , TAG_13 = 0x1000 - , TAG_14 = 0x2000 - , TAG_15 = 0x4000 - , TAG_16 = 0x8000 - , ALL_TAGS = 0xFFFF + _1 = 0x0001 + , _2 = 0x0002 + , _3 = 0x0004 + , _4 = 0x0008 + , _5 = 0x0010 + , _6 = 0x0020 + , _7 = 0x0040 + , _8 = 0x0080 + , _9 = 0x0100 + , _10 = 0x0200 + , _11 = 0x0400 + , _12 = 0x0800 + , _13 = 0x1000 + , _14 = 0x2000 + , _15 = 0x4000 + , _16 = 0x8000 + , ALL = 0xFFFF }; + /*---------------------------------------------------------------------------------*/ + /* Data Members */ + /*---------------------------------------------------------------------------------*/ + static constexpr int NUM_LAYERS = 16; + /*---------------------------------------------------------------------------------*/ /* Constructors & Destructor */ /*---------------------------------------------------------------------------------*/ - SHCollisionTag () noexcept; - SHCollisionTag (uint16_t tagValue) noexcept; - SHCollisionTag (eTag tagValue) noexcept; + SHCollisionTag () noexcept; + SHCollisionTag (uint16_t mask) noexcept; + SHCollisionTag (Layer layer) noexcept; SHCollisionTag (const SHCollisionTag&) noexcept = default; SHCollisionTag (SHCollisionTag&&) noexcept = default; @@ -77,50 +82,31 @@ namespace SHADE /* Getter Functions */ /*---------------------------------------------------------------------------------*/ - [[nodiscard]] uint16_t GetTagValue () const noexcept; - [[nodiscard]] bool GetTagState (eTag tag) const noexcept; - [[nodiscard]] bool GetTagState (int tagIndex) const; + [[nodiscard]] uint16_t GetMask () const noexcept; + [[nodiscard]] const std::string& GetName () const noexcept; + [[nodiscard]] bool GetLayerState (Layer layer) const noexcept; + [[nodiscard]] bool GetLayerState (int layerIndex) const; /*---------------------------------------------------------------------------------*/ /* Setter Functions */ /*---------------------------------------------------------------------------------*/ - void SetValue (uint16_t tagValue) noexcept; - - void SetTagState (eTag tag, bool tagState) noexcept; - void SetTagState (const std::string& tagName, bool tagState) noexcept; - void SetTagState (int tagIndex, bool tagState); - - /*---------------------------------------------------------------------------------*/ - /* Function Members */ - /*---------------------------------------------------------------------------------*/ - - static void Init (const std::filesystem::path& tagNameFilePath) noexcept; - static void Exit (const std::filesystem::path& tagNameFilePath) noexcept; - static void UpdateTagNamesFromFile(const std::filesystem::path& tagNameFilePath) noexcept; - - static void SetTagName (const std::string& newTagName, int tagIndex); - static void RemoveTagName (int tagIndex); - - [[nodiscard]] static const std::string& GetTagName (int tagIndex); + void SetMask (uint16_t newMask) noexcept; + void SetName (const std::string_view& newName) noexcept; + void SetLayerState (Layer layer, bool state) noexcept; + void SetLayerState (int layerIndex, bool state); private: - /*---------------------------------------------------------------------------------*/ - /* Static Data Members */ - /*---------------------------------------------------------------------------------*/ - - static constexpr int NUM_TAGS = 16; - static std::string tagNames[NUM_TAGS]; - /*---------------------------------------------------------------------------------*/ /* Data Members */ /*---------------------------------------------------------------------------------*/ - uint16_t mask; + uint16_t mask; + std::string name; }; } // namespace SHADE -SHADE::SHCollisionTag::eTag SH_API operator|(SHADE::SHCollisionTag::eTag lhs, SHADE::SHCollisionTag::eTag rhs) noexcept; +SHADE::SHCollisionTag::Layer SH_API operator|(SHADE::SHCollisionTag::Layer lhs, SHADE::SHCollisionTag::Layer rhs) noexcept; diff --git a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp index 745d64c5..11106cf8 100644 --- a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp +++ b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp @@ -134,9 +134,9 @@ namespace SHADE return type; } - const SHCollisionTag& SHCollisionShape::GetCollisionTags() const noexcept + const SHCollisionTag& SHCollisionShape::GetCollisionTag() const noexcept { - return collisionTags; + return collisionTag; } float SHCollisionShape::GetFriction() const noexcept @@ -245,10 +245,10 @@ namespace SHADE isTrigger = trigger; } - void SHCollisionShape::SetCollisionTags(const SHCollisionTag& newCollisionTag) noexcept + void SHCollisionShape::SetCollisionTag(const SHCollisionTag& newCollisionTag) noexcept { dirty = true; - collisionTags = newCollisionTag; + collisionTag = newCollisionTag; } void SHCollisionShape::SetFriction(float friction) noexcept diff --git a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h index fd08e55d..09793026 100644 --- a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h +++ b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h @@ -75,7 +75,7 @@ namespace SHADE [[nodiscard]] Type GetType () const noexcept; - [[nodiscard]] const SHCollisionTag& GetCollisionTags () const noexcept; + [[nodiscard]] const SHCollisionTag& GetCollisionTag () const noexcept; [[nodiscard]] float GetFriction () const noexcept; [[nodiscard]] float GetBounciness () const noexcept; @@ -95,7 +95,7 @@ namespace SHADE void SetBoundingSphere (float radius); void SetIsTrigger (bool isTrigger) noexcept; - void SetCollisionTags (const SHCollisionTag& newCollisionTag) noexcept; + void SetCollisionTag (const SHCollisionTag& newCollisionTag) noexcept; void SetFriction (float friction) noexcept; void SetBounciness (float bounciness) noexcept; void SetDensity (float density) noexcept; @@ -113,7 +113,7 @@ namespace SHADE EntityID entityID; // The entity this collider belongs to bool isTrigger; bool dirty; - SHCollisionTag collisionTags; + SHCollisionTag collisionTag; SHShape* shape; SHPhysicsMaterial material; SHVec3 positionOffset; diff --git a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp index ea3d5996..8de928f0 100644 --- a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp +++ b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObject.cpp @@ -322,7 +322,7 @@ namespace SHADE rp3dMaterial.setMassDensity(collisionShape.GetDensity()); // Sync tags - const unsigned short MASK_BITS = collisionShape.GetCollisionTags(); + const unsigned short MASK_BITS = collisionShape.GetCollisionTag(); rp3dCollider->setCollisionCategoryBits(MASK_BITS); rp3dCollider->setCollideWithMaskBits(MASK_BITS); diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp index 17f27eaf..b2f618a7 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp @@ -19,6 +19,7 @@ #include "ECS_Base/Managers/SHEntityManager.h" #include "ECS_Base/Managers/SHSystemManager.h" #include "Editor/SHEditor.h" +#include "Physics/Collision/SHCollisionTagMatrix.h" #include "Physics/SHPhysicsEvents.h" #include "Scene/SHSceneManager.h" #include "Scripting/SHScriptEngine.h" @@ -87,7 +88,7 @@ namespace SHADE void SHPhysicsSystem::SetCollisionTagFile(const std::filesystem::path& tagNamesFilePath) noexcept { - SHCollisionTag::UpdateTagNamesFromFile(tagNamesFilePath); + SHCollisionTagMatrix::UpdateTagNamesFromFile(tagNamesFilePath); } @@ -100,7 +101,7 @@ namespace SHADE // Initialise collision tags std::filesystem::path defaultCollisionTagNameFilePath { ASSET_ROOT }; defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig"); - SHCollisionTag::Init(defaultCollisionTagNameFilePath); + SHCollisionTagMatrix::Init(defaultCollisionTagNameFilePath); // Subscribe to component events const std::shared_ptr ADD_COMPONENT_RECEIVER { std::make_shared>(this, &SHPhysicsSystem::addPhysicsComponent) }; @@ -138,7 +139,7 @@ namespace SHADE // Write collision tag names to file std::filesystem::path defaultCollisionTagNameFilePath { ASSET_ROOT }; defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig"); - SHCollisionTag::Exit(defaultCollisionTagNameFilePath); + SHCollisionTagMatrix::Exit(defaultCollisionTagNameFilePath); } void SHPhysicsSystem::ForceUpdate() -- 2.40.1 From cada3acb8ab4506f77dcadfa97e6496025b31521 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Sun, 20 Nov 2022 18:30:08 +0800 Subject: [PATCH 6/7] Collision tags should be referenced by pointers --- .../Collision/SHCollisionTagMatrix.cpp | 72 ++++++------------- .../Physics/Collision/SHCollisionTagMatrix.h | 8 ++- .../Physics/Interface/SHCollisionShape.cpp | 26 ++++--- .../src/Physics/Interface/SHCollisionShape.h | 7 +- 4 files changed, 48 insertions(+), 65 deletions(-) diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.cpp b/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.cpp index ce6cd900..b687c6ca 100644 --- a/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.cpp +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.cpp @@ -46,6 +46,26 @@ namespace SHADE return -1; } + SHCollisionTag* SHCollisionTagMatrix::GetTag(int tagIndex) + { + if (tagIndex < 0 || tagIndex > SHCollisionTag::NUM_LAYERS) + throw std::invalid_argument("Index out of range!"); + + return &collisionTags[tagIndex]; + } + + SHCollisionTag* SHCollisionTagMatrix::GetTag(const std::string& tagName) noexcept + { + for (int i = 0; i < SHCollisionTag::NUM_LAYERS; ++i) + { + if (collisionTags[i].GetName() == tagName) + return &collisionTags[i]; + } + + SHLOGV_WARNING("Collision Tag {} cannot be found!", tagName) + return nullptr; + } + /*-----------------------------------------------------------------------------------*/ /* Setter Function Definitions */ /*-----------------------------------------------------------------------------------*/ @@ -200,56 +220,4 @@ namespace SHADE collisionTagNamesFile.close(); } - - void SHCollisionTagMatrix::UpdateTagNamesFromFile(const std::filesystem::path& tagNameFilePath) noexcept - { - std::ifstream collisionTagNamesFile { tagNameFilePath }; - - if (!collisionTagNamesFile.is_open()) - { - SHLOG_ERROR("Failed to open file for Collision Tag Names! Default tag names used!") - return; - } - - std::stringstream ss; - std::string line; - - int linesRead = 0; - while (std::getline(collisionTagNamesFile, line)) - { - // Do not read anything beyond the first 16 lines - if (linesRead >= 16) - break; - - ss << line; - ++linesRead; - - // First element is index. - int tagIndex; - ss >> tagIndex; - - // Next element is name of the tag - std::string tagName; - ss >> tagName; - - // If no tag name read, use default. - if (tagName.empty()) - { - SHLOG_ERROR - ( - "Collision tag file line {} does not match the required format of 'indextag name'. Name left unchanged for index {}" - , linesRead + 1 - , tagIndex - ) - - continue; - } - - collisionTags[tagIndex].SetName(tagName); - - ss.clear(); - } - - collisionTagNamesFile.close(); - } } // namespace SHADE \ No newline at end of file diff --git a/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.h b/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.h index eac23ebb..90018fe4 100644 --- a/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.h +++ b/SHADE_Engine/src/Physics/Collision/SHCollisionTagMatrix.h @@ -29,8 +29,11 @@ namespace SHADE /* Getter Functions */ /*---------------------------------------------------------------------------------*/ - [[nodiscard]] static const std::string& GetTagName (int tagIndex); - [[nodiscard]] static int GetTagIndex (const std::string& tagName) noexcept; + [[nodiscard]] static const std::string& GetTagName (int tagIndex); + [[nodiscard]] static int GetTagIndex (const std::string& tagName) noexcept; + + [[nodiscard]] static SHCollisionTag* GetTag (int tagIndex); + [[nodiscard]] static SHCollisionTag* GetTag (const std::string& tagName) noexcept; /*---------------------------------------------------------------------------------*/ /* Setter Functions */ @@ -53,7 +56,6 @@ namespace SHADE static void Init (const std::filesystem::path& tagNameFilePath) noexcept; static void Exit (const std::filesystem::path& tagNameFilePath) noexcept; - static void UpdateTagNamesFromFile (const std::filesystem::path& tagNameFilePath) noexcept; private: /*---------------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp index 11106cf8..c8a082a5 100644 --- a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp +++ b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.cpp @@ -16,6 +16,7 @@ #include "Math/Geometry/SHBox.h" #include "Math/Geometry/SHSphere.h" #include "Math/SHMathHelpers.h" +#include "Physics/Collision/SHCollisionTagMatrix.h" #include "Reflection/SHReflectionMetadata.h" #include "SHColliderComponent.h" @@ -26,12 +27,13 @@ namespace SHADE /*-----------------------------------------------------------------------------------*/ SHCollisionShape::SHCollisionShape(EntityID eid, Type colliderType, const SHPhysicsMaterial& physicsMaterial) - : type { colliderType } - , entityID { eid } - , isTrigger { false } - , dirty { true } - , shape { nullptr } - , material { physicsMaterial } + : type { colliderType } + , entityID { eid } + , isTrigger { false } + , dirty { true } + , shape { nullptr } + , material { physicsMaterial } + , collisionTag { SHCollisionTagMatrix::GetTag(0) } { switch (type) { @@ -57,6 +59,8 @@ namespace SHADE , shape { nullptr } , material { rhs.material } , positionOffset { rhs.positionOffset } + , rotationOffset { rhs.rotationOffset } + , collisionTag { rhs.collisionTag } { CopyShape(rhs.shape); } @@ -69,6 +73,8 @@ namespace SHADE , shape { nullptr } , material { rhs.material } , positionOffset { rhs.positionOffset } + , rotationOffset { rhs.rotationOffset } + , collisionTag { rhs.collisionTag } { CopyShape(rhs.shape); } @@ -93,6 +99,8 @@ namespace SHADE dirty = true; material = rhs.material; positionOffset = rhs.positionOffset; + rotationOffset = rhs.rotationOffset; + collisionTag = rhs.collisionTag; delete shape; CopyShape(rhs.shape); @@ -108,6 +116,8 @@ namespace SHADE dirty = true; material = rhs.material; positionOffset = rhs.positionOffset; + rotationOffset = rhs.rotationOffset; + collisionTag = rhs.collisionTag; delete shape; CopyShape(rhs.shape); @@ -136,7 +146,7 @@ namespace SHADE const SHCollisionTag& SHCollisionShape::GetCollisionTag() const noexcept { - return collisionTag; + return *collisionTag; } float SHCollisionShape::GetFriction() const noexcept @@ -245,7 +255,7 @@ namespace SHADE isTrigger = trigger; } - void SHCollisionShape::SetCollisionTag(const SHCollisionTag& newCollisionTag) noexcept + void SHCollisionShape::SetCollisionTag(SHCollisionTag* newCollisionTag) noexcept { dirty = true; collisionTag = newCollisionTag; diff --git a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h index 09793026..597814a6 100644 --- a/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h +++ b/SHADE_Engine/src/Physics/Interface/SHCollisionShape.h @@ -95,7 +95,7 @@ namespace SHADE void SetBoundingSphere (float radius); void SetIsTrigger (bool isTrigger) noexcept; - void SetCollisionTag (const SHCollisionTag& newCollisionTag) noexcept; + void SetCollisionTag (SHCollisionTag* newCollisionTag) noexcept; void SetFriction (float friction) noexcept; void SetBounciness (float bounciness) noexcept; void SetDensity (float density) noexcept; @@ -113,12 +113,15 @@ namespace SHADE EntityID entityID; // The entity this collider belongs to bool isTrigger; bool dirty; - SHCollisionTag collisionTag; + SHShape* shape; SHPhysicsMaterial material; + SHVec3 positionOffset; SHVec3 rotationOffset; + SHCollisionTag* collisionTag; + /*---------------------------------------------------------------------------------*/ /* Function Members */ /*---------------------------------------------------------------------------------*/ -- 2.40.1 From d4ad60ea7974ea8ec6111421cf0b063cdc7c6625 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Sun, 20 Nov 2022 20:12:20 +0800 Subject: [PATCH 7/7] Fix compile error with collision tags --- SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp | 6 ------ SHADE_Engine/src/Physics/System/SHPhysicsSystem.h | 1 - 2 files changed, 7 deletions(-) diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp index b2f618a7..396edd93 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp @@ -86,12 +86,6 @@ namespace SHADE worldState.UpdateSettings(); } - void SHPhysicsSystem::SetCollisionTagFile(const std::filesystem::path& tagNamesFilePath) noexcept - { - SHCollisionTagMatrix::UpdateTagNamesFromFile(tagNamesFilePath); - } - - /*-----------------------------------------------------------------------------------*/ /* Public Function Member Definitions */ /*-----------------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.h b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.h index 89ecb51e..f92be4cd 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.h +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.h @@ -69,7 +69,6 @@ namespace SHADE void SetFixedUpdateRate (double fixedUpdateRate) noexcept; void SetWorldSettings (const SHPhysicsWorldState::WorldSettings& settings) noexcept; - void SetCollisionTagFile (const std::filesystem::path& tagNamesFilePath) noexcept; /*---------------------------------------------------------------------------------*/ /* Function Members */ -- 2.40.1