summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/command_queue_mt.cpp1
-rw-r--r--core/command_queue_mt.h6
-rw-r--r--core/math/math_2d.h2
-rw-r--r--core/reference.h5
-rw-r--r--core/string_buffer.h6
-rw-r--r--core/string_builder.h6
-rw-r--r--editor/editor_node.cpp3
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm2
-rw-r--r--scene/gui/rich_text_label.cpp11
-rw-r--r--scene/gui/rich_text_label.h2
-rw-r--r--servers/arvr_server.cpp50
-rw-r--r--servers/arvr_server.h17
-rw-r--r--servers/physics/shape_sw.h2
-rw-r--r--servers/visual/visual_server_viewport.cpp10
15 files changed, 106 insertions, 19 deletions
diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp
index 6bb3135757..a39c920dfa 100644
--- a/core/command_queue_mt.cpp
+++ b/core/command_queue_mt.cpp
@@ -105,6 +105,7 @@ CommandQueueMT::CommandQueueMT(bool p_sync) {
read_ptr = 0;
write_ptr = 0;
+ dealloc_ptr = 0;
mutex = Mutex::create();
for (int i = 0; i < SYNC_SEMAPHORES; i++) {
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index c1439bdc4c..3942b961d3 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -309,9 +309,9 @@ class CommandQueueMT {
};
uint8_t command_mem[COMMAND_MEM_SIZE];
- uint32_t read_ptr = 0;
- uint32_t write_ptr = 0;
- uint32_t dealloc_ptr = 0;
+ uint32_t read_ptr;
+ uint32_t write_ptr;
+ uint32_t dealloc_ptr;
SyncSemaphore sync_sems[SYNC_SEMAPHORES];
Mutex *mutex;
Semaphore *sync;
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index 02d921b67e..e7188da85b 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -303,7 +303,7 @@ struct Rect2 {
inline real_t distance_to(const Vector2 &p_point) const {
- real_t dist;
+ real_t dist = 0.0;
bool inside = true;
if (p_point.x < position.x) {
diff --git a/core/reference.h b/core/reference.h
index a0bdb62258..0d6b1ced6e 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -63,7 +63,7 @@ public:
template <class T>
class Ref {
- T *reference = NULL;
+ T *reference;
void ref(const Ref &p_from) {
@@ -213,10 +213,9 @@ public:
Ref(T *p_reference) {
+ reference = NULL;
if (p_reference)
ref_pointer(p_reference);
- else
- reference = NULL;
}
Ref(const Variant &p_variant) {
diff --git a/core/string_buffer.h b/core/string_buffer.h
index b148e45544..7e9b151bea 100644
--- a/core/string_buffer.h
+++ b/core/string_buffer.h
@@ -39,7 +39,7 @@ class StringBuffer {
CharType short_buffer[SHORT_BUFFER_SIZE];
String buffer;
- int string_length = 0;
+ int string_length;
_FORCE_INLINE_ CharType *current_buffer_ptr() {
return static_cast<Vector<CharType> &>(buffer).empty() ? short_buffer : buffer.ptrw();
@@ -79,6 +79,10 @@ public:
_FORCE_INLINE_ operator String() {
return as_string();
}
+
+ StringBuffer() {
+ string_length = 0;
+ }
};
template <int SHORT_BUFFER_SIZE>
diff --git a/core/string_builder.h b/core/string_builder.h
index 9e2599ac32..596b3bf730 100644
--- a/core/string_builder.h
+++ b/core/string_builder.h
@@ -37,7 +37,7 @@
class StringBuilder {
- uint32_t string_length = 0;
+ uint32_t string_length;
Vector<String> strings;
Vector<const char *> c_strings;
@@ -75,6 +75,10 @@ public:
_FORCE_INLINE_ operator String() const {
return as_string();
}
+
+ StringBuilder() {
+ string_length = 0;
+ }
};
#endif // STRING_BUILDER_H
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 36ea90ed66..94b4754478 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1599,7 +1599,8 @@ void EditorNode::_edit_current() {
// special case if use of external editor is true
if (main_plugin->get_name() == "Script" && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
- main_plugin->edit(current_obj);
+ if (!changing_scene)
+ main_plugin->edit(current_obj);
}
else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) {
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 29935f197e..72ca8969d0 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -100,7 +100,7 @@ public:
id context;
CursorShape cursor_shape;
- NSCursor *cursors[CURSOR_MAX] = { NULL };
+ NSCursor *cursors[CURSOR_MAX];
MouseMode mouse_mode;
String title;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index d125ca5a67..0e7c0f1a4e 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -263,6 +263,7 @@ static Vector2 get_mouse_pos(NSEvent *event) {
NSWindow *window = (NSWindow *)[notification object];
CGFloat newBackingScaleFactor = [window backingScaleFactor];
CGFloat oldBackingScaleFactor = [[[notification userInfo] objectForKey:@"NSBackingPropertyOldScaleFactorKey"] doubleValue];
+ [OS_OSX::singleton->window_view setWantsBestResolutionOpenGLSurface:YES];
if (newBackingScaleFactor != oldBackingScaleFactor) {
//Set new display scale and window size
@@ -2369,6 +2370,7 @@ OS_OSX *OS_OSX::singleton = NULL;
OS_OSX::OS_OSX() {
+ memset(cursors, 0, sizeof(cursors));
key_event_pos = 0;
mouse_mode = OS::MOUSE_MODE_VISIBLE;
main_loop = NULL;
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 5bc5d8e690..ae07d5e671 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -125,6 +125,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
l.descent_caches.clear();
l.char_count = 0;
l.minimum_width = 0;
+ l.maximum_width = 0;
}
int wofs = margin;
@@ -200,7 +201,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
#define ENSURE_WIDTH(m_width) \
if (p_mode == PROCESS_CACHE) { \
- l.minimum_width = MAX(l.minimum_width, wofs + m_width); \
+ l.maximum_width = MAX(l.maximum_width, MIN(p_width, wofs + m_width)); \
+ l.minimum_width = MAX(l.minimum_width, m_width); \
} \
if (wofs + m_width > p_width) { \
if (p_mode == PROCESS_CACHE) { \
@@ -469,6 +471,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
//set minimums to zero
for (int i = 0; i < table->columns.size(); i++) {
table->columns[i].min_width = 0;
+ table->columns[i].max_width = 0;
table->columns[i].width = 0;
}
//compute minimum width for each cell
@@ -486,6 +489,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
_process_line(frame, Point2(), ly, available_width, i, PROCESS_CACHE, cfont, Color());
table->columns[column].min_width = MAX(table->columns[column].min_width, frame->lines[i].minimum_width);
+ table->columns[column].max_width = MAX(table->columns[column].max_width, frame->lines[i].maximum_width);
}
idx++;
}
@@ -498,12 +502,13 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
for (int i = 0; i < table->columns.size(); i++) {
remaining_width -= table->columns[i].min_width;
+ if (table->columns[i].max_width > table->columns[i].min_width)
+ table->columns[i].expand = true;
if (table->columns[i].expand)
total_ratio += table->columns[i].expand_ratio;
}
//assign actual widths
-
for (int i = 0; i < table->columns.size(); i++) {
table->columns[i].width = table->columns[i].min_width;
if (table->columns[i].expand)
@@ -1633,7 +1638,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
tag_stack.push_front(tag);
} else if (tag.begins_with("cell=")) {
- int ratio = tag.substr(6, tag.length()).to_int();
+ int ratio = tag.substr(5, tag.length()).to_int();
if (ratio < 1)
ratio = 1;
//use monospace font
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index e7d5e6bb1b..83938cff61 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -87,6 +87,7 @@ private:
int height_accum_cache;
int char_count;
int minimum_width;
+ int maximum_width;
Line() {
from = NULL;
@@ -199,6 +200,7 @@ private:
bool expand;
int expand_ratio;
int min_width;
+ int max_width;
int width;
};
diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp
index 8620b182df..f9d402fe7b 100644
--- a/servers/arvr_server.cpp
+++ b/servers/arvr_server.cpp
@@ -44,6 +44,7 @@ void ARVRServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_world_scale"), &ARVRServer::set_world_scale);
ClassDB::bind_method(D_METHOD("get_reference_frame"), &ARVRServer::get_reference_frame);
ClassDB::bind_method(D_METHOD("center_on_hmd", "rotation_mode", "keep_height"), &ARVRServer::center_on_hmd);
+ ClassDB::bind_method(D_METHOD("get_hmd_transform"), &ARVRServer::get_hmd_transform);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "world_scale"), "set_world_scale", "get_world_scale");
@@ -54,8 +55,13 @@ void ARVRServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_tracker_count"), &ARVRServer::get_tracker_count);
ClassDB::bind_method(D_METHOD("get_tracker", "idx"), &ARVRServer::get_tracker);
+ ClassDB::bind_method(D_METHOD("get_primary_interface"), &ARVRServer::get_primary_interface);
ClassDB::bind_method(D_METHOD("set_primary_interface", "interface"), &ARVRServer::set_primary_interface);
+ ClassDB::bind_method(D_METHOD("get_last_process_usec"), &ARVRServer::get_last_process_usec);
+ ClassDB::bind_method(D_METHOD("get_last_commit_usec"), &ARVRServer::get_last_commit_usec);
+ ClassDB::bind_method(D_METHOD("get_last_frame_usec"), &ARVRServer::get_last_frame_usec);
+
BIND_ENUM_CONSTANT(TRACKER_CONTROLLER);
BIND_ENUM_CONSTANT(TRACKER_BASESTATION);
BIND_ENUM_CONSTANT(TRACKER_ANCHOR);
@@ -132,6 +138,14 @@ void ARVRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height)
};
};
+Transform ARVRServer::get_hmd_transform() {
+ Transform hmd_transform;
+ if (primary_interface != NULL) {
+ hmd_transform = primary_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, hmd_transform);
+ };
+ return hmd_transform;
+};
+
void ARVRServer::add_interface(const Ref<ARVRInterface> &p_interface) {
ERR_FAIL_COND(p_interface.is_null());
@@ -314,6 +328,42 @@ void ARVRServer::clear_primary_interface_if(const Ref<ARVRInterface> &p_primary_
};
};
+uint64_t ARVRServer::get_last_process_usec() {
+ return last_process_usec;
+};
+
+uint64_t ARVRServer::get_last_commit_usec() {
+ return last_commit_usec;
+};
+
+uint64_t ARVRServer::get_last_frame_usec() {
+ return last_frame_usec;
+};
+
+void ARVRServer::_process() {
+ /* called from visual_server_viewport.draw_viewports right before we start drawing our viewports */
+
+ /* mark for our frame timing */
+ last_process_usec = OS::get_singleton()->get_ticks_usec();
+
+ /* process all active interfaces */
+ for (int i = 0; i < interfaces.size(); i++) {
+ if (!interfaces[i].is_valid()) {
+ // ignore, not a valid reference
+ } else if (interfaces[i]->is_initialized()) {
+ interfaces[i]->process();
+ };
+ };
+};
+
+void ARVRServer::_mark_commit() {
+ /* time this */
+ last_commit_usec = OS::get_singleton()->get_ticks_usec();
+
+ /* now store our difference as we may overwrite last_process_usec before this is accessed */
+ last_frame_usec = last_commit_usec - last_process_usec;
+};
+
ARVRServer::ARVRServer() {
singleton = this;
world_scale = 1.0;
diff --git a/servers/arvr_server.h b/servers/arvr_server.h
index 63b7edc73b..1f4d84fe19 100644
--- a/servers/arvr_server.h
+++ b/servers/arvr_server.h
@@ -31,6 +31,7 @@
#ifndef ARVR_SERVER_H
#define ARVR_SERVER_H
+#include "os/os.h"
#include "os/thread_safe.h"
#include "reference.h"
#include "rid.h"
@@ -84,6 +85,10 @@ private:
Transform world_origin; /* our world origin point, maps a location in our virtual world to the origin point in our real world tracking volume */
Transform reference_frame; /* our reference frame */
+ uint64_t last_process_usec; /* for frame timing, usec when we did our processing */
+ uint64_t last_commit_usec; /* for frame timing, usec when we finished committing both eyes */
+ uint64_t last_frame_usec; /* time it took between process and commiting, we should probably average this over the last x frames */
+
protected:
static ARVRServer *singleton;
@@ -134,6 +139,11 @@ public:
void center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height);
/*
+ get_hmd_transform gets our hmd transform (centered between eyes) with most up to date tracking, relative to the origin
+ */
+ Transform get_hmd_transform();
+
+ /*
Interfaces are objects that 'glue' Godot to an AR or VR SDK such as the Oculus SDK, OpenVR, OpenHMD, etc.
*/
void add_interface(const Ref<ARVRInterface> &p_interface);
@@ -163,6 +173,13 @@ public:
ARVRPositionalTracker *get_tracker(int p_index) const;
ARVRPositionalTracker *find_by_type_and_id(TrackerType p_tracker_type, int p_tracker_id) const;
+ uint64_t get_last_process_usec();
+ uint64_t get_last_commit_usec();
+ uint64_t get_last_frame_usec();
+
+ void _process();
+ void _mark_commit();
+
ARVRServer();
~ARVRServer();
};
diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h
index 7f7f9f4f98..7be818b23c 100644
--- a/servers/physics/shape_sw.h
+++ b/servers/physics/shape_sw.h
@@ -240,7 +240,7 @@ public:
_FORCE_INLINE_ real_t get_height() const { return height; }
_FORCE_INLINE_ real_t get_radius() const { return radius; }
- virtual real_t get_area() { return 4.0 / 3.0 * Math_PI * radius * radius * radius + height * Math_PI * radius * radius; }
+ virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius + height * Math_PI * radius * radius; }
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CAPSULE; }
diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp
index 3eb8953c1f..83e05f6f25 100644
--- a/servers/visual/visual_server_viewport.cpp
+++ b/servers/visual/visual_server_viewport.cpp
@@ -239,10 +239,9 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
void VisualServerViewport::draw_viewports() {
// get our arvr interface in case we need it
Ref<ARVRInterface> arvr_interface = ARVRServer::get_singleton()->get_primary_interface();
- if (arvr_interface.is_valid()) {
- // update our positioning information as late as possible...
- arvr_interface->process();
- }
+
+ // process all our active interfaces
+ ARVRServer::get_singleton()->_process();
clear_color = GLOBAL_GET("rendering/environment/default_clear_color");
@@ -286,6 +285,9 @@ void VisualServerViewport::draw_viewports() {
_draw_viewport(vp, ARVRInterface::EYE_RIGHT);
arvr_interface->commit_for_eye(ARVRInterface::EYE_RIGHT, vp->render_target, vp->viewport_to_screen_rect);
}
+
+ // and for our frame timing, mark when we've finished commiting our eyes
+ ARVRServer::get_singleton()->_mark_commit();
} else {
VSG::rasterizer->set_current_render_target(vp->render_target);