Added missing method RenderManager.removePreView (String viewName)

Noticed, there were methods to remove main/post viewport with the name as an argument in RenderManager.java, but not one for a pre viewport. Sorry no diff, and its not been tested :slight_smile:

[java]/**
* Removes the pre ViewPort with the specified name.
*
* @param viewName The preViewPort name to remove
* @return True if the ViewPort was removed successfully.
*
* @see #createPreView(java.lang.String, com.jme3.renderer.Camera)
*/
public boolean removePreView(String viewName) {
for (int i = 0; i < preViewPorts.size(); i++) {
if (preViewPorts.get(i).getName().equals(viewName)) {
preViewPorts.remove(i);
return true;
}
}
return false;
}[/java]

This completes the pattern of removeMainView(), removePostView(), … but it doesn’t add much functionality to the class since there’s a trivial workaround using getPreView(String) and removePreView(ViewPort).

Is there a second for this proposal? If so, I’m prepared to test and commit.

Seems reasonable to complete the API :slight_smile:

Really @wezrule should be testing it before posting it as a patch tho :stuck_out_tongue:

I tested it on the JME trunk, and (not surprisingly) it works. The affected files are:

/trunk/engine/src/core/com/jme3/renderer/RenderManager.java
and
/branches/gradle-restructure/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java

Here is the final diff:

--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -107,6 +107,24 @@
     }
 
     /**
+     * Removes the pre ViewPort with the specified name.
+     *
+     * @param viewName The name of the pre ViewPort to remove
+     * @return True if the ViewPort was removed successfully.
+     *
+     * @see #createPreView(java.lang.String, com.jme3.renderer.Camera)
+     */
+    public boolean removePreView(String viewName) {
+        for (int i = 0; i &lt; preViewPorts.size(); i++) {
+            if (preViewPorts.get(i).getName().equals(viewName)) {
+                preViewPorts.remove(i);
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
      * Removes the specified pre ViewPort.
      * 
      * @param view The pre ViewPort to remove

Do I have permission to commit this?

1 Like

go ahead

2 Likes

Done. Thank you, RĂ©my!

1 Like

cool, thanks @solg!

@zarch said: Seems reasonable to complete the API :)

Really @wezrule should be testing it before posting it as a patch tho :stuck_out_tongue:

I think my build was screwed at the time, and I noticed it was missing by accident (I didn’t even need the method). So it was just a quick “heads” up, this is missing, before I forget about it :slight_smile: