summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ISSUE_TEMPLATE.md5
-rw-r--r--doc/classes/ARVRController.xml5
-rw-r--r--doc/classes/ARVRServer.xml11
-rw-r--r--doc/classes/AnimationPlayer.xml1
-rw-r--r--doc/classes/Mutex.xml6
-rw-r--r--doc/classes/Semaphore.xml6
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2
-rw-r--r--editor/project_manager.cpp6
-rw-r--r--modules/bullet/godot_result_callbacks.cpp5
-rw-r--r--modules/bullet/rigid_body_bullet.cpp39
-rw-r--r--modules/bullet/rigid_body_bullet.h1
-rw-r--r--platform/osx/detect.py2
-rw-r--r--platform/windows/detect.py4
-rw-r--r--platform/x11/detect.py2
-rw-r--r--scene/3d/arvr_nodes.cpp10
-rw-r--r--scene/3d/camera.cpp12
-rw-r--r--scene/3d/camera.h2
-rw-r--r--scene/gui/base_button.cpp8
-rw-r--r--servers/arvr/arvr_positional_tracker.cpp23
-rw-r--r--servers/arvr_server.cpp21
-rw-r--r--servers/arvr_server.h14
21 files changed, 122 insertions, 63 deletions
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
index dbfb2bdeab..ddddc3a1a9 100644
--- a/ISSUE_TEMPLATE.md
+++ b/ISSUE_TEMPLATE.md
@@ -1,5 +1,5 @@
**Godot version:**
-<!-- If thirdparty of self-compiled, specify the build date or commit hash. -->
+<!-- If thirdparty or self-compiled, specify the build date or commit hash. -->
**OS/device including version:**
@@ -15,3 +15,6 @@
**Minimal reproduction project:**
<!-- Optional but greatly speeds up debugging. You can drag and drop a zip archive to upload it. -->
+
+
+- [ ] I searched the existing [GitHub issues](https://github.com/godotengine/godot/issues?utf8=%E2%9C%93&q=is%3Aissue+) for potential duplicates.
diff --git a/doc/classes/ARVRController.xml b/doc/classes/ARVRController.xml
index 47a9341643..2adc073ebe 100644
--- a/doc/classes/ARVRController.xml
+++ b/doc/classes/ARVRController.xml
@@ -62,7 +62,10 @@
</methods>
<members>
<member name="controller_id" type="int" setter="set_controller_id" getter="get_controller_id">
- The controller's id. The first controller that the [ARVRServer] detects will have id 1, the second id 2, the third id 3, etc. When a controller is turned off, it's slot is freed. This ensures controllers will keep the same id even when controllers with lower ids are turned off.
+ The controller's id.
+ A controller id of 0 is unbound and will always result in an inactive node. Controller id 1 is reserved for the first controller that identifies itself as the left hand controller and id 2 is reserved for the first controller that identifies itself as the right hand controller.
+ For any other controller that the [ARVRServer] detects we continue with controller id 3.
+ When a controller is turned off, its slot is freed. This ensures controllers will keep the same id even when controllers with lower ids are turned off.
</member>
<member name="rumble" type="float" setter="set_rumble" getter="get_rumble">
The degree to which the tracker rumbles. Ranges from [code]0.0[/code] to [code]1.0[/code] with precision [code].01[/code]. If changed, updates [member ARVRPositionalTracker.rumble] accordingly.
diff --git a/doc/classes/ARVRServer.xml b/doc/classes/ARVRServer.xml
index 17202c8c2c..ffe6c35240 100644
--- a/doc/classes/ARVRServer.xml
+++ b/doc/classes/ARVRServer.xml
@@ -14,7 +14,7 @@
<method name="center_on_hmd">
<return type="void">
</return>
- <argument index="0" name="ignore_tilt" type="bool">
+ <argument index="0" name="rotation_mode" type="bool">
</argument>
<argument index="1" name="keep_height" type="bool">
</argument>
@@ -154,5 +154,14 @@
<constant name="TRACKER_ANY" value="255" enum="TrackerType">
Used internally to select all trackers.
</constant>
+ <constant name="RESET_FULL_ROTATION" value="0" enum="RotationMode">
+ Fully reset the orientation of the HMD. Regardless of what direction the user is looking to in the real world. The user will look dead ahead in the virtual world.
+ </constant>
+ <constant name="RESET_BUT_KEEP_TILT" value="1" enum="RotationMode">
+ Resets the orientation but keeps the tilt of the device. So if we're looking down, we keep looking down but heading will be reset.
+ </constant>
+ <constant name="DONT_RESET_ROTATION" value="2" enum="RotationMode">
+ Does not reset the orientation of the HMD, only the position of the player gets centered.
+ </constant>
</constants>
</class>
diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml
index 570f5e9741..a244788020 100644
--- a/doc/classes/AnimationPlayer.xml
+++ b/doc/classes/AnimationPlayer.xml
@@ -133,6 +133,7 @@
<return type="float">
</return>
<description>
+ Returns the speed scaling ratio of the current animation channel. For instance, if this value is 1 then the animation plays at normal speed. If it's 0.5 then it plays at half speed. If it's 2 then it plays at double speed.
</description>
</method>
<method name="has_animation" qualifiers="const">
diff --git a/doc/classes/Mutex.xml b/doc/classes/Mutex.xml
index 4b845c05ad..74d59b2dd3 100644
--- a/doc/classes/Mutex.xml
+++ b/doc/classes/Mutex.xml
@@ -4,7 +4,7 @@
A synchronization Mutex.
</brief_description>
<description>
- A synchronization Mutex. Element used in multi-threadding. Basically a binary [Semaphore]. Guarantees that only one thread has this lock, can be used to protect a critical section.
+ A synchronization Mutex. Element used to synchronize multiple [Thread]s. Basically a binary [Semaphore]. Guarantees that only one thread can ever acquire this lock at a time. Can be used to protect a critical section. Be careful to avoid deadlocks.
</description>
<tutorials>
</tutorials>
@@ -22,14 +22,14 @@
<return type="int" enum="Error">
</return>
<description>
- Try locking this [code]Mutex[/code], does not block. Returns [OK] on success else [ERR_BUSY].
+ Try locking this [code]Mutex[/code], does not block. Returns [OK] on success, [ERR_BUSY] otherwise.
</description>
</method>
<method name="unlock">
<return type="void">
</return>
<description>
- Unlock this [code]Mutex[/code], leaving it to others threads.
+ Unlock this [code]Mutex[/code], leaving it to other threads.
</description>
</method>
</methods>
diff --git a/doc/classes/Semaphore.xml b/doc/classes/Semaphore.xml
index d8deb9651a..c8206ff2c2 100644
--- a/doc/classes/Semaphore.xml
+++ b/doc/classes/Semaphore.xml
@@ -4,7 +4,7 @@
A synchronization Semaphore.
</brief_description>
<description>
- A synchronization Semaphore. Element used in multi-threadding. Initialized to zero on creation.
+ A synchronization Semaphore. Element used to synchronize multiple [Thread]s. Initialized to zero on creation. Be careful to avoid deadlocks. For a binary version, see [Mutex].
</description>
<tutorials>
</tutorials>
@@ -15,14 +15,14 @@
<return type="int" enum="Error">
</return>
<description>
- Lowers the [code]Semaphore[/code], allowing one more thread in.
+ Lowers the [code]Semaphore[/code], allowing one more thread in. Returns [OK] on success, [ERR_BUSY] otherwise.
</description>
</method>
<method name="wait">
<return type="int" enum="Error">
</return>
<description>
- Tries to wait for the [code]Semaphore[/code], if its value is zero, blocks until non-zero.
+ Tries to wait for the [code]Semaphore[/code], if its value is zero, blocks until non-zero. Returns [OK] on success, [ERR_BUSY] otherwise.
</description>
</method>
</methods>
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index f5bfea3395..ceb1ec09fc 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -4100,7 +4100,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
select_button->connect("pressed", this, "_tool_select", make_binds(TOOL_SELECT));
select_button->set_pressed(true);
select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTR("Select Mode"), KEY_Q));
- select_button->set_tooltip(TTR("Select Mode") + " $sc\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Depth list selection"));
+ select_button->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Depth list selection"));
move_button = memnew(ToolButton);
hb->add_child(move_button);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 00488a2a88..04e9f0adc1 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -536,21 +536,21 @@ public:
if (mode == MODE_IMPORT) {
set_title(TTR("Import Existing Project"));
- get_ok()->set_text(TTR("Import"));
+ get_ok()->set_text(TTR("Import & Edit"));
name_container->hide();
project_path->grab_focus();
} else if (mode == MODE_NEW) {
set_title(TTR("Create New Project"));
- get_ok()->set_text(TTR("Create"));
+ get_ok()->set_text(TTR("Create & Edit"));
name_container->show();
project_name->grab_focus();
} else if (mode == MODE_INSTALL) {
set_title(TTR("Install Project:") + " " + zip_title);
- get_ok()->set_text(TTR("Install"));
+ get_ok()->set_text(TTR("Install & Edit"));
name_container->hide();
project_path->grab_focus();
}
diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp
index cbf30c8a2e..37e45cfff8 100644
--- a/modules/bullet/godot_result_callbacks.cpp
+++ b/modules/bullet/godot_result_callbacks.cpp
@@ -142,6 +142,9 @@ bool GodotAllContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) co
btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1) {
+ if (m_count >= m_resultMax)
+ return cp.getDistance();
+
if (cp.getDistance() <= 0) {
PhysicsDirectSpaceState::ShapeResult &result = m_results[m_count];
@@ -165,7 +168,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con
++m_count;
}
- return m_count < m_resultMax;
+ return cp.getDistance();
}
bool GodotContactPairContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const {
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 669b2c3f0c..26a4eeb065 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -264,6 +264,7 @@ RigidBodyBullet::RigidBodyBullet() :
can_sleep(true),
force_integration_callback(NULL),
isTransformChanged(false),
+ previousActiveState(true),
maxCollisionsDetection(0),
collisionsCount(0),
maxAreasWhereIam(10),
@@ -287,6 +288,7 @@ RigidBodyBullet::RigidBodyBullet() :
for (int i = areasWhereIam.size() - 1; 0 <= i; --i) {
areasWhereIam[i] = NULL;
}
+ btBody->setSleepingThresholds(0.2, 0.2);
}
RigidBodyBullet::~RigidBodyBullet() {
@@ -337,7 +339,7 @@ void RigidBodyBullet::set_space(SpaceBullet *p_space) {
void RigidBodyBullet::dispatch_callbacks() {
/// The check isTransformChanged is necessary in order to call integrated forces only when the first transform is sent
- if (btBody->isActive() && force_integration_callback && isTransformChanged) {
+ if (previousActiveState != btBody->isActive() && force_integration_callback && isTransformChanged) {
BulletPhysicsDirectBodyState *bodyDirect = BulletPhysicsDirectBodyState::get_singleton(this);
@@ -364,6 +366,8 @@ void RigidBodyBullet::dispatch_callbacks() {
/// Lock axis
btBody->setLinearVelocity(btBody->getLinearVelocity() * btBody->getLinearFactor());
btBody->setAngularVelocity(btBody->getAngularVelocity() * btBody->getAngularFactor());
+
+ previousActiveState = btBody->isActive();
}
void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) {
@@ -580,7 +584,8 @@ Variant RigidBodyBullet::get_state(PhysicsServer::BodyState p_state) const {
void RigidBodyBullet::apply_central_impulse(const Vector3 &p_impulse) {
btVector3 btImpu;
G_TO_B(p_impulse, btImpu);
- btBody->activate();
+ if (Vector3() != p_impulse)
+ btBody->activate();
btBody->applyCentralImpulse(btImpu);
}
@@ -589,14 +594,16 @@ void RigidBodyBullet::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impul
btVector3 btPos;
G_TO_B(p_impulse, btImpu);
G_TO_B(p_pos, btPos);
- btBody->activate();
+ if (Vector3() != p_impulse)
+ btBody->activate();
btBody->applyImpulse(btImpu, btPos);
}
void RigidBodyBullet::apply_torque_impulse(const Vector3 &p_impulse) {
btVector3 btImp;
G_TO_B(p_impulse, btImp);
- btBody->activate();
+ if (Vector3() != p_impulse)
+ btBody->activate();
btBody->applyTorqueImpulse(btImp);
}
@@ -605,28 +612,32 @@ void RigidBodyBullet::apply_force(const Vector3 &p_force, const Vector3 &p_pos)
btVector3 btPos;
G_TO_B(p_force, btForce);
G_TO_B(p_pos, btPos);
- btBody->activate();
+ if (Vector3() != p_force)
+ btBody->activate();
btBody->applyForce(btForce, btPos);
}
void RigidBodyBullet::apply_central_force(const Vector3 &p_force) {
btVector3 btForce;
G_TO_B(p_force, btForce);
- btBody->activate();
+ if (Vector3() != p_force)
+ btBody->activate();
btBody->applyCentralForce(btForce);
}
void RigidBodyBullet::apply_torque(const Vector3 &p_torque) {
btVector3 btTorq;
G_TO_B(p_torque, btTorq);
- btBody->activate();
+ if (Vector3() != p_torque)
+ btBody->activate();
btBody->applyTorque(btTorq);
}
void RigidBodyBullet::set_applied_force(const Vector3 &p_force) {
btVector3 btVec = btBody->getTotalTorque();
- btBody->activate();
+ if (Vector3() != p_force)
+ btBody->activate();
btBody->clearForces();
btBody->applyTorque(btVec);
@@ -644,7 +655,8 @@ Vector3 RigidBodyBullet::get_applied_force() const {
void RigidBodyBullet::set_applied_torque(const Vector3 &p_torque) {
btVector3 btVec = btBody->getTotalForce();
- btBody->activate();
+ if (Vector3() != p_torque)
+ btBody->activate();
btBody->clearForces();
btBody->applyCentralForce(btVec);
@@ -711,7 +723,8 @@ bool RigidBodyBullet::is_continuous_collision_detection_enabled() const {
void RigidBodyBullet::set_linear_velocity(const Vector3 &p_velocity) {
btVector3 btVec;
G_TO_B(p_velocity, btVec);
- btBody->activate();
+ if (Vector3() != p_velocity)
+ btBody->activate();
btBody->setLinearVelocity(btVec);
}
@@ -724,7 +737,8 @@ Vector3 RigidBodyBullet::get_linear_velocity() const {
void RigidBodyBullet::set_angular_velocity(const Vector3 &p_velocity) {
btVector3 btVec;
G_TO_B(p_velocity, btVec);
- btBody->activate();
+ if (Vector3() != p_velocity)
+ btBody->activate();
btBody->setAngularVelocity(btVec);
}
@@ -833,6 +847,9 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) {
void RigidBodyBullet::reload_space_override_modificator() {
+ if (!is_active())
+ return;
+
Vector3 newGravity(space->get_gravity_direction() * space->get_gravity_magnitude());
real_t newLinearDamp(linearDamp);
real_t newAngularDamp(angularDamp);
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index c0eb148e24..c3b72172d9 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -207,6 +207,7 @@ private:
bool isScratchedSpaceOverrideModificator;
bool isTransformChanged;
+ bool previousActiveState; // Last check state
ForceIntegrationCallback *force_integration_callback;
diff --git a/platform/osx/detect.py b/platform/osx/detect.py
index e8a8319431..5b04ab8826 100644
--- a/platform/osx/detect.py
+++ b/platform/osx/detect.py
@@ -82,7 +82,7 @@ def configure(env):
env['RANLIB'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib"
env['AS'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as"
env.Append(CCFLAGS=['-D__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define
- if (env["openmp"]):
+ if env['tools'] and env['openmp']:
env.Append(CPPFLAGS=['-fopenmp'])
env.Append(LINKFLAGS=['-fopenmp'])
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 564359d743..e216868bd8 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -191,7 +191,7 @@ def configure(env):
if (env["use_lto"]):
env.Append(CCFLAGS=['/GL'])
env.Append(LINKFLAGS=['/LTCG'])
- if (env["openmp"]):
+ if env['tools'] and env['openmp']:
env.Append(CPPFLAGS=['/openmp'])
env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")])
@@ -270,7 +270,7 @@ def configure(env):
env.Append(CCFLAGS=['-flto'])
env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))])
- if (env["openmp"]):
+ if env['tools'] and env['openmp']:
env.Append(CPPFLAGS=['-fopenmp'])
env.Append(LINKFLAGS=['-fopenmp'])
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index 09bf57c5f1..98ae9a8658 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -265,7 +265,7 @@ def configure(env):
env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu'])
- if env["openmp"]:
+ if env['tools'] and env['openmp']:
env.Append(CPPFLAGS=['-fopenmp'])
env.Append(LINKFLAGS=['-fopenmp'])
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index e1e0b9b1ce..2bb41bf49e 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -231,7 +231,7 @@ void ARVRController::_notification(int p_what) {
void ARVRController::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_controller_id", "controller_id"), &ARVRController::set_controller_id);
ClassDB::bind_method(D_METHOD("get_controller_id"), &ARVRController::get_controller_id);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id", PROPERTY_HINT_RANGE, "1,32,1"), "set_controller_id", "get_controller_id");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_controller_id", "get_controller_id");
ClassDB::bind_method(D_METHOD("get_controller_name"), &ARVRController::get_controller_name);
// passthroughs to information about our related joystick
@@ -251,7 +251,8 @@ void ARVRController::_bind_methods() {
};
void ARVRController::set_controller_id(int p_controller_id) {
- // we don't check any bounds here, this controller may not yet be active and just be a place holder until it is.
+ // We don't check any bounds here, this controller may not yet be active and just be a place holder until it is.
+ // Note that setting this to 0 means this node is not bound to a controller yet.
controller_id = p_controller_id;
};
@@ -420,7 +421,7 @@ void ARVRAnchor::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &ARVRAnchor::set_anchor_id);
ClassDB::bind_method(D_METHOD("get_anchor_id"), &ARVRAnchor::get_anchor_id);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id"), "set_anchor_id", "get_anchor_id");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_anchor_id", "get_anchor_id");
ClassDB::bind_method(D_METHOD("get_anchor_name"), &ARVRAnchor::get_anchor_name);
ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRAnchor::get_is_active);
@@ -430,7 +431,8 @@ void ARVRAnchor::_bind_methods() {
};
void ARVRAnchor::set_anchor_id(int p_anchor_id) {
- // we don't check any bounds here, this anchor may not yet be active and just be a place holder until it is.
+ // We don't check any bounds here, this anchor may not yet be active and just be a place holder until it is.
+ // Note that setting this to 0 means this node is not bound to an anchor yet.
anchor_id = p_anchor_id;
};
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 72c0b979af..c74abb7e2d 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -407,15 +407,6 @@ Camera::KeepAspect Camera::get_keep_aspect_mode() const {
return keep_aspect;
}
-void Camera::set_vaspect(bool p_vaspect) {
- set_keep_aspect_mode(p_vaspect ? KEEP_WIDTH : KEEP_HEIGHT);
- _update_camera_mode();
-}
-
-bool Camera::get_vaspect() const {
- return keep_aspect == KEEP_HEIGHT;
-}
-
void Camera::set_doppler_tracking(DopplerTracking p_tracking) {
if (doppler_tracking == p_tracking)
@@ -468,14 +459,11 @@ void Camera::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_environment"), &Camera::get_environment);
ClassDB::bind_method(D_METHOD("set_keep_aspect_mode", "mode"), &Camera::set_keep_aspect_mode);
ClassDB::bind_method(D_METHOD("get_keep_aspect_mode"), &Camera::get_keep_aspect_mode);
- ClassDB::bind_method(D_METHOD("set_vaspect"), &Camera::set_vaspect);
- ClassDB::bind_method(D_METHOD("get_vaspect"), &Camera::get_vaspect);
ClassDB::bind_method(D_METHOD("set_doppler_tracking", "mode"), &Camera::set_doppler_tracking);
ClassDB::bind_method(D_METHOD("get_doppler_tracking"), &Camera::get_doppler_tracking);
//ClassDB::bind_method(D_METHOD("_camera_make_current"),&Camera::_camera_make_current );
ADD_PROPERTY(PropertyInfo(Variant::INT, "keep_aspect", PROPERTY_HINT_ENUM, "Keep Width,Keep Height"), "set_keep_aspect_mode", "get_keep_aspect_mode");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vaspect"), "set_vaspect", "get_vaspect");
ADD_PROPERTY(PropertyInfo(Variant::INT, "cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_environment", "get_environment");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "h_offset"), "set_h_offset", "get_h_offset");
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index 520afb962b..d69a02afeb 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -148,8 +148,6 @@ public:
void set_keep_aspect_mode(KeepAspect p_aspect);
KeepAspect get_keep_aspect_mode() const;
- void set_vaspect(bool p_vaspect);
- bool get_vaspect() const;
void set_v_offset(float p_offset);
float get_v_offset() const;
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 148277f2dd..a67fe2aeeb 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -450,11 +450,11 @@ String BaseButton::get_tooltip(const Point2 &p_pos) const {
String tooltip = Control::get_tooltip(p_pos);
if (shortcut.is_valid() && shortcut->is_valid()) {
- if (tooltip.find("$sc") != -1) {
- tooltip = tooltip.replace_first("$sc", "(" + shortcut->get_as_text() + ")");
- } else {
- tooltip += " (" + shortcut->get_as_text() + ")";
+ String text = shortcut->get_name() + " (" + shortcut->get_as_text() + ")";
+ if (shortcut->get_name().nocasecmp_to(tooltip) != 0) {
+ text += "\n" + tooltip;
}
+ tooltip = text;
}
return tooltip;
}
diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp
index fc0270615c..fb97d5b86b 100644
--- a/servers/arvr/arvr_positional_tracker.cpp
+++ b/servers/arvr/arvr_positional_tracker.cpp
@@ -62,13 +62,15 @@ void ARVRPositionalTracker::_bind_methods() {
void ARVRPositionalTracker::set_type(ARVRServer::TrackerType p_type) {
if (type != p_type) {
type = p_type;
+ hand = ARVRPositionalTracker::TRACKER_HAND_UNKNOWN;
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
// get a tracker id for our type
+ // note if this is a controller this will be 3 or higher but we may change it later.
tracker_id = arvr_server->get_free_tracker_id_for_type(p_type);
- }
+ };
};
ARVRServer::TrackerType ARVRPositionalTracker::get_type() const {
@@ -156,7 +158,24 @@ ARVRPositionalTracker::TrackerHand ARVRPositionalTracker::get_hand() const {
};
void ARVRPositionalTracker::set_hand(const ARVRPositionalTracker::TrackerHand p_hand) {
- hand = p_hand;
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+
+ if (hand != p_hand) {
+ // we can only set this if we've previously set this to be a controller!!
+ ERR_FAIL_COND((type != ARVRServer::TRACKER_CONTROLLER) && (p_hand != ARVRPositionalTracker::TRACKER_HAND_UNKNOWN));
+
+ hand = p_hand;
+ if (hand == ARVRPositionalTracker::TRACKER_LEFT_HAND) {
+ if (!arvr_server->is_tracker_id_in_use_for_type(type, 1)) {
+ tracker_id = 1;
+ };
+ } else if (hand == ARVRPositionalTracker::TRACKER_RIGHT_HAND) {
+ if (!arvr_server->is_tracker_id_in_use_for_type(type, 2)) {
+ tracker_id = 2;
+ };
+ };
+ };
};
Transform ARVRPositionalTracker::get_transform(bool p_adjust_by_reference_frame) const {
diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp
index 1e73d6753c..df73040e1e 100644
--- a/servers/arvr_server.cpp
+++ b/servers/arvr_server.cpp
@@ -43,7 +43,7 @@ void ARVRServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_world_scale"), &ARVRServer::get_world_scale);
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", "ignore_tilt", "keep_height"), &ARVRServer::center_on_hmd);
+ ClassDB::bind_method(D_METHOD("center_on_hmd", "rotation_mode", "keep_height"), &ARVRServer::center_on_hmd);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "world_scale"), "set_world_scale", "get_world_scale");
@@ -63,6 +63,10 @@ void ARVRServer::_bind_methods() {
BIND_ENUM_CONSTANT(TRACKER_UNKNOWN);
BIND_ENUM_CONSTANT(TRACKER_ANY);
+ BIND_ENUM_CONSTANT(RESET_FULL_ROTATION);
+ BIND_ENUM_CONSTANT(RESET_BUT_KEEP_TILT);
+ BIND_ENUM_CONSTANT(DONT_RESET_ROTATION);
+
ADD_SIGNAL(MethodInfo("interface_added", PropertyInfo(Variant::STRING, "name")));
ADD_SIGNAL(MethodInfo("interface_removed", PropertyInfo(Variant::STRING, "name")));
@@ -96,7 +100,7 @@ Transform ARVRServer::get_reference_frame() const {
return reference_frame;
};
-void ARVRServer::center_on_hmd(bool p_ignore_tilt, bool p_keep_height) {
+void ARVRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height) {
if (primary_interface != NULL) {
// clear our current reference frame or we'll end up double adjusting it
reference_frame = Transform();
@@ -105,7 +109,7 @@ void ARVRServer::center_on_hmd(bool p_ignore_tilt, bool p_keep_height) {
Transform new_reference_frame = primary_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, Transform());
// remove our tilt
- if (p_ignore_tilt) {
+ if (p_rotation_mode == 1) {
// take the Y out of our Z
new_reference_frame.basis.set_axis(2, Vector3(new_reference_frame.basis.elements[0][2], 0.0, new_reference_frame.basis.elements[2][2]).normalized());
@@ -114,6 +118,9 @@ void ARVRServer::center_on_hmd(bool p_ignore_tilt, bool p_keep_height) {
// and X is our cross reference
new_reference_frame.basis.set_axis(0, new_reference_frame.basis.get_axis(1).cross(new_reference_frame.basis.get_axis(2)).normalized());
+ } else if (p_rotation_mode == 2) {
+ // remove our rotation, we're only interesting in centering on position
+ new_reference_frame.basis = Basis();
};
// don't negate our height
@@ -229,8 +236,12 @@ bool ARVRServer::is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p
};
int ARVRServer::get_free_tracker_id_for_type(TrackerType p_tracker_type) {
- // we start checking at 1, 0 means that it's not a controller..
- int tracker_id = 1;
+ // We start checking at 1, 0 means that it's not a controller..
+ // Note that for controller we reserve:
+ // - 1 for the left hand controller and
+ // - 2 for the right hand controller
+ // so we start at 3 :)
+ int tracker_id = p_tracker_type == ARVRServer::TRACKER_CONTROLLER ? 3 : 1;
while (is_tracker_id_in_use_for_type(p_tracker_type, tracker_id)) {
// try the next one
diff --git a/servers/arvr_server.h b/servers/arvr_server.h
index 9b84ee2e99..0381e6e533 100644
--- a/servers/arvr_server.h
+++ b/servers/arvr_server.h
@@ -68,6 +68,12 @@ public:
TRACKER_ANY = 0xff /* used by get_connected_trackers to return all types */
};
+ enum RotationMode {
+ RESET_FULL_ROTATION = 0, /* we reset the full rotation, regardless of how the HMD is oriented, we're looking dead ahead */
+ RESET_BUT_KEEP_TILT = 1, /* reset rotation but keep tilt. */
+ DONT_RESET_ROTATION = 2, /* don't reset the rotation, we will only center on position */
+ };
+
private:
Vector<Ref<ARVRInterface> > interfaces;
Vector<ARVRPositionalTracker *> trackers;
@@ -78,8 +84,6 @@ 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 */
- bool is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const;
-
protected:
static ARVRServer *singleton;
@@ -127,7 +131,7 @@ public:
and in the virtual world out of sync
*/
Transform get_reference_frame() const;
- void center_on_hmd(bool p_ignore_tilt, bool p_keep_height);
+ void center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height);
/*
Interfaces are objects that 'glue' Godot to an AR or VR SDK such as the Oculus SDK, OpenVR, OpenHMD, etc.
@@ -150,9 +154,8 @@ public:
/*
Our trackers are objects that expose the orientation and position of physical devices such as controller, anchor points, etc.
They are created and managed by our active AR/VR interfaces.
-
- Note that for trackers that
*/
+ bool is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const;
int get_free_tracker_id_for_type(TrackerType p_tracker_type);
void add_tracker(ARVRPositionalTracker *p_tracker);
void remove_tracker(ARVRPositionalTracker *p_tracker);
@@ -167,5 +170,6 @@ public:
#define ARVR ARVRServer
VARIANT_ENUM_CAST(ARVRServer::TrackerType);
+VARIANT_ENUM_CAST(ARVRServer::RotationMode);
#endif