[Add] 도끼 충돌 추가

This commit is contained in:
hyunbin14
2025-12-12 13:15:36 +09:00
parent fbfcd70eaa
commit f84e48b71b
5 changed files with 128 additions and 10 deletions
@@ -44,6 +44,10 @@ HRESULT CGoblin_BattleAxe::Initialize(void* pArg)
void CGoblin_BattleAxe::Priority_Update(_float fTimeDelta)
{
if (m_bVisible) {
XMStoreFloat4(&m_vStartAxePos, Get_WorldPostion());
XMStoreFloat4(&m_vStartGripPos, Get_WorldPostion());
}
m_pModelCom->Combined_BoneMatrix();
_matrix socketMatrix = {};
@@ -75,7 +79,13 @@ void CGoblin_BattleAxe::Update(_float fTimeDelta)
void CGoblin_BattleAxe::Late_Update(_float fTimeDelta)
{
m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this);
if (m_bVisible) {
m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this);
SwingHit(m_bPlayerHit);
}
else {
m_bPlayerHit = false;
}
}
HRESULT CGoblin_BattleAxe::Render()
@@ -83,8 +93,10 @@ HRESULT CGoblin_BattleAxe::Render()
if (!m_pModelCom)
return S_OK;
if (!m_bVisible)
if (!m_bVisible) {
return S_OK;
}
if (FAILED(Bind_ShaderResources())) {
return E_FAIL;
@@ -193,6 +205,93 @@ HRESULT CGoblin_BattleAxe::Bind_ShaderResources()
return S_OK;
}
void CGoblin_BattleAxe::CheckAxeHits(_uint& iHitCount, vector<PSX::PxSweepHit>& pxHits)
{
{
_vector vStartPos = XMLoadFloat4(&m_vStartAxePos);
_vector vEndPos = XMVectorSet(m_vAxeMat._41, m_vAxeMat._42, m_vAxeMat._43,1.f);
_vector vDir = vEndPos - vStartPos;
_float fDistance = XMVectorGetX(XMVector4Length(vDir));
vDir = XMVector4Normalize(vDir);
_bool bCollision = false;
m_SweepBufferAxe = {};
bCollision = m_pGameInstance->SphereCast(1.2f, vStartPos, vDir, fDistance, PSX::PxHitFlag::eDEFAULT, PSX::PxQueryFlag::eDYNAMIC, m_SweepBufferAxe);
if (true == bCollision) {
iHitCount += m_SweepBufferAxe.getNbTouches() + m_SweepBufferAxe.hasBlock;
auto touches = m_SweepBufferAxe.getTouches();
for (_uint i = 0; i < m_SweepBufferAxe.nbTouches; ++i) {
pxHits.push_back(m_SweepBufferAxe.touches[i]);
}
if (true == m_SweepBufferAxe.hasBlock) {
pxHits.push_back(m_SweepBufferAxe.block);
}
}
}
{
_vector vStartPos = XMLoadFloat4(&m_vStartGripPos);
_vector vEndPos = m_pTransformCom->Get_State(STATE::POSITION);
_vector vDir = vEndPos - vStartPos;
_float fDistance = XMVectorGetX(XMVector4Length(vDir));
vDir = XMVector4Normalize(vDir);
_bool bCollision = false;
m_SweepBufferGrip = {};
bCollision = m_pGameInstance->SphereCast(1.2f, vStartPos, vDir, fDistance, PSX::PxHitFlag::eDEFAULT, PSX::PxQueryFlag::eDYNAMIC, m_SweepBufferGrip);
if (true == bCollision) {
iHitCount += m_SweepBufferGrip.getNbTouches() + m_SweepBufferGrip.hasBlock;
auto touches = m_SweepBufferGrip.getTouches();
for (_uint i = 0; i < m_SweepBufferGrip.nbTouches; ++i) {
pxHits.push_back(m_SweepBufferGrip.touches[i]);
}
if (true == m_SweepBufferGrip.hasBlock) {
pxHits.push_back(m_SweepBufferGrip.block);
}
}
}
}
void CGoblin_BattleAxe::SwingHit(_bool& bPlayerHit)
{
vector<PSX::PxSweepHit> pxHits;
_uint iHitCount = 0;
CheckAxeHits(iHitCount, pxHits);
{
for (_uint i = 0; i < pxHits.size(); ++i) {
PSX::PxActor* pxHitActor = pxHits[i].actor;
if (nullptr != pxHitActor && nullptr != pxHitActor->userData) {
PhsXUserData* pUserData = (PhsXUserData*)pxHitActor->userData;
switch (PXOBJECT(pUserData->iSubKind))
{
case PXOBJECT::PLAYER:
{
if (true == bPlayerHit) {
continue;
}
CStat* pStat = pUserData->pCharacter->Get_Owner()->Get_Component<CStat>();
pStat->Get_Damage(20.f);
bPlayerHit = true;
pUserData->pOwner->OnCollision(this);
} break;
case PXOBJECT::ALLY_HITBOX:
break;
case PXOBJECT::ENVIRIONMENT:
break;
case PXOBJECT::TERRAIN:
break;
case PXOBJECT::BOX:
break;
case PXOBJECT::NPC:
break;
default:
break;
}
}
}
}
}
CGoblin_BattleAxe* CGoblin_BattleAxe::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
@@ -238,7 +238,7 @@ HRESULT CLevel_GamePlay::Ready_Background()
isReady_Background = true;
#endif // gimch
#ifdef Bin
isReady_Background = false;
isReady_Background = true;
#endif //
#ifdef 진우
isReady_Background = true;
@@ -267,7 +267,7 @@ HRESULT CLevel_GamePlay::Ready_Background()
return E_FAIL;
/* 조명 오브젝트 */
/*CInfoInstance::GetInstance()->Load_LightElements("LightElement"); */
CInfoInstance::GetInstance()->Load_LightElements("LightElement");
/* 상호작용 오브젝트 */
CInfoInstance::GetInstance()->Load_InteractableElements("E_INTER_Barrel");
+1 -1
View File
@@ -312,7 +312,7 @@ HRESULT CLoader::Loading_For_GamePlay()
isLoad_Background = true;
#endif // gimch
#ifdef Bin
isLoad_Background = false;
isLoad_Background = true;
#endif //
#ifdef 진우
isLoad_Background = true;
@@ -989,7 +989,7 @@ void CPlayer::Behavior_LightAttackEnter()
Add_Event(pairAnimInfo.first,
[this]() {_uint iIndex = 0; m_pEffectPool->Use_Skill(SKILL_TYPE::JAP, Get_PartObject<CWand>(), &iIndex); },
0.1f);
0.07f);
Add_Event(pairAnimInfo.first,
[this]() { m_pEffectPool->Use_Skill(SKILL_TYPE::JAP_SIDE, Get_PartObject<CWand>()); },
@@ -1016,7 +1016,13 @@ HRESULT CPlayer::Behavior_LightAttackExitCheck(_float fTimeDelta)
_uint iNext = iCurr + 1;
pairAnimInfo = m_Animation[STATEANIM::LIGHT_ATTACK];
pairAnimInfo.first = iNext;
_float fAttackRatio;
if (pairAnimInfo.first - m_Animation[STATEANIM::LIGHT_ATTACK].first == 3) {
fAttackRatio = 0.12f;
}
else {
fAttackRatio = 0.07f;
}
Add_Event(pairAnimInfo.first,
[this]() {m_bLookAt = true;
@@ -1032,7 +1038,7 @@ HRESULT CPlayer::Behavior_LightAttackExitCheck(_float fTimeDelta)
_uint comboIndex = m_pModelCom->Get_AnimIndex() - m_Animation[STATEANIM::LIGHT_ATTACK].first;
m_pEffectPool->Use_Skill(SKILL_TYPE::JAP, Get_PartObject<CWand>(), &comboIndex);
},
0.05f);
fAttackRatio);
Add_Event(iNext,
[this]() {m_pEffectPool->Use_Skill(SKILL_TYPE::JAP_SIDE,Get_PartObject<CWand>());
@@ -1831,7 +1837,7 @@ void CPlayer::Behavior_Broom_DismountEnter()
m_pTransformCom->Set_State(STATE::RIGHT, right);
m_pTransformCom->Set_State(STATE::UP, up);
m_pTransformCom->Set_State(STATE::LOOK, look);
m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second,1.f,false,1.3f);
m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second,1.f,false,1.6f);
}
HRESULT CPlayer::Behavior_Broom_DismountExitCheck(_float fTimeDelta)
@@ -2310,7 +2316,7 @@ void CPlayer::Set_Anim()
m_Animation[STATEANIM::SPELL_90_L] = { 826,false };
m_Animation[STATEANIM::MAPHELP] = { 122,false };
m_Animation[STATEANIM::POTION] = { 114,false }; // 114 포션 // 909 루모스
m_Animation[STATEANIM::POTION] = { 115,false }; // 114 포션 // 909 루모스
m_Animation[STATEANIM::ACCIO] = { 417,false };
m_Animation[STATEANIM::DESCENDO] = { 857,false };
m_Animation[STATEANIM::DEPULSO] = { 858,false };
@@ -35,6 +35,15 @@ class CGoblin_BattleAxe final : public CPartObject
_float4x4 m_vAxeMat= {};
PSX::PxSweepBufferN<12> m_SweepBufferAxe = {};
PSX::PxSweepBufferN<12> m_SweepBufferGrip = {};
const _float4* m_pAxePos = { nullptr };
const _float4* m_pAxeGripPos = { nullptr };
_float4 m_vStartAxePos = { };
_float4 m_vStartGripPos = { };
_bool m_bPlayerHit = {};
#ifdef _DEBUG
unique_ptr<GeometricPrimitive> m_pGripShape = { nullptr };
unique_ptr<GeometricPrimitive> m_pSubShape = { nullptr };
@@ -45,6 +54,10 @@ class CGoblin_BattleAxe final : public CPartObject
HRESULT Ready_Components();
HRESULT Bind_ShaderResources();
void CheckAxeHits(_uint& iHitCount, vector<PSX::PxSweepHit>& pxHits);
void SwingHit(_bool& bPlayerHit);
public:
static CGoblin_BattleAxe* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr)override;