@@ -52,7 +52,7 @@ public static B2Island b2CreateIsland(B2World world, int setIndex)
5252 island . joints = b2Array_Create < B2JointLink > ( ) ;
5353 island . constraintRemoveCount = 0 ;
5454
55- ref B2IslandSim islandSim = ref b2Array_Add ( ref set . islandSims ) ;
55+ ref B2IslandSim islandSim = ref b2Array_Emplace ( ref set . islandSims ) ;
5656 islandSim . islandId = islandId ;
5757
5858 return island ;
@@ -430,14 +430,14 @@ public static void b2SplitIsland(B2World world, int baseId)
430430 B2JointLink [ ] baseJoints = baseIsland . joints . data ;
431431 int baseJointCapacity = baseIsland . joints . capacity ;
432432
433- B2ArenaAllocator alloc = world . arena ;
433+ B2StackAllocator alloc = world . stack ;
434434
435435 // No lock is needed because I ensure the allocator is not used while this task is active.
436436 // Allocate contactCounts and jointCounts before ranks so ranks can be freed first (LIFO arena).
437- ArraySegment < int > parents = b2AllocateArenaItem < int > ( alloc , baseBodyCount , "parents" ) ;
438- ArraySegment < int > contactCounts = b2AllocateArenaItem < int > ( alloc , baseBodyCount , "contact counts" ) ;
439- ArraySegment < int > jointCounts = b2AllocateArenaItem < int > ( alloc , baseBodyCount , "joint counts" ) ;
440- ArraySegment < int > ranks = b2AllocateArenaItem < int > ( alloc , baseBodyCount , "ranks" ) ;
437+ ArraySegment < int > parents = b2StackAlloc < int > ( alloc , baseBodyCount , "parents" ) ;
438+ ArraySegment < int > contactCounts = b2StackAlloc < int > ( alloc , baseBodyCount , "contact counts" ) ;
439+ ArraySegment < int > jointCounts = b2StackAlloc < int > ( alloc , baseBodyCount , "joint counts" ) ;
440+ ArraySegment < int > ranks = b2StackAlloc < int > ( alloc , baseBodyCount , "ranks" ) ;
441441 for ( int i = 0 ; i < baseBodyCount ; ++ i )
442442 {
443443 parents [ i ] = i ;
@@ -507,7 +507,7 @@ public static void b2SplitIsland(B2World world, int baseId)
507507 }
508508
509509 // Done with ranks
510- b2FreeArenaItem ( alloc , ranks ) ;
510+ b2StackFree ( alloc , ranks ) ;
511511 ranks = null ;
512512
513513 // Flatten all parent indices and count connected components.
@@ -525,9 +525,9 @@ public static void b2SplitIsland(B2World world, int baseId)
525525 if ( componentCount == 1 )
526526 {
527527 baseIsland . constraintRemoveCount = 0 ;
528- b2FreeArenaItem ( alloc , jointCounts ) ;
529- b2FreeArenaItem ( alloc , contactCounts ) ;
530- b2FreeArenaItem ( alloc , parents ) ;
528+ b2StackFree ( alloc , jointCounts ) ;
529+ b2StackFree ( alloc , contactCounts ) ;
530+ b2StackFree ( alloc , parents ) ;
531531 return ;
532532 }
533533
@@ -548,15 +548,15 @@ public static void b2SplitIsland(B2World world, int baseId)
548548 baseIsland = null ;
549549
550550 // Map from body index to new island index. Only set for root bodies.
551- ArraySegment < int > rootMap = b2AllocateArenaItem < int > ( alloc , baseBodyCount , "root map" ) ;
551+ ArraySegment < int > rootMap = b2StackAlloc < int > ( alloc , baseBodyCount , "root map" ) ;
552552 for ( int i = 0 ; i < baseBodyCount ; ++ i )
553553 {
554554 rootMap [ i ] = B2_NULL_INDEX ;
555555 }
556556
557- ArraySegment < int > componentBodyCounts = b2AllocateArenaItem < int > ( alloc , componentCount , "component body counts" ) ;
558- ArraySegment < int > componentContactCounts = b2AllocateArenaItem < int > ( alloc , componentCount , "component contact counts" ) ;
559- ArraySegment < int > componentJointCounts = b2AllocateArenaItem < int > ( alloc , componentCount , "component joint counts" ) ;
557+ ArraySegment < int > componentBodyCounts = b2StackAlloc < int > ( alloc , componentCount , "component body counts" ) ;
558+ ArraySegment < int > componentContactCounts = b2StackAlloc < int > ( alloc , componentCount , "component contact counts" ) ;
559+ ArraySegment < int > componentJointCounts = b2StackAlloc < int > ( alloc , componentCount , "component joint counts" ) ;
560560 int islandCount = 0 ;
561561
562562 // Find the root body for each body and create islands as needed.
@@ -579,7 +579,7 @@ public static void b2SplitIsland(B2World world, int baseId)
579579 B2_ASSERT ( islandCount == componentCount ) ;
580580
581581 // Map from new island index to island id
582- ArraySegment < int > islandIds = b2AllocateArenaItem < int > ( alloc , islandCount , "island ids" ) ;
582+ ArraySegment < int > islandIds = b2StackAlloc < int > ( alloc , islandCount , "island ids" ) ;
583583
584584 // Create new islands and reserve body/contact/joint arrays
585585 for ( int i = 0 ; i < islandCount ; ++ i )
@@ -661,14 +661,14 @@ public static void b2SplitIsland(B2World world, int baseId)
661661 b2Free ( baseJoints , baseJointCapacity ) ;
662662
663663 // Free arena items in LIFO order
664- b2FreeArenaItem ( alloc , islandIds ) ;
665- b2FreeArenaItem ( alloc , componentJointCounts ) ;
666- b2FreeArenaItem ( alloc , componentContactCounts ) ;
667- b2FreeArenaItem ( alloc , componentBodyCounts ) ;
668- b2FreeArenaItem ( alloc , rootMap ) ;
669- b2FreeArenaItem ( alloc , jointCounts ) ;
670- b2FreeArenaItem ( alloc , contactCounts ) ;
671- b2FreeArenaItem ( alloc , parents ) ;
664+ b2StackFree ( alloc , islandIds ) ;
665+ b2StackFree ( alloc , componentJointCounts ) ;
666+ b2StackFree ( alloc , componentContactCounts ) ;
667+ b2StackFree ( alloc , componentBodyCounts ) ;
668+ b2StackFree ( alloc , rootMap ) ;
669+ b2StackFree ( alloc , jointCounts ) ;
670+ b2StackFree ( alloc , contactCounts ) ;
671+ b2StackFree ( alloc , parents ) ;
672672 }
673673
674674 // Split an island because some contacts and/or joints have been removed.
0 commit comments