summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/arvr_nodes.cpp110
-rw-r--r--scene/3d/arvr_nodes.h7
-rw-r--r--scene/3d/camera.h8
-rw-r--r--scene/3d/gi_probe.cpp4
-rw-r--r--scene/gui/file_dialog.cpp1
-rw-r--r--scene/gui/rich_text_label.cpp2
-rw-r--r--scene/gui/video_player.cpp7
-rw-r--r--scene/gui/video_player.h1
-rw-r--r--scene/register_scene_types.cpp7
9 files changed, 139 insertions, 8 deletions
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index 147d3bf115..c6b6c02129 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -67,6 +67,105 @@ String ARVRCamera::get_configuration_warning() const {
return String();
};
+Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, Vector3());
+
+ Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
+ ERR_FAIL_COND_V(arvr_interface.is_null(), Vector3());
+
+ if (!is_inside_tree()) {
+ ERR_EXPLAIN("Camera is not inside scene.");
+ ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
+ };
+
+ Size2 viewport_size = get_viewport()->get_camera_rect_size();
+ Vector2 cpos = get_viewport()->get_camera_coords(p_pos);
+ Vector3 ray;
+
+ CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
+ float screen_w, screen_h;
+ cm.get_viewport_size(screen_w, screen_h);
+ ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_w, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_h, -get_znear()).normalized();
+
+ return ray;
+};
+
+Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, Vector2());
+
+ Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
+ ERR_FAIL_COND_V(arvr_interface.is_null(), Vector2());
+
+ if (!is_inside_tree()) {
+ ERR_EXPLAIN("Camera is not inside scene.");
+ ERR_FAIL_COND_V(!is_inside_tree(), Vector2());
+ };
+
+ Size2 viewport_size = get_viewport()->get_visible_rect().size;
+
+ CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
+
+ Plane p(get_camera_transform().xform_inv(p_pos), 1.0);
+
+ p = cm.xform4(p);
+ p.normal /= p.d;
+
+ Point2 res;
+ res.x = (p.normal.x * 0.5 + 0.5) * viewport_size.x;
+ res.y = (-p.normal.y * 0.5 + 0.5) * viewport_size.y;
+
+ return res;
+};
+
+Vector3 ARVRCamera::project_position(const Point2 &p_point) const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, Vector3());
+
+ Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
+ ERR_FAIL_COND_V(arvr_interface.is_null(), Vector3());
+
+ if (!is_inside_tree()) {
+ ERR_EXPLAIN("Camera is not inside scene.");
+ ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
+ };
+
+ Size2 viewport_size = get_viewport()->get_visible_rect().size;
+
+ CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
+
+ Size2 vp_size;
+ cm.get_viewport_size(vp_size.x, vp_size.y);
+
+ Vector2 point;
+ point.x = (p_point.x / viewport_size.x) * 2.0 - 1.0;
+ point.y = (1.0 - (p_point.y / viewport_size.y)) * 2.0 - 1.0;
+ point *= vp_size;
+
+ Vector3 p(point.x, point.y, -get_znear());
+
+ return get_camera_transform().xform(p);
+};
+
+Vector<Plane> ARVRCamera::get_frustum() const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, Vector<Plane>());
+
+ Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
+ ERR_FAIL_COND_V(arvr_interface.is_null(), Vector<Plane>());
+
+ ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>());
+
+ Size2 viewport_size = get_viewport()->get_visible_rect().size;
+ CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
+ return cm.get_projection_planes(get_camera_transform());
+};
+
ARVRCamera::ARVRCamera(){
// nothing to do here yet for now..
};
@@ -297,6 +396,8 @@ void ARVRAnchor::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRAnchor::get_is_active);
ClassDB::bind_method(D_METHOD("get_size"), &ARVRAnchor::get_size);
+
+ ClassDB::bind_method(D_METHOD("get_plane"), &ARVRAnchor::get_plane);
};
void ARVRAnchor::set_anchor_id(int p_anchor_id) {
@@ -346,6 +447,15 @@ String ARVRAnchor::get_configuration_warning() const {
return String();
};
+Plane ARVRAnchor::get_plane() const {
+ Vector3 location = get_translation();
+ Basis orientation = get_transform().basis;
+
+ Plane plane(location, orientation.get_axis(1).normalized());
+
+ return plane;
+};
+
ARVRAnchor::ARVRAnchor() {
anchor_id = 0;
is_active = true;
diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h
index 5269ec0248..e0ccfab58b 100644
--- a/scene/3d/arvr_nodes.h
+++ b/scene/3d/arvr_nodes.h
@@ -52,6 +52,11 @@ protected:
public:
String get_configuration_warning() const;
+ virtual Vector3 project_local_ray_normal(const Point2 &p_pos) const;
+ virtual Point2 unproject_position(const Vector3 &p_pos) const;
+ virtual Vector3 project_position(const Point2 &p_point) const;
+ virtual Vector<Plane> get_frustum() const;
+
ARVRCamera();
~ARVRCamera();
};
@@ -118,6 +123,8 @@ public:
bool get_is_active() const;
Vector3 get_size() const;
+ Plane get_plane() const;
+
String get_configuration_warning() const;
ARVRAnchor();
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index 3a725eaf66..73c6844c1a 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -127,16 +127,16 @@ public:
virtual Transform get_camera_transform() const;
Vector3 project_ray_normal(const Point2 &p_pos) const;
- Vector3 project_ray_origin(const Point2 &p_pos) const;
+ virtual Vector3 project_ray_origin(const Point2 &p_pos) const;
Vector3 project_local_ray_normal(const Point2 &p_pos) const;
- Point2 unproject_position(const Vector3 &p_pos) const;
+ virtual Point2 unproject_position(const Vector3 &p_pos) const;
bool is_position_behind(const Vector3 &p_pos) const;
- Vector3 project_position(const Point2 &p_point) const;
+ virtual Vector3 project_position(const Point2 &p_point) const;
void set_cull_mask(uint32_t p_layers);
uint32_t get_cull_mask() const;
- Vector<Plane> get_frustum() const;
+ virtual Vector<Plane> get_frustum() const;
void set_environment(const Ref<Environment> &p_environment);
Ref<Environment> get_environment() const;
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 66364d40f9..9d55a82824 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -1486,8 +1486,8 @@ GIProbe::GIProbe() {
subdiv = SUBDIV_128;
dynamic_range = 4;
energy = 1.0;
- bias = 0.0;
- normal_bias = 0.8;
+ bias = 1.5;
+ normal_bias = 0.0;
propagation = 1.0;
extents = Vector3(10, 10, 10);
color_scan_cell_width = 4;
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 87a232e766..320dad9301 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -115,6 +115,7 @@ Vector<String> FileDialog::get_selected_files() const {
void FileDialog::update_dir() {
dir->set_text(dir_access->get_current_dir());
+ drives->select(dir_access->get_current_drive());
}
void FileDialog::_dir_entered(String p_dir) {
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index d9287e6f63..c2ce2a633e 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -1949,7 +1949,7 @@ void RichTextLabel::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "visible_characters", PROPERTY_HINT_RANGE, "-1,128000,1"), "set_visible_characters", "get_visible_characters");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_percent_visible", "get_percent_visible");
- ADD_SIGNAL(MethodInfo("meta_clicked", PropertyInfo(Variant::NIL, "meta")));
+ ADD_SIGNAL(MethodInfo("meta_clicked", PropertyInfo(Variant::NIL, "meta", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT)));
BIND_ENUM_CONSTANT(ALIGN_LEFT);
BIND_ENUM_CONSTANT(ALIGN_CENTER);
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 816556af30..190ccd50d5 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -285,6 +285,12 @@ float VideoPlayer::get_stream_position() const {
return playback->get_playback_position();
};
+void VideoPlayer::set_stream_position(float p_position) {
+
+ if (playback.is_valid())
+ playback->seek(p_position);
+}
+
Ref<Texture> VideoPlayer::get_video_texture() {
if (playback.is_valid())
@@ -327,6 +333,7 @@ void VideoPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_stream_name"), &VideoPlayer::get_stream_name);
+ ClassDB::bind_method(D_METHOD("set_stream_position", "position"), &VideoPlayer::set_stream_position);
ClassDB::bind_method(D_METHOD("get_stream_position"), &VideoPlayer::get_stream_position);
ClassDB::bind_method(D_METHOD("set_autoplay", "enabled"), &VideoPlayer::set_autoplay);
diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h
index bea10907bb..f04e90365f 100644
--- a/scene/gui/video_player.h
+++ b/scene/gui/video_player.h
@@ -93,6 +93,7 @@ public:
String get_stream_name() const;
float get_stream_position() const;
+ void set_stream_position(float p_position);
void set_autoplay(bool p_enable);
bool has_autoplay() const;
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index b9dfbd6bb0..a85a0fb9f7 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -222,13 +222,18 @@ void register_scene_types() {
String font_path = GLOBAL_DEF("gui/theme/custom_font", "");
ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/custom_font", PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.font", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
+ bool has_theme = false;
if (theme_path != String()) {
Ref<Theme> theme = ResourceLoader::load(theme_path);
if (theme.is_valid()) {
Theme::set_default(theme);
+ has_theme = true;
+ } else {
+ ERR_PRINTS("Error loading custom theme '" + theme_path + "'");
}
- } else {
+ }
+ if (!has_theme) {
Ref<Font> font;
if (font_path != String()) {
font = ResourceLoader::load(font_path);