mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge branch 'master' of github.com:highfidelity/hifi into helpApp1
This commit is contained in:
commit
e8b93998da
22 changed files with 223 additions and 106 deletions
20
BUILD_WIN.md
20
BUILD_WIN.md
|
@ -5,7 +5,7 @@ If you are upgrading from previous versions, do a clean uninstall of those versi
|
|||
|
||||
Note: The prerequisites will require about 10 GB of space on your drive. You will also need a system with at least 8GB of main memory.
|
||||
|
||||
### Step 1. Visual Studio & Python
|
||||
### Step 1. Visual Studio & Python 3.x
|
||||
|
||||
If you don’t have Community or Professional edition of Visual Studio, download [Visual Studio Community 2019](https://visualstudio.microsoft.com/vs/). If you have Visual Studio 2017, you are not required to download Visual Studio 2019.
|
||||
|
||||
|
@ -21,7 +21,7 @@ When selecting components, check "Desktop development with C++". On the right on
|
|||
* MSVC v141 - VS 2017 C++ x64/x86 build tools
|
||||
* MSVC v140 - VS 2015 C++ build tools (v14.00)
|
||||
|
||||
If you do not already have a Python development environment installed, also check "Python Development" in this screen.
|
||||
If you do not already have a Python 3.x development environment installed, also check "Python Development" in this screen.
|
||||
|
||||
If you already have Visual Studio installed and need to add Python, open the "Add or remove programs" control panel and find the "Microsoft Visual Studio Installer". Select it and click "Modify". In the installer, select "Modify" again, then check "Python Development" and allow the installer to apply the changes.
|
||||
|
||||
|
@ -31,9 +31,10 @@ If you do not wish to use the Python installation bundled with Visual Studio, yo
|
|||
|
||||
### Step 2. Installing CMake
|
||||
|
||||
Download and install the latest version of CMake 3.14.
|
||||
Download and install the latest version of CMake 3.15.
|
||||
* Note that earlier versions of CMake will work, but there is a specific bug related to the interaction of Visual Studio 2019 and CMake versions prior to 3.15 that will cause Visual Studio to rebuild far more than it needs to on every build
|
||||
|
||||
Download the file named win64-x64 Installer from the [CMake Website](https://cmake.org/download/). You can access the installer on this [3.14 Version page](https://cmake.org/files/v3.14/). During installation, make sure to check "Add CMake to system PATH for all users" when prompted.
|
||||
Download the file named win64-x64 Installer from the [CMake Website](https://cmake.org/download/). You can access the installer on this [3.15 Version page](https://cmake.org/files/v3.15/). During installation, make sure to check "Add CMake to system PATH for all users" when prompted.
|
||||
|
||||
### Step 3. Create VCPKG environment variable
|
||||
In the next step, you will use CMake to build High Fidelity. By default, the CMake process builds dependency files in Windows' `%TEMP%` directory, which is periodically cleared by the operating system. To prevent you from having to re-build the dependencies in the event that Windows clears that directory, we recommend that you create a `HIFI_VCPKG_BASE` environment variable linked to a directory somewhere on your machine. That directory will contain all dependency files until you manually remove them.
|
||||
|
@ -42,9 +43,18 @@ To create this variable:
|
|||
* Naviagte to 'Edit the System Environment Variables' Through the start menu.
|
||||
* Click on 'Environment Variables'
|
||||
* Select 'New'
|
||||
* Set "Variable name" to HIFI_VCPKG_BASE
|
||||
* Set "Variable name" to `HIFI_VCPKG_BASE`
|
||||
* Set "Variable value" to any directory that you have control over.
|
||||
|
||||
Additionally, if you have Visual Studio 2019 installed and _only_ Visual Studio 2019 (i.e. you do not have Visual Studio 2017 installed) you must add an additional environment variable `HIFI_VCPKG_BOOTSTRAP` that will fix a bug in our `vcpkg` pre-build step.
|
||||
|
||||
To create this variable:
|
||||
* Naviagte to 'Edit the System Environment Variables' Through the start menu.
|
||||
* Click on 'Environment Variables'
|
||||
* Select 'New'
|
||||
* Set "Variable name" to `HIFI_VCPKG_BOOTSTRAP`
|
||||
* Set "Variable value" to `1`
|
||||
|
||||
### Step 4. Running CMake to Generate Build Files
|
||||
|
||||
Run Command Prompt from Start and run the following commands:
|
||||
|
|
|
@ -160,6 +160,11 @@ bool EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O
|
|||
if (sendComplete && nodeData->wantReportInitialCompletion() && _traversal.finished()) {
|
||||
// Dealt with all nearby entities.
|
||||
nodeData->setReportInitialCompletion(false);
|
||||
// initial stats and entity packets are reliable until the initial query is complete
|
||||
// to guarantee all entity data is available for safe landing/physics start. Afterwards
|
||||
// the packets are unreliable for performance.
|
||||
nodeData->stats.getStatsMessage().setReliable(false);
|
||||
nodeData->getPacket().setReliable(false);
|
||||
|
||||
// Send EntityQueryInitialResultsComplete reliable packet ...
|
||||
auto initialCompletion = NLPacket::create(PacketType::EntityQueryInitialResultsComplete,
|
||||
|
|
|
@ -194,13 +194,13 @@ int OctreeSendThread::handlePacketSend(SharedNodePointer node, OctreeQueryNode*
|
|||
|
||||
// actually send it
|
||||
OctreeServer::didCallWriteDatagram(this);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(statsPacket, *node);
|
||||
DependencyManager::get<NodeList>()->sendPacket(NLPacket::createCopy(statsPacket), *node);
|
||||
} else {
|
||||
// not enough room in the packet, send two packets
|
||||
|
||||
// first packet
|
||||
OctreeServer::didCallWriteDatagram(this);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(statsPacket, *node);
|
||||
DependencyManager::get<NodeList>()->sendPacket(NLPacket::createCopy(statsPacket), *node);
|
||||
|
||||
int numBytes = statsPacket.getDataSize();
|
||||
_totalBytes += numBytes;
|
||||
|
@ -230,7 +230,7 @@ int OctreeSendThread::handlePacketSend(SharedNodePointer node, OctreeQueryNode*
|
|||
|
||||
// second packet
|
||||
OctreeServer::didCallWriteDatagram(this);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(sentPacket, *node);
|
||||
DependencyManager::get<NodeList>()->sendPacket(NLPacket::createCopy(sentPacket), *node);
|
||||
|
||||
numBytes = sentPacket.getDataSize();
|
||||
_totalBytes += numBytes;
|
||||
|
@ -263,7 +263,8 @@ int OctreeSendThread::handlePacketSend(SharedNodePointer node, OctreeQueryNode*
|
|||
// just send the octree packet
|
||||
OctreeServer::didCallWriteDatagram(this);
|
||||
NLPacket& sentPacket = nodeData->getPacket();
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(sentPacket, *node);
|
||||
|
||||
DependencyManager::get<NodeList>()->sendPacket(NLPacket::createCopy(sentPacket), *node);
|
||||
|
||||
int numBytes = sentPacket.getDataSize();
|
||||
_totalBytes += numBytes;
|
||||
|
|
|
@ -71,16 +71,19 @@ endif()
|
|||
|
||||
if 'Windows' == system:
|
||||
self.exe = os.path.join(self.path, 'vcpkg.exe')
|
||||
self.bootstrapCmd = 'bootstrap-vcpkg.bat'
|
||||
self.vcpkgUrl = 'https://hifi-public.s3.amazonaws.com/dependencies/vcpkg/vcpkg-win32.tar.gz?versionId=YZYkDejDRk7L_hrK_WVFthWvisAhbDzZ'
|
||||
self.vcpkgHash = '3e0ff829a74956491d57666109b3e6b5ce4ed0735c24093884317102387b2cb1b2cd1ff38af9ed9173501f6e32ffa05cc6fe6d470b77a71ca1ffc3e0aa46ab9e'
|
||||
self.hostTriplet = 'x64-windows'
|
||||
elif 'Darwin' == system:
|
||||
self.exe = os.path.join(self.path, 'vcpkg')
|
||||
self.bootstrapCmd = 'bootstrap-vcpkg.sh'
|
||||
self.vcpkgUrl = 'https://hifi-public.s3.amazonaws.com/dependencies/vcpkg/vcpkg-osx.tar.gz?versionId=_fhqSxjfrtDJBvEsQ8L_ODcdUjlpX9cc'
|
||||
self.vcpkgHash = '519d666d02ef22b87c793f016ca412e70f92e1d55953c8f9bd4ee40f6d9f78c1df01a6ee293907718f3bbf24075cc35492fb216326dfc50712a95858e9cbcb4d'
|
||||
self.hostTriplet = 'x64-osx'
|
||||
else:
|
||||
self.exe = os.path.join(self.path, 'vcpkg')
|
||||
self.bootstrapCmd = 'bootstrap-vcpkg.sh'
|
||||
self.vcpkgUrl = 'https://hifi-public.s3.amazonaws.com/dependencies/vcpkg/vcpkg-linux.tar.gz?versionId=97Nazh24etEVKWz33XwgLY0bvxEfZgMU'
|
||||
self.vcpkgHash = '6a1ce47ef6621e699a4627e8821ad32528c82fce62a6939d35b205da2d299aaa405b5f392df4a9e5343dd6a296516e341105fbb2dd8b48864781d129d7fba10d'
|
||||
self.hostTriplet = 'x64-linux'
|
||||
|
@ -141,8 +144,14 @@ endif()
|
|||
downloadVcpkg = True
|
||||
|
||||
if downloadVcpkg:
|
||||
print("Fetching vcpkg from {} to {}".format(self.vcpkgUrl, self.path))
|
||||
hifi_utils.downloadAndExtract(self.vcpkgUrl, self.path, self.vcpkgHash)
|
||||
if "HIFI_VCPKG_BOOTSTRAP" in os.environ:
|
||||
print("Cloning vcpkg from github to {}".format(self.path))
|
||||
hifi_utils.executeSubprocess(['git', 'clone', 'git@github.com:microsoft/vcpkg.git', self.path])
|
||||
print("Bootstrapping vcpkg")
|
||||
hifi_utils.executeSubprocess([self.bootstrapCmd], folder=self.path)
|
||||
else:
|
||||
print("Fetching vcpkg from {} to {}".format(self.vcpkgUrl, self.path))
|
||||
hifi_utils.downloadAndExtract(self.vcpkgUrl, self.path, self.vcpkgHash)
|
||||
|
||||
print("Replacing port files")
|
||||
portsPath = os.path.join(self.path, 'ports')
|
||||
|
|
|
@ -292,7 +292,7 @@ static const uint32_t MAX_CONCURRENT_RESOURCE_DOWNLOADS = 4;
|
|||
// For processing on QThreadPool, we target a number of threads after reserving some
|
||||
// based on how many are being consumed by the application and the display plugin. However,
|
||||
// we will never drop below the 'min' value
|
||||
static const int MIN_PROCESSING_THREAD_POOL_SIZE = 1;
|
||||
static const int MIN_PROCESSING_THREAD_POOL_SIZE = 2;
|
||||
|
||||
static const QString SNAPSHOT_EXTENSION = ".jpg";
|
||||
static const QString JPG_EXTENSION = ".jpg";
|
||||
|
|
|
@ -43,6 +43,8 @@ set(src_files
|
|||
src/LaunchInterface.h
|
||||
src/CustomUI.h
|
||||
src/CustomUI.m
|
||||
src/NSTask+NSTaskExecveAdditions.h
|
||||
src/NSTask+NSTaskExecveAdditions.m
|
||||
src/main.mm
|
||||
nib/Window.xib
|
||||
nib/SplashScreen.xib
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#import "ProcessScreen.h"
|
||||
#import "ErrorViewController.h"
|
||||
#import "Settings.h"
|
||||
#import "NSTask+NSTaskExecveAdditions.h"
|
||||
|
||||
@interface Launcher ()
|
||||
|
||||
|
@ -456,8 +457,6 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
|||
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
|
||||
NSURL *url = [NSURL fileURLWithPath:[workspace fullPathForApplication:[[self getAppPath] stringByAppendingString:@"interface.app/Contents/MacOS/interface"]]];
|
||||
|
||||
NSError *error = nil;
|
||||
|
||||
NSString* contentPath = [[self getDownloadPathForContentAndScripts] stringByAppendingString:@"content"];
|
||||
NSString* displayName = [ self displayName];
|
||||
NSString* scriptsPath = [[self getAppPath] stringByAppendingString:@"interface.app/Contents/Resources/scripts/simplifiedUIBootstrapper.js"];
|
||||
|
@ -484,13 +483,11 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
|||
@"--no-updater",
|
||||
@"--no-launcher", nil];
|
||||
}
|
||||
[workspace launchApplicationAtURL:url options:NSWorkspaceLaunchNewInstance configuration:[NSDictionary dictionaryWithObject:arguments forKey:NSWorkspaceLaunchConfigurationArguments] error:&error];
|
||||
|
||||
[NSTimer scheduledTimerWithTimeInterval: 3.0
|
||||
target: self
|
||||
selector: @selector(exitLauncher:)
|
||||
userInfo:nil
|
||||
repeats: NO];
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
task.launchPath = [url path];
|
||||
task.arguments = arguments;
|
||||
[task replaceThisProcess];
|
||||
}
|
||||
|
||||
- (ProcessState) currentProccessState
|
||||
|
@ -500,15 +497,20 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
|||
|
||||
- (void) callLaunchInterface:(NSTimer*) timer
|
||||
{
|
||||
NSWindow* mainWindow = [[[NSApplication sharedApplication] windows] objectAtIndex:0];
|
||||
|
||||
ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil];
|
||||
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen];
|
||||
[self launchInterface];
|
||||
}
|
||||
|
||||
|
||||
- (void) exitLauncher:(NSTimer*) timer
|
||||
{
|
||||
[NSApp terminate:self];
|
||||
[mainWindow setContentViewController: processScreen];
|
||||
@try
|
||||
{
|
||||
[self launchInterface];
|
||||
}
|
||||
@catch (NSException *exception)
|
||||
{
|
||||
NSLog(@"Caught exception: Name: %@, Reason: %@", exception.name, exception.reason);
|
||||
ErrorViewController* errorViewController = [[ErrorViewController alloc] initWithNibName:@"ErrorScreen" bundle:nil];
|
||||
[mainWindow setContentViewController: errorViewController];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
9
launchers/darwin/src/NSTask+NSTaskExecveAdditions.h
Normal file
9
launchers/darwin/src/NSTask+NSTaskExecveAdditions.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSTask (NSTaskExecveAdditions)
|
||||
- (void) replaceThisProcess;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
73
launchers/darwin/src/NSTask+NSTaskExecveAdditions.m
Normal file
73
launchers/darwin/src/NSTask+NSTaskExecveAdditions.m
Normal file
|
@ -0,0 +1,73 @@
|
|||
#import "NSTask+NSTaskExecveAdditions.h"
|
||||
|
||||
#import <libgen.h>
|
||||
|
||||
char **
|
||||
toCArray(NSArray<NSString *> *array)
|
||||
{
|
||||
// Add one to count to accommodate the NULL that terminates the array.
|
||||
char **cArray = (char **) calloc([array count] + 1, sizeof(char *));
|
||||
if (cArray == NULL) {
|
||||
NSException *exception = [NSException
|
||||
exceptionWithName:@"MemoryException"
|
||||
reason:@"malloc failed"
|
||||
userInfo:nil];
|
||||
@throw exception;
|
||||
}
|
||||
char *str;
|
||||
for (int i = 0; i < [array count]; i++) {
|
||||
str = (char *) [array[i] UTF8String];
|
||||
if (str == NULL) {
|
||||
NSException *exception = [NSException
|
||||
exceptionWithName:@"NULLStringException"
|
||||
reason:@"UTF8String was NULL"
|
||||
userInfo:nil];
|
||||
@throw exception;
|
||||
}
|
||||
if (asprintf(&cArray[i], "%s", str) == -1) {
|
||||
for (int j = 0; j < i; j++) {
|
||||
free(cArray[j]);
|
||||
}
|
||||
free(cArray);
|
||||
NSException *exception = [NSException
|
||||
exceptionWithName:@"MemoryException"
|
||||
reason:@"malloc failed"
|
||||
userInfo:nil];
|
||||
@throw exception;
|
||||
}
|
||||
}
|
||||
return cArray;
|
||||
}
|
||||
|
||||
@implementation NSTask (NSTaskExecveAdditions)
|
||||
|
||||
- (void) replaceThisProcess {
|
||||
char **args = toCArray([@[[self launchPath]] arrayByAddingObjectsFromArray:[self arguments]]);
|
||||
|
||||
NSMutableArray *env = [[NSMutableArray alloc] init];
|
||||
NSDictionary* environvment = [[NSProcessInfo processInfo] environment];
|
||||
for (NSString* key in environvment) {
|
||||
NSString* environmentVariable = [[key stringByAppendingString:@"="] stringByAppendingString:environvment[key]];
|
||||
[env addObject:environmentVariable];
|
||||
}
|
||||
|
||||
char** envp = toCArray(env);
|
||||
// `execve` replaces the current process with `path`.
|
||||
// It will only return if it fails to replace the current process.
|
||||
chdir(dirname(args[0]));
|
||||
execve(args[0], (char * const *)args, envp);
|
||||
|
||||
// If we're here `execve` failed. :(
|
||||
for (int i = 0; i < [[self arguments] count]; i++) {
|
||||
free((void *) args[i]);
|
||||
}
|
||||
free((void *) args);
|
||||
|
||||
NSException *exception = [NSException
|
||||
exceptionWithName:@"ExecveException"
|
||||
reason:[NSString stringWithFormat:@"couldn't execve: %s", strerror(errno)]
|
||||
userInfo:nil];
|
||||
@throw exception;
|
||||
}
|
||||
|
||||
@end
|
|
@ -943,9 +943,6 @@ bool processRandomSwitchStateMachineNode(AnimNode::Pointer node, const QJsonObje
|
|||
}
|
||||
|
||||
auto randomStatePtr = std::make_shared<AnimRandomSwitch::RandomSwitchState>(id, iter->second, interpTarget, interpDuration, interpTypeEnum, easingTypeEnum, priority, resume);
|
||||
if (priority > 0.0f) {
|
||||
smNode->addToPrioritySum(priority);
|
||||
}
|
||||
assert(randomStatePtr);
|
||||
|
||||
if (!interpTargetVar.isEmpty()) {
|
||||
|
|
|
@ -27,22 +27,35 @@ const AnimPoseVec& AnimRandomSwitch::evaluate(const AnimVariantMap& animVars, co
|
|||
AnimRandomSwitch::RandomSwitchState::Pointer desiredState = _currentState;
|
||||
if (abs(_randomSwitchEvaluationCount - context.getEvaluationCount()) > 1 || animVars.lookup(_triggerRandomSwitchVar, false)) {
|
||||
|
||||
// get a random number and decide which motion to choose.
|
||||
// filter states different to the last random state and with priorities.
|
||||
bool currentStateHasPriority = false;
|
||||
float dice = randFloatInRange(0.0f, 1.0f);
|
||||
float lowerBound = 0.0f;
|
||||
for (const RandomSwitchState::Pointer& randState : _randomStates) {
|
||||
std::vector<RandomSwitchState::Pointer> randomStatesToConsider;
|
||||
randomStatesToConsider.reserve(_randomStates.size());
|
||||
float totalPriorities = 0.0f;
|
||||
for (size_t i = 0; i < _randomStates.size(); i++) {
|
||||
auto randState = _randomStates[i];
|
||||
if (randState->getPriority() > 0.0f) {
|
||||
float upperBound = lowerBound + (randState->getPriority() / _totalPriorities);
|
||||
if ((dice > lowerBound) && (dice < upperBound)) {
|
||||
desiredState = randState;
|
||||
bool isRepeatingClip = _children[randState->getChildIndex()]->getID() == _lastPlayedState;
|
||||
if (!isRepeatingClip) {
|
||||
randomStatesToConsider.push_back(randState);
|
||||
totalPriorities += randState->getPriority();
|
||||
}
|
||||
lowerBound = upperBound;
|
||||
|
||||
// this indicates if the curent state is one that can be selected randomly, or is one that was transitioned to by the random duration timer.
|
||||
currentStateHasPriority = currentStateHasPriority || (_currentState == randState);
|
||||
}
|
||||
}
|
||||
// get a random number and decide which motion to choose.
|
||||
float dice = randFloatInRange(0.0f, 1.0f);
|
||||
float lowerBound = 0.0f;
|
||||
for (size_t i = 0; i < randomStatesToConsider.size(); i++) {
|
||||
auto randState = randomStatesToConsider[i];
|
||||
float upperBound = lowerBound + (randState->getPriority() / totalPriorities);
|
||||
if ((dice > lowerBound) && (dice < upperBound)) {
|
||||
desiredState = randState;
|
||||
break;
|
||||
}
|
||||
lowerBound = upperBound;
|
||||
}
|
||||
if (abs(_randomSwitchEvaluationCount - context.getEvaluationCount()) > 1) {
|
||||
_duringInterp = false;
|
||||
switchRandomState(animVars, context, desiredState, _duringInterp);
|
||||
|
@ -155,8 +168,8 @@ void AnimRandomSwitch::addState(RandomSwitchState::Pointer randomState) {
|
|||
}
|
||||
|
||||
void AnimRandomSwitch::switchRandomState(const AnimVariantMap& animVars, const AnimContext& context, RandomSwitchState::Pointer desiredState, bool shouldInterp) {
|
||||
|
||||
auto nextStateNode = _children[desiredState->getChildIndex()];
|
||||
_lastPlayedState = nextStateNode->getID();
|
||||
if (shouldInterp) {
|
||||
|
||||
const float FRAMES_PER_SECOND = 30.0f;
|
||||
|
|
|
@ -143,7 +143,6 @@ protected:
|
|||
void setTransitionVar(const QString& transitionVar) { _transitionVar = transitionVar; }
|
||||
void setTriggerTimeMin(float triggerTimeMin) { _triggerTimeMin = triggerTimeMin; }
|
||||
void setTriggerTimeMax(float triggerTimeMax) { _triggerTimeMax = triggerTimeMax; }
|
||||
void addToPrioritySum(float priority) { _totalPriorities += priority; }
|
||||
|
||||
void addState(RandomSwitchState::Pointer randomState);
|
||||
|
||||
|
@ -164,7 +163,6 @@ protected:
|
|||
float _alpha = 0.0f;
|
||||
AnimPoseVec _prevPoses;
|
||||
AnimPoseVec _nextPoses;
|
||||
float _totalPriorities { 0.0f };
|
||||
|
||||
RandomSwitchState::Pointer _currentState;
|
||||
RandomSwitchState::Pointer _previousState;
|
||||
|
@ -179,6 +177,7 @@ protected:
|
|||
float _randomSwitchTimeMin { 10.0f };
|
||||
float _randomSwitchTimeMax { 20.0f };
|
||||
float _randomSwitchTime { 0.0f };
|
||||
QString _lastPlayedState;
|
||||
|
||||
private:
|
||||
// no copies
|
||||
|
|
|
@ -170,27 +170,21 @@ static void channelDownmix(int16_t* source, int16_t* dest, int numSamples) {
|
|||
}
|
||||
}
|
||||
|
||||
static float computeLoudness(int16_t* samples, int numSamples, int numChannels, bool& isClipping) {
|
||||
static bool detectClipping(int16_t* samples, int numSamples, int numChannels) {
|
||||
|
||||
const int32_t CLIPPING_THRESHOLD = 32392; // -0.1 dBFS
|
||||
const int32_t CLIPPING_DETECTION = 3; // consecutive samples over threshold
|
||||
const int CLIPPING_DETECTION = 3; // consecutive samples over threshold
|
||||
|
||||
float scale = numSamples ? 1.0f / numSamples : 0.0f;
|
||||
|
||||
int32_t loudness = 0;
|
||||
isClipping = false;
|
||||
bool isClipping = false;
|
||||
|
||||
if (numChannels == 2) {
|
||||
int32_t oversLeft = 0;
|
||||
int32_t oversRight = 0;
|
||||
int oversLeft = 0;
|
||||
int oversRight = 0;
|
||||
|
||||
for (int i = 0; i < numSamples/2; i++) {
|
||||
int32_t left = std::abs((int32_t)samples[2*i+0]);
|
||||
int32_t right = std::abs((int32_t)samples[2*i+1]);
|
||||
|
||||
loudness += left;
|
||||
loudness += right;
|
||||
|
||||
if (left > CLIPPING_THRESHOLD) {
|
||||
isClipping |= (++oversLeft >= CLIPPING_DETECTION);
|
||||
} else {
|
||||
|
@ -203,13 +197,11 @@ static float computeLoudness(int16_t* samples, int numSamples, int numChannels,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
int32_t overs = 0;
|
||||
int overs = 0;
|
||||
|
||||
for (int i = 0; i < numSamples; i++) {
|
||||
int32_t sample = std::abs((int32_t)samples[i]);
|
||||
|
||||
loudness += sample;
|
||||
|
||||
if (sample > CLIPPING_THRESHOLD) {
|
||||
isClipping |= (++overs >= CLIPPING_DETECTION);
|
||||
} else {
|
||||
|
@ -218,6 +210,17 @@ static float computeLoudness(int16_t* samples, int numSamples, int numChannels,
|
|||
}
|
||||
}
|
||||
|
||||
return isClipping;
|
||||
}
|
||||
|
||||
static float computeLoudness(int16_t* samples, int numSamples) {
|
||||
|
||||
float scale = numSamples ? 1.0f / numSamples : 0.0f;
|
||||
|
||||
int32_t loudness = 0;
|
||||
for (int i = 0; i < numSamples; i++) {
|
||||
loudness += std::abs((int32_t)samples[i]);
|
||||
}
|
||||
return (float)loudness * scale;
|
||||
}
|
||||
|
||||
|
@ -1404,6 +1407,15 @@ void AudioClient::handleMicAudioInput() {
|
|||
|
||||
_inputRingBuffer.readSamples(inputAudioSamples.get(), inputSamplesRequired);
|
||||
|
||||
// detect clipping on the raw input
|
||||
bool isClipping = detectClipping(inputAudioSamples.get(), inputSamplesRequired, _inputFormat.channelCount());
|
||||
if (isClipping) {
|
||||
_timeSinceLastClip = 0.0f;
|
||||
} else if (_timeSinceLastClip >= 0.0f) {
|
||||
_timeSinceLastClip += AudioConstants::NETWORK_FRAME_SECS;
|
||||
}
|
||||
isClipping = (_timeSinceLastClip >= 0.0f) && (_timeSinceLastClip < 2.0f); // 2 second hold time
|
||||
|
||||
#if defined(WEBRTC_ENABLED)
|
||||
if (_isAECEnabled) {
|
||||
processWebrtcNearEnd(inputAudioSamples.get(), inputSamplesRequired / _inputFormat.channelCount(),
|
||||
|
@ -1411,9 +1423,7 @@ void AudioClient::handleMicAudioInput() {
|
|||
}
|
||||
#endif
|
||||
|
||||
// detect loudness and clipping on the raw input
|
||||
bool isClipping = false;
|
||||
float loudness = computeLoudness(inputAudioSamples.get(), inputSamplesRequired, _inputFormat.channelCount(), isClipping);
|
||||
float loudness = computeLoudness(inputAudioSamples.get(), inputSamplesRequired);
|
||||
_lastRawInputLoudness = loudness;
|
||||
|
||||
// envelope detection
|
||||
|
@ -1421,14 +1431,6 @@ void AudioClient::handleMicAudioInput() {
|
|||
loudness += tc * (_lastSmoothedRawInputLoudness - loudness);
|
||||
_lastSmoothedRawInputLoudness = loudness;
|
||||
|
||||
// clipping indicator
|
||||
if (isClipping) {
|
||||
_timeSinceLastClip = 0.0f;
|
||||
} else if (_timeSinceLastClip >= 0.0f) {
|
||||
_timeSinceLastClip += AudioConstants::NETWORK_FRAME_SECS;
|
||||
}
|
||||
isClipping = (_timeSinceLastClip >= 0.0f) && (_timeSinceLastClip < 2.0f); // 2 second hold time
|
||||
|
||||
emit inputLoudnessChanged(_lastSmoothedRawInputLoudness, isClipping);
|
||||
|
||||
if (!_muted) {
|
||||
|
|
|
@ -78,7 +78,8 @@ public:
|
|||
void setVsyncEnabled(bool vsyncEnabled) { _vsyncEnabled = vsyncEnabled; }
|
||||
bool isVsyncEnabled() const { return _vsyncEnabled; }
|
||||
// Three threads, one for rendering, one for texture transfers, one reserved for the GL driver
|
||||
int getRequiredThreadCount() const override { return 3; }
|
||||
// Drop to one reserved for better other-task performance in desktop
|
||||
int getRequiredThreadCount() const override { return 1; }
|
||||
|
||||
virtual std::function<void(gpu::Batch&, const gpu::TexturePointer&)> getHUDOperator() override;
|
||||
void copyTextureToQuickFramebuffer(NetworkTexturePointer source,
|
||||
|
|
|
@ -53,6 +53,8 @@ public:
|
|||
void updateVisionSqueezeParameters(float visionSqueezeX, float visionSqueezeY, float visionSqueezeTransition,
|
||||
int visionSqueezePerEye, float visionSqueezeGroundPlaneY,
|
||||
float visionSqueezeSpotlightSize);
|
||||
// Attempt to reserve two threads.
|
||||
int getRequiredThreadCount() const override { return 2; }
|
||||
|
||||
signals:
|
||||
void hmdMountedChanged();
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
|
||||
bool isPartOfMessage() const { return _isPartOfMessage; }
|
||||
bool isReliable() const { return _isReliable; }
|
||||
void setReliable(bool reliable) { _isReliable = reliable; }
|
||||
|
||||
ObfuscationLevel getObfuscationLevel() const { return _obfuscationLevel; }
|
||||
SequenceNumber getSequenceNumber() const { return _sequenceNumber; }
|
||||
|
|
|
@ -82,7 +82,7 @@ bool OctreeQueryNode::shouldSuppressDuplicatePacket() {
|
|||
void OctreeQueryNode::init() {
|
||||
_myPacketType = getMyPacketType();
|
||||
|
||||
_octreePacket = NLPacket::create(getMyPacketType());
|
||||
_octreePacket = NLPacket::create(getMyPacketType(), -1, true);
|
||||
|
||||
resetOctreePacket(); // don't bump sequence
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ private:
|
|||
|
||||
bool _isReadyToSend;
|
||||
|
||||
std::unique_ptr<NLPacket> _statsPacket = NLPacket::create(PacketType::OctreeStats);
|
||||
std::unique_ptr<NLPacket> _statsPacket = NLPacket::create(PacketType::OctreeStats, -1, true);
|
||||
|
||||
// scene timing data in usecs
|
||||
bool _isStarted;
|
||||
|
|
|
@ -30,34 +30,18 @@ Q_DECLARE_METATYPE(QByteArray*)
|
|||
|
||||
XMLHttpRequestClass::XMLHttpRequestClass(QScriptEngine* engine) :
|
||||
_engine(engine),
|
||||
_async(true),
|
||||
_url(),
|
||||
_method(""),
|
||||
_responseType(""),
|
||||
_request(),
|
||||
_reply(NULL),
|
||||
_sendData(NULL),
|
||||
_rawResponseData(),
|
||||
_responseData(""),
|
||||
_onTimeout(QScriptValue::NullValue),
|
||||
_onReadyStateChange(QScriptValue::NullValue),
|
||||
_readyState(XMLHttpRequestClass::UNSENT),
|
||||
_errorCode(QNetworkReply::NoError),
|
||||
_timeout(0),
|
||||
_timer(this),
|
||||
_numRedirects(0) {
|
||||
_timer(this) {
|
||||
|
||||
_request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||
_timer.setSingleShot(true);
|
||||
}
|
||||
|
||||
XMLHttpRequestClass::~XMLHttpRequestClass() {
|
||||
if (_reply) { delete _reply; }
|
||||
if (_sendData) { delete _sendData; }
|
||||
if (_reply) { _reply->deleteLater(); }
|
||||
}
|
||||
|
||||
QScriptValue XMLHttpRequestClass::constructor(QScriptContext* context, QScriptEngine* engine) {
|
||||
return engine->newQObject(new XMLHttpRequestClass(engine));
|
||||
return engine->newQObject(new XMLHttpRequestClass(engine), QScriptEngine::ScriptOwnership);
|
||||
}
|
||||
|
||||
QScriptValue XMLHttpRequestClass::getStatus() const {
|
||||
|
@ -169,13 +153,12 @@ void XMLHttpRequestClass::send() {
|
|||
|
||||
void XMLHttpRequestClass::send(const QScriptValue& data) {
|
||||
if (_readyState == OPENED && !_reply) {
|
||||
|
||||
if (!data.isNull()) {
|
||||
_sendData = new QBuffer(this);
|
||||
if (data.isObject()) {
|
||||
QByteArray ba = qscriptvalue_cast<QByteArray>(data);
|
||||
_sendData->setData(ba);
|
||||
_sendData = qscriptvalue_cast<QByteArray>(data);
|
||||
} else {
|
||||
_sendData->setData(data.toString().toUtf8());
|
||||
_sendData = data.toString().toUtf8();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,6 +218,10 @@ void XMLHttpRequestClass::requestFinished() {
|
|||
}
|
||||
}
|
||||
|
||||
disconnectFromReply(_reply);
|
||||
_reply->deleteLater();
|
||||
_reply = nullptr;
|
||||
|
||||
setReadyState(DONE);
|
||||
emit requestComplete();
|
||||
}
|
||||
|
@ -246,7 +233,7 @@ void XMLHttpRequestClass::abortRequest() {
|
|||
disconnectFromReply(_reply);
|
||||
_reply->abort();
|
||||
_reply->deleteLater();
|
||||
_reply = NULL;
|
||||
_reply = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,23 +98,23 @@ private:
|
|||
void disconnectFromReply(QNetworkReply* reply);
|
||||
void abortRequest();
|
||||
|
||||
QScriptEngine* _engine;
|
||||
bool _async;
|
||||
QScriptEngine* _engine { nullptr };
|
||||
bool _async { true };
|
||||
QUrl _url;
|
||||
QString _method;
|
||||
QString _responseType;
|
||||
QNetworkRequest _request;
|
||||
QNetworkReply* _reply;
|
||||
QBuffer* _sendData;
|
||||
QNetworkReply* _reply { nullptr };
|
||||
QByteArray _sendData;
|
||||
QByteArray _rawResponseData;
|
||||
QScriptValue _responseData;
|
||||
QScriptValue _onTimeout;
|
||||
QScriptValue _onReadyStateChange;
|
||||
ReadyState _readyState;
|
||||
QNetworkReply::NetworkError _errorCode;
|
||||
int _timeout;
|
||||
QScriptValue _onTimeout { QScriptValue::NullValue };
|
||||
QScriptValue _onReadyStateChange { QScriptValue::NullValue };
|
||||
ReadyState _readyState { XMLHttpRequestClass::UNSENT };
|
||||
QNetworkReply::NetworkError _errorCode { QNetworkReply::NoError };
|
||||
int _timeout { 0 };
|
||||
QTimer _timer;
|
||||
int _numRedirects;
|
||||
int _numRedirects { 0 };
|
||||
|
||||
private slots:
|
||||
void requestFinished();
|
||||
|
|
|
@ -39,6 +39,10 @@ module.exports = {
|
|||
if (error) {
|
||||
response = { statusCode: httpRequest.status };
|
||||
}
|
||||
|
||||
// Break circular reference to httpRequest so the engine can garbage collect it.
|
||||
httpRequest.onreadystatechange = null;
|
||||
|
||||
callback(error, response, optionalCallbackParameter);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -355,7 +355,7 @@ CameraManager = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.isRightButton || (event.isLeftButton && event.isControl && !event.isShifted)) {
|
||||
if (event.isRightButton || (event.isLeftButton && event.isAlt && !event.isShifted)) {
|
||||
that.mode = MODE_ORBIT;
|
||||
} else if (event.isMiddleButton || (event.isLeftButton && event.isControl && event.isShifted)) {
|
||||
that.mode = MODE_PAN;
|
||||
|
|
Loading…
Reference in a new issue