From 4eba3daeeed92726954784394f0b298450a3cd0b Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Sun, 27 Jan 2013 10:20:23 -0800 Subject: j3dcore: annotate list of Views in Physical body, call remove directly Signed-off-by: Harvey Harrison --- .../share/javax/media/j3d/PhysicalBody.java | 29 +++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/classes/share/javax/media/j3d/PhysicalBody.java b/src/classes/share/javax/media/j3d/PhysicalBody.java index 448284f..b263551 100644 --- a/src/classes/share/javax/media/j3d/PhysicalBody.java +++ b/src/classes/share/javax/media/j3d/PhysicalBody.java @@ -96,8 +96,8 @@ public class PhysicalBody extends Object { // This is used in both SCREEN_VIEW and HMD_VIEW modes. Transform3D headToHeadTracker = new Transform3D(); - // A list of View Objects that refer to this - ArrayList users = new ArrayList(); +// A list of View Objects that refer to this +ArrayList users = new ArrayList(); // Mask that indicates this PhysicalBody's view dependence info. has changed, // and CanvasViewCache may need to recompute the final view matries. @@ -124,26 +124,21 @@ public class PhysicalBody extends Object { initHeadToHeadTracker(); } - // Add a user to the list of users - synchronized void removeUser(View view) { - int idx = users.indexOf(view); - if (idx >= 0) { - users.remove(idx); - } - } +// Add a user to the list of users +synchronized void removeUser(View view) { + users.remove(view); +} - // Add a user to the list of users - synchronized void addUser(View view) { - int idx = users.indexOf(view); - if (idx < 0) { - users.add(view); - } - } +// Add a user to the list of users +synchronized void addUser(View view) { + if (!users.contains(view)) + users.add(view); +} // Add a user to the list of users synchronized void notifyUsers() { for (int i=users.size()-1; i>=0; i--) { - View view = (View)users.get(i); + View view = users.get(i); // XXXX: notifyUsers should have a parameter denoting field changed if (view.soundScheduler != null) { view.soundScheduler.setListenerFlag( -- cgit v1.2.3