Hello!
I would like update an objects possition “swimming” on a fluid terrain. For the surface I use dynamic terrain with an updateVertex on every frame. This works so fine: humanGrid | Babylon.js Playground (babylonjs.com)
But I can’t get the dynamically calculated getHeightFromMap to update “swimming” object. Height remains always the same. I would need recalculated normal map too, to calculate further object movement.
That said, if you update the terrain with your own custom function, it’s likely that you can know/compute each point elevation, because it’s actually what this custom does (computing each point elevation).
It seems that this function calculates heights and Normals and stores them internally. Strange, that last parameter of getHeightFromMap should be also normal vector - but it’s always zero.
How can i read this internal array? Or do I have actual vertices heights in a custom array and calculate objects heights myself?
GravWell uses a similar dynamic terrain approach, and I well recall how much I wrestled with the same issues you are! It’s been quite a long time since I’ve looked at the code in depth, but I do think I remember that there was something wonky with updateVertex and useCustomVertexFunction and that I ended up setting computeNormals and useCustomVertexFunction to false but that it still executes (presumably since we’re overwriting the default vertex function with ours?).