[add] 피직스 소멸자 세팅
This commit is contained in:
@@ -193,6 +193,7 @@
|
||||
<ClInclude Include="..\public\MapObject_Manager.h" />
|
||||
<ClInclude Include="..\Public\MainLight.h" />
|
||||
<ClInclude Include="..\public\MapObject_Collision.h" />
|
||||
<ClInclude Include="..\Public\Dummy_PhysXDoor.h" />
|
||||
<ClInclude Include="..\public\Terrain.h" />
|
||||
<ClInclude Include="..\Public\Level_PhysXLab.h" />
|
||||
<ClInclude Include="..\Public\TestEffect.h" />
|
||||
@@ -262,6 +263,7 @@
|
||||
<ClCompile Include="..\private\MapObject_Manager.cpp" />
|
||||
<ClCompile Include="..\Private\MainLight.cpp" />
|
||||
<ClCompile Include="..\private\MapObject_Collision.cpp" />
|
||||
<ClCompile Include="..\Private\Dummy_PhysXDoor.cpp" />
|
||||
<ClCompile Include="..\private\Terrain.cpp" />
|
||||
<ClCompile Include="..\Private\Level_PhysXLab.cpp" />
|
||||
<ClCompile Include="..\Private\TestEffect.cpp" />
|
||||
|
||||
@@ -217,6 +217,9 @@
|
||||
<Filter Include="02.GameObjects\Dummys\DummyPhysX\Callback">
|
||||
<UniqueIdentifier>{b6d1496a-c8ef-4b7a-9ed4-f00b0a244313}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.GameObjects\Dummys\DummyPhysX\PhysXDoor">
|
||||
<UniqueIdentifier>{3131278b-18f5-4b84-ba85-73104998e9c9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Editor.h">
|
||||
@@ -426,6 +429,9 @@
|
||||
<ClInclude Include="..\Public\CallBack_Playable_Behavior.h">
|
||||
<Filter>02.GameObjects\Dummys\DummyPhysX\Callback\Playable\Behavior</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Dummy_PhysXDoor.h">
|
||||
<Filter>02.GameObjects\Dummys\DummyPhysX\PhysXDoor</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Editor.ico">
|
||||
@@ -631,6 +637,9 @@
|
||||
<ClCompile Include="..\Private\CallBack_Playable_Behavior.cpp">
|
||||
<Filter>02.GameObjects\Dummys\DummyPhysX\Callback\Playable\Behavior</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Dummy_PhysXDoor.cpp">
|
||||
<Filter>02.GameObjects\Dummys\DummyPhysX\PhysXDoor</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Editor.rc">
|
||||
|
||||
@@ -39,6 +39,16 @@ void CDummy_PhysXBox::Priority_Update(_float fTimeDelta)
|
||||
|
||||
void CDummy_PhysXBox::Update(_float fTimeDelta)
|
||||
{
|
||||
if (m_pGameInstance->Key_Pressing(DIK_LCONTROL)) {
|
||||
if (m_pGameInstance->Key_Down(DIK_X)) {
|
||||
m_pGameInstance->Detach_Actor(*m_pRigidBody->Get_Actor());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_pGameInstance->Key_Down(DIK_X)) {
|
||||
m_pGameInstance->Attach_Actor(*m_pRigidBody->Get_Actor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDummy_PhysXBox::Late_Update(_float fTimeDelta)
|
||||
@@ -50,20 +60,20 @@ 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))) {
|
||||
// return E_FAIL;
|
||||
//}
|
||||
if (FAILED(m_pModelCom->Render(0))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (FAILED(m_pRigidBody->Render())) {
|
||||
return E_FAIL;
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
#include "pch.h"
|
||||
#include "Dummy_PhysXDoor.h"
|
||||
|
||||
#include "GameInstance.h"
|
||||
|
||||
|
||||
CDummy_PhysXDoor::CDummy_PhysXDoor(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: CGameObject{ pDevice, pContext }
|
||||
{
|
||||
}
|
||||
|
||||
CDummy_PhysXDoor::CDummy_PhysXDoor(const CDummy_PhysXDoor& rhs)
|
||||
: CGameObject(rhs)
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT CDummy_PhysXDoor::Initialize_Prototype()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDummy_PhysXDoor::Initialize(void* pArg)
|
||||
{
|
||||
if (FAILED(__super::Initialize(pArg))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(Ready_Components(pArg))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CDummy_PhysXDoor::Priority_Update(_float fTimeDelta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CDummy_PhysXDoor::Update(_float fTimeDelta)
|
||||
{
|
||||
}
|
||||
|
||||
void CDummy_PhysXDoor::Late_Update(_float fTimeDelta)
|
||||
{
|
||||
if (m_pGameInstance->isIn_WorldFrustum(Get_WorldPostion(), m_pTransformCom->Get_Radius())) {
|
||||
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this);
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CDummy_PhysXDoor::Render()
|
||||
{
|
||||
//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->Render(0))) {
|
||||
// return E_FAIL;
|
||||
//}
|
||||
#ifdef _DEBUG
|
||||
if (FAILED(m_pRigidBody->Render())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDummy_PhysXDoor::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_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
|
||||
|
||||
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), (CComponent**)&m_pRigidBody, &Desc))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Com_Shader */
|
||||
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH,
|
||||
reinterpret_cast<CComponent**>(&m_pShaderCom)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_Box"), (CComponent**)&m_pModelCom))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDummy_PhysXDoor::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_PhysXDoor* CDummy_PhysXDoor::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
{
|
||||
CDummy_PhysXDoor* pInstance = new CDummy_PhysXDoor(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype()))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CDummy_PhysXDoor");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CGameObject* CDummy_PhysXDoor::Clone(void* pArg, CGameObject* pOwner)
|
||||
{
|
||||
CDummy_PhysXDoor* pInstance = new CDummy_PhysXDoor(*this);
|
||||
pInstance->m_pOwner = pOwner;
|
||||
if (FAILED(pInstance->Initialize(pArg)))
|
||||
{
|
||||
MSG_BOX("Failed to Cloned : CDummy_PhysXDoor");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
void CDummy_PhysXDoor::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
SAFE_RELEASE(m_pRigidBody);
|
||||
SAFE_RELEASE(m_pShaderCom);
|
||||
SAFE_RELEASE(m_pModelCom);
|
||||
}
|
||||
|
||||
void CDummy_PhysXDoor::Describe_Entity()
|
||||
{
|
||||
}
|
||||
@@ -39,6 +39,14 @@ void CDummy_PhysXPlayable::Update(_float fTimeDelta)
|
||||
if (m_pGameInstance->Key_Pressing(DIK_C)) {
|
||||
m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, -10.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
|
||||
}
|
||||
if (m_pGameInstance->Key_Down(DIK_V)) {
|
||||
m_pGameInstance->Detach_Actor(*m_pCharacter_Controller->Get_Actor());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_pGameInstance->Key_Down(DIK_V)) {
|
||||
m_pGameInstance->Attach_Actor(*m_pCharacter_Controller->Get_Actor());
|
||||
}
|
||||
}
|
||||
m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, -GRAVITY * fTimeDelta, 0.f, 0.f));
|
||||
m_pCharacter_Controller->Move(fTimeDelta);
|
||||
|
||||
@@ -91,7 +91,7 @@ HRESULT CLevel_PhysXLab::Ready_Layer_Terrain(const _wstring& strLayerTag)
|
||||
|
||||
HRESULT CLevel_PhysXLab::Ready_Layer_PhysXObjects(const _wstring& strLayerTag)
|
||||
{
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
for (int i = 0; i < 500; ++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) };
|
||||
|
||||
@@ -533,7 +533,7 @@ HRESULT CLoader::Loading_For_PhysXLevel()
|
||||
CRigidBody_Dynamic::RIGIDBODY_PROTOTYPE_DYNAMIC_DESC Desc{};
|
||||
{
|
||||
Desc.eType = ACTOR::BOX;
|
||||
Desc.ePxRigidBodyFlags = {};
|
||||
Desc.ePxRigidBodyFlags = { /*PSX::PxRigidBodyFlag::eKINEMATIC*/ };
|
||||
Desc.ePxShapeFlags = { PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE };
|
||||
Desc.ePxMaterialTypes = { PXMATERIAL::DEFAULT };
|
||||
Desc.vMatInfo = { 0.5f, 0.5f, 0.6f };
|
||||
|
||||
@@ -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_PhysXDoor final : public CGameObject
|
||||
{
|
||||
public:
|
||||
typedef struct tagBoxStartPos
|
||||
{
|
||||
_float3 vPos = {};
|
||||
_float3 vRotRPY = {};
|
||||
}BOXSTARTPOS_DESC;
|
||||
private:
|
||||
CDummy_PhysXDoor(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
CDummy_PhysXDoor(const CDummy_PhysXDoor& rhs);
|
||||
virtual ~CDummy_PhysXDoor() = 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_PhysXDoor* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override;
|
||||
virtual void Free() override;
|
||||
void Describe_Entity() override;
|
||||
};
|
||||
|
||||
NS_END
|
||||
@@ -60,6 +60,11 @@ HRESULT CCharacter_Controller::Render()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
PSX::PxRigidDynamic* CCharacter_Controller::Get_Actor()
|
||||
{
|
||||
return m_pController->getActor();
|
||||
}
|
||||
|
||||
#endif // _DEBUG
|
||||
|
||||
void CCharacter_Controller::Resize_Volume(_float fHeight)
|
||||
@@ -188,7 +193,7 @@ HRESULT CCharacter_Controller::Initialize(void* pArg)
|
||||
{ // PhsXUserData
|
||||
m_tagData.eKind = PHYSX_KIND::CCTActor;
|
||||
m_tagData.pOwner = m_pOwner;
|
||||
XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
XMStoreFloat4x4(&m_tagData.BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
m_tagData.pCharacter = this;
|
||||
}
|
||||
|
||||
|
||||
@@ -431,7 +431,7 @@ void CGameInstance::Transform_Frustum_ToLocalSpace(_fmatrix WorldMatrixInverse)
|
||||
|
||||
_bool CGameInstance::isIn_WorldFrustum(_fvector vWorldPos, _float fRadius)
|
||||
{
|
||||
return m_pPipeLine->isIn_LocalFrustum(vWorldPos, fRadius);
|
||||
return m_pPipeLine->isIn_WorldFrustum(vWorldPos, fRadius);
|
||||
}
|
||||
|
||||
_bool CGameInstance::isIn_LocalFrustum(_fvector vLocalPos, _float fRadius)
|
||||
@@ -614,13 +614,17 @@ void CGameInstance::ReleaseController(_uint iControllerIndex)
|
||||
{
|
||||
m_pPhysX_Manager->ReleaseController(iControllerIndex);
|
||||
}
|
||||
void CGameInstance::Attach_Actor(CRigidBody& RigidBody, PSX::PxActor& Actor)
|
||||
void CGameInstance::Attach_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
m_pPhysX_Manager->Attach_Actor(RigidBody, Actor);
|
||||
m_pPhysX_Manager->Attach_Actor(Actor);
|
||||
}
|
||||
void CGameInstance::Detach_Actor(CRigidBody& RigidBody, PSX::PxActor*& pActor)
|
||||
void CGameInstance::Detach_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
m_pPhysX_Manager->Detach_Actor(RigidBody, pActor);
|
||||
m_pPhysX_Manager->Detach_Actor(Actor);
|
||||
}
|
||||
void CGameInstance::Release_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
m_pPhysX_Manager->Detach_Actor(Actor);
|
||||
}
|
||||
HRESULT CGameInstance::ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix)
|
||||
{
|
||||
|
||||
@@ -55,8 +55,6 @@ PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody_Dynamic& RigidB
|
||||
PSX::PxRigidBodyFlags pxRigidFlags = RigidBody.Get_RigidBodyFlags();
|
||||
pActorDynamic->setRigidBodyFlags(pxRigidFlags);
|
||||
|
||||
|
||||
|
||||
if (pxRigidFlags.isSet(PSX::PxRigidBodyFlag::eKINEMATIC)) {
|
||||
|
||||
}
|
||||
@@ -64,7 +62,7 @@ PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody_Dynamic& RigidB
|
||||
PSX::PxRigidBodyExt::updateMassAndInertia(*pActorDynamic, (PSX::PxReal)RigidBody.Get_Density());
|
||||
}
|
||||
|
||||
Attach_Actor(RigidBody, *pActorDynamic);
|
||||
m_pRestBodies.insert(pActorDynamic);
|
||||
|
||||
return pActorDynamic;
|
||||
}
|
||||
@@ -119,8 +117,8 @@ PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody_Static& RigidBody
|
||||
pShape->setContactOffset(RigidBody.Get_ContactOffset());
|
||||
pShape->setRestOffset(0.f);
|
||||
|
||||
|
||||
Attach_Actor(RigidBody, *pActor);
|
||||
m_pRestBodies.insert(pActor);
|
||||
Attach_Actor(*pActor);
|
||||
|
||||
return pActor;
|
||||
}
|
||||
@@ -223,44 +221,6 @@ HRESULT CPhysX_Manager::LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangle
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// 바이너리 로드에는 128B 정렬된 메모리 포인터를 넘겨야 함. InputData 그대로 넘기면 안됨
|
||||
// 심지어 바이너리로 불러온 블럭은 피직스의 모든 메시들을 릴리즈 한 뒤에 해제 해야 함
|
||||
//_bool CPhysX_Manager::LoadTriMeshes_Binary(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
|
||||
//{
|
||||
// filesystem::path pathPhysX = pPath;
|
||||
// pathPhysX.replace_extension(".bmap");
|
||||
//
|
||||
// PSX::PxSerializationRegistry* pSerializationRegistry = PSX::PxSerialization::createSerializationRegistry(*m_pPhysics);
|
||||
//
|
||||
// PSX::PxDefaultFileInputData InputData(pathPhysX.string().c_str());
|
||||
// PSX::PxCollection* extRefs = PxCreateCollection();
|
||||
//
|
||||
// PSX::PxCollection* pCollections = PSX::PxSerialization::createCollectionFromBinary(&InputData, *pSerializationRegistry, extRefs);
|
||||
// if (nullptr == pCollections) {
|
||||
// extRefs->release();
|
||||
// pSerializationRegistry->release();
|
||||
// assert(pCollections);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// const PSX::PxU32 iNumTriMeshes = pCollections->getNbObjects();
|
||||
// TriMeshes.reserve(iNumTriMeshes);
|
||||
// for (PSX::PxU32 i = 0; i < iNumTriMeshes; ++i) {
|
||||
// PSX::PxBase& pObject = pCollections->getObject(i);
|
||||
//
|
||||
// if (pObject.getConcreteType() == PSX::PxConcreteType::eTRIANGLE_MESH_BVH34) {
|
||||
// PSX::PxTriangleMesh* pTriMesh = static_cast<PSX::PxTriangleMesh*>(&pObject);
|
||||
// pTriMesh->acquireReference();
|
||||
// TriMeshes.push_back(pTriMesh);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// extRefs->release();
|
||||
// pCollections->release();
|
||||
// pSerializationRegistry->release();
|
||||
// return true;
|
||||
//}
|
||||
|
||||
PSX::PxTriangleMesh* CPhysX_Manager::Find_TriangleMesh(const _tchar* pMeshName)
|
||||
{
|
||||
map<_wstring, PSX::PxTriangleMesh*>::iterator iter = m_TriangleMeshes.find(pMeshName);
|
||||
@@ -272,18 +232,16 @@ PSX::PxTriangleMesh* CPhysX_Manager::Find_TriangleMesh(const _tchar* pMeshName)
|
||||
|
||||
void CPhysX_Manager::Update_Kinematic()
|
||||
{
|
||||
for (auto& pairBody : m_RigidBodys) {
|
||||
PSX::PxRigidDynamic* pActor = pairBody.second->is<PSX::PxRigidDynamic>();
|
||||
for (auto& pBody : m_pActiveBodys) {
|
||||
PSX::PxRigidDynamic* pActor = pBody->is<PSX::PxRigidDynamic>();
|
||||
if (nullptr == pActor) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pActor->getRigidBodyFlags() & PSX::PxRigidBodyFlag::eKINEMATIC)
|
||||
{
|
||||
CRigidBody* pBody = pairBody.first;
|
||||
const CTransform* pTransform = pBody->Get_TransformPtr();
|
||||
const CTransform* pTransform = static_cast<PhsXUserData*>(pBody->userData)->pOwner->Get_Component<CTransform>();
|
||||
|
||||
|
||||
pActor->setKinematicTarget(XMWorldToPx_NoScale(pTransform->Get_XMWorldMatrix()));
|
||||
}
|
||||
}
|
||||
@@ -321,10 +279,6 @@ void CPhysX_Manager::Update_Dynamic_ActiveActors()
|
||||
}
|
||||
CTransform* pTransform = pUserData->pOwner->Get_Component<CTransform>();
|
||||
|
||||
|
||||
// PSX::PxTransform pPrevPxTransform = pUserData->m_BeforeMatrix;
|
||||
// XMMatrixDecompose(nullptr, (_vector*)&pPrevPxTransform.q, (_vector*)&pPrevPxTransform.p, XMLoadFloat4x4(&pUserData->m_BeforeMatrix));
|
||||
|
||||
PSX::PxTransform pPxTransform = pActorDynamic->getGlobalPose();
|
||||
_float3 vOriginalScale = pTransform->Get_Scale();
|
||||
_matrix WorldMatrix = {};
|
||||
@@ -333,60 +287,58 @@ void CPhysX_Manager::Update_Dynamic_ActiveActors()
|
||||
pTransform->Set_WorldMatrix(WorldMatrix);
|
||||
}
|
||||
}
|
||||
//_uint iNumActor = (_uint)m_RigidBodys.size();
|
||||
//for (_uint i = 0; i < iNumActor; ++i) {
|
||||
//for (auto& pairBody : m_RigidBodys)
|
||||
// pairBody.second->userData
|
||||
//}
|
||||
}
|
||||
|
||||
//void CPhysX_Manager::Update_Dynamic_AllActors()
|
||||
//{
|
||||
// for (pair<CRigidBody*, PSX::PxActor*>& pairActors : m_RigidBodys) {
|
||||
// PSX::PxRigidDynamic* pActorDynamic = pairActors.second->is<PSX::PxRigidDynamic>();
|
||||
// if (nullptr != pActorDynamic) {
|
||||
// CTransform* pTransform = ((CRigidBody*)(pActorDynamic->userData))->Get_TransformPtr();
|
||||
//
|
||||
// PSX::PxTransform pxTransform = pActorDynamic->getGlobalPose();
|
||||
// _float3 vOriginalScale = pTransform->Get_Scale();
|
||||
// _matrix WorldMatrix = {};
|
||||
// WorldMatrix = XMMatrixAffineTransformation(XMLoadFloat3(&vOriginalScale), XMVectorZero(), XMLoadFloat4((_float4*)&pxTransform.q), XMLoadFloat3((_float3*)&pxTransform.p));
|
||||
// pTransform->Set_WorldMatrix(WorldMatrix);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
void CPhysX_Manager::ClearScene()
|
||||
{
|
||||
for (auto& pObject : m_RigidBodys) {
|
||||
pObject.second->release();
|
||||
} m_RigidBodys.clear();
|
||||
for (auto& pBody : m_pActiveBodys) {
|
||||
pBody->release();
|
||||
} m_pActiveBodys.clear();
|
||||
for (auto& pBody : m_pRestBodies) {
|
||||
pBody->release();
|
||||
} m_pRestBodies.clear();
|
||||
}
|
||||
void CPhysX_Manager::Attach_Actor(CRigidBody& RigidBody, PSX::PxActor& Actor)
|
||||
void CPhysX_Manager::Attach_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
if (m_pScene == nullptr){
|
||||
unordered_set<PSX::PxActor*>::iterator iter = m_pRestBodies.find(&Actor);
|
||||
if (m_pRestBodies.end() == iter) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_RigidBodys.emplace_back(&RigidBody, &Actor);
|
||||
m_pScene->addActor(Actor);
|
||||
else {
|
||||
m_pRestBodies.erase(&Actor);
|
||||
}
|
||||
m_pActiveBodys.insert(&Actor);
|
||||
if (m_pScene != nullptr) {
|
||||
m_pScene->addActor(Actor);
|
||||
}
|
||||
}
|
||||
|
||||
void CPhysX_Manager::Detach_Actor(CRigidBody& RigidBody, PSX::PxActor*& pActor)
|
||||
unordered_set<PSX::PxActor*>::iterator CPhysX_Manager::Detach_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
if (m_pScene == nullptr){
|
||||
return;
|
||||
}
|
||||
|
||||
list<pair<CRigidBody*, PSX::PxActor*>>::iterator iter = m_RigidBodys.begin();
|
||||
for (; iter != m_RigidBodys.end(); ++iter){
|
||||
if ((*iter).second == pActor) {
|
||||
m_RigidBodys.erase(iter);
|
||||
break;
|
||||
unordered_set<PSX::PxActor*>::iterator iterOut = m_pRestBodies.end();
|
||||
unordered_set<PSX::PxActor*>::iterator iter = m_pActiveBodys.find(&Actor);
|
||||
if (m_pActiveBodys.end() != iter) {
|
||||
m_pActiveBodys.erase(iter); // 액터를 활성화 맵에서 분리 해주고
|
||||
iterOut = m_pRestBodies.insert(&Actor).first; // 액터를 다시 쓸 수 있기 때문에 따로 보관해줌
|
||||
if (m_pScene != nullptr) {
|
||||
m_pScene->removeActor(Actor);
|
||||
}
|
||||
}
|
||||
|
||||
m_pScene->removeActor(*pActor);
|
||||
return iterOut;
|
||||
}
|
||||
|
||||
void CPhysX_Manager::Release_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
// 혹시 활성화 맵에 들어있을 수도 있으니 검사
|
||||
unordered_set<PSX::PxActor*>::iterator iterResult = Detach_Actor(Actor);
|
||||
if (m_pRestBodies.end() != iterResult) { // 방금 전까지만 해도 활성화 중이었던 액터 라면
|
||||
m_pRestBodies.erase(iterResult); // 바로 지워줌
|
||||
}
|
||||
else {
|
||||
m_pActiveBodys.erase(&Actor);
|
||||
m_pRestBodies.erase(&Actor);
|
||||
}
|
||||
Actor.release();
|
||||
}
|
||||
|
||||
PSX::PxController* CPhysX_Manager::Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc)
|
||||
@@ -442,7 +394,7 @@ HRESULT CPhysX_Manager::Initialize()
|
||||
}
|
||||
|
||||
if (FAILED(Connect_DebugServer())) {
|
||||
assert(false);
|
||||
ASSERT_NURI(false);
|
||||
}
|
||||
|
||||
{ // 씬 세팅
|
||||
@@ -581,9 +533,7 @@ CPhysX_Manager* CPhysX_Manager::Create(ID3D11Device* pDevice, ID3D11DeviceContex
|
||||
|
||||
void CPhysX_Manager::Free()
|
||||
{
|
||||
for (auto& pObjects : m_RigidBodys) {
|
||||
pObjects.second->release();
|
||||
} m_RigidBodys.clear();
|
||||
ClearScene();
|
||||
|
||||
for (auto& pMeshes : m_TriangleMeshes) {
|
||||
pMeshes.second->release();
|
||||
|
||||
@@ -44,7 +44,6 @@ void CPipeLine::Transform_Frustum_ToLocalSpace(_fmatrix WorldMatrixInverse)
|
||||
|
||||
_bool CPipeLine::isIn_WorldFrustum(_fvector vWorldPos, _float fRadius)
|
||||
{
|
||||
return true;
|
||||
for (size_t i = 0; i < 6; i++)
|
||||
{
|
||||
if (fRadius < XMVectorGetX(XMPlaneDotCoord(XMLoadFloat4(&m_vWorldPlanes[i]), vWorldPos)))
|
||||
@@ -56,7 +55,6 @@ _bool CPipeLine::isIn_WorldFrustum(_fvector vWorldPos, _float fRadius)
|
||||
|
||||
_bool CPipeLine::isIn_LocalFrustum(_fvector vLocalPos, _float fRadius)
|
||||
{
|
||||
return true;
|
||||
for (size_t i = 0; i < 6; i++)
|
||||
{
|
||||
if (fRadius < XMVectorGetX(XMPlaneDotCoord(XMLoadFloat4(&m_vLocalPlanes[i]), vLocalPos)))
|
||||
|
||||
@@ -93,7 +93,7 @@ HRESULT CRigidBody_Dynamic::Initialize(void* pArg)
|
||||
}
|
||||
#endif // _DEBUG
|
||||
m_tagData.pOwner = m_pOwner;
|
||||
XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
XMStoreFloat4x4(&m_tagData.BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
m_tagData.pBody = this;
|
||||
m_pRigidBody = m_pGameInstance->Add_DynamicActor(*this);
|
||||
m_pRigidBody->userData = &m_tagData;
|
||||
|
||||
@@ -31,7 +31,7 @@ HRESULT CRigidBody_Static::Initialize(void* pArg)
|
||||
return E_FAIL;
|
||||
}
|
||||
m_tagData.pOwner = m_pOwner;
|
||||
XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
XMStoreFloat4x4(&m_tagData.BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
m_tagData.pBody = this;
|
||||
m_pRigidBody = m_pGameInstance->Add_StaticActor(*this);
|
||||
m_pRigidBody->userData = &m_tagData;
|
||||
|
||||
@@ -50,6 +50,7 @@ class ENGINE_DLL CCharacter_Controller final :
|
||||
#ifdef _DEBUG
|
||||
virtual HRESULT Render() override;
|
||||
#endif
|
||||
PSX::PxRigidDynamic* Get_Actor();
|
||||
|
||||
_float Get_ContactOffset() const { return m_pController->getContactOffset(); }
|
||||
void Set_ContactOffset(_float fValue) { return m_pController->setContactOffset((PSX::PxF32)fValue); }
|
||||
|
||||
@@ -318,10 +318,10 @@ typedef struct tagVertexModelInstanceParticleDesc
|
||||
|
||||
typedef struct tagPhsXUserData {
|
||||
|
||||
PHYSX_KIND eKind = PHYSX_KIND::NOT_DEFINED;
|
||||
_uint iSubKind = UINT_MAX;
|
||||
class CGameObject* pOwner = { nullptr };
|
||||
_float4x4 m_BeforeMatrix = { };
|
||||
PHYSX_KIND eKind = PHYSX_KIND::NOT_DEFINED;
|
||||
class CGameObject* pOwner = { nullptr };
|
||||
_float4x4 BeforeMatrix = { };
|
||||
_uint iSubKind = UINT_MAX;
|
||||
|
||||
union {
|
||||
class CRigidBody* pBody;
|
||||
|
||||
@@ -193,8 +193,9 @@ class ENGINE_DLL CGameInstance final : public CBase
|
||||
PSX::PxController* Add_BoxController(PSX::PxBoxControllerDesc& Desc);
|
||||
PSX::PxController* Get_Controller(_uint iControllerIndex);
|
||||
void ReleaseController(_uint iControllerIndex);
|
||||
void Attach_Actor(CRigidBody& RigidBody, PSX::PxActor& Actor);
|
||||
void Detach_Actor(CRigidBody& RigidBody, PSX::PxActor*& pActor);
|
||||
void Attach_Actor(PSX::PxActor& Actor);
|
||||
void Detach_Actor(PSX::PxActor& pActor);
|
||||
void Release_Actor(PSX::PxActor& Actor);
|
||||
|
||||
HRESULT ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix = XMMatrixIdentity());
|
||||
HRESULT SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
|
||||
|
||||
@@ -36,10 +36,10 @@ class CPhysX_Manager final : public CBase
|
||||
|
||||
void Update(_float fTimeDelta);
|
||||
void ClearScene();
|
||||
void Attach_Actor(CRigidBody& RigidBody, PSX::PxActor& Actor);
|
||||
void Detach_Actor(CRigidBody& RigidBody, PSX::PxActor*& pActor);
|
||||
void Attach_Actor(PSX::PxActor& Actor);
|
||||
unordered_set<PSX::PxActor*>::iterator Detach_Actor(PSX::PxActor& Actor);
|
||||
void Release_Actor(PSX::PxActor& Actor);
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CHARACTER_CONTROLLER
|
||||
/* dev-treadmill.tistory.com/158 */
|
||||
|
||||
@@ -75,7 +75,8 @@ class CPhysX_Manager final : public CBase
|
||||
|
||||
|
||||
|
||||
list<pair<CRigidBody*, PSX::PxActor*>> m_RigidBodys = { };
|
||||
unordered_set<PSX::PxActor*> m_pActiveBodys = { };
|
||||
unordered_set<PSX::PxActor*> m_pRestBodies = { }; // 피직스의 액터로 구별되기 때문에 피직스액터 포인터를 키로 사용함
|
||||
map<_wstring, PSX::PxTriangleMesh*> m_TriangleMeshes = {};
|
||||
map<_wstring, PSX::PxTriangleMeshGeometry*> m_TriangleMeshGeometry = {};
|
||||
#ifdef 기무리
|
||||
|
||||
Reference in New Issue
Block a user