Sign in to follow this  
  • entries
    12
  • comments
    12
  • views
    8277

Improving builder performance

Sign in to follow this  
Orbital Fan

245 views

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.
Sign in to follow this  


2 Comments


Recommended Comments

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

Share this comment


Link to comment
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.

Share this comment


Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now