[add] Desc PhysX Scene
This commit is contained in:
@@ -62,6 +62,11 @@ HRESULT CCharacter_Controller::Render()
|
||||
|
||||
#endif // _DEBUG
|
||||
|
||||
void CCharacter_Controller::Resize_Volume(_float fHeight)
|
||||
{
|
||||
m_pController->resize(fHeight);
|
||||
}
|
||||
|
||||
void CCharacter_Controller::Modify_Volume(_float3 fVolume)
|
||||
{
|
||||
switch (m_eBodyType)
|
||||
@@ -129,18 +134,13 @@ _float3 CCharacter_Controller::Get_Volume()
|
||||
|
||||
void CCharacter_Controller::Move(_float fTimeDelta)
|
||||
{
|
||||
PSX::PxVec3 pxVecMomentum = {}; // 순간 이동량
|
||||
_float fMinimumDistant = FLT_EPSILON3; // 이동량 오차 허용치, ( 크면 클수록 이동이 더 일찍 끝난다, 순간 이동량보다 같거나 더 크면 안움직일듯? )
|
||||
_vector vMomentum = m_pTransform->Get_CurrentMomentum();
|
||||
XMStoreFloat3((_float3*)&pxVecMomentum, vMomentum);
|
||||
|
||||
PSX::PxControllerFilters pxFilter = {}; // 충돌 대상 필터
|
||||
const PSX::PxObstacleContext* pPxObstacles = { nullptr }; // 캐릭터가 충돌해야할 추가적인 장애물 객체?, 닿은 장애물은 캐시된다?
|
||||
PSX::PxVec3 pxVecMomentum = {}; // 순간 이동량
|
||||
_float fMinimumDistant = FLT_EPSILON3; // 이동량 오차 허용치, ( 크면 클수록 이동이 더 일찍 끝난다, 순간 이동량보다 같거나 더 크면 안움직일듯? )
|
||||
PSX::PxControllerFilters pxFilter = {}; // 충돌 대상 필터
|
||||
const PSX::PxObstacleContext* pPxObstacles = { nullptr }; // 캐릭터가 충돌해야할 추가적인 장애물 객체?, 닿은 장애물은 캐시된다?
|
||||
|
||||
XMStoreFloat3((_float3*)&pxVecMomentum, m_pTransform->Get_CurrentMomentum());
|
||||
|
||||
// eCOLLISION_SIDES = (1 << 0), //!< Character is colliding to the sides.
|
||||
// eCOLLISION_UP = (1 << 1), //!< Character has collision above.
|
||||
// eCOLLISION_DOWN = (1 << 2) //!< Character has collision below.
|
||||
m_eBeforeCollisionFlags = m_pController->move(pxVecMomentum, fMinimumDistant, fTimeDelta, pxFilter, pPxObstacles);
|
||||
|
||||
|
||||
@@ -171,11 +171,6 @@ _float3 CCharacter_Controller::Get_FootPosition()
|
||||
return { (_float)pxLVecfootPos.x, (_float)pxLVecfootPos.y, (_float)pxLVecfootPos.z };
|
||||
}
|
||||
|
||||
void CCharacter_Controller::Resize_Volume(_float fHeight)
|
||||
{
|
||||
m_pController->resize(fHeight);
|
||||
}
|
||||
|
||||
HRESULT CCharacter_Controller::Initialize_Prototype()
|
||||
{
|
||||
return S_OK;
|
||||
@@ -184,9 +179,19 @@ HRESULT CCharacter_Controller::Initialize_Prototype()
|
||||
HRESULT CCharacter_Controller::Initialize(void* pArg)
|
||||
{
|
||||
Character_Controller_DESC* pDesc = static_cast<Character_Controller_DESC*>(pArg);
|
||||
m_eBodyType = pDesc->eBodyType;
|
||||
m_bAutoStepping = pDesc->bAutoStepping;
|
||||
m_pTransform = pDesc->pTransform;
|
||||
{ // Character_Controller_DESC
|
||||
m_eBodyType = pDesc->eBodyType;
|
||||
m_bAutoStepping = pDesc->bAutoStepping;
|
||||
m_pTransform = pDesc->pTransform;
|
||||
|
||||
}
|
||||
{ // PhsXUserData
|
||||
m_tagData.eKind = PHYSX_KIND::CCTActor;
|
||||
m_tagData.pOwner = m_pOwner;
|
||||
XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
m_tagData.pCharacter = this;
|
||||
}
|
||||
|
||||
|
||||
switch (m_eBodyType)
|
||||
{
|
||||
@@ -199,10 +204,7 @@ HRESULT CCharacter_Controller::Initialize(void* pArg)
|
||||
Desc.contactOffset = pDesc->fContactOffset;
|
||||
Desc.material = m_pGameInstance->Get_Material(&pDesc->fMaterial);
|
||||
m_pController = m_pGameInstance->Add_BoxController(Desc);
|
||||
#ifdef _DEBUG
|
||||
_float3 vVolume = Get_Volume();
|
||||
m_pMainShape = (GeometricPrimitive::CreateBox(m_pContext, vVolume, false, false));
|
||||
#endif // _DEBUG
|
||||
m_pController->setUserData(&m_tagData);
|
||||
} break;
|
||||
case Engine::ACTOR::CAPSULE:
|
||||
{
|
||||
@@ -213,26 +215,52 @@ HRESULT CCharacter_Controller::Initialize(void* pArg)
|
||||
Desc.contactOffset = pDesc->fContactOffset;
|
||||
Desc.material = m_pGameInstance->Get_Material(&pDesc->fMaterial);
|
||||
m_pController = m_pGameInstance->Add_CapsuleController(Desc);
|
||||
#ifdef _DEBUG
|
||||
_float3 vVolume = Get_Volume();
|
||||
m_pSubShape = (GeometricPrimitive::CreateSphere(m_pContext, vVolume.x, 10, false, false));
|
||||
m_pMainShape = (GeometricPrimitive::CreateCylinder(m_pContext, vVolume.y, vVolume.x, 10, false));
|
||||
#endif // _DEBUG
|
||||
m_pController->setUserData(&m_tagData);
|
||||
} break;
|
||||
default:
|
||||
assert(false); // PhysX에서 불가능
|
||||
return E_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (nullptr == m_pController) {
|
||||
assert(false);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_pController->setSlopeLimit(m_fSlopeLimit);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (FAILED(Debug_Initialize())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
HRESULT CCharacter_Controller::Debug_Initialize()
|
||||
{
|
||||
_float3 vVolume = Get_Volume();
|
||||
switch (m_eBodyType)
|
||||
{
|
||||
case ACTOR::BOX:
|
||||
m_pMainShape = (GeometricPrimitive::CreateBox(m_pContext, vVolume, false, false));
|
||||
break;
|
||||
case ACTOR::CAPSULE:
|
||||
m_pMainShape = (GeometricPrimitive::CreateCylinder(m_pContext, vVolume.y, vVolume.x, 10, false));
|
||||
m_pSubShape = (GeometricPrimitive::CreateSphere(m_pContext, vVolume.x, 10, false, false));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
_bool CCharacter_Controller::Check_Overlap()
|
||||
{
|
||||
return _bool();
|
||||
@@ -295,6 +323,7 @@ void CCharacter_Controller::Describe_Entity()
|
||||
if (GUI::SliderFloat("StepOffset", &fStepOffset, 0.f, 3.f, "%.2f")) {
|
||||
m_pController->setStepOffset(fStepOffset);
|
||||
} GUIHelpMarker("In stepped regions, the tolerance height the controller can climb.\n Capsule behaves slightly differently.");
|
||||
|
||||
if (ACTOR::CAPSULE == m_eBodyType) {
|
||||
PSX::PxCapsuleController* pController = (PSX::PxCapsuleController*)m_pController;
|
||||
|
||||
@@ -317,6 +346,7 @@ void CCharacter_Controller::Describe_Entity()
|
||||
GUIHelpMarker("A capsule is affected by its lower sphere and tends to generate an up vector on steps.\nIn eEASY, the up vector is combined with the step offset, allowing easier climbing; in eCONSTRAINED, the up vector is removed during step detection and only the step offset is used.");
|
||||
}
|
||||
}
|
||||
|
||||
if (GUI::SliderFloat3("Volume", (_float*)&vVolume, 0.1f, 10.f, "%.2f")) {
|
||||
Modify_Volume(vVolume);
|
||||
}GUIHelpMarker("Box uses vSize; Capsule uses x->fRadius, y->fHeight.\nThe capsule's fHeight is likely the distance from the lower sphere center to the upper sphere center.");
|
||||
|
||||
@@ -573,11 +573,11 @@ void CGameInstance::RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTr
|
||||
return m_pPhysX_Manager->RegistTriMesh(pName, pPxTriMesh);
|
||||
}
|
||||
|
||||
const PSX::PxRigidDynamic* CGameInstance::Add_DynamicActor(CRigidBody& RigidBody)
|
||||
PSX::PxRigidDynamic* CGameInstance::Add_DynamicActor(CRigidBody& RigidBody)
|
||||
{
|
||||
return m_pPhysX_Manager->Add_DynamicActor(RigidBody);
|
||||
}
|
||||
const PSX::PxRigidStatic* CGameInstance::Add_StaticActor(CRigidBody& RigidBody)
|
||||
PSX::PxRigidStatic* CGameInstance::Add_StaticActor(CRigidBody& RigidBody)
|
||||
{
|
||||
return m_pPhysX_Manager->Add_StaticActor(RigidBody);
|
||||
}
|
||||
|
||||
@@ -28,15 +28,13 @@ CPhysX_Manager::CPhysX_Manager(ID3D11Device* pDevice, ID3D11DeviceContext* pCont
|
||||
SAFE_ADDREF(m_pGameInstance);
|
||||
}
|
||||
|
||||
const PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody& RigidBody)
|
||||
PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody& RigidBody)
|
||||
{
|
||||
_matrix WorldMatrix = RigidBody.Get_TransformPtr()->Get_XMWorldMatrix();
|
||||
PSX::PxTransform pxWorldMatrix = XMWorldToPx_NoScale(WorldMatrix);
|
||||
|
||||
// PxRigidDynamic 씬의 동적 바디 인터페이스
|
||||
PSX::PxRigidDynamic* pActorDynamic = m_pPhysics->createRigidDynamic(pxWorldMatrix);
|
||||
pActorDynamic->userData = &RigidBody;
|
||||
|
||||
PSX::PxShape* pShape = nullptr;
|
||||
PSX::PxGeometryHolder geoHolder = {};
|
||||
|
||||
@@ -84,15 +82,13 @@ const PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody& RigidBod
|
||||
return pActorDynamic;
|
||||
}
|
||||
|
||||
const PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody& RigidBody)
|
||||
PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody& RigidBody)
|
||||
{
|
||||
_matrix WorldMatrix = RigidBody.Get_TransformPtr()->Get_XMWorldMatrix();
|
||||
PSX::PxTransform pxWorldMatrix = XMWorldToPx_NoScale(WorldMatrix);
|
||||
|
||||
// PxRigidStatic 씬의 정적 바디 인터페이스
|
||||
PSX::PxRigidStatic* pActor = m_pPhysics->createRigidStatic(pxWorldMatrix);
|
||||
pActor->userData = &RigidBody;
|
||||
|
||||
PSX::PxShape* pShape = { nullptr };
|
||||
PSX::PxTriangleMesh* pPxMesh = Find_TriangleMesh(RigidBody.Get_PxMeshKey());
|
||||
PSX::PxTriangleMeshGeometry* pPxMeshGeometry = { nullptr };
|
||||
@@ -330,15 +326,18 @@ void CPhysX_Manager::Update_Dynamic_ActiveActors()
|
||||
PSX::PxActor** ppActiveActors = m_pScene->getActiveActors(iNumActiveActor);
|
||||
|
||||
for (PSX::PxU32 i = 0; i < iNumActiveActor; ++i) {
|
||||
PhsXUserData* pUserData = (PhsXUserData*)ppActiveActors[i]->userData;
|
||||
PSX::PxRigidDynamic* pActorDynamic = ppActiveActors[i]->is<PSX::PxRigidDynamic>();
|
||||
|
||||
if (nullptr != pActorDynamic) {
|
||||
if (nullptr == ppActiveActors[i]->userData) {
|
||||
continue;
|
||||
}
|
||||
CTransform* pTransform = ((CRigidBody*)ppActiveActors[i]->userData)->Get_TransformPtr();
|
||||
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 pPrevPxTransform;
|
||||
PSX::PxTransform pPxTransform = pActorDynamic->getGlobalPose();
|
||||
_float3 vOriginalScale = pTransform->Get_Scale();
|
||||
_matrix WorldMatrix = {};
|
||||
@@ -354,21 +353,21 @@ void CPhysX_Manager::Update_Dynamic_ActiveActors()
|
||||
//}
|
||||
}
|
||||
|
||||
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::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()
|
||||
{
|
||||
@@ -433,7 +432,6 @@ HRESULT CPhysX_Manager::Initialize()
|
||||
assert(false);
|
||||
}
|
||||
|
||||
|
||||
{ // 씬 세팅
|
||||
m_ToleranceScale.length = 1.f; // 1 meter
|
||||
m_ToleranceScale.speed = GRAVITY; //
|
||||
@@ -453,17 +451,41 @@ HRESULT CPhysX_Manager::Initialize()
|
||||
return E_FAIL;
|
||||
}
|
||||
sceneDesc.cpuDispatcher = m_pDispatcher;
|
||||
sceneDesc.filterShader = PSX::PxDefaultSimulationFilterShader; // 레이어 충돌, 오브젝트에 속성을 주고 복잡한 필터링 충돌 식
|
||||
sceneDesc.flags =
|
||||
PSX::PxSceneFlag::eENABLE_PCM // 기본 true, 현대적인 충돌시스템 적용
|
||||
| PSX::PxSceneFlag::eENABLE_ACTIVE_ACTORS // 현재 움직임이 있는 액터만 가져옴
|
||||
| PSX::PxSceneFlag::eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS // 그중에 키네틱은 뺌
|
||||
| PSX::PxSceneFlag::eENABLE_CCD // CCD 기본플래그, 키면 비쌈. 단일오브젝트만 켤 수 있으니 선택적으로 고려
|
||||
| PSX::PxSceneFlag::eDISABLE_CCD_RESWEEP // CCD 옵션플래그, 정확도 낮추고 비용 아낌
|
||||
//| PSX::PxSceneFlag::eDISABLE_CONTACT_REPORT_BUFFER_RESIZE // 접촉 리포트버퍼 리사이즈 금지 -> 보통 끔
|
||||
//| PSX::PxSceneFlag::eDISABLE_CONTACT_CACHE // 접촉 캐시를 금지 -> 그냥 켜두자, 캐시 있는게 보통 더 낫다
|
||||
//| PSX::PxSceneFlag::eREQUIRE_RW_LOCK // 멀티스레딩 환경에서 혹시라도 락 걸고 접근하지 않아 발생할 일을 제거,
|
||||
//| PSX::PxSceneFlag::eENABLE_STABILIZATION // 물체가 얽힌 상황에서 불안정한걸 방지. 추가비용인듯
|
||||
//| PSX::PxSceneFlag::eENABLE_AVERAGE_POINT // 이해 못하겠음
|
||||
//| PSX::PxSceneFlag::eEnable_GPU_Dynamics // 피직스 그래픽가속 설정. 여기선 세팅 안돼서 비활성화ㅏ
|
||||
//| PSX::PxSceneFlag::eEnable_Direct_GPU_API // 직접 그래픽버퍼를 다루게끔 설정
|
||||
//| PSX::PxSceneFlag::eEnable_Enhanced_Determinism // 중간에 액터 추가해도 결과가 바뀌지 않는 결정론 수준 향상, 리플레이기능 ㅇㅇ
|
||||
//| PSX::PxSceneFlag::eENABLE_FRICTION_EVERY_ITERATION // 마찰 꼐산 추가
|
||||
//| PSX::PxSceneFlag::eENABLE_EXTERNAL_FORCES_EVERY_ITERATION_TGS // 중력 나눠서 여러번 적용
|
||||
//| PSX::PxSceneFlag::eENABLE_PCM // 기본 true
|
||||
//| PSX::PxSceneFlag::eENABLE_BODY_ACCELERATIONS // 선형 각가속도 값을 쿼리가능하도록 설정
|
||||
//| PSX::PxSceneFlag::eEnable_solver_residual_reporting // 고급 디버깅, 연구 용
|
||||
//| PSX::PxSceneFlag::eSOLVE_ARTICULATION_CONTACT_LAST 물리 관절 처리 시나리오 순서 변경
|
||||
;
|
||||
|
||||
sceneDesc.filterShader = PSX::PxDefaultSimulationFilterShader;
|
||||
|
||||
sceneDesc.flags = PSX::PxSceneFlag::eENABLE_PCM | PSX::PxSceneFlag::eENABLE_CCD| PSX::PxSceneFlag::eENABLE_ACTIVE_ACTORS | PSX::PxSceneFlag::eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS;
|
||||
if (false == sceneDesc.isValid()) {
|
||||
assert(false);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_pScene = m_pPhysics->createScene(sceneDesc);
|
||||
|
||||
// CCT
|
||||
m_pCCTManager = PxCreateControllerManager(*m_pScene);
|
||||
m_pCCTManager->setOverlapRecoveryModule(false);
|
||||
m_pCCTManager->setOverlapRecoveryModule(true); // 복구모듈은 하이트필드에는 적용되지 않음, 오직 스태틱만 대상
|
||||
m_pCCTManager->setPreciseSweeps(true); // 정밀 스윕
|
||||
m_pCCTManager->setPreventVerticalSlidingAgainstCeiling(false); // 천장타고 슬라이딩 허용 비허용
|
||||
}
|
||||
|
||||
// 디버그서버의 클라 세팅
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "pch.h"
|
||||
#include "pch.h"
|
||||
#include "RigidBody.h"
|
||||
#include "GameInstance.h"
|
||||
#include "GameObject.h"
|
||||
@@ -63,11 +63,6 @@ HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc)
|
||||
m_fContactOffset = Desc.fContactOffset;
|
||||
m_vhalfGeometryInfo = Desc.vhalfGeometryInfo;
|
||||
m_fDensity = Desc.fDensity;
|
||||
#ifdef _DEBUG
|
||||
if (FAILED(Add_DebugShape())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@@ -102,13 +97,63 @@ HRESULT CRigidBody::Initialize(void* pArg)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Initialize_UserData();
|
||||
m_pRigidBody->userData = &m_tagData;
|
||||
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
Add_DebugShape();
|
||||
if (FAILED(Add_DebugShape())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CRigidBody::Initialize_UserData()
|
||||
{
|
||||
|
||||
switch (m_eActorType)
|
||||
{
|
||||
case Engine::ACTOR::BOX:
|
||||
m_tagData.eKind = PHYSX_KIND::BODY_DYNAMIC;
|
||||
m_tagData.pOwner = m_pOwner;
|
||||
XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
m_tagData.pBody = this;
|
||||
break;
|
||||
case Engine::ACTOR::CAPSULE:
|
||||
m_tagData.eKind = PHYSX_KIND::BODY_DYNAMIC;
|
||||
m_tagData.pOwner = m_pOwner;
|
||||
XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
m_tagData.pBody = this;
|
||||
break;
|
||||
case Engine::ACTOR::SPHERE:
|
||||
m_tagData.eKind = PHYSX_KIND::BODY_DYNAMIC;
|
||||
m_tagData.pOwner = m_pOwner;
|
||||
XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
m_tagData.pBody = this;
|
||||
break;
|
||||
case Engine::ACTOR::PLANE:
|
||||
break;
|
||||
case Engine::ACTOR::TRIANGLEMESH:
|
||||
m_tagData.eKind = PHYSX_KIND::BODY_STATIC;
|
||||
m_tagData.pOwner = m_pOwner;
|
||||
XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
m_tagData.pBody = this;
|
||||
break;
|
||||
case Engine::ACTOR::HEIGHTFIELD:
|
||||
break;
|
||||
case Engine::ACTOR::END:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
HRESULT CRigidBody::Add_DebugShape()
|
||||
{
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
NS_BEGIN(Engine)
|
||||
class CTransform;
|
||||
class ENGINE_DLL CCharacter_Controller final :
|
||||
public CComponent
|
||||
public CComponent,
|
||||
{
|
||||
/* dev-treadmill.tistory.com/158 */
|
||||
/* dev-treadmill.tistory.com/159 */
|
||||
// 기본적으로 아무 힘도 받지 않는, 주지 않는 놈임
|
||||
// kinematic 기반임
|
||||
public:
|
||||
#pragma region STRUCT
|
||||
struct CapsuleInfo
|
||||
@@ -33,7 +35,7 @@ class ENGINE_DLL CCharacter_Controller final :
|
||||
|
||||
union
|
||||
{
|
||||
_float3 vBoxSize; // 박스는 AABB임
|
||||
_float3 vBoxSize; // CCT박스는 회전없는 AABB임
|
||||
CapsuleInfo tCapsuleInfo;
|
||||
};
|
||||
}Character_Controller_DESC;
|
||||
@@ -42,21 +44,21 @@ class ENGINE_DLL CCharacter_Controller final :
|
||||
CCharacter_Controller(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
CCharacter_Controller(const CCharacter_Controller& rhs);
|
||||
virtual ~CCharacter_Controller() = default;
|
||||
|
||||
public:
|
||||
#ifdef _DEBUG
|
||||
virtual HRESULT Render() override;
|
||||
#endif
|
||||
|
||||
_float Get_ContactOffset() const { return m_pController->getContactOffset(); }
|
||||
void Set_ContactOffset(_float fValue) const { return m_pController->setContactOffset((PSX::PxF32)fValue); }
|
||||
void Set_ContactOffset(_float fValue) { return m_pController->setContactOffset((PSX::PxF32)fValue); }
|
||||
|
||||
void Move(_float fTimeDelta); // 이동
|
||||
void Move(_float fTimeDelta); // 이동 // 충돌보정만 있음,
|
||||
void Set_Position(_fvector vNewPos); // 순간이동
|
||||
_vector Get_Position();
|
||||
_float3 Get_FootPosition(); // ContactOffset이 고려된 발바닥 위치( 실제보다 더 아래에 위치한다는 뜻 )
|
||||
_float3 Get_FootPosition(); // ContactOffset이 고려된 발바닥 위치( 실제보다 바닥 위치가 더 아래에 위치한다는 뜻 )
|
||||
|
||||
|
||||
void Resize_Volume(_float fHeight); // 높이를 수정하고 바닥에 붙임
|
||||
void Resize_Volume(_float fHeight); // 높이를 수정하고 바닥에 붙임
|
||||
void Modify_Volume(_float3 fVolume);
|
||||
_float3 Get_Volume();
|
||||
|
||||
@@ -65,12 +67,12 @@ class ENGINE_DLL CCharacter_Controller final :
|
||||
PSX::PxController* m_pController = { nullptr };
|
||||
CTransform* m_pTransform = { nullptr };
|
||||
_bool m_bAutoStepping = { false };
|
||||
_float m_fSlopeLimit = { 0.f }; // cosf
|
||||
_float m_fSlopeLimit = { 0.f }; // cosf각도, 오르막 경사각 제한. ( 추가설정 필요함 )
|
||||
PhsXUserData m_tagData = {};
|
||||
|
||||
|
||||
function<void()> m_funcHitCallback = { nullptr };
|
||||
function<void()> m_funcBehaviorCallback = { nullptr };
|
||||
PSX::PxControllerCollisionFlags m_eBeforeCollisionFlags = {};;
|
||||
function<void()> m_funcHitCallback = { nullptr };
|
||||
function<void()> m_funcBehaviorCallback = { nullptr };
|
||||
PSX::PxControllerCollisionFlags m_eBeforeCollisionFlags = {};
|
||||
#ifdef _DEBUG
|
||||
unique_ptr<GeometricPrimitive> m_pMainShape = { nullptr };
|
||||
unique_ptr<GeometricPrimitive> m_pSubShape = { nullptr };
|
||||
@@ -79,6 +81,10 @@ class ENGINE_DLL CCharacter_Controller final :
|
||||
private:
|
||||
virtual HRESULT Initialize_Prototype() override;
|
||||
virtual HRESULT Initialize(void* pArg) override;
|
||||
#ifdef _DEBUG
|
||||
virtual HRESULT Debug_Initialize();
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
_bool Check_Overlap();
|
||||
|
||||
|
||||
@@ -73,11 +73,11 @@ enum aiTextureType {
|
||||
#endif // !EDITOR_PROJECT
|
||||
|
||||
enum class PHYSX_KIND {
|
||||
NOT_DEFINED = 0,
|
||||
CCTActor = 1,
|
||||
OBSTACLEActor = 2,
|
||||
BODY_STATIC = 3,
|
||||
BODY_DYNAMIC = 4,
|
||||
NOT_DEFINED,
|
||||
BODY_STATIC,
|
||||
BODY_DYNAMIC,
|
||||
CCTActor,
|
||||
OBSTACLEActor,
|
||||
};
|
||||
|
||||
NS_END
|
||||
|
||||
@@ -322,4 +322,4 @@ typedef struct tagPhsXUserData {
|
||||
};
|
||||
}PhsXUserData;
|
||||
|
||||
NS_END
|
||||
NS_END
|
||||
|
||||
@@ -181,8 +181,8 @@ class ENGINE_DLL CGameInstance final : public CBase
|
||||
#pragma region PhysX_Manager
|
||||
PSX::PxMaterial* Get_Material(_float3* vMatInfo);
|
||||
void RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh);
|
||||
const PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody);
|
||||
const PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody);
|
||||
PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody);
|
||||
PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody);
|
||||
|
||||
|
||||
PSX::PxController* Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
|
||||
@@ -20,8 +20,8 @@ class CPhysX_Manager final : public CBase
|
||||
// HRESULT Update_RegionOfInterest(); ( 충돌 컬링, 필터링도 검색해야함 )
|
||||
// Aggregate ( 충돌 그룹, 이 그룹끼리는 서로 충돌검사를 하지 않음, 지형, 레그돌 등 )
|
||||
|
||||
const PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody);
|
||||
const PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody);
|
||||
PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody);
|
||||
PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody);
|
||||
|
||||
void RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh);
|
||||
PSX::PxMaterial* Create_Material(const _float3* vMatInfo);
|
||||
@@ -34,7 +34,6 @@ class CPhysX_Manager final : public CBase
|
||||
|
||||
void Update(_float fTimeDelta);
|
||||
void ClearScene();
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CHARACTER_CONTROLLER
|
||||
@@ -83,7 +82,7 @@ class CPhysX_Manager final : public CBase
|
||||
HRESULT Connect_DebugServer();
|
||||
void Update_Kinematic();
|
||||
void Update_Dynamic_ActiveActors();
|
||||
void Update_Dynamic_AllActors();
|
||||
//void Update_Dynamic_AllActors();
|
||||
|
||||
public:
|
||||
static CPhysX_Manager* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
|
||||
@@ -63,9 +63,10 @@ class ENGINE_DLL CRigidBody final : public CComponent
|
||||
PSX::PxRigidBodyFlags m_ePxRigidBodyFlags = {};
|
||||
PXMATERIAL m_eMatType = { PXMATERIAL::END };
|
||||
_float m_fContactOffset = { 0.05f };
|
||||
const PSX::PxActor* m_pRigidBody = { nullptr }; // 실제 시뮬레이션을 도는 본체
|
||||
PSX::PxActor* m_pRigidBody = { nullptr }; // 실제 시뮬레이션을 도는 본체
|
||||
|
||||
CTransform* m_pTransform = { nullptr };
|
||||
PhsXUserData m_tagData = {};
|
||||
|
||||
#pragma region DYNAMIC
|
||||
PSX::PxShapeFlags m_ePxShapeFlags = { PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE };
|
||||
@@ -86,6 +87,7 @@ class ENGINE_DLL CRigidBody final : public CComponent
|
||||
private:
|
||||
HRESULT Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc);
|
||||
HRESULT Initialize(void* pArg);
|
||||
HRESULT Initialize_UserData();
|
||||
#ifdef _DEBUG
|
||||
HRESULT Add_DebugShape();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user