Update viewer position on transform changes instead of process
This commit is contained in:
parent
40d299413f
commit
90cc96d241
@ -3,9 +3,7 @@
|
||||
#include <core/engine.h>
|
||||
|
||||
VoxelViewer::VoxelViewer() {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
set_process(true);
|
||||
}
|
||||
set_notify_transform(!Engine::get_singleton()->is_editor_hint());
|
||||
}
|
||||
|
||||
void VoxelViewer::set_view_distance(unsigned int distance) {
|
||||
@ -60,8 +58,11 @@ void VoxelViewer::_notification(int p_what) {
|
||||
}
|
||||
break;
|
||||
|
||||
case NOTIFICATION_PROCESS:
|
||||
_process();
|
||||
case NOTIFICATION_TRANSFORM_CHANGED:
|
||||
if (is_active()) {
|
||||
const Vector3 pos = get_global_transform().origin;
|
||||
VoxelServer::get_singleton()->set_viewer_position(_viewer_id, pos);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -69,11 +70,6 @@ void VoxelViewer::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelViewer::_process() {
|
||||
const Vector3 pos = get_global_transform().origin;
|
||||
VoxelServer::get_singleton()->set_viewer_position(_viewer_id, pos);
|
||||
}
|
||||
|
||||
bool VoxelViewer::is_active() const {
|
||||
return is_inside_tree() && !Engine::get_singleton()->is_editor_hint();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user