Skip to content

Commit 39d09de

Browse files
authored
jme3-examples: convert fields to local variables (#1501)
1 parent 8edbb5b commit 39d09de

File tree

70 files changed

+270
-385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+270
-385
lines changed

jme3-examples/src/main/java/jme3test/animation/TestCinematic.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2020 jMonkeyEngine
2+
* Copyright (c) 2009-2021 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -57,11 +57,9 @@ public class TestCinematic extends SimpleApplication {
5757

5858
private Spatial model;
5959
private Spatial teapot;
60-
private MotionPath path;
6160
private MotionEvent cameraMotionEvent;
6261
private Cinematic cinematic;
6362
private ChaseCamera chaseCam;
64-
private FilterPostProcessor fpp;
6563
private FadeFilter fade;
6664
private float time = 0;
6765

@@ -181,7 +179,7 @@ private void createCameraMotion() {
181179
camNode.lookAt(teapot.getLocalTranslation(), Vector3f.UNIT_Y);
182180

183181
CameraNode camNode2 = cinematic.bindCamera("aroundCam", cam);
184-
path = new MotionPath();
182+
MotionPath path = new MotionPath();
185183
path.setCycle(true);
186184
path.addWayPoint(new Vector3f(20, 3, 0));
187185
path.addWayPoint(new Vector3f(0, 3, 20));
@@ -227,7 +225,7 @@ private void createScene() {
227225
light.setColor(ColorRGBA.White.mult(1.5f));
228226
rootNode.addLight(light);
229227

230-
fpp = new FilterPostProcessor(assetManager);
228+
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
231229
fade = new FadeFilter();
232230
fpp.addFilter(fade);
233231

jme3-examples/src/main/java/jme3test/audio/TestAmbient.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2012 jMonkeyEngine
2+
* Copyright (c) 2009-2021 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -43,8 +43,6 @@
4343

4444
public class TestAmbient extends SimpleApplication {
4545

46-
private AudioNode nature, waves;
47-
4846
public static void main(String[] args) {
4947
TestAmbient test = new TestAmbient();
5048
test.start();
@@ -59,15 +57,15 @@ public void simpleInitApp() {
5957
Environment env = new Environment(eax);
6058
audioRenderer.setEnvironment(env);
6159

62-
waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg",
63-
DataType.Buffer);
60+
AudioNode waves = new AudioNode(assetManager,
61+
"Sound/Environment/Ocean Waves.ogg", DataType.Buffer);
6462
waves.setPositional(true);
6563
waves.setLocalTranslation(new Vector3f(0, 0,0));
6664
waves.setMaxDistance(100);
6765
waves.setRefDistance(5);
6866

69-
nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg",
70-
DataType.Stream);
67+
AudioNode nature = new AudioNode(assetManager,
68+
"Sound/Environment/Nature.ogg", DataType.Stream);
7169
nature.setPositional(false);
7270
nature.setVolume(3);
7371

jme3-examples/src/main/java/jme3test/batching/TestBatchNodeCluster.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ public int getz(int i) {
331331
return zPosition.get(i);
332332
}
333333
private float time = 0;
334-
private Spatial box;
335334

336335
@Override
337336
public void simpleUpdate(float tpf) {
@@ -352,7 +351,7 @@ public void simpleUpdate(float tpf) {
352351
mult1 = -1.0f;
353352
mult2 = -1.0f;
354353
}
355-
box = batchNode.getChild("Box" + random);
354+
Spatial box = batchNode.getChild("Box" + random);
356355
if (box != null) {
357356
Vector3f v = box.getLocalTranslation();
358357
box.setLocalTranslation(v.x + FastMath.sin(time * mult1) * 20, v.y + (FastMath.sin(time * mult1) * FastMath.cos(time * mult1) * 20), v.z + FastMath.cos(time * mult2) * 20);

jme3-examples/src/main/java/jme3test/batching/TestBatchNodeTower.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public class TestBatchNodeTower extends SimpleApplication {
7878
private Material mat;
7979
private Material mat2;
8080
private Material mat3;
81-
private DirectionalLightShadowFilter shadowRenderer;
8281
private Sphere bullet;
8382
private Box brick;
8483
private SphereCollisionShape bulletCollisionShape;
@@ -120,9 +119,9 @@ public void simpleInitApp() {
120119
batchNode.batch();
121120
batchNode.setShadowMode(ShadowMode.CastAndReceive);
122121
rootNode.attachChild(batchNode);
123-
124-
125-
shadowRenderer = new DirectionalLightShadowFilter(assetManager, 1024, 2);
122+
123+
DirectionalLightShadowFilter shadowRenderer
124+
= new DirectionalLightShadowFilter(assetManager, 1024, 2);
126125
DirectionalLight dl = new DirectionalLight();
127126
dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
128127
shadowRenderer.setLight(dl);

jme3-examples/src/main/java/jme3test/bullet/TestAttachDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
public class TestAttachDriver extends SimpleApplication implements ActionListener {
6161

6262
private VehicleControl vehicle;
63-
private RigidBodyControl driver;
6463
private RigidBodyControl bridge;
6564
private SliderJoint slider;
6665
private final float accelerationForce = 1000.0f;
@@ -202,7 +201,8 @@ private void buildPlayer() {
202201
//driver
203202
Node driverNode=new Node("driverNode");
204203
driverNode.setLocalTranslation(0,2,0);
205-
driver=new RigidBodyControl(new BoxCollisionShape(new Vector3f(0.2f,.5f,0.2f)));
204+
RigidBodyControl driver
205+
= new RigidBodyControl(new BoxCollisionShape(new Vector3f(0.2f,.5f,0.2f)));
206206
driverNode.addControl(driver);
207207

208208
rootNode.attachChild(driverNode);

jme3-examples/src/main/java/jme3test/bullet/TestCollisionListener.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
public class TestCollisionListener extends SimpleApplication implements PhysicsCollisionListener {
4949

5050
private BulletAppState bulletAppState;
51-
private Sphere bullet;
5251

5352
public static void main(String[] args) {
5453
TestCollisionListener app = new TestCollisionListener();
@@ -60,7 +59,7 @@ public void simpleInitApp() {
6059
bulletAppState = new BulletAppState();
6160
stateManager.attach(bulletAppState);
6261
bulletAppState.setDebugEnabled(true);
63-
bullet = new Sphere(32, 32, 0.4f, true, false);
62+
Sphere bullet = new Sphere(32, 32, 0.4f, true, false);
6463
bullet.setTextureMode(TextureMode.Projected);
6564

6665
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());

jme3-examples/src/main/java/jme3test/bullet/TestFancyCar.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public class TestFancyCar extends SimpleApplication implements ActionListener {
5454

5555
private BulletAppState bulletAppState;
5656
private VehicleControl player;
57-
private float wheelRadius;
5857
private float steeringValue = 0;
5958
private float accelerationValue = 0;
6059
private Node carNode;
@@ -174,7 +173,7 @@ private void buildPlayer() {
174173
Geometry wheel_fr = findGeom(carNode, "WheelFrontRight");
175174
wheel_fr.center();
176175
box = (BoundingBox) wheel_fr.getModelBound();
177-
wheelRadius = box.getYExtent();
176+
float wheelRadius = box.getYExtent();
178177
float back_wheel_h = (wheelRadius * 1.7f) - 1f;
179178
float front_wheel_h = (wheelRadius * 1.9f) - 1f;
180179
player.addWheel(wheel_fr.getParent(), box.getCenter().add(0, -front_wheel_h, 0),

jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ public class TestHoveringTank extends SimpleApplication implements AnalogListene
7070
private BulletAppState bulletAppState;
7171
private PhysicsHoverControl hoverControl;
7272
private Spatial spaceCraft;
73-
private TerrainQuad terrain;
74-
private Material matRock;
7573
/**
7674
* initial location of the tank (in world/physics-space coordinates)
7775
*/
@@ -252,7 +250,8 @@ public void simpleUpdate(float tpf) {
252250
}
253251

254252
private void createTerrain() {
255-
matRock = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
253+
Material matRock = new Material(assetManager,
254+
"Common/MatDefs/Terrain/TerrainLighting.j3md");
256255
matRock.setBoolean("useTriPlanarMapping", false);
257256
matRock.setBoolean("WardIso", true);
258257
matRock.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
@@ -286,7 +285,8 @@ private void createTerrain() {
286285
} catch (Exception e) {
287286
e.printStackTrace();
288287
}
289-
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
288+
TerrainQuad terrain
289+
= new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
290290
List<Camera> cameras = new ArrayList<>();
291291
cameras.add(getCamera());
292292
TerrainLodControl control = new TerrainLodControl(terrain, cameras);

jme3-examples/src/main/java/jme3test/bullet/TestIssue1120.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public class TestIssue1120 extends SimpleApplication {
6868
private static TestIssue1120 test;
6969
private BulletAppState bulletAppState;
7070
private final boolean physicsDebug = true;
71-
private BitmapFont font;
72-
private final BitmapText[] testInfo = new BitmapText[2];
7371
private BitmapText speedText;
7472
private final List<Spatial> testObjects = new ArrayList<>();
7573
private static final boolean SKIP_SETTINGS = false;//Used for repeated runs of this test during dev
@@ -133,7 +131,8 @@ public void simpleInitApp() {
133131
}, "pause", "restart", "+", "-");
134132

135133
guiNode = getGuiNode();
136-
font = assetManager.loadFont("Interface/Fonts/Default.fnt");
134+
BitmapFont font = assetManager.loadFont("Interface/Fonts/Default.fnt");
135+
BitmapText[] testInfo = new BitmapText[2];
137136
testInfo[0] = new BitmapText(font);
138137
testInfo[1] = new BitmapText(font);
139138
speedText = new BitmapText(font);

jme3-examples/src/main/java/jme3test/bullet/TestPhysicsCharacter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ public class TestPhysicsCharacter extends SimpleApplication implements ActionLis
5656

5757
private BulletAppState bulletAppState;
5858
private CharacterControl physicsCharacter;
59-
private Node characterNode;
60-
private CameraNode camNode;
6159
final private Vector3f walkDirection = new Vector3f(0,0,0);
6260
final private Vector3f viewDirection = new Vector3f(0,0,0);
6361
private boolean leftStrafe = false, rightStrafe = false, forward = false, backward = false,
@@ -110,7 +108,7 @@ public void simpleInitApp() {
110108
// Add a physics character to the world
111109
physicsCharacter = new CharacterControl(new CapsuleCollisionShape(0.5f, 1.8f), .1f);
112110
physicsCharacter.setPhysicsLocation(new Vector3f(0, 1, 0));
113-
characterNode = new Node("character node");
111+
Node characterNode = new Node("character node");
114112
Spatial model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
115113
model.scale(0.25f);
116114
characterNode.addControl(physicsCharacter);
@@ -119,7 +117,7 @@ public void simpleInitApp() {
119117
characterNode.attachChild(model);
120118

121119
// set forward camera node that follows the character
122-
camNode = new CameraNode("CamNode", cam);
120+
CameraNode camNode = new CameraNode("CamNode", cam);
123121
camNode.setControlDir(ControlDirection.SpatialToCamera);
124122
camNode.setLocalTranslation(new Vector3f(0, 1, -5));
125123
camNode.lookAt(model.getLocalTranslation(), Vector3f.UNIT_Y);

0 commit comments

Comments
 (0)