Use the library's texture when needed in Terrain job.

This commit is contained in:
Relintai 2022-02-24 10:19:49 +01:00
parent 40478dda74
commit 4978e6c35f
1 changed files with 21 additions and 2 deletions

View File

@ -82,8 +82,17 @@ void Terrain2DTerrain2DJob::phase_library_setup() {
Ref<Terrain2DMaterialCache> cache = lib->material_cache_get(_chunk->material_cache_key_get());
if (!cache.is_valid()) {
//todo library texture get
//Try a fallback texture
Ref<Terrain2DChunkDefault> cd = _chunk;
if (cd.is_valid()) {
Ref<Texture> tex = lib->texture_get();
if (tex.is_valid()) {
cd->mesh_rid_set(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, Terrain2DChunkDefault::MESH_TYPE_INDEX_TEXTURE_RID, tex->get_rid());
}
}
next_phase();
return;
}
@ -105,6 +114,16 @@ void Terrain2DTerrain2DJob::phase_library_setup() {
}
}
}
} else {
Ref<Terrain2DChunkDefault> cd = _chunk;
if (cd.is_valid()) {
Ref<Texture> tex = lib->texture_get();
if (tex.is_valid()) {
cd->mesh_rid_set(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, Terrain2DChunkDefault::MESH_TYPE_INDEX_TEXTURE_RID, tex->get_rid());
}
}
}
next_phase();