Merge branch 'Develope' into Bloom

This commit is contained in:
kimnuri
2025-11-26 23:02:00 +09:00
338 changed files with 3632 additions and 268 deletions
@@ -561,6 +561,36 @@ HRESULT CPhysX_Manager::Initialize()
// }
//}
#endif // 진우
#ifdef gimch
PlaneData.eKind = PHYSX_KIND::BODY_STATIC;
PlaneData.iSubKind = UINT_MAX;
PlaneData.pOwner = nullptr;
PlaneData.pBody = nullptr;
m_pMaterials.reserve(ENUM_CLASS(PXMATERIAL::END));
m_pMaterials.push_back(m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f));
PSX::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *m_pMaterials[ENUM_CLASS(PXMATERIAL::DEFAULT)]);
pGroundPlane->userData = &PlaneData;
pGroundPlane->setName("PHYSX_MANAGER_PLANE");
m_pScene->addActor(*pGroundPlane);;
//{
// float halfExtent = .5f;
// physx::PxShape* shape = m_pPhysics->createShape(physx::PxSphereGeometry(halfExtent), *pMaterial);
// physx::PxU32 size = 30;
// 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);
// }
// }
//}
#endif // 진우
#endif // EDITOR_PROJECT
#ifdef Bin
+3 -4
View File
@@ -30,11 +30,10 @@ void CQuadTree::Culling(CGameInstance* pGameInstance, const _float3* pVertexPosi
_bool isDraw[NEIGHBOR_END] = { true, true, true, true };
/* 이웃노드가 그려지는지 확인 */
for (size_t i = 0; i < NEIGHBOR_END; i++)
for (_uint i = 0; i < NEIGHBOR_END; i++)
{
if (nullptr != m_pNeighbors[i])
isDraw[i] = m_pNeighbors[i]->isDraw(pGameInstance, pVertexPositions);
}
/* 점들이 절두체 안에 있는지 확인 */
@@ -173,7 +172,7 @@ void CQuadTree::Culling(CGameInstance* pGameInstance, const _float3* pVertexPosi
/* Range 는 사각형의 중심에서 꼭짓점까지의 거리 */
_float fRange = XMVector3Length(XMLoadFloat3(&pVertexPositions[m_iCorners[CORNER_LT]]) - XMLoadFloat3(&pVertexPositions[m_iCenter])).m128_f32[0];
if (true == pGameInstance->isIn_LocalFrustum(XMLoadFloat3(&pVertexPositions[m_iCenter]), fRange * 1.5f))
if (true == pGameInstance->isIn_LocalFrustum(XMLoadFloat3(&pVertexPositions[m_iCenter]), fRange ))
{
for (size_t i = 0; i < CORNER_END; i++)
{
@@ -332,7 +331,7 @@ _bool CQuadTree::isDraw(CGameInstance* pGameInstance, const _float3* pVertexPosi
_vector vCamPos = XMLoadFloat4(pGameInstance->Get_CamPosition());
_vector vCenter = XMLoadFloat3(&pVertexPositions[m_iCenter]);
if (m_iCorners[CORNER_RT] - m_iCorners[CORNER_LT] < XMVectorGetX(XMVector3Length(vCamPos - vCenter)) * 0.04f)
if (m_iCorners[CORNER_RT] - m_iCorners[CORNER_LT] < XMVectorGetX(XMVector3Length(vCamPos - vCenter)) * 0.05f)
return true;
return false;
@@ -17,12 +17,15 @@ CVIBuffer_Terrain::CVIBuffer_Terrain(const CVIBuffer_Terrain& rhs)
, m_iNumVerticesX{ rhs.m_iNumVerticesX }
, m_iNumVerticesZ{ rhs.m_iNumVerticesZ }
, m_pQuadTree{ rhs.m_pQuadTree }
#ifdef EDITOR_PROJECT
, m_HeigthValues{ rhs.m_HeigthValues }
#endif
{
Safe_AddRef(m_pQuadTree);
}
HRESULT CVIBuffer_Terrain::Initialize_Prototype(const _char* pFilePath, _uint iSizeX, _uint iSizeZ)
#ifdef EDITOR_PROJECT
HRESULT CVIBuffer_Terrain::Initialize_Prototype(const _char* pFilePath)
{
_int iWidth = {};
_int iHeight = {};
@@ -215,6 +218,171 @@ HRESULT CVIBuffer_Terrain::Initialize_Prototype(const _char* pFilePath, _uint iS
return S_OK;
}
#endif
HRESULT CVIBuffer_Terrain::Initialize_Prototype(const _char* pFilePath, _uint iSizeX, _uint iSizeZ)
{
m_iNumVerticesX = iSizeX + 1;
m_iNumVerticesZ = iSizeZ + 1;
m_iNumVertices = m_iNumVerticesX * m_iNumVerticesZ;
_float* pPixels = new _float[m_iNumVertices];
ZeroMemory(pPixels, sizeof(_float) * m_iNumVertices);
#pragma region READ_DATA
string strFilePath = "../Bin/Resources/Data/Map/" + string(pFilePath);
ifstream in(strFilePath, ios::binary);
if (false == in.is_open())
{
MSG_BOX("Failed to Load Model Binanry File");
return E_FAIL;
}
for (_uint i = 0; i < m_iNumVerticesZ; ++i)
{
for (_uint j = 0; j < m_iNumVerticesX; ++j)
{
_uint iIndex = i * m_iNumVerticesX + j;
in.read(reinterpret_cast<_char*>(&pPixels[iIndex]), sizeof(_float));
}
}
in.close();
#pragma endregion
m_iNumVertexBuffers = 1;
m_iVertexStride = sizeof(VTXNORTEX);
m_iNumIndices = (m_iNumVerticesX - 1) * (m_iNumVerticesZ - 1) * 2 * 3;
m_iIndexStride = 4;
m_eIndexFormat = DXGI_FORMAT_R32_UINT;
m_ePrimitive = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
#pragma region VERTEX_BUFFER
D3D11_BUFFER_DESC VBDesc{};
VBDesc.ByteWidth = m_iVertexStride * m_iNumVertices;
VBDesc.Usage = D3D11_USAGE_STAGING;
VBDesc.BindFlags = 0;//D3D11_BIND_VERTEX_BUFFER;
VBDesc.StructureByteStride = m_iVertexStride;
VBDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ;
VBDesc.MiscFlags = 0;
VTXNORTEX* pVertices = new VTXNORTEX[m_iNumVertices];
ZeroMemory(pVertices, sizeof(VTXNORTEX) * m_iNumVertices);
m_pVertexPositions = new _float3[m_iNumVertices];
ZeroMemory(m_pVertexPositions, sizeof(_float3) * m_iNumVertices);
for (_uint i = 0; i < m_iNumVerticesZ; i++)
{
for (_uint j = 0; j < m_iNumVerticesX; j++)
{
_uint iIndex = i * m_iNumVerticesX + j;
m_pVertexPositions[iIndex] = pVertices[iIndex].vPosition = _float3(
(_float)j * m_iNumVerticesX / (m_iNumVerticesX - 1.f),
(_float)(pPixels[iIndex]),
(_float)i * m_iNumVerticesZ / (m_iNumVerticesZ - 1.f)
);
m_HeigthValues.push_back((_float)(pPixels[iIndex]));
pVertices[iIndex].vNormal = _float3(0.f, 0.f, 0.f);
pVertices[iIndex].vTexcoord = _float2((_float)j / (m_iNumVerticesX), (_float)i / m_iNumVerticesZ);
}
}
D3D11_SUBRESOURCE_DATA InitialVBData{};
InitialVBData.pSysMem = pVertices;
#pragma endregion
#pragma region INDEX_BUFFER
D3D11_BUFFER_DESC IBDesc{};
IBDesc.ByteWidth = m_iIndexStride * m_iNumIndices;
IBDesc.Usage = D3D11_USAGE_DYNAMIC;
IBDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
IBDesc.StructureByteStride = m_iIndexStride;
IBDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
IBDesc.MiscFlags = 0;
_uint* pIndices = new _uint[m_iNumIndices];
ZeroMemory(pIndices, sizeof(_uint) * m_iNumIndices);
_uint iNumIndices = {};
for (_uint i = 0; i < m_iNumVerticesZ - 1; i++)
{
for (_uint j = 0; j < m_iNumVerticesX - 1; j++)
{
_uint iIndex = i * m_iNumVerticesX + j;
_uint iIndices[4] = {
iIndex + m_iNumVerticesX,
iIndex + m_iNumVerticesX + 1,
iIndex + 1,
iIndex
};
_vector vSourDir, vDestDir, vNormal;
pIndices[iNumIndices++] = iIndices[0];
pIndices[iNumIndices++] = iIndices[1];
pIndices[iNumIndices++] = iIndices[2];
vSourDir = XMLoadFloat3(&pVertices[iIndices[1]].vPosition) - XMLoadFloat3(&pVertices[iIndices[0]].vPosition);
vDestDir = XMLoadFloat3(&pVertices[iIndices[2]].vPosition) - XMLoadFloat3(&pVertices[iIndices[1]].vPosition);
vNormal = XMVector3Normalize(XMVector3Cross(vSourDir, vDestDir));
XMStoreFloat3(&pVertices[iIndices[0]].vNormal, XMLoadFloat3(&pVertices[iIndices[0]].vNormal) + vNormal);
XMStoreFloat3(&pVertices[iIndices[1]].vNormal, XMLoadFloat3(&pVertices[iIndices[1]].vNormal) + vNormal);
XMStoreFloat3(&pVertices[iIndices[2]].vNormal, XMLoadFloat3(&pVertices[iIndices[2]].vNormal) + vNormal);
pIndices[iNumIndices++] = iIndices[0];
pIndices[iNumIndices++] = iIndices[2];
pIndices[iNumIndices++] = iIndices[3];
vSourDir = XMLoadFloat3(&pVertices[iIndices[2]].vPosition) - XMLoadFloat3(&pVertices[iIndices[0]].vPosition);
vDestDir = XMLoadFloat3(&pVertices[iIndices[3]].vPosition) - XMLoadFloat3(&pVertices[iIndices[2]].vPosition);
vNormal = XMVector3Normalize(XMVector3Cross(vSourDir, vDestDir));
XMStoreFloat3(&pVertices[iIndices[0]].vNormal, XMLoadFloat3(&pVertices[iIndices[0]].vNormal) + vNormal);
XMStoreFloat3(&pVertices[iIndices[2]].vNormal, XMLoadFloat3(&pVertices[iIndices[2]].vNormal) + vNormal);
XMStoreFloat3(&pVertices[iIndices[3]].vNormal, XMLoadFloat3(&pVertices[iIndices[3]].vNormal) + vNormal);
}
}
for (size_t i = 0; i < m_iNumVertices; i++)
{
XMStoreFloat3(&pVertices[i].vNormal,
XMVector3Normalize(XMLoadFloat3(&pVertices[i].vNormal)));
}
D3D11_SUBRESOURCE_DATA InitialIBData{};
InitialIBData.pSysMem = pIndices;
#pragma endregion
if (FAILED(m_pDevice->CreateBuffer(&VBDesc, &InitialVBData, &m_pVB)))
return E_FAIL;
if (FAILED(m_pDevice->CreateBuffer(&IBDesc, &InitialIBData, &m_pIB)))
return E_FAIL;
Safe_Delete_Array(pVertices);
Safe_Delete_Array(pIndices);
Safe_Delete_Array(pPixels);
m_pQuadTree = CQuadTree::Create(m_iNumVerticesX * m_iNumVerticesZ - m_iNumVerticesX, m_iNumVerticesX * m_iNumVerticesZ - 1, m_iNumVerticesX - 1, 0);
if (nullptr == m_pQuadTree)
return E_FAIL;
m_pQuadTree->SetUp_Neighbors();
return S_OK;
}
HRESULT CVIBuffer_Terrain::Initialize(void* pArg)
{
@@ -273,6 +441,41 @@ void CVIBuffer_Terrain::FitY(_fmatrix WorldMatrix, _float fY)
m_pContext->Unmap(m_pVB, 0);
}
HRESULT CVIBuffer_Terrain::Load_HeightMap(const _char* pFilePath)
{
string strFilePath = "../Bin/Resources/Data/Map/" + string(pFilePath);
ifstream in(strFilePath, ios::binary);
if (false == in.is_open())
{
MSG_BOX("Failed to Load Model Binanry File");
return E_FAIL;
}
D3D11_MAPPED_SUBRESOURCE SubResource{};
m_pContext->Map(m_pVB, 0, D3D11_MAP_WRITE, 0, &SubResource);
VTXNORTEX* pVertices = static_cast<VTXNORTEX*>(SubResource.pData);
for (_uint i = 0; i < m_iNumVerticesZ; ++i)
{
for (_uint j = 0; j < m_iNumVerticesX; ++j)
{
_uint iIndex = i * m_iNumVerticesX + j;
in.read(reinterpret_cast<_char*>(&pVertices[iIndex].vPosition.y), sizeof(_float));
}
}
in.close();
m_pContext->Unmap(m_pVB, 0);
return S_OK;
}
#ifdef EDITOR_PROJECT
void CVIBuffer_Terrain::Change_HeigthRatio(_float fRatio)
{
D3D11_MAPPED_SUBRESOURCE SubResource{};
@@ -288,7 +491,6 @@ void CVIBuffer_Terrain::Change_HeigthRatio(_float fRatio)
m_pContext->Unmap(m_pVB, 0);
}
#ifdef _DEBUG
void CVIBuffer_Terrain::Set_CullingRadius(_float fRaduis)
{
@@ -330,40 +532,22 @@ HRESULT CVIBuffer_Terrain::Save_HeightMap(const _char* pFilePath)
return S_OK;
}
#endif // EDITOR_PROJECT
HRESULT CVIBuffer_Terrain::Load_HeightMap(const _char* pFilePath)
#ifdef EDITOR_PROJECT
CVIBuffer_Terrain* CVIBuffer_Terrain::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pFilePath)
{
string strFilePath = "../Bin/Resources/Data/Map/" + string(pFilePath);
CVIBuffer_Terrain* pInstance = new CVIBuffer_Terrain(pDevice, pContext);
ifstream in(strFilePath, ios::binary);
if (false == in.is_open())
if (FAILED(pInstance->Initialize_Prototype(pFilePath)))
{
MSG_BOX("Failed to Load Model Binanry File");
return E_FAIL;
MSG_BOX("Failed to Created : CVIBuffer_Terrain");
Safe_Release(pInstance);
}
D3D11_MAPPED_SUBRESOURCE SubResource{};
m_pContext->Map(m_pVB, 0, D3D11_MAP_WRITE, 0, &SubResource);
VTXNORTEX* pVertices = static_cast<VTXNORTEX*>(SubResource.pData);
for (_uint i = 0; i < m_iNumVerticesZ; ++i)
{
for (_uint j = 0; j < m_iNumVerticesX; ++j)
{
_uint iIndex = i * m_iNumVerticesX + j;
in.read(reinterpret_cast<_char*>(&pVertices[iIndex].vPosition.y), sizeof(_float));
}
}
in.close();
m_pContext->Unmap(m_pVB, 0);
return S_OK;
return pInstance;
}
#endif // _DEBUG
#endif // EDITOR_PROJECT
CVIBuffer_Terrain* CVIBuffer_Terrain::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pFilePath, _uint iSizeX, _uint iSizeZ)
{
@@ -89,6 +89,10 @@ class CPhysX_Manager final : public CBase
#ifdef 진우
PhsXUserData PlaneData = {};
#endif // 기무리
#ifdef gimch
PhsXUserData PlaneData = {};
#endif // 기무리
#ifdef Bin
@@ -19,19 +19,24 @@ class ENGINE_DLL CVIBuffer_Terrain final : public CVIBuffer
_float2 Get_Size() { return _float2((_float)m_iNumVerticesX, (_float)m_iNumVerticesZ); }
public:
#ifdef EDITOR_PROJECT
virtual HRESULT Initialize_Prototype(const _char* pFilePath);
#endif // EDITOR_PROJECT
virtual HRESULT Initialize_Prototype(const _char* pFilePath, _uint iSizeX, _uint iSizeZ);
virtual HRESULT Initialize(void* pArg);
_bool Picking(_fmatrix WorldMatrix, _float3* pOut);
void Culling(_fmatrix WorldMatrix);
void FitY(_fmatrix WorldMatrix, _float fY);
void Change_HeigthRatio(_float fRatio);
#ifdef _DEBUG
HRESULT Load_HeightMap(const _char* pFilePath);
#ifdef EDITOR_PROJECT
void Change_HeigthRatio(_float fRatio);
void Set_CullingRadius(_float fRaduis);
HRESULT Save_HeightMap(const _char* pFilePath);
HRESULT Load_HeightMap(const _char* pFilePath);
#endif // _DEBUG
#endif
private:
@@ -44,6 +49,9 @@ class ENGINE_DLL CVIBuffer_Terrain final : public CVIBuffer
class CQuadTree* m_pQuadTree = { nullptr };
public:
#ifdef EDITOR_PROJECT
static CVIBuffer_Terrain* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pFilePath);
#endif // EDITOR_PROJECT
static CVIBuffer_Terrain* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pFilePath, _uint iSizeX, _uint iSizeZ);
virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr) override;
virtual void Free() override;