subdivide the input mesh just for more accurate collision detection
fix a bug in subdivideTri
clean up the code