Open yangruihan opened 3 years ago
核心逻辑
touching = m_Controller->move((const PxVec3&)movement, m_MinMoveDistance, elapsedTime, filters);
可以找到m_Controller的类型是physx::PxCapsuleController*,真正执行移动的逻辑是 PhysX 提供的
m_Controller
physx::PxCapsuleController*
于是取得 PhysX 源码:https://github.com/NVIDIAGameWorks/PhysX-3.4
主要移动逻辑位于 PhysX_3.4\Source\PhysXCharacterKinematic\src\CctCharacterController.cpp
PhysX_3.4\Source\PhysXCharacterKinematic\src\CctCharacterController.cpp
调用堆栈:CapsuleController::move->Controller::move->SweepTest::moveCharacter
CapsuleController::move
Controller::move
SweepTest::moveCharacter
查看moveCharacter源码可以发现大体分为一下几个阶段:
moveCharacter
Ps::decomposeVector(normal_compo, tangent_compo, direction, upDirection);
volume.computeTemporalBox(*this, temporalBox, volume.mCenter, direction);
updateTouchedGeoms(userData, userObstacles, temporalBox, filters, SideVector);
Move 分析
核心逻辑
可以找到
m_Controller
的类型是physx::PxCapsuleController*
,真正执行移动的逻辑是 PhysX 提供的于是取得 PhysX 源码:https://github.com/NVIDIAGameWorks/PhysX-3.4
主要移动逻辑位于
PhysX_3.4\Source\PhysXCharacterKinematic\src\CctCharacterController.cpp
调用堆栈:
CapsuleController::move
->Controller::move
->SweepTest::moveCharacter
查看
moveCharacter
源码可以发现大体分为一下几个阶段:Ps::decomposeVector(normal_compo, tangent_compo, direction, upDirection);
(PhysX_3.4\Source\PhysXCharacterKinematic\src\CctCharacterController.cpp
1706)volume.computeTemporalBox(*this, temporalBox, volume.mCenter, direction);
(PhysX_3.4\Source\PhysXCharacterKinematic\src\CctCharacterController.cpp
1742)updateTouchedGeoms(userData, userObstacles, temporalBox, filters, SideVector);
(PhysX_3.4\Source\PhysXCharacterKinematic\src\CctCharacterController.cpp
1745)PhysX_3.4\Source\PhysXCharacterKinematic\src\CctCharacterController.cpp
1748 ~ 1956)