Setting Up Materials
Setting Up Properties
Landscape Tool
Extending Editor Functionality
Light Sources
World Objects
Sound Objects
Pathfinding Objects
Usage Examples
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes


Computation of physical interactions can be very demanding. There are optimization techniques providing high performance and overall stability for your interactive projects.物理相互作用的计算可能非常苛刻。有一些优化技术可为您的交互式项目提供高性能和整体稳定性。

Common Settings常用设定#

Keep the global physics settings at a reasonable demanding level.全局物理设置保持在合理的要求水平。

To configure physics settings, open the Settings window by choosing Window -> Settings in the main menu and select Runtime -> World -> Physics section.要配置物理设置,请在主菜单中选择Window -> Settings,然后选择Runtime -> World -> Physics部分,以打开Settings窗口。

  • Specify the Distance from the camera, from which physical interactions are not calculated. If the distance between the camera and the physics-based node exceeds this limit, the node freezes and its physical calculations are skipped until the node gets closer to the camera.从相机中指定 距离 ,但不会从中计算物理相互作用。如果摄像头与基于物理的节点之间的距离超过此限制,则该节点将冻结,并跳过其物理计算,直到该节点更靠近摄像头为止。

    Cloth simulation halts starting from the specified distance from the camera从与相机的指定距离开始,布料模拟暂停

    Cloth, Rope, and Water physical bodies have their own Simulation Distance parameter as well. Cloth, RopeWater物理体也有自己的Simulation Distance参数。
  • Using the Iterations parameter may increase stability, but can also result in a higher load. A high number of iterations may lead to noticeable lags as very time-consuming calculations are automatically skipped. One physics iteration is quite enough for simple scenes.使用Iterations参数可以提高稳定性,但也可能导致更高的负载。大量的迭代可能会导致明显的滞后,因为会自动跳过非常耗时的计算。对于简单的场景,一个物理迭代就足够了。
  • Adjust the time Budget for Physics simulation.调整 预算 用于物理模拟的时间。

Collision Detection Optimization碰撞检测优化#

Filtering Interactions过滤互动#

It is very unlikely that each physics-based object in your project will interact with all other objects. Most probably, objects can be divided into groups dedicated to certain tasks.项目中的每个基于物理学的对象极不可能与所有其他对象进行交互。对象很可能可以分为专用于某些任务的组。

If you have multiple objects that take part in physical simulation, divide the ones that are hardly going to interact with each other, into different "groups" by using the Bit Masking mechanism.如果您有多个参与物理模拟的对象,则可以使用 Bit Masking 机制将几乎不会互相影响的对象划分为不同的“组”。

Limiting Collisions限制碰撞#

Set matching Collision Masks for those particular shapes, surfaces, and bodies that are expected to collide. If the masks do not match, shapes and bodies will simply ignore each other by going through.为预期会碰撞的特定形状Collision Masks表面实体设置匹配的 。如果蒙版不匹配,则形状和实体将通过相互忽略。

Collisions are calculated for a plane and a sphere while a box is ignored due to unmatching Collision Masks为平面和球体计算碰撞,但由于不匹配Collision蒙版而忽略了一个框
The Collision Mask of the sphere's physical shape球体物理形状的Collision蒙版
The Collision Mask of the box's physical shape盒子物理形状的Collision蒙版
The Collision Mask of the plane's surface平面的Collision蒙版
The Collision Mask of the ground's surface地面的Collision蒙版

In Unigine, you can set up filtering accurately by using the Exclusion Mask. This mask allows ignoring shapes with the matching exclusion masks regardless of their Collision Masks.在Unigine中,您可以使用排除掩码准确地设置过滤。此蒙版允许忽略具有匹配排除蒙版的形状,而不考虑其碰撞蒙版

Surfaces that are not intended for physical interactions should have the Collision flag disabled. For example, a dashboard inside a cockpit would never take part in collision detection on the outside.不适用于物理交互的表面应禁用Collision标志。例如,座舱内的仪表板永远不会参与外部的碰撞检测。

Avoiding detection of undesired and unnecessary collisions is a basic way to reduce the amount of physical calculations.避免检测到不必要和不必要的冲突是减少物理计算量的基本方法。

Filtering Physical Effects过滤物理效果#

Specify certain physicals that should affect only corresponding bodies by using the Physical Masks the same way as for collisions. On the image below, a Physical Wind object affects a cloth banner but not a sphere.通过使用 指定与碰撞相同的某些物理Physical Masks,它们仅会影响相应的物体。在下图中,一个Physical Wind对象会影响布料横幅,但不会影响球体。

A physical wind affects a cloth but not a sphere物理风影响布料但不影响球体
Physical mask of the cloth banner布标的Physical蒙版
Physical mask of the sphere球形的Physical蒙版
Physical mask of the Physical Wind object Physical Wind对象的Physical掩码

Intersection Mask交叉口罩#

Intersection is a generic point of a specified area (or line) and an object. Calculation of intersection between a ray cast and a surface is fast and inexpensive and therefore sometimes can be used instead of computing collision. For example, calculation of collisions of car wheels with the ground can be simplified by using intersections. 交点是指定区域(或线)和对象的通用点。射线投射和曲面之间的相交的计算是快速且廉价的,因此有时可以代替计算碰撞而使用。例如,可以使用交叉点简化车轮与地面的碰撞的计算。

Although it is a programmatic approach only, it requires Intersection Masks to be set for filtering purposes.尽管它只是一种编程方法,但它需要设置 Intersection掩码 进行过滤。

Both physical shapes and surfaces have intersection masks.物理形状曲面都具有交叉蒙版。

Reducing Colliders Complexity降低碰撞机的复杂性#

As a rule, most 3D objects should be represented by a complex and detailed visible mesh and an invisible simplified shape used by a physics engine for collision detection (collider).通常,大多数3D对象应该由物理引擎用于碰撞检测( collider )的复杂且详细的可见网格和不可见的简化形状表示。

Detailed visible mesh详细的可见网格
Invisible physical representation by using simplified shapes使用简化形状的不可见物理表示形式

Using Simpler Shapes使用更简单的形状#

Physical shapes consisting of simple primitives make collision calculations easier while keeping performance high and accuracy acceptable. Therefore, it is recommended to approximate geometry with simple primitives (Sphere, Capsule, Cylinder, Box), which are faster and less memory demanding.由简单图元组成的物理 shapes 使得碰撞计算更容易,同时保持高性能和准确性。因此,建议使用简单的图元( Sphere Capsule Cylinder Box )对几何进行近似估算更快,内存需求更少。

Complex shapes, such as Convex Hull and a set of autogenerated convex hulls, should be selected for representing complex and composite geometry when simple shapes don't allow achieving the desired goals.当复杂形状和复合几何无法实现所需的形状时,应选择复杂形状,例如凸包自动生成的凸包的集合期望的目标。

A car can be approximated using one complex shape and several simple shapes可以使用一个复杂的形状和几个简单的形状来近似汽车

At the same time you should keep the number of shapes as low as possible in order to avoid heavy calculations leading to the performance drop. Remember that a shape doesn't have to duplicate the mesh it approximates. Even though primitives are not precise, in most cases they provide acceptable results.同时​​,应将形状的数量保持为 low ,以避免繁琐的计算而导致性能下降。请记住,形状不必复制它近似的网格。即使基元不精确,在大多数情况下它们也可以提供可接受的结果。

Rough approximation is accurate enough粗略近似足够准确

Using Simpler Geometry使用更简单的几何#

The simpler geometry is used for surface collisions detection, the more performance will be gained.用于检测表面碰撞的几何形状越简单,将获得越多的性能。

If a mesh representing a physical obstacle has several levels of detail (LODs), the least detailed one is the most preferable for collision and intersection detection. Enable the Collision and Intersection options for this LOD and disable them for the other ones.如果代表物理障碍物的网格具有多个详细级别(LOD),则最不详细的级别最适合于碰撞和相交检测。对此LOD启用CollisionIntersection选项,对其他LOD禁用它们。

Use the lowest level of detail for intersections and collisions使用最低级别的相交和碰撞

Approximating collision shapes by using primitives is also a good practice. You can apply the following approach:使用基本体来逼近碰撞形状也是一种好习惯。您可以采用以下方法:

  1. Ensure that the original node is not a Collider — check that Collision flag is disabled for its surfaces, bodies, and shapes. Since now it is not taken into account by collision detection.确保原始节点不是 Collider —检查是否已禁用Collision标志的表面,实体和形状。从现在起,碰撞检测就不再考虑它了。

  2. Add a cylinder object to the scene by choosing Create -> Primitive -> Cylinder in the Menu Bar and cover the original mesh with the primitive.通过在菜单栏中选择Create -> Primitive -> Cylinder将圆柱对象添加到场景中,并用图元覆盖原始网格。

  3. Make sure that the Collision option of the surface is enabled for the primitive node. 请确保已为原始节点启用了曲面的Collision选项。
  4. Hide the visual representation of the primitive's surface. You can do it either by clearing its Viewport and Shadow masks or simply by setting its Max Visibility parameter to the negative infinity (-inf) — this ensures that the surface is not visible at any distance.隐藏基本体表面的视觉表示。您可以通过清除其ViewportShadow蒙版,或仅通过将其Max Visibility参数设置为负无穷大(-inf)来执行此操作,这可以确保在任何距离都看不到该表面。

    Now the detailed mesh provides only visual representation, while physical interactions are calculated for the primitive cylinder.现在,详细的网格仅提供视觉表示,而为原始圆柱体计算物理相互作用。

Collision Detection Approach碰撞检测方法#

Continuous Collision Detection is a very demanding operation, therefore, it is recommended to use this approach only for fast-moving objects and objects requiring precise calculations. 连续碰撞检测是一项非常苛刻的操作,因此,建议仅将这种方法用于快速移动的物体和需要精确计算的物体。

In most cases, Discrete Collision Detection would be enough. For this purpose, select a shape and uncheck the Continuous flag for it.在大多数情况下,离散碰撞检测就足够了。为此,请选择一个形状,然后取消选中Continuous标志。

Continuous collision detection is available for sphere and capsule shapes only.连续碰撞检测仅适用于球形胶囊形状。

Optimizing Physical Bodies优化身体#


It is recommended to enable Freezing to all Rigid, Ragdoll, and Fracturebodies. This allows saving a great deal of computational resources by skipping physical calculations of immobile objects until they are affected by any force or object.建议对所有Rigid, FractureRagdollbodies都启用Freezing。这样可以跳过不动对象的物理计算,直到它们受到任何力或对象的影响,从而节省大量计算资源。

To enable freezing, perform the following steps:要启用冻结,请执行以下步骤:

  1. Enable the Freezable flag for all types of physical bodies listed above.为上面列出的所有类型的身体启用Freezable标志。
  2. Set appropriate values of the Frozen Linear Velocity and Frozen Angular Velocity parameters for each physical body or adjust the global parameters. These global freezing thresholds are compared to the ones set for each body, and the highest value is chosen to freeze the body.

    设置适当的值Frozen Linear VelocityFrozen Angular Velocity每个身体的参数或调整全局参数。将这些全局冻结阈值与为每个身体设置的阈值进行比较,然后选择最大值以冻结身体。

  3. Adjust the number of Frozen Frames. The lower the value, the faster objects get frozen.调整Frozen Frames的数量。值越低,冻结的对象越快。


Although the fracture body is a relatively inexpensive type, in case of large number of fracture pieces, the impact on performance may become significant. To avoid performance drops, the following tips can be used:尽管断裂体是一种相对便宜的类型,但是在大量断裂件的情况下,对性能的影响可能会变得很大。为避免性能下降,可以使用以下技巧:

  • Use the Volume Threshold parameter to reduce the number of fracture pieces.使用Volume Threshold参数来减少断裂件的数量。
  • Remove the pieces of a fractured body from the scene.从场景中移除骨折的身体。

A code-based example illustrating how to remove (fade with the time) the fracture pieces from the scene can be found in the Physics section of the UnigineScript samples.可以在UnigineScript1示例Physics部分中找到一个基于代码的示例,该示例说明了如何从场景中删除(随时间消逝)碎片。

最新更新: 2020-10-10