The world my smart little guys live on, is a big icosphere with over 40 thousand points. The terrain height is generated randomly to form mountains and seas. After generation en thus after changing the mesh vertices, I can use collision with a ray to determine where on the terrain the user is moving the mouse.
At this moment picking the location is very precise.
When I reload a saved world after that, the mesh vertices are again modified to set the height of the saved terrain. After this picking the location is suddenly very off most of the time. And never in the same direction.
It looks like after loading a saved world, the collision is looking at an older version of the mesh. There is only one globe mesh, no copies and it is not replaced when loading.
Not sure what there is in this documentation that I not already use…
I like to think I have a firm grip on manipulating the mesh and its vertices. That part works: the changes are visible.
And I do use .updateBound()
The strange thing is that it works after the first manipulation (generating a terrain) and not after the second manipulation (restoring the world that was loaded). The way I change the vertices is similar:
Generating the terrain:
// -------------------------------------------------
// Nieuwe vertex-vector maken
pos = _idx * 3;
//Dan halen we de vector op
Vector3f vec = new Vector3f(
vertData.get(pos),
vertData.get(pos + 1),
vertData.get(pos + 2));
// Bereken de hoogte, bereken de nieuwe vector
Vector3f delta = vec.normalize();
delta = delta.mult(_height + GLOB.GLOBE_BASE_SIZE);
vec = delta;
vertData.put(pos, vec.x);
vertData.put(pos + 1, vec.y);
vertData.put(pos + 2, vec.z);