Merge branch 'protocol' of github.com:birarda/hifi into control-pair-probe

This commit is contained in:
Stephen Birarda 2015-08-31 16:07:27 -06:00
commit adad752860
32 changed files with 828 additions and 247 deletions

View file

@ -125,39 +125,43 @@ void AssetServer::handleAssetGetInfo(QSharedPointer<NLPacket> packet, SharedNode
} }
void AssetServer::handleAssetGet(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode) { void AssetServer::handleAssetGet(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode) {
MessageID messageID;
QByteArray assetHash;
uint8_t extensionLength;
DataOffset start;
DataOffset end;
auto minSize = qint64(sizeof(messageID) + SHA256_HASH_LENGTH + sizeof(extensionLength) + sizeof(start) + sizeof(end)); auto minSize = qint64(sizeof(MessageID) + SHA256_HASH_LENGTH + sizeof(uint8_t) + sizeof(DataOffset) + sizeof(DataOffset));
if (packet->getPayloadSize() < minSize) { if (packet->getPayloadSize() < minSize) {
qDebug() << "ERROR bad file request"; qDebug() << "ERROR bad file request";
return; return;
} }
packet->readPrimitive(&messageID);
assetHash = packet->read(SHA256_HASH_LENGTH);
packet->readPrimitive(&extensionLength);
QByteArray extension = packet->read(extensionLength);
packet->readPrimitive(&start);
packet->readPrimitive(&end);
QByteArray hexHash = assetHash.toHex();
qDebug() << "Received a request for the file (" << messageID << "): " << hexHash << " from " << start << " to " << end;
// Queue task // Queue task
QString filePath = _resourcesDirectory.filePath(QString(hexHash) + "." + QString(extension)); auto task = new SendAssetTask(packet, senderNode, _resourcesDirectory);
auto task = new SendAssetTask(messageID, assetHash, filePath, start, end, senderNode);
_taskPool.start(task); _taskPool.start(task);
} }
void AssetServer::handleAssetUpload(QSharedPointer<NLPacketList> packetList, SharedNodePointer senderNode) { void AssetServer::handleAssetUpload(QSharedPointer<NLPacketList> packetList, SharedNodePointer senderNode) {
qDebug() << "Starting an UploadAssetTask for upload from" << uuidStringWithoutCurlyBraces(senderNode->getUUID());
auto task = new UploadAssetTask(packetList, senderNode, _resourcesDirectory); if (senderNode->getCanRez()) {
_taskPool.start(task); qDebug() << "Starting an UploadAssetTask for upload from" << uuidStringWithoutCurlyBraces(senderNode->getUUID());
auto task = new UploadAssetTask(packetList, senderNode, _resourcesDirectory);
_taskPool.start(task);
} else {
// this is a node the domain told us is not allowed to rez entities
// for now this also means it isn't allowed to add assets
// so return a packet with error that indicates that
auto permissionErrorPacket = NLPacket::create(PacketType::AssetUploadReply, sizeof(MessageID) + sizeof(AssetServerError));
MessageID messageID;
packetList->readPrimitive(&messageID);
// write the message ID and a permission denied error
permissionErrorPacket->writePrimitive(messageID);
permissionErrorPacket->writePrimitive(AssetServerError::PERMISSION_DENIED);
// send off the packet
auto nodeList = DependencyManager::get<NodeList>();
nodeList->sendPacket(std::move(permissionErrorPacket), *senderNode);
}
} }

View file

