diff --git a/engine/src/test/jme3test/bullet/TestBoneRagdoll.java b/engine/src/test/jme3test/bullet/TestBoneRagdoll.java index fd0254251..2cb23e6ab 100644 --- a/engine/src/test/jme3test/bullet/TestBoneRagdoll.java +++ b/engine/src/test/jme3test/bullet/TestBoneRagdoll.java @@ -80,6 +80,10 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi Node model; RagdollControl ragdoll; float bulletSize = 1f; + Material mat; + Material mat3; + private Sphere bullet; + private SphereCollisionShape bulletCollisionShape; public static void main(String[] args) { TestBoneRagdoll app = new TestBoneRagdoll(); @@ -90,6 +94,10 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi initCrossHairs(); initMaterial(); + bullet = new Sphere(32, 32, 1.0f, true, false); + bullet.setTextureMode(TextureMode.Projected); + bulletCollisionShape = new SphereCollisionShape(1.0f); + cam.setLocation(new Vector3f(0.26924422f, 6.646658f, 22.265987f)); cam.setRotation(new Quaternion(-2.302544E-4f, 0.99302495f, -0.117888905f, -0.0019395084f)); @@ -231,16 +239,6 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi private PhysicsSpace getPhysicsSpace() { return bulletAppState.getPhysicsSpace(); } - Material mat; - Material mat3; - private static final Sphere bullet; - private static SphereCollisionShape bulletCollisionShape; - - static { - bullet = new Sphere(32, 32, 1.0f, true, false); - bullet.setTextureMode(TextureMode.Projected); - bulletCollisionShape = new SphereCollisionShape(1.0f); - } public void initMaterial() { diff --git a/engine/src/test/jme3test/bullet/TestBrickTower.java b/engine/src/test/jme3test/bullet/TestBrickTower.java index 1daed8c9c..bb1026cab 100644 --- a/engine/src/test/jme3test/bullet/TestBrickTower.java +++ b/engine/src/test/jme3test/bullet/TestBrickTower.java @@ -79,18 +79,10 @@ public class TestBrickTower extends SimpleApplication { Material mat2; Material mat3; PssmShadowRenderer bsr; - private static final Sphere bullet; - private static final Box brick; - private static final SphereCollisionShape bulletCollisionShape; + private Sphere bullet; + private Box brick; + private SphereCollisionShape bulletCollisionShape; - static { - bullet = new Sphere(32, 32, 0.4f, true, false); - bullet.setTextureMode(TextureMode.Projected); - bulletCollisionShape = new SphereCollisionShape(0.4f); - - brick = new Box(Vector3f.ZERO, brickWidth, brickHeight, brickDepth); - brick.scaleTextureCoordinates(new Vector2f(1f, .5f)); - } private BulletAppState bulletAppState; public static void main(String args[]) { @@ -103,6 +95,12 @@ public class TestBrickTower extends SimpleApplication { bulletAppState = new BulletAppState(); bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); stateManager.attach(bulletAppState); + bullet = new Sphere(32, 32, 0.4f, true, false); + bullet.setTextureMode(TextureMode.Projected); + bulletCollisionShape = new SphereCollisionShape(0.4f); + + brick = new Box(Vector3f.ZERO, brickWidth, brickHeight, brickDepth); + brick.scaleTextureCoordinates(new Vector2f(1f, .5f)); // bulletAppState.getPhysicsSpace().enableDebug(assetManager); initMaterial(); initTower(); diff --git a/engine/src/test/jme3test/bullet/TestBrickWall.java b/engine/src/test/jme3test/bullet/TestBrickWall.java index a0d85ca88..570deb55f 100644 --- a/engine/src/test/jme3test/bullet/TestBrickWall.java +++ b/engine/src/test/jme3test/bullet/TestBrickWall.java @@ -39,8 +39,10 @@ import com.jme3.bullet.collision.shapes.BoxCollisionShape; import com.jme3.bullet.collision.shapes.SphereCollisionShape; import com.jme3.bullet.control.RigidBodyControl; import com.jme3.font.BitmapText; +import com.jme3.input.KeyInput; import com.jme3.input.MouseInput; import com.jme3.input.controls.ActionListener; +import com.jme3.input.controls.KeyTrigger; import com.jme3.input.controls.MouseButtonTrigger; import com.jme3.material.Material; import com.jme3.math.Vector2f; @@ -67,18 +69,10 @@ public class TestBrickWall extends SimpleApplication { Material mat2; Material mat3; BasicShadowRenderer bsr; - private static final Sphere bullet; - private static final Box brick; - private static final SphereCollisionShape bulletCollisionShape; + private static Sphere bullet; + private static Box brick; + private static SphereCollisionShape bulletCollisionShape; - static { - bullet = new Sphere(32, 32, 0.4f, true, false); - bullet.setTextureMode(TextureMode.Projected); - bulletCollisionShape = new SphereCollisionShape(0.4f); - - brick = new Box(Vector3f.ZERO, bLength, bHeight, bWidth); - brick.scaleTextureCoordinates(new Vector2f(1f, .5f)); - } private BulletAppState bulletAppState; public static void main(String args[]) { @@ -88,9 +82,20 @@ public class TestBrickWall extends SimpleApplication { @Override public void simpleInitApp() { + System.loadLibrary("bulletjme"); + PhysicsSpace.initNativePhysics(); + System.out.println("processors: " + Runtime.getRuntime().availableProcessors()); + bulletAppState = new BulletAppState(); bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); stateManager.attach(bulletAppState); + + bullet = new Sphere(32, 32, 0.4f, true, false); + bullet.setTextureMode(TextureMode.Projected); + bulletCollisionShape = new SphereCollisionShape(0.4f); + brick = new Box(Vector3f.ZERO, bLength, bHeight, bWidth); + brick.scaleTextureCoordinates(new Vector2f(1f, .5f)); + initMaterial(); initWall(); initFloor(); @@ -100,6 +105,8 @@ public class TestBrickWall extends SimpleApplication { cam.setFrustumFar(15); inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); inputManager.addListener(actionListener, "shoot"); + inputManager.addMapping("gc", new KeyTrigger(KeyInput.KEY_X)); + inputManager.addListener(actionListener, "gc"); rootNode.setShadowMode(ShadowMode.Off); bsr = new BasicShadowRenderer(assetManager, 256); @@ -118,6 +125,8 @@ public class TestBrickWall extends SimpleApplication { bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(cam.getLocation()); + + SphereCollisionShape bulletCollisionShape = new SphereCollisionShape(0.4f); RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1); // RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1); bulletNode.setLinearVelocity(cam.getDirection().mult(25)); @@ -125,6 +134,9 @@ public class TestBrickWall extends SimpleApplication { rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletNode); } + if (name.equals("gc") && !keyPressed) { + System.gc(); + } } }; diff --git a/engine/src/test/jme3test/bullet/TestCcd.java b/engine/src/test/jme3test/bullet/TestCcd.java index f0af517d7..5ed99ef04 100644 --- a/engine/src/test/jme3test/bullet/TestCcd.java +++ b/engine/src/test/jme3test/bullet/TestCcd.java @@ -61,16 +61,10 @@ public class TestCcd extends SimpleApplication implements ActionListener{ private Material mat; private Material mat2; - private static final Sphere bullet; - private static final SphereCollisionShape bulletCollisionShape; + private Sphere bullet; + private SphereCollisionShape bulletCollisionShape; private BulletAppState bulletAppState; - static { - bullet = new Sphere(32, 32, 0.4f, true, false); - bullet.setTextureMode(TextureMode.Projected); - bulletCollisionShape = new SphereCollisionShape(0.1f); - } - public static void main(String[] args) { TestCcd app = new TestCcd(); app.start(); @@ -88,6 +82,9 @@ public class TestCcd extends SimpleApplication implements ActionListener{ bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.getPhysicsSpace().enableDebug(assetManager); + bullet = new Sphere(32, 32, 0.4f, true, false); + bullet.setTextureMode(TextureMode.Projected); + bulletCollisionShape = new SphereCollisionShape(0.1f); setupKeys(); mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md"); diff --git a/engine/src/test/jme3test/bullet/TestCollisionListener.java b/engine/src/test/jme3test/bullet/TestCollisionListener.java index c134976ed..3c6c38c9b 100644 --- a/engine/src/test/jme3test/bullet/TestCollisionListener.java +++ b/engine/src/test/jme3test/bullet/TestCollisionListener.java @@ -52,14 +52,8 @@ public class TestCollisionListener extends SimpleApplication implements PhysicsC private BulletAppState bulletAppState; private Material mat; - private static final Sphere bullet; - private static final SphereCollisionShape bulletCollisionShape; - - static { - bullet = new Sphere(32, 32, 0.4f, true, false); - bullet.setTextureMode(TextureMode.Projected); - bulletCollisionShape = new SphereCollisionShape(0.4f); - } + private Sphere bullet; + private SphereCollisionShape bulletCollisionShape; public static void main(String[] args) { TestCollisionListener app = new TestCollisionListener(); @@ -71,6 +65,9 @@ public class TestCollisionListener extends SimpleApplication implements PhysicsC bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.getPhysicsSpace().enableDebug(assetManager); + bullet = new Sphere(32, 32, 0.4f, true, false); + bullet.setTextureMode(TextureMode.Projected); + bulletCollisionShape = new SphereCollisionShape(0.4f); PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); PhysicsTestHelper.createBallShooter(this, rootNode, bulletAppState.getPhysicsSpace()); diff --git a/engine/src/test/jme3test/bullet/TestPhysicsCharacter.java b/engine/src/test/jme3test/bullet/TestPhysicsCharacter.java index c7c0fc5f8..dfb114d1d 100644 --- a/engine/src/test/jme3test/bullet/TestPhysicsCharacter.java +++ b/engine/src/test/jme3test/bullet/TestPhysicsCharacter.java @@ -59,14 +59,8 @@ public class TestPhysicsCharacter extends SimpleApplication implements ActionLis private CharacterControl physicsCharacter; private Vector3f walkDirection = new Vector3f(); private Material mat; - private static final Sphere bullet; - private static final SphereCollisionShape bulletCollisionShape; - - static { - bullet = new Sphere(32, 32, 0.4f, true, false); - bullet.setTextureMode(TextureMode.Projected); - bulletCollisionShape = new SphereCollisionShape(0.4f); - } + private Sphere bullet; + private SphereCollisionShape bulletCollisionShape; public static void main(String[] args) { TestPhysicsCharacter app = new TestPhysicsCharacter(); @@ -86,12 +80,17 @@ public class TestPhysicsCharacter extends SimpleApplication implements ActionLis inputManager.addListener(this, "Ups"); inputManager.addListener(this, "Downs"); inputManager.addListener(this, "Space"); + inputManager.addMapping("gc", new KeyTrigger(KeyInput.KEY_X)); + inputManager.addListener(this, "gc"); } @Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); + bullet = new Sphere(32, 32, 0.4f, true, false); + bullet.setTextureMode(TextureMode.Projected); + bulletCollisionShape = new SphereCollisionShape(0.4f); PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); setupKeys(); @@ -151,5 +150,8 @@ public class TestPhysicsCharacter extends SimpleApplication implements ActionLis } else if (binding.equals("Space")) { physicsCharacter.jump(); } + if (binding.equals("gc") && !value) { + System.gc(); + } } }