|
|
@ -274,7 +274,7 @@ public class LodGenerator { |
|
|
|
gatherVertexData(mesh, vertexLookup); |
|
|
|
gatherVertexData(mesh, vertexLookup); |
|
|
|
gatherIndexData(mesh, vertexLookup); |
|
|
|
gatherIndexData(mesh, vertexLookup); |
|
|
|
computeCosts(); |
|
|
|
computeCosts(); |
|
|
|
assert (assertValidMesh()); |
|
|
|
// assert (assertValidMesh());
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -333,7 +333,7 @@ public class LodGenerator { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
tri.vertexId[i] = ((ShortBuffer) b).get(); |
|
|
|
tri.vertexId[i] = ((ShortBuffer) b).get(); |
|
|
|
} |
|
|
|
} |
|
|
|
assert (tri.vertexId[i] < vertexLookup.size()); |
|
|
|
// assert (tri.vertexId[i] < vertexLookup.size());
|
|
|
|
tri.vertex[i] = vertexLookup.get(tri.vertexId[i]); |
|
|
|
tri.vertex[i] = vertexLookup.get(tri.vertexId[i]); |
|
|
|
//debug only;
|
|
|
|
//debug only;
|
|
|
|
tri.vertex[i].index = tri.vertexId[i]; |
|
|
|
tri.vertex[i].index = tri.vertexId[i]; |
|
|
@ -364,8 +364,8 @@ public class LodGenerator { |
|
|
|
logger.log(Level.FINE, "Found isolated vertex {0} It will be excluded from Lod level calculations.", vertex); |
|
|
|
logger.log(Level.FINE, "Found isolated vertex {0} It will be excluded from Lod level calculations.", vertex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
assert (vertexList.size() == collapseCostSet.size()); |
|
|
|
// assert (vertexList.size() == collapseCostSet.size());
|
|
|
|
assert (checkCosts()); |
|
|
|
// assert (checkCosts());
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Debug only
|
|
|
|
//Debug only
|
|
|
@ -383,16 +383,16 @@ public class LodGenerator { |
|
|
|
private void computeVertexCollapseCost(Vertex vertex) { |
|
|
|
private void computeVertexCollapseCost(Vertex vertex) { |
|
|
|
|
|
|
|
|
|
|
|
vertex.collapseCost = UNINITIALIZED_COLLAPSE_COST; |
|
|
|
vertex.collapseCost = UNINITIALIZED_COLLAPSE_COST; |
|
|
|
assert (!vertex.edges.isEmpty()); |
|
|
|
// assert (!vertex.edges.isEmpty());
|
|
|
|
for (Edge edge : vertex.edges) { |
|
|
|
for (Edge edge : vertex.edges) { |
|
|
|
edge.collapseCost = computeEdgeCollapseCost(vertex, edge); |
|
|
|
edge.collapseCost = computeEdgeCollapseCost(vertex, edge); |
|
|
|
assert (edge.collapseCost != UNINITIALIZED_COLLAPSE_COST); |
|
|
|
// assert (edge.collapseCost != UNINITIALIZED_COLLAPSE_COST);
|
|
|
|
if (vertex.collapseCost > edge.collapseCost) { |
|
|
|
if (vertex.collapseCost > edge.collapseCost) { |
|
|
|
vertex.collapseCost = edge.collapseCost; |
|
|
|
vertex.collapseCost = edge.collapseCost; |
|
|
|
vertex.collapseTo = edge.destination; |
|
|
|
vertex.collapseTo = edge.destination; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
assert (vertex.collapseCost != UNINITIALIZED_COLLAPSE_COST); |
|
|
|
// assert (vertex.collapseCost != UNINITIALIZED_COLLAPSE_COST);
|
|
|
|
collapseCostSet.add(vertex); |
|
|
|
collapseCostSet.add(vertex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -515,7 +515,7 @@ public class LodGenerator { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
assert (cost >= 0); |
|
|
|
// assert (cost >= 0);
|
|
|
|
|
|
|
|
|
|
|
|
return cost * src.position.distanceSquared(dest.position); |
|
|
|
return cost * src.position.distanceSquared(dest.position); |
|
|
|
} |
|
|
|
} |
|
|
@ -641,7 +641,7 @@ public class LodGenerator { |
|
|
|
buf.rewind(); |
|
|
|
buf.rewind(); |
|
|
|
for (Triangle triangle : triangleList) { |
|
|
|
for (Triangle triangle : triangleList) { |
|
|
|
if (!triangle.isRemoved) { |
|
|
|
if (!triangle.isRemoved) { |
|
|
|
assert (indexCount != 0); |
|
|
|
// assert (indexCount != 0);
|
|
|
|
if (isShortBuffer) { |
|
|
|
if (isShortBuffer) { |
|
|
|
for (int m = 0; m < 3; m++) { |
|
|
|
for (int m = 0; m < 3; m++) { |
|
|
|
((ShortBuffer) buf).put((short) triangle.vertexId[m]); |
|
|
|
((ShortBuffer) buf).put((short) triangle.vertexId[m]); |
|
|
@ -766,7 +766,7 @@ public class LodGenerator { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void addEdge(Vertex v, Edge edge) { |
|
|
|
private void addEdge(Vertex v, Edge edge) { |
|
|
|
assert (edge.destination != v); |
|
|
|
// assert (edge.destination != v);
|
|
|
|
|
|
|
|
|
|
|
|
for (Edge ed : v.edges) { |
|
|
|
for (Edge ed : v.edges) { |
|
|
|
if (ed.equals(edge)) { |
|
|
|
if (ed.equals(edge)) { |
|
|
@ -827,7 +827,7 @@ public class LodGenerator { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
assert (false); |
|
|
|
// assert (false);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateVertexCollapseCost(Vertex vertex) { |
|
|
|
private void updateVertexCollapseCost(Vertex vertex) { |
|
|
@ -836,15 +836,15 @@ public class LodGenerator { |
|
|
|
|
|
|
|
|
|
|
|
for (Edge edge : vertex.edges) { |
|
|
|
for (Edge edge : vertex.edges) { |
|
|
|
edge.collapseCost = computeEdgeCollapseCost(vertex, edge); |
|
|
|
edge.collapseCost = computeEdgeCollapseCost(vertex, edge); |
|
|
|
assert (edge.collapseCost != UNINITIALIZED_COLLAPSE_COST); |
|
|
|
// assert (edge.collapseCost != UNINITIALIZED_COLLAPSE_COST);
|
|
|
|
if (collapseCost > edge.collapseCost) { |
|
|
|
if (collapseCost > edge.collapseCost) { |
|
|
|
collapseCost = edge.collapseCost; |
|
|
|
collapseCost = edge.collapseCost; |
|
|
|
collapseTo = edge.destination; |
|
|
|
collapseTo = edge.destination; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (collapseCost != vertex.collapseCost || vertex.collapseTo != collapseTo) { |
|
|
|
if (collapseCost != vertex.collapseCost || vertex.collapseTo != collapseTo) { |
|
|
|
assert (vertex.collapseTo != null); |
|
|
|
// assert (vertex.collapseTo != null);
|
|
|
|
assert (find(collapseCostSet, vertex)); |
|
|
|
// assert (find(collapseCostSet, vertex));
|
|
|
|
collapseCostSet.remove(vertex); |
|
|
|
collapseCostSet.remove(vertex); |
|
|
|
if (collapseCost != UNINITIALIZED_COLLAPSE_COST) { |
|
|
|
if (collapseCost != UNINITIALIZED_COLLAPSE_COST) { |
|
|
|
vertex.collapseCost = collapseCost; |
|
|
|
vertex.collapseCost = collapseCost; |
|
|
@ -852,7 +852,7 @@ public class LodGenerator { |
|
|
|
collapseCostSet.add(vertex); |
|
|
|
collapseCostSet.add(vertex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
assert (vertex.collapseCost != UNINITIALIZED_COLLAPSE_COST); |
|
|
|
// assert (vertex.collapseCost != UNINITIALIZED_COLLAPSE_COST);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean hasSrcID(int srcID, List<CollapsedEdge> cEdges) { |
|
|
|
private boolean hasSrcID(int srcID, List<CollapsedEdge> cEdges) { |
|
|
@ -871,14 +871,14 @@ public class LodGenerator { |
|
|
|
if (src.edges.isEmpty()) { |
|
|
|
if (src.edges.isEmpty()) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
assert (assertValidVertex(dest)); |
|
|
|
// assert (assertValidVertex(dest));
|
|
|
|
assert (assertValidVertex(src)); |
|
|
|
// assert (assertValidVertex(src));
|
|
|
|
|
|
|
|
|
|
|
|
assert (src.collapseCost != NEVER_COLLAPSE_COST); |
|
|
|
// assert (src.collapseCost != NEVER_COLLAPSE_COST);
|
|
|
|
assert (src.collapseCost != UNINITIALIZED_COLLAPSE_COST); |
|
|
|
// assert (src.collapseCost != UNINITIALIZED_COLLAPSE_COST);
|
|
|
|
assert (!src.edges.isEmpty()); |
|
|
|
// assert (!src.edges.isEmpty());
|
|
|
|
assert (!src.triangles.isEmpty()); |
|
|
|
// assert (!src.triangles.isEmpty());
|
|
|
|
assert (src.edges.contains(new Edge(dest))); |
|
|
|
// assert (src.edges.contains(new Edge(dest)));
|
|
|
|
|
|
|
|
|
|
|
|
// It may have vertexIDs and triangles from different submeshes(different vertex buffers),
|
|
|
|
// It may have vertexIDs and triangles from different submeshes(different vertex buffers),
|
|
|
|
// so we need to connect them correctly based on deleted triangle's edge.
|
|
|
|
// so we need to connect them correctly based on deleted triangle's edge.
|
|
|
@ -916,8 +916,8 @@ public class LodGenerator { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
assert (!tmpCollapsedEdges.isEmpty()); |
|
|
|
// assert (!tmpCollapsedEdges.isEmpty());
|
|
|
|
assert (!dest.edges.contains(new Edge(src))); |
|
|
|
// assert (!dest.edges.contains(new Edge(src)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Iterator<Triangle> it = src.triangles.iterator(); it.hasNext();) { |
|
|
|
for (Iterator<Triangle> it = src.triangles.iterator(); it.hasNext();) { |
|
|
|