From 1a4b15feb274307bf4a48b96b0eeda78ef96c5e8 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Fri, 28 Oct 2022 14:29:05 +0800 Subject: [PATCH] Changed ColliderBound to CollisionShape because ColliderBound sounds weird --- SHADE_Engine/src/Scripting/SHScriptEngine.cpp | 4 +- SHADE_Managed/src/Components/Collider.cxx | 66 +++++++++---------- SHADE_Managed/src/Components/Collider.h++ | 6 +- SHADE_Managed/src/Components/Collider.hxx | 42 ++++++------ 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/SHADE_Engine/src/Scripting/SHScriptEngine.cpp b/SHADE_Engine/src/Scripting/SHScriptEngine.cpp index f0f8912b..21ce7b82 100644 --- a/SHADE_Engine/src/Scripting/SHScriptEngine.cpp +++ b/SHADE_Engine/src/Scripting/SHScriptEngine.cpp @@ -417,13 +417,13 @@ namespace SHADE ( DEFAULT_CSHARP_LIB_NAME, DEFAULT_CSHARP_NAMESPACE + ".Collider", - "OnColliderBoundChanged" + "OnCollisionShapeChanged" ); csColliderOnRemoved = dotNet.GetFunctionPtr ( DEFAULT_CSHARP_LIB_NAME, DEFAULT_CSHARP_NAMESPACE + ".Collider", - "OnColliderRemoved" + "OnCollisionShapeRemoved" ); csEditorRenderScripts = dotNet.GetFunctionPtr ( diff --git a/SHADE_Managed/src/Components/Collider.cxx b/SHADE_Managed/src/Components/Collider.cxx index 6768ad1c..f2119b43 100644 --- a/SHADE_Managed/src/Components/Collider.cxx +++ b/SHADE_Managed/src/Components/Collider.cxx @@ -22,7 +22,7 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ /* ColliderBound - Constructors */ /*---------------------------------------------------------------------------------*/ - ColliderBound::ColliderBound(int arrayIdx, Entity attachedEntity) + CollisionShape::CollisionShape(int arrayIdx, Entity attachedEntity) : arrayIndex { arrayIdx } , entity { attachedEntity } {} @@ -30,7 +30,7 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ /* ColliderBound - Setter Functions */ /*---------------------------------------------------------------------------------*/ - void ColliderBound::updateArrayIndex(int index) + void CollisionShape::updateArrayIndex(int index) { arrayIndex = index; } @@ -38,42 +38,42 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ /* BoxColliderBound - Constructors */ /*---------------------------------------------------------------------------------*/ - BoxColliderBound::BoxColliderBound(int arrayIdx, Entity attachedEntity) - : ColliderBound { arrayIndex, attachedEntity } + BoxCollider::BoxCollider(int arrayIdx, Entity attachedEntity) + : CollisionShape { arrayIndex, attachedEntity } {} /*---------------------------------------------------------------------------------*/ /* BoxColliderBound - Properties */ /*---------------------------------------------------------------------------------*/ - Vector3 BoxColliderBound::Center::get() + Vector3 BoxCollider::Center::get() { return Convert::ToCLI(getNativeBoundObject().GetCenter()); } - void BoxColliderBound::Center::set(Vector3 value) + void BoxCollider::Center::set(Vector3 value) { getNativeBoundObject().SetCenter(Convert::ToNative(value)); } - Vector3 BoxColliderBound::HalfExtents::get() + Vector3 BoxCollider::HalfExtents::get() { return Convert::ToCLI(getNativeBoundObject().GetHalfExtents()); } - void BoxColliderBound::HalfExtents::set(Vector3 value) + void BoxCollider::HalfExtents::set(Vector3 value) { getNativeBoundObject().SetHalfExtents(Convert::ToNative(value)); } - Vector3 BoxColliderBound::Min::get() + Vector3 BoxCollider::Min::get() { return Convert::ToCLI(getNativeBoundObject().GetMin()); } - void BoxColliderBound::Min::set(Vector3 value) + void BoxCollider::Min::set(Vector3 value) { getNativeBoundObject().SetMin(Convert::ToNative(value)); } - Vector3 BoxColliderBound::Max::get() + Vector3 BoxCollider::Max::get() { return Convert::ToCLI(getNativeBoundObject().GetMax()); } - void BoxColliderBound::Max::set(Vector3 value) + void BoxCollider::Max::set(Vector3 value) { getNativeBoundObject().SetMax(Convert::ToNative(value)); } @@ -81,11 +81,11 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ /* BoxColliderBound - Usage Functions */ /*---------------------------------------------------------------------------------*/ - bool BoxColliderBound::TestPoint(Vector3 point) + bool BoxCollider::TestPoint(Vector3 point) { return getNativeBoundObject().TestPoint(Convert::ToNative(point)); } - bool BoxColliderBound::Raycast(Ray ray, float maxDistance) + bool BoxCollider::Raycast(Ray ray, float maxDistance) { return getNativeBoundObject().Raycast(Convert::ToNative(ray), maxDistance); } @@ -93,19 +93,19 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ /* BoxColliderBound - Properties */ /*---------------------------------------------------------------------------------*/ - Vector3 SphereColliderBound::Center::get() + Vector3 SphereCollider::Center::get() { return Convert::ToCLI(getNativeBoundObject().GetCenter()); } - void SphereColliderBound::Center::set(Vector3 value) + void SphereCollider::Center::set(Vector3 value) { getNativeBoundObject().SetCenter(Convert::ToNative(value)); } - float SphereColliderBound::Radius::get() + float SphereCollider::Radius::get() { return getNativeBoundObject().GetRadius(); } - void SphereColliderBound::Radius::set(float value) + void SphereCollider::Radius::set(float value) { getNativeBoundObject().SetRadius(value); } @@ -113,11 +113,11 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ /* SphereColliderBound - Usage Functions */ /*---------------------------------------------------------------------------------*/ - bool SphereColliderBound::TestPoint(Vector3 point) + bool SphereCollider::TestPoint(Vector3 point) { return getNativeBoundObject().TestPoint(Convert::ToNative(point)); } - bool SphereColliderBound::Raycast(Ray ray, float maxDistance) + bool SphereCollider::Raycast(Ray ray, float maxDistance) { return getNativeBoundObject().Raycast(Convert::ToNative(ray), maxDistance); } @@ -125,8 +125,8 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ /* SphereColliderBound - Constructors */ /*---------------------------------------------------------------------------------*/ - SphereColliderBound::SphereColliderBound(int arrayIndex, Entity attachedEntity) - : ColliderBound{ arrayIndex, attachedEntity } + SphereCollider::SphereCollider(int arrayIndex, Entity attachedEntity) + : CollisionShape{ arrayIndex, attachedEntity } {} /*---------------------------------------------------------------------------------*/ @@ -137,7 +137,7 @@ namespace SHADE { // Create lists if they don't exist if (colliders == nullptr) - colliders = gcnew CollidersMap; + colliders = gcnew ColliderMap; if (!colliders->ContainsKey(entity)) colliders->Add(entity, gcnew WeakReferenceList()); @@ -148,7 +148,7 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ /* Collider - Properties */ /*---------------------------------------------------------------------------------*/ - int Collider::ColliderBoundsCount::get() + int Collider::CollisionShapeCount::get() { return static_cast(GetNativeComponent()->GetColliders().size()); } @@ -156,7 +156,7 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ /* Collider - ColliderBound Functions */ /*---------------------------------------------------------------------------------*/ - ColliderBound^ Collider::GetColliderBound(int index) + CollisionShape^ Collider::GetCollisionShape(int index) { // Populate the list if it hasn't been if (subColliderList == nullptr) @@ -172,15 +172,15 @@ namespace SHADE return subColliderList[index]; } generic - T Collider::GetColliderBound(int index) + T Collider::GetCollisionShape(int index) { - return safe_cast(GetColliderBound(index)); + return safe_cast(GetCollisionShape(index)); } /*---------------------------------------------------------------------------------*/ /* Event Handling Functions */ /*---------------------------------------------------------------------------------*/ - void Collider::OnColliderRemoved(EntityID entity) + void Collider::OnCollisionShapeRemoved(EntityID entity) { SAFE_NATIVE_CALL_BEGIN // Check if there are any colliders to update @@ -192,7 +192,7 @@ namespace SHADE SAFE_NATIVE_CALL_END("Collider.OnColliderRemoved") } - void Collider::OnColliderBoundChanged(EntityID entity) + void Collider::OnCollisionShapeChanged(EntityID entity) { SAFE_NATIVE_CALL_BEGIN // Check if there are any colliders to update @@ -226,20 +226,20 @@ namespace SHADE if (subColliderList) subColliderList->Clear(); else - subColliderList = gcnew System::Collections::Generic::List(); + subColliderList = gcnew System::Collections::Generic::List(); // Populate the list int i = 0; for (const auto& collider : GetNativeComponent()->GetColliders()) { - ColliderBound^ bound = nullptr; + CollisionShape^ bound = nullptr; switch (collider.GetType()) { case SHCollider::Type::BOX: - bound = gcnew BoxColliderBound(i, Owner.GetEntity()); + bound = gcnew BoxCollider(i, Owner.GetEntity()); break; case SHCollider::Type::SPHERE: - bound = gcnew SphereColliderBound(i, Owner.GetEntity()); + bound = gcnew SphereCollider(i, Owner.GetEntity()); break; case SHCollider::Type::CAPSULE: // TODO diff --git a/SHADE_Managed/src/Components/Collider.h++ b/SHADE_Managed/src/Components/Collider.h++ index 66f77e18..1f8b43eb 100644 --- a/SHADE_Managed/src/Components/Collider.h++ +++ b/SHADE_Managed/src/Components/Collider.h++ @@ -18,8 +18,8 @@ of DigiPen Institute of Technology is prohibited. #include "Component.hxx" namespace SHADE { - template - ColliderBoundType& SHADE::ColliderBound::getNativeBoundObject() + template + CollisionShapeType& SHADE::CollisionShape::getNativeBoundObject() { SHColliderComponent* collider = SHComponentManager::GetComponent_s(entity); if (!collider) @@ -31,7 +31,7 @@ namespace SHADE if (bounds.GetType() != SHCollider::Type::BOX) throw gcnew System::InvalidOperationException("Attempted to retrieve invalid ColliderBound."); - return reinterpret_cast(bounds); + return reinterpret_cast(bounds); } catch (std::invalid_argument&) { diff --git a/SHADE_Managed/src/Components/Collider.hxx b/SHADE_Managed/src/Components/Collider.hxx index f827ab71..9555976f 100644 --- a/SHADE_Managed/src/Components/Collider.hxx +++ b/SHADE_Managed/src/Components/Collider.hxx @@ -27,7 +27,7 @@ namespace SHADE /// /// Base interface for all Collider Shapes. /// - public ref class ColliderBound + public ref class CollisionShape { public: /*-----------------------------------------------------------------------------*/ @@ -51,7 +51,7 @@ namespace SHADE /*-----------------------------------------------------------------------------*/ /* Constructors */ /*-----------------------------------------------------------------------------*/ - ColliderBound(int arrayIdx, Entity attachedEntity); + CollisionShape(int arrayIdx, Entity attachedEntity); /*-----------------------------------------------------------------------------*/ /* Data Members */ @@ -62,8 +62,8 @@ namespace SHADE /*-----------------------------------------------------------------------------*/ /* Helper Functions */ /*-----------------------------------------------------------------------------*/ - template - ColliderBoundType& getNativeBoundObject(); + template + CollisionShapeType& getNativeBoundObject(); internal: /*-----------------------------------------------------------------------------*/ @@ -75,7 +75,7 @@ namespace SHADE /// /// Box-shaped Collider Bound. /// - public ref class BoxColliderBound : public ColliderBound + public ref class BoxCollider : public CollisionShape { public: /*-----------------------------------------------------------------------------*/ @@ -128,13 +128,13 @@ namespace SHADE /*-----------------------------------------------------------------------------*/ /* Constructors */ /*-----------------------------------------------------------------------------*/ - BoxColliderBound(int arrayIndex, Entity attachedEntity); + BoxCollider(int arrayIndex, Entity attachedEntity); }; /// /// Sphere-shaped Collider Bound. /// - public ref class SphereColliderBound : public ColliderBound + public ref class SphereCollider : public CollisionShape { public: /*-----------------------------------------------------------------------------*/ @@ -169,7 +169,7 @@ namespace SHADE /*-----------------------------------------------------------------------------*/ /* Constructors */ /*-----------------------------------------------------------------------------*/ - SphereColliderBound(int arrayIndex, Entity attachedEntity); + SphereCollider(int arrayIndex, Entity attachedEntity); }; /// @@ -196,7 +196,7 @@ namespace SHADE /// /// Total number of ColliderBounds in the Collider component. /// - property int ColliderBoundsCount + property int CollisionShapeCount { int get(); } @@ -209,7 +209,7 @@ namespace SHADE /// /// Index to retrieve a ColliderBound from. /// ColliderBound for the specified index. - ColliderBound^ GetColliderBound(int index); + CollisionShape^ GetCollisionShape(int index); /// /// Retrieves a ColliderBound at the specified index in the ColliderBound list /// and casts it to the appropriate type. @@ -217,42 +217,42 @@ namespace SHADE /// Type of the ColliderBound to cast to. /// Index to retrieve a ColliderBound from. /// ColliderBound for the specified index. - generic where T:ColliderBound - T GetColliderBound(int index); + generic where T:CollisionShape + T GetCollisionShape(int index); internal: /*-----------------------------------------------------------------------------*/ /* Event Handling Functions */ /*-----------------------------------------------------------------------------*/ /// - /// To be called from native code when a collider has been removed. + /// To be called from native code when a collision shape has been removed. /// - /// The entity which has it's collider removed. - static void OnColliderRemoved(EntityID entity); + /// The entity which has it's collision shape removed. + static void OnCollisionShapeRemoved(EntityID entity); /// - /// To be called from native code when a Collider bound has been removed. + /// To be called from native code when a Collision Shape has been changed. /// /// - /// The entity which has it's collider bounds changed. + /// The entity which has it's collision shape changed. /// - static void OnColliderBoundChanged(EntityID entity); + static void OnCollisionShapeChanged(EntityID entity); private: /*-----------------------------------------------------------------------------*/ /* Type Definitions */ /*-----------------------------------------------------------------------------*/ using WeakReferenceList = System::Collections::Generic::List; - using CollidersMap = System::Collections::Generic::Dictionary; + using ColliderMap = System::Collections::Generic::Dictionary; /*-----------------------------------------------------------------------------*/ /* Static Data Members */ /*-----------------------------------------------------------------------------*/ - static CollidersMap^ colliders; + static ColliderMap^ colliders; /*-----------------------------------------------------------------------------*/ /* Data Members */ /*-----------------------------------------------------------------------------*/ - System::Collections::Generic::List^ subColliderList; + System::Collections::Generic::List^ subColliderList; /*-----------------------------------------------------------------------------*/ /* Helper Functions */