Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Remove Surface code #9

Closed
wants to merge 1 commit into from

4 participants

@davidejones

I've added in the ability to remove surfaces from a mesh

removeSurfaces();
removeSurfaceAt(index:int);
removeSurface(surface:Surface);

For a demo please see http://forum.alternativaplatform.com/posts/list/0/9535.page

@Yaski
Owner

Before we will merge it in the master, we want to do some optimization of your code. (Like in AnimationClip.removeTrack() i think).
And also in the Skin needed some special removeSurface() implementation, it is because Skin overrides addSurface() method and uses aditional surfaces data.

@davidejones

oh ok, i didn't even think about Skin

@makc

4 months now and still no removeSurface in master :neutral_face:

@Yaski
Owner

We don't want merge incomplete request

@makc

Right, but I thought this

we want to do some optimization of your code

was saying that you will be working on that yourself :)

@Yaski
Owner

Sorry. I had no time to work on it :)

@gonchar gonchar closed this
@gonchar
Collaborator

done. in community branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 13, 2012
  1. @davidejones

    Remove Surface code

    davidejones authored
This page is out of date. Refresh to see the latest.
Showing with 32 additions and 1 deletion.
  1. +32 −1 src/alternativa/engine3d/objects/Mesh.as
View
33 src/alternativa/engine3d/objects/Mesh.as
@@ -74,7 +74,38 @@ package alternativa.engine3d.objects {
}
}
- // TODO: Add removeSurface() method
+ /**
+ * Removes the specified <code>Surface</code> instance from the <code>Mesh</code> instance.
+ * @param surface The <code>Surface</code> instance to remove.
+ * @return The <code>Surface</code> instance that you pass in the <code>child</code> parameter.
+ */
+ public function removeSurface(surface:Surface):Surface {
+ for(var i:int = _surfaces.length - 1; i >= 0; i--) {
+ if(_surfaces[i] == surface) {
+ _surfaces.splice(_surfaces.indexOf(surface),1);
+ _surfacesLength = _surfacesLength-1;
+ }
+ }
+ return surface;
+ }
+
+ /**
+ * Removes the <code>Surface</code> instance specified by index from the <code>Mesh</code> instance.
+ * @param index Index.
+ * @return The <code>Surface</code> instance that will be removed.
+ */
+ public function removeSurfaceAt(index:int):Surface {
+ return removeSurface(getSurface(index));
+ }
+
+ /**
+ * Removes all <code>Surface</code> instances from the <code>Mesh</code> instance.
+ */
+ public function removeSurfaces():void {
+ for(var i:int = _surfaces.length - 1; i >= 0; i--) {
+ removeSurfaceAt(i);
+ }
+ }
/**
* Adds <code>Surface</code> to <code>Mesh</code> object.
Something went wrong with that request. Please try again.