Changed ColliderBound to CollisionShape because ColliderBound sounds weird
This commit is contained in:
parent
4fc87866ee
commit
1a4b15feb2
|
@ -417,13 +417,13 @@ namespace SHADE
|
|||
(
|
||||
DEFAULT_CSHARP_LIB_NAME,
|
||||
DEFAULT_CSHARP_NAMESPACE + ".Collider",
|
||||
"OnColliderBoundChanged"
|
||||
"OnCollisionShapeChanged"
|
||||
);
|
||||
csColliderOnRemoved = dotNet.GetFunctionPtr<CsEventRelayFuncPtr>
|
||||
(
|
||||
DEFAULT_CSHARP_LIB_NAME,
|
||||
DEFAULT_CSHARP_NAMESPACE + ".Collider",
|
||||
"OnColliderRemoved"
|
||||
"OnCollisionShapeRemoved"
|
||||
);
|
||||
csEditorRenderScripts = dotNet.GetFunctionPtr<CsScriptEditorFuncPtr>
|
||||
(
|
||||
|
|
|
@ -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<SHBoundingBox>().GetCenter());
|
||||
}
|
||||
void BoxColliderBound::Center::set(Vector3 value)
|
||||
void BoxCollider::Center::set(Vector3 value)
|
||||
{
|
||||
getNativeBoundObject<SHBoundingBox>().SetCenter(Convert::ToNative(value));
|
||||
}
|
||||
Vector3 BoxColliderBound::HalfExtents::get()
|
||||
Vector3 BoxCollider::HalfExtents::get()
|
||||
{
|
||||
return Convert::ToCLI(getNativeBoundObject<SHBoundingBox>().GetHalfExtents());
|
||||
}
|
||||
void BoxColliderBound::HalfExtents::set(Vector3 value)
|
||||
void BoxCollider::HalfExtents::set(Vector3 value)
|
||||
{
|
||||
getNativeBoundObject<SHBoundingBox>().SetHalfExtents(Convert::ToNative(value));
|
||||
}
|
||||
Vector3 BoxColliderBound::Min::get()
|
||||
Vector3 BoxCollider::Min::get()
|
||||
{
|
||||
return Convert::ToCLI(getNativeBoundObject<SHBoundingBox>().GetMin());
|
||||
}
|
||||
void BoxColliderBound::Min::set(Vector3 value)
|
||||
void BoxCollider::Min::set(Vector3 value)
|
||||
{
|
||||
getNativeBoundObject<SHBoundingBox>().SetMin(Convert::ToNative(value));
|
||||
}
|
||||
Vector3 BoxColliderBound::Max::get()
|
||||
Vector3 BoxCollider::Max::get()
|
||||
{
|
||||
return Convert::ToCLI(getNativeBoundObject<SHBoundingBox>().GetMax());
|
||||
}
|
||||
void BoxColliderBound::Max::set(Vector3 value)
|
||||
void BoxCollider::Max::set(Vector3 value)
|
||||
{
|
||||
getNativeBoundObject<SHBoundingBox>().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<SHBoundingBox>().TestPoint(Convert::ToNative(point));
|
||||
}
|
||||
bool BoxColliderBound::Raycast(Ray ray, float maxDistance)
|
||||
bool BoxCollider::Raycast(Ray ray, float maxDistance)
|
||||
{
|
||||
return getNativeBoundObject<SHBoundingBox>().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<SHBoundingSphere>().GetCenter());
|
||||
}
|
||||
void SphereColliderBound::Center::set(Vector3 value)
|
||||
void SphereCollider::Center::set(Vector3 value)
|
||||
{
|
||||
getNativeBoundObject<SHBoundingSphere>().SetCenter(Convert::ToNative(value));
|
||||
}
|
||||
float SphereColliderBound::Radius::get()
|
||||
float SphereCollider::Radius::get()
|
||||
{
|
||||
return getNativeBoundObject<SHBoundingSphere>().GetRadius();
|
||||
}
|
||||
void SphereColliderBound::Radius::set(float value)
|
||||
void SphereCollider::Radius::set(float value)
|
||||
{
|
||||
getNativeBoundObject<SHBoundingSphere>().SetRadius(value);
|
||||
}
|
||||
|
@ -113,11 +113,11 @@ namespace SHADE
|
|||
/*---------------------------------------------------------------------------------*/
|
||||
/* SphereColliderBound - Usage Functions */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
bool SphereColliderBound::TestPoint(Vector3 point)
|
||||
bool SphereCollider::TestPoint(Vector3 point)
|
||||
{
|
||||
return getNativeBoundObject<SHBoundingBox>().TestPoint(Convert::ToNative(point));
|
||||
}
|
||||
bool SphereColliderBound::Raycast(Ray ray, float maxDistance)
|
||||
bool SphereCollider::Raycast(Ray ray, float maxDistance)
|
||||
{
|
||||
return getNativeBoundObject<SHBoundingBox>().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<int>(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<typename T>
|
||||
T Collider::GetColliderBound(int index)
|
||||
T Collider::GetCollisionShape(int index)
|
||||
{
|
||||
return safe_cast<T>(GetColliderBound(index));
|
||||
return safe_cast<T>(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<ColliderBound^>();
|
||||
subColliderList = gcnew System::Collections::Generic::List<CollisionShape^>();
|
||||
|
||||
// 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
|
||||
|
|
|
@ -18,8 +18,8 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include "Component.hxx"
|
||||
namespace SHADE
|
||||
{
|
||||
template<typename ColliderBoundType>
|
||||
ColliderBoundType& SHADE::ColliderBound::getNativeBoundObject()
|
||||
template<typename CollisionShapeType>
|
||||
CollisionShapeType& SHADE::CollisionShape::getNativeBoundObject()
|
||||
{
|
||||
SHColliderComponent* collider = SHComponentManager::GetComponent_s<SHColliderComponent>(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<ColliderBoundType&>(bounds);
|
||||
return reinterpret_cast<CollisionShapeType&>(bounds);
|
||||
}
|
||||
catch (std::invalid_argument&)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace SHADE
|
|||
/// <summary>
|
||||
/// Base interface for all Collider Shapes.
|
||||
/// </summary>
|
||||
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<typename ColliderBoundType>
|
||||
ColliderBoundType& getNativeBoundObject();
|
||||
template<typename CollisionShapeType>
|
||||
CollisionShapeType& getNativeBoundObject();
|
||||
|
||||
internal:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
@ -75,7 +75,7 @@ namespace SHADE
|
|||
/// <summary>
|
||||
/// Box-shaped Collider Bound.
|
||||
/// </summary>
|
||||
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);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Sphere-shaped Collider Bound.
|
||||
/// </summary>
|
||||
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);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -196,7 +196,7 @@ namespace SHADE
|
|||
/// <summary>
|
||||
/// Total number of ColliderBounds in the Collider component.
|
||||
/// </summary>
|
||||
property int ColliderBoundsCount
|
||||
property int CollisionShapeCount
|
||||
{
|
||||
int get();
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ namespace SHADE
|
|||
/// </summary>
|
||||
/// <param name="index">Index to retrieve a ColliderBound from.</param>
|
||||
/// <returns>ColliderBound for the specified index.</returns>
|
||||
ColliderBound^ GetColliderBound(int index);
|
||||
CollisionShape^ GetCollisionShape(int index);
|
||||
/// <summary>
|
||||
/// Retrieves a ColliderBound at the specified index in the ColliderBound list
|
||||
/// and casts it to the appropriate type.
|
||||
|
@ -217,42 +217,42 @@ namespace SHADE
|
|||
/// <typeparam name="T">Type of the ColliderBound to cast to.</typeparam>
|
||||
/// <param name="index">Index to retrieve a ColliderBound from.</param>
|
||||
/// <returns>ColliderBound for the specified index.</returns>
|
||||
generic<typename T> where T:ColliderBound
|
||||
T GetColliderBound(int index);
|
||||
generic<typename T> where T:CollisionShape
|
||||
T GetCollisionShape(int index);
|
||||
|
||||
internal:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Event Handling Functions */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity which has it's collider removed.</param>
|
||||
static void OnColliderRemoved(EntityID entity);
|
||||
/// <param name="entity">The entity which has it's collision shape removed.</param>
|
||||
static void OnCollisionShapeRemoved(EntityID entity);
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="entity">
|
||||
/// The entity which has it's collider bounds changed.
|
||||
/// The entity which has it's collision shape changed.
|
||||
/// </param>
|
||||
static void OnColliderBoundChanged(EntityID entity);
|
||||
static void OnCollisionShapeChanged(EntityID entity);
|
||||
|
||||
private:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Type Definitions */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
using WeakReferenceList = System::Collections::Generic::List<System::WeakReference^>;
|
||||
using CollidersMap = System::Collections::Generic::Dictionary<EntityID, WeakReferenceList^>;
|
||||
using ColliderMap = System::Collections::Generic::Dictionary<EntityID, WeakReferenceList^>;
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Static Data Members */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
static CollidersMap^ colliders;
|
||||
static ColliderMap^ colliders;
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Data Members */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
System::Collections::Generic::List<ColliderBound^>^ subColliderList;
|
||||
System::Collections::Generic::List<CollisionShape^>^ subColliderList;
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Helper Functions */
|
||||
|
|
Loading…
Reference in New Issue