- // If no heightmaps
- if(m_hm_split == 0)
- {
- /*std::cout<<"Sector has no heightmap"
- <<" while trying to get height at ("<<p.X<<","<<p.Y<<")"
- <<" for sector ("<<m_pos.X<<","<<m_pos.Y<<")"
- <<std::endl;*/
- return GROUNDHEIGHT_NOTFOUND_SETVALUE;
- }
-
- // Side length of heightmap
- s16 hm_d = MAP_BLOCKSIZE / m_hm_split;
-
- // Position of selected heightmap
- v2s16 hm_p = getContainerPos(p, hm_d);
- if(isInArea(hm_p, m_hm_split) == false)
- {
- /*std::cout<<"Sector has no heightmap ("<<hm_p.X<<","<<hm_p.Y<<")"
- <<" while trying to get height at ("<<p.X<<","<<p.Y<<")"
- <<" for sector ("<<m_pos.X<<","<<m_pos.Y<<")"
- <<std::endl;*/
- return GROUNDHEIGHT_NOTFOUND_SETVALUE;
- }
-
- // Selected heightmap
- FixedHeightmap *hm = m_heightmaps[hm_p.Y * m_hm_split + hm_p.X];
-
- if(hm == NULL)
- {
- /*std::cout<<"Sector heightmap ("<<hm_p.X<<","<<hm_p.Y<<")"
- " is NULL"
- <<" while trying to get height at ("<<p.X<<","<<p.Y<<")"
- <<" for sector ("<<m_pos.X<<","<<m_pos.Y<<")"
- <<std::endl;*/
- return GROUNDHEIGHT_NOTFOUND_SETVALUE;
- }
-
- // Position in selected heighmap
- v2s16 p_in_hm = p - hm_p * hm_d;
- if(isInArea(p_in_hm, hm_d+1) == false)
- {
- /*std::cout<<"Position ("<<p_in_hm.X<<","<<p_in_hm.Y<<")"
- " not in sector heightmap area"
- <<" while trying to get height at ("<<p.X<<","<<p.Y<<")"
- <<" for sector ("<<m_pos.X<<","<<m_pos.Y<<")"
- <<std::endl;*/
- return GROUNDHEIGHT_NOTFOUND_SETVALUE;
- }
-
- f32 h = hm->getGroundHeight(p_in_hm);
-
- /*if(h < GROUNDHEIGHT_VALID_MINVALUE)
- {
- std::cout<<"Sector heightmap ("<<hm_p.X<<","<<hm_p.Y<<")"
- " returned invalid value"
- <<" while trying to get height at ("<<p.X<<","<<p.Y<<")"
- <<" which is ("<<p_in_hm.X<<","<<p_in_hm.Y<<") in heightmap"
- <<" for sector ("<<m_pos.X<<","<<m_pos.Y<<")"
- <<std::endl;
- }*/
-
- return h;