@@ -21,8 +21,15 @@ of this software and associated documentation files (the "Software"), to deal
2121 */
2222package testjoltjni .junit ;
2323
24+ import com .github .stephengold .joltjni .CollideSettingsBase ;
2425import com .github .stephengold .joltjni .CollisionGroup ;
2526import com .github .stephengold .joltjni .GroupFilterTable ;
27+ import com .github .stephengold .joltjni .PhysicsSettings ;
28+ import com .github .stephengold .joltjni .ShapeCastSettings ;
29+ import com .github .stephengold .joltjni .Vec3 ;
30+ import com .github .stephengold .joltjni .enumerate .EActiveEdgeMode ;
31+ import com .github .stephengold .joltjni .enumerate .EBackFaceMode ;
32+ import com .github .stephengold .joltjni .enumerate .ECollectFacesMode ;
2633import com .github .stephengold .joltjni .readonly .ConstCollisionGroup ;
2734import com .github .stephengold .joltjni .readonly .ConstGroupFilter ;
2835import org .junit .Assert ;
@@ -48,6 +55,7 @@ public void test018() {
4855 TestUtils .initializeNativeLibrary ();
4956
5057 doCollisionGroup ();
58+ doShapeCastSettings ();
5159
5260 TestUtils .cleanup ();
5361 }
@@ -71,6 +79,66 @@ private static void doCollisionGroup() {
7179 System .gc ();
7280 }
7381
82+ /**
83+ * Test the {@code ShapeCastSettings} class.
84+ */
85+ private static void doShapeCastSettings () {
86+ ShapeCastSettings settings = new ShapeCastSettings ();
87+
88+ testShapeCastSettingsDefaults (settings );
89+ ShapeCastSettings copy = new ShapeCastSettings (settings );
90+ testShapeCastSettingsSetters (settings );
91+ testShapeCastSettingsDefaults (copy );
92+ settings .set (copy );
93+ testShapeCastSettingsDefaults (settings );
94+
95+ TestUtils .testClose (copy , settings );
96+ System .gc ();
97+ }
98+
99+ /**
100+ * Test the getters and defaults of the specified
101+ * {@code CollideSettingsBase}.
102+ *
103+ * @param settings the settings to test (not {@code null}, unaffected)
104+ */
105+ private static void testCollideSettingsBaseDefaults (
106+ CollideSettingsBase settings ) {
107+ Assert .assertEquals (EActiveEdgeMode .CollideOnlyWithActive ,
108+ settings .getActiveEdgeMode ());
109+ TestUtils .assertEquals (0f , 0f , 0f ,
110+ settings .getActiveEdgeMovementDirection (), 0f );
111+ Assert .assertEquals (ECollectFacesMode .NoFaces ,
112+ settings .getCollectFacesMode ());
113+ Assert .assertEquals (PhysicsSettings .cDefaultCollisionTolerance ,
114+ settings .getCollisionTolerance (), 0f );
115+ Assert .assertEquals (PhysicsSettings .cDefaultPenetrationTolerance ,
116+ settings .getPenetrationTolerance (), 0f );
117+ }
118+
119+ /**
120+ * Test the setters of the specified {@code CollideSettingsBase}.
121+ *
122+ * @param settings the settings to test (not {@code null})
123+ */
124+ private static void testCollideSettingsBaseSetters (
125+ CollideSettingsBase settings ) {
126+ settings .setActiveEdgeMode (EActiveEdgeMode .CollideWithAll );
127+ settings .setActiveEdgeMovementDirection (new Vec3 (1f , 2f , 3f ));
128+ settings .setCollectFacesMode (ECollectFacesMode .CollectFaces );
129+ settings .setCollisionTolerance (0.4f );
130+ settings .setPenetrationTolerance (0.5f );
131+
132+ Assert .assertEquals (EActiveEdgeMode .CollideWithAll ,
133+ settings .getActiveEdgeMode ());
134+ TestUtils .assertEquals (1f , 2f , 3f ,
135+ settings .getActiveEdgeMovementDirection (), 0f );
136+ Assert .assertEquals (ECollectFacesMode .CollectFaces ,
137+ settings .getCollectFacesMode ());
138+ Assert .assertEquals (0.4f , settings .getCollisionTolerance (), 0f );
139+ Assert .assertEquals (0.5f , settings .getPenetrationTolerance (), 0f );
140+ }
141+
74142 /**
75143 * Test the getters and defaults of the specified {@code CollisionGroup}.
76144 *
@@ -101,4 +169,43 @@ private static void testCollisionGroupSetters(CollisionGroup group) {
101169
102170 TestUtils .testClose (actualFilter , filter );
103171 }
172+
173+ /**
174+ * Test the getters and defaults of the specified {@code ShapeCastSettings}.
175+ *
176+ * @param settings the settings to test (not {@code null}, unaffected)
177+ */
178+ private static void testShapeCastSettingsDefaults (
179+ ShapeCastSettings settings ) {
180+ testCollideSettingsBaseDefaults (settings );
181+
182+ Assert .assertEquals (EBackFaceMode .IgnoreBackFaces ,
183+ settings .getBackFaceModeConvex ());
184+ Assert .assertEquals (EBackFaceMode .IgnoreBackFaces ,
185+ settings .getBackFaceModeTriangles ());
186+ Assert .assertFalse (settings .getReturnDeepestPoint ());
187+ Assert .assertFalse (settings .getUseShrunkenShapeAndConvexRadius ());
188+ }
189+
190+ /**
191+ * Test the setters of the specified {@code ShapeCastSettings}.
192+ *
193+ * @param settings the group to test (not {@code null})
194+ */
195+ private static void testShapeCastSettingsSetters (
196+ ShapeCastSettings settings ) {
197+ settings .setBackFaceModeConvex (EBackFaceMode .CollideWithBackFaces );
198+ settings .setBackFaceModeTriangles (EBackFaceMode .CollideWithBackFaces );
199+ settings .setReturnDeepestPoint (true );
200+ settings .setUseShrunkenShapeAndConvexRadius (true );
201+
202+ testCollideSettingsBaseSetters (settings );
203+
204+ Assert .assertEquals (EBackFaceMode .CollideWithBackFaces ,
205+ settings .getBackFaceModeConvex ());
206+ Assert .assertEquals (EBackFaceMode .CollideWithBackFaces ,
207+ settings .getBackFaceModeTriangles ());
208+ Assert .assertTrue (settings .getReturnDeepestPoint ());
209+ Assert .assertTrue (settings .getUseShrunkenShapeAndConvexRadius ());
210+ }
104211}
0 commit comments