Merge branch 'master' into feature/qt-update

This commit is contained in:
Julian Groß 2021-04-16 01:55:51 +02:00 committed by GitHub
commit 1cadfcc284
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 4809 additions and 1757 deletions

View file

@ -41,8 +41,15 @@ endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/_env/EXTERNAL_BUILD_ASSETS.txt" "${EXTERNAL_BUILD_ASSETS}")
MESSAGE(STATUS "EXTERNAL_BUILD_ASSETS: ${EXTERNAL_BUILD_ASSETS}")
# read USE_GLES enviroment variable and sets it as GLES option
# TODO still gets overwritten by "use GLES on linux aarch64"
set(GLES_OPTION "$ENV{USE_GLES}")
# use GLES on linux aarch64
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(GLES_OPTION ON)
endif()
# Will affect VCPKG dependencies
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/_env/USE_GLES.txt" "${GLES_OPTION}")
MESSAGE(STATUS "GLES_OPTION: ${GLES_OPTION}")
@ -187,7 +194,7 @@ else ()
set(PLATFORM_QT_COMPONENTS WebEngine Xml)
endif ()
if (USE_GLES AND (NOT ANDROID))
if (USE_GLES AND (NOT ANDROID AND NOT UNIX))
set(DISABLE_QML_OPTION ON)
endif()

View file

@ -54,7 +54,7 @@ elseif(APPLE)
LOG 1
)
elseif(NOT ANDROID)
elseif(NOT ANDROID AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
# FIXME need to account for different architectures
set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${SOURCE_DIR}/redistributable_bin/linux64/libsteam_api.so CACHE STRING INTERNAL)

View file

@ -30,7 +30,7 @@ macro(SETUP_HIFI_LIBRARY)
foreach(SRC ${AVX2_SRCS})
if (WIN32)
set_source_files_properties(${SRC} PROPERTIES COMPILE_FLAGS /arch:AVX2)
elseif (APPLE OR (UNIX AND NOT ANDROID))
elseif (APPLE OR (UNIX AND NOT ANDROID AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64"))
set_source_files_properties(${SRC} PROPERTIES COMPILE_FLAGS "-mavx2 -mfma")
endif()
endforeach()

View file

@ -1,4 +1,4 @@
Source: hifi-client-deps
Version: 0.1
Description: Collected dependencies for High Fidelity applications
Build-Depends: hifi-deps, aristo (windows), glslang, liblo (windows), nlohmann-json, openvr (linux|windows), quazip (!android), sdl2 (!android), spirv-cross (!android), spirv-tools (!android), sranipal (windows), vulkanmemoryallocator
Build-Depends: hifi-deps, aristo (windows), glslang, liblo (windows), nlohmann-json, openvr ((linux&!arm)|windows), quazip (!android), sdl2 (!android), spirv-cross (!android), spirv-tools (!android), sranipal (windows), vulkanmemoryallocator

View file

@ -0,0 +1,37 @@
commit 8909ba06ea1893a6e028836fbade28fd115ee1cc
Author: Julian Groß <julian.g@posteo.de>
Date: Wed Feb 17 04:51:49 2021 +0100
Enable building on aarch64 according to https://github.com/castano/nvidia-texture-tools/pull/309 and https://github.com/castano/nvidia-texture-tools/pull/322
diff --git a/src/nvcore/Debug.cpp b/src/nvcore/Debug.cpp
index 9ab4525..e335f97 100644
--- a/src/nvcore/Debug.cpp
+++ b/src/nvcore/Debug.cpp
@@ -1008,6 +1008,13 @@ void debug::dumpInfo()
#endif
}
+static va_list getEmptyVAList(va_list list, ...)
+{
+ va_start(list, list);
+ va_end(list);
+ return list;
+}
+
/// Dump callstack using the specified handler.
void debug::dumpCallstack(MessageHandler *messageHandler, int callstackLevelsToSkip /*= 0*/)
{
@@ -1020,8 +1027,11 @@ void debug::dumpCallstack(MessageHandler *messageHandler, int callstackLevelsToS
Array<const char *> lines;
writeStackTrace(trace, size, callstackLevelsToSkip + 1, lines); // + 1 to skip the call to dumpCallstack
+ va_list empty;
+ empty = getEmptyVAList(empty);
+
for (uint i = 0; i < lines.count(); i++) {
- messageHandler->log(lines[i], NULL);
+ messageHandler->log(lines[i], empty);
delete lines[i];
}
}

View file

@ -0,0 +1,25 @@
From 84dc6af45b1176a2b82d089239665cb3dc1584de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julian=20Gro=C3=9F?= <firedefender1@googlemail.com>
Date: Wed, 23 Dec 2020 07:33:39 +0100
Subject: [PATCH] Hack: remove #include <sys/sysctl.h> to build on
linux-aarch64
---
src/nvthread/nvthread.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/nvthread/nvthread.cpp b/src/nvthread/nvthread.cpp
index 2b3abe6..cec9f4f 100644
--- a/src/nvthread/nvthread.cpp
+++ b/src/nvthread/nvthread.cpp
@@ -11,7 +11,6 @@
#include <unistd.h>
#elif NV_OS_UNIX
#include <sys/types.h>
-#include <sys/sysctl.h>
#include <unistd.h>
#elif NV_OS_DARWIN
#import <stdio.h>
--
2.17.1

View file

@ -15,6 +15,13 @@ vcpkg_from_github(
HEAD_REF master
)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64)
vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES "${CMAKE_CURRENT_LIST_DIR}/0001-Build-on-aarch64.patch" "${CMAKE_CURRENT_LIST_DIR}/0002-Hack-remove-include-sysctl.h-to-build-on-linux-a.patch"
)
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS

