@@ -132,6 +132,8 @@ internal IBody3D CreateBody(Entity entity, World world)
132132 return default ;
133133 }
134134
135+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
136+
135137 return Impl . CreateBody ( entity , world ) ;
136138 }
137139
@@ -166,6 +168,8 @@ internal bool CreateBox(Entity entity, Vector3 extents, Vector3 position, Quater
166168 return false ;
167169 }
168170
171+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
172+
169173 return Impl . CreateBox ( entity , extents , position , rotation , motionType , layer , isTrigger , gravityFactor ,
170174 friction , restitution , freezeX , freezeY , freezeZ , is2DPlane , mass , out body ) ;
171175 }
@@ -201,6 +205,8 @@ internal bool CreateSphere(Entity entity, float radius, Vector3 position, Quater
201205 return false ;
202206 }
203207
208+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
209+
204210 return Impl . CreateSphere ( entity , radius , position , rotation , motionType , layer , isTrigger , gravityFactor ,
205211 friction , restitution , freezeX , freezeY , freezeZ , is2DPlane , mass , out body ) ;
206212 }
@@ -237,6 +243,8 @@ internal bool CreateCapsule(Entity entity, float height, float radius, Vector3 p
237243 return false ;
238244 }
239245
246+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
247+
240248 return Impl . CreateCapsule ( entity , height , radius , position , rotation , motionType , layer , isTrigger , gravityFactor ,
241249 friction , restitution , freezeX , freezeY , freezeZ , is2DPlane , mass , out body ) ;
242250 }
@@ -273,6 +281,8 @@ internal bool CreateCylinder(Entity entity, float height, float radius, Vector3
273281 return false ;
274282 }
275283
284+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
285+
276286 return Impl . CreateCylinder ( entity , height , radius , position , rotation , motionType , layer , isTrigger , gravityFactor ,
277287 friction , restitution , freezeX , freezeY , freezeZ , is2DPlane , mass , out body ) ;
278288 }
@@ -308,6 +318,8 @@ internal bool CreateMesh(Entity entity, Mesh mesh, Vector3 position, Quaternion
308318 return false ;
309319 }
310320
321+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
322+
311323 return Impl . CreateMesh ( entity , mesh , position , rotation , motionType , layer , isTrigger , gravityFactor ,
312324 friction , restitution , freezeX , freezeY , freezeZ , is2DPlane , mass , out body ) ;
313325 }
@@ -337,6 +349,8 @@ internal bool CreateHeightMap(Entity entity, float[] heights, Vector3 offset, Ve
337349 return false ;
338350 }
339351
352+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
353+
340354 return Impl . CreateHeightMap ( entity , heights , offset , scale , position , rotation , layer , friction , restitution , mass , out body ) ;
341355 }
342356
@@ -351,6 +365,8 @@ internal void DestroyBody(IBody3D body)
351365 return ;
352366 }
353367
368+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
369+
354370 Impl . DestroyBody ( body ) ;
355371 }
356372
@@ -364,6 +380,8 @@ internal void DestroyAllBodies()
364380 return ;
365381 }
366382
383+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
384+
367385 Impl . DestroyAllBodies ( ) ;
368386 }
369387
@@ -379,6 +397,8 @@ internal void AddBody(IBody3D body, bool activated)
379397 return ;
380398 }
381399
400+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
401+
382402 Impl . AddBody ( body , activated ) ;
383403 }
384404
@@ -393,6 +413,8 @@ internal void RemoveBody(IBody3D body)
393413 return ;
394414 }
395415
416+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
417+
396418 Impl . RemoveBody ( body ) ;
397419 }
398420
@@ -416,6 +438,8 @@ public bool RayCast(Ray ray, out IBody3D body, out float fraction, LayerMask lay
416438 return false ;
417439 }
418440
441+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
442+
419443 return Impl . RayCast ( ray , out body , out fraction , layerMask , triggerQuery , maxDistance ) ;
420444 }
421445
@@ -431,6 +455,8 @@ public float GravityFactor(IBody3D body)
431455 return default ;
432456 }
433457
458+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
459+
434460 return Impl . GravityFactor ( body ) ;
435461 }
436462
@@ -446,6 +472,8 @@ public void SetGravityFactor(IBody3D body, float factor)
446472 return ;
447473 }
448474
475+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
476+
449477 Impl . SetGravityFactor ( body , factor ) ;
450478 }
451479
@@ -461,6 +489,8 @@ public void SetBodyPosition(IBody3D body, Vector3 newPosition)
461489 return ;
462490 }
463491
492+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
493+
464494 Impl . SetBodyPosition ( body , newPosition ) ;
465495 }
466496
@@ -476,6 +506,8 @@ public void SetBodyRotation(IBody3D body, Quaternion newRotation)
476506 return ;
477507 }
478508
509+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
510+
479511 Impl . SetBodyRotation ( body , newRotation ) ;
480512 }
481513
@@ -491,6 +523,8 @@ public void SetBodyTrigger(IBody3D body, bool value)
491523 return ;
492524 }
493525
526+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
527+
494528 Impl . SetBodyTrigger ( body , value ) ;
495529 }
496530
@@ -506,6 +540,8 @@ public IBody3D GetBody(Entity entity)
506540 return default ;
507541 }
508542
543+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
544+
509545 return Impl . GetBody ( entity ) ;
510546 }
511547
@@ -521,6 +557,8 @@ public void AddForce(IBody3D body, Vector3 force)
521557 return ;
522558 }
523559
560+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
561+
524562 Impl . AddForce ( body , force ) ;
525563 }
526564
@@ -536,6 +574,8 @@ public void AddImpulse(IBody3D body, Vector3 impulse)
536574 return ;
537575 }
538576
577+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
578+
539579 Impl . AddImpulse ( body , impulse ) ;
540580 }
541581
@@ -551,6 +591,8 @@ public void AddAngularImpulse(IBody3D body, Vector3 impulse)
551591 return ;
552592 }
553593
594+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
595+
554596 Impl . AddAngularImpulse ( body , impulse ) ;
555597 }
556598
@@ -565,7 +607,9 @@ public void RecreateBody(Entity entity)
565607 return ;
566608 }
567609
568- if ( entity . TryGetComponent < RigidBody3D > ( out var rigidBody ) )
610+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
611+
612+ if ( entity . TryGetComponent < RigidBody3D > ( out var rigidBody ) )
569613 {
570614 if ( rigidBody . body != null )
571615 {
@@ -609,6 +653,8 @@ public void Startup()
609653 return ;
610654 }
611655
656+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
657+
612658 var rigidBody = ( RigidBody3D ) component ;
613659
614660 rigidBody . body = CreateBody ( entity , world ) ;
@@ -621,6 +667,8 @@ public void Startup()
621667 return ;
622668 }
623669
670+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
671+
624672 var character = ( Character3D ) component ;
625673
626674 character . body = CreateBody ( entity , world ) ;
@@ -633,6 +681,8 @@ public void Startup()
633681 return ;
634682 }
635683
684+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
685+
636686 var rigidBody = ( RigidBody3D ) component ;
637687
638688 DestroyBody ( rigidBody . body ) ;
@@ -647,6 +697,8 @@ public void Startup()
647697 return ;
648698 }
649699
700+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
701+
650702 var character = ( Character3D ) component ;
651703
652704 DestroyBody ( character . body ) ;
@@ -683,7 +735,9 @@ public void Update()
683735 return ;
684736 }
685737
686- if ( needsSubsystemCheck )
738+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
739+
740+ if ( needsSubsystemCheck )
687741 {
688742 needsSubsystemCheck = false ;
689743
@@ -698,6 +752,8 @@ public void Update()
698752
699753 public void BodyActivated ( IBody3D body )
700754 {
755+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
756+
701757 lock ( lockObject )
702758 {
703759 foreach ( var system in physicsReceivers )
@@ -709,6 +765,8 @@ public void BodyActivated(IBody3D body)
709765
710766 public void BodyDeactivated ( IBody3D body )
711767 {
768+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
769+
712770 lock ( lockObject )
713771 {
714772 foreach ( var system in physicsReceivers )
@@ -720,6 +778,8 @@ public void BodyDeactivated(IBody3D body)
720778
721779 public void ContactAdded ( IBody3D A , IBody3D B )
722780 {
781+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
782+
723783 lock ( lockObject )
724784 {
725785 foreach ( var system in physicsReceivers )
@@ -731,6 +791,8 @@ public void ContactAdded(IBody3D A, IBody3D B)
731791
732792 public void ContactPersisted ( IBody3D A , IBody3D B )
733793 {
794+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
795+
734796 lock ( lockObject )
735797 {
736798 foreach ( var system in physicsReceivers )
@@ -742,6 +804,8 @@ public void ContactPersisted(IBody3D A, IBody3D B)
742804
743805 public void ContactRemoved ( IBody3D A , IBody3D B )
744806 {
807+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
808+
745809 lock ( lockObject )
746810 {
747811 foreach ( var system in physicsReceivers )
@@ -753,6 +817,8 @@ public void ContactRemoved(IBody3D A, IBody3D B)
753817
754818 public bool ContactValidate ( IBody3D A , IBody3D B )
755819 {
820+ using var profiler = new PerformanceProfiler ( PerformanceProfilerType . Physics ) ;
821+
756822 lock ( lockObject )
757823 {
758824 foreach ( var system in physicsReceivers )
0 commit comments