[add] PhysX CCT 추가

This commit is contained in:
kimnuri
2025-11-10 09:59:26 +09:00
parent 56841bef3e
commit ac10b4221d
11 changed files with 179 additions and 34 deletions
@@ -136,16 +136,14 @@
<Filter Include="50.UI\Mission\Active_Icon">
<UniqueIdentifier>{977fe4d3-c3b5-413c-80fe-777ece19453e}</UniqueIdentifier>
</Filter>
<<<<<<< Updated upstream
<Filter Include="02.GameObjects\Terrain">
<UniqueIdentifier>{44a3ddc2-3993-48d6-840c-3da09daeab70}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Env\Manger">
<UniqueIdentifier>{584466e9-fe1a-4a7d-a4ba-54d62ee1a7c1}</UniqueIdentifier>
=======
</Filter>
<Filter Include="01.Level\60.PhysXLab">
<UniqueIdentifier>{943a760b-2861-45b7-87b8-462e1309c172}</UniqueIdentifier>
>>>>>>> Stashed changes
</Filter>
</ItemGroup>
<ItemGroup>
@@ -257,7 +255,6 @@
<ClInclude Include="..\public\Active_Icon.h">
<Filter>50.UI\Mission\Active_Icon</Filter>
</ClInclude>
<<<<<<< Updated upstream
<ClInclude Include="..\public\Level_MapViewer.h">
<Filter>01.Level\30.MapViewer</Filter>
</ClInclude>
@@ -269,10 +266,9 @@
</ClInclude>
<ClInclude Include="..\public\MapObject_Manager.h">
<Filter>02.GameObjects\Env\Manger</Filter>
=======
</ClInclude>
<ClInclude Include="..\Public\Level_PhysXLab.h">
<Filter>01.Level\60.PhysXLab</Filter>
>>>>>>> Stashed changes
</ClInclude>
</ItemGroup>
<ItemGroup>
@@ -377,7 +373,6 @@
<ClCompile Include="..\private\Active_Icon.cpp">
<Filter>50.UI\Mission\Active_Icon</Filter>
</ClCompile>
<<<<<<< Updated upstream
<ClCompile Include="..\private\Level_MapViewer.cpp">
<Filter>01.Level\30.MapViewer</Filter>
</ClCompile>
@@ -389,10 +384,9 @@
</ClCompile>
<ClCompile Include="..\private\MapObject_Manager.cpp">
<Filter>02.GameObjects\Env\Manger</Filter>
=======
</ClCompile>
<ClCompile Include="..\Private\Level_PhysXLab.cpp">
<Filter>01.Level\60.PhysXLab</Filter>
>>>>>>> Stashed changes
</ClCompile>
</ItemGroup>
<ItemGroup>
@@ -0,0 +1,2 @@
#include "pch.h"
#include "Level_PhysXLab.h"
@@ -0,0 +1,5 @@
#pragma once
class CLevel_PhysXLab
{
};
+10 -2
View File
@@ -124,7 +124,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalLibraryDirectories>../ThirdPartyLib/fMod/;../ThirdPartyLib/DirectXTK/;../ThirdPartyLib/FX11/;../ThirdPartyLib/Assimp/;../ThirdPartyLib/PhysX/$(Configuration)/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>d3d11.lib;fmod_vc.lib;dinput8.lib;LowLevel_static_64.lib;LowLevelAABB_static_64.lib;LowLevelDynamics_static_64.lib;PhysX_64.lib;PhysXCommon_64.lib;PhysXCooking_64.lib;PhysXExtensions_static_64.lib;PhysXFoundation_64.lib;PhysXPvdSDK_static_64.lib;PhysXTask_static_64.lib;SceneQuery_static_64.lib;SimulationController_static_64.lib;DirectXTKd.lib;Effects11d.lib;assimp-vc145-mtd.lib;%(AdditionalDependencies);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>d3d11.lib;fmod_vc.lib;dinput8.lib;LowLevel_static_64.lib;LowLevelAABB_static_64.lib;LowLevelDynamics_static_64.lib;PhysX_64.lib;PhysXCommon_64.lib;PhysXCooking_64.lib;PhysXExtensions_static_64.lib;PhysXFoundation_64.lib;PhysXPvdSDK_static_64.lib;PhysXTask_static_64.lib;SceneQuery_static_64.lib;SimulationController_static_64.lib;PhysXCharacterKinematic_static_64.lib;DirectXTKd.lib;Effects11d.lib;assimp-vc145-mtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -147,7 +147,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalLibraryDirectories>../ThirdPartyLib/fMod/;../ThirdPartyLib/DirectXTK/;../ThirdPartyLib/FX11/;../ThirdPartyLib/Assimp/;../ThirdPartyLib/PhysX/$(Configuration)/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>d3d11.lib;fmod_vc.lib;dinput8.lib;LowLevel_static_64.lib;LowLevelAABB_static_64.lib;LowLevelDynamics_static_64.lib;PhysX_64.lib;PhysXCommon_64.lib;PhysXCooking_64.lib;PhysXExtensions_static_64.lib;PhysXFoundation_64.lib;PhysXPvdSDK_static_64.lib;PhysXTask_static_64.lib;SceneQuery_static_64.lib;SimulationController_static_64.lib;DirectXTK.lib;Effects11.lib;assimp-vc145-mt.lib;%(AdditionalDependencies);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>d3d11.lib;fmod_vc.lib;dinput8.lib;LowLevel_static_64.lib;LowLevelAABB_static_64.lib;LowLevelDynamics_static_64.lib;PhysX_64.lib;PhysXCommon_64.lib;PhysXCooking_64.lib;PhysXExtensions_static_64.lib;PhysXFoundation_64.lib;PhysXPvdSDK_static_64.lib;PhysXTask_static_64.lib;SceneQuery_static_64.lib;SimulationController_static_64.lib;PhysXCharacterKinematic_static_64.lib;DirectXTK.lib;Effects11.lib;assimp-vc145-mt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@@ -172,6 +172,10 @@
</ClCompile>
<ClCompile Include="..\Private\Cell.cpp" />
<ClCompile Include="..\Private\Channel.cpp" />
<ClCompile Include="..\Private\Character_Controller.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\Private\Collider.cpp" />
<ClCompile Include="..\Private\Collider_Manager.cpp" />
<ClCompile Include="..\Private\Component.cpp" />
@@ -380,6 +384,10 @@
</ClInclude>
<ClInclude Include="..\Public\Cell.h" />
<ClInclude Include="..\Public\Channel.h" />
<ClInclude Include="..\Public\Character_Controller.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\Public\Collider.h" />
<ClInclude Include="..\Public\Collider_Manager.h" />
<ClInclude Include="..\Public\Component.h" />
@@ -238,6 +238,9 @@
<Filter Include="02.Element\02.Component\07.RigidBody">
<UniqueIdentifier>{5c89d610-7e57-40a5-bc65-04e5fa25df89}</UniqueIdentifier>
</Filter>
<Filter Include="03.Management\21.PhysX_Manager\CCT">
<UniqueIdentifier>{b20c0397-6254-4350-bc83-ee695f9fd012}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Private\Base.cpp">
@@ -438,12 +441,12 @@
<ClCompile Include="..\Private\ComputeShader.cpp">
<Filter>01.Utility\06.ComputeShader</Filter>
</ClCompile>
<<<<<<< Updated upstream
<ClCompile Include="..\Private\VIBuffer_Terrain.cpp">
<Filter>02.Element\02.Component\02.VIBuffer\Terrain</Filter>
</ClCompile>
=======
>>>>>>> Stashed changes
<ClCompile Include="..\Private\Character_Controller.cpp">
<Filter>03.Management\21.PhysX_Manager\CCT</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Public\Base.h">
@@ -1004,16 +1007,17 @@
<ClInclude Include="..\public\Picking.h">
<Filter>01.Utility\06. Picking</Filter>
</ClInclude>
<<<<<<< Updated upstream
<ClInclude Include="..\Public\VIBuffer_Terrain.h">
<Filter>02.Element\02.Component\02.VIBuffer\Terrain</Filter>
=======
</ClInclude>
<ClInclude Include="..\Public\PhysX_Manager.h">
<Filter>03.Management\21.PhysX_Manager</Filter>
</ClInclude>
<ClInclude Include="..\Public\RigidBody.h">
<Filter>02.Element\02.Component\07.RigidBody</Filter>
>>>>>>> Stashed changes
</ClInclude>
<ClInclude Include="..\Public\Character_Controller.h">
<Filter>03.Management\21.PhysX_Manager\CCT</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
@@ -0,0 +1,38 @@
#include "pch.h"
#include "Character_Controller.h"
#include "GameInstance.h"
CCharacter_Controller::CCharacter_Controller(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) :
m_pDevice(pDevice),
m_pContext(pContext),
m_pGameInstance(CGameInstance::GetInstance())
{
SAFE_ADDREF(m_pDevice);
SAFE_ADDREF(m_pContext);
SAFE_ADDREF(m_pGameInstance);
}
CCharacter_Controller* CCharacter_Controller::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, PSX::PxScene* pScene)
{
CCharacter_Controller* pInstance = new CCharacter_Controller(pDevice, pContext);
if (FAILED(pInstance->Initialize(pScene))) {
SAFE_RELEASE(pInstance);
assert(false);
}
return pInstance;
}
HRESULT CCharacter_Controller::Initialize(PSX::PxScene* pScene)
{
m_pScene = pScene;
return S_OK;
}
void CCharacter_Controller::Free()
{
__super::Free();
SAFE_RELEASE(m_pDevice);
SAFE_RELEASE(m_pContext);
SAFE_RELEASE(m_pGameInstance);
}
@@ -519,14 +519,12 @@ _bool CGameInstance::SaveAssimpModel(const _char* filename)
auto iter = m_ModelMap.find(filename);
return iter->second->SaveAssimpModel(filename);
}
<<<<<<< Updated upstream
#endif
SaveModel* CGameInstance::Load_SaveModel(const _char* filePath)
{
auto iter = m_sModelMap.find(filePath);
return &iter->second;
}
=======
#pragma region PhysX_Manager
PSX::PxMaterial* CGameInstance::Get_Material(_float3& vMatInfo)
@@ -551,7 +549,6 @@ const PSX::PxRigidStatic* CGameInstance::Add_StaticActor(CRigidBody& RigidBody)
}
#pragma endregion
>>>>>>> Stashed changes
bool CGameInstance::Key_Pressing(int _iKey)
{
if (false == (GUI::IsWindowFocused(ImGuiFocusedFlags_AnyWindow))) {
@@ -121,7 +121,7 @@ PSX::PxShape* CPhysX_Manager::Create_Shape(ACTOR eType, _float3& vhalfGeometryIn
HRESULT CPhysX_Manager::Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh* pMesh)
{
PSX::PxTriangleMesh* pTriangleMesh = pMesh->ConvertToPxMesh(m_pParam);
PSX::PxTriangleMesh* pTriangleMesh = pMesh->ConvertToPxMesh(m_pCookingParam);
if (nullptr != pTriangleMesh) {
m_TriangleMeshes.emplace(wstrMeshKey, pTriangleMesh);
@@ -207,6 +207,49 @@ void CPhysX_Manager::ClearScene()
} m_RigidBodys.clear();
}
PSX::PxController* CPhysX_Manager::Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc)
{
PSX::PxController* pController = { nullptr };
pController = m_pCCTManager->createController(Desc);
return pController;
}
PSX::PxController* CPhysX_Manager::Add_BoxController(PSX::PxBoxControllerDesc& Desc)
{
PSX::PxController* pController = { nullptr };
pController = m_pCCTManager->createController(Desc);
return pController;
}
PSX::PxController* CPhysX_Manager::Get_Controller(_uint iControllerIndex)
{
return nullptr;
}
void CPhysX_Manager::ReleaseController(_uint iControllerIndex)
{
if (iControllerIndex >= Get_NumCurrentController()) {
assert(false);
return;
}
m_pCCTManager->getController((PSX::PxU32)iControllerIndex)->release();
}
_uint CPhysX_Manager::Get_NumCurrentController()
{
return (_uint)m_pCCTManager->getNbControllers();
}
HRESULT CPhysX_Manager::PurgeAllController()
{
m_pCCTManager->purgeControllers();
return S_OK;
}
HRESULT CPhysX_Manager::Initialize()
{
@@ -227,7 +270,7 @@ HRESULT CPhysX_Manager::Initialize()
m_pPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *m_pFoundation, m_ToleranceScale, true, m_pPvd);
m_pParam = new PSX::PxCookingParams(m_pPhysics->getTolerancesScale());
m_pCookingParam = new PSX::PxCookingParams(m_pPhysics->getTolerancesScale());
PSX::PxSceneDesc sceneDesc = { m_pPhysics->getTolerancesScale() };
sceneDesc.gravity = PSX::PxVec3(0.f, GRAVITY, 0.f);
@@ -242,6 +285,8 @@ HRESULT CPhysX_Manager::Initialize()
return E_FAIL;
}
m_pScene = m_pPhysics->createScene(sceneDesc);
m_pCCTManager = PxCreateControllerManager(*m_pScene);
}
// µð¹ö±×¼­¹öÀÇ Å¬¶ó ¼¼ÆÃ
@@ -299,8 +344,8 @@ void CPhysX_Manager::Free()
Safe_Delete(pGeometry.second);
} m_TriangleMeshGeometry.clear();
if (nullptr != m_pParam) {
Safe_Delete(m_pParam);
if (nullptr != m_pCookingParam) {
Safe_Delete(m_pCookingParam);
}
if (nullptr != m_pScene) {
@@ -0,0 +1,27 @@
#pragma once
#include "Base.h"
NS_BEGIN(Engine)
class CCharacter_Controller final : public CBase
{
private:
CCharacter_Controller(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual ~CCharacter_Controller() = default;
private:
class CGameInstance* m_pGameInstance = { nullptr };
ID3D11Device* m_pDevice = { nullptr };
ID3D11DeviceContext* m_pContext = { nullptr };
PSX::PxScene* m_pScene = { nullptr };
private:
HRESULT Initialize(PSX::PxScene* pScene);
public:
static CCharacter_Controller* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, PSX::PxScene* pScene);
virtual void Free() override;
};
NS_END
+26 -10
View File
@@ -13,24 +13,40 @@ class CPhysX_Manager final : public CBase
CPhysX_Manager(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual ~CPhysX_Manager() = default;
#pragma region RIGID_BODY
public:
const PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody);
const PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody);
/* dev-treadmill.tistory.com/155 */
// HRESULT Update_RegionOfInterest(); ( 충돌 컬링, 필터링도 검색해야함 )
// Aggregate ( 충돌 그룹, 이 그룹끼리는 서로 충돌검사를 하지 않음, 지형, 레그돌 등 )
const PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody);
const PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody);
PSX::PxMaterial* Get_Material(_float3& vMatInfo);
PSX::PxShape* Create_Shape(ACTOR eType, _float3& vhalfGeometryInfo, PSX::PxMaterial& pxMaterial, _bool bExclusive, PSX::PxShapeFlags ePxShapeFlag);
HRESULT Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh* pMesh);
PSX::PxTriangleMesh* Find_TriangleMesh(const _wstring& wstrFilePath);
/* dev-treadmill.tistory.com/155 */
// HRESULT Update_RegionOfInterest(); ( 충돌 컬링, 필터링도 검색해야함 )
// Aggregate ( 충돌 그룹, 이 그룹끼리는 서로 충돌검사를 하지 않음, 지형, 레그돌 등 )
void Update(_float fTimeDelta);
void ClearScene();
#pragma endregion
#pragma region CHARACTER_CONTROLLER
/* https://dev-treadmill.tistory.com/158 */
public:
PSX::PxController* Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc);
PSX::PxController* Add_BoxController(PSX::PxBoxControllerDesc& Desc);
PSX::PxController* Get_Controller(_uint iControllerIndex);
void ReleaseController(_uint iControllerIndex);
_uint Get_NumCurrentController();
HRESULT PurgeAllController();
#pragma endregion
private:
@@ -46,15 +62,15 @@ class CPhysX_Manager final : public CBase
PSX::PxPhysics* m_pPhysics = { nullptr }; // 피직스 객체의 생성, 초기화, 조작 담당 (싱글톤)
PSX::PxScene* m_pScene = { nullptr }; // 피직스 시뮬레이션의 공간
PSX::PxControllerManager* m_pCCTManager = { nullptr }; // 피직스 캐릭터 컨트롤러를 전부 추적하고 매니징함
PSX::PxPvd* m_pPvd = { nullptr }; // 피직스 시뮬레이션 디버깅을 위한 도구
PSX::PxCookingParams* m_pParam = { nullptr };
PSX::PxCookingParams* m_pCookingParam = { nullptr };
list<pair<CRigidBody*, PSX::PxActor*>> m_RigidBodys = { };
map<_wstring, PSX::PxTriangleMesh*> m_TriangleMeshes = {};
map<_wstring, PSX::PxTriangleMeshGeometry*> m_TriangleMeshGeometry = {};
_uint m_iNumLevel = {};
private:
HRESULT Initialize();
HRESULT Connect_DebugServer();
+9
View File
@@ -67,6 +67,15 @@ using namespace std;
using namespace FMOD;
// PhysX
#pragma warning(push)
#pragma warning(disable: 26495)
#pragma warning(disable: 33010)
#include "PhysX/PxPhysics.h"
#include "PhysX/PxPhysicsAPI.h"
#pragma warning(pop)
#ifdef _DEBUG