mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 20:06:48 +02:00
Merge remote-tracking branch 'upstream/master' into 20315
This commit is contained in:
commit
1bcb3f7c75
79 changed files with 1218 additions and 554 deletions
8
BUILD.md
8
BUILD.md
|
@ -2,7 +2,6 @@
|
|||
|
||||
* [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.12.2
|
||||
* [Qt](http://qt-project.org/downloads) ~> 5.3.2
|
||||
* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4
|
||||
* [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1g
|
||||
* IMPORTANT: OpenSSL 1.0.1g is critical to avoid a security vulnerability.
|
||||
* [Intel Threading Building Blocks](https://www.threadingbuildingblocks.org/) ~> 4.3
|
||||
|
@ -10,6 +9,13 @@
|
|||
* [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82
|
||||
* [Gverb](https://github.com/highfidelity/gverb/archive/master.zip) (direct download to latest version)
|
||||
|
||||
#### CMake External Project Dependencies
|
||||
|
||||
The following dependencies will be downloaded, built, linked and included automatically by CMake where we require them. The CMakeLists files that handle grabbing each of the following external dependencies can be found in the [cmake/externals folder](cmake/externals). The resulting downloads, source files and binaries will be placed in the `build` directory in each of the subfolders for each external project. These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared.
|
||||
|
||||
* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4
|
||||
* [gverb](https://github.com/highfidelity/gverb)
|
||||
|
||||
### OS Specific Build Guides
|
||||
* [BUILD_OSX.md](BUILD_OSX.md) - additional instructions for OS X.
|
||||
* [BUILD_LINUX.md](BUILD_LINUX.md) - additional instructions for Linux.
|
||||
|
|
|
@ -127,11 +127,6 @@ To put the Gear VR Service into developer mode you need an application with an O
|
|||
|
||||
Once the application is on your device, go to `Settings->Application Manager->Gear VR Service->Manage Storage`. Tap on `VR Service Version` six times. It will scan your device to verify that you have an osig file in an application on your device, and then it will let you enable Developer mode.
|
||||
|
||||
####GLM
|
||||
|
||||
GLM is a header only library and technically the same GLM used for desktop builds of hifi could be used for the Android build. However, to avoid conflicts with system installations of Android dependencies, CMake will only look for Android headers and libraries in `ANDROID_LIB_DIR` or in your android-ndk install.
|
||||
|
||||
Download the [glm headers](http://sourceforge.net/projects/ogl-math/files/) from their sourceforge page. The version you download should match the requirement shown in the [general build guide](BUILD.md). Extract the archive into your `ANDROID_LIB_DIR` and rename the extracted folder to `glm`.
|
||||
|
||||
###CMake
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Please read the [general build guide](BUILD.md) for information on dependencies
|
|||
[Homebrew](http://brew.sh/) is an excellent package manager for OS X. It makes install of all hifi dependencies very simple.
|
||||
|
||||
brew tap highfidelity/homebrew-formulas
|
||||
brew install cmake glm openssl tbb libsoxr
|
||||
brew install cmake openssl tbb libsoxr
|
||||
brew install highfidelity/formulas/qt5
|
||||
brew link qt5 --force
|
||||
|
||||
|
|
23
BUILD_WIN.md
23
BUILD_WIN.md
|
@ -56,9 +56,6 @@ The recommended route for CMake to find the external dependencies is to place al
|
|||
-> bin
|
||||
-> include
|
||||
-> lib
|
||||
-> glm
|
||||
-> glm
|
||||
-> glm.hpp
|
||||
-> openssl
|
||||
-> bin
|
||||
-> include
|
||||
|
@ -129,26 +126,6 @@ Download the binary package: `glew-1.10.0-win32.zip`. Extract to %HIFI_LIB_DIR%\
|
|||
|
||||
Add to the PATH: `%HIFI_LIB_DIR%\glew\bin\Release\Win32`
|
||||
|
||||
###GLM
|
||||
|
||||
This package contains only headers, so there's nothing to add to the PATH.
|
||||
|
||||
Be careful with glm. For the folder other libraries would normally call 'include', the folder containing the headers, glm opts to use 'glm'. You will have a glm folder nested inside the top-level glm folder.
|
||||
|
||||
###Gverb
|
||||
|
||||
1. Go to https://github.com/highfidelity/gverb
|
||||
Or download the sources directly via this link:
|
||||
https://github.com/highfidelity/gverb/archive/master.zip
|
||||
|
||||
2. Extract the archive
|
||||
|
||||
3. Place the directories “include” and “src” in interface/external/gverb
|
||||
(Normally next to this readme)
|
||||
|
||||
4. Clear your build directory, run cmake, build and you should be all set.
|
||||
|
||||
|
||||
###Bullet
|
||||
|
||||
Bullet 2.82 source can be [downloaded here](https://code.google.com/p/bullet/downloads/detail?name=bullet-2.82-r2704.zip). Bullet does not come with prebuilt libraries, you need to make those yourself.
|
||||
|
|
|
@ -104,6 +104,7 @@ set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries")
|
|||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
|
||||
|
||||
set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros")
|
||||
set(EXTERNAL_PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/externals")
|
||||
|
||||
file(GLOB HIFI_CUSTOM_MACROS "cmake/macros/*.cmake")
|
||||
foreach(CUSTOM_MACRO ${HIFI_CUSTOM_MACROS})
|
||||
|
|
|
@ -2,7 +2,9 @@ set(TARGET_NAME assignment-client)
|
|||
|
||||
setup_hifi_project(Core Gui Network Script Widgets)
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS})
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(
|
||||
|
|
|
@ -208,7 +208,7 @@ void Agent::run() {
|
|||
|
||||
_scriptEngine.init(); // must be done before we set up the viewers
|
||||
|
||||
_scriptEngine.registerGlobalObject("SoundCache", &SoundCache::getInstance());
|
||||
_scriptEngine.registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
|
||||
|
||||
_scriptEngine.registerGlobalObject("EntityViewer", &_entityViewer);
|
||||
_entityViewer.setJurisdictionListener(_scriptEngine.getEntityScriptingInterface()->getJurisdictionListener());
|
||||
|
|
|
@ -136,7 +136,7 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
|||
|
||||
// Create Singleton objects on main thread
|
||||
NetworkAccessManager::getInstance();
|
||||
SoundCache::getInstance();
|
||||
auto soundCache = DependencyManager::get<SoundCache>();
|
||||
}
|
||||
|
||||
void AssignmentClient::sendAssignmentRequest() {
|
||||
|
|
|
@ -147,3 +147,14 @@ void EntityServer::pruneDeletedEntities() {
|
|||
}
|
||||
}
|
||||
|
||||
void EntityServer::readAdditionalConfiguration(const QJsonObject& settingsSectionObject) {
|
||||
bool wantEditLogging = false;
|
||||
readOptionBool(QString("wantEditLogging"), settingsSectionObject, wantEditLogging);
|
||||
qDebug("wantEditLogging=%s", debug::valueOf(wantEditLogging));
|
||||
|
||||
|
||||
EntityTree* tree = static_cast<EntityTree*>(_tree);
|
||||
tree->setWantEditLogging(wantEditLogging);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
virtual int sendSpecialPacket(const SharedNodePointer& node, OctreeQueryNode* queryNode, int& packetsSent);
|
||||
|
||||
virtual void entityCreated(const EntityItem& newEntity, const SharedNodePointer& senderNode);
|
||||
virtual void readAdditionalConfiguration(const QJsonObject& settingsSectionObject);
|
||||
|
||||
public slots:
|
||||
void pruneDeletedEntities();
|
||||
|
|
15
cmake/externals/glm/CMakeLists.txt
vendored
Normal file
15
cmake/externals/glm/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
set(EXTERNAL_NAME glm)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
${EXTERNAL_NAME}
|
||||
PREFIX ${EXTERNAL_NAME}
|
||||
URL http://pkgs.fedoraproject.org/repo/pkgs/glm/glm-0.9.5.4.zip/fab76fc982b256b46208e5c750ed456a/glm-0.9.5.4.zip
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||
LOG_DOWNLOAD ON
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR)
|
||||
|
||||
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
||||
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE TYPE STRING)
|
25
cmake/externals/gverb/CMakeLists.txt
vendored
Normal file
25
cmake/externals/gverb/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
set(EXTERNAL_NAME gverb)
|
||||
|
||||
if (ANDROID)
|
||||
set(ANDROID_CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DANDROID_NATIVE_API_LEVEL=19")
|
||||
endif ()
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
${EXTERNAL_NAME}
|
||||
PREFIX ${EXTERNAL_NAME}
|
||||
GIT_REPOSITORY https://github.com/birarda/gverb.git
|
||||
CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||
LOG_DOWNLOAD ON
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR)
|
||||
|
||||
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
||||
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE TYPE STRING)
|
||||
|
||||
if (WIN32)
|
||||
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/gverb.lib CACHE TYPE STRING)
|
||||
else ()
|
||||
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/libgverb.a CACHE TYPE STRING)
|
||||
endif ()
|
25
cmake/macros/AddDependencyExternalProject.cmake
Normal file
25
cmake/macros/AddDependencyExternalProject.cmake
Normal file
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# SetupExternalProject.cmake
|
||||
# cmake/macros
|
||||
#
|
||||
# Copyright 2015 High Fidelity, Inc.
|
||||
# Created by Stephen Birarda on February 13, 2014
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(ADD_DEPENDENCY_EXTERNAL_PROJECT _PROJ_NAME)
|
||||
|
||||
string(TOUPPER ${_PROJ_NAME} _PROJ_NAME_UPPER)
|
||||
|
||||
if (NOT DEFINED GET_${_PROJ_NAME_UPPER} OR GET_${_PROJ_NAME_UPPER})
|
||||
if (NOT TARGET ${_PROJ_NAME})
|
||||
add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${CMAKE_BINARY_DIR}/externals/${_PROJ_NAME})
|
||||
endif ()
|
||||
|
||||
add_dependencies(${TARGET_NAME} ${_PROJ_NAME})
|
||||
|
||||
endif ()
|
||||
|
||||
endmacro()
|
|
@ -10,22 +10,21 @@
|
|||
|
||||
macro(HIFI_LIBRARY_SEARCH_HINTS LIBRARY_FOLDER)
|
||||
string(TOUPPER ${LIBRARY_FOLDER} LIBRARY_PREFIX)
|
||||
set(${LIBRARY_PREFIX}_SEARCH_DIRS "")
|
||||
|
||||
if (${LIBRARY_PREFIX}_ROOT_DIR)
|
||||
set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_ROOT_DIR}")
|
||||
list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_ROOT_DIR}")
|
||||
endif ()
|
||||
|
||||
if (ANDROID)
|
||||
set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "/${LIBRARY_FOLDER}")
|
||||
list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "/${LIBRARY_FOLDER}")
|
||||
endif ()
|
||||
|
||||
if (DEFINED ENV{${LIBRARY_PREFIX}_ROOT_DIR})
|
||||
set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "$ENV{${LIBRARY_PREFIX}_ROOT_DIR}")
|
||||
list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "$ENV{${LIBRARY_PREFIX}_ROOT_DIR}")
|
||||
endif ()
|
||||
|
||||
if (DEFINED ENV{HIFI_LIB_DIR})
|
||||
set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "$ENV{HIFI_LIB_DIR}/${LIBRARY_FOLDER}")
|
||||
list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "$ENV{HIFI_LIB_DIR}/${LIBRARY_FOLDER}")
|
||||
endif ()
|
||||
|
||||
endmacro(HIFI_LIBRARY_SEARCH_HINTS _library_folder)
|
|
@ -1,13 +0,0 @@
|
|||
#
|
||||
# IncludeGLM.cmake
|
||||
#
|
||||
# Copyright 2013 High Fidelity, Inc.
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(INCLUDE_GLM)
|
||||
find_package(GLM REQUIRED)
|
||||
include_directories(SYSTEM "${GLM_INCLUDE_DIRS}")
|
||||
endmacro(INCLUDE_GLM)
|
|
@ -18,9 +18,7 @@ include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
|||
hifi_library_search_hints("glm")
|
||||
|
||||
# locate header
|
||||
find_path(GLM_INCLUDE_DIR "glm/glm.hpp" HINTS ${GLM_SEARCH_DIRS})
|
||||
|
||||
set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
|
||||
find_path(GLM_INCLUDE_DIRS "glm/glm.hpp" HINTS ${GLM_SEARCH_DIRS})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIRS)
|
||||
|
|
|
@ -15,25 +15,11 @@
|
|||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
if (GVERB_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(GVERB_FOUND TRUE)
|
||||
else (GVERB_INCLUDE_DIRS)
|
||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("gverb")
|
||||
|
||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("gverb")
|
||||
find_path(GVERB_INCLUDE_DIRS gverb.h PATH_SUFFIXES include HINTS ${GVERB_SEARCH_DIRS})
|
||||
find_library(GVERB_LIBRARIES gverb PATH_SUFFIXES lib HINTS ${GVERB_SEARCH_DIRS})
|
||||
|
||||
find_path(GVERB_INCLUDE_DIRS gverb.h PATH_SUFFIXES include HINTS ${GVERB_SEARCH_DIRS} NO_CMAKE_FIND_ROOT_PATH)
|
||||
find_path(GVERB_SRC_DIRS gverb.c PATH_SUFFIXES src HINTS ${GVERB_SEARCH_DIRS} NO_CMAKE_FIND_ROOT_PATH)
|
||||
|
||||
if (GVERB_INCLUDE_DIRS)
|
||||
set(GVERB_FOUND TRUE)
|
||||
endif (GVERB_INCLUDE_DIRS)
|
||||
|
||||
if (GVERB_FOUND)
|
||||
message(STATUS "Found Gverb: ${GVERB_INCLUDE_DIRS}")
|
||||
else (GVERB_FOUND)
|
||||
message(FATAL_ERROR "Could NOT find Gverb. Read ./libraries/audio-client/externals/gverb/readme.txt")
|
||||
endif (GVERB_FOUND)
|
||||
|
||||
endif(GVERB_INCLUDE_DIRS)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GVERB DEFAULT_MSG GVERB_INCLUDE_DIRS GVERB_LIBRARIES)
|
|
@ -409,6 +409,13 @@
|
|||
"default": "",
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "wantEditLogging",
|
||||
"type": "checkbox",
|
||||
"help": "Logging of all edits to entities",
|
||||
"default": true,
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "verboseDebug",
|
||||
"type": "checkbox",
|
||||
|
|
248
examples/controllers/oculus/goTo.js
Normal file
248
examples/controllers/oculus/goTo.js
Normal file
|
@ -0,0 +1,248 @@
|
|||
//
|
||||
// goTo.js
|
||||
// examples
|
||||
//
|
||||
// Created by Thijs Wenker on 12/28/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Control a virtual keyboard using your favorite HMD.
|
||||
// Usage: Enable VR-mode and go to First person mode,
|
||||
// look at the key that you would like to press, and press the spacebar on your "REAL" keyboard.
|
||||
//
|
||||
// Enter a location URL using your HMD. Press Enter to pop-up the virtual keyboard and location input.
|
||||
// Press Space on the keyboard or the X button on your gamepad to press a key that you have selected.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("../../libraries/globals.js");
|
||||
Script.include("../../libraries/virtualKeyboard.js");
|
||||
|
||||
const MAX_SHOW_INSTRUCTION_TIMES = 2;
|
||||
const INSTRUCTIONS_SETTING = "GoToInstructionsShowCounter"
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
|
||||
function Instructions(imageURL, originalWidth, originalHeight) {
|
||||
var tthis = this;
|
||||
this.originalSize = {w: originalWidth, h: originalHeight};
|
||||
this.visible = false;
|
||||
this.overlay = Overlays.addOverlay("image", {
|
||||
imageURL: imageURL,
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: originalWidth,
|
||||
height: originalHeight,
|
||||
alpha: 1,
|
||||
visible: this.visible
|
||||
});
|
||||
|
||||
this.show = function() {
|
||||
var timesShown = Settings.getValue(INSTRUCTIONS_SETTING);
|
||||
timesShown = timesShown === "" ? 0 : parseInt(timesShown);
|
||||
print(timesShown);
|
||||
if (timesShown < MAX_SHOW_INSTRUCTION_TIMES) {
|
||||
Settings.setValue(INSTRUCTIONS_SETTING, timesShown + 1);
|
||||
tthis.visible = true;
|
||||
tthis.rescale();
|
||||
Overlays.editOverlay(tthis.overlay, {visible: tthis.visible});
|
||||
return;
|
||||
}
|
||||
tthis.remove();
|
||||
}
|
||||
|
||||
this.remove = function() {
|
||||
Overlays.deleteOverlay(tthis.overlay);
|
||||
tthis.visible = false;
|
||||
};
|
||||
|
||||
this.rescale = function() {
|
||||
var scale = Math.min(windowDimensions.x / tthis.originalSize.w, windowDimensions.y / tthis.originalSize.h);
|
||||
var newWidth = tthis.originalSize.w * scale;
|
||||
var newHeight = tthis.originalSize.h * scale;
|
||||
Overlays.editOverlay(tthis.overlay, {
|
||||
x: (windowDimensions.x / 2) - (newWidth / 2),
|
||||
y: (windowDimensions.y / 2) - (newHeight / 2),
|
||||
width: newWidth,
|
||||
height: newHeight
|
||||
});
|
||||
};
|
||||
this.rescale();
|
||||
};
|
||||
|
||||
var theInstruction = new Instructions(HIFI_PUBLIC_BUCKET + "images/tutorial-goTo.svg", 457, 284.1);
|
||||
|
||||
var firstControllerPlugged = false;
|
||||
|
||||
|
||||
var cursor = new Cursor({visible: false});
|
||||
var keyboard = new Keyboard({visible: false});
|
||||
var textFontSize = 9;
|
||||
var text = null;
|
||||
var locationURL = "";
|
||||
|
||||
function appendChar(char) {
|
||||
locationURL += char;
|
||||
updateTextOverlay();
|
||||
Overlays.editOverlay(text, {text: locationURL});
|
||||
}
|
||||
|
||||
function deleteChar() {
|
||||
if (locationURL.length > 0) {
|
||||
locationURL = locationURL.substring(0, locationURL.length - 1);
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
function updateTextOverlay() {
|
||||
var maxLineWidth = Overlays.textSize(text, locationURL).width;
|
||||
var suggestedFontSize = (windowDimensions.x / maxLineWidth) * textFontSize * 0.90;
|
||||
var maxFontSize = 140;
|
||||
textFontSize = (suggestedFontSize > maxFontSize) ? maxFontSize : suggestedFontSize;
|
||||
var topMargin = (250 - textFontSize) / 4;
|
||||
Overlays.editOverlay(text, {text: locationURL, font: {size: textFontSize}, topMargin: topMargin, visible: keyboard.visible});
|
||||
maxLineWidth = Overlays.textSize(text, locationURL).width;
|
||||
Overlays.editOverlay(text, {leftMargin: (windowDimensions.x - maxLineWidth) / 2});
|
||||
}
|
||||
|
||||
keyboard.onKeyPress = function(event) {
|
||||
if (event.event == 'keypress') {
|
||||
appendChar(event.char);
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onKeyRelease = function(event) {
|
||||
// you can cancel a key by releasing its focusing before releasing it
|
||||
if (event.focus) {
|
||||
if (event.event == 'delete') {
|
||||
deleteChar();
|
||||
} else if (event.event == 'submit' || event.event == 'enter') {
|
||||
print("going to hifi://" + locationURL);
|
||||
location = "hifi://" + locationURL;
|
||||
locationURL = "";
|
||||
keyboard.hide();
|
||||
cursor.hide();
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onFullyLoaded = function() {
|
||||
print("Virtual-keyboard fully loaded.");
|
||||
var dimensions = Controller.getViewportDimensions();
|
||||
text = Overlays.addOverlay("text", {
|
||||
x: 0,
|
||||
y: dimensions.y - keyboard.height() - 260,
|
||||
width: dimensions.x,
|
||||
height: 250,
|
||||
backgroundColor: { red: 255, green: 255, blue: 255},
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
topMargin: 5,
|
||||
leftMargin: 0,
|
||||
font: {size: textFontSize},
|
||||
text: "",
|
||||
alpha: 0.8,
|
||||
visible: keyboard.visible
|
||||
});
|
||||
updateTextOverlay();
|
||||
// the cursor is being loaded after the keyboard, else it will be on the background of the keyboard
|
||||
cursor.initialize();
|
||||
cursor.updateVisibility(keyboard.visible);
|
||||
cursor.onUpdate = function(position) {
|
||||
keyboard.setFocusPosition(position.x, position.y);
|
||||
};
|
||||
};
|
||||
|
||||
function keyPressEvent(event) {
|
||||
if (theInstruction.visible) {
|
||||
return;
|
||||
}
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.pressFocussedKey();
|
||||
} else if (event.key === ENTER_CHARCODE || event.key === RETURN_CHARCODE) {
|
||||
keyboard.toggle();
|
||||
if (cursor !== undefined) {
|
||||
cursor.updateVisibility(keyboard.visible);
|
||||
}
|
||||
Overlays.editOverlay(text, {visible: keyboard.visible});
|
||||
}
|
||||
}
|
||||
|
||||
function keyReleaseEvent(event) {
|
||||
if (theInstruction.visible) {
|
||||
return;
|
||||
}
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
keyboard.remove();
|
||||
cursor.remove();
|
||||
Overlays.deleteOverlay(text);
|
||||
Overlays.deleteOverlay(textSizeMeasureOverlay);
|
||||
Controller.releaseKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
Controller.releaseKeyEvents({key: RETURN_CHARCODE});
|
||||
Controller.releaseKeyEvents({key: ENTER_CHARCODE});
|
||||
theInstruction.remove();
|
||||
}
|
||||
|
||||
function reportButtonValue(button, newValue, oldValue) {
|
||||
if (theInstruction.visible) {
|
||||
if (button == Joysticks.BUTTON_FACE_BOTTOM && newValue) {
|
||||
theInstruction.remove();
|
||||
}
|
||||
} else if (button == Joysticks.BUTTON_FACE_BOTTOM) {
|
||||
if (newValue) {
|
||||
keyboard.pressFocussedKey();
|
||||
} else {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
} else if (button == Joysticks.BUTTON_FACE_RIGHT && newValue) {
|
||||
deleteChar();
|
||||
} else if (button == Joysticks.BUTTON_FACE_LEFT && newValue) {
|
||||
keyboard.hide();
|
||||
if (cursor !== undefined) {
|
||||
cursor.hide();
|
||||
}
|
||||
Overlays.editOverlay(text, {visible: false});
|
||||
} else if (button == Joysticks.BUTTON_RIGHT_SHOULDER && newValue) {
|
||||
if (keyboard.visible) {
|
||||
print("going to hifi://" + locationURL);
|
||||
location = "hifi://" + locationURL;
|
||||
locationURL = "";
|
||||
keyboard.hide();
|
||||
cursor.hide();
|
||||
updateTextOverlay();
|
||||
return;
|
||||
}
|
||||
keyboard.show();
|
||||
if (cursor !== undefined) {
|
||||
cursor.show();
|
||||
}
|
||||
Overlays.editOverlay(text, {visible: true});
|
||||
}
|
||||
}
|
||||
|
||||
function addJoystick(gamepad) {
|
||||
gamepad.buttonStateChanged.connect(reportButtonValue);
|
||||
if (!firstControllerPlugged) {
|
||||
firstControllerPlugged = true;
|
||||
theInstruction.show();
|
||||
}
|
||||
}
|
||||
|
||||
var allJoysticks = Joysticks.getAllJoysticks();
|
||||
for (var i = 0; i < allJoysticks.length; i++) {
|
||||
addJoystick(allJoysticks[i]);
|
||||
}
|
||||
|
||||
Joysticks.joystickAdded.connect(addJoystick);
|
||||
Controller.captureKeyEvents({key: RETURN_CHARCODE});
|
||||
Controller.captureKeyEvents({key: ENTER_CHARCODE});
|
||||
Controller.captureKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
183
examples/controllers/oculus/virtualKeyboardTextEntityExample.js
Normal file
183
examples/controllers/oculus/virtualKeyboardTextEntityExample.js
Normal file
|
@ -0,0 +1,183 @@
|
|||
//
|
||||
// virtualKeyboardTextEntityExample.js
|
||||
// examples
|
||||
//
|
||||
// Created by Thijs Wenker on 12/28/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Control a virtual keyboard using your favorite HMD.
|
||||
// Usage: Enable VR-mode and go to First person mode,
|
||||
// look at the key that you would like to press, and press the spacebar on your "REAL" keyboard.
|
||||
//
|
||||
// leased some code from newEditEntities.js for Text Entity example
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("../../libraries/globals.js");
|
||||
Script.include("../../libraries/virtualKeyboard.js");
|
||||
|
||||
const SPAWN_DISTANCE = 1;
|
||||
const DEFAULT_TEXT_DIMENSION_Z = 0.02;
|
||||
|
||||
const TEXT_MARGIN_TOP = 0.15;
|
||||
const TEXT_MARGIN_LEFT = 0.15;
|
||||
const TEXT_MARGIN_RIGHT = 0.17;
|
||||
const TEXT_MARGIN_BOTTOM = 0.17;
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
var cursor = new Cursor();
|
||||
var keyboard = new Keyboard();
|
||||
var textFontSize = 9;
|
||||
var text = null;
|
||||
var textText = "";
|
||||
var textSizeMeasureOverlay = Overlays.addOverlay("text3d", {visible: false});
|
||||
|
||||
function appendChar(char) {
|
||||
textText += char;
|
||||
updateTextOverlay();
|
||||
Overlays.editOverlay(text, {text: textText});
|
||||
}
|
||||
|
||||
function deleteChar() {
|
||||
if (textText.length > 0) {
|
||||
textText = textText.substring(0, textText.length - 1);
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
function updateTextOverlay() {
|
||||
var textLines = textText.split("\n");
|
||||
var suggestedFontSize = (windowDimensions.x / Overlays.textSize(text, textText).width) * textFontSize * 0.90;
|
||||
var maxFontSize = 170 / textLines.length;
|
||||
textFontSize = (suggestedFontSize > maxFontSize) ? maxFontSize : suggestedFontSize;
|
||||
var topMargin = (250 - (textFontSize * textLines.length)) / 4;
|
||||
Overlays.editOverlay(text, {text: textText, font: {size: textFontSize}, topMargin: topMargin});
|
||||
Overlays.editOverlay(text, {leftMargin: (windowDimensions.x - Overlays.textSize(text, textLines).width) / 2});
|
||||
}
|
||||
|
||||
keyboard.onKeyPress = function(event) {
|
||||
if (event.event == 'keypress') {
|
||||
appendChar(event.char);
|
||||
} else if (event.event == 'enter') {
|
||||
appendChar("\n");
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onKeyRelease = function(event) {
|
||||
print("Key release event test");
|
||||
// you can cancel a key by releasing its focusing before releasing it
|
||||
if (event.focus) {
|
||||
if (event.event == 'delete') {
|
||||
deleteChar();
|
||||
} else if (event.event == 'submit') {
|
||||
print(textText);
|
||||
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
var textLines = textText.split("\n");
|
||||
var maxLineWidth = Overlays.textSize(textSizeMeasureOverlay, textText).width;
|
||||
var usernameLine = "--" + GlobalServices.myUsername;
|
||||
var usernameWidth = Overlays.textSize(textSizeMeasureOverlay, usernameLine).width;
|
||||
if (maxLineWidth < usernameWidth) {
|
||||
maxLineWidth = usernameWidth;
|
||||
} else {
|
||||
var spaceableWidth = maxLineWidth - usernameWidth;
|
||||
//TODO: WORKAROUND WARNING BELOW Fix this when spaces are not trimmed out of the textsize calculation anymore
|
||||
var spaceWidth = Overlays.textSize(textSizeMeasureOverlay, "| |").width
|
||||
- Overlays.textSize(textSizeMeasureOverlay, "||").width;
|
||||
var numberOfSpaces = Math.floor(spaceableWidth / spaceWidth);
|
||||
for (var i = 0; i < numberOfSpaces; i++) {
|
||||
usernameLine = " " + usernameLine;
|
||||
}
|
||||
}
|
||||
var dimension_x = maxLineWidth + TEXT_MARGIN_RIGHT + TEXT_MARGIN_LEFT;
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
Entities.addEntity({
|
||||
type: "Text",
|
||||
rotation: MyAvatar.orientation,
|
||||
position: position,
|
||||
dimensions: { x: dimension_x, y: (textLines.length + 1) * 0.14 + TEXT_MARGIN_TOP + TEXT_MARGIN_BOTTOM, z: DEFAULT_TEXT_DIMENSION_Z },
|
||||
backgroundColor: { red: 0, green: 0, blue: 0 },
|
||||
textColor: { red: 255, green: 255, blue: 255 },
|
||||
text: textText + "\n" + usernameLine,
|
||||
lineHeight: 0.1
|
||||
});
|
||||
}
|
||||
textText = "";
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onFullyLoaded = function() {
|
||||
print("Virtual-keyboard fully loaded.");
|
||||
var dimensions = Controller.getViewportDimensions();
|
||||
text = Overlays.addOverlay("text", {
|
||||
x: 0,
|
||||
y: dimensions.y - keyboard.height() - 260,
|
||||
width: dimensions.x,
|
||||
height: 250,
|
||||
backgroundColor: { red: 255, green: 255, blue: 255},
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
topMargin: 5,
|
||||
leftMargin: 0,
|
||||
font: {size: textFontSize},
|
||||
text: "",
|
||||
alpha: 0.8
|
||||
});
|
||||
updateTextOverlay();
|
||||
// the cursor is being loaded after the keyboard, else it will be on the background of the keyboard
|
||||
cursor.initialize();
|
||||
cursor.onUpdate = function(position) {
|
||||
keyboard.setFocusPosition(position.x, position.y);
|
||||
};
|
||||
};
|
||||
|
||||
function keyPressEvent(event) {
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.pressFocussedKey();
|
||||
}
|
||||
}
|
||||
|
||||
function keyReleaseEvent(event) {
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
keyboard.remove();
|
||||
cursor.remove();
|
||||
Overlays.deleteOverlay(text);
|
||||
Overlays.deleteOverlay(textSizeMeasureOverlay);
|
||||
Controller.releaseKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
}
|
||||
|
||||
function reportButtonValue(button, newValue, oldValue) {
|
||||
if (button == Joysticks.BUTTON_FACE_BOTTOM) {
|
||||
if (newValue) {
|
||||
keyboard.pressFocussedKey();
|
||||
} else {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
} else if (button == Joysticks.BUTTON_FACE_RIGHT && newValue) {
|
||||
deleteChar();
|
||||
}
|
||||
}
|
||||
|
||||
function addJoystick(gamepad) {
|
||||
gamepad.buttonStateChanged.connect(reportButtonValue);
|
||||
}
|
||||
|
||||
var allJoysticks = Joysticks.getAllJoysticks();
|
||||
for (var i = 0; i < allJoysticks.length; i++) {
|
||||
addJoystick(allJoysticks[i]);
|
||||
}
|
||||
|
||||
Joysticks.joystickAdded.connect(addJoystick);
|
||||
Controller.captureKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
|
@ -127,7 +127,7 @@ var toolBar = (function () {
|
|||
height: toolHeight,
|
||||
alpha: 0.9,
|
||||
visible: true
|
||||
}, true, false);
|
||||
});
|
||||
|
||||
browseModelsButton = toolBar.addTool({
|
||||
imageURL: toolIconUrl + "list-icon.svg",
|
||||
|
@ -262,6 +262,8 @@ var toolBar = (function () {
|
|||
toolBar.move(toolsX, toolsY);
|
||||
};
|
||||
|
||||
var newModelButtonDown = false;
|
||||
var browseModelsButtonDown = false;
|
||||
that.mousePressEvent = function (event) {
|
||||
var clickedOverlay,
|
||||
url,
|
||||
|
@ -274,19 +276,14 @@ var toolBar = (function () {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Handle these two buttons in the mouseRelease event handler so that we don't suppress a mouseRelease event from
|
||||
// occurring when showing a modal dialog.
|
||||
if (newModelButton === toolBar.clicked(clickedOverlay)) {
|
||||
url = Window.prompt("Model URL", modelURLs[Math.floor(Math.random() * modelURLs.length)]);
|
||||
if (url !== null && url !== "") {
|
||||
addModel(url);
|
||||
}
|
||||
newModelButtonDown = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (browseModelsButton === toolBar.clicked(clickedOverlay)) {
|
||||
url = Window.s3Browse(".*(fbx|FBX)");
|
||||
if (url !== null && url !== "") {
|
||||
addModel(url);
|
||||
}
|
||||
browseModelsButtonDown = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -348,6 +345,7 @@ var toolBar = (function () {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (newTextButton === toolBar.clicked(clickedOverlay)) {
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
|
@ -367,10 +365,37 @@ var toolBar = (function () {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
that.mouseReleaseEvent = function(event) {
|
||||
var handled = false;
|
||||
if (newModelButtonDown) {
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||
if (newModelButton === toolBar.clicked(clickedOverlay)) {
|
||||
url = Window.prompt("Model URL", modelURLs[Math.floor(Math.random() * modelURLs.length)]);
|
||||
if (url !== null && url !== "") {
|
||||
addModel(url);
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
} else if (browseModelsButtonDown) {
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||
if (browseModelsButton === toolBar.clicked(clickedOverlay)) {
|
||||
url = Window.s3Browse(".*(fbx|FBX)");
|
||||
if (url !== null && url !== "") {
|
||||
addModel(url);
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
newModelButtonDown = false;
|
||||
browseModelsButtonDown = false;
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
that.cleanup = function () {
|
||||
toolBar.cleanup();
|
||||
};
|
||||
|
@ -533,6 +558,9 @@ function highlightEntityUnderCursor(position, accurateRay) {
|
|||
|
||||
|
||||
function mouseReleaseEvent(event) {
|
||||
if (toolBar.mouseReleaseEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
if (placingEntityID) {
|
||||
if (isActive) {
|
||||
selectionManager.setSelections([placingEntityID]);
|
||||
|
@ -959,9 +987,18 @@ PropertiesTool = function(opts) {
|
|||
selectionManager.saveProperties();
|
||||
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
|
||||
Entities.editEntity(selectionManager.selections[i], {
|
||||
dimensions: properties.naturalDimensions,
|
||||
});
|
||||
var naturalDimensions = properties.naturalDimensions;
|
||||
|
||||
// If any of the natural dimensions are not 0, resize
|
||||
if (properties.type == "Model" && naturalDimensions.x == 0
|
||||
&& naturalDimensions.y == 0 && naturalDimensions.z == 0) {
|
||||
Window.alert("Cannot reset entity to its natural dimensions: Model URL"
|
||||
+ " is invalid or the model has not yet been loaded.");
|
||||
} else {
|
||||
Entities.editEntity(selectionManager.selections[i], {
|
||||
dimensions: properties.naturalDimensions,
|
||||
});
|
||||
}
|
||||
}
|
||||
pushCommandForSelections();
|
||||
selectionManager._update();
|
||||
|
|
|
@ -9,179 +9,50 @@
|
|||
// Usage: Enable VR-mode and go to First person mode,
|
||||
// look at the key that you would like to press, and press the spacebar on your "REAL" keyboard.
|
||||
//
|
||||
// leased some code from newEditEntities.js for Text Entity example
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
// experimental 3dmode
|
||||
THREE_D_MODE = false;
|
||||
|
||||
const KBD_UPPERCASE_DEFAULT = 0;
|
||||
const KBD_LOWERCASE_DEFAULT = 1;
|
||||
const KBD_UPPERCASE_HOVER = 2;
|
||||
const KBD_LOWERCASE_HOVER = 3;
|
||||
const KBD_BACKGROUND = 4;
|
||||
KBD_UPPERCASE_DEFAULT = 0;
|
||||
KBD_LOWERCASE_DEFAULT = 1;
|
||||
KBD_UPPERCASE_HOVER = 2;
|
||||
KBD_LOWERCASE_HOVER = 3;
|
||||
KBD_BACKGROUND = 4;
|
||||
|
||||
const KEYBOARD_URL = HIFI_PUBLIC_BUCKET + "images/keyboard.svg";
|
||||
const CURSOR_URL = HIFI_PUBLIC_BUCKET + "images/cursor.svg";
|
||||
KEYBOARD_URL = HIFI_PUBLIC_BUCKET + "images/keyboard.svg";
|
||||
CURSOR_URL = HIFI_PUBLIC_BUCKET + "images/cursor.svg";
|
||||
|
||||
const SPACEBAR_CHARCODE = 32;
|
||||
RETURN_CHARCODE = 0x01000004;
|
||||
ENTER_CHARCODE = 0x01000005;
|
||||
SPACEBAR_CHARCODE = 32;
|
||||
|
||||
const KEYBOARD_WIDTH = 1174.7;
|
||||
const KEYBOARD_HEIGHT = 434.1;
|
||||
KEYBOARD_WIDTH = 1174.7;
|
||||
KEYBOARD_HEIGHT = 434.1;
|
||||
|
||||
const CURSOR_WIDTH = 33.9;
|
||||
const CURSOR_HEIGHT = 33.9;
|
||||
CURSOR_WIDTH = 33.9;
|
||||
CURSOR_HEIGHT = 33.9;
|
||||
|
||||
KEYBOARD_SCALE_MULTIPLIER = 0.50;
|
||||
|
||||
// VIEW_ANGLE can be adjusted to your likings, the smaller the faster movement.
|
||||
// Try setting it to 60 if it goes too fast for you.
|
||||
const VIEW_ANGLE = 40.0;
|
||||
const VIEW_ANGLE_BY_TWO = VIEW_ANGLE / 2;
|
||||
|
||||
const SPAWN_DISTANCE = 1;
|
||||
const DEFAULT_TEXT_DIMENSION_Z = 0.02;
|
||||
|
||||
const BOUND_X = 0;
|
||||
const BOUND_Y = 1;
|
||||
const BOUND_W = 2;
|
||||
const BOUND_H = 3;
|
||||
|
||||
const KEY_STATE_LOWER = 0;
|
||||
const KEY_STATE_UPPER = 1;
|
||||
|
||||
const TEXT_MARGIN_TOP = 0.15;
|
||||
const TEXT_MARGIN_LEFT = 0.15;
|
||||
const TEXT_MARGIN_RIGHT = 0.17;
|
||||
const TEXT_MARGIN_BOTTOM = 0.17;
|
||||
KEY_STATE_LOWER = 0;
|
||||
KEY_STATE_UPPER = 1;
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
var cursor = null;
|
||||
var keyboard = new Keyboard();
|
||||
var textFontSize = 9;
|
||||
var text = null;
|
||||
var textText = "";
|
||||
var textSizeMeasureOverlay = Overlays.addOverlay("text3d", {visible: false});
|
||||
|
||||
function appendChar(char) {
|
||||
textText += char;
|
||||
updateTextOverlay();
|
||||
Overlays.editOverlay(text, {text: textText});
|
||||
}
|
||||
|
||||
function deleteChar() {
|
||||
if (textText.length > 0) {
|
||||
textText = textText.substring(0, textText.length - 1);
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
function updateTextOverlay() {
|
||||
var textLines = textText.split("\n");
|
||||
var maxLineWidth = 0;
|
||||
for (textLine in textLines) {
|
||||
var lineWidth = Overlays.textSize(text, textLines[textLine]).width;
|
||||
if (lineWidth > maxLineWidth) {
|
||||
maxLineWidth = lineWidth;
|
||||
}
|
||||
}
|
||||
var suggestedFontSize = (windowDimensions.x / maxLineWidth) * textFontSize * 0.90;
|
||||
var maxFontSize = 190 / textLines.length;
|
||||
textFontSize = (suggestedFontSize > maxFontSize) ? maxFontSize : suggestedFontSize;
|
||||
var topMargin = (250 - (textFontSize * textLines.length)) / 4;
|
||||
Overlays.editOverlay(text, {text: textText, font: {size: textFontSize}, topMargin: topMargin});
|
||||
var maxLineWidth = 0;
|
||||
for (textLine in textLines) {
|
||||
var lineWidth = Overlays.textSize(text, textLines[textLine]).width;
|
||||
if (lineWidth > maxLineWidth) {
|
||||
maxLineWidth = lineWidth;
|
||||
}
|
||||
}
|
||||
Overlays.editOverlay(text, {leftMargin: (windowDimensions.x - maxLineWidth) / 2});
|
||||
}
|
||||
|
||||
keyboard.onKeyPress = function(event) {
|
||||
if (event.event == 'keypress') {
|
||||
appendChar(event.char);
|
||||
} else if (event.event == 'enter') {
|
||||
appendChar("\n");
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onKeyRelease = function(event) {
|
||||
print("Key release event test");
|
||||
// you can cancel a key by releasing its focusing before releasing it
|
||||
if (event.focus) {
|
||||
if (event.event == 'delete') {
|
||||
deleteChar();
|
||||
} else if (event.event == 'submit') {
|
||||
print(textText);
|
||||
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||
|
||||
var textLines = textText.split("\n");
|
||||
var maxLineWidth = 0;
|
||||
for (textLine in textLines) {
|
||||
var lineWidth = Overlays.textSize(textSizeMeasureOverlay, textLines[textLine]).width;
|
||||
if (lineWidth > maxLineWidth) {
|
||||
maxLineWidth = lineWidth;
|
||||
}
|
||||
}
|
||||
var usernameLine = "--" + GlobalServices.myUsername;
|
||||
var usernameWidth = Overlays.textSize(textSizeMeasureOverlay, usernameLine).width;
|
||||
if (maxLineWidth < usernameWidth) {
|
||||
maxLineWidth = usernameWidth;
|
||||
} else {
|
||||
var spaceableWidth = maxLineWidth - usernameWidth;
|
||||
var spaceWidth = Overlays.textSize(textSizeMeasureOverlay, " ").width;
|
||||
var numberOfSpaces = Math.floor(spaceableWidth / spaceWidth);
|
||||
for (var i = 0; i < numberOfSpaces; i++) {
|
||||
usernameLine = " " + usernameLine;
|
||||
}
|
||||
}
|
||||
var dimension_x = maxLineWidth + TEXT_MARGIN_RIGHT + TEXT_MARGIN_LEFT;
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
Entities.addEntity({
|
||||
type: "Text",
|
||||
rotation: MyAvatar.orientation,
|
||||
position: position,
|
||||
dimensions: { x: dimension_x, y: (textLines.length + 1) * 0.14 + TEXT_MARGIN_TOP + TEXT_MARGIN_BOTTOM, z: DEFAULT_TEXT_DIMENSION_Z },
|
||||
backgroundColor: { red: 0, green: 0, blue: 0 },
|
||||
textColor: { red: 255, green: 255, blue: 255 },
|
||||
text: textText + "\n" + usernameLine
|
||||
});
|
||||
}
|
||||
textText = "";
|
||||
updateTextOverlay();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
keyboard.onFullyLoaded = function() {
|
||||
print("Virtual-keyboard fully loaded.");
|
||||
var dimensions = Controller.getViewportDimensions();
|
||||
text = Overlays.addOverlay("text", {
|
||||
x: 0,
|
||||
y: dimensions.y - keyboard.height() - 260,
|
||||
width: dimensions.x,
|
||||
height: 250,
|
||||
backgroundColor: { red: 255, green: 255, blue: 255},
|
||||
color: { red: 0, green: 0, blue: 0},
|
||||
topMargin: 5,
|
||||
leftMargin: 0,
|
||||
font: {size: textFontSize},
|
||||
text: "",
|
||||
alpha: 0.8
|
||||
});
|
||||
updateTextOverlay();
|
||||
// the cursor is being loaded after the keyboard, else it will be on the background of the keyboard
|
||||
cursor = new Cursor();
|
||||
cursor.onUpdate = function(position) {
|
||||
keyboard.setFocusPosition(position.x, position.y);
|
||||
};
|
||||
};
|
||||
|
||||
function KeyboardKey(keyboard, keyProperties) {
|
||||
KeyboardKey = (function(keyboard, keyProperties) {
|
||||
var tthis = this;
|
||||
this._focus = false;
|
||||
this._beingPressed = false;
|
||||
|
@ -247,6 +118,11 @@ function KeyboardKey(keyboard, keyProperties) {
|
|||
});
|
||||
}
|
||||
};
|
||||
this.updateVisibility = function() {
|
||||
for (var i = 0; i < tthis.bounds.length; i++) {
|
||||
Overlays.editOverlay(tthis.overlays[i], {visible: tthis.keyboard.visible});
|
||||
}
|
||||
};
|
||||
this.rescale = function() {
|
||||
for (var i = 0; i < tthis.bounds.length; i++) {
|
||||
Overlays.editOverlay(tthis.overlays[i], {
|
||||
|
@ -271,24 +147,48 @@ function KeyboardKey(keyboard, keyProperties) {
|
|||
return true;
|
||||
};
|
||||
for (var i = 0; i < this.bounds.length; i++) {
|
||||
var newOverlay = Overlays.cloneOverlay(this.keyboard.background);
|
||||
Overlays.editOverlay(newOverlay, {
|
||||
x: this.keyboard.getX() + this.bounds[i][BOUND_X] * keyboard.scale,
|
||||
y: this.keyboard.getY() + this.bounds[i][BOUND_Y] * keyboard.scale,
|
||||
width: this.bounds[i][BOUND_W] * keyboard.scale,
|
||||
height: this.bounds[i][BOUND_H] * keyboard.scale,
|
||||
subImage: {width: this.bounds[i][BOUND_W], height: this.bounds[i][BOUND_H], x: this.bounds[i][BOUND_X], y: (KEYBOARD_HEIGHT * this.keyState) + this.bounds[i][BOUND_Y]},
|
||||
alpha: 1
|
||||
});
|
||||
this.overlays.push(newOverlay);
|
||||
if (THREE_D_MODE) {
|
||||
this.overlays.push(Overlays.addOverlay("billboard", {
|
||||
scale: 1,
|
||||
rotation: MyAvatar.rotation,
|
||||
isFacingAvatar: false,
|
||||
url: KEYBOARD_URL,
|
||||
alpha: 1,
|
||||
position: {
|
||||
x: MyAvatar.position.x,// + this.bounds[i][BOUND_X] * 0.01,// /*+ this.keyboard.getX()*/ + this.bounds[i][BOUND_X] * keyboard.scale,
|
||||
y: MyAvatar.position.y,// - this.bounds[i][BOUND_Y] * 0.01,// /*+ this.keyboard.getY()*/ + this.bounds[i][BOUND_Y] * keyboard.scale,
|
||||
z: MyAvatar.position.z
|
||||
},
|
||||
width: this.bounds[i][BOUND_W] * keyboard.scale,
|
||||
height: this.bounds[i][BOUND_H] * keyboard.scale,
|
||||
subImage: {width: this.bounds[i][BOUND_W], height: this.bounds[i][BOUND_H], x: this.bounds[i][BOUND_X], y: (KEYBOARD_HEIGHT * this.keyState) + this.bounds[i][BOUND_Y]},
|
||||
alpha: 1,
|
||||
visible: tthis.keyboard.visible
|
||||
}));
|
||||
} else {
|
||||
this.overlays.push(Overlays.addOverlay("image", {
|
||||
imageURL: KEYBOARD_URL,
|
||||
x: this.keyboard.getX() + this.bounds[i][BOUND_X] * keyboard.scale,
|
||||
y: this.keyboard.getY() + this.bounds[i][BOUND_Y] * keyboard.scale,
|
||||
width: this.bounds[i][BOUND_W] * keyboard.scale,
|
||||
height: this.bounds[i][BOUND_H] * keyboard.scale,
|
||||
subImage: {width: this.bounds[i][BOUND_W], height: this.bounds[i][BOUND_H], x: this.bounds[i][BOUND_X], y: (KEYBOARD_HEIGHT * this.keyState) + this.bounds[i][BOUND_Y]},
|
||||
alpha: 1,
|
||||
visible: tthis.keyboard.visible
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function Keyboard() {
|
||||
Keyboard = (function(params) {
|
||||
if (params === undefined) {
|
||||
params = {};
|
||||
}
|
||||
var tthis = this;
|
||||
this.focussed_key = -1;
|
||||
this.scale = windowDimensions.x / KEYBOARD_WIDTH;
|
||||
this.scale = (windowDimensions.x / KEYBOARD_WIDTH) * KEYBOARD_SCALE_MULTIPLIER;
|
||||
this.shift = false;
|
||||
this.visible = params.visible != undefined ? params.visible : true;
|
||||
this.width = function() {
|
||||
return KEYBOARD_WIDTH * tthis.scale;
|
||||
};
|
||||
|
@ -301,17 +201,33 @@ function Keyboard() {
|
|||
this.getY = function() {
|
||||
return windowDimensions.y - this.height();
|
||||
};
|
||||
this.background = Overlays.addOverlay("image", {
|
||||
x: this.getX(),
|
||||
y: this.getY(),
|
||||
width: this.width(),
|
||||
height: this.height(),
|
||||
subImage: {width: KEYBOARD_WIDTH, height: KEYBOARD_HEIGHT, y: KEYBOARD_HEIGHT * KBD_BACKGROUND},
|
||||
imageURL: KEYBOARD_URL,
|
||||
alpha: 1
|
||||
});
|
||||
if (THREE_D_MODE) {
|
||||
this.background = Overlays.addOverlay("billboard", {
|
||||
scale: 1,
|
||||
position: MyAvatar.position,
|
||||
rotation: MyAvatar.rotation,
|
||||
width: this.width(),
|
||||
height: this.height(),
|
||||
subImage: {width: KEYBOARD_WIDTH, height: KEYBOARD_HEIGHT, y: KEYBOARD_HEIGHT * KBD_BACKGROUND},
|
||||
isFacingAvatar: false,
|
||||
url: KEYBOARD_URL,
|
||||
alpha: 1,
|
||||
visible: this.visible
|
||||
});
|
||||
} else {
|
||||
this.background = Overlays.addOverlay("image", {
|
||||
x: this.getX(),
|
||||
y: this.getY(),
|
||||
width: this.width(),
|
||||
height: this.height(),
|
||||
subImage: {width: KEYBOARD_WIDTH, height: KEYBOARD_HEIGHT, y: KEYBOARD_HEIGHT * KBD_BACKGROUND},
|
||||
imageURL: KEYBOARD_URL,
|
||||
alpha: 1,
|
||||
visible: this.visible
|
||||
});
|
||||
}
|
||||
this.rescale = function() {
|
||||
this.scale = windowDimensions.x / KEYBOARD_WIDTH;
|
||||
this.scale = (windowDimensions.x / KEYBOARD_WIDTH) * KEYBOARD_SCALE_MULTIPLIER;
|
||||
Overlays.editOverlay(tthis.background, {
|
||||
x: this.getX(),
|
||||
y: this.getY(),
|
||||
|
@ -349,6 +265,9 @@ function Keyboard() {
|
|||
};
|
||||
|
||||
this.pressFocussedKey = function() {
|
||||
if (!tthis.visible) {
|
||||
return tthis;
|
||||
}
|
||||
if (tthis.focussed_key != -1) {
|
||||
if (tthis.keys[tthis.focussed_key].event == 'shift') {
|
||||
tthis.toggleShift();
|
||||
|
@ -402,6 +321,32 @@ function Keyboard() {
|
|||
for (var i = 0; i < this.keys.length; i++) {
|
||||
this.keys[i].remove();
|
||||
}
|
||||
// resets the cursor and magnifier
|
||||
this.updateVisibility(false);
|
||||
};
|
||||
|
||||
this.show = function() {
|
||||
tthis.updateVisibility(true);
|
||||
};
|
||||
|
||||
this.hide = function() {
|
||||
tthis.updateVisibility(false);
|
||||
};
|
||||
|
||||
this.toggle = function() {
|
||||
tthis.updateVisibility(!tthis.visible);
|
||||
};
|
||||
|
||||
this.updateVisibility = function(visible) {
|
||||
tthis.visible = visible;
|
||||
if (HMD.magnifier == visible) {
|
||||
HMD.toggleMagnifier();
|
||||
}
|
||||
Window.cursorVisible = !visible;
|
||||
Overlays.editOverlay(tthis.background, { visible: tthis.visible });
|
||||
for (var i = 0; i < this.keys.length; i++) {
|
||||
this.keys[i].updateVisibility();
|
||||
}
|
||||
};
|
||||
|
||||
this.onKeyPress = null;
|
||||
|
@ -502,97 +447,94 @@ function Keyboard() {
|
|||
|
||||
{bounds: [[899, 355, 263, 67]], event: 'submit'}
|
||||
];
|
||||
|
||||
for (var i = 0; i < keyProperties.length; i++) {
|
||||
this.keys.push(new KeyboardKey(this, keyProperties[i]));
|
||||
}
|
||||
this.keyboardTextureLoaded = function() {
|
||||
if (Overlays.isLoaded(tthis.background)) {
|
||||
Script.clearInterval(tthis.keyboardTextureLoaded_timer);
|
||||
for (var i = 0; i < keyProperties.length; i++) {
|
||||
tthis.keys.push(new KeyboardKey(tthis, keyProperties[i]));
|
||||
}
|
||||
if (keyboard.onFullyLoaded != null) {
|
||||
tthis.onFullyLoaded();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.keyboardTextureLoaded_timer = Script.setInterval(this.keyboardTextureLoaded, 250);
|
||||
}
|
||||
});
|
||||
|
||||
function Cursor() {
|
||||
Cursor = (function(params) {
|
||||
if (params === undefined) {
|
||||
params = {};
|
||||
}
|
||||
var tthis = this;
|
||||
this.x = windowDimensions.x / 2;
|
||||
this.y = windowDimensions.y / 2;
|
||||
this.overlay = Overlays.addOverlay("image", {
|
||||
x: this.x,
|
||||
y: this.y,
|
||||
width: CURSOR_WIDTH,
|
||||
height: CURSOR_HEIGHT,
|
||||
imageURL: CURSOR_URL,
|
||||
alpha: 1
|
||||
});
|
||||
this.remove = function() {
|
||||
Overlays.deleteOverlay(this.overlay);
|
||||
this.initialize = function() {
|
||||
this.visible = params.visible != undefined ? params.visible : true;
|
||||
this.x = windowDimensions.x / 2;
|
||||
this.y = windowDimensions.y / 2;
|
||||
this.overlay = Overlays.addOverlay("image", {
|
||||
x: this.x,
|
||||
y: this.y,
|
||||
width: CURSOR_WIDTH,
|
||||
height: CURSOR_HEIGHT,
|
||||
imageURL: CURSOR_URL,
|
||||
alpha: 1,
|
||||
visible: this.visible
|
||||
});
|
||||
this.remove = function() {
|
||||
Overlays.deleteOverlay(this.overlay);
|
||||
};
|
||||
this.getPosition = function() {
|
||||
return {x: tthis.getX(), y: tthis.getY()};
|
||||
};
|
||||
this.getX = function() {
|
||||
return tthis.x;
|
||||
};
|
||||
this.getY = function() {
|
||||
return tthis.y;
|
||||
};
|
||||
this.show = function() {
|
||||
tthis.updateVisibility(true);
|
||||
};
|
||||
this.hide = function() {
|
||||
tthis.updateVisibility(false);
|
||||
};
|
||||
this.toggle = function() {
|
||||
tthis.updateVisibility(!tthis.visible);
|
||||
};
|
||||
this.updateVisibility = function(visible) {
|
||||
tthis.visible = visible;
|
||||
Overlays.editOverlay(this.overlay, { visible: tthis.visible });
|
||||
};
|
||||
this.onUpdate = null;
|
||||
this.update = function() {
|
||||
var newWindowDimensions = Controller.getViewportDimensions();
|
||||
if (newWindowDimensions.x != windowDimensions.x || newWindowDimensions.y != windowDimensions.y) {
|
||||
windowDimensions = newWindowDimensions;
|
||||
keyboard.rescale();
|
||||
Overlays.editOverlay(text, {
|
||||
y: windowDimensions.y - keyboard.height() - 260,
|
||||
width: windowDimensions.x
|
||||
});
|
||||
}
|
||||
var editobject = {};
|
||||
var hudLookatPosition = HMD.getHUDLookAtPosition2D();
|
||||
if (hudLookatPosition === null) {
|
||||
return;
|
||||
}
|
||||
if (tthis.x !== hudLookatPosition.x) {
|
||||
tthis.x = hudLookatPosition.x;
|
||||
editobject.x = tthis.x - (CURSOR_WIDTH / 2);
|
||||
}
|
||||
if (tthis.y !== hudLookatPosition.y) {
|
||||
tthis.y = hudLookatPosition.y;
|
||||
editobject.y = tthis.y - (CURSOR_HEIGHT / 2);
|
||||
}
|
||||
if (Object.keys(editobject).length > 0) {
|
||||
Overlays.editOverlay(tthis.overlay, editobject);
|
||||
if (tthis.onUpdate != null) {
|
||||
tthis.onUpdate(tthis.getPosition());
|
||||
}
|
||||
}
|
||||
};
|
||||
Script.update.connect(this.update);
|
||||
};
|
||||
this.getPosition = function() {
|
||||
return {x: tthis.getX(), y: tthis.getY()};
|
||||
};
|
||||
this.getX = function() {
|
||||
return tthis.x;
|
||||
};
|
||||
this.getY = function() {
|
||||
return tthis.y;
|
||||
};
|
||||
this.onUpdate = null;
|
||||
this.update = function() {
|
||||
var newWindowDimensions = Controller.getViewportDimensions();
|
||||
if (newWindowDimensions.x != windowDimensions.x || newWindowDimensions.y != windowDimensions.y) {
|
||||
windowDimensions = newWindowDimensions;
|
||||
keyboard.rescale();
|
||||
Overlays.editOverlay(text, {
|
||||
y: windowDimensions.y - keyboard.height() - 260,
|
||||
width: windowDimensions.x
|
||||
});
|
||||
}
|
||||
var editobject = {};
|
||||
if (MyAvatar.getHeadFinalYaw() <= VIEW_ANGLE_BY_TWO && MyAvatar.getHeadFinalYaw() >= -1 * VIEW_ANGLE_BY_TWO) {
|
||||
angle = ((-1 * MyAvatar.getHeadFinalYaw()) + VIEW_ANGLE_BY_TWO) / VIEW_ANGLE;
|
||||
tthis.x = angle * windowDimensions.x;
|
||||
editobject.x = tthis.x - (CURSOR_WIDTH / 2);
|
||||
}
|
||||
if (MyAvatar.getHeadFinalPitch() <= VIEW_ANGLE_BY_TWO && MyAvatar.getHeadFinalPitch() >= -1 * VIEW_ANGLE_BY_TWO) {
|
||||
angle = ((-1 * MyAvatar.getHeadFinalPitch()) + VIEW_ANGLE_BY_TWO) / VIEW_ANGLE;
|
||||
tthis.y = angle * windowDimensions.y;
|
||||
editobject.y = tthis.y - (CURSOR_HEIGHT / 2);
|
||||
}
|
||||
if (Object.keys(editobject).length > 0) {
|
||||
Overlays.editOverlay(tthis.overlay, editobject);
|
||||
if (tthis.onUpdate != null) {
|
||||
tthis.onUpdate(tthis.getPosition());
|
||||
}
|
||||
}
|
||||
};
|
||||
Script.update.connect(this.update);
|
||||
}
|
||||
|
||||
function keyPressEvent(event) {
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.pressFocussedKey();
|
||||
}
|
||||
}
|
||||
|
||||
function keyReleaseEvent(event) {
|
||||
if (event.key === SPACEBAR_CHARCODE) {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
keyboard.remove();
|
||||
cursor.remove();
|
||||
Overlays.deleteOverlay(text);
|
||||
Overlays.deleteOverlay(textSizeMeasureOverlay);
|
||||
Controller.releaseKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
}
|
||||
Controller.captureKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
});
|
|
@ -24,7 +24,9 @@ endif ()
|
|||
|
||||
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(shared networking audio-client avatars)
|
||||
include_dependency_includes()
|
||||
|
|
|
@ -32,8 +32,6 @@ elseif (WIN32)
|
|||
set(GL_HEADERS "#include <windowshacks.h>\n#include <GL/glew.h>\n#include <GL/wglew.h>")
|
||||
endif ()
|
||||
|
||||
# set up the external glm library
|
||||
include_glm()
|
||||
include_bullet()
|
||||
|
||||
# create the InterfaceConfig.h file based on GL_HEADERS above
|
||||
|
@ -109,6 +107,11 @@ endif()
|
|||
# create the executable, make it a bundle on OS X
|
||||
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
|
||||
|
||||
# set up the external glm library
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS})
|
||||
|
||||
# link required hifi libraries
|
||||
link_hifi_libraries(shared octree environment gpu model fbx metavoxels networking entities avatars
|
||||
audio audio-client animation script-engine physics
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
#include <HFBackEvent.h>
|
||||
#include <LogHandler.h>
|
||||
#include <MainWindow.h>
|
||||
#include <ModelEntityItem.h>
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <OctalCode.h>
|
||||
#include <OctreeSceneStats.h>
|
||||
|
@ -110,6 +111,7 @@
|
|||
#include "scripting/AccountScriptingInterface.h"
|
||||
#include "scripting/AudioDeviceScriptingInterface.h"
|
||||
#include "scripting/ClipboardScriptingInterface.h"
|
||||
#include "scripting/HMDScriptingInterface.h"
|
||||
#include "scripting/JoystickScriptingInterface.h"
|
||||
#include "scripting/GlobalServicesScriptingInterface.h"
|
||||
#include "scripting/LocationScriptingInterface.h"
|
||||
|
@ -211,6 +213,8 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
auto addressManager = DependencyManager::set<AddressManager>();
|
||||
auto nodeList = DependencyManager::set<NodeList>(NodeType::Agent, listenPort);
|
||||
auto geometryCache = DependencyManager::set<GeometryCache>();
|
||||
auto scriptCache = DependencyManager::set<ScriptCache>();
|
||||
auto soundCache = DependencyManager::set<SoundCache>();
|
||||
auto glowEffect = DependencyManager::set<GlowEffect>();
|
||||
auto faceshift = DependencyManager::set<Faceshift>();
|
||||
auto audio = DependencyManager::set<AudioClient>();
|
||||
|
@ -523,13 +527,21 @@ void Application::aboutToQuit() {
|
|||
}
|
||||
|
||||
void Application::cleanupBeforeQuit() {
|
||||
// make sure we don't call the idle timer any more
|
||||
delete idleTimer;
|
||||
|
||||
// save state
|
||||
QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection);
|
||||
_settingsThread.quit();
|
||||
saveSettings();
|
||||
_window->saveGeometry();
|
||||
|
||||
// TODO: now that this is in cleanupBeforeQuit do we really need it to stop and force
|
||||
// an event loop to send the packet?
|
||||
UserActivityLogger::getInstance().close();
|
||||
|
||||
// let the avatar mixer know we're out
|
||||
MyAvatar::sendKillAvatar();
|
||||
|
||||
// stop the AudioClient
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
|
||||
|
@ -540,16 +552,12 @@ void Application::cleanupBeforeQuit() {
|
|||
}
|
||||
|
||||
Application::~Application() {
|
||||
EntityTree* tree = _entities.getTree();
|
||||
tree->lockForWrite();
|
||||
_entities.getTree()->setSimulation(NULL);
|
||||
tree->unlock();
|
||||
|
||||
qInstallMessageHandler(NULL);
|
||||
|
||||
_window->saveGeometry();
|
||||
|
||||
// make sure we don't call the idle timer any more
|
||||
delete idleTimer;
|
||||
|
||||
// let the avatar mixer know we're out
|
||||
MyAvatar::sendKillAvatar();
|
||||
|
||||
// ask the datagram processing thread to quit and wait until it is done
|
||||
_nodeThread->quit();
|
||||
|
@ -561,13 +569,18 @@ Application::~Application() {
|
|||
Menu::getInstance()->deleteLater();
|
||||
|
||||
_myAvatar = NULL;
|
||||
|
||||
ModelEntityItem::cleanupLoadedAnimations() ;
|
||||
|
||||
DependencyManager::destroy<GLCanvas>();
|
||||
|
||||
qDebug() << "start destroying ResourceCaches Application::~Application() line:" << __LINE__;
|
||||
DependencyManager::destroy<AnimationCache>();
|
||||
DependencyManager::destroy<TextureCache>();
|
||||
DependencyManager::destroy<GeometryCache>();
|
||||
DependencyManager::destroy<ScriptCache>();
|
||||
DependencyManager::destroy<SoundCache>();
|
||||
qDebug() << "done destroying ResourceCaches Application::~Application() line:" << __LINE__;
|
||||
}
|
||||
|
||||
void Application::initializeGL() {
|
||||
|
@ -3466,7 +3479,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
||||
scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
|
||||
scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
|
||||
scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
|
||||
|
||||
|
@ -3480,6 +3493,10 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
|
||||
scriptEngine->registerGlobalObject("UndoStack", &_undoStackScriptingInterface);
|
||||
|
||||
QScriptValue hmdInterface = scriptEngine->registerGlobalObject("HMD", &HMDScriptingInterface::getInstance());
|
||||
scriptEngine->registerFunction(hmdInterface, "getHUDLookAtPosition2D", HMDScriptingInterface::getHUDLookAtPosition2D, 0);
|
||||
scriptEngine->registerFunction(hmdInterface, "getHUDLookAtPosition3D", HMDScriptingInterface::getHUDLookAtPosition3D, 0);
|
||||
|
||||
#ifdef HAVE_RTMIDI
|
||||
scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
|
||||
#endif
|
||||
|
|
|
@ -129,12 +129,12 @@ void DatagramProcessor::processDatagrams() {
|
|||
|
||||
if (incomingType == PacketTypeMuteEnvironment) {
|
||||
glm::vec3 position;
|
||||
float radius, distance;
|
||||
float radius;
|
||||
|
||||
int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment);
|
||||
memcpy(&position, incomingPacket.constData() + headerSize, sizeof(glm::vec3));
|
||||
memcpy(&radius, incomingPacket.constData() + headerSize + sizeof(glm::vec3), sizeof(float));
|
||||
distance = glm::distance(DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition(),
|
||||
float distance = glm::distance(DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition(),
|
||||
position);
|
||||
|
||||
mute = mute && (distance < radius);
|
||||
|
|
|
@ -688,7 +688,7 @@ void OculusManager::getEulerAngles(float& yaw, float& pitch, float& roll) {
|
|||
roll = 0.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
glm::vec3 OculusManager::getRelativePosition() {
|
||||
#if (defined(__APPLE__) || defined(_WIN32)) && HAVE_LIBOVR
|
||||
ovrTrackingState trackingState = ovrHmd_GetTrackingState(_ovrHmd, ovr_GetTimeInSeconds());
|
||||
|
|
56
interface/src/scripting/HMDScriptingInterface.cpp
Normal file
56
interface/src/scripting/HMDScriptingInterface.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
//
|
||||
// HMDScriptingInterface.cpp
|
||||
// interface/src/scripting
|
||||
//
|
||||
// Created by Thijs Wenker on 1/12/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "HMDScriptingInterface.h"
|
||||
|
||||
#include <avatar/AvatarManager.h>
|
||||
|
||||
HMDScriptingInterface& HMDScriptingInterface::getInstance() {
|
||||
static HMDScriptingInterface sharedInstance;
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
bool HMDScriptingInterface::getHUDLookAtPosition3D(glm::vec3& result) const {
|
||||
Camera* camera = Application::getInstance()->getCamera();
|
||||
glm::vec3 position = camera->getPosition();
|
||||
glm::quat orientation = camera->getOrientation();
|
||||
|
||||
glm::vec3 direction = orientation * glm::vec3(0.0f, 0.0f, -1.0f);
|
||||
|
||||
ApplicationOverlay& applicationOverlay = Application::getInstance()->getApplicationOverlay();
|
||||
|
||||
return applicationOverlay.calculateRayUICollisionPoint(position, direction, result);
|
||||
}
|
||||
|
||||
QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine) {
|
||||
|
||||
glm::vec3 hudIntersection;
|
||||
|
||||
if ((&HMDScriptingInterface::getInstance())->getHUDLookAtPosition3D(hudIntersection)) {
|
||||
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
glm::vec3 sphereCenter = myAvatar->getDefaultEyePosition();
|
||||
glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * (hudIntersection - sphereCenter);
|
||||
glm::quat rotation = ::rotationBetween(glm::vec3(0.0f, 0.0f, -1.0f), direction);
|
||||
glm::vec3 eulers = ::safeEulerAngles(rotation);
|
||||
return qScriptValueFromValue<glm::vec2>(engine, Application::getInstance()->getApplicationOverlay()
|
||||
.sphericalToOverlay(glm::vec2(eulers.y, -eulers.x)));
|
||||
}
|
||||
return QScriptValue::NullValue;
|
||||
}
|
||||
|
||||
QScriptValue HMDScriptingInterface::getHUDLookAtPosition3D(QScriptContext* context, QScriptEngine* engine) {
|
||||
glm::vec3 result;
|
||||
HMDScriptingInterface* hmdInterface = &HMDScriptingInterface::getInstance();
|
||||
if ((&HMDScriptingInterface::getInstance())->getHUDLookAtPosition3D(result)) {
|
||||
return qScriptValueFromValue<glm::vec3>(engine, result);
|
||||
}
|
||||
return QScriptValue::NullValue;
|
||||
}
|
42
interface/src/scripting/HMDScriptingInterface.h
Normal file
42
interface/src/scripting/HMDScriptingInterface.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
//
|
||||
// HMDScriptingInterface.h
|
||||
// interface/src/scripting
|
||||
//
|
||||
// Created by Thijs Wenker on 1/12/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_HMDScriptingInterface_h
|
||||
#define hifi_HMDScriptingInterface_h
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "devices/OculusManager.h"
|
||||
|
||||
class HMDScriptingInterface : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool magnifier READ getMagnifier)
|
||||
Q_PROPERTY(bool active READ isHMDMode)
|
||||
public:
|
||||
static HMDScriptingInterface& getInstance();
|
||||
|
||||
static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine);
|
||||
static QScriptValue getHUDLookAtPosition3D(QScriptContext* context, QScriptEngine* engine);
|
||||
|
||||
public slots:
|
||||
void toggleMagnifier() { Application::getInstance()->getApplicationOverlay().toggleMagnifier(); };
|
||||
|
||||
private:
|
||||
HMDScriptingInterface() {};
|
||||
bool getMagnifier() const { return Application::getInstance()->getApplicationOverlay().hasMagnifier(); };
|
||||
bool isHMDMode() const { return Application::getInstance()->isHMDMode(); }
|
||||
|
||||
bool getHUDLookAtPosition3D(glm::vec3& result) const;
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_HMDScriptingInterface_h
|
|
@ -139,6 +139,7 @@ ApplicationOverlay::ApplicationOverlay() :
|
|||
_alpha(1.0f),
|
||||
_oculusUIRadius(1.0f),
|
||||
_crosshairTexture(0),
|
||||
_magnifier(true),
|
||||
_previousBorderWidth(-1),
|
||||
_previousBorderHeight(-1),
|
||||
_previousMagnifierBottomLeft(),
|
||||
|
@ -559,7 +560,7 @@ void ApplicationOverlay::renderPointers() {
|
|||
|
||||
_reticlePosition[MOUSE] = position;
|
||||
_reticleActive[MOUSE] = true;
|
||||
_magActive[MOUSE] = true;
|
||||
_magActive[MOUSE] = _magnifier;
|
||||
_reticleActive[LEFT_CONTROLLER] = false;
|
||||
_reticleActive[RIGHT_CONTROLLER] = false;
|
||||
} else if (qApp->getLastMouseMoveWasSimulated() && Menu::getInstance()->isOptionChecked(MenuOption::SixenseMouseInput)) {
|
||||
|
@ -718,6 +719,9 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) {
|
|||
|
||||
//Renders a small magnification of the currently bound texture at the coordinates
|
||||
void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool showBorder) {
|
||||
if (!_magnifier) {
|
||||
return;
|
||||
}
|
||||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
|
||||
const int widgetWidth = glCanvas->width();
|
||||
|
@ -789,7 +793,7 @@ void ApplicationOverlay::renderAudioMeter() {
|
|||
// Audio VU Meter and Mute Icon
|
||||
const int MUTE_ICON_SIZE = 24;
|
||||
const int MUTE_ICON_PADDING = 10;
|
||||
const int AUDIO_METER_WIDTH = MIRROR_VIEW_WIDTH - MUTE_ICON_SIZE - MUTE_ICON_PADDING;
|
||||
const int AUDIO_METER_WIDTH = MIRROR_VIEW_WIDTH - MUTE_ICON_SIZE - MUTE_ICON_PADDING;
|
||||
const int AUDIO_METER_SCALE_WIDTH = AUDIO_METER_WIDTH - 2 ;
|
||||
const int AUDIO_METER_HEIGHT = 8;
|
||||
const int AUDIO_METER_GAP = 5;
|
||||
|
@ -845,8 +849,8 @@ void ApplicationOverlay::renderAudioMeter() {
|
|||
audioMeterY += AUDIO_METER_HEIGHT;
|
||||
|
||||
// Draw audio meter background Quad
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X, audioMeterY, AUDIO_METER_WIDTH, AUDIO_METER_HEIGHT,
|
||||
glm::vec4(0.298f, 0.757f, 0.722f, 1));
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X, audioMeterY, AUDIO_METER_WIDTH, AUDIO_METER_HEIGHT,
|
||||
glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
if (audioLevel > AUDIO_RED_START) {
|
||||
glm::vec4 quadColor;
|
||||
|
|
|
@ -37,6 +37,9 @@ public:
|
|||
QPoint getPalmClickLocation(const PalmData *palm) const;
|
||||
bool calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction, glm::vec3& result) const;
|
||||
|
||||
bool hasMagnifier() const { return _magnifier; }
|
||||
void toggleMagnifier() { _magnifier = !_magnifier; }
|
||||
|
||||
float getOculusUIAngularSize() const { return _oculusUIAngularSize; }
|
||||
void setOculusUIAngularSize(float oculusUIAngularSize) { _oculusUIAngularSize = oculusUIAngularSize; }
|
||||
|
||||
|
@ -109,7 +112,8 @@ private:
|
|||
bool _magActive[NUMBER_OF_RETICLES];
|
||||
float _magSizeMult[NUMBER_OF_RETICLES];
|
||||
quint64 _lastMouseMove;
|
||||
|
||||
bool _magnifier;
|
||||
|
||||
float _alpha;
|
||||
float _oculusUIRadius;
|
||||
float _trailingAudioLoudness;
|
||||
|
|
|
@ -59,8 +59,8 @@ CachesSizeDialog::CachesSizeDialog(QWidget* parent) :
|
|||
void CachesSizeDialog::confirmClicked(bool checked) {
|
||||
DependencyManager::get<AnimationCache>()->setUnusedResourceCacheSize(_animations->value() * BYTES_PER_MEGABYTES);
|
||||
DependencyManager::get<GeometryCache>()->setUnusedResourceCacheSize(_geometries->value() * BYTES_PER_MEGABYTES);
|
||||
ScriptCache::getInstance()->setUnusedResourceCacheSize(_scripts->value() * BYTES_PER_MEGABYTES);
|
||||
SoundCache::getInstance().setUnusedResourceCacheSize(_sounds->value() * BYTES_PER_MEGABYTES);
|
||||
DependencyManager::get<ScriptCache>()->setUnusedResourceCacheSize(_scripts->value() * BYTES_PER_MEGABYTES);
|
||||
DependencyManager::get<SoundCache>()->setUnusedResourceCacheSize(_sounds->value() * BYTES_PER_MEGABYTES);
|
||||
DependencyManager::get<TextureCache>()->setUnusedResourceCacheSize(_textures->value() * BYTES_PER_MEGABYTES);
|
||||
|
||||
QDialog::close();
|
||||
|
@ -69,8 +69,8 @@ void CachesSizeDialog::confirmClicked(bool checked) {
|
|||
void CachesSizeDialog::resetClicked(bool checked) {
|
||||
_animations->setValue(DependencyManager::get<AnimationCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
_geometries->setValue(DependencyManager::get<GeometryCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
_scripts->setValue(ScriptCache::getInstance()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
_sounds->setValue(SoundCache::getInstance().getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
_scripts->setValue(DependencyManager::get<ScriptCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
_sounds->setValue(DependencyManager::get<SoundCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
_textures->setValue(DependencyManager::get<TextureCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,9 @@ LoginDialog::LoginDialog(QWidget* parent) :
|
|||
this, &LoginDialog::handleLoginClicked);
|
||||
connect(_ui->closeButton, &QPushButton::clicked,
|
||||
this, &LoginDialog::close);
|
||||
|
||||
// Initialize toggle connection
|
||||
toggleQAction();
|
||||
};
|
||||
|
||||
LoginDialog::~LoginDialog() {
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
|
||||
#include "Rectangle3DOverlay.h"
|
||||
|
||||
Rectangle3DOverlay::Rectangle3DOverlay() {
|
||||
Rectangle3DOverlay::Rectangle3DOverlay() :
|
||||
_geometryCacheID(DependencyManager::get<GeometryCache>()->allocateID())
|
||||
{
|
||||
}
|
||||
|
||||
Rectangle3DOverlay::Rectangle3DOverlay(const Rectangle3DOverlay* rectangle3DOverlay) :
|
||||
|
|
|
@ -8,17 +8,13 @@ link_hifi_libraries(audio)
|
|||
# append audio includes to our list of includes to bubble
|
||||
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${HIFI_LIBRARY_DIR}/audio/src")
|
||||
|
||||
set(GVERB_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/gverb")
|
||||
# have CMake grab Gverb from git and then set up linking and directory include
|
||||
add_dependency_external_project(gverb)
|
||||
|
||||
# As Gverb is currently the only reverb library, it's required.
|
||||
find_package(Gverb REQUIRED)
|
||||
|
||||
file(GLOB GVERB_SRCS ${GVERB_SRC_DIRS}/*.c)
|
||||
add_library(gverb STATIC ${GVERB_SRCS})
|
||||
target_link_libraries(${TARGET_NAME} gverb)
|
||||
|
||||
# append gverb includes to our list of includes to bubble
|
||||
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${GVERB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} ${GVERB_LIBRARIES})
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${GVERB_INCLUDE_DIRS})
|
||||
|
||||
# we use libsoxr for resampling
|
||||
find_package(Soxr REQUIRED)
|
||||
|
|
14
libraries/audio-client/external/gverb/readme.txt
vendored
14
libraries/audio-client/external/gverb/readme.txt
vendored
|
@ -1,14 +0,0 @@
|
|||
Instructions for adding the Gverb library to audio-client
|
||||
(This is a required library)
|
||||
Clément Brisset, October 22nd, 2014
|
||||
|
||||
1. Go to https://github.com/highfidelity/gverb
|
||||
Or download the sources directly via this link:
|
||||
https://github.com/highfidelity/gverb/archive/master.zip
|
||||
|
||||
2. Extract the archive
|
||||
|
||||
3. Place the directories “include” and “src” in libraries/audio-client/external/gverb
|
||||
(Normally next to this readme)
|
||||
|
||||
4. Clear your build directory, run cmake, build and you should be all set.
|
|
@ -33,6 +33,11 @@
|
|||
#include <QtMultimedia/QAudioInput>
|
||||
#include <QtMultimedia/QAudioOutput>
|
||||
|
||||
extern "C" {
|
||||
#include <gverb/gverb.h>
|
||||
#include <gverb/gverbdsp.h>
|
||||
}
|
||||
|
||||
#include <soxr.h>
|
||||
|
||||
#include <NodeList.h>
|
||||
|
@ -888,13 +893,14 @@ void AudioClient::processReceivedSamples(const QByteArray& inputBuffer, QByteArr
|
|||
|
||||
void AudioClient::sendMuteEnvironmentPacket() {
|
||||
QByteArray mutePacket = byteArrayWithPopulatedHeader(PacketTypeMuteEnvironment);
|
||||
QDataStream mutePacketStream(&mutePacket, QIODevice::Append);
|
||||
int headerSize = mutePacket.size();
|
||||
|
||||
const float MUTE_RADIUS = 50;
|
||||
|
||||
glm::vec3 currentSourcePosition = _positionGetter();
|
||||
mutePacketStream.writeBytes(reinterpret_cast<const char *>(¤tSourcePosition), sizeof(glm::vec3));
|
||||
mutePacketStream.writeBytes(reinterpret_cast<const char *>(&MUTE_RADIUS), sizeof(float));
|
||||
mutePacket.resize(mutePacket.size() + sizeof(glm::vec3) + sizeof(float));
|
||||
memcpy(mutePacket.data() + headerSize, ¤tSourcePosition, sizeof(glm::vec3));
|
||||
memcpy(mutePacket.data() + headerSize + sizeof(glm::vec3), &MUTE_RADIUS, sizeof(float));
|
||||
|
||||
// grab our audio mixer from the NodeList, if it exists
|
||||
auto nodelist = DependencyManager::get<NodeList>();
|
||||
|
|
|
@ -47,10 +47,7 @@
|
|||
#pragma warning( disable : 4273 )
|
||||
#pragma warning( disable : 4305 )
|
||||
#endif
|
||||
extern "C" {
|
||||
#include <gverb.h>
|
||||
#include <gverbdsp.h>
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
@ -68,6 +65,7 @@ class QAudioInput;
|
|||
class QAudioOutput;
|
||||
class QIODevice;
|
||||
struct soxr;
|
||||
typedef struct ty_gverb ty_gverb;
|
||||
|
||||
typedef glm::vec3 (*AudioPositionGetter)();
|
||||
typedef glm::quat (*AudioOrientationGetter)();
|
||||
|
|
|
@ -3,7 +3,9 @@ set(TARGET_NAME audio)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network)
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(networking shared)
|
||||
|
||||
|
|
|
@ -15,11 +15,6 @@
|
|||
|
||||
static int soundPointerMetaTypeId = qRegisterMetaType<SharedSoundPointer>();
|
||||
|
||||
SoundCache& SoundCache::getInstance() {
|
||||
static SoundCache staticInstance;
|
||||
return staticInstance;
|
||||
}
|
||||
|
||||
SoundCache::SoundCache(QObject* parent) :
|
||||
ResourceCache(parent)
|
||||
{
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
#include "Sound.h"
|
||||
|
||||
/// Scriptable interface for sound loading.
|
||||
class SoundCache : public ResourceCache {
|
||||
class SoundCache : public ResourceCache, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
static SoundCache& getInstance();
|
||||
|
||||
Q_INVOKABLE SharedSoundPointer getSound(const QUrl& url);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -3,7 +3,9 @@ set(TARGET_NAME avatars)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network Script)
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(audio shared networking)
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ set(TARGET_NAME entities-renderer)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Widgets OpenGL Network Script)
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(shared gpu script-engine render-utils)
|
||||
|
||||
|
|
|
@ -3,7 +3,10 @@ set(TARGET_NAME entities)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Network Script)
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
include_bullet()
|
||||
|
||||
link_hifi_libraries(avatars shared octree gpu model fbx networking animation)
|
||||
|
|
|
@ -194,6 +194,7 @@ public:
|
|||
bool containsBoundsProperties() const { return (_positionChanged || _dimensionsChanged); }
|
||||
bool containsPositionChange() const { return _positionChanged; }
|
||||
bool containsDimensionsChange() const { return _dimensionsChanged; }
|
||||
bool containsAnimationSettingsChange() const { return _animationSettingsChanged; }
|
||||
|
||||
float getGlowLevel() const { return _glowLevel; }
|
||||
float getLocalRenderAlpha() const { return _localRenderAlpha; }
|
||||
|
@ -256,12 +257,57 @@ inline void EntityItemProperties::setPosition(const glm::vec3& value)
|
|||
|
||||
|
||||
inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
|
||||
debug << "EntityItemProperties[" << "\n"
|
||||
<< " position:" << properties.getPosition() << "in meters" << "\n"
|
||||
<< " velocity:" << properties.getVelocity() << "in meters" << "\n"
|
||||
<< " last edited:" << properties.getLastEdited() << "\n"
|
||||
<< " edited ago:" << properties.getEditedAgo() << "\n"
|
||||
<< "]";
|
||||
debug << "EntityItemProperties[" << "\n";
|
||||
|
||||
// TODO: figure out why position and animationSettings don't seem to like the macro approach
|
||||
if (properties.containsPositionChange()) {
|
||||
debug << " position:" << properties.getPosition() << "in meters" << "\n";
|
||||
}
|
||||
if (properties.containsAnimationSettingsChange()) {
|
||||
debug << " animationSettings:" << properties.getAnimationSettings() << "\n";
|
||||
}
|
||||
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Dimensions, dimensions, "in meters");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Velocity, velocity, "in meters");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Visible, visible, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Rotation, rotation, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Density, density, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Gravity, gravity, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Damping, damping, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Lifetime, lifetime, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Script, script, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Color, color, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, ModelURL, modelURL, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, AnimationURL, animationURL, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, AnimationFPS, animationFPS, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, AnimationFrameIndex, animationFrameIndex, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, AnimationIsPlaying, animationIsPlaying, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, RegistrationPoint, registrationPoint, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, AngularVelocity, angularVelocity, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, AngularDamping, angularDamping, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, IgnoreForCollisions, ignoreForCollisions, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, CollisionsWillMove, collisionsWillMove, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, IsSpotlight, isSpotlight, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, DiffuseColor, diffuseColor, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, AmbientColor, ambientColor, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, SpecularColor, specularColor, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, ConstantAttenuation, constantAttenuation, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, LinearAttenuation, linearAttenuation, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, QuadraticAttenuation, quadraticAttenuation, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Exponent, exponent, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Cutoff, cutoff, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Locked, locked, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Textures, textures, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, UserData, userData, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Text, text, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, LineHeight, lineHeight, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, TextColor, textColor, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, BackgroundColor, backgroundColor, "");
|
||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, ShapeType, shapeType, "");
|
||||
|
||||
debug << " last edited:" << properties.getLastEdited() << "\n";
|
||||
debug << " edited ago:" << properties.getEditedAgo() << "\n";
|
||||
debug << "]";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
|
|
@ -321,6 +321,10 @@
|
|||
T _##n; \
|
||||
bool _##n##Changed;
|
||||
|
||||
#define DEBUG_PROPERTY_IF_CHANGED(D, P, N, n, x) \
|
||||
if (P.n##Changed()) { \
|
||||
D << " " << #n << ":" << P.get##N() << x << "\n"; \
|
||||
}
|
||||
|
||||
|
||||
#endif // hifi_EntityItemPropertiesMacros_h
|
||||
|
|
|
@ -592,6 +592,10 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char
|
|||
|
||||
// if the EntityItem exists, then update it
|
||||
if (existingEntity) {
|
||||
if (wantEditLogging()) {
|
||||
qDebug() << "User [" << senderNode->getUUID() << "] editing entity. ID:" << entityItemID;
|
||||
qDebug() << " properties:" << properties;
|
||||
}
|
||||
updateEntity(entityItemID, properties, senderNode->getCanAdjustLocks());
|
||||
existingEntity->markAsChangedOnServer();
|
||||
} else {
|
||||
|
|
|
@ -151,6 +151,9 @@ public:
|
|||
void emitEntityScriptChanging(const EntityItemID& entityItemID);
|
||||
|
||||
void setSimulation(EntitySimulation* simulation);
|
||||
|
||||
bool wantEditLogging() const { return _wantEditLogging; }
|
||||
void setWantEditLogging(bool value) { _wantEditLogging = value; }
|
||||
|
||||
signals:
|
||||
void deletingEntity(const EntityItemID& entityID);
|
||||
|
@ -180,6 +183,8 @@ private:
|
|||
QHash<EntityItemID, EntityTreeElement*> _entityToElementMap;
|
||||
|
||||
EntitySimulation* _simulation;
|
||||
|
||||
bool _wantEditLogging = false;
|
||||
};
|
||||
|
||||
#endif // hifi_EntityTree_h
|
||||
|
|
|
@ -163,16 +163,6 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
|
|||
|
||||
QMap<QString, AnimationPointer> ModelEntityItem::_loadedAnimations; // TODO: improve cleanup by leveraging the AnimationPointer(s)
|
||||
|
||||
// This class/instance will cleanup the animations once unloaded.
|
||||
class EntityAnimationsBookkeeper {
|
||||
public:
|
||||
~EntityAnimationsBookkeeper() {
|
||||
ModelEntityItem::cleanupLoadedAnimations();
|
||||
}
|
||||
};
|
||||
|
||||
EntityAnimationsBookkeeper modelAnimationsBookkeeperInstance;
|
||||
|
||||
void ModelEntityItem::cleanupLoadedAnimations() {
|
||||
foreach(AnimationPointer animation, _loadedAnimations) {
|
||||
animation.clear();
|
||||
|
|
|
@ -3,7 +3,9 @@ set(TARGET_NAME environment)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(shared networking)
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ set(TARGET_NAME fbx)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(shared gpu model networking octree)
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ set(TARGET_NAME gpu)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
||||
include_glm()
|
||||
|
||||
link_hifi_libraries(shared)
|
||||
|
||||
if (APPLE)
|
||||
|
|
|
@ -8,7 +8,9 @@ setup_hifi_library(Network Script Widgets)
|
|||
# link in the networking library
|
||||
link_hifi_libraries(shared networking)
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
# call macro to include our dependency includes and bubble them up via a property on our target
|
||||
include_dependency_includes()
|
|
@ -465,9 +465,9 @@ void Bitstream::writeRawDelta(const QScriptValue& value, const QScriptValue& ref
|
|||
} else if (reference.isArray()) {
|
||||
if (value.isArray()) {
|
||||
*this << false;
|
||||
int length = value.property(ScriptCache::getInstance()->getLengthString()).toInt32();
|
||||
int length = value.property(DependencyManager::get<ScriptCache>()->getLengthString()).toInt32();
|
||||
*this << length;
|
||||
int referenceLength = reference.property(ScriptCache::getInstance()->getLengthString()).toInt32();
|
||||
int referenceLength = reference.property(DependencyManager::get<ScriptCache>()->getLengthString()).toInt32();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (i < referenceLength) {
|
||||
writeDelta(value.property(i), reference.property(i));
|
||||
|
@ -555,7 +555,7 @@ void Bitstream::readRawDelta(QScriptValue& value, const QScriptValue& reference)
|
|||
} else {
|
||||
QVariant variant;
|
||||
readRawDelta(variant, reference.toVariant());
|
||||
value = ScriptCache::getInstance()->getEngine()->newVariant(variant);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newVariant(variant);
|
||||
}
|
||||
} else if (reference.isQObject()) {
|
||||
bool typeChanged;
|
||||
|
@ -566,7 +566,7 @@ void Bitstream::readRawDelta(QScriptValue& value, const QScriptValue& reference)
|
|||
} else {
|
||||
QObject* object;
|
||||
readRawDelta(object, reference.toQObject());
|
||||
value = ScriptCache::getInstance()->getEngine()->newQObject(object, QScriptEngine::ScriptOwnership);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newQObject(object, QScriptEngine::ScriptOwnership);
|
||||
}
|
||||
} else if (reference.isQMetaObject()) {
|
||||
bool typeChanged;
|
||||
|
@ -577,7 +577,7 @@ void Bitstream::readRawDelta(QScriptValue& value, const QScriptValue& reference)
|
|||
} else {
|
||||
const QMetaObject* metaObject;
|
||||
*this >> metaObject;
|
||||
value = ScriptCache::getInstance()->getEngine()->newQMetaObject(metaObject);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newQMetaObject(metaObject);
|
||||
}
|
||||
} else if (reference.isDate()) {
|
||||
bool typeChanged;
|
||||
|
@ -588,7 +588,7 @@ void Bitstream::readRawDelta(QScriptValue& value, const QScriptValue& reference)
|
|||
} else {
|
||||
QDateTime dateTime;
|
||||
*this >> dateTime;
|
||||
value = ScriptCache::getInstance()->getEngine()->newDate(dateTime);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newDate(dateTime);
|
||||
}
|
||||
} else if (reference.isRegExp()) {
|
||||
bool typeChanged;
|
||||
|
@ -599,7 +599,7 @@ void Bitstream::readRawDelta(QScriptValue& value, const QScriptValue& reference)
|
|||
} else {
|
||||
QRegExp regExp;
|
||||
*this >> regExp;
|
||||
value = ScriptCache::getInstance()->getEngine()->newRegExp(regExp);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newRegExp(regExp);
|
||||
}
|
||||
} else if (reference.isArray()) {
|
||||
bool typeChanged;
|
||||
|
@ -610,8 +610,8 @@ void Bitstream::readRawDelta(QScriptValue& value, const QScriptValue& reference)
|
|||
} else {
|
||||
int length;
|
||||
*this >> length;
|
||||
value = ScriptCache::getInstance()->getEngine()->newArray(length);
|
||||
int referenceLength = reference.property(ScriptCache::getInstance()->getLengthString()).toInt32();
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newArray(length);
|
||||
int referenceLength = reference.property(DependencyManager::get<ScriptCache>()->getLengthString()).toInt32();
|
||||
for (int i = 0; i < length; i++) {
|
||||
QScriptValue element;
|
||||
if (i < referenceLength) {
|
||||
|
@ -630,7 +630,7 @@ void Bitstream::readRawDelta(QScriptValue& value, const QScriptValue& reference)
|
|||
|
||||
} else {
|
||||
// start by shallow-copying the reference
|
||||
value = ScriptCache::getInstance()->getEngine()->newObject();
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newObject();
|
||||
for (QScriptValueIterator it(reference); it.hasNext(); ) {
|
||||
it.next();
|
||||
value.setProperty(it.scriptName(), it.value());
|
||||
|
@ -1036,7 +1036,7 @@ Bitstream& Bitstream::operator<<(const QScriptValue& value) {
|
|||
|
||||
} else if (value.isArray()) {
|
||||
writeScriptValueType(*this, ARRAY_SCRIPT_VALUE);
|
||||
int length = value.property(ScriptCache::getInstance()->getLengthString()).toInt32();
|
||||
int length = value.property(DependencyManager::get<ScriptCache>()->getLengthString()).toInt32();
|
||||
*this << length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
*this << value.property(i);
|
||||
|
@ -1087,37 +1087,37 @@ Bitstream& Bitstream::operator>>(QScriptValue& value) {
|
|||
case VARIANT_SCRIPT_VALUE: {
|
||||
QVariant variantValue;
|
||||
*this >> variantValue;
|
||||
value = ScriptCache::getInstance()->getEngine()->newVariant(variantValue);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newVariant(variantValue);
|
||||
break;
|
||||
}
|
||||
case QOBJECT_SCRIPT_VALUE: {
|
||||
QObject* object;
|
||||
*this >> object;
|
||||
ScriptCache::getInstance()->getEngine()->newQObject(object, QScriptEngine::ScriptOwnership);
|
||||
DependencyManager::get<ScriptCache>()->getEngine()->newQObject(object, QScriptEngine::ScriptOwnership);
|
||||
break;
|
||||
}
|
||||
case QMETAOBJECT_SCRIPT_VALUE: {
|
||||
const QMetaObject* metaObject;
|
||||
*this >> metaObject;
|
||||
ScriptCache::getInstance()->getEngine()->newQMetaObject(metaObject);
|
||||
DependencyManager::get<ScriptCache>()->getEngine()->newQMetaObject(metaObject);
|
||||
break;
|
||||
}
|
||||
case DATE_SCRIPT_VALUE: {
|
||||
QDateTime dateTime;
|
||||
*this >> dateTime;
|
||||
value = ScriptCache::getInstance()->getEngine()->newDate(dateTime);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newDate(dateTime);
|
||||
break;
|
||||
}
|
||||
case REGEXP_SCRIPT_VALUE: {
|
||||
QRegExp regExp;
|
||||
*this >> regExp;
|
||||
value = ScriptCache::getInstance()->getEngine()->newRegExp(regExp);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newRegExp(regExp);
|
||||
break;
|
||||
}
|
||||
case ARRAY_SCRIPT_VALUE: {
|
||||
int length;
|
||||
*this >> length;
|
||||
value = ScriptCache::getInstance()->getEngine()->newArray(length);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newArray(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
QScriptValue element;
|
||||
*this >> element;
|
||||
|
@ -1126,7 +1126,7 @@ Bitstream& Bitstream::operator>>(QScriptValue& value) {
|
|||
break;
|
||||
}
|
||||
case OBJECT_SCRIPT_VALUE: {
|
||||
value = ScriptCache::getInstance()->getEngine()->newObject();
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newObject();
|
||||
forever {
|
||||
QScriptString name;
|
||||
*this >> name;
|
||||
|
@ -1477,7 +1477,7 @@ Bitstream& Bitstream::operator>(QScriptString& string) {
|
|||
QString rawString;
|
||||
*this >> rawString;
|
||||
string = (rawString == INVALID_STRING) ? QScriptString() :
|
||||
ScriptCache::getInstance()->getEngine()->toStringHandle(rawString);
|
||||
DependencyManager::get<ScriptCache>()->getEngine()->toStringHandle(rawString);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -1828,7 +1828,7 @@ QJsonValue JSONWriter::getData(const QScriptValue& value) {
|
|||
} else if (value.isArray()) {
|
||||
object.insert("type", QString("ARRAY"));
|
||||
QJsonArray array;
|
||||
int length = value.property(ScriptCache::getInstance()->getLengthString()).toInt32();
|
||||
int length = value.property(DependencyManager::get<ScriptCache>()->getLengthString()).toInt32();
|
||||
for (int i = 0; i < length; i++) {
|
||||
array.append(getData(value.property(i)));
|
||||
}
|
||||
|
@ -2209,31 +2209,31 @@ void JSONReader::putData(const QJsonValue& data, QScriptValue& value) {
|
|||
} else if (type == "VARIANT") {
|
||||
QVariant variant;
|
||||
putData(object.value("value"), variant);
|
||||
value = ScriptCache::getInstance()->getEngine()->newVariant(variant);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newVariant(variant);
|
||||
|
||||
} else if (type == "QOBJECT") {
|
||||
QObject* qObject;
|
||||
putData(object.value("value"), qObject);
|
||||
value = ScriptCache::getInstance()->getEngine()->newQObject(qObject, QScriptEngine::ScriptOwnership);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newQObject(qObject, QScriptEngine::ScriptOwnership);
|
||||
|
||||
} else if (type == "QMETAOBJECT") {
|
||||
const QMetaObject* metaObject;
|
||||
putData(object.value("value"), metaObject);
|
||||
value = ScriptCache::getInstance()->getEngine()->newQMetaObject(metaObject);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newQMetaObject(metaObject);
|
||||
|
||||
} else if (type == "DATE") {
|
||||
QDateTime dateTime;
|
||||
putData(object.value("value"), dateTime);
|
||||
value = ScriptCache::getInstance()->getEngine()->newDate(dateTime);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newDate(dateTime);
|
||||
|
||||
} else if (type == "REGEXP") {
|
||||
QRegExp regExp;
|
||||
putData(object.value("value"), regExp);
|
||||
value = ScriptCache::getInstance()->getEngine()->newRegExp(regExp);
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newRegExp(regExp);
|
||||
|
||||
} else if (type == "ARRAY") {
|
||||
QJsonArray array = object.value("value").toArray();
|
||||
value = ScriptCache::getInstance()->getEngine()->newArray(array.size());
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newArray(array.size());
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
QScriptValue element;
|
||||
putData(array.at(i), element);
|
||||
|
@ -2241,7 +2241,7 @@ void JSONReader::putData(const QJsonValue& data, QScriptValue& value) {
|
|||
}
|
||||
} else if (type == "OBJECT") {
|
||||
QJsonObject jsonObject = object.value("value").toObject();
|
||||
value = ScriptCache::getInstance()->getEngine()->newObject();
|
||||
value = DependencyManager::get<ScriptCache>()->getEngine()->newObject();
|
||||
for (QJsonObject::const_iterator it = jsonObject.constBegin(); it != jsonObject.constEnd(); it++) {
|
||||
QScriptValue element;
|
||||
putData(it.value(), element);
|
||||
|
|
|
@ -663,7 +663,7 @@ void ParameterizedURLEditor::updateURL() {
|
|||
QByteArray valuePropertyName = widget->property("valuePropertyName").toByteArray();
|
||||
const QMetaObject* widgetMetaObject = widget->metaObject();
|
||||
QMetaProperty widgetProperty = widgetMetaObject->property(widgetMetaObject->indexOfProperty(valuePropertyName));
|
||||
parameters.insert(ScriptCache::getInstance()->getEngine()->toStringHandle(
|
||||
parameters.insert(DependencyManager::get<ScriptCache>()->getEngine()->toStringHandle(
|
||||
widget->property("parameterName").toString()), widgetProperty.read(widget));
|
||||
}
|
||||
}
|
||||
|
@ -677,7 +677,7 @@ void ParameterizedURLEditor::updateParameters() {
|
|||
if (_program) {
|
||||
_program->disconnect(this);
|
||||
}
|
||||
_program = ScriptCache::getInstance()->getProgram(_url.getURL());
|
||||
_program = DependencyManager::get<ScriptCache>()->getProgram(_url.getURL());
|
||||
if (_program->isLoaded()) {
|
||||
continueUpdatingParameters();
|
||||
} else {
|
||||
|
@ -698,7 +698,7 @@ void ParameterizedURLEditor::continueUpdatingParameters() {
|
|||
}
|
||||
delete form;
|
||||
}
|
||||
QSharedPointer<NetworkValue> value = ScriptCache::getInstance()->getValue(_url.getURL());
|
||||
QSharedPointer<NetworkValue> value = DependencyManager::get<ScriptCache>()->getValue(_url.getURL());
|
||||
const QList<ParameterInfo>& parameters = static_cast<RootNetworkValue*>(value.data())->getParameterInfo();
|
||||
if (parameters.isEmpty()) {
|
||||
return;
|
||||
|
|
|
@ -57,8 +57,8 @@ bool operator==(const QScriptValue& first, const QScriptValue& second) {
|
|||
if (!second.isArray()) {
|
||||
return false;
|
||||
}
|
||||
int length = first.property(ScriptCache::getInstance()->getLengthString()).toInt32();
|
||||
if (second.property(ScriptCache::getInstance()->getLengthString()).toInt32() != length) {
|
||||
int length = first.property(DependencyManager::get<ScriptCache>()->getLengthString()).toInt32();
|
||||
if (second.property(DependencyManager::get<ScriptCache>()->getLengthString()).toInt32() != length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
@ -103,11 +103,6 @@ bool operator<(const QScriptValue& first, const QScriptValue& second) {
|
|||
return first.lessThan(second);
|
||||
}
|
||||
|
||||
ScriptCache* ScriptCache::getInstance() {
|
||||
static ScriptCache cache;
|
||||
return &cache;
|
||||
}
|
||||
|
||||
ScriptCache::ScriptCache() :
|
||||
_engine(NULL)
|
||||
{
|
||||
|
|
|
@ -25,13 +25,11 @@ class NetworkProgram;
|
|||
class NetworkValue;
|
||||
|
||||
/// Maintains a cache of loaded scripts.
|
||||
class ScriptCache : public ResourceCache {
|
||||
class ScriptCache : public ResourceCache, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
|
||||
static ScriptCache* getInstance();
|
||||
|
||||
ScriptCache();
|
||||
|
||||
void setEngine(QScriptEngine* engine);
|
||||
|
|
|
@ -3,7 +3,9 @@ set(TARGET_NAME model)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(shared gpu)
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ const char SOLO_NODE_TYPES[2] = {
|
|||
const QUrl DEFAULT_NODE_AUTH_URL = QUrl("https://metaverse.highfidelity.io");
|
||||
|
||||
LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short dtlsListenPort) :
|
||||
linkedDataCreateCallback(NULL),
|
||||
_sessionUUID(),
|
||||
_nodeHash(),
|
||||
_nodeMutex(QReadWriteLock::Recursive),
|
||||
|
|
|
@ -3,7 +3,9 @@ set(TARGET_NAME octree)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(shared networking)
|
||||
|
||||
|
|
|
@ -49,14 +49,32 @@ void OctreePersistThread::parseSettings(const QJsonObject& settings) {
|
|||
qDebug() << "BACKUP RULES:";
|
||||
|
||||
foreach (const QJsonValue& value, backupRules) {
|
||||
|
||||
QJsonObject obj = value.toObject();
|
||||
|
||||
int interval = 0;
|
||||
int count = 0;
|
||||
|
||||
QJsonValue intervalVal = obj["backupInterval"];
|
||||
if (intervalVal.isString()) {
|
||||
interval = intervalVal.toString().toInt();
|
||||
} else {
|
||||
interval = intervalVal.toInt();
|
||||
}
|
||||
|
||||
QJsonValue countVal = obj["maxBackupVersions"];
|
||||
if (countVal.isString()) {
|
||||
count = countVal.toString().toInt();
|
||||
} else {
|
||||
count = countVal.toInt();
|
||||
}
|
||||
|
||||
qDebug() << " Name:" << obj["Name"].toString();
|
||||
qDebug() << " format:" << obj["format"].toString();
|
||||
qDebug() << " interval:" << obj["backupInterval"].toInt();
|
||||
qDebug() << " count:" << obj["maxBackupVersions"].toInt();
|
||||
qDebug() << " interval:" << interval;
|
||||
qDebug() << " count:" << count;
|
||||
|
||||
BackupRule newRule = { obj["Name"].toString(), obj["backupInterval"].toInt(),
|
||||
obj["format"].toString(), obj["maxBackupVersions"].toInt(), 0};
|
||||
BackupRule newRule = { obj["Name"].toString(), interval, obj["format"].toString(), count, 0};
|
||||
|
||||
newRule.lastBackup = getMostRecentBackupTimeInUsecs(obj["format"].toString());
|
||||
|
||||
|
@ -213,7 +231,9 @@ void OctreePersistThread::persist() {
|
|||
}
|
||||
_tree->unlock();
|
||||
|
||||
qDebug() << "persist operation calling backup...";
|
||||
backup(); // handle backup if requested
|
||||
qDebug() << "persist operation DONE with backup...";
|
||||
|
||||
|
||||
// create our "lock" file to indicate we're saving.
|
||||
|
@ -319,34 +339,41 @@ bool OctreePersistThread::getMostRecentBackup(const QString& format,
|
|||
void OctreePersistThread::rollOldBackupVersions(const BackupRule& rule) {
|
||||
|
||||
if (rule.extensionFormat.contains("%N")) {
|
||||
qDebug() << "Rolling old backup versions for rule" << rule.name << "...";
|
||||
for(int n = rule.maxBackupVersions - 1; n > 0; n--) {
|
||||
QString backupExtensionN = rule.extensionFormat;
|
||||
QString backupExtensionNplusOne = rule.extensionFormat;
|
||||
backupExtensionN.replace(QString("%N"), QString::number(n));
|
||||
backupExtensionNplusOne.replace(QString("%N"), QString::number(n+1));
|
||||
if (rule.maxBackupVersions > 0) {
|
||||
qDebug() << "Rolling old backup versions for rule" << rule.name << "...";
|
||||
for(int n = rule.maxBackupVersions - 1; n > 0; n--) {
|
||||
QString backupExtensionN = rule.extensionFormat;
|
||||
QString backupExtensionNplusOne = rule.extensionFormat;
|
||||
backupExtensionN.replace(QString("%N"), QString::number(n));
|
||||
backupExtensionNplusOne.replace(QString("%N"), QString::number(n+1));
|
||||
|
||||
QString backupFilenameN = _filename + backupExtensionN;
|
||||
QString backupFilenameNplusOne = _filename + backupExtensionNplusOne;
|
||||
QString backupFilenameN = _filename + backupExtensionN;
|
||||
QString backupFilenameNplusOne = _filename + backupExtensionNplusOne;
|
||||
|
||||
QFile backupFileN(backupFilenameN);
|
||||
QFile backupFileN(backupFilenameN);
|
||||
|
||||
if (backupFileN.exists()) {
|
||||
qDebug() << "rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
int result = rename(qPrintable(backupFilenameN), qPrintable(backupFilenameNplusOne));
|
||||
if (result == 0) {
|
||||
qDebug() << "DONE rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
} else {
|
||||
qDebug() << "ERROR in rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
if (backupFileN.exists()) {
|
||||
qDebug() << "rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
int result = rename(qPrintable(backupFilenameN), qPrintable(backupFilenameNplusOne));
|
||||
if (result == 0) {
|
||||
qDebug() << "DONE rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
} else {
|
||||
qDebug() << "ERROR in rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug() << "Done rolling old backup versions...";
|
||||
} else {
|
||||
qDebug() << "Rolling backups for rule" << rule.name << "."
|
||||
<< " Max Rolled Backup Versions less than 1 [" << rule.maxBackupVersions << "]."
|
||||
<< " No need to roll backups...";
|
||||
}
|
||||
qDebug() << "Done rolling old backup versions...";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OctreePersistThread::backup() {
|
||||
qDebug() << "backup operation wantBackup:" << _wantBackup;
|
||||
if (_wantBackup) {
|
||||
quint64 now = usecTimestampNow();
|
||||
|
||||
|
@ -354,10 +381,12 @@ void OctreePersistThread::backup() {
|
|||
BackupRule& rule = _backupRules[i];
|
||||
|
||||
quint64 sinceLastBackup = now - rule.lastBackup;
|
||||
|
||||
quint64 SECS_TO_USECS = 1000 * 1000;
|
||||
quint64 intervalToBackup = rule.interval * SECS_TO_USECS;
|
||||
|
||||
|
||||
qDebug() << "Checking [" << rule.name << "] - Time since last backup [" << sinceLastBackup << "] " <<
|
||||
"compared to backup interval [" << intervalToBackup << "]...";
|
||||
|
||||
if (sinceLastBackup > intervalToBackup) {
|
||||
qDebug() << "Time since last backup [" << sinceLastBackup << "] for rule [" << rule.name
|
||||
<< "] exceeds backup interval [" << intervalToBackup << "] doing backup now...";
|
||||
|
@ -379,15 +408,28 @@ void OctreePersistThread::backup() {
|
|||
}
|
||||
|
||||
|
||||
qDebug() << "backing up persist file " << _filename << "to" << backupFileName << "...";
|
||||
bool result = QFile::copy(_filename, backupFileName);
|
||||
if (result) {
|
||||
qDebug() << "DONE backing up persist file...";
|
||||
if (rule.maxBackupVersions > 0) {
|
||||
QFile persistFile(_filename);
|
||||
if (persistFile.exists()) {
|
||||
qDebug() << "backing up persist file " << _filename << "to" << backupFileName << "...";
|
||||
bool result = QFile::copy(_filename, backupFileName);
|
||||
if (result) {
|
||||
qDebug() << "DONE backing up persist file...";
|
||||
rule.lastBackup = now; // only record successful backup in this case.
|
||||
} else {
|
||||
qDebug() << "ERROR in backing up persist file...";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "persist file " << _filename << " does not exist. " <<
|
||||
"nothing to backup for this rule ["<< rule.name << "]...";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "ERROR in backing up persist file...";
|
||||
qDebug() << "This backup rule" << rule.name
|
||||
<< " has Max Rolled Backup Versions less than 1 [" << rule.maxBackupVersions << "]."
|
||||
<< " There are no backups to be done...";
|
||||
}
|
||||
|
||||
rule.lastBackup = now;
|
||||
} else {
|
||||
qDebug() << "Backup not needed for this rule ["<< rule.name << "]...";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@ set(TARGET_NAME physics)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library()
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
include_bullet()
|
||||
if (BULLET_FOUND)
|
||||
target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES})
|
||||
|
|
|
@ -8,7 +8,9 @@ qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Widgets OpenGL Network Script)
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(animation fbx shared gpu)
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ set(TARGET_NAME script-engine)
|
|||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(Gui Network Script Widgets)
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
link_hifi_libraries(shared octree gpu model fbx entities animation audio physics metavoxels)
|
||||
|
||||
|
|
|
@ -31,44 +31,41 @@ AudioScriptingInterface::AudioScriptingInterface() :
|
|||
}
|
||||
|
||||
ScriptAudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjectorOptions& injectorOptions) {
|
||||
AudioInjector* injector = NULL;
|
||||
QMetaObject::invokeMethod(this, "invokedPlaySound", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(AudioInjector*, injector),
|
||||
Q_ARG(Sound*, sound), Q_ARG(const AudioInjectorOptions&, injectorOptions));
|
||||
if (injector) {
|
||||
return new ScriptAudioInjector(injector);
|
||||
} else {
|
||||
return NULL;
|
||||
if (QThread::currentThread() != thread()) {
|
||||
ScriptAudioInjector* injector = NULL;
|
||||
|
||||
QMetaObject::invokeMethod(this, "playSound", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(ScriptAudioInjector*, injector),
|
||||
Q_ARG(Sound*, sound), Q_ARG(const AudioInjectorOptions&, injectorOptions));
|
||||
return injector;
|
||||
}
|
||||
}
|
||||
|
||||
AudioInjector* AudioScriptingInterface::invokedPlaySound(Sound* sound, const AudioInjectorOptions& injectorOptions) {
|
||||
|
||||
if (sound) {
|
||||
// stereo option isn't set from script, this comes from sound metadata or filename
|
||||
AudioInjectorOptions optionsCopy = injectorOptions;
|
||||
optionsCopy.stereo = sound->isStereo();
|
||||
|
||||
|
||||
QThread* injectorThread = new QThread();
|
||||
injectorThread->setObjectName("Audio Injector Thread");
|
||||
|
||||
|
||||
AudioInjector* injector = new AudioInjector(sound, optionsCopy);
|
||||
injector->setLocalAudioInterface(_localAudioInterface);
|
||||
|
||||
|
||||
injector->moveToThread(injectorThread);
|
||||
|
||||
|
||||
// start injecting when the injector thread starts
|
||||
connect(injectorThread, &QThread::started, injector, &AudioInjector::injectAudio);
|
||||
|
||||
|
||||
// connect the right slots and signals for AudioInjector and thread cleanup
|
||||
connect(injector, &AudioInjector::destroyed, injectorThread, &QThread::quit);
|
||||
connect(injectorThread, &QThread::finished, injectorThread, &QThread::deleteLater);
|
||||
|
||||
|
||||
injectorThread->start();
|
||||
|
||||
return injector;
|
||||
|
||||
|
||||
return new ScriptAudioInjector(injector);
|
||||
|
||||
} else {
|
||||
qDebug() << "AudioScriptingInterface::playSound called with null Sound object.";
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,9 +32,6 @@ protected:
|
|||
signals:
|
||||
void mutedByMixer();
|
||||
void environmentMuted();
|
||||
|
||||
private slots:
|
||||
AudioInjector* invokedPlaySound(Sound* sound, const AudioInjectorOptions& injectorOptions);
|
||||
|
||||
private:
|
||||
AudioScriptingInterface();
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
|
||||
QScriptValue injectorToScriptValue(QScriptEngine* engine, ScriptAudioInjector* const& in) {
|
||||
// when the script goes down we want to cleanup the injector
|
||||
QObject::connect(engine, &QScriptEngine::destroyed, in, &ScriptAudioInjector::stopInjectorImmediately);
|
||||
|
||||
QObject::connect(engine, &QScriptEngine::destroyed, in, &ScriptAudioInjector::stopInjectorImmediately,
|
||||
Qt::DirectConnection);
|
||||
|
||||
return engine->newQObject(in, QScriptEngine::ScriptOwnership);
|
||||
}
|
||||
|
@ -36,5 +38,6 @@ ScriptAudioInjector::~ScriptAudioInjector() {
|
|||
}
|
||||
|
||||
void ScriptAudioInjector::stopInjectorImmediately() {
|
||||
qDebug() << "ScriptAudioInjector::stopInjectorImmediately called to stop audio injector immediately.";
|
||||
_injector->stopAndDeleteLater();
|
||||
}
|
||||
|
|
|
@ -272,8 +272,12 @@ QScriptValue ScriptEngine::registerGlobalObject(const QString& name, QObject* ob
|
|||
}
|
||||
|
||||
void ScriptEngine::registerFunction(const QString& name, QScriptEngine::FunctionSignature fun, int numArguments) {
|
||||
registerFunction(globalObject(), name, fun, numArguments);
|
||||
}
|
||||
|
||||
void ScriptEngine::registerFunction(QScriptValue parent, const QString& name, QScriptEngine::FunctionSignature fun, int numArguments) {
|
||||
QScriptValue scriptFun = newFunction(fun, numArguments);
|
||||
globalObject().setProperty(name, scriptFun);
|
||||
parent.setProperty(name, scriptFun);
|
||||
}
|
||||
|
||||
void ScriptEngine::registerGetterSetter(const QString& name, QScriptEngine::FunctionSignature getter,
|
||||
|
|
|
@ -58,6 +58,8 @@ public:
|
|||
void registerGetterSetter(const QString& name, QScriptEngine::FunctionSignature getter,
|
||||
QScriptEngine::FunctionSignature setter, QScriptValue object = QScriptValue::NullValue);
|
||||
void registerFunction(const QString& name, QScriptEngine::FunctionSignature fun, int numArguments = -1);
|
||||
void registerFunction(QScriptValue parent, const QString& name, QScriptEngine::FunctionSignature fun,
|
||||
int numArguments = -1);
|
||||
|
||||
Q_INVOKABLE void setIsAvatar(bool isAvatar);
|
||||
bool isAvatar() const { return _isAvatar; }
|
||||
|
|
|
@ -4,5 +4,9 @@ set(TARGET_NAME shared)
|
|||
# TODO: there isn't really a good reason to have Script linked here - let's get what is requiring it out (RegisteredMetaTypes.cpp)
|
||||
setup_hifi_library(Gui Network Script Widgets)
|
||||
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
# call macro to include our dependency includes and bubble them up via a property on our target
|
||||
include_dependency_includes()
|
|
@ -2,8 +2,6 @@ set(TARGET_NAME audio-tests)
|
|||
|
||||
setup_hifi_project()
|
||||
|
||||
include_glm()
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(shared audio networking)
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@ set(TARGET_NAME metavoxel-tests)
|
|||
|
||||
auto_mtc()
|
||||
|
||||
include_glm()
|
||||
|
||||
setup_hifi_project(Network Script Widgets)
|
||||
|
||||
# link in the shared libraries
|
||||
|
|
|
@ -219,14 +219,14 @@ static QScriptValue createRandomScriptValue(bool complex = false, bool ensureHas
|
|||
|
||||
case 4: {
|
||||
int length = randIntInRange(2, 6);
|
||||
QScriptValue value = ScriptCache::getInstance()->getEngine()->newArray(length);
|
||||
QScriptValue value = DependencyManager::get<ScriptCache>()->getEngine()->newArray(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
value.setProperty(i, createRandomScriptValue());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
default: {
|
||||
QScriptValue value = ScriptCache::getInstance()->getEngine()->newObject();
|
||||
QScriptValue value = DependencyManager::get<ScriptCache>()->getEngine()->newObject();
|
||||
if (ensureHashOrder) {
|
||||
// we can't depend on the iteration order, so if we need it to be the same (as when comparing bytes), we
|
||||
// can only have one property
|
||||
|
@ -747,7 +747,7 @@ static SharedObjectPointer mutate(const SharedObjectPointer& state) {
|
|||
case 3: {
|
||||
SharedObjectPointer newState = state->clone(true);
|
||||
QScriptValue oldValue = static_cast<TestSharedObjectA*>(newState.data())->getBizzle();
|
||||
QScriptValue newValue = ScriptCache::getInstance()->getEngine()->newObject();
|
||||
QScriptValue newValue = DependencyManager::get<ScriptCache>()->getEngine()->newObject();
|
||||
for (QScriptValueIterator it(oldValue); it.hasNext(); ) {
|
||||
it.next();
|
||||
newValue.setProperty(it.scriptName(), it.value());
|
||||
|
@ -755,8 +755,8 @@ static SharedObjectPointer mutate(const SharedObjectPointer& state) {
|
|||
switch (randIntInRange(0, 2)) {
|
||||
case 0: {
|
||||
QScriptValue oldArray = oldValue.property("foo");
|
||||
int oldLength = oldArray.property(ScriptCache::getInstance()->getLengthString()).toInt32();
|
||||
QScriptValue newArray = ScriptCache::getInstance()->getEngine()->newArray(oldLength);
|
||||
int oldLength = oldArray.property(DependencyManager::get<ScriptCache>()->getLengthString()).toInt32();
|
||||
QScriptValue newArray = DependencyManager::get<ScriptCache>()->getEngine()->newArray(oldLength);
|
||||
for (int i = 0; i < oldLength; i++) {
|
||||
newArray.setProperty(i, oldArray.property(i));
|
||||
}
|
||||
|
@ -1203,8 +1203,8 @@ TestSharedObjectA::TestSharedObjectA(float foo, TestEnum baz, TestFlags bong) :
|
|||
_bong(bong) {
|
||||
sharedObjectsCreated++;
|
||||
|
||||
_bizzle = ScriptCache::getInstance()->getEngine()->newObject();
|
||||
_bizzle.setProperty("foo", ScriptCache::getInstance()->getEngine()->newArray(4));
|
||||
_bizzle = DependencyManager::get<ScriptCache>()->getEngine()->newObject();
|
||||
_bizzle.setProperty("foo", DependencyManager::get<ScriptCache>()->getEngine()->newArray(4));
|
||||
}
|
||||
|
||||
TestSharedObjectA::~TestSharedObjectA() {
|
||||
|
|
|
@ -2,8 +2,6 @@ set(TARGET_NAME octree-tests)
|
|||
|
||||
setup_hifi_project(Script Network)
|
||||
|
||||
include_glm()
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(shared octree gpu model fbx metavoxels networking entities avatars audio animation script-engine physics)
|
||||
|
||||
|
|
|
@ -2,7 +2,10 @@ set(TARGET_NAME physics-tests)
|
|||
|
||||
setup_hifi_project()
|
||||
|
||||
include_glm()
|
||||
add_dependency_external_project(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
||||
include_bullet()
|
||||
|
||||
link_hifi_libraries(shared physics)
|
||||
|
|
|
@ -2,8 +2,6 @@ set(TARGET_NAME render-utils-tests)
|
|||
|
||||
setup_hifi_project(Quick Gui OpenGL)
|
||||
|
||||
include_glm()
|
||||
|
||||
#include_oglplus()
|
||||
|
||||
# link in the shared libraries
|
||||
|
|
|
@ -2,8 +2,6 @@ set(TARGET_NAME shared-tests)
|
|||
|
||||
setup_hifi_project()
|
||||
|
||||
include_glm()
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(shared)
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
set(TARGET_NAME bitstream2json)
|
||||
setup_hifi_project(Widgets Script)
|
||||
|
||||
include_glm()
|
||||
|
||||
link_hifi_libraries(metavoxels)
|
||||
|
||||
include_dependency_includes()
|
|
@ -1,8 +1,6 @@
|
|||
set(TARGET_NAME json2bitstream)
|
||||
setup_hifi_project(Widgets Script)
|
||||
|
||||
include_glm()
|
||||
|
||||
link_hifi_libraries(metavoxels)
|
||||
|
||||
include_dependency_includes()
|
Loading…
Reference in a new issue