mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-27 06:07:14 +01:00
Work on fixing the remaining issues / error messages with World overrides.
This commit is contained in:
parent
338cc9c93d
commit
786e20b159
@ -157,12 +157,12 @@ void Camera::_notification(int p_what) {
|
|||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_BECAME_CURRENT: {
|
case NOTIFICATION_BECAME_CURRENT: {
|
||||||
if (viewport) {
|
if (viewport) {
|
||||||
viewport->find_world_3d()->_register_camera(this);
|
viewport->_world_3d_register_camera(this);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_LOST_CURRENT: {
|
case NOTIFICATION_LOST_CURRENT: {
|
||||||
if (viewport) {
|
if (viewport) {
|
||||||
viewport->find_world_3d()->_remove_camera(this);
|
viewport->_world_3d_remove_camera(this);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "core/config/engine.h"
|
#include "core/config/engine.h"
|
||||||
#include "core/core_string_names.h"
|
#include "core/core_string_names.h"
|
||||||
|
#include "scene/3d/camera.h"
|
||||||
#include "scene/3d/spatial.h"
|
#include "scene/3d/spatial.h"
|
||||||
#include "scene/3d/world_environment_3d.h"
|
#include "scene/3d/world_environment_3d.h"
|
||||||
#include "scene/resources/world_2d.h"
|
#include "scene/resources/world_2d.h"
|
||||||
@ -164,6 +165,28 @@ Ref<World3D> World::find_world_3d() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<World2D> World::find_world_2d_no_override() const {
|
||||||
|
if (world_2d.is_valid()) {
|
||||||
|
return world_2d;
|
||||||
|
} else if (_parent_world) {
|
||||||
|
return _parent_world->find_world_2d();
|
||||||
|
} else {
|
||||||
|
return Ref<World2D>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<World3D> World::find_world_3d_no_override() const {
|
||||||
|
if (own_world_3d.is_valid()) {
|
||||||
|
return own_world_3d;
|
||||||
|
} else if (world_3d.is_valid()) {
|
||||||
|
return world_3d;
|
||||||
|
} else if (_parent_world) {
|
||||||
|
return _parent_world->find_world_3d();
|
||||||
|
} else {
|
||||||
|
return Ref<World3D>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
World *World::get_override_world() {
|
World *World::get_override_world() {
|
||||||
return _override_world;
|
return _override_world;
|
||||||
}
|
}
|
||||||
@ -192,6 +215,8 @@ void World::set_override_world(World *p_world) {
|
|||||||
old_world->_remove_overridden_world(this);
|
old_world->_remove_overridden_world(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_clear_override_cameras();
|
||||||
|
|
||||||
_override_world = p_world;
|
_override_world = p_world;
|
||||||
|
|
||||||
if (_override_world) {
|
if (_override_world) {
|
||||||
@ -204,6 +229,7 @@ void World::set_override_world(World *p_world) {
|
|||||||
if (old_world_3d != new_world_3d) {
|
if (old_world_3d != new_world_3d) {
|
||||||
if (new_world_3d.is_valid()) {
|
if (new_world_3d.is_valid()) {
|
||||||
old_world_3d->move_cameras_into(new_world_3d);
|
old_world_3d->move_cameras_into(new_world_3d);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ERR_PRINT("!new_world_3d.is_valid()");
|
ERR_PRINT("!new_world_3d.is_valid()");
|
||||||
}
|
}
|
||||||
@ -212,6 +238,10 @@ void World::set_override_world(World *p_world) {
|
|||||||
ERR_PRINT("!old_world_3d.is_valid()");
|
ERR_PRINT("!old_world_3d.is_valid()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_override_world) {
|
||||||
|
_add_override_cameras_into(_override_world);
|
||||||
|
}
|
||||||
|
|
||||||
_on_after_world_override_changed();
|
_on_after_world_override_changed();
|
||||||
}
|
}
|
||||||
void World::set_override_world_bind(Node *p_world) {
|
void World::set_override_world_bind(Node *p_world) {
|
||||||
@ -324,6 +354,63 @@ void World::update_worlds() {
|
|||||||
find_world_3d()->_update(get_tree()->get_frame());
|
find_world_3d()->_update(get_tree()->get_frame());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::_world_3d_register_camera(Camera *p_camera) {
|
||||||
|
if (_override_world) {
|
||||||
|
_override_world->_world_3d_register_camera_as_override(p_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
_world_3d_register_camera_no_override(p_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::_world_3d_remove_camera(Camera *p_camera) {
|
||||||
|
if (_override_world) {
|
||||||
|
_override_world->_world_3d_remove_camera_as_override(p_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
_world_3d_remove_camera_no_override(p_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::_world_3d_register_camera_no_override(Camera *p_camera) {
|
||||||
|
find_world_3d_no_override()->_register_camera(p_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::_world_3d_remove_camera_no_override(Camera *p_camera) {
|
||||||
|
find_world_3d_no_override()->_remove_camera(p_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::_world_3d_register_camera_as_override(Camera *p_camera) {
|
||||||
|
find_world_3d_no_override()->_register_camera(p_camera);
|
||||||
|
|
||||||
|
_override_cameras.push_back(p_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::_world_3d_remove_camera_as_override(Camera *p_camera) {
|
||||||
|
find_world_3d_no_override()->_remove_camera(p_camera);
|
||||||
|
|
||||||
|
_override_cameras.erase(p_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::_clear_override_cameras() {
|
||||||
|
while (_override_cameras.size() > 0) {
|
||||||
|
_world_3d_remove_camera_as_override(_override_cameras[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::_add_override_cameras_into(World *p_from) {
|
||||||
|
Ref<World3D> w3d = find_world_3d_no_override();
|
||||||
|
|
||||||
|
ERR_FAIL_COND(!w3d.is_valid());
|
||||||
|
|
||||||
|
List<Camera *> cameras;
|
||||||
|
w3d->get_camera_list(&cameras);
|
||||||
|
|
||||||
|
for (List<Camera *>::Element *E = cameras.front(); E; E = E->next()) {
|
||||||
|
Camera *cam = E->get();
|
||||||
|
|
||||||
|
_world_3d_register_camera_as_override(cam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
World::World() {
|
World::World() {
|
||||||
world_2d = Ref<World2D>(memnew(World2D));
|
world_2d = Ref<World2D>(memnew(World2D));
|
||||||
_override_world = NULL;
|
_override_world = NULL;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
|
|
||||||
|
class Camera;
|
||||||
class World3D;
|
class World3D;
|
||||||
class World2D;
|
class World2D;
|
||||||
|
|
||||||
@ -27,6 +28,8 @@ public:
|
|||||||
|
|
||||||
Ref<World2D> find_world_2d() const;
|
Ref<World2D> find_world_2d() const;
|
||||||
Ref<World3D> find_world_3d() const;
|
Ref<World3D> find_world_3d() const;
|
||||||
|
Ref<World2D> find_world_2d_no_override() const;
|
||||||
|
Ref<World3D> find_world_3d_no_override() const;
|
||||||
|
|
||||||
World *get_override_world();
|
World *get_override_world();
|
||||||
World *get_override_world_or_this();
|
World *get_override_world_or_this();
|
||||||
@ -56,6 +59,15 @@ public:
|
|||||||
|
|
||||||
void update_worlds();
|
void update_worlds();
|
||||||
|
|
||||||
|
void _world_3d_register_camera(Camera *p_camera);
|
||||||
|
void _world_3d_remove_camera(Camera *p_camera);
|
||||||
|
void _world_3d_register_camera_no_override(Camera *p_camera);
|
||||||
|
void _world_3d_remove_camera_no_override(Camera *p_camera);
|
||||||
|
void _world_3d_register_camera_as_override(Camera *p_camera);
|
||||||
|
void _world_3d_remove_camera_as_override(Camera *p_camera);
|
||||||
|
void _clear_override_cameras();
|
||||||
|
void _add_override_cameras_into(World *p_from);
|
||||||
|
|
||||||
World();
|
World();
|
||||||
~World();
|
~World();
|
||||||
|
|
||||||
@ -88,6 +100,7 @@ protected:
|
|||||||
World *_override_world;
|
World *_override_world;
|
||||||
|
|
||||||
Vector<World *> _overriding_worlds;
|
Vector<World *> _overriding_worlds;
|
||||||
|
Vector<Camera *> _override_cameras;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include "world_3d.h"
|
#include "world_3d.h"
|
||||||
|
|
||||||
#include "core/math/projection.h"
|
|
||||||
#include "core/math/octree.h"
|
|
||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
|
#include "core/math/octree.h"
|
||||||
|
#include "core/math/projection.h"
|
||||||
#include "scene/3d/camera.h"
|
#include "scene/3d/camera.h"
|
||||||
#include "scene/3d/visibility_notifier.h"
|
#include "scene/3d/visibility_notifier.h"
|
||||||
#include "scene/scene_string_names.h"
|
#include "scene/scene_string_names.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user