bullet物理引擎(6) 通用提示

  • 避免过大、过小的运动物体。
    如果物体过小,需要增加模拟频率(btDiscreteDynamicsWorld::stepSimulation的参数)。60帧的推荐运动物体大小在0.2米 – 5米。

Avoid very small and very large collision shapes
The minimum object size for moving objects is about 0.2 units, 20 centimeters for Earth gravity. If
smaller objects or bigger gravity are manipulated, reduce the internal simulation frequency
accordingly, using the third argument of btDiscreteDynamicsWorld::stepSimulation. By
default it is 60Hz. For instance, simulating a dice throw (1cm-wide box with a gravity of 9.8m/s2)
requires a frequency of at least 300Hz (1./300.). It is recommended to keep the maximum size of
moving objects smaller then about 5 units/meters.

  • 避免过大的质量差异
    Avoid large mass ratios (differences)
    Simulation becomes unstable when a heavy object is resting on a very light object. It is best to keep the
    mass around 1. This means accurate interaction between a tank and a very light object is not realistic.

  • 合并静态三角mesh。多个物体最好能合并为一个。
    Combine multiple static triangle meshes into one
    Many small btBvhTriangleMeshShape pollute the broadphase. Better combine them.

  • 使用内部频率 60赫兹,使用内部步长。
    Use the default internal fixed timestep
    Bullet works best with a fixed internal timestep of at least 60 hertz (1/60 second).
    For safety and stability, Bullet will automatically subdivide the variable timestep into fixed internal
    simulation substeps, up to a maximum number of substeps specified as second argument to
    stepSimulation. When the timestep is smaller then the internal substep, Bullet will interpolate the
    This safety mechanism can be disabled by passing 0 as maximum number of substeps (second
    argument to stepSimulation): the internal timestep and substeps are disabled, and the actual
    timestep is simulated. It is not recommended to disable this safety mechanism.

  • 布娃娃系统使用btConeTwistConstraint
    For ragdolls use btConeTwistConstraint
    It is better to build a ragdoll out of btHingeConstraint and/or btConeTwistLimit for knees,
    elbows and arms.

  • 不要设置碰撞外边框为0
    Don’t set the collision margin to zero
    Collision detection system needs some margin for performance and stability. If the gap is noticeable,
    please compensate the graphics representation.

  • 限制btConvexHullShape 的顶点数量100以下。
    Use less then 100 vertices in a convex mesh
    It is best to keep the number of vertices in a btConvexHullShape limited. It is better for
    performance, and too many vertices might cause instability. Use the btShapeHull utility to simplify
    convex hulls.

  • 避免三角网格中,出现巨大或者退化的三角形。(一般设计工具都对这个有优化)
    Avoid huge or degenerate triangles in a triangle mesh
    Keep the size of triangles reasonable, say below 10 units/meters. Also degenerate triangles with large
    size ratios between each sides or close to zero area can better be avoided.

  • 分析工具绕过了内存分配器,要检测内存泄露的话,禁用分析工具。
    The profiling feature btQuickProf bypasses the memory allocator
    If necessary, disable the profiler when checking for memory leaks, or when creating the final version
    of your software release. The profiling feature can be switched off by defining #define
    BT_NO_PROFILE 1 in Bullet/src/LinearMath/btQuickProf.h




37 + = 47