Merge branch 'master' into 21369

This commit is contained in:
NeetBhagat 2017-06-12 11:17:26 +05:30
commit e6a5930365
19 changed files with 228 additions and 76 deletions

View file

@ -161,7 +161,12 @@ Rectangle {
text.text: devicename
onCheckBoxClicked: {
if (checked) {
AudioDevice.setInputDeviceAsync(devicename)
if (devicename.length > 0) {
console.log("Audio.qml about to call AudioDevice.setInputDeviceAsync().devicename:" + devicename);
AudioDevice.setInputDeviceAsync(devicename);
} else {
console.log("Audio.qml attempted to set input device to empty device name.");
}
}
}
}
@ -217,7 +222,13 @@ Rectangle {
text.text: devicename
onCheckBoxClicked: {
if (checked) {
AudioDevice.setOutputDeviceAsync(devicename)
if (devicename.length > 0) {
console.log("Audio.qml about to call AudioDevice.setOutputDeviceAsync().devicename:" + devicename);
AudioDevice.setOutputDeviceAsync(devicename);
} else {
console.log("Audio.qml attempted to set output device to empty device name.");
}
}
}
}

View file

@ -4126,10 +4126,10 @@ void Application::updateMyAvatarLookAtPosition() {
}
} else {
// I am not looking at anyone else, so just look forward
if (isHMD) {
glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() *
myAvatar->getHeadControllerPoseInSensorFrame().getMatrix();
lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, -TREE_SCALE));
auto headPose = myAvatar->getHeadControllerPoseInSensorFrame();
if (headPose.isValid()) {
glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() * headPose.getMatrix();
lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, TREE_SCALE));
} else {
lookAtSpot = myAvatar->getHead()->getEyePosition() +
(myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));

View file

@ -21,15 +21,35 @@
#include "MainWindow.h"
#include "Menu.h"
#include "AvatarBookmarks.h"
#include "InterfaceLogging.h"
#include <QtQuick/QQuickWindow>
AvatarBookmarks::AvatarBookmarks() {
_bookmarksFilename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + AVATARBOOKMARKS_FILENAME;
_bookmarksFilename = PathUtils::getAppDataPath() + "/" + AVATARBOOKMARKS_FILENAME;
readFromFile();
}
void AvatarBookmarks::readFromFile() {
// migrate old avatarbookmarks.json, used to be in 'local' folder on windows
QString oldConfigPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + AVATARBOOKMARKS_FILENAME;
QFile oldConfig(oldConfigPath);
// I imagine that in a year from now, this code for migrating (as well as the two lines above)
// may be removed since all bookmarks should have been migrated by then
// - Robbie Uvanni (6.8.2017)
if (oldConfig.exists()) {
if (QDir().rename(oldConfigPath, _bookmarksFilename)) {
qCDebug(interfaceapp) << "Successfully migrated" << AVATARBOOKMARKS_FILENAME;
} else {
qCDebug(interfaceapp) << "Failed to migrate" << AVATARBOOKMARKS_FILENAME;
}
}
Bookmarks::readFromFile();
}
void AvatarBookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) {
// Add menus/actions
auto bookmarkAction = menubar->addActionToQMenuAndActionHash(menu, MenuOption::BookmarkAvatar);

View file

@ -29,6 +29,7 @@ public slots:
protected:
void addBookmarkToMenu(Menu* menubar, const QString& name, const QString& address) override;
void readFromFile();
private:
const QString AVATARBOOKMARKS_FILENAME = "avatarbookmarks.json";

View file

@ -2664,8 +2664,8 @@ bool MyAvatar::FollowHelper::shouldActivateVertical(const MyAvatar& myAvatar, co
return (offset.y > CYLINDER_TOP) || (offset.y < CYLINDER_BOTTOM);
}
void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix, bool hasDriveInput) {
_desiredBodyMatrix = desiredBodyMatrix;
void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix,
const glm::mat4& currentBodyMatrix, bool hasDriveInput) {
if (myAvatar.getHMDLeanRecenterEnabled()) {
if (!isActive(Rotation) && shouldActivateRotation(myAvatar, desiredBodyMatrix, currentBodyMatrix)) {
@ -2679,7 +2679,7 @@ void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat
}
}
glm::mat4 desiredWorldMatrix = myAvatar.getSensorToWorldMatrix() * _desiredBodyMatrix;
glm::mat4 desiredWorldMatrix = myAvatar.getSensorToWorldMatrix() * desiredBodyMatrix;
glm::mat4 currentWorldMatrix = myAvatar.getSensorToWorldMatrix() * currentBodyMatrix;
AnimPose followWorldPose(currentWorldMatrix);

View file

@ -702,7 +702,6 @@ private:
Vertical,
NumFollowTypes
};
glm::mat4 _desiredBodyMatrix;
float _timeRemaining[NumFollowTypes];
void deactivate();

View file

@ -9,7 +9,9 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "AudioClient.h"
#include <AudioClient.h>
#include <AudioClientLogging.h>
#include "AudioDeviceScriptingInterface.h"
#include "SettingsScriptingInterface.h"
@ -44,17 +46,23 @@ AudioDeviceScriptingInterface::AudioDeviceScriptingInterface(): QAbstractListMod
onDeviceChanged();
//set up previously saved device
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
const QString inDevice = settings->getValue("audio_input_device").toString();
const QString inDevice = settings->getValue("audio_input_device", _currentInputDevice).toString();
if (inDevice != _currentInputDevice) {
qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << inDevice << "] _currentInputDevice:" << _currentInputDevice;
setInputDeviceAsync(inDevice);
}
const QString outDevice = settings->getValue("audio_output_device").toString();
// If the audio_output_device setting is not available, use the _currentOutputDevice
auto outDevice = settings->getValue("audio_output_device", _currentOutputDevice).toString();
if (outDevice != _currentOutputDevice) {
qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() outDevice: [" << outDevice << "] _currentOutputDevice:" << _currentOutputDevice;
setOutputDeviceAsync(outDevice);
}
}
bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) {
qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName;
bool result;
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice",
Qt::BlockingQueuedConnection,
@ -64,6 +72,9 @@ bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) {
}
bool AudioDeviceScriptingInterface::setOutputDevice(const QString& deviceName) {
qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName;
bool result;
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice",
Qt::BlockingQueuedConnection,
@ -86,8 +97,10 @@ bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuN
for (ScriptingAudioDeviceInfo di: _devices) {
if (mode == di.mode && deviceMenuName.contains(di.name)) {
if (mode == QAudio::AudioOutput) {
qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() device: [" << di.name << "]";
setOutputDeviceAsync(di.name);
} else {
qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << di.name << "]";
setInputDeviceAsync(di.name);
}
return true;
@ -98,12 +111,26 @@ bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuN
}
void AudioDeviceScriptingInterface::setInputDeviceAsync(const QString& deviceName) {
qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName;
if (deviceName.isEmpty()) {
qCDebug(audioclient) << __FUNCTION__ << "attempt to set empty deviceName:" << deviceName << "... ignoring!";
return;
}
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice",
Qt::QueuedConnection,
Q_ARG(const QString&, deviceName));
}
void AudioDeviceScriptingInterface::setOutputDeviceAsync(const QString& deviceName) {
qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName;
if (deviceName.isEmpty()) {
qCDebug(audioclient) << __FUNCTION__ << "attempt to set empty deviceName:" << deviceName << "... ignoring!";
return;
}
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice",
Qt::QueuedConnection,
Q_ARG(const QString&, deviceName));
@ -241,8 +268,11 @@ void AudioDeviceScriptingInterface::onCurrentInputDeviceChanged(const QString& n
void AudioDeviceScriptingInterface::onCurrentOutputDeviceChanged(const QString& name)
{
currentDeviceUpdate(name, QAudio::AudioOutput);
// FIXME - this is kinda janky to set the setting on the result of a signal
//we got a signal that device changed. Save it now
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
qCDebug(audioclient) << __FUNCTION__ << "about to call settings->setValue('audio_output_device', name); name:" << name;
settings->setValue("audio_output_device", name);
emit currentOutputDeviceChanged(name);
}

View file

@ -166,7 +166,10 @@ AudioClient::AudioClient() :
connect(&_receivedAudioStream, &MixedProcessedAudioStream::processSamples,
this, &AudioClient::processReceivedSamples, Qt::DirectConnection);
connect(this, &AudioClient::changeDevice, this, [=](const QAudioDeviceInfo& outputDeviceInfo) { switchOutputToAudioDevice(outputDeviceInfo); });
connect(this, &AudioClient::changeDevice, this, [=](const QAudioDeviceInfo& outputDeviceInfo) {
qCDebug(audioclient) << "got AudioClient::changeDevice signal, about to call switchOutputToAudioDevice() outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]";
switchOutputToAudioDevice(outputDeviceInfo);
});
connect(&_receivedAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioClient::handleMismatchAudioFormat);
@ -379,7 +382,8 @@ QAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
CoUninitialize();
}
qCDebug(audioclient) << "[" << deviceName << "] [" << getNamedAudioDeviceForMode(mode, deviceName).deviceName() << "]";
qCDebug(audioclient) << "defaultAudioDeviceForMode mode: " << (mode == QAudio::AudioOutput ? "Output" : "Input")
<< " [" << deviceName << "] [" << getNamedAudioDeviceForMode(mode, deviceName).deviceName() << "]";
return getNamedAudioDeviceForMode(mode, deviceName);
#endif
@ -555,8 +559,12 @@ void AudioClient::start() {
}
void AudioClient::stop() {
// "switch" to invalid devices in order to shut down the state
qCDebug(audioclient) << "AudioClient::stop(), about to call switchInputToAudioDevice(null)";
switchInputToAudioDevice(QAudioDeviceInfo());
qCDebug(audioclient) << "AudioClient::stop(), about to call switchOutputToAudioDevice(null)";
switchOutputToAudioDevice(QAudioDeviceInfo());
}
@ -748,12 +756,12 @@ QVector<QString> AudioClient::getDeviceNames(QAudio::Mode mode) {
}
bool AudioClient::switchInputToAudioDevice(const QString& inputDeviceName) {
qCDebug(audioclient) << "[" << inputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName).deviceName() << "]";
qCDebug(audioclient) << "switchInputToAudioDevice [" << inputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName).deviceName() << "]";
return switchInputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName));
}
bool AudioClient::switchOutputToAudioDevice(const QString& outputDeviceName) {
qCDebug(audioclient) << "[" << outputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName).deviceName() << "]";
qCDebug(audioclient) << "switchOutputToAudioDevice [" << outputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName).deviceName() << "]";
return switchOutputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName));
}
@ -1298,6 +1306,7 @@ void AudioClient::setIsStereoInput(bool isStereoInput) {
}
// change in channel count for desired input format, restart the input device
qCDebug(audioclient) << __FUNCTION__ << "about to call switchInputToAudioDevice:" << _inputAudioDeviceName;
switchInputToAudioDevice(_inputAudioDeviceName);
}
}
@ -1334,6 +1343,7 @@ void AudioClient::outputFormatChanged() {
}
bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo) {
qCDebug(audioclient) << __FUNCTION__ << "inputDeviceInfo: [" << inputDeviceInfo.deviceName() << "]";
bool supportedFormat = false;
// cleanup any previously initialized device
@ -1448,6 +1458,8 @@ void AudioClient::outputNotify() {
}
bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo) {
qCDebug(audioclient) << "AudioClient::switchOutputToAudioDevice() outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]";
bool supportedFormat = false;
Lock localAudioLock(_localAudioMutex);
@ -1582,7 +1594,11 @@ bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDevice
}
int AudioClient::setOutputBufferSize(int numFrames, bool persist) {
qCDebug(audioclient) << __FUNCTION__ << "numFrames:" << numFrames << "persist:" << persist;
numFrames = std::min(std::max(numFrames, MIN_BUFFER_FRAMES), MAX_BUFFER_FRAMES);
qCDebug(audioclient) << __FUNCTION__ << "clamped numFrames:" << numFrames << "_sessionOutputBufferSizeFrames:" << _sessionOutputBufferSizeFrames;
if (numFrames != _sessionOutputBufferSizeFrames) {
qCInfo(audioclient, "Audio output buffer set to %d frames", numFrames);
_sessionOutputBufferSizeFrames = numFrames;
@ -1594,6 +1610,7 @@ int AudioClient::setOutputBufferSize(int numFrames, bool persist) {
// The buffer size can't be adjusted after QAudioOutput::start() has been called, so
// recreate the device by switching to the default.
QAudioDeviceInfo outputDeviceInfo = defaultAudioDeviceForMode(QAudio::AudioOutput);
qCDebug(audioclient) << __FUNCTION__ << "about to send changeDevice signal outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]";
emit changeDevice(outputDeviceInfo); // On correct thread, please, as setOutputBufferSize can be called from main thread.
}
}

View file

@ -221,6 +221,12 @@ void HmdDisplayPlugin::internalPresent() {
float shiftLeftBy = getLeftCenterPixel() - (sourceSize.x / 2);
float newWidth = sourceSize.x - shiftLeftBy;
// Experimentally adjusted the region presented in preview to avoid seeing the masked pixels and recenter the center...
static float SCALE_WIDTH = 0.9f;
static float SCALE_OFFSET = 2.0f;
newWidth *= SCALE_WIDTH;
shiftLeftBy *= SCALE_OFFSET;
const unsigned int RATIO_Y = 9;
const unsigned int RATIO_X = 16;
glm::uvec2 originalClippedSize { newWidth, newWidth * RATIO_Y / RATIO_X };

View file

@ -20,6 +20,10 @@
#include <DependencyManager.h>
#include "AddressManager.h"
UserActivityLogger::UserActivityLogger() {
_timer.start();
}
UserActivityLogger& UserActivityLogger::getInstance() {
static UserActivityLogger sharedInstance;
return sharedInstance;
@ -42,6 +46,12 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall
actionPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"action_name\"");
actionPart.setBody(QByteArray().append(action));
multipart->append(actionPart);
// Log the local-time that this event was logged
QHttpPart elapsedPart;
elapsedPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"elapsed_ms\"");
elapsedPart.setBody(QString::number(_timer.elapsed()).toLocal8Bit());
multipart->append(elapsedPart);
// If there are action details, add them to the multipart
if (!details.isEmpty()) {

View file

@ -18,6 +18,7 @@
#include <QString>
#include <QJsonObject>
#include <QNetworkReply>
#include <QElapsedTimer>
#include <SettingHandle.h>
#include "AddressManager.h"
@ -51,8 +52,10 @@ private slots:
void requestError(QNetworkReply& errorReply);
private:
UserActivityLogger() {};
UserActivityLogger();
Setting::Handle<bool> _disabled { "UserActivityLoggerDisabled", false };
QElapsedTimer _timer;
};
#endif // hifi_UserActivityLogger_h

View file

@ -69,7 +69,7 @@ std::vector<vec3> polygon() {
std::vector<vec3> result;
result.reserve(SIDES);
double angleIncrement = 2.0 * M_PI / SIDES;
for (size_t i = 0; i < SIDES; ++i) {
for (size_t i = 0; i < SIDES; i++) {
double angle = (double)i * angleIncrement;
result.push_back(vec3{ cos(angle) * 0.5, 0.0, sin(angle) * 0.5 });
}
@ -172,20 +172,20 @@ void setupFlatShape(GeometryCache::ShapeData& shapeData, const geometry::Solid<N
vertices.reserve(N * faceCount * 2);
solidIndices.reserve(faceIndexCount * faceCount);
for (size_t f = 0; f < faceCount; ++f) {
for (size_t f = 0; f < faceCount; f++) {
const Face<N>& face = shape.faces[f];
// Compute the face normal
vec3 faceNormal = shape.getFaceNormal(f);
// Create the vertices for the face
for (Index i = 0; i < N; ++i) {
for (Index i = 0; i < N; i++) {
Index originalIndex = face[i];
vertices.push_back(shape.vertices[originalIndex]);
vertices.push_back(faceNormal);
}
// Create the wire indices for unseen edges
for (Index i = 0; i < N; ++i) {
for (Index i = 0; i < N; i++) {
Index a = i;
Index b = (i + 1) % N;
auto token = indexToken(face[a], face[b]);
@ -197,7 +197,7 @@ void setupFlatShape(GeometryCache::ShapeData& shapeData, const geometry::Solid<N
}
// Create the solid face indices
for (Index i = 0; i < N - 2; ++i) {
for (Index i = 0; i < N - 2; i++) {
solidIndices.push_back(0 + baseVertex);
solidIndices.push_back(i + 1 + baseVertex);
solidIndices.push_back(i + 2 + baseVertex);
@ -229,10 +229,10 @@ void setupSmoothShape(GeometryCache::ShapeData& shapeData, const geometry::Solid
solidIndices.reserve(faceIndexCount * faceCount);
for (size_t f = 0; f < faceCount; ++f) {
for (size_t f = 0; f < faceCount; f++) {
const Face<N>& face = shape.faces[f];
// Create the wire indices for unseen edges
for (Index i = 0; i < N; ++i) {
for (Index i = 0; i < N; i++) {
Index a = face[i];
Index b = face[(i + 1) % N];
auto token = indexToken(a, b);
@ -244,7 +244,7 @@ void setupSmoothShape(GeometryCache::ShapeData& shapeData, const geometry::Solid
}
// Create the solid face indices
for (Index i = 0; i < N - 2; ++i) {
for (Index i = 0; i < N - 2; i++) {
solidIndices.push_back(face[i] + baseVertex);
solidIndices.push_back(face[i + 1] + baseVertex);
solidIndices.push_back(face[i + 2] + baseVertex);
@ -256,23 +256,30 @@ void setupSmoothShape(GeometryCache::ShapeData& shapeData, const geometry::Solid
}
template <uint32_t N>
void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer) {
void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer, bool isConical = false) {
using namespace geometry;
Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE);
VertexVector vertices;
IndexVector solidIndices, wireIndices;
// Top and bottom faces
// Top (if not conical) and bottom faces
std::vector<vec3> shape = polygon<N>();
for (const vec3& v : shape) {
vertices.push_back(vec3(v.x, 0.5f, v.z));
vertices.push_back(vec3(0, 1, 0));
if (isConical) {
for (uint32_t i = 0; i < N; i++) {
vertices.push_back(vec3(0.0f, 0.5f, 0.0f));
vertices.push_back(vec3(0.0f, 1.0f, 0.0f));
}
} else {
for (const vec3& v : shape) {
vertices.push_back(vec3(v.x, 0.5f, v.z));
vertices.push_back(vec3(0.0f, 1.0f, 0.0f));
}
}
for (const vec3& v : shape) {
vertices.push_back(vec3(v.x, -0.5f, v.z));
vertices.push_back(vec3(0, -1, 0));
vertices.push_back(vec3(0.0f, -1.0f, 0.0f));
}
for (uint32_t i = 2; i < N; ++i) {
for (uint32_t i = 2; i < N; i++) {
solidIndices.push_back(baseVertex + 0);
solidIndices.push_back(baseVertex + i);
solidIndices.push_back(baseVertex + i - 1);
@ -280,7 +287,7 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver
solidIndices.push_back(baseVertex + i + N - 1);
solidIndices.push_back(baseVertex + i + N);
}
for (uint32_t i = 1; i <= N; ++i) {
for (uint32_t i = 1; i <= N; i++) {
wireIndices.push_back(baseVertex + (i % N));
wireIndices.push_back(baseVertex + i - 1);
wireIndices.push_back(baseVertex + (i % N) + N);
@ -290,12 +297,12 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver
// Now do the sides
baseVertex += 2 * N;
for (uint32_t i = 0; i < N; ++i) {
for (uint32_t i = 0; i < N; i++) {
vec3 left = shape[i];
vec3 right = shape[(i + 1) % N];
vec3 normal = glm::normalize(left + right);
vec3 topLeft = vec3(left.x, 0.5f, left.z);
vec3 topRight = vec3(right.x, 0.5f, right.z);
vec3 topLeft = (isConical ? vec3(0.0f, 0.5f, 0.0f) : vec3(left.x, 0.5f, left.z));
vec3 topRight = (isConical ? vec3(0.0f, 0.5f, 0.0f) : vec3(right.x, 0.5f, right.z));
vec3 bottomLeft = vec3(left.x, -0.5f, left.z);
vec3 bottomRight = vec3(right.x, -0.5f, right.z);
@ -325,6 +332,41 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver
shapeData.setupIndices(indexBuffer, solidIndices, wireIndices);
}
void drawCircle(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer) {
// Draw a circle with radius 1/4th the size of the bounding box
using namespace geometry;
Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE);
VertexVector vertices;
IndexVector solidIndices, wireIndices;
const int NUM_CIRCLE_VERTICES = 64;
std::vector<vec3> shape = polygon<NUM_CIRCLE_VERTICES>();
for (const vec3& v : shape) {
vertices.push_back(vec3(v.x, 0.0f, v.z));
vertices.push_back(vec3(0.0f, 0.0f, 0.0f));
}
for (uint32_t i = 2; i < NUM_CIRCLE_VERTICES; i++) {
solidIndices.push_back(baseVertex + 0);
solidIndices.push_back(baseVertex + i);
solidIndices.push_back(baseVertex + i - 1);
solidIndices.push_back(baseVertex + NUM_CIRCLE_VERTICES);
solidIndices.push_back(baseVertex + i + NUM_CIRCLE_VERTICES - 1);
solidIndices.push_back(baseVertex + i + NUM_CIRCLE_VERTICES);
}
for (uint32_t i = 1; i <= NUM_CIRCLE_VERTICES; i++) {
wireIndices.push_back(baseVertex + (i % NUM_CIRCLE_VERTICES));
wireIndices.push_back(baseVertex + i - 1);
wireIndices.push_back(baseVertex + (i % NUM_CIRCLE_VERTICES) + NUM_CIRCLE_VERTICES);
wireIndices.push_back(baseVertex + (i - 1) + NUM_CIRCLE_VERTICES);
}
shapeData.setupVertices(vertexBuffer, vertices);
shapeData.setupIndices(indexBuffer, solidIndices, wireIndices);
}
// FIXME solids need per-face vertices, but smooth shaded
// components do not. Find a way to support using draw elements
// or draw arrays as appropriate
@ -357,8 +399,8 @@ void GeometryCache::buildShapes() {
Index baseVertex = (Index)(_shapeVertices->getSize() / SHAPE_VERTEX_STRIDE);
ShapeData& shapeData = _shapes[Line];
shapeData.setupVertices(_shapeVertices, VertexVector {
vec3(-0.5, 0, 0), vec3(-0.5f, 0, 0),
vec3(0.5f, 0, 0), vec3(0.5f, 0, 0)
vec3(-0.5f, 0.0f, 0.0f), vec3(-0.5f, 0.0f, 0.0f),
vec3(0.5f, 0.0f, 0.0f), vec3(0.5f, 0.0f, 0.0f)
});
IndexVector wireIndices;
// Only two indices
@ -367,20 +409,22 @@ void GeometryCache::buildShapes() {
shapeData.setupIndices(_shapeIndices, IndexVector(), wireIndices);
}
// Not implememented yet:
//Triangle,
extrudePolygon<3>(_shapes[Triangle], _shapeVertices, _shapeIndices);
//Hexagon,
extrudePolygon<6>(_shapes[Hexagon], _shapeVertices, _shapeIndices);
//Octagon,
extrudePolygon<8>(_shapes[Octagon], _shapeVertices, _shapeIndices);
//Quad,
//Circle,
//Torus,
//Cone,
//Cylinder,
extrudePolygon<64>(_shapes[Cylinder], _shapeVertices, _shapeIndices);
//Cone,
extrudePolygon<64>(_shapes[Cone], _shapeVertices, _shapeIndices, true);
//Circle
drawCircle(_shapes[Circle], _shapeVertices, _shapeIndices);
// Not implememented yet:
//Quad,
//Torus,
}
gpu::Stream::FormatPointer& getSolidStreamFormat() {
@ -597,7 +641,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con
auto pointCount = points.size();
auto colorCount = colors.size();
int compactColor = 0;
for (auto i = 0; i < pointCount; ++i) {
for (auto i = 0; i < pointCount; i++) {
const auto& point = points[i];
*(vertex++) = point.x;
*(vertex++) = point.y;
@ -674,7 +718,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
const glm::vec3 NORMAL(0.0f, 0.0f, 1.0f);
auto pointCount = points.size();
auto colorCount = colors.size();
for (auto i = 0; i < pointCount; ++i) {
for (auto i = 0; i < pointCount; i++) {
const glm::vec3& point = points[i];
if (i < colorCount) {
const glm::vec4& color = colors[i];

View file

@ -142,8 +142,8 @@ public:
Dodecahedron,
Icosahedron,
Torus, // not yet implemented
Cone, // not yet implemented
Cylinder, // not yet implemented
Cone,
Cylinder,
NUM_SHAPES,
};

View file

@ -618,7 +618,6 @@ var toolBar = (function () {
that.toggle = function () {
that.setActive(!isActive);
activeButton.editProperties({isActive: isActive});
if (!isActive) {
tablet.gotoHomeScreen();
}
@ -642,6 +641,8 @@ var toolBar = (function () {
enabled: active
}));
isActive = active;
activeButton.editProperties({isActive: isActive});
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
if (!isActive) {

View file

@ -610,6 +610,7 @@ hr {
.dropdown dl[dropped="true"] {
color: #404040;
background: linear-gradient(#afafaf, #afafaf);
z-index: 998;
}
.dropdown dt {
@ -657,7 +658,8 @@ hr {
font-family: FiraSans-SemiBold;
font-size: 15px;
color: #404040;
background-color: #afafaf
background-color: #afafaf;
z-index: 999;
}
.dropdown li:hover {
background-color: #00b4ef;

View file

@ -503,7 +503,7 @@ div.jsoneditor-contextmenu-root {
div.jsoneditor-contextmenu {
position: absolute;
box-sizing: content-box;
z-index: 99999;
z-index: 998;
}
div.jsoneditor-contextmenu ul,

View file

@ -51,6 +51,9 @@
<option value="Hexagon">Hexagon</option>
<option value="Triangle">Triangle</option>
<option value="Octagon">Octagon</option>
<option value="Cylinder">Cylinder</option>
<option value="Cone">Cone</option>
<option value="Circle">Circle</option>
</select>
</div>
<div class="property text">

View file

@ -43,7 +43,7 @@ var LOCAL_TABLET_MODEL_PATH = Script.resourcesPath() + "meshes/tablet-with-home-
// returns object with two fields:
// * position - position in front of the user
// * rotation - rotation of entity so it faces the user.
function calcSpawnInfo(hand, height) {
function calcSpawnInfo(hand, tabletHeight) {
var finalPosition;
var headPos = (HMD.active && Camera.mode === "first person") ? HMD.position : Camera.position;
@ -53,30 +53,35 @@ function calcSpawnInfo(hand, height) {
hand = NO_HANDS;
}
var handController = null;
if (HMD.active && hand !== NO_HANDS) {
var handController = getControllerWorldLocation(hand, true);
handController = getControllerWorldLocation(hand, true);
}
var TABLET_UP_OFFSET = 0.1;
var TABLET_FORWARD_OFFSET = 0.1;
var normal = Vec3.multiplyQbyV(handController.rotation, {x: 0, y: -1, z: 0});
var pitch = Math.asin(normal.y);
var MAX_PITCH = Math.PI / 4;
if (pitch < -MAX_PITCH) {
pitch = -MAX_PITCH;
} else if (pitch > MAX_PITCH) {
pitch = MAX_PITCH;
if (handController && handController.valid) {
// Orient tablet per hand pitch and yaw.
// Angle it back similar to holding it like a book.
// Move tablet up so that hand is at bottom.
// Move tablet back so that hand is in front.
var position = handController.position;
var rotation = handController.rotation;
if (hand === Controller.Standard.LeftHand) {
rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(0, 90, 0));
} else {
rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(0, -90, 0));
}
var normal = Vec3.multiplyQbyV(rotation, Vec3.UNIT_NEG_Y);
var lookAt = Quat.lookAt(Vec3.ZERO, normal, Vec3.multiplyQbyV(MyAvatar.orientation, Vec3.UNIT_Y));
var TABLET_RAKE_ANGLE = 30;
rotation = Quat.multiply(Quat.angleAxis(TABLET_RAKE_ANGLE, Vec3.multiplyQbyV(lookAt, Vec3.UNIT_X)), lookAt);
// rebuild normal from pitch and heading.
var heading = Math.atan2(normal.z, normal.x);
normal = {x: Math.cos(heading), y: Math.sin(pitch), z: Math.sin(heading)};
var position = Vec3.sum(handController.position, {x: 0, y: TABLET_UP_OFFSET, z: 0});
var rotation = Quat.lookAt({x: 0, y: 0, z: 0}, normal, Y_AXIS);
var offset = Vec3.multiplyQbyV(rotation, {x: 0, y: height / 2, z: TABLET_FORWARD_OFFSET});
var RELATIVE_SPAWN_OFFSET = { x: 0, y: 0.4, z: 0.05 };
position = Vec3.sum(position, Vec3.multiplyQbyV(rotation, Vec3.multiply(tabletHeight, RELATIVE_SPAWN_OFFSET)));
return {
position: Vec3.sum(offset, position),
position: position,
rotation: rotation
};
} else {

View file

@ -48,7 +48,7 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString outputPath) {
_baker->moveToThread(qApp->getNextWorkerThread());
} else {
qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl;
return;
QApplication::exit(1);
}
// invoke the bake method on the baker thread
@ -60,5 +60,5 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString outputPath) {
void BakerCLI::handleFinishedBaker() {
qCDebug(model_baking) << "Finished baking file.";
QApplication::quit();
QApplication::exit(_baker.get()->hasErrors());
}