mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:44:21 +02:00
Merge branch 'RC-57' of https://github.com/highfidelity/hifi into pop_dynamicTests57
This commit is contained in:
commit
febc725520
58 changed files with 675 additions and 374 deletions
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <ClientServerUtils.h>
|
||||
#include <FBXBaker.h>
|
||||
#include <JSBaker.h>
|
||||
#include <NodeType.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <PathUtils.h>
|
||||
|
@ -49,10 +50,12 @@ static const int INTERFACE_RUNNING_CHECK_FREQUENCY_MS = 1000;
|
|||
|
||||
const QString ASSET_SERVER_LOGGING_TARGET_NAME = "asset-server";
|
||||
|
||||
static const QStringList BAKEABLE_MODEL_EXTENSIONS = { "fbx" };
|
||||
static const QStringList BAKEABLE_MODEL_EXTENSIONS = {"fbx"};
|
||||
static QStringList BAKEABLE_TEXTURE_EXTENSIONS;
|
||||
static const QStringList BAKEABLE_SCRIPT_EXTENSIONS = {"js"};
|
||||
static const QString BAKED_MODEL_SIMPLE_NAME = "asset.fbx";
|
||||
static const QString BAKED_TEXTURE_SIMPLE_NAME = "texture.ktx";
|
||||
static const QString BAKED_SCRIPT_SIMPLE_NAME = "asset.js";
|
||||
|
||||
void AssetServer::bakeAsset(const AssetHash& assetHash, const AssetPath& assetPath, const QString& filePath) {
|
||||
qDebug() << "Starting bake for: " << assetPath << assetHash;
|
||||
|
@ -99,6 +102,8 @@ std::pair<BakingStatus, QString> AssetServer::getAssetStatus(const AssetPath& pa
|
|||
bakedFilename = BAKED_MODEL_SIMPLE_NAME;
|
||||
} else if (BAKEABLE_TEXTURE_EXTENSIONS.contains(extension.toLocal8Bit()) && hasMetaFile(hash)) {
|
||||
bakedFilename = BAKED_TEXTURE_SIMPLE_NAME;
|
||||
} else if (BAKEABLE_SCRIPT_EXTENSIONS.contains(extension)) {
|
||||
bakedFilename = BAKED_SCRIPT_SIMPLE_NAME;
|
||||
} else {
|
||||
return { Irrelevant, "" };
|
||||
}
|
||||
|
@ -186,6 +191,8 @@ bool AssetServer::needsToBeBaked(const AssetPath& path, const AssetHash& assetHa
|
|||
bakedFilename = BAKED_MODEL_SIMPLE_NAME;
|
||||
} else if (loaded && BAKEABLE_TEXTURE_EXTENSIONS.contains(extension.toLocal8Bit())) {
|
||||
bakedFilename = BAKED_TEXTURE_SIMPLE_NAME;
|
||||
} else if (BAKEABLE_SCRIPT_EXTENSIONS.contains(extension)) {
|
||||
bakedFilename = BAKED_SCRIPT_SIMPLE_NAME;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -488,6 +495,8 @@ void AssetServer::handleGetMappingOperation(ReceivedMessage& message, SharedNode
|
|||
bakedRootFile = BAKED_MODEL_SIMPLE_NAME;
|
||||
} else if (BAKEABLE_TEXTURE_EXTENSIONS.contains(assetPathExtension.toLocal8Bit())) {
|
||||
bakedRootFile = BAKED_TEXTURE_SIMPLE_NAME;
|
||||
} else if (BAKEABLE_SCRIPT_EXTENSIONS.contains(assetPathExtension)) {
|
||||
bakedRootFile = BAKED_SCRIPT_SIMPLE_NAME;
|
||||
}
|
||||
|
||||
auto originalAssetHash = it->second;
|
||||
|
@ -1141,6 +1150,7 @@ bool AssetServer::renameMapping(AssetPath oldPath, AssetPath newPath) {
|
|||
|
||||
static const QString BAKED_ASSET_SIMPLE_FBX_NAME = "asset.fbx";
|
||||
static const QString BAKED_ASSET_SIMPLE_TEXTURE_NAME = "texture.ktx";
|
||||
static const QString BAKED_ASSET_SIMPLE_JS_NAME = "asset.js";
|
||||
|
||||
QString getBakeMapping(const AssetHash& hash, const QString& relativeFilePath) {
|
||||
return HIDDEN_BAKED_CONTENT_FOLDER + hash + "/" + relativeFilePath;
|
||||
|
@ -1204,14 +1214,14 @@ void AssetServer::handleCompletedBake(QString originalAssetHash, QString origina
|
|||
// setup the mapping for this bake file
|
||||
auto relativeFilePath = QUrl(filePath).fileName();
|
||||
qDebug() << "Relative file path is: " << relativeFilePath;
|
||||
|
||||
if (relativeFilePath.endsWith(".fbx", Qt::CaseInsensitive)) {
|
||||
// for an FBX file, we replace the filename with the simple name
|
||||
// (to handle the case where two mapped assets have the same hash but different names)
|
||||
relativeFilePath = BAKED_ASSET_SIMPLE_FBX_NAME;
|
||||
} else if (relativeFilePath.endsWith(".js", Qt::CaseInsensitive)) {
|
||||
relativeFilePath = BAKED_ASSET_SIMPLE_JS_NAME;
|
||||
} else if (!originalAssetPath.endsWith(".fbx", Qt::CaseInsensitive)) {
|
||||
relativeFilePath = BAKED_ASSET_SIMPLE_TEXTURE_NAME;
|
||||
|
||||
}
|
||||
|
||||
QString bakeMapping = getBakeMapping(originalAssetHash, relativeFilePath);
|
||||
|
@ -1364,6 +1374,8 @@ bool AssetServer::setBakingEnabled(const AssetPathList& paths, bool enabled) {
|
|||
bakedFilename = BAKED_MODEL_SIMPLE_NAME;
|
||||
} else if (BAKEABLE_TEXTURE_EXTENSIONS.contains(extension.toLocal8Bit()) && hasMetaFile(hash)) {
|
||||
bakedFilename = BAKED_TEXTURE_SIMPLE_NAME;
|
||||
} else if (BAKEABLE_SCRIPT_EXTENSIONS.contains(extension)) {
|
||||
bakedFilename = BAKED_SCRIPT_SIMPLE_NAME;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <FBXBaker.h>
|
||||
#include <PathUtils.h>
|
||||
#include <JSBaker.h>
|
||||
|
||||
BakeAssetTask::BakeAssetTask(const AssetHash& assetHash, const AssetPath& assetPath, const QString& filePath) :
|
||||
_assetHash(assetHash),
|
||||
|
@ -52,6 +53,10 @@ void BakeAssetTask::run() {
|
|||
_baker = std::unique_ptr<FBXBaker> {
|
||||
new FBXBaker(QUrl("file:///" + _filePath), fn, tempOutputDir)
|
||||
};
|
||||
} else if (_assetPath.endsWith(".js", Qt::CaseInsensitive)) {
|
||||
_baker = std::unique_ptr<JSBaker>{
|
||||
new JSBaker(QUrl("file:///" + _filePath), PathUtils::generateTemporaryDir())
|
||||
};
|
||||
} else {
|
||||
tempOutputDir = PathUtils::generateTemporaryDir();
|
||||
_baker = std::unique_ptr<TextureBaker> {
|
||||
|
|
|
@ -97,7 +97,11 @@ void AudioMixerSlavePool::run(ConstIter begin, ConstIter end) {
|
|||
#else
|
||||
// fill the queue
|
||||
std::for_each(_begin, _end, [&](const SharedNodePointer& node) {
|
||||
#if defined(__clang__) && defined(Q_OS_LINUX)
|
||||
_queue.push(node);
|
||||
#else
|
||||
_queue.emplace(node);
|
||||
#endif
|
||||
});
|
||||
|
||||
{
|
||||
|
|
|
@ -97,7 +97,11 @@ void AvatarMixerSlavePool::run(ConstIter begin, ConstIter end) {
|
|||
#else
|
||||
// fill the queue
|
||||
std::for_each(_begin, _end, [&](const SharedNodePointer& node) {
|
||||
#if defined(__clang__) && defined(Q_OS_LINUX)
|
||||
_queue.push(node);
|
||||
#else
|
||||
_queue.emplace(node);
|
||||
#endif
|
||||
});
|
||||
|
||||
{
|
||||
|
|
2
cmake/externals/glew/CMakeLists.txt
vendored
2
cmake/externals/glew/CMakeLists.txt
vendored
|
@ -9,7 +9,7 @@ ExternalProject_Add(
|
|||
${EXTERNAL_NAME}
|
||||
URL http://hifi-public.s3.amazonaws.com/dependencies/glew_simple_1.13.0.zip
|
||||
URL_MD5 73f833649e904257b35bf4e84f8bdfb5
|
||||
CONFIGURE_COMMAND CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||
CONFIGURE_COMMAND CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||
LOG_DOWNLOAD 1
|
||||
LOG_CONFIGURE 1
|
||||
LOG_BUILD 1
|
||||
|
|
2
cmake/externals/nvtt/CMakeLists.txt
vendored
2
cmake/externals/nvtt/CMakeLists.txt
vendored
|
@ -31,7 +31,7 @@ else ()
|
|||
${EXTERNAL_NAME}
|
||||
URL http://hifi-public.s3.amazonaws.com/dependencies/nvidia-texture-tools-2.1.0.hifi.zip
|
||||
URL_MD5 5794b950f8b265a9a41b2839b3bf7ebb
|
||||
CONFIGURE_COMMAND CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DNVTT_SHARED=1 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||
CONFIGURE_COMMAND CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DNVTT_SHARED=1 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||
LOG_DOWNLOAD 1
|
||||
LOG_CONFIGURE 1
|
||||
LOG_BUILD 1
|
||||
|
|
|
@ -14,9 +14,17 @@ endif ()
|
|||
|
||||
if (HIFI_MEMORY_DEBUGGING)
|
||||
if (UNIX)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -U_FORTIFY_SOURCE -fno-stack-protector -fno-omit-frame-pointer")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan -static-libstdc++ -fsanitize=address")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan -static-libstdc++ -fsanitize=address")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# for clang on Linux
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
|
||||
else ()
|
||||
# for gcc on Linux
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fsanitize=address -U_FORTIFY_SOURCE -fno-stack-protector -fno-omit-frame-pointer")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan -static-libstdc++ -fsanitize=undefined -fsanitize=address")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan -static-libstdc++ -fsanitize=undefined -fsanitize=address")
|
||||
endif()
|
||||
endif (UNIX)
|
||||
endif ()
|
||||
endmacro(SETUP_MEMORY_DEBUGGER)
|
||||
|
|
|
@ -262,7 +262,13 @@ target_link_libraries(
|
|||
)
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries(${TARGET_NAME} pthread)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
# Linux
|
||||
target_link_libraries(${TARGET_NAME} pthread atomic)
|
||||
else ()
|
||||
# OSX
|
||||
target_link_libraries(${TARGET_NAME} pthread)
|
||||
endif ()
|
||||
endif(UNIX)
|
||||
|
||||
# assume we are using a Qt build without bearer management
|
||||
|
|
|
@ -124,7 +124,7 @@ Rectangle {
|
|||
selectByMouse: false
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key == Qt.Key_Return) {
|
||||
if (event.key == Qt.Key_Return || event.key == Qt.Key_Space) {
|
||||
mirrorText.text = "";
|
||||
event.accepted = true;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,20 @@ TextField {
|
|||
|
||||
y: textFieldLabel.visible ? textFieldLabel.height + textFieldLabel.anchors.bottomMargin : 0
|
||||
|
||||
// workaround for https://bugreports.qt.io/browse/QTBUG-49297
|
||||
Keys.onPressed: {
|
||||
switch (event.key) {
|
||||
case Qt.Key_Return:
|
||||
case Qt.Key_Enter:
|
||||
event.accepted = true;
|
||||
|
||||
// emit accepted signal manually
|
||||
if (acceptableInput) {
|
||||
accepted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
style: TextFieldStyle {
|
||||
textColor: {
|
||||
if (isLightColorScheme) {
|
||||
|
|
|
@ -200,12 +200,6 @@ Rectangle {
|
|||
// Style
|
||||
color: hifi.colors.lightGray;
|
||||
}
|
||||
FontLoader { id: ralewayRegular; source: "../../../../fonts/Raleway-Regular.ttf"; }
|
||||
TextMetrics {
|
||||
id: textMetrics;
|
||||
font.family: ralewayRegular.name
|
||||
text: root.itemOwner;
|
||||
}
|
||||
RalewayRegular {
|
||||
id: ownedBy;
|
||||
text: root.itemOwner;
|
||||
|
@ -215,8 +209,7 @@ Rectangle {
|
|||
anchors.top: ownedByHeader.bottom;
|
||||
anchors.topMargin: 8;
|
||||
anchors.left: ownedByHeader.left;
|
||||
height: textMetrics.height;
|
||||
width: root.isMyCert ? textMetrics.width + 25 : ownedByHeader.width;
|
||||
height: paintedHeight;
|
||||
// Style
|
||||
color: hifi.colors.darkGray;
|
||||
elide: Text.ElideRight;
|
||||
|
@ -231,7 +224,7 @@ Rectangle {
|
|||
anchors.topMargin: 4;
|
||||
anchors.bottom: ownedBy.bottom;
|
||||
anchors.left: ownedBy.right;
|
||||
anchors.leftMargin: 4;
|
||||
anchors.leftMargin: 6;
|
||||
anchors.right: ownedByHeader.right;
|
||||
// Style
|
||||
color: hifi.colors.lightGray;
|
||||
|
|
|
@ -90,17 +90,22 @@ Item {
|
|||
ListElement {
|
||||
isExpanded: false;
|
||||
question: "What are private keys?"
|
||||
answer: qsTr("A private key is a secret piece of text that is used to decrypt code.<br><br>In High Fidelity, <b>your private keys are used to decrypt the contents of your Wallet and Purchases.</b>");
|
||||
answer: qsTr("A private key is a secret piece of text that is used to prove ownership, unlock confidential information, and sign transactions.<br><br>In High Fidelity, <b>your private keys are used to securely access the contents of your Wallet and Purchases.</b>");
|
||||
}
|
||||
ListElement {
|
||||
isExpanded: false;
|
||||
question: "Where are my private keys stored?"
|
||||
answer: qsTr('Your private keys are <b>only stored on your hard drive</b> in High Fidelity Interface\'s AppData directory.<br><br><b><font color="#0093C5"><a href="#privateKeyPath">Tap here to open the file path of your hifikey in your file explorer.</a></font></b><br><br> You may backup this file by copying it to a USB flash drive, or to a service like Dropbox or Google Drive. Restore your backup by replacing the file in Interface\'s AppData directory with your backed-up copy.');
|
||||
answer: qsTr('By default, your private keys are <b>only stored on your hard drive</b> in High Fidelity Interface\'s AppData directory.<br><br><b><font color="#0093C5"><a href="#privateKeyPath">Tap here to open the file path of your hifikey in your file explorer.</a></font></b>');
|
||||
}
|
||||
ListElement {
|
||||
isExpanded: false;
|
||||
question: "How can I backup my private keys?"
|
||||
answer: qsTr('You may backup the file containing your private keys by copying it to a USB flash drive, or to a service like Dropbox or Google Drive.<br><br>Restore your backup by replacing the file in Interface\'s AppData directory with your backed-up copy.<br><br><b><font color="#0093C5"><a href="#privateKeyPath">Tap here to open the file path of your hifikey in your file explorer.</a></font></b>');
|
||||
}
|
||||
ListElement {
|
||||
isExpanded: false;
|
||||
question: "What happens if I lose my passphrase?"
|
||||
answer: qsTr("If you lose your passphrase, you will no longer have access to the contents of your Wallet or My Purchases.<br><br><b>Nobody can help you recover your passphrase, including High Fidelity.</b> Please write it down and store it securely.");
|
||||
answer: qsTr("Your passphrase is used to encrypt your private keys. If you lose your passphrase, you will no longer be able to decrypt your private key file. You will also no longer have access to the contents of your Wallet or My Purchases.<br><br><b>Nobody can help you recover your passphrase, including High Fidelity.</b> Please write it down and store it securely.");
|
||||
}
|
||||
ListElement {
|
||||
isExpanded: false;
|
||||
|
|
|
@ -679,7 +679,7 @@ Item {
|
|||
anchors.right: parent.right;
|
||||
anchors.rightMargin: 30;
|
||||
height: 40;
|
||||
text: "Open Instructions for Later";
|
||||
text: "Open Backup Instructions for Later";
|
||||
onClicked: {
|
||||
instructions01Container.visible = false;
|
||||
instructions02Container.visible = true;
|
||||
|
|
|
@ -79,8 +79,6 @@
|
|||
#include <gpu/Batch.h>
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/gl/GLBackend.h>
|
||||
#include <HFActionEvent.h>
|
||||
#include <HFBackEvent.h>
|
||||
#include <InfoView.h>
|
||||
#include <input-plugins/InputPlugin.h>
|
||||
#include <controllers/UserInputMapper.h>
|
||||
|
@ -2859,10 +2857,6 @@ bool Application::event(QEvent* event) {
|
|||
break;
|
||||
}
|
||||
|
||||
if (HFActionEvent::types().contains(event->type())) {
|
||||
_controllerScriptingInterface->handleMetaEvent(static_cast<HFMetaEvent*>(event));
|
||||
}
|
||||
|
||||
return QApplication::event(event);
|
||||
}
|
||||
|
||||
|
@ -3167,25 +3161,8 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
case Qt::Key_Equal:
|
||||
getMyAvatar()->resetSize();
|
||||
break;
|
||||
case Qt::Key_Space: {
|
||||
if (!event->isAutoRepeat()) {
|
||||
// FIXME -- I don't think we've tested the HFActionEvent in a while... this looks possibly dubious
|
||||
// this starts an HFActionEvent
|
||||
HFActionEvent startActionEvent(HFActionEvent::startType(),
|
||||
computePickRay(getMouse().x, getMouse().y));
|
||||
sendEvent(this, &startActionEvent);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Escape: {
|
||||
getActiveDisplayPlugin()->abandonCalibration();
|
||||
if (!event->isAutoRepeat()) {
|
||||
// this starts the HFCancelEvent
|
||||
HFBackEvent startBackEvent(HFBackEvent::startType());
|
||||
sendEvent(this, &startBackEvent);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3211,30 +3188,6 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
|||
if (_keyboardMouseDevice->isActive()) {
|
||||
_keyboardMouseDevice->keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Space: {
|
||||
if (!event->isAutoRepeat()) {
|
||||
// FIXME -- I don't think we've tested the HFActionEvent in a while... this looks possibly dubious
|
||||
// this ends the HFActionEvent
|
||||
HFActionEvent endActionEvent(HFActionEvent::endType(),
|
||||
computePickRay(getMouse().x, getMouse().y));
|
||||
sendEvent(this, &endActionEvent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Escape: {
|
||||
if (!event->isAutoRepeat()) {
|
||||
// this ends the HFCancelEvent
|
||||
HFBackEvent endBackEvent(HFBackEvent::endType());
|
||||
sendEvent(this, &endBackEvent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
event->ignore();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Application::focusOutEvent(QFocusEvent* event) {
|
||||
|
@ -3371,13 +3324,6 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
|||
if (_keyboardMouseDevice->isActive()) {
|
||||
_keyboardMouseDevice->mousePressEvent(event);
|
||||
}
|
||||
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
// nobody handled this - make it an action event on the _window object
|
||||
HFActionEvent actionEvent(HFActionEvent::startType(),
|
||||
computePickRay(mappedEvent.x(), mappedEvent.y()));
|
||||
sendEvent(this, &actionEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3432,13 +3378,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event) {
|
|||
if (_keyboardMouseDevice->isActive()) {
|
||||
_keyboardMouseDevice->mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
// fire an action end event
|
||||
HFActionEvent actionEvent(HFActionEvent::endType(),
|
||||
computePickRay(mappedEvent.x(), mappedEvent.y()));
|
||||
sendEvent(this, &actionEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4025,9 +3964,14 @@ void Application::calibrateEyeTracker5Points() {
|
|||
}
|
||||
#endif
|
||||
|
||||
bool Application::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset) {
|
||||
bool Application::exportEntities(const QString& filename,
|
||||
const QVector<EntityItemID>& entityIDs,
|
||||
const glm::vec3* givenOffset) {
|
||||
QHash<EntityItemID, EntityItemPointer> entities;
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const QUuid myAvatarID = nodeList->getSessionUUID();
|
||||
|
||||
auto entityTree = getEntities()->getTree();
|
||||
auto exportTree = std::make_shared<EntityTree>();
|
||||
exportTree->createRootElement();
|
||||
|
@ -4043,8 +3987,12 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt
|
|||
|
||||
if (!givenOffset) {
|
||||
EntityItemID parentID = entityItem->getParentID();
|
||||
if (parentID.isInvalidID() || !entityIDs.contains(parentID) || !entityTree->findEntityByEntityItemID(parentID)) {
|
||||
auto position = entityItem->getPosition(); // If parent wasn't selected, we want absolute position, which isn't in properties.
|
||||
bool parentIsAvatar = (parentID == AVATAR_SELF_ID || parentID == myAvatarID);
|
||||
if (!parentIsAvatar && (parentID.isInvalidID() ||
|
||||
!entityIDs.contains(parentID) ||
|
||||
!entityTree->findEntityByEntityItemID(parentID))) {
|
||||
// If parent wasn't selected, we want absolute position, which isn't in properties.
|
||||
auto position = entityItem->getPosition();
|
||||
root.x = glm::min(root.x, position.x);
|
||||
root.y = glm::min(root.y, position.y);
|
||||
root.z = glm::min(root.z, position.z);
|
||||
|
@ -4064,12 +4012,16 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt
|
|||
for (EntityItemPointer& entityDatum : entities) {
|
||||
auto properties = entityDatum->getProperties();
|
||||
EntityItemID parentID = properties.getParentID();
|
||||
if (parentID.isInvalidID()) {
|
||||
properties.setPosition(properties.getPosition() - root);
|
||||
bool parentIsAvatar = (parentID == AVATAR_SELF_ID || parentID == myAvatarID);
|
||||
if (parentIsAvatar) {
|
||||
properties.setParentID(AVATAR_SELF_ID);
|
||||
} else {
|
||||
if (parentID.isInvalidID()) {
|
||||
properties.setPosition(properties.getPosition() - root);
|
||||
} else if (!entities.contains(parentID)) {
|
||||
entityDatum->globalizeProperties(properties, "Parent %3 of %2 %1 is not selected for export.", -root);
|
||||
} // else valid parent -- don't offset
|
||||
}
|
||||
else if (!entities.contains(parentID)) {
|
||||
entityDatum->globalizeProperties(properties, "Parent %3 of %2 %1 is not selected for export.", -root);
|
||||
} // else valid parent -- don't offset
|
||||
exportTree->addEntity(entityDatum->getEntityItemID(), properties);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -53,7 +53,7 @@ const QUuid MY_AVATAR_KEY; // NULL key
|
|||
|
||||
AvatarManager::AvatarManager(QObject* parent) :
|
||||
_avatarsToFade(),
|
||||
_myAvatar(std::make_shared<MyAvatar>(qApp->thread()))
|
||||
_myAvatar(new MyAvatar(qApp->thread()), [](MyAvatar* ptr) { ptr->deleteLater(); })
|
||||
{
|
||||
// register a meta type for the weak pointer we'll use for the owning avatar mixer for each avatar
|
||||
qRegisterMetaType<QWeakPointer<Node> >("NodeWeakPointer");
|
||||
|
@ -297,7 +297,7 @@ void AvatarManager::simulateAvatarFades(float deltaTime) {
|
|||
}
|
||||
|
||||
AvatarSharedPointer AvatarManager::newSharedAvatar() {
|
||||
return std::make_shared<OtherAvatar>(qApp->thread());
|
||||
return AvatarSharedPointer(new OtherAvatar(qApp->thread()), [](OtherAvatar* ptr) { ptr->deleteLater(); });
|
||||
}
|
||||
|
||||
void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason) {
|
||||
|
|
|
@ -3238,3 +3238,9 @@ void MyAvatar::setModelScale(float scale) {
|
|||
emit sensorToWorldScaleChanged(sensorToWorldScale);
|
||||
}
|
||||
}
|
||||
|
||||
SpatialParentTree* MyAvatar::getParentTree() const {
|
||||
auto entityTreeRenderer = qApp->getEntities();
|
||||
EntityTreePointer entityTree = entityTreeRenderer ? entityTreeRenderer->getTree() : nullptr;
|
||||
return entityTree.get();
|
||||
}
|
||||
|
|
|
@ -544,6 +544,8 @@ public:
|
|||
float getUserHeight() const;
|
||||
float getUserEyeHeight() const;
|
||||
|
||||
virtual SpatialParentTree* getParentTree() const override;
|
||||
|
||||
public slots:
|
||||
void increaseSize();
|
||||
void decreaseSize();
|
||||
|
|
|
@ -105,19 +105,19 @@ RSA* readKeys(const char* filename) {
|
|||
return key;
|
||||
}
|
||||
|
||||
bool writeBackupInstructions() {
|
||||
bool Wallet::writeBackupInstructions() {
|
||||
QString inputFilename(PathUtils::resourcesPath() + "html/commerce/backup_instructions.html");
|
||||
QString filename = PathUtils::getAppDataFilePath(INSTRUCTIONS_FILE);
|
||||
QFile outputFile(filename);
|
||||
QString outputFilename = PathUtils::getAppDataFilePath(INSTRUCTIONS_FILE);
|
||||
QFile outputFile(outputFilename);
|
||||
bool retval = false;
|
||||
|
||||
if (QFile::exists(filename))
|
||||
if (QFile::exists(outputFilename) || getKeyFilePath() == "")
|
||||
{
|
||||
QFile::remove(filename);
|
||||
return false;
|
||||
}
|
||||
QFile::copy(inputFilename, filename);
|
||||
QFile::copy(inputFilename, outputFilename);
|
||||
|
||||
if (QFile::exists(filename) && outputFile.open(QIODevice::ReadWrite)) {
|
||||
if (QFile::exists(outputFilename) && outputFile.open(QIODevice::ReadWrite)) {
|
||||
|
||||
QByteArray fileData = outputFile.readAll();
|
||||
QString text(fileData);
|
||||
|
@ -132,7 +132,7 @@ bool writeBackupInstructions() {
|
|||
retval = true;
|
||||
qCDebug(commerce) << "wrote html file successfully";
|
||||
} else {
|
||||
qCDebug(commerce) << "failed to open output html file" << filename;
|
||||
qCDebug(commerce) << "failed to open output html file" << outputFilename;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -154,8 +154,6 @@ bool writeKeys(const char* filename, RSA* keys) {
|
|||
QFile(QString(filename)).remove();
|
||||
return retval;
|
||||
}
|
||||
|
||||
writeBackupInstructions();
|
||||
|
||||
retval = true;
|
||||
qCDebug(commerce) << "wrote keys successfully";
|
||||
|
@ -359,6 +357,8 @@ bool Wallet::setPassphrase(const QString& passphrase) {
|
|||
|
||||
_publicKeys.clear();
|
||||
|
||||
writeBackupInstructions();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -526,6 +526,8 @@ bool Wallet::generateKeyPair() {
|
|||
qCInfo(commerce) << "Generating keypair.";
|
||||
auto keyPair = generateRSAKeypair();
|
||||
|
||||
writeBackupInstructions();
|
||||
|
||||
// TODO: redo this soon -- need error checking and so on
|
||||
writeSecurityImage(_securityImage, keyFilePath());
|
||||
QString oldKey = _publicKeys.count() == 0 ? "" : _publicKeys.last();
|
||||
|
|
|
@ -80,6 +80,7 @@ private:
|
|||
void updateImageProvider();
|
||||
bool writeSecurityImage(const QPixmap* pixmap, const QString& outputFilePath);
|
||||
bool readSecurityImage(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferLen);
|
||||
bool writeBackupInstructions();
|
||||
|
||||
void account();
|
||||
};
|
||||
|
|
|
@ -13,23 +13,10 @@
|
|||
|
||||
#include <avatar/AvatarManager.h>
|
||||
#include <avatar/MyAvatar.h>
|
||||
#include <HFBackEvent.h>
|
||||
#include <plugins/PluginManager.h>
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
void ControllerScriptingInterface::handleMetaEvent(HFMetaEvent* event) {
|
||||
if (event->type() == HFActionEvent::startType()) {
|
||||
emit actionStartEvent(static_cast<HFActionEvent&>(*event));
|
||||
} else if (event->type() == HFActionEvent::endType()) {
|
||||
emit actionEndEvent(static_cast<HFActionEvent&>(*event));
|
||||
} else if (event->type() == HFBackEvent::startType()) {
|
||||
emit backStartEvent();
|
||||
} else if (event->type() == HFBackEvent::endType()) {
|
||||
emit backEndEvent();
|
||||
}
|
||||
}
|
||||
|
||||
bool ControllerScriptingInterface::isKeyCaptured(QKeyEvent* event) const {
|
||||
return isKeyCaptured(KeyEvent(*event));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <controllers/UserInputMapper.h>
|
||||
#include <controllers/ScriptingInterface.h>
|
||||
|
||||
#include <HFActionEvent.h>
|
||||
#include <KeyEvent.h>
|
||||
#include <MouseEvent.h>
|
||||
#include <SpatialEvent.h>
|
||||
|
@ -36,8 +35,6 @@ public:
|
|||
void emitKeyPressEvent(QKeyEvent* event);
|
||||
void emitKeyReleaseEvent(QKeyEvent* event);
|
||||
|
||||
void handleMetaEvent(HFMetaEvent* event);
|
||||
|
||||
void emitMouseMoveEvent(QMouseEvent* event);
|
||||
void emitMousePressEvent(QMouseEvent* event);
|
||||
void emitMouseDoublePressEvent(QMouseEvent* event);
|
||||
|
@ -72,12 +69,6 @@ signals:
|
|||
void keyPressEvent(const KeyEvent& event);
|
||||
void keyReleaseEvent(const KeyEvent& event);
|
||||
|
||||
void actionStartEvent(const HFActionEvent& event);
|
||||
void actionEndEvent(const HFActionEvent& event);
|
||||
|
||||
void backStartEvent();
|
||||
void backEndEvent();
|
||||
|
||||
void mouseMoveEvent(const MouseEvent& event);
|
||||
void mousePressEvent(const MouseEvent& event);
|
||||
void mouseDoublePressEvent(const MouseEvent& event);
|
||||
|
|
|
@ -305,3 +305,9 @@ Transform Base3DOverlay::evalRenderTransform() {
|
|||
void Base3DOverlay::setRenderTransform(const Transform& transform) {
|
||||
_renderTransform = transform;
|
||||
}
|
||||
|
||||
SpatialParentTree* Base3DOverlay::getParentTree() const {
|
||||
auto entityTreeRenderer = qApp->getEntities();
|
||||
EntityTreePointer entityTree = entityTreeRenderer ? entityTreeRenderer->getTree() : nullptr;
|
||||
return entityTree.get();
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
virtual AABox getBounds() const override = 0;
|
||||
|
||||
void update(float deltatime) override;
|
||||
|
||||
|
||||
void notifyRenderTransformChange() const;
|
||||
|
||||
void setProperties(const QVariantMap& properties) override;
|
||||
|
@ -69,6 +69,8 @@ public:
|
|||
return findRayIntersection(origin, direction, distance, face, surfaceNormal);
|
||||
}
|
||||
|
||||
virtual SpatialParentTree* getParentTree() const override;
|
||||
|
||||
protected:
|
||||
virtual void locationChanged(bool tellPhysics = true) override;
|
||||
virtual void parentDeleted() override;
|
||||
|
|
|
@ -161,33 +161,33 @@ OverlayID Overlays::addOverlay(const QString& type, const QVariant& properties)
|
|||
Overlay::Pointer thisOverlay = nullptr;
|
||||
|
||||
if (type == ImageOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<ImageOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new ImageOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == Image3DOverlay::TYPE || type == "billboard") { // "billboard" for backwards compatibility
|
||||
thisOverlay = std::make_shared<Image3DOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new Image3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == TextOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<TextOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new TextOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == Text3DOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<Text3DOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new Text3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == Shape3DOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<Shape3DOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new Shape3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == Cube3DOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<Cube3DOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new Cube3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == Sphere3DOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<Sphere3DOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new Sphere3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == Circle3DOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<Circle3DOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new Circle3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == Rectangle3DOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<Rectangle3DOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new Rectangle3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == Line3DOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<Line3DOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new Line3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == Grid3DOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<Grid3DOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new Grid3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == ModelOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<ModelOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new ModelOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == Web3DOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<Web3DOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new Web3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
} else if (type == RectangleOverlay::TYPE) {
|
||||
thisOverlay = std::make_shared<RectangleOverlay>();
|
||||
thisOverlay = Overlay::Pointer(new RectangleOverlay(), [](Overlay* ptr) { ptr->deleteLater(); });
|
||||
}
|
||||
|
||||
if (thisOverlay) {
|
||||
|
@ -230,7 +230,7 @@ OverlayID Overlays::cloneOverlay(OverlayID id) {
|
|||
Overlay::Pointer thisOverlay = getOverlay(id);
|
||||
|
||||
if (thisOverlay) {
|
||||
OverlayID cloneId = addOverlay(Overlay::Pointer(thisOverlay->createClone()));
|
||||
OverlayID cloneId = addOverlay(Overlay::Pointer(thisOverlay->createClone(), [](Overlay* ptr) { ptr->deleteLater(); }));
|
||||
#if OVERLAY_PANELS
|
||||
auto attachable = std::dynamic_pointer_cast<PanelAttachable>(thisOverlay);
|
||||
if (attachable && attachable->getParentPanel()) {
|
||||
|
@ -741,13 +741,6 @@ void Overlays::sendHoverLeaveOverlay(const OverlayID& id, const PointerEvent& ev
|
|||
}
|
||||
|
||||
OverlayID Overlays::getKeyboardFocusOverlay() {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
OverlayID result;
|
||||
PROFILE_RANGE(script, __FUNCTION__);
|
||||
BLOCKING_INVOKE_METHOD(this, "getKeyboardFocusOverlay", Q_RETURN_ARG(OverlayID, result));
|
||||
return result;
|
||||
}
|
||||
|
||||
return qApp->getKeyboardFocusOverlay();
|
||||
}
|
||||
|
||||
|
|
247
libraries/baking/src/JSBaker.cpp
Normal file
247
libraries/baking/src/JSBaker.cpp
Normal file
|
@ -0,0 +1,247 @@
|
|||
//
|
||||
// JSBaker.cpp
|
||||
// libraries/baking/src
|
||||
//
|
||||
// Created by Utkarsh Gautam on 9/18/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <PathUtils.h>
|
||||
|
||||
#include "JSBaker.h"
|
||||
#include "Baker.h"
|
||||
|
||||
const int ASCII_CHARACTERS_UPPER_LIMIT = 126;
|
||||
|
||||
JSBaker::JSBaker(const QUrl& jsURL, const QString& bakedOutputDir) :
|
||||
_jsURL(jsURL),
|
||||
_bakedOutputDir(bakedOutputDir)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void JSBaker::bake() {
|
||||
qCDebug(js_baking) << "JS Baker " << _jsURL << "bake starting";
|
||||
|
||||
// Import file to start baking
|
||||
QFile jsFile(_jsURL.toLocalFile());
|
||||
if (!jsFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
handleError("Error opening " + _jsURL.fileName() + " for reading");
|
||||
return;
|
||||
}
|
||||
|
||||
// Read file into an array
|
||||
QByteArray inputJS = jsFile.readAll();
|
||||
QByteArray outputJS;
|
||||
|
||||
// Call baking on inputJS and store result in outputJS
|
||||
bool success = bakeJS(inputJS, outputJS);
|
||||
if (!success) {
|
||||
qCDebug(js_baking) << "Bake Failed";
|
||||
handleError("Unterminated multi-line comment");
|
||||
return;
|
||||
}
|
||||
|
||||
// Bake Successful. Export the file
|
||||
auto fileName = _jsURL.fileName();
|
||||
auto baseName = fileName.left(fileName.lastIndexOf('.'));
|
||||
auto bakedFilename = baseName + BAKED_JS_EXTENSION;
|
||||
|
||||
_bakedJSFilePath = _bakedOutputDir + "/" + bakedFilename;
|
||||
|
||||
QFile bakedFile;
|
||||
bakedFile.setFileName(_bakedJSFilePath);
|
||||
if (!bakedFile.open(QIODevice::WriteOnly)) {
|
||||
handleError("Error opening " + _bakedJSFilePath + " for writing");
|
||||
return;
|
||||
}
|
||||
|
||||
bakedFile.write(outputJS);
|
||||
|
||||
// Export successful
|
||||
_outputFiles.push_back(_bakedJSFilePath);
|
||||
qCDebug(js_baking) << "Exported" << _jsURL << "minified to" << _bakedJSFilePath;
|
||||
|
||||
// emit signal to indicate the JS baking is finished
|
||||
emit finished();
|
||||
}
|
||||
|
||||
bool JSBaker::bakeJS(const QByteArray& inputFile, QByteArray& outputFile) {
|
||||
// Read from inputFile and write to outputFile per character
|
||||
QTextStream in(inputFile, QIODevice::ReadOnly);
|
||||
QTextStream out(outputFile, QIODevice::WriteOnly);
|
||||
|
||||
// Algorithm requires the knowledge of previous and next character for each character read
|
||||
QChar currentCharacter;
|
||||
QChar nextCharacter;
|
||||
// Initialize previousCharacter with new line
|
||||
QChar previousCharacter = '\n';
|
||||
|
||||
in >> currentCharacter;
|
||||
|
||||
while (!in.atEnd()) {
|
||||
in >> nextCharacter;
|
||||
|
||||
if (currentCharacter == '\r') {
|
||||
out << '\n';
|
||||
} else if (currentCharacter == '/') {
|
||||
// Check if single line comment i.e. //
|
||||
if (nextCharacter == '/') {
|
||||
handleSingleLineComments(in);
|
||||
|
||||
//Start fresh after handling comments
|
||||
previousCharacter = '\n';
|
||||
in >> currentCharacter;
|
||||
continue;
|
||||
} else if (nextCharacter == '*') {
|
||||
// Check if multi line comment i.e. /*
|
||||
bool success = handleMultiLineComments(in);
|
||||
if (!success) {
|
||||
// Errors present return false
|
||||
return false;
|
||||
}
|
||||
//Start fresh after handling comments
|
||||
previousCharacter = '\n';
|
||||
in >> currentCharacter;
|
||||
continue;
|
||||
} else {
|
||||
// If '/' is not followed by '/' or '*' print '/'
|
||||
out << currentCharacter;
|
||||
}
|
||||
} else if (isSpaceOrTab(currentCharacter)) {
|
||||
// Check if white space or tab
|
||||
|
||||
// Skip multiple spaces or tabs
|
||||
while (isSpaceOrTab(nextCharacter)) {
|
||||
in >> nextCharacter;
|
||||
if (nextCharacter == '\n') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// check if space can be omitted
|
||||
if (!canOmitSpace(previousCharacter, nextCharacter)) {
|
||||
out << ' ';
|
||||
}
|
||||
} else if (currentCharacter == '\n') {
|
||||
// Check if new line
|
||||
|
||||
//Skip multiple new lines
|
||||
//Skip new line followed by space or tab
|
||||
while (nextCharacter == '\n' || isSpaceOrTab(nextCharacter)) {
|
||||
in >> nextCharacter;
|
||||
}
|
||||
|
||||
// Check if new line can be omitted
|
||||
if (!canOmitNewLine(previousCharacter, nextCharacter)) {
|
||||
out << '\n';
|
||||
}
|
||||
} else if (isQuote(currentCharacter)) {
|
||||
// Print the current quote and nextCharacter as is
|
||||
out << currentCharacter;
|
||||
out << nextCharacter;
|
||||
|
||||
// Store the type of quote we are processing
|
||||
QChar quote = currentCharacter;
|
||||
|
||||
// Don't modify the quoted strings
|
||||
while (nextCharacter != quote) {
|
||||
in >> nextCharacter;
|
||||
out << nextCharacter;
|
||||
}
|
||||
|
||||
//Start fresh after handling quoted strings
|
||||
previousCharacter = nextCharacter;
|
||||
in >> currentCharacter;
|
||||
continue;
|
||||
} else {
|
||||
// In all other cases write the currentCharacter to outputFile
|
||||
out << currentCharacter;
|
||||
}
|
||||
|
||||
previousCharacter = currentCharacter;
|
||||
currentCharacter = nextCharacter;
|
||||
}
|
||||
|
||||
//write currentCharacter to output file when nextCharacter reaches EOF
|
||||
if (currentCharacter != '\n') {
|
||||
out << currentCharacter;
|
||||
}
|
||||
|
||||
// Successful bake. Return true
|
||||
return true;
|
||||
}
|
||||
|
||||
void JSBaker::handleSingleLineComments(QTextStream& in) {
|
||||
QChar character;
|
||||
while (!in.atEnd()) {
|
||||
in >> character;
|
||||
if (character == '\n') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool JSBaker::handleMultiLineComments(QTextStream& in) {
|
||||
QChar character;
|
||||
while (!in.atEnd()) {
|
||||
in >> character;
|
||||
if (character == '*') {
|
||||
if (in.read(1) == '/') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JSBaker::canOmitSpace(QChar previousCharacter, QChar nextCharacter) {
|
||||
return(!((isAlphanum(previousCharacter) || isNonAscii(previousCharacter) || isSpecialCharacter(previousCharacter)) &&
|
||||
(isAlphanum(nextCharacter) || isNonAscii(nextCharacter) || isSpecialCharacter(nextCharacter)))
|
||||
);
|
||||
}
|
||||
|
||||
bool JSBaker::canOmitNewLine(QChar previousCharacter, QChar nextCharacter) {
|
||||
return (!((isAlphanum(previousCharacter) || isNonAscii(previousCharacter) || isSpecialCharacterPrevious(previousCharacter)) &&
|
||||
(isAlphanum(nextCharacter) || isNonAscii(nextCharacter) || isSpecialCharacterNext(nextCharacter)))
|
||||
);
|
||||
}
|
||||
|
||||
//Check if character is alphabet, number or one of the following: '_', '$', '\\' or a non-ASCII character
|
||||
bool JSBaker::isAlphanum(QChar c) {
|
||||
return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z')
|
||||
|| c == '_' || c == '$' || c == '\\' || c > ASCII_CHARACTERS_UPPER_LIMIT);
|
||||
}
|
||||
|
||||
bool JSBaker::isNonAscii(QChar c) {
|
||||
return ((int)c.toLatin1() > ASCII_CHARACTERS_UPPER_LIMIT);
|
||||
}
|
||||
|
||||
// If previous and next characters are special characters, don't omit space
|
||||
bool JSBaker::isSpecialCharacter(QChar c) {
|
||||
return (c == '\'' || c == '$' || c == '_' || c == '/' || c== '+' || c == '-');
|
||||
}
|
||||
|
||||
// If previous character is a special character, maybe don't omit new line (depends on next character as well)
|
||||
bool JSBaker::isSpecialCharacterPrevious(QChar c) {
|
||||
return (c == '\'' || c == '$' || c == '_' || c == '}' || c == ']' || c == ')' || c == '+' || c == '-'
|
||||
|| c == '"' || c == "'");
|
||||
}
|
||||
|
||||
// If next character is a special character, maybe don't omit new line (depends on previous character as well)
|
||||
bool JSBaker::isSpecialCharacterNext(QChar c) {
|
||||
return (c == '\'' || c == '$' || c == '_' || c == '{' || c == '[' || c == '(' || c == '+' || c == '-');
|
||||
}
|
||||
|
||||
// Check if white space or tab
|
||||
bool JSBaker::isSpaceOrTab(QChar c) {
|
||||
return (c == ' ' || c == '\t');
|
||||
}
|
||||
|
||||
// Check If the currentCharacter is " or ' or `
|
||||
bool JSBaker::isQuote(QChar c) {
|
||||
return (c == '"' || c == "'" || c == '`');
|
||||
}
|
49
libraries/baking/src/JSBaker.h
Normal file
49
libraries/baking/src/JSBaker.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// JSBaker.h
|
||||
// libraries/baking/src
|
||||
//
|
||||
// Created by Utkarsh Gautam on 9/18/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_JSBaker_h
|
||||
#define hifi_JSBaker_h
|
||||
|
||||
#include "Baker.h"
|
||||
#include "JSBakingLoggingCategory.h"
|
||||
|
||||
static const QString BAKED_JS_EXTENSION = ".baked.js";
|
||||
|
||||
class JSBaker : public Baker {
|
||||
Q_OBJECT
|
||||
public:
|
||||
JSBaker(const QUrl& jsURL, const QString& bakedOutputDir);
|
||||
static bool bakeJS(const QByteArray& inputFile, QByteArray& outputFile);
|
||||
|
||||
public slots:
|
||||
virtual void bake() override;
|
||||
|
||||
private:
|
||||
QUrl _jsURL;
|
||||
QString _bakedOutputDir;
|
||||
QString _bakedJSFilePath;
|
||||
|
||||
static void handleSingleLineComments(QTextStream& in);
|
||||
static bool handleMultiLineComments(QTextStream& in);
|
||||
|
||||
static bool canOmitSpace(QChar previousCharacter, QChar nextCharacter);
|
||||
static bool canOmitNewLine(QChar previousCharacter, QChar nextCharacter);
|
||||
|
||||
static bool isAlphanum(QChar c);
|
||||
static bool isNonAscii(QChar c);
|
||||
static bool isSpecialCharacter(QChar c);
|
||||
static bool isSpecialCharacterPrevious(QChar c);
|
||||
static bool isSpecialCharacterNext(QChar c);
|
||||
static bool isSpaceOrTab(QChar c);
|
||||
static bool isQuote(QChar c);
|
||||
};
|
||||
|
||||
#endif // !hifi_JSBaker_h
|
14
libraries/baking/src/JSBakingLoggingCategory.cpp
Normal file
14
libraries/baking/src/JSBakingLoggingCategory.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// JSBakingLoggingCategory.cpp
|
||||
// libraries/baking/src
|
||||
//
|
||||
// Created by Utkarsh Gautam on 9/18/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "JSBakingLoggingCategory.h"
|
||||
|
||||
Q_LOGGING_CATEGORY(js_baking, "hifi.JS-baking");
|
19
libraries/baking/src/JSBakingLoggingCategory.h
Normal file
19
libraries/baking/src/JSBakingLoggingCategory.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// JSBakingLoggingCategory.h
|
||||
// libraries/baking/src
|
||||
//
|
||||
// Created by Utkarsh Gautam on 9/18/17.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_JSBakingLoggingCategory_h
|
||||
#define hifi_JSBakingLoggingCategory_h
|
||||
|
||||
#include <QtCore/QLoggingCategory>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(js_baking)
|
||||
|
||||
#endif // hifi_ModelBakingLoggingCategory_h
|
|
@ -237,19 +237,7 @@ void EntityTreeRenderer::update(bool simulate) {
|
|||
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
||||
tree->update(simulate);
|
||||
|
||||
if (simulate) {
|
||||
// Handle enter/leave entity logic
|
||||
checkEnterLeaveEntities();
|
||||
|
||||
// Even if we're not moving the mouse, if we started clicking on an entity and we have
|
||||
// not yet released the hold then this is still considered a holdingClickOnEntity event
|
||||
// and we want to simulate this message here as well as in mouse move
|
||||
if (_lastPointerEventValid && !_currentClickingOnEntityID.isInvalidID()) {
|
||||
emit holdingClickOnEntity(_currentClickingOnEntityID, _lastPointerEvent);
|
||||
_entitiesScriptEngine->callEntityScriptMethod(_currentClickingOnEntityID, "holdingClickOnEntity", _lastPointerEvent);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the rendereable entities as needed
|
||||
{
|
||||
PerformanceTimer sceneTimer("scene");
|
||||
auto scene = _viewState->getMain3DScene();
|
||||
|
@ -269,6 +257,20 @@ void EntityTreeRenderer::update(bool simulate) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (simulate) {
|
||||
// Handle enter/leave entity logic
|
||||
checkEnterLeaveEntities();
|
||||
|
||||
// Even if we're not moving the mouse, if we started clicking on an entity and we have
|
||||
// not yet released the hold then this is still considered a holdingClickOnEntity event
|
||||
// and we want to simulate this message here as well as in mouse move
|
||||
if (_lastPointerEventValid && !_currentClickingOnEntityID.isInvalidID()) {
|
||||
emit holdingClickOnEntity(_currentClickingOnEntityID, _lastPointerEvent);
|
||||
_entitiesScriptEngine->callEntityScriptMethod(_currentClickingOnEntityID, "holdingClickOnEntity", _lastPointerEvent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,8 @@ bool ModelEntityWrapper::isModelLoaded() const {
|
|||
}
|
||||
|
||||
EntityItemPointer RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity{ new RenderableModelEntityItem(entityID, properties.getDimensionsInitialized()) };
|
||||
EntityItemPointer entity(new RenderableModelEntityItem(entityID, properties.getDimensionsInitialized()),
|
||||
[](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ void loop3(const T& start, const T& end, F f) {
|
|||
}
|
||||
|
||||
EntityItemPointer RenderablePolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
std::shared_ptr<RenderablePolyVoxEntityItem> entity{ new RenderablePolyVoxEntityItem(entityID) };
|
||||
std::shared_ptr<RenderablePolyVoxEntityItem> entity(new RenderablePolyVoxEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
entity->initializePolyVox();
|
||||
return entity;
|
||||
|
|
|
@ -45,7 +45,7 @@ void EntityEditPacketSender::queueEditAvatarEntityMessage(PacketType type,
|
|||
}
|
||||
EntityItemPointer entity = entityTree->findEntityByEntityItemID(entityItemID);
|
||||
if (!entity) {
|
||||
qCDebug(entities) << "EntityEditPacketSender::queueEditEntityMessage can't find entity.";
|
||||
qCDebug(entities) << "EntityEditPacketSender::queueEditAvatarEntityMessage can't find entity: " << entityItemID;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2092,7 +2092,13 @@ bool EntityTree::sendEntitiesOperation(const OctreeElementPointer& element, void
|
|||
|
||||
QHash<EntityItemID, EntityItemID>::iterator iter = args->map->find(oldID);
|
||||
if (iter == args->map->end()) {
|
||||
EntityItemID newID = QUuid::createUuid();
|
||||
EntityItemID newID;
|
||||
if (oldID == AVATAR_SELF_ID) {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
newID = EntityItemID(nodeList->getSessionUUID());
|
||||
} else {
|
||||
newID = QUuid::createUuid();
|
||||
}
|
||||
args->map->insert(oldID, newID);
|
||||
return newID;
|
||||
}
|
||||
|
@ -2109,8 +2115,8 @@ bool EntityTree::sendEntitiesOperation(const OctreeElementPointer& element, void
|
|||
properties.setPosition(properties.getPosition() + args->root);
|
||||
} else {
|
||||
EntityItemPointer parentEntity = args->ourTree->findEntityByEntityItemID(oldParentID);
|
||||
if (parentEntity) { // map the parent
|
||||
properties.setParentID(getMapped(parentEntity->getID()));
|
||||
if (parentEntity || oldParentID == AVATAR_SELF_ID) { // map the parent
|
||||
properties.setParentID(getMapped(oldParentID));
|
||||
// But do not add root offset in this case.
|
||||
} else { // Should not happen, but let's try to be helpful...
|
||||
item->globalizeProperties(properties, "Cannot find %3 parent of %2 %1", args->root);
|
||||
|
@ -2185,6 +2191,12 @@ bool EntityTree::readFromMap(QVariantMap& map) {
|
|||
entityItemID = EntityItemID(QUuid::createUuid());
|
||||
}
|
||||
|
||||
if (properties.getClientOnly()) {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||
properties.setOwningAvatarID(myNodeID);
|
||||
}
|
||||
|
||||
EntityItemPointer entity = addEntity(entityItemID, properties);
|
||||
if (!entity) {
|
||||
qCDebug(entities) << "adding Entity failed:" << entityItemID << properties.getType();
|
||||
|
|
|
@ -30,7 +30,7 @@ const float LightEntityItem::DEFAULT_CUTOFF = PI / 2.0f;
|
|||
bool LightEntityItem::_lightsArePickable = false;
|
||||
|
||||
EntityItemPointer LightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity { new LightEntityItem(entityID) };
|
||||
EntityItemPointer entity(new LightEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ const int LineEntityItem::MAX_POINTS_PER_LINE = 70;
|
|||
|
||||
|
||||
EntityItemPointer LineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity { new LineEntityItem(entityID) };
|
||||
EntityItemPointer entity(new LineEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
@ -214,4 +214,4 @@ void LineEntityItem::resetPointsChanged() {
|
|||
withWriteLock([&] {
|
||||
_pointsChanged = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ const QString ModelEntityItem::DEFAULT_MODEL_URL = QString("");
|
|||
const QString ModelEntityItem::DEFAULT_COMPOUND_SHAPE_URL = QString("");
|
||||
|
||||
EntityItemPointer ModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity { new ModelEntityItem(entityID) };
|
||||
EntityItemPointer entity(new ModelEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ uint64_t Properties::emitIntervalUsecs() const {
|
|||
|
||||
|
||||
EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity { new ParticleEffectEntityItem(entityID) };
|
||||
EntityItemPointer entity(new ParticleEffectEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ const int PolyLineEntityItem::MAX_POINTS_PER_LINE = 70;
|
|||
|
||||
|
||||
EntityItemPointer PolyLineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity{ new PolyLineEntityItem(entityID) };
|
||||
EntityItemPointer entity(new PolyLineEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ const QString PolyVoxEntityItem::DEFAULT_Y_TEXTURE_URL = QString("");
|
|||
const QString PolyVoxEntityItem::DEFAULT_Z_TEXTURE_URL = QString("");
|
||||
|
||||
EntityItemPointer PolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity { new PolyVoxEntityItem(entityID) };
|
||||
EntityItemPointer entity(new PolyVoxEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace entity {
|
|||
}
|
||||
|
||||
ShapeEntityItem::Pointer ShapeEntityItem::baseFactory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
Pointer entity { new ShapeEntityItem(entityID) };
|
||||
Pointer entity(new ShapeEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ const xColor TextEntityItem::DEFAULT_BACKGROUND_COLOR = { 0, 0, 0};
|
|||
const bool TextEntityItem::DEFAULT_FACE_CAMERA = false;
|
||||
|
||||
EntityItemPointer TextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity { new TextEntityItem(entityID) };
|
||||
EntityItemPointer entity(new TextEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
const QString WebEntityItem::DEFAULT_SOURCE_URL("http://www.google.com");
|
||||
|
||||
EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity { new WebEntityItem(entityID) };
|
||||
EntityItemPointer entity(new WebEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ const bool ZoneEntityItem::DEFAULT_GHOSTING_ALLOWED = true;
|
|||
const QString ZoneEntityItem::DEFAULT_FILTER_URL = "";
|
||||
|
||||
EntityItemPointer ZoneEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItemPointer entity { new ZoneEntityItem(entityID) };
|
||||
EntityItemPointer entity(new ZoneEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
|
||||
entity->setProperties(properties);
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -1202,10 +1202,6 @@ gpu::TexturePointer TextureUsage::processCubeTextureColorFromImage(const QImage&
|
|||
formatGPU = HDR_FORMAT;
|
||||
}
|
||||
|
||||
if (image.format() != QIMAGE_HDR_FORMAT) {
|
||||
image = convertToHDRFormat(image, HDR_FORMAT);
|
||||
}
|
||||
|
||||
// Find the layout of the cubemap in the 2D image
|
||||
// Use the original image size since processSourceImage may have altered the size / aspect ratio
|
||||
int foundLayout = CubeLayout::findLayout(srcImage.width(), srcImage.height());
|
||||
|
@ -1233,6 +1229,13 @@ gpu::TexturePointer TextureUsage::processCubeTextureColorFromImage(const QImage&
|
|||
faces.push_back(faceImage);
|
||||
}
|
||||
}
|
||||
|
||||
if (image.format() != QIMAGE_HDR_FORMAT) {
|
||||
for (auto& face : faces) {
|
||||
face = convertToHDRFormat(face, HDR_FORMAT);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
qCDebug(imagelogging) << "Failed to find a known cube map layout from this image:" << QString(srcImageName.c_str());
|
||||
return nullptr;
|
||||
|
|
|
@ -676,7 +676,7 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
|||
}
|
||||
|
||||
// insert the new node and release our read lock
|
||||
#ifdef Q_OS_ANDROID
|
||||
#if defined(Q_OS_ANDROID) || (defined(__clang__) && defined(Q_OS_LINUX))
|
||||
_nodeHash.insert(UUIDNodePair(newNode->getUUID(), newNodePointer));
|
||||
#else
|
||||
_nodeHash.emplace(newNode->getUUID(), newNodePointer);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "HFActionEvent.h"
|
||||
#include "KeyEvent.h"
|
||||
#include "MouseEvent.h"
|
||||
#include "SpatialEvent.h"
|
||||
|
@ -20,7 +19,6 @@
|
|||
#include "EventTypes.h"
|
||||
|
||||
void registerEventTypes(QScriptEngine* engine) {
|
||||
qScriptRegisterMetaType(engine, HFActionEvent::toScriptValue, HFActionEvent::fromScriptValue);
|
||||
qScriptRegisterMetaType(engine, KeyEvent::toScriptValue, KeyEvent::fromScriptValue);
|
||||
qScriptRegisterMetaType(engine, MouseEvent::toScriptValue, MouseEvent::fromScriptValue);
|
||||
qScriptRegisterMetaType(engine, PointerEvent::toScriptValue, PointerEvent::fromScriptValue);
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
//
|
||||
// HFActionEvent.cpp
|
||||
// script-engine/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-10-27.
|
||||
// Copyright 2014 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 "HFActionEvent.h"
|
||||
|
||||
HFActionEvent::HFActionEvent(QEvent::Type type, const PickRay& actionRay) :
|
||||
HFMetaEvent(type),
|
||||
actionRay(actionRay)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QEvent::Type HFActionEvent::startType() {
|
||||
static QEvent::Type startType = HFMetaEvent::newEventType();
|
||||
return startType;
|
||||
}
|
||||
|
||||
QEvent::Type HFActionEvent::endType() {
|
||||
static QEvent::Type endType = HFMetaEvent::newEventType();
|
||||
return endType;
|
||||
}
|
||||
|
||||
QScriptValue HFActionEvent::toScriptValue(QScriptEngine* engine, const HFActionEvent& event) {
|
||||
QScriptValue obj = engine->newObject();
|
||||
obj.setProperty("actionRay", pickRayToScriptValue(engine, event.actionRay));
|
||||
return obj;
|
||||
}
|
||||
|
||||
void HFActionEvent::fromScriptValue(const QScriptValue& object, HFActionEvent& event) {
|
||||
// not yet implemented
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
//
|
||||
// HFActionEvent.h
|
||||
// script-engine/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-10-27.
|
||||
// Copyright 2014 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_HFActionEvent_h
|
||||
#define hifi_HFActionEvent_h
|
||||
|
||||
|
||||
#include <qscriptengine.h>
|
||||
|
||||
#include <RegisteredMetaTypes.h>
|
||||
|
||||
#include "HFMetaEvent.h"
|
||||
|
||||
class HFActionEvent : public HFMetaEvent {
|
||||
public:
|
||||
HFActionEvent() {};
|
||||
HFActionEvent(QEvent::Type type, const PickRay& actionRay);
|
||||
|
||||
static QEvent::Type startType();
|
||||
static QEvent::Type endType();
|
||||
|
||||
static QScriptValue toScriptValue(QScriptEngine* engine, const HFActionEvent& event);
|
||||
static void fromScriptValue(const QScriptValue& object, HFActionEvent& event);
|
||||
|
||||
PickRay actionRay;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(HFActionEvent)
|
||||
|
||||
#endif // hifi_HFActionEvent_h
|
|
@ -1,28 +0,0 @@
|
|||
//
|
||||
// HFBackEvent.cpp
|
||||
// script-engine/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-10-27.
|
||||
// Copyright 2014 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 "HFBackEvent.h"
|
||||
|
||||
HFBackEvent::HFBackEvent(QEvent::Type type) :
|
||||
HFMetaEvent(type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QEvent::Type HFBackEvent::startType() {
|
||||
static QEvent::Type startType = HFMetaEvent::newEventType();
|
||||
return startType;
|
||||
}
|
||||
|
||||
QEvent::Type HFBackEvent::endType() {
|
||||
static QEvent::Type endType = HFMetaEvent::newEventType();
|
||||
return endType;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
//
|
||||
// HFBackEvent.h
|
||||
// script-engine/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-10-27.
|
||||
// Copyright 2014 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_HFBackEvent_h
|
||||
#define hifi_HFBackEvent_h
|
||||
|
||||
#include <qevent.h>
|
||||
#include <qscriptengine.h>
|
||||
|
||||
#include "HFMetaEvent.h"
|
||||
|
||||
class HFBackEvent : public HFMetaEvent {
|
||||
public:
|
||||
HFBackEvent() {};
|
||||
HFBackEvent(QEvent::Type type);
|
||||
|
||||
static QEvent::Type startType();
|
||||
static QEvent::Type endType();
|
||||
};
|
||||
|
||||
#endif // hifi_HFBackEvent_h
|
|
@ -1,20 +0,0 @@
|
|||
//
|
||||
// HFMetaEvent.cpp
|
||||
// script-engine/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-10-27.
|
||||
// Copyright 2014 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 "HFMetaEvent.h"
|
||||
|
||||
QSet<QEvent::Type> HFMetaEvent::_types = QSet<QEvent::Type>();
|
||||
|
||||
QEvent::Type HFMetaEvent::newEventType() {
|
||||
QEvent::Type newType = static_cast<QEvent::Type>(QEvent::registerEventType());
|
||||
_types.insert(newType);
|
||||
return newType;
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
//
|
||||
// HFMetaEvent.h
|
||||
// script-engine/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-10-27.
|
||||
// Copyright 2014 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_HFMetaEvent_h
|
||||
#define hifi_HFMetaEvent_h
|
||||
|
||||
#include <qevent.h>
|
||||
|
||||
class HFMetaEvent : public QEvent {
|
||||
public:
|
||||
HFMetaEvent() : QEvent(HFMetaEvent::newEventType()) {};
|
||||
HFMetaEvent(QEvent::Type type) : QEvent(type) {};
|
||||
static const QSet<QEvent::Type>& types() { return HFMetaEvent::_types; }
|
||||
protected:
|
||||
static QEvent::Type newEventType();
|
||||
|
||||
static QSet<QEvent::Type> _types;
|
||||
};
|
||||
|
||||
#endif // hifi_HFMetaEvent_h
|
|
@ -102,8 +102,11 @@ SpatiallyNestablePointer SpatiallyNestable::getParentPointer(bool& success) cons
|
|||
if (parent && parent->getID() == parentID) {
|
||||
// parent pointer is up-to-date
|
||||
if (!_parentKnowsMe) {
|
||||
parent->beParentOfChild(getThisPointer());
|
||||
_parentKnowsMe = true;
|
||||
SpatialParentTree* parentTree = parent->getParentTree();
|
||||
if (!parentTree || parentTree == getParentTree()) {
|
||||
parent->beParentOfChild(getThisPointer());
|
||||
_parentKnowsMe = true;
|
||||
}
|
||||
}
|
||||
success = true;
|
||||
return parent;
|
||||
|
@ -129,8 +132,15 @@ SpatiallyNestablePointer SpatiallyNestable::getParentPointer(bool& success) cons
|
|||
|
||||
parent = _parent.lock();
|
||||
if (parent) {
|
||||
parent->beParentOfChild(getThisPointer());
|
||||
_parentKnowsMe = true;
|
||||
|
||||
// it's possible for an entity with a parent of AVATAR_SELF_ID can be imported into a side-tree
|
||||
// such as the clipboard's. if this is the case, we don't want the parent to consider this a
|
||||
// child.
|
||||
SpatialParentTree* parentTree = parent->getParentTree();
|
||||
if (!parentTree || parentTree == getParentTree()) {
|
||||
parent->beParentOfChild(getThisPointer());
|
||||
_parentKnowsMe = true;
|
||||
}
|
||||
}
|
||||
|
||||
success = (parent || parentID.isNull());
|
||||
|
|
|
@ -193,6 +193,11 @@
|
|||
var navbarBrandElement = document.getElementsByClassName('navbar-brand')[0];
|
||||
var purchasesElement = document.createElement('a');
|
||||
var dropDownElement = document.getElementById('user-dropdown');
|
||||
|
||||
$('#user-dropdown').find('.username')[0].style = "max-width:80px;white-space:nowrap;overflow:hidden;" +
|
||||
"text-overflow:ellipsis;display:inline-block;position:relative;top:4px;";
|
||||
$('#user-dropdown').find('.caret')[0].style = "position:relative;top:-3px;";
|
||||
|
||||
purchasesElement.id = "purchasesButton";
|
||||
purchasesElement.setAttribute('href', "#");
|
||||
purchasesElement.innerHTML = "My Purchases";
|
||||
|
|
|
@ -222,7 +222,7 @@ getControllerJointIndex = function (hand) {
|
|||
return controllerJointIndex;
|
||||
}
|
||||
|
||||
return MyAvatar.getJointIndex("Head");
|
||||
return -1;
|
||||
};
|
||||
|
||||
propsArePhysical = function (props) {
|
||||
|
|
10
tests/baking/CMakeLists.txt
Normal file
10
tests/baking/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
# Declare dependencies
|
||||
macro (setup_testcase_dependencies)
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(shared baking)
|
||||
|
||||
package_libraries_for_deployment()
|
||||
endmacro ()
|
||||
|
||||
setup_hifi_testcase()
|
92
tests/baking/src/JSBakerTest.cpp
Normal file
92
tests/baking/src/JSBakerTest.cpp
Normal file
|
@ -0,0 +1,92 @@
|
|||
//
|
||||
// JSBakerTest.cpp
|
||||
// tests/networking/src
|
||||
//
|
||||
// Created by Utkarsh Gautam on 09/26/17.
|
||||
// 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 "JSBakerTest.h"
|
||||
QTEST_MAIN(JSBakerTest)
|
||||
|
||||
void JSBakerTest::setTestCases() {
|
||||
// Test cases contain a std::pair(input, desiredOutput)
|
||||
|
||||
_testCases.emplace_back("var a=1;", "var a=1;");
|
||||
_testCases.emplace_back("var a=1;//single line comment\nvar b=2;", "var a=1;var b=2;");
|
||||
_testCases.emplace_back("a\rb", "a\nb");
|
||||
_testCases.emplace_back("a/*multi\n line \n comment*/ b", "ab");
|
||||
_testCases.emplace_back("a/b", "a/b");
|
||||
_testCases.emplace_back("var a = 1;", "var a=1;"); // Multiple spaces omitted
|
||||
_testCases.emplace_back("var a=\t\t\t1;", "var a=1;"); // Multiple tabs omitted
|
||||
|
||||
// Cases for space not omitted
|
||||
_testCases.emplace_back("var x", "var x");
|
||||
_testCases.emplace_back("a '", "a '");
|
||||
_testCases.emplace_back("a $", "a $");
|
||||
_testCases.emplace_back("a _", "a _");
|
||||
_testCases.emplace_back("a /", "a /");
|
||||
_testCases.emplace_back("a 1", "a 1");
|
||||
_testCases.emplace_back("1 a", "1 a");
|
||||
_testCases.emplace_back("$ a", "$ a");
|
||||
_testCases.emplace_back("_ a", "_ a");
|
||||
_testCases.emplace_back("/ a", "/ a");
|
||||
_testCases.emplace_back("$ $", "$ $");
|
||||
_testCases.emplace_back("_ _", "_ _");
|
||||
_testCases.emplace_back("/ /", "/ /");
|
||||
|
||||
_testCases.emplace_back("a\n\n\n\nb", "a\nb"); // Skip multiple new lines
|
||||
_testCases.emplace_back("a\n\n b", "a\nb"); // Skip multiple new lines followed by whitespace
|
||||
_testCases.emplace_back("a\n\n b", "a\nb"); // Skip multiple new lines followed by tab
|
||||
|
||||
//Cases for new line not omitted
|
||||
_testCases.emplace_back("a\nb", "a\nb");
|
||||
_testCases.emplace_back("a\n9", "a\n9");
|
||||
_testCases.emplace_back("9\na", "9\na");
|
||||
_testCases.emplace_back("a\n$", "a\n$");
|
||||
_testCases.emplace_back("a\n[", "a\n[");
|
||||
_testCases.emplace_back("a\n{", "a\n{");
|
||||
_testCases.emplace_back("a\n(", "a\n(");
|
||||
_testCases.emplace_back("a\n+", "a\n+");
|
||||
_testCases.emplace_back("a\n'", "a\n'");
|
||||
_testCases.emplace_back("a\n-", "a\n-");
|
||||
_testCases.emplace_back("$\na", "$\na");
|
||||
_testCases.emplace_back("$\na", "$\na");
|
||||
_testCases.emplace_back("_\na", "_\na");
|
||||
_testCases.emplace_back("]\na", "]\na");
|
||||
_testCases.emplace_back("}\na", "}\na");
|
||||
_testCases.emplace_back(")\na", ")\na");
|
||||
_testCases.emplace_back("+\na", "+\na");
|
||||
_testCases.emplace_back("-\na", "-\na");
|
||||
|
||||
// Cases to check quoted strings are not modified
|
||||
_testCases.emplace_back("'abcd1234$%^&[](){}'\na", "'abcd1234$%^&[](){}'\na");
|
||||
_testCases.emplace_back("\"abcd1234$%^&[](){}\"\na", "\"abcd1234$%^&[](){}\"\na");
|
||||
_testCases.emplace_back("`abcd1234$%^&[](){}`\na", "`abcd1234$%^&[](){}`a");
|
||||
|
||||
// Edge Cases
|
||||
|
||||
//No semicolon to terminate an expression, instead a new line used for termination
|
||||
_testCases.emplace_back("var x=5\nvar y=6;", "var x=5\nvar y=6;");
|
||||
|
||||
//a + ++b is minified as a+ ++b.
|
||||
_testCases.emplace_back("a + ++b", "a + ++b");
|
||||
|
||||
//a - --b is minified as a- --b.
|
||||
_testCases.emplace_back("a - --b", "a - --b");
|
||||
}
|
||||
|
||||
void JSBakerTest::testJSBaking() {
|
||||
|
||||
for (int i = 0;i < _testCases.size();i++) {
|
||||
QByteArray output;
|
||||
auto input = _testCases.at(i).first;
|
||||
JSBaker::bakeJS(input, output);
|
||||
|
||||
auto desiredOutput = _testCases.at(i).second;
|
||||
QCOMPARE(output, desiredOutput);
|
||||
}
|
||||
}
|
29
tests/baking/src/JSBakerTest.h
Normal file
29
tests/baking/src/JSBakerTest.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// JSBakerTest.h
|
||||
// tests/networking/src
|
||||
//
|
||||
// Created by Utkarsh Gautam on 9/26/17.
|
||||
// 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_JSBakerTest_h
|
||||
#define hifi_JSBakerTest_h
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <JSBaker.h>
|
||||
|
||||
class JSBakerTest : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void setTestCases();
|
||||
void testJSBaking();
|
||||
|
||||
private:
|
||||
std::vector<std::pair<QByteArray, QByteArray>> _testCases;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue