EEVEE Next: Fix crash on Scenes without a World
Create a default world when scenes don't have one. This is a 1:1 copy of the current EEVEE implementation. Pull Request: https://projects.blender.org/blender/blender/pulls/107891
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user