EEVEE Next: Fix crash on Scenes without a World #107891

Merged
Miguel Pozo merged 1 commits from pragma37/blender:pull-fix-eevee-next-world into main 2023-05-16 15:06:50 +02:00
2 changed files with 23 additions and 2 deletions

View File

@ -57,6 +57,23 @@ bNodeTree *DefaultWorldNodeTree::nodetree_get(::World *wo)
*
* \{ */
World::~World()
{
BKE_id_free(nullptr, default_world_);
}
::World *World::default_world_get()
{
if (default_world_ == nullptr) {
default_world_ = static_cast<::World *>(BKE_id_new_nomain(ID_WO, "EEVEEE default world"));
copy_v3_fl(&default_world_->horr, 0.0f);
default_world_->use_nodes = 0;
default_world_->nodetree = nullptr;
BLI_listbase_clear(&default_world_->gpumaterial);
}
return default_world_;
}
void World::sync()
{
// if (inst_.lookdev.sync_world()) {
@ -65,8 +82,7 @@ void World::sync()
::World *bl_world = inst_.scene->world;
if (bl_world == nullptr) {
// bl_world = BKE_world_default();
return;
bl_world = default_world_get();
}
WorldHandle &wo_handle = inst_.sync.sync_world(bl_world);

View File

@ -53,8 +53,13 @@ class World {
/* Used to detect if world change. */
::World *prev_original_world = nullptr;
/* Used when the scene doesn't have a world. */
::World *default_world_ = nullptr;
::World *default_world_get();
public:
World(Instance &inst) : inst_(inst){};
~World();
void sync();
};