}
triangleLookupGridSize = Math.max(1, 2 * (int) Math.sqrt(numTriangles));
triangleLookup = new HashMap<Integer, IntegerArray>();
BoundingBoxBuilder2 builder = new BoundingBoxBuilder2();
for (Point2 p : texCoords) {
builder.add(p);
}
texBoundingBox = builder.getBoundingBox();
AffineMatrix2 T = texBoundingBox.toMatrix().inverse();
for (int fi = 0, nf = faces.size(); fi < nf; fi++) {
Face f = faces.get(fi);
if (f.texIndices != null) {
for (int tri = 0; tri < f.decomp.length; tri += 3) {
Point2 a = T.times(texCoords.get(f.texIndices[f.decomp[tri]]));
Point2 b = T.times(texCoords.get(f.texIndices[f.decomp[tri + 1]]));
Point2 c = T.times(texCoords.get(f.texIndices[f.decomp[tri + 2]]));
builder.reset();
builder.add(a);
builder.add(b);
builder.add(c);
Box2 bound = builder.getBoundingBox();
int i0 = MathUtil.clamp((int) Math.floor(bound.minimumX() * (double) triangleLookupGridSize), 0, triangleLookupGridSize - 1);
int i1 = MathUtil.clamp((int) Math.floor(bound.maximumX() * (double) triangleLookupGridSize), 0, triangleLookupGridSize - 1);
int j0 = MathUtil.clamp((int) Math.floor(bound.minimumY() * (double) triangleLookupGridSize), 0, triangleLookupGridSize - 1);
int j1 = MathUtil.clamp((int) Math.floor(bound.maximumY() * (double) triangleLookupGridSize), 0, triangleLookupGridSize - 1);