Help with sorting algorithm in javascript
Go to solution
Solved by RushFan,
It was just because java(script?) references objects when you make them equal to another one so I just made a new temporary one.
NEW CODE:
tri[] fintris = new tri[calctris.length];
for(int i = 0; i < fintris.length; i++){
int maxCnt = 0;
float maxVal = 0;
for(int i1 = 0; i1 < calctris.length; i1++){
if(maxVal < calctris[i1].a.z){
maxCnt = i1;
maxVal = calctris[i1].a.z;
fintris[ i] = new tri(new vert(calctris[i1].a.x, calctris[i1].a.y, calctris[i1].a.z), new vert(calctris[i1].b.x, calctris[i1].b.y, calctris[i1].a.z), new vert(calctris[i1].c.x, calctris[i1].c.y, calctris[i1].a.z));
}
}
calctris[maxCnt].a.z = 0;
}

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now