Merge pull request #1 from vircadia/master

upgrade repository
This commit is contained in:
Alezia Kurdis 2021-04-07 21:44:28 -04:00 committed by GitHub
commit 05382c690f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
152 changed files with 3409 additions and 1030 deletions

17
.github/stale.yml vendored Normal file
View file

@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 120
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 60
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had recent activity.
It will be closed if no further activity occurs.
Thank you for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

101
BUILD.md
View file

@ -1,6 +1,6 @@
# General Build Information
*Last Updated on August 26, 2020*
*Last Updated on December 21, 2020*
### OS Specific Build Guides
@ -11,7 +11,7 @@
### Dependencies
- [git](https://git-scm.com/downloads): >= 1.6
- [cmake](https://cmake.org/download/): 3.9
- [CMake](https://cmake.org/download/): 3.9
- [Python](https://www.python.org/downloads/): 3.6 or higher
- [Node.JS](https://nodejs.org/en/): >= 12.13.1 LTS
- Used to build the Screen Sharing executable.
@ -41,15 +41,18 @@ These are not placed in your normal build tree when doing an out of source build
Vircadia uses CMake to generate build files and project files for your platform.
#### Qt
CMake will download Qt 5.12.3 using vcpkg.
To override this (i.e. use an installed Qt configuration - you will need to set a QT_CMAKE_PREFIX_PATH environment variable pointing to your Qt **lib/cmake** folder.
CMake will download Qt 5.12.3 using vcpkg.
To override this (i.e. use an installed Qt configuration - you will need to set a QT_CMAKE_PREFIX_PATH environment variable pointing to your Qt **lib/cmake** folder.
This can either be entered directly into your shell session before you build or in your shell profile (e.g.: ~/.bash_profile, ~/.bashrc, ~/.zshrc - this depends on your shell and environment). The path it needs to be set to will depend on where and how Qt5 was installed. e.g.
export QT_CMAKE_PREFIX_PATH=/usr/local/Qt5.12.3/gcc_64/lib/cmake
export QT_CMAKE_PREFIX_PATH=/usr/local/qt/5.12.3/clang_64/lib/cmake/
export QT_CMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.12.3/lib/cmake
export QT_CMAKE_PREFIX_PATH=/usr/local/opt/qt5/lib/cmake
```bash
export QT_CMAKE_PREFIX_PATH=/usr/local/Qt5.12.3/gcc_64/lib/cmake
export QT_CMAKE_PREFIX_PATH=/usr/local/qt/5.12.3/clang_64/lib/cmake/
export QT_CMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.12.3/lib/cmake
export QT_CMAKE_PREFIX_PATH=/usr/local/opt/qt5/lib/cmake
```
#### VCPKG
@ -59,7 +62,9 @@ You do not need to install vcpkg.
Building the dependencies can be lengthy and the resulting files will be stored in your OS temp directory.
However, those files can potentially get cleaned up by the OS, so in order to avoid this and having to redo the lengthy build step, you can set the following environment variable:
export HIFI_VCPKG_BASE=/path/to/directory
```bash
export HIFI_VCPKG_BASE=/path/to/directory
```
Where `/path/to/directory` is the path to a directory where you wish the build files to get stored.
@ -67,48 +72,58 @@ Where `/path/to/directory` is the path to a directory where you wish the build f
##### Possible Environment Variables
// The URL to post the dump to.
CMAKE_BACKTRACE_URL
// The identifying tag of the release.
CMAKE_BACKTRACE_TOKEN
// The release version.
RELEASE_NUMBER
// The build commit.
BUILD_NUMBER
```text
// The URL to post the dump to.
CMAKE_BACKTRACE_URL
// The identifying tag of the release.
CMAKE_BACKTRACE_TOKEN
// The release version, e.g., 2021.3.2.
RELEASE_NUMBER
// The release name, e.g., Eos.
RELEASE_NAME
// The build commit, e.g., use a Git hash for the most recent commit in the branch - fd6973b.
BUILD_NUMBER
// The type of release.
RELEASE_TYPE=PRODUCTION|PR|DEV
// The Interface will have a custom default home and startup location.
PRELOADED_STARTUP_LOCATION=Location/IP/URL
// The Interface will have a custom default script whitelist, comma separated, no spaces.
// This will also activate the whitelist on Interface's first run.
PRELOADED_SCRIPT_WHITELIST=ListOfEntries
// Code-signing environment variables must be set during runtime of CMake AND globally when the signing takes place.
HF_PFX_FILE=Path to certificate
HF_PFX_PASSPHRASE=Passphrase for certificate
// Determine the build type
PRODUCTION_BUILD=0|1
PR_BUILD=0|1
STABLE_BUILD=0|1
// Determine if to utilize testing or stable Metaverse URLs
USE_STABLE_GLOBAL_SERVICES=1
BUILD_GLOBAL_SERVICES=STABLE
```
// The type of release.
RELEASE_TYPE=PRODUCTION|PR|DEV
// The Interface will have a custom default home and startup location.
INITIAL_STARTUP_LOCATION=Location/IP/URL
// Code-signing environment variables must be set during runtime of CMake AND globally when the signing takes place.
HF_PFX_FILE=Path to certificate
HF_PFX_PASSPHRASE=Passphrase for certificate
// Determine the build type
PRODUCTION_BUILD=0|1
PR_BUILD=0|1
STABLE_BUILD=0|1
// Determine if to utilize testing or stable Metaverse URLs
USE_STABLE_GLOBAL_SERVICES=1
BUILD_GLOBAL_SERVICES=STABLE
##### Generate Files
Create a build directory in the root of your checkout and then run the CMake build from there. This will keep the rest of the directory clean.
mkdir build
cd build
cmake ..
```bash
mkdir build
cd build
cmake ..
```
If CMake gives you the same error message repeatedly after the build fails, try removing `CMakeCache.txt`.
##### Generating a release/debug only vcpkg build
In order to generate a release or debug only vcpkg package, you could use the use the `VCPKG_BUILD_TYPE` define in your cmake generate command. Building a release only vcpkg can drastically decrease the total build time.
In order to generate a release or debug only vcpkg package, you could use the use the `VCPKG_BUILD_TYPE` define in your CMake generate command. Building a release only vcpkg can drastically decrease the total build time.
For release only vcpkg:
@ -124,7 +139,9 @@ Any variables that need to be set for CMake to find dependencies can be set as E
For example, to pass the QT_CMAKE_PREFIX_PATH variable (if not using the vcpkg'ed version) during build file generation:
cmake .. -DQT_CMAKE_PREFIX_PATH=/usr/local/qt/5.12.3/lib/cmake
```bash
cmake .. -DQT_CMAKE_PREFIX_PATH=/usr/local/qt/5.12.3/lib/cmake
```
#### Finding Dependencies

View file

@ -42,11 +42,13 @@ Follow the directions [here](https://developer.android.com/studio/publish/app-si
Create a `gradle.properties` file in the `.gradle` folder (`$HOME/.gradle` on Unix, `Users/<yourname>/.gradle` on Windows). Edit the file to contain the following
HIFI_ANDROID_PRECOMPILED=<your_home_directory>/Android/hifi_externals
HIFI_ANDROID_KEYSTORE=<key_store_directory>/<keystore_name>.jks
HIFI_ANDROID_KEYSTORE_PASSWORD=<password>
HIFI_ANDROID_KEY_ALIAS=<key_alias>
HIFI_ANDROID_KEY_PASSWORD=<key_passwords>
```properties
HIFI_ANDROID_PRECOMPILED=<your_home_directory>/Android/hifi_externals
HIFI_ANDROID_KEYSTORE=<key_store_directory>/<keystore_name>.jks
HIFI_ANDROID_KEYSTORE_PASSWORD=<password>
HIFI_ANDROID_KEY_ALIAS=<key_alias>
HIFI_ANDROID_KEY_PASSWORD=<key_passwords>
```
Note, do not use $HOME for the path. It must be a fully qualified path name. Also, be sure to use forward slashes in your path.
@ -54,21 +56,26 @@ Note, do not use $HOME for the path. It must be a fully qualified path name. Als
Add these lines to `gradle.properties`
SUPPRESS_QUEST_INTERFACE
SUPPRESS_QUEST_FRAME_PLAYER
```properties
SUPPRESS_QUEST_INTERFACE
SUPPRESS_QUEST_FRAME_PLAYER
```
#### If you are building for an Oculus Quest
Add these lines to `gradle.properties`
SUPPRESS_INTERFACE
SUPPRESS_FRAME_PLAYER
```properties
SUPPRESS_INTERFACE
SUPPRESS_FRAME_PLAYER
```
#### The Frame Player for both Android Phone and Oculus Quest is optional, so if you encounter problems with these during your build, you can skip them by adding these lines to `gradle.properties`
SUPPRESS_FRAME_PLAYER
SUPPRESS_QUEST_FRAME_PLAYER
```properties
SUPPRESS_FRAME_PLAYER
SUPPRESS_QUEST_FRAME_PLAYER
```
### Clone the repository

View file

@ -168,39 +168,3 @@ If your goal is to set up a development environment, it is desirable to set the
directory that vcpkg builds into with the `HIFI_VCPKG_BASE` environment variable.
For example, you might set `HIFI_VCPKG_BASE` to `/home/$USER/vcpkg`.
By default, vcpkg will build in the system `/tmp` directory.
##### Ubuntu 18.04 only
In Ubuntu 18.04 there is a problem related with NVidia driver library version.
It can be worked around following these steps:
1. Uninstall incompatible nvtt libraries:
`sudo apt-get remove libnvtt2 libnvtt-dev`
1. Install libssl1.0-dev:
`sudo apt-get -y install libssl1.0-dev`
1. Clone castano nvidia-texture-tools:
`git clone https://github.com/castano/nvidia-texture-tools`
`cd nvidia-texture-tools/`
1. Make these changes in repo:
* In file **VERSION** set `2.2.1`
* In file **configure**:
* set `build="release"`
* set `-DNVTT_SHARED=1`
1. Configure, build and install:
`./configure`
`make`
`sudo make install`
1. Link compiled files:
`sudo ln -s /usr/local/lib/libnvcore.so /usr/lib/libnvcore.so`
`sudo ln -s /usr/local/lib/libnvimage.so /usr/lib/libnvimage.so`
`sudo ln -s /usr/local/lib/libnvmath.so /usr/lib/libnvmath.so`
`sudo ln -s /usr/local/lib/libnvtt.so /usr/lib/libnvtt.so`
1. After running these steps you can run interface:
`interface/interface`

View file

@ -8,22 +8,26 @@ Please read the [general build guide](BUILD.md) for information on dependencies
[Homebrew](https://brew.sh/) is an excellent package manager for macOS. It makes install of some Vircadia dependencies very simple.
brew install cmake openssl npm
```bash
brew install cmake openssl npm
```
### Python 3
Download an install Python 3.6.6 or higher from [here](https://www.python.org/downloads/).
Download an install Python 3.6.6 or higher from [here](https://www.python.org/downloads/).
Execute the `Update Shell Profile.command` script that is provided with the installer.
### OSX SDK
You will need version `10.12` of the OSX SDK for building, otherwise you may have crashing or other unintended issues due to the deprecation of OpenGL on OSX. You can get that SDK from [here](https://github.com/phracker/MacOSX-SDKs). You must copy it in to your Xcode SDK directory, e.g.
cp -rp ~/Downloads/MacOSX10.12.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
```bash
cp -rp ~/Downloads/MacOSX10.12.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
```
### OpenSSL
Assuming you've installed OpenSSL using the homebrew instructions above, you'll need to set OPENSSL_ROOT_DIR so CMake can find your installations.
Assuming you've installed OpenSSL using the homebrew instructions above, you'll need to set OPENSSL_ROOT_DIR so CMake can find your installations.
For OpenSSL installed via homebrew, set OPENSSL_ROOT_DIR via
`export OPENSSL_ROOT_DIR=/usr/local/opt/openssl`
or by appending `-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl` to `cmake`
@ -31,12 +35,14 @@ For OpenSSL installed via homebrew, set OPENSSL_ROOT_DIR via
### Xcode
You can ask CMake to generate Xcode project files instead of Unix Makefiles using the `-G Xcode` parameter after CMake. You will need to select the Xcode installation in the terminal first if you have not done so already.
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
cmake ../ -DCMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOSX_SDK=10.12 ..
If `cmake` complains about Python 3 being missing, you may need to update your CMake binary with command `brew upgrade cmake`, or by downloading and running the latest CMake installer, depending on how you originally instaled CMake
```bash
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
cmake ../ -DCMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOSX_SDK=10.12 ..
```
If `cmake` complains about Python 3 being missing, you may need to update your CMake binary with command `brew upgrade cmake`, or by downloading and running the latest CMake installer, depending on how you originally installed CMake.
After running CMake, you will have the make files or Xcode project file necessary to build all of the components. Open the hifi.xcodeproj file, choose ALL_BUILD from the Product > Scheme menu (or target drop down), and click Run.

View file

@ -1,6 +1,6 @@
# Creating an Installer
*Last Updated on August 24, 2020*
*Last Updated on March 4, 2021*
Follow the [build guide](BUILD.md) to figure out how to build Vircadia for your platform.
@ -9,13 +9,13 @@ During generation, CMake should produce an `install` target and a `package` targ
The `install` target will copy the Vircadia targets and their dependencies to your `CMAKE_INSTALL_PREFIX`.
This variable is set by the `project(hifi)` command in `CMakeLists.txt` to `C:/Program Files/hifi` and stored in `build/CMakeCache.txt`
### Packaging
## Packaging
To produce an installer, run the `package` target. However you will want to follow the steps specific to your platform below.
#### Windows
### Windows
##### Prerequisites
#### Prerequisites
To produce an executable installer on Windows, the following are required:
@ -63,11 +63,11 @@ To produce an executable installer on Windows, the following are required:
1. [Node.JS and NPM](<https://nodejs.org/en/download/>)
1. Install version 10.15.0 LTS (or greater)
##### Code Signing (optional)
#### Code Signing (optional)
For code signing to work, you will need to set the `HF_PFX_FILE` and `HF_PFX_PASSPHRASE` environment variables to be present during CMake runtime and globally as we proceed to package the installer.
##### Creating the Installer
#### Creating the Installer
1. Perform a clean cmake from a new terminal.
1. Open the `vircadia.sln` solution with elevated (administrator) permissions on Visual Studio and select the **Release** configuration.
@ -79,7 +79,14 @@ For code signing to work, you will need to set the `HF_PFX_FILE` and `HF_PFX_PAS
1. Build CMakeTargets->PACKAGE
The installer is now available in `build\_CPack_Packages\win64\NSIS`
#### OS X
#### FAQ
1. **Problem:** Failure to open a file. ```File: failed opening file "\FOLDERSHARE\XYZSRelease\...\Credits.rtf" Error in script "C:\TFS\XYZProject\Releases\NullsoftInstaller\XYZWin7Installer.nsi" on line 77 -- aborting creation process```
1. **Cause:** The complete path (current directory + relative path) has to be < 260 characters to any of the relevant files.
1. **Solution:** Move your build and packaging folder as high up in the drive as possible to prevent an overage.
### OS X
1. [npm](<https://www.npmjs.com/get-npm>)
Install version 12.16.3 LTS
@ -91,8 +98,156 @@ For code signing to work, you will need to set the `HF_PFX_FILE` and `HF_PFX_PAS
1. Perform a Release build of `package`
Installer is now available in `build/_CPack_Packages/Darwin/DragNDrop
### FAQ
### Linux
1. **Problem:** Failure to open a file. ```File: failed opening file "\FOLDERSHARE\XYZSRelease\...\Credits.rtf" Error in script "C:\TFS\XYZProject\Releases\NullsoftInstaller\XYZWin7Installer.nsi" on line 77 -- aborting creation process```
1. **Cause:** The complete path (current directory + relative path) has to be < 260 characters to any of the relevant files.
1. **Solution:** Move your build and packaging folder as high up in the drive as possible to prevent an overage.
#### Server
##### Ubuntu 18.04 | .deb
1. Ensure you are using an Ubuntu 18.04 system. There is no required minimum to the amount of CPU cores needed, however it's recommended that you use as many as you have available in order to have an efficient experience.
```text
Recommended CPU Cores: 16
Minimum Disk Space: 40GB
```
3. Get and bootstrap Vircadia Builder.
```bash
git clone https://github.com/vircadia/vircadia-builder.git
cd vircadia-builder
```
3. Run Vircadia Builder.
```bash
./vircadia-builder --build server
```
4. If Vircadia Builder needed to install dependencies and asks you to run it again then do so. Otherwise, skip to the next step.
```bash
./vircadia-builder --build server
```
5. Vircadia Builder will ask you to configure it to build the server. The values will be prefilled with defaults, the following steps will explain what they are and what you might want to put. *Advanced users: See [here](BUILD.md#possible-environment-variables) for possible environment variables and settings.*
6. This value is the Git repository of Vircadia. You can set this URL to your fork of the Vircadia repository if you need to.
```text
Git repository: https://github.com/vircadia/vircadia/
# OR, for example
Git repository: https://github.com/digisomni/vircadia/
```
7. This value is the tag on the repository. If you would like to use a specific version of Vircadia, typically tags will be named like this: "v2021.1.0-rc"
```text
Git tag: master
# OR, for example
Git tag: v2021.1.0-rc
```
8. This value is the release type. For example, the options are `production`, `pr`, or `dev`. If you are making a build for yourself and others to use then use `production`.
```text
Release type: DEV
# OR, for example we recommend you use
Release type: PRODUCTION
```
9. This value is the release version. Release numbers should be in a format of `YEAR-MAJORVERSION-MINORVERSION` which might look like this: `2021.1.0`.
```text
Release number: 2021.1.0
```
10. This value is the build number. We typically use the hash of the most recent commit on that Git tag which might look like this: `fd6973b`.
```text
Build number: fd6973b
```
11. This value is the directory that Vircadia will get installed to. You should leave this as the default value unless you are an advanced user.
```text
Installation dir: /home/ubuntu/Vircadia
```
12. This value is the number of CPU cores that the Vircadia Builder will use to compile the Vircadia server. By default it will use all cores available on your build server. You should leave this as the default value it gives you for your build server.
```text
CPU cores to use for Vircadia: 16
```
13. This value is the number of CPU cores that the Vircadia Builder will use to compile Qt5 (a required component for Vircadia). By default it will use all cores available on your build server. You should leave this as the default value it gives you for your build server.
```text
CPU cores to use for Qt5: 16
```
14. It will ask you if you would like to proceed with the specified values. If you're happy with the configuration, type `yes`, otherwise enter `no` and press enter to start over. You can press `Ctrl` + `C` simultaneously on your keyboard to exit.
15. Vircadia Builder will now run, it may take a while. See this [table](https://github.com/vircadia/vircadia-builder#how-long-does-it-take) for estimated times.
16. Navigate to the `pkg-scripts` directory.
```bash
cd ../Vircadia/source/pkg-scripts/
```
17. Generate the .rpm package. Set `RPMVERSION` to the same version you entered for the `Release number` on Vircadia Builder. *Advanced users: the version cannot begin with a letter and cannot include underscores or dashes in it.*
```bash
DEBVERSION="2021.1.0" DEBEMAIL="your-email@somewhere.com" DEBFULLNAME="Your Full Name" ./make-deb-server
```
18. If successful, the generated .deb package will be in the `pkg-scripts` folder.
##### Amazon Linux 2 | .rpm
1. Ensure you are using an Amazon Linux 2 system. You will need many CPU cores to complete this process within a reasonable time. As an alternative to AWS EC2, you may use a [virtual machine](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html). Here are the recommended specs:
```text
AWS EC2 Instance Type: C5a.4xlarge
Recommended CPU Cores: 16
Minimum Disk Space: 40GB
```
2. Update the system and install dependencies.
```bash
sudo yum update -y
sudo yum install git -y
sudo yum install rpm-build
```
3. Get and bootstrap Vircadia Builder.
```bash
git clone https://github.com/vircadia/vircadia-builder.git
cd vircadia-builder
sudo ./install_amazon_linux_deps.sh
```
4. Run Vircadia Builder.
```bash
./vircadia-builder --build server
```
5. If Vircadia Builder needed to install dependencies and asks you to run it again then do so. Otherwise, skip to the next step.
```bash
./vircadia-builder --build server
```
6. Vircadia Builder will ask you to configure it to build the server. The values will be prefilled with defaults, the following steps will explain what they are and what you might want to put. *Advanced users: See [here](BUILD.md#possible-environment-variables) for possible environment variables and settings.*
7. This value is the Git repository of Vircadia. You can set this URL to your fork of the Vircadia repository if you need to.
```text
Git repository: https://github.com/vircadia/vircadia/
# OR, for example
Git repository: https://github.com/digisomni/vircadia/
```
8. This value is the tag on the repository. If you would like to use a specific version of Vircadia, typically tags will be named like this: "v2021.1.0-rc".
```text
Git tag: master
# OR, for example
Git tag: v2021.1.0-rc
```
9. This value is the release type. For example, the options are `production`, `pr`, or `dev`. If you are making a build for yourself and others to use then use `production`.
```text
Release type: DEV
# OR, for example we recommend you use
Release type: PRODUCTION
```
10. This value is the release version. Release numbers typically should be in a format of `YEAR-MAJORVERSION-MINORVERSION` which might look like this: `2021.1.0`.
```text
Release number: 2021.1.0
```
11. This value is the build number. We typically use the hash of the most recent commit on that Git tag which might look like this: `fd6973b`.
```text
Build number: fd6973b
```
12. This value is the directory that Vircadia will get installed to. You should leave this as the default value unless you are an advanced user.
```text
Installation dir: /root/Vircadia
```
13. This value is the number of CPU cores that the Vircadia Builder will use to compile the Vircadia server. By default it will use all cores available on your build server given you have enough memory. You should leave this as the default value it gives you for your build server.
```text
CPU cores to use for Vircadia: 16
```
14. This value is the number of CPU cores that the Vircadia Builder will use to compile Qt5 (a required component for Vircadia). By default it will use all cores available on your build server given you have enough memory. You should leave this as the default value it gives you for your build server.
```text
CPU cores to use for Qt5: 16
```
15. It will ask you if you would like to proceed with the specified values. If you're happy with the configuration, type `yes`, otherwise enter `no` and press enter to start over. You can press `Ctrl` + `C` simultaneously on your keyboard to exit.
16. Vircadia Builder will now run, it may take a while. See this [table](https://github.com/vircadia/vircadia-builder#how-long-does-it-take) for estimated times.
17. Navigate to the `pkg-scripts` directory.
```bash
cd ../Vircadia/source/pkg-scripts/
```
18. Generate the .rpm package. Set `RPMVERSION` to the same version you entered for the `Release number` on Vircadia Builder. *Advanced users: the version cannot begin with a letter and cannot include underscores or dashes in it.*
```bash
RPMVERSION="2021.1.0" ./make-rpm-server
```
19. If successful, the generated .rpm package will be in the `pkg-scripts` folder of the Vircadia source files.

View file

@ -29,9 +29,11 @@ Vircadia™ is a 3D social software project seeking to incrementally bring about
### How to generate an Installer
- [For Windows](https://github.com/vircadia/vircadia/blob/master/INSTALLER.md)
- [For Mac](https://github.com/vircadia/vircadia/blob/master/INSTALLER.md#os-x)
- [For Linux - AppImage - Vircadia Builder](https://github.com/vircadia/vircadia-builder/blob/master/README.md#building-appimages)
- [For Windows - Interface & Server](https://github.com/vircadia/vircadia/blob/master/INSTALLER.md)
- [For Mac - Interface](https://github.com/vircadia/vircadia/blob/master/INSTALLER.md#os-x)
- [For Linux - Server .deb - Vircadia Builder](INSTALLER.md#ubuntu-1804--deb)
- [For Linux - Server .rpm - Vircadia Builder](INSTALLER.md#amazon-linux-2--rpm)
- [For Linux - Interface AppImage - Vircadia Builder](https://github.com/vircadia/vircadia-builder/blob/master/README.md#building-appimages)
### Boot to Metaverse: [The Goal](https://vircadia.com/vision/)

View file

@ -269,7 +269,13 @@ void AvatarMixerClientData::processSetTraitsMessage(ReceivedMessage& message,
// the avatar mixer uses the negative value of the sent version
instanceVersionRef = -packetTraitVersion;
} else {
_avatar->processTraitInstance(traitType, instanceID, message.read(traitSize));
// Don't accept avatar entity data for distribution unless sender has rez permissions on the domain.
// The sender shouldn't be sending avatar entity data, however this provides a back-up.
auto trait = message.read(traitSize);
if (sendingNode.getCanRezAvatarEntities()) {
_avatar->processTraitInstance(traitType, instanceID, trait);
}
instanceVersionRef = packetTraitVersion;
}
@ -290,6 +296,29 @@ void AvatarMixerClientData::processSetTraitsMessage(ReceivedMessage& message,
}
}
void AvatarMixerClientData::emulateDeleteEntitiesTraitsMessage(const QList<QUuid>& avatarEntityIDs) {
// Emulates processSetTraitsMessage() actions on behalf of an avatar whose canRezAvatarEntities permission has been removed.
// The source avatar should be removing its avatar entities. However, using this method provides a back-up.
auto traitType = AvatarTraits::AvatarEntity;
for (const auto& entityID : avatarEntityIDs) {
auto& instanceVersionRef = _lastReceivedTraitVersions.getInstanceValueRef(traitType, entityID);
_avatar->processDeletedTraitInstance(traitType, entityID);
// Mixer doesn't need deleted IDs.
_avatar->getAndClearRecentlyRemovedIDs();
// to track a deleted instance but keep version information
// the avatar mixer uses the negative value of the sent version
// Because there is no originating message from an avatar we enlarge the magnitude by 1.
// If a user subsequently has canRezAvatarEntities permission granted, they will have to relog in order for their
// avatar entities to be visible to others.
instanceVersionRef = -instanceVersionRef - 1;
}
_lastReceivedTraitsChange = std::chrono::steady_clock::now();
}
void AvatarMixerClientData::processBulkAvatarTraitsAckMessage(ReceivedMessage& message) {
// Avatar Traits flow control marks each outgoing avatar traits packet with a
// sequence number. The mixer caches the traits sent in the traits packet.

View file

@ -132,6 +132,7 @@ public:
int processPackets(const SlaveSharedData& slaveSharedData); // returns number of packets processed
void processSetTraitsMessage(ReceivedMessage& message, const SlaveSharedData& slaveSharedData, Node& sendingNode);
void emulateDeleteEntitiesTraitsMessage(const QList<QUuid>& avatarEntityIDs);
void processBulkAvatarTraitsAckMessage(ReceivedMessage& message);
void checkSkeletonURLAgainstWhitelist(const SlaveSharedData& slaveSharedData, Node& sendingNode,
AvatarTraits::TraitVersion traitVersion);

View file

@ -432,6 +432,17 @@ void AvatarMixerSlave::broadcastAvatarDataToAgent(const SharedNodePointer& node)
}
}
// The source avatar should be removing its avatar entities. However, provide a back-up.
if (sendAvatar) {
if (!sourceAvatarNode->getCanRezAvatarEntities()) {
auto sourceAvatarNodeData = reinterpret_cast<AvatarMixerClientData*>(sourceAvatarNode->getLinkedData());
auto avatarEntityIDs = sourceAvatarNodeData->getAvatar().getAvatarEntityIDs();
if (avatarEntityIDs.count() > 0) {
sourceAvatarNodeData->emulateDeleteEntitiesTraitsMessage(avatarEntityIDs);
}
}
}
if (sendAvatar) {
AvatarDataSequenceNumber lastSeqToReceiver = destinationNodeData->getLastBroadcastSequenceNumber(sourceAvatarNode->getLocalID());
AvatarDataSequenceNumber lastSeqFromSender = sourceAvatarNodeData->getLastReceivedSequenceNumber();

View file

@ -398,7 +398,7 @@ void ScriptableAvatar::setAvatarEntityData(const AvatarEntityMap& avatarEntityDa
// clear deleted traits
for (const auto& id : idsToClear) {
clearAvatarEntity(id);
clearAvatarEntityInternal(id);
}
}
@ -408,7 +408,7 @@ void ScriptableAvatar::updateAvatarEntity(const QUuid& entityID, const QByteArra
std::map<QUuid, EntityItemPointer>::iterator itr = _entities.find(entityID);
if (itr != _entities.end()) {
_entities.erase(itr);
clearAvatarEntity(entityID);
clearAvatarEntityInternal(entityID);
}
return;
}

View file

@ -20,6 +20,7 @@
#include <udt/PacketHeaders.h>
const QString MESSAGES_MIXER_LOGGING_NAME = "messages-mixer";
const int MESSAGES_MIXER_RATE_LIMITER_INTERVAL = 1000; // 1 second
MessagesMixer::MessagesMixer(ReceivedMessage& message) : ThreadedAssignment(message)
{
@ -44,10 +45,20 @@ void MessagesMixer::handleMessages(QSharedPointer<ReceivedMessage> receivedMessa
QByteArray data;
QUuid senderID;
bool isText;
auto senderUUID = senderNode->getUUID();
MessagesClient::decodeMessagesPacket(receivedMessage, channel, isText, message, data, senderID);
auto nodeList = DependencyManager::get<NodeList>();
auto itr = _allSubscribers.find(senderUUID);
if (itr == _allSubscribers.end()) {
_allSubscribers[senderUUID] = 1;
} else if (*itr >= _maxMessagesPerSecond) {
return;
} else {
*itr += 1;
}
nodeList->eachMatchingNode(
[&](const SharedNodePointer& node)->bool {
return node->getActiveSocket() && _channelSubscribers[channel].contains(node->getUUID());
@ -60,14 +71,18 @@ void MessagesMixer::handleMessages(QSharedPointer<ReceivedMessage> receivedMessa
}
void MessagesMixer::handleMessagesSubscribe(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
auto senderUUID = senderNode->getUUID();
QString channel = QString::fromUtf8(message->getMessage());
_channelSubscribers[channel] << senderNode->getUUID();
_channelSubscribers[channel] << senderUUID;
}
void MessagesMixer::handleMessagesUnsubscribe(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
auto senderUUID = senderNode->getUUID();
QString channel = QString::fromUtf8(message->getMessage());
if (_channelSubscribers.contains(channel)) {
_channelSubscribers[channel].remove(senderNode->getUUID());
_channelSubscribers[channel].remove(senderUUID);
}
}
@ -88,7 +103,48 @@ void MessagesMixer::sendStatsPacket() {
}
void MessagesMixer::run() {
ThreadedAssignment::commonInit(MESSAGES_MIXER_LOGGING_NAME, NodeType::MessagesMixer);
auto nodeList = DependencyManager::get<NodeList>();
nodeList->addSetOfNodeTypesToNodeInterestSet({ NodeType::Agent, NodeType::EntityScriptServer });
DomainHandler& domainHandler = nodeList->getDomainHandler();
connect(&domainHandler, &DomainHandler::settingsReceived, this, &MessagesMixer::domainSettingsRequestComplete);
ThreadedAssignment::commonInit(MESSAGES_MIXER_LOGGING_NAME, NodeType::MessagesMixer);
startMaxMessagesProcessor();
}
void MessagesMixer::domainSettingsRequestComplete() {
auto nodeList = DependencyManager::get<NodeList>();
// parse the settings to pull out the values we need
parseDomainServerSettings(nodeList->getDomainHandler().getSettingsObject());
}
void MessagesMixer::parseDomainServerSettings(const QJsonObject& domainSettings) {
const QString MESSAGES_MIXER_SETTINGS_KEY = "messages_mixer";
QJsonObject messagesMixerGroupObject = domainSettings[MESSAGES_MIXER_SETTINGS_KEY].toObject();
const QString NODE_MESSAGES_PER_SECOND_KEY = "max_node_messages_per_second";
QJsonValue maxMessagesPerSecondValue = messagesMixerGroupObject.value(NODE_MESSAGES_PER_SECOND_KEY);
_maxMessagesPerSecond = maxMessagesPerSecondValue.toInt(DEFAULT_NODE_MESSAGES_PER_SECOND);
}
void MessagesMixer::processMaxMessagesContainer() {
_allSubscribers.clear();
}
void MessagesMixer::startMaxMessagesProcessor() {
if (_maxMessagesTimer) {
stopMaxMessagesProcessor();
}
_maxMessagesTimer = new QTimer();
connect(_maxMessagesTimer, &QTimer::timeout, this, &MessagesMixer::processMaxMessagesContainer);
_maxMessagesTimer->start(MESSAGES_MIXER_RATE_LIMITER_INTERVAL); // Clear the container every second.
}
void MessagesMixer::stopMaxMessagesProcessor() {
_maxMessagesTimer->stop();
_maxMessagesTimer->deleteLater();
_maxMessagesTimer = nullptr;
}

View file

@ -32,9 +32,21 @@ private slots:
void handleMessages(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
void handleMessagesSubscribe(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
void handleMessagesUnsubscribe(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
void parseDomainServerSettings(const QJsonObject& domainSettings);
void domainSettingsRequestComplete();
void startMaxMessagesProcessor();
void stopMaxMessagesProcessor();
void processMaxMessagesContainer();
private:
QHash<QString,QSet<QUuid>> _channelSubscribers;
QHash<QString, QSet<QUuid>> _channelSubscribers;
QHash<QUuid, int> _allSubscribers;
const int DEFAULT_NODE_MESSAGES_PER_SECOND = 1000;
int _maxMessagesPerSecond { 0 };
QTimer* _maxMessagesTimer { nullptr };
};
#endif // hifi_MessagesMixer_h

View file

@ -4,6 +4,7 @@
#
# Created by Leonardo Murillo on 12/16/2015.
# Copyright 2015 High Fidelity, Inc.
# Copyright 2021 Vircadia contributors.
#
# Distributed under the Apache License, Version 2.0.
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -20,9 +21,9 @@ macro(GENERATE_INSTALLERS)
set(INSTALLER_TYPE "client_only")
string(REGEX REPLACE "Vircadia" "Vircadia Interface" _DISPLAY_NAME ${BUILD_ORGANIZATION})
elseif (SERVER_ONLY)
set(_PACKAGE_NAME_EXTRA "-Sandbox")
set(_PACKAGE_NAME_EXTRA "-Server")
set(INSTALLER_TYPE "server_only")
string(REGEX REPLACE "Vircadia" "Vircadia Sandbox" _DISPLAY_NAME ${BUILD_ORGANIZATION})
string(REGEX REPLACE "Vircadia" "Vircadia Server" _DISPLAY_NAME ${BUILD_ORGANIZATION})
else ()
set(_DISPLAY_NAME ${BUILD_ORGANIZATION})
set(INSTALLER_TYPE "full")
@ -31,7 +32,7 @@ macro(GENERATE_INSTALLERS)
set(CPACK_PACKAGE_NAME ${_DISPLAY_NAME})
set(CPACK_PACKAGE_VENDOR "Vircadia")
set(CPACK_PACKAGE_VERSION ${BUILD_VERSION})
set(CPACK_PACKAGE_FILE_NAME "Vircadia${_PACKAGE_NAME_EXTRA}-${BUILD_VERSION}")
set(CPACK_PACKAGE_FILE_NAME "Vircadia${_PACKAGE_NAME_EXTRA}-${BUILD_VERSION}-${RELEASE_NAME}")
set(CPACK_NSIS_DISPLAY_NAME ${_DISPLAY_NAME})
set(CPACK_NSIS_PACKAGE_NAME ${_DISPLAY_NAME})
if (PR_BUILD)
@ -122,7 +123,7 @@ macro(GENERATE_INSTALLERS)
endif ()
if (BUILD_SERVER)
cpack_add_component(${SERVER_COMPONENT} DISPLAY_NAME "Vircadia Sandbox")
cpack_add_component(${SERVER_COMPONENT} DISPLAY_NAME "Vircadia Server")
endif ()
include(CPack)

View file

@ -8,23 +8,30 @@
#
macro(SETUP_MEMORY_DEBUGGER)
if (DEFINED ENV{HIFI_MEMORY_DEBUGGING})
SET( HIFI_MEMORY_DEBUGGING true )
if ("$ENV{VIRCADIA_MEMORY_DEBUGGING}")
SET( VIRCADIA_MEMORY_DEBUGGING true )
endif ()
if (HIFI_MEMORY_DEBUGGING)
if (VIRCADIA_MEMORY_DEBUGGING)
if (UNIX)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# for clang on Linux
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -shared-libasan -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -shared-libasan -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -shared-libasan -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address -fsanitize=leak -fsanitize-recover=address")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=address -fsanitize=leak -fsanitize-recover=address")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=address -fsanitize=leak -fsanitize-recover=address")
else ()
# for gcc on Linux
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fsanitize=address -U_FORTIFY_SOURCE -fno-stack-protector -fno-omit-frame-pointer")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan -static-libstdc++ -fsanitize=undefined -fsanitize=address")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan -static-libstdc++ -fsanitize=undefined -fsanitize=address")
# For some reason, using -fstack-protector results in this error:
# usr/bin/ld: ../../libraries/audio/libaudio.so: undefined reference to `FIR_1x4_AVX512(float*, float*, float*, float*, float*, float (*) [64], int)'
# The '-DSTACK_PROTECTOR' argument below disables the usage of this function in the code. This should be fine as it only works on the latest Intel hardware,
# and is an optimization that should make no functional difference.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fsanitize=address -fsanitize=leak -U_FORTIFY_SOURCE -DSTACK_PROTECTOR -fstack-protector-strong -fno-omit-frame-pointer")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=address -fsanitize=leak ")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=address -fsanitize=leak")
endif()
endif (UNIX)
else()
message(FATAL_ERROR "Memory debugging is not supported on this platform." )
endif()
endif ()
endmacro(SETUP_MEMORY_DEBUGGER)

View file

@ -25,7 +25,10 @@ macro(SET_PACKAGING_PARAMETERS)
set_from_env(RELEASE_NUMBER RELEASE_NUMBER "")
set_from_env(RELEASE_NAME RELEASE_NAME "")
set_from_env(STABLE_BUILD STABLE_BUILD 0)
set_from_env(INITIAL_STARTUP_LOCATION INITIAL_STARTUP_LOCATION "")
set_from_env(PRELOADED_STARTUP_LOCATION PRELOADED_STARTUP_LOCATION "")
set_from_env(PRELOADED_SCRIPT_WHITELIST PRELOADED_SCRIPT_WHITELIST "")
set_from_env(BYPASS_SIGNING BYPASS_SIGNING 0)
message(STATUS "The RELEASE_TYPE variable is: ${RELEASE_TYPE}")
@ -177,12 +180,12 @@ macro(SET_PACKAGING_PARAMETERS)
if (PRODUCTION_BUILD)
set(INTERFACE_SHORTCUT_NAME "Vircadia")
set(CONSOLE_SHORTCUT_NAME "Console")
set(SANDBOX_SHORTCUT_NAME "Sandbox")
set(SANDBOX_SHORTCUT_NAME "Server")
set(APP_USER_MODEL_ID "com.vircadia.console")
else ()
set(INTERFACE_SHORTCUT_NAME "Vircadia - ${BUILD_VERSION_NO_SHA}")
set(CONSOLE_SHORTCUT_NAME "Console - ${BUILD_VERSION_NO_SHA}")
set(SANDBOX_SHORTCUT_NAME "Sandbox - ${BUILD_VERSION_NO_SHA}")
set(SANDBOX_SHORTCUT_NAME "Server - ${BUILD_VERSION_NO_SHA}")
endif ()
set(INTERFACE_HF_SHORTCUT_NAME "${INTERFACE_SHORTCUT_NAME}")

View file

@ -29,7 +29,8 @@ namespace BuildInfo {
const QString BUILD_NUMBER = "@BUILD_NUMBER@";
const QString BUILD_GLOBAL_SERVICES = "@BUILD_GLOBAL_SERVICES@";
const QString BUILD_TIME = "@BUILD_TIME@";
const QString INITIAL_STARTUP_LOCATION = "@INITIAL_STARTUP_LOCATION@";
const QString PRELOADED_STARTUP_LOCATION = "@PRELOADED_STARTUP_LOCATION@";
const QString PRELOADED_SCRIPT_WHITELIST = "@PRELOADED_SCRIPT_WHITELIST@";
enum BuildType {
Dev,

View file

@ -251,8 +251,8 @@ Var substringResult
!macro InitSection SecName
; This macro reads component installed flag from the registry and
;changes checked state of the section on the components page.
;Input: section index constant name specified in Section command.
; changes checked state of the section on the components page.
; Input: section index constant name specified in Section command.
ClearErrors
;Reading component status from registry
@ -718,7 +718,7 @@ Function InstallTypesPage
StrCpy $OffsetUnits u
StrCpy $Express "0"
${NSD_CreateRadioButton} 30% $CurrentOffset$OffsetUnits 100% 10u "Express Install (Recommended)"; $\nInstalls Vircadia Interface and Vircadia Sandbox"
${NSD_CreateRadioButton} 30% $CurrentOffset$OffsetUnits 100% 10u "Express Install (Recommended)"; $\nInstalls Vircadia Interface"
pop $ExpressInstallRadioButton
${NSD_OnClick} $ExpressInstallRadioButton ChangeExpressLabel
IntOp $CurrentOffset $CurrentOffset + 15
@ -1346,6 +1346,7 @@ Section "-Core installation"
${EndIf}
${If} @SERVER_COMPONENT_CONDITIONAL@
${AndIf} $Express != "1"
; handling for server console shortcut
Delete "$SMPROGRAMS\$STARTMENU_FOLDER\@CONSOLE_SHORTCUT_NAME@.lnk"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\@SANDBOX_HF_SHORTCUT_NAME@.lnk" \

View file

@ -1,5 +1,5 @@
{
"version": 2.4,
"version": 2.5,
"settings": [
{
"name": "metaverse",
@ -295,10 +295,10 @@
},
{
"name": "approved_safe_urls",
"label": "Approved Script and QML URLs",
"label": "Approved Script and QML URLs (Not Enabled)",
"help": "These URLs will be sent to the Interface as safe URLs to allow through the whitelist if the Interface has this security option enabled.",
"placeholder": "0",
"default": "1",
"placeholder": "",
"default": "",
"advanced": false
},
{
@ -338,7 +338,7 @@
"name": "standard_permissions",
"type": "table",
"label": "Domain-Wide User Permissions",
"help": "Indicate which types of users can have which <a data-toggle='tooltip' data-html=true title='<p><strong>Domain-Wide User Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether a user can connect to the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether a user change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether a user can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether a user can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether a user can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether a user can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether a user can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether a user can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Rez Certified</strong><br />Sets whether a user can create new certified entities.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific user will supersede any parameter-level permissions that might otherwise apply to that user. Additionally, if more than one parameter is applicable to a given user, the permissions given to that user will be the sum of all applicable parameters. For example, let&rsquo;s say only localhost users can connect and only logged in users can lock and unlock entities. If a user is both logged in and on localhost then they will be able to both connect and lock/unlock entities.</p>'>domain-wide permissions</a>.",
"help": "Indicate which types of users can have which <a data-toggle='tooltip' data-html=true title='<p><strong>Domain-Wide User Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether a user can connect to the domain.</li><li><strong>Avatar Entities</strong><br />Sets whether a user can use avatar entities on the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether a user change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether a user can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether a user can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether a user can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether a user can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether a user can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether a user can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Rez Certified</strong><br />Sets whether a user can create new certified entities.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific user will supersede any parameter-level permissions that might otherwise apply to that user. Additionally, if more than one parameter is applicable to a given user, the permissions given to that user will be the sum of all applicable parameters. For example, let&rsquo;s say only localhost users can connect and only logged in users can lock and unlock entities. If a user is both logged in and on localhost then they will be able to both connect and lock/unlock entities.</p>'>domain-wide permissions</a>.",
"caption": "Standard Permissions",
"can_add_new_rows": false,
"groups": [
@ -347,8 +347,8 @@
"span": 1
},
{
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide User Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether a user can connect to the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether a user change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether a user can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether a user can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether a user can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether a user can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether a user can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether a user can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether a user can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific user will supersede any parameter-level permissions that might otherwise apply to that user. Additionally, if more than one parameter is applicable to a given user, the permissions given to that user will be the sum of all applicable parameters. For example, let&rsquo;s say only localhost users can connect and only logged in users can lock and unlock entities. If a user is both logged in and on localhost then they will be able to both connect and lock/unlock entities.</p>'>?</a>",
"span": 11
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide User Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether a user can connect to the domain.</li><li><strong>Avatar Entities</strong><br />Sets whether a user can use avatar entities on the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether a user change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether a user can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether a user can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether a user can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether a user can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether a user can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether a user can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether a user can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific user will supersede any parameter-level permissions that might otherwise apply to that user. Additionally, if more than one parameter is applicable to a given user, the permissions given to that user will be the sum of all applicable parameters. For example, let&rsquo;s say only localhost users can connect and only logged in users can lock and unlock entities. If a user is both logged in and on localhost then they will be able to both connect and lock/unlock entities.</p>'>?</a>",
"span": 12
}
],
"columns": [
@ -363,6 +363,13 @@
"editable": true,
"default": false
},
{
"name": "id_can_rez_avatar_entities",
"label": "Avatar Entities",
"type": "checkbox",
"editable": true,
"default": false
},
{
"name": "id_can_adjust_locks",
"label": "Lock / Unlock",
@ -439,17 +446,20 @@
"default": [
{
"id_can_connect": true,
"id_can_rez_avatar_entities": true,
"id_can_rez_tmp_certified": true,
"permissions_id": "anonymous"
},
{
"id_can_connect": true,
"id_can_rez_avatar_entities": true,
"id_can_rez_tmp_certified": true,
"permissions_id": "friends"
},
{
"id_can_adjust_locks": true,
"id_can_connect": true,
"id_can_rez_avatar_entities": true,
"id_can_adjust_locks": true,
"id_can_connect_past_max_capacity": true,
"id_can_kick": true,
"id_can_replace_content": true,
@ -463,6 +473,7 @@
},
{
"id_can_connect": true,
"id_can_rez_avatar_entities": true,
"id_can_rez_tmp_certified": true,
"permissions_id": "logged-in"
}
@ -484,8 +495,8 @@
"span": 1
},
{
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide User Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether users in specific groups can connect to the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether users in specific groups can change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether users in specific groups can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether users in specific groups can create new entities with a finite lifetime.</li><li><strong>Rez Temporary</strong><br />Sets whether users in specific groups can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether a users in specific groups can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether a user can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether users in specific groups can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether user in specific groups can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether a user can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Permissions granted to a specific user will be a union of the permissions granted to the groups they are in, as well as permissions from the previous section. Group permissions are only granted if the user doesn&rsquo;t have their own row in the per-account section, below.</p>'>?</a>",
"span": 11
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide User Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether users in specific groups can connect to the domain.</li><li><strong>Avatar Entities</strong><br />Sets whether users in specific groups can use avatar entities on the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether users in specific groups can change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether users in specific groups can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether users in specific groups can create new entities with a finite lifetime.</li><li><strong>Rez Temporary</strong><br />Sets whether users in specific groups can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether users in specific groups can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether users in specific groups can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether users in specific groups can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether user in specific groups can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether a user can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Permissions granted to a specific user will be a union of the permissions granted to the groups they are in, as well as permissions from the previous section. Group permissions are only granted if the user doesn&rsquo;t have their own row in the per-account section, below.</p>'>?</a>",
"span": 12
}
],
"columns": [
@ -525,6 +536,13 @@
"editable": true,
"default": false
},
{
"name": "id_can_rez_avatar_entities",
"label": "Avatar Entities",
"type": "checkbox",
"editable": true,
"default": false
},
{
"name": "id_can_adjust_locks",
"label": "Lock / Unlock",
@ -613,8 +631,8 @@
"span": 1
},
{
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide User Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether users in specific groups can connect to the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether users in specific groups can change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether users in specific groups can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether users in specific groups can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether a users in specific groups can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether a user can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether users in specific groups can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether user in specific groups can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether users in specific groups can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property</li></ul><p>Permissions granted to a specific user will be a union of the permissions granted to the groups they are in. Group permissions are only granted if the user doesn&rsquo;t have their own row in the per-account section, below.</p>'>?</a>",
"span": 11
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide User Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether users in specific groups can connect to the domain.</li><li><strong>Avatar Entities</strong><br />Sets whether users in specific groups can use avatar entities on the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether users in specific groups can change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether users in specific groups can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether users in specific groups can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether users in specific groups can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether users in specific groups can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether users in specific groups can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether user in specific groups can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether users in specific groups can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property</li></ul><p>Permissions granted to a specific user will be a union of the permissions granted to the groups they are in. Group permissions are only granted if the user doesn&rsquo;t have their own row in the per-account section, below.</p>'>?</a>",
"span": 12
}
],
"columns": [
@ -651,6 +669,13 @@
"editable": true,
"default": false
},
{
"name": "id_can_rez_avatar_entities",
"label": "Avatar Entities",
"type": "checkbox",
"editable": true,
"default": false
},
{
"name": "id_can_adjust_locks",
"label": "Lock / Unlock",
@ -734,8 +759,8 @@
"span": 1
},
{
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide User Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether a user can connect to the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether a user change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether a user can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether a user can create new entities with a finite lifetime.</li><li><strong>Rez Temporary</strong><br />Sets whether a user can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether a user can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether a user can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether a user can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether a user can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether a user can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific user will supersede any parameter-level or group permissions that might otherwise apply to that user.</p>'>?</a>",
"span": 11
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide User Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether a user can connect to the domain.</li><li><strong>Avatar Entities</strong><br />Sets whether a user can use avatar entities on the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether a user change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether a user can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether a user can create new entities with a finite lifetime.</li><li><strong>Rez Temporary</strong><br />Sets whether a user can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether a user can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether a user can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether a user can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether a user can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether a user can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific user will supersede any parameter-level or group permissions that might otherwise apply to that user.</p>'>?</a>",
"span": 12
}
],
"columns": [
@ -750,6 +775,13 @@
"editable": true,
"default": false
},
{
"name": "id_can_rez_avatar_entities",
"label": "Avatar Entities",
"type": "checkbox",
"editable": true,
"default": false
},
{
"name": "id_can_adjust_locks",
"label": "Lock / Unlock",
@ -833,8 +865,8 @@
"span": 1
},
{
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide IP Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether users from specific IPs can connect to the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether users from specific IPs can change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether users from specific IPs can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether users from specific IPs can create new entities with a finite lifetime.</li><li><strong>Rez Temporary</strong><br />Sets whether a user can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether users from specific IPs can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether users from specific IPs can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether users from specific IPs can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether users from specific IPs can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether users from specific IPs can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific IP will supersede any parameter-level permissions that might otherwise apply to that user (from groups or standard permissions above). IP address permissions are overriden if the user has their own row in the users section.</p>'>?</a>",
"span": 11
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide IP Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether users from specific IPs can connect to the domain.</li><li><strong>Avatar Entities</strong><br />Sets whether users from specific IPs can use avatar entities on the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether users from specific IPs can change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether users from specific IPs can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether users from specific IPs can create new entities with a finite lifetime.</li><li><strong>Rez Temporary</strong><br />Sets whether a user can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether users from specific IPs can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether users from specific IPs can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether users from specific IPs can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether users from specific IPs can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether users from specific IPs can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific IP will supersede any parameter-level permissions that might otherwise apply to that user (from groups or standard permissions above). IP address permissions are overriden if the user has their own row in the users section.</p>'>?</a>",
"span": 12
}
],
"columns": [
@ -849,6 +881,13 @@
"editable": true,
"default": false
},
{
"name": "id_can_rez_avatar_entities",
"label": "Avatar Entities",
"type": "checkbox",
"editable": true,
"default": false
},
{
"name": "id_can_adjust_locks",
"label": "Lock / Unlock",
@ -932,8 +971,8 @@
"span": 1
},
{
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide MAC Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether users with specific MACs can connect to the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether users from specific MACs can change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether users with specific MACs can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether users with specific MACs can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether users with specific MACs can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether users with specific MACs can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether users with specific MACs can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether users with specific MACs can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether users with specific MACs can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific MAC will supersede any parameter-level permissions that might otherwise apply to that user (from groups or standard permissions above). MAC address permissions are overriden if the user has their own row in the users section.</p>'>?</a>",
"span": 11
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide MAC Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether users with specific MACs can connect to the domain.</li><li><strong>Avatar Entities</strong><br />Sets whether users with specific MACs can use avatar entities on the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether users from specific MACs can change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether users with specific MACs can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether users with specific MACs can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether users with specific MACs can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether users with specific MACs can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether users with specific MACs can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether users with specific MACs can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether users with specific MACs can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific MAC will supersede any parameter-level permissions that might otherwise apply to that user (from groups or standard permissions above). MAC address permissions are overriden if the user has their own row in the users section.</p>'>?</a>",
"span": 12
}
],
"columns": [
@ -948,6 +987,13 @@
"editable": true,
"default": false
},
{
"name": "id_can_rez_avatar_entities",
"label": "Avatar Entities",
"type": "checkbox",
"editable": true,
"default": false
},
{
"name": "id_can_adjust_locks",
"label": "Lock / Unlock",
@ -1031,8 +1077,8 @@
"span": 1
},
{
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide Machine Fingerprint Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether users with specific Machine Fingerprints can connect to the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether users from specific Machine Fingerprints can change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether users with specific Machine Fingerprints can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether users with specific Machine Fingerprints can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether users with specific Machine Fingerprints can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether users with specific Machine Fingerprints can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether users with specific Machine Fingerprints can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether users with specific Machine Fingerprints can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether users with specific Machine Fingerprints can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific Machine Fingerprint will supersede any parameter-level permissions that might otherwise apply to that user (from groups or standard permissions above). Machine Fingerprint address permissions are overriden if the user has their own row in the users section.</p>'>?</a>",
"span": 11
"label": "Permissions <a data-toggle='tooltip' data-html='true' title='<p><strong>Domain-Wide Machine Fingerprint Permissions</strong></p><ul><li><strong>Connect</strong><br />Sets whether users with specific Machine Fingerprints can connect to the domain.</li><li><strong>Avatar Entities</strong><br />Sets whether users with specific Machine Fingerprints can use avatar entities on the domain.</li><li><strong>Lock / Unlock</strong><br />Sets whether users from specific Machine Fingerprints can change the &ldquo;locked&rdquo; property of an entity (either from on to off or off to on).</li><li><strong>Rez</strong><br />Sets whether users with specific Machine Fingerprints can create new entities.</li><li><strong>Rez Temporary</strong><br />Sets whether users with specific Machine Fingerprints can create new entities with a finite lifetime.</li><li><strong>Rez Certified</strong><br />Sets whether users with specific Machine Fingerprints can create new certified entities.</li><li><strong>Rez Temporary Certified</strong><br />Sets whether users with specific Machine Fingerprints can create new certified entities with a finite lifetime.</li><li><strong>Write Assets</strong><br />Sets whether users with specific Machine Fingerprints can make changes to the domain&rsquo;s asset-server assets.</li><li><strong>Ignore Max Capacity</strong><br />Sets whether users with specific Machine Fingerprints can connect even if the domain has reached or exceeded its maximum allowed agents.</li><li><strong>Replace Content</strong><br>Sets whether users with specific Machine Fingerprints can replace entire content sets by wiping existing domain content.</li><li><strong>Get and Set Private User Data</strong><br>Sets whether a user can get and set the privateUserData entity property.</li></ul><p>Note that permissions assigned to a specific Machine Fingerprint will supersede any parameter-level permissions that might otherwise apply to that user (from groups or standard permissions above). Machine Fingerprint address permissions are overriden if the user has their own row in the users section.</p>'>?</a>",
"span": 12
}
],
"columns": [
@ -1047,6 +1093,13 @@
"editable": true,
"default": false
},
{
"name": "id_can_rez_avatar_entities",
"label": "Avatar Entities",
"type": "checkbox",
"editable": true,
"default": false
},
{
"name": "id_can_adjust_locks",
"label": "Lock / Unlock",
@ -1488,6 +1541,24 @@
}
]
},
{
"name": "messages_mixer",
"label": "Messages Mixer",
"assignment-types": [
4
],
"settings": [
{
"name": "max_node_messages_per_second",
"type": "int",
"label": "Maximum Message Rate",
"help": "Maximum message send rate (messages per second) per node",
"placeholder": 1000,
"default": 1000,
"advanced": true
}
]
},
{
"name": "entity_server_settings",
"label": "Entities",

View file

@ -465,6 +465,7 @@ function savePermissions() {
"standard_permissions": [
{
"id_can_connect": anonymousCanConnect,
"id_can_rez_avatar_entities": anonymousCanConnect,
"id_can_rez": anonymousCanRez,
"id_can_rez_certified": anonymousCanRez,
"id_can_rez_tmp": anonymousCanRez,
@ -473,6 +474,7 @@ function savePermissions() {
},
{
"id_can_connect": friendsCanConnect,
"id_can_rez_avatar_entities": friendsCanConnect,
"id_can_rez": friendsCanRez,
"id_can_rez_certified": friendsCanRez,
"id_can_rez_tmp": friendsCanRez,
@ -481,6 +483,7 @@ function savePermissions() {
},
{
"id_can_connect": loggedInCanConnect,
"id_can_rez_avatar_entities": loggedInCanConnect,
"id_can_rez": loggedInCanRez,
"id_can_rez_certified": loggedInCanRez,
"id_can_rez_tmp": loggedInCanRez,
@ -490,6 +493,7 @@ function savePermissions() {
{
"id_can_adjust_locks": localhostPermissions,
"id_can_connect": localhostPermissions,
"id_can_rez_avatar_entities": localhostPermissions,
"id_can_connect_past_max_capacity": localhostPermissions,
"id_can_kick": localhostPermissions,
"id_can_replace_content": localhostPermissions,

View file

@ -353,6 +353,7 @@ void DomainGatekeeper::updateNodePermissions() {
userPerms.permissions |= NodePermissions::Permission::canWriteToAssetServer;
userPerms.permissions |= NodePermissions::Permission::canReplaceDomainContent;
userPerms.permissions |= NodePermissions::Permission::canGetAndSetPrivateUserData;
userPerms.permissions |= NodePermissions::Permission::canRezAvatarEntities;
} else {
// at this point we don't have a sending socket for packets from this node - assume it is the active socket
// or the public socket if we haven't activated a socket for the node yet
@ -448,6 +449,7 @@ SharedNodePointer DomainGatekeeper::processAssignmentConnectRequest(const NodeCo
userPerms.permissions |= NodePermissions::Permission::canWriteToAssetServer;
userPerms.permissions |= NodePermissions::Permission::canReplaceDomainContent;
userPerms.permissions |= NodePermissions::Permission::canGetAndSetPrivateUserData;
userPerms.permissions |= NodePermissions::Permission::canRezAvatarEntities;
newNode->setPermissions(userPerms);
return newNode;
}

View file

@ -66,6 +66,7 @@ using namespace std::chrono;
Q_LOGGING_CATEGORY(domain_server, "hifi.domain_server")
Q_LOGGING_CATEGORY(domain_server_ice, "hifi.domain_server.ice")
Q_LOGGING_CATEGORY(domain_server_auth, "vircadia.domain_server.auth")
const QString ACCESS_TOKEN_KEY_PATH = "metaverse.access_token";
const QString DomainServer::REPLACEMENT_FILE_EXTENSION = ".replace";
@ -1545,9 +1546,9 @@ void DomainServer::sendHeartbeatToMetaverse(const QString& networkAddress, const
static const QString PORT_SETTINGS_KEY = "domain_server." + PUBLIC_SOCKET_PORT_KEY;
const int portFromSettings = _settingsManager.valueForKeyPath(PORT_SETTINGS_KEY).toInt();
if (port != NULL) {
if (port != 0) {
domainObject[PUBLIC_SOCKET_PORT_KEY] = port;
} else if (portFromSettings != NULL) {
} else if (portFromSettings != 0) {
domainObject[PUBLIC_SOCKET_PORT_KEY] = portFromSettings;
}
@ -2771,6 +2772,20 @@ void DomainServer::profileRequestFinished() {
}
}
QString DomainServer::operationToString(const QNetworkAccessManager::Operation &op) {
switch(op) {
case QNetworkAccessManager::Operation::HeadOperation: return "HEAD";
case QNetworkAccessManager::Operation::GetOperation: return "GET";
case QNetworkAccessManager::Operation::PutOperation: return "PUT";
case QNetworkAccessManager::Operation::PostOperation: return "POST";
case QNetworkAccessManager::Operation::DeleteOperation: return "DELETE";
case QNetworkAccessManager::Operation::CustomOperation: return "CUSTOM";
case QNetworkAccessManager::Operation::UnknownOperation:
default:
return "UNKNOWN";
}
}
std::pair<bool, QString> DomainServer::isAuthenticatedRequest(HTTPConnection* connection) {
static const QByteArray HTTP_COOKIE_HEADER_KEY = "Cookie";
@ -2784,6 +2799,9 @@ std::pair<bool, QString> DomainServer::isAuthenticatedRequest(HTTPConnection* c
QVariant adminUsersVariant = _settingsManager.valueForKeyPath(ADMIN_USERS_CONFIG_KEY);
QVariant adminRolesVariant = _settingsManager.valueForKeyPath(ADMIN_ROLES_CONFIG_KEY);
QString httpPeerAddress = connection->peerAddress().toString();
QString httpOperation = operationToString(connection->requestOperation());
if (_oauthEnable) {
QString cookieString = connection->requestHeader(HTTP_COOKIE_HEADER_KEY);
@ -2817,11 +2835,15 @@ std::pair<bool, QString> DomainServer::isAuthenticatedRequest(HTTPConnection* c
foreach(const QString& userRole, sessionData.getRoles()) {
if (adminRolesArray.contains(userRole)) {
// this user has a role that allows them to administer the domain-server
qCInfo(domain_server_auth) << httpPeerAddress << "- OAuth:" << profileUsername << " - "
<< httpOperation << " " << connection->requestUrl();
return { true, profileUsername };
}
}
}
qCWarning(domain_server_auth) << httpPeerAddress << "- OAuth authentication failed for " << profileUsername << "-"
<< httpOperation << " " << connection->requestUrl();
connection->respond(HTTPConnection::StatusCode401, UNAUTHENTICATED_BODY);
// the user does not have allowed username or role, return 401
@ -2833,6 +2855,9 @@ std::pair<bool, QString> DomainServer::isAuthenticatedRequest(HTTPConnection* c
if (connection->requestHeader(REQUESTED_WITH_HEADER) == XML_REQUESTED_WITH) {
// unauthorized XHR requests get a 401 and not a 302, since there isn't an XHR
// path to OAuth authorize
qCWarning(domain_server_auth) << httpPeerAddress << "- OAuth unauthorized XHR -"
<< httpOperation << " " << connection->requestUrl();
connection->respond(HTTPConnection::StatusCode401, UNAUTHENTICATED_BODY);
} else {
// re-direct this user to OAuth page
@ -2849,6 +2874,8 @@ std::pair<bool, QString> DomainServer::isAuthenticatedRequest(HTTPConnection* c
redirectHeaders.insert("Location", authURL.toEncoded());
qCWarning(domain_server_auth) << httpPeerAddress << "- OAuth redirecting -"
<< httpOperation << " " << connection->requestUrl();
connection->respond(HTTPConnection::StatusCode302,
QByteArray(), HTTPConnection::DefaultContentType, redirectHeaders);
}
@ -2883,7 +2910,12 @@ std::pair<bool, QString> DomainServer::isAuthenticatedRequest(HTTPConnection* c
"" : QCryptographicHash::hash(headerPassword.toUtf8(), QCryptographicHash::Sha256).toHex();
if (settingsUsername == headerUsername && hexHeaderPassword == settingsPassword) {
qCInfo(domain_server_auth) << httpPeerAddress << "- Basic:" << headerUsername << "-"
<< httpOperation << " " << connection->requestUrl();
return { true, headerUsername };
} else {
qCWarning(domain_server_auth) << httpPeerAddress << "- Basic auth failed for" << headerUsername << "-"
<< httpOperation << " " << connection->requestUrl();
}
}
}
@ -2904,11 +2936,13 @@ std::pair<bool, QString> DomainServer::isAuthenticatedRequest(HTTPConnection* c
connection->respond(HTTPConnection::StatusCode401, UNAUTHENTICATED_BODY,
HTTPConnection::DefaultContentType, basicAuthHeader);
qCWarning(domain_server_auth) << httpPeerAddress << "- Basic auth required -" << httpOperation << " " << connection->requestUrl();
// not authenticated, bubble up false
return { false, QString() };
} else {
// we don't have an OAuth URL + admin roles/usernames, so all users are authenticated
qCWarning(domain_server_auth) << httpPeerAddress << "- OPEN ACCESS -" << httpOperation << " " << connection->requestUrl();
return { true, QString() };
}
}

View file

@ -43,6 +43,7 @@
Q_DECLARE_LOGGING_CATEGORY(domain_server)
Q_DECLARE_LOGGING_CATEGORY(domain_server_ice)
Q_DECLARE_LOGGING_CATEGORY(domain_server_auth)
typedef QSharedPointer<Assignment> SharedAssignmentPointer;
typedef QMultiHash<QUuid, WalletTransaction*> TransactionHash;
@ -233,6 +234,8 @@ private:
std::initializer_list<QString> optionalData = { },
bool requireAccessToken = true);
QString operationToString(const QNetworkAccessManager::Operation &op);
SubnetList _acSubnetWhitelist;
std::vector<QString> _replicatedUsernames;

View file

@ -37,6 +37,7 @@
#include <SettingHandle.h>
#include <SettingHelpers.h>
#include <FingerprintUtils.h>
#include <ModerationFlags.h>
#include "DomainServerNodeData.h"
@ -527,6 +528,28 @@ void DomainServerSettingsManager::setupConfigMap(const QString& userConfigFilena
*newAdminRoles = adminRoles;
}
if (oldVersion < 2.5) {
// Default values for new canRezAvatarEntities permission.
unpackPermissions();
std::list<std::unordered_map<NodePermissionsKey, NodePermissionsPointer>> permissionsSets{
_standardAgentPermissions.get(),
_agentPermissions.get(),
_ipPermissions.get(),
_macPermissions.get(),
_machineFingerprintPermissions.get(),
_groupPermissions.get(),
_groupForbiddens.get()
};
foreach (auto permissionsSet, permissionsSets) {
for (auto entry : permissionsSet) {
const auto& userKey = entry.first;
if (permissionsSet[userKey]->can(NodePermissions::Permission::canConnectToDomain)) {
permissionsSet[userKey]->set(NodePermissions::Permission::canRezAvatarEntities);
}
}
}
packPermissions();
}
// write the current description version to our settings
*versionVariant = _descriptionVersion;
@ -863,6 +886,20 @@ void DomainServerSettingsManager::processNodeKickRequestPacket(QSharedPointer<Re
// pull the UUID being kicked from the packet
QUuid nodeUUID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
bool hasOptionalBanParameters = false;
int banParameters;
bool banByUsername;
bool banByFingerprint;
bool banByIP;
// pull optional ban parameters from the packet
if (message.data()->getSize() == (NUM_BYTES_RFC4122_UUID + sizeof(int))) {
hasOptionalBanParameters = true;
message->readPrimitive(&banParameters);
banByUsername = banParameters & ModerationFlags::BanFlags::BAN_BY_USERNAME;
banByFingerprint = banParameters & ModerationFlags::BanFlags::BAN_BY_FINGERPRINT;
banByIP = banParameters & ModerationFlags::BanFlags::BAN_BY_IP;
}
if (!nodeUUID.isNull() && nodeUUID != sendingNode->getUUID()) {
// make sure we actually have a node with this UUID
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
@ -881,16 +918,20 @@ void DomainServerSettingsManager::processNodeKickRequestPacket(QSharedPointer<Re
if (!verifiedUsername.isEmpty()) {
// if we have a verified user name for this user, we first apply the kick to the username
// check if there were already permissions
bool hadPermissions = havePermissionsForName(verifiedUsername);
// if we have optional ban parameters, we should ban the username based on the parameter
if (!hasOptionalBanParameters || banByUsername) {
// check if there were already permissions
bool hadPermissions = havePermissionsForName(verifiedUsername);
// grab or create permissions for the given username
auto userPermissions = _agentPermissions[matchingNode->getPermissions().getKey()];
// grab or create permissions for the given username
auto userPermissions = _agentPermissions[matchingNode->getPermissions().getKey()];
newPermissions = !hadPermissions || userPermissions->can(NodePermissions::Permission::canConnectToDomain);
newPermissions =
!hadPermissions || userPermissions->can(NodePermissions::Permission::canConnectToDomain);
// ensure that the connect permission is clear
userPermissions->clear(NodePermissions::Permission::canConnectToDomain);
// ensure that the connect permission is clear
userPermissions->clear(NodePermissions::Permission::canConnectToDomain);
}
}
// if we didn't have a username, or this domain-server uses the "multi-kick" setting to
@ -898,7 +939,7 @@ void DomainServerSettingsManager::processNodeKickRequestPacket(QSharedPointer<Re
// then we remove connect permissions for the machine fingerprint (or IP as fallback)
const QString MULTI_KICK_SETTINGS_KEYPATH = "security.multi_kick_logged_in";
if (verifiedUsername.isEmpty() || valueOrDefaultValueForKeyPath(MULTI_KICK_SETTINGS_KEYPATH).toBool()) {
if (banByFingerprint || verifiedUsername.isEmpty() || valueOrDefaultValueForKeyPath(MULTI_KICK_SETTINGS_KEYPATH).toBool()) {
// remove connect permissions for the machine fingerprint
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(matchingNode->getLinkedData());
if (nodeData) {
@ -923,36 +964,39 @@ void DomainServerSettingsManager::processNodeKickRequestPacket(QSharedPointer<Re
fingerprintPermissions->clear(NodePermissions::Permission::canConnectToDomain);
}
} else {
// if no node data, all we can do is IP address
auto& kickAddress = matchingNode->getActiveSocket()
? matchingNode->getActiveSocket()->getAddress()
: matchingNode->getPublicSocket().getAddress();
// if no node data, all we can do is ban by IP address
banByIP = true;
}
}
if (banByIP) {
auto& kickAddress = matchingNode->getActiveSocket()
? matchingNode->getActiveSocket()->getAddress()
: matchingNode->getPublicSocket().getAddress();
// probably isLoopback covers it, as whenever I try to ban an agent on same machine as the domain-server
// it is always 127.0.0.1, but looking at the public and local addresses just to be sure
// TODO: soon we will have feedback (in the form of a message to the client) after we kick. When we
// do, we will have a success flag, and perhaps a reason for failure. For now, just don't do it.
if (kickAddress == limitedNodeList->getPublicSockAddr().getAddress() ||
kickAddress == limitedNodeList->getLocalSockAddr().getAddress() ||
kickAddress.isLoopback() ) {
qWarning() << "attempt to kick node running on same machine as domain server, ignoring KickRequest";
return;
}
// probably isLoopback covers it, as whenever I try to ban an agent on same machine as the domain-server
// it is always 127.0.0.1, but looking at the public and local addresses just to be sure
// TODO: soon we will have feedback (in the form of a message to the client) after we kick. When we
// do, we will have a success flag, and perhaps a reason for failure. For now, just don't do it.
if (kickAddress == limitedNodeList->getPublicSockAddr().getAddress() ||
kickAddress == limitedNodeList->getLocalSockAddr().getAddress() ||
kickAddress.isLoopback() ) {
qWarning() << "attempt to kick node running on same machine as domain server, ignoring KickRequest";
return;
}
NodePermissionsKey ipAddressKey(kickAddress.toString(), QUuid());
NodePermissionsKey ipAddressKey(kickAddress.toString(), QUuid());
// check if there were already permissions for the IP
bool hadIPPermissions = hasPermissionsForIP(kickAddress);
// check if there were already permissions for the IP
bool hadIPPermissions = hasPermissionsForIP(kickAddress);
// grab or create permissions for the given IP address
auto ipPermissions = _ipPermissions[ipAddressKey];
// grab or create permissions for the given IP address
auto ipPermissions = _ipPermissions[ipAddressKey];
if (!hadIPPermissions || ipPermissions->can(NodePermissions::Permission::canConnectToDomain)) {
newPermissions = true;
if (!hadIPPermissions || ipPermissions->can(NodePermissions::Permission::canConnectToDomain)) {
newPermissions = true;
ipPermissions->clear(NodePermissions::Permission::canConnectToDomain);
}
ipPermissions->clear(NodePermissions::Permission::canConnectToDomain);
}
}
@ -1448,6 +1492,8 @@ QJsonObject DomainServerSettingsManager::settingsResponseObjectForType(const QSt
SettingsBackupFlag settingsBackupFlag) {
QJsonObject responseObject;
responseObject["version"] = _descriptionVersion; // Domain settings version number.
if (!typeValue.isEmpty() || authentication == Authenticated) {
// convert the string type value to a QJsonValue
QJsonValue queryType = typeValue.isEmpty() ? QJsonValue() : QJsonValue(typeValue.toInt());

View file

@ -518,7 +518,12 @@ Rectangle {
glyphText: "\ue02e"
onClicked: {
adjustWearables.open(currentAvatar);
if (!AddressManager.isConnected || Entities.canRezAvatarEntities()) {
adjustWearables.open(currentAvatar);
} else {
Window.alert("You cannot use wearables on this domain.")
}
}
}
@ -529,7 +534,11 @@ Rectangle {
glyphText: wearablesFrozen ? hifi.glyphs.lock : hifi.glyphs.unlock;
onClicked: {
emitSendToScript({'method' : 'toggleWearablesFrozen'});
if (!AddressManager.isConnected || Entities.canRezAvatarEntities()) {
emitSendToScript({'method' : 'toggleWearablesFrozen'});
} else {
Window.alert("You cannot use wearables on this domain.")
}
}
}
}

View file

@ -478,7 +478,7 @@ Rectangle {
visible: iAmAdmin;
role: "mute";
title: "SILENCE";
width: actionButtonWidth;
width: actionButtonWidth - 8;
movable: false;
resizable: false;
}
@ -506,6 +506,7 @@ Rectangle {
id: itemCell;
property bool isCheckBox: styleData.role === "personalMute" || styleData.role === "ignore";
property bool isButton: styleData.role === "mute" || styleData.role === "kick";
property bool isBan: styleData.role === "kick";
property bool isAvgAudio: styleData.role === "avgAudioLevel";
opacity: !isButton ? (model && model.isPresent ? 1.0 : 0.4) : 1.0; // Admin actions shouldn't turn gray
@ -605,7 +606,9 @@ Rectangle {
color: 2; // Red
visible: isButton;
enabled: !nameCard.isReplicated;
anchors.centerIn: parent;
anchors.verticalCenter: itemCell.verticalCenter;
anchors.left: parent.left;
anchors.leftMargin: styleData.role === "kick" ? 1 : 14;
width: 32;
height: 32;
onClicked: {
@ -620,7 +623,39 @@ Rectangle {
HiFiGlyphs {
text: (styleData.role === "kick") ? hifi.glyphs.error : hifi.glyphs.muted;
// Size
size: parent.height*1.3;
size: parent.height * 1.3;
// Anchors
anchors.fill: parent;
// Style
horizontalAlignment: Text.AlignHCenter;
color: enabled ? hifi.buttons.textColor[actionButton.color]
: hifi.buttons.disabledTextColor[actionButton.colorScheme];
}
}
HifiControlsUit.Button {
id: hardBanButton;
color: 2; // Red
visible: isBan;
enabled: !nameCard.isReplicated;
anchors.verticalCenter: itemCell.verticalCenter;
anchors.left: parent.left;
anchors.leftMargin: actionButton.width + 3;
width: 32;
height: 32;
onClicked: {
Users[styleData.role](model.sessionId, Users.BAN_BY_USERNAME | Users.BAN_BY_FINGERPRINT | Users.BAN_BY_IP);
UserActivityLogger["palAction"](styleData.role, model.sessionId);
if (styleData.role === "kick") {
nearbyUserModelData.splice(model.userIndex, 1);
nearbyUserModel.remove(model.userIndex); // after changing nearbyUserModelData, b/c ListModel can frob the data
}
}
// muted/error glyphs
HiFiGlyphs {
text: hifi.glyphs.alert;
// Size
size: parent.height * 1.3;
// Anchors
anchors.fill: parent;
// Style
@ -720,7 +755,8 @@ Rectangle {
onClicked: letterbox(hifi.glyphs.question,
"Admin Actions",
"<b>Silence</b> mutes a user's microphone. Silenced users can unmute themselves by clicking &quot;UNMUTE&quot; on their toolbar.<br><br>" +
"<b>Ban</b> removes a user from this domain and prevents them from returning. Admins can un-ban users from the Sandbox Domain Settings page.");
"<b>Ban (left)</b> identifies a user by username (if applicable) and machine fingerprint, then removes them from this domain and prevents them from returning. Admins can un-ban users from the Server Domain Settings page.<br><br>" +
"<b>Hard Ban (right)</b> identifies a user by username (if applicable), machine fingerprint, and IP address, then removes them from this domain and prevents them from returning. Admins can un-ban users from the Server Domain Settings page.");
onEntered: adminHelpText.color = "#94132e";
onExited: adminHelpText.color = hifi.colors.redHighlight;
}

View file

@ -15,6 +15,7 @@
import QtQuick 2.10
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import stylesUit 1.0
import controlsUit 1.0 as HifiControlsUit
@ -104,6 +105,11 @@ Rectangle {
AudioScriptingInterface.setSystemInjectorGain(sliderValue);
}
}
function updateNoiseReductionThresholdFromQML(sliderValue) {
if (AudioScriptingInterface.getNoiseReductionThreshold() !== sliderValue) {
AudioScriptingInterface.setNoiseReductionThreshold(sliderValue);
}
}
Component.onCompleted: {
enablePeakValues();
@ -164,7 +170,7 @@ Rectangle {
x: 2 * margins.paddings;
width: parent.width;
// switch heights + 2 * top margins
height: (root.switchHeight) * 6 + 48;
height: (bar.currentIndex === 0) ? (root.switchHeight) * 2 + 48 : (root.switchHeight) * 4 + 48;
anchors.top: firstSeparator.bottom;
anchors.topMargin: 10;
@ -175,6 +181,7 @@ Rectangle {
height: parent.height;
anchors.top: parent.top
anchors.left: parent.left;
HifiControlsUit.Switch {
id: muteMic;
height: root.switchHeight;
@ -193,45 +200,11 @@ Rectangle {
}
}
HifiControlsUit.Switch {
id: noiseReductionSwitch;
height: root.switchHeight;
switchWidth: root.switchWidth;
anchors.top: muteMic.bottom;
anchors.topMargin: 24
anchors.left: parent.left
labelTextOn: "Noise Reduction";
labelTextSize: 16;
backgroundOnColor: "#E3E3E3";
checked: AudioScriptingInterface.noiseReduction;
onCheckedChanged: {
AudioScriptingInterface.noiseReduction = checked;
checked = Qt.binding(function() { return AudioScriptingInterface.noiseReduction; }); // restore binding
}
}
HifiControlsUit.Switch {
id: acousticEchoCancellationSwitch;
height: root.switchHeight;
switchWidth: root.switchWidth;
anchors.top: noiseReductionSwitch.bottom
anchors.topMargin: 24
anchors.left: parent.left
labelTextOn: "Echo Cancellation";
labelTextSize: 16;
backgroundOnColor: "#E3E3E3";
checked: AudioScriptingInterface.acousticEchoCancellation;
onCheckedChanged: {
AudioScriptingInterface.acousticEchoCancellation = checked;
checked = Qt.binding(function() { return AudioScriptingInterface.acousticEchoCancellation; });
}
}
HifiControlsUit.Switch {
id: pttSwitch
height: root.switchHeight;
switchWidth: root.switchWidth;
anchors.top: acousticEchoCancellationSwitch.bottom;
anchors.top: muteMic.bottom;
anchors.topMargin: 24
anchors.left: parent.left
labelTextOn: (bar.currentIndex === 0) ? qsTr("Push To Talk (T)") : qsTr("Push To Talk");
@ -254,6 +227,7 @@ Rectangle {
height: parent.height;
anchors.top: parent.top
anchors.left: switchContainer.right;
HifiControlsUit.Switch {
id: warnMutedSwitch
height: root.switchHeight;
@ -271,7 +245,6 @@ Rectangle {
}
}
HifiControlsUit.Switch {
id: audioLevelSwitch
height: root.switchHeight;
@ -519,13 +492,282 @@ Rectangle {
anchors.top: systemInjectorGainContainer.bottom;
anchors.topMargin: 10;
}
Item {
id: noiseReductionHeader
x: margins.paddings;
width: parent.width - margins.paddings * 2;
height: 36;
anchors.top: secondSeparator.bottom;
anchors.topMargin: 10;
HiFiGlyphs {
width: margins.sizeCheckBox;
text: hifi.glyphs.mic;
color: hifi.colors.white;
anchors.left: parent.left;
anchors.leftMargin: -size / 4; // The glyph has empty space at left about 25%
anchors.verticalCenter: parent.verticalCenter;
size: 30;
}
RalewayRegular {
anchors.verticalCenter: parent.verticalCenter;
width: margins.sizeText + margins.sizeLevel;
anchors.left: parent.left;
anchors.leftMargin: margins.sizeCheckBox;
size: 22;
color: hifi.colors.white;
text: qsTr("Noise Reduction");
}
}
Item {
id: noiseReductionSwitches;
x: 2 * margins.paddings;
width: parent.width;
// switch heights + 2 * top margins
height: (root.switchHeight) * 5 + 48;
anchors.top: noiseReductionHeader.bottom;
anchors.topMargin: 0;
Item {
id: noiseReductionSwitchContainer;
x: margins.paddings;
width: parent.width / 2;
height: parent.height;
anchors.top: parent.top;
anchors.left: parent.left;
HifiControlsUit.Switch {
id: acousticEchoCancellationSwitch;
height: root.switchHeight;
switchWidth: root.switchWidth;
anchors.top: noiseReductionSwitchContainer.top
anchors.topMargin: 24
anchors.left: parent.left
labelTextOn: "Echo Cancellation";
labelTextSize: 16;
backgroundOnColor: "#E3E3E3";
checked: AudioScriptingInterface.acousticEchoCancellation;
onCheckedChanged: {
AudioScriptingInterface.acousticEchoCancellation = checked;
checked = Qt.binding(function () { return AudioScriptingInterface.acousticEchoCancellation; });
}
}
HifiControlsUit.Switch {
id: noiseReductionSwitch;
height: root.switchHeight;
switchWidth: root.switchWidth;
anchors.top: acousticEchoCancellationSwitch.bottom;
anchors.topMargin: 24
anchors.left: parent.left
labelTextOn: "Noise Reduction";
labelTextSize: 16;
backgroundOnColor: "#E3E3E3";
checked: AudioScriptingInterface.noiseReduction;
onCheckedChanged: {
AudioScriptingInterface.noiseReduction = checked;
checked = Qt.binding(function () { return AudioScriptingInterface.noiseReduction; }); // restore binding
}
}
HifiControlsUit.Switch {
id: noiseReductionAutomaticSwitch;
height: root.switchHeight;
switchWidth: root.switchWidth;
anchors.top: noiseReductionSwitch.bottom;
anchors.topMargin: 24;
anchors.left: parent.left;
labelTextOn: "Manual Noise Reduction";
labelTextSize: 16;
backgroundOnColor: "#E3E3E3";
checked: !AudioScriptingInterface.noiseReductionAutomatic;
visible: AudioScriptingInterface.noiseReduction;
onCheckedChanged: {
AudioScriptingInterface.noiseReductionAutomatic = !checked;
checked = Qt.binding(function () { return !AudioScriptingInterface.noiseReductionAutomatic; }); // restore binding
}
}
}
}
Item {
id: noiseReductionThresholdContainer
x: margins.paddings;
anchors.top: noiseReductionSwitches.bottom;
anchors.topMargin: 16;
width: parent.width - margins.paddings * 2;
height: avatarGainSliderTextMetrics.height + 10;
visible: AudioScriptingInterface.noiseReduction && !AudioScriptingInterface.noiseReductionAutomatic;
HifiControlsUit.Slider {
id: noiseReductionThresholdSlider
anchors.right: parent.right
height: noiseReductionThresholdSliderTextMetrics.height
width: 200
minimumValue: 0.0
maximumValue: 1.0
stepSize: 0.05
value: AudioScriptingInterface.getNoiseReductionThreshold()
onValueChanged: {
updateNoiseReductionThresholdFromQML(value);
}
onPressedChanged: {
if (!pressed) {
updateNoiseReductionThresholdFromQML(value);
}
}
MouseArea {
anchors.fill: parent
onWheel: {
// Do nothing.
}
onDoubleClicked: {
noiseReductionThresholdSlider.value = 0.0;
}
onPressed: {
// Pass through to Slider
mouse.accepted = false;
}
onReleased: {
// the above mouse.accepted seems to make this
// never get called, nonetheless...
mouse.accepted = false;
}
}
}
TextMetrics {
id: noiseReductionThresholdSliderTextMetrics
text: noiseReductionThresholdSliderText.text
font: noiseReductionThresholdSliderText.font
}
RalewayRegular {
// The slider for my card is special, it controls the master gain
id: noiseReductionThresholdSliderText;
text: "Audio input threshold";
size: 16;
anchors.left: parent.left;
color: hifi.colors.white;
horizontalAlignment: Text.AlignLeft;
verticalAlignment: Text.AlignTop;
}
Item {
id: noisePeak
anchors.right: parent.right
anchors.rightMargin: 5;
anchors.top: noiseReductionThresholdSlider.bottom;
width: noiseReductionThresholdSlider.width - 10;
height: 8;
Text {
id: status;
anchors {
horizontalCenter: parent.horizontalCenter;
verticalCenter: parent.verticalCenter;
}
visible: AudioScriptingInterface.muted;
color: "#E2334D";
text: "MUTED";
font.pointSize: 10;
}
Item {
id: noiseBar;
property bool gated: false;
property var level: AudioScriptingInterface.inputLevel;
width: parent.width;
height: parent.height;
anchors { fill: parent }
visible: !status.visible;
function onNoiseGateOpened() {
noiseBar.gated = false;
}
function onNoiseGateClosed() {
noiseBar.gated = true;
}
function onInputLevelChanged(level) {
noiseBar.level = level;
}
Component.onCompleted: {
AudioScriptingInterface.noiseGateOpened.connect(onNoiseGateOpened);
AudioScriptingInterface.noiseGateClosed.connect(onNoiseGateClosed);
AudioScriptingInterface.inputLevelChanged.connect(onInputLevelChanged);
}
Component.onDestruction: {
AudioScriptingInterface.noiseGateOpened.disconnect(onNoiseGateOpened);
AudioScriptingInterface.noiseGateClosed.disconnect(onNoiseGateClosed);
AudioScriptingInterface.inputLevelChanged.disconnect(onInputLevelChanged);
}
Rectangle { // base
radius: 4;
anchors { fill: parent }
color: colors.gutter;
}
Rectangle { // noiseMask
id: noiseMask;
width: parent.width * noiseBar.level;
radius: 5;
anchors {
bottom: parent.bottom;
bottomMargin: 0;
top: parent.top;
topMargin: 0;
left: parent.left;
leftMargin: 0;
}
}
LinearGradient {
anchors { fill: noiseMask }
source: noiseMask
start: Qt.point(0, 0);
end: Qt.point(noiseBar.width, 0);
gradient: Gradient {
GradientStop {
position: 0;
color: noiseBar.gated ? "#E2334D" : "#39A38F";
}
GradientStop {
position: 1;
color: noiseBar.gated ? "#E2334D" : "#39A38F";
}
}
}
}
}
}
Separator {
id: thirdSeparator;
anchors.top: noiseReductionThresholdContainer.bottom;
anchors.topMargin: 14;
}
Item {
id: inputDeviceHeader
x: margins.paddings;
width: parent.width - margins.paddings*2;
height: 36;
anchors.top: secondSeparator.bottom;
anchors.top: thirdSeparator.bottom;
anchors.topMargin: 10;
HiFiGlyphs {
@ -597,19 +839,19 @@ Rectangle {
}
}
AudioControls.InputPeak {
id: inputLevel
anchors.right: parent.right
peak: model.peak;
anchors.verticalCenter: parent.verticalCenter
visible: ((bar.currentIndex === 1 && isVR) ||
(bar.currentIndex === 0 && !isVR)) &&
AudioScriptingInterface.devices.input.peakValuesAvailable;
id: inputLevel
anchors.right: parent.right
peak: model.peak;
anchors.verticalCenter: parent.verticalCenter
visible: ((bar.currentIndex === 1 && isVR) ||
(bar.currentIndex === 0 && !isVR)) &&
AudioScriptingInterface.devices.input.peakValuesAvailable;
}
}
}
Separator {
id: thirdSeparator;
id: fourthSeparator;
anchors.top: inputView.bottom;
anchors.topMargin: 10;
}
@ -617,7 +859,7 @@ Rectangle {
Item {
id: outputDeviceHeader;
anchors.topMargin: 10;
anchors.top: thirdSeparator.bottom;
anchors.top: fourthSeparator.bottom;
x: margins.paddings;
width: parent.width - margins.paddings*2
height: 36
@ -684,4 +926,4 @@ Rectangle {
}
}
}
}
}

View file

@ -112,8 +112,7 @@ MessageBox {
popup.button1text = 'CANCEL'
popup.titleText = 'Get Avatars'
popup.bodyText = 'Get avatars from <b><a href="app://marketplace">Marketplace.</a></b>' + '<br/>' +
'Wear avatars in <b><a href="app://purchases">Inventory.</a></b>'
popup.bodyText = 'Get avatars from the Community Bazaar. (Coming soon!)'
popup.onLinkClicked = function(link) {
popup.close();

View file

@ -4,6 +4,56 @@
"/": "/0.155245,-0.941538,23.9289/0,0.791589,0,0.611053"
},
"Entities": [
{
"id": "{0a199807-4a83-4286-b09c-f21124627c3e}",
"type": "Box",
"name": "Config Wizard Loader",
"lastEdited": 1613737207915514,
"visible": false,
"position": {
"x": -1.2722,
"y": 0.4266,
"z": 24.2307
},
"dimensions": {
"x": 0.20000000298023224,
"y": 0.20000000298023224,
"z": 0.20000000298023224
},
"rotation": {
"x": 0,
"y": -0.7660443782806396,
"z": 0,
"w": -0.6427876949310303
},
"created": 1613736996738696,
"lastEditedBy": "{ff9b500e-e450-4127-b41f-1c42be16f71b}",
"queryAACube": {
"x": -0.17320507764816284,
"y": -0.17320507764816284,
"z": -0.17320507764816284,
"scale": 0.3464101552963257
},
"grab": {
"grabbable": false
},
"damping": 0,
"angularDamping": 0,
"collisionless": true,
"ignoreForCollisions": true,
"script": "https://cdn-1.vircadia.com/us-e-1/DomainContent/Tutorial/Apps/configWizard/dist/wizardLoader.js",
"color": {
"red": 0,
"green": 180,
"blue": 239
},
"shape": "Cube",
"clientOnly": false,
"avatarEntity": false,
"localEntity": false,
"faceCamera": false,
"isFacingAvatar": false
},
{
"id": "{eb485a2d-2040-42f6-a960-51c88e2434b9}",
"type": "Box",

View file

@ -1306,6 +1306,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
_entityServerConnectionTimer.setSingleShot(true);
connect(&_entityServerConnectionTimer, &QTimer::timeout, this, &Application::setFailedToConnectToEntityServer);
connect(&domainHandler, &DomainHandler::confirmConnectWithoutAvatarEntities,
this, &Application::confirmConnectWithoutAvatarEntities);
connect(&domainHandler, &DomainHandler::connectedToDomain, this, [this]() {
if (!isServerlessMode()) {
_entityServerConnectionTimer.setInterval(ENTITY_SERVER_ADDED_TIMEOUT);
@ -2493,7 +2496,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
return viewFrustum.getPosition();
});
DependencyManager::get<UsersScriptingInterface>()->setKickConfirmationOperator([this] (const QUuid& nodeID) { userKickConfirmation(nodeID); });
DependencyManager::get<UsersScriptingInterface>()->setKickConfirmationOperator([this] (const QUuid& nodeID, unsigned int banFlags) { userKickConfirmation(nodeID, banFlags); });
render::entities::WebEntityRenderer::setAcquireWebSurfaceOperator([=](const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) {
bool isTablet = url == TabletScriptingInterface::QML;
@ -2989,6 +2992,8 @@ Application::~Application() {
qInstallMessageHandler(LogHandler::verboseMessageHandler);
#ifdef Q_OS_MAC
// 26 Feb 2021 - Tried re-enabling this call but OSX still crashes on exit.
//
// 10/16/2019 - Disabling this call. This causes known crashes (A), and it is not
// fully understood whether it might cause other unknown crashes (B).
//
@ -3573,7 +3578,7 @@ void Application::onDesktopRootItemCreated(QQuickItem* rootItem) {
_desktopRootItemCreated = true;
}
void Application::userKickConfirmation(const QUuid& nodeID) {
void Application::userKickConfirmation(const QUuid& nodeID, unsigned int banFlags) {
auto avatarHashMap = DependencyManager::get<AvatarHashMap>();
auto avatar = avatarHashMap->getAvatarBySessionID(nodeID);
@ -3598,7 +3603,7 @@ void Application::userKickConfirmation(const QUuid& nodeID) {
// ask the NodeList to kick the user with the given session ID
if (yes) {
DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID);
DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID, banFlags);
}
DependencyManager::get<UsersScriptingInterface>()->setWaitForKickResponse(false);
@ -4013,7 +4018,7 @@ void Application::handleSandboxStatus(QNetworkReply* reply) {
// If this is a first run we short-circuit the address passed in
if (_firstRun.get()) {
if (!BuildInfo::INITIAL_STARTUP_LOCATION.isEmpty()) {
if (!BuildInfo::PRELOADED_STARTUP_LOCATION.isEmpty()) {
DependencyManager::get<LocationBookmarks>()->setHomeLocationToAddress(NetworkingConstants::DEFAULT_VIRCADIA_ADDRESS);
Menu::getInstance()->triggerOption(MenuOption::HomeLocation);
}
@ -9172,6 +9177,32 @@ void Application::setShowBulletConstraintLimits(bool value) {
_physicsEngine->setShowBulletConstraintLimits(value);
}
void Application::confirmConnectWithoutAvatarEntities() {
if (_confirmConnectWithoutAvatarEntitiesDialog) {
// Dialog is already displayed.
return;
}
if (!getMyAvatar()->hasAvatarEntities()) {
// No avatar entities so continue with login.
DependencyManager::get<NodeList>()->getDomainHandler().setCanConnectWithoutAvatarEntities(true);
return;
}
QString continueMessage = "Your wearables will not display on this domain. Continue?";
_confirmConnectWithoutAvatarEntitiesDialog = OffscreenUi::asyncQuestion("Continue Without Wearables", continueMessage,
QMessageBox::Yes | QMessageBox::No);
if (_confirmConnectWithoutAvatarEntitiesDialog->getDialogItem()) {
QObject::connect(_confirmConnectWithoutAvatarEntitiesDialog, &ModalDialogListener::response, this, [=](QVariant answer) {
QObject::disconnect(_confirmConnectWithoutAvatarEntitiesDialog, &ModalDialogListener::response, this, nullptr);
_confirmConnectWithoutAvatarEntitiesDialog = nullptr;
bool shouldConnect = (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes);
DependencyManager::get<NodeList>()->getDomainHandler().setCanConnectWithoutAvatarEntities(shouldConnect);
});
}
}
void Application::createLoginDialog() {
const glm::vec3 LOGIN_DIMENSIONS { 0.89f, 0.5f, 0.01f };
const auto OFFSET = glm::vec2(0.7f, -0.1f);

View file

@ -50,6 +50,8 @@
#include <shared/ConicalViewFrustum.h>
#include <shared/FileLogger.h>
#include <RunningMarker.h>
#include <ModerationFlags.h>
#include <OffscreenUi.h>
#include "avatar/MyAvatar.h"
#include "FancyCamera.h"
@ -325,6 +327,8 @@ public:
int getOtherAvatarsReplicaCount() { return DependencyManager::get<AvatarHashMap>()->getReplicaCount(); }
void setOtherAvatarsReplicaCount(int count) { DependencyManager::get<AvatarHashMap>()->setReplicaCount(count); }
void confirmConnectWithoutAvatarEntities();
bool getLoginDialogPoppedUp() const { return _loginDialogPoppedUp; }
void createLoginDialog();
void updateLoginDialogPosition();
@ -608,7 +612,7 @@ private:
void toggleTabletUI(bool shouldOpen = false) const;
bool shouldCaptureMouse() const;
void userKickConfirmation(const QUuid& nodeID);
void userKickConfirmation(const QUuid& nodeID, unsigned int banFlags = ModerationFlags::getDefaultBanFlags());
MainWindow* _window;
QElapsedTimer& _sessionRunTimer;
@ -723,6 +727,8 @@ private:
bool _loginDialogPoppedUp{ false };
bool _desktopRootItemCreated{ false };
ModalDialogListener* _confirmConnectWithoutAvatarEntitiesDialog { nullptr };
bool _developerMenuVisible{ false };
QString _previousAvatarSkeletonModel;
float _previousAvatarTargetScale;

View file

@ -35,6 +35,7 @@ void ConnectionMonitor::init() {
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &ConnectionMonitor::stopTimer);
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ConnectionMonitor::stopTimer);
connect(&domainHandler, &DomainHandler::redirectToErrorDomainURL, this, &ConnectionMonitor::stopTimer);
connect(&domainHandler, &DomainHandler::confirmConnectWithoutAvatarEntities, this, &ConnectionMonitor::stopTimer);
connect(this, &ConnectionMonitor::setRedirectErrorState, &domainHandler, &DomainHandler::setRedirectErrorState);
auto accountManager = DependencyManager::get<AccountManager>();
connect(accountManager.data(), &AccountManager::loginComplete, this, &ConnectionMonitor::startTimer);

View file

@ -556,8 +556,6 @@ Menu::Menu() {
});
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::FixGaze, 0, false);
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ToggleHipsFollowing, 0, false,
avatar.get(), SLOT(setToggleHips(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawBaseOfSupport, 0, false,
avatar.get(), SLOT(setEnableDebugDrawBaseOfSupport(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawDefaultPose, 0, false,

View file

@ -211,7 +211,6 @@ namespace MenuOption {
const QString ThirdPerson = "Third Person Legacy";
const QString ThreePointCalibration = "3 Point Calibration";
const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus"; // FIXME - this value duplicated in Basic2DWindowOpenGLDisplayPlugin.cpp
const QString ToggleHipsFollowing = "Toggle Hips Following";
const QString ToolWindow = "Tool Window";
const QString TransmitterDrive = "Transmitter Drive";
const QString TurnWithHead = "Turn using Head";

View file

@ -544,7 +544,7 @@ void AvatarManager::removeDeadAvatarEntities(const SetOfEntities& deadEntities)
QUuid entityOwnerID = entity->getOwningAvatarID();
AvatarSharedPointer avatar = getAvatarBySessionID(entityOwnerID);
if (avatar) {
avatar->clearAvatarEntity(entity->getID());
avatar->clearAvatarEntityInternal(entity->getID());
}
}
}

View file

@ -278,6 +278,9 @@ MyAvatar::MyAvatar(QThread* thread) :
// when we leave a domain we lift whatever restrictions that domain may have placed on our scale
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &MyAvatar::leaveDomain);
auto nodeList = DependencyManager::get<NodeList>();
connect(nodeList.data(), &NodeList::canRezAvatarEntitiesChanged, this, &MyAvatar::handleCanRezAvatarEntitiesChanged);
_bodySensorMatrix = deriveBodyFromHMDSensor();
using namespace recording;
@ -365,12 +368,20 @@ MyAvatar::MyAvatar(QThread* thread) :
connect(&(_skeletonModel->getRig()), &Rig::onLoadFailed, this, &MyAvatar::onLoadFailed);
_characterController.setDensity(_density);
_addAvatarEntitiesToTreeTimer.setSingleShot(true);
connect(&_addAvatarEntitiesToTreeTimer, &QTimer::timeout, [this] {
addAvatarEntitiesToTree();
});
}
MyAvatar::~MyAvatar() {
_lookAtTargetAvatar.reset();
delete _scriptEngine;
_scriptEngine = nullptr;
if (_addAvatarEntitiesToTreeTimer.isActive()) {
_addAvatarEntitiesToTreeTimer.stop();
}
}
QString MyAvatar::getDominantHand() const {
@ -1393,15 +1404,9 @@ float loadSetting(Settings& settings, const QString& name, float defaultValue) {
}
void MyAvatar::setToggleHips(bool followHead) {
_follow.setToggleHipsFollowing(followHead);
}
void MyAvatar::FollowHelper::setToggleHipsFollowing(bool followHead) {
_toggleHipsFollowing = followHead;
}
bool MyAvatar::FollowHelper::getToggleHipsFollowing() const {
return _toggleHipsFollowing;
Q_UNUSED(followHead);
qCDebug(interfaceapp) << "MyAvatar.setToggleHips is deprecated; it no longer does anything; it will soon be removed from the API; "
"please update your script";
}
void MyAvatar::setEnableDebugDrawBaseOfSupport(bool isEnabled) {
@ -1533,7 +1538,23 @@ void MyAvatar::storeAvatarEntityDataPayload(const QUuid& entityID, const QByteAr
void MyAvatar::clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFromTree) {
// NOTE: the requiresRemovalFromTree argument is unused
AvatarData::clearAvatarEntity(entityID);
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp) << "Ignoring clearAvatarEntity() because don't have canRezAvatarEntities permission on domain";
return;
}
clearAvatarEntityInternal(entityID);
}
void MyAvatar::clearAvatarEntityInternal(const QUuid& entityID) {
AvatarData::clearAvatarEntityInternal(entityID);
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
// Don't delete potentially non-rezzed avatar entities from cache, otherwise they're removed from settings.
return;
}
_avatarEntitiesLock.withWriteLock([&] {
_cachedAvatarEntityBlobsToDelete.push_back(entityID);
});
@ -1564,6 +1585,39 @@ void MyAvatar::sanitizeAvatarEntityProperties(EntityItemProperties& properties)
properties.markAllChanged();
}
void MyAvatar::addAvatarEntitiesToTree() {
AvatarEntityMap::const_iterator constItr = _cachedAvatarEntityBlobs.begin();
while (constItr != _cachedAvatarEntityBlobs.end()) {
QUuid id = constItr.key();
_entitiesToAdd.push_back(id); // worked once: hat shown. then unshown when permissions removed but then entity was deleted somewhere along the line!
++constItr;
}
}
bool MyAvatar::hasAvatarEntities() const {
return _cachedAvatarEntityBlobs.count() > 0;
}
void MyAvatar::handleCanRezAvatarEntitiesChanged(bool canRezAvatarEntities) {
if (canRezAvatarEntities) {
// Start displaying avatar entities.
// Allow time for the avatar mixer to be updated with the user's permissions so that it doesn't discard the avatar
// entities sent. In theory, typical worst case would be Interface running on same PC as server and the timings of
// Interface and the avatar mixer sending DomainListRequest to the domain server being such that the avatar sends its
// DomainListRequest and gets its DomainList response DOMAIN_SERVER_CHECK_IN_MSECS after Interface does. Allow extra
// time in case the avatar mixer is bogged down.
_addAvatarEntitiesToTreeTimer.start(5 * DOMAIN_SERVER_CHECK_IN_MSECS); // Single-shot.
} else {
// Cancel any pending addAvatarEntitiesToTree() call.
if (_addAvatarEntitiesToTreeTimer.isActive()) {
_addAvatarEntitiesToTreeTimer.stop();
}
// Stop displaying avatar entities.
removeAvatarEntitiesFromTree();
}
}
void MyAvatar::handleChangedAvatarEntityData() {
// NOTE: this is a per-frame update
if (getID().isNull() ||
@ -1583,6 +1637,8 @@ void MyAvatar::handleChangedAvatarEntityData() {
return;
}
bool canRezAvatarEntites = DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities();
// We collect changes to AvatarEntities and then handle them all in one spot per frame: handleChangedAvatarEntityData().
// Basically this is a "transaction pattern" with an extra complication: these changes can come from two
// "directions" and the "authoritative source" of each direction is different, so we maintain two distinct sets
@ -1669,12 +1725,15 @@ void MyAvatar::handleChangedAvatarEntityData() {
continue;
}
sanitizeAvatarEntityProperties(properties);
entityTree->withWriteLock([&] {
EntityItemPointer entity = entityTree->addEntity(id, properties);
if (entity) {
packetSender->queueEditAvatarEntityMessage(entityTree, id);
}
});
if (canRezAvatarEntites) {
entityTree->withWriteLock([&] {
EntityItemPointer entity = entityTree->addEntity(id, properties);
if (entity) {
packetSender->queueEditAvatarEntityMessage(entityTree, id);
}
});
}
}
// CHANGE real entities
@ -1692,7 +1751,7 @@ void MyAvatar::handleChangedAvatarEntityData() {
skip = true;
}
});
if (!skip) {
if (!skip && canRezAvatarEntites) {
sanitizeAvatarEntityProperties(properties);
entityTree->withWriteLock([&] {
if (entityTree->updateEntity(id, properties)) {
@ -1834,6 +1893,11 @@ AvatarEntityMap MyAvatar::getAvatarEntityData() const {
return data;
}
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp) << "Ignoring getAvatarEntityData() because don't have canRezAvatarEntities permission on domain";
return data;
}
QList<QUuid> avatarEntityIDs;
_avatarEntitiesLock.withReadLock([&] {
avatarEntityIDs = _packedAvatarEntityData.keys();
@ -1879,6 +1943,12 @@ void MyAvatar::setAvatarEntityData(const AvatarEntityMap& avatarEntityData) {
// avatarEntityData is expected to be a map of QByteArrays that represent EntityItemProperties objects from JavaScript,
// aka: unfortunately-formatted-binary-blobs because we store them in non-human-readable format in Settings.
//
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp) << "Ignoring setAvatarEntityData() because don't have canRezAvatarEntities permission on domain";
return;
}
if (avatarEntityData.size() > MAX_NUM_AVATAR_ENTITIES) {
// the data is suspect
qCDebug(interfaceapp) << "discard suspect AvatarEntityData with size =" << avatarEntityData.size();
@ -1939,6 +2009,12 @@ void MyAvatar::setAvatarEntityData(const AvatarEntityMap& avatarEntityData) {
void MyAvatar::updateAvatarEntity(const QUuid& entityID, const QByteArray& entityData) {
// NOTE: this is an invokable Script call
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp) << "Ignoring updateAvatarEntity() because don't have canRezAvatarEntities permission on domain";
return;
}
bool changed = false;
_avatarEntitiesLock.withWriteLock([&] {
auto data = QJsonDocument::fromBinaryData(entityData);
@ -2030,7 +2106,6 @@ void MyAvatar::loadData() {
allowAvatarLeaningPreferenceStrings[static_cast<uint>(AllowAvatarLeaningPreference::Default)])));
setEnableMeshVisible(Menu::getInstance()->isOptionChecked(MenuOption::MeshVisible));
_follow.setToggleHipsFollowing (Menu::getInstance()->isOptionChecked(MenuOption::ToggleHipsFollowing));
setEnableDebugDrawBaseOfSupport(Menu::getInstance()->isOptionChecked(MenuOption::AnimDebugDrawBaseOfSupport));
setEnableDebugDrawDefaultPose(Menu::getInstance()->isOptionChecked(MenuOption::AnimDebugDrawDefaultPose));
setEnableDebugDrawAnimPose(Menu::getInstance()->isOptionChecked(MenuOption::AnimDebugDrawAnimPose));
@ -2532,7 +2607,7 @@ void MyAvatar::removeWornAvatarEntity(const EntityItemID& entityID) {
auto entity = entityTree->findEntityByID(entityID);
if (entity && isWearableEntity(entity)) {
treeRenderer->deleteEntity(entityID);
clearAvatarEntity(entityID);
clearAvatarEntityInternal(entityID);
}
}
}
@ -2565,6 +2640,13 @@ QVariantList MyAvatar::getAvatarEntitiesVariant() {
QVariantList avatarEntitiesData;
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
if (entityTree && !DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp)
<< "Ignoring getAvatarEntitiesVariant() because don't have canRezAvatarEntities permission on domain";
return avatarEntitiesData;
}
if (entityTree) {
QList<QUuid> avatarEntityIDs;
_avatarEntitiesLock.withReadLock([&] {
@ -2897,6 +2979,11 @@ void MyAvatar::attach(const QString& modelURL, const QString& jointName,
);
return;
}
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp) << "Ignoring attach() because don't have canRezAvatarEntities permission on domain";
return;
}
AttachmentData data;
data.modelURL = modelURL;
data.jointName = jointName;
@ -2918,6 +3005,11 @@ void MyAvatar::detachOne(const QString& modelURL, const QString& jointName) {
);
return;
}
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp) << "Ignoring detachOne() because don't have canRezAvatarEntities permission on domain";
return;
}
QUuid entityID;
if (findAvatarEntity(modelURL, jointName, entityID)) {
DependencyManager::get<EntityScriptingInterface>()->deleteEntity(entityID);
@ -2933,6 +3025,11 @@ void MyAvatar::detachAll(const QString& modelURL, const QString& jointName) {
);
return;
}
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp) << "Ignoring detachAll() because don't have canRezAvatarEntities permission on domain";
return;
}
QUuid entityID;
while (findAvatarEntity(modelURL, jointName, entityID)) {
DependencyManager::get<EntityScriptingInterface>()->deleteEntity(entityID);
@ -2946,6 +3043,11 @@ void MyAvatar::setAttachmentData(const QVector<AttachmentData>& attachmentData)
Q_ARG(const QVector<AttachmentData>&, attachmentData));
return;
}
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp) << "Ignoring setAttachmentData() because don't have canRezAvatarEntities permission on domain";
return;
}
std::vector<EntityItemProperties> newEntitiesProperties;
for (auto& data : attachmentData) {
QUuid entityID;
@ -2968,6 +3070,12 @@ void MyAvatar::setAttachmentData(const QVector<AttachmentData>& attachmentData)
QVector<AttachmentData> MyAvatar::getAttachmentData() const {
QVector<AttachmentData> attachmentData;
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp) << "Ignoring getAttachmentData() because don't have canRezAvatarEntities permission on domain";
return attachmentData;
}
QList<QUuid> avatarEntityIDs;
_avatarEntitiesLock.withReadLock([&] {
avatarEntityIDs = _packedAvatarEntityData.keys();
@ -2982,6 +3090,13 @@ QVector<AttachmentData> MyAvatar::getAttachmentData() const {
QVariantList MyAvatar::getAttachmentsVariant() const {
QVariantList result;
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp)
<< "Ignoring getAttachmentsVariant() because don't have canRezAvatarEntities permission on domain";
return result;
}
for (const auto& attachment : getAttachmentData()) {
result.append(attachment.toVariant());
}
@ -2994,6 +3109,13 @@ void MyAvatar::setAttachmentsVariant(const QVariantList& variant) {
Q_ARG(const QVariantList&, variant));
return;
}
if (!DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities()) {
qCDebug(interfaceapp)
<< "Ignoring setAttachmentsVariant() because don't have canRezAvatarEntities permission on domain";
return;
}
QVector<AttachmentData> newAttachments;
newAttachments.reserve(variant.size());
for (const auto& attachmentVar : variant) {
@ -4065,7 +4187,8 @@ float MyAvatar::getGravity() {
void MyAvatar::setSessionUUID(const QUuid& sessionUUID) {
QUuid oldSessionID = getSessionUUID();
Avatar::setSessionUUID(sessionUUID);
bool sendPackets = !DependencyManager::get<NodeList>()->getSessionUUID().isNull();
bool sendPackets = !DependencyManager::get<NodeList>()->getSessionUUID().isNull()
&& DependencyManager::get<NodeList>()->getThisNodeCanRezAvatarEntities();
if (!sendPackets) {
return;
}
@ -5514,7 +5637,7 @@ void MyAvatar::setSitStandStateChange(bool stateChanged) {
}
// Determine if the user's real-world sit/stand state has changed.
float MyAvatar::getSitStandStateChange() const {
bool MyAvatar::getSitStandStateChange() const {
return _sitStandStateChange;
}
@ -5696,7 +5819,7 @@ bool MyAvatar::FollowHelper::shouldActivateHorizontal_userSitting(const MyAvatar
bool stepDetected = false;
if (forwardLeanAmount > MAX_FORWARD_LEAN) {
stepDetected = true;
} else if (forwardLeanAmount < 0 && forwardLeanAmount < -MAX_BACKWARD_LEAN) {
} else if (forwardLeanAmount < -MAX_BACKWARD_LEAN) {
stepDetected = true;
} else {
stepDetected = fabs(lateralLeanAmount) > MAX_LATERAL_LEAN;

View file

@ -1454,6 +1454,7 @@ public:
void removeWornAvatarEntity(const EntityItemID& entityID);
void clearWornAvatarEntities();
bool hasAvatarEntities() const;
/**jsdoc
* Checks whether your avatar is flying.
@ -1800,7 +1801,7 @@ public:
void setAnalogPlusSprintSpeed(float value);
float getAnalogPlusSprintSpeed() const;
void setSitStandStateChange(bool stateChanged);
float getSitStandStateChange() const;
bool getSitStandStateChange() const;
void updateSitStandState(float newHeightReading, float dt);
QVector<QString> getScriptUrls();
@ -1939,6 +1940,8 @@ public:
void avatarEntityDataToJson(QJsonObject& root) const override;
void storeAvatarEntityDataPayload(const QUuid& entityID, const QByteArray& payload) override;
/**jsdoc
* @comment Uses the base class's JSDoc.
*/
@ -2277,12 +2280,6 @@ public slots:
*/
bool getEnableMeshVisible() const override;
/**jsdoc
* @function MyAvatar.storeAvatarEntityDataPayload
* @deprecated This function is deprecated and will be removed.
*/
void storeAvatarEntityDataPayload(const QUuid& entityID, const QByteArray& payload) override;
/**jsdoc
* @comment Uses the base class's JSDoc.
*/
@ -2656,6 +2653,7 @@ private slots:
protected:
void handleChangedAvatarEntityData();
void handleCanRezAvatarEntitiesChanged(bool canRezAvatarEntities);
virtual void beParentOfChild(SpatiallyNestablePointer newChild) const override;
virtual void forgetChild(SpatiallyNestablePointer newChild) const override;
virtual void recalculateChildCauterization() const override;
@ -2710,6 +2708,10 @@ private:
void attachmentDataToEntityProperties(const AttachmentData& data, EntityItemProperties& properties);
AttachmentData entityPropertiesToAttachmentData(const EntityItemProperties& properties) const;
bool findAvatarEntity(const QString& modelURL, const QString& jointName, QUuid& entityID);
void addAvatarEntitiesToTree();
// FIXME: Rename to clearAvatarEntity() once the API call is removed.
void clearAvatarEntityInternal(const QUuid& entityID) override;
bool cameraInsideHead(const glm::vec3& cameraPosition) const;
@ -2907,8 +2909,6 @@ private:
void setForceActivateVertical(bool val);
bool getForceActivateHorizontal() const;
void setForceActivateHorizontal(bool val);
bool getToggleHipsFollowing() const;
void setToggleHipsFollowing(bool followHead);
std::atomic<bool> _forceActivateRotation { false };
std::atomic<bool> _forceActivateVertical { false };
std::atomic<bool> _forceActivateHorizontal { false };
@ -3109,6 +3109,8 @@ private:
glm::vec3 _cameraEyesOffset;
float _landingAfterJumpTime { 0.0f };
QTimer _addAvatarEntitiesToTreeTimer;
};
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);

View file

@ -25,6 +25,8 @@ QString Audio::DESKTOP { "Desktop" };
QString Audio::HMD { "VR" };
Setting::Handle<bool> enableNoiseReductionSetting { QStringList { Audio::AUDIO, "NoiseReduction" }, true };
Setting::Handle<bool> enableNoiseReductionAutomaticSetting { QStringList { Audio::AUDIO, "NoiseReductionAutomatic" }, true };
Setting::Handle<float> setNoiseReductionThresholdSetting { QStringList { Audio::AUDIO, "NoiseReductionThreshold" }, 0.1f };
Setting::Handle<bool> enableWarnWhenMutedSetting { QStringList { Audio::AUDIO, "WarnWhenMuted" }, true };
Setting::Handle<bool> enableAcousticEchoCancellationSetting { QStringList { Audio::AUDIO, "AcousticEchoCancellation" }, true };
@ -40,6 +42,8 @@ Audio::Audio() : _devices(_contextIsHMD) {
auto client = DependencyManager::get<AudioClient>().data();
connect(client, &AudioClient::muteToggled, this, &Audio::setMuted);
connect(client, &AudioClient::noiseReductionChanged, this, &Audio::enableNoiseReduction);
connect(client, &AudioClient::noiseReductionAutomaticChanged, this, &Audio::enableNoiseReductionAutomatic);
connect(client, &AudioClient::noiseReductionThresholdChanged, this, &Audio::setNoiseReductionThreshold);
connect(client, &AudioClient::warnWhenMutedChanged, this, &Audio::enableWarnWhenMuted);
connect(client, &AudioClient::acousticEchoCancellationChanged, this, &Audio::enableAcousticEchoCancellation);
connect(client, &AudioClient::inputLoudnessChanged, this, &Audio::onInputLoudnessChanged);
@ -47,6 +51,8 @@ Audio::Audio() : _devices(_contextIsHMD) {
connect(this, &Audio::contextChanged, &_devices, &AudioDevices::onContextChanged);
connect(this, &Audio::pushingToTalkChanged, this, &Audio::handlePushedToTalk);
enableNoiseReduction(enableNoiseReductionSetting.get());
enableNoiseReductionAutomatic(enableNoiseReductionAutomaticSetting.get());
setNoiseReductionThreshold(setNoiseReductionThresholdSetting.get());
enableWarnWhenMuted(enableWarnWhenMutedSetting.get());
enableAcousticEchoCancellation(enableAcousticEchoCancellationSetting.get());
onContextChanged();
@ -286,6 +292,50 @@ void Audio::enableNoiseReduction(bool enable) {
}
}
bool Audio::noiseReductionAutomatic() const {
return resultWithReadLock<bool>([&] {
return _noiseReductionAutomatic;
});
}
void Audio::enableNoiseReductionAutomatic(bool enable) {
bool changed = false;
withWriteLock([&] {
if (_noiseReductionAutomatic != enable) {
_noiseReductionAutomatic = enable;
auto client = DependencyManager::get<AudioClient>().data();
QMetaObject::invokeMethod(client, "setNoiseReductionAutomatic", Q_ARG(bool, enable), Q_ARG(bool, false));
enableNoiseReductionAutomaticSetting.set(enable);
changed = true;
}
});
if (changed) {
emit noiseReductionAutomaticChanged(enable);
}
}
float Audio::getNoiseReductionThreshold() {
return resultWithReadLock<float>([&] {
return _noiseReductionThreshold;
});
}
void Audio::setNoiseReductionThreshold(float threshold) {
bool changed = false;
withWriteLock([&] {
if (_noiseReductionThreshold != threshold) {
_noiseReductionThreshold = threshold;
auto client = DependencyManager::get<AudioClient>().data();
QMetaObject::invokeMethod(client, "setNoiseReductionThreshold", Q_ARG(float, threshold), Q_ARG(bool, false));
setNoiseReductionThresholdSetting.set(threshold);
changed = true;
}
});
if (changed) {
emit noiseReductionThresholdChanged(threshold);
}
}
bool Audio::warnWhenMutedEnabled() const {
return resultWithReadLock<bool>([&] {
return _enableWarnWhenMuted;

View file

@ -50,6 +50,11 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable {
* @property {boolean} noiseReduction - <code>true</code> if noise reduction is enabled, otherwise <code>false</code>. When
* enabled, the input audio signal is blocked (fully attenuated) when it falls below an adaptive threshold set just
* above the noise floor.
* @property {boolean} noiseReductionAutomatic - <code>true</code> if audio input noise reduction automatic mode is enabled,
* <code>false</code> if in manual mode. Manual mode allows you to use <code>Audio.noiseReductionThreshold</code>
* to set a manual sensitivity for the noise gate.
* @property {number} noiseReductionThreshold - Sets the noise gate threshold before your mic audio is transmitted.
* (Applies only if <code>Audio.noiseReductionAutomatic</code> is <code>false</code>.)
* @property {number} inputVolume - Adjusts the volume of the input audio, range <code>0.0</code> &ndash; <code>1.0</code>.
* If set to a value, the resulting value depends on the input device: for example, the volume can't be changed on some
* devices, and others might only support values of <code>0.0</code> and <code>1.0</code>.
@ -92,6 +97,8 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable {
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
Q_PROPERTY(bool noiseReduction READ noiseReductionEnabled WRITE enableNoiseReduction NOTIFY noiseReductionChanged)
Q_PROPERTY(bool noiseReductionAutomatic READ noiseReductionAutomatic WRITE enableNoiseReductionAutomatic NOTIFY noiseReductionAutomaticChanged)
Q_PROPERTY(float noiseReductionThreshold READ getNoiseReductionThreshold WRITE setNoiseReductionThreshold NOTIFY noiseReductionThresholdChanged)
Q_PROPERTY(bool warnWhenMuted READ warnWhenMutedEnabled WRITE enableWarnWhenMuted NOTIFY warnWhenMutedChanged)
Q_PROPERTY(bool acousticEchoCancellation
READ acousticEchoCancellationEnabled WRITE enableAcousticEchoCancellation NOTIFY acousticEchoCancellationChanged)
@ -124,6 +131,7 @@ public:
bool isMuted() const;
bool noiseReductionEnabled() const;
bool noiseReductionAutomatic() const;
bool warnWhenMutedEnabled() const;
bool acousticEchoCancellationEnabled() const;
float getInputVolume() const;
@ -270,6 +278,20 @@ public:
* @returns {number} The injector gain (dB) in the client.
*/
Q_INVOKABLE float getSystemInjectorGain();
/**jsdoc
* Sets the noise gate threshold before your mic audio is transmitted. (Applies only if <code>Audio.noiseReductionAutomatic</code> is <code>false</code>.)
* @function Audio.setNoiseReductionThreshold
* @param {number} threshold - The level that your input must surpass to be transmitted. <code>0.0</code> (open the gate completely) &ndash; <code>1.0</code>
*/
Q_INVOKABLE void setNoiseReductionThreshold(float threshold);
/**jsdoc
* Gets the noise reduction threshold.
* @function Audio.getNoiseReductionThreshold
* @returns {number} The noise reduction threshold. <code>0.0</code> &ndash; <code>1.0</code>
*/
Q_INVOKABLE float getNoiseReductionThreshold();
/**jsdoc
* Starts making an audio recording of the audio being played in-world (i.e., not local-only audio) to a file in WAV format.
@ -398,6 +420,23 @@ signals:
* @returns {Signal}
*/
void noiseReductionChanged(bool isEnabled);
/**jsdoc
* Triggered when the audio input noise reduction mode is changed.
* @function Audio.noiseReductionAutomaticChanged
* @param {boolean} isEnabled - <code>true</code> if audio input noise reduction automatic mode is enabled, <code>false</code> if in manual mode.
* @returns {Signal}
*/
void noiseReductionAutomaticChanged(bool isEnabled);
/**jsdoc
* Triggered when the audio input noise reduction threshold is changed.
* @function Audio.noiseReductionThresholdChanged
* @param {number} threshold - The threshold for the audio input noise reduction, range <code>0.0</code> (open the gate completely) &ndash; <code>1.0</code>
* (close the gate completely).
* @returns {Signal}
*/
void noiseReductionThresholdChanged(float threshold);
/**jsdoc
* Triggered when "warn when muted" is enabled or disabled.
@ -512,6 +551,7 @@ public slots:
private slots:
void setMuted(bool muted);
void enableNoiseReduction(bool enable);
void enableNoiseReductionAutomatic(bool enable);
void enableWarnWhenMuted(bool enable);
void enableAcousticEchoCancellation(bool enable);
void setInputVolume(float volume);
@ -533,8 +573,10 @@ private:
float _localInjectorGain { 0.0f }; // in dB
float _systemInjectorGain { 0.0f }; // in dB
float _pttOutputGainDesktop { 0.0f }; // in dB
float _noiseReductionThreshold { 0.1f }; // Match default value of AudioClient::_noiseReductionThreshold.
bool _isClipping { false };
bool _enableNoiseReduction { true }; // Match default value of AudioClient::_isNoiseGateEnabled.
bool _noiseReductionAutomatic { true }; // Match default value of AudioClient::_noiseReductionAutomatic.
bool _enableWarnWhenMuted { true };
bool _enableAcousticEchoCancellation { true }; // AudioClient::_isAECEnabled
bool _contextIsHMD { false };

View file

@ -250,9 +250,9 @@ void setupPreferences() {
{
auto getter = []()->bool { return !Menu::getInstance()->isOptionChecked(MenuOption::DisableActivityLogger); };
auto setter = [](bool value) { Menu::getInstance()->setIsOptionChecked(MenuOption::DisableActivityLogger, !value); };
preferences->addPreference(new CheckPreference("Privacy", "Send data - High Fidelity uses information provided by your "
preferences->addPreference(new CheckPreference("Privacy", "Send data - Vircadia uses information provided by your "
"client to improve the product through the logging of errors, tracking of usage patterns, "
"installation and system details. By allowing High Fidelity to collect this information "
"installation and system details. By allowing Vircadia to collect this information "
"you are helping to improve the product. ", getter, setter));
}
@ -364,7 +364,7 @@ void setupPreferences() {
auto preference = new SpinnerSliderPreference(VR_MOVEMENT, "Camera Sensitivity", getter, setter);
preference->setMin(0.01f);
preference->setMax(5.0f);
preference->setStep(0.1);
preference->setStep(0.1f);
preference->setDecimals(2);
preferences->addPreference(preference);
}

View file

@ -22,6 +22,7 @@
#include "AnimationLogging.h"
#include "CubicHermiteSpline.h"
#include "AnimUtil.h"
#include "AnimSkeleton.h"
static const int MAX_TARGET_MARKERS = 30;
static const float JOINT_CHAIN_INTERP_TIME = 0.5f;
@ -66,7 +67,7 @@ AnimInverseKinematics::IKTargetVar::IKTargetVar(const QString& jointNameIn, cons
poleVectorVar(poleVectorVarIn),
weight(weightIn),
numFlexCoefficients(flexCoefficientsIn.size()),
jointIndex(-1)
jointIndex(AnimSkeleton::INVALID_JOINT_INDEX)
{
numFlexCoefficients = std::min(numFlexCoefficients, (size_t)MAX_FLEX_COEFFICIENTS);
for (size_t i = 0; i < numFlexCoefficients; i++) {
@ -172,14 +173,14 @@ bool debounceJointWarnings() {
void AnimInverseKinematics::computeTargets(const AnimVariantMap& animVars, std::vector<IKTarget>& targets, const AnimPoseVec& underPoses) {
_hipsTargetIndex = -1;
_hipsTargetIndex = AnimSkeleton::INVALID_JOINT_INDEX;
targets.reserve(_targetVarVec.size());
for (auto& targetVar : _targetVarVec) {
// update targetVar jointIndex cache
if (targetVar.jointIndex == -1) {
if (targetVar.jointIndex == AnimSkeleton::INVALID_JOINT_INDEX) {
int jointIndex = _skeleton->nameToJointIndex(targetVar.jointName);
if (jointIndex >= 0) {
// this targetVar has a valid joint --> cache the indices
@ -190,7 +191,7 @@ void AnimInverseKinematics::computeTargets(const AnimVariantMap& animVars, std::
}
IKTarget target;
if (targetVar.jointIndex != -1) {
if (targetVar.jointIndex != AnimSkeleton::INVALID_JOINT_INDEX) {
target.setType(animVars.lookup(targetVar.typeVar, (int)IKTarget::Type::RotationAndPosition));
target.setIndex(targetVar.jointIndex);
if (target.getType() != IKTarget::Type::Unknown) {
@ -329,7 +330,7 @@ void AnimInverseKinematics::solve(const AnimContext& context, const std::vector<
// update the absolutePoses
for (int i = 0; i < (int)_relativePoses.size(); ++i) {
auto parentIndex = _skeleton->getParentIndex((int)i);
if (parentIndex != -1) {
if (parentIndex != AnimSkeleton::INVALID_JOINT_INDEX) {
absolutePoses[i] = absolutePoses[parentIndex] * _relativePoses[i];
}
}
@ -351,12 +352,12 @@ void AnimInverseKinematics::solve(const AnimContext& context, const std::vector<
// finally set the relative rotation of each tip to agree with absolute target rotation
for (auto& target: targets) {
int tipIndex = target.getIndex();
int parentIndex = (tipIndex >= 0) ? _skeleton->getParentIndex(tipIndex) : -1;
int parentIndex = (tipIndex >= 0) ? _skeleton->getParentIndex(tipIndex) : AnimSkeleton::INVALID_JOINT_INDEX;
int chainIndex = targetToChainMap[tipIndex];
bool needsInterpolation = _prevJointChainInfoVec[chainIndex].timer > 0.0f;
float alpha = needsInterpolation ? getInterpolationAlpha(_prevJointChainInfoVec[chainIndex].timer) : 0.0f;
// update rotationOnly targets that don't lie on the ik chain of other ik targets.
if (parentIndex != -1 && !_rotationAccumulators[tipIndex].isDirty() &&
if (parentIndex != AnimSkeleton::INVALID_JOINT_INDEX && !_rotationAccumulators[tipIndex].isDirty() &&
(target.getType() == IKTarget::Type::RotationOnly || target.getType() == IKTarget::Type::Unknown)) {
if (target.getType() == IKTarget::Type::RotationOnly) {
const glm::quat& targetRotation = target.getRotation();
@ -434,11 +435,11 @@ void AnimInverseKinematics::solveTargetWithCCD(const AnimContext& context, const
int tipIndex = target.getIndex();
int pivotIndex = _skeleton->getParentIndex(tipIndex);
if (pivotIndex == -1 || pivotIndex == _hipsIndex) {
if (pivotIndex == AnimSkeleton::INVALID_JOINT_INDEX || pivotIndex == _hipsIndex) {
return;
}
int pivotsParentIndex = _skeleton->getParentIndex(pivotIndex);
if (pivotsParentIndex == -1) {
if (pivotsParentIndex == AnimSkeleton::INVALID_JOINT_INDEX) {
// TODO?: handle case where tip's parent is root?
return;
}
@ -485,7 +486,7 @@ void AnimInverseKinematics::solveTargetWithCCD(const AnimContext& context, const
chainDepth++;
// descend toward root, pivoting each joint to get tip closer to target position
while (pivotIndex != _hipsIndex && pivotsParentIndex != -1) {
while (pivotIndex != _hipsIndex && pivotsParentIndex != AnimSkeleton::INVALID_JOINT_INDEX) {
assert(chainDepth < jointChainInfoOut.jointInfoVec.size());
@ -579,12 +580,12 @@ void AnimInverseKinematics::solveTargetWithCCD(const AnimContext& context, const
if (target.getPoleVectorEnabled()) {
int topJointIndex = target.getIndex();
int midJointIndex = _skeleton->getParentIndex(topJointIndex);
if (midJointIndex != -1) {
if (midJointIndex != AnimSkeleton::INVALID_JOINT_INDEX) {
int baseJointIndex = _skeleton->getParentIndex(midJointIndex);
if (baseJointIndex != -1) {
if (baseJointIndex != AnimSkeleton::INVALID_JOINT_INDEX) {
int baseParentJointIndex = _skeleton->getParentIndex(baseJointIndex);
AnimPose topPose, midPose, basePose;
int topChainIndex = -1, baseChainIndex = -1;
int topChainIndex = AnimSkeleton::INVALID_JOINT_INDEX, baseChainIndex = AnimSkeleton::INVALID_JOINT_INDEX;
const size_t MAX_CHAIN_DEPTH = 30;
AnimPose postAbsPoses[MAX_CHAIN_DEPTH];
AnimPose accum = absolutePoses[_hipsIndex];
@ -756,7 +757,7 @@ void AnimInverseKinematics::computeAndCacheSplineJointInfosForIKTarget(const Ani
int index = target.getIndex();
int endIndex = _skeleton->getParentIndex(_hipsIndex);
while (index != endIndex) {
while (index != endIndex && index != AnimSkeleton::INVALID_JOINT_INDEX) {
AnimPose defaultPose = _skeleton->getAbsoluteDefaultPose(index);
float ratio = glm::dot(defaultPose.trans() - basePose.trans(), baseToTipNormal) / baseToTipLength;
@ -1460,7 +1461,7 @@ void AnimInverseKinematics::setSkeletonInternal(AnimSkeleton::ConstPointer skele
// invalidate all targetVars
for (auto& targetVar: _targetVarVec) {
targetVar.jointIndex = -1;
targetVar.jointIndex = AnimSkeleton::INVALID_JOINT_INDEX;
}
for (auto& accumulator: _rotationAccumulators) {
@ -1480,18 +1481,18 @@ void AnimInverseKinematics::setSkeletonInternal(AnimSkeleton::ConstPointer skele
if (_hipsIndex >= 0) {
_hipsParentIndex = _skeleton->getParentIndex(_hipsIndex);
} else {
_hipsParentIndex = -1;
_hipsParentIndex = AnimSkeleton::INVALID_JOINT_INDEX;
}
_leftHandIndex = _skeleton->nameToJointIndex("LeftHand");
_rightHandIndex = _skeleton->nameToJointIndex("RightHand");
} else {
clearConstraints();
_headIndex = -1;
_hipsIndex = -1;
_hipsParentIndex = -1;
_leftHandIndex = -1;
_rightHandIndex = -1;
_headIndex = AnimSkeleton::INVALID_JOINT_INDEX;
_hipsIndex = AnimSkeleton::INVALID_JOINT_INDEX;
_hipsParentIndex = AnimSkeleton::INVALID_JOINT_INDEX;
_leftHandIndex = AnimSkeleton::INVALID_JOINT_INDEX;
_rightHandIndex = AnimSkeleton::INVALID_JOINT_INDEX;
}
}
@ -1531,7 +1532,7 @@ void AnimInverseKinematics::debugDrawRelativePoses(const AnimContext& context) c
// draw line to parent
int parentIndex = _skeleton->getParentIndex(i);
if (parentIndex != -1) {
if (parentIndex != AnimSkeleton::INVALID_JOINT_INDEX) {
glm::vec3 parentPos = transformPoint(geomToWorldMatrix, poses[parentIndex].trans());
DebugDraw::getInstance().drawRay(pos, parentPos, GRAY);
}
@ -1580,7 +1581,7 @@ void AnimInverseKinematics::debugDrawIKChain(const JointChainInfo& jointChainInf
DebugDraw::getInstance().drawRay(pos, pos + AXIS_LENGTH * zAxis, BLUE);
// draw line to parent
if (parentIndex != -1) {
if (parentIndex != AnimSkeleton::INVALID_JOINT_INDEX) {
glm::vec3 parentPos = transformPoint(geomToWorldMatrix, poses[parentIndex].trans());
glm::vec4 color = GRAY;
@ -1629,13 +1630,13 @@ void AnimInverseKinematics::debugDrawConstraints(const AnimContext& context) con
// draw line to parent
int parentIndex = _skeleton->getParentIndex(i);
if (parentIndex != -1) {
if (parentIndex != AnimSkeleton::INVALID_JOINT_INDEX) {
glm::vec3 parentPos = transformPoint(geomToWorldMatrix, poses[parentIndex].trans());
DebugDraw::getInstance().drawRay(pos, parentPos, GRAY);
}
glm::quat parentAbsRot;
if (parentIndex != -1) {
if (parentIndex != AnimSkeleton::INVALID_JOINT_INDEX) {
parentAbsRot = poses[parentIndex].rot();
}
@ -1733,7 +1734,7 @@ void AnimInverseKinematics::preconditionRelativePosesToAvoidLimbLock(const AnimC
const float MIN_AXIS_LENGTH = 1.0e-4f;
for (auto& target : targets) {
if (target.getIndex() != -1 && target.getType() == IKTarget::Type::RotationAndPosition) {
if (target.getIndex() != AnimSkeleton::INVALID_JOINT_INDEX && target.getType() == IKTarget::Type::RotationAndPosition) {
for (int i = 0; i < NUM_LIMBS; i++) {
if (limbs[i].first == target.getIndex()) {
int tipIndex = limbs[i].first;

View file

@ -66,7 +66,7 @@ int AnimSkeleton::nameToJointIndex(const QString& jointName) const {
if (_jointIndicesByName.end() != itr) {
return itr.value();
}
return -1;
return INVALID_JOINT_INDEX;
}
int AnimSkeleton::getNumJoints() const {
@ -80,7 +80,7 @@ int AnimSkeleton::getChainDepth(int jointIndex) const {
do {
chainDepth++;
index = _parentIndices[index];
} while (index != -1);
} while (index != INVALID_JOINT_INDEX);
return chainDepth;
} else {
return 0;
@ -108,7 +108,7 @@ const AnimPose& AnimSkeleton::getPostRotationPose(int jointIndex) const {
std::vector<int> AnimSkeleton::getChildrenOfJoint(int jointIndex) const {
// Children and grandchildren, etc.
std::vector<int> result;
if (jointIndex != -1) {
if (jointIndex != INVALID_JOINT_INDEX) {
for (int i = jointIndex + 1; i < (int)_parentIndices.size(); i++) {
if (_parentIndices[i] == jointIndex || (std::find(result.begin(), result.end(), _parentIndices[i]) != result.end())) {
result.push_back(i);
@ -135,7 +135,7 @@ void AnimSkeleton::convertRelativePosesToAbsolute(AnimPoseVec& poses) const {
int lastIndex = std::min((int)poses.size(), _jointsSize);
for (int i = 0; i < lastIndex; ++i) {
int parentIndex = _parentIndices[i];
if (parentIndex != -1) {
if (parentIndex != INVALID_JOINT_INDEX) {
poses[i] = poses[parentIndex] * poses[i];
}
}
@ -146,7 +146,7 @@ void AnimSkeleton::convertAbsolutePosesToRelative(AnimPoseVec& poses) const {
int lastIndex = std::min((int)poses.size(), _jointsSize);
for (int i = lastIndex - 1; i >= 0; --i) {
int parentIndex = _parentIndices[i];
if (parentIndex != -1) {
if (parentIndex != INVALID_JOINT_INDEX) {
poses[i] = poses[parentIndex].inverse() * poses[i];
}
}
@ -157,7 +157,7 @@ void AnimSkeleton::convertRelativeRotationsToAbsolute(std::vector<glm::quat>& ro
int lastIndex = std::min((int)rotations.size(), _jointsSize);
for (int i = 0; i < lastIndex; ++i) {
int parentIndex = _parentIndices[i];
if (parentIndex != -1) {
if (parentIndex != INVALID_JOINT_INDEX) {
rotations[i] = rotations[parentIndex] * rotations[i];
}
}
@ -168,7 +168,7 @@ void AnimSkeleton::convertAbsoluteRotationsToRelative(std::vector<glm::quat>& ro
int lastIndex = std::min((int)rotations.size(), _jointsSize);
for (int i = lastIndex - 1; i >= 0; --i) {
int parentIndex = _parentIndices[i];
if (parentIndex != -1) {
if (parentIndex != INVALID_JOINT_INDEX) {
rotations[i] = glm::inverse(rotations[parentIndex]) * rotations[i];
}
}
@ -280,7 +280,7 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints,
// so we can restore them after a future mirror operation
_nonMirroredIndices.push_back(i);
}
int mirrorJointIndex = -1;
int mirrorJointIndex = INVALID_JOINT_INDEX;
if (_joints[i].name.startsWith("Left")) {
QString mirrorJointName = QString(_joints[i].name).replace(0, 4, "Right");
mirrorJointIndex = nameToJointIndex(mirrorJointName);
@ -350,7 +350,7 @@ std::vector<int> AnimSkeleton::lookUpJointIndices(const std::vector<QString>& jo
result.reserve(jointNames.size());
for (auto& name : jointNames) {
int index = nameToJointIndex(name);
if (index == -1) {
if (index == INVALID_JOINT_INDEX) {
qWarning(animation) << "AnimSkeleton::lookUpJointIndices(): could not find bone with name " << name;
}
result.push_back(index);

View file

@ -30,6 +30,8 @@ public:
const QString& getJointName(int jointIndex) const;
int getNumJoints() const;
int getChainDepth(int jointIndex) const;
static const int INVALID_JOINT_INDEX { -1 };
// the default poses are the orientations of the joints on frame 0.
const AnimPose& getRelativeDefaultPose(int jointIndex) const;

View file

@ -1266,7 +1266,7 @@ void AudioClient::processWebrtcNearEnd(int16_t* samples, int numFrames, int numC
void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
// If there is server echo, reverb will be applied to the recieved audio stream so no need to have it here.
bool hasReverb = _reverb || _receivedAudioStream.hasReverb();
if ((_muted && !_shouldEchoLocally) || !_audioOutput || (!_shouldEchoLocally && !hasReverb)) {
if ((_muted && !_shouldEchoLocally) || !_audioOutput || (!_shouldEchoLocally && !hasReverb) || !_audioGateOpen) {
return;
}
@ -1342,6 +1342,13 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
}
}
float AudioClient::loudnessToLevel(float loudness) {
float level = loudness * (1 / 32768.0f); // level in [0, 1]
level = 6.02059991f * fastLog2f(level); // convert to dBFS
level = (level + 48.0f) * (1 / 42.0f); // map [-48, -6] dBFS to [0, 1]
return glm::clamp(level, 0.0f, 1.0f);
}
void AudioClient::handleAudioInput(QByteArray& audioBuffer) {
if (!_audioPaused) {
@ -1352,9 +1359,14 @@ void AudioClient::handleAudioInput(QByteArray& audioBuffer) {
int numSamples = audioBuffer.size() / AudioConstants::SAMPLE_SIZE;
int numFrames = numSamples / (_isStereoInput ? AudioConstants::STEREO : AudioConstants::MONO);
if (_isNoiseGateEnabled) {
if (_isNoiseGateEnabled && _isNoiseReductionAutomatic) {
// The audio gate includes DC removal
audioGateOpen = _audioGate->render(samples, samples, numFrames);
} else if (_isNoiseGateEnabled && !_isNoiseReductionAutomatic &&
loudnessToLevel(_lastSmoothedRawInputLoudness) >= _noiseReductionThreshold) {
audioGateOpen = _audioGate->removeDC(samples, samples, numFrames);
} else if (_isNoiseGateEnabled && !_isNoiseReductionAutomatic) {
audioGateOpen = false;
} else {
audioGateOpen = _audioGate->removeDC(samples, samples, numFrames);
}
@ -1750,6 +1762,24 @@ void AudioClient::setNoiseReduction(bool enable, bool emitSignal) {
}
}
void AudioClient::setNoiseReductionAutomatic(bool enable, bool emitSignal) {
if (_isNoiseReductionAutomatic != enable) {
_isNoiseReductionAutomatic = enable;
if (emitSignal) {
emit noiseReductionAutomaticChanged(_isNoiseReductionAutomatic);
}
}
}
void AudioClient::setNoiseReductionThreshold(float threshold, bool emitSignal) {
if (_noiseReductionThreshold != threshold) {
_noiseReductionThreshold = threshold;
if (emitSignal) {
emit noiseReductionThresholdChanged(_noiseReductionThreshold);
}
}
}
void AudioClient::setWarnWhenMuted(bool enable, bool emitSignal) {
if (_warnWhenMuted != enable) {
_warnWhenMuted = enable;

View file

@ -217,6 +217,12 @@ public slots:
void setNoiseReduction(bool isNoiseGateEnabled, bool emitSignal = true);
bool isNoiseReductionEnabled() const { return _isNoiseGateEnabled; }
void setNoiseReductionAutomatic(bool isNoiseGateAutomatic, bool emitSignal = true);
bool isNoiseReductionAutomatic() const { return _isNoiseReductionAutomatic; }
void setNoiseReductionThreshold(float noiseReductionThreshold, bool emitSignal = true);
float noiseReductionThreshold() const { return _noiseReductionThreshold; }
void setWarnWhenMuted(bool isNoiseGateEnabled, bool emitSignal = true);
bool isWarnWhenMutedEnabled() const { return _warnWhenMuted; }
@ -265,6 +271,8 @@ signals:
void inputVolumeChanged(float volume);
void muteToggled(bool muted);
void noiseReductionChanged(bool noiseReductionEnabled);
void noiseReductionAutomaticChanged(bool noiseReductionAutomatic);
void noiseReductionThresholdChanged(bool noiseReductionThreshold);
void warnWhenMutedChanged(bool warnWhenMutedEnabled);
void acousticEchoCancellationChanged(bool acousticEchoCancellationEnabled);
void mutedByMixer();
@ -310,6 +318,8 @@ private:
friend class CheckDevicesThread;
friend class LocalInjectorsThread;
float loudnessToLevel(float loudness);
// background tasks
void checkDevices();
void checkPeakValues();
@ -397,6 +407,8 @@ private:
bool _shouldEchoLocally{ false };
bool _shouldEchoToServer{ false };
bool _isNoiseGateEnabled{ true };
bool _isNoiseReductionAutomatic{ true };
float _noiseReductionThreshold{ 0.1f };
bool _warnWhenMuted;
bool _isAECEnabled{ true };

View file

@ -91,8 +91,8 @@ static const float azimuthTable[NAZIMUTH][3] = {
// A first-order shelving filter is used to minimize the disturbance in ITD.
//
// Loosely based on data from S. Spagnol, "Distance rendering and perception of nearby virtual sound sources
// with a near-field filter model, Applied Acoustics (2017)
//
// with a near-field filter model," Applied Acoustics (2017)
//
static const int NNEARFIELD = 9;
static const float nearFieldTable[NNEARFIELD][3] = { // { b0, b1, a1 }
{ 0.008410604f, -0.000262748f, -0.991852144f }, // gain = 1/256
@ -388,7 +388,12 @@ void crossfade_4x2_AVX2(float* src, float* dst, const float* win, int numFrames)
void interpolate_AVX2(const float* src0, const float* src1, float* dst, float frac, float gain);
static void FIR_1x4(float* src, float* dst0, float* dst1, float* dst2, float* dst3, float coef[4][HRTF_TAPS], int numFrames) {
#ifndef STACK_PROTECTOR
// Enabling -fstack-protector on gcc causes an undefined reference to FIR_1x4_AVX512 here
static auto f = cpuSupportsAVX512() ? FIR_1x4_AVX512 : (cpuSupportsAVX2() ? FIR_1x4_AVX2 : FIR_1x4_SSE);
#else
static auto f = cpuSupportsAVX2() ? FIR_1x4_AVX2 : FIR_1x4_SSE;
#endif
(*f)(src, dst0, dst1, dst2, dst3, coef, numFrames); // dispatch
}

View file

@ -1444,9 +1444,7 @@ int Avatar::getJointIndex(const QString& name) const {
}
withValidJointIndicesCache([&]() {
if (_modelJointIndicesCache.contains(name)) {
result = _modelJointIndicesCache.value(name) - 1;
}
result = _modelJointIndicesCache.value(name, result + 1) - 1;
});
return result;
}

View file

@ -1938,6 +1938,10 @@ void AvatarData::clearJointsData() {
}
int AvatarData::getFauxJointIndex(const QString& name) const {
static constexpr QChar fauxJointFirstChar('_');// The first character of all the faux joint names.
if (!name.startsWith(fauxJointFirstChar)) {
return -1;
};
if (name == "_SENSOR_TO_WORLD_MATRIX") {
return SENSOR_TO_WORLD_MATRIX_INDEX;
}
@ -2246,7 +2250,7 @@ void AvatarData::processTraitInstance(AvatarTraits::TraitType traitType,
void AvatarData::processDeletedTraitInstance(AvatarTraits::TraitType traitType, AvatarTraits::TraitInstanceID instanceID) {
if (traitType == AvatarTraits::AvatarEntity) {
clearAvatarEntity(instanceID);
clearAvatarEntityInternal(instanceID);
} else if (traitType == AvatarTraits::Grab) {
clearAvatarGrabData(instanceID);
}
@ -3034,6 +3038,10 @@ void AvatarData::updateAvatarEntity(const QUuid& entityID, const QByteArray& ent
void AvatarData::clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFromTree) {
// NOTE: requiresRemovalFromTree is unused
clearAvatarEntityInternal(entityID);
}
void AvatarData::clearAvatarEntityInternal(const QUuid& entityID) {
bool removedEntity = false;
_avatarEntitiesLock.withWriteLock([this, &removedEntity, &entityID] {
removedEntity = _packedAvatarEntityData.remove(entityID);
@ -3046,6 +3054,24 @@ void AvatarData::clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFr
}
}
void AvatarData::clearAvatarEntities() {
QList<QUuid> avatarEntityIDs;
_avatarEntitiesLock.withReadLock([&] {
avatarEntityIDs = _packedAvatarEntityData.keys();
});
for (const auto& entityID : avatarEntityIDs) {
clearAvatarEntityInternal(entityID);
}
}
QList<QUuid> AvatarData::getAvatarEntityIDs() const {
QList<QUuid> avatarEntityIDs;
_avatarEntitiesLock.withReadLock([&] {
avatarEntityIDs = _packedAvatarEntityData.keys();
});
return avatarEntityIDs;
}
AvatarEntityMap AvatarData::getAvatarEntityData() const {
// overridden where needed
// NOTE: the return value is expected to be a map of unfortunately-formatted-binary-blobs

View file

@ -1186,6 +1186,13 @@ public:
* @deprecated This function is deprecated and will be removed.
*/
Q_INVOKABLE virtual void clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFromTree = true);
// FIXME: Rename to clearAvatarEntity() once the API call is removed.
virtual void clearAvatarEntityInternal(const QUuid& entityID);
void clearAvatarEntities();
QList<QUuid> getAvatarEntityIDs() const;
/**jsdoc
* Enables blend shapes set using {@link Avatar.setBlendshape} or {@link MyAvatar.setBlendshape} to be transmitted to other

View file

@ -168,20 +168,20 @@ void TextureBaker::processTexture() {
gpu::BackendTarget::GLES32
}};
for (auto target : BACKEND_TARGETS) {
auto processedTexture = image::processImage(buffer, _textureURL.toString().toStdString(), image::ColorChannel::NONE,
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, true,
target, _abortProcessing);
if (!processedTexture) {
auto processedTextureAndSize = image::processImage(buffer, _textureURL.toString().toStdString(), image::ColorChannel::NONE,
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, true,
target, _abortProcessing);
if (!processedTextureAndSize.first) {
handleError("Could not process texture " + _textureURL.toString());
return;
}
processedTexture->setSourceHash(hash);
processedTextureAndSize.first->setSourceHash(hash);
if (shouldStop()) {
return;
}
auto memKTX = gpu::Texture::serialize(*processedTexture);
auto memKTX = gpu::Texture::serialize(*processedTextureAndSize.first, processedTextureAndSize.second);
if (!memKTX) {
handleError("Could not serialize " + _textureURL.toString() + " to KTX");
return;
@ -211,19 +211,19 @@ void TextureBaker::processTexture() {
// Uncompressed KTX
if (_textureType == image::TextureUsage::Type::SKY_TEXTURE || _textureType == image::TextureUsage::Type::AMBIENT_TEXTURE) {
buffer->reset();
auto processedTexture = image::processImage(std::move(buffer), _textureURL.toString().toStdString(), image::ColorChannel::NONE,
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, false, gpu::BackendTarget::GL45, _abortProcessing);
if (!processedTexture) {
auto processedTextureAndSize = image::processImage(std::move(buffer), _textureURL.toString().toStdString(), image::ColorChannel::NONE,
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, false, gpu::BackendTarget::GL45, _abortProcessing);
if (!processedTextureAndSize.first) {
handleError("Could not process texture " + _textureURL.toString());
return;
}
processedTexture->setSourceHash(hash);
processedTextureAndSize.first->setSourceHash(hash);
if (shouldStop()) {
return;
}
auto memKTX = gpu::Texture::serialize(*processedTexture);
auto memKTX = gpu::Texture::serialize(*processedTextureAndSize.first, processedTextureAndSize.second);
if (!memKTX) {
handleError("Could not serialize " + _textureURL.toString() + " to KTX");
return;

View file

@ -118,7 +118,7 @@ public:
const QString& getName() const { return _name; }
// By default, Input Devices do not support haptics
virtual bool triggerHapticPulse(float strength, float duration, controller::Hand hand) { return false; }
virtual bool triggerHapticPulse(float strength, float duration, uint16_t index) { return false; }
// Update call MUST be called once per simulation loop
// It takes care of updating the action states and deltas

View file

@ -134,13 +134,13 @@ namespace controller {
return DependencyManager::get<UserInputMapper>()->getActionNames();
}
bool ScriptingInterface::triggerHapticPulse(float strength, float duration, controller::Hand hand) const {
return DependencyManager::get<UserInputMapper>()->triggerHapticPulse(strength, duration, hand);
bool ScriptingInterface::triggerHapticPulse(float strength, float duration, uint16_t index) const {
return DependencyManager::get<UserInputMapper>()->triggerHapticPulse(strength, duration, index);
}
bool ScriptingInterface::triggerShortHapticPulse(float strength, controller::Hand hand) const {
bool ScriptingInterface::triggerShortHapticPulse(float strength, uint16_t index) const {
const float SHORT_HAPTIC_DURATION_MS = 250.0f;
return DependencyManager::get<UserInputMapper>()->triggerHapticPulse(strength, SHORT_HAPTIC_DURATION_MS, hand);
return DependencyManager::get<UserInputMapper>()->triggerHapticPulse(strength, SHORT_HAPTIC_DURATION_MS, index);
}
void ScriptingInterface::startInputRecording() {
@ -189,13 +189,13 @@ namespace controller {
emit inputDeviceRunningChanged(deviceName, isRunning);
}
bool ScriptingInterface::triggerHapticPulseOnDevice(unsigned int device, float strength, float duration, controller::Hand hand) const {
return DependencyManager::get<UserInputMapper>()->triggerHapticPulseOnDevice(device, strength, duration, hand);
bool ScriptingInterface::triggerHapticPulseOnDevice(unsigned int device, float strength, float duration, uint16_t index) const {
return DependencyManager::get<UserInputMapper>()->triggerHapticPulseOnDevice(device, strength, duration, index);
}
bool ScriptingInterface::triggerShortHapticPulseOnDevice(unsigned int device, float strength, controller::Hand hand) const {
bool ScriptingInterface::triggerShortHapticPulseOnDevice(unsigned int device, float strength, uint16_t index) const {
const float SHORT_HAPTIC_DURATION_MS = 250.0f;
return DependencyManager::get<UserInputMapper>()->triggerHapticPulseOnDevice(device, strength, SHORT_HAPTIC_DURATION_MS, hand);
return DependencyManager::get<UserInputMapper>()->triggerHapticPulseOnDevice(device, strength, SHORT_HAPTIC_DURATION_MS, index);
}
void ScriptingInterface::updateMaps() {

View file

@ -212,22 +212,28 @@ namespace controller {
* @function Controller.triggerHapticPulse
* @param {number} strength - The strength of the haptic pulse, range <code>0.0</code> &ndash; <code>1.0</code>.
* @param {number} duration - The duration of the haptic pulse, in milliseconds.
* @param {Controller.Hand} [hand=2] - The hand or hands to trigger the haptic pulse on.
* @param {number} [index=2] - The index on devices on which to trigger the haptic pulse. The meaning of each index
* will vary by device. For example, for hand controllers, <code>index = 0</code> is the left hand,
* <code>index = 1</code> is the right hand, and <code>index = 2</code> is both hands. For other devices,
* such as haptic vests, index will have a different meaning, defined by the input device.
* @example <caption>Trigger a haptic pulse on the right hand.</caption>
* var HAPTIC_STRENGTH = 0.5;
* var HAPTIC_DURATION = 10;
* var RIGHT_HAND = 1;
* Controller.triggerHapticPulse(HAPTIC_STRENGTH, HAPTIC_DURATION, RIGHT_HAND);
*/
Q_INVOKABLE bool triggerHapticPulse(float strength, float duration, controller::Hand hand = BOTH) const;
Q_INVOKABLE bool triggerHapticPulse(float strength, float duration, uint16_t index = 2) const;
/**jsdoc
* Triggers a 250ms haptic pulse on connected and enabled devices that have the capability.
* @function Controller.triggerShortHapticPulse
* @param {number} strength - The strength of the haptic pulse, range <code>0.0</code> &ndash; <code>1.0</code>.
* @param {Controller.Hand} [hand=2] - The hand or hands to trigger the haptic pulse on.
* @param {number} [index=2] - The index on devices on which to trigger the haptic pulse. The meaning of each index
* will vary by device. For example, for hand controllers, <code>index = 0</code> is the left hand,
* <code>index = 1</code> is the right hand, and <code>index = 2</code> is both hands. For other devices,
* such as haptic vests, index will have a different meaning, defined by the input device.
*/
Q_INVOKABLE bool triggerShortHapticPulse(float strength, controller::Hand hand = BOTH) const;
Q_INVOKABLE bool triggerShortHapticPulse(float strength, uint16_t index = 2) const;
/**jsdoc
* Triggers a haptic pulse on a particular device if connected and enabled and it has the capability.
@ -235,7 +241,10 @@ namespace controller {
* @param {number} deviceID - The ID of the device to trigger the haptic pulse on.
* @param {number} strength - The strength of the haptic pulse, range <code>0.0</code> &ndash; <code>1.0</code>.
* @param {number} duration - The duration of the haptic pulse, in milliseconds.
* @param {Controller.Hand} [hand=2] - The hand or hands to trigger the haptic pulse on.
* @param {number} [index=2] - The index on this device on which to trigger the haptic pulse. The meaning of each index
* will vary by device. For example, for hand controllers, <code>index = 0</code> is the left hand,
* <code>index = 1</code> is the right hand, and <code>index = 2</code> is both hands. For other devices,
* such as haptic vests, index will have a different meaning, defined by the input device.
* @example <caption>Trigger a haptic pulse on an Oculus Touch controller.</caption>
* var HAPTIC_STRENGTH = 0.5;
* var deviceID = Controller.findDevice("OculusTouch");
@ -243,19 +252,20 @@ namespace controller {
* var RIGHT_HAND = 1;
* Controller.triggerHapticPulseOnDevice(deviceID, HAPTIC_STRENGTH, HAPTIC_DURATION, RIGHT_HAND);
*/
Q_INVOKABLE bool triggerHapticPulseOnDevice(unsigned int device, float strength, float duration,
controller::Hand hand = BOTH) const;
Q_INVOKABLE bool triggerHapticPulseOnDevice(unsigned int device, float strength, float duration,
uint16_t index = 2) const;
/**jsdoc
* Triggers a 250ms haptic pulse on a particular device if connected and enabled and it has the capability.
* @function Controller.triggerShortHapticPulseOnDevice
* @param {number} deviceID - The ID of the device to trigger the haptic pulse on.
* @param {number} strength - The strength of the haptic pulse, range <code>0.0</code> &ndash; <code>1.0</code>.
* @param {Controller.Hand} [hand=2] - The hand or hands to trigger the haptic pulse on.
* @param {number} [index=2] - The index on this device on which to trigger the haptic pulse. The meaning of each index
* will vary by device. For example, for hand controllers, <code>index = 0</code> is the left hand,
* <code>index = 1</code> is the right hand, and <code>index = 2</code> is both hands. For other devices,
* such as haptic vests, index will have a different meaning, defined by the input device.
*/
Q_INVOKABLE bool triggerShortHapticPulseOnDevice(unsigned int device, float strength, controller::Hand hand = BOTH)
const;
Q_INVOKABLE bool triggerShortHapticPulseOnDevice(unsigned int device, float strength, uint16_t index = 2) const;
/**jsdoc
* Creates a new controller mapping. Routes can then be added to the mapping using {@link MappingObject} methods and

View file

@ -365,19 +365,19 @@ Pose UserInputMapper::getPoseState(Action action) const {
}
bool UserInputMapper::triggerHapticPulse(float strength, float duration, controller::Hand hand) {
bool UserInputMapper::triggerHapticPulse(float strength, float duration, uint16_t index) {
Locker locker(_lock);
bool toReturn = false;
for (const auto& device : _registeredDevices) {
toReturn = device.second->triggerHapticPulse(strength, duration, hand) || toReturn;
toReturn = device.second->triggerHapticPulse(strength, duration, index) || toReturn;
}
return toReturn;
}
bool UserInputMapper::triggerHapticPulseOnDevice(uint16 deviceID, float strength, float duration, controller::Hand hand) {
bool UserInputMapper::triggerHapticPulseOnDevice(uint16 deviceID, float strength, float duration, uint16_t index) {
Locker locker(_lock);
if (_registeredDevices.find(deviceID) != _registeredDevices.end()) {
return _registeredDevices[deviceID]->triggerHapticPulse(strength, duration, hand);
return _registeredDevices[deviceID]->triggerHapticPulse(strength, duration, index);
}
return false;
}

View file

@ -91,8 +91,8 @@ namespace controller {
void setActionState(Action action, float value, bool valid = true);
void deltaActionState(Action action, float delta, bool valid = true);
void setActionState(Action action, const Pose& value) { _poseStates[toInt(action)] = value; }
bool triggerHapticPulse(float strength, float duration, controller::Hand hand);
bool triggerHapticPulseOnDevice(uint16 deviceID, float strength, float duration, controller::Hand hand);
bool triggerHapticPulse(float strength, float duration, uint16_t index);
bool triggerHapticPulseOnDevice(uint16 deviceID, float strength, float duration, uint16_t index);
static Input makeStandardInput(controller::StandardButtonChannel button);
static Input makeStandardInput(controller::StandardAxisChannel axis);

View file

@ -78,6 +78,9 @@ public:
/// Returns a pointer to the underlying socket, to which WebSocket message bodies should be written.
QTcpSocket* socket() const { return _socket; }
/// Returns the IP address on the other side of the connection
const QHostAddress &peerAddress() const { return _address; }
/// Returns the request operation.
QNetworkAccessManager::Operation requestOperation() const { return _requestOperation; }

View file

@ -29,6 +29,8 @@
#include "RenderableZoneEntityItem.h"
#include "RenderableMaterialEntityItem.h"
#include "RenderPipelines.h"
using namespace render;
using namespace render::entities;
@ -149,10 +151,11 @@ Item::Bound EntityRenderer::getBound(RenderArgs* args) {
}
ShapeKey EntityRenderer::getShapeKey() {
ShapeKey::Builder builder = ShapeKey::Builder().withOwnPipeline();
if (_primitiveMode == PrimitiveMode::LINES) {
return ShapeKey::Builder().withOwnPipeline().withWireframe();
builder.withWireframe();
}
return ShapeKey::Builder().withOwnPipeline();
return builder.build();
}
render::hifi::Tag EntityRenderer::getTagMask() const {
@ -365,6 +368,7 @@ bool EntityRenderer::needsRenderUpdate() const {
if (_prevIsTransparent != isTransparent()) {
return true;
}
return needsRenderUpdateFromEntity(_entity);
}
@ -491,6 +495,176 @@ void EntityRenderer::removeMaterial(graphics::MaterialPointer material, const st
emit requestRenderUpdate();
}
EntityRenderer::Pipeline EntityRenderer::getPipelineType(const graphics::MultiMaterial& materials) {
if (materials.top().material && materials.top().material->isProcedural() && materials.top().material->isReady()) {
return Pipeline::PROCEDURAL;
}
graphics::MaterialKey drawMaterialKey = materials.getMaterialKey();
if (drawMaterialKey.isEmissive() || drawMaterialKey.isMetallic() || drawMaterialKey.isScattering()) {
return Pipeline::MATERIAL;
}
// If the material is using any map, we need to use a material ShapeKey
for (int i = 0; i < graphics::Material::MapChannel::NUM_MAP_CHANNELS; i++) {
if (drawMaterialKey.isMapChannel(graphics::Material::MapChannel(i))) {
return Pipeline::MATERIAL;
}
}
return Pipeline::SIMPLE;
}
bool EntityRenderer::needsRenderUpdateFromMaterials() const {
MaterialMap::const_iterator materials;
{
std::lock_guard<std::mutex> lock(_materialsLock);
materials = _materials.find("0");
if (materials == _materials.cend()) {
return false;
}
}
if (materials->second.shouldUpdate()) {
return true;
}
if (materials->second.top().material && materials->second.top().material->isProcedural() && materials->second.top().material->isReady()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(materials->second.top().material);
if (procedural->isFading()) {
return true;
}
}
return false;
}
void EntityRenderer::updateMaterials(bool baseMaterialChanged) {
MaterialMap::iterator materials;
{
std::lock_guard<std::mutex> lock(_materialsLock);
materials = _materials.find("0");
if (materials == _materials.end()) {
return;
}
}
if (baseMaterialChanged) {
materials->second.setNeedsUpdate(true);
}
bool requestUpdate = false;
if (materials->second.top().material && materials->second.top().material->isProcedural() && materials->second.top().material->isReady()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(materials->second.top().material);
if (procedural->isFading()) {
procedural->setIsFading(Interpolate::calculateFadeRatio(procedural->getFadeStartTime()) < 1.0f);
requestUpdate = true;
}
}
if (materials->second.shouldUpdate()) {
RenderPipelines::updateMultiMaterial(materials->second);
requestUpdate = true;
}
if (requestUpdate) {
emit requestRenderUpdate();
}
}
bool EntityRenderer::materialsTransparent() const {
MaterialMap::const_iterator materials;
{
std::lock_guard<std::mutex> lock(_materialsLock);
materials = _materials.find("0");
if (materials == _materials.cend()) {
return false;
}
}
if (materials->second.top().material) {
if (materials->second.top().material->isProcedural() && materials->second.top().material->isReady()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(materials->second.top().material);
if (procedural->isFading()) {
return true;
}
}
if (materials->second.getMaterialKey().isTranslucent()) {
return true;
}
}
return false;
}
Item::Bound EntityRenderer::getMaterialBound(RenderArgs* args) {
MaterialMap::iterator materials;
{
std::lock_guard<std::mutex> lock(_materialsLock);
materials = _materials.find("0");
if (materials == _materials.end()) {
return EntityRenderer::getBound(args);
}
}
if (materials->second.top().material && materials->second.top().material->isProcedural() && materials->second.top().material->isReady()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(materials->second.top().material);
if (procedural->hasVertexShader() && procedural->hasBoundOperator()) {
return procedural->getBound(args);
}
}
return EntityRenderer::getBound(args);
}
void EntityRenderer::updateShapeKeyBuilderFromMaterials(ShapeKey::Builder& builder) {
MaterialMap::iterator materials;
{
std::lock_guard<std::mutex> lock(_materialsLock);
materials = _materials.find("0");
if (materials != _materials.end()) {
if (materials->second.shouldUpdate()) {
RenderPipelines::updateMultiMaterial(materials->second);
}
} else {
return;
}
}
if (isTransparent()) {
builder.withTranslucent();
}
if (_primitiveMode == PrimitiveMode::LINES) {
builder.withWireframe();
}
builder.withCullFaceMode(materials->second.getCullFaceMode());
graphics::MaterialKey drawMaterialKey = materials->second.getMaterialKey();
if (drawMaterialKey.isUnlit()) {
builder.withUnlit();
}
auto pipelineType = getPipelineType(materials->second);
if (pipelineType == Pipeline::MATERIAL) {
builder.withMaterial();
if (drawMaterialKey.isNormalMap()) {
builder.withTangents();
}
if (drawMaterialKey.isLightMap()) {
builder.withLightMap();
}
} else if (pipelineType == Pipeline::PROCEDURAL) {
builder.withOwnPipeline();
}
}
glm::vec4 EntityRenderer::calculatePulseColor(const glm::vec4& color, const PulsePropertyGroup& pulseProperties, quint64 start) {
if (pulseProperties.getPeriod() == 0.0f || (pulseProperties.getColorMode() == PulseMode::NONE && pulseProperties.getAlphaMode() == PulseMode::NONE)) {
return color;

View file

@ -55,8 +55,14 @@ public:
const uint64_t& getUpdateTime() const { return _updateTime; }
enum class Pipeline {
SIMPLE,
MATERIAL,
PROCEDURAL
};
virtual void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName);
virtual void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName);
static Pipeline getPipelineType(const graphics::MultiMaterial& materials);
virtual scriptable::ScriptableModelBase getScriptableModel() override { return scriptable::ScriptableModelBase(); }
@ -117,6 +123,14 @@ protected:
Transform getTransformToCenterWithMaybeOnlyLocalRotation(const EntityItemPointer& entity, bool& success) const;
// Shared methods for entities that support materials
using MaterialMap = std::unordered_map<std::string, graphics::MultiMaterial>;
bool needsRenderUpdateFromMaterials() const;
void updateMaterials(bool baseMaterialChanged = false);
bool materialsTransparent() const;
Item::Bound getMaterialBound(RenderArgs* args);
void updateShapeKeyBuilderFromMaterials(ShapeKey::Builder& builder);
Item::Bound _bound;
SharedSoundPointer _collisionSound;
QUuid _changeHandlerId;
@ -132,13 +146,13 @@ protected:
RenderLayer _renderLayer { RenderLayer::WORLD };
PrimitiveMode _primitiveMode { PrimitiveMode::SOLID };
QVector<QUuid> _renderWithZones;
BillboardMode _billboardMode;
BillboardMode _billboardMode { BillboardMode::NONE };
bool _cauterized { false };
bool _moving { false };
Transform _renderTransform;
std::unordered_map<std::string, graphics::MultiMaterial> _materials;
std::mutex _materialsLock;
MaterialMap _materials;
mutable std::mutex _materialsLock;
quint64 _created;

View file

@ -11,10 +11,15 @@
#include <DependencyManager.h>
#include <GeometryCache.h>
#include "RenderPipelines.h"
using namespace render;
using namespace render::entities;
GizmoEntityRenderer::GizmoEntityRenderer(const EntityItemPointer& entity) : Parent(entity) {}
GizmoEntityRenderer::GizmoEntityRenderer(const EntityItemPointer& entity) : Parent(entity) {
_material->setCullFaceMode(graphics::MaterialKey::CullFaceMode::CULL_NONE);
addMaterial(graphics::MaterialLayer(_material, 0), "0");
}
GizmoEntityRenderer::~GizmoEntityRenderer() {
auto geometryCache = DependencyManager::get<GeometryCache>();
@ -31,12 +36,8 @@ GizmoEntityRenderer::~GizmoEntityRenderer() {
}
}
bool GizmoEntityRenderer::isTransparent() const {
bool ringTransparent = _gizmoType == GizmoType::RING && (_ringProperties.getInnerStartAlpha() < 1.0f ||
_ringProperties.getInnerEndAlpha() < 1.0f || _ringProperties.getOuterStartAlpha() < 1.0f ||
_ringProperties.getOuterEndAlpha() < 1.0f);
return Parent::isTransparent() || ringTransparent;
bool GizmoEntityRenderer::needsRenderUpdate() const {
return needsRenderUpdateFromMaterials() || Parent::needsRenderUpdate();
}
void GizmoEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
@ -193,10 +194,20 @@ void GizmoEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
}
}
}
updateMaterials();
}
bool GizmoEntityRenderer::isTransparent() const {
bool ringTransparent = _gizmoType == GizmoType::RING && (_ringProperties.getInnerStartAlpha() < 1.0f ||
_ringProperties.getInnerEndAlpha() < 1.0f || _ringProperties.getOuterStartAlpha() < 1.0f ||
_ringProperties.getOuterEndAlpha() < 1.0f);
return ringTransparent || Parent::isTransparent() || materialsTransparent();
}
Item::Bound GizmoEntityRenderer::getBound(RenderArgs* args) {
auto bound = Parent::getBound(args);
auto bound = Parent::getMaterialBound(args);
if (_ringProperties.getHasTickMarks()) {
glm::vec3 scale = bound.getScale();
for (int i = 0; i < 3; i += 2) {
@ -220,13 +231,8 @@ Item::Bound GizmoEntityRenderer::getBound(RenderArgs* args) {
}
ShapeKey GizmoEntityRenderer::getShapeKey() {
auto builder = render::ShapeKey::Builder().withoutCullFace();
if (isTransparent()) {
builder.withTranslucent();
}
if (_primitiveMode == PrimitiveMode::LINES) {
builder.withUnlit().withDepthBias();
}
auto builder = render::ShapeKey::Builder().withDepthBias();
updateShapeKeyBuilderFromMaterials(builder);
return builder.build();
}
@ -249,15 +255,29 @@ void GizmoEntityRenderer::doRender(RenderArgs* args) {
transparent = isTransparent();
});
bool wireframe = render::ShapeKey(args->_globalShapeKey).isWireframe() || _primitiveMode == PrimitiveMode::LINES;
bool forward = _renderLayer != RenderLayer::WORLD || args->_renderMethod == Args::RenderMethod::FORWARD;
graphics::MultiMaterial materials;
{
std::lock_guard<std::mutex> lock(_materialsLock);
materials = _materials["0"];
}
geometryCache->bindSimpleProgram(batch, false, transparent, wireframe, true, true, forward, graphics::MaterialKey::CULL_NONE);
bool wireframe = render::ShapeKey(args->_globalShapeKey).isWireframe() || _primitiveMode == PrimitiveMode::LINES;
transform.setRotation(BillboardModeHelpers::getBillboardRotation(transform.getTranslation(), transform.getRotation(), _billboardMode,
args->_renderMode == RenderArgs::RenderMode::SHADOW_RENDER_MODE ? BillboardModeHelpers::getPrimaryViewFrustumPosition() : args->getViewFrustum().getPosition(), true));
batch.setModelTransform(transform);
Pipeline pipelineType = getPipelineType(materials);
if (pipelineType == Pipeline::PROCEDURAL) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(materials.top().material);
transparent |= procedural->isFading();
procedural->prepare(batch, transform.getTranslation(), transform.getScale(), transform.getRotation(), _created, ProceduralProgramKey(transparent));
} else if (pipelineType == Pipeline::MATERIAL) {
if (RenderPipelines::bindMaterials(materials, batch, args->_renderMode, args->_enableTexturing)) {
args->_details._materialSwitches++;
}
}
// Background circle
geometryCache->renderVertices(batch, wireframe ? gpu::LINE_STRIP : _solidPrimitive, _ringGeometryID);

View file

@ -13,6 +13,8 @@
#include <GizmoEntityItem.h>
#include <procedural/Procedural.h>
namespace render { namespace entities {
class GizmoEntityRenderer : public TypedEntityRenderer<GizmoEntityItem> {
@ -29,10 +31,12 @@ protected:
bool isTransparent() const override;
private:
virtual bool needsRenderUpdate() const override;
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
virtual void doRender(RenderArgs* args) override;
std::shared_ptr<graphics::ProceduralMaterial> _material { std::make_shared<graphics::ProceduralMaterial>() };
GizmoType _gizmoType { UNSET_GIZMO_TYPE };
RingGizmoPropertyGroup _ringProperties;
PrimitiveMode _prevPrimitiveMode;

View file

@ -10,12 +10,17 @@
#include <DependencyManager.h>
#include <GeometryCache.h>
#include <graphics/ShaderConstants.h>
#include "RenderPipelines.h"
using namespace render;
using namespace render::entities;
ImageEntityRenderer::ImageEntityRenderer(const EntityItemPointer& entity) : Parent(entity) {
_geometryId = DependencyManager::get<GeometryCache>()->allocateID();
_material->setCullFaceMode(graphics::MaterialKey::CullFaceMode::CULL_NONE);
addMaterial(graphics::MaterialLayer(_material, 0), "0");
}
ImageEntityRenderer::~ImageEntityRenderer() {
@ -25,8 +30,8 @@ ImageEntityRenderer::~ImageEntityRenderer() {
}
}
bool ImageEntityRenderer::isTransparent() const {
return Parent::isTransparent() || (_textureIsLoaded && _texture->getGPUTexture() && _texture->getGPUTexture()->getUsage().isAlpha()) || _alpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE;
bool ImageEntityRenderer::needsRenderUpdate() const {
return needsRenderUpdateFromMaterials() || Parent::needsRenderUpdate();
}
void ImageEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
@ -51,67 +56,111 @@ void ImageEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
_textureIsLoaded = false;
}
_emissive = entity->getEmissive();
_keepAspectRatio = entity->getKeepAspectRatio();
_subImage = entity->getSubImage();
_color = entity->getColor();
_alpha = entity->getAlpha();
_pulseProperties = entity->getPulseProperties();
bool materialChanged = false;
glm::vec3 color = toGlm(entity->getColor());
if (_color != color) {
_color = color;
_material->setAlbedo(color);
materialChanged = true;
}
float alpha = entity->getAlpha();
if (_alpha != alpha) {
_alpha = alpha;
_material->setOpacity(alpha);
materialChanged = true;
}
auto emissive = entity->getEmissive();
if (_emissive != emissive) {
_emissive = emissive;
_material->setUnlit(_emissive);
materialChanged = true;
}
updateMaterials(materialChanged);
bool nextTextureLoaded = _texture && (_texture->isLoaded() || _texture->isFailed());
if (!_textureIsLoaded) {
emit requestRenderUpdate();
if (nextTextureLoaded) {
float width = _texture->getOriginalWidth();
float height = _texture->getOriginalHeight();
glm::vec3 naturalDimensions = glm::vec3(1.0f, 1.0f, 0.01f);
if (width < height) {
naturalDimensions.x = width / height;
} else {
naturalDimensions.y = height / width;
}
// Unlike Models (where the Renderer also doubles as the EntityItem), Images need to
// convey this information back to the game object from the Renderer
entity->setNaturalDimension(naturalDimensions);
}
}
_textureIsLoaded = _texture && (_texture->isLoaded() || _texture->isFailed());
_textureIsLoaded = nextTextureLoaded;
}
bool ImageEntityRenderer::isTransparent() const {
bool imageTransparent = _alpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE ||
(_textureIsLoaded && _texture->getGPUTexture() && _texture->getGPUTexture()->getUsage().isAlpha());
return imageTransparent || Parent::isTransparent() || materialsTransparent();
}
Item::Bound ImageEntityRenderer::getBound(RenderArgs* args) {
return Parent::getMaterialBound(args);
}
ShapeKey ImageEntityRenderer::getShapeKey() {
auto builder = render::ShapeKey::Builder().withoutCullFace().withDepthBias();
if (isTransparent()) {
builder.withTranslucent();
}
if (_emissive) {
builder.withUnlit();
}
if (_primitiveMode == PrimitiveMode::LINES) {
builder.withWireframe();
}
auto builder = render::ShapeKey::Builder().withDepthBias();
updateShapeKeyBuilderFromMaterials(builder);
return builder.build();
}
void ImageEntityRenderer::doRender(RenderArgs* args) {
glm::vec4 color = glm::vec4(toGlm(_color), _alpha);
color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created);
Transform transform;
withReadLock([&] {
transform = _renderTransform;
});
PerformanceTimer perfTimer("RenderableImageEntityItem::render");
Q_ASSERT(args->_batch);
if (!_visible || !_texture || !_texture->isLoaded() || color.a == 0.0f) {
graphics::MultiMaterial materials;
{
std::lock_guard<std::mutex> lock(_materialsLock);
materials = _materials["0"];
}
auto& schema = materials.getSchemaBuffer().get<graphics::MultiMaterial::Schema>();
glm::vec4 color = glm::vec4(ColorUtils::tosRGBVec3(schema._albedo), schema._opacity);
color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created);
if (!_texture || !_texture->isLoaded() || color.a == 0.0f) {
return;
}
Q_ASSERT(args->_batch);
Transform transform;
bool transparent;
withReadLock([&] {
transform = _renderTransform;
transparent = isTransparent();
});
gpu::Batch* batch = args->_batch;
transform.setRotation(BillboardModeHelpers::getBillboardRotation(transform.getTranslation(), transform.getRotation(), _billboardMode,
args->_renderMode == RenderArgs::RenderMode::SHADOW_RENDER_MODE ? BillboardModeHelpers::getPrimaryViewFrustumPosition() : args->getViewFrustum().getPosition()));
batch->setModelTransform(transform);
batch->setResourceTexture(0, _texture->getGPUTexture());
float imageWidth = _texture->getWidth();
float imageHeight = _texture->getHeight();
float originalWidth = _texture->getOriginalWidth();
float originalHeight = _texture->getOriginalHeight();
QRect fromImage;
if (_subImage.width() <= 0) {
fromImage.setX(0);
fromImage.setWidth(imageWidth);
} else {
float scaleX = imageWidth / _texture->getOriginalWidth();
float scaleX = imageWidth / originalWidth;
fromImage.setX(scaleX * _subImage.x());
fromImage.setWidth(scaleX * _subImage.width());
}
@ -120,22 +169,48 @@ void ImageEntityRenderer::doRender(RenderArgs* args) {
fromImage.setY(0);
fromImage.setHeight(imageHeight);
} else {
float scaleY = imageHeight / _texture->getOriginalHeight();
float scaleY = imageHeight / originalHeight;
fromImage.setY(scaleY * _subImage.y());
fromImage.setHeight(scaleY * _subImage.height());
}
float maxSize = glm::max(fromImage.width(), fromImage.height());
float x = _keepAspectRatio ? fromImage.width() / (2.0f * maxSize) : 0.5f;
float y = _keepAspectRatio ? fromImage.height() / (2.0f * maxSize) : 0.5f;
glm::vec2 texCoordBottomLeft((fromImage.x() + 0.5f) / imageWidth, (fromImage.y() + fromImage.height() - 0.5f) / imageHeight);
glm::vec2 texCoordTopRight((fromImage.x() + fromImage.width() - 0.5f) / imageWidth, (fromImage.y() + 0.5f) / imageHeight);
if (_keepAspectRatio) {
glm::vec3 scale = transform.getScale();
float targetAspectRatio = originalWidth / originalHeight;
float currentAspectRatio = scale.x / scale.y;
if (targetAspectRatio < currentAspectRatio) {
scale.x *= targetAspectRatio / currentAspectRatio;
} else {
scale.y /= targetAspectRatio / currentAspectRatio;
}
transform.setScale(scale);
}
batch->setModelTransform(transform);
Pipeline pipelineType = getPipelineType(materials);
if (pipelineType == Pipeline::PROCEDURAL) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(materials.top().material);
transparent |= procedural->isFading();
procedural->prepare(*batch, transform.getTranslation(), transform.getScale(), transform.getRotation(), _created, ProceduralProgramKey(transparent));
} else if (pipelineType == Pipeline::SIMPLE) {
batch->setResourceTexture(0, _texture->getGPUTexture());
} else {
if (RenderPipelines::bindMaterials(materials, *batch, args->_renderMode, args->_enableTexturing)) {
args->_details._materialSwitches++;
}
}
DependencyManager::get<GeometryCache>()->renderQuad(
*batch, glm::vec2(-x, -y), glm::vec2(x, y), texCoordBottomLeft, texCoordTopRight,
*batch, glm::vec2(-0.5f), glm::vec2(0.5f), texCoordBottomLeft, texCoordTopRight,
color, _geometryId
);
batch->setResourceTexture(0, nullptr);
if (pipelineType == Pipeline::SIMPLE) {
// we have to reset this to white for other simple shapes
batch->setResourceTexture(graphics::slot::texture::Texture::MaterialAlbedo, DependencyManager::get<TextureCache>()->getWhiteTexture());
}
}

View file

@ -13,6 +13,8 @@
#include <ImageEntityItem.h>
#include <procedural/Procedural.h>
namespace render { namespace entities {
class ImageEntityRenderer : public TypedEntityRenderer<ImageEntityItem> {
@ -23,11 +25,13 @@ public:
~ImageEntityRenderer();
protected:
Item::Bound getBound(RenderArgs* args) override;
ShapeKey getShapeKey() override;
bool isTransparent() const override;
private:
virtual bool needsRenderUpdate() const override;
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
virtual void doRender(RenderArgs* args) override;
@ -40,8 +44,9 @@ private:
bool _keepAspectRatio;
QRect _subImage;
glm::u8vec3 _color;
float _alpha;
std::shared_ptr<graphics::ProceduralMaterial> _material { std::make_shared<graphics::ProceduralMaterial>() };
glm::vec3 _color { NAN };
float _alpha { NAN };
PulsePropertyGroup _pulseProperties;
int _geometryId { 0 };

View file

@ -219,6 +219,10 @@ ShapeKey MaterialEntityRenderer::getShapeKey() {
builder.withTranslucent();
}
if (drawMaterial) {
builder.withCullFaceMode(drawMaterial->getCullFaceMode());
}
if (drawMaterial && drawMaterial->isProcedural() && drawMaterial->isReady()) {
builder.withOwnPipeline();
} else {

View file

@ -1254,13 +1254,13 @@ void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
if (_hasModel && !model) {
model = std::make_shared<Model>(nullptr, entity.get(), _created);
connect(model.get(), &Model::requestRenderUpdate, this, &ModelEntityRenderer::requestRenderUpdate);
connect(model.get(), &Model::setURLFinished, this, [&](bool didVisualGeometryRequestSucceed) {
connect(model.get(), &Model::setURLFinished, this, [=](bool didVisualGeometryRequestSucceed) {
_didLastVisualGeometryRequestSucceed = didVisualGeometryRequestSucceed;
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
render::Transaction transaction;
transaction.updateItem<PayloadProxyInterface>(_renderItemID, [&](PayloadProxyInterface& self) {
transaction.updateItem<PayloadProxyInterface>(_renderItemID, [=](PayloadProxyInterface& self) {
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
withWriteLock([&] {
withWriteLock([=] {
setKey(didVisualGeometryRequestSucceed, _model);
_model->setVisibleInScene(_visible, scene);
_model->setCauterized(_cauterized, scene);

View file

@ -29,26 +29,7 @@ ShapeEntityRenderer::ShapeEntityRenderer(const EntityItemPointer& entity) : Pare
}
bool ShapeEntityRenderer::needsRenderUpdate() const {
if (resultWithReadLock<bool>([&] {
auto mat = _materials.find("0");
if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() &&
mat->second.top().material->isReady()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
if (procedural->isFading()) {
return true;
}
}
if (mat != _materials.end() && mat->second.shouldUpdate()) {
return true;
}
return false;
})) {
return true;
}
return Parent::needsRenderUpdate();
return needsRenderUpdateFromMaterials() || Parent::needsRenderUpdate();
}
void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
@ -91,155 +72,58 @@ void ShapeEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
materialChanged = true;
}
withReadLock([&] {
auto materials = _materials.find("0");
if (materials != _materials.end()) {
if (materialChanged) {
materials->second.setNeedsUpdate(true);
}
bool requestUpdate = false;
if (materials->second.top().material && materials->second.top().material->isProcedural() && materials->second.top().material->isReady()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(materials->second.top().material);
if (procedural->isFading()) {
procedural->setIsFading(Interpolate::calculateFadeRatio(procedural->getFadeStartTime()) < 1.0f);
requestUpdate = true;
}
}
if (materials->second.shouldUpdate()) {
RenderPipelines::updateMultiMaterial(materials->second);
requestUpdate = true;
}
if (requestUpdate) {
emit requestRenderUpdate();
}
}
});
updateMaterials(materialChanged);
}
bool ShapeEntityRenderer::isTransparent() const {
if (_pulseProperties.getAlphaMode() != PulseMode::NONE) {
return true;
}
auto mat = _materials.find("0");
if (mat != _materials.end() && mat->second.top().material) {
if (mat->second.top().material->isProcedural() && mat->second.top().material->isReady()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
if (procedural->isFading()) {
return true;
}
}
if (mat->second.getMaterialKey().isTranslucent()) {
return true;
}
}
return Parent::isTransparent();
return _pulseProperties.getAlphaMode() != PulseMode::NONE || Parent::isTransparent() || materialsTransparent();
}
ShapeEntityRenderer::Pipeline ShapeEntityRenderer::getPipelineType(const graphics::MultiMaterial& materials) const {
if (materials.top().material && materials.top().material->isProcedural() && materials.top().material->isReady()) {
return Pipeline::PROCEDURAL;
}
graphics::MaterialKey drawMaterialKey = materials.getMaterialKey();
if (drawMaterialKey.isEmissive() || drawMaterialKey.isUnlit() || drawMaterialKey.isMetallic() || drawMaterialKey.isScattering()) {
return Pipeline::MATERIAL;
}
// If the material is using any map, we need to use a material ShapeKey
for (int i = 0; i < graphics::Material::MapChannel::NUM_MAP_CHANNELS; i++) {
if (drawMaterialKey.isMapChannel(graphics::Material::MapChannel(i))) {
return Pipeline::MATERIAL;
}
}
return Pipeline::SIMPLE;
Item::Bound ShapeEntityRenderer::getBound(RenderArgs* args) {
return Parent::getMaterialBound(args);
}
ShapeKey ShapeEntityRenderer::getShapeKey() {
ShapeKey::Builder builder;
auto mat = _materials.find("0");
if (mat != _materials.end() && mat->second.shouldUpdate()) {
RenderPipelines::updateMultiMaterial(mat->second);
}
if (isTransparent()) {
builder.withTranslucent();
}
if (_primitiveMode == PrimitiveMode::LINES) {
builder.withWireframe();
}
auto pipelineType = getPipelineType(mat->second);
if (pipelineType == Pipeline::MATERIAL) {
builder.withMaterial();
graphics::MaterialKey drawMaterialKey = mat->second.getMaterialKey();
if (drawMaterialKey.isNormalMap()) {
builder.withTangents();
}
if (drawMaterialKey.isLightMap()) {
builder.withLightMap();
}
if (drawMaterialKey.isUnlit()) {
builder.withUnlit();
}
builder.withCullFaceMode(mat->second.getCullFaceMode());
} else if (pipelineType == Pipeline::PROCEDURAL) {
builder.withOwnPipeline();
}
updateShapeKeyBuilderFromMaterials(builder);
return builder.build();
}
Item::Bound ShapeEntityRenderer::getBound(RenderArgs* args) {
auto mat = _materials.find("0");
if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() &&
mat->second.top().material->isReady()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
if (procedural->hasVertexShader() && procedural->hasBoundOperator()) {
return procedural->getBound(args);
}
}
return Parent::getBound(args);
}
void ShapeEntityRenderer::doRender(RenderArgs* args) {
PerformanceTimer perfTimer("RenderableShapeEntityItem::render");
Q_ASSERT(args->_batch);
gpu::Batch& batch = *args->_batch;
graphics::MultiMaterial materials;
auto geometryCache = DependencyManager::get<GeometryCache>();
GeometryCache::Shape geometryShape = geometryCache->getShapeForEntityShape(_shape);
glm::vec4 outColor;
Pipeline pipelineType;
Transform transform;
withReadLock([&] {
transform = _renderTransform;
{
std::lock_guard<std::mutex> lock(_materialsLock);
materials = _materials["0"];
pipelineType = getPipelineType(materials);
auto& schema = materials.getSchemaBuffer().get<graphics::MultiMaterial::Schema>();
outColor = glm::vec4(ColorUtils::tosRGBVec3(schema._albedo), schema._opacity);
});
}
auto& schema = materials.getSchemaBuffer().get<graphics::MultiMaterial::Schema>();
glm::vec4 outColor = glm::vec4(ColorUtils::tosRGBVec3(schema._albedo), schema._opacity);
outColor = EntityRenderer::calculatePulseColor(outColor, _pulseProperties, _created);
if (outColor.a == 0.0f) {
return;
}
gpu::Batch& batch = *args->_batch;
auto geometryCache = DependencyManager::get<GeometryCache>();
GeometryCache::Shape geometryShape = geometryCache->getShapeForEntityShape(_shape);
Transform transform;
withReadLock([&] {
transform = _renderTransform;
});
bool wireframe = render::ShapeKey(args->_globalShapeKey).isWireframe() || _primitiveMode == PrimitiveMode::LINES;
transform.setRotation(BillboardModeHelpers::getBillboardRotation(transform.getTranslation(), transform.getRotation(), _billboardMode,
args->_renderMode == RenderArgs::RenderMode::SHADOW_RENDER_MODE ? BillboardModeHelpers::getPrimaryViewFrustumPosition() : args->getViewFrustum().getPosition(),
_shape < entity::Shape::Cube || _shape > entity::Shape::Icosahedron));
batch.setModelTransform(transform);
Pipeline pipelineType = getPipelineType(materials);
if (pipelineType == Pipeline::PROCEDURAL) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(materials.top().material);
outColor = procedural->getColor(outColor);
@ -248,7 +132,7 @@ void ShapeEntityRenderer::doRender(RenderArgs* args) {
procedural->prepare(batch, transform.getTranslation(), transform.getScale(), transform.getRotation(), _created, ProceduralProgramKey(outColor.a < 1.0f));
});
if (render::ShapeKey(args->_globalShapeKey).isWireframe() || _primitiveMode == PrimitiveMode::LINES) {
if (wireframe) {
geometryCache->renderWireShape(batch, geometryShape, outColor);
} else {
geometryCache->renderShape(batch, geometryShape, outColor);
@ -256,12 +140,21 @@ void ShapeEntityRenderer::doRender(RenderArgs* args) {
} else if (pipelineType == Pipeline::SIMPLE) {
// FIXME, support instanced multi-shape rendering using multidraw indirect
outColor.a *= _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
render::ShapePipelinePointer pipeline = geometryCache->getShapePipelinePointer(outColor.a < 1.0f, false,
_renderLayer != RenderLayer::WORLD || args->_renderMethod == Args::RenderMethod::FORWARD, materials.top().material->getCullFaceMode());
if (render::ShapeKey(args->_globalShapeKey).isWireframe() || _primitiveMode == PrimitiveMode::LINES) {
geometryCache->renderWireShapeInstance(args, batch, geometryShape, outColor, pipeline);
bool forward = _renderLayer != RenderLayer::WORLD || args->_renderMethod == Args::RenderMethod::FORWARD;
if (outColor.a >= 1.0f) {
render::ShapePipelinePointer pipeline = geometryCache->getShapePipelinePointer(false, wireframe || materials.top().material->isUnlit(),
forward, materials.top().material->getCullFaceMode());
if (wireframe) {
geometryCache->renderWireShapeInstance(args, batch, geometryShape, outColor, pipeline);
} else {
geometryCache->renderSolidShapeInstance(args, batch, geometryShape, outColor, pipeline);
}
} else {
geometryCache->renderSolidShapeInstance(args, batch, geometryShape, outColor, pipeline);
if (wireframe) {
geometryCache->renderWireShape(batch, geometryShape, outColor);
} else {
geometryCache->renderShape(batch, geometryShape, outColor);
}
}
} else {
if (RenderPipelines::bindMaterials(materials, batch, args->_renderMode, args->_enableTexturing)) {

View file

@ -35,9 +35,6 @@ private:
virtual void doRender(RenderArgs* args) override;
virtual bool isTransparent() const override;
enum Pipeline { SIMPLE, MATERIAL, PROCEDURAL };
Pipeline getPipelineType(const graphics::MultiMaterial& materials) const;
QString _proceduralData;
entity::Shape _shape { entity::Sphere };

View file

@ -20,6 +20,7 @@
#include "GLMHelpers.h"
#include "DeferredLightingEffect.h"
#include "RenderPipelines.h"
using namespace render;
using namespace render::entities;
@ -35,6 +36,8 @@ TextEntityRenderer::TextEntityRenderer(const EntityItemPointer& entity) :
if (geometryCache) {
_geometryID = geometryCache->allocateID();
}
_material->setCullFaceMode(graphics::MaterialKey::CullFaceMode::CULL_NONE);
addMaterial(graphics::MaterialLayer(_material, 0), "0");
}
TextEntityRenderer::~TextEntityRenderer() {
@ -44,41 +47,8 @@ TextEntityRenderer::~TextEntityRenderer() {
}
}
bool TextEntityRenderer::isTransparent() const {
return Parent::isTransparent() || _backgroundAlpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE;
}
bool TextEntityRenderer::isTextTransparent() const {
return resultWithReadLock<bool>([&] {
return Parent::isTransparent() || _textAlpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE;
});
}
ItemKey TextEntityRenderer::getKey() {
return ItemKey::Builder(Parent::getKey()).withMetaCullGroup();
}
ShapeKey TextEntityRenderer::getShapeKey() {
auto builder = render::ShapeKey::Builder().withoutCullFace();
if (isTransparent()) {
builder.withTranslucent();
}
if (_unlit) {
builder.withUnlit();
}
if (_primitiveMode == PrimitiveMode::LINES) {
builder.withWireframe();
}
return builder.build();
}
uint32_t TextEntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) const {
auto parentSubs = Parent::metaFetchMetaSubItems(subItems);
if (Item::isValidID(_textRenderID)) {
subItems.emplace_back(_textRenderID);
return parentSubs + 1;
}
return parentSubs;
bool TextEntityRenderer::needsRenderUpdate() const {
return needsRenderUpdateFromMaterials() || Parent::needsRenderUpdate();
}
void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
@ -98,58 +68,126 @@ void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointe
_lineHeight = entity->getLineHeight();
_textColor = toGlm(entity->getTextColor());
_textAlpha = entity->getTextAlpha();
_backgroundColor = toGlm(entity->getBackgroundColor());
_backgroundAlpha = entity->getBackgroundAlpha();
_leftMargin = entity->getLeftMargin();
_rightMargin = entity->getRightMargin();
_topMargin = entity->getTopMargin();
_bottomMargin = entity->getBottomMargin();
_unlit = entity->getUnlit();
_font = entity->getFont();
_effect = entity->getTextEffect();
_effectColor = toGlm(entity->getTextEffectColor());
_effectThickness = entity->getTextEffectThickness();
_alignment = entity->getAlignment();
bool materialChanged = false;
glm::vec3 color = toGlm(entity->getBackgroundColor());
if (_backgroundColor != color) {
_backgroundColor = color;
_material->setAlbedo(color);
materialChanged = true;
}
float alpha = entity->getBackgroundAlpha();
if (_backgroundAlpha != alpha) {
_backgroundAlpha = alpha;
_material->setOpacity(alpha);
materialChanged = true;
}
auto unlit = entity->getUnlit();
if (_unlit != unlit) {
_unlit = unlit;
_material->setUnlit(_unlit);
materialChanged = true;
}
updateMaterials(materialChanged);
updateTextRenderItem();
}
bool TextEntityRenderer::isTransparent() const {
bool backgroundTransparent = _backgroundAlpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE;
return backgroundTransparent || Parent::isTransparent() || materialsTransparent();
}
bool TextEntityRenderer::isTextTransparent() const {
return Parent::isTransparent() || _textAlpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE;
}
Item::Bound TextEntityRenderer::getBound(RenderArgs* args) {
return Parent::getMaterialBound(args);
}
ItemKey TextEntityRenderer::getKey() {
return ItemKey::Builder(Parent::getKey()).withMetaCullGroup();
}
ShapeKey TextEntityRenderer::getShapeKey() {
auto builder = render::ShapeKey::Builder().withDepthBias();
updateShapeKeyBuilderFromMaterials(builder);
return builder.build();
}
uint32_t TextEntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) const {
auto parentSubs = Parent::metaFetchMetaSubItems(subItems);
if (Item::isValidID(_textRenderID)) {
subItems.emplace_back(_textRenderID);
return parentSubs + 1;
}
return parentSubs;
}
void TextEntityRenderer::doRender(RenderArgs* args) {
PerformanceTimer perfTimer("RenderableTextEntityItem::render");
Q_ASSERT(args->_batch);
gpu::Batch& batch = *args->_batch;
glm::vec4 backgroundColor;
Transform transform;
withReadLock([&] {
transform = _renderTransform;
graphics::MultiMaterial materials;
{
std::lock_guard<std::mutex> lock(_materialsLock);
materials = _materials["0"];
}
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
backgroundColor = glm::vec4(_backgroundColor, fadeRatio * _backgroundAlpha);
});
auto& schema = materials.getSchemaBuffer().get<graphics::MultiMaterial::Schema>();
glm::vec4 backgroundColor = glm::vec4(ColorUtils::tosRGBVec3(schema._albedo), schema._opacity);
backgroundColor = EntityRenderer::calculatePulseColor(backgroundColor, _pulseProperties, _created);
if (backgroundColor.a <= 0.0f) {
return;
}
gpu::Batch& batch = *args->_batch;
bool transparent;
Transform transform;
withReadLock([&] {
transparent = isTransparent();
transform = _renderTransform;
});
transform.setRotation(BillboardModeHelpers::getBillboardRotation(transform.getTranslation(), transform.getRotation(), _billboardMode,
args->_renderMode == RenderArgs::RenderMode::SHADOW_RENDER_MODE ? BillboardModeHelpers::getPrimaryViewFrustumPosition() : args->getViewFrustum().getPosition()));
batch.setModelTransform(transform);
Pipeline pipelineType = getPipelineType(materials);
if (pipelineType == Pipeline::PROCEDURAL) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(materials.top().material);
transparent |= procedural->isFading();
procedural->prepare(batch, transform.getTranslation(), transform.getScale(), transform.getRotation(), _created, ProceduralProgramKey(transparent));
} else if (pipelineType == Pipeline::MATERIAL) {
if (RenderPipelines::bindMaterials(materials, batch, args->_renderMode, args->_enableTexturing)) {
args->_details._materialSwitches++;
}
}
auto geometryCache = DependencyManager::get<GeometryCache>();
// FIXME: we want to use instanced rendering here, but if textAlpha < 1 and backgroundAlpha < 1, the transparency sorting will be wrong
//render::ShapePipelinePointer pipeline = geometryCache->getShapePipelinePointer(backgroundColor.a < 1.0f, _unlit,
// _renderLayer != RenderLayer::WORLD || args->_renderMethod == Args::RenderMethod::FORWARD);
//if (render::ShapeKey(args->_globalShapeKey).isWireframe() || _primitiveMode == PrimitiveMode::LINES) {
// geometryCache->renderWireShapeInstance(args, batch, GeometryCache::Quad, backgroundColor, pipeline);
//} else {
// geometryCache->renderSolidShapeInstance(args, batch, GeometryCache::Quad, backgroundColor, pipeline);
//}
if (pipelineType == Pipeline::SIMPLE) {
geometryCache->renderQuad(batch, glm::vec2(-0.5f), glm::vec2(0.5f), backgroundColor, _geometryID);
} else {
geometryCache->renderQuad(batch, glm::vec2(-0.5f), glm::vec2(0.5f), glm::vec2(0.0f), glm::vec2(1.0f), backgroundColor, _geometryID);
}
geometryCache->renderQuad(batch, glm::vec2(-0.5), glm::vec2(0.5), backgroundColor, _geometryID);
const int TRIANBLES_PER_QUAD = 2;
args->_details._trianglesRendered += TRIANBLES_PER_QUAD;
const int TRIANGLES_PER_QUAD = 2;
args->_details._trianglesRendered += TRIANGLES_PER_QUAD;
}
QSizeF TextEntityRenderer::textSize(const QString& text) const {

View file

@ -14,6 +14,8 @@
#include "RenderableEntityItem.h"
#include <procedural/Procedural.h>
class TextEntityItem;
class TextRenderer3D;
@ -33,6 +35,7 @@ public:
protected:
bool isTransparent() const override;
bool isTextTransparent() const;
Item::Bound getBound(RenderArgs* args) override;
ShapeKey getShapeKey() override;
ItemKey getKey() override;
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) const override;
@ -41,6 +44,7 @@ protected:
void onRemoveFromSceneTyped(const TypedEntityPointer& entity) override;
private:
virtual bool needsRenderUpdate() const override;
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
virtual void doRender(RenderArgs* args) override;
@ -53,10 +57,12 @@ private:
float _lineHeight;
glm::vec3 _textColor;
float _textAlpha;
glm::vec3 _backgroundColor;
float _backgroundAlpha;
bool _unlit;
std::shared_ptr<graphics::ProceduralMaterial> _material { std::make_shared<graphics::ProceduralMaterial>() };
glm::vec3 _backgroundColor { NAN };
float _backgroundAlpha { NAN };
float _leftMargin;
float _rightMargin;
float _topMargin;

View file

@ -1772,13 +1772,11 @@ bool EntityItem::contains(const glm::vec3& point) const {
ShapeType shapeType = getShapeType();
if (shapeType == SHAPE_TYPE_SPHERE) {
// SPHERE case is special:
// anything with shapeType == SPHERE must collide as a bounding sphere in the world-frame regardless of dimensions
// therefore we must do math using an unscaled localPoint relative to sphere center
glm::vec3 dimensions = getScaledDimensions();
glm::vec3 localPoint = point - (getWorldPosition() + getWorldOrientation() * (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()) + getPivot()));
const float HALF_SQUARED = 0.25f;
return glm::length2(localPoint) < HALF_SQUARED * glm::length2(dimensions);
if (dimensions.x == dimensions.y && dimensions.y == dimensions.z) {
glm::vec3 localPoint = point - (getWorldPosition() + getWorldOrientation() * (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()) + getPivot()));
return glm::length2(localPoint) < glm::length2(0.5f * dimensions.x);
}
}
// we transform into the "normalized entity-frame" where the bounding box is centered on the origin
@ -1805,6 +1803,7 @@ bool EntityItem::contains(const glm::vec3& point) const {
localPoint = glm::abs(localPoint);
return glm::all(glm::lessThanEqual(localPoint, glm::vec3(NORMALIZED_HALF_SIDE)));
}
case SHAPE_TYPE_SPHERE:
case SHAPE_TYPE_ELLIPSOID: {
// since we've transformed into the normalized space this is just a sphere-point intersection test
return glm::length2(localPoint) <= NORMALIZED_RADIUS_SQUARED;

View file

@ -723,7 +723,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
*
* @property {Vec3} naturalPosition=0,0,0 - The center of the entity's unscaled mesh model if it has one, otherwise
* {@link Vec3(0)|Vec3.ZERO}. <em>Read-only.</em>
* @property {Vec3} naturalDimensions - The dimensions of the entity's unscaled mesh model if it has one, otherwise
* @property {Vec3} naturalDimensions - The dimensions of the entity's unscaled mesh model or image if it has one, otherwise
* {@link Vec3(0)|Vec3.ONE}. <em>Read-only.</em>
*
* @property {Vec3} velocity=0,0,0 - The linear velocity of the entity in m/s with respect to world coordinates.

View file

@ -57,6 +57,7 @@ EntityScriptingInterface::EntityScriptingInterface(bool bidOnSimulationOwnership
connect(nodeList.data(), &NodeList::canRezTmpCertifiedChanged, this, &EntityScriptingInterface::canRezTmpCertifiedChanged);
connect(nodeList.data(), &NodeList::canWriteAssetsChanged, this, &EntityScriptingInterface::canWriteAssetsChanged);
connect(nodeList.data(), &NodeList::canGetAndSetPrivateUserDataChanged, this, &EntityScriptingInterface::canGetAndSetPrivateUserDataChanged);
connect(nodeList.data(), &NodeList::canRezAvatarEntitiesChanged, this, &EntityScriptingInterface::canRezAvatarEntitiesChanged);
auto& packetReceiver = nodeList->getPacketReceiver();
packetReceiver.registerListener(PacketType::EntityScriptCallMethod,
@ -114,6 +115,11 @@ bool EntityScriptingInterface::canGetAndSetPrivateUserData() {
return nodeList->getThisNodeCanGetAndSetPrivateUserData();
}
bool EntityScriptingInterface::canRezAvatarEntities() {
auto nodeList = DependencyManager::get<NodeList>();
return nodeList->getThisNodeCanRezAvatarEntities();
}
void EntityScriptingInterface::setEntityTree(EntityTreePointer elementTree) {
if (_entityTree) {
disconnect(_entityTree.get(), &EntityTree::addingEntityPointer, this, &EntityScriptingInterface::onAddingEntity);
@ -481,6 +487,15 @@ QUuid EntityScriptingInterface::addEntityInternal(const EntityItemProperties& pr
_activityTracking.addedEntityCount++;
auto nodeList = DependencyManager::get<NodeList>();
if (entityHostType == entity::HostType::AVATAR && !nodeList->getThisNodeCanRezAvatarEntities()) {
qCDebug(entities) << "Ignoring addEntity() because don't have canRezAvatarEntities permission on domain";
// Only need to intercept methods that may add an avatar entity because avatar entities are removed from the tree when
// the user doesn't have canRezAvatarEntities permission.
return QUuid();
}
EntityItemProperties propertiesWithSimID = properties;
propertiesWithSimID.setEntityHostType(entityHostType);
if (entityHostType == entity::HostType::AVATAR) {
@ -493,7 +508,6 @@ QUuid EntityScriptingInterface::addEntityInternal(const EntityItemProperties& pr
}
// the created time will be set in EntityTree::addEntity by recordCreationTime()
auto nodeList = DependencyManager::get<NodeList>();
auto sessionID = nodeList->getSessionUUID();
propertiesWithSimID.setLastEditedBy(sessionID);
@ -1002,7 +1016,7 @@ void EntityScriptingInterface::deleteEntity(const QUuid& id) {
for (auto entity : entitiesToDeleteImmediately) {
if (entity->isMyAvatarEntity()) {
getEntityPacketSender()->getMyAvatar()->clearAvatarEntity(entity->getID(), false);
getEntityPacketSender()->getMyAvatar()->clearAvatarEntityInternal(entity->getID());
}
}
}

View file

@ -289,6 +289,14 @@ public slots:
* <code>privateUserData</code> property of entities, otherwise <code>false</code>.
*/
Q_INVOKABLE bool canGetAndSetPrivateUserData();
/**jsdoc
* Checks whether or not the script can rez avatar entities.
* @function Entities.canRezAvatarEntities
* @returns {boolean} <code>true</code> if the domain server will allow the script to rez avatar entities,
* otherwise <code>false</code>.
*/
Q_INVOKABLE bool canRezAvatarEntities();
/**jsdoc
* <p>How an entity is hosted and sent to others for display.</p>
@ -2255,11 +2263,20 @@ signals:
/**jsdoc
* Triggered when your ability to get and set private user data changes.
* @function Entities.canGetAndSetPrivateUserDataChanged
* @param {boolean} canGetAndSetPrivateUserData - <code>true</code> if the script change the <code>privateUserData</code>
* @param {boolean} canGetAndSetPrivateUserData - <code>true</code> if the script can change the <code>privateUserData</code>
* property of an entity, <code>false</code> if it can't.
* @returns {Signal}
*/
void canGetAndSetPrivateUserDataChanged(bool canGetAndSetPrivateUserData);
/**jsdoc
* Triggered when your ability to use avatar entities is changed.
* @function Entities.canRezAvatarEntitiesChanged
* @param {boolean} canRezAvatarEntities - <code>true</code> if the script can change edit avatar entities,
* <code>false</code> if it can't.
* @returns {Signal}
*/
void canRezAvatarEntitiesChanged(bool canRezAvatarEntities);
/**jsdoc

View file

@ -34,6 +34,7 @@ EntityItemProperties ImageEntityItem::getProperties(const EntityPropertyFlags& d
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
withReadLock([&] {
_pulseProperties.getProperties(properties);
properties.setNaturalDimensions(_naturalDimensions);
});
COPY_ENTITY_PROPERTY_TO_PROPERTIES(imageURL, getImageURL);
@ -217,4 +218,10 @@ PulsePropertyGroup ImageEntityItem::getPulseProperties() const {
return resultWithReadLock<PulsePropertyGroup>([&] {
return _pulseProperties;
});
}
}
void ImageEntityItem::setNaturalDimension(const glm::vec3& naturalDimensions) const {
withWriteLock([&] {
_naturalDimensions = naturalDimensions;
});
}

View file

@ -63,6 +63,8 @@ public:
PulsePropertyGroup getPulseProperties() const;
void setNaturalDimension(const glm::vec3& naturalDimensions) const;
protected:
glm::u8vec3 _color;
float _alpha;
@ -72,6 +74,8 @@ protected:
bool _emissive { false };
bool _keepAspectRatio { true };
QRect _subImage;
mutable glm::vec3 _naturalDimensions;
};
#endif // hifi_ImageEntityItem_h

View file

@ -339,7 +339,7 @@ bool ShapeEntityItem::findDetailedParabolaIntersection(const glm::vec3& origin,
bool ShapeEntityItem::getRotateForPicking() const {
auto shape = getShape();
return getBillboardMode() != BillboardMode::NONE && (_shape < entity::Shape::Cube || _shape > entity::Shape::Icosahedron);
return getBillboardMode() != BillboardMode::NONE && (shape < entity::Shape::Cube || shape > entity::Shape::Icosahedron);
}
void ShapeEntityItem::debugDump() const {

View file

@ -270,7 +270,6 @@ void ZoneEntityItem::debugDump() const {
}
void ZoneEntityItem::setShapeType(ShapeType type) {
ShapeType oldShapeType = _shapeType;
switch(type) {
case SHAPE_TYPE_NONE:
case SHAPE_TYPE_CAPSULE_X:
@ -288,7 +287,12 @@ void ZoneEntityItem::setShapeType(ShapeType type) {
default:
break;
}
_shapeType = type;
ShapeType oldShapeType;
withWriteLock([&] {
oldShapeType = _shapeType;
_shapeType = type;
});
if (type == SHAPE_TYPE_COMPOUND) {
if (type != oldShapeType) {
@ -300,16 +304,21 @@ void ZoneEntityItem::setShapeType(ShapeType type) {
}
ShapeType ZoneEntityItem::getShapeType() const {
return _shapeType;
return resultWithReadLock<ShapeType>([&] {
return _shapeType;
});
}
void ZoneEntityItem::setCompoundShapeURL(const QString& url) {
QString oldCompoundShapeURL = _compoundShapeURL;
QString oldCompoundShapeURL;
ShapeType shapeType;
withWriteLock([&] {
oldCompoundShapeURL = _compoundShapeURL;
_compoundShapeURL = url;
shapeType = _shapeType;
});
if (oldCompoundShapeURL != url) {
if (_shapeType == SHAPE_TYPE_COMPOUND) {
if (shapeType == SHAPE_TYPE_COMPOUND) {
fetchCollisionGeometryResource();
} else {
_shapeResource.reset();
@ -333,7 +342,7 @@ bool ZoneEntityItem::findDetailedParabolaIntersection(const glm::vec3& origin, c
bool ZoneEntityItem::contains(const glm::vec3& point) const {
GeometryResource::Pointer resource = _shapeResource;
if (_shapeType == SHAPE_TYPE_COMPOUND && resource) {
if (getShapeType() == SHAPE_TYPE_COMPOUND && resource) {
if (resource->isLoaded()) {
const HFMModel& hfmModel = resource->getHFMModel();

View file

@ -1863,7 +1863,7 @@ void GLTFSerializer::setHFMMaterial(HFMMaterial& hfmMat, const GLTFMaterial& mat
template<typename T, typename L>
bool GLTFSerializer::readArray(const hifi::ByteArray& bin, int byteOffset, int count,
QVector<L>& outarray, int accessorType) {
QVector<L>& outarray, int accessorType, bool normalized) {
QDataStream blobstream(bin);
blobstream.setByteOrder(QDataStream::LittleEndian);
@ -1899,12 +1899,22 @@ bool GLTFSerializer::readArray(const hifi::ByteArray& bin, int byteOffset, int c
blobstream.setDevice(nullptr);
return false;
}
float scale = 1.0f; // Normalized output values should always be floats.
if (normalized) {
scale = (float)(std::numeric_limits<T>::max)();
}
for (int i = 0; i < count; ++i) {
for (int j = 0; j < bufferCount; ++j) {
if (!blobstream.atEnd()) {
T value;
blobstream >> value;
outarray.push_back(value);
if (normalized) {
outarray.push_back(std::max((float)value / scale, -1.0f));
} else {
outarray.push_back(value);
}
} else {
blobstream.setDevice(nullptr);
return false;
@ -1917,24 +1927,24 @@ bool GLTFSerializer::readArray(const hifi::ByteArray& bin, int byteOffset, int c
}
template<typename T>
bool GLTFSerializer::addArrayOfType(const hifi::ByteArray& bin, int byteOffset, int count,
QVector<T>& outarray, int accessorType, int componentType) {
QVector<T>& outarray, int accessorType, int componentType, bool normalized) {
switch (componentType) {
case GLTFAccessorComponentType::BYTE: {}
case GLTFAccessorComponentType::UNSIGNED_BYTE: {
return readArray<uchar>(bin, byteOffset, count, outarray, accessorType);
return readArray<uchar>(bin, byteOffset, count, outarray, accessorType, normalized);
}
case GLTFAccessorComponentType::SHORT: {
return readArray<short>(bin, byteOffset, count, outarray, accessorType);
return readArray<short>(bin, byteOffset, count, outarray, accessorType, normalized);
}
case GLTFAccessorComponentType::UNSIGNED_INT: {
return readArray<uint>(bin, byteOffset, count, outarray, accessorType);
return readArray<uint>(bin, byteOffset, count, outarray, accessorType, normalized);
}
case GLTFAccessorComponentType::UNSIGNED_SHORT: {
return readArray<ushort>(bin, byteOffset, count, outarray, accessorType);
return readArray<ushort>(bin, byteOffset, count, outarray, accessorType, normalized);
}
case GLTFAccessorComponentType::FLOAT: {
return readArray<float>(bin, byteOffset, count, outarray, accessorType);
return readArray<float>(bin, byteOffset, count, outarray, accessorType, normalized);
}
}
return false;
@ -1951,11 +1961,11 @@ bool GLTFSerializer::addArrayFromAccessor(GLTFAccessor& accessor, QVector<T>& ou
int accBoffset = accessor.defined["byteOffset"] ? accessor.byteOffset : 0;
success = addArrayOfType(buffer.blob, bufferview.byteOffset + accBoffset, accessor.count, outarray, accessor.type,
accessor.componentType);
accessor.componentType, accessor.normalized);
} else {
for (int i = 0; i < accessor.count; ++i) {
T value;
memset(&value, 0, sizeof(T)); // Make sure the dummy array is initalised to zero.
memset(&value, 0, sizeof(T)); // Make sure the dummy array is initialized to zero.
outarray.push_back(value);
}
}
@ -1971,7 +1981,7 @@ bool GLTFSerializer::addArrayFromAccessor(GLTFAccessor& accessor, QVector<T>& ou
success = addArrayOfType(sparseIndicesBuffer.blob, sparseIndicesBufferview.byteOffset + accSIBoffset,
accessor.sparse.count, out_sparse_indices_array, GLTFAccessorType::SCALAR,
accessor.sparse.indices.componentType);
accessor.sparse.indices.componentType, false);
if (success) {
QVector<T> out_sparse_values_array;
@ -1981,7 +1991,8 @@ bool GLTFSerializer::addArrayFromAccessor(GLTFAccessor& accessor, QVector<T>& ou
int accSVBoffset = accessor.sparse.values.defined["byteOffset"] ? accessor.sparse.values.byteOffset : 0;
success = addArrayOfType(sparseValuesBuffer.blob, sparseValuesBufferview.byteOffset + accSVBoffset,
accessor.sparse.count, out_sparse_values_array, accessor.type, accessor.componentType);
accessor.sparse.count, out_sparse_values_array, accessor.type, accessor.componentType,
accessor.normalized);
if (success) {
for (int i = 0; i < accessor.sparse.count; ++i) {

View file

@ -527,7 +527,7 @@ struct GLTFAccessor {
int componentType; //required
int count; //required
int type; //required
bool normalized{ false };
bool normalized { false };
QVector<double> max;
QVector<double> min;
GLTFAccessorSparse sparse;
@ -832,11 +832,11 @@ private:
template<typename T, typename L>
bool readArray(const hifi::ByteArray& bin, int byteOffset, int count,
QVector<L>& outarray, int accessorType);
QVector<L>& outarray, int accessorType, bool normalized);
template<typename T>
bool addArrayOfType(const hifi::ByteArray& bin, int byteOffset, int count,
QVector<T>& outarray, int accessorType, int componentType);
QVector<T>& outarray, int accessorType, int componentType, bool normalized);
template <typename T>
bool addArrayFromAccessor(GLTFAccessor& accessor, QVector<T>& outarray);

View file

@ -840,10 +840,7 @@ void GLBackend::do_glColor4f(const Batch& batch, size_t paramOffset) {
if (_input._colorAttribute != newColor) {
_input._colorAttribute = newColor;
glVertexAttrib4fv(gpu::Stream::COLOR, &_input._colorAttribute.r);
// Color has been changed and is not white. To prevent colors from bleeding
// between different objects, we need to set the _hadColorAttribute flag
// as if a previous render call had potential colors
_input._hadColorAttribute = (newColor != glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
_input._hasColorAttribute = true;
}
(void)CHECK_GL_ERROR();
}

View file

@ -348,36 +348,37 @@ protected:
virtual void updateInput() = 0;
struct InputStageState {
bool _invalidFormat{ true };
bool _lastUpdateStereoState{ false };
bool _hadColorAttribute{ true };
FormatReference _format{ GPU_REFERENCE_INIT_VALUE };
bool _invalidFormat { true };
bool _lastUpdateStereoState { false };
bool _hasColorAttribute { false };
bool _hadColorAttribute { false };
FormatReference _format { GPU_REFERENCE_INIT_VALUE };
std::string _formatKey;
typedef std::bitset<MAX_NUM_ATTRIBUTES> ActivationCache;
ActivationCache _attributeActivation{ 0 };
ActivationCache _attributeActivation { 0 };
typedef std::bitset<MAX_NUM_INPUT_BUFFERS> BuffersState;
BuffersState _invalidBuffers{ 0 };
BuffersState _attribBindingBuffers{ 0 };
BuffersState _invalidBuffers { 0 };
BuffersState _attribBindingBuffers { 0 };
std::array<BufferReference, MAX_NUM_INPUT_BUFFERS> _buffers{};
std::array<Offset, MAX_NUM_INPUT_BUFFERS> _bufferOffsets{};
std::array<Offset, MAX_NUM_INPUT_BUFFERS> _bufferStrides{};
std::array<GLuint, MAX_NUM_INPUT_BUFFERS> _bufferVBOs{};
std::array<BufferReference, MAX_NUM_INPUT_BUFFERS> _buffers;
std::array<Offset, MAX_NUM_INPUT_BUFFERS> _bufferOffsets;
std::array<Offset, MAX_NUM_INPUT_BUFFERS> _bufferStrides;
std::array<GLuint, MAX_NUM_INPUT_BUFFERS> _bufferVBOs;
glm::vec4 _colorAttribute{ 0.0f };
glm::vec4 _colorAttribute { 1.0f };
BufferReference _indexBuffer{};
Offset _indexBufferOffset{ 0 };
Type _indexBufferType{ UINT32 };
BufferReference _indexBuffer;
Offset _indexBufferOffset { 0 };
Type _indexBufferType { UINT32 };
BufferReference _indirectBuffer{};
Offset _indirectBufferOffset{ 0 };
Offset _indirectBufferStride{ 0 };
BufferReference _indirectBuffer;
Offset _indirectBufferOffset { 0 };
Offset _indirectBufferStride { 0 };
GLuint _defaultVAO{ 0 };
GLuint _defaultVAO { 0 };
} _input;
virtual void initTransform() = 0;

View file

@ -103,6 +103,9 @@ void GLBackend::resetInputStage() {
reset(_input._format);
_input._formatKey.clear();
_input._invalidFormat = false;
_input._hasColorAttribute = false;
_input._hadColorAttribute = false;
_input._colorAttribute = vec4(1.0f);
_input._attributeActivation.reset();
for (uint32_t i = 0; i < _input._buffers.size(); i++) {
@ -159,15 +162,15 @@ void GLBackend::updateInput() {
_input._invalidFormat |= (isStereoNow != _input._lastUpdateStereoState);
#endif
_input._lastUpdateStereoState = isStereoNow;
bool hasColorAttribute = _input._hasColorAttribute;
if (_input._invalidFormat) {
InputStageState::ActivationCache newActivation;
// Assign the vertex format required
auto format = acquire(_input._format);
if (format) {
bool hasColorAttribute{ false };
_input._attribBindingBuffers.reset();
const auto& attributes = format->getAttributes();
@ -186,12 +189,12 @@ void GLBackend::updateInput() {
uint8_t locationCount = attrib._element.getLocationCount();
GLenum type = gl::ELEMENT_TYPE_TO_GL[attrib._element.getType()];
GLuint offset = (GLuint)attrib._offset;;
GLuint offset = (GLuint)attrib._offset;
GLboolean isNormalized = attrib._element.isNormalized();
GLenum perLocationSize = attrib._element.getLocationSize();
hasColorAttribute = hasColorAttribute || (slot == Stream::COLOR);
hasColorAttribute |= slot == Stream::COLOR;
for (GLuint locNum = 0; locNum < locationCount; ++locNum) {
GLuint attriNum = (GLuint)(slot + locNum);
@ -224,14 +227,11 @@ void GLBackend::updateInput() {
#endif
}
if (_input._hadColorAttribute && !hasColorAttribute) {
// The previous input stage had a color attribute but this one doesn't so reset
// color to pure white.
const auto white = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
glVertexAttrib4fv(Stream::COLOR, &white.r);
_input._colorAttribute = white;
if (!hasColorAttribute && _input._hadColorAttribute) {
// The previous input stage had a color attribute but this one doesn't, so reset the color to pure white.
_input._colorAttribute = glm::vec4(1.0f);
glVertexAttrib4fv(Stream::COLOR, &_input._colorAttribute.r);
}
_input._hadColorAttribute = hasColorAttribute;
}
// Manage Activation what was and what is expected now
@ -253,6 +253,9 @@ void GLBackend::updateInput() {
_stats._ISNumFormatChanges++;
}
_input._hadColorAttribute = hasColorAttribute;
_input._hasColorAttribute = false;
if (_input._invalidBuffers.any()) {
auto vbo = _input._bufferVBOs.data();
auto offset = _input._bufferOffsets.data();
@ -276,4 +279,3 @@ void GLBackend::updateInput() {
(void)CHECK_GL_ERROR();
}
}

View file

@ -33,6 +33,8 @@ void GL41Backend::updateInput() {
#endif
_input._lastUpdateStereoState = isStereoNow;
bool hasColorAttribute = _input._hasColorAttribute;
if (_input._invalidFormat || _input._invalidBuffers.any()) {
auto format = acquire(_input._format);
@ -71,8 +73,6 @@ void GL41Backend::updateInput() {
// now we need to bind the buffers and assign the attrib pointers
if (format) {
bool hasColorAttribute{ false };
const auto& buffers = _input._buffers;
const auto& offsets = _input._bufferOffsets;
const auto& strides = _input._bufferStrides;
@ -110,7 +110,7 @@ void GL41Backend::updateInput() {
uintptr_t pointer = (uintptr_t)(attrib._offset + offsets[bufferNum]);
GLboolean isNormalized = attrib._element.isNormalized();
hasColorAttribute = hasColorAttribute || (slot == Stream::COLOR);
hasColorAttribute |= slot == Stream::COLOR;
for (size_t locNum = 0; locNum < locationCount; ++locNum) {
if (attrib._element.isInteger()) {
@ -132,17 +132,16 @@ void GL41Backend::updateInput() {
}
}
if (_input._hadColorAttribute && !hasColorAttribute) {
// The previous input stage had a color attribute but this one doesn't so reset
// color to pure white.
const auto white = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
glVertexAttrib4fv(Stream::COLOR, &white.r);
_input._colorAttribute = white;
if (!hasColorAttribute && _input._hadColorAttribute) {
// The previous input stage had a color attribute but this one doesn't, so reset the color to pure white.
_input._colorAttribute = glm::vec4(1.0f);
glVertexAttrib4fv(Stream::COLOR, &_input._colorAttribute.r);
}
_input._hadColorAttribute = hasColorAttribute;
}
// everything format related should be in sync now
_input._invalidFormat = false;
}
}
_input._hadColorAttribute = hasColorAttribute;
_input._hasColorAttribute = false;
}

View file

@ -35,14 +35,14 @@ void GL45Backend::updateInput() {
#endif
_input._lastUpdateStereoState = isStereoNow;
bool hasColorAttribute = _input._hasColorAttribute;
if (_input._invalidFormat) {
InputStageState::ActivationCache newActivation;
// Assign the vertex format required
auto format = acquire(_input._format);
if (format) {
bool hasColorAttribute{ false };
_input._attribBindingBuffers.reset();
const auto& attributes = format->getAttributes();
@ -61,12 +61,12 @@ void GL45Backend::updateInput() {
uint8_t locationCount = attrib._element.getLocationCount();
GLenum type = gl::ELEMENT_TYPE_TO_GL[attrib._element.getType()];
GLuint offset = (GLuint)attrib._offset;;
GLuint offset = (GLuint)attrib._offset;
GLboolean isNormalized = attrib._element.isNormalized();
GLenum perLocationSize = attrib._element.getLocationSize();
hasColorAttribute = hasColorAttribute || (slot == Stream::COLOR);
hasColorAttribute |= slot == Stream::COLOR;
for (GLuint locNum = 0; locNum < locationCount; ++locNum) {
GLuint attriNum = (GLuint)(slot + locNum);
@ -99,14 +99,11 @@ void GL45Backend::updateInput() {
#endif
}
if (_input._hadColorAttribute && !hasColorAttribute) {
// The previous input stage had a color attribute but this one doesn't so reset
// color to pure white.
const auto white = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
glVertexAttrib4fv(Stream::COLOR, &white.r);
_input._colorAttribute = white;
if (!hasColorAttribute && _input._hadColorAttribute) {
// The previous input stage had a color attribute but this one doesn't, so reset the color to pure white.
_input._colorAttribute = glm::vec4(1.0f);
glVertexAttrib4fv(Stream::COLOR, &_input._colorAttribute.r);
}
_input._hadColorAttribute = hasColorAttribute;
}
// Manage Activation what was and what is expected now
@ -128,6 +125,9 @@ void GL45Backend::updateInput() {
_stats._ISNumFormatChanges++;
}
_input._hadColorAttribute = hasColorAttribute;
_input._hasColorAttribute = false;
if (_input._invalidBuffers.any()) {
auto vbo = _input._bufferVBOs.data();
auto offset = _input._bufferOffsets.data();

View file

@ -579,11 +579,11 @@ public:
ExternalUpdates getUpdates() const;
// Serialize a texture into a KTX file
static ktx::KTXUniquePointer serialize(const Texture& texture);
static ktx::KTXUniquePointer serialize(const Texture& texture, const glm::ivec2& originalSize);
static TexturePointer build(const ktx::KTXDescriptor& descriptor);
static TexturePointer unserialize(const std::string& ktxFile);
static TexturePointer unserialize(const cache::FilePointer& cacheEntry, const std::string& source = std::string());
static std::pair<TexturePointer, glm::ivec2> build(const ktx::KTXDescriptor& descriptor);
static std::pair<TexturePointer, glm::ivec2> unserialize(const std::string& ktxFile);
static std::pair<TexturePointer, glm::ivec2> unserialize(const cache::FilePointer& cacheEntry, const std::string& source = std::string());
static bool evalKTXFormat(const Element& mipFormat, const Element& texelFormat, ktx::Header& header);
static bool evalTextureFormat(const ktx::Header& header, Element& mipFormat, Element& texelFormat);

View file

@ -13,6 +13,7 @@
#include "Texture.h"
#include <QtCore/QByteArray>
#include <glm/gtc/type_ptr.hpp>
#include <ktx/KTX.h>
@ -30,15 +31,16 @@ struct GPUKTXPayload {
using Version = uint8;
static const std::string KEY;
static const Version CURRENT_VERSION { 1 };
static const Version CURRENT_VERSION { 2 };
static const size_t PADDING { 2 };
static const size_t SIZE { sizeof(Version) + sizeof(Sampler::Desc) + sizeof(uint32) + sizeof(TextureUsageType) + PADDING };
static_assert(GPUKTXPayload::SIZE == 36, "Packing size may differ between platforms");
static const size_t SIZE { sizeof(Version) + sizeof(Sampler::Desc) + sizeof(uint32) + sizeof(TextureUsageType) + sizeof(glm::ivec2) + PADDING };
static_assert(GPUKTXPayload::SIZE == 44, "Packing size may differ between platforms");
static_assert(GPUKTXPayload::SIZE % 4 == 0, "GPUKTXPayload is not 4 bytes aligned");
Sampler::Desc _samplerDesc;
Texture::Usage _usage;
TextureUsageType _usageType;
glm::ivec2 _originalSize { 0, 0 };
Byte* serialize(Byte* data) const {
*(Version*)data = CURRENT_VERSION;
@ -56,26 +58,22 @@ struct GPUKTXPayload {
memcpy(data, &_usageType, sizeof(TextureUsageType));
data += sizeof(TextureUsageType);
memcpy(data, glm::value_ptr(_originalSize), sizeof(glm::ivec2));
data += sizeof(glm::ivec2);
return data + PADDING;
}
bool unserialize(const Byte* data, size_t size) {
if (size != SIZE) {
Version version = *(const Version*)data;
data += sizeof(Version);
if (version > CURRENT_VERSION) {
// If we try to load a version that we don't know how to parse,
// it will render incorrectly
return false;
}
Version version = *(const Version*)data;
if (version != CURRENT_VERSION) {
glm::vec4 borderColor(1.0f);
if (memcmp(&borderColor, data, sizeof(glm::vec4)) == 0) {
memcpy(this, data, sizeof(GPUKTXPayload));
return true;
} else {
return false;
}
}
data += sizeof(Version);
memcpy(&_samplerDesc, data, sizeof(Sampler::Desc));
data += sizeof(Sampler::Desc);
@ -87,6 +85,13 @@ struct GPUKTXPayload {
data += sizeof(uint32);
memcpy(&_usageType, data, sizeof(TextureUsageType));
data += sizeof(TextureUsageType);
if (version >= 2) {
memcpy(&_originalSize, data, sizeof(glm::ivec2));
data += sizeof(glm::ivec2);
}
return true;
}
@ -382,7 +387,7 @@ void Texture::setKtxBacking(const cache::FilePointer& cacheEntry) {
}
ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
ktx::KTXUniquePointer Texture::serialize(const Texture& texture, const glm::ivec2& originalSize) {
ktx::Header header;
// From texture format to ktx format description
@ -459,6 +464,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
gpuKeyval._samplerDesc = texture.getSampler().getDesc();
gpuKeyval._usage = texture.getUsage();
gpuKeyval._usageType = texture.getUsageType();
gpuKeyval._originalSize = originalSize;
Byte keyvalPayload[GPUKTXPayload::SIZE];
gpuKeyval.serialize(keyvalPayload);
@ -514,19 +520,19 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
return ktxBuffer;
}
TexturePointer Texture::build(const ktx::KTXDescriptor& descriptor) {
std::pair<TexturePointer, glm::ivec2> Texture::build(const ktx::KTXDescriptor& descriptor) {
Format mipFormat = Format::COLOR_BGRA_32;
Format texelFormat = Format::COLOR_SRGBA_32;
const auto& header = descriptor.header;
if (!Texture::evalTextureFormat(header, mipFormat, texelFormat)) {
return nullptr;
return { nullptr, { 0, 0 } };
}
// Find Texture Type based on dimensions
Type type = TEX_1D;
if (header.pixelWidth == 0) {
return nullptr;
return { nullptr, { 0, 0 } };
} else if (header.pixelHeight == 0) {
type = TEX_1D;
} else if (header.pixelDepth == 0) {
@ -569,39 +575,39 @@ TexturePointer Texture::build(const ktx::KTXDescriptor& descriptor) {
texture->overrideIrradiance(std::make_shared<SphericalHarmonics>(irradianceKtxKeyValue._irradianceSH));
}
return texture;
return { texture, gpuktxKeyValue._originalSize };
}
TexturePointer Texture::unserialize(const cache::FilePointer& cacheEntry, const std::string& source) {
std::pair<TexturePointer, glm::ivec2> Texture::unserialize(const cache::FilePointer& cacheEntry, const std::string& source) {
std::unique_ptr<ktx::KTX> ktxPointer = ktx::KTX::create(std::make_shared<storage::FileStorage>(cacheEntry->getFilepath().c_str()));
if (!ktxPointer) {
return nullptr;
return { nullptr, { 0, 0 } };
}
auto texture = build(ktxPointer->toDescriptor());
if (texture) {
texture->setKtxBacking(cacheEntry);
if (texture->source().empty()) {
texture->setSource(source);
auto textureAndSize = build(ktxPointer->toDescriptor());
if (textureAndSize.first) {
textureAndSize.first->setKtxBacking(cacheEntry);
if (textureAndSize.first->source().empty()) {
textureAndSize.first->setSource(source);
}
}
return texture;
return { textureAndSize.first, textureAndSize.second };
}
TexturePointer Texture::unserialize(const std::string& ktxfile) {
std::pair<TexturePointer, glm::ivec2> Texture::unserialize(const std::string& ktxfile) {
std::unique_ptr<ktx::KTX> ktxPointer = ktx::KTX::create(std::make_shared<storage::FileStorage>(ktxfile.c_str()));
if (!ktxPointer) {
return nullptr;
return { nullptr, { 0, 0 } };
}
auto texture = build(ktxPointer->toDescriptor());
if (texture) {
texture->setKtxBacking(ktxfile);
texture->setSource(ktxfile);
auto textureAndSize = build(ktxPointer->toDescriptor());
if (textureAndSize.first) {
textureAndSize.first->setKtxBacking(ktxfile);
textureAndSize.first->setSource(ktxfile);
}
return texture;
return { textureAndSize.first, textureAndSize.second };
}
bool Texture::evalKTXFormat(const Element& mipFormat, const Element& texelFormat, ktx::Header& header) {

View file

@ -338,9 +338,9 @@ void mapToRedChannel(Image& image, ColorChannel sourceChannel) {
}
}
gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::string& filename, ColorChannel sourceChannel,
int maxNumPixels, TextureUsage::Type textureType,
bool compress, BackendTarget target, const std::atomic<bool>& abortProcessing) {
std::pair<gpu::TexturePointer, glm::ivec2> processImage(std::shared_ptr<QIODevice> content, const std::string& filename, ColorChannel sourceChannel,
int maxNumPixels, TextureUsage::Type textureType,
bool compress, BackendTarget target, const std::atomic<bool>& abortProcessing) {
Image image = processRawImageData(*content.get(), filename);
// Texture content can take up a lot of memory. Here we release our ownership of that content
@ -354,7 +354,7 @@ gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::
if (imageWidth == 0 || imageHeight == 0 || image.getFormat() == Image::Format_Invalid) {
QString reason(image.getFormat() == Image::Format_Invalid ? "(Invalid Format)" : "(Size is invalid)");
qCWarning(imagelogging) << "Failed to load:" << qPrintable(reason);
return nullptr;
return { nullptr, { imageWidth, imageHeight } };
}
// Validate the image is less than _maxNumPixels, and downscale if necessary
@ -378,7 +378,7 @@ gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::
auto loader = TextureUsage::getTextureLoaderForType(textureType);
auto texture = loader(std::move(image), filename, compress, target, abortProcessing);
return texture;
return { texture, { imageWidth, imageHeight } };
}
Image processSourceImage(Image&& srcImage, bool cubemap, BackendTarget target) {

View file

@ -121,9 +121,9 @@ gpu::TexturePointer processCubeTextureColorFromImage(Image&& srcImage, const std
const QStringList getSupportedFormats();
gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::string& url, ColorChannel sourceChannel,
int maxNumPixels, TextureUsage::Type textureType,
bool compress, gpu::BackendTarget target, const std::atomic<bool>& abortProcessing = false);
std::pair<gpu::TexturePointer, glm::ivec2> processImage(std::shared_ptr<QIODevice> content, const std::string& url, ColorChannel sourceChannel,
int maxNumPixels, TextureUsage::Type textureType,
bool compress, gpu::BackendTarget target, const std::atomic<bool>& abortProcessing = false);
void convertToTextureWithMips(gpu::Texture* texture, Image&& image, gpu::BackendTarget target, const std::atomic<bool>& abortProcessing = false, int face = -1);
void convertToTexture(gpu::Texture* texture, Image&& image, gpu::BackendTarget target, const std::atomic<bool>& abortProcessing = false, int face = -1, int mipLevel = 0);

View file

@ -199,7 +199,7 @@ void TouchscreenVirtualPadDevice::InputDevice::update(float deltaTime, const con
_axisStateMap.clear();
}
bool TouchscreenVirtualPadDevice::InputDevice::triggerHapticPulse(float strength, float duration, controller::Hand hand) {
bool TouchscreenVirtualPadDevice::InputDevice::triggerHapticPulse(float strength, float duration, uint16_t index) {
auto& virtualPadManager = VirtualPad::Manager::instance();
virtualPadManager.requestHapticFeedback((int) duration);
return true;

View file

@ -71,7 +71,7 @@ protected:
virtual controller::Input::NamedVector getAvailableInputs() const override;
virtual QString getDefaultMappingConfig() const override;
virtual bool triggerHapticPulse(float strength, float duration, controller::Hand hand) override;
virtual bool triggerHapticPulse(float strength, float duration, uint16_t index) override;
virtual void update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override;
virtual void focusOutEvent() override;

View file

@ -19,7 +19,7 @@ using FilePointer = cache::FilePointer;
// Whenever a change is made to the serialized format for the KTX cache that isn't backward compatible,
// this value should be incremented. This will force the KTX cache to be wiped
const int KTXCache::CURRENT_VERSION = 0x01;
const int KTXCache::CURRENT_VERSION = 0x02;
const int KTXCache::INVALID_VERSION = 0x00;
const char* KTXCache::SETTING_VERSION_NAME = "hifi.ktx.cache_version";

View file

@ -266,23 +266,24 @@ NetworkTexturePointer TextureCache::getTexture(const QUrl& url, image::TextureUs
return ResourceCache::getResource(modifiedUrl, QUrl(), &extra, std::hash<TextureExtra>()(extra)).staticCast<NetworkTexture>();
}
gpu::TexturePointer TextureCache::getTextureByHash(const std::string& hash) {
std::weak_ptr<gpu::Texture> weakPointer;
std::pair<gpu::TexturePointer, glm::ivec2> TextureCache::getTextureByHash(const std::string& hash) {
std::pair<gpu::TextureWeakPointer, glm::ivec2> weakPointer;
{
std::unique_lock<std::mutex> lock(_texturesByHashesMutex);
weakPointer = _texturesByHashes[hash];
}
return weakPointer.lock();
return { weakPointer.first.lock(), weakPointer.second };
}
gpu::TexturePointer TextureCache::cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture) {
gpu::TexturePointer result;
std::pair<gpu::TexturePointer, glm::ivec2> TextureCache::cacheTextureByHash(const std::string& hash, const std::pair<gpu::TexturePointer, glm::ivec2>& textureAndSize) {
std::pair<gpu::TexturePointer, glm::ivec2> result;
{
std::unique_lock<std::mutex> lock(_texturesByHashesMutex);
result = _texturesByHashes[hash].lock();
if (!result) {
_texturesByHashes[hash] = texture;
result = texture;
auto& value = _texturesByHashes[hash];
result = { value.first.lock(), value.second };
if (!result.first) {
_texturesByHashes[hash] = textureAndSize;
result = textureAndSize;
}
}
return result;
@ -616,7 +617,7 @@ void NetworkTexture::makeLocalRequest() {
ktxDescriptor = std::make_shared<ktx::KTXDescriptor>(ktxFile->toDescriptor());
}
gpu::TexturePointer texture;
std::pair<gpu::TexturePointer, glm::ivec2> textureAndSize;
if (ktxDescriptor) {
std::string hash;
// Create bare ktx in memory
@ -634,18 +635,18 @@ void NetworkTexture::makeLocalRequest() {
}
auto textureCache = DependencyManager::get<TextureCache>();
texture = textureCache->getTextureByHash(hash);
if (!texture) {
texture = gpu::Texture::build(*ktxDescriptor);
if (texture) {
texture->setKtxBacking(path.toStdString());
texture->setSource(path.toStdString());
texture = textureCache->cacheTextureByHash(hash, texture);
textureAndSize = textureCache->getTextureByHash(hash);
if (!textureAndSize.first) {
textureAndSize = gpu::Texture::build(*ktxDescriptor);
if (textureAndSize.first) {
textureAndSize.first->setKtxBacking(path.toStdString());
textureAndSize.first->setSource(path.toStdString());
textureAndSize = textureCache->cacheTextureByHash(hash, textureAndSize);
}
}
}
if (!texture) {
if (!textureAndSize.first) {
qCDebug(networking).noquote() << "Failed load local KTX from" << path;
QMetaObject::invokeMethod(this, "setImage",
Q_ARG(gpu::TexturePointer, nullptr),
@ -655,11 +656,11 @@ void NetworkTexture::makeLocalRequest() {
}
_ktxResourceState = PENDING_MIP_REQUEST;
_lowestKnownPopulatedMip = texture->minAvailableMipLevel();
_lowestKnownPopulatedMip = textureAndSize.first->minAvailableMipLevel();
QMetaObject::invokeMethod(this, "setImage",
Q_ARG(gpu::TexturePointer, texture),
Q_ARG(int, texture->getWidth()),
Q_ARG(int, texture->getHeight()));
Q_ARG(gpu::TexturePointer, textureAndSize.first),
Q_ARG(int, textureAndSize.second.x),
Q_ARG(int, textureAndSize.second.y));
}
@ -968,22 +969,22 @@ void NetworkTexture::handleFinishedInitialLoad() {
auto textureCache = DependencyManager::get<TextureCache>();
gpu::TexturePointer texture = textureCache->getTextureByHash(hash);
std::pair<gpu::TexturePointer, glm::ivec2> textureAndSize = textureCache->getTextureByHash(hash);
if (!texture) {
if (!textureAndSize.first) {
auto ktxFile = textureCache->_ktxCache->getFile(hash);
if (ktxFile) {
texture = gpu::Texture::unserialize(ktxFile);
if (texture) {
texture = textureCache->cacheTextureByHash(hash, texture);
if (texture->source().empty()) {
texture->setSource(url.toString().toStdString());
textureAndSize = gpu::Texture::unserialize(ktxFile);
if (textureAndSize.first) {
textureAndSize = textureCache->cacheTextureByHash(hash, textureAndSize);
if (textureAndSize.first->source().empty()) {
textureAndSize.first->setSource(url.toString().toStdString());
}
}
}
}
if (!texture) {
if (!textureAndSize.first) {
auto memKtx = ktx::KTX::createBare(*header, keyValues);
if (!memKtx) {
qWarning() << " Ktx could not be created, bailing";
@ -1010,9 +1011,9 @@ void NetworkTexture::handleFinishedInitialLoad() {
auto newKtxDescriptor = memKtx->toDescriptor();
texture = gpu::Texture::build(newKtxDescriptor);
texture->setKtxBacking(file);
texture->setSource(filename);
textureAndSize = gpu::Texture::build(newKtxDescriptor);
textureAndSize.first->setKtxBacking(file);
textureAndSize.first->setSource(filename);
auto& images = originalKtxDescriptor->images;
size_t imageSizeRemaining = ktxHighMipData.size();
@ -1025,7 +1026,7 @@ void NetworkTexture::handleFinishedInitialLoad() {
break;
}
ktxData -= image._imageSize;
texture->assignStoredMip(static_cast<gpu::uint16>(level), image._imageSize, ktxData);
textureAndSize.first->assignStoredMip(static_cast<gpu::uint16>(level), image._imageSize, ktxData);
ktxData -= ktx::IMAGE_SIZE_WIDTH;
imageSizeRemaining -= (image._imageSize + ktx::IMAGE_SIZE_WIDTH);
}
@ -1033,13 +1034,13 @@ void NetworkTexture::handleFinishedInitialLoad() {
// We replace the texture with the one stored in the cache. This deals with the possible race condition of two different
// images with the same hash being loaded concurrently. Only one of them will make it into the cache by hash first and will
// be the winner
texture = textureCache->cacheTextureByHash(filename, texture);
textureAndSize = textureCache->cacheTextureByHash(filename, textureAndSize);
}
QMetaObject::invokeMethod(resource.data(), "setImage",
Q_ARG(gpu::TexturePointer, texture),
Q_ARG(int, texture->getWidth()),
Q_ARG(int, texture->getHeight()));
Q_ARG(gpu::TexturePointer, textureAndSize.first),
Q_ARG(int, textureAndSize.second.x),
Q_ARG(int, textureAndSize.second.y));
QMetaObject::invokeMethod(resource.data(), "startRequestForNextMipLevel");
});
@ -1229,15 +1230,15 @@ void ImageReader::read() {
auto textureCache = DependencyManager::get<TextureCache>();
if (textureCache) {
// If we already have a live texture with the same hash, use it
auto texture = textureCache->getTextureByHash(hash);
auto textureAndSize = textureCache->getTextureByHash(hash);
// If there is no live texture, check if there's an existing KTX file
if (!texture) {
if (!textureAndSize.first) {
auto ktxFile = textureCache->_ktxCache->getFile(hash);
if (ktxFile) {
texture = gpu::Texture::unserialize(ktxFile, _url.toString().toStdString());
if (texture) {
texture = textureCache->cacheTextureByHash(hash, texture);
textureAndSize = gpu::Texture::unserialize(ktxFile, _url.toString().toStdString());
if (textureAndSize.first) {
textureAndSize = textureCache->cacheTextureByHash(hash, textureAndSize);
} else {
qCWarning(materialnetworking) << "Invalid cached KTX " << _url << " under hash " << hash.c_str() << ", recreating...";
}
@ -1246,17 +1247,17 @@ void ImageReader::read() {
// If we found the texture either because it's in use or via KTX deserialization,
// set the image and return immediately.
if (texture) {
if (textureAndSize.first) {
QMetaObject::invokeMethod(resource.data(), "setImage",
Q_ARG(gpu::TexturePointer, texture),
Q_ARG(int, texture->getWidth()),
Q_ARG(int, texture->getHeight()));
Q_ARG(gpu::TexturePointer, textureAndSize.first),
Q_ARG(int, textureAndSize.second.x),
Q_ARG(int, textureAndSize.second.y));
return;
}
}
// Proccess new texture
gpu::TexturePointer texture;
std::pair<gpu::TexturePointer, ivec2> textureAndSize;
{
PROFILE_RANGE_EX(resource_parse_image_raw, __FUNCTION__, 0xffff0000, 0);
@ -1269,23 +1270,23 @@ void ImageReader::read() {
constexpr bool shouldCompress = false;
#endif
auto target = getBackendTarget();
texture = image::processImage(std::move(buffer), _url.toString().toStdString(), _sourceChannel, _maxNumPixels, networkTexture->getTextureType(), shouldCompress, target);
textureAndSize = image::processImage(std::move(buffer), _url.toString().toStdString(), _sourceChannel, _maxNumPixels, networkTexture->getTextureType(), shouldCompress, target);
if (!texture) {
if (!textureAndSize.first) {
QMetaObject::invokeMethod(resource.data(), "setImage",
Q_ARG(gpu::TexturePointer, texture),
Q_ARG(gpu::TexturePointer, textureAndSize.first),
Q_ARG(int, 0),
Q_ARG(int, 0));
return;
}
texture->setSourceHash(hash);
texture->setFallbackTexture(networkTexture->getFallbackTexture());
textureAndSize.first->setSourceHash(hash);
textureAndSize.first->setFallbackTexture(networkTexture->getFallbackTexture());
}
// Save the image into a KTXFile
if (texture && textureCache) {
auto memKtx = gpu::Texture::serialize(*texture);
if (textureAndSize.first && textureCache) {
auto memKtx = gpu::Texture::serialize(*textureAndSize.first, textureAndSize.second);
// Move the texture into a memory mapped file
if (memKtx) {
@ -1294,20 +1295,20 @@ void ImageReader::read() {
auto& ktxCache = textureCache->_ktxCache;
auto file = ktxCache->writeFile(data, KTXCache::Metadata(hash, length));
if (file) {
texture->setKtxBacking(file);
textureAndSize.first->setKtxBacking(file);
}
}
// We replace the texture with the one stored in the cache. This deals with the possible race condition of two different
// images with the same hash being loaded concurrently. Only one of them will make it into the cache by hash first and will
// be the winner
texture = textureCache->cacheTextureByHash(hash, texture);
textureAndSize = textureCache->cacheTextureByHash(hash, textureAndSize);
}
QMetaObject::invokeMethod(resource.data(), "setImage",
Q_ARG(gpu::TexturePointer, texture),
Q_ARG(int, texture->getWidth()),
Q_ARG(int, texture->getHeight()));
Q_ARG(gpu::TexturePointer, textureAndSize.first),
Q_ARG(int, textureAndSize.second.x),
Q_ARG(int, textureAndSize.second.y));
}
NetworkTexturePointer TextureCache::getResourceTexture(const QUrl& resourceTextureUrl) {

View file

@ -183,8 +183,8 @@ public:
const QByteArray& content = QByteArray(), int maxNumPixels = ABSOLUTE_MAX_TEXTURE_NUM_PIXELS,
image::ColorChannel sourceChannel = image::ColorChannel::NONE);
gpu::TexturePointer getTextureByHash(const std::string& hash);
gpu::TexturePointer cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture);
std::pair<gpu::TexturePointer, glm::ivec2> getTextureByHash(const std::string& hash);
std::pair<gpu::TexturePointer, glm::ivec2> cacheTextureByHash(const std::string& hash, const std::pair<gpu::TexturePointer, glm::ivec2>& textureAndSize);
NetworkTexturePointer getResourceTexture(const QUrl& resourceTextureUrl);
const gpu::FramebufferPointer& getHmdPreviewFramebuffer(int width, int height);
@ -226,7 +226,7 @@ private:
std::shared_ptr<cache::FileCache> _ktxCache { std::make_shared<KTXCache>(KTX_DIRNAME, KTX_EXT) };
// Map from image hashes to texture weak pointers
std::unordered_map<std::string, std::weak_ptr<gpu::Texture>> _texturesByHashes;
std::unordered_map<std::string, std::pair<std::weak_ptr<gpu::Texture>, glm::ivec2>> _texturesByHashes;
std::mutex _texturesByHashesMutex;
gpu::TexturePointer _permutationNormalTexture;

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2014-09-10.
// Copyright 2014 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -35,11 +36,11 @@ const QString REDIRECT_HIFI_ADDRESS = NetworkingConstants::REDIRECT_HIFI_ADDRESS
const QString ADDRESS_MANAGER_SETTINGS_GROUP = "AddressManager";
const QString SETTINGS_CURRENT_ADDRESS_KEY = "address";
const QString DEFAULT_VIRCADIA_ADDRESS = (!BuildInfo::INITIAL_STARTUP_LOCATION.isEmpty())
? BuildInfo::INITIAL_STARTUP_LOCATION
const QString DEFAULT_VIRCADIA_ADDRESS = (!BuildInfo::PRELOADED_STARTUP_LOCATION.isEmpty())
? BuildInfo::PRELOADED_STARTUP_LOCATION
: NetworkingConstants::DEFAULT_VIRCADIA_ADDRESS;
const QString DEFAULT_HOME_ADDRESS = (!BuildInfo::INITIAL_STARTUP_LOCATION.isEmpty())
? BuildInfo::INITIAL_STARTUP_LOCATION
const QString DEFAULT_HOME_ADDRESS = (!BuildInfo::PRELOADED_STARTUP_LOCATION.isEmpty())
? BuildInfo::PRELOADED_STARTUP_LOCATION
: NetworkingConstants::DEFAULT_VIRCADIA_ADDRESS;
Setting::Handle<QUrl> currentAddressHandle(QStringList() << ADDRESS_MANAGER_SETTINGS_GROUP << "address", DEFAULT_VIRCADIA_ADDRESS);
@ -414,6 +415,8 @@ void AddressManager::handleLookupString(const QString& lookupString, bool fromSu
QString sanitizedString = lookupString.trimmed();
if (!sanitizedString.isEmpty()) {
resetConfirmConnectWithoutAvatarEntities();
// make this a valid hifi URL and handle it off to handleUrl
handleUrl(sanitizedString, fromSuggestions ? Suggestions : UserInput);
}
@ -873,6 +876,11 @@ bool AddressManager::setDomainInfo(const QUrl& domainURL, LookupTrigger trigger)
return emitHostChanged;
}
void AddressManager::goToEntry(LookupTrigger trigger) {
resetConfirmConnectWithoutAvatarEntities();
handleUrl(DEFAULT_VIRCADIA_ADDRESS, trigger);
}
void AddressManager::goToUser(const QString& username, bool shouldMatchOrientation) {
QString formattedUsername = QUrl::toPercentEncoding(username);
@ -889,6 +897,11 @@ void AddressManager::goToUser(const QString& username, bool shouldMatchOrientati
QByteArray(), nullptr, requestParams);
}
void AddressManager::goToLastAddress() {
resetConfirmConnectWithoutAvatarEntities();
handleUrl(_lastVisitedURL, LookupTrigger::AttemptedRefresh);
}
bool AddressManager::canGoBack() const {
return (_backStack.size() > 0);
}
@ -1023,3 +1036,10 @@ QString AddressManager::getPlaceName() const {
}
return QString();
}
void AddressManager::resetConfirmConnectWithoutAvatarEntities() {
DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
if (!domainHandler.isConnected()) {
domainHandler.resetConfirmConnectWithoutAvatarEntities();
}
}

View file

@ -301,9 +301,7 @@ public slots:
* @param {location.LookupTrigger} trigger=StartupFromSettings - The reason for the function call. Helps ensure that user's
* location history is correctly maintained.
*/
void goToEntry(LookupTrigger trigger = LookupTrigger::StartupFromSettings) {
handleUrl(DEFAULT_VIRCADIA_ADDRESS, trigger);
}
void goToEntry(LookupTrigger trigger = LookupTrigger::StartupFromSettings);
/**jsdoc
* Takes you to the specified user's location.
@ -318,7 +316,7 @@ public slots:
* Takes you to the last address tried. This will be the last URL tried from <code>location.handleLookupString</code>.
* @function location.goToLastAddress
*/
void goToLastAddress() { handleUrl(_lastVisitedURL, LookupTrigger::AttemptedRefresh); }
void goToLastAddress();
/**jsdoc
* Checks if going back to the previous location is possible.
@ -527,6 +525,8 @@ private:
void addCurrentAddressToHistory(LookupTrigger trigger);
void resetConfirmConnectWithoutAvatarEntities();
QUrl _domainURL;
QUrl _lastVisitedURL;

View file

@ -126,6 +126,8 @@ void DomainHandler::hardReset(QString reason) {
emit resetting();
softReset(reason);
_haveAskedConnectWithoutAvatarEntities = false;
_canConnectWithoutAvatarEntities = false;
_isInErrorState = false;
emit redirectErrorStateChanged(_isInErrorState);
@ -364,10 +366,14 @@ void DomainHandler::setIsConnected(bool isConnected) {
_lastDomainConnectionError = -1;
emit connectedToDomain(_domainURL);
// FIXME: Reinstate the requestDomainSettings() call here in version 2021.2.0 instead of having it in
// NodeList::processDomainServerList().
/*
if (_domainURL.scheme() == URL_SCHEME_HIFI && !_domainURL.host().isEmpty()) {
// we've connected to new domain - time to ask it for global settings
requestDomainSettings();
}
*/
} else {
emit disconnectedFromDomain();
@ -375,6 +381,24 @@ void DomainHandler::setIsConnected(bool isConnected) {
}
}
void DomainHandler::setCanConnectWithoutAvatarEntities(bool canConnect) {
_canConnectWithoutAvatarEntities = canConnect;
_haveAskedConnectWithoutAvatarEntities = true;
}
bool DomainHandler::canConnectWithoutAvatarEntities() {
if (!_canConnectWithoutAvatarEntities && !_haveAskedConnectWithoutAvatarEntities) {
if (_isConnected) {
// Already connected so don't ask. (Permission removed from user while in the domain.)
setCanConnectWithoutAvatarEntities(true);
} else {
// Ask whether to connect to the domain.
emit confirmConnectWithoutAvatarEntities();
}
}
return _canConnectWithoutAvatarEntities;
}
void DomainHandler::connectedToServerless(std::map<QString, QString> namedPaths) {
_namedPaths = namedPaths;
setIsConnected(true);

View file

@ -98,6 +98,7 @@ public:
Node::LocalID getLocalID() const { return _localID; }
void setLocalID(Node::LocalID localID) { _localID = localID; }
QString getScheme() const { return _domainURL.scheme(); }
QString getHostname() const { return _domainURL.host(); }
QUrl getErrorDomainURL(){ return _errorDomainURL; }
@ -133,6 +134,9 @@ public:
bool isConnected() const { return _isConnected; }
void setIsConnected(bool isConnected);
void setCanConnectWithoutAvatarEntities(bool canConnect);
bool canConnectWithoutAvatarEntities();
bool isServerless() const { return _domainURL.scheme() != URL_SCHEME_HIFI; }
bool getInterstitialModeEnabled() const;
void setInterstitialModeEnabled(bool enableInterstitialMode);
@ -159,6 +163,10 @@ public:
bool checkInPacketTimeout();
void clearPendingCheckins() { _checkInPacketsSinceLastReply = 0; }
void resetConfirmConnectWithoutAvatarEntities() {
_haveAskedConnectWithoutAvatarEntities = false;
}
/**jsdoc
* <p>The reasons that you may be refused connection to a domain are defined by numeric values:</p>
* <table>
@ -252,6 +260,7 @@ signals:
void completedSocketDiscovery();
void resetting();
void confirmConnectWithoutAvatarEntities();
void connectedToDomain(QUrl domainURL);
void disconnectedFromDomain();
@ -287,6 +296,8 @@ private:
HifiSockAddr _iceServerSockAddr;
NetworkPeer _icePeer;
bool _isConnected { false };
bool _haveAskedConnectWithoutAvatarEntities { false };
bool _canConnectWithoutAvatarEntities { false };
bool _isInErrorState { false };
QJsonObject _settingsObject;
QString _pendingPath;

View file

@ -17,6 +17,9 @@
#include <SettingHandle.h>
#include <SettingManager.h>
#include <DependencyManager.h>
#include <QFile>
#include <QCryptographicHash>
#include <QDirIterator>
#ifdef Q_OS_WIN
#include <Windows.h>
@ -36,8 +39,80 @@ QUuid FingerprintUtils::_machineFingerprint { QUuid() };
QString FingerprintUtils::getMachineFingerprintString() {
QString uuidString;
#ifdef Q_OS_LINUX
// sadly need to be root to get smbios guid from linux, so
// for now lets do nothing.
// As per the documentation:
// https://man7.org/linux/man-pages/man5/machine-id.5.html
//
// 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.
qCWarning(networking) << "Failed to open /etc/machine-id";
QDir netDevicesDir("/sys/class/net");
QFileInfoList netDevicesInfo = netDevicesDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
if (netDevicesInfo.empty()) {
// Let getMachineFingerprint handle this contingency
qCWarning(networking) << "Failed to find any hardware networking devices";
return "";
}
for(auto& fileInfo : netDevicesInfo) {
if (fileInfo.isSymLink() && fileInfo.symLinkTarget().contains("virtual")) {
// symlink points to something like:
// ../../devices/virtual/net/lo
// these are not real devices and have random IDs, so we
// don't care about them.
continue;
}
QFile addressFile(fileInfo.filePath() + "/address");
if (addressFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
qCDebug(networking) << "Adding contents of " << addressFile.fileName();
hash.addData(addressFile.readAll());
} else {
qCWarning(networking) << "Failed to read " << addressFile.fileName();
}
}
} else {
QByteArray data = machineIdFile.readAll();
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

View file

@ -198,6 +198,10 @@ void LimitedNodeList::setPermissions(const NodePermissions& newPermissions) {
newPermissions.can(NodePermissions::Permission::canGetAndSetPrivateUserData)) {
emit canGetAndSetPrivateUserDataChanged(_permissions.can(NodePermissions::Permission::canGetAndSetPrivateUserData));
}
if (originalPermissions.can(NodePermissions::Permission::canRezAvatarEntities) !=
newPermissions.can(NodePermissions::Permission::canRezAvatarEntities)) {
emit canRezAvatarEntitiesChanged(_permissions.can(NodePermissions::Permission::canRezAvatarEntities));
}
}
void LimitedNodeList::setSocketLocalPort(quint16 socketLocalPort) {

View file

@ -133,6 +133,7 @@ public:
bool getThisNodeCanKick() const { return _permissions.can(NodePermissions::Permission::canKick); }
bool getThisNodeCanReplaceContent() const { return _permissions.can(NodePermissions::Permission::canReplaceDomainContent); }
bool getThisNodeCanGetAndSetPrivateUserData() const { return _permissions.can(NodePermissions::Permission::canGetAndSetPrivateUserData); }
bool getThisNodeCanRezAvatarEntities() const { return _permissions.can(NodePermissions::Permission::canRezAvatarEntities); }
quint16 getSocketLocalPort() const { return _nodeSocket.localPort(); }
Q_INVOKABLE void setSocketLocalPort(quint16 socketLocalPort);
@ -390,6 +391,7 @@ signals:
void canKickChanged(bool canKick);
void canReplaceContentChanged(bool canReplaceContent);
void canGetAndSetPrivateUserDataChanged(bool canGetAndSetPrivateUserData);
void canRezAvatarEntitiesChanged(bool canRezAvatarEntities);
protected slots:
void connectedForLocalSocketTest();

View file

@ -84,6 +84,7 @@ public:
bool getCanKick() const { return _permissions.can(NodePermissions::Permission::canKick); }
bool getCanReplaceContent() const { return _permissions.can(NodePermissions::Permission::canReplaceDomainContent); }
bool getCanGetAndSetPrivateUserData() const { return _permissions.can(NodePermissions::Permission::canGetAndSetPrivateUserData); }
bool getCanRezAvatarEntities() const { return _permissions.can(NodePermissions::Permission::canRezAvatarEntities); }
using NodesIgnoredPair = std::pair<std::vector<QUuid>, bool>;

Some files were not shown because too many files have changed in this diff Show more