Added CollisionInfo and SHPhysicsSystemInterface
This commit is contained in:
parent
2ca353a0b7
commit
ccbbdc6485
|
@ -0,0 +1,52 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file SHPhysicsSystemInterface.cpp
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 31, 2022
|
||||||
|
\brief Contains the definitions of the functions of the static
|
||||||
|
SHPhysicsSystemInterface class.
|
||||||
|
|
||||||
|
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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
// Precompiled Headers
|
||||||
|
#include "SHpch.h"
|
||||||
|
// Primary Header
|
||||||
|
#include "SHPhysicsSystemInterface.h"
|
||||||
|
// Project Includes
|
||||||
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
|
#include "Physics/SHPhysicsSystem.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Static Usage Functions */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
const std::vector<SHCollisionEvent>& SHPhysicsSystemInterface::GetCollisionInfo() noexcept
|
||||||
|
{
|
||||||
|
static std::vector<SHCollisionEvent> emptyVec;
|
||||||
|
|
||||||
|
auto phySystem = SHSystemManager::GetSystem<SHPhysicsSystem>();
|
||||||
|
if (phySystem)
|
||||||
|
{
|
||||||
|
return phySystem->GetCollisionInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("[SHPhysicsSystemInterface] Failed to get collision events. Empty vector returned instead.");
|
||||||
|
return emptyVec;
|
||||||
|
}
|
||||||
|
const std::vector<SHCollisionEvent>& SHPhysicsSystemInterface::GetTriggerInfo() noexcept
|
||||||
|
{
|
||||||
|
static std::vector<SHCollisionEvent> emptyVec;
|
||||||
|
|
||||||
|
auto phySystem = SHSystemManager::GetSystem<SHPhysicsSystem>();
|
||||||
|
if (phySystem)
|
||||||
|
{
|
||||||
|
return phySystem->GetTriggerInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("[SHPhysicsSystemInterface] Failed to get trigger events. Empty vector returned instead.");
|
||||||
|
return emptyVec;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file SHPhysicsSystemInterface.h
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 31, 2022
|
||||||
|
\brief Contains the definition of the SHGraphicsSystemInterface static class.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
// STL Includes
|
||||||
|
#include <vector>
|
||||||
|
// Project Includes
|
||||||
|
#include "SHPhysicsUtils.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Type Definitions */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Static class that wraps up certain functions in the SHPhysicsSystem so that
|
||||||
|
/// accessing it from SHADE_Managed would not cause issues due to C++20 features.
|
||||||
|
/// </summary>
|
||||||
|
class SH_API SHPhysicsSystemInterface final
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Constructor */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
SHPhysicsSystemInterface() = delete;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Static Usage Functions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
[[nodiscard]] static const std::vector<SHCollisionEvent>& GetCollisionInfo() noexcept;
|
||||||
|
[[nodiscard]] static const std::vector<SHCollisionEvent>& GetTriggerInfo() noexcept;
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file CollisionInfo.hxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 31, 2022
|
||||||
|
\brief Contains the definition of the managed CollisionInfo struct with the
|
||||||
|
definition of its properties and declaration of functions.
|
||||||
|
|
||||||
|
Note: This file is written in C++17/CLI.
|
||||||
|
|
||||||
|
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 Includes
|
||||||
|
#include "Engine/GameObject.hxx"
|
||||||
|
#include "Components/RigidBody.hxx"
|
||||||
|
#include "Components/Collider.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Struct that describes a collision
|
||||||
|
/// </summary>
|
||||||
|
public value struct CollisionInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// The GameObject whose collider you are colliding with.
|
||||||
|
/// </summary>
|
||||||
|
property GameObject GameObject;
|
||||||
|
/// <summary>
|
||||||
|
/// The Collider that you are colliding with.
|
||||||
|
/// </summary>
|
||||||
|
property Collider^ Collider
|
||||||
|
{
|
||||||
|
SHADE::Collider^ get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The CollisionShape of the Collider that you are colliding with.
|
||||||
|
/// </summary>
|
||||||
|
property CollisionShape^ CollisionShape
|
||||||
|
{
|
||||||
|
SHADE::CollisionShape^ get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The RigidBody that you are colliding with.
|
||||||
|
/// </summary>
|
||||||
|
property RigidBody^ RigidBody
|
||||||
|
{
|
||||||
|
SHADE::RigidBody^ get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue