TerrainGrid getHeightmapHeight

Hi, i want getHeightmapHeight(Vector2f) and then modify terrain, but i have problem with getHeightmapHeight method… for 4 initials quad its working perfect, but when i move and try getHeight from other quad i get FLoat.NaN, i am using Ray casting from mouse cursor and its working fine i dont know what coordinate system getHeight using so i need help.

        float radius = TerrainUtils.getRadius();
        Vector3f loc = hit.getContactPoint();

        int radiusStepsX = (int) (radius / terrain.getLocalScale().x);
        int radiusStepsZ = (int) (radius / terrain.getLocalScale().z);

        float xStepAmount = terrain.getLocalScale().x;
        float zStepAmount = terrain.getLocalScale().z;

        List<Vector2f> locs = new ArrayList<>();
        List<Float> heights = new ArrayList<>();

        float desiredHeight = secondaryMarker.getWorldTranslation().y;

        for (int z = -radiusStepsZ; z < radiusStepsZ; z++) {
            for (int x = -radiusStepsX; x < radiusStepsX; x++) {
                float locX = loc.x + (x * xStepAmount);
                float locZ = loc.z + (z * zStepAmount);
                if (TerrainUtils.isInRadius(locX - loc.x, locZ - loc.z, radius)) {
                    Vector2f terrainLoc = new Vector2f(locX, locZ);
                    
                    // adjust height based on radius of the tool
                    float terrainHeightAtLoc = terrain.getHeightmapHeight(terrainLoc) * terrain.getWorldScale().y;
                    if (precision) {
                        locs.add(terrainLoc);
                        heights.add(desiredHeight / terrain.getLocalScale().y);
                    } else {
                        float epsilon = 0.1f * height; // rounding error for snapping

                        float adj = 0;
                        if (terrainHeightAtLoc < desiredHeight) {
                            adj = 1;
                        } else if (terrainHeightAtLoc > desiredHeight) {
                            adj = -1;
                        }

                        adj *= height;

                        adj *= TerrainUtils.calculateHeight(radius, 1, locX - loc.x, locZ - loc.z);

                        // test if adjusting too far and then cap it
                        if (adj > 0 && TerrainUtils.floatGreaterThan((terrainHeightAtLoc + adj), desiredHeight, epsilon)) {
                            adj = desiredHeight - terrainHeightAtLoc;
                        } else if (adj < 0 && TerrainUtils.floatLessThan((terrainHeightAtLoc + adj), desiredHeight, epsilon)) {
                            adj = terrainHeightAtLoc - desiredHeight;
                        }

                        if (!TerrainUtils.floatEquals(adj, 0, 0.001f)) {
                            locs.add(terrainLoc);
                            heights.add(adj);
                        }

                    }
                }
            }
        }
        if (precision) {
            terrain.setHeight(locs, heights);
        } else {
            terrain.adjustHeight(locs, heights);
        }
        terrain.updateModelBound();
    }```

I ran into this issue in the past, but i don’t remember how I solved it off the top of my head right now without looking back at the code.

But maybe the posts in this thread could help