MCPcopy Create free account
hub / github.com/SFML/SFML / getMoisture

Function getMoisture

examples/island/Island.cpp:107–116  ·  view source on GitHub ↗

/////////////////////////////////////////////////////// Get the terrain moisture at the given coordinates. ///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

105///
106////////////////////////////////////////////////////////////
107float getMoisture(sf::Vector2u position)
108{
109 const sf::Vector2f normalized = sf::Vector2f(position).componentWiseDiv(sf::Vector2f(resolution)) -
110 sf::Vector2f(0.5f, 0.5f);
111 const sf::Vector2f transformed = normalized * 4.f + sf::Vector2f(0.5f, 0.5f);
112
113 const float moisture = stb_perlin_noise3(transformed.x, transformed.y, 0, 0, 0, 0);
114
115 return (moisture + 1.f) / 2.f;
116}
117
118
119////////////////////////////////////////////////////////////

Callers 1

computeVertexFunction · 0.85

Calls 1

stb_perlin_noise3Function · 0.85

Tested by

no test coverage detected