[fix] LightManager 누수 잡음

[add] 피직스 레벨 만듬
[add] 피직스 충돌 확인
This commit is contained in:
kimnuri
2025-11-10 16:03:53 +09:00
parent dd78b340b4
commit 6059aa990b
21 changed files with 761 additions and 67 deletions
@@ -153,6 +153,11 @@
<ClInclude Include="..\public\Active_Icon.h" />
<ClInclude Include="..\public\GamePlay_Canvas.h" />
<ClInclude Include="..\Public\DebugCamera.h" />
<ClInclude Include="..\Public\Dummy_PhysXBox.h" />
<ClInclude Include="..\Public\Dummy_PhysXMesh.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\Public\Effect_Editor.h" />
<ClInclude Include="..\Public\EditEffect.h" />
<ClInclude Include="..\public\Level_MapViewer.h" />
@@ -206,6 +211,11 @@
<ClCompile Include="..\private\Active_Icon.cpp" />
<ClCompile Include="..\private\GamePlay_Canvas.cpp" />
<ClCompile Include="..\Private\DebugCamera.cpp" />
<ClCompile Include="..\Private\Dummy_PhysXBox.cpp" />
<ClCompile Include="..\Private\Dummy_PhysXMesh.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\Private\Effect_Editor.cpp" />
<ClCompile Include="..\Private\EditEffect.cpp" />
<ClCompile Include="..\private\Level_MapViewer.cpp" />
@@ -160,8 +160,16 @@
<Filter Include="02.GameObjects\Monster">
<UniqueIdentifier>{a2944f33-1db0-480a-b793-7ec7f81e8116}</UniqueIdentifier>
</Filter>
<<<<<<< Updated upstream
<Filter Include="50.UI\GamePlay_Canvas\Loding_Panel\LoadingWidget_Flame">
<UniqueIdentifier>{c347da03-98f1-4095-a4e4-2c840c308916}</UniqueIdentifier>
=======
<Filter Include="02.GameObjects\Dummys\PhysXBox">
<UniqueIdentifier>{c7e7d3c7-fd26-4035-88b4-11233459559c}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Dummys\PhysXMesh">
<UniqueIdentifier>{15a9dfe7-f3f7-4906-8bd4-91734f4ddc92}</UniqueIdentifier>
>>>>>>> Stashed changes
</Filter>
</ItemGroup>
<ItemGroup>
@@ -315,6 +323,12 @@
<ClInclude Include="..\Public\Level_PhysXLab.h">
<Filter>01.Level\60.PhysXLab</Filter>
</ClInclude>
<ClInclude Include="..\Public\Dummy_PhysXBox.h">
<Filter>02.GameObjects\Dummys\PhysXBox</Filter>
</ClInclude>
<ClInclude Include="..\Public\Dummy_PhysXMesh.h">
<Filter>02.GameObjects\Dummys\PhysXMesh</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="Editor.ico">
@@ -460,6 +474,12 @@
<ClCompile Include="..\Private\Monster.cpp">
<Filter>02.GameObjects\Monster</Filter>
</ClCompile>
<ClCompile Include="..\Private\Dummy_PhysXBox.cpp">
<Filter>02.GameObjects\Dummys\PhysXBox</Filter>
</ClCompile>
<ClCompile Include="..\Private\Dummy_PhysXMesh.cpp">
<Filter>02.GameObjects\Dummys\PhysXMesh</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Editor.rc">
@@ -0,0 +1,167 @@
#include "pch.h"
#include "Dummy_PhysXBox.h"
#include "GameInstance.h"
CDummy_PhysXBox::CDummy_PhysXBox(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: CGameObject{ pDevice, pContext }
{
}
CDummy_PhysXBox::CDummy_PhysXBox(const CDummy_PhysXBox& rhs)
: CGameObject(rhs)
{
}
HRESULT CDummy_PhysXBox::Initialize_Prototype()
{
return S_OK;
}
HRESULT CDummy_PhysXBox::Initialize(void* pArg)
{
if (FAILED(__super::Initialize(pArg))) {
return E_FAIL;
}
if (FAILED(Ready_Components(pArg))) {
return E_FAIL;
}
return S_OK;
}
void CDummy_PhysXBox::Priority_Update(_float fTimeDelta)
{
}
void CDummy_PhysXBox::Update(_float fTimeDelta)
{
}
void CDummy_PhysXBox::Late_Update(_float fTimeDelta)
{
//_float4* vPos = (_float4*)(m_pTransformCom->Get_WorldMatrixPtr()->m[3]);
//m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this, *vPos, m_pTransformCom->Get_Radius());
}
HRESULT CDummy_PhysXBox::Render()
{
//if (FAILED(Bind_ShaderResources())) {
// return E_FAIL;
//}
//_uint iNumMeshes = m_pModelCom->Get_NumMeshes();
//for (_uint i = 0; i < iNumMeshes; i++)
//{
// if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) {
// return E_FAIL;
// }
// if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_NormalTexture", aiTextureType_NORMALS, 0))) {
// return E_FAIL;
// }
// if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::SKYBOX)))) {
// return E_FAIL;
// }
// if (FAILED(m_pModelCom->Render(i))) {
// return E_FAIL;
// }
//}
return S_OK;
}
HRESULT CDummy_PhysXBox::Ready_Components(void* pArg)
{
if (FAILED(__super::Ready_Components(pArg))) {
return E_FAIL;
}
BOXSTARTPOS_DESC* pBox = static_cast<BOXSTARTPOS_DESC*>(pArg);
m_pTransformCom->Set_State(STATE::POSITION, XMVectorSetW(XMLoadFloat3(&pBox->vPos), 1.f));
m_pTransformCom->Rotation(pBox->vRotRPY.x, pBox->vRotRPY.y, pBox->vRotRPY.z);
{ // RIGID_BODY
CRigidBody::RIGIDBODY_DESC Desc{};
Desc.tRigidDynamicDesc.bIsKinematic = false;
Desc.tRigidDynamicDesc.fDensity = 1000.f;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), (CComponent**)&m_pRigidBody, &Desc))) {
return E_FAIL;
}
m_pActor = m_pGameInstance->Add_DynamicActor(*m_pRigidBody);
if (nullptr == m_pActor) {
assert(false);
return E_FAIL;
}
}
return S_OK;
}
HRESULT CDummy_PhysXBox::Bind_ShaderResources()
{
//if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) {
// return E_FAIL;
//}
//if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) {
// return E_FAIL;
//}
//if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) {
// return E_FAIL;
//}
//if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) {
// return E_FAIL;
//}
return S_OK;
}
CDummy_PhysXBox* CDummy_PhysXBox::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
CDummy_PhysXBox* pInstance = new CDummy_PhysXBox(pDevice, pContext);
if (FAILED(pInstance->Initialize_Prototype()))
{
MSG_BOX("Failed to Created : CDummy_PhysXBox");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
CGameObject* CDummy_PhysXBox::Clone(void* pArg, CGameObject* pOwner)
{
CDummy_PhysXBox* pInstance = new CDummy_PhysXBox(*this);
pInstance->m_pOwner = pOwner;
if (FAILED(pInstance->Initialize(pArg)))
{
MSG_BOX("Failed to Cloned : CDummy_PhysXBox");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
void CDummy_PhysXBox::Free()
{
__super::Free();
SAFE_RELEASE(m_pRigidBody);
//SAFE_RELEASE(m_pModelCom);
//SAFE_RELEASE(m_pShaderCom);
}
void CDummy_PhysXBox::Describe_Entity()
{
}
@@ -0,0 +1,166 @@
#include "pch.h"
#include "Dummy_PhysXMesh.h"
#include "GameInstance.h"
CDummy_PhysXMesh::CDummy_PhysXMesh(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: CGameObject{ pDevice, pContext }
{
}
CDummy_PhysXMesh::CDummy_PhysXMesh(const CDummy_PhysXMesh& rhs)
: CGameObject(rhs)
{
}
HRESULT CDummy_PhysXMesh::Initialize_Prototype()
{
return S_OK;
}
HRESULT CDummy_PhysXMesh::Initialize(void* pArg)
{
if (FAILED(__super::Initialize(pArg))) {
return E_FAIL;
}
if (FAILED(Ready_Components(pArg))) {
return E_FAIL;
}
return S_OK;
}
void CDummy_PhysXMesh::Priority_Update(_float fTimeDelta)
{
}
void CDummy_PhysXMesh::Update(_float fTimeDelta)
{
}
void CDummy_PhysXMesh::Late_Update(_float fTimeDelta)
{
//_float4* vPos = (_float4*)(m_pTransformCom->Get_WorldMatrixPtr()->m[3]);
//m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this, *vPos, m_pTransformCom->Get_Radius());
}
HRESULT CDummy_PhysXMesh::Render()
{
//if (FAILED(Bind_ShaderResources())) {
// return E_FAIL;
//}
//_uint iNumMeshes = m_pModelCom->Get_NumMeshes();
//for (_uint i = 0; i < iNumMeshes; i++)
//{
// if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) {
// return E_FAIL;
// }
// if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_NormalTexture", aiTextureType_NORMALS, 0))) {
// return E_FAIL;
// }
// if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::SKYBOX)))) {
// return E_FAIL;
// }
// if (FAILED(m_pModelCom->Render(i))) {
// return E_FAIL;
// }
//}
return S_OK;
}
HRESULT CDummy_PhysXMesh::Ready_Components(void* pArg)
{
if (FAILED(__super::Ready_Components(pArg))) {
return E_FAIL;
}
BOXSTARTPOS_DESC* pBox = static_cast<BOXSTARTPOS_DESC*>(pArg);
m_pTransformCom->Set_State(STATE::POSITION, XMVectorSetW(XMLoadFloat3(&pBox->vPos), 1.f));
m_pTransformCom->Rotation(pBox->vRotRPY.x, pBox->vRotRPY.y, pBox->vRotRPY.z);
{ // RIGID_BODY
CRigidBody::RIGIDBODY_DESC Desc{};
Desc.tRigidDynamicDesc.bIsKinematic = false;
Desc.tRigidDynamicDesc.fDensity = 1000.f;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), (CComponent**)&m_pRigidBody, &Desc))) {
return E_FAIL;
}
m_pActor = m_pGameInstance->Add_DynamicActor(*m_pRigidBody);
if (nullptr == m_pActor) {
assert(false);
return E_FAIL;
}
}
return S_OK;
}
HRESULT CDummy_PhysXMesh::Bind_ShaderResources()
{
//if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) {
// return E_FAIL;
//}
//if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) {
// return E_FAIL;
//}
//if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) {
// return E_FAIL;
//}
//if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) {
// return E_FAIL;
//}
return S_OK;
}
CDummy_PhysXMesh* CDummy_PhysXMesh::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
CDummy_PhysXMesh* pInstance = new CDummy_PhysXMesh(pDevice, pContext);
if (FAILED(pInstance->Initialize_Prototype()))
{
MSG_BOX("Failed to Created : CDummy_PhysXMesh");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
CGameObject* CDummy_PhysXMesh::Clone(void* pArg, CGameObject* pOwner)
{
CDummy_PhysXMesh* pInstance = new CDummy_PhysXMesh(*this);
pInstance->m_pOwner = pOwner;
if (FAILED(pInstance->Initialize(pArg)))
{
MSG_BOX("Failed to Cloned : CDummy_PhysXMesh");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
void CDummy_PhysXMesh::Free()
{
__super::Free();
SAFE_RELEASE(m_pRigidBody);
//SAFE_RELEASE(m_pModelCom);
//SAFE_RELEASE(m_pShaderCom);
}
void CDummy_PhysXMesh::Describe_Entity()
{
}
@@ -8,6 +8,8 @@
#include "Level_ObjectViewer.h"
#include "Level_EffectViewer.h"
#include "Level_MapViewer.h"
#include "Level_PhysXLab.h"
CLevel_Loading::CLevel_Loading(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID)
: CLevel{ pDevice, pContext, ENUM_CLASS(eLevelID) }
@@ -57,9 +59,9 @@ void CLevel_Loading::Update(_float fTimeDelta)
case LEVEL::EFFECT:
pNewLevel = CLevel_EffectViewer::Create(m_pDevice, m_pContext, m_eNextLevelID);
break;
//case LEVEL::SKIllSTUDIO:
// pNewLevel = CLevel_SkillStudio::Create(m_pDevice, m_pContext, m_eNextLevelID);
// break;
case LEVEL::PHYSX:
pNewLevel = CLevel_PhysXLab::Create(m_pDevice, m_pContext, m_eNextLevelID);
break;
//case LEVEL::PARTICLE:
// pNewLevel = CLevel_ParticleViewer::Create(m_pDevice, m_pContext, m_eNextLevelID);
// break;
@@ -38,10 +38,10 @@ void CLevel_Logo::Update(_float fTimeDelta)
if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::EFFECT))))
return;
}
//else if (GUI::Button("Skill Editor", { 100, 100 })) {
// if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::SKIllSTUDIO))))
// return;
//}
else if (GUI::Button("PhysX Simulator", { 100, 100 })) {
if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::PHYSX))))
return;
}
//else if (GUI::Button("Particle Editor", { 100, 100 })) {
// if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::PARTICLE))))
// return;
@@ -1,2 +1,122 @@
#include "pch.h"
#include "Level_PhysXLab.h"
#include "Level_PhysXLab.h"
#include "GameInstance.h"
#include "Level_Loading.h"
#include "DebugCamera.h"
#include "Terrain.h"
#include "Dummy_PhysXBox.h"
CLevel_PhysXLab::CLevel_PhysXLab(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID)
: CLevel{ pDevice, pContext, ENUM_CLASS(eLevelID) }
{
}
void CLevel_PhysXLab::Update(_float fTimeDelta)
{
}
HRESULT CLevel_PhysXLab::Render()
{
SetWindowText(g_hWnd, TEXT("PhysXEditor·¹º§ÀÔ´Ï´Ù"));
GUI::ShowDemoWindow();
return S_OK;
}
HRESULT CLevel_PhysXLab::Initialize()
{
if (FAILED(Ready_Layer_Light()))
return E_FAIL;
if (FAILED(Ready_Layer_Camera(LAYER_CAMERA))) {
return E_FAIL;
}
if (FAILED(Ready_Layer_Terrain(TEXT("Layer_Terrain")))) {
return E_FAIL;
}
if (FAILED(Ready_Layer_PhysXObjects(TEXT("Layer_PhysXObject")))) {
return E_FAIL;
}
return S_OK;
}
HRESULT CLevel_PhysXLab::Ready_Layer_Light()
{
LIGHT_DESC LightDesc{};
LightDesc.eType = LIGHT::DIRECTIONAL;
LightDesc.vDiffuse = _float4(0.8f, 0.8f, 0.8f, 0.f);
LightDesc.vAmbient = _float4(0.8f, 0.8f, 0.8f, 0.f);
LightDesc.vSpecular = _float4(0.f, 0.f, 0.f, 0.f);
LightDesc.vDirection = _float4(1.f, -1.f, 1.f, 0.f);
if (FAILED(m_pGameInstance->On_Light(NEXT_LEVEL, TEXT("Main_Light"), LightDesc, nullptr))) {
return E_FAIL;
}
return S_OK;
}
HRESULT CLevel_PhysXLab::Ready_Layer_Camera(const _wstring& strLayerTag)
{
CDebugCamera::CAMERA_DEBUG_DESC CameraDesc{};
CameraDesc.fFovy = XMConvertToRadians(60.0f);
CameraDesc.fNear = 0.1f;
CameraDesc.fFar = 500.f;
CameraDesc.vEye = _float3(0.f, 10.f, -10.f);
CameraDesc.vAt = _float3(0.f, 0.f, 0.f);
CameraDesc.fSpeedPerSec = 2.f;
CameraDesc.fRotationPerSec = XMConvertToRadians(90.0f);
CameraDesc.fMouseSensor = 0.1f;
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CDebugCamera>(g_iStaticLevel, NEXT_LEVEL,
strLayerTag, &CameraDesc)))
return E_FAIL;
return S_OK;
}
HRESULT CLevel_PhysXLab::Ready_Layer_Terrain(const _wstring& strLayerTag)
{
return S_OK;
}
HRESULT CLevel_PhysXLab::Ready_Layer_PhysXObjects(const _wstring& strLayerTag)
{
for (int i = 0; i < 50; ++i) {
CDummy_PhysXBox::BOXSTARTPOS_DESC Desc{};
Desc.vPos = { m_pGameInstance->Random_Float(0.f, 30.f), m_pGameInstance->Random_Float(3.f, 33.f), m_pGameInstance->Random_Float(0.f, 30.f) };
Desc.vRotRPY = { m_pGameInstance->Random_Float(0.f, XM_2PI), m_pGameInstance->Random_Float(0.f, XM_2PI), m_pGameInstance->Random_Float(0.f, XM_2PI) };
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CDummy_PhysXBox>(g_iStaticLevel, NEXT_LEVEL, LAYER_CUBE, &Desc))) {
return E_FAIL;
}
}
return S_OK;
}
CLevel_PhysXLab* CLevel_PhysXLab::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID)
{
CLevel_PhysXLab* pInstance = new CLevel_PhysXLab(pDevice, pContext, eLevelID);
if (FAILED(pInstance->Initialize()))
{
MSG_BOX("Failed to Created : CLevel_PhysXLab");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
void CLevel_PhysXLab::Free()
{
__super::Free();
}
+49 -8
View File
@@ -13,10 +13,7 @@
#include "Body.h"
#include "Hair.h"
#include "Dummy_Goblin.h"
#include "Dummy_Goblin.h"
#include "Monster.h"
#include <filesystem>
#pragma endregion
#pragma region UI
@@ -30,8 +27,6 @@
#include "Mission_Key.h"
#include "Mission_KeyHold.h"
#include "Mouse_Cursor.h"
#include "Dummy_Cube.h"
#include "LodingWidget1.h"
#include "MiniMap_TrimBorder.h"
#include "Active_Icon.h"
@@ -63,6 +58,12 @@
#pragma endregion
#pragma region PHYSX_HEADER
#include "Dummy_PhysXBox.h"
#pragma endregion
CLoader::CLoader(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: m_pDevice{ pDevice }
, m_pContext{ pContext }
@@ -129,9 +130,9 @@ HRESULT CLoader::Loading()
case LEVEL::EFFECT:
hr = Loading_For_Effect();
break;
//case LEVEL::SKIllSTUDIO:
// hr = Loading_For_SkillStudio();
// break;
case LEVEL::PHYSX:
hr = Loading_For_PhysXLevel();
break;
//case LEVEL::PARTICLE:
// hr = Loading_For_Particle();
// break;
@@ -488,6 +489,46 @@ HRESULT CLoader::Loading_For_Effect()
return S_OK;
}
HRESULT CLoader::Loading_For_PhysXLevel()
{
m_strMessage = TEXT("PhysX Bodies Loading..");
{
CRigidBody::RIGIDBODY_PROTOTYPEDESC Desc{};
Desc.tRigidDynamicDesc.bExclusive = false;
Desc.tRigidDynamicDesc.vhalfGeometryInfo = { 0.5f, 0.5f, 0.5f };
Desc.tRigidDynamicDesc.vMatInfo = { 0.5f, 0.5f, 0.6f };
Desc.tRigidDynamicDesc.ePxShapeFlag = { PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE };
m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), CRigidBody::Create(m_pDevice, m_pContext, Desc));
}
//{
// CRigidBody::RIGIDBODY_PROTOTYPEDESC Desc{};
// Desc.tRigidStaticDesc.pMesh;
// Desc.tRigidStaticDesc.vMatInfo = { 0.5f, 0.5f, 0.6f };
// Desc.tRigidStaticDesc.pMeshKey = TEXT("PHYSX_STATIC_MESH");
//}
m_strMessage = TEXT("Texture Loading..");
m_strMessage = TEXT("Model Loading..");
m_strMessage = TEXT("Shader Loading..");
m_strMessage = TEXT("Prototype Loading..");
if (FAILED(m_pGameInstance->Add_Prototype<CDummy_PhysXBox>(g_iStaticLevel, CDummy_PhysXBox::Create(m_pDevice, m_pContext)))){
return E_FAIL;
}
m_strMessage = TEXT("Loading Success!");
m_isFinished = true;
return S_OK;
}
HRESULT CLoader::Asset_FileLoad(const _char* pDirectoryPath, const _tchar* pPreName, function<HRESULT(_wstring, const _char*)> AddPrototypeEvent)
{
for (const auto& file : filesystem::directory_iterator(pDirectoryPath))
@@ -0,0 +1,53 @@
#pragma once
#include "Editor_Define.h"
#include "GameObject.h"
NS_BEGIN(Engine)
class CModel;
class CShader;
class CRigidBody;
NS_END
NS_BEGIN(Editor)
class CDummy_PhysXBox final : public CGameObject
{
public:
typedef struct tagBoxStartPos
{
_float3 vPos = {};
_float3 vRotRPY = {};
}BOXSTARTPOS_DESC;
private:
CDummy_PhysXBox(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
CDummy_PhysXBox(const CDummy_PhysXBox& rhs);
virtual ~CDummy_PhysXBox() = default;
public:
virtual void Priority_Update(_float fTimeDelta) override;
virtual void Update(_float fTimeDelta) override;
virtual void Late_Update(_float fTimeDelta) override;
virtual HRESULT Render() override;
private:
CRigidBody* m_pRigidBody = { nullptr };
const PSX::PxRigidDynamic* m_pActor = { nullptr };
//CModel* m_pModelCom = { nullptr };
//CShader* m_pShaderCom = { nullptr };
private:
virtual HRESULT Initialize_Prototype() override;
virtual HRESULT Initialize(void* pArg) override;
virtual HRESULT Ready_Components(void* pArg) override;
virtual HRESULT Bind_ShaderResources() override;
public:
static CDummy_PhysXBox* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override;
virtual void Free() override;
void Describe_Entity() override;
};
NS_END
@@ -0,0 +1,53 @@
#pragma once
#include "Editor_Define.h"
#include "GameObject.h"
NS_BEGIN(Engine)
class CModel;
class CShader;
class CRigidBody;
NS_END
NS_BEGIN(Editor)
class CDummy_PhysXMesh final : public CGameObject
{
public:
typedef struct tagBoxStartPos
{
_float3 vPos = {};
_float3 vRotRPY = {};
}BOXSTARTPOS_DESC;
private:
CDummy_PhysXMesh(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
CDummy_PhysXMesh(const CDummy_PhysXMesh& rhs);
virtual ~CDummy_PhysXMesh() = default;
public:
virtual void Priority_Update(_float fTimeDelta) override;
virtual void Update(_float fTimeDelta) override;
virtual void Late_Update(_float fTimeDelta) override;
virtual HRESULT Render() override;
private:
CRigidBody* m_pRigidBody = { nullptr };
const PSX::PxRigidDynamic* m_pActor = { nullptr };
//CModel* m_pModelCom = { nullptr };
//CShader* m_pShaderCom = { nullptr };
private:
virtual HRESULT Initialize_Prototype() override;
virtual HRESULT Initialize(void* pArg) override;
virtual HRESULT Ready_Components(void* pArg) override;
virtual HRESULT Bind_ShaderResources() override;
public:
static CDummy_PhysXMesh* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override;
virtual void Free() override;
void Describe_Entity() override;
};
NS_END
@@ -11,7 +11,7 @@ namespace Editor
const unsigned int g_iWinSizeX = 1920;
const unsigned int g_iWinSizeY = 1080;
enum class LEVEL { STATIC, LOADING, LOGO, LOBY, GAMEPLAY, RESTART, OBJECT, MAP,UI, EFFECT, END };
enum class LEVEL { STATIC, LOADING, LOGO, LOBY, GAMEPLAY, RESTART, OBJECT, MAP,UI, EFFECT, PHYSX, END };
enum class COLLIDABLEOBJECT { PLAYER, MONSTER, HOSTILE_HITBOX, ALLY_HITBOX, NEUTRAL_HITBOX, ENVIRIONMENT, NPC, ITEM, TRIGGERBOX, REGION, NOCOLLIDE, END };
enum class SHADER_PASS_ANIM { DEFAULT, SHADOW, CAPTURE, BLUR, END };
+28 -1
View File
@@ -1,5 +1,32 @@
#pragma once
class CLevel_PhysXLab
#include "Editor_Define.h"
#include "Level.h"
NS_BEGIN(Editor)
class CLevel_PhysXLab final : public CLevel
{
private:
CLevel_PhysXLab(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID);
virtual ~CLevel_PhysXLab() = default;
public:
virtual void Update(_float fTimeDelta) override;
virtual HRESULT Render() override;
private:
virtual HRESULT Initialize() override;
HRESULT Ready_Layer_Light();
HRESULT Ready_Layer_Camera(const _wstring& strLayerTag);
HRESULT Ready_Layer_Terrain(const _wstring& strLayerTag);
HRESULT Ready_Layer_PhysXObjects(const _wstring& strLayerTag);
public:
static CLevel_PhysXLab* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID);
virtual void Free() override;
};
NS_END
+1
View File
@@ -47,6 +47,7 @@ class CLoader final : public CBase
HRESULT Loading_For_MapViewer();
HRESULT Loading_For_UI();
HRESULT Loading_For_Effect();
HRESULT Loading_For_PhysXLevel();
private:
HRESULT Asset_FileLoad(const _char* pDirectoryPath, const _tchar* pPreName, function<HRESULT(_wstring, const _char*)> AddPrototypeEvent);
@@ -238,7 +238,7 @@
<Filter Include="02.Element\02.Component\07.RigidBody">
<UniqueIdentifier>{5c89d610-7e57-40a5-bc65-04e5fa25df89}</UniqueIdentifier>
</Filter>
<Filter Include="03.Management\21.PhysX_Manager\CCT">
<Filter Include="02.Element\02.Component\08.Character_Controller">
<UniqueIdentifier>{b20c0397-6254-4350-bc83-ee695f9fd012}</UniqueIdentifier>
</Filter>
<Filter Include="02.Element\01.GameObject\50.UI\CanvasObject">
@@ -454,7 +454,7 @@
<Filter>02.Element\02.Component\02.VIBuffer\Terrain</Filter>
</ClCompile>
<ClCompile Include="..\Private\Character_Controller.cpp">
<Filter>03.Management\21.PhysX_Manager\CCT</Filter>
<Filter>02.Element\02.Component\08.Character_Controller</Filter>
</ClCompile>
<ClCompile Include="..\private\CanvasObject.cpp">
<Filter>02.Element\01.GameObject\50.UI\CanvasObject</Filter>
@@ -1035,7 +1035,7 @@
<Filter>02.Element\02.Component\07.RigidBody</Filter>
</ClInclude>
<ClInclude Include="..\Public\Character_Controller.h">
<Filter>03.Management\21.PhysX_Manager\CCT</Filter>
<Filter>02.Element\02.Component\08.Character_Controller</Filter>
</ClInclude>
<ClInclude Include="..\public\CanvasObject.h">
<Filter>02.Element\01.GameObject\50.UI\CanvasObject</Filter>
@@ -90,10 +90,10 @@ HRESULT CGameInstance::Initialize_Engine(const ENGINE_DESC& EngineDesc, ID3D11De
if (nullptr == m_pCollider_Manager) {
return E_FAIL;
}
//m_pPhysX_Manager = CPhysX_Manager::Create(*ppDevice, *ppContext);
//if (nullptr == m_pPhysX_Manager) {
// return E_FAIL;
//}
m_pPhysX_Manager = CPhysX_Manager::Create(*ppDevice, *ppContext);
if (nullptr == m_pPhysX_Manager) {
return E_FAIL;
}
return S_OK;
}
@@ -117,7 +117,7 @@ void CGameInstance::Update_Engine(_float fTimeDelta)
m_pLevel_Manager->Update(fTimeDelta);
m_pObject_Manager->Clear_DeadObj();
//m_pPhysX_Manager->Update(fTimeDelta);
m_pPhysX_Manager->Update(fTimeDelta);
//m_pObstacle_Manager->Refresh_Region();
}
@@ -78,7 +78,7 @@ HRESULT CGameObject::Add_Asset_Component(_uint iTargetLevel, const _wstring strP
if (ppOut != nullptr)
{
*ppOut = pComponent;
Safe_AddRef(pComponent);
SAFE_ADDREF(pComponent);
}
@@ -10,8 +10,10 @@ static PSX::PxTransform XMWorldToPx(const _matrix& WorldMatrix)
_vector vPos, vRotq, vScale;
XMMatrixDecompose(&vScale, &vRotq, &vPos, WorldMatrix);
vRotq = XMQuaternionNormalize(vRotq);
PSX::PxTransform out;
XMStoreFloat3((_float3*)&out.p, WorldMatrix.r[3]);
XMStoreFloat3((_float3*)&out.p, vPos);
XMStoreFloat4((_float4*)&out.q, vRotq);
return out;
@@ -78,13 +80,15 @@ const PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody& RigidBody)
}
PSX::PxRigidStatic* pActor = m_pPhysics->createRigidStatic(pxWorldMatrix); pPxMeshGeometry;
PSX::PxRigidStatic* pActor = m_pPhysics->createRigidStatic(pxWorldMatrix);
PSX::PxShape* pShape = PSX::PxRigidActorExt::createExclusiveShape(*pActor, *pPxMeshGeometry, *RigidBody.Get_PxMaterial());
pShape->setFlag(PSX::PxShapeFlag::eSCENE_QUERY_SHAPE, true);
pShape->setFlag(PSX::PxShapeFlag::eSIMULATION_SHAPE, true);
pActor->attachShape(*pShape);
pActor->userData = &RigidBody;
m_RigidBodys.emplace_back(&RigidBody, pActor);
m_pScene->addActor(*pActor);
return pActor;
}
@@ -133,9 +137,9 @@ HRESULT CPhysX_Manager::Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh*
return E_FAIL;
}
PSX::PxTriangleMesh* CPhysX_Manager::Find_TriangleMesh(const _wstring& wstrFilePath)
PSX::PxTriangleMesh* CPhysX_Manager::Find_TriangleMesh(const _wstring& wstrMeshKey)
{
map<_wstring, PSX::PxTriangleMesh*>::iterator iter = m_TriangleMeshes.find(wstrFilePath);
map<_wstring, PSX::PxTriangleMesh*>::iterator iter = m_TriangleMeshes.find(wstrMeshKey);
if (iter != m_TriangleMeshes.end()) {
return iter->second;
}
@@ -186,6 +190,9 @@ void CPhysX_Manager::Update_Dynamic()
PSX::PxRigidDynamic* pActorDynamic = ppActiveActors[i]->is<PSX::PxRigidDynamic>();
if (nullptr != pActorDynamic) {
if (nullptr == ppActiveActors[i]->userData) {
continue;
}
CTransform* pTransform = ((CRigidBody*)ppActiveActors[i]->userData)->Get_PxTransformPtr();
PSX::PxTransform pPrevPxTransform;
@@ -220,13 +227,13 @@ PSX::PxController* CPhysX_Manager::Add_BoxController(PSX::PxBoxControllerDesc& D
PSX::PxController* pController = { nullptr };
pController = m_pCCTManager->createController(Desc);
//pController->
return pController;
}
PSX::PxController* CPhysX_Manager::Get_Controller(_uint iControllerIndex)
{
return nullptr;
return m_pCCTManager->getController((PSX::PxU32)iControllerIndex);
}
void CPhysX_Manager::ReleaseController(_uint iControllerIndex)
@@ -253,7 +260,6 @@ HRESULT CPhysX_Manager::PurgeAllController()
HRESULT CPhysX_Manager::Initialize()
{
m_pFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, m_AllocatorCallBack, m_ErrorCallBack);
if (nullptr == m_pFoundation) {
assert(false);
@@ -266,17 +272,23 @@ HRESULT CPhysX_Manager::Initialize()
{ // 씬 세팅
m_ToleranceScale.length = 1.f;
m_ToleranceScale.speed = GRAVITY;
m_ToleranceScale.length = 1.f; // 1 meter
m_ToleranceScale.speed = GRAVITY; //
m_pPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *m_pFoundation, m_ToleranceScale, true, m_pPvd);
m_pCookingParam = new PSX::PxCookingParams(m_pPhysics->getTolerancesScale());
PSX::PxSceneDesc sceneDesc = { m_pPhysics->getTolerancesScale() };
sceneDesc.gravity = PSX::PxVec3(0.f, GRAVITY, 0.f);
sceneDesc.gravity = PSX::PxVec3(0.f, -GRAVITY, 0.f);
sceneDesc.cpuDispatcher = m_pDispatcher = PSX::PxDefaultCpuDispatcherCreate(2/*cpu ÄÚ¾î °¹¼ö*/);
m_pDispatcher = PSX::PxDefaultCpuDispatcherCreate(2/*cpu ÄÚ¾î °¹¼ö*/);
if (nullptr == m_pDispatcher) {
assert(false);
return E_FAIL;
}
sceneDesc.cpuDispatcher = m_pDispatcher;
sceneDesc.filterShader = PSX::PxDefaultSimulationFilterShader;
@@ -298,26 +310,47 @@ HRESULT CPhysX_Manager::Initialize()
pPvdClient->setScenePvdFlag(PSX::PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES, true);
}
physx::PxMaterial* pMaterial = m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f);
physx::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *pMaterial);
m_pScene->addActor(*pGroundPlane);
{
float halfExtent = .5f;
physx::PxShape* shape = m_pPhysics->createShape(physx::PxSphereGeometry(halfExtent), *pMaterial);
physx::PxU32 size = 100;
physx::PxTransform pxTransform(physx::PxVec3(0));
for (physx::PxU32 i = 0; i < size; i++) {
for (physx::PxU32 j = 0; j < size - i; j++) {
physx::PxTransform localTm(physx::PxVec3(physx::PxReal(j * 2) - physx::PxReal(size - i) + 100, physx::PxReal(i * 2 + 1), 0) * halfExtent);
physx::PxRigidDynamic* body = m_pPhysics->createRigidDynamic(pxTransform.transform(localTm));
body->attachShape(*shape);
physx::PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
m_pScene->addActor(*body);
}
}
}
return S_OK;
}
HRESULT CPhysX_Manager::Connect_DebugServer()
{
// 네트워크 디버거 전송객체 생성
PSX::PxPvdTransport* pTransport = PSX::PxDefaultPvdSocketTransportCreate("127.0.0.1", 5425, 10);
if (nullptr == pTransport) {
m_pTransport = PSX::PxDefaultPvdSocketTransportCreate("127.0.0.1", 5425, 10);
if (nullptr == m_pTransport) {
assert(false);
return E_FAIL;
}
m_pPvd = PSX::PxCreatePvd(*m_pFoundation);
if (nullptr == m_pPvd) {
pTransport->release();
m_pTransport->release();
assert(false);
return E_FAIL;
}
m_pPvd->connect(*pTransport, PSX::PxPvdInstrumentationFlag::eALL);
pTransport->release();
m_pPvd->connect(*m_pTransport, PSX::PxPvdInstrumentationFlag::eALL);
return S_OK;
}
@@ -365,11 +398,14 @@ void CPhysX_Manager::Free()
m_pPvd->release(); m_pPvd = nullptr;
}
if (nullptr != m_pTransport) {
m_pTransport->release(); m_pTransport = nullptr;
}
if (nullptr != m_pFoundation) {
m_pFoundation->release(); m_pFoundation = nullptr;
}
__super::Free();
SAFE_RELEASE(m_pDevice);
+10 -17
View File
@@ -6,8 +6,6 @@
CRigidBody::CRigidBody(ID3D11Device* pDevice, ID3D11DeviceContext* pContext):
CComponent(pDevice, pContext)
{
SAFE_ADDREF(pDevice);
SAFE_ADDREF(pContext);
}
CRigidBody::CRigidBody(const CRigidBody& rhs):
@@ -16,10 +14,11 @@ CRigidBody::CRigidBody(const CRigidBody& rhs):
m_eActorType(rhs.m_eActorType),
m_vhalfGeometryInfo(rhs.m_vhalfGeometryInfo),
m_pShape(rhs.m_pShape),
m_pMeshKey(rhs.m_pMeshKey)
m_pMeshKey(rhs.m_pMeshKey),
m_bExclusive(rhs.m_bExclusive),
m_bKinematic(rhs.m_bKinematic)
{
m_pMaterial->acquireReference();
m_pShape->acquireReference();
}
HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc)
@@ -32,7 +31,8 @@ HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc)
case ACTOR::SPHERE:
m_pMaterial = m_pGameInstance->Get_Material(Desc.tRigidDynamicDesc.vMatInfo);
m_vhalfGeometryInfo = Desc.tRigidDynamicDesc.vhalfGeometryInfo;
m_pShape = m_pGameInstance->Create_Shape(m_eActorType, m_vhalfGeometryInfo, *m_pMaterial, Desc.tRigidDynamicDesc.bExclusive, Desc.tRigidDynamicDesc.ePxShapeFlag);
m_bExclusive = Desc.tRigidDynamicDesc.bExclusive;
m_pShape = m_pGameInstance->Create_Shape(m_eActorType, m_vhalfGeometryInfo, *m_pMaterial, m_bExclusive, Desc.tRigidDynamicDesc.ePxShapeFlag);
if (nullptr == m_pShape) {
assert(false);
m_pMaterial->release();
@@ -54,7 +54,6 @@ HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc)
default:
break;
}
return S_OK;
}
@@ -65,6 +64,9 @@ HRESULT CRigidBody::Initialize(void* pArg)
if (FAILED(__super::Initialize(pArg))) {
return E_FAIL;
}
if (true == m_bExclusive) {
return E_FAIL;
}
m_pTransform = m_pOwner->Get_Component<CTransform>();
SAFE_ADDREF(m_pTransform);
@@ -75,7 +77,7 @@ HRESULT CRigidBody::Initialize(void* pArg)
case Engine::ACTOR::CAPSULE:
case Engine::ACTOR::SPHERE:
m_fDensity = pDesc->tRigidDynamicDesc.fDensity;
m_bKenematic = pDesc->tRigidDynamicDesc.bIsKinematic;
m_bKinematic = pDesc->tRigidDynamicDesc.bIsKinematic;
m_pRigidBody = m_pGameInstance->Add_DynamicActor(*this);
break;
case Engine::ACTOR::PLANE:
@@ -124,15 +126,6 @@ void CRigidBody::Free()
{
__super::Free();
if (nullptr != m_pMaterial) {
m_pMaterial->release();
m_pMaterial = nullptr;
}
if (nullptr != m_pShape) {
m_pShape->release();
m_pShape = nullptr;
}
SAFE_RELEASE(m_pTransform);
}
+3 -1
View File
@@ -79,7 +79,9 @@
//}
#define FLT_EPSILON3 1.192092896e-03F
#define FLT_EPSILON5 1.192092896e-05F
#define GRAVITY -9.81f
// GRAVITY 음수 박으면 피직스 로드 실패함
#define GRAVITY 9.81f
constexpr unsigned int g_iMaxShadowWidth = 16384;
constexpr unsigned int g_iMaxShadowHeight = 9216;
@@ -27,7 +27,7 @@ class CPhysX_Manager final : public CBase
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);
PSX::PxTriangleMesh* Find_TriangleMesh(const _wstring& wstrMeshKey);
void Update(_float fTimeDelta);
void ClearScene();
@@ -65,6 +65,8 @@ class CPhysX_Manager final : public CBase
PSX::PxControllerManager* m_pCCTManager = { nullptr }; // 피직스 캐릭터 컨트롤러를 전부 추적하고 매니징함
PSX::PxPvd* m_pPvd = { nullptr }; // 피직스 시뮬레이션 디버깅을 위한 도구
PSX::PxCookingParams* m_pCookingParam = { nullptr };
PSX::PxPvdTransport* m_pTransport = { nullptr };
list<pair<CRigidBody*, PSX::PxActor*>> m_RigidBodys = { };
+3 -2
View File
@@ -72,7 +72,7 @@ class ENGINE_DLL CRigidBody final : public CComponent
const PSX::PxMaterial* Get_PxMaterial() const { return m_pMaterial; }
_float Get_Density() const { return m_fDensity; }
_bool Is_Kinematic() const { return m_bKenematic; }
_bool Is_Kinematic() const { return m_bKinematic; }
private:
ACTOR m_eActorType = ACTOR::END;
@@ -81,7 +81,8 @@ class ENGINE_DLL CRigidBody final : public CComponent
PSX::PxShape* m_pShape = { nullptr }; // 피직스 객체의 모양 ( 머테리얼로 만들어짐 )
_float3 m_vhalfGeometryInfo = {};
CTransform* m_pTransform = { nullptr };
_bool m_bKenematic = { false };
_bool m_bKinematic = { false };
_bool m_bExclusive = { false };
_float m_fDensity = { 1000.f };
const _tchar* m_pMeshKey = { nullptr };