Improving builder performance

Published May 15, 2007
Advertisement
So my asset conditioning tool (which I've just called "Builder") is kinda slow when loading obj mesh files. It uses Java, but I don't think that's the issue. The slowness is coming from the vertex indexer, which requires running through all the vertices of the mesh many times for each vertex (so it can compare it self to other verts).

I'm guessing i have to use some form of hashing here, but I can't quite get my head around how this'll work. My algo goes something like this:

	// go through each vertex	for (int i = 0; i < vertList.size(); i++) {						duplicateVert = findDuplicateVert(i);			// snip ...			}	// snip...	private int findDuplicateVert(int listPos) {				Vertex cmpVert = vertList.get(listPos);				for (int i = 0; i < listPos; i++) {						if (vertList.get(i).compare(cmpVert) == true) {								// found duplicate vert				return i;			}		}				return -1; // means we didn't find a duplicate vert	}


As you can see it'll spend alot of time in findDuplicateVert() doing compare(). For large meshes this is an issue. The compare function tests whether 2 verts have the same xyz,uv coords, etc. I've never really used hashing functions, but I guess I could use the x coordinates as they key... just to reduce the number of times it goes through the list.. Are hash functions able to have multiple keys? Would be cool to be able to use the xyz coords as a key. I'll have to investigate java.util.Hashtable.
Previous Entry Progress so far
Next Entry The name
0 likes 2 comments

Comments

MGB
Hi,

I'm at this stage with my stuff at the mo - been looking at 'refinery' for Collada - seems to be exactly what you're writing here - have you considered it?

cheers,
Aph
June 19, 2007 04:04 PM
MGB
Oh, and if you pack your xyz into say an int64 you could use that as a hash key :)
I use a similar method in my game for a LOS cache map.
June 19, 2007 04:07 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement

Latest Entries

Been too long!

1016 views

Eclipse oh no :(

1094 views

New Eclipse

953 views

3d engine

853 views

Coming along

1007 views

3d file formats

889 views

The name

925 views
Advertisement