iMiniB3D : Remove tri bug?

BlitzMax Forums/MiniB3D Module/iMiniB3D : Remove tri bug?

ima747(Posted 2012) [#1]
I haven't used remove tri in a long time, and never before in iMiniB3D, but it looks like there's a bug in it. Per documentation it doesn't remove verts (there's no way to remove verts) just the tri connecting them, however when I remove a tri it seems like everything gets all kinds of out of allignment and broken...

Mesh *test = Mesh::CreateCube();
Surface *surf = test->GetSurface(1);
surf->RemoveTri(1);



AdamRedwoods(Posted 2012) [#2]
yeah, weird. but i wouldn't use TriangleVertex() since it reads things backwards and makes it confusing to debug.

try this, and play with the ordering of v0, v1, v2
// removes a tri from a surface
void Surface::RemoveTri(int tri){

	int temp_num = no_tris;

	int* src=new int[no_tris*3];
	
	for(int t=0;t<no_tris-1;t++){

		src[t*3+0]=tris[t*3+0];
		src[t*3+1]=tris[t*3+1];
		src[t*3+2]=tris[t*3+2];		
			
	}
	
	ClearSurface(false,true);

	for(int t=0;t<temp_num-1;t++){

		int v0=src[t*3+0];
		int v1=src[t*3+1];
		int v2=src[t*3+2];
	
		if(t!=tri) AddTriangle(v0,v1,v2);
		
	}
	
	delete[] src;
	
}


Last edited 2012


ima747(Posted 2012) [#3]
Just tried with your updated removetri and its better/different, but still quite wrong from what should be happening. Re-ordering the verts seems to oddly have little/no effect...

Last edited 2012


AdamRedwoods(Posted 2012) [#4]
I've updated the code above, I found an error.


ima747(Posted 2012) [#5]
Better still, but it seems to warp the texture coords for some reason...