Changed casts

This commit is contained in:
Diren D Bharwani 2023-03-03 21:16:18 +08:00
parent 74c32457a8
commit 5c38244ce4
3 changed files with 2 additions and 157 deletions

View File

@ -436,12 +436,12 @@ namespace SHADE
if (ImGui::Selectable("Box Collider"))
{
auto* compositeCollider = dynamic_cast<SHCompositeCollider* const>(component->GetCollider());
auto* compositeCollider = reinterpret_cast<SHCompositeCollider* const>(component->GetCollider());
compositeCollider->AddBoxCollisionShape(SHVec3::One);
}
if (ImGui::Selectable("Sphere Collider"))
{
auto* compositeCollider = dynamic_cast<SHCompositeCollider* const>(component->GetCollider());
auto* compositeCollider = reinterpret_cast<SHCompositeCollider* const>(component->GetCollider());
compositeCollider->AddSphereCollisionShape(1.0f);
}

View File

@ -1,117 +0,0 @@
/****************************************************************************************
* \file SHCollisionID.h
* \author Diren D Bharwani, diren.dbharwani, 390002520
* \brief Interface for Collision Information for Collision & Triggers.
*
* \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
// Project Headers
#include "Physics/Interface/SHColliderComponent.h"
#include "Physics/Interface/SHRigidBodyComponent.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Forward Declarations */
/*-----------------------------------------------------------------------------------*/
struct SHCollisionKeyHash;
/*-----------------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------------*/
/**
* @brief
* Encapsulates the information when two collision shapes intersect.
*/
class SH_API SHCollisionKey
{
private:
/*---------------------------------------------------------------------------------*/
/* Friends */
/*---------------------------------------------------------------------------------*/
friend struct SHCollisionKeyHash;
public:
/*---------------------------------------------------------------------------------*/
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
SHCollisionKey () noexcept;
SHCollisionKey (const SHCollisionKey& rhs) noexcept;
SHCollisionKey (SHCollisionKey&& rhs) noexcept;
~SHCollisionKey () noexcept = default;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
SHCollisionKey& operator= (const SHCollisionKey& rhs) noexcept;
SHCollisionKey& operator= (SHCollisionKey&& rhs) noexcept;
bool operator==(const SHCollisionKey& rhs) const;
/*---------------------------------------------------------------------------------*/
/* Getter Functions */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] EntityID GetEntityA () const noexcept;
[[nodiscard]] EntityID GetEntityB () const noexcept;
[[nodiscard]] uint32_t GetShapeIndexA () const noexcept;
[[nodiscard]] uint32_t GetShapeIndexB () const noexcept;
[[nodiscard]] const SHRigidBodyComponent* GetRigidBodyA () const noexcept;
[[nodiscard]] const SHRigidBodyComponent* GetRigidBodyB () const noexcept;
[[nodiscard]] const SHCollisionShape* GetCollisionShapeA () const noexcept;
[[nodiscard]] const SHCollisionShape* GetCollisionShapeB () const noexcept;
/*---------------------------------------------------------------------------------*/
/* Setter Functions */
/*---------------------------------------------------------------------------------*/
void SetEntityA (EntityID entityID) noexcept;
void SetEntityB (EntityID entityID) noexcept;
void SetCollisionShapeA (uint32_t shapeIndexA) noexcept;
void SetCollisionShapeB (uint32_t shapeIndexB) noexcept;
private:
static constexpr uint32_t ENTITY_A = 0;
static constexpr uint32_t SHAPE_INDEX_A = 1;
static constexpr uint32_t ENTITY_B = 2;
static constexpr uint32_t SHAPE_INDEX_B = 3;
/*---------------------------------------------------------------------------------*/
/* Data Members */
/*---------------------------------------------------------------------------------*/
union
{
uint64_t value[2]; // EntityValue, ShapeIndexValue
uint32_t ids [4]; // EntityA, EntityB, ShapeIndexA, ShapeIndexB
};
};
/**
* @brief
* Encapsulates a functor to hash a CollisionKey
*/
struct SHCollisionKeyHash
{
public:
/*---------------------------------------------------------------------------------*/
/* Member Functions */
/*---------------------------------------------------------------------------------*/
std::size_t operator()(const SHCollisionKey& id) const;
};
} // namespace SHADE

View File

@ -1,38 +0,0 @@
/****************************************************************************************
* \file SHCollisionUtils.cpp
* \author Diren D Bharwani, diren.dbharwani, 390002520
* \brief Implementation for some objects to assist with collision detection
*
* \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 <SHpch.h>
// Primary Header
#include "SHCollisionUtils.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Operator Overload Definitions */
/*-----------------------------------------------------------------------------------*/
SHVec3 SHCollisionUtils::ShapeTransform::operator*(const SHVec3& rhs) const noexcept
{
return SHVec3::Rotate(rhs, orientation) + position;
}
/*-----------------------------------------------------------------------------------*/
/* Public Member Functions Definitions */
/*-----------------------------------------------------------------------------------*/
SHCollisionUtils::ShapeTransform SHCollisionUtils::ShapeTransform::GetInverse() const noexcept
{
const SHQuaternion INV_ORIENTATION = SHQuaternion::Inverse(orientation);
return ShapeTransform { SHVec3::Rotate(-position, INV_ORIENTATION), INV_ORIENTATION };
}
} // namespace SHADE