mirror of
https://github.com/lubosz/overte.git
synced 2025-08-25 00:03:18 +02:00
Merge remote-tracking branch 'upstream/master' into RunningScripts
Conflicts: interface/src/Application.cpp interface/src/ui/FramelessDialog.cpp interface/src/ui/FramelessDialog.h
This commit is contained in:
commit
edcff0b67f
45 changed files with 1654 additions and 425 deletions
|
@ -17,8 +17,6 @@
|
|||
#include "AssignmentClientMonitor.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
initialiseUsecTimestampNow();
|
||||
|
||||
#ifndef WIN32
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
#endif
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
#include "DomainServer.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
initialiseUsecTimestampNow();
|
||||
|
||||
#ifndef WIN32
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
#endif
|
||||
|
|
|
@ -1088,7 +1088,6 @@ function keyPressEvent(event) {
|
|||
red: colors[whichColor].red,
|
||||
green: colors[whichColor].green,
|
||||
blue: colors[whichColor].blue };
|
||||
Voxels.eraseVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s);
|
||||
Voxels.setVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s, newVoxel.red, newVoxel.green, newVoxel.blue);
|
||||
setAudioPosition();
|
||||
initialVoxelSound.playRandom();
|
||||
|
@ -1394,7 +1393,6 @@ function checkControllers() {
|
|||
if (Vec3.length(Vec3.subtract(fingerTipPosition,lastFingerAddVoxel)) > (FINGERTIP_VOXEL_SIZE / 2)) {
|
||||
newColor = { red: colors[whichColor].red, green: colors[whichColor].green, blue: colors[whichColor].blue };
|
||||
|
||||
Voxels.eraseVoxel(fingerTipPosition.x, fingerTipPosition.y, fingerTipPosition.z, FINGERTIP_VOXEL_SIZE);
|
||||
Voxels.setVoxel(fingerTipPosition.x, fingerTipPosition.y, fingerTipPosition.z, FINGERTIP_VOXEL_SIZE,
|
||||
newColor.red, newColor.green, newColor.blue);
|
||||
|
||||
|
|
|
@ -19,6 +19,12 @@ function mouseMoveEvent(event) {
|
|||
print("computePickRay direction=" + pickRay.direction.x + ", " + pickRay.direction.y + ", " + pickRay.direction.z);
|
||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||
var intersection = Voxels.findRayIntersection(pickRay);
|
||||
if (!intersection.accurate) {
|
||||
print(">>> NOTE: intersection not accurate. will try calling Voxels.findRayIntersectionBlocking()");
|
||||
intersection = Voxels.findRayIntersectionBlocking(pickRay);
|
||||
print(">>> AFTER BLOCKING CALL intersection.accurate=" + intersection.accurate);
|
||||
}
|
||||
|
||||
if (intersection.intersects) {
|
||||
print("intersection voxel.red/green/blue=" + intersection.voxel.red + ", "
|
||||
+ intersection.voxel.green + ", " + intersection.voxel.blue);
|
||||
|
|
291
examples/swissArmyJetpack.js
Normal file
291
examples/swissArmyJetpack.js
Normal file
|
@ -0,0 +1,291 @@
|
|||
//
|
||||
// swissArmyJetpack.js
|
||||
// examples
|
||||
//
|
||||
// Created by Andrew Meadows 2014.04.24
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This is a work in progress. It will eventually be able to move the avatar around,
|
||||
// toggle collision groups, modify avatar movement options, and other stuff (maybe trigger animations).
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
// misc global constants
|
||||
var NUMBER_OF_COLLISION_BUTTONS = 3;
|
||||
var NUMBER_OF_BUTTONS = 4;
|
||||
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 = 3.0;
|
||||
var MIN_COLLISIONLESS_SPEED = 5.0;
|
||||
var MAX_WALKING_SPEED = 30.0;
|
||||
var MAX_COLLIDABLE_SPEED = 35.0;
|
||||
|
||||
// button URL and geometry/UI tuning
|
||||
var BUTTON_IMAGE_URL = "http://highfidelity-public.s3-us-west-1.amazonaws.com/images/testing-swatches.svg";
|
||||
var DISABLED_OFFSET_Y = 12;
|
||||
var ENABLED_OFFSET_Y = 55 + 12;
|
||||
var UI_BUFFER = 1;
|
||||
var OFFSET_X = UI_BUFFER;
|
||||
var OFFSET_Y = 200;
|
||||
var BUTTON_WIDTH = 30;
|
||||
var BUTTON_HEIGHT = 30;
|
||||
var TEXT_OFFSET_X = OFFSET_X + BUTTON_WIDTH + UI_BUFFER;
|
||||
var TEXT_HEIGHT = BUTTON_HEIGHT;
|
||||
var TEXT_WIDTH = 210;
|
||||
|
||||
var MSEC_PER_SECOND = 1000;
|
||||
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 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 };
|
||||
var standing = false;
|
||||
|
||||
// speedometer globals
|
||||
var speed = 0.0;
|
||||
var lastPosition = MyAvatar.position;
|
||||
var speedometer = Overlays.addOverlay("text", {
|
||||
x: OFFSET_X,
|
||||
y: OFFSET_Y - BUTTON_HEIGHT,
|
||||
width: BUTTON_WIDTH + UI_BUFFER + TEXT_WIDTH,
|
||||
height: TEXT_HEIGHT,
|
||||
color: { red: 0, green: 0, blue: 0 },
|
||||
textColor: { red: 255, green: 0, blue: 0},
|
||||
topMargin: 4,
|
||||
leftMargin: 4,
|
||||
text: "Speed: 0.0"
|
||||
});
|
||||
|
||||
// collision group buttons
|
||||
var buttons = new Array();
|
||||
var labels = new Array();
|
||||
|
||||
var labelContents = new Array();
|
||||
labelContents[0] = "Collide with Avatars";
|
||||
labelContents[1] = "Collide with Voxels";
|
||||
labelContents[2] = "Collide with Particles";
|
||||
labelContents[3] = "Use local gravity";
|
||||
var groupBits = 0;
|
||||
|
||||
var enabledColors = new Array();
|
||||
enabledColors[0] = { red: 255, green: 0, blue: 0};
|
||||
enabledColors[1] = { red: 0, green: 255, blue: 0};
|
||||
enabledColors[2] = { red: 0, green: 0, blue: 255};
|
||||
enabledColors[3] = { red: 255, green: 255, blue: 0};
|
||||
|
||||
var disabledColors = new Array();
|
||||
disabledColors[0] = { red: 90, green: 75, blue: 75};
|
||||
disabledColors[1] = { red: 75, green: 90, blue: 75};
|
||||
disabledColors[2] = { red: 75, green: 75, blue: 90};
|
||||
disabledColors[3] = { red: 90, green: 90, blue: 75};
|
||||
|
||||
var buttonStates = new Array();
|
||||
|
||||
for (i = 0; i < NUMBER_OF_BUTTONS; i++) {
|
||||
var offsetS = 12
|
||||
var offsetT = DISABLED_OFFSET_Y;
|
||||
|
||||
buttons[i] = Overlays.addOverlay("image", {
|
||||
x: OFFSET_X,
|
||||
y: OFFSET_Y + (BUTTON_HEIGHT * i),
|
||||
width: BUTTON_WIDTH,
|
||||
height: BUTTON_HEIGHT,
|
||||
subImage: { x: offsetS, y: offsetT, width: BUTTON_WIDTH, height: BUTTON_HEIGHT },
|
||||
imageURL: BUTTON_IMAGE_URL,
|
||||
color: disabledColors[i],
|
||||
alpha: 1,
|
||||
});
|
||||
|
||||
labels[i] = Overlays.addOverlay("text", {
|
||||
x: TEXT_OFFSET_X,
|
||||
y: OFFSET_Y + (BUTTON_HEIGHT * i),
|
||||
width: TEXT_WIDTH,
|
||||
height: TEXT_HEIGHT,
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
textColor: { red: 255, green: 0, blue: 0},
|
||||
topMargin: 4,
|
||||
leftMargin: 4,
|
||||
text: labelContents[i]
|
||||
});
|
||||
|
||||
buttonStates[i] = false;
|
||||
}
|
||||
|
||||
|
||||
// functions
|
||||
|
||||
function updateButton(i, enabled) {
|
||||
var offsetY = DISABLED_OFFSET_Y;
|
||||
var buttonColor = disabledColors[i];
|
||||
if (enabled) {
|
||||
offsetY = ENABLED_OFFSET_Y;
|
||||
buttonColor = enabledColors[i];
|
||||
if (i == 0) {
|
||||
groupBits |= COLLISION_GROUP_AVATARS;
|
||||
} else if (i == 1) {
|
||||
groupBits |= COLLISION_GROUP_VOXELS;
|
||||
} else if (i == 2) {
|
||||
groupBits |= COLLISION_GROUP_PARTICLES;
|
||||
}
|
||||
} else {
|
||||
if (i == 0) {
|
||||
groupBits &= ~COLLISION_GROUP_AVATARS;
|
||||
} else if (i == 1) {
|
||||
groupBits &= ~COLLISION_GROUP_VOXELS;
|
||||
} else if (i == 2) {
|
||||
groupBits &= ~COLLISION_GROUP_PARTICLES;
|
||||
}
|
||||
}
|
||||
if (groupBits != MyAvatar.collisionGroups) {
|
||||
MyAvatar.collisionGroups = groupBits;
|
||||
}
|
||||
|
||||
Overlays.editOverlay(buttons[i], { subImage: { y: offsetY } } );
|
||||
Overlays.editOverlay(buttons[i], { color: buttonColor } );
|
||||
buttonStates[i] = enabled;
|
||||
}
|
||||
|
||||
|
||||
// When our script shuts down, we should clean up all of our overlays
|
||||
function scriptEnding() {
|
||||
for (i = 0; i < NUMBER_OF_BUTTONS; i++) {
|
||||
Overlays.deleteOverlay(buttons[i]);
|
||||
Overlays.deleteOverlay(labels[i]);
|
||||
}
|
||||
Overlays.deleteOverlay(speedometer);
|
||||
}
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
||||
|
||||
function updateSpeedometerDisplay() {
|
||||
Overlays.editOverlay(speedometer, { text: "Speed: " + speed.toFixed(2) });
|
||||
}
|
||||
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) {
|
||||
if (groupBits != MyAvatar.collisionGroups) {
|
||||
groupBits = MyAvatar.collisionGroups;
|
||||
updateButton(0, groupBits & COLLISION_GROUP_AVATARS);
|
||||
updateButton(1, groupBits & COLLISION_GROUP_VOXELS);
|
||||
updateButton(2, groupBits & COLLISION_GROUP_PARTICLES);
|
||||
}
|
||||
|
||||
// measure speed
|
||||
var distance = Vec3.distance(MyAvatar.position, lastPosition);
|
||||
speed = 0.8 * speed + 0.2 * distance / deltaTime;
|
||||
lastPosition = MyAvatar.position;
|
||||
|
||||
dater = new Date();
|
||||
var now = dater.getTime();
|
||||
|
||||
// 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) {
|
||||
// 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 {
|
||||
// no intersection
|
||||
if (gravityOffExpiry < now && MyAvatar.motionBehaviors & AVATAR_MOTION_OBEY_LOCAL_GRAVITY) {
|
||||
disableArtificialGravity();
|
||||
}
|
||||
gravityOnExpiry = now + GRAVITY_ON_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
|
||||
// enable collision with voxels
|
||||
groupBits |= COLLISION_GROUP_VOXELS;
|
||||
updateButton(1, groupBits & COLLISION_GROUP_VOXELS);
|
||||
}
|
||||
} else {
|
||||
collisionOnExpiry = now + COLLISION_EXPIRY_PERIOD;
|
||||
}
|
||||
if (speed > MAX_COLLIDABLE_SPEED) {
|
||||
if (MyAvatar.collisionGroups & COLLISION_GROUP_VOXELS) {
|
||||
// disable collisions with voxels
|
||||
groupBits &= ~COLLISION_GROUP_VOXELS;
|
||||
updateButton(1, groupBits & COLLISION_GROUP_VOXELS);
|
||||
}
|
||||
}
|
||||
}
|
||||
Script.update.connect(update);
|
||||
|
||||
|
||||
// we also handle click detection in our mousePressEvent()
|
||||
function mousePressEvent(event) {
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||
for (i = 0; i < NUMBER_OF_COLLISION_BUTTONS; i++) {
|
||||
if (clickedOverlay == buttons[i]) {
|
||||
var enabled = !(buttonStates[i]);
|
||||
updateButton(i, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
Controller.mousePressEvent.connect(mousePressEvent);
|
||||
|
58
interface/resources/images/hifi-logo.svg
Normal file
58
interface/resources/images/hifi-logo.svg
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 55.5 55.5" enable-background="new 0 0 55.5 55.5" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#0E7077" d="M47.4,8.1C42.1,2.9,35.2,0,27.8,0C20.3,0,13.4,2.9,8.1,8.1C2.9,13.4,0,20.3,0,27.8
|
||||
c0,7.4,2.9,14.4,8.1,19.6c5.2,5.2,12.2,8.1,19.6,8.1c7.4,0,14.4-2.9,19.6-8.1c5.2-5.2,8.1-12.2,8.1-19.6
|
||||
C55.5,20.3,52.6,13.4,47.4,8.1z M45.4,45.4c-4.7,4.7-11,7.3-17.7,7.3c-6.7,0-12.9-2.6-17.7-7.3c-4.7-4.7-7.3-11-7.3-17.7
|
||||
c0-6.7,2.6-12.9,7.3-17.7c4.7-4.7,11-7.3,17.7-7.3c6.7,0,12.9,2.6,17.7,7.3c4.7,4.7,7.3,11,7.3,17.7
|
||||
C52.7,34.4,50.1,40.7,45.4,45.4z"/>
|
||||
<g>
|
||||
<path fill="#0E7077" d="M20.3,37.6c-0.6,0-1.2-0.5-1.2-1.2V15c0-0.6,0.5-1.2,1.2-1.2c0.6,0,1.2,0.5,1.2,1.2v21.5
|
||||
C21.5,37.1,21,37.6,20.3,37.6z"/>
|
||||
<path fill="#0E7077" d="M21.7,14.4c-0.8,0.8-2,0.8-2.7,0c-0.8-0.8-0.8-2,0-2.7c0.8-0.8,2-0.8,2.7,0
|
||||
C22.5,12.5,22.5,13.7,21.7,14.4"/>
|
||||
<g>
|
||||
<path fill="#0E7077" d="M20.3,16.2c-0.8,0-1.6-0.3-2.2-0.9c-1.2-1.2-1.2-3.2,0-4.4c0.6-0.6,1.4-0.9,2.2-0.9
|
||||
c0.8,0,1.6,0.3,2.2,0.9c0.6,0.6,0.9,1.4,0.9,2.2c0,0.8-0.3,1.6-0.9,2.2C21.9,15.8,21.2,16.2,20.3,16.2z M20.3,12.3
|
||||
c-0.2,0-0.4,0.1-0.6,0.2c-0.3,0.3-0.3,0.8,0,1.1c0.3,0.3,0.8,0.3,1.1,0c0.1-0.1,0.2-0.3,0.2-0.6c0-0.2-0.1-0.4-0.2-0.6
|
||||
C20.7,12.4,20.5,12.3,20.3,12.3z"/>
|
||||
</g>
|
||||
<path fill="#0E7077" d="M19,37c0.8-0.8,2-0.8,2.7,0c0.8,0.8,0.8,2,0,2.7c-0.8,0.8-2,0.8-2.7,0C18.2,39,18.2,37.8,19,37"/>
|
||||
<g>
|
||||
<path fill="#0E7077" d="M20.3,41.5c-0.8,0-1.6-0.3-2.2-0.9c-0.6-0.6-0.9-1.4-0.9-2.2c0-0.8,0.3-1.6,0.9-2.2
|
||||
c0.6-0.6,1.4-0.9,2.2-0.9c0.8,0,1.6,0.3,2.2,0.9c0.6,0.6,0.9,1.4,0.9,2.2c0,0.8-0.3,1.6-0.9,2.2C21.9,41.2,21.2,41.5,20.3,41.5z
|
||||
M20.3,37.6c-0.2,0-0.4,0.1-0.6,0.2c-0.1,0.1-0.2,0.3-0.2,0.6c0,0.2,0.1,0.4,0.2,0.6c0.3,0.3,0.8,0.3,1.1,0
|
||||
c0.1-0.1,0.2-0.3,0.2-0.6c0-0.2-0.1-0.4-0.2-0.6C20.7,37.7,20.5,37.6,20.3,37.6z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#0E7077" d="M35.2,41.7c-0.6,0-1.2-0.5-1.2-1.2V19c0-0.6,0.5-1.2,1.2-1.2c0.6,0,1.2,0.5,1.2,1.2v21.5
|
||||
C36.4,41.2,35.8,41.7,35.2,41.7z"/>
|
||||
</g>
|
||||
<path fill="#0E7077" d="M36.6,18.5c-0.8,0.8-2,0.8-2.7,0c-0.8-0.8-0.8-2,0-2.7c0.8-0.8,2-0.8,2.7,0
|
||||
C37.3,16.5,37.3,17.7,36.6,18.5"/>
|
||||
<g>
|
||||
<path fill="#0E7077" d="M35.2,20.2c-0.8,0-1.6-0.3-2.2-0.9c-1.2-1.2-1.2-3.2,0-4.4c0.6-0.6,1.4-0.9,2.2-0.9
|
||||
c0.8,0,1.6,0.3,2.2,0.9c0.6,0.6,0.9,1.4,0.9,2.2c0,0.8-0.3,1.6-0.9,2.2C36.8,19.9,36,20.2,35.2,20.2z M35.2,16.3
|
||||
c-0.2,0-0.4,0.1-0.6,0.2c-0.3,0.3-0.3,0.8,0,1.1c0.3,0.3,0.8,0.3,1.1,0c0.1-0.1,0.2-0.3,0.2-0.6c0-0.2-0.1-0.4-0.2-0.6
|
||||
C35.6,16.4,35.4,16.3,35.2,16.3z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#0E7077" d="M35.2,45.6c-0.8,0-1.6-0.3-2.2-0.9c-1.2-1.2-1.2-3.2,0-4.4c0.6-0.6,1.4-0.9,2.2-0.9
|
||||
c0.8,0,1.6,0.3,2.2,0.9c0.6,0.6,0.9,1.4,0.9,2.2c0,0.8-0.3,1.6-0.9,2.2C36.8,45.2,36,45.6,35.2,45.6z M35.2,41.7
|
||||
c-0.2,0-0.4,0.1-0.6,0.2c-0.3,0.3-0.3,0.8,0,1.1c0.3,0.3,0.8,0.3,1.1,0c0.1-0.1,0.2-0.3,0.2-0.6s-0.1-0.4-0.2-0.6
|
||||
C35.6,41.8,35.4,41.7,35.2,41.7z"/>
|
||||
</g>
|
||||
<path fill="#0E7077" d="M33.8,41.1c0.8-0.8,2-0.8,2.7,0c0.8,0.8,0.8,2,0,2.7c-0.8,0.8-2,0.8-2.7,0C33.1,43.1,33.1,41.8,33.8,41.1
|
||||
"/>
|
||||
<g>
|
||||
|
||||
<rect x="19.6" y="26.2" transform="matrix(0.9064 0.4224 -0.4224 0.9064 14.1626 -9.1647)" fill="#0E7077" width="16.4" height="2.3"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.6 KiB |
17
interface/resources/images/login.svg
Normal file
17
interface/resources/images/login.svg
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 23.6 22.3" enable-background="new 0 0 23.6 22.3" xml:space="preserve">
|
||||
<g>
|
||||
<g id="Your_Icon_8_">
|
||||
<g>
|
||||
<polygon fill="#E7EEEE" points="6.8,7.8 0,7.8 0,14.1 6.8,14.1 6.8,19 14.4,11 6.8,3.1 "/>
|
||||
<polygon fill="#E7EEEE" points="12.9,3.1 14.3,3.1 14.3,1.4 12.9,1.4 12.9,1.4 11.2,1.4 11.2,6.5 12.9,8.2 "/>
|
||||
<polygon fill="#E7EEEE" points="12.9,13.7 11.2,15.5 11.2,20.7 14.3,20.7 14.3,19.1 12.9,19.1 "/>
|
||||
<path fill="#E7EEEE" d="M15,0v22.3l8.5-2.4V2.4L15,0z M17.8,12.2h-0.3c-0.4,0-0.7-0.4-0.8-0.9h-0.3v-0.7h0.3
|
||||
c0.1-0.5,0.4-0.9,0.8-0.9h0.3c0.5,0,0.8,0.5,0.8,1.2C18.7,11.6,18.3,12.2,17.8,12.2z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1 KiB |
|
@ -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);
|
||||
}
|
|
@ -317,6 +317,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
|
||||
|
@ -865,7 +868,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
|
||||
case Qt::Key_G:
|
||||
if (isShifted) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::Gravity);
|
||||
Menu::getInstance()->triggerOption(MenuOption::ObeyEnvironmentalGravity);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -3578,34 +3581,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "ui/InfoView.h"
|
||||
#include "ui/MetavoxelEditor.h"
|
||||
#include "ui/ModelsBrowser.h"
|
||||
#include "ui/LoginDialog.h"
|
||||
|
||||
|
||||
Menu* Menu::_instance = NULL;
|
||||
|
@ -187,9 +188,9 @@ Menu::Menu() :
|
|||
QAction::PreferencesRole);
|
||||
|
||||
addDisabledActionAndSeparator(editMenu, "Physics");
|
||||
addCheckableActionToQMenuAndActionHash(editMenu, MenuOption::Gravity, Qt::SHIFT | Qt::Key_G, false);
|
||||
|
||||
|
||||
QObject* avatar = appInstance->getAvatar();
|
||||
addCheckableActionToQMenuAndActionHash(editMenu, MenuOption::ObeyEnvironmentalGravity, Qt::SHIFT | Qt::Key_G, true,
|
||||
avatar, SLOT(updateMotionBehaviors()));
|
||||
|
||||
|
||||
addAvatarCollisionSubMenu(editMenu);
|
||||
|
@ -508,7 +509,7 @@ void Menu::loadSettings(QSettings* settings) {
|
|||
// MyAvatar caches some menu options, so we have to update them whenever we load settings.
|
||||
// TODO: cache more settings in MyAvatar that are checked with very high frequency.
|
||||
MyAvatar* myAvatar = Application::getInstance()->getAvatar();
|
||||
myAvatar->updateCollisionFlags();
|
||||
myAvatar->updateCollisionGroups();
|
||||
|
||||
if (lockedSettings) {
|
||||
Application::getInstance()->unlockSettings();
|
||||
|
@ -817,38 +818,9 @@ const int QLINE_MINIMUM_WIDTH = 400;
|
|||
const float DIALOG_RATIO_OF_WINDOW = 0.30f;
|
||||
|
||||
void Menu::loginForCurrentDomain() {
|
||||
QDialog loginDialog(Application::getInstance()->getWindow());
|
||||
loginDialog.setWindowTitle("Login");
|
||||
|
||||
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||
loginDialog.setLayout(layout);
|
||||
loginDialog.setWindowFlags(Qt::Sheet);
|
||||
|
||||
QFormLayout* form = new QFormLayout();
|
||||
layout->addLayout(form, 1);
|
||||
|
||||
QLineEdit* loginLineEdit = new QLineEdit();
|
||||
loginLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||
form->addRow("Login:", loginLineEdit);
|
||||
|
||||
QLineEdit* passwordLineEdit = new QLineEdit();
|
||||
passwordLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||
passwordLineEdit->setEchoMode(QLineEdit::Password);
|
||||
form->addRow("Password:", passwordLineEdit);
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
loginDialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
||||
loginDialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
||||
layout->addWidget(buttons);
|
||||
|
||||
int dialogReturn = loginDialog.exec();
|
||||
|
||||
if (dialogReturn == QDialog::Accepted && !loginLineEdit->text().isEmpty() && !passwordLineEdit->text().isEmpty()) {
|
||||
// attempt to get an access token given this username and password
|
||||
AccountManager::getInstance().requestAccessToken(loginLineEdit->text(), passwordLineEdit->text());
|
||||
}
|
||||
|
||||
sendFakeEnterEvent();
|
||||
LoginDialog* loginDialog = new LoginDialog(Application::getInstance()->getWindow());
|
||||
loginDialog->show();
|
||||
loginDialog->resizeAndPosition(false);
|
||||
}
|
||||
|
||||
void Menu::editPreferences() {
|
||||
|
@ -931,7 +903,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];
|
||||
|
||||
|
@ -952,12 +929,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());
|
||||
}
|
||||
|
@ -1381,13 +1353,13 @@ void Menu::addAvatarCollisionSubMenu(QMenu* overMenu) {
|
|||
Application* appInstance = Application::getInstance();
|
||||
QObject* avatar = appInstance->getAvatar();
|
||||
addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithEnvironment,
|
||||
0, false, avatar, SLOT(updateCollisionFlags()));
|
||||
0, false, avatar, SLOT(updateCollisionGroups()));
|
||||
addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithAvatars,
|
||||
0, true, avatar, SLOT(updateCollisionFlags()));
|
||||
0, true, avatar, SLOT(updateCollisionGroups()));
|
||||
addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithVoxels,
|
||||
0, false, avatar, SLOT(updateCollisionFlags()));
|
||||
0, false, avatar, SLOT(updateCollisionGroups()));
|
||||
addCheckableActionToQMenuAndActionHash(subMenu, MenuOption::CollideWithParticles,
|
||||
0, true, avatar, SLOT(updateCollisionFlags()));
|
||||
0, true, avatar, SLOT(updateCollisionGroups()));
|
||||
}
|
||||
|
||||
QAction* Menu::getActionFromName(const QString& menuName, QMenu* menu) {
|
||||
|
|
|
@ -315,7 +315,7 @@ namespace MenuOption {
|
|||
const QString GoTo = "Go To...";
|
||||
const QString GoToDomain = "Go To Domain...";
|
||||
const QString GoToLocation = "Go To Location...";
|
||||
const QString Gravity = "Use Gravity";
|
||||
const QString ObeyEnvironmentalGravity = "Obey Environmental Gravity";
|
||||
const QString HandsCollideWithSelf = "Collide With Self";
|
||||
const QString HeadMouse = "Head Mouse";
|
||||
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
||||
|
|
|
@ -47,16 +47,14 @@ Avatar::Avatar() :
|
|||
AvatarData(),
|
||||
_skeletonModel(this),
|
||||
_bodyYawDelta(0.0f),
|
||||
_mode(AVATAR_MODE_STANDING),
|
||||
_velocity(0.0f, 0.0f, 0.0f),
|
||||
_thrust(0.0f, 0.0f, 0.0f),
|
||||
_leanScale(0.5f),
|
||||
_scale(1.0f),
|
||||
_worldUpDirection(DEFAULT_UP_DIRECTION),
|
||||
_mouseRayOrigin(0.0f, 0.0f, 0.0f),
|
||||
_mouseRayDirection(0.0f, 0.0f, 0.0f),
|
||||
_moving(false),
|
||||
_collisionFlags(0),
|
||||
_collisionGroups(0),
|
||||
_initialized(false),
|
||||
_shouldRenderBillboard(true)
|
||||
{
|
||||
|
@ -138,20 +136,9 @@ void Avatar::simulate(float deltaTime) {
|
|||
head->simulate(deltaTime, false, _shouldRenderBillboard);
|
||||
}
|
||||
|
||||
// use speed and angular velocity to determine walking vs. standing
|
||||
float speed = glm::length(_velocity);
|
||||
if (speed + fabs(_bodyYawDelta) > 0.2) {
|
||||
_mode = AVATAR_MODE_WALKING;
|
||||
} else {
|
||||
_mode = AVATAR_MODE_INTERACTING;
|
||||
}
|
||||
|
||||
// update position by velocity, and subtract the change added earlier for gravity
|
||||
_position += _velocity * deltaTime;
|
||||
|
||||
// Zero thrust out now that we've added it to velocity in this frame
|
||||
_thrust = glm::vec3(0, 0, 0);
|
||||
|
||||
// update animation for display name fade in/out
|
||||
if ( _displayNameTargetAlpha != _displayNameAlpha) {
|
||||
// the alpha function is
|
||||
|
@ -166,7 +153,7 @@ void Avatar::simulate(float deltaTime) {
|
|||
// Fading in
|
||||
_displayNameAlpha = 1 - (1 - _displayNameAlpha) * coef;
|
||||
}
|
||||
_displayNameAlpha = abs(_displayNameAlpha - _displayNameTargetAlpha) < 0.01? _displayNameTargetAlpha : _displayNameAlpha;
|
||||
_displayNameAlpha = abs(_displayNameAlpha - _displayNameTargetAlpha) < 0.01f ? _displayNameTargetAlpha : _displayNameAlpha;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -563,7 +550,7 @@ bool Avatar::findCollisions(const QVector<const Shape*>& shapes, CollisionList&
|
|||
}
|
||||
|
||||
bool Avatar::findParticleCollisions(const glm::vec3& particleCenter, float particleRadius, CollisionList& collisions) {
|
||||
if (_collisionFlags & COLLISION_GROUP_PARTICLES) {
|
||||
if (_collisionGroups & COLLISION_GROUP_PARTICLES) {
|
||||
return false;
|
||||
}
|
||||
bool collided = false;
|
||||
|
@ -753,19 +740,19 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
|
|||
glEnd();
|
||||
}
|
||||
|
||||
void Avatar::updateCollisionFlags() {
|
||||
_collisionFlags = 0;
|
||||
void Avatar::updateCollisionGroups() {
|
||||
_collisionGroups = 0;
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CollideWithEnvironment)) {
|
||||
_collisionFlags |= COLLISION_GROUP_ENVIRONMENT;
|
||||
_collisionGroups |= COLLISION_GROUP_ENVIRONMENT;
|
||||
}
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CollideWithAvatars)) {
|
||||
_collisionFlags |= COLLISION_GROUP_AVATARS;
|
||||
_collisionGroups |= COLLISION_GROUP_AVATARS;
|
||||
}
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CollideWithVoxels)) {
|
||||
_collisionFlags |= COLLISION_GROUP_VOXELS;
|
||||
_collisionGroups |= COLLISION_GROUP_VOXELS;
|
||||
}
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CollideWithParticles)) {
|
||||
_collisionFlags |= COLLISION_GROUP_PARTICLES;
|
||||
_collisionGroups |= COLLISION_GROUP_PARTICLES;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,13 +46,6 @@ enum DriveKeys {
|
|||
MAX_DRIVE_KEYS
|
||||
};
|
||||
|
||||
enum AvatarMode {
|
||||
AVATAR_MODE_STANDING = 0,
|
||||
AVATAR_MODE_WALKING,
|
||||
AVATAR_MODE_INTERACTING,
|
||||
NUM_AVATAR_MODES
|
||||
};
|
||||
|
||||
enum ScreenTintLayer {
|
||||
SCREEN_TINT_BEFORE_LANDSCAPE = 0,
|
||||
SCREEN_TINT_BEFORE_AVATARS,
|
||||
|
@ -70,6 +63,7 @@ class Texture;
|
|||
|
||||
class Avatar : public AvatarData {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(quint32 collisionGroups READ getCollisionGroups WRITE setCollisionGroups)
|
||||
|
||||
public:
|
||||
Avatar();
|
||||
|
@ -155,8 +149,11 @@ public:
|
|||
virtual float getBoundingRadius() const;
|
||||
void updateShapePositions();
|
||||
|
||||
quint32 getCollisionGroups() const { return _collisionGroups; }
|
||||
virtual void setCollisionGroups(quint32 collisionGroups) { _collisionGroups = (collisionGroups & VALID_COLLISION_GROUPS); }
|
||||
|
||||
public slots:
|
||||
void updateCollisionFlags();
|
||||
void updateCollisionGroups();
|
||||
|
||||
signals:
|
||||
void collisionWithAvatar(const QUuid& myUUID, const QUuid& theirUUID, const CollisionInfo& collision);
|
||||
|
@ -164,9 +161,7 @@ signals:
|
|||
protected:
|
||||
SkeletonModel _skeletonModel;
|
||||
float _bodyYawDelta;
|
||||
AvatarMode _mode;
|
||||
glm::vec3 _velocity;
|
||||
glm::vec3 _thrust;
|
||||
float _leanScale;
|
||||
float _scale;
|
||||
glm::vec3 _worldUpDirection;
|
||||
|
@ -175,7 +170,7 @@ protected:
|
|||
float _stringLength;
|
||||
bool _moving; ///< set when position is changing
|
||||
|
||||
uint32_t _collisionFlags;
|
||||
quint32 _collisionGroups;
|
||||
|
||||
// protected methods...
|
||||
glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
||||
|
|
|
@ -55,16 +55,13 @@ MyAvatar::MyAvatar() :
|
|||
_shouldJump(false),
|
||||
_gravity(0.0f, -1.0f, 0.0f),
|
||||
_distanceToNearestAvatar(std::numeric_limits<float>::max()),
|
||||
_elapsedTimeMoving(0.0f),
|
||||
_elapsedTimeStopped(0.0f),
|
||||
_elapsedTimeSinceCollision(0.0f),
|
||||
_lastCollisionPosition(0, 0, 0),
|
||||
_speedBrakes(false),
|
||||
_thrust(0.0f),
|
||||
_isThrustOn(false),
|
||||
_thrustMultiplier(1.0f),
|
||||
_moveTarget(0,0,0),
|
||||
_motionBehaviors(0),
|
||||
_lastBodyPenetration(0.0f),
|
||||
_moveTargetStepCounter(0),
|
||||
_lookAtTargetAvatar(),
|
||||
_shouldRender(true),
|
||||
_billboardValid(false),
|
||||
|
@ -98,11 +95,6 @@ void MyAvatar::reset() {
|
|||
setOrientation(glm::quat(glm::vec3(0.0f)));
|
||||
}
|
||||
|
||||
void MyAvatar::setMoveTarget(const glm::vec3 moveTarget) {
|
||||
_moveTarget = moveTarget;
|
||||
_moveTargetStepCounter = 0;
|
||||
}
|
||||
|
||||
void MyAvatar::update(float deltaTime) {
|
||||
Head* head = getHead();
|
||||
head->relaxLean(deltaTime);
|
||||
|
@ -133,10 +125,8 @@ void MyAvatar::update(float deltaTime) {
|
|||
head->setAudioLoudness(audio->getLastInputLoudness());
|
||||
head->setAudioAverageLoudness(audio->getAudioAverageInputLoudness());
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) {
|
||||
if (_motionBehaviors & AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY) {
|
||||
setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()));
|
||||
} else {
|
||||
setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
simulate(deltaTime);
|
||||
|
@ -146,17 +136,6 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
|
||||
glm::quat orientation = getOrientation();
|
||||
|
||||
// Update movement timers
|
||||
_elapsedTimeSinceCollision += deltaTime;
|
||||
const float VELOCITY_MOVEMENT_TIMER_THRESHOLD = 0.2f;
|
||||
if (glm::length(_velocity) < VELOCITY_MOVEMENT_TIMER_THRESHOLD) {
|
||||
_elapsedTimeMoving = 0.0f;
|
||||
_elapsedTimeStopped += deltaTime;
|
||||
} else {
|
||||
_elapsedTimeStopped = 0.0f;
|
||||
_elapsedTimeMoving += deltaTime;
|
||||
}
|
||||
|
||||
if (_scale != _targetScale) {
|
||||
float scale = (1.0f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _targetScale;
|
||||
setScale(scale);
|
||||
|
@ -270,34 +249,11 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
// update the euler angles
|
||||
setOrientation(orientation);
|
||||
|
||||
const float WALKING_SPEED_THRESHOLD = 0.2f;
|
||||
// use speed and angular velocity to determine walking vs. standing
|
||||
float speed = glm::length(_velocity);
|
||||
if (speed + fabs(_bodyYawDelta) > WALKING_SPEED_THRESHOLD) {
|
||||
_mode = AVATAR_MODE_WALKING;
|
||||
} else {
|
||||
_mode = AVATAR_MODE_INTERACTING;
|
||||
}
|
||||
|
||||
// update moving flag based on speed
|
||||
const float MOVING_SPEED_THRESHOLD = 0.01f;
|
||||
float speed = glm::length(_velocity);
|
||||
_moving = speed > MOVING_SPEED_THRESHOLD;
|
||||
|
||||
// If a move target is set, update position explicitly
|
||||
const float MOVE_FINISHED_TOLERANCE = 0.1f;
|
||||
const float MOVE_SPEED_FACTOR = 2.0f;
|
||||
const int MOVE_TARGET_MAX_STEPS = 250;
|
||||
if ((glm::length(_moveTarget) > EPSILON) && (_moveTargetStepCounter < MOVE_TARGET_MAX_STEPS)) {
|
||||
if (glm::length(_position - _moveTarget) > MOVE_FINISHED_TOLERANCE) {
|
||||
_position += (_moveTarget - _position) * (deltaTime * MOVE_SPEED_FACTOR);
|
||||
_moveTargetStepCounter++;
|
||||
} else {
|
||||
// Move completed
|
||||
_moveTarget = glm::vec3(0,0,0);
|
||||
_moveTargetStepCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
updateChatCircle(deltaTime);
|
||||
|
||||
_position += _velocity * deltaTime;
|
||||
|
@ -325,10 +281,10 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
head->simulate(deltaTime, true);
|
||||
|
||||
// Zero thrust out now that we've added it to velocity in this frame
|
||||
_thrust = glm::vec3(0.0f);
|
||||
_thrust *= glm::vec3(0.0f);
|
||||
|
||||
// now that we're done stepping the avatar forward in time, compute new collisions
|
||||
if (_collisionFlags != 0) {
|
||||
if (_collisionGroups != 0) {
|
||||
Camera* myCamera = Application::getInstance()->getCamera();
|
||||
|
||||
float radius = getSkeletonHeight() * COLLISION_RADIUS_SCALE;
|
||||
|
@ -336,15 +292,15 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
radius = myCamera->getAspectRatio() * (myCamera->getNearClip() / cos(myCamera->getFieldOfView() / 2.0f));
|
||||
radius *= COLLISION_RADIUS_SCALAR;
|
||||
}
|
||||
if (_collisionFlags) {
|
||||
if (_collisionGroups) {
|
||||
updateShapePositions();
|
||||
if (_collisionFlags & COLLISION_GROUP_ENVIRONMENT) {
|
||||
if (_collisionGroups & COLLISION_GROUP_ENVIRONMENT) {
|
||||
updateCollisionWithEnvironment(deltaTime, radius);
|
||||
}
|
||||
if (_collisionFlags & COLLISION_GROUP_VOXELS) {
|
||||
if (_collisionGroups & COLLISION_GROUP_VOXELS) {
|
||||
updateCollisionWithVoxels(deltaTime, radius);
|
||||
}
|
||||
if (_collisionFlags & COLLISION_GROUP_AVATARS) {
|
||||
if (_collisionGroups & COLLISION_GROUP_AVATARS) {
|
||||
updateCollisionWithAvatars(deltaTime);
|
||||
}
|
||||
}
|
||||
|
@ -452,8 +408,6 @@ void MyAvatar::renderDebugBodyPoints() {
|
|||
glTranslatef(position.x, position.y, position.z);
|
||||
glutSolidSphere(0.15, 10, 10);
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// virtual
|
||||
|
@ -507,6 +461,27 @@ void MyAvatar::renderHeadMouse() const {
|
|||
*/
|
||||
}
|
||||
|
||||
void MyAvatar::setLocalGravity(glm::vec3 gravity) {
|
||||
_motionBehaviors |= AVATAR_MOTION_OBEY_LOCAL_GRAVITY;
|
||||
// Environmental and Local gravities are incompatible. Since Local is being set here
|
||||
// the environmental setting must be removed.
|
||||
_motionBehaviors &= ~AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY;
|
||||
setGravity(gravity);
|
||||
}
|
||||
|
||||
void MyAvatar::setGravity(const glm::vec3& gravity) {
|
||||
_gravity = gravity;
|
||||
getHead()->setGravity(_gravity);
|
||||
|
||||
// use the gravity to determine the new world up direction, if possible
|
||||
float gravityLength = glm::length(gravity);
|
||||
if (gravityLength > EPSILON) {
|
||||
_worldUpDirection = _gravity / -gravityLength;
|
||||
} else {
|
||||
_worldUpDirection = DEFAULT_UP_DIRECTION;
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::saveData(QSettings* settings) {
|
||||
settings->beginGroup("Avatar");
|
||||
|
||||
|
@ -831,7 +806,6 @@ void MyAvatar::applyHardCollision(const glm::vec3& penetration, float elasticity
|
|||
// cancel out the velocity component in the direction of penetration
|
||||
float penetrationLength = glm::length(penetration);
|
||||
if (penetrationLength > EPSILON) {
|
||||
_elapsedTimeSinceCollision = 0.0f;
|
||||
glm::vec3 direction = penetration / penetrationLength;
|
||||
_velocity -= glm::dot(_velocity, direction) * direction * (1.0f + elasticity);
|
||||
_velocity *= glm::clamp(1.0f - damping, 0.0f, 1.0f);
|
||||
|
@ -868,7 +842,7 @@ void MyAvatar::updateCollisionSound(const glm::vec3 &penetration, float deltaTim
|
|||
std::min(COLLISION_LOUDNESS * velocityTowardCollision, 1.0f),
|
||||
frequency * (1.0f + velocityTangentToCollision / velocityTowardCollision),
|
||||
std::min(velocityTangentToCollision / velocityTowardCollision * NOISE_SCALING, 1.0f),
|
||||
1.0f - DURATION_SCALING * powf(frequency, 0.5f) / velocityTowardCollision, true);
|
||||
1.0f - DURATION_SCALING * powf(frequency, 0.5f) / velocityTowardCollision, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1091,19 +1065,6 @@ void MyAvatar::maybeUpdateBillboard() {
|
|||
sendBillboardPacket();
|
||||
}
|
||||
|
||||
void MyAvatar::setGravity(glm::vec3 gravity) {
|
||||
_gravity = gravity;
|
||||
getHead()->setGravity(_gravity);
|
||||
|
||||
// use the gravity to determine the new world up direction, if possible
|
||||
float gravityLength = glm::length(gravity);
|
||||
if (gravityLength > EPSILON) {
|
||||
_worldUpDirection = _gravity / -gravityLength;
|
||||
} else {
|
||||
_worldUpDirection = DEFAULT_UP_DIRECTION;
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::goHome() {
|
||||
qDebug("Going Home!");
|
||||
setPosition(START_LOCATION);
|
||||
|
@ -1188,7 +1149,40 @@ void MyAvatar::goToLocationFromResponse(const QJsonObject& jsonObject) {
|
|||
} else {
|
||||
QMessageBox::warning(Application::getInstance()->getWindow(), "", "That user or location could not be found.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MyAvatar::updateMotionBehaviors() {
|
||||
_motionBehaviors = 0;
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::ObeyEnvironmentalGravity)) {
|
||||
_motionBehaviors |= AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY;
|
||||
// Environmental and Local gravities are incompatible. Environmental setting trumps local.
|
||||
_motionBehaviors &= ~AVATAR_MOTION_OBEY_LOCAL_GRAVITY;
|
||||
}
|
||||
if (! (_motionBehaviors & (AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY | AVATAR_MOTION_OBEY_LOCAL_GRAVITY))) {
|
||||
setGravity(glm::vec3(0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::setCollisionGroups(quint32 collisionGroups) {
|
||||
Avatar::setCollisionGroups(collisionGroups & VALID_COLLISION_GROUPS);
|
||||
Menu* menu = Menu::getInstance();
|
||||
menu->setIsOptionChecked(MenuOption::CollideWithEnvironment, (bool)(_collisionGroups & COLLISION_GROUP_ENVIRONMENT));
|
||||
menu->setIsOptionChecked(MenuOption::CollideWithAvatars, (bool)(_collisionGroups & COLLISION_GROUP_AVATARS));
|
||||
menu->setIsOptionChecked(MenuOption::CollideWithVoxels, (bool)(_collisionGroups & COLLISION_GROUP_VOXELS));
|
||||
menu->setIsOptionChecked(MenuOption::CollideWithParticles, (bool)(_collisionGroups & COLLISION_GROUP_PARTICLES));
|
||||
}
|
||||
|
||||
void MyAvatar::setMotionBehaviors(quint32 flags) {
|
||||
_motionBehaviors = flags;
|
||||
Menu* menu = Menu::getInstance();
|
||||
menu->setIsOptionChecked(MenuOption::ObeyEnvironmentalGravity, (bool)(_motionBehaviors & AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY));
|
||||
// Environmental and Local gravities are incompatible. Environmental setting trumps local.
|
||||
if (_motionBehaviors & AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY) {
|
||||
_motionBehaviors &= ~AVATAR_MOTION_OBEY_LOCAL_GRAVITY;
|
||||
setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()));
|
||||
} else if (! (_motionBehaviors & (AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY | AVATAR_MOTION_OBEY_LOCAL_GRAVITY))) {
|
||||
setGravity(glm::vec3(0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) {
|
||||
|
|
|
@ -28,6 +28,8 @@ enum AvatarHandState
|
|||
class MyAvatar : public Avatar {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally)
|
||||
Q_PROPERTY(quint32 motionBehaviors READ getMotionBehaviors WRITE setMotionBehaviors)
|
||||
Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setLocalGravity)
|
||||
|
||||
public:
|
||||
MyAvatar();
|
||||
|
@ -49,15 +51,11 @@ public:
|
|||
void setMousePressed(bool mousePressed) { _mousePressed = mousePressed; }
|
||||
void setVelocity(const glm::vec3 velocity) { _velocity = velocity; }
|
||||
void setLeanScale(float scale) { _leanScale = scale; }
|
||||
void setGravity(glm::vec3 gravity);
|
||||
void setMoveTarget(const glm::vec3 moveTarget);
|
||||
void setLocalGravity(glm::vec3 gravity);
|
||||
void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; }
|
||||
|
||||
// getters
|
||||
AvatarMode getMode() const { return _mode; }
|
||||
float getLeanScale() const { return _leanScale; }
|
||||
float getElapsedTimeStopped() const { return _elapsedTimeStopped; }
|
||||
float getElapsedTimeMoving() const { return _elapsedTimeMoving; }
|
||||
const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
|
||||
const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
|
||||
glm::vec3 getGravity() const { return _gravity; }
|
||||
|
@ -91,6 +89,10 @@ public:
|
|||
virtual void setFaceModelURL(const QUrl& faceModelURL);
|
||||
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL);
|
||||
|
||||
virtual void setCollisionGroups(quint32 collisionGroups);
|
||||
void setMotionBehaviors(quint32 flags);
|
||||
quint32 getMotionBehaviors() const { return _motionBehaviors; }
|
||||
|
||||
void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration);
|
||||
|
||||
public slots:
|
||||
|
@ -107,6 +109,8 @@ public slots:
|
|||
glm::vec3 getThrust() { return _thrust; };
|
||||
void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }
|
||||
|
||||
void updateMotionBehaviors();
|
||||
|
||||
signals:
|
||||
void transformChanged();
|
||||
|
||||
|
@ -117,17 +121,19 @@ private:
|
|||
bool _shouldJump;
|
||||
float _driveKeys[MAX_DRIVE_KEYS];
|
||||
glm::vec3 _gravity;
|
||||
glm::vec3 _environmentGravity;
|
||||
float _distanceToNearestAvatar; // How close is the nearest avatar?
|
||||
float _elapsedTimeMoving; // Timers to drive camera transitions when moving
|
||||
float _elapsedTimeStopped;
|
||||
float _elapsedTimeSinceCollision;
|
||||
|
||||
// motion stuff
|
||||
glm::vec3 _lastCollisionPosition;
|
||||
bool _speedBrakes;
|
||||
glm::vec3 _thrust; // final acceleration for the current frame
|
||||
bool _isThrustOn;
|
||||
float _thrustMultiplier;
|
||||
glm::vec3 _moveTarget;
|
||||
|
||||
quint32 _motionBehaviors;
|
||||
|
||||
glm::vec3 _lastBodyPenetration;
|
||||
int _moveTargetStepCounter;
|
||||
QWeakPointer<AvatarData> _lookAtTargetAvatar;
|
||||
glm::vec3 _targetAvatarPosition;
|
||||
bool _shouldRender;
|
||||
|
@ -144,6 +150,7 @@ private:
|
|||
void updateCollisionSound(const glm::vec3& penetration, float deltaTime, float frequency);
|
||||
void updateChatCircle(float deltaTime);
|
||||
void maybeUpdateBillboard();
|
||||
void setGravity(const glm::vec3& gravity);
|
||||
};
|
||||
|
||||
#endif // hifi_MyAvatar_h
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <SharedUtil.h>
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
initialiseUsecTimestampNow();
|
||||
QElapsedTimer startupTime;
|
||||
startupTime.start();
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ FramelessDialog::FramelessDialog(QWidget *parent, Qt::WindowFlags flags, Positio
|
|||
_isResizing(false),
|
||||
_resizeInitialWidth(0),
|
||||
_selfHidden(false),
|
||||
_position(position) {
|
||||
_position(position),
|
||||
_hideOnBlur(true) {
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
|
@ -44,7 +45,7 @@ bool FramelessDialog::eventFilter(QObject* sender, QEvent* event) {
|
|||
}
|
||||
break;
|
||||
case QEvent::WindowStateChange:
|
||||
if (parentWidget()->isMinimized()) {
|
||||
if (_hideOnBlur && parentWidget()->isMinimized()) {
|
||||
if (isVisible()) {
|
||||
_selfHidden = true;
|
||||
setHidden(true);
|
||||
|
@ -56,7 +57,7 @@ bool FramelessDialog::eventFilter(QObject* sender, QEvent* event) {
|
|||
break;
|
||||
case QEvent::ApplicationDeactivate:
|
||||
// hide on minimize and focus lost
|
||||
if (isVisible()) {
|
||||
if (_hideOnBlur && isVisible()) {
|
||||
_selfHidden = true;
|
||||
setHidden(true);
|
||||
}
|
||||
|
@ -85,18 +86,23 @@ void FramelessDialog::setStyleSheetFile(const QString& fileName) {
|
|||
|
||||
void FramelessDialog::showEvent(QShowEvent* event) {
|
||||
resizeAndPosition();
|
||||
QDialog::showEvent(event);
|
||||
}
|
||||
|
||||
void FramelessDialog::resizeAndPosition(bool resizeParent) {
|
||||
// keep full app height
|
||||
setFixedHeight(parentWidget()->size().height());
|
||||
// keep full app height or width depending on position
|
||||
if (_position == POSITION_LEFT || _position == POSITION_RIGHT) {
|
||||
setFixedHeight(parentWidget()->size().height());
|
||||
} else {
|
||||
setFixedWidth(parentWidget()->size().width());
|
||||
}
|
||||
|
||||
// resize parrent if width is smaller than this dialog
|
||||
if (resizeParent && parentWidget()->size().width() < size().width()) {
|
||||
parentWidget()->resize(size().width(), parentWidget()->size().height());
|
||||
}
|
||||
|
||||
if (_position == POSITION_LEFT) {
|
||||
if (_position == POSITION_LEFT || _position == POSITION_TOP) {
|
||||
// move to upper left corner
|
||||
move(parentWidget()->geometry().topLeft());
|
||||
} else if (_position == POSITION_RIGHT) {
|
||||
|
@ -105,16 +111,26 @@ void FramelessDialog::resizeAndPosition(bool resizeParent) {
|
|||
pos.setX(pos.x() - size().width());
|
||||
move(pos);
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
void FramelessDialog::mousePressEvent(QMouseEvent* mouseEvent) {
|
||||
if (_allowResize && mouseEvent->button() == Qt::LeftButton) {
|
||||
bool hitLeft = _position == POSITION_LEFT && abs(mouseEvent->pos().x() - size().width()) < RESIZE_HANDLE_WIDTH;
|
||||
bool hitRight = _position == POSITION_RIGHT && mouseEvent->pos().x() < RESIZE_HANDLE_WIDTH;
|
||||
if (hitLeft || hitRight) {
|
||||
_isResizing = true;
|
||||
_resizeInitialWidth = size().width();
|
||||
QApplication::setOverrideCursor(Qt::SizeHorCursor);
|
||||
if (_position == POSITION_LEFT || _position == POSITION_RIGHT) {
|
||||
bool hitLeft = (_position == POSITION_LEFT) && (abs(mouseEvent->pos().x() - size().width()) < RESIZE_HANDLE_WIDTH);
|
||||
bool hitRight = (_position == POSITION_RIGHT) && (mouseEvent->pos().x() < RESIZE_HANDLE_WIDTH);
|
||||
if (hitLeft || hitRight) {
|
||||
_isResizing = true;
|
||||
_resizeInitialWidth = size().width();
|
||||
QApplication::setOverrideCursor(Qt::SizeHorCursor);
|
||||
}
|
||||
} else {
|
||||
bool hitTop = (_position == POSITION_TOP) && (abs(mouseEvent->pos().y() - size().height()) < RESIZE_HANDLE_WIDTH);
|
||||
if (hitTop) {
|
||||
_isResizing = true;
|
||||
_resizeInitialWidth = size().height();
|
||||
QApplication::setOverrideCursor(Qt::SizeHorCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,6 +150,8 @@ void FramelessDialog::mouseMoveEvent(QMouseEvent* mouseEvent) {
|
|||
resizeAndPosition();
|
||||
_resizeInitialWidth = size().width();
|
||||
setUpdatesEnabled(true);
|
||||
} else if (_position == POSITION_TOP) {
|
||||
resize(size().width(), mouseEvent->pos().y());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,14 +17,17 @@
|
|||
|
||||
class FramelessDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Position { POSITION_LEFT, POSITION_RIGHT };
|
||||
|
||||
FramelessDialog(QWidget* parent = 0, Qt::WindowFlags flags = 0, Position position = POSITION_LEFT);
|
||||
public:
|
||||
enum Position { POSITION_LEFT, POSITION_RIGHT, POSITION_TOP };
|
||||
|
||||
FramelessDialog(QWidget* parent, Qt::WindowFlags flags = 0, Position position = POSITION_LEFT);
|
||||
void setStyleSheetFile(const QString& fileName);
|
||||
void setAllowResize(bool allowResize) { _allowResize = allowResize; };
|
||||
bool getAllowResize() { return _allowResize; };
|
||||
void setHideOnBlur(bool hideOnBlur) { _hideOnBlur = hideOnBlur; };
|
||||
bool getHideOnBlur() { return _hideOnBlur; };
|
||||
void resizeAndPosition(bool resizeParent = true);
|
||||
|
||||
protected:
|
||||
virtual void mouseMoveEvent(QMouseEvent* mouseEvent);
|
||||
|
@ -42,6 +45,7 @@ private:
|
|||
int _resizeInitialWidth;
|
||||
bool _selfHidden; ///< true when the dialog itself because of a window event (deactivation or minimization)
|
||||
Position _position;
|
||||
bool _hideOnBlur;
|
||||
|
||||
};
|
||||
|
||||
|
|
91
interface/src/ui/LoginDialog.cpp
Normal file
91
interface/src/ui/LoginDialog.cpp
Normal file
|
@ -0,0 +1,91 @@
|
|||
//
|
||||
// LoginDialog.cpp
|
||||
// interface/src/ui
|
||||
//
|
||||
// Created by Ryan Huffman on 4/23/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "Application.h"
|
||||
#include "Menu.h"
|
||||
#include "AccountManager.h"
|
||||
#include "ui_loginDialog.h"
|
||||
|
||||
#include "LoginDialog.h"
|
||||
|
||||
const QString FORGOT_PASSWORD_URL = "https://data-web.highfidelity.io/password/new";
|
||||
|
||||
LoginDialog::LoginDialog(QWidget* parent) :
|
||||
FramelessDialog(parent, 0, FramelessDialog::POSITION_TOP),
|
||||
_ui(new Ui::LoginDialog) {
|
||||
|
||||
_ui->setupUi(this);
|
||||
_ui->errorLabel->hide();
|
||||
_ui->emailLineEdit->setFocus();
|
||||
_ui->logoLabel->setPixmap(QPixmap(Application::resourcesPath() + "images/hifi-logo.svg"));
|
||||
_ui->loginButton->setIcon(QIcon(Application::resourcesPath() + "images/login.svg"));
|
||||
_ui->infoLabel->setVisible(false);
|
||||
_ui->errorLabel->setVisible(false);
|
||||
|
||||
setModal(true);
|
||||
setHideOnBlur(false);
|
||||
|
||||
connect(&AccountManager::getInstance(), &AccountManager::loginComplete,
|
||||
this, &LoginDialog::handleLoginCompleted);
|
||||
connect(&AccountManager::getInstance(), &AccountManager::loginFailed,
|
||||
this, &LoginDialog::handleLoginFailed);
|
||||
connect(_ui->loginButton, &QPushButton::clicked,
|
||||
this, &LoginDialog::handleLoginClicked);
|
||||
connect(_ui->closeButton, &QPushButton::clicked,
|
||||
this, &LoginDialog::close);
|
||||
};
|
||||
|
||||
LoginDialog::~LoginDialog() {
|
||||
delete _ui;
|
||||
};
|
||||
|
||||
void LoginDialog::handleLoginCompleted(const QUrl& authURL) {
|
||||
_ui->infoLabel->setVisible(false);
|
||||
_ui->errorLabel->setVisible(false);
|
||||
close();
|
||||
};
|
||||
|
||||
void LoginDialog::handleLoginFailed() {
|
||||
_ui->infoLabel->setVisible(false);
|
||||
_ui->errorLabel->setVisible(true);
|
||||
|
||||
_ui->errorLabel->show();
|
||||
_ui->loginArea->setDisabled(false);
|
||||
|
||||
// Move focus to password and select the entire line
|
||||
_ui->passwordLineEdit->setFocus();
|
||||
_ui->passwordLineEdit->setSelection(0, _ui->emailLineEdit->maxLength());
|
||||
};
|
||||
|
||||
void LoginDialog::handleLoginClicked() {
|
||||
// If the email or password inputs are empty, move focus to them, otherwise attempt to login.
|
||||
if (_ui->emailLineEdit->text().isEmpty()) {
|
||||
_ui->emailLineEdit->setFocus();
|
||||
} else if (_ui->passwordLineEdit->text().isEmpty()) {
|
||||
_ui->passwordLineEdit->setFocus();
|
||||
} else {
|
||||
_ui->infoLabel->setVisible(true);
|
||||
_ui->errorLabel->setVisible(false);
|
||||
|
||||
_ui->loginArea->setDisabled(true);
|
||||
AccountManager::getInstance().requestAccessToken(_ui->emailLineEdit->text(), _ui->passwordLineEdit->text());
|
||||
}
|
||||
};
|
||||
|
||||
void LoginDialog::moveEvent(QMoveEvent* event) {
|
||||
// Modal dialogs seemed to get repositioned automatically. Combat this by moving the window if needed.
|
||||
resizeAndPosition();
|
||||
};
|
42
interface/src/ui/LoginDialog.h
Normal file
42
interface/src/ui/LoginDialog.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
//
|
||||
// LoginDialog.h
|
||||
// interface/src/ui
|
||||
//
|
||||
// Created by Ryan Huffman on 4/23/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_LoginDialog_h
|
||||
#define hifi_LoginDialog_h
|
||||
|
||||
#include <QObject>
|
||||
#include "FramelessDialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class LoginDialog;
|
||||
}
|
||||
|
||||
class LoginDialog : public FramelessDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LoginDialog(QWidget* parent);
|
||||
~LoginDialog();
|
||||
|
||||
public slots:
|
||||
void handleLoginClicked();
|
||||
void handleLoginCompleted(const QUrl& authURL);
|
||||
void handleLoginFailed();
|
||||
|
||||
protected:
|
||||
void moveEvent(QMoveEvent* event);
|
||||
|
||||
private:
|
||||
Ui::LoginDialog* _ui;
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_LoginDialog_h
|
491
interface/ui/loginDialog.ui
Normal file
491
interface/ui/loginDialog.ui
Normal file
|
@ -0,0 +1,491 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LoginDialog</class>
|
||||
<widget class="QDialog" name="LoginDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1003</width>
|
||||
<height>130</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>130</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font-family: Helvetica, Arial, sans-serif;</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="statusArea" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="errorMessages" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>825</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="infoLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Helvetica,Arial,sans-serif</family>
|
||||
<pointsize>17</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Authenticating...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Helvetica,Arial,sans-serif</family>
|
||||
<pointsize>17</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: #992800;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><style type="text/css">
|
||||
a { text-decoration: none; color: #267077;}
|
||||
</style>
|
||||
Invalid username or password. <a href="https://data-web.highfidelity.io/password/new">Recover?</a></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>SplitHCursor</cursorShape>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>../resources/images/close.svg</normaloff>../resources/images/close.svg</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="loginAreaContainer" native="true">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>102</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="spacerLeft">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="logoArea" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="logoLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>../resources/images/hifi-logo.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="loginArea" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>931</width>
|
||||
<height>60</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit {
|
||||
padding: 10px;
|
||||
border-width: 1px; border-style: solid; border-radius: 3px; border-color: #aaa;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="emailLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>54</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Helvetica,Arial,sans-serif</family>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">padding-top: 14px;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Username or Email</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="passwordLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>54</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Helvetica,Arial,sans-serif</family>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">padding-top: 14px;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="loginButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>141</width>
|
||||
<height>54</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Helvetica,Arial,sans-serif</family>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">
|
||||
background: #0e7077;
|
||||
color: #e7eeee;
|
||||
border-radius: 4px; padding-top: 1px;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> Login</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>../resources/images/login.svg</normaloff>../resources/images/login.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Helvetica,Arial,sans-serif</family>
|
||||
<pointsize>17</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><style type="text/css">
|
||||
a { text-decoration: none; color: #267077;}
|
||||
</style>
|
||||
<a href="https://data-web.highfidelity.io/password/new">Recover password?</a></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacerRight">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -50,6 +50,10 @@ typedef unsigned long long quint64;
|
|||
#include "HeadData.h"
|
||||
#include "HandData.h"
|
||||
|
||||
// avatar motion behaviors
|
||||
const quint32 AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY = 1U << 0;
|
||||
const quint32 AVATAR_MOTION_OBEY_LOCAL_GRAVITY = 1U << 1;
|
||||
|
||||
// First bitset
|
||||
const int KEY_STATE_START_BIT = 0; // 1st and 2nd bits
|
||||
const int HAND_STATE_START_BIT = 2; // 3rd and 4th bits
|
||||
|
|
|
@ -282,10 +282,13 @@ void AccountManager::requestAccessToken(const QString& login, const QString& pas
|
|||
QUrl grantURL = _authURL;
|
||||
grantURL.setPath("/oauth/token");
|
||||
|
||||
const QString ACCOUNT_MANAGER_REQUESTED_SCOPE = "owner";
|
||||
|
||||
QByteArray postData;
|
||||
postData.append("grant_type=password&");
|
||||
postData.append("username=" + login + "&");
|
||||
postData.append("password=" + password);
|
||||
postData.append("password=" + password + "&");
|
||||
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE);
|
||||
|
||||
request.setUrl(grantURL);
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
|
@ -334,6 +337,7 @@ void AccountManager::requestFinished() {
|
|||
} else {
|
||||
// TODO: error handling
|
||||
qDebug() << "Error in response for password grant -" << rootObject["error_description"].toString();
|
||||
emit loginFailed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ signals:
|
|||
void usernameChanged(const QString& username);
|
||||
void accessTokenChanged();
|
||||
void loginComplete(const QUrl& authURL);
|
||||
void loginFailed();
|
||||
void logoutComplete();
|
||||
private slots:
|
||||
void processReply();
|
||||
|
|
|
@ -62,6 +62,8 @@ PacketVersion versionForPacketType(PacketType type) {
|
|||
case PacketTypeVoxelSet:
|
||||
case PacketTypeVoxelSetDestructive:
|
||||
return 1;
|
||||
case PacketTypeOctreeStats:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -542,6 +542,19 @@ OctreeElement* Octree::getOctreeElementAt(float x, float y, float z, float s) co
|
|||
return node;
|
||||
}
|
||||
|
||||
OctreeElement* Octree::getOctreeEnclosingElementAt(float x, float y, float z, float s) const {
|
||||
unsigned char* octalCode = pointToOctalCode(x,y,z,s);
|
||||
OctreeElement* node = nodeForOctalCode(_rootNode, octalCode, NULL);
|
||||
|
||||
delete[] octalCode; // cleanup memory
|
||||
#ifdef HAS_AUDIT_CHILDREN
|
||||
if (node) {
|
||||
node->auditChildren("Octree::getOctreeElementAt()");
|
||||
}
|
||||
#endif // def HAS_AUDIT_CHILDREN
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
OctreeElement* Octree::getOrCreateChildElementAt(float x, float y, float z, float s) {
|
||||
return getRoot()->getOrCreateChildElementAt(x, y, z, s);
|
||||
|
@ -581,8 +594,9 @@ bool findRayIntersectionOp(OctreeElement* node, void* extraData) {
|
|||
}
|
||||
|
||||
bool Octree::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
OctreeElement*& node, float& distance, BoxFace& face, Octree::lockType lockType) {
|
||||
RayArgs args = { origin / (float)(TREE_SCALE), direction, node, distance, face };
|
||||
OctreeElement*& node, float& distance, BoxFace& face,
|
||||
Octree::lockType lockType, bool* accurateResult) {
|
||||
RayArgs args = { origin / (float)(TREE_SCALE), direction, node, distance, face, false};
|
||||
|
||||
bool gotLock = false;
|
||||
if (lockType == Octree::Lock) {
|
||||
|
@ -591,6 +605,9 @@ bool Octree::findRayIntersection(const glm::vec3& origin, const glm::vec3& direc
|
|||
} else if (lockType == Octree::TryLock) {
|
||||
gotLock = tryLockForRead();
|
||||
if (!gotLock) {
|
||||
if (accurateResult) {
|
||||
*accurateResult = false; // if user asked to accuracy or result, let them know this is inaccurate
|
||||
}
|
||||
return args.found; // if we wanted to tryLock, and we couldn't then just bail...
|
||||
}
|
||||
}
|
||||
|
@ -601,6 +618,9 @@ bool Octree::findRayIntersection(const glm::vec3& origin, const glm::vec3& direc
|
|||
unlock();
|
||||
}
|
||||
|
||||
if (accurateResult) {
|
||||
*accurateResult = true; // if user asked to accuracy or result, let them know this is accurate
|
||||
}
|
||||
return args.found;
|
||||
}
|
||||
|
||||
|
@ -627,7 +647,8 @@ bool findSpherePenetrationOp(OctreeElement* element, void* extraData) {
|
|||
if (element->hasContent()) {
|
||||
glm::vec3 elementPenetration;
|
||||
if (element->findSpherePenetration(args->center, args->radius, elementPenetration, &args->penetratedObject)) {
|
||||
// NOTE: it is possible for this penetration accumulation algorithm to produce a final penetration vector with zero length.
|
||||
// NOTE: it is possible for this penetration accumulation algorithm to produce a
|
||||
// final penetration vector with zero length.
|
||||
args->penetration = addPenetrations(args->penetration, elementPenetration * (float)(TREE_SCALE));
|
||||
args->found = true;
|
||||
}
|
||||
|
@ -636,7 +657,7 @@ bool findSpherePenetrationOp(OctreeElement* element, void* extraData) {
|
|||
}
|
||||
|
||||
bool Octree::findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration,
|
||||
void** penetratedObject, Octree::lockType lockType) {
|
||||
void** penetratedObject, Octree::lockType lockType, bool* accurateResult) {
|
||||
|
||||
SphereArgs args = {
|
||||
center / (float)(TREE_SCALE),
|
||||
|
@ -653,6 +674,9 @@ bool Octree::findSpherePenetration(const glm::vec3& center, float radius, glm::v
|
|||
} else if (lockType == Octree::TryLock) {
|
||||
gotLock = tryLockForRead();
|
||||
if (!gotLock) {
|
||||
if (accurateResult) {
|
||||
*accurateResult = false; // if user asked to accuracy or result, let them know this is inaccurate
|
||||
}
|
||||
return args.found; // if we wanted to tryLock, and we couldn't then just bail...
|
||||
}
|
||||
}
|
||||
|
@ -666,6 +690,9 @@ bool Octree::findSpherePenetration(const glm::vec3& center, float radius, glm::v
|
|||
unlock();
|
||||
}
|
||||
|
||||
if (accurateResult) {
|
||||
*accurateResult = true; // if user asked to accuracy or result, let them know this is accurate
|
||||
}
|
||||
return args.found;
|
||||
}
|
||||
|
||||
|
@ -728,7 +755,7 @@ bool findShapeCollisionsOp(OctreeElement* node, void* extraData) {
|
|||
}
|
||||
|
||||
bool Octree::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius,
|
||||
glm::vec3& penetration, Octree::lockType lockType) {
|
||||
glm::vec3& penetration, Octree::lockType lockType, bool* accurateResult) {
|
||||
|
||||
CapsuleArgs args = {
|
||||
start / (float)(TREE_SCALE),
|
||||
|
@ -745,6 +772,9 @@ bool Octree::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end
|
|||
} else if (lockType == Octree::TryLock) {
|
||||
gotLock = tryLockForRead();
|
||||
if (!gotLock) {
|
||||
if (accurateResult) {
|
||||
*accurateResult = false; // if user asked to accuracy or result, let them know this is inaccurate
|
||||
}
|
||||
return args.found; // if we wanted to tryLock, and we couldn't then just bail...
|
||||
}
|
||||
}
|
||||
|
@ -754,10 +784,15 @@ bool Octree::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end
|
|||
if (gotLock) {
|
||||
unlock();
|
||||
}
|
||||
|
||||
if (accurateResult) {
|
||||
*accurateResult = true; // if user asked to accuracy or result, let them know this is accurate
|
||||
}
|
||||
return args.found;
|
||||
}
|
||||
|
||||
bool Octree::findShapeCollisions(const Shape* shape, CollisionList& collisions, Octree::lockType lockType) {
|
||||
bool Octree::findShapeCollisions(const Shape* shape, CollisionList& collisions,
|
||||
Octree::lockType lockType, bool* accurateResult) {
|
||||
|
||||
ShapeArgs args = { shape, collisions, false };
|
||||
|
||||
|
@ -768,6 +803,9 @@ bool Octree::findShapeCollisions(const Shape* shape, CollisionList& collisions,
|
|||
} else if (lockType == Octree::TryLock) {
|
||||
gotLock = tryLockForRead();
|
||||
if (!gotLock) {
|
||||
if (accurateResult) {
|
||||
*accurateResult = false; // if user asked to accuracy or result, let them know this is inaccurate
|
||||
}
|
||||
return args.found; // if we wanted to tryLock, and we couldn't then just bail...
|
||||
}
|
||||
}
|
||||
|
@ -777,6 +815,10 @@ bool Octree::findShapeCollisions(const Shape* shape, CollisionList& collisions,
|
|||
if (gotLock) {
|
||||
unlock();
|
||||
}
|
||||
|
||||
if (accurateResult) {
|
||||
*accurateResult = true; // if user asked to accuracy or result, let them know this is accurate
|
||||
}
|
||||
return args.found;
|
||||
}
|
||||
|
||||
|
@ -803,7 +845,7 @@ bool getElementEnclosingOperation(OctreeElement* element, void* extraData) {
|
|||
return true; // keep looking
|
||||
}
|
||||
|
||||
OctreeElement* Octree::getElementEnclosingPoint(const glm::vec3& point, Octree::lockType lockType) {
|
||||
OctreeElement* Octree::getElementEnclosingPoint(const glm::vec3& point, Octree::lockType lockType, bool* accurateResult) {
|
||||
GetElementEnclosingArgs args;
|
||||
args.point = point;
|
||||
args.element = NULL;
|
||||
|
@ -815,6 +857,9 @@ OctreeElement* Octree::getElementEnclosingPoint(const glm::vec3& point, Octree::
|
|||
} else if (lockType == Octree::TryLock) {
|
||||
gotLock = tryLockForRead();
|
||||
if (!gotLock) {
|
||||
if (accurateResult) {
|
||||
*accurateResult = false; // if user asked to accuracy or result, let them know this is inaccurate
|
||||
}
|
||||
return args.element; // if we wanted to tryLock, and we couldn't then just bail...
|
||||
}
|
||||
}
|
||||
|
@ -825,6 +870,9 @@ OctreeElement* Octree::getElementEnclosingPoint(const glm::vec3& point, Octree::
|
|||
unlock();
|
||||
}
|
||||
|
||||
if (accurateResult) {
|
||||
*accurateResult = false; // if user asked to accuracy or result, let them know this is inaccurate
|
||||
}
|
||||
return args.element;
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,15 @@ public:
|
|||
void reaverageOctreeElements(OctreeElement* startNode = NULL);
|
||||
|
||||
void deleteOctreeElementAt(float x, float y, float z, float s);
|
||||
|
||||
/// Find the voxel at position x,y,z,s
|
||||
/// \return pointer to the OctreeElement or NULL if none at x,y,z,s.
|
||||
OctreeElement* getOctreeElementAt(float x, float y, float z, float s) const;
|
||||
|
||||
/// Find the voxel at position x,y,z,s
|
||||
/// \return pointer to the OctreeElement or to the smallest enclosing parent if none at x,y,z,s.
|
||||
OctreeElement* getOctreeEnclosingElementAt(float x, float y, float z, float s) const;
|
||||
|
||||
OctreeElement* getOrCreateChildElementAt(float x, float y, float z, float s);
|
||||
|
||||
void recurseTreeWithOperation(RecurseOctreeOperation operation, void* extraData = NULL);
|
||||
|
@ -241,17 +249,20 @@ public:
|
|||
} lockType;
|
||||
|
||||
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
OctreeElement*& node, float& distance, BoxFace& face, Octree::lockType lockType = Octree::TryLock);
|
||||
OctreeElement*& node, float& distance, BoxFace& face,
|
||||
Octree::lockType lockType = Octree::TryLock, bool* accurateResult = NULL);
|
||||
|
||||
bool findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration,
|
||||
void** penetratedObject = NULL, Octree::lockType lockType = Octree::TryLock);
|
||||
bool findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration, void** penetratedObject = NULL,
|
||||
Octree::lockType lockType = Octree::TryLock, bool* accurateResult = NULL);
|
||||
|
||||
bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius,
|
||||
glm::vec3& penetration, Octree::lockType lockType = Octree::TryLock);
|
||||
bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration,
|
||||
Octree::lockType lockType = Octree::TryLock, bool* accurateResult = NULL);
|
||||
|
||||
bool findShapeCollisions(const Shape* shape, CollisionList& collisions, Octree::lockType = Octree::TryLock);
|
||||
bool findShapeCollisions(const Shape* shape, CollisionList& collisions,
|
||||
Octree::lockType = Octree::TryLock, bool* accurateResult = NULL);
|
||||
|
||||
OctreeElement* getElementEnclosingPoint(const glm::vec3& point, Octree::lockType lockType = Octree::TryLock);
|
||||
OctreeElement* getElementEnclosingPoint(const glm::vec3& point,
|
||||
Octree::lockType lockType = Octree::TryLock, bool* accurateResult = NULL);
|
||||
|
||||
// Note: this assumes the fileFormat is the HIO individual voxels code files
|
||||
void loadOctreeFile(const char* fileName, bool wantColorRandomizer);
|
||||
|
|
|
@ -646,70 +646,70 @@ int OctreeSceneStats::unpackFromMessage(const unsigned char* sourceBuffer, int a
|
|||
|
||||
|
||||
void OctreeSceneStats::printDebugDetails() {
|
||||
qDebug("\n------------------------------");
|
||||
qDebug("OctreeSceneStats:");
|
||||
qDebug(" start : %llu", (long long unsigned int)_start);
|
||||
qDebug(" end : %llu", (long long unsigned int)_end);
|
||||
qDebug(" elapsed : %llu", (long long unsigned int)_elapsed);
|
||||
qDebug(" encoding : %llu", (long long unsigned int)_totalEncodeTime);
|
||||
qDebug() << "\n------------------------------";
|
||||
qDebug() << "OctreeSceneStats:";
|
||||
qDebug() << "start: " << _start;
|
||||
qDebug() << "end: " << _end;
|
||||
qDebug() << "elapsed: " << _elapsed;
|
||||
qDebug() << "encoding: " << _totalEncodeTime;
|
||||
qDebug();
|
||||
qDebug(" full scene: %s", debug::valueOf(_isFullScene));
|
||||
qDebug(" moving: %s", debug::valueOf(_isMoving));
|
||||
qDebug() << "full scene: " << debug::valueOf(_isFullScene);
|
||||
qDebug() << "moving: " << debug::valueOf(_isMoving);
|
||||
qDebug();
|
||||
qDebug(" packets: %d", _packets);
|
||||
qDebug(" bytes : %ld", _bytes);
|
||||
qDebug() << "packets: " << _packets;
|
||||
qDebug() << "bytes: " << _bytes;
|
||||
qDebug();
|
||||
qDebug(" total elements : %lu", _totalElements );
|
||||
qDebug(" internal : %lu", _totalInternal );
|
||||
qDebug(" leaves : %lu", _totalLeaves );
|
||||
qDebug(" traversed : %lu", _traversed );
|
||||
qDebug(" internal : %lu", _internal );
|
||||
qDebug(" leaves : %lu", _leaves );
|
||||
qDebug(" skipped distance : %lu", _skippedDistance );
|
||||
qDebug(" internal : %lu", _internalSkippedDistance );
|
||||
qDebug(" leaves : %lu", _leavesSkippedDistance );
|
||||
qDebug(" skipped out of view : %lu", _skippedOutOfView );
|
||||
qDebug(" internal : %lu", _internalSkippedOutOfView );
|
||||
qDebug(" leaves : %lu", _leavesSkippedOutOfView );
|
||||
qDebug(" skipped was in view : %lu", _skippedWasInView );
|
||||
qDebug(" internal : %lu", _internalSkippedWasInView );
|
||||
qDebug(" leaves : %lu", _leavesSkippedWasInView );
|
||||
qDebug(" skipped no change : %lu", _skippedNoChange );
|
||||
qDebug(" internal : %lu", _internalSkippedNoChange );
|
||||
qDebug(" leaves : %lu", _leavesSkippedNoChange );
|
||||
qDebug(" skipped occluded : %lu", _skippedOccluded );
|
||||
qDebug(" internal : %lu", _internalSkippedOccluded );
|
||||
qDebug(" leaves : %lu", _leavesSkippedOccluded );
|
||||
qDebug() << "total elements: " << _totalElements;
|
||||
qDebug() << "internal: " << _totalInternal;
|
||||
qDebug() << "leaves: " << _totalLeaves;
|
||||
qDebug() << "traversed: " << _traversed;
|
||||
qDebug() << "internal: " << _internal;
|
||||
qDebug() << "leaves: " << _leaves;
|
||||
qDebug() << "skipped distance: " << _skippedDistance;
|
||||
qDebug() << "internal: " << _internalSkippedDistance;
|
||||
qDebug() << "leaves: " << _leavesSkippedDistance;
|
||||
qDebug() << "skipped out of view: " << _skippedOutOfView;
|
||||
qDebug() << "internal: " << _internalSkippedOutOfView;
|
||||
qDebug() << "leaves: " << _leavesSkippedOutOfView;
|
||||
qDebug() << "skipped was in view: " << _skippedWasInView;
|
||||
qDebug() << "internal: " << _internalSkippedWasInView;
|
||||
qDebug() << "leaves: " << _leavesSkippedWasInView;
|
||||
qDebug() << "skipped no change: " << _skippedNoChange;
|
||||
qDebug() << "internal: " << _internalSkippedNoChange;
|
||||
qDebug() << "leaves: " << _leavesSkippedNoChange;
|
||||
qDebug() << "skipped occluded: " << _skippedOccluded;
|
||||
qDebug() << "internal: " << _internalSkippedOccluded;
|
||||
qDebug() << "leaves: " << _leavesSkippedOccluded;
|
||||
qDebug();
|
||||
qDebug(" color sent : %lu", _colorSent );
|
||||
qDebug(" internal : %lu", _internalColorSent );
|
||||
qDebug(" leaves : %lu", _leavesColorSent );
|
||||
qDebug(" Didn't Fit : %lu", _didntFit );
|
||||
qDebug(" internal : %lu", _internalDidntFit );
|
||||
qDebug(" leaves : %lu", _leavesDidntFit );
|
||||
qDebug(" color bits : %lu", _colorBitsWritten );
|
||||
qDebug(" exists bits : %lu", _existsBitsWritten );
|
||||
qDebug(" in packet bit : %lu", _existsInPacketBitsWritten);
|
||||
qDebug(" trees removed : %lu", _treesRemoved );
|
||||
qDebug() << "color sent: " << _colorSent;
|
||||
qDebug() << "internal: " << _internalColorSent;
|
||||
qDebug() << "leaves: " << _leavesColorSent;
|
||||
qDebug() << "Didn't Fit: " << _didntFit;
|
||||
qDebug() << "internal: " << _internalDidntFit;
|
||||
qDebug() << "leaves: " << _leavesDidntFit;
|
||||
qDebug() << "color bits: " << _colorBitsWritten;
|
||||
qDebug() << "exists bits: " << _existsBitsWritten;
|
||||
qDebug() << "in packet bit: " << _existsInPacketBitsWritten;
|
||||
qDebug() << "trees removed: " << _treesRemoved;
|
||||
}
|
||||
|
||||
OctreeSceneStats::ItemInfo OctreeSceneStats::_ITEMS[] = {
|
||||
{ "Elapsed" , GREENISH , 2 , "Elapsed,fps" },
|
||||
{ "Encode" , YELLOWISH , 2 , "Time,fps" },
|
||||
{ "Network" , GREYISH , 3 , "Packets,Bytes,KBPS" },
|
||||
{ "Octrees on Server" , GREENISH , 3 , "Total,Internal,Leaves" },
|
||||
{ "Octrees Sent" , YELLOWISH , 5 , "Total,Bits/Octree,Avg Bits/Octree,Internal,Leaves" },
|
||||
{ "Colors Sent" , GREYISH , 3 , "Total,Internal,Leaves" },
|
||||
{ "Bitmasks Sent" , GREENISH , 3 , "Colors,Exists,In Packets" },
|
||||
{ "Traversed" , YELLOWISH , 3 , "Total,Internal,Leaves" },
|
||||
{ "Skipped - Total" , GREYISH , 3 , "Total,Internal,Leaves" },
|
||||
{ "Skipped - Distance" , GREENISH , 3 , "Total,Internal,Leaves" },
|
||||
{ "Skipped - Out of View", YELLOWISH , 3 , "Total,Internal,Leaves" },
|
||||
{ "Skipped - Was in View", GREYISH , 3 , "Total,Internal,Leaves" },
|
||||
{ "Skipped - No Change" , GREENISH , 3 , "Total,Internal,Leaves" },
|
||||
{ "Skipped - Occluded" , YELLOWISH , 3 , "Total,Internal,Leaves" },
|
||||
{ "Didn't fit in packet" , GREYISH , 4 , "Total,Internal,Leaves,Removed" },
|
||||
{ "Mode" , GREENISH , 4 , "Moving,Stationary,Partial,Full" },
|
||||
{ "Elapsed", GREENISH, 2, "Elapsed,fps" },
|
||||
{ "Encode", YELLOWISH, 2, "Time,fps" },
|
||||
{ "Network", GREYISH, 3, "Packets,Bytes,KBPS" },
|
||||
{ "Octrees on Server", GREENISH, 3, "Total,Internal,Leaves" },
|
||||
{ "Octrees Sent", YELLOWISH, 5, "Total,Bits/Octree,Avg Bits/Octree,Internal,Leaves" },
|
||||
{ "Colors Sent", GREYISH, 3, "Total,Internal,Leaves" },
|
||||
{ "Bitmasks Sent", GREENISH, 3, "Colors,Exists,In Packets" },
|
||||
{ "Traversed", YELLOWISH, 3, "Total,Internal,Leaves" },
|
||||
{ "Skipped - Total", GREYISH, 3, "Total,Internal,Leaves" },
|
||||
{ "Skipped - Distance", GREENISH, 3, "Total,Internal,Leaves" },
|
||||
{ "Skipped - Out of View", YELLOWISH, 3, "Total,Internal,Leaves" },
|
||||
{ "Skipped - Was in View", GREYISH, 3, "Total,Internal,Leaves" },
|
||||
{ "Skipped - No Change", GREENISH, 3, "Total,Internal,Leaves" },
|
||||
{ "Skipped - Occluded", YELLOWISH, 3, "Total,Internal,Leaves" },
|
||||
{ "Didn't fit in packet", GREYISH, 4, "Total,Internal,Leaves,Removed" },
|
||||
{ "Mode", GREENISH, 4, "Moving,Stationary,Partial,Full" },
|
||||
};
|
||||
|
||||
const char* OctreeSceneStats::getItemValue(Item item) {
|
||||
|
@ -732,12 +732,14 @@ const char* OctreeSceneStats::getItemValue(Item item) {
|
|||
case ITEM_PACKETS: {
|
||||
float elapsedSecs = ((float)_elapsed / (float)USECS_PER_SECOND);
|
||||
calculatedKBPS = elapsedSecs == 0 ? 0 : ((_bytes * 8) / elapsedSecs) / 1000;
|
||||
sprintf(_itemValueBuffer, "%d packets %lu bytes (%d kbps)", _packets, _bytes, calculatedKBPS);
|
||||
sprintf(_itemValueBuffer, "%d packets %lu bytes (%d kbps)", _packets, (long unsigned int)_bytes, calculatedKBPS);
|
||||
break;
|
||||
}
|
||||
case ITEM_VOXELS_SERVER: {
|
||||
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
|
||||
_totalElements, _totalInternal, _totalLeaves);
|
||||
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
|
||||
(long unsigned int)_totalElements,
|
||||
(long unsigned int)_totalInternal,
|
||||
(long unsigned int)_totalLeaves);
|
||||
break;
|
||||
}
|
||||
case ITEM_VOXELS: {
|
||||
|
@ -745,12 +747,14 @@ const char* OctreeSceneStats::getItemValue(Item item) {
|
|||
float calculatedBPV = total == 0 ? 0 : (_bytes * 8) / total;
|
||||
float averageBPV = _bitsPerOctreeAverage.getAverage();
|
||||
sprintf(_itemValueBuffer, "%lu (%.2f bits/octree Average: %.2f bits/octree) %lu internal %lu leaves",
|
||||
total, calculatedBPV, averageBPV, _existsInPacketBitsWritten, _colorSent);
|
||||
total, calculatedBPV, averageBPV,
|
||||
(long unsigned int)_existsInPacketBitsWritten,
|
||||
(long unsigned int)_colorSent);
|
||||
break;
|
||||
}
|
||||
case ITEM_TRAVERSED: {
|
||||
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
|
||||
_traversed, _internal, _leaves);
|
||||
(long unsigned int)_traversed, (long unsigned int)_internal, (long unsigned int)_leaves);
|
||||
break;
|
||||
}
|
||||
case ITEM_SKIPPED: {
|
||||
|
@ -769,42 +773,59 @@ const char* OctreeSceneStats::getItemValue(Item item) {
|
|||
}
|
||||
case ITEM_SKIPPED_DISTANCE: {
|
||||
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
|
||||
_skippedDistance, _internalSkippedDistance, _leavesSkippedDistance);
|
||||
(long unsigned int)_skippedDistance,
|
||||
(long unsigned int)_internalSkippedDistance,
|
||||
(long unsigned int)_leavesSkippedDistance);
|
||||
break;
|
||||
}
|
||||
case ITEM_SKIPPED_OUT_OF_VIEW: {
|
||||
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
|
||||
_skippedOutOfView, _internalSkippedOutOfView, _leavesSkippedOutOfView);
|
||||
(long unsigned int)_skippedOutOfView,
|
||||
(long unsigned int)_internalSkippedOutOfView,
|
||||
(long unsigned int)_leavesSkippedOutOfView);
|
||||
break;
|
||||
}
|
||||
case ITEM_SKIPPED_WAS_IN_VIEW: {
|
||||
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
|
||||
_skippedWasInView, _internalSkippedWasInView, _leavesSkippedWasInView);
|
||||
(long unsigned int)_skippedWasInView,
|
||||
(long unsigned int)_internalSkippedWasInView,
|
||||
(long unsigned int)_leavesSkippedWasInView);
|
||||
break;
|
||||
}
|
||||
case ITEM_SKIPPED_NO_CHANGE: {
|
||||
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
|
||||
_skippedNoChange, _internalSkippedNoChange, _leavesSkippedNoChange);
|
||||
(long unsigned int)_skippedNoChange,
|
||||
(long unsigned int)_internalSkippedNoChange,
|
||||
(long unsigned int)_leavesSkippedNoChange);
|
||||
break;
|
||||
}
|
||||
case ITEM_SKIPPED_OCCLUDED: {
|
||||
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
|
||||
_skippedOccluded, _internalSkippedOccluded, _leavesSkippedOccluded);
|
||||
(long unsigned int)_skippedOccluded,
|
||||
(long unsigned int)_internalSkippedOccluded,
|
||||
(long unsigned int)_leavesSkippedOccluded);
|
||||
break;
|
||||
}
|
||||
case ITEM_COLORS: {
|
||||
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
|
||||
_colorSent, _internalColorSent, _leavesColorSent);
|
||||
(long unsigned int)_colorSent,
|
||||
(long unsigned int)_internalColorSent,
|
||||
(long unsigned int)_leavesColorSent);
|
||||
break;
|
||||
}
|
||||
case ITEM_DIDNT_FIT: {
|
||||
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves (removed: %lu)",
|
||||
_didntFit, _internalDidntFit, _leavesDidntFit, _treesRemoved);
|
||||
(long unsigned int)_didntFit,
|
||||
(long unsigned int)_internalDidntFit,
|
||||
(long unsigned int)_leavesDidntFit,
|
||||
(long unsigned int)_treesRemoved);
|
||||
break;
|
||||
}
|
||||
case ITEM_BITS: {
|
||||
sprintf(_itemValueBuffer, "colors: %lu, exists: %lu, in packets: %lu",
|
||||
_colorBitsWritten, _existsBitsWritten, _existsInPacketBitsWritten);
|
||||
(long unsigned int)_colorBitsWritten,
|
||||
(long unsigned int)_existsBitsWritten,
|
||||
(long unsigned int)_existsInPacketBitsWritten);
|
||||
break;
|
||||
}
|
||||
case ITEM_MODE: {
|
||||
|
@ -820,11 +841,7 @@ const char* OctreeSceneStats::getItemValue(Item item) {
|
|||
|
||||
void OctreeSceneStats::trackIncomingOctreePacket(const QByteArray& packet,
|
||||
bool wasStatsPacket, int nodeClockSkewUsec) {
|
||||
_incomingPacket++;
|
||||
_incomingBytes += packet.size();
|
||||
if (!wasStatsPacket) {
|
||||
_incomingWastedBytes += (MAX_PACKET_SIZE - packet.size());
|
||||
}
|
||||
const bool wantExtraDebugging = false;
|
||||
|
||||
int numBytesPacketHeader = numBytesForPacketHeader(packet);
|
||||
const unsigned char* dataAt = reinterpret_cast<const unsigned char*>(packet.data()) + numBytesPacketHeader;
|
||||
|
@ -842,12 +859,43 @@ void OctreeSceneStats::trackIncomingOctreePacket(const QByteArray& packet,
|
|||
|
||||
OCTREE_PACKET_SENT_TIME arrivedAt = usecTimestampNow();
|
||||
int flightTime = arrivedAt - sentAt + nodeClockSkewUsec;
|
||||
|
||||
if (wantExtraDebugging) {
|
||||
qDebug() << "sentAt:" << sentAt << " usecs";
|
||||
qDebug() << "arrivedAt:" << arrivedAt << " usecs";
|
||||
qDebug() << "nodeClockSkewUsec:" << nodeClockSkewUsec << " usecs";
|
||||
qDebug() << "flightTime:" << flightTime << " usecs";
|
||||
}
|
||||
|
||||
// Guard against possible corrupted packets... with bad timestamps
|
||||
const int MAX_RESONABLE_FLIGHT_TIME = 200 * USECS_PER_SECOND; // 200 seconds is more than enough time for a packet to arrive
|
||||
const int MIN_RESONABLE_FLIGHT_TIME = 0;
|
||||
if (flightTime > MAX_RESONABLE_FLIGHT_TIME || flightTime < MIN_RESONABLE_FLIGHT_TIME) {
|
||||
qDebug() << "ignoring unreasonable packet... flightTime:" << flightTime;
|
||||
return; // ignore any packets that are unreasonable
|
||||
}
|
||||
|
||||
// Guard against possible corrupted packets... with bad sequence numbers
|
||||
const int MAX_RESONABLE_SEQUENCE_OFFSET = 2000;
|
||||
const int MIN_RESONABLE_SEQUENCE_OFFSET = -2000;
|
||||
int sequenceOffset = (sequence - _incomingLastSequence);
|
||||
if (sequenceOffset > MAX_RESONABLE_SEQUENCE_OFFSET || sequenceOffset < MIN_RESONABLE_SEQUENCE_OFFSET) {
|
||||
qDebug() << "ignoring unreasonable packet... sequence:" << sequence << "_incomingLastSequence:" << _incomingLastSequence;
|
||||
return; // ignore any packets that are unreasonable
|
||||
}
|
||||
|
||||
// track packets here...
|
||||
_incomingPacket++;
|
||||
_incomingBytes += packet.size();
|
||||
if (!wasStatsPacket) {
|
||||
_incomingWastedBytes += (MAX_PACKET_SIZE - packet.size());
|
||||
}
|
||||
|
||||
const int USECS_PER_MSEC = 1000;
|
||||
float flightTimeMsecs = flightTime / USECS_PER_MSEC;
|
||||
_incomingFlightTimeAverage.updateAverage(flightTimeMsecs);
|
||||
|
||||
// track out of order and possibly lost packets...
|
||||
const bool wantExtraDebugging = false;
|
||||
if (sequence == _incomingLastSequence) {
|
||||
if (wantExtraDebugging) {
|
||||
qDebug() << "last packet duplicate got:" << sequence << "_incomingLastSequence:" << _incomingLastSequence;
|
||||
|
|
|
@ -146,30 +146,30 @@ public:
|
|||
const std::vector<unsigned char*>& getJurisdictionEndNodes() const { return _jurisdictionEndNodes; }
|
||||
|
||||
bool isMoving() const { return _isMoving; };
|
||||
unsigned long getTotalElements() const { return _totalElements; }
|
||||
unsigned long getTotalInternal() const { return _totalInternal; }
|
||||
unsigned long getTotalLeaves() const { return _totalLeaves; }
|
||||
unsigned long getTotalEncodeTime() const { return _totalEncodeTime; }
|
||||
unsigned long getElapsedTime() const { return _elapsed; }
|
||||
quint64 getTotalElements() const { return _totalElements; }
|
||||
quint64 getTotalInternal() const { return _totalInternal; }
|
||||
quint64 getTotalLeaves() const { return _totalLeaves; }
|
||||
quint64 getTotalEncodeTime() const { return _totalEncodeTime; }
|
||||
quint64 getElapsedTime() const { return _elapsed; }
|
||||
|
||||
unsigned long getLastFullElapsedTime() const { return _lastFullElapsed; }
|
||||
unsigned long getLastFullTotalEncodeTime() const { return _lastFullTotalEncodeTime; }
|
||||
unsigned int getLastFullTotalPackets() const { return _lastFullTotalPackets; }
|
||||
unsigned long getLastFullTotalBytes() const { return _lastFullTotalBytes; }
|
||||
quint64 getLastFullElapsedTime() const { return _lastFullElapsed; }
|
||||
quint64 getLastFullTotalEncodeTime() const { return _lastFullTotalEncodeTime; }
|
||||
quint32 getLastFullTotalPackets() const { return _lastFullTotalPackets; }
|
||||
quint64 getLastFullTotalBytes() const { return _lastFullTotalBytes; }
|
||||
|
||||
// Used in client implementations to track individual octree packets
|
||||
void trackIncomingOctreePacket(const QByteArray& packet, bool wasStatsPacket, int nodeClockSkewUsec);
|
||||
|
||||
unsigned int getIncomingPackets() const { return _incomingPacket; }
|
||||
unsigned long getIncomingBytes() const { return _incomingBytes; }
|
||||
unsigned long getIncomingWastedBytes() const { return _incomingWastedBytes; }
|
||||
unsigned int getIncomingOutOfOrder() const { return _incomingLate + _incomingEarly; }
|
||||
unsigned int getIncomingLikelyLost() const { return _incomingLikelyLost; }
|
||||
unsigned int getIncomingRecovered() const { return _incomingRecovered; }
|
||||
unsigned int getIncomingEarly() const { return _incomingEarly; }
|
||||
unsigned int getIncomingLate() const { return _incomingLate; }
|
||||
unsigned int getIncomingReallyLate() const { return _incomingReallyLate; }
|
||||
unsigned int getIncomingPossibleDuplicate() const { return _incomingPossibleDuplicate; }
|
||||
quint32 getIncomingPackets() const { return _incomingPacket; }
|
||||
quint64 getIncomingBytes() const { return _incomingBytes; }
|
||||
quint64 getIncomingWastedBytes() const { return _incomingWastedBytes; }
|
||||
quint32 getIncomingOutOfOrder() const { return _incomingLate + _incomingEarly; }
|
||||
quint32 getIncomingLikelyLost() const { return _incomingLikelyLost; }
|
||||
quint32 getIncomingRecovered() const { return _incomingRecovered; }
|
||||
quint32 getIncomingEarly() const { return _incomingEarly; }
|
||||
quint32 getIncomingLate() const { return _incomingLate; }
|
||||
quint32 getIncomingReallyLate() const { return _incomingReallyLate; }
|
||||
quint32 getIncomingPossibleDuplicate() const { return _incomingPossibleDuplicate; }
|
||||
float getIncomingFlightTimeAverage() { return _incomingFlightTimeAverage.getAverage(); }
|
||||
|
||||
private:
|
||||
|
@ -178,7 +178,8 @@ private:
|
|||
|
||||
bool _isReadyToSend;
|
||||
unsigned char _statsMessage[MAX_PACKET_SIZE];
|
||||
int _statsMessageLength;
|
||||
|
||||
qint32 _statsMessageLength;
|
||||
|
||||
// scene timing data in usecs
|
||||
bool _isStarted;
|
||||
|
@ -188,8 +189,8 @@ private:
|
|||
|
||||
quint64 _lastFullElapsed;
|
||||
quint64 _lastFullTotalEncodeTime;
|
||||
unsigned int _lastFullTotalPackets;
|
||||
unsigned long _lastFullTotalBytes;
|
||||
quint32 _lastFullTotalPackets;
|
||||
quint64 _lastFullTotalBytes;
|
||||
|
||||
SimpleMovingAverage _elapsedAverage;
|
||||
SimpleMovingAverage _bitsPerOctreeAverage;
|
||||
|
@ -198,46 +199,46 @@ private:
|
|||
quint64 _encodeStart;
|
||||
|
||||
// scene octree related data
|
||||
unsigned long _totalElements;
|
||||
unsigned long _totalInternal;
|
||||
unsigned long _totalLeaves;
|
||||
quint64 _totalElements;
|
||||
quint64 _totalInternal;
|
||||
quint64 _totalLeaves;
|
||||
|
||||
unsigned long _traversed;
|
||||
unsigned long _internal;
|
||||
unsigned long _leaves;
|
||||
quint64 _traversed;
|
||||
quint64 _internal;
|
||||
quint64 _leaves;
|
||||
|
||||
unsigned long _skippedDistance;
|
||||
unsigned long _internalSkippedDistance;
|
||||
unsigned long _leavesSkippedDistance;
|
||||
quint64 _skippedDistance;
|
||||
quint64 _internalSkippedDistance;
|
||||
quint64 _leavesSkippedDistance;
|
||||
|
||||
unsigned long _skippedOutOfView;
|
||||
unsigned long _internalSkippedOutOfView;
|
||||
unsigned long _leavesSkippedOutOfView;
|
||||
quint64 _skippedOutOfView;
|
||||
quint64 _internalSkippedOutOfView;
|
||||
quint64 _leavesSkippedOutOfView;
|
||||
|
||||
unsigned long _skippedWasInView;
|
||||
unsigned long _internalSkippedWasInView;
|
||||
unsigned long _leavesSkippedWasInView;
|
||||
quint64 _skippedWasInView;
|
||||
quint64 _internalSkippedWasInView;
|
||||
quint64 _leavesSkippedWasInView;
|
||||
|
||||
unsigned long _skippedNoChange;
|
||||
unsigned long _internalSkippedNoChange;
|
||||
unsigned long _leavesSkippedNoChange;
|
||||
quint64 _skippedNoChange;
|
||||
quint64 _internalSkippedNoChange;
|
||||
quint64 _leavesSkippedNoChange;
|
||||
|
||||
unsigned long _skippedOccluded;
|
||||
unsigned long _internalSkippedOccluded;
|
||||
unsigned long _leavesSkippedOccluded;
|
||||
quint64 _skippedOccluded;
|
||||
quint64 _internalSkippedOccluded;
|
||||
quint64 _leavesSkippedOccluded;
|
||||
|
||||
unsigned long _colorSent;
|
||||
unsigned long _internalColorSent;
|
||||
unsigned long _leavesColorSent;
|
||||
quint64 _colorSent;
|
||||
quint64 _internalColorSent;
|
||||
quint64 _leavesColorSent;
|
||||
|
||||
unsigned long _didntFit;
|
||||
unsigned long _internalDidntFit;
|
||||
unsigned long _leavesDidntFit;
|
||||
quint64 _didntFit;
|
||||
quint64 _internalDidntFit;
|
||||
quint64 _leavesDidntFit;
|
||||
|
||||
unsigned long _colorBitsWritten;
|
||||
unsigned long _existsBitsWritten;
|
||||
unsigned long _existsInPacketBitsWritten;
|
||||
unsigned long _treesRemoved;
|
||||
quint64 _colorBitsWritten;
|
||||
quint64 _existsBitsWritten;
|
||||
quint64 _existsInPacketBitsWritten;
|
||||
quint64 _treesRemoved;
|
||||
|
||||
// Accounting Notes:
|
||||
//
|
||||
|
@ -255,22 +256,22 @@ private:
|
|||
//
|
||||
|
||||
// scene network related data
|
||||
unsigned int _packets;
|
||||
unsigned long _bytes;
|
||||
unsigned int _passes;
|
||||
quint32 _packets;
|
||||
quint64 _bytes;
|
||||
quint32 _passes;
|
||||
|
||||
// incoming packets stats
|
||||
unsigned int _incomingPacket;
|
||||
unsigned long _incomingBytes;
|
||||
unsigned long _incomingWastedBytes;
|
||||
quint32 _incomingPacket;
|
||||
quint64 _incomingBytes;
|
||||
quint64 _incomingWastedBytes;
|
||||
|
||||
uint16_t _incomingLastSequence; /// last incoming sequence number
|
||||
unsigned int _incomingLikelyLost; /// count of packets likely lost, may be off by _incomingReallyLate count
|
||||
unsigned int _incomingRecovered; /// packets that were late, and we had in our missing list, we consider recovered
|
||||
unsigned int _incomingEarly; /// out of order earlier than expected
|
||||
unsigned int _incomingLate; /// out of order later than expected
|
||||
unsigned int _incomingReallyLate; /// out of order and later than MAX_MISSING_SEQUENCE_OLD_AGE late
|
||||
unsigned int _incomingPossibleDuplicate; /// out of order possibly a duplicate
|
||||
quint16 _incomingLastSequence; /// last incoming sequence number
|
||||
quint32 _incomingLikelyLost; /// count of packets likely lost, may be off by _incomingReallyLate count
|
||||
quint32 _incomingRecovered; /// packets that were late, and we had in our missing list, we consider recovered
|
||||
quint32 _incomingEarly; /// out of order earlier than expected
|
||||
quint32 _incomingLate; /// out of order later than expected
|
||||
quint32 _incomingReallyLate; /// out of order and later than MAX_MISSING_SEQUENCE_OLD_AGE late
|
||||
quint32 _incomingPossibleDuplicate; /// out of order possibly a duplicate
|
||||
QSet<uint16_t> _missingSequenceNumbers;
|
||||
SimpleMovingAverage _incomingFlightTimeAverage;
|
||||
|
||||
|
@ -280,7 +281,7 @@ private:
|
|||
|
||||
|
||||
static ItemInfo _ITEMS[];
|
||||
static int const MAX_ITEM_VALUE_LENGTH = 128;
|
||||
static const int MAX_ITEM_VALUE_LENGTH = 128;
|
||||
char _itemValueBuffer[MAX_ITEM_VALUE_LENGTH];
|
||||
|
||||
unsigned char* _jurisdictionRoot;
|
||||
|
|
|
@ -119,10 +119,19 @@ void LocalVoxels::pasteFrom(float x, float y, float z, float scale, const QStrin
|
|||
}
|
||||
|
||||
RayToVoxelIntersectionResult LocalVoxels::findRayIntersection(const PickRay& ray) {
|
||||
return findRayIntersectionWorker(ray, Octree::TryLock);
|
||||
}
|
||||
|
||||
RayToVoxelIntersectionResult LocalVoxels::findRayIntersectionBlocking(const PickRay& ray) {
|
||||
return findRayIntersectionWorker(ray, Octree::Lock);
|
||||
}
|
||||
|
||||
RayToVoxelIntersectionResult LocalVoxels::findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType) {
|
||||
RayToVoxelIntersectionResult result;
|
||||
if (_tree) {
|
||||
OctreeElement* element;
|
||||
result.intersects = _tree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face);
|
||||
result.intersects = _tree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face,
|
||||
lockType, &result.accurate);
|
||||
if (result.intersects) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
result.voxel.x = voxel->getCorner().x;
|
||||
|
|
|
@ -76,13 +76,22 @@ public:
|
|||
/// \param source LocalVoxels' source tree
|
||||
Q_INVOKABLE void pasteFrom(float x, float y, float z, float scale, const QString source);
|
||||
|
||||
/// If the scripting context has visible voxels, this will determine a ray intersection
|
||||
/// If the scripting context has visible voxels, this will determine a ray intersection, the results
|
||||
/// may be inaccurate if the engine is unable to access the visible voxels, in which case result.accurate
|
||||
/// will be false.
|
||||
Q_INVOKABLE RayToVoxelIntersectionResult findRayIntersection(const PickRay& ray);
|
||||
|
||||
/// If the scripting context has visible voxels, this will determine a ray intersection, and will block in
|
||||
/// order to return an accurate result
|
||||
Q_INVOKABLE RayToVoxelIntersectionResult findRayIntersectionBlocking(const PickRay& ray);
|
||||
|
||||
/// returns a voxel space axis aligned vector for the face, useful in doing voxel math
|
||||
Q_INVOKABLE glm::vec3 getFaceVector(const QString& face);
|
||||
|
||||
private:
|
||||
/// actually does the work of finding the ray intersection, can be called in locking mode or tryLock mode
|
||||
RayToVoxelIntersectionResult findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType);
|
||||
|
||||
QString _name;
|
||||
StrongVoxelTreePointer _tree;
|
||||
};
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <AudioRingBuffer.h>
|
||||
#include <AvatarData.h>
|
||||
#include <CollisionInfo.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <UUID.h>
|
||||
|
@ -230,8 +231,16 @@ void ScriptEngine::init() {
|
|||
|
||||
registerGlobalObject("Voxels", &_voxelsScriptingInterface);
|
||||
|
||||
QScriptValue treeScaleValue = _engine.newVariant(QVariant(TREE_SCALE));
|
||||
_engine.globalObject().setProperty("TREE_SCALE", treeScaleValue);
|
||||
// constants
|
||||
QScriptValue globalObject = _engine.globalObject();
|
||||
globalObject.setProperty("TREE_SCALE", _engine.newVariant(QVariant(TREE_SCALE)));
|
||||
globalObject.setProperty("COLLISION_GROUP_ENVIRONMENT", _engine.newVariant(QVariant(COLLISION_GROUP_ENVIRONMENT)));
|
||||
globalObject.setProperty("COLLISION_GROUP_AVATARS", _engine.newVariant(QVariant(COLLISION_GROUP_AVATARS)));
|
||||
globalObject.setProperty("COLLISION_GROUP_VOXELS", _engine.newVariant(QVariant(COLLISION_GROUP_VOXELS)));
|
||||
globalObject.setProperty("COLLISION_GROUP_PARTICLES", _engine.newVariant(QVariant(COLLISION_GROUP_PARTICLES)));
|
||||
|
||||
globalObject.setProperty("AVATAR_MOTION_OBEY_LOCAL_GRAVITY", _engine.newVariant(QVariant(AVATAR_MOTION_OBEY_LOCAL_GRAVITY)));
|
||||
globalObject.setProperty("AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY", _engine.newVariant(QVariant(AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY)));
|
||||
|
||||
// let the VoxelPacketSender know how frequently we plan to call it
|
||||
_voxelsScriptingInterface.getVoxelPacketSender()->setProcessCallIntervalHint(SCRIPT_DATA_CALLBACK_USECS);
|
||||
|
|
|
@ -36,6 +36,10 @@ float Vec3::length(const glm::vec3& v) {
|
|||
return glm::length(v);
|
||||
}
|
||||
|
||||
float Vec3::distance(const glm::vec3& v1, const glm::vec3& v2) {
|
||||
return glm::distance(v1, v2);
|
||||
}
|
||||
|
||||
glm::vec3 Vec3::normalize(const glm::vec3& v) {
|
||||
return glm::normalize(v);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public slots:
|
|||
glm::vec3 sum(const glm::vec3& v1, const glm::vec3& v2);
|
||||
glm::vec3 subtract(const glm::vec3& v1, const glm::vec3& v2);
|
||||
float length(const glm::vec3& v);
|
||||
float distance(const glm::vec3& v1, const glm::vec3& v2);
|
||||
glm::vec3 normalize(const glm::vec3& v);
|
||||
void print(const QString& lable, const glm::vec3& v);
|
||||
};
|
||||
|
|
|
@ -27,6 +27,7 @@ const quint32 COLLISION_GROUP_ENVIRONMENT = 1U << 0;
|
|||
const quint32 COLLISION_GROUP_AVATARS = 1U << 1;
|
||||
const quint32 COLLISION_GROUP_VOXELS = 1U << 2;
|
||||
const quint32 COLLISION_GROUP_PARTICLES = 1U << 3;
|
||||
const quint32 VALID_COLLISION_GROUPS = 0x0f;
|
||||
|
||||
// CollisionInfo contains details about the collision between two things: BodyA and BodyB.
|
||||
// The assumption is that the context that analyzes the collision knows about BodyA but
|
||||
|
|
|
@ -30,27 +30,22 @@
|
|||
#include "OctalCode.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
|
||||
static qint64 TIME_REFERENCE = 0; // in usec
|
||||
static QElapsedTimer timestampTimer;
|
||||
static int usecTimestampNowAdjust = 0; // in usec
|
||||
|
||||
void initialiseUsecTimestampNow() {
|
||||
static bool initialised = false;
|
||||
if (initialised) {
|
||||
qDebug() << "[WARNING] Double initialisation of usecTimestampNow().";
|
||||
return;
|
||||
}
|
||||
|
||||
TIME_REFERENCE = QDateTime::currentMSecsSinceEpoch() * 1000; // ms to usec
|
||||
initialised = true;
|
||||
}
|
||||
|
||||
void usecTimestampNowForceClockSkew(int clockSkew) {
|
||||
::usecTimestampNowAdjust = clockSkew;
|
||||
}
|
||||
|
||||
quint64 usecTimestampNow() {
|
||||
static bool usecTimestampNowIsInitialized = false;
|
||||
static qint64 TIME_REFERENCE = 0; // in usec
|
||||
static QElapsedTimer timestampTimer;
|
||||
|
||||
if (!usecTimestampNowIsInitialized) {
|
||||
TIME_REFERENCE = QDateTime::currentMSecsSinceEpoch() * 1000; // ms to usec
|
||||
timestampTimer.start();
|
||||
usecTimestampNowIsInitialized = true;
|
||||
}
|
||||
|
||||
// usec nsec to usec usec
|
||||
return TIME_REFERENCE + timestampTimer.nsecsElapsed() / 1000 + ::usecTimestampNowAdjust;
|
||||
}
|
||||
|
@ -620,7 +615,7 @@ int unpackClipValueFromTwoByte(const unsigned char* buffer, float& clipValue) {
|
|||
}
|
||||
|
||||
int packFloatToByte(unsigned char* buffer, float value, float scaleBy) {
|
||||
unsigned char holder;
|
||||
quint8 holder;
|
||||
const float CONVERSION_RATIO = (255 / scaleBy);
|
||||
holder = floorf(value * CONVERSION_RATIO);
|
||||
memcpy(buffer, &holder, sizeof(holder));
|
||||
|
@ -628,7 +623,7 @@ int packFloatToByte(unsigned char* buffer, float value, float scaleBy) {
|
|||
}
|
||||
|
||||
int unpackFloatFromByte(const unsigned char* buffer, float& value, float scaleBy) {
|
||||
unsigned char holder;
|
||||
quint8 holder;
|
||||
memcpy(&holder, buffer, sizeof(holder));
|
||||
value = ((float)holder / (float) 255) * scaleBy;
|
||||
return sizeof(holder);
|
||||
|
|
|
@ -60,7 +60,6 @@ static const quint64 USECS_PER_SECOND = USECS_PER_MSEC * MSECS_PER_SECOND;
|
|||
|
||||
const int BITS_IN_BYTE = 8;
|
||||
|
||||
void initialiseUsecTimestampNow();
|
||||
quint64 usecTimestampNow();
|
||||
void usecTimestampNowForceClockSkew(int clockSkew);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ void voxelDetailFromScriptValue(const QScriptValue &object, VoxelDetail& voxelDe
|
|||
|
||||
RayToVoxelIntersectionResult::RayToVoxelIntersectionResult() :
|
||||
intersects(false),
|
||||
accurate(true), // assume it's accurate
|
||||
voxel(),
|
||||
distance(0),
|
||||
face()
|
||||
|
@ -50,6 +51,7 @@ RayToVoxelIntersectionResult::RayToVoxelIntersectionResult() :
|
|||
QScriptValue rayToVoxelIntersectionResultToScriptValue(QScriptEngine* engine, const RayToVoxelIntersectionResult& value) {
|
||||
QScriptValue obj = engine->newObject();
|
||||
obj.setProperty("intersects", value.intersects);
|
||||
obj.setProperty("accurate", value.accurate);
|
||||
QScriptValue voxelValue = voxelDetailToScriptValue(engine, value.voxel);
|
||||
obj.setProperty("voxel", voxelValue);
|
||||
obj.setProperty("distance", value.distance);
|
||||
|
@ -88,6 +90,7 @@ QScriptValue rayToVoxelIntersectionResultToScriptValue(QScriptEngine* engine, co
|
|||
|
||||
void rayToVoxelIntersectionResultFromScriptValue(const QScriptValue& object, RayToVoxelIntersectionResult& value) {
|
||||
value.intersects = object.property("intersects").toVariant().toBool();
|
||||
value.accurate = object.property("accurate").toVariant().toBool();
|
||||
QScriptValue voxelValue = object.property("voxel");
|
||||
if (voxelValue.isValid()) {
|
||||
voxelDetailFromScriptValue(voxelValue, value.voxel);
|
||||
|
|
|
@ -39,6 +39,7 @@ class RayToVoxelIntersectionResult {
|
|||
public:
|
||||
RayToVoxelIntersectionResult();
|
||||
bool intersects;
|
||||
bool accurate;
|
||||
VoxelDetail voxel;
|
||||
float distance;
|
||||
BoxFace face;
|
||||
|
|
|
@ -42,7 +42,11 @@ void VoxelTree::deleteVoxelAt(float x, float y, float z, float s) {
|
|||
}
|
||||
|
||||
VoxelTreeElement* VoxelTree::getVoxelAt(float x, float y, float z, float s) const {
|
||||
return (VoxelTreeElement*)getOctreeElementAt(x, y, z, s);
|
||||
return static_cast<VoxelTreeElement*>(getOctreeElementAt(x, y, z, s));
|
||||
}
|
||||
|
||||
VoxelTreeElement* VoxelTree::getEnclosingVoxelAt(float x, float y, float z, float s) const {
|
||||
return static_cast<VoxelTreeElement*>(getOctreeEnclosingElementAt(x, y, z, s));
|
||||
}
|
||||
|
||||
void VoxelTree::createVoxel(float x, float y, float z, float s,
|
||||
|
|
|
@ -29,7 +29,15 @@ public:
|
|||
VoxelTreeElement* getRoot() { return (VoxelTreeElement*)_rootNode; }
|
||||
|
||||
void deleteVoxelAt(float x, float y, float z, float s);
|
||||
|
||||
/// Find the voxel at position x,y,z,s
|
||||
/// \return pointer to the VoxelTreeElement or NULL if none at x,y,z,s.
|
||||
VoxelTreeElement* getVoxelAt(float x, float y, float z, float s) const;
|
||||
|
||||
/// Find the voxel at position x,y,z,s
|
||||
/// \return pointer to the VoxelTreeElement or to the smallest enclosing parent if none at x,y,z,s.
|
||||
VoxelTreeElement* getEnclosingVoxelAt(float x, float y, float z, float s) const;
|
||||
|
||||
void createVoxel(float x, float y, float z, float s,
|
||||
unsigned char red, unsigned char green, unsigned char blue, bool destructive = false);
|
||||
|
||||
|
|
|
@ -13,6 +13,50 @@
|
|||
|
||||
#include "VoxelTreeCommands.h"
|
||||
|
||||
|
||||
|
||||
struct SendVoxelsOperationArgs {
|
||||
const unsigned char* newBaseOctCode;
|
||||
VoxelEditPacketSender* packetSender;
|
||||
};
|
||||
|
||||
bool sendVoxelsOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = static_cast<VoxelTreeElement*>(element);
|
||||
SendVoxelsOperationArgs* args = static_cast<SendVoxelsOperationArgs*>(extraData);
|
||||
if (voxel->isColored()) {
|
||||
const unsigned char* nodeOctalCode = voxel->getOctalCode();
|
||||
unsigned char* codeColorBuffer = NULL;
|
||||
int codeLength = 0;
|
||||
int bytesInCode = 0;
|
||||
int codeAndColorLength;
|
||||
|
||||
// If the newBase is NULL, then don't rebase
|
||||
if (args->newBaseOctCode) {
|
||||
codeColorBuffer = rebaseOctalCode(nodeOctalCode, args->newBaseOctCode, true);
|
||||
codeLength = numberOfThreeBitSectionsInCode(codeColorBuffer);
|
||||
bytesInCode = bytesRequiredForCodeLength(codeLength);
|
||||
codeAndColorLength = bytesInCode + SIZE_OF_COLOR_DATA;
|
||||
} else {
|
||||
codeLength = numberOfThreeBitSectionsInCode(nodeOctalCode);
|
||||
bytesInCode = bytesRequiredForCodeLength(codeLength);
|
||||
codeAndColorLength = bytesInCode + SIZE_OF_COLOR_DATA;
|
||||
codeColorBuffer = new unsigned char[codeAndColorLength];
|
||||
memcpy(codeColorBuffer, nodeOctalCode, bytesInCode);
|
||||
}
|
||||
|
||||
// copy the colors over
|
||||
codeColorBuffer[bytesInCode + RED_INDEX] = voxel->getColor()[RED_INDEX];
|
||||
codeColorBuffer[bytesInCode + GREEN_INDEX] = voxel->getColor()[GREEN_INDEX];
|
||||
codeColorBuffer[bytesInCode + BLUE_INDEX] = voxel->getColor()[BLUE_INDEX];
|
||||
args->packetSender->queueVoxelEditMessage(PacketTypeVoxelSetDestructive,
|
||||
codeColorBuffer, codeAndColorLength);
|
||||
|
||||
delete[] codeColorBuffer;
|
||||
}
|
||||
return true; // keep going
|
||||
}
|
||||
|
||||
|
||||
AddVoxelCommand::AddVoxelCommand(VoxelTree* tree, VoxelDetail& voxel, VoxelEditPacketSender* packetSender, QUndoCommand* parent) :
|
||||
QUndoCommand("Add Voxel", parent),
|
||||
_tree(tree),
|
||||
|
@ -43,11 +87,40 @@ DeleteVoxelCommand::DeleteVoxelCommand(VoxelTree* tree, VoxelDetail& voxel, Voxe
|
|||
QUndoCommand("Delete Voxel", parent),
|
||||
_tree(tree),
|
||||
_packetSender(packetSender),
|
||||
_voxel(voxel)
|
||||
_voxel(voxel),
|
||||
_oldTree(NULL)
|
||||
{
|
||||
_tree->lockForRead();
|
||||
VoxelTreeElement* element = _tree->getEnclosingVoxelAt(_voxel.x, _voxel.y, _voxel.z, _voxel.s);
|
||||
if (element->getScale() == _voxel.s) {
|
||||
if (!element->hasContent() && !element->isLeaf()) {
|
||||
_oldTree = new VoxelTree();
|
||||
_tree->copySubTreeIntoNewTree(element, _oldTree, false);
|
||||
} else {
|
||||
_voxel.red = element->getColor()[0];
|
||||
_voxel.green = element->getColor()[1];
|
||||
_voxel.blue = element->getColor()[2];
|
||||
}
|
||||
} else if (element->hasContent() && element->isLeaf()) {
|
||||
_voxel.red = element->getColor()[0];
|
||||
_voxel.green = element->getColor()[1];
|
||||
_voxel.blue = element->getColor()[2];
|
||||
} else {
|
||||
_voxel.s = 0.0f;
|
||||
qDebug() << "No element for delete.";
|
||||
}
|
||||
_tree->unlock();
|
||||
}
|
||||
|
||||
DeleteVoxelCommand::~DeleteVoxelCommand() {
|
||||
delete _oldTree;
|
||||
}
|
||||
|
||||
void DeleteVoxelCommand::redo() {
|
||||
if (_voxel.s == 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_tree) {
|
||||
_tree->deleteVoxelAt(_voxel.x, _voxel.y, _voxel.z, _voxel.s);
|
||||
}
|
||||
|
@ -57,10 +130,32 @@ void DeleteVoxelCommand::redo() {
|
|||
}
|
||||
|
||||
void DeleteVoxelCommand::undo() {
|
||||
if (_tree) {
|
||||
_tree->createVoxel(_voxel.x, _voxel.y, _voxel.z, _voxel.s, _voxel.red, _voxel.green, _voxel.blue);
|
||||
if (_voxel.s == 0.0f) {
|
||||
return;
|
||||
}
|
||||
if (_packetSender) {
|
||||
_packetSender->queueVoxelEditMessages(PacketTypeVoxelSet, 1, &_voxel);
|
||||
|
||||
if (_oldTree) {
|
||||
VoxelTreeElement* element = _oldTree->getVoxelAt(_voxel.x, _voxel.y, _voxel.z, _voxel.s);
|
||||
if (element) {
|
||||
if (_tree) {
|
||||
_tree->lockForWrite();
|
||||
_oldTree->copySubTreeIntoNewTree(element, _tree, false);
|
||||
_tree->unlock();
|
||||
}
|
||||
if (_packetSender) {
|
||||
SendVoxelsOperationArgs args;
|
||||
args.newBaseOctCode = NULL;
|
||||
args.packetSender = _packetSender;
|
||||
_oldTree->recurseTreeWithOperation(sendVoxelsOperation, &args);
|
||||
_packetSender->releaseQueuedMessages();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_tree) {
|
||||
_tree->createVoxel(_voxel.x, _voxel.y, _voxel.z, _voxel.s, _voxel.red, _voxel.green, _voxel.blue);
|
||||
}
|
||||
if (_packetSender) {
|
||||
_packetSender->queueVoxelEditMessages(PacketTypeVoxelSet, 1, &_voxel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ private:
|
|||
class DeleteVoxelCommand : public QUndoCommand {
|
||||
public:
|
||||
DeleteVoxelCommand(VoxelTree* tree, VoxelDetail& voxel, VoxelEditPacketSender* packetSender = NULL, QUndoCommand* parent = NULL);
|
||||
~DeleteVoxelCommand();
|
||||
|
||||
virtual void redo();
|
||||
virtual void undo();
|
||||
|
@ -44,6 +45,7 @@ private:
|
|||
VoxelTree* _tree;
|
||||
VoxelEditPacketSender* _packetSender;
|
||||
VoxelDetail _voxel;
|
||||
VoxelTree* _oldTree;
|
||||
};
|
||||
|
||||
#endif // hifi_VoxelTreeCommands_h
|
||||
|
|
|
@ -76,32 +76,16 @@ void VoxelsScriptingInterface::setVoxel(float x, float y, float z, float scale,
|
|||
if (_tree) {
|
||||
if (_undoStack) {
|
||||
AddVoxelCommand* addCommand = new AddVoxelCommand(_tree,
|
||||
addVoxelDetail,
|
||||
getVoxelPacketSender());
|
||||
|
||||
VoxelTreeElement* deleteVoxelElement = _tree->getVoxelAt(addVoxelDetail.x, addVoxelDetail.y, addVoxelDetail.z, addVoxelDetail.s);
|
||||
if (deleteVoxelElement) {
|
||||
nodeColor color;
|
||||
memcpy(&color, &deleteVoxelElement->getColor(), sizeof(nodeColor));
|
||||
VoxelDetail deleteVoxelDetail = {addVoxelDetail.x,
|
||||
addVoxelDetail.y,
|
||||
addVoxelDetail.z,
|
||||
addVoxelDetail.s,
|
||||
color[0],
|
||||
color[1],
|
||||
color[2]};
|
||||
DeleteVoxelCommand* delCommand = new DeleteVoxelCommand(_tree,
|
||||
deleteVoxelDetail,
|
||||
getVoxelPacketSender());
|
||||
_undoStack->beginMacro(addCommand->text());
|
||||
// As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves.
|
||||
_undoStack->push(delCommand);
|
||||
_undoStack->push(addCommand);
|
||||
_undoStack->endMacro();
|
||||
} else {
|
||||
// As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves.
|
||||
_undoStack->push(addCommand);
|
||||
}
|
||||
addVoxelDetail,
|
||||
getVoxelPacketSender());
|
||||
DeleteVoxelCommand* deleteCommand = new DeleteVoxelCommand(_tree,
|
||||
addVoxelDetail,
|
||||
getVoxelPacketSender());
|
||||
_undoStack->beginMacro(addCommand->text());
|
||||
// As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves.
|
||||
_undoStack->push(deleteCommand);
|
||||
_undoStack->push(addCommand);
|
||||
_undoStack->endMacro();
|
||||
} else {
|
||||
// queue the destructive add
|
||||
queueVoxelAdd(PacketTypeVoxelSetDestructive, addVoxelDetail);
|
||||
|
@ -138,12 +122,21 @@ void VoxelsScriptingInterface::eraseVoxel(float x, float y, float z, float scale
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
RayToVoxelIntersectionResult VoxelsScriptingInterface::findRayIntersection(const PickRay& ray) {
|
||||
return findRayIntersectionWorker(ray, Octree::TryLock);
|
||||
}
|
||||
|
||||
RayToVoxelIntersectionResult VoxelsScriptingInterface::findRayIntersectionBlocking(const PickRay& ray) {
|
||||
return findRayIntersectionWorker(ray, Octree::Lock);
|
||||
}
|
||||
|
||||
RayToVoxelIntersectionResult VoxelsScriptingInterface::findRayIntersectionWorker(const PickRay& ray,
|
||||
Octree::lockType lockType) {
|
||||
RayToVoxelIntersectionResult result;
|
||||
if (_tree) {
|
||||
OctreeElement* element;
|
||||
result.intersects = _tree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face);
|
||||
result.intersects = _tree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face,
|
||||
lockType, &result.accurate);
|
||||
if (result.intersects) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
result.voxel.x = voxel->getCorner().x;
|
||||
|
|
|
@ -35,17 +35,16 @@ public:
|
|||
void setVoxelTree(VoxelTree* tree) { _tree = tree; }
|
||||
void setUndoStack(QUndoStack* undoStack) { _undoStack = undoStack; }
|
||||
|
||||
public slots:
|
||||
|
||||
public:
|
||||
/// provide the world scale
|
||||
const int getTreeScale() const { return TREE_SCALE; }
|
||||
Q_INVOKABLE const int getTreeScale() const { return TREE_SCALE; }
|
||||
|
||||
/// checks the local voxel tree for a voxel at the specified location and scale
|
||||
/// \param x the x-coordinate of the voxel (in meter units)
|
||||
/// \param y the y-coordinate of the voxel (in meter units)
|
||||
/// \param z the z-coordinate of the voxel (in meter units)
|
||||
/// \param scale the scale of the voxel (in meter units)
|
||||
VoxelDetail getVoxelAt(float x, float y, float z, float scale);
|
||||
Q_INVOKABLE VoxelDetail getVoxelAt(float x, float y, float z, float scale);
|
||||
|
||||
/// queues the creation of a voxel which will be sent by calling process on the PacketSender
|
||||
/// \param x the x-coordinate of the voxel (in meter units)
|
||||
|
@ -55,7 +54,7 @@ public slots:
|
|||
/// \param red the R value for RGB color of voxel
|
||||
/// \param green the G value for RGB color of voxel
|
||||
/// \param blue the B value for RGB color of voxel
|
||||
void setVoxelNonDestructive(float x, float y, float z, float scale, uchar red, uchar green, uchar blue);
|
||||
Q_INVOKABLE void setVoxelNonDestructive(float x, float y, float z, float scale, uchar red, uchar green, uchar blue);
|
||||
|
||||
/// queues the destructive creation of a voxel which will be sent by calling process on the PacketSender
|
||||
/// \param x the x-coordinate of the voxel (in meter units)
|
||||
|
@ -65,27 +64,36 @@ public slots:
|
|||
/// \param red the R value for RGB color of voxel
|
||||
/// \param green the G value for RGB color of voxel
|
||||
/// \param blue the B value for RGB color of voxel
|
||||
void setVoxel(float x, float y, float z, float scale, uchar red, uchar green, uchar blue);
|
||||
Q_INVOKABLE void setVoxel(float x, float y, float z, float scale, uchar red, uchar green, uchar blue);
|
||||
|
||||
/// queues the deletion of a voxel, sent by calling process on the PacketSender
|
||||
/// \param x the x-coordinate of the voxel (in meter units)
|
||||
/// \param y the y-coordinate of the voxel (in meter units)
|
||||
/// \param z the z-coordinate of the voxel (in meter units)
|
||||
/// \param scale the scale of the voxel (in meter units)
|
||||
void eraseVoxel(float x, float y, float z, float scale);
|
||||
Q_INVOKABLE void eraseVoxel(float x, float y, float z, float scale);
|
||||
|
||||
/// If the scripting context has visible voxels, this will determine a ray intersection
|
||||
RayToVoxelIntersectionResult findRayIntersection(const PickRay& ray);
|
||||
/// If the scripting context has visible voxels, this will determine a ray intersection, the results
|
||||
/// may be inaccurate if the engine is unable to access the visible voxels, in which case result.accurate
|
||||
/// will be false.
|
||||
Q_INVOKABLE RayToVoxelIntersectionResult findRayIntersection(const PickRay& ray);
|
||||
|
||||
/// If the scripting context has visible voxels, this will determine a ray intersection, and will block in
|
||||
/// order to return an accurate result
|
||||
Q_INVOKABLE RayToVoxelIntersectionResult findRayIntersectionBlocking(const PickRay& ray);
|
||||
|
||||
/// returns a voxel space axis aligned vector for the face, useful in doing voxel math
|
||||
glm::vec3 getFaceVector(const QString& face);
|
||||
Q_INVOKABLE glm::vec3 getFaceVector(const QString& face);
|
||||
|
||||
/// checks the local voxel tree for the smallest voxel enclosing the point
|
||||
/// \param point the x,y,z coordinates of the point (in meter units)
|
||||
/// \return VoxelDetail - if no voxel encloses the point then VoxelDetail items will be 0
|
||||
VoxelDetail getVoxelEnclosingPoint(const glm::vec3& point);
|
||||
Q_INVOKABLE VoxelDetail getVoxelEnclosingPoint(const glm::vec3& point);
|
||||
|
||||
private:
|
||||
/// actually does the work of finding the ray intersection, can be called in locking mode or tryLock mode
|
||||
RayToVoxelIntersectionResult findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType);
|
||||
|
||||
void queueVoxelAdd(PacketType addPacketType, VoxelDetail& addVoxelDetails);
|
||||
VoxelTree* _tree;
|
||||
QUndoStack* _undoStack;
|
||||
|
|
Loading…
Reference in a new issue