@ -18,42 +18,56 @@
#include <NLPacket.h> #include <NLPacket.h>
#include <NLPacketList.h> #include <NLPacketList.h>
#include <NodeList.h> #include <NodeList.h>
#include <udt/Packet.h>
#include "AssetUtils.h" #include "AssetUtils.h"
SendAssetTask::SendAssetTask(MessageID messageID, const QByteArray& assetHash, QString filePath, DataOffset start, DataOffset end, SendAssetTask::SendAssetTask(QSharedPointer<NLPacket> packet, const SharedNodePointer& sendToNode, const QDir& resourcesDir) :
const SharedNodePointer& sendToNode) :
QRunnable(), QRunnable(),
_messageID(messageID), _packet(packet),
_assetHash(assetHash), _senderNode(sendToNode),
_filePath(filePath), _resourcesDir(resourcesDir)
_start(start),
_end(end),
_sendToNode(sendToNode)
{ {
} }
void SendAssetTask::run() { void SendAssetTask::run() {
QString hexHash = _assetHash.toHex(); MessageID messageID;
qDebug() << "Starting task to send asset: " << hexHash << " for messageID " << _messageID; uint8_t extensionLength;
DataOffset start, end;
_packet->readPrimitive(&messageID);
QByteArray assetHash = _packet->read(SHA256_HASH_LENGTH);
_packet->readPrimitive(&extensionLength);
QByteArray extension = _packet->read(extensionLength);
_packet->readPrimitive(&start);
_packet->readPrimitive(&end);
QString hexHash = assetHash.toHex();
qDebug() << "Received a request for the file (" << messageID << "): " << hexHash << " from " << start << " to " << end;
qDebug() << "Starting task to send asset: " << hexHash << " for messageID " << messageID;
auto replyPacketList = std::unique_ptr<NLPacketList>(new NLPacketList(PacketType::AssetGetReply, QByteArray(), true, true)); auto replyPacketList = std::unique_ptr<NLPacketList>(new NLPacketList(PacketType::AssetGetReply, QByteArray(), true, true));
replyPacketList->write(_assetHash); replyPacketList->write(assetHash);
replyPacketList->writePrimitive(_messageID); replyPacketList->writePrimitive(messageID);
if (_end <= _start) { if (end <= start) {
writeError(replyPacketList.get(), AssetServerError::INVALID_BYTE_RANGE); writeError(replyPacketList.get(), AssetServerError::INVALID_BYTE_RANGE);
} else { } else {
QFile file { _filePath }; QString filePath = _resourcesDir.filePath(QString(hexHash) + "." + QString(extension));
QFile file { filePath };
if (file.open(QIODevice::ReadOnly)) { if (file.open(QIODevice::ReadOnly)) {
if (file.size() < _end) { if (file.size() < end) {
writeError(replyPacketList.get(), AssetServerError::INVALID_BYTE_RANGE); writeError(replyPacketList.get(), AssetServerError::INVALID_BYTE_RANGE);
qCDebug(networking) << "Bad byte range: " << hexHash << " " << _start << ":" << _end; qCDebug(networking) << "Bad byte range: " << hexHash << " " << start << ":" << end;
} else { } else {
auto size = _end - _start; auto size = end - start;
file.seek(_start); file.seek(start);
replyPacketList->writePrimitive(AssetServerError::NO_ERROR); replyPacketList->writePrimitive(AssetServerError::NO_ERROR);
replyPacketList->writePrimitive(size); replyPacketList->writePrimitive(size);
replyPacketList->write(file.read(size)); replyPacketList->write(file.read(size));
@ -61,11 +75,11 @@ void SendAssetTask::run() {
} }
file.close(); file.close();
} else { } else {
qCDebug(networking) << "Asset not found: " << _filePath << "(" << hexHash << ")"; qCDebug(networking) << "Asset not found: " << filePath << "(" << hexHash << ")";
writeError(replyPacketList.get(), AssetServerError::ASSET_NOT_FOUND); writeError(replyPacketList.get(), AssetServerError::ASSET_NOT_FOUND);
} }
} }
auto nodeList = DependencyManager::get<NodeList>(); auto nodeList = DependencyManager::get<NodeList>();
nodeList->sendPacketList(std::move(replyPacketList), *_sendToNode); nodeList->sendPacketList(std::move(replyPacketList), *_senderNode);
} }

View file

@ -12,28 +12,27 @@
#ifndef hifi_SendAssetTask_h #ifndef hifi_SendAssetTask_h
#define hifi_SendAssetTask_h #define hifi_SendAssetTask_h
#include <QByteArray> #include <QtCore/QByteArray>
#include <QString> #include <QtCore/QSharedPointer>
#include <QRunnable> #include <QtCore/QString>
#include <QtCore/QRunnable>
#include "AssetUtils.h" #include "AssetUtils.h"
#include "AssetServer.h" #include "AssetServer.h"
#include "Node.h" #include "Node.h"
class NLPacket;
class SendAssetTask : public QRunnable { class SendAssetTask : public QRunnable {
public: public:
SendAssetTask(MessageID messageID, const QByteArray& assetHash, QString filePath, DataOffset start, DataOffset end, SendAssetTask(QSharedPointer<NLPacket> packet, const SharedNodePointer& sendToNode, const QDir& resourcesDir);
const SharedNodePointer& sendToNode);
void run(); void run();
private: private:
MessageID _messageID; QSharedPointer<NLPacket> _packet;
QByteArray _assetHash; SharedNodePointer _senderNode;
QString _filePath; QDir _resourcesDir;
DataOffset _start;
DataOffset _end;
SharedNodePointer _sendToNode;
}; };
#endif #endif

View file

@ -37,25 +37,6 @@ void UploadAssetTask::run() {
MessageID messageID; MessageID messageID;
buffer.read(reinterpret_cast<char*>(&messageID), sizeof(messageID)); buffer.read(reinterpret_cast<char*>(&messageID), sizeof(messageID));
if (!_senderNode->getCanRez()) {
// this is a node the domain told us is not allowed to rez entities
// for now this also means it isn't allowed to add assets
// so return a packet with error that indicates that
auto permissionErrorPacket = NLPacket::create(PacketType::AssetUploadReply, sizeof(MessageID) + sizeof(AssetServerError));
// write the message ID and a permission denied error
permissionErrorPacket->writePrimitive(messageID);
permissionErrorPacket->writePrimitive(AssetServerError::PERMISSION_DENIED);
// send off the packet
auto nodeList = DependencyManager::get<NodeList>();
nodeList->sendPacket(std::move(permissionErrorPacket), *_senderNode);
// return so we're not attempting to handle upload
return;
}
uint8_t extensionLength; uint8_t extensionLength;
buffer.read(reinterpret_cast<char*>(&extensionLength), sizeof(extensionLength)); buffer.read(reinterpret_cast<char*>(&extensionLength), sizeof(extensionLength));

View file

@ -0,0 +1,582 @@
//
// breakdanceToy.js
// examples
//
// Created by Brad Hefta-Gaub on August 24, 2015
// Copyright 2015 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
//
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
// helpers
// Computes the penetration between a point and a sphere (centered at the origin)
// if point is inside sphere: returns true and stores the result in 'penetration'
// (the vector that would move the point outside the sphere)
// otherwise returns false
function findSphereHit(point, sphereRadius) {
var EPSILON = 0.000001; //smallish positive number - used as margin of error for some computations
var vectorLength = Vec3.length(point);
if (vectorLength < EPSILON) {
return true;
}
var distance = vectorLength - sphereRadius;
if (distance < 0.0) {
return true;
}
return false;
}
function findSpherePointHit(sphereCenter, sphereRadius, point) {
return findSphereHit(Vec3.subtract(point,sphereCenter), sphereRadius);
}
function findSphereSphereHit(firstCenter, firstRadius, secondCenter, secondRadius) {
return findSpherePointHit(firstCenter, firstRadius + secondRadius, secondCenter);
}
function getPositionPuppet() {
var DISTANCE_IN_FRONT = 2;
var DISTANCE_UP = 0.4;
var DISTANCE_TO_SIDE = 0.0;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var left = Vec3.multiply(right, -1);
var upOffset = Vec3.multiply(up, DISTANCE_UP);
var leftOffset = Vec3.multiply(left, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(leftOffset, frontOffset), upOffset);
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
function getPositionLeftFront() {
var DISTANCE_IN_FRONT = 0.6;
var DISTANCE_UP = 0.4;
var DISTANCE_TO_SIDE = 0.3;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var left = Vec3.multiply(right, -1);
var upOffset = Vec3.multiply(up, DISTANCE_UP);
var leftOffset = Vec3.multiply(left, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(leftOffset, frontOffset), upOffset);
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
function getPositionLeftSide() {
var DISTANCE_IN_FRONT = 0.0;
var DISTANCE_UP = 0.5;
var DISTANCE_TO_SIDE = 0.9;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var left = Vec3.multiply(right, -1);
var upOffset = Vec3.multiply(up, DISTANCE_UP);
var leftOffset = Vec3.multiply(left, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(leftOffset, frontOffset), upOffset);
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
function getPositionLeftOverhead() {
var DISTANCE_IN_FRONT = 0.2;
var DISTANCE_UP = 1;
var DISTANCE_TO_SIDE = 0.3;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var left = Vec3.multiply(right, -1);
var upOffset = Vec3.multiply(up, DISTANCE_UP);
var leftOffset = Vec3.multiply(left, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(leftOffset, frontOffset), upOffset);
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
function getPositionLeftLowered() {
var DISTANCE_IN_FRONT = 0.2;
var DISTANCE_DOWN = 0.1;
var DISTANCE_TO_SIDE = 0.3;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var left = Vec3.multiply(right, -1);
var downOffset = Vec3.multiply(up, DISTANCE_DOWN);
var leftOffset = Vec3.multiply(left, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(leftOffset, frontOffset), downOffset );
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
function getPositionLeftOnBase() {
var DISTANCE_IN_FRONT = 0.2;
var DISTANCE_DOWN = -0.4;
var DISTANCE_TO_SIDE = 0.3;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var left = Vec3.multiply(right, -1);
var downOffset = Vec3.multiply(up, DISTANCE_DOWN);
var leftOffset = Vec3.multiply(left, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(leftOffset, frontOffset), downOffset );
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
function getPositionRightFront() {
var DISTANCE_IN_FRONT = 0.6;
var DISTANCE_UP = 0.4;
var DISTANCE_TO_SIDE = 0.3;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var upOffset = Vec3.multiply(up, DISTANCE_UP);
var rightOffset = Vec3.multiply(right, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(rightOffset, frontOffset), upOffset);
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
function getPositionRightSide() {
var DISTANCE_IN_FRONT = 0.0;
var DISTANCE_UP = 0.5;
var DISTANCE_TO_SIDE = 0.9;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var upOffset = Vec3.multiply(up, DISTANCE_UP);
var rightOffset = Vec3.multiply(right, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(rightOffset, frontOffset), upOffset);
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
function getPositionRightOverhead() {
var DISTANCE_IN_FRONT = 0.2;
var DISTANCE_UP = 1;
var DISTANCE_TO_SIDE = 0.3;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var upOffset = Vec3.multiply(up, DISTANCE_UP);
var rightOffset = Vec3.multiply(right, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(rightOffset, frontOffset), upOffset);
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
function getPositionRightLowered() {
var DISTANCE_IN_FRONT = 0.2;
var DISTANCE_DOWN = 0.1;
var DISTANCE_TO_SIDE = 0.3;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var downOffset = Vec3.multiply(up, DISTANCE_DOWN);
var rightOffset = Vec3.multiply(right, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(rightOffset, frontOffset), downOffset );
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
function getPositionRightOnBase() {
var DISTANCE_IN_FRONT = 0.2;
var DISTANCE_DOWN = -0.4;
var DISTANCE_TO_SIDE = 0.3;
var up = Quat.getUp(MyAvatar.orientation);
var front = Quat.getFront(MyAvatar.orientation);
var right = Quat.getRight(MyAvatar.orientation);
var downOffset = Vec3.multiply(up, DISTANCE_DOWN);
var rightOffset = Vec3.multiply(right, DISTANCE_TO_SIDE);
var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
var offset = Vec3.sum(Vec3.sum(rightOffset, frontOffset), downOffset );
var position = Vec3.sum(MyAvatar.position, offset);
return position;
}
// We will also demonstrate some 3D overlays. We will create a couple of cubes, spheres, and lines
// our 3D cube that moves around...
var handSize = 0.25;
var leftCubePosition = MyAvatar.getLeftPalmPosition();
var rightCubePosition = MyAvatar.getRightPalmPosition();
var text = Overlays.addOverlay("text", {
x: 100,
y: 300,
width: 900,
height: 50,
backgroundColor: { red: 0, green: 0, blue: 0},
color: { red: 255, green: 255, blue: 255},
topMargin: 4,
leftMargin: 4,
text: "POSE...",
alpha: 1,
backgroundAlpha: 0.5
});
var leftHand= Overlays.addOverlay("cube", {
position: leftCubePosition,
size: handSize,
color: { red: 0, green: 0, blue: 255},
alpha: 1,
solid: false
});
var rightHand= Overlays.addOverlay("cube", {
position: rightCubePosition,
size: handSize,
color: { red: 255, green: 0, blue: 0},
alpha: 1,
solid: false
});
var targetSize = 0.3;
var targetColor = { red: 128, green: 128, blue: 128};
var targetColorHit = { red: 0, green: 255, blue: 0};
var moveCycleColor = { red: 255, green: 255, blue: 0};
var TEMPORARY_LIFETIME = 60;
var animationSettings = JSON.stringify({
fps: 30,
running: true,
loop: true,
firstFrame: 1,
lastFrame: 10000
});
var naturalDimensions = { x: 1.63, y: 1.67, z: 0.31 };
var dimensions = Vec3.multiply(naturalDimensions, 0.3);
var puppetEntityID = Entities.addEntity({
type: "Model",
modelURL: "https://hifi-public.s3.amazonaws.com/models/Bboys/bboy1/bboy1.fbx",
animationURL: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx",
animationSettings: animationSettings,
position: getPositionPuppet(),
ignoreForCollisions: true,
dimensions: dimensions,
lifetime: TEMPORARY_LIFETIME
});
var leftOnBase = Overlays.addOverlay("cube", {
position: getPositionLeftOnBase(),
size: targetSize,
color: targetColor,
alpha: 1,
solid: false
});
var leftLowered = Overlays.addOverlay("cube", {
position: getPositionLeftLowered(),
size: targetSize,
color: targetColor,
alpha: 1,
solid: false
});
var leftOverhead = Overlays.addOverlay("cube", {
position: getPositionLeftOverhead(),
size: targetSize,
color: targetColor,
alpha: 1,
solid: false
});
var leftSide= Overlays.addOverlay("cube", {
position: getPositionLeftSide(),
size: targetSize,
color: targetColor,
alpha: 1,
solid: false
});
var leftFront= Overlays.addOverlay("cube", {
position: getPositionLeftFront(),
size: targetSize,
color: targetColor,
alpha: 1,
solid: false
});
var rightOnBase = Overlays.addOverlay("cube", {
position: getPositionRightOnBase(),
size: targetSize,
color: targetColor,
alpha: 1,
solid: false
});
var rightLowered = Overlays.addOverlay("cube", {
position: getPositionRightLowered(),
size: targetSize,
color: targetColor,
alpha: 1,
solid: false
});
var rightOverhead = Overlays.addOverlay("cube", {
position: getPositionRightOverhead(),
size: targetSize,
color: targetColor,
alpha: 1,
solid: false
});
var rightSide= Overlays.addOverlay("cube", {
position: getPositionRightSide(),
size: targetSize,
color: targetColor,
alpha: 1,
solid: false
});
var rightFront= Overlays.addOverlay("cube", {
position: getPositionRightFront(),
size: targetSize,
color: targetColor,
alpha: 1,
solid: false
});
var startDate = new Date();
var lastTime = startDate.getTime();
var NO_POSE = 0;
var LEFT_ON_BASE = 1;
var LEFT_OVERHEAD = 2;
var LEFT_LOWERED = 4;
var LEFT_SIDE = 8;
var LEFT_FRONT = 16;
var RIGHT_ON_BASE = 32;
var RIGHT_OVERHEAD = 64;
var RIGHT_LOWERED = 128;
var RIGHT_SIDE = 256;
var RIGHT_FRONT = 512;
var lastPoseValue = NO_POSE;
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/bboy_pose_to_idle.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/bboy_uprock.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/bboy_uprock_start.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_footwork_1.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_footwork_2.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_footwork_3.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_footwork_to_freeze.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_footwork_to_idle.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_freeze_var_1.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_freeze_var_2.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_freeze_var_3.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_freeze_var_4.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_freezes.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_swipes.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_uprock.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_uprock_var_1.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_uprock_var_1_end.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_uprock_var_1_start.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_uprock_var_2.fbx
//http://s3.amazonaws.com/hifi-public/animations/Breakdancing/flair.fbx
var poses = Array();
/*
poses[0 ] = { name: "no pose", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_OVERHEAD ] = { name: "Left Overhead" , animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_LOWERED ] = { name: "Left Lowered", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_SIDE ] = { name: "Left Side", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_FRONT ] = { name: "Left Front", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[RIGHT_OVERHEAD ] = { name: "Right Overhead", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[RIGHT_LOWERED ] = { name: "Right Lowered", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[RIGHT_SIDE ] = { name: "Right Side", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[RIGHT_FRONT ] = { name: "Right Front", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
*/
poses[LEFT_ON_BASE + RIGHT_ON_BASE ] = { name: "Left On Base + Right On Base", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_OVERHEAD + RIGHT_ON_BASE ] = { name: "Left Overhead + Right On Base", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_LOWERED + RIGHT_ON_BASE ] = { name: "Left Lowered + Right On Base", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_SIDE + RIGHT_ON_BASE ] = { name: "Left Side + Right On Base", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_FRONT + RIGHT_ON_BASE ] = { name: "Left Front + Right On Base", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_ON_BASE + RIGHT_OVERHEAD ] = { name: "Left On Base + Right Overhead", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_ON_BASE + RIGHT_LOWERED ] = { name: "Left On Base + Right Lowered", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_ON_BASE + RIGHT_SIDE ] = { name: "Left On Base + Right Side", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_ON_BASE + RIGHT_FRONT ] = { name: "Left On Base + Right Front", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_ready.fbx" };
poses[LEFT_OVERHEAD + RIGHT_OVERHEAD ] = { name: "Left Overhead + Right Overhead", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/bboy_uprock.fbx" };
poses[LEFT_LOWERED + RIGHT_OVERHEAD ] = { name: "Left Lowered + Right Overhead", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_footwork_1.fbx" };
poses[LEFT_SIDE + RIGHT_OVERHEAD ] = { name: "Left Side + Right Overhead", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_footwork_2.fbx" };
poses[LEFT_FRONT + RIGHT_OVERHEAD ] = { name: "Left Front + Right Overhead", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_footwork_3.fbx" };
poses[LEFT_OVERHEAD + RIGHT_LOWERED ] = { name: "Left Overhead + Right Lowered", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_footwork_to_freeze.fbx" };
poses[LEFT_LOWERED + RIGHT_LOWERED ] = { name: "Left Lowered + Right Lowered", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_footwork_to_idle.fbx" };
poses[LEFT_SIDE + RIGHT_LOWERED ] = { name: "Left Side + Right Lowered", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_freeze_var_1.fbx" };
poses[LEFT_FRONT + RIGHT_LOWERED ] = { name: "Left Front + Right Lowered", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_freeze_var_2.fbx" };
poses[LEFT_OVERHEAD + RIGHT_SIDE ] = { name: "Left Overhead + Right Side", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_freeze_var_3.fbx" };
poses[LEFT_LOWERED + RIGHT_SIDE ] = { name: "Left Lowered + Right Side", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_freeze_var_4.fbx" };
poses[LEFT_SIDE + RIGHT_SIDE ] = { name: "Left Side + Right Side", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_freezes.fbx" };
poses[LEFT_FRONT + RIGHT_SIDE ] = { name: "Left Front + Right Side", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_swipes.fbx" };
poses[LEFT_OVERHEAD + RIGHT_FRONT ] = { name: "Left Overhead + Right Front", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_uprock.fbx" };
poses[LEFT_LOWERED + RIGHT_FRONT ] = { name: "Left Lowered + Right Front", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_uprock_var_1.fbx" };
poses[LEFT_SIDE + RIGHT_FRONT ] = { name: "Left Side + Right Front", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_uprock_var_2.fbx" };
poses[LEFT_FRONT + RIGHT_FRONT ] = { name: "Left Front + Right Front", animation: "http://s3.amazonaws.com/hifi-public/animations/Breakdancing/breakdance_uprock_var_1_end.fbx" };
Script.update.connect(function(deltaTime) {
var date= new Date();
var now= date.getTime();
var elapsed = now - lastTime;
var inMoveCycle = false;
var leftHandPos = MyAvatar.getLeftPalmPosition();
var rightHandPos = MyAvatar.getRightPalmPosition();
Overlays.editOverlay(leftHand, { position: leftHandPos } );
Overlays.editOverlay(rightHand, { position: rightHandPos } );
var hitTargetLeftOnBase = findSphereSphereHit(leftHandPos, handSize/2, getPositionLeftOnBase(), targetSize/2);
var hitTargetLeftOverhead = findSphereSphereHit(leftHandPos, handSize/2, getPositionLeftOverhead(), targetSize/2);
var hitTargetLeftLowered = findSphereSphereHit(leftHandPos, handSize/2, getPositionLeftLowered(), targetSize/2);
var hitTargetLeftSide = findSphereSphereHit(leftHandPos, handSize/2, getPositionLeftSide(), targetSize/2);
var hitTargetLeftFront = findSphereSphereHit(leftHandPos, handSize/2, getPositionLeftFront(), targetSize/2);
var hitTargetRightOnBase = findSphereSphereHit(rightHandPos, handSize/2, getPositionRightOnBase(), targetSize/2);
var hitTargetRightOverhead = findSphereSphereHit(rightHandPos, handSize/2, getPositionRightOverhead(), targetSize/2);
var hitTargetRightLowered = findSphereSphereHit(rightHandPos, handSize/2, getPositionRightLowered(), targetSize/2);
var hitTargetRightSide = findSphereSphereHit(rightHandPos, handSize/2, getPositionRightSide(), targetSize/2);
var hitTargetRightFront = findSphereSphereHit(rightHandPos, handSize/2, getPositionRightFront(), targetSize/2);
// determine target colors
var targetColorLeftOnBase = hitTargetLeftOnBase ? targetColorHit : targetColor;
var targetColorLeftOverhead = hitTargetLeftOverhead ? targetColorHit : targetColor;
var targetColorLeftLowered = hitTargetLeftLowered ? targetColorHit : targetColor;
var targetColorLeftSide = hitTargetLeftSide ? targetColorHit : targetColor;
var targetColorLeftFront = hitTargetLeftFront ? targetColorHit : targetColor;
var targetColorRightOnBase = hitTargetRightOnBase ? targetColorHit : targetColor;
var targetColorRightOverhead = hitTargetRightOverhead ? targetColorHit : targetColor;
var targetColorRightLowered = hitTargetRightLowered ? targetColorHit : targetColor;
var targetColorRightSide = hitTargetRightSide ? targetColorHit : targetColor;
var targetColorRightFront = hitTargetRightFront ? targetColorHit : targetColor;
// calculate a combined arm pose based on left and right hits
var poseValue = NO_POSE;
poseValue += hitTargetLeftOnBase ? LEFT_ON_BASE : 0;
poseValue += hitTargetLeftOverhead ? LEFT_OVERHEAD : 0;
poseValue += hitTargetLeftLowered ? LEFT_LOWERED : 0;
poseValue += hitTargetLeftSide ? LEFT_SIDE : 0;
poseValue += hitTargetLeftFront ? LEFT_FRONT : 0;
poseValue += hitTargetRightOnBase ? RIGHT_ON_BASE : 0;
poseValue += hitTargetRightOverhead ? RIGHT_OVERHEAD : 0;
poseValue += hitTargetRightLowered ? RIGHT_LOWERED : 0;
poseValue += hitTargetRightSide ? RIGHT_SIDE : 0;
poseValue += hitTargetRightFront ? RIGHT_FRONT : 0;
if (poses[poseValue] == undefined) {
Overlays.editOverlay(text, { text: "no pose -- value:" + poseValue });
} else {
Overlays.editOverlay(text, { text: "pose:" + poses[poseValue].name + "\n" + "animation:" + poses[poseValue].animation });
var props = Entities.getEntityProperties(puppetEntityID);
Entities.editEntity(puppetEntityID, {
animationURL: poses[poseValue].animation,
lifetime: TEMPORARY_LIFETIME + props.age // renew lifetime
});
}
lastPoseValue = poseValue;
Overlays.editOverlay(leftOnBase, { position: getPositionLeftOnBase(), color: targetColorLeftOnBase } );
Overlays.editOverlay(leftOverhead, { position: getPositionLeftOverhead(), color: targetColorLeftOverhead } );
Overlays.editOverlay(leftLowered, { position: getPositionLeftLowered(), color: targetColorLeftLowered } );
Overlays.editOverlay(leftSide, { position: getPositionLeftSide() , color: targetColorLeftSide } );
Overlays.editOverlay(leftFront, { position: getPositionLeftFront() , color: targetColorLeftFront } );
Overlays.editOverlay(rightOnBase, { position: getPositionRightOnBase(), color: targetColorRightOnBase } );
Overlays.editOverlay(rightOverhead, { position: getPositionRightOverhead(), color: targetColorRightOverhead } );
Overlays.editOverlay(rightLowered, { position: getPositionRightLowered(), color: targetColorRightLowered } );
Overlays.editOverlay(rightSide, { position: getPositionRightSide() , color: targetColorRightSide } );
Overlays.editOverlay(rightFront, { position: getPositionRightFront() , color: targetColorRightFront } );
});
Script.scriptEnding.connect(function() {
Overlays.deleteOverlay(leftHand);
Overlays.deleteOverlay(rightHand);
Overlays.deleteOverlay(text);
Overlays.deleteOverlay(leftOnBase);
Overlays.deleteOverlay(leftOverhead);
Overlays.deleteOverlay(leftLowered);
Overlays.deleteOverlay(leftSide);
Overlays.deleteOverlay(leftFront);
Overlays.deleteOverlay(rightOnBase);
Overlays.deleteOverlay(rightOverhead);
Overlays.deleteOverlay(rightLowered);
Overlays.deleteOverlay(rightSide);
Overlays.deleteOverlay(rightFront);
print("puppetEntityID:"+puppetEntityID);
Entities.deleteEntity(puppetEntityID);
});

View file

@ -83,5 +83,11 @@ EntityListTool = function(opts) {
} }
}); });
webView.visibilityChanged.connect(function (visible) {
if (visible) {
that.sendUpdate();
}
});
return that; return that;
}; };

View file

@ -66,42 +66,46 @@ void IceServer::processPacket(std::unique_ptr<udt::Packet> packet) {
auto nlPacket = NLPacket::fromBase(std::move(packet)); auto nlPacket = NLPacket::fromBase(std::move(packet));
if (nlPacket->getType() == PacketType::ICEServerHeartbeat) { // make sure that this packet at least looks like something we can read
SharedNetworkPeer peer = addOrUpdateHeartbeatingPeer(*nlPacket); if (nlPacket->getPayloadSize() >= NLPacket::localHeaderSize(PacketType::ICEServerHeartbeat)) {
// so that we can send packets to the heartbeating peer when we need, we need to activate a socket now if (nlPacket->getType() == PacketType::ICEServerHeartbeat) {
peer->activateMatchingOrNewSymmetricSocket(nlPacket->getSenderSockAddr()); SharedNetworkPeer peer = addOrUpdateHeartbeatingPeer(*nlPacket);
} else if (nlPacket->getType() == PacketType::ICEServerQuery) {
QDataStream heartbeatStream(nlPacket.get());
// this is a node hoping to connect to a heartbeating peer - do we have the heartbeating peer?
QUuid senderUUID;
heartbeatStream >> senderUUID;
// pull the public and private sock addrs for this peer
HifiSockAddr publicSocket, localSocket;
heartbeatStream >> publicSocket >> localSocket;
// check if this node also included a UUID that they would like to connect to
QUuid connectRequestID;
heartbeatStream >> connectRequestID;
SharedNetworkPeer matchingPeer = _activePeers.value(connectRequestID);
if (matchingPeer) {
qDebug() << "Sending information for peer" << connectRequestID << "to peer" << senderUUID; // so that we can send packets to the heartbeating peer when we need, we need to activate a socket now
peer->activateMatchingOrNewSymmetricSocket(nlPacket->getSenderSockAddr());
} else if (nlPacket->getType() == PacketType::ICEServerQuery) {
QDataStream heartbeatStream(nlPacket.get());
// we have the peer they want to connect to - send them pack the information for that peer // this is a node hoping to connect to a heartbeating peer - do we have the heartbeating peer?
sendPeerInformationPacket(*matchingPeer, &nlPacket->getSenderSockAddr()); QUuid senderUUID;
heartbeatStream >> senderUUID;
// we also need to send them to the active peer they are hoping to connect to // pull the public and private sock addrs for this peer
// create a dummy peer object we can pass to sendPeerInformationPacket HifiSockAddr publicSocket, localSocket;
heartbeatStream >> publicSocket >> localSocket;
NetworkPeer dummyPeer(senderUUID, publicSocket, localSocket); // check if this node also included a UUID that they would like to connect to
sendPeerInformationPacket(dummyPeer, matchingPeer->getActiveSocket()); QUuid connectRequestID;
} else { heartbeatStream >> connectRequestID;
qDebug() << "Peer" << senderUUID << "asked for" << connectRequestID << "but no matching peer found";
SharedNetworkPeer matchingPeer = _activePeers.value(connectRequestID);
if (matchingPeer) {
qDebug() << "Sending information for peer" << connectRequestID << "to peer" << senderUUID;
// we have the peer they want to connect to - send them pack the information for that peer
sendPeerInformationPacket(*matchingPeer, &nlPacket->getSenderSockAddr());
// we also need to send them to the active peer they are hoping to connect to
// create a dummy peer object we can pass to sendPeerInformationPacket
NetworkPeer dummyPeer(senderUUID, publicSocket, localSocket);
sendPeerInformationPacket(dummyPeer, matchingPeer->getActiveSocket());
} else {
qDebug() << "Peer" << senderUUID << "asked for" << connectRequestID << "but no matching peer found";
}
} }
} }
} }

View file

@ -5067,5 +5067,7 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index)
void Application::crashApplication() { void Application::crashApplication() {
QObject* object = nullptr; QObject* object = nullptr;
bool value = object->isWindowType(); bool value = object->isWindowType();
Q_UNUSED(value);
qCDebug(interfaceapp) << "Intentionally crashed Interface"; qCDebug(interfaceapp) << "Intentionally crashed Interface";
} }

View file

@ -223,7 +223,7 @@ Menu::Menu() {
addActionToQMenuAndActionHash(toolsMenu, MenuOption::PackageModel, 0, addActionToQMenuAndActionHash(toolsMenu, MenuOption::PackageModel, 0,
qApp, SLOT(packageModel())); qApp, SLOT(packageModel()));
MenuWrapper* displayMenu = addMenu(DisplayPlugin::MENU_PATH()); addMenu(DisplayPlugin::MENU_PATH());
{ {
MenuWrapper* displayModeMenu = addMenu(MenuOption::OutputMenu); MenuWrapper* displayModeMenu = addMenu(MenuOption::OutputMenu);
QActionGroup* displayModeGroup = new QActionGroup(displayModeMenu); QActionGroup* displayModeGroup = new QActionGroup(displayModeMenu);

View file

@ -844,7 +844,6 @@ void MyAvatar::sendKillAvatar() {
DependencyManager::get<NodeList>()->broadcastToNodes(std::move(killPacket), NodeSet() << NodeType::AvatarMixer); DependencyManager::get<NodeList>()->broadcastToNodes(std::move(killPacket), NodeSet() << NodeType::AvatarMixer);
} }
static int counter = 0;
void MyAvatar::updateLookAtTargetAvatar() { void MyAvatar::updateLookAtTargetAvatar() {
// //
// Look at the avatar whose eyes are closest to the ray in direction of my avatar's head // Look at the avatar whose eyes are closest to the ray in direction of my avatar's head

View file

@ -45,6 +45,7 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid
auto dockWidget = new QDockWidget(title, toolWindow); auto dockWidget = new QDockWidget(title, toolWindow);
dockWidget->setFeatures(QDockWidget::DockWidgetMovable); dockWidget->setFeatures(QDockWidget::DockWidgetMovable);
connect(dockWidget, &QDockWidget::visibilityChanged, this, &WebWindowClass::visibilityChanged);
_webView = new QWebView(dockWidget); _webView = new QWebView(dockWidget);
addEventBridgeToWindowObject(); addEventBridgeToWindowObject();

View file

@ -60,6 +60,7 @@ public slots:
void setTitle(const QString& title); void setTitle(const QString& title);
signals: signals:
void visibilityChanged(bool visible); // Tool window
void moved(glm::vec2 position); void moved(glm::vec2 position);
void resized(QSizeF size); void resized(QSizeF size);
void closed(); void closed();

View file

@ -206,8 +206,6 @@ void ApplicationCompositor::displayOverlayTexture(RenderArgs* renderArgs) {
updateTooltips(); updateTooltips();
auto deviceSize = qApp->getDeviceSize();
//Handle fading and deactivation/activation of UI //Handle fading and deactivation/activation of UI
gpu::Batch batch; gpu::Batch batch;

View file

@ -80,32 +80,34 @@ void OpenGLDisplayPlugin::deactivate() {
// Pass input events on to the application // Pass input events on to the application
bool OpenGLDisplayPlugin::eventFilter(QObject* receiver, QEvent* event) { bool OpenGLDisplayPlugin::eventFilter(QObject* receiver, QEvent* event) {
switch (event->type()) { switch (event->type()) {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick: case QEvent::MouseButtonDblClick:
case QEvent::MouseMove: case QEvent::MouseMove:
case QEvent::Wheel: case QEvent::Wheel:
case QEvent::TouchBegin: case QEvent::TouchBegin:
case QEvent::TouchEnd: case QEvent::TouchEnd:
case QEvent::TouchUpdate: case QEvent::TouchUpdate:
case QEvent::FocusIn: case QEvent::FocusIn:
case QEvent::FocusOut: case QEvent::FocusOut:
case QEvent::KeyPress: case QEvent::KeyPress:
case QEvent::KeyRelease: case QEvent::KeyRelease:
case QEvent::ShortcutOverride: case QEvent::ShortcutOverride:
case QEvent::DragEnter: case QEvent::DragEnter:
case QEvent::Drop: case QEvent::Drop:
case QEvent::Resize: case QEvent::Resize:
if (QCoreApplication::sendEvent(QCoreApplication::instance(), event)) { if (QCoreApplication::sendEvent(QCoreApplication::instance(), event)) {
return true; return true;
} }
break; default:
break;
} }
return false; return false;
} }
@ -141,4 +143,4 @@ bool OpenGLDisplayPlugin::isVsyncEnabled() {
#else #else
return true; return true;
#endif #endif
} }

View file

@ -51,20 +51,22 @@ protected:
private: private:
static const QString NAME; static const QString NAME;
ovrHmd _hmd;
float _ipd{ OVR_DEFAULT_IPD };
unsigned int _frameIndex;
ovrEyeRenderDesc _eyeRenderDescs[2];
ovrPosef _eyePoses[2]; ovrPosef _eyePoses[2];
ovrVector3f _eyeOffsets[2];
ovrFovPort _eyeFovs[2];
mat4 _eyeProjections[3]; mat4 _eyeProjections[3];
mat4 _compositeEyeProjections[2]; mat4 _compositeEyeProjections[2];
uvec2 _desiredFramebufferSize; uvec2 _desiredFramebufferSize;
ovrTrackingState _trackingState; ovrTrackingState _trackingState;
#if (OVR_MAJOR_VERSION >= 6) #if (OVR_MAJOR_VERSION >= 6)
ovrHmd _hmd;
float _ipd{ OVR_DEFAULT_IPD };
unsigned int _frameIndex;
ovrEyeRenderDesc _eyeRenderDescs[2];
ovrVector3f _eyeOffsets[2];
ovrFovPort _eyeFovs[2];
ovrLayerEyeFov& getSceneLayer(); ovrLayerEyeFov& getSceneLayer();
ovrHmdDesc _hmdDesc; ovrHmdDesc _hmdDesc;
SwapFboPtr _sceneFbo; SwapFboPtr _sceneFbo;

View file

@ -34,7 +34,7 @@ const QString & OculusLegacyDisplayPlugin::getName() const {
return NAME; return NAME;
} }
OculusLegacyDisplayPlugin::OculusLegacyDisplayPlugin() : _ipd(OVR_DEFAULT_IPD) { OculusLegacyDisplayPlugin::OculusLegacyDisplayPlugin() {
} }
uvec2 OculusLegacyDisplayPlugin::getRecommendedRenderSize() const { uvec2 OculusLegacyDisplayPlugin::getRecommendedRenderSize() const {

View file

@ -44,7 +44,6 @@ protected:
private: private:
static const QString NAME; static const QString NAME;
float _ipd{ OVR_DEFAULT_IPD };
ovrHmd _hmd; ovrHmd _hmd;
unsigned int _frameIndex; unsigned int _frameIndex;
ovrTrackingState _trackingState; ovrTrackingState _trackingState;

View file

@ -78,7 +78,7 @@ void StereoDisplayPlugin::activate() {
} }
void StereoDisplayPlugin::updateScreen() { void StereoDisplayPlugin::updateScreen() {
for (int i = 0; i < _screenActions.size(); ++i) { for (int i = 0; i < (int) _screenActions.size(); ++i) {
if (_screenActions[i]->isChecked()) { if (_screenActions[i]->isChecked()) {
CONTAINER->setFullscreen(qApp->screens().at(i)); CONTAINER->setFullscreen(qApp->screens().at(i));
break; break;

View file

@ -41,7 +41,6 @@ void GLBackend::do_setViewportTransform(Batch& batch, uint32 paramOffset) {
if (_stereo._pass) { if (_stereo._pass) {
vp.x += vp.z; vp.x += vp.z;
} }
int i = 0;
} }
glViewport(vp.x, vp.y, vp.z, vp.w); glViewport(vp.x, vp.y, vp.z, vp.w);

View file

@ -50,7 +50,7 @@ AssetRequest* AssetClient::createRequest(const QString& hash, const QString& ext
SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer); SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
if (!assetServer) { if (!assetServer) {
qDebug() << "No Asset Server"; qDebug().nospace() << "Could not request " << hash << "." << extension << " since you are not currently connected to an asset-server.";
return nullptr; return nullptr;
} }
@ -70,11 +70,12 @@ AssetUpload* AssetClient::createUpload(const QString& filename) {
auto nodeList = DependencyManager::get<NodeList>(); auto nodeList = DependencyManager::get<NodeList>();
SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer); SharedNodePointer assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
if (assetServer) { if (!assetServer) {
return new AssetUpload(this, filename); qDebug() << "Could not upload" << filename << "since you are not currently connected to an asset-server.";
return nullptr;
} }
return nullptr; return new AssetUpload(this, filename);
} }
bool AssetClient::getAsset(const QString& hash, const QString& extension, DataOffset start, DataOffset end, bool AssetClient::getAsset(const QString& hash, const QString& extension, DataOffset start, DataOffset end,

View file

@ -68,6 +68,5 @@ void AssetResourceRequest::doSend() {
} }
void AssetResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) { void AssetResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
qDebug() << "Got asset data: " << bytesReceived << " / " << bytesTotal;
emit progress(bytesReceived, bytesTotal); emit progress(bytesReceived, bytesTotal);
} }

View file

@ -41,21 +41,22 @@ void AssetUpload::start() {
// ask the AssetClient to upload the asset and emit the proper signals from the passed callback // ask the AssetClient to upload the asset and emit the proper signals from the passed callback
auto assetClient = DependencyManager::get<AssetClient>(); auto assetClient = DependencyManager::get<AssetClient>();
assetClient->uploadAsset(data, _extension, [this](bool success, const QString& hash){ assetClient->uploadAsset(data, _extension, [this](AssetServerError error, const QString& hash){
if (success) { switch (error) {
// successful upload - emit finished with a point to ourselves and the resulting hash case NO_ERROR:
_result = Success; _result = Success;
break;
emit finished(this, hash); case ASSET_TOO_LARGE:
} else { _result = TooLarge;
// error during upload - emit finished with an empty hash break;
// callers can get the error from this object case PERMISSION_DENIED:
_result = PermissionDenied;
// TODO: get the actual error from the callback break;
_result = PermissionDenied; default:
_result = ErrorLoadingFile;
emit finished(this, hash); break;
} }
emit finished(this, hash);
}); });
} else { } else {
// we couldn't open the file - set the error result // we couldn't open the file - set the error result

View file

@ -17,8 +17,6 @@ void FileResourceRequest::doSend() {
QString filename = _url.toLocalFile(); QString filename = _url.toLocalFile();
QFile file(filename); QFile file(filename);
_state = Finished;
if (file.exists()) { if (file.exists()) {
if (file.open(QFile::ReadOnly)) { if (file.open(QFile::ReadOnly)) {
_data = file.readAll(); _data = file.readAll();
@ -30,5 +28,6 @@ void FileResourceRequest::doSend() {
_result = ResourceRequest::NotFound; _result = ResourceRequest::NotFound;
} }
_state = Finished;
emit finished(); emit finished();
} }

View file

@ -40,12 +40,12 @@ void HTTPResourceRequest::doSend() {
} }
_reply = networkAccessManager.get(networkRequest); _reply = networkAccessManager.get(networkRequest);
connect(_reply, &QNetworkReply::finished, this, &HTTPResourceRequest::onRequestFinished); connect(_reply, &QNetworkReply::finished, this, &HTTPResourceRequest::onRequestFinished);
connect(_reply, &QNetworkReply::downloadProgress, this, &HTTPResourceRequest::onDownloadProgress);
connect(&_sendTimer, &QTimer::timeout, this, &HTTPResourceRequest::onTimeout);
static const int TIMEOUT_MS = 10000; static const int TIMEOUT_MS = 10000;
connect(&_sendTimer, &QTimer::timeout, this, &HTTPResourceRequest::onTimeout);
_sendTimer.setSingleShot(true); _sendTimer.setSingleShot(true);
_sendTimer.start(TIMEOUT_MS); _sendTimer.start(TIMEOUT_MS);
} }
@ -54,43 +54,46 @@ void HTTPResourceRequest::onRequestFinished() {
Q_ASSERT(_state == InProgress); Q_ASSERT(_state == InProgress);
Q_ASSERT(_reply); Q_ASSERT(_reply);
_state = Finished; _sendTimer.stop();
auto error = _reply->error(); switch(_reply->error()) {
if (error == QNetworkReply::NoError) { case QNetworkReply::NoError:
_data = _reply->readAll(); _data = _reply->readAll();
_loadedFromCache = _reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool(); _loadedFromCache = _reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool();
_result = ResourceRequest::Success; _result = Success;
emit finished(); break;
} else if (error == QNetworkReply::TimeoutError) { case QNetworkReply::TimeoutError:
_result = ResourceRequest::Timeout; _result = Timeout;
emit finished(); break;
} else { default:
_result = ResourceRequest::Error; _result = Error;
emit finished(); break;
} }
_reply->disconnect(this);
_reply->deleteLater(); _reply->deleteLater();
_reply = nullptr; _reply = nullptr;
_state = Finished;
emit finished();
} }
void HTTPResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) { void HTTPResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
if (_state == InProgress) { Q_ASSERT(_state == InProgress);
// We've received data, so reset the timer
_sendTimer.start(); // We've received data, so reset the timer
} _sendTimer.start();
emit progress(bytesReceived, bytesTotal); emit progress(bytesReceived, bytesTotal);
} }
void HTTPResourceRequest::onTimeout() { void HTTPResourceRequest::onTimeout() {
Q_ASSERT(_state != NotStarted); Q_ASSERT(_state == InProgress);
_reply->disconnect(this);
if (_state == InProgress) { _reply->abort();
qCDebug(networking) << "Timed out loading " << _url; _reply->deleteLater();
_reply->abort(); _reply = nullptr;
_state = Finished;
_result = Timeout; _result = Timeout;
emit finished(); _state = Finished;
} emit finished();
} }

View file

@ -21,9 +21,8 @@
class HTTPResourceRequest : public ResourceRequest { class HTTPResourceRequest : public ResourceRequest {
Q_OBJECT Q_OBJECT
public: public:
~HTTPResourceRequest();
HTTPResourceRequest(QObject* parent, const QUrl& url) : ResourceRequest(parent, url) { } HTTPResourceRequest(QObject* parent, const QUrl& url) : ResourceRequest(parent, url) { }
~HTTPResourceRequest();
protected: protected:
virtual void doSend() override; virtual void doSend() override;

View file

@ -158,14 +158,12 @@ void ResourceCache::attemptRequest(Resource* resource) {
// Disable request limiting for ATP // Disable request limiting for ATP
if (resource->getURL().scheme() != URL_SCHEME_ATP) { if (resource->getURL().scheme() != URL_SCHEME_ATP) {
if (_requestLimit <= 0) { if (_requestLimit <= 0) {
qDebug() << "REQUEST LIMIT REACHED (" << _requestLimit << "), queueing: " << resource->getURL();
// wait until a slot becomes available // wait until a slot becomes available
sharedItems->_pendingRequests.append(resource); sharedItems->_pendingRequests.append(resource);
return; return;
} }
qDebug() << "-- Decreasing limit for : " << resource->getURL(); --_requestLimit;
_requestLimit--;
} }
sharedItems->_loadingRequests.append(resource); sharedItems->_loadingRequests.append(resource);
@ -176,8 +174,7 @@ void ResourceCache::requestCompleted(Resource* resource) {
auto sharedItems = DependencyManager::get<ResourceCacheSharedItems>(); auto sharedItems = DependencyManager::get<ResourceCacheSharedItems>();
sharedItems->_loadingRequests.removeOne(resource); sharedItems->_loadingRequests.removeOne(resource);
if (resource->getURL().scheme() != URL_SCHEME_ATP) { if (resource->getURL().scheme() != URL_SCHEME_ATP) {
qDebug() << "++ Increasing limit after finished: " << resource->getURL(); ++_requestLimit;
_requestLimit++;
} }
// look for the highest priority pending request // look for the highest priority pending request
@ -367,63 +364,53 @@ void Resource::handleDownloadProgress(uint64_t bytesReceived, uint64_t bytesTota
void Resource::handleReplyFinished() { void Resource::handleReplyFinished() {
Q_ASSERT(_request); Q_ASSERT(_request);
ResourceCache::requestCompleted(this);
auto result = _request->getResult(); auto result = _request->getResult();
if (result == ResourceRequest::Success) { if (result == ResourceRequest::Success) {
_data = _request->getData(); _data = _request->getData();
qDebug() << "Request finished for " << _url << ", " << _activeUrl; qDebug() << "Request finished for " << _url << ", " << _activeUrl;
_request->disconnect(this); finishedLoading(true);
_request->deleteLater();
_request = nullptr;
ResourceCache::requestCompleted(this);
emit loaded(_data); emit loaded(_data);
downloadFinished(_data); downloadFinished(_data);
} else { } else {
_request->disconnect(this);
_request->deleteLater();
_request = nullptr;
if (result == ResourceRequest::Result::Timeout) {
qDebug() << "Timed out loading" << _url << "received" << _bytesReceived << "total" << _bytesTotal;
} else {
qDebug() << "Error loading " << _url;
}
bool retry = false;
switch (result) { switch (result) {
case ResourceRequest::Result::Timeout: case ResourceRequest::Result::Timeout: {
case ResourceRequest::Result::ServerUnavailable: qDebug() << "Timed out loading" << _url << "received" << _bytesReceived << "total" << _bytesTotal;
case ResourceRequest::Result::Error: { // Fall through to other cases
}
case ResourceRequest::Result::ServerUnavailable: {
// retry with increasing delays // retry with increasing delays
const int MAX_ATTEMPTS = 8; const int MAX_ATTEMPTS = 8;
const int BASE_DELAY_MS = 1000; const int BASE_DELAY_MS = 1000;
if (++_attempts < MAX_ATTEMPTS) { if (_attempts++ < MAX_ATTEMPTS) {
QTimer::singleShot(BASE_DELAY_MS * (int)pow(2.0, _attempts), this, SLOT(attemptRequest())); auto waitTime = BASE_DELAY_MS * (int)pow(2.0, _attempts);
retry = true; qDebug().nospace() << "Retrying to load the asset in " << waitTime
<< "ms, attempt " << _attempts << " of " << MAX_ATTEMPTS;
QTimer::singleShot(waitTime, this, &Resource::attemptRequest);
break; break;
} }
// fall through to final failure // fall through to final failure
} }
default: default: {
qDebug() << "Error loading " << _url;
auto error = (result == ResourceRequest::Timeout) ? QNetworkReply::TimeoutError
: QNetworkReply::UnknownNetworkError;
emit failed(error);
finishedLoading(false); finishedLoading(false);
break; break;
} }
auto error = result == ResourceRequest::Timeout ? QNetworkReply::TimeoutError : QNetworkReply::UnknownNetworkError;
if (!retry) {
emit failed(error);
ResourceCache::requestCompleted(this);
} }
} }
_request->disconnect(this);
_request->deleteLater();
_request = nullptr;
} }
void Resource::downloadFinished(const QByteArray& data) { void Resource::downloadFinished(const QByteArray& data) {
;
} }
uint qHash(const QPointer<QObject>& value, uint seed) { uint qHash(const QPointer<QObject>& value, uint seed) {

View file

@ -27,7 +27,7 @@ ResourceRequest* ResourceManager::createResourceRequest(QObject* parent, const Q
return new AssetResourceRequest(parent, url); return new AssetResourceRequest(parent, url);
} }
qDebug() << "Failed to load: " << url.url(); qDebug() << "Unknown scheme (" << scheme << ") for URL: " << url.url();
return nullptr; return nullptr;
} }

View file

@ -65,11 +65,11 @@ void compileProgram(ProgramPtr & result, const std::string& vs, const std::strin
.Compile() .Compile()
); );
result->Link(); result->Link();
} catch (ProgramBuildError & err) { } catch (ProgramBuildError& err) {
Q_UNUSED(err); Q_UNUSED(err);
qWarning() << err.Log().c_str(); qWarning() << err.Log().c_str();
Q_ASSERT_X(false, "compileProgram", "Failed to build shader program"); Q_ASSERT_X(false, "compileProgram", "Failed to build shader program");
qFatal((const char*)err.Message); qFatal("%s", (const char*) err.Message);
result.reset(); result.reset();
} }
} }

View file

@ -34,9 +34,11 @@ void BatchLoader::start() {
} }
_started = true; _started = true;
for (QUrl url : _urls) { for (const auto& url : _urls) {
auto request = ResourceManager::createResourceRequest(this, url); auto request = ResourceManager::createResourceRequest(this, url);
if (!request) { if (!request) {
_data.insert(url, QString());
qCDebug(scriptengine) << "Could not load" << url;
continue; continue;
} }
connect(request, &ResourceRequest::finished, this, [=]() { connect(request, &ResourceRequest::finished, this, [=]() {
@ -44,6 +46,7 @@ void BatchLoader::start() {
_data.insert(url, request->getData()); _data.insert(url, request->getData());
} else { } else {
_data.insert(url, QString()); _data.insert(url, QString());
qCDebug(scriptengine) << "Could not load" << url;
} }
request->deleteLater(); request->deleteLater();
checkFinished(); checkFinished();

View file

@ -16,16 +16,16 @@
#include "WebSocketClass.h" #include "WebSocketClass.h"
WebSocketClass::WebSocketClass(QScriptEngine* engine, QString url) : WebSocketClass::WebSocketClass(QScriptEngine* engine, QString url) :
_engine(engine), _webSocket(new QWebSocket()),
_webSocket(new QWebSocket()) _engine(engine)
{ {
initialize(); initialize();
_webSocket->open(url); _webSocket->open(url);
} }
WebSocketClass::WebSocketClass(QScriptEngine* engine, QWebSocket* qWebSocket) : WebSocketClass::WebSocketClass(QScriptEngine* engine, QWebSocket* qWebSocket) :
_engine(engine), _webSocket(qWebSocket),
_webSocket(qWebSocket) _engine(engine)
{ {
initialize(); initialize();
} }

View file

@ -15,8 +15,8 @@
#include "WebSocketServerClass.h" #include "WebSocketServerClass.h"
WebSocketServerClass::WebSocketServerClass(QScriptEngine* engine, const QString& serverName, const quint16 port) : WebSocketServerClass::WebSocketServerClass(QScriptEngine* engine, const QString& serverName, const quint16 port) :
_engine(engine), _webSocketServer(serverName, QWebSocketServer::SslMode::NonSecureMode),
_webSocketServer(serverName, QWebSocketServer::SslMode::NonSecureMode) _engine(engine)
{ {
if (_webSocketServer.listen(QHostAddress::Any, port)) { if (_webSocketServer.listen(QHostAddress::Any, port)) {
connect(&_webSocketServer, &QWebSocketServer::newConnection, this, &WebSocketServerClass::onNewConnection); connect(&_webSocketServer, &QWebSocketServer::newConnection, this, &WebSocketServerClass::onNewConnection);

View file

@ -378,8 +378,6 @@ glm::mat4 createMatFromQuatAndPos(const glm::quat& q, const glm::vec3& p) {
// cancel out roll and pitch // cancel out roll and pitch
glm::quat cancelOutRollAndPitch(const glm::quat& q) { glm::quat cancelOutRollAndPitch(const glm::quat& q) {
glm::vec3 xAxis = q * glm::vec3(1, 0, 0);
glm::vec3 yAxis = q * glm::vec3(0, 1, 0);
glm::vec3 zAxis = q * glm::vec3(0, 0, 1); glm::vec3 zAxis = q * glm::vec3(0, 0, 1);
// cancel out the roll and pitch // cancel out the roll and pitch
@ -393,8 +391,6 @@ glm::quat cancelOutRollAndPitch(const glm::quat& q) {
// cancel out roll and pitch // cancel out roll and pitch
glm::mat4 cancelOutRollAndPitch(const glm::mat4& m) { glm::mat4 cancelOutRollAndPitch(const glm::mat4& m) {
glm::vec3 xAxis = glm::vec3(m[0]);
glm::vec3 yAxis = glm::vec3(m[1]);
glm::vec3 zAxis = glm::vec3(m[2]); glm::vec3 zAxis = glm::vec3(m[2]);
// cancel out the roll and pitch // cancel out the roll and pitch