View file

@ -53,6 +53,7 @@ endif()
# OS dependent information
system = platform.system()
cpu_architecture = platform.machine()
if 'Windows' == system:
self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-windows.tar.gz'
@ -62,23 +63,61 @@ endif()
import distro
dist = distro.linux_distribution()
if distro.id() == 'ubuntu':
u_major = int( distro.major_version() )
u_minor = int( distro.minor_version() )
if 'x86_64' == cpu_architecture:
if distro.id() == 'ubuntu':
u_major = int( distro.major_version() )
u_minor = int( distro.minor_version() )
if u_major == 18:
self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-ubuntu-18.04-amd64.tar.xz'
elif u_major > 19:
print("We don't support " + distro.name(pretty=True) + " yet. Perhaps consider helping us out?")
raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!')
if u_major == 18:
self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-ubuntu-18.04-amd64.tar.xz'
elif u_major > 19:
print("We don't support " + distro.name(pretty=True) + " yet. Perhaps consider helping us out?")
raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!')
else:
print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading.");
raise Exception('UNKNOWN LINUX DISTRO VERSION!!!')
else:
print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading.");
raise Exception('UNKNOWN LINUX DISTRO VERSION!!!')
print("Sorry, " + distro.name(pretty=True) + " is not supported on x86_64. Please consider helping us out.")
print("It's also possible to build Qt for your distribution, please see the documentation at:")
print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder")
raise Exception('UNKNOWN LINUX VERSION!!!')
elif 'aarch64' == cpu_architecture:
if distro.id() == 'ubuntu':
u_major = int( distro.major_version() )
u_minor = int( distro.minor_version() )
if u_major == 18:
self.qtUrl = 'http://motofckr9k.ddns.net/vircadia_packages/qt5-install-5.15.2-ubuntu-18.04-aarch64_test.tar.xz'
elif u_major > 19:
print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?")
raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!')
else:
print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading.");
raise Exception('UNKNOWN LINUX DISTRO VERSION!!!')
elif distro.id() == 'debian':
u_major = int( distro.major_version() )
u_minor = int( distro.minor_version() )
if u_major == 10:
#self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-16.04-with-symbols.tar.gz'
print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?")
raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!')
elif u_major > 10:
print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?")
raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!')
else:
print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading.");
raise Exception('UNKNOWN LINUX DISTRO VERSION!!!')
else:
print("Sorry, " + distro.name(pretty=True) + " is not supported on aarch64. Please consider helping us out.")
print("It's also possible to build Qt for your distribution, please see the documentation at:")
print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder")
raise Exception('UNKNOWN LINUX VERSION!!!')
else:
print("Sorry, " + distro.name(pretty=True) + " is not supported. Please consider helping us out.")
print("It's also possible to build Qt for your distribution, please see the documentation at:")
print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder")
raise Exception('UNKNOWN LINUX VERSION!!!')
raise Exception('UNKNOWN CPU ARCHITECTURE!!!')
else:
print("System : " + platform.system())
print("Architecture: " + platform.architecture())

View file

@ -44,13 +44,14 @@ endif()
self.assets_url = self.readVar('EXTERNAL_BUILD_ASSETS')
# The noClean flag indicates we're doing weird dependency maintenance stuff
# i.e. we've got an explicit checkout of vcpkg and we don't want the script to
# do stuff it might otherwise do. It typically indicates that we're using our
# i.e. we've got an explicit checkout of vcpkg and we don't want the script to
# do stuff it might otherwise do. It typically indicates that we're using our
# own git checkout of vcpkg and manually managing it
self.noClean = False
# OS dependent information
system = platform.system()
machine = platform.machine()
if 'HIFI_VCPKG_PATH' in os.environ:
self.path = os.environ['HIFI_VCPKG_PATH']
@ -105,6 +106,12 @@ endif()
self.bootstrapEnv['CXXFLAGS'] = '-D_CTERMID_H_'
if usePrebuilt:
self.prebuiltArchive = self.assets_url + "/dependencies/vcpkg/builds/vcpkg-osx.tgz%3FversionId=6JrIMTdvpBF3MAsjA92BMkO79Psjzs6Z"
elif 'Linux' == system and 'aarch64' == machine:
self.exe = os.path.join(self.path, 'vcpkg')
self.bootstrapCmds = [ os.path.join(self.path, 'bootstrap-vcpkg.sh'), '-disableMetrics' ]
self.vcpkgUrl = 'http://motofckr9k.ddns.net/vircadia_packages/vcpkg-2020.11-1_arm64.tar.xz'
self.vcpkgHash = 'f39fa1c34d2ba820954b8ce4acc05e3d0ce5fa5efe5440516ba910ff222c85c658ba4bbfc92b3fa6cbb594f99be115cda69ebe44ed38d4d3988058fb1faefbb3'
self.hostTriplet = 'arm64-linux'
else:
self.exe = os.path.join(self.path, 'vcpkg')
self.bootstrapCmds = [ os.path.join(self.path, 'bootstrap-vcpkg.sh'), '-disableMetrics' ]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,59 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// 2020 Silverfish.
//material sequencer, put on a material entity (server script) to make it iterate through discrete steps of X UV offset.
/*UserData:
{
"verticalOffset": 0,
"segments": 16,
"updateInterval": 250
}
*/
(function() {
var DEFAULT_VERTICAL_OFFSET = 0.0;
var DEFAULT_HORIZONTAL_SPEED = 1;
var DEFAULT_UPDATE_INTERVAL = 1000;
var DEFAULT_SEGMENTS = 16;
var self = this;
var _entityID;
this.preload = function(entityID) {
_entityID = entityID;
var verticalOffset = DEFAULT_VERTICAL_OFFSET;
var updateInterval = DEFAULT_UPDATE_INTERVAL;
var moveDistance = 1 / DEFAULT_SEGMENTS;
var verticalOffset = DEFAULT_VERTICAL_OFFSET;
var oldPosition = 0;
var currentPosition = 0;
var userData = JSON.parse(Entities.getEntityProperties(_entityID, ["userData"]).userData);
if (userData !== undefined) {
if (userData.segments !== undefined) {
moveDistance = 1 / userData.segments;
}
if (userData.verticalOffset !== undefined) {
verticalOffset = userData.verticalOffset;
}
if (userData.updateInterval !== undefined) {
updateInterval = userData.updateInterval;
}
}
self.intervalID = Script.setInterval(function() {
if(currentPosition >= 1){
currentPosition = 0;
oldPosition = 0;
}
Entities.editEntity(_entityID, { materialMappingPos: { x: currentPosition, y: verticalOffset}});
// print("current Pos: " + currentPosition);
currentPosition = oldPosition + moveDistance;
oldPosition = currentPosition;
}, updateInterval);
};
this.unload = function() {
Script.clearInterval(self.intervalID);
}
});

View file

@ -0,0 +1,182 @@
//
// mirrorClient.js
//
// Created by Patrick Manalich
// Edited by Rebecca Stankus on 8/30/17.
// Edited by David Back on 11/17/17.
// Edited by Anna Brewer on 7/12/19.
// Copyright 2017 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
//
// Attach `mirrorClient.js` to a box entity whose z dimension is very small,
// and whose x and y dimensions are up to you. See comments in `mirrorReflection.js`
// for more information about the mirror on/off zone.
"use strict";
(function () { // BEGIN LOCAL SCOPE
// VARIABLES
/* globals utils, Render */
var _this = this;
var MAX_MIRROR_RESOLUTION_SIDE_PX = 960; // The max pixel resolution of the long side of the mirror
var ZERO_ROT = { w: 1, x: 0, y: 0, z: 0 }; // Constant quaternion for a rotation of 0
var FAR_CLIP_DISTANCE = 16; // The far clip distance for the spectator camera when the mirror is on
var mirrorLocalEntityID = false; // The entity ID of the local entity that displays the mirror reflection
var mirrorLocalEntityRunning; // True if mirror local entity is reflecting, false otherwise
var mirrorLocalEntityOffset = 0.01; // The distance between the center of the mirror and the mirror local entity
var spectatorCameraConfig = Render.getConfig("SecondaryCamera"); // Render configuration for the spectator camera
var lastDimensions = { x: 0, y: 0 }; // The previous dimensions of the mirror
var previousFarClipDistance; // Store the specator camera's previous far clip distance that we override for the mirror
// LOCAL FUNCTIONS
function isPositionInsideBox(position, boxProperties) {
var localPosition = Vec3.multiplyQbyV(Quat.inverse(boxProperties.rotation),
Vec3.subtract(MyAvatar.position, boxProperties.position));
var halfDimensions = Vec3.multiply(boxProperties.dimensions, 0.5);
return -halfDimensions.x <= localPosition.x &&
halfDimensions.x >= localPosition.x &&
-halfDimensions.y <= localPosition.y &&
halfDimensions.y >= localPosition.y &&
-halfDimensions.z <= localPosition.z &&
halfDimensions.z >= localPosition.z;
}
// When x or y dimensions of the mirror change - reset the resolution of the
// spectator camera and edit the mirror local entity to adjust for the new dimensions
function updateMirrorDimensions(forceUpdate) {
if (!mirrorLocalEntityID) {
return;
}
if (mirrorLocalEntityRunning) {
var newDimensions = Entities.getEntityProperties(_this.entityID, 'dimensions').dimensions;
if (forceUpdate === true || (newDimensions.x != lastDimensions.x || newDimensions.y != lastDimensions.y)) {
var mirrorResolution = _this.calculateMirrorResolution(newDimensions);
spectatorCameraConfig.resetSizeSpectatorCamera(mirrorResolution.x, mirrorResolution.y);
Entities.editEntity(mirrorLocalEntityID, {
dimensions: {
x: (Math.max(newDimensions.x, newDimensions.y)),
y: (Math.max(newDimensions.x, newDimensions.y)),
z: 0
}
});
}
lastDimensions = newDimensions;
}
}
// Takes in an mirror scalar number which is used for the index of "halfDimSigns" that is needed to adjust the mirror
// local entity's position. Deletes and re-adds the mirror local entity so the url and position are updated.
function createMirrorLocalEntity() {
if (mirrorLocalEntityID) {
Entities.deleteEntity(mirrorLocalEntityID);
mirrorLocalEntityID = false;
}
if (mirrorLocalEntityRunning) {
mirrorLocalEntityID = Entities.addEntity({
type: "Image",
name: "mirrorLocalEntity",
imageURL: "resource://spectatorCameraFrame",
emissive: true,
parentID: _this.entityID,
alpha: 1,
localPosition: {
x: 0,
y: 0,
z: mirrorLocalEntityOffset
},
localRotation: Quat.fromPitchYawRollDegrees(0, 0, 180),
isVisibleInSecondaryCamera: false
}, "local");
updateMirrorDimensions(true);
}
}
_this.calculateMirrorResolution = function(entityDimensions) {
var mirrorResolutionX, mirrorResolutionY;
if (entityDimensions.x > entityDimensions.y) {
mirrorResolutionX = MAX_MIRROR_RESOLUTION_SIDE_PX;
mirrorResolutionY = Math.round(mirrorResolutionX * entityDimensions.y / entityDimensions.x);
} else {
mirrorResolutionY = MAX_MIRROR_RESOLUTION_SIDE_PX;
mirrorResolutionX = Math.round(mirrorResolutionY * entityDimensions.x / entityDimensions.y);
}
var resolution = {
"x": mirrorResolutionX,
"y": mirrorResolutionY
};
return resolution;
};
// Sets up spectator camera to render the mirror, calls 'createMirrorLocalEntity' once to set up
// mirror local entity, then connects 'updateMirrorDimensions' to update dimension changes
_this.mirrorLocalEntityOn = function(onPreload) {
if (!mirrorLocalEntityRunning) {
if (!spectatorCameraConfig.attachedEntityId) {
mirrorLocalEntityRunning = true;
spectatorCameraConfig.mirrorProjection = true;
spectatorCameraConfig.attachedEntityId = _this.entityID;
previousFarClipDistance = spectatorCameraConfig.farClipPlaneDistance;
spectatorCameraConfig.farClipPlaneDistance = FAR_CLIP_DISTANCE;
var entityProperties = Entities.getEntityProperties(_this.entityID, ['dimensions']);
var mirrorEntityDimensions = entityProperties.dimensions;
var initialResolution = _this.calculateMirrorResolution(mirrorEntityDimensions);
spectatorCameraConfig.resetSizeSpectatorCamera(initialResolution.x, initialResolution.y);
spectatorCameraConfig.enableSecondaryCameraRenderConfigs(true);
createMirrorLocalEntity();
Script.update.connect(updateMirrorDimensions);
} else {
print("Cannot turn on mirror if spectator camera is already in use");
}
}
};
// Resets spectator camera, deletes the mirror local entity, and disconnects 'updateMirrorDimensions'
_this.mirrorLocalEntityOff = function() {
if (mirrorLocalEntityRunning) {
spectatorCameraConfig.enableSecondaryCameraRenderConfigs(false);
spectatorCameraConfig.mirrorProjection = false;
spectatorCameraConfig.attachedEntityId = null;
spectatorCameraConfig.farClipPlaneDistance = previousFarClipDistance;
if (mirrorLocalEntityID) {
Entities.deleteEntity(mirrorLocalEntityID);
mirrorLocalEntityID = false;
}
Script.update.disconnect(updateMirrorDimensions);
mirrorLocalEntityRunning = false;
}
};
// ENTITY FUNCTIONS
_this.preload = function(entityID) {
_this.entityID = entityID;
mirrorlocalEntityRunning = false;
// If avatar is already inside the mirror zone at the time preload is called then turn on the mirror
var children = Entities.getChildrenIDs(_this.entityID);
var childZero = Entities.getEntityProperties(children[0]);
if (isPositionInsideBox(MyAvatar.position, {
position: childZero.position,
rotation: childZero.rotation,
dimensions: childZero.dimensions
})) {
_this.mirrorLocalEntityOn(true);
}
};
// Turn off mirror on unload
_this.unload = function(entityID) {
_this.mirrorLocalEntityOff();
};
});

View file

@ -0,0 +1,32 @@
//
// mirrorReflection.js
//
// Created by Rebecca Stankus on 8/30/17.
// Copyright 2017 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
//
// Attach `mirrorReflection.js` to a zone entity that is parented to
// the box entity whose Script is `mirrorClient.js`.
// When a user enters this zone, the mirror will turn on.
// When a user leaves this zone, the mirror will turn off.
(function () {
var mirrorID, reflectionAreaID;
// get id of reflection area and mirror
this.preload = function(entityID) {
reflectionAreaID = entityID;
mirrorID = Entities.getEntityProperties(reflectionAreaID, 'parentID').parentID;
};
// when avatar enters reflection area, begin reflecting
this.enterEntity = function(entityID){
Entities.callEntityMethod(mirrorID, 'mirrorLocalEntityOn');
};
// when avatar leaves reflection area, stop reflecting
this.leaveEntity = function (entityID) {
Entities.callEntityMethod(mirrorID, 'mirrorLocalEntityOff');
};
});

View file

@ -0,0 +1,47 @@
//
// portal.js
// Created by Zach Fox on 2019-05-23
// Copyright 2019 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
(function () {
var Portal = function() {};
Portal.prototype = {
enterEntity: function (id) {
var properties = Entities.getEntityProperties(id, ["userData"]);
var userData;
try {
userData = JSON.parse(properties.userData);
} catch (e) {
console.error("Error parsing userData: ", e);
}
if (userData) {
if (userData.destination) {
var destination = userData.destination;
if (userData.destination.indexOf("bookmark:") > -1) {
var bookmarkName = userData.destination.replace("bookmark:", "");
destination = LocationBookmarks.getAddress(bookmarkName);
}
Window.location = destination;
} else {
console.log("Please specify `destination` inside this entity's `userData`!");
return;
}
} else {
console.log("Please specify this entity's `userData`! See README.md for instructions.");
return;
}
}
};
return new Portal();
});

View file

@ -0,0 +1,202 @@
/* eslint-disable no-magic-numbers */
//
// soundEmitter.js
//
// Created by Zach Fox on 2019-07-05
// Copyright High Fidelity 2019
//
// Licensed under the Apache 2.0 License
// See accompanying license file or http://apache.org/
//
(function() {
var that;
var SOUND_EMITTER_UPDATE_INTERVAL_MS = 500;
var DEFAULT_AUDIO_INJECTOR_OPTIONS = {
"position": {
"x": 0,
"y": 0,
"z": 0
},
"volume": 0.5,
"loop": false,
"localOnly": false
};
var SoundEmitter = function() {
that = this;
that.entityID = false;
that.soundObjectURL = false;
that.soundObject = false;
that.audioInjector = false;
that.audioInjectorOptions = DEFAULT_AUDIO_INJECTOR_OPTIONS;
that.signalsConnected = {};
that.soundEmitterUpdateInterval = false;
};
SoundEmitter.prototype = {
preload: function(entityID) {
that.entityID = entityID;
var properties = Entities.getEntityProperties(that.entityID, ["userData"]);
var userData;
try {
userData = JSON.parse(properties.userData);
} catch (e) {
console.error("Error parsing userData: ", e);
}
if (userData) {
if (userData.soundURL && userData.soundURL.length > 0) {
that.handleNewSoundURL(userData.soundURL);
} else {
console.log("Please specify this entity's `userData`! See README.md for instructions.");
return;
}
} else {
console.log("Please specify this entity's `userData`! See README.md for instructions.");
return;
}
},
clearCurrentSoundData: function() {
that.soundObjectURL = false;
if (that.signalsConnected["soundObjectReady"]) {
that.soundObject.ready.disconnect(that.updateSoundEmitter);
that.signalsConnected["soundObjectReady"] = false;
}
that.soundObject = false;
if (that.audioInjector) {
if (that.audioInjector.playing) {
that.audioInjector.stop();
}
that.audioInjector = false;
}
that.audioInjectorOptions = DEFAULT_AUDIO_INJECTOR_OPTIONS;
if (that.soundEmitterUpdateInterval) {
Script.clearInterval(that.soundEmitterUpdateInterval);
that.soundEmitterUpdateInterval = false;
}
},
unload: function() {
that.clearCurrentSoundData();
},
handleNewSoundURL: function(newSoundURL) {
that.clearCurrentSoundData();
that.soundObjectURL = newSoundURL;
that.soundObject = SoundCache.getSound(that.soundObjectURL);
if (that.soundObject.downloaded) {
that.updateSoundEmitter();
} else {
that.soundObject.ready.connect(that.updateSoundEmitter);
that.signalsConnected["soundObjectReady"] = true;
}
},
positionChanged: function(newPos) {
return (newPos.x !== that.audioInjectorOptions.position.x ||
newPos.y !== that.audioInjectorOptions.position.y ||
newPos.z !== that.audioInjectorOptions.position.z);
},
updateSoundEmitter: function() {
var properties = Entities.getEntityProperties(that.entityID, ["userData", "position", "script", "serverScripts"]);
var userData;
try {
userData = JSON.parse(properties.userData);
} catch (e) {
console.error("Error parsing userData: ", e);
}
var optionsChanged = false;
var shouldRestartPlayback = false;
var newPosition = properties.position;
if (userData) {
if (userData.soundURL && userData.soundURL.length > 0 && userData.soundURL !== that.soundObjectURL) {
console.log("Sound Emitter: User put a new sound URL into `userData`! Resetting...");
that.handleNewSoundURL(userData.soundURL);
return;
}
if (typeof(userData.volume) !== "undefined" && !isNaN(userData.volume) && userData.volume !== that.audioInjectorOptions.volume) {
optionsChanged = true;
that.audioInjectorOptions.volume = userData.volume;
}
if (typeof(userData.shouldLoop) !== "undefined" && userData.shouldLoop !== that.audioInjectorOptions.shouldLoop) {
optionsChanged = true;
if (!that.audioInjectorOptions.loop && userData.shouldLoop && that.audioInjector && !that.audioInjector.playing) {
shouldRestartPlayback = true;
}
that.audioInjectorOptions.loop = userData.shouldLoop;
}
if (typeof(userData.positionOverride) !== "undefined" && !isNaN(userData.positionOverride.x) &&
!isNaN(userData.positionOverride.y) && !isNaN(userData.positionOverride.z)) {
newPosition = userData.positionOverride;
}
} else {
console.log("Please specify this entity's `userData`! See README.md for instructions.");
that.clearCurrentSoundData();
return;
}
var localOnly = that.audioInjectorOptions.localOnly;
// If this script is attached as a client entity script...
if (properties.script.indexOf("soundEmitter.js") > -1) {
// ... Make sure that the audio injector IS local only.
localOnly = true;
// Else if this script is attached as a client server script...
} else if (properties.serverScripts.indexOf("soundEmitter.js") > -1) {
// ... Make sure that the audio injector IS NOT local only.
localOnly = false;
}
if (localOnly !== that.audioInjectorOptions.localOnly) {
optionsChanged = true;
that.audioInjectorOptions.localOnly = localOnly;
}
if (that.positionChanged(newPosition)) {
optionsChanged = true;
that.audioInjectorOptions["position"] = newPosition;
}
if (!that.audioInjector || shouldRestartPlayback) {
that.audioInjector = Audio.playSound(that.soundObject, that.audioInjectorOptions);
} else if (optionsChanged) {
that.audioInjector.setOptions(that.audioInjectorOptions);
}
if (!that.soundEmitterUpdateInterval) {
that.soundEmitterUpdateInterval = Script.setInterval(that.updateSoundEmitter, SOUND_EMITTER_UPDATE_INTERVAL_MS);
}
}
};
return new SoundEmitter();
});

View file

@ -0,0 +1,77 @@
'use strict';
//
// wizardLoader.js
//
// Created by Kalila L. on Feb 19 2021.
// Copyright 2021 Vircadia contributors.
//
// This script is used to load the onboarding wizard at the location of the entity it's on.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
(function() {
var CONFIG_WIZARD_WEB_URL = 'https://cdn-1.vircadia.com/us-e-1/DomainContent/Tutorial/Apps/configWizard/dist/index.html';
var loaderEntityID;
var configWizardEntityID;
function onWebAppEventReceived(sendingEntityID, event) {
if (sendingEntityID === configWizardEntityID) {
var eventJSON = JSON.parse(event);
if (eventJSON.command === 'first-run-wizard-ready') {
var objectToSend = {
command: 'script-to-web-initialize',
data: {
performancePreset: Performance.getPerformancePreset(),
refreshRateProfile: Performance.getRefreshRateProfile(),
displayName: MyAvatar.displayName
}
};
Entities.emitScriptEvent(configWizardEntityID, JSON.stringify(objectToSend));
}
if (eventJSON.command === 'complete-wizard') {
Performance.setPerformancePreset(eventJSON.data.performancePreset);
Performance.setRefreshRateProfile(eventJSON.data.refreshRateProfile);
MyAvatar.displayName = eventJSON.data.displayName;
Entities.deleteEntity(configWizardEntityID);
Entities.webEventReceived.disconnect(onWebAppEventReceived);
}
}
}
this.preload = function (entityID) {
loaderEntityID = entityID;
var loaderEntityProps = Entities.getEntityProperties(loaderEntityID, ['position', 'rotation']);
configWizardEntityID = Entities.addEntity({
type: 'Web',
sourceUrl: CONFIG_WIZARD_WEB_URL,
maxFPS: 60,
dpi: 20,
useBackground: false,
grab: {
grabbable: false
},
position: loaderEntityProps.position,
rotation: loaderEntityProps.rotation,
dimensions: { x: 1.4, y: 0.75, z: 0 }
}, 'local');
Entities.webEventReceived.connect(onWebAppEventReceived);
}
this.unload = function () {
if (configWizardEntityID) {
Entities.deleteEntity(configWizardEntityID);
Entities.webEventReceived.disconnect(onWebAppEventReceived);
}
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@ setup_hifi_library(Concurrent)
link_hifi_libraries(shared gl gpu gpu-gl-common shaders)
if (UNIX AND NOT VIRCADIA_THREAD_DEBUGGING)
target_link_libraries(${TARGET_NAME} pthread)
endif(UNIX)
endif(UNIX AND NOT VIRCADIA_THREAD_DEBUGGING)
GroupSources("src")
set(OpenGL_GL_PREFERENCE "LEGACY")

View file

@ -32,12 +32,25 @@
#include <IOKit/storage/IOMedia.h>
#endif //Q_OS_MAC
// Number of iterations to apply to the hash, for stretching.
// The number is arbitrary and has the only purpose of slowing down brute-force
// attempts. The number here should be low enough not to cause any trouble for
// low-end hardware.
//
// Changing this results in different hardware IDs being computed.
static const int HASH_ITERATIONS = 65535;
// Salt string for the hardware ID, makes our IDs unique to our project.
// Changing this results in different hardware IDs being computed.
static const QByteArray HASH_SALT{"Vircadia"};
static const QString FALLBACK_FINGERPRINT_KEY = "fallbackFingerprint";
QUuid FingerprintUtils::_machineFingerprint { QUuid() };
QString FingerprintUtils::getMachineFingerprintString() {
QString uuidString;
QCryptographicHash hash(QCryptographicHash::Keccak_256);
#ifdef Q_OS_LINUX
// As per the documentation:
// https://man7.org/linux/man-pages/man5/machine-id.5.html
@ -45,8 +58,6 @@ QString FingerprintUtils::getMachineFingerprintString() {
// we use the machine id as a base, but add an application-specific key to it.
// If machine-id isn't available, we try hardware networking devices instead.
QCryptographicHash hash(QCryptographicHash::Keccak_256);
QFile machineIdFile("/etc/machine-id");
if (!machineIdFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
// No machine ID, probably no systemd.
@ -58,7 +69,7 @@ QString FingerprintUtils::getMachineFingerprintString() {
if (netDevicesInfo.empty()) {
// Let getMachineFingerprint handle this contingency
qCWarning(networking) << "Failed to find any hardware networking devices";
return "";
return QUuid().toString();
}
for(auto& fileInfo : netDevicesInfo) {
@ -84,49 +95,20 @@ QString FingerprintUtils::getMachineFingerprintString() {
hash.addData(data);
}
// Makes this hash unique to us
hash.addData("Vircadia");
// Stretching
for (int i=0; i < 65535; i++) {
hash.addData(hash.result());
}
QByteArray result = hash.result();
result.resize(128 / 8); // GUIDs are 128 bit numbers
// Set UUID version to 4, ensuring it's a valid UUID
result[6] = (result[6] & 0x0F) | 0x40;
// Of course, Qt couldn't be nice and just parse something like:
// 1b1b9d6d45c2473bac13dc3011ff58d6
//
// So we have to turn it into:
// {1b1b9d6d-45c2-473b-ac13-dc3011ff58d6}
uuidString = result.toHex();
uuidString.insert(20, '-');
uuidString.insert(16, '-');
uuidString.insert(12, '-');
uuidString.insert(8, '-');
uuidString.prepend("{");
uuidString.append("}");
qCDebug(networking) << "Linux machine fingerprint:" << uuidString;
#endif //Q_OS_LINUX
#ifdef Q_OS_MAC
io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
IOObjectRelease(ioRegistryRoot);
uuidString = QString::fromCFString(uuidCf);
hash.addData(QString::fromCFString(uuidCf).toUtf8());
CFRelease(uuidCf);
qCDebug(networking) << "Mac serial number: " << uuidString;
#endif //Q_OS_MAC
#ifdef Q_OS_WIN
HKEY cryptoKey;
bool success = false;
// try and open the key that contains the machine GUID
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &cryptoKey) == ERROR_SUCCESS) {
DWORD type;
@ -143,7 +125,8 @@ QString FingerprintUtils::getMachineFingerprintString() {
if (RegQueryValueEx(cryptoKey, MACHINE_GUID_KEY, NULL, NULL,
reinterpret_cast<LPBYTE>(&machineGUID[0]), &guidSize) == ERROR_SUCCESS) {
uuidString = QString::fromStdString(machineGUID);
hash.addData(QString::fromStdString(machineGUID).toUtf8());
success = true;
}
}
}
@ -151,10 +134,43 @@ QString FingerprintUtils::getMachineFingerprintString() {
RegCloseKey(cryptoKey);
}
if (!success) {
// Let getMachineFingerprint handle this contingency
return QUuid().toString();
}
#endif //Q_OS_WIN
return uuidString;
// Makes this hash unique to us
hash.addData(HASH_SALT);
// Stretching
for (int i = 0; i < HASH_ITERATIONS; i++) {
hash.addData(hash.result());
}
QByteArray result = hash.result();
result.resize(128 / 8); // GUIDs are 128 bit numbers
// Set UUID version to 4, ensuring it's a valid UUID
result[6] = (result[6] & 0x0F) | 0x40;
// Of course, Qt couldn't be nice and just parse something like:
// 1b1b9d6d45c2473bac13dc3011ff58d6
//
// So we have to turn it into:
// {1b1b9d6d-45c2-473b-ac13-dc3011ff58d6}
QString uuidString = result.toHex();
uuidString.insert(20, '-');
uuidString.insert(16, '-');
uuidString.insert(12, '-');
uuidString.insert(8, '-');
uuidString.prepend("{");
uuidString.append("}");
qCDebug(networking) << "Final machine fingerprint:" << uuidString;
return uuidString;
}
QUuid FingerprintUtils::getMachineFingerprint() {

View file

@ -47,11 +47,14 @@ endif()
# server-side plugins
set(DIR "pcmCodec")
add_subdirectory(${DIR})
set(DIR "hifiCodec")
add_subdirectory(${DIR})
set(DIR "opusCodec")
add_subdirectory(${DIR})
if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(DIR "hifiCodec")
add_subdirectory(${DIR})
endif()
# example plugins
set(DIR "JSAPIExample")
add_subdirectory(${DIR})