Cleanup; prepared for buildings

This commit is contained in:
Segey Lapin
2021-10-16 03:08:07 +03:00
parent f4c39becea
commit 45a67ac8bd
5 changed files with 87 additions and 11 deletions

View File

@@ -479,6 +479,7 @@ void RoadsData::_bind_methods()
{
ClassDB::bind_method(D_METHOD("get_road_grid"), &RoadsData::get_road_grid);
ClassDB::bind_method(D_METHOD("get_sdf", "x", "y", "z"), &RoadsData::get_sdf);
ClassDB::bind_method(D_METHOD("get_site_pos", "site"), &RoadsData::get_site_pos);
}
void RoadsData::set_noise(Ref<FastNoiseLite> noise)
{
@@ -492,6 +493,7 @@ float RoadsData::get_sdf(int x, int y, int z)
{
if (!curve.is_valid() || !noise.is_valid())
return (float)y;
/* will need to fix this for larger world */
if (sdf_data.has(x * 50000 + z))
return (float)y - sdf_data[x * 50000 + z];
float ret;
@@ -510,9 +512,21 @@ float RoadsData::get_sdf(int x, int y, int z)
}
sdf_mutex.unlock();
goto out;
} else {
int site = rg->get_site_from_point(x, z);
// printf("in site %d %d %d\n", site, rg->site_is_town(site), rg->site_is_farm(site));
if (site >= 0 && (rg->site_is_town(site) || rg->site_is_farm(site))) {
ret = y - rg->get_site_avg_height(site);
goto out;
}
}
ret = y - n;
out:
return ret;
}
Vector2 RoadsData::get_site_pos(int site)
{
return rg->get_site_pos(site);
}