| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL |
| | 6 | | { |
| | 7 | | public interface IPhysicsSyncController |
| | 8 | | { |
| | 9 | | bool isDirty { get; } |
| | 10 | | void MarkDirty(); |
| | 11 | | void Sync(); |
| | 12 | | } |
| | 13 | |
|
| | 14 | | public class PhysicsSyncController : IPhysicsSyncController |
| | 15 | | { |
| 0 | 16 | | public bool isDirty { get; private set; } = false; |
| | 17 | |
|
| 666 | 18 | | public PhysicsSyncController() |
| | 19 | | { |
| 666 | 20 | | Physics.autoSimulation = false; |
| 666 | 21 | | Physics.autoSyncTransforms = false; |
| 666 | 22 | | } |
| | 23 | |
|
| 38600 | 24 | | public void MarkDirty() { isDirty = true; } |
| | 25 | |
|
| | 26 | | public void Sync() |
| | 27 | | { |
| 36992 | 28 | | if (!isDirty) |
| 18270 | 29 | | return; |
| | 30 | |
|
| 18722 | 31 | | isDirty = false; |
| 18722 | 32 | | Physics.SyncTransforms(); |
| 18722 | 33 | | } |
| | 34 | | } |
| | 35 | | } |