PhysX物理引擎(4)Character Controller

本文主要介绍PhysX角色控制器相关的内部机制和使用方法。 PhysX物理引擎系列记录了在实际项目中使用Nvdia PhysX 3.4物理引擎(Code, Doc)的一些经验,有不少对官方资料的补充。 Warm-up Character Controller (a.k.a CCT) is a special physical object handling player movement. In PhysX, CCT is not a Rigidbody, which means it does not integrate seamlessly in collision system. However, there is a kinematic actor underlying in CCT, and you can attach custom data via PxController::getActor()->userData. ...

December 4, 2023 · 4 min

PhysX物理引擎(3)Rigidbody Dynamics

本文主要介绍PhysX刚体动力学相关的内部机制和使用方法。 PhysX物理引擎系列记录了在实际项目中使用Nvdia PhysX 3.4物理引擎(Code, Doc)的一些经验,有不少对官方资料的补充。 Warm-up Let’s start with some key concepts: Both Kinematic and Dynamic rigidbodies are represented as PxRigidDynamic in PhysX. You can switch between them at runtime using PxRigidBody::setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, true). Kinematic and Static actors remain stationary unless explicitly moved in code. Moving Static actors can result in incorrect collision behavior with dynamic actors. When moving Kinematic actors, always use PxRigidDynamic::setKinematicTarget each frame instead of PxRigidActor::setGlobalPose to ensure correct collision detection with dynamic actors. This post focuses on dynamic rigidbody movement, covering topics such as force and torque, gravity, sleeping, and more. ...

September 4, 2023 · 3 min

PhysX物理引擎(2)Collision

本文主要介绍PhysX碰撞检测的一些内部机制和使用方法。 PhysX物理引擎系列记录了在实际项目中使用Nvdia PhysX 3.4物理引擎(Code, Doc)的一些经验,有不少对官方资料的补充。 Warm-up Static, Kinematic & Dynamic Static colliders are non-movable. In fact, they are not rigidbody, just PxRigidStatic. Kinematic and dynamic rigidbody are both PxRigidDynamic, and can switch to each other at runtime by setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, true/false). The biggest difference is that kinematic rigidbody behaves like infinite mass, and will not move by external force. Instead, you call MovePosition on it. Dynamic rigidbody is the only type we can AddForce to, which has mass, center of mass, and inertia tensor to simulate a natural movement with Newton’s laws of motion. classDiagram PxRigidActor <-- PxRigidStatic PxRigidActor <-- PxRigidBody PxRigidBody <-- PxRigidDynamic PxRigidActor *.. PxShape class PxRigidBody { PxRigidBodyFlag } class PxShape { PxShapeFlag } We cannot make a rigidbody without a shape. Shapes are tangible, with a real size. ...

August 11, 2023 · 3 min

PhysX零值Crash

本文是PhysX物理引擎系列的特别篇,记录了影响近一周的物理引擎底层概率性Crash的定位过程和修复方法,具有很高的实践参考价值。“有多高?”“三四层楼那么高啦!” 发现问题 运维同事发现体验服和某区在新版本上线一小段时间后,会出现概率不高但持续出现的进程Crash。这里先简单说明一下:我们会在一台机器上部署多个GameServer实例,每个GameServer实例进程同时进行着多场不同的Match,如果某一场Match出现了业务层Crash,并不会影响其他Match。但如果是C++物理库内出现Crash,则会同时中止其他正常运行的Match,对玩家的影响较大。 ...

June 13, 2023 · 5 min

PhysX物理引擎(1)Scene Query

本文主要介绍PhysX场景查询的一些内部机制和使用方法。 PhysX物理引擎系列记录了在实际项目中使用Nvdia PhysX 3.4物理引擎(Code, Doc)的一些经验,有不少对官方资料的补充。 Warm-up A Scene in PhysX engine is a container of objects in a hierachical manner. --- title: Scene Hierachy --- classDiagram direction LR class world class scene { Flags Gravity ... } class actor { ActorFlags Name GlobalPose ... } class shape { Flags GeometryType LocalPose QueryFilterData SimulationFilterData ... } class geometry { ... } class material { friction restitution damping } world "1"*.. "N"scene scene "1"*.. "N"actor actor "1"*.. "N"shape shape o--geometry shape o--material There are only position and rotation in GlobalPose and LocalPose, no “scale”. Scale only reflects on geometry’s actual size. ...

May 26, 2023 · 3 min