I forgot to mention I think I found the cause for the original problem this thread started with.
There is not an actual code fix for it because what cause’s the
problem also happened in recast.
I think this method in jme3AI
private TriangleMesh buildNavMesh(float[] positions, int[] indices, IntermediateData intermediateData)
Is similar to this method in recast,
public RecastBuilderResult build(InputGeom geom, RecastBuilderConfig bcfg)
Both rely on a thread to build the mesh, recast uses these.
private RecastBuilderResult[][] buildSingleThread(InputGeom geom, RecastConfig cfg, float[] bmin, float[] bmax, int tw, int th)
or
private RecastBuilderResult[][] buildMultiThread(InputGeom geom, RecastConfig cfg, float[] bmin, float[] bmax, int tw, int th, int threads)
Both of these methods have a executor timeout of,
ec.awaitTermination(1000, TimeUnit.HOURS);
Heres whats going on. When these two variables
int tw
int th
initialize they are tile width and tile height so a tile that is m_tileSize 64 for instance calculates to a 32x32 iteration in this for loop in either of the two methods,
for (int x = 0; x < tw; ++x) {
for (int y = 0; y < th; ++y) {
final int tx = x;
final int ty = y;
ec.submit((Runnable) () -> {
result[tx][ty] = build(geom, new RecastBuilderConfig(cfg, bmin, bmax, tx, ty, true));
});
}
}
In this instance that’s 32 iterations tw
and 32 iterations of th
. The th
part of this loop actually builds the mesh. This can take anywhere from 300ms to 1100ms per iteration
.
On a rather small mesh that’s 32x32 = 1024 iterations x min of 300 ms or about 5 minutes. On large meshes with different tile sizes this can increase to 25k+ iterations at 1000 ms each or in laymen terms, 8+ hours to complete this loop.
So its not a problem that can be resolved by anything other than more computing power or just use smaller meshes.