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. ...

深入 LossyScale

本文是PhysX物理引擎系列的番外篇,其实要弄明白一个3D数学问题:如何处理父节点带有非均匀缩放、子节点带有旋转时,子节点的最终大小和形态。 问题源自笔者在修改物理引擎为其添加scale属性时遇到的一个bug。解决后对WorldScale为什么叫做LossyScale、空间变换和基变换有了更深的理解。 ...

PhysX零值Crash

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

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. ...