-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRigidBody.cpp
More file actions
62 lines (52 loc) · 1.76 KB
/
Copy pathRigidBody.cpp
File metadata and controls
62 lines (52 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "RigidBody.h"
RigidBody::RigidBody(EColliderType collidreType, unsigned int id, unsigned int layerNumber)
: m_colliderType(collidreType)
, m_id(id)
, m_layerNumber(layerNumber)
, m_radius()
, m_halfHeight()
, m_Extent()
, m_scale(1.0f, 1.0f, 1.0f)
, m_offsetRotation(math::quaternion::identity())
, m_offsetPsition()
{
}
RigidBody::~RigidBody()
{
}
void RigidBody::UpdateShapeGeometry(physx::PxRigidActor* Actor, const physx::PxGeometry& newGeometry, physx::PxPhysics* physics, physx::PxMaterial* material, unsigned int* collisionMatrix, void* userData)
{
physx::PxShape* newShape = physics->createShape(newGeometry, *material, true);
physx::PxGeometryType::Enum geomType = newGeometry.getType();
// [핵심 수정] 생성 시와 동일하게 Y축으로 세우는 로컬 회전을 적용합니다!
if (geomType == physx::PxGeometryType::eCAPSULE) {
physx::PxTransform localPose(physx::PxQuat(physx::PxHalfPi, physx::PxVec3(0, 0, 1)));
newShape->setLocalPose(localPose);
}
physx::PxFilterData filterData;
filterData.word0 = m_layerNumber;
filterData.word1 = collisionMatrix[m_layerNumber];
filterData.word2 = 1 << m_layerNumber;
newShape->setSimulationFilterData(filterData);
newShape->setQueryFilterData(filterData);
newShape->setContactOffset(0.02f);
newShape->setRestOffset(0.01f);
newShape->userData = userData;
userData = nullptr;
if (m_colliderType == EColliderType::COLLISION)
{
newShape->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE, true);
}
else {
newShape->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE, false);
newShape->setFlag(physx::PxShapeFlag::eTRIGGER_SHAPE, true);
}
physx::PxShape* oldShape = nullptr;
Actor->getShapes(&oldShape, 1);
if (oldShape != nullptr)
{
Actor->detachShape(*oldShape);
}
Actor->attachShape(*newShape);
newShape->release();
}