From f944c34da583d9cd7fc5b536d28f00e4fa8f4bf3 Mon Sep 17 00:00:00 2001 From: "Norbraten, Terry" <tdnorbra@nps.edu> Date: Tue, 9 Jun 2020 19:38:02 -0700 Subject: [PATCH] consolidate methods --- .../common/input/dis/DISProtocolHandler.java | 68 ++++++------------- .../renderer/common/input/dis/LinkedList.java | 1 - 2 files changed, 22 insertions(+), 47 deletions(-) diff --git a/src/java/org/web3d/vrml/renderer/common/input/dis/DISProtocolHandler.java b/src/java/org/web3d/vrml/renderer/common/input/dis/DISProtocolHandler.java index b8f9b885..2a9077f0 100644 --- a/src/java/org/web3d/vrml/renderer/common/input/dis/DISProtocolHandler.java +++ b/src/java/org/web3d/vrml/renderer/common/input/dis/DISProtocolHandler.java @@ -9,7 +9,6 @@ * purpose. Use it at your own risk. If there's a problem you get to fix it. * ****************************************************************************/ - package org.web3d.vrml.renderer.common.input.dis; // External imports @@ -31,7 +30,6 @@ import org.xj3d.core.eventmodel.NetworkProtocolHandler; /** * The handler for DIS protocol network traffic. - * <p> * * @author Alan Hudson * @version $Revision: 1.26 $ @@ -118,7 +116,7 @@ public class DISProtocolHandler "org.web3d.vrml.renderer.common.dis.input.deadreckonPosition"; /** The value read from the system property for MIPMAPS */ - protected static final boolean deadreckonPosition; + protected static final boolean DEAD_RECKON_POSITION; /** The default dead reckon position value */ protected static final boolean DEFAULT_DEADRECKON_ROTATION = true; @@ -128,7 +126,7 @@ public class DISProtocolHandler "org.web3d.vrml.renderer.common.dis.input.deadreckonRotation"; /** The value read from the system property for deadReckonRotation */ - protected static final boolean deadreckonRotation; + protected static final boolean DEAD_RECKON_ROTATION; // Scratch matrixes for smoothing Matrix3d rotationMatrix; @@ -152,10 +150,10 @@ public class DISProtocolHandler AxisAngle4d axisTemp; static { - deadreckonPosition = PropertyTools.fetchSystemProperty(DEADRECKON_POSITION_PROP, + DEAD_RECKON_POSITION = PropertyTools.fetchSystemProperty(DEADRECKON_POSITION_PROP, DEFAULT_DEADRECKON_POSITION); - deadreckonRotation = PropertyTools.fetchSystemProperty(DEADRECKON_ROTATION_PROP, + DEAD_RECKON_ROTATION = PropertyTools.fetchSystemProperty(DEADRECKON_ROTATION_PROP, DEFAULT_DEADRECKON_ROTATION); } @@ -346,7 +344,7 @@ public class DISProtocolHandler } } - if ((deadreckonPosition || deadreckonRotation) && !node.closeEnough) { + if ((DEAD_RECKON_POSITION || DEAD_RECKON_ROTATION) && !node.closeEnough) { // Handle dead reckoning dt = (currTime - node.lastTime) * 0.001f; // dt = (currTime - node.lastTime) * 0.01f; @@ -364,7 +362,7 @@ public class DISProtocolHandler int idx; - if (deadreckonPosition) { + if (DEAD_RECKON_POSITION) { node.translationConverger.getValue(currTime, translationVec); tempPositionArray[0] = (float) translationVec.x; tempPositionArray[1] = (float) translationVec.y; @@ -373,7 +371,7 @@ public class DISProtocolHandler di.setValue(idx, tempPositionArray, 3); } - if (deadreckonRotation) { + if (DEAD_RECKON_ROTATION) { node.rotationConverger.getValue(currTime, rotationQuat); rotationQuat.normalize(); @@ -470,35 +468,24 @@ public class DISProtocolHandler di.addNetworkRoleListener(this); - switch (di.getRole()) { - case VRMLNetworkInterfaceNodeType.ROLE_MANAGER: - address = di.getAddress(); - port = di.getPort(); + address = di.getAddress(); + port = di.getPort(); - id = new DISConnectionId(address, port); - conn = connections.get(id); + id = new DISConnectionId(address, port); + conn = connections.get(id); - if (conn == null) { - conn = new DISConnectionHandler(nodeMap, liveList, managerList, notifiedSet, address, port); - - connections.put(id, conn); - } + if (conn == null) { + // TODO: When do we get rid of these? + conn = new DISConnectionHandler(nodeMap, liveList, managerList, notifiedSet, address, port); + connections.put(id, conn); + } + + switch (di.getRole()) { + case VRMLNetworkInterfaceNodeType.ROLE_MANAGER: managerList.add(di); break; case VRMLNetworkInterfaceNodeType.ROLE_READER: - address = di.getAddress(); - port = di.getPort(); - - id = new DISConnectionId(address, port); - conn = connections.get(id); - - if (conn == null) { - // TODO: When do we get rid of these? - conn = new DISConnectionHandler(nodeMap, liveList, managerList, notifiedSet, address, port); - - connections.put(id, conn); - } siteID = di.getSiteID(); appID = di.getAppID(); @@ -520,19 +507,6 @@ public class DISProtocolHandler break; case VRMLNetworkInterfaceNodeType.ROLE_WRITER: - address = di.getAddress(); - port = di.getPort(); - - id = new DISConnectionId(address, port); - conn = connections.get(id); - - if (conn == null) { - // TODO: When do we get rid of these? - conn = new DISConnectionHandler(nodeMap, liveList, managerList, notifiedSet, address, port); - - connections.put(id, conn); - } - siteID = di.getSiteID(); appID = di.getAppID(); entityID = di.getEntityID(); @@ -589,6 +563,7 @@ public class DISProtocolHandler //---------------------------------------------------------- // Methods required for NetworkRoleListener //---------------------------------------------------------- + /** * The role of this node has changed. * @@ -669,6 +644,7 @@ public class DISProtocolHandler //---------------------------------------------------------- // Local convenience methods //---------------------------------------------------------- + /** * Calculate the dead reckoning position of a EntityStatePDU * @param espdu @@ -790,4 +766,4 @@ public class DISProtocolHandler rotMatrix.mul(psiMat); } -} // end class file DISProtocolHandler.java \ No newline at end of file +} // end class file DISProtocolHandler.java diff --git a/src/java/org/web3d/vrml/renderer/common/input/dis/LinkedList.java b/src/java/org/web3d/vrml/renderer/common/input/dis/LinkedList.java index 6cca4549..4aa2124e 100644 --- a/src/java/org/web3d/vrml/renderer/common/input/dis/LinkedList.java +++ b/src/java/org/web3d/vrml/renderer/common/input/dis/LinkedList.java @@ -24,7 +24,6 @@ package org.web3d.vrml.renderer.common.input.dis; * @author Alan Hudson * @version $Revision: 1.2 $ */ - class LinkedList { public ListEntry head; public ListEntry tail; -- GitLab