MinieLibrary/src/test/java/jme3utilities/minie/test/TestDefaults.java
/**
     * Verify defaults common to all newly-created physics spaces.
     *
     * @param space the space to test (not null, unaffected)
     */
Verify defaults common to all newly-created physics spaces.
@param space the space to test (not null, unaffected)
Verify defaults common to all newly - created physics spaces . @param space the space to test ( not null unaffected )
private void testPhysicsSpace(PhysicsSpace space) {
        testCollisionSpace(space);
        Assert.assertEquals(0, space.countCollisionGroupListeners());
        Assert.assertEquals(0, space.countCollisionListeners());
        Assert.assertEquals(0, space.countJoints());
        Assert.assertEquals(0, space.countRigidBodies());
        Assert.assertEquals(0, space.countTickListeners());
        Assert.assertEquals(1 / 60f, space.getAccuracy(), 0f);
        MinieTest.assertEquals(0f, -9.81f, 0f, space.getGravity(null), 0f);
        Assert.assertFalse(space.isUsingScr());
        Assert.assertEquals(4, space.maxSubSteps());
        Assert.assertEquals(0.1f, space.maxTimeStep(), 0f);
        SolverInfo info = space.getSolverInfo();
        Assert.assertNotNull(info);
        Assert.assertNotEquals(0L, info.nativeId());
        Assert.assertEquals(0f, info.globalCfm(), 0f);
        Assert.assertEquals(128, info.minBatch());
        String className = space.getClass().getSimpleName();
        int expectedMode = (className.equals("MultiBodySpace")) ? 0x114 : 0x104;
        Assert.assertEquals(expectedMode, info.mode());
        Assert.assertEquals(10, info.numIterations());
        Assert.assertTrue(info.isSplitImpulseEnabled());
        Assert.assertEquals(0.1, info.splitImpulseErp(), 1e-6f);
        Assert.assertEquals(-0.04, info.splitImpulseThreshold(), 1e-7f);
        if (space instanceof MultiBodySpace) {
            MultiBodySpace mbSpace = (MultiBodySpace) space;
            Assert.assertEquals(0, mbSpace.countMultiBodies());
        } else if (space instanceof PhysicsSoftSpace) {
            PhysicsSoftSpace softSpace = (PhysicsSoftSpace) space;
            Assert.assertEquals(0, softSpace.countSoftBodies());
            SoftBodyWorldInfo sbwi = softSpace.getWorldInfo();
            Assert.assertEquals(1.2f, sbwi.airDensity(), 0f);
            MinieTest.assertEquals(0f, -9.81f, 0f, sbwi.copyGravity(null), 0f);
            Assert.assertEquals(1000f, sbwi.maxDisplacement(), 0f);
            Assert.assertEquals(0f, sbwi.waterDensity(), 0f);
            MinieTest.assertEquals(0f, 0f, 0f, sbwi.copyWaterNormal(null), 0f);
            Assert.assertEquals(0f, sbwi.waterOffset(), 0f);
        }
    }
private void testPhysicsSpace ( PhysicsSpace space ) { testCollisionSpace ( space ) ; Assert . assertEquals ( 0 , space . countCollisionGroupListeners ( ) ) ; Assert . assertEquals ( 0 , space . countCollisionListeners ( ) ) ; Assert . assertEquals ( 0 , space . countJoints ( ) ) ; Assert . assertEquals ( 0 , space . countRigidBodies ( ) ) ; Assert . assertEquals ( 0 , space . countTickListeners ( ) ) ; Assert . assertEquals ( 1 / 60f , space . getAccuracy ( ) , 0f ) ; MinieTest . assertEquals ( 0f , - 9.81f , 0f , space . getGravity ( null ) , 0f ) ; Assert . assertFalse ( space . isUsingScr ( ) ) ; Assert . assertEquals ( 4 , space . maxSubSteps ( ) ) ; Assert . assertEquals ( 0.1f , space . maxTimeStep ( ) , 0f ) ; SolverInfo info = space . getSolverInfo ( ) ; Assert . assertNotNull ( info ) ; Assert . assertNotEquals ( 0L , info . nativeId ( ) ) ; Assert . assertEquals ( 0f , info . globalCfm ( ) , 0f ) ; Assert . assertEquals ( 128 , info . minBatch ( ) ) ; String className = space . getClass ( ) . getSimpleName ( ) ; int expectedMode = ( className . equals ( "MultiBodySpace" ) ) ? 0x114 : 0x104 ; Assert . assertEquals ( expectedMode , info . mode ( ) ) ; Assert . assertEquals ( 10 , info . numIterations ( ) ) ; Assert . assertTrue ( info . isSplitImpulseEnabled ( ) ) ; Assert . assertEquals ( 0.1 , info . splitImpulseErp ( ) , 1e-6f ) ; Assert . assertEquals ( - 0.04 , info . splitImpulseThreshold ( ) , 1e-7f ) ; if ( space instanceof MultiBodySpace ) { MultiBodySpace mbSpace = ( MultiBodySpace ) space ; Assert . assertEquals ( 0 , mbSpace . countMultiBodies ( ) ) ; } else if ( space instanceof PhysicsSoftSpace ) { PhysicsSoftSpace softSpace = ( PhysicsSoftSpace ) space ; Assert . assertEquals ( 0 , softSpace . countSoftBodies ( ) ) ; SoftBodyWorldInfo sbwi = softSpace . getWorldInfo ( ) ; Assert . assertEquals ( 1.2f , sbwi . airDensity ( ) , 0f ) ; MinieTest . assertEquals ( 0f , - 9.81f , 0f , sbwi . copyGravity ( null ) , 0f ) ; Assert . assertEquals ( 1000f , sbwi . maxDisplacement ( ) , 0f ) ; Assert . assertEquals ( 0f , sbwi . waterDensity ( ) , 0f ) ; MinieTest . assertEquals ( 0f , 0f , 0f , sbwi . copyWaterNormal ( null ) , 0f ) ; Assert . assertEquals ( 0f , sbwi . waterOffset ( ) , 0f ) ; } }
Verify defaults common to all newly-created physics spaces.
Verify defaults common to all newly - created physics spaces .