[Fix] 옷 애니메이션 안돌림

This commit is contained in:
hyunbin14
2025-12-26 14:03:40 +09:00
parent f4d0b640af
commit 9cf54843b7
10 changed files with 132 additions and 33 deletions
+15 -15
View File
@@ -297,9 +297,9 @@ HRESULT CPlayer::Render()
}
#ifdef _DEBUG
for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) {
m_pRobeJointRoute[i]->Render();
}
//for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) {
// m_pRobeJointRoute[i]->Render();
//}
m_pCharacter_Controller->Render();
//m_pRigidBody->Render();
m_pLeftLeg->Render();
@@ -549,15 +549,15 @@ HRESULT CPlayer::Ready_Components()
return E_FAIL;
}
}
{ // RobeSocket
for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) {
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::JOINT_ROUTE);
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_JOINT_ROUTE"), (CComponent**)&m_pRobeJointRoute[i], &Desc))) {
return E_FAIL;
}
}
}
//{ // RobeSocket
// for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) {
// CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
// Desc.iSubKind = ENUM_CLASS(PXOBJECT::JOINT_ROUTE);
// if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_JOINT_ROUTE"), (CComponent**)&m_pRobeJointRoute[i], &Desc))) {
// return E_FAIL;
// }
// }
//}
return S_OK;
}
@@ -771,9 +771,9 @@ void CPlayer::Free()
#endif // _DEBUG
SAFE_RELEASE(m_pRightLeg);
SAFE_RELEASE(m_pLeftLeg);
for (_uint i = 0; i < ENUM_CLASS(PXOBJECT::JOINT_ROUTE); ++i) {
SAFE_RELEASE(m_pRobeJointRoute[i]);
}
//for (_uint i = 0; i < ENUM_CLASS(PXOBJECT::JOINT_ROUTE); ++i) {
// SAFE_RELEASE(m_pRobeJointRoute[i]);
//}
SAFE_RELEASE(m_pGrapInteractive);
if (nullptr != m_pInfoInstance) {
+1 -1
View File
@@ -76,7 +76,7 @@ class CPlayer final : public CUnit
CStat* m_pStat = { nullptr };
CRigidBody_Dynamic* m_pRightLeg = { nullptr };
CRigidBody_Dynamic* m_pLeftLeg = { nullptr };
CRigidBody_Dynamic* m_pRobeJointRoute[ENUM_CLASS(PXOBJECT::JOINT_ROUTE)] = {nullptr};
// CRigidBody_Dynamic* m_pRobeJointRoute[ENUM_CLASS(PXOBJECT::JOINT_ROUTE)] = {nullptr};
private:
virtual HRESULT Initialize_Prototype() override;
virtual HRESULT Initialize(void* pArg) override;
@@ -25,6 +25,7 @@ StructuredBuffer<Channel> g_PrevChannelBuffer : register(t3);
StructuredBuffer<int> g_ParentBuffer : register(t4);
StructuredBuffer<BoneLocal> g_BoneLocalBuffer : register(t5);
StructuredBuffer<uint> g_BoneRemap : register(t6);
StructuredBuffer<int> g_SkipBone : register(t7);
RWStructuredBuffer<float4x4> g_LocalMatrixOut : register(u0);
@@ -42,7 +43,9 @@ cbuffer AnimCB : register(b0)
float BlendRatio;
int RootBoneIndex;
float3 _pad0;
int SkipCount;
int _pad0;
int _pad1;
row_major float4x4 PreTransformMatrix;
float4 RootInitRot;
@@ -337,8 +340,22 @@ row_major float4x4 SampleBlendedLocal(uint bone)
void CS_LOCAL(uint3 DTid : SV_DispatchThreadID)
{
uint bone = DTid.x;
if (bone >= BoneCount)
return;
if (SkipCount != 0)
{
for (int i = 0; i < SkipCount; i++)
{
if (bone == g_SkipBone[i])
{
g_LocalMatrixOut[bone] = g_BoneLocalBuffer[bone].BoneLocal;
return;
}
}
}
g_LocalMatrixOut[bone] = SampleBlendedLocal(bone);
}
@@ -24,7 +24,9 @@ cbuffer AnimCB : register(b0)
float BlendRatio;
int RootBoneIndex;
float3 _pad0;
int SkipCount;
int _pad0;
int _pad1;
row_major float4x4 PreTransformMatrix;
float4 RootInitRot;
@@ -25,6 +25,7 @@ StructuredBuffer<Channel> g_PrevChannelBuffer : register(t3);
StructuredBuffer<int> g_ParentBuffer : register(t4);
StructuredBuffer<BoneLocal> g_BoneLocalBuffer : register(t5);
StructuredBuffer<uint> g_BoneRemap : register(t6);
StructuredBuffer<int> g_SkipBone : register(t7);
RWStructuredBuffer<float4x4> g_LocalMatrixOut : register(u0);
@@ -42,7 +43,9 @@ cbuffer AnimCB : register(b0)
float BlendRatio;
int RootBoneIndex;
float3 _pad0;
int SkipCount;
int _pad0;
int _pad1;
row_major float4x4 PreTransformMatrix;
float4 RootInitRot;
@@ -337,8 +340,22 @@ row_major float4x4 SampleBlendedLocal(uint bone)
void CS_LOCAL(uint3 DTid : SV_DispatchThreadID)
{
uint bone = DTid.x;
if (bone >= BoneCount)
return;
if (SkipCount != 0)
{
for (int i = 0; i < SkipCount; i++)
{
if (bone == g_SkipBone[i])
{
g_LocalMatrixOut[bone] = g_BoneLocalBuffer[bone].BoneLocal;
return;
}
}
}
g_LocalMatrixOut[bone] = SampleBlendedLocal(bone);
}
@@ -24,7 +24,9 @@ cbuffer AnimCB : register(b0)
float BlendRatio;
int RootBoneIndex;
float3 _pad0;
int SkipCount;
int _pad0;
int _pad1;
row_major float4x4 PreTransformMatrix;
float4 RootInitRot;
+1
View File
@@ -422,6 +422,7 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(const CModel* pModel, SaveMesh* _Save
HRESULT CMesh::Create_BoneRemapBuffer()
{
D3D11_BUFFER_DESC desc{};
desc.Usage = D3D11_USAGE_DEFAULT;
desc.ByteWidth = sizeof(_uint) * (_uint)m_BoneRemap.size();
+61 -8
View File
@@ -1341,6 +1341,10 @@ void CModel::InItialize_BoneIndex()
{
m_iBoneIndex[ENUM_CLASS(BLEND_BONE::NECK)] = i;
}
if (m_Bones[i]->Compare_Name("Hips_Cloth"))
{
m_iBoneIndex[ENUM_CLASS(BLEND_BONE::HIPS_CLOTH)] = i;
}
}
}
@@ -1373,6 +1377,19 @@ void CModel::Initialize_BoneMasks()
BuildMask(m_iBoneIndex[ENUM_CLASS(BLEND_BONE::SHOULDER_L)], m_BoneMask[ENUM_CLASS(BLEND_BONE::SHOULDER_L)]);
BuildMask(m_iBoneIndex[ENUM_CLASS(BLEND_BONE::SHOULDER_R)], m_BoneMask[ENUM_CLASS(BLEND_BONE::SHOULDER_R)]);
BuildMask(m_iBoneIndex[ENUM_CLASS(BLEND_BONE::NECK)], m_BoneMask[ENUM_CLASS(BLEND_BONE::NECK)]);
BuildMask(m_iBoneIndex[ENUM_CLASS(BLEND_BONE::HIPS_CLOTH)], m_BoneMask[ENUM_CLASS(BLEND_BONE::HIPS_CLOTH)]);
if (m_iBoneIndex[ENUM_CLASS(BLEND_BONE::HIPS_CLOTH)] != -1)
{
for (_uint i = 0; i < (_uint)m_BoneMask[ENUM_CLASS(BLEND_BONE::HIPS_CLOTH)].size(); i++)
{
if (m_BoneMask[ENUM_CLASS(BLEND_BONE::HIPS_CLOTH)][i] == 1)
{
m_iSkipBoneCount++;
m_SkipBoneindex.push_back(i);
}
}
}
for (_uint i = 0; i < m_Bones.size(); i++)
{
@@ -1421,9 +1438,10 @@ HRESULT CModel::Create_ComputeShaderLocal()
sizeof(CHANNEL_DESC), // 채널
sizeof(KEYFRAME_DESC), // 이전애님 키프레임
sizeof(CHANNEL_DESC), // 이전애님 채널
sizeof(int), // 부모 인덱스
sizeof(_int), // 부모 인덱스
sizeof(_float4x4), // 로컬좌표
sizeof(_uint)
sizeof(_uint),
sizeof(_int) //스킵본 인덱스
};
_uint CS_OutputStrides[] = {
@@ -1433,7 +1451,7 @@ HRESULT CModel::Create_ComputeShaderLocal()
CComputeShader::CS_INFO CS_Desc = {};
CS_Desc.iNumElement = (_uint)m_Bones.size();
CS_Desc.iNumInputBuffer = 7;
CS_Desc.iNumInputBuffer = 8;
CS_Desc.iNumOutputBuffer = 1;
CS_Desc.iInputStructStride = CS_InputStrides;
@@ -1493,6 +1511,33 @@ HRESULT CModel::Create_BoneLocalVB()
return S_OK;
}
HRESULT CModel::Create_SkipBoneVB()
{
D3D11_BUFFER_DESC desc{};
desc.Usage = D3D11_USAGE_DEFAULT;
desc.ByteWidth = sizeof(_int) * (_uint)m_Bones.size();
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0;
desc.StructureByteStride = sizeof(_int);
desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
D3D11_SUBRESOURCE_DATA init{};
init.pSysMem = m_SkipBoneindex.data();
m_pDevice->CreateBuffer(&desc, &init, &m_pSkipBoneBuffer);
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
srvDesc.Format = DXGI_FORMAT_UNKNOWN;
srvDesc.Buffer.FirstElement = 0;
srvDesc.Buffer.NumElements = (_uint)m_Bones.size();
if (FAILED(m_pDevice->CreateShaderResourceView(m_pSkipBoneBuffer, &srvDesc, &m_pSkipBoneSRV)))
return E_FAIL;
return S_OK;
}
HRESULT CModel::Create_BoneMatrixVB()
{
_uint iCount = (_uint)m_Bones.size();
@@ -1702,6 +1747,9 @@ void CModel::ComputeLocal(_uint AnimIndex, _uint MeshIndex)
pDesc->PrevTime = m_Animations[m_iPreAnimIndex]->Get_CurrentTrackPosition();
pDesc->BlendRatio = m_fRatio;
pDesc->RootBoneIndex = m_iRootBoneIndex;
pDesc->SkipCount = m_iSkipBoneCount;
pDesc->padding = 0;
pDesc->padding1 = 0;
pDesc->PreTransformMatrix = m_PreTransformMatrix;
pDesc->RootInitRot = m_vInitialRootRot;
m_pContext->Unmap(m_pConstantBuffer, 0);
@@ -1721,7 +1769,8 @@ void CModel::ComputeLocal(_uint AnimIndex, _uint MeshIndex)
m_Animations[m_iPreAnimIndex]->Get_ChannelBuffer(),
m_pParentBuffer,
m_pBoneLocalBuffer,
m_Meshes[MeshIndex]->Get_BoneRemapBuffer()
m_Meshes[MeshIndex]->Get_BoneRemapBuffer(),
m_pSkipBoneBuffer
};
ID3D11ShaderResourceView* srvs[] =
@@ -1732,7 +1781,8 @@ void CModel::ComputeLocal(_uint AnimIndex, _uint MeshIndex)
m_Animations[m_iPreAnimIndex]->Get_ChannelSrv(),
m_pParentSRV,
m_pBoneLocalSRV,
m_Meshes[MeshIndex]->Get_BoneRemapSRV()
m_Meshes[MeshIndex]->Get_BoneRemapSRV(),
m_pSkipBoneSRV
};
ID3D11UnorderedAccessView* uavs[] =
@@ -1745,7 +1795,7 @@ void CModel::ComputeLocal(_uint AnimIndex, _uint MeshIndex)
0,
_float3((_float)iGroupCountX, 1.f, 1.f),
srvs,
7,
8,
uavs,
1,
m_pConstantBuffer
@@ -1755,9 +1805,9 @@ void CModel::ComputeLocal(_uint AnimIndex, _uint MeshIndex)
UINT counts[1] = { 0 };
m_pContext->CSSetUnorderedAccessViews(0, 1, nullUAV, counts);
ID3D11ShaderResourceView* nullSRV[7] = { nullptr };
ID3D11ShaderResourceView* nullSRV[8] = { nullptr };
m_pContext->CSSetShaderResources(0, 7, nullSRV);
m_pContext->CSSetShaderResources(0, 8, nullSRV);
}
@@ -2231,6 +2281,7 @@ HRESULT CModel::Initialize(void* pArg)
Create_BoneMatrixVB();
Create_ParentVB();
Create_BoneLocalVB();
Create_SkipBoneVB();
Create_ParentSrv();
Create_BoneLocalSrv();
@@ -2367,11 +2418,13 @@ void CModel::Free()
SAFE_RELEASE(m_pBoneLocalBuffer);
SAFE_RELEASE(m_pBoneMatrixBuffer);
SAFE_RELEASE(m_pPrevBoneMatrixBuffer);
SAFE_RELEASE(m_pSkipBoneBuffer);
SAFE_RELEASE(m_pLocalMatrixBuffer);
SAFE_RELEASE(m_pParentSRV);
SAFE_RELEASE(m_pBoneLocalSRV);
SAFE_RELEASE(m_pBoneMatrixSRV);
SAFE_RELEASE(m_pPrevBoneMatrixSRV);
SAFE_RELEASE(m_pSkipBoneSRV);
SAFE_RELEASE(m_pBoneMatrixUAV);
SAFE_RELEASE(m_pLocalMatrixSRV);
SAFE_RELEASE(m_pLocalMatrixUAV);
+1 -1
View File
@@ -8,7 +8,7 @@ enum class COLLIDER { AABB, OBB, SPHERE, END };
enum class RENDER {PRIORITY, SHADOW_NEAR, NONBLEND, DECAL, BLUR, NONLIGHT, EFFECT ,BLEND, BLOOM, DISTORTION, BULR_MESH ,UI, OCCLUSION, SHADOW_MIDDLE, PRESHADOW, UI_OVERLAY ,END };
enum class RAY { LOCAL, WORLD, END };
enum class ACTOR { BOX, CAPSULE, SPHERE, PLANE, TRIANGLEMESH, HEIGHTFIELD, END };
enum class BLEND_BONE{SPINE,SHOULDER_L,SHOULDER_R,NECK,SHOULDER_NECK_L, SHOULDER_NECK_R,END};
enum class BLEND_BONE{SPINE,SHOULDER_L,SHOULDER_R,NECK,SHOULDER_NECK_L, SHOULDER_NECK_R,HIPS_CLOTH,END};
enum class STAT { NAME, CURRENTHP, MAXHP, TARGETHP, MELEE, MAGIC, DEFENSE, SPEED, AGILITY, LEVEL, EXPERIENCE, MAX_EXPERIENCE, GOLD, END };
//enum class CONDITION { POISON, HPREGENERATION, PANIC, GRAP, END };
enum class SHADOW : _ubyte {
+11 -4
View File
@@ -20,7 +20,9 @@ class ENGINE_DLL CModel final : public CComponent
_float BlendRatio;
_int RootBoneIndex;
_float3 padding;
_int SkipCount;
_int padding;
_int padding1;
_float4x4 PreTransformMatrix;
_float4 RootInitRot;
@@ -43,6 +45,7 @@ class ENGINE_DLL CModel final : public CComponent
virtual HRESULT Render_Indexed(_uint iMeshIndex, _uint IndexCount, _uint StartIndexLocation, _uint BaseVertexLocation);
MODEL Get_Type() { return m_eType; }
void Set_Temp(_bool Temp) { m_bTemp = Temp; }
_int Get_SkipBoneIndex(_int Index) { return m_SkipBoneindex[Index]; }
#pragma endregion
#pragma region Animation
_bool Play_Animation(_float fTimeDelta, class CTransform* pTransform = nullptr); // 애니메이션에 델타타임을 넣어줌
@@ -164,7 +167,7 @@ class ENGINE_DLL CModel final : public CComponent
_float m_fRatio = {};
_int m_iCurrSecondAnimIndex = { -1 };
_int m_iBoneIndex[ENUM_CLASS(BLEND_BONE::END)] = { -1,-1,-1,-1,-1,-1 };
_int m_iBoneIndex[ENUM_CLASS(BLEND_BONE::END)] = { -1,-1,-1,-1,-1,-1,-1 };
vector<vector<_uint>> m_BoneMask;
vector<_bool> m_CPUBoneMask;
@@ -195,6 +198,8 @@ class ENGINE_DLL CModel final : public CComponent
_bool m_bRootBone = {};
_float4x4 m_RootMatrix = {};
_bool m_bTemp = {false};
_int m_iSkipBoneCount = {};
vector<_int> m_SkipBoneindex = {};
private:
@@ -211,6 +216,7 @@ class ENGINE_DLL CModel final : public CComponent
HRESULT Create_ComputeShaderLocal();
HRESULT Create_ParentVB();
HRESULT Create_BoneLocalVB();
HRESULT Create_SkipBoneVB();
HRESULT Create_Temp();
HRESULT Create_BoneMatrixVB();
HRESULT Create_Const();
@@ -221,11 +227,10 @@ class ENGINE_DLL CModel final : public CComponent
_uint m_iNumBuffer = {};
vector<_int> m_Parent = {};
vector<_int> m_Parent = {};
vector<_float4x4> m_BoneLocal = {};
vector<ANIMSTATE_DESC> m_AnimRanges;
vector<_float4x4> m_BoneMatrixCPU;
class CComputeShader* m_pComputeShader = nullptr;
@@ -236,6 +241,7 @@ class ENGINE_DLL CModel final : public CComponent
ID3D11Buffer* m_pBoneMatrixBuffer = { nullptr };
ID3D11Buffer* m_pPrevBoneMatrixBuffer = { nullptr };
ID3D11Buffer* m_pBoneLocalBuffer = { nullptr };
ID3D11Buffer* m_pSkipBoneBuffer = { nullptr };
ID3D11Buffer* m_pLocalMatrixBuffer = { nullptr };
@@ -244,6 +250,7 @@ class ENGINE_DLL CModel final : public CComponent
ID3D11ShaderResourceView* m_pBoneMatrixSRV = { nullptr };
ID3D11ShaderResourceView* m_pPrevBoneMatrixSRV = { nullptr };
ID3D11ShaderResourceView* m_pLocalMatrixSRV = { nullptr };
ID3D11ShaderResourceView* m_pSkipBoneSRV = { nullptr };
ID3D11UnorderedAccessView* m_pBoneMatrixUAV = { nullptr };
ID3D11UnorderedAccessView* m_pLocalMatrixUAV = { nullptr };