Merge branch 'master' of https://github.com/highfidelity/hifi into brown

This commit is contained in:
Sam Cake 2017-04-13 09:51:27 -07:00
commit 3b385772c3
16 changed files with 154 additions and 87 deletions

View file

@ -325,7 +325,7 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) {
_stats.overBudgetAvatars++;
detail = PALIsOpen ? AvatarData::PALMinimum : AvatarData::NoData;
} else if (!isInView) {
detail = PALIsOpen ? AvatarData::PALMinimum : AvatarData::NoData;
detail = PALIsOpen ? AvatarData::PALMinimum : AvatarData::MinimumData;
nodeData->incrementAvatarOutOfView();
} else {
detail = distribution(generator) < AVATAR_SEND_FULL_UPDATE_RATIO

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

View file

@ -91,7 +91,7 @@ Item {
}
MouseArea {
anchors.fill: parent
enabled: (selected || isMyCard) && activeTab == "nearbyTab";
enabled: (selected && activeTab == "nearbyTab") || isMyCard;
hoverEnabled: enabled
onClicked: {
userInfoViewer.url = defaultBaseUrl + "/users/" + userName;

View file

@ -1401,6 +1401,13 @@ Rectangle {
var selectedIDs = getSelectedConnectionsUserNames();
connectionsUserModelData.sort(function (a, b) {
var aValue = a[sortProperty].toString().toLowerCase(), bValue = b[sortProperty].toString().toLowerCase();
if (!aValue && !bValue) {
return 0;
} else if (!aValue) {
return after;
} else if (!bValue) {
return before;
}
switch (true) {
case (aValue < bValue): return before;
case (aValue > bValue): return after;

View file

@ -6417,7 +6417,7 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa
// If we're not doing an animated snapshot as well...
if (!includeAnimated || !(SnapshotAnimated::alsoTakeAnimatedSnapshot.get())) {
// Tell the dependency manager that the capture of the still snapshot has taken place.
emit DependencyManager::get<WindowScriptingInterface>()->snapshotTaken(path, "", notify);
emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(path, notify);
} else {
// Get an animated GIF snapshot and save it
SnapshotAnimated::saveSnapshotAnimated(path, aspectRatio, qApp, DependencyManager::get<WindowScriptingInterface>());

View file

@ -77,7 +77,7 @@ void Head::simulate(float deltaTime, bool isMine) {
float audioLoudness = 0.0f;
if (_owningAvatar) {
_owningAvatar->getAudioLoudness();
audioLoudness = _owningAvatar->getAudioLoudness();
}
// Update audio trailing average for rendering facial animations

View file

@ -240,8 +240,8 @@ void SkeletonModel::updateAttitude() {
// Called by Avatar::simulate after it has set the joint states (fullUpdate true if changed),
// but just before head has been simulated.
void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
updateAttitude();
if (fullUpdate) {
updateAttitude();
setBlendshapeCoefficients(_owningAvatar->getHead()->getBlendshapeCoefficients());
Model::simulate(deltaTime, fullUpdate);

View file

@ -71,9 +71,10 @@ signals:
void domainChanged(const QString& domainHostname);
void svoImportRequested(const QString& url);
void domainConnectionRefused(const QString& reasonMessage, int reasonCode, const QString& extraInfo);
void snapshotTaken(const QString& pathStillSnapshot, const QString& pathAnimatedSnapshot, bool notify);
void stillSnapshotTaken(const QString& pathStillSnapshot, bool notify);
void snapshotShared(const QString& error);
void processingGif();
void processingGifStarted(const QString& pathStillSnapshot);
void processingGifCompleted(const QString& pathAnimatedSnapshot);
void connectionAdded(const QString& connectionName);
void connectionError(const QString& errorString);

View file

@ -86,7 +86,8 @@ void SnapshotAnimated::captureFrames() {
SnapshotAnimated::snapshotAnimatedTimerRunning = false;
// Notify the user that we're processing the snapshot
emit SnapshotAnimated::snapshotAnimatedDM->processingGif();
// This also pops up the "Share" dialog. The unprocessed GIF will be visualized as a loading icon until processingGifCompleted() is called.
emit SnapshotAnimated::snapshotAnimatedDM->processingGifStarted(SnapshotAnimated::snapshotStillPath);
// Kick off the thread that'll pack the frames into the GIF
QtConcurrent::run(processFrames);
@ -132,7 +133,7 @@ void SnapshotAnimated::processFrames() {
// Reset the current frame timestamp
SnapshotAnimated::snapshotAnimatedTimestamp = 0;
SnapshotAnimated::snapshotAnimatedFirstFrameTimestamp = 0;
// Let the window scripting interface know that the snapshots have been taken.
emit SnapshotAnimated::snapshotAnimatedDM->snapshotTaken(SnapshotAnimated::snapshotStillPath, SnapshotAnimated::snapshotAnimatedPath, false);
// Update the "Share" dialog with the processed GIF.
emit SnapshotAnimated::snapshotAnimatedDM->processingGifCompleted(SnapshotAnimated::snapshotAnimatedPath);
}

View file

@ -71,7 +71,7 @@ public:
void addSample(T sample) {
if (numSamples > 0) {
average = ((float)sample * WEIGHTING) + ((float)average * ONE_MINUS_WEIGHTING);
average = (sample * WEIGHTING) + (average * ONE_MINUS_WEIGHTING);
} else {
average = sample;
}

View file

@ -24,7 +24,6 @@
Q_DECLARE_LOGGING_CATEGORY(inputplugins)
Q_LOGGING_CATEGORY(inputplugins, "hifi.inputplugins")
const char* KinectPlugin::NAME = "Kinect";
const char* KinectPlugin::KINECT_ID_STRING = "Kinect";
@ -493,11 +492,23 @@ void KinectPlugin::ProcessBody(INT64 time, int bodyCount, IBody** bodies) {
//_joints[j].orientation = jointOrientation;
if (joints[j].JointType == JointType_HandRight) {
static const quat kinectToHandRight = glm::angleAxis(-PI / 2.0f, Vectors::UNIT_Y);
_joints[j].orientation = jointOrientation * kinectToHandRight;
// add moving average of orientation quaternion
glm::quat jointSample = jointOrientation * kinectToHandRight;
if (glm::dot(jointSample, _RightHandOrientationAverage.getAverage()) < 0) {
jointSample = -jointSample;
}
_RightHandOrientationAverage.addSample(jointSample);
_joints[j].orientation = glm::normalize(_RightHandOrientationAverage.getAverage());
} else if (joints[j].JointType == JointType_HandLeft) {
// To transform from Kinect to our LEFT Hand.... Postive 90 deg around Y
static const quat kinectToHandLeft = glm::angleAxis(PI / 2.0f, Vectors::UNIT_Y);
_joints[j].orientation = jointOrientation * kinectToHandLeft;
// add moving average of orientation quaternion
glm::quat jointSample = jointOrientation * kinectToHandLeft;
if (glm::dot(jointSample, _LeftHandOrientationAverage.getAverage()) < 0) {
jointSample = -jointSample;
}
_LeftHandOrientationAverage.addSample(jointSample);
_joints[j].orientation = glm::normalize(_LeftHandOrientationAverage.getAverage());
} else {
_joints[j].orientation = jointOrientation;
}
@ -643,4 +654,4 @@ void KinectPlugin::InputDevice::clearState() {
int poseIndex = KinectJointIndexToPoseIndex((KinectJointIndex)i);
_poseStateMap[poseIndex] = controller::Pose();
}
}
}

View file

@ -23,6 +23,7 @@
// Kinect Header files
#include <Kinect.h>
#include <SimpleMovingAverage.h>
// Safe release for interfaces
template<class Interface> inline void SafeRelease(Interface *& pInterfaceToRelease) {
@ -58,6 +59,11 @@ public:
virtual void saveSettings() const override;
virtual void loadSettings() override;
private:
// add variables for moving average
ThreadSafeMovingAverage<glm::quat, 2> _LeftHandOrientationAverage;
ThreadSafeMovingAverage<glm::quat, 2> _RightHandOrientationAverage;
protected:
struct KinectJoint {

View file

@ -29,13 +29,13 @@ var COLORS_TELEPORT_SEAT = {
red: 255,
green: 0,
blue: 170
}
};
var COLORS_TELEPORT_CAN_TELEPORT = {
red: 97,
green: 247,
blue: 255
}
};
var COLORS_TELEPORT_CANNOT_TELEPORT = {
red: 0,
@ -52,7 +52,7 @@ var COLORS_TELEPORT_CANCEL = {
var TELEPORT_CANCEL_RANGE = 1;
var COOL_IN_DURATION = 500;
const handInfo = {
var handInfo = {
right: {
controllerInput: Controller.Standard.RightHand
},
@ -80,7 +80,7 @@ function Trigger(hand) {
this.down = function() {
var down = _this.buttonValue === 1 ? 1.0 : 0.0;
return down
return down;
};
}
@ -90,8 +90,9 @@ var ignoredEntities = [];
var TELEPORTER_STATES = {
IDLE: 'idle',
COOL_IN: 'cool_in',
TARGETTING: 'targetting',
TARGETTING_INVALID: 'targetting_invalid',
}
};
var TARGET = {
NONE: 'none', // Not currently targetting anything
@ -99,7 +100,7 @@ var TARGET = {
INVALID: 'invalid', // The current target is invalid (wall, ceiling, etc.)
SURFACE: 'surface', // The current target is a valid surface
SEAT: 'seat', // The current target is a seat
}
};
function Teleporter() {
var _this = this;
@ -114,8 +115,8 @@ function Teleporter() {
this.updateConnected = null;
this.activeHand = null;
this.telporterMappingInternalName = 'Hifi-Teleporter-Internal-Dev-' + Math.random();
this.teleportMappingInternal = Controller.newMapping(this.telporterMappingInternalName);
this.teleporterMappingInternalName = 'Hifi-Teleporter-Internal-Dev-' + Math.random();
this.teleportMappingInternal = Controller.newMapping(this.teleporterMappingInternalName);
// Setup overlays
this.cancelOverlay = Overlays.addOverlay("model", {
@ -135,11 +136,11 @@ function Teleporter() {
});
this.enableMappings = function() {
Controller.enableMapping(this.telporterMappingInternalName);
Controller.enableMapping(this.teleporterMappingInternalName);
};
this.disableMappings = function() {
Controller.disableMapping(teleporter.telporterMappingInternalName);
Controller.disableMapping(teleporter.teleporterMappingInternalName);
};
this.cleanup = function() {
@ -179,7 +180,7 @@ function Teleporter() {
if (_this.state === TELEPORTER_STATES.COOL_IN) {
_this.state = TELEPORTER_STATES.TARGETTING;
}
}, COOL_IN_DURATION)
}, COOL_IN_DURATION);
this.activeHand = hand;
this.enableMappings();
@ -203,13 +204,13 @@ function Teleporter() {
};
this.deleteOverlayBeams = function() {
for (key in this.overlayLines) {
for (var key in this.overlayLines) {
if (this.overlayLines[key] !== null) {
Overlays.deleteOverlay(this.overlayLines[key]);
this.overlayLines[key] = null;
}
}
}
};
this.update = function() {
if (_this.state === TELEPORTER_STATES.IDLE) {
@ -272,7 +273,8 @@ function Teleporter() {
this.hideCancelOverlay();
this.hideSeatOverlay();
this.updateLineOverlay(_this.activeHand, pickRay.origin, intersection.intersection, COLORS_TELEPORT_CAN_TELEPORT);
this.updateLineOverlay(_this.activeHand, pickRay.origin, intersection.intersection,
COLORS_TELEPORT_CAN_TELEPORT);
this.updateDestinationOverlay(this.targetOverlay, intersection);
}
} else if (teleportLocationType === TARGET.SEAT) {
@ -284,13 +286,15 @@ function Teleporter() {
}
if (((_this.activeHand == 'left' ? leftPad : rightPad).buttonValue === 0) && inTeleportMode === true) {
if (((_this.activeHand === 'left' ? leftPad : rightPad).buttonValue === 0) && inTeleportMode === true) {
// remember the state before we exit teleport mode and set it back to IDLE
var previousState = this.state;
this.exitTeleportMode();
this.hideCancelOverlay();
this.hideTargetOverlay();
this.hideSeatOverlay();
if (teleportLocationType === TARGET.NONE || teleportLocationType === TARGET.INVALID || this.state === TELEPORTER_STATES.COOL_IN) {
if (teleportLocationType === TARGET.NONE || teleportLocationType === TARGET.INVALID || previousState === TELEPORTER_STATES.COOL_IN) {
// Do nothing
} else if (teleportLocationType === TARGET.SEAT) {
Entities.callEntityMethod(intersection.entityID, 'sit');
@ -321,7 +325,7 @@ function Teleporter() {
this.overlayLines[hand] = Overlays.addOverlay("line3d", lineProperties);
} else {
var success = Overlays.editOverlay(this.overlayLines[hand], {
Overlays.editOverlay(this.overlayLines[hand], {
start: closePoint,
end: farPoint,
color: color
@ -361,7 +365,7 @@ function Teleporter() {
};
}
//related to repositioning the avatar after you teleport
// related to repositioning the avatar after you teleport
function getAvatarFootOffset() {
var data = getJointData();
var upperLeg, lowerLeg, foot, toe, toeTop;
@ -384,14 +388,14 @@ function getAvatarFootOffset() {
var offset = upperLeg + lowerLeg + foot + toe + toeTop;
offset = offset / 100;
return offset;
};
}
function getJointData() {
var allJointData = [];
var jointNames = MyAvatar.jointNames;
jointNames.forEach(function(joint, index) {
var translation = MyAvatar.getJointTranslation(index);
var rotation = MyAvatar.getJointRotation(index)
var rotation = MyAvatar.getJointRotation(index);
allJointData.push({
joint: joint,
index: index,
@ -401,7 +405,7 @@ function getJointData() {
});
return allJointData;
};
}
var leftPad = new ThumbPad('left');
var rightPad = new ThumbPad('right');
@ -420,7 +424,7 @@ function isMoving() {
} else {
return false;
}
};
}
function parseJSON(json) {
try {
@ -433,7 +437,7 @@ function parseJSON(json) {
// point that is being intersected with is looked at. If this normal is more
// than MAX_ANGLE_FROM_UP_TO_TELEPORT degrees from <0, 1, 0> (straight up), then
// you can't teleport there.
const MAX_ANGLE_FROM_UP_TO_TELEPORT = 70;
var MAX_ANGLE_FROM_UP_TO_TELEPORT = 70;
function getTeleportTargetType(intersection) {
if (!intersection.intersects) {
return TARGET.NONE;
@ -465,7 +469,7 @@ function getTeleportTargetType(intersection) {
} else {
return TARGET.SURFACE;
}
};
}
function registerMappings() {
mappingName = 'Hifi-Teleporter-Dev-' + Math.random();
@ -487,7 +491,7 @@ function registerMappings() {
if (isMoving() === true) {
return;
}
teleporter.enterTeleportMode('left')
teleporter.enterTeleportMode('left');
return;
});
teleportMapping.from(Controller.Standard.RightPrimaryThumb)
@ -502,10 +506,10 @@ function registerMappings() {
return;
}
teleporter.enterTeleportMode('right')
teleporter.enterTeleportMode('right');
return;
});
};
}
registerMappings();
@ -521,7 +525,6 @@ Script.scriptEnding.connect(cleanup);
var isDisabled = false;
var handleTeleportMessages = function(channel, message, sender) {
var data;
if (sender === MyAvatar.sessionUUID) {
if (channel === 'Hifi-Teleport-Disabler') {
if (message === 'both') {
@ -531,7 +534,7 @@ var handleTeleportMessages = function(channel, message, sender) {
isDisabled = 'left';
}
if (message === 'right') {
isDisabled = 'right'
isDisabled = 'right';
}
if (message === 'none') {
isDisabled = false;
@ -545,7 +548,7 @@ var handleTeleportMessages = function(channel, message, sender) {
}
}
}
}
};
Messages.subscribe('Hifi-Teleport-Disabler');
Messages.subscribe('Hifi-Teleport-Ignore-Add');

View file

@ -21,6 +21,7 @@ function addImage(data) {
img = document.createElement("IMG"),
div2 = document.createElement("DIV"),
id = "p" + idCounter++;
img.id = id + "img";
function toggle() { data.share = input.checked; }
div.style.height = "" + Math.floor(100 / imageCount) + "%";
if (imageCount > 1) {
@ -33,7 +34,7 @@ function addImage(data) {
label.setAttribute('for', id); // cannot do label.for =
input.id = id;
input.type = "checkbox";
input.checked = (id === "p0");
input.checked = false;
data.share = input.checked;
input.addEventListener('change', toggle);
div2.setAttribute("class", "property checkbox");
@ -46,9 +47,9 @@ function addImage(data) {
document.getElementById("snapshot-images").appendChild(div);
paths.push(data);
}
function handleShareButtons(shareMsg) {
function handleShareButtons(messageOptions) {
var openFeed = document.getElementById('openFeed');
openFeed.checked = shareMsg.openFeedAfterShare;
openFeed.checked = messageOptions.openFeedAfterShare;
openFeed.onchange = function () {
EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot",
@ -56,7 +57,7 @@ function handleShareButtons(shareMsg) {
}));
};
if (!shareMsg.canShare) {
if (!messageOptions.canShare) {
// this means you may or may not be logged in, but can't share
// because you are not in a public place.
document.getElementById("sharing").innerHTML = "<p class='prompt'>Snapshots can be shared when they're taken in shareable places.";
@ -74,13 +75,26 @@ window.onload = function () {
return;
}
// last element of list contains a bool for whether or not we can share stuff
var shareMsg = message.action.pop();
handleShareButtons(shareMsg);
// rest are image paths which we add
imageCount = message.action.length;
message.action.forEach(addImage);
// The last element of the message contents list contains a bunch of options,
// including whether or not we can share stuff
// The other elements of the list contain image paths.
var messageOptions = message.action.pop();
handleShareButtons(messageOptions);
if (messageOptions.containsGif) {
if (messageOptions.processingGif) {
imageCount = message.action.length + 1; // "+1" for the GIF that'll finish processing soon
message.action.unshift({ localPath: '../../../resources/icons/loadingDark.gif' });
message.action.forEach(addImage);
document.getElementById('p0').disabled = true;
} else {
document.getElementById('p0').disabled = false;
document.getElementById('p0img').src = message.action[0].localPath;
}
} else {
imageCount = message.action.length;
message.action.forEach(addImage);
}
});
EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot",

View file

@ -532,7 +532,7 @@ function onNotify(msg) {
createNotification(wordWrap(msg), NotificationType.UNKNOWN); // Needs a generic notification system for user feedback, thus using this
}
function onSnapshotTaken(pathStillSnapshot, pathAnimatedSnapshot, notify) {
function onSnapshotTaken(pathStillSnapshot, notify) {
if (notify) {
var imageProperties = {
path: "file:///" + pathStillSnapshot,
@ -656,8 +656,8 @@ Script.update.connect(update);
Script.scriptEnding.connect(scriptEnding);
Menu.menuItemEvent.connect(menuItemEvent);
Window.domainConnectionRefused.connect(onDomainConnectionRefused);
Window.snapshotTaken.connect(onSnapshotTaken);
Window.processingGif.connect(processingGif);
Window.stillSnapshotTaken.connect(onSnapshotTaken);
Window.processingGifStarted.connect(processingGif);
Window.connectionAdded.connect(connectionAdded);
Window.connectionError.connect(connectionError);
Window.notifyEditError = onEditError;

View file

@ -157,7 +157,9 @@ function onClicked() {
resetOverlays = Menu.isOptionChecked("Overlays"); // For completness. Certainly true if the button is visible to be clicke.
reticleVisible = Reticle.visible;
Reticle.visible = false;
Window.snapshotTaken.connect(resetButtons);
Window.stillSnapshotTaken.connect(stillSnapshotTaken);
Window.processingGifStarted.connect(processingGifStarted);
Window.processingGifCompleted.connect(processingGifCompleted);
// hide overlays if they are on
if (resetOverlays) {
@ -193,25 +195,14 @@ function isDomainOpen(id) {
response.total_entries;
}
function resetButtons(pathStillSnapshot, pathAnimatedSnapshot, notify) {
// If we're not taking an animated snapshot, we have to show the HUD.
// If we ARE taking an animated snapshot, we've already re-enabled the HUD by this point.
if (pathAnimatedSnapshot === "") {
// show hud
Reticle.visible = reticleVisible;
// show overlays if they were on
if (resetOverlays) {
Menu.setIsOptionChecked("Overlays", true);
}
} else {
// Allow the user to click the snapshot HUD button again
if (!buttonConnected) {
button.clicked.connect(onClicked);
buttonConnected = true;
}
function stillSnapshotTaken(pathStillSnapshot, notify) {
// show hud
Reticle.visible = reticleVisible;
// show overlays if they were on
if (resetOverlays) {
Menu.setIsOptionChecked("Overlays", true);
}
Window.snapshotTaken.disconnect(resetButtons);
Window.stillSnapshotTaken.disconnect(stillSnapshotTaken);
// A Snapshot Review dialog might be left open indefinitely after taking the picture,
// during which time the user may have moved. So stash that info in the dialog so that
@ -220,12 +211,11 @@ function resetButtons(pathStillSnapshot, pathAnimatedSnapshot, notify) {
var confirmShareContents = [
{ localPath: pathStillSnapshot, href: href },
{
containsGif: false,
processingGif: false,
canShare: !!isDomainOpen(domainId),
openFeedAfterShare: shouldOpenFeedAfterShare()
}];
if (pathAnimatedSnapshot !== "") {
confirmShareContents.unshift({ localPath: pathAnimatedSnapshot, href: href });
}
confirmShare(confirmShareContents);
if (clearOverlayWhenMoving) {
MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog
@ -233,15 +223,51 @@ function resetButtons(pathStillSnapshot, pathAnimatedSnapshot, notify) {
HMD.openTablet();
}
function processingGif() {
// show hud
Reticle.visible = reticleVisible;
function processingGifStarted(pathStillSnapshot) {
Window.processingGifStarted.disconnect(processingGifStarted);
button.clicked.disconnect(onClicked);
buttonConnected = false;
// show hud
Reticle.visible = reticleVisible;
// show overlays if they were on
if (resetOverlays) {
Menu.setIsOptionChecked("Overlays", true);
}
var confirmShareContents = [
{ localPath: pathStillSnapshot, href: href },
{
containsGif: true,
processingGif: true,
canShare: !!isDomainOpen(domainId),
openFeedAfterShare: shouldOpenFeedAfterShare()
}];
confirmShare(confirmShareContents);
if (clearOverlayWhenMoving) {
MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog
}
HMD.openTablet();
}
function processingGifCompleted(pathAnimatedSnapshot) {
Window.processingGifCompleted.disconnect(processingGifCompleted);
button.clicked.connect(onClicked);
buttonConnected = true;
var confirmShareContents = [
{ localPath: pathAnimatedSnapshot, href: href },
{
containsGif: true,
processingGif: false,
canShare: !!isDomainOpen(domainId),
openFeedAfterShare: shouldOpenFeedAfterShare()
}];
readyData = confirmShareContents;
tablet.emitScriptEvent(JSON.stringify({
type: "snapshot",
action: readyData
}));
}
function onTabletScreenChanged(type, url) {
@ -265,7 +291,6 @@ function onConnected() {
button.clicked.connect(onClicked);
buttonConnected = true;
Window.snapshotShared.connect(snapshotShared);
Window.processingGif.connect(processingGif);
tablet.screenChanged.connect(onTabletScreenChanged);
Account.usernameChanged.connect(onConnected);
Script.scriptEnding.connect(function () {
@ -277,7 +302,6 @@ Script.scriptEnding.connect(function () {
tablet.removeButton(button);
}
Window.snapshotShared.disconnect(snapshotShared);
Window.processingGif.disconnect(processingGif);
tablet.screenChanged.disconnect(onTabletScreenChanged);
});