From f829a5b323c54db870d829b9b5e94736a538b1dd Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 27 Apr 2014 00:29:38 +0200 Subject: [PATCH 1/7] Fix CustomUrl Fixed custom url so that hifi://domain/ works. Also goes earlier to the location. --- interface/src/Application.cpp | 53 ++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 97b5c05f25..ee4862d515 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -316,6 +316,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : Particle::setVoxelEditPacketSender(&_voxelEditSender); Particle::setParticleEditPacketSender(&_particleEditSender); + // when -url in command line, teleport to location + urlGoTo(argc, constArgv); + // For now we're going to set the PPS for outbound packets to be super high, this is // probably not the right long term solution. But for now, we're going to do this to // allow you to move a particle around in your hand @@ -352,8 +355,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : QMutexLocker locker(&_settingsMutex); _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); } - //When -url in command line, teleport to location - urlGoTo(argc, constArgv); } Application::~Application() { @@ -3576,34 +3577,34 @@ void Application::takeSnapshot() { void Application::urlGoTo(int argc, const char * constArgv[]) { //Gets the url (hifi://domain/destination/orientation) QString customUrl = getCmdOption(argc, constArgv, "-url"); + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (urlParts.count() == 1) { + // location coordinates or place name + QString domain = urlParts[0]; + Menu::goToDomain(domain); + // as there are no coordinates, go to 0,0,0 + QString destination = "0,0,0"; + Menu::goTo(destination); + } else if (urlParts.count() > 1) { + // if url has 2 or more parts, the first one is domain name + QString domain = urlParts[0]; - if (customUrl.startsWith("hifi://")) { - QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); - if (urlParts.count() > 1) { - // if url has 2 or more parts, the first one is domain name - QString domain = urlParts[0]; + // second part is either a destination coordinate or + // a place name + QString destination = urlParts[1]; - // second part is either a destination coordinate or - // a place name - QString destination = urlParts[1]; + // any third part is an avatar orientation. + QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); - // any third part is an avatar orientation. - QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); - - Menu::goToDomain(domain); + Menu::goToDomain(domain); - // goto either @user, #place, or x-xx,y-yy,z-zz - // style co-ordinate. - Menu::goTo(destination); + // goto either @user, #place, or x-xx,y-yy,z-zz + // style co-ordinate. + Menu::goTo(destination); - if (!orientation.isEmpty()) { - // location orientation - Menu::goToOrientation(orientation); - } - } else if (urlParts.count() == 1) { - // location coordinates or place name - QString destination = urlParts[0]; - Menu::goTo(destination); + if (!orientation.isEmpty()) { + // location orientation + Menu::goToOrientation(orientation); } - } + } } From ec410d105b524d864f1fc63461e512050a48116c Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 27 Apr 2014 00:31:28 +0200 Subject: [PATCH 2/7] Fix CustomUrl Fixed custom url so that hifi://domain/ works. --- interface/src/Menu.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 44117df55c..524e496acc 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -931,7 +931,15 @@ void Menu::goTo() { if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) { QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); - if (urlParts.count() > 1) { + if (urlParts.count() == 1) { + // location coordinates or place name + QString domain = urlParts[0]; + goToDomain(domain); + // as there are no coordinates, go to 0,0,0 + QString destination = "0,0,0"; + goTo(destination); + } + else if (urlParts.count() > 1) { // if url has 2 or more parts, the first one is domain name QString domain = urlParts[0]; @@ -952,12 +960,7 @@ void Menu::goTo() { // location orientation goToOrientation(orientation); } - } else if (urlParts.count() == 1) { - // location coordinates or place name - QString destination = urlParts[0]; - goTo(destination); } - } else { goToUser(gotoDialog.textValue()); } From 9f070406ed2fe152dd7fb28249e8ba892d3e4c9f Mon Sep 17 00:00:00 2001 From: Stojce Slavkovski Date: Tue, 29 Apr 2014 00:02:24 +0200 Subject: [PATCH 3/7] missing 'extra debugging' check icon; fix font --- interface/resources/styles/log_dialog.qss | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/interface/resources/styles/log_dialog.qss b/interface/resources/styles/log_dialog.qss index b7387c1ee7..330356e750 100644 --- a/interface/resources/styles/log_dialog.qss +++ b/interface/resources/styles/log_dialog.qss @@ -33,6 +33,7 @@ QPushButton#searchButton { } QPushButton#revealLogButton { + font-family: Helvetica, Arial, sans-serif; background: url(styles/txt-file.svg); background-repeat: none; background-position: left center; @@ -50,9 +51,9 @@ QCheckBox { } QCheckBox::indicator:unchecked { - image: url(:/styles/unchecked.svg); + image: url(styles/unchecked.svg); } QCheckBox::indicator:checked { - image: url(:/styles/checked.svg); + image: url(styles/checked.svg); } \ No newline at end of file From 2c7fcada3b3d6fa928d91145c1e7a9b2c4ff8c76 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 29 Apr 2014 10:00:12 -0700 Subject: [PATCH 4/7] make gravity transitions faster --- examples/swissArmyJetpack.js | 91 +++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 27 deletions(-) diff --git a/examples/swissArmyJetpack.js b/examples/swissArmyJetpack.js index db3368d251..fb4dc1dc04 100644 --- a/examples/swissArmyJetpack.js +++ b/examples/swissArmyJetpack.js @@ -19,7 +19,7 @@ var DOWN = { x: 0.0, y: -1.0, z: 0.0 }; var MAX_VOXEL_SCAN_DISTANCE = 30.0; // behavior transition thresholds -var MIN_FLYING_SPEED = 1.0; +var MIN_FLYING_SPEED = 3.0; var MIN_COLLISIONLESS_SPEED = 5.0; var MAX_WALKING_SPEED = 30.0; var MAX_COLLIDABLE_SPEED = 35.0; @@ -38,11 +38,16 @@ var TEXT_HEIGHT = BUTTON_HEIGHT; var TEXT_WIDTH = 210; var MSEC_PER_SECOND = 1000; -var EXPIRY_PERIOD = 2 * MSEC_PER_SECOND; +var RAYCAST_EXPIRY_PERIOD = MSEC_PER_SECOND / 16; +var COLLISION_EXPIRY_PERIOD = 2 * MSEC_PER_SECOND; +var GRAVITY_ON_EXPIRY_PERIOD = MSEC_PER_SECOND / 2; +var GRAVITY_OFF_EXPIRY_PERIOD = MSEC_PER_SECOND / 8; var dater = new Date(); -var collisionOnExpiry = dater.getTime() + EXPIRY_PERIOD; -var gravityOnExpiry = dater.getTime() + EXPIRY_PERIOD; +var raycastExpiry = dater.getTime() + RAYCAST_EXPIRY_PERIOD; +var gravityOnExpiry = dater.getTime() + GRAVITY_ON_EXPIRY_PERIOD; +var gravityOffExpiry = dater.getTime() + GRAVITY_OFF_EXPIRY_PERIOD; +var collisionOnExpiry = dater.getTime() + COLLISION_EXPIRY_PERIOD; // avatar state var velocity = { x: 0.0, y: 0.0, z: 0.0 }; @@ -169,6 +174,19 @@ function updateSpeedometerDisplay() { } Script.setInterval(updateSpeedometerDisplay, 100); +function disableArtificialGravity() { + MyAvatar.motionBehaviors = MyAvatar.motionBehaviors & ~AVATAR_MOTION_OBEY_LOCAL_GRAVITY; + updateButton(3, false); +} + +function enableArtificialGravity() { + // NOTE: setting the gravity automatically sets the AVATAR_MOTION_OBEY_LOCAL_GRAVITY behavior bit. + MyAvatar.gravity = DOWN; + updateButton(3, true); + // also enable collisions with voxels + groupBits |= COLLISION_GROUP_VOXELS; + updateButton(1, groupBits & COLLISION_GROUP_VOXELS); +} // Our update() function is called at approximately 60fps, and we will use it to animate our various overlays function update(deltaTime) { @@ -187,31 +205,57 @@ function update(deltaTime) { dater = new Date(); var now = dater.getTime(); - if (speed < MIN_FLYING_SPEED) { + // transition gravity + if (raycastExpiry < now) { // scan for landing platform ray = { origin: MyAvatar.position, direction: DOWN }; var intersection = Voxels.findRayIntersection(ray); + // NOTE: it is possible for intersection.intersects to be false when it should be true + // (perhaps the raycast failed to lock the octree thread?). To workaround this problem + // we only transition on repeated failures. + if (intersection.intersects) { - if (!(MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY)) { - var v = intersection.voxel; - var maxCorner = Vec3.sum({ x: v.x, y: v.y, z: v.z }, {x: v.s, y: v.s, z: v.s }); - var distance = lastPosition.y - maxCorner.y; - if ((gravityOnExpiry < now) && (distance < MAX_VOXEL_SCAN_DISTANCE)) { - // NOTE: setting the gravity automatically sets the AVATAR_MOTION_OBEY_LOCAL_GRAVITY behavior bit. - MyAvatar.gravity = DOWN; - updateButton(3, true); + // compute distance to voxel + var v = intersection.voxel; + var maxCorner = Vec3.sum({ x: v.x, y: v.y, z: v.z }, {x: v.s, y: v.s, z: v.s }); + var distance = lastPosition.y - maxCorner.y; + + if (distance < MAX_VOXEL_SCAN_DISTANCE) { + if (speed < MIN_FLYING_SPEED && + gravityOnExpiry < now && + !(MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY)) { + enableArtificialGravity(); } + if (speed < MAX_WALKING_SPEED) { + gravityOffExpiry = now + GRAVITY_OFF_EXPIRY_PERIOD; + } else if (gravityOffExpiry < now && MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { + disableArtificialGravity(); + } + } else { + // distance too far + if (gravityOffExpiry < now && MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { + disableArtificialGravity(); + } + gravityOnExpiry = now + GRAVITY_ON_EXPIRY_PERIOD; } } else { - if (MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { - MyAvatar.motionBehaviors = MyAvatar.motionBehaviors & ~AVATAR_MOTION_OBEY_LOCAL_GRAVITY; - updateButton(3, false); + // no intersection + if (gravityOffExpiry < now && MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { + disableArtificialGravity(); } - gravityOnExpiry = now + EXPIRY_PERIOD; + gravityOnExpiry = now + GRAVITY_ON_EXPIRY_PERIOD; } - } else { - gravityOnExpiry = now + EXPIRY_PERIOD; } + if (speed > MAX_WALKING_SPEED && gravityOffExpiry < now) { + if (MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { + // turn off gravity + MyAvatar.motionBehaviors = MyAvatar.motionBehaviors & ~AVATAR_MOTION_OBEY_LOCAL_GRAVITY; + updateButton(3, false); + } + gravityOnExpiry = now + GRAVITY_ON_EXPIRY_PERIOD; + } + + // transition collidability with voxels if (speed < MIN_COLLISIONLESS_SPEED) { if (collisionOnExpiry < now && !(MyAvatar.collisionGroups & COLLISION_GROUP_VOXELS)) { // TODO: check to make sure not already colliding @@ -220,14 +264,7 @@ function update(deltaTime) { updateButton(1, groupBits & COLLISION_GROUP_VOXELS); } } else { - collisionOnExpiry = now + EXPIRY_PERIOD; - } - if (speed > MAX_WALKING_SPEED) { - if (MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) { - // turn off gravity - MyAvatar.motionBehaviors = MyAvatar.motionBehaviors & ~AVATAR_MOTION_OBEY_LOCAL_GRAVITY; - updateButton(3, false); - } + collisionOnExpiry = now + COLLISION_EXPIRY_PERIOD; } if (speed > MAX_COLLIDABLE_SPEED) { if (MyAvatar.collisionGroups & COLLISION_GROUP_VOXELS) { From ac8adad0e07d3d088813bb31047a6820884f6953 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 29 Apr 2014 20:49:20 +0200 Subject: [PATCH 5/7] Remove 0,0,0 entry. --- interface/src/Menu.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 524e496acc..8ae2380aa3 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -935,9 +935,6 @@ void Menu::goTo() { // location coordinates or place name QString domain = urlParts[0]; goToDomain(domain); - // as there are no coordinates, go to 0,0,0 - QString destination = "0,0,0"; - goTo(destination); } else if (urlParts.count() > 1) { // if url has 2 or more parts, the first one is domain name From 14b91aa04bced778e1ef886ec176bf2d9daf7fdc Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 29 Apr 2014 20:49:40 +0200 Subject: [PATCH 6/7] Remove 0,0,0 entry --- interface/src/Application.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ee4862d515..1138c6b183 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3582,9 +3582,6 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { // location coordinates or place name QString domain = urlParts[0]; Menu::goToDomain(domain); - // as there are no coordinates, go to 0,0,0 - QString destination = "0,0,0"; - Menu::goTo(destination); } else if (urlParts.count() > 1) { // if url has 2 or more parts, the first one is domain name QString domain = urlParts[0]; From 65706ae5f73fa0dc043bde2ea96e5c369c07c41f Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 29 Apr 2014 20:59:33 +0200 Subject: [PATCH 7/7] Re-add customUrl.startWith --- interface/src/Application.cpp | 56 ++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1138c6b183..457f884c8c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3577,31 +3577,33 @@ void Application::takeSnapshot() { void Application::urlGoTo(int argc, const char * constArgv[]) { //Gets the url (hifi://domain/destination/orientation) QString customUrl = getCmdOption(argc, constArgv, "-url"); - QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); - if (urlParts.count() == 1) { - // location coordinates or place name - QString domain = urlParts[0]; - Menu::goToDomain(domain); - } else if (urlParts.count() > 1) { - // if url has 2 or more parts, the first one is domain name - QString domain = urlParts[0]; - - // second part is either a destination coordinate or - // a place name - QString destination = urlParts[1]; - - // any third part is an avatar orientation. - QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); - - Menu::goToDomain(domain); - - // goto either @user, #place, or x-xx,y-yy,z-zz - // style co-ordinate. - Menu::goTo(destination); - - if (!orientation.isEmpty()) { - // location orientation - Menu::goToOrientation(orientation); - } - } + if(customUrl.startsWith(CUSTOM_URL_SCHEME + "//")) { + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (urlParts.count() == 1) { + // location coordinates or place name + QString domain = urlParts[0]; + Menu::goToDomain(domain); + } else if (urlParts.count() > 1) { + // if url has 2 or more parts, the first one is domain name + QString domain = urlParts[0]; + + // second part is either a destination coordinate or + // a place name + QString destination = urlParts[1]; + + // any third part is an avatar orientation. + QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); + + Menu::goToDomain(domain); + + // goto either @user, #place, or x-xx,y-yy,z-zz + // style co-ordinate. + Menu::goTo(destination); + + if (!orientation.isEmpty()) { + // location orientation + Menu::goToOrientation(orientation); + } + } + } }