mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-26 13:10:02 +02:00
merge andrew/thermonuclear into andrew/inertia
Conflicts: libraries/entities/src/EntityItem.cpp libraries/entities/src/EntityItem.h
This commit is contained in:
commit
961dc5a231
23 changed files with 353 additions and 106 deletions
|
@ -21,7 +21,7 @@
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
#include <SoundCache.h>
|
||||||
|
|
||||||
#include "AssignmentFactory.h"
|
#include "AssignmentFactory.h"
|
||||||
#include "AssignmentThread.h"
|
#include "AssignmentThread.h"
|
||||||
|
@ -122,7 +122,9 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
||||||
connect(&AccountManager::getInstance(), &AccountManager::authRequired,
|
connect(&AccountManager::getInstance(), &AccountManager::authRequired,
|
||||||
this, &AssignmentClient::handleAuthenticationRequest);
|
this, &AssignmentClient::handleAuthenticationRequest);
|
||||||
|
|
||||||
|
// Create Singleton objects on main thread
|
||||||
NetworkAccessManager::getInstance();
|
NetworkAccessManager::getInstance();
|
||||||
|
SoundCache::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignmentClient::sendAssignmentRequest() {
|
void AssignmentClient::sendAssignmentRequest() {
|
||||||
|
|
42
examples/acScripts/ambiance.js
Normal file
42
examples/acScripts/ambiance.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
//
|
||||||
|
// ambiance.js
|
||||||
|
// examples
|
||||||
|
//
|
||||||
|
// Created by Clément Brisset on 11/18/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
|
||||||
|
//
|
||||||
|
|
||||||
|
var soundURL = "https://s3.amazonaws.com/hifi-public/sounds/08_Funny_Bone.wav";
|
||||||
|
var position = { x: 700, y: 25, z: 725 };
|
||||||
|
var audioOptions = {
|
||||||
|
position: position,
|
||||||
|
volume: 0.4,
|
||||||
|
loop: true,
|
||||||
|
stereo: false
|
||||||
|
};
|
||||||
|
|
||||||
|
var sound = SoundCache.getSound(soundURL, audioOptions.isStereo);
|
||||||
|
var injector = null;
|
||||||
|
var count = 100;
|
||||||
|
|
||||||
|
Script.update.connect(function() {
|
||||||
|
if (count > 0) {
|
||||||
|
count--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sound.downloaded && injector === null) {
|
||||||
|
print("Sound downloaded.");
|
||||||
|
injector = Audio.playSound(sound, audioOptions);
|
||||||
|
print("Playing: " + injector);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(function() {
|
||||||
|
if (injector !== null) {
|
||||||
|
injector.stop();
|
||||||
|
}
|
||||||
|
});
|
|
@ -15,17 +15,43 @@
|
||||||
this.graboffset = null;
|
this.graboffset = null;
|
||||||
this.clickedAt = null;
|
this.clickedAt = null;
|
||||||
this.firstHolding = true;
|
this.firstHolding = true;
|
||||||
this.clickedX = -1;
|
this.clicked = { x: -1, y: -1};
|
||||||
this.clickedY = -1;
|
this.lastMovedPosition = { x: -1, y: -1};
|
||||||
|
this.lastMovedTime = 0;
|
||||||
this.rotateOverlayTarget = null;
|
this.rotateOverlayTarget = null;
|
||||||
this.rotateOverlayInner = null;
|
this.rotateOverlayInner = null;
|
||||||
this.rotateOverlayOuter = null;
|
this.rotateOverlayOuter = null;
|
||||||
this.rotateOverlayCurrent = null;
|
this.rotateOverlayCurrent = null;
|
||||||
this.rotateMode = false;
|
this.rotateMode = false;
|
||||||
this.originalRotation = null;
|
this.originalRotation = null;
|
||||||
this.sound = null;
|
|
||||||
|
this.moveSoundURLS = [
|
||||||
|
"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove1.wav",
|
||||||
|
"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove2.wav",
|
||||||
|
"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove3.wav"
|
||||||
|
];
|
||||||
|
|
||||||
|
this.turnSoundURLS = [
|
||||||
|
|
||||||
|
"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove1.wav",
|
||||||
|
"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove2.wav",
|
||||||
|
"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureMove3.wav"
|
||||||
|
|
||||||
|
// TODO: determine if these or other turn sounds work better than move sounds.
|
||||||
|
//"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn1.wav",
|
||||||
|
//"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn2.wav",
|
||||||
|
//"http://public.highfidelity.io/sounds/MovingFurniture/FurnitureTurn3.wav"
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
this.moveSounds = new Array();
|
||||||
|
this.turnSounds = new Array();
|
||||||
|
this.moveSound = null;
|
||||||
|
this.turnSound = null;
|
||||||
this.injector = null;
|
this.injector = null;
|
||||||
|
|
||||||
|
var debug = false;
|
||||||
|
var displayRotateTargets = true; // change to false if you don't want the rotate targets
|
||||||
var rotateOverlayTargetSize = 10000; // really big target
|
var rotateOverlayTargetSize = 10000; // really big target
|
||||||
var innerSnapAngle = 22.5; // the angle which we snap to on the inner rotation tool
|
var innerSnapAngle = 22.5; // the angle which we snap to on the inner rotation tool
|
||||||
var innerRadius;
|
var innerRadius;
|
||||||
|
@ -34,25 +60,62 @@
|
||||||
var yawZero;
|
var yawZero;
|
||||||
var rotationNormal;
|
var rotationNormal;
|
||||||
var yawNormal;
|
var yawNormal;
|
||||||
|
var stopSoundDelay = 100; // number of msecs of not moving to have sound stop
|
||||||
|
|
||||||
var debug = true;
|
this.getRandomInt = function(min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
// Download sound if needed
|
this.downloadSounds = function() {
|
||||||
this.maybeDownloadSound = function() {
|
for (var i = 0; i < this.moveSoundURLS.length; i++) {
|
||||||
if (this.sound === null) {
|
this.moveSounds[i] = SoundCache.getSound(this.moveSoundURLS[i]);
|
||||||
this.sound = SoundCache.getSound("http://public.highfidelity.io/sounds/Collisions-otherorganic/whoosh2.raw");
|
|
||||||
}
|
}
|
||||||
}
|
for (var i = 0; i < this.turnSoundURLS.length; i++) {
|
||||||
// Play drag sound
|
this.turnSounds[i] = SoundCache.getSound(this.turnSoundURLS[i]);
|
||||||
this.playSound = function() {
|
|
||||||
this.stopSound();
|
|
||||||
if (this.sound && this.sound.downloaded) {
|
|
||||||
this.injector = Audio.playSound(this.sound, { position: this.properties.position, loop: true, volume: 0.1 });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop drag sound
|
this.pickRandomSounds = function() {
|
||||||
|
var moveIndex = this.getRandomInt(0, this.moveSounds.length - 1);
|
||||||
|
var turnIndex = this.getRandomInt(0, this.turnSounds.length - 1);
|
||||||
|
if (debug) {
|
||||||
|
print("Random sounds -- turn:" + turnIndex + " move:" + moveIndex);
|
||||||
|
}
|
||||||
|
this.moveSound = this.moveSounds[moveIndex];
|
||||||
|
this.turnSound = this.turnSounds[turnIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Play move sound
|
||||||
|
this.playMoveSound = function() {
|
||||||
|
if (debug) {
|
||||||
|
print("playMoveSound()");
|
||||||
|
}
|
||||||
|
if (this.moveSound && this.moveSound.downloaded) {
|
||||||
|
if (debug) {
|
||||||
|
print("playMoveSound() --- calling this.injector = Audio.playSound(this.moveSound...)");
|
||||||
|
}
|
||||||
|
this.injector = Audio.playSound(this.moveSound, { position: this.properties.position, loop: true, volume: 0.1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Play turn sound
|
||||||
|
this.playTurnSound = function() {
|
||||||
|
if (debug) {
|
||||||
|
print("playTurnSound()");
|
||||||
|
}
|
||||||
|
if (this.turnSound && this.turnSound.downloaded) {
|
||||||
|
if (debug) {
|
||||||
|
print("playTurnSound() --- calling this.injector = Audio.playSound(this.turnSound...)");
|
||||||
|
}
|
||||||
|
this.injector = Audio.playSound(this.turnSound, { position: this.properties.position, loop: true, volume: 0.1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop sound
|
||||||
this.stopSound = function() {
|
this.stopSound = function() {
|
||||||
|
if (debug) {
|
||||||
|
print("stopSound()");
|
||||||
|
}
|
||||||
if (this.injector) {
|
if (this.injector) {
|
||||||
Audio.stopInjector(this.injector);
|
Audio.stopInjector(this.injector);
|
||||||
this.injector = null;
|
this.injector = null;
|
||||||
|
@ -87,10 +150,32 @@
|
||||||
this.graboffset = Vec3.subtract(this.properties.position, intersection);
|
this.graboffset = Vec3.subtract(this.properties.position, intersection);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.stopSoundIfNotMoving = function(mouseEvent) {
|
||||||
|
var nowDate = new Date();
|
||||||
|
var nowMSecs = nowDate.getTime();
|
||||||
|
if(mouseEvent.x == this.lastMovedPosition.x && mouseEvent.y == this.lastMovedPosition.y) {
|
||||||
|
var elapsedSinceLastMove = nowMSecs - this.lastMovedMSecs;
|
||||||
|
if (debug) {
|
||||||
|
print("elapsedSinceLastMove:" + elapsedSinceLastMove);
|
||||||
|
}
|
||||||
|
if (elapsedSinceLastMove > stopSoundDelay) {
|
||||||
|
if (debug) {
|
||||||
|
print("calling stopSound()...");
|
||||||
|
}
|
||||||
|
this.stopSound();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// if we've moved, then track our last move position and time...
|
||||||
|
this.lastMovedMSecs = nowMSecs;
|
||||||
|
this.lastMovedPosition.x = mouseEvent.x;
|
||||||
|
this.lastMovedPosition.y = mouseEvent.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.move = function(mouseEvent) {
|
this.move = function(mouseEvent) {
|
||||||
this.updatePosition(mouseEvent);
|
this.updatePosition(mouseEvent);
|
||||||
if (this.injector === null) {
|
if (this.injector === null) {
|
||||||
this.playSound();
|
this.playMoveSound();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -147,6 +232,10 @@
|
||||||
majorTickMarksLength: 0.25, minorTickMarksLength: 0.1, });
|
majorTickMarksLength: 0.25, minorTickMarksLength: 0.1, });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.injector === null) {
|
||||||
|
this.playTurnSound();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// All callbacks start by updating the properties
|
// All callbacks start by updating the properties
|
||||||
this.updateProperties = function(entityID) {
|
this.updateProperties = function(entityID) {
|
||||||
|
@ -185,7 +274,7 @@
|
||||||
|
|
||||||
this.rotateOverlayTarget = Overlays.addOverlay("circle3d", {
|
this.rotateOverlayTarget = Overlays.addOverlay("circle3d", {
|
||||||
position: this.properties.position,
|
position: this.properties.position,
|
||||||
size: 10000,
|
size: rotateOverlayTargetSize,
|
||||||
color: { red: 0, green: 0, blue: 0 },
|
color: { red: 0, green: 0, blue: 0 },
|
||||||
alpha: 0.0,
|
alpha: 0.0,
|
||||||
solid: true,
|
solid: true,
|
||||||
|
@ -201,7 +290,7 @@
|
||||||
alpha: innerAlpha,
|
alpha: innerAlpha,
|
||||||
color: { red: 51, green: 152, blue: 203 },
|
color: { red: 51, green: 152, blue: 203 },
|
||||||
solid: true,
|
solid: true,
|
||||||
visible: true,
|
visible: displayRotateTargets,
|
||||||
rotation: yawOverlayRotation,
|
rotation: yawOverlayRotation,
|
||||||
hasTickMarks: true,
|
hasTickMarks: true,
|
||||||
majorTickMarksAngle: innerSnapAngle,
|
majorTickMarksAngle: innerSnapAngle,
|
||||||
|
@ -222,7 +311,7 @@
|
||||||
alpha: outerAlpha,
|
alpha: outerAlpha,
|
||||||
color: { red: 51, green: 152, blue: 203 },
|
color: { red: 51, green: 152, blue: 203 },
|
||||||
solid: true,
|
solid: true,
|
||||||
visible: true,
|
visible: displayRotateTargets,
|
||||||
rotation: yawOverlayRotation,
|
rotation: yawOverlayRotation,
|
||||||
|
|
||||||
hasTickMarks: true,
|
hasTickMarks: true,
|
||||||
|
@ -244,7 +333,7 @@
|
||||||
color: { red: 224, green: 67, blue: 36},
|
color: { red: 224, green: 67, blue: 36},
|
||||||
alpha: 0.8,
|
alpha: 0.8,
|
||||||
solid: true,
|
solid: true,
|
||||||
visible: true,
|
visible: displayRotateTargets,
|
||||||
rotation: yawOverlayRotation,
|
rotation: yawOverlayRotation,
|
||||||
ignoreRayIntersection: true, // always ignore this
|
ignoreRayIntersection: true, // always ignore this
|
||||||
hasTickMarks: true,
|
hasTickMarks: true,
|
||||||
|
@ -260,19 +349,25 @@
|
||||||
|
|
||||||
this.preload = function(entityID) {
|
this.preload = function(entityID) {
|
||||||
this.updateProperties(entityID); // All callbacks start by updating the properties
|
this.updateProperties(entityID); // All callbacks start by updating the properties
|
||||||
this.maybeDownloadSound();
|
this.downloadSounds();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.clickDownOnEntity = function(entityID, mouseEvent) {
|
this.clickDownOnEntity = function(entityID, mouseEvent) {
|
||||||
this.updateProperties(entityID); // All callbacks start by updating the properties
|
this.updateProperties(entityID); // All callbacks start by updating the properties
|
||||||
this.grab(mouseEvent);
|
this.grab(mouseEvent);
|
||||||
|
|
||||||
var d = new Date();
|
var nowDate = new Date();
|
||||||
this.clickedAt = d.getTime();
|
var nowMSecs = nowDate.getTime();
|
||||||
|
this.clickedAt = nowMSecs;
|
||||||
this.firstHolding = true;
|
this.firstHolding = true;
|
||||||
|
|
||||||
this.clickedX = mouseEvent.x;
|
this.clicked.x = mouseEvent.x;
|
||||||
this.clickedY = mouseEvent.y;
|
this.clicked.y = mouseEvent.y;
|
||||||
|
this.lastMovedPosition.x = mouseEvent.x;
|
||||||
|
this.lastMovedPosition.y = mouseEvent.y;
|
||||||
|
this.lastMovedMSecs = nowMSecs;
|
||||||
|
|
||||||
|
this.pickRandomSounds();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.holdingClickOnEntity = function(entityID, mouseEvent) {
|
this.holdingClickOnEntity = function(entityID, mouseEvent) {
|
||||||
|
@ -281,7 +376,7 @@
|
||||||
|
|
||||||
if (this.firstHolding) {
|
if (this.firstHolding) {
|
||||||
// if we haven't moved yet...
|
// if we haven't moved yet...
|
||||||
if (this.clickedX == mouseEvent.x && this.clickedY == mouseEvent.y) {
|
if (this.clicked.x == mouseEvent.x && this.clicked.y == mouseEvent.y) {
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
var now = d.getTime();
|
var now = d.getTime();
|
||||||
|
|
||||||
|
@ -301,6 +396,8 @@
|
||||||
} else {
|
} else {
|
||||||
this.move(mouseEvent);
|
this.move(mouseEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.stopSoundIfNotMoving(mouseEvent);
|
||||||
};
|
};
|
||||||
this.clickReleaseOnEntity = function(entityID, mouseEvent) {
|
this.clickReleaseOnEntity = function(entityID, mouseEvent) {
|
||||||
this.updateProperties(entityID); // All callbacks start by updating the properties
|
this.updateProperties(entityID); // All callbacks start by updating the properties
|
||||||
|
|
|
@ -12,14 +12,13 @@
|
||||||
{ red: 0, green: 0, blue: 255 },
|
{ red: 0, green: 0, blue: 255 },
|
||||||
];
|
];
|
||||||
|
|
||||||
posY = document.getElementById("horiz-y");
|
elPosY = document.getElementById("horiz-y");
|
||||||
minorSpacing = document.getElementById("minor-spacing");
|
elMinorSpacing = document.getElementById("minor-spacing");
|
||||||
majorSpacing = document.getElementById("major-spacing");
|
elMajorSpacing = document.getElementById("major-spacing");
|
||||||
gridOn = document.getElementById("grid-on");
|
elSnapToGrid = document.getElementById("snap-to-grid");
|
||||||
snapToGrid = document.getElementById("snap-to-grid");
|
elHorizontalGridVisible = document.getElementById("horiz-grid-visible");
|
||||||
hGridVisible = document.getElementById("horiz-grid-visible");
|
elMoveToSelection = document.getElementById("move-to-selection");
|
||||||
bMoveToSelection = document.getElementById("move-to-selection");
|
elMoveToAvatar = document.getElementById("move-to-avatar");
|
||||||
bMoveToAvatar = document.getElementById("move-to-avatar");
|
|
||||||
|
|
||||||
if (window.EventBridge !== undefined) {
|
if (window.EventBridge !== undefined) {
|
||||||
EventBridge.scriptEventReceived.connect(function(data) {
|
EventBridge.scriptEventReceived.connect(function(data) {
|
||||||
|
@ -27,27 +26,27 @@
|
||||||
|
|
||||||
if (data.origin) {
|
if (data.origin) {
|
||||||
var origin = data.origin;
|
var origin = data.origin;
|
||||||
posY.value = origin.y;
|
elPosY.value = origin.y.toFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.minorGridSpacing) {
|
if (data.minorGridSpacing) {
|
||||||
minorSpacing.value = data.minorGridSpacing;
|
elMinorSpacing.value = data.minorGridSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.majorGridEvery) {
|
if (data.majorGridEvery) {
|
||||||
majorSpacing.value = data.majorGridEvery;
|
elMajorSpacing.value = data.majorGridEvery;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.gridColor) {
|
if (data.gridColor) {
|
||||||
gridColor = data.gridColor;
|
gridColor = data.gridColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.snapToGrid !== undefined) {
|
if (data.elSnapToGrid !== undefined) {
|
||||||
snapToGrid.checked = data.snapToGrid == true;
|
elSnapToGrid.checked = data.snapToGrid == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.visible !== undefined) {
|
if (data.visible !== undefined) {
|
||||||
hGridVisible.checked = data.visible == true;
|
elHorizontalGridVisible.checked = data.visible == true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -55,29 +54,31 @@
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "update",
|
type: "update",
|
||||||
origin: {
|
origin: {
|
||||||
y: posY.value,
|
y: elPosY.value,
|
||||||
},
|
},
|
||||||
minorGridSpacing: minorSpacing.value,
|
minorGridSpacing: elMinorSpacing.value,
|
||||||
majorGridEvery: majorSpacing.value,
|
majorGridEvery: elMajorSpacing.value,
|
||||||
gridColor: gridColor,
|
gridColor: gridColor,
|
||||||
snapToGrid: snapToGrid.checked,
|
snapToGrid: elSnapToGrid.checked,
|
||||||
visible: hGridVisible.checked,
|
visible: elHorizontalGridVisible.checked,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("input", emitUpdate);
|
elPosY.addEventListener("change", emitUpdate);
|
||||||
hGridVisible.addEventListener("change", emitUpdate);
|
elMinorSpacing.addEventListener("change", emitUpdate);
|
||||||
snapToGrid.addEventListener("change", emitUpdate);
|
elMajorSpacing.addEventListener("change", emitUpdate);
|
||||||
|
elSnapToGrid.addEventListener("change", emitUpdate);
|
||||||
|
elHorizontalGridVisible.addEventListener("change", emitUpdate);
|
||||||
|
|
||||||
bMoveToAvatar.addEventListener("click", function() {
|
elMoveToAvatar.addEventListener("click", function() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
action: "moveToAvatar",
|
action: "moveToAvatar",
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
bMoveToSelection.addEventListener("click", function() {
|
elMoveToSelection.addEventListener("click", function() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
action: "moveToSelection",
|
action: "moveToSelection",
|
||||||
|
|
|
@ -1403,6 +1403,8 @@ SelectionDisplay = (function () {
|
||||||
|
|
||||||
vector = vec3Mult(mask, vector);
|
vector = vec3Mult(mask, vector);
|
||||||
|
|
||||||
|
vector = grid.snapToSpacing(vector);
|
||||||
|
|
||||||
var changeInDimensions = Vec3.multiply(-1, vec3Mult(signs, vector));
|
var changeInDimensions = Vec3.multiply(-1, vec3Mult(signs, vector));
|
||||||
var newDimensions;
|
var newDimensions;
|
||||||
if (proportional) {
|
if (proportional) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ Grid = function(opts) {
|
||||||
var minorGridWidth = 0.5;
|
var minorGridWidth = 0.5;
|
||||||
var majorGridWidth = 1.5;
|
var majorGridWidth = 1.5;
|
||||||
|
|
||||||
var snapToGrid = true;
|
var snapToGrid = false;
|
||||||
|
|
||||||
var gridOverlay = Overlays.addOverlay("grid", {
|
var gridOverlay = Overlays.addOverlay("grid", {
|
||||||
position: { x: 0 , y: 0, z: 0 },
|
position: { x: 0 , y: 0, z: 0 },
|
||||||
|
@ -69,6 +69,24 @@ Grid = function(opts) {
|
||||||
return Vec3.sum(position, origin);
|
return Vec3.sum(position, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.snapToSpacing = function(delta, majorOnly) {
|
||||||
|
print('snaptogrid? ' + snapToGrid);
|
||||||
|
if (!snapToGrid) {
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
var spacing = majorOnly ? (minorGridSpacing * majorGridEvery) : minorGridSpacing;
|
||||||
|
|
||||||
|
var snappedDelta = {
|
||||||
|
x: Math.round(delta.x / spacing) * spacing,
|
||||||
|
y: Math.round(delta.y / spacing) * spacing,
|
||||||
|
z: Math.round(delta.z / spacing) * spacing,
|
||||||
|
};
|
||||||
|
|
||||||
|
return snappedDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
that.setPosition = function(newPosition, noUpdate) {
|
that.setPosition = function(newPosition, noUpdate) {
|
||||||
origin = Vec3.subtract(newPosition, { x: 0, y: yOffset, z: 0 });
|
origin = Vec3.subtract(newPosition, { x: 0, y: yOffset, z: 0 });
|
||||||
origin.x = 0;
|
origin.x = 0;
|
||||||
|
|
|
@ -1930,11 +1930,14 @@ void Application::init() {
|
||||||
// check if we have a URL in settings to load to jump back to
|
// check if we have a URL in settings to load to jump back to
|
||||||
// we load this separate from the other settings so we don't double lookup a URL
|
// we load this separate from the other settings so we don't double lookup a URL
|
||||||
QSettings* interfaceSettings = lockSettings();
|
QSettings* interfaceSettings = lockSettings();
|
||||||
QUrl addressURL = interfaceSettings->value(SETTINGS_ADDRESS_KEY).toUrl();
|
QVariant addressVariant = interfaceSettings->value(SETTINGS_ADDRESS_KEY);
|
||||||
|
|
||||||
AddressManager::getInstance().handleLookupString(addressURL.toString());
|
QString addressString = addressVariant.isNull()
|
||||||
|
? DEFAULT_HIFI_ADDRESS : addressVariant.toUrl().toString();
|
||||||
|
|
||||||
unlockSettings();
|
unlockSettings();
|
||||||
|
|
||||||
|
AddressManager::getInstance().handleLookupString(addressString);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Loaded settings";
|
qDebug() << "Loaded settings";
|
||||||
|
@ -2942,6 +2945,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
||||||
if (whichCamera.getMode() == CAMERA_MODE_MIRROR) {
|
if (whichCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f));
|
viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f));
|
||||||
}
|
}
|
||||||
|
if (renderSide != RenderArgs::MONO) {
|
||||||
|
glm::mat4 invView = glm::inverse(_untranslatedViewMatrix);
|
||||||
|
|
||||||
|
viewTransform.evalFromRawMatrix(invView);
|
||||||
|
viewTransform.preTranslate(_viewMatrixTranslation);
|
||||||
|
}
|
||||||
|
|
||||||
setViewTransform(viewTransform);
|
setViewTransform(viewTransform);
|
||||||
|
|
||||||
glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z);
|
glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <glm/gtx/quaternion.hpp>
|
#include <glm/gtx/quaternion.hpp>
|
||||||
#include <glm/gtx/vector_angle.hpp>
|
#include <glm/gtx/vector_angle.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
#include <glm/gtx/vector_query.hpp>
|
||||||
|
|
||||||
#include <GeometryUtil.h>
|
#include <GeometryUtil.h>
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
|
@ -664,8 +665,18 @@ void Avatar::renderDisplayName() {
|
||||||
|
|
||||||
// we need "always facing camera": we must remove the camera rotation from the stack
|
// we need "always facing camera": we must remove the camera rotation from the stack
|
||||||
glm::quat rotation = Application::getInstance()->getCamera()->getRotation();
|
glm::quat rotation = Application::getInstance()->getCamera()->getRotation();
|
||||||
glm::vec3 axis = glm::axis(rotation);
|
|
||||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
glm::vec3 frontAxis(1.f, 0.f, 0.f);
|
||||||
|
frontAxis = glm::rotate(rotation, frontAxis);
|
||||||
|
frontAxis = glm::normalize(glm::vec3(frontAxis.x, 0.f, frontAxis.z));
|
||||||
|
|
||||||
|
// TODO : test this secodn solution which should be better wfor occulus
|
||||||
|
//glm::vec3 camPosition = Application::getInstance()->getCamera()->getPosition();
|
||||||
|
//glm::vec3 frontAxis = camPosition - textPosition;
|
||||||
|
//frontAxis = glm::normalize(glm::vec3(frontAxis.z, 0.f, -frontAxis.x));
|
||||||
|
|
||||||
|
float angle = acos(frontAxis.x) * ((frontAxis.z < 0) ? 1.f : -1.f);
|
||||||
|
glRotatef(glm::degrees(angle), 0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
// We need to compute the scale factor such as the text remains with fixed size respect to window coordinates
|
// We need to compute the scale factor such as the text remains with fixed size respect to window coordinates
|
||||||
// We project a unit vector and check the difference in screen coordinates, to check which is the
|
// We project a unit vector and check the difference in screen coordinates, to check which is the
|
||||||
|
@ -695,7 +706,8 @@ void Avatar::renderDisplayName() {
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
double textWindowHeight = abs(result1[1] - result0[1]);
|
double textWindowHeight = abs(result1[1] - result0[1]);
|
||||||
float scaleFactor = Application::getInstance()->getRenderResolutionScale() *
|
float scaleFactor = Application::getInstance()->getRenderResolutionScale() * // Scale compensate for the resolution
|
||||||
|
QApplication::desktop()->windowHandle()->devicePixelRatio() * // And the device pixel ratio
|
||||||
((textWindowHeight > EPSILON) ? 1.0f / textWindowHeight : 1.0f);
|
((textWindowHeight > EPSILON) ? 1.0f / textWindowHeight : 1.0f);
|
||||||
glScalef(scaleFactor, scaleFactor, 1.0);
|
glScalef(scaleFactor, scaleFactor, 1.0);
|
||||||
|
|
||||||
|
|
|
@ -504,10 +504,12 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
||||||
(bodyOrientation * glm::quat(orientation.x, orientation.y, orientation.z, orientation.w) *
|
(bodyOrientation * glm::quat(orientation.x, orientation.y, orientation.z, orientation.w) *
|
||||||
glm::vec3(_eyeRenderDesc[eye].ViewAdjust.x, _eyeRenderDesc[eye].ViewAdjust.y, _eyeRenderDesc[eye].ViewAdjust.z));
|
glm::vec3(_eyeRenderDesc[eye].ViewAdjust.x, _eyeRenderDesc[eye].ViewAdjust.y, _eyeRenderDesc[eye].ViewAdjust.z));
|
||||||
|
|
||||||
|
RenderArgs::RenderSide renderSide = RenderArgs::STEREO_LEFT;
|
||||||
if (eyeIndex == 0) {
|
if (eyeIndex == 0) {
|
||||||
_leftEyePosition = thisEyePosition;
|
_leftEyePosition = thisEyePosition;
|
||||||
} else {
|
} else {
|
||||||
_rightEyePosition = thisEyePosition;
|
_rightEyePosition = thisEyePosition;
|
||||||
|
renderSide = RenderArgs::STEREO_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
_camera->update(1.0f / Application::getInstance()->getFps());
|
_camera->update(1.0f / Application::getInstance()->getFps());
|
||||||
|
@ -522,11 +524,15 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
||||||
glViewport(_eyeRenderViewport[eye].Pos.x, _eyeRenderViewport[eye].Pos.y,
|
glViewport(_eyeRenderViewport[eye].Pos.x, _eyeRenderViewport[eye].Pos.y,
|
||||||
_eyeRenderViewport[eye].Size.w, _eyeRenderViewport[eye].Size.h);
|
_eyeRenderViewport[eye].Size.w, _eyeRenderViewport[eye].Size.h);
|
||||||
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(_eyeRenderDesc[eye].ViewAdjust.x, _eyeRenderDesc[eye].ViewAdjust.y, _eyeRenderDesc[eye].ViewAdjust.z);
|
|
||||||
|
|
||||||
Application::getInstance()->displaySide(*_camera);
|
// HACK: instead of passing the stereo eye offset directly in the matrix, pass it in the camera offset
|
||||||
|
//glTranslatef(_eyeRenderDesc[eye].ViewAdjust.x, _eyeRenderDesc[eye].ViewAdjust.y, _eyeRenderDesc[eye].ViewAdjust.z);
|
||||||
|
|
||||||
|
_camera->setEyeOffsetPosition(glm::vec3(-_eyeRenderDesc[eye].ViewAdjust.x, -_eyeRenderDesc[eye].ViewAdjust.y, -_eyeRenderDesc[eye].ViewAdjust.z));
|
||||||
|
Application::getInstance()->displaySide(*_camera, false, RenderArgs::MONO);
|
||||||
|
|
||||||
applicationOverlay.displayOverlayTextureOculus(*_camera);
|
applicationOverlay.displayOverlayTextureOculus(*_camera);
|
||||||
_activeEyeIndex = -1;
|
_activeEyeIndex = -1;
|
||||||
|
|
|
@ -17,8 +17,11 @@ const int DEFAULT_WIDTH = 300;
|
||||||
|
|
||||||
ToolWindow::ToolWindow(QWidget* parent) :
|
ToolWindow::ToolWindow(QWidget* parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
|
_selfHidden(false),
|
||||||
_hasShown(false),
|
_hasShown(false),
|
||||||
_lastGeometry() {
|
_lastGeometry() {
|
||||||
|
|
||||||
|
Application::getInstance()->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolWindow::event(QEvent* event) {
|
bool ToolWindow::event(QEvent* event) {
|
||||||
|
@ -47,8 +50,37 @@ bool ToolWindow::event(QEvent* event) {
|
||||||
return QMainWindow::event(event);
|
return QMainWindow::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ToolWindow::eventFilter(QObject* sender, QEvent* event) {
|
||||||
|
switch (event->type()) {
|
||||||
|
case QEvent::WindowStateChange:
|
||||||
|
if (Application::getInstance()->getWindow()->isMinimized()) {
|
||||||
|
// If we are already visible, we are self-hiding
|
||||||
|
_selfHidden = isVisible();
|
||||||
|
setVisible(false);
|
||||||
|
} else {
|
||||||
|
if (_selfHidden) {
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QEvent::ApplicationDeactivate:
|
||||||
|
_selfHidden = isVisible();
|
||||||
|
setVisible(false);
|
||||||
|
break;
|
||||||
|
case QEvent::ApplicationActivate:
|
||||||
|
if (_selfHidden) {
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ToolWindow::onChildVisibilityUpdated(bool visible) {
|
void ToolWindow::onChildVisibilityUpdated(bool visible) {
|
||||||
if (visible) {
|
if (!_selfHidden && visible) {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
bool hasVisible = false;
|
bool hasVisible = false;
|
||||||
|
@ -59,7 +91,10 @@ void ToolWindow::onChildVisibilityUpdated(bool visible) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setVisible(hasVisible);
|
// If a child was hidden and we don't have any children still visible, hide ourself.
|
||||||
|
if (!hasVisible) {
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,15 @@ public:
|
||||||
virtual void addDockWidget(Qt::DockWidgetArea area, QDockWidget* dockWidget, Qt::Orientation orientation);
|
virtual void addDockWidget(Qt::DockWidgetArea area, QDockWidget* dockWidget, Qt::Orientation orientation);
|
||||||
virtual void removeDockWidget(QDockWidget* dockWidget);
|
virtual void removeDockWidget(QDockWidget* dockWidget);
|
||||||
|
|
||||||
|
virtual bool eventFilter(QObject* sender, QEvent* event);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onChildVisibilityUpdated(bool visible);
|
void onChildVisibilityUpdated(bool visible);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Indicates whether this window was hidden by itself (because the main window lost focus).
|
||||||
|
bool _selfHidden;
|
||||||
bool _hasShown;
|
bool _hasShown;
|
||||||
QRect _lastGeometry;
|
QRect _lastGeometry;
|
||||||
};
|
};
|
||||||
|
|
|
@ -69,9 +69,10 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
||||||
xColor color = getColor();
|
xColor color = getColor();
|
||||||
glm::vec3 position = getPosition();
|
glm::vec3 position = getPosition();
|
||||||
|
|
||||||
const int GRID_DIVISIONS = 300;
|
const int MINOR_GRID_DIVISIONS = 100;
|
||||||
|
const int MAJOR_GRID_DIVISIONS = 50;
|
||||||
const float MAX_COLOR = 255.0f;
|
const float MAX_COLOR = 255.0f;
|
||||||
float scale = GRID_DIVISIONS * spacing;
|
|
||||||
|
|
||||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||||
|
|
||||||
|
@ -80,12 +81,13 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
||||||
// Minor grid
|
// Minor grid
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
{
|
{
|
||||||
glTranslatef(_minorGridWidth * (floorf(rotated.x / spacing) - GRID_DIVISIONS / 2),
|
glTranslatef(_minorGridWidth * (floorf(rotated.x / spacing) - MINOR_GRID_DIVISIONS / 2),
|
||||||
spacing * (floorf(rotated.y / spacing) - GRID_DIVISIONS / 2), position.z);
|
spacing * (floorf(rotated.y / spacing) - MINOR_GRID_DIVISIONS / 2), position.z);
|
||||||
|
|
||||||
|
float scale = MINOR_GRID_DIVISIONS * spacing;
|
||||||
glScalef(scale, scale, scale);
|
glScalef(scale, scale, scale);
|
||||||
|
|
||||||
Application::getInstance()->getGeometryCache()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
|
Application::getInstance()->getGeometryCache()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS);
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
@ -94,13 +96,13 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
||||||
{
|
{
|
||||||
glLineWidth(4.0f);
|
glLineWidth(4.0f);
|
||||||
spacing *= _majorGridEvery;
|
spacing *= _majorGridEvery;
|
||||||
glTranslatef(spacing * (floorf(rotated.x / spacing) - GRID_DIVISIONS / 2),
|
glTranslatef(spacing * (floorf(rotated.x / spacing) - MAJOR_GRID_DIVISIONS / 2),
|
||||||
spacing * (floorf(rotated.y / spacing) - GRID_DIVISIONS / 2), position.z);
|
spacing * (floorf(rotated.y / spacing) - MAJOR_GRID_DIVISIONS / 2), position.z);
|
||||||
|
|
||||||
scale *= _majorGridEvery;
|
float scale = MAJOR_GRID_DIVISIONS * spacing;
|
||||||
glScalef(scale, scale, scale);
|
glScalef(scale, scale, scale);
|
||||||
|
|
||||||
Application::getInstance()->getGeometryCache()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
|
Application::getInstance()->getGeometryCache()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS);
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
|
|
@ -484,7 +484,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
dataAt += propertyFlags.getEncodedLength();
|
dataAt += propertyFlags.getEncodedLength();
|
||||||
bytesRead += propertyFlags.getEncodedLength();
|
bytesRead += propertyFlags.getEncodedLength();
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_POSITION, glm::vec3, _position);
|
READ_ENTITY_PROPERTY_SETTER(PROP_POSITION, glm::vec3, updatePosition);
|
||||||
|
|
||||||
// Old bitstreams had PROP_RADIUS, new bitstreams have PROP_DIMENSIONS
|
// Old bitstreams had PROP_RADIUS, new bitstreams have PROP_DIMENSIONS
|
||||||
if (args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_DIMENSIONS) {
|
if (args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_DIMENSIONS) {
|
||||||
|
@ -503,7 +503,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
READ_ENTITY_PROPERTY(PROP_DIMENSIONS, glm::vec3, _dimensions);
|
READ_ENTITY_PROPERTY_SETTER(PROP_DIMENSIONS, glm::vec3, setDimensions);
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
qDebug() << " readEntityDataFromBuffer() NEW FORMAT... look for PROP_DIMENSIONS";
|
qDebug() << " readEntityDataFromBuffer() NEW FORMAT... look for PROP_DIMENSIONS";
|
||||||
}
|
}
|
||||||
|
@ -513,19 +513,19 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
qDebug() << " readEntityDataFromBuffer() _dimensions:" << getDimensionsInMeters() << " in meters";
|
qDebug() << " readEntityDataFromBuffer() _dimensions:" << getDimensionsInMeters() << " in meters";
|
||||||
}
|
}
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY_QUAT(PROP_ROTATION, _rotation);
|
READ_ENTITY_PROPERTY_QUAT_SETTER(PROP_ROTATION, updateRotation);
|
||||||
READ_ENTITY_PROPERTY(PROP_MASS, float, _mass);
|
READ_ENTITY_PROPERTY_SETTER(PROP_MASS, float, updateMass);
|
||||||
READ_ENTITY_PROPERTY(PROP_VELOCITY, glm::vec3, _velocity);
|
READ_ENTITY_PROPERTY_SETTER(PROP_VELOCITY, glm::vec3, updateVelocity);
|
||||||
READ_ENTITY_PROPERTY(PROP_GRAVITY, glm::vec3, _gravity);
|
READ_ENTITY_PROPERTY_SETTER(PROP_GRAVITY, glm::vec3, updateGravity);
|
||||||
READ_ENTITY_PROPERTY(PROP_DAMPING, float, _damping);
|
READ_ENTITY_PROPERTY(PROP_DAMPING, float, _damping);
|
||||||
READ_ENTITY_PROPERTY(PROP_LIFETIME, float, _lifetime);
|
READ_ENTITY_PROPERTY_SETTER(PROP_LIFETIME, float, updateLifetime);
|
||||||
READ_ENTITY_PROPERTY_STRING(PROP_SCRIPT,setScript);
|
READ_ENTITY_PROPERTY_STRING(PROP_SCRIPT,setScript);
|
||||||
READ_ENTITY_PROPERTY(PROP_REGISTRATION_POINT, glm::vec3, _registrationPoint);
|
READ_ENTITY_PROPERTY(PROP_REGISTRATION_POINT, glm::vec3, _registrationPoint);
|
||||||
READ_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, glm::vec3, _angularVelocity);
|
READ_ENTITY_PROPERTY_SETTER(PROP_ANGULAR_VELOCITY, glm::vec3, updateAngularVelocity);
|
||||||
READ_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, float, _angularDamping);
|
READ_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, float, _angularDamping);
|
||||||
READ_ENTITY_PROPERTY(PROP_VISIBLE, bool, _visible);
|
READ_ENTITY_PROPERTY(PROP_VISIBLE, bool, _visible);
|
||||||
READ_ENTITY_PROPERTY(PROP_IGNORE_FOR_COLLISIONS, bool, _ignoreForCollisions);
|
READ_ENTITY_PROPERTY_SETTER(PROP_IGNORE_FOR_COLLISIONS, bool, updateIgnoreForCollisions);
|
||||||
READ_ENTITY_PROPERTY_SETTER(PROP_COLLISIONS_WILL_MOVE, bool, setCollisionsWillMove);
|
READ_ENTITY_PROPERTY_SETTER(PROP_COLLISIONS_WILL_MOVE, bool, updateCollisionsWillMove);
|
||||||
READ_ENTITY_PROPERTY(PROP_LOCKED, bool, _locked);
|
READ_ENTITY_PROPERTY(PROP_LOCKED, bool, _locked);
|
||||||
READ_ENTITY_PROPERTY_STRING(PROP_USER_DATA,setUserData);
|
READ_ENTITY_PROPERTY_STRING(PROP_USER_DATA,setUserData);
|
||||||
|
|
||||||
|
@ -1064,6 +1064,13 @@ void EntityItem::updateCollisionsWillMove(bool value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityItem::updateLifetime(float value) {
|
||||||
|
if (_lifetime != value) {
|
||||||
|
_lifetime = value;
|
||||||
|
_updateFlags |= UPDATE_LIFETIME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_BULLET_PHYSICS
|
#ifdef USE_BULLET_PHYSICS
|
||||||
void EntityItem::destroyMotionState() {
|
void EntityItem::destroyMotionState() {
|
||||||
if (_motionState) {
|
if (_motionState) {
|
||||||
|
|
|
@ -45,10 +45,10 @@ enum EntityUpdateFlags {
|
||||||
UPDATE_MASS = 0x0004,
|
UPDATE_MASS = 0x0004,
|
||||||
UPDATE_COLLISION = 0x0008,
|
UPDATE_COLLISION = 0x0008,
|
||||||
UPDATE_SHAPE = 0x0010,
|
UPDATE_SHAPE = 0x0010,
|
||||||
|
UPDATE_LIFETIME = 0x0020
|
||||||
//UPDATE_APPEARANCE = 0x8000,
|
//UPDATE_APPEARANCE = 0x8000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// EntityItem class this is the base class for all entity types. It handles the basic properties and functionality available
|
/// EntityItem class this is the base class for all entity types. It handles the basic properties and functionality available
|
||||||
/// to all other entity types. In particular: postion, size, rotation, age, lifetime, velocity, gravity. You can not instantiate
|
/// to all other entity types. In particular: postion, size, rotation, age, lifetime, velocity, gravity. You can not instantiate
|
||||||
/// one directly, instead you must only construct one of it's derived classes with additional features.
|
/// one directly, instead you must only construct one of it's derived classes with additional features.
|
||||||
|
@ -290,9 +290,10 @@ public:
|
||||||
void updateAngularVelocity(const glm::vec3& value);
|
void updateAngularVelocity(const glm::vec3& value);
|
||||||
void updateIgnoreForCollisions(bool value);
|
void updateIgnoreForCollisions(bool value);
|
||||||
void updateCollisionsWillMove(bool value);
|
void updateCollisionsWillMove(bool value);
|
||||||
|
void updateLifetime(float value);
|
||||||
|
|
||||||
void setUpdateFlags(uint32_t mask) { _updateFlags |= mask; }
|
uint32_t getUpdateFlags() const { return _updateFlags; }
|
||||||
void clearUpdateFlags(uint32_t mask) { _updateFlags &= ~mask; }
|
void clearUpdateFlags() { _updateFlags = 0; }
|
||||||
|
|
||||||
#ifdef USE_BULLET_PHYSICS
|
#ifdef USE_BULLET_PHYSICS
|
||||||
EntityMotionState* getMotionState() const { return _motionState; }
|
EntityMotionState* getMotionState() const { return _motionState; }
|
||||||
|
|
|
@ -63,6 +63,17 @@
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define READ_ENTITY_PROPERTY_QUAT_SETTER(P,M) \
|
||||||
|
if (propertyFlags.getHasProperty(P)) { \
|
||||||
|
glm::quat fromBuffer; \
|
||||||
|
int bytes = unpackOrientationQuatFromBytes(dataAt, fromBuffer); \
|
||||||
|
dataAt += bytes; \
|
||||||
|
bytesRead += bytes; \
|
||||||
|
if (overwriteLocalData) { \
|
||||||
|
M(fromBuffer); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
#define READ_ENTITY_PROPERTY_STRING(P,O) \
|
#define READ_ENTITY_PROPERTY_STRING(P,O) \
|
||||||
if (propertyFlags.getHasProperty(P)) { \
|
if (propertyFlags.getHasProperty(P)) { \
|
||||||
uint16_t length; \
|
uint16_t length; \
|
||||||
|
|
|
@ -691,13 +691,14 @@ void EntityTree::updateChangedEntities(quint64 now, QSet<EntityItemID>& entities
|
||||||
foreach (EntityItem* thisEntity, _changedEntities) {
|
foreach (EntityItem* thisEntity, _changedEntities) {
|
||||||
// check to see if the lifetime has expired, for immortal entities this is always false
|
// check to see if the lifetime has expired, for immortal entities this is always false
|
||||||
if (thisEntity->lifetimeHasExpired()) {
|
if (thisEntity->lifetimeHasExpired()) {
|
||||||
qDebug() << "Lifetime has expired for thisEntity:" << thisEntity->getEntityItemID();
|
qDebug() << "Lifetime has expired for entity:" << thisEntity->getEntityItemID();
|
||||||
entitiesToDelete << thisEntity->getEntityItemID();
|
entitiesToDelete << thisEntity->getEntityItemID();
|
||||||
clearEntityState(thisEntity);
|
clearEntityState(thisEntity);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Andrew to push changes to physics engine (when we know how to sort the changes)
|
// TODO: Andrew to push changes to physics engine (when we know how to sort the changes)
|
||||||
updateEntityState(thisEntity);
|
updateEntityState(thisEntity);
|
||||||
}
|
}
|
||||||
|
thisEntity->clearUpdateFlags();
|
||||||
}
|
}
|
||||||
_changedEntities.clear();
|
_changedEntities.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -747,8 +747,9 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
||||||
EntityTreeElement* currentContainingElement = _myTree->getContainingElement(entityItemID);
|
EntityTreeElement* currentContainingElement = _myTree->getContainingElement(entityItemID);
|
||||||
|
|
||||||
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
||||||
// TODO: Andrew to only set changed if something has actually changed
|
if (entityItem->getUpdateFlags()) {
|
||||||
_myTree->entityChanged(entityItem);
|
_myTree->entityChanged(entityItem);
|
||||||
|
}
|
||||||
bool bestFitAfter = bestFitEntityBounds(entityItem);
|
bool bestFitAfter = bestFitEntityBounds(entityItem);
|
||||||
|
|
||||||
if (bestFitBefore != bestFitAfter) {
|
if (bestFitBefore != bestFitAfter) {
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
#include "AccountManager.h"
|
#include "AccountManager.h"
|
||||||
|
|
||||||
static const QString HIFI_URL_SCHEME = "hifi";
|
const QString HIFI_URL_SCHEME = "hifi";
|
||||||
|
const QString DEFAULT_HIFI_ADDRESS = "hifi://sandbox";
|
||||||
|
|
||||||
typedef const glm::vec3& (*PositionGetter)();
|
typedef const glm::vec3& (*PositionGetter)();
|
||||||
typedef glm::quat (*OrientationGetter)();
|
typedef glm::quat (*OrientationGetter)();
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#include "HifiSockAddr.h"
|
#include "HifiSockAddr.h"
|
||||||
#include "NetworkPeer.h"
|
#include "NetworkPeer.h"
|
||||||
|
|
||||||
const QString DEFAULT_DOMAIN_HOSTNAME = "sandbox.highfidelity.io";
|
|
||||||
|
|
||||||
const unsigned short DEFAULT_DOMAIN_SERVER_PORT = 40102;
|
const unsigned short DEFAULT_DOMAIN_SERVER_PORT = 40102;
|
||||||
const unsigned short DEFAULT_DOMAIN_SERVER_DTLS_PORT = 40103;
|
const unsigned short DEFAULT_DOMAIN_SERVER_DTLS_PORT = 40103;
|
||||||
const quint16 DOMAIN_SERVER_HTTP_PORT = 40100;
|
const quint16 DOMAIN_SERVER_HTTP_PORT = 40100;
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#define getpid _getpid
|
#define getpid _getpid
|
||||||
|
@ -21,6 +19,7 @@
|
||||||
#include <unistd.h> // for getpid() on linux
|
#include <unistd.h> // for getpid() on linux
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <qdatetime.h>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
|
|
||||||
|
@ -38,6 +37,10 @@ LogHandler::LogHandler() :
|
||||||
QTimer* logFlushTimer = new QTimer(this);
|
QTimer* logFlushTimer = new QTimer(this);
|
||||||
connect(logFlushTimer, &QTimer::timeout, this, &LogHandler::flushRepeatedMessages);
|
connect(logFlushTimer, &QTimer::timeout, this, &LogHandler::flushRepeatedMessages);
|
||||||
logFlushTimer->start(VERBOSE_LOG_INTERVAL_SECONDS * 1000);
|
logFlushTimer->start(VERBOSE_LOG_INTERVAL_SECONDS * 1000);
|
||||||
|
|
||||||
|
// when the log handler is first setup we should print our timezone
|
||||||
|
QString timezoneString = "Time zone: " + QDateTime::currentDateTime().toString("t");
|
||||||
|
printf("%s\n", qPrintable(timezoneString));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* stringForLogType(LogMsgType msgType) {
|
const char* stringForLogType(LogMsgType msgType) {
|
||||||
|
@ -57,8 +60,8 @@ const char* stringForLogType(LogMsgType msgType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the following will produce 2000-10-02 13:55:36 -0700
|
// the following will produce 11/18 13:55:36
|
||||||
const char DATE_STRING_FORMAT[] = "%Y-%m-%d %H:%M:%S %z";
|
const QString DATE_STRING_FORMAT = "MM/dd hh:mm:ss";
|
||||||
|
|
||||||
void LogHandler::flushRepeatedMessages() {
|
void LogHandler::flushRepeatedMessages() {
|
||||||
QHash<QString, int>::iterator message = _repeatMessageCountHash.begin();
|
QHash<QString, int>::iterator message = _repeatMessageCountHash.begin();
|
||||||
|
@ -108,18 +111,11 @@ QString LogHandler::printMessage(LogMsgType type, const QMessageLogContext& cont
|
||||||
}
|
}
|
||||||
|
|
||||||
// log prefix is in the following format
|
// log prefix is in the following format
|
||||||
// [DEBUG] [TIMESTAMP] [PID:PARENT_PID] [TARGET] logged string
|
// [DEBUG] [TIMESTAMP] [PID] [TARGET] logged string
|
||||||
|
|
||||||
QString prefixString = QString("[%1]").arg(stringForLogType(type));
|
QString prefixString = QString("[%1]").arg(stringForLogType(type));
|
||||||
|
|
||||||
time_t rawTime;
|
prefixString.append(QString(" [%1]").arg(QDateTime::currentDateTime().toString(DATE_STRING_FORMAT)));
|
||||||
time(&rawTime);
|
|
||||||
struct tm* localTime = localtime(&rawTime);
|
|
||||||
|
|
||||||
char dateString[100];
|
|
||||||
strftime(dateString, sizeof(dateString), DATE_STRING_FORMAT, localTime);
|
|
||||||
|
|
||||||
prefixString.append(QString(" [%1]").arg(dateString));
|
|
||||||
|
|
||||||
if (_shouldOutputPID) {
|
if (_shouldOutputPID) {
|
||||||
prefixString.append(QString(" [%1").arg(getpid()));
|
prefixString.append(QString(" [%1").arg(getpid()));
|
||||||
|
|
Loading…
Reference in a new issue