[add] 피직스 객체 디버그 드로우 추가

This commit is contained in:
kimnuri
2025-11-13 19:22:06 +09:00
parent 8fb613d4f6
commit 861ea610dc
9 changed files with 286 additions and 51 deletions
@@ -172,6 +172,7 @@
</ClInclude>
<ClInclude Include="..\Public\Effect_Editor.h" />
<ClInclude Include="..\Public\EditEffect.h" />
<ClInclude Include="..\Public\Information.h" />
<ClInclude Include="..\public\Level_MapViewer.h" />
<ClInclude Include="..\Public\LoadingWidget.h" />
<ClInclude Include="..\public\MapContainer.h" />
@@ -238,6 +239,7 @@
</ClCompile>
<ClCompile Include="..\Private\Effect_Editor.cpp" />
<ClCompile Include="..\Private\EditEffect.cpp" />
<ClCompile Include="..\Private\Information.cpp" />
<ClCompile Include="..\private\Level_MapViewer.cpp" />
<ClCompile Include="..\Private\LoadingWidget.cpp" />
<ClCompile Include="..\private\MapContainer.cpp" />
@@ -405,6 +405,9 @@
<ClInclude Include="..\public\DummySkyBox.h">
<Filter>02.GameObjects\Dummys\DummySkyBox</Filter>
</ClInclude>
<ClInclude Include="..\Public\Information.h">
<Filter>03.Information</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="Editor.ico">
@@ -604,6 +607,9 @@
<ClCompile Include="..\private\DummySkyBox.cpp">
<Filter>02.GameObjects\Dummys\DummySkyBox</Filter>
</ClCompile>
<ClCompile Include="..\Private\Information.cpp">
<Filter>03.Information</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Editor.rc">
@@ -50,20 +50,26 @@ void CDummy_PhysXBox::Late_Update(_float fTimeDelta)
HRESULT CDummy_PhysXBox::Render()
{
if (FAILED(Bind_ShaderResources())) {
return E_FAIL;
}
//if (FAILED(Bind_ShaderResources())) {
// return E_FAIL;
//}
if (FAILED(m_pModelCom->Bind_Material(0, m_pShaderCom, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) {
return E_FAIL;
}
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::DEFAULT)))) {
return E_FAIL;
}
//if (FAILED(m_pModelCom->Bind_Material(0, m_pShaderCom, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) {
// return E_FAIL;
//}
//if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::DEFAULT)))) {
// return E_FAIL;
//}
if (FAILED(m_pModelCom->Render(0))) {
//if (FAILED(m_pModelCom->Render(0))) {
// return E_FAIL;
//}
#ifdef _DEBUG
if (FAILED(m_pRigidBody->Render())) {
return E_FAIL;
}
#endif // _DEBUG
return S_OK;
}
@@ -53,20 +53,20 @@ void CDummy_PhysXPlayable::Late_Update(_float fTimeDelta)
HRESULT CDummy_PhysXPlayable::Render()
{
if (FAILED(Bind_ShaderResources())) {
return E_FAIL;
}
//if (FAILED(Bind_ShaderResources())) {
// return E_FAIL;
//}
if (FAILED(m_pModelCom->Bind_Material(0, m_pShaderCom, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) {
return E_FAIL;
}
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::DEFAULT)))) {
return E_FAIL;
}
//if (FAILED(m_pModelCom->Bind_Material(0, m_pShaderCom, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) {
// return E_FAIL;
//}
//if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::DEFAULT)))) {
// return E_FAIL;
//}
if (FAILED(m_pModelCom->Render(0))) {
return E_FAIL;
}
//if (FAILED(m_pModelCom->Render(0))) {
// return E_FAIL;
//}
#ifdef _DEBUG
if (FAILED(m_pCharacter_Controller->Render())) {
return E_FAIL;
@@ -0,0 +1,86 @@
#include "pch.h"
#include "Information.h"
IMPLEMENT_SINGLETON(CInformation)
HRESULT CInformation::Initialize_Info(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
m_pDevice = pDevice;
m_pContext = pContext;
SAFE_ADDREF(m_pDevice);
SAFE_ADDREF(m_pContext);
return S_OK;
}
HRESULT CInformation::Release_Info()
{
if (nullptr == s_pInstance) {
return S_OK;
}
DestroyInstance();
//SAFE_RELEASE();
//SAFE_RELEASE();
return S_OK;
}
_bool CInformation::strListBox(const _char* Label, _int& iCurrentIndex, vector<_string>& contents)
{
assert(iCurrentIndex < contents.size());
assert(iCurrentIndex >= 0);
return GUI::ListBox(Label, &iCurrentIndex, [](void* data, _int iIndex)->const _char*
{
auto vec = static_cast<vector<_string>*>(data);
return (*vec)[iIndex].c_str();
}, &contents, (_int)(contents.size())
);
}
_bool CInformation::wstrListBox(const _char* Label, _int& iCurrentIndex, vector<_wstring>& contents)
{
assert(iCurrentIndex < contents.size());
assert(iCurrentIndex >= 0);
return GUI::ListBox(Label, &iCurrentIndex, [](void* data, _int iIndex)->const _char*
{
auto vec = static_cast<vector<_wstring>*>(data);
return CMyTools::ToString((*vec)[iIndex]).c_str();
}, &contents, (_int)(contents.size())
);
}
void CInformation::Log_Render()
{
GUI::Begin("Log");
GUI::Text(m_strLog.c_str());
GUI::End();
}
void CInformation::Log_Push(const _char* pContents)
{
m_strLog.append(_string("\n") + pContents);
}
void CInformation::Log_Clear()
{
m_strLog.clear();
}
CInformation::CInformation()
{
}
void CInformation::Free()
{
__super::Free();
SAFE_RELEASE(m_pDevice);
SAFE_RELEASE(m_pContext);
}
@@ -0,0 +1,60 @@
#pragma once
#include "Base.h"
#include "Editor_Define.h"
NS_BEGIN(Editor)
typedef class CInformation final : public CBase
{
DECLARE_SINGLETON(CInformation)
public:
HRESULT Initialize_Info(ID3D11Device* pDevice = nullptr, ID3D11DeviceContext* pContext = nullptr);
HRESULT Release_Info();
#pragma region WHOLEPART
_bool strListBox(const _char* Label, _int& iCurrentIndex, vector<_string>& contents);
_bool wstrListBox(const _char* Label, _int& iCurrentIndex, vector<_wstring>& contents);
#pragma endregion // Àü¿ª
#pragma region OBJECTVIEWER
#pragma endregion
#pragma region MAPVIEWER
#pragma endregion
#pragma region EFFECTVIEWER
#pragma endregion
#pragma region UIVIEWER
#pragma endregion
#pragma region PHYSXVIEWER
#pragma endregion
#pragma region COMBINEDVIEWER
#pragma endregion
public:
#pragma region LOG
void Log_Render();
void Log_Push(const _char* pContents);
void Log_Clear();
#pragma endregion
private:
ID3D11Device* m_pDevice = { nullptr };
ID3D11DeviceContext* m_pContext = { nullptr };
class CGameInstance* m_pGameInstance = { nullptr };
_string m_strLog = {};
private:
CInformation();
virtual ~CInformation() = default;
virtual void Free() override;
}INFO;
NS_END
@@ -53,8 +53,7 @@ HRESULT CCharacter_Controller::Render()
m_pSubShape->Draw(ScaleSphereMatrix * WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
m_pSubShape->Draw(ScaleSphereMatrix * WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
}
break;
} break;
default:
break;
}
+84 -24
View File
@@ -18,8 +18,39 @@ CRigidBody::CRigidBody(const CRigidBody& rhs):
m_bExclusive(rhs.m_bExclusive),
m_bKinematic(rhs.m_bKinematic)
{
//m_pMaterial->acquireReference();
}
#ifdef _DEBUG
HRESULT CRigidBody::Render()
{
_matrix WorldMatrix = m_pTransform->Get_XMWorldMatrix();
_matrix ViewMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW);
_matrix ProjMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ);
_vector vColor = CMyTools::ColorRGB_A_HEXtoVECTOR(0x2fc48000, 1.f);
switch (m_eActorType)
{
case ACTOR::BOX:
{
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
} break;
case ACTOR::CAPSULE:
{
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
_matrix WorldUp = XMMatrixTranslationFromVector(m_pTransform->Get_State(STATE::UP) * m_vhalfGeometryInfo.y);
_matrix WorldDown = XMMatrixTranslationFromVector(m_pTransform->Get_State(STATE::UP) * -m_vhalfGeometryInfo.y);
m_pSubShape->Draw(WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
m_pSubShape->Draw(WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
} break;
case ACTOR::SPHERE:
{
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
} break;
default:
break;
}
return S_OK;
}
#endif // _DEBUG
HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc)
{
@@ -29,31 +60,22 @@ HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc)
case ACTOR::BOX:
case ACTOR::CAPSULE:
case ACTOR::SPHERE:
m_pMaterial = m_pGameInstance->Get_Material(Desc.tRigidDynamicDesc.vMatInfo);
m_vhalfGeometryInfo = Desc.tRigidDynamicDesc.vhalfGeometryInfo;
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();
m_pMaterial = nullptr;
return E_FAIL;
}
Add_DynamicPrototype(Desc);
break;
case ACTOR::PLANE:
break;
case ACTOR::TRIANGLEMESH:
{
m_pMaterial = m_pGameInstance->Get_Material(Desc.tRigidDynamicDesc.vMatInfo);
m_wstrMeshKey = CMyTools::ToWstring(Desc.tRigidStaticDesc.szMeshName);
}
break;
case ACTOR::HEIGHTFIELD:
break;
default:
break;
}
return S_OK;
#ifdef _DEBUG
if (FAILED(Add_DebugShape())) {
return E_FAIL;
}
#endif // _DEBUG
return S_OK;
}
@@ -92,12 +114,54 @@ HRESULT CRigidBody::Initialize(void* pArg)
default:
break;
}
#ifdef _DEBUG
Add_DebugShape();
#endif // _DEBUG
return S_OK;
}
HRESULT CRigidBody::Add_DynamicPrototype(RIGIDBODY_PROTOTYPEDESC& Desc)
{
m_pMaterial = m_pGameInstance->Get_Material(Desc.tRigidDynamicDesc.vMatInfo);
m_vhalfGeometryInfo = Desc.tRigidDynamicDesc.vhalfGeometryInfo;
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();
m_pMaterial = nullptr;
return E_FAIL;
}
return S_OK;
}
#ifdef _DEBUG
HRESULT CRigidBody::Add_DebugShape()
{
switch (m_eActorType)
{
case ACTOR::BOX:
m_pMainShape = (GeometricPrimitive::CreateBox(m_pContext, m_vhalfGeometryInfo, false, false));
break;
case ACTOR::CAPSULE:
m_pSubShape = (GeometricPrimitive::CreateSphere(m_pContext, m_vhalfGeometryInfo.x, 10, false, false));
m_pMainShape = (GeometricPrimitive::CreateCylinder(m_pContext, m_vhalfGeometryInfo.y, m_vhalfGeometryInfo.x, 10, false));
break;
case ACTOR::SPHERE:
m_pMainShape = (GeometricPrimitive::CreateSphere(m_pContext, m_vhalfGeometryInfo.x, 10, false, false));
break;
case ACTOR::PLANE:
case ACTOR::TRIANGLEMESH:
case ACTOR::HEIGHTFIELD:
break;
default:
break;
}
return S_OK;
}
#endif // _DEBUG
CRigidBody* CRigidBody::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, RIGIDBODY_PROTOTYPEDESC& Desc)
{
CRigidBody* pInstance = new CRigidBody(pDevice, pContext);
@@ -127,10 +191,6 @@ void CRigidBody::Free()
__super::Free();
SAFE_RELEASE(m_pTransform);
//if (nullptr != m_pMaterial) {
// m_pMaterial->release();
// m_pMaterial = nullptr;
//}
}
void CRigidBody::Describe_Entity()
+19 -3
View File
@@ -26,6 +26,8 @@ class ENGINE_DLL CRigidBody final : public CComponent
PSX::PxShapeFlags ePxShapeFlag = { PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE };
}RIGID_DYNAMIC_PROTOTYPEDESC;
typedef struct tagRigidBody_PrototypeDesc
{
ACTOR eType;
@@ -65,6 +67,11 @@ class ENGINE_DLL CRigidBody final : public CComponent
CRigidBody(const CRigidBody& rhs);
virtual ~CRigidBody() = default;
public:
#ifdef _DEBUG
virtual HRESULT Render()override;
#endif // _DEBUG
ACTOR Get_Type() const { return m_eActorType; }
PSX::PxShape* Get_ShapePtr() const { return m_pShape; }
CTransform* Get_PxTransformPtr() const { return m_pTransform; }
@@ -76,9 +83,9 @@ class ENGINE_DLL CRigidBody final : public CComponent
private:
ACTOR m_eActorType = ACTOR::END;
const PSX::PxActor* m_pRigidBody = { nullptr }; // 실제 시뮬레이션을 도는 본체
PSX::PxMaterial* m_pMaterial = { nullptr }; // 피직스 객체의 속성 등
PSX::PxShape* m_pShape = { nullptr }; // 피직스 객체의 모양 ( 머테리얼로 만들어짐 )
const PSX::PxActor* m_pRigidBody = { nullptr }; // 실제 시뮬레이션을 도는 본체
PSX::PxMaterial* m_pMaterial = { nullptr }; // 피직스 객체의 속성 등
PSX::PxShape* m_pShape = { nullptr }; // 피직스 객체의 모양 ( 머테리얼로 만들어짐 )
_float3 m_vhalfGeometryInfo = {};
_float m_fContactOffset = { 0.05f };
CTransform* m_pTransform = { nullptr };
@@ -88,8 +95,17 @@ class ENGINE_DLL CRigidBody final : public CComponent
_wstring m_wstrMeshKey = { };
private:
#ifdef _DEBUG
unique_ptr<GeometricPrimitive> m_pMainShape = { nullptr };
unique_ptr<GeometricPrimitive> m_pSubShape = { nullptr };
#endif // _DEBUG
HRESULT Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc);
HRESULT Initialize(void* pArg);
HRESULT Add_DynamicPrototype(RIGIDBODY_PROTOTYPEDESC& Desc);
#ifdef _DEBUG
HRESULT Add_DebugShape();
#endif
public:
static CRigidBody* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, RIGIDBODY_PROTOTYPEDESC& Desc);