|
2 | 2 | // SPDX-FileCopyrightText: 2025 Ikpil Choi([email protected]) |
3 | 3 | // SPDX-License-Identifier: MIT |
4 | 4 |
|
| 5 | +using System.Runtime.CompilerServices; |
| 6 | + |
5 | 7 | namespace Box2D.NET |
6 | 8 | { |
7 | 9 | /** |
@@ -41,71 +43,89 @@ public static class B2Ids |
41 | 43 | public static readonly B2JointId b2_nullJointId = new B2JointId(0, 0, 0); |
42 | 44 |
|
43 | 45 | /// Macro to determine if any id is null. |
| 46 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
44 | 47 | public static bool B2_IS_NULL(B2WorldId id) => id.index1 == 0; |
45 | | - |
| 48 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
46 | 49 | public static bool B2_IS_NULL(B2BodyId id) => id.index1 == 0; |
| 50 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
47 | 51 | public static bool B2_IS_NULL(B2ShapeId id) => id.index1 == 0; |
| 52 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
48 | 53 | public static bool B2_IS_NULL(B2ChainId id) => id.index1 == 0; |
| 54 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
49 | 55 | public static bool B2_IS_NULL(B2JointId id) => id.index1 == 0; |
50 | | - |
| 56 | + |
51 | 57 | /// Macro to determine if any id is non-null. |
| 58 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
52 | 59 | public static bool B2_IS_NON_NULL(B2WorldId id) => id.index1 != 0; |
53 | | - |
| 60 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
54 | 61 | public static bool B2_IS_NON_NULL(B2BodyId id) => id.index1 != 0; |
| 62 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
55 | 63 | public static bool B2_IS_NON_NULL(B2ShapeId id) => id.index1 != 0; |
| 64 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
56 | 65 | public static bool B2_IS_NON_NULL(B2ChainId id) => id.index1 != 0; |
| 66 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
57 | 67 | public static bool B2_IS_NON_NULL(B2JointId id) => id.index1 != 0; |
58 | 68 |
|
59 | 69 | /// Compare two ids for equality. Doesn't work for b2WorldId. |
| 70 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
60 | 71 | public static bool B2_ID_EQUALS(B2BodyId id1, B2BodyId id2) => id1.index1 == id2.index1 && id1.world0 == id2.world0 && id1.generation == id2.generation; |
| 72 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
61 | 73 | public static bool B2_ID_EQUALS(B2ShapeId id1, B2ShapeId id2) => id1.index1 == id2.index1 && id1.world0 == id2.world0 && id1.generation == id2.generation; |
62 | 74 |
|
63 | 75 | /// Store a body id into a ulong. |
| 76 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
64 | 77 | public static ulong b2StoreBodyId(B2BodyId id) |
65 | 78 | { |
66 | 79 | return ((ulong)id.index1 << 32) | ((ulong)id.world0) << 16 | (ulong)id.generation; |
67 | 80 | } |
68 | 81 |
|
69 | 82 | /// Load a ulong into a body id. |
| 83 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
70 | 84 | public static B2BodyId b2LoadBodyId(ulong x) |
71 | 85 | { |
72 | 86 | B2BodyId id = new B2BodyId((int)(x >> 32), (ushort)(x >> 16), (ushort)(x)); |
73 | 87 | return id; |
74 | 88 | } |
75 | 89 |
|
76 | 90 | /// Store a shape id into a ulong. |
| 91 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
77 | 92 | public static ulong b2StoreShapeId(B2ShapeId id) |
78 | 93 | { |
79 | 94 | return ((ulong)id.index1 << 32) | ((ulong)id.world0) << 16 | (ulong)id.generation; |
80 | 95 | } |
81 | 96 |
|
82 | 97 | /// Load a ulong into a shape id. |
| 98 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
83 | 99 | public static B2ShapeId b2LoadShapeId(ulong x) |
84 | 100 | { |
85 | 101 | B2ShapeId id = new B2ShapeId((int)(x >> 32), (ushort)(x >> 16), (ushort)(x)); |
86 | 102 | return id; |
87 | 103 | } |
88 | 104 |
|
89 | 105 | /// Store a chain id into a ulong. |
| 106 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
90 | 107 | public static ulong b2StoreChainId(B2ChainId id) |
91 | 108 | { |
92 | 109 | return ((ulong)id.index1 << 32) | ((ulong)id.world0) << 16 | (ulong)id.generation; |
93 | 110 | } |
94 | 111 |
|
95 | 112 | /// Load a ulong into a chain id. |
| 113 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
96 | 114 | public static B2ChainId b2LoadChainId(ulong x) |
97 | 115 | { |
98 | 116 | B2ChainId id = new B2ChainId((int)(x >> 32), (ushort)(x >> 16), (ushort)(x)); |
99 | 117 | return id; |
100 | 118 | } |
101 | 119 |
|
102 | 120 | /// Store a joint id into a ulong. |
| 121 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
103 | 122 | public static ulong b2StoreJointId(B2JointId id) |
104 | 123 | { |
105 | 124 | return ((ulong)id.index1 << 32) | ((ulong)id.world0) << 16 | (ulong)id.generation; |
106 | 125 | } |
107 | 126 |
|
108 | 127 | /// Load a ulong into a joint id. |
| 128 | + [MethodImpl(MethodImplOptions.AggressiveInlining)] |
109 | 129 | public static B2JointId b2LoadJointId(ulong x) |
110 | 130 | { |
111 | 131 | B2JointId id = new B2JointId((int)(x >> 32), (ushort)(x >> 16), (ushort)(x)); |
|
0 commit comments