Search Issue Tracker

By Design

Votes

0

Found in [Package]

1.4.0-pre.3 - Physics

Issue ID

ECSB-1732

Regression

No

Excessive CPU usage happens when a Mesh Collider is attached to imported .blend models

Package: Unity Physics

-

How to reproduce:
1. Open the attached “IN-105787” project
2. Open the “Test” Scene and and expand the foldout in the Hierarchy
3. Enable and expand the “New Sub Scene”
4. Disable GameObjects “Ship_FBXImport_NotLaggy_A” and “Ship_FBXImport_NotLaggy_B”
5. Enter Play mode
6. Open the Profiler window and start recording the Profiler information by clicking the red button
7. Observe the result

Expected result: The CPU Usage does not consistently exceed the target frame time
Actual result: The CPU Usage consistently exceeds the target frame time

Reproducible with: 1.2.1 (2022.3.64f1), 1.4.0-pre.3 (2022.3.64f1, 6000.0.53f1, 6000.1.11f1, 6000.2.0b9, 6000.3.0a1)

Reproduced on: Windows 11
Not reproduced on: No other environment tested

Notes:
- The issue does not occur when the “Ship_BlenderImport_Laggy_A” and “Ship_BlenderImport_Laggy_B” GameObjects are marked as Static
- The user reports that the memory size for the Blender Import is very large when viewed in the Entities Hierarchy Inspector View for the Physics Collider

  1. Resolution Note:

    The slow down is due to the fact that (1) the meshes are way too high density to be used for colliders, and (2) the meshes (both laggy and non-laggy) are all placed at exactly the same location.
    If the rigid bodies are marked as dynamic (which they are by default in the test scene) the collision detection will attempt to collide all these 4 ships with each other, trying to resolve contacts between them. Since the triangle density in these meshes is way too high for game physics the amount of computation then greatly exceeds real-time performance needs.
    Use a low poly mesh for the MeshCollider of your ships instead, or use multiple convex or primitive colliders instead.

    When marking the ships as static, the issue disappears since static will not collide with static, and therefore there is no work done in the collision detection.
    Also make sure that Burst is enabled under Jobs -> Burst -> Enable Compilation. Since Unity Physics is using Burst for high performance computations, if it is disabled, the simulation will be very slow in general, with or without "good" MeshCollider meshes.

    Considering all that, I "fixed" your scene by simply not having all 4 ships coincide at start and instead moving them apart. This makes the simulation run fast even with all 4 ships enabled. I would though recommend applying some of the tips I provided above to reduce the workload in your game.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.