mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into 19597
This commit is contained in:
commit
ca2c8d2fff
4 changed files with 88 additions and 50 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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,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");
|
||||
|
||||
if (customUrl.startsWith("hifi://")) {
|
||||
if(customUrl.startsWith(CUSTOM_URL_SCHEME + "//")) {
|
||||
QStringList urlParts = customUrl.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];
|
||||
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);
|
||||
}
|
||||
} else if (urlParts.count() == 1) {
|
||||
// location coordinates or place name
|
||||
QString destination = urlParts[0];
|
||||
Menu::goTo(destination);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -907,7 +907,12 @@ 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);
|
||||
}
|
||||
else if (urlParts.count() > 1) {
|
||||
// if url has 2 or more parts, the first one is domain name
|
||||
QString domain = urlParts[0];
|
||||
|
||||
|
@ -928,12 +933,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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue