Spring.GetGroundExtreme & in-game heightmap changes

Spring.GetGroundExtreme & in-game heightmap changes

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
zoggop
Posts: 289
Joined: 07 Sep 2010, 18:47

Spring.GetGroundExtreme & in-game heightmap changes

Post by zoggop »

I posted this as a mantis bug, but jK is certain Spring.GetGroundExtremes() is fine under all circumstances. To me it appears that Spring.GetGroundExtremes() returns the extremes of the heightmap when it's first loaded only. If the heightmap is changed with lua functions such as Spring.AdjustHeightMap(), or deformed by explosions in such a way as to create a new minimum or maximum, Spring.GetGroundExtremes() will return the same values as it did when the map loaded.

Attached is a screenshot showing a height at cursor of 92, yet a gadget prints the minimum height from Spring.GetGroundExtremes as 108. The height is 92 after a BA commander explosion.

here's the gadget used to test:

Code: Select all

function gadget:GetInfo()
  return {
    name      = "Loony: Heightmap Test",
    desc      = "heightmap test.",
    author    = "zoggop",
    date      = "January 2015",
    license   = "whatever",
    layer     = 10,
    enabled   = true
   }
end

-- synced --------------------------------------------------------------------

if gadgetHandler:IsSyncedCode() then 

function gadget:UnitCreated()
  Spring.Echo(Spring.GetGroundExtremes())
end

end
am i doing something wrong?
Attachments
minimum_height_mismatch.jpg
(97.32 KiB) Not downloaded yet
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Spring.GetGroundExtreme & in-game heightmap changes

Post by Kloot »

Not at all, your description of the problem is accurate.

In 99.0 the current extrema will be available as the third and fourth return values of GetGroundExtremes.
User avatar
zoggop
Posts: 289
Joined: 07 Sep 2010, 18:47

Re: Spring.GetGroundExtreme & in-game heightmap changes

Post by zoggop »

ah, excellent. i was just reporting something that's already been addressed then
Post Reply

Return to “Lua Scripts”