Merge remote-tracking branch 'hifi/master' into android_goto_splash

This commit is contained in:
Cristian Luis Duarte 2018-04-11 18:03:16 -03:00
commit d993e4938e
37 changed files with 521 additions and 178 deletions

View file

@ -1486,16 +1486,16 @@ std::pair<bool, AssetMeta> AssetServer::readMetaFile(AssetUtils::AssetHash hash)
if (error.error == QJsonParseError::NoError && doc.isObject()) { if (error.error == QJsonParseError::NoError && doc.isObject()) {
auto root = doc.object(); auto root = doc.object();
auto bakeVersion = root[BAKE_VERSION_KEY].toInt(-1); auto bakeVersion = root[BAKE_VERSION_KEY];
auto failedLastBake = root[FAILED_LAST_BAKE_KEY]; auto failedLastBake = root[FAILED_LAST_BAKE_KEY];
auto lastBakeErrors = root[LAST_BAKE_ERRORS_KEY]; auto lastBakeErrors = root[LAST_BAKE_ERRORS_KEY];
if (bakeVersion != -1 if (bakeVersion.isDouble()
&& failedLastBake.isBool() && failedLastBake.isBool()
&& lastBakeErrors.isString()) { && lastBakeErrors.isString()) {
AssetMeta meta; AssetMeta meta;
meta.bakeVersion = bakeVersion; meta.bakeVersion = bakeVersion.toInt();
meta.failedLastBake = failedLastBake.toBool(); meta.failedLastBake = failedLastBake.toBool();
meta.lastBakeErrors = lastBakeErrors.toString(); meta.lastBakeErrors = lastBakeErrors.toString();

View file

@ -14,12 +14,24 @@ macro(GENERATE_INSTALLERS)
set(CPACK_MODULE_PATH ${CPACK_MODULE_PATH} "${HF_CMAKE_DIR}/templates") set(CPACK_MODULE_PATH ${CPACK_MODULE_PATH} "${HF_CMAKE_DIR}/templates")
set(_DISPLAY_NAME ${BUILD_ORGANIZATION})
if (CLIENT_ONLY)
set(_PACKAGE_NAME_EXTRA "-Interface")
set(INSTALLER_TYPE "client_only")
string(REGEX REPLACE "High Fidelity" "High Fidelity Interface" _DISPLAY_NAME ${BUILD_ORGANIZATION})
elseif (SERVER_ONLY)
set(_PACKAGE_NAME_EXTRA "-Sandbox")
set(INSTALLER_TYPE "server_only")
string(REGEX REPLACE "High Fidelity" "High Fidelity Sandbox" _DISPLAY_NAME ${BUILD_ORGANIZATION})
else ()
set(_DISPLAY_NAME ${BUILD_ORGANIZATION})
set(INSTALLER_TYPE "full")
endif ()
set(CPACK_PACKAGE_NAME ${_DISPLAY_NAME}) set(CPACK_PACKAGE_NAME ${_DISPLAY_NAME})
set(CPACK_PACKAGE_VENDOR "High Fidelity") set(CPACK_PACKAGE_VENDOR "High Fidelity")
set(CPACK_PACKAGE_VERSION ${BUILD_VERSION}) set(CPACK_PACKAGE_VERSION ${BUILD_VERSION})
set(CPACK_PACKAGE_FILE_NAME "HighFidelity-Beta-${BUILD_VERSION}") set(CPACK_PACKAGE_FILE_NAME "HighFidelity-Beta${_PACKAGE_NAME_EXTRA}-${BUILD_VERSION}")
set(CPACK_NSIS_DISPLAY_NAME ${_DISPLAY_NAME}) set(CPACK_NSIS_DISPLAY_NAME ${_DISPLAY_NAME})
set(CPACK_NSIS_PACKAGE_NAME ${_DISPLAY_NAME}) set(CPACK_NSIS_PACKAGE_NAME ${_DISPLAY_NAME})
if (PR_BUILD) if (PR_BUILD)

View file

@ -48,3 +48,4 @@ set(UNINSTALLER_HEADER_IMAGE "@UNINSTALLER_HEADER_IMAGE@")
set(ADD_REMOVE_ICON_PATH "@ADD_REMOVE_ICON_PATH@") set(ADD_REMOVE_ICON_PATH "@ADD_REMOVE_ICON_PATH@")
set(SERVER_COMPONENT_CONDITIONAL "@SERVER_COMPONENT_CONDITIONAL@") set(SERVER_COMPONENT_CONDITIONAL "@SERVER_COMPONENT_CONDITIONAL@")
set(CLIENT_COMPONENT_CONDITIONAL "@CLIENT_COMPONENT_CONDITIONAL@") set(CLIENT_COMPONENT_CONDITIONAL "@CLIENT_COMPONENT_CONDITIONAL@")
set(INSTALLER_TYPE "@INSTALLER_TYPE@")

View file

@ -710,11 +710,9 @@ Function PostInstallOptionsPage
!insertmacro SetInstallOption $ServerStartupCheckbox @CONSOLE_STARTUP_REG_KEY@ ${BST_CHECKED} !insertmacro SetInstallOption $ServerStartupCheckbox @CONSOLE_STARTUP_REG_KEY@ ${BST_CHECKED}
${EndIf} ${EndIf}
${If} @SERVER_COMPONENT_CONDITIONAL@ ${NSD_CreateCheckbox} 0 $CurrentOffset$OffsetUnits 100% 10u "&Perform a clean install (Delete older settings and content)"
${NSD_CreateCheckbox} 0 $CurrentOffset$OffsetUnits 100% 10u "&Perform a clean install (Delete older settings and content)" Pop $CleanInstallCheckbox
Pop $CleanInstallCheckbox IntOp $CurrentOffset $CurrentOffset + 15
IntOp $CurrentOffset $CurrentOffset + 15
${EndIf}
${If} @PR_BUILD@ == 1 ${If} @PR_BUILD@ == 1
; a PR build defaults all install options expect LaunchServerNowCheckbox, LaunchClientNowCheckbox and the settings copy to unchecked ; a PR build defaults all install options expect LaunchServerNowCheckbox, LaunchClientNowCheckbox and the settings copy to unchecked
@ -809,10 +807,8 @@ Function ReadPostInstallOptions
${NSD_GetState} $LaunchClientNowCheckbox $LaunchClientNowState ${NSD_GetState} $LaunchClientNowCheckbox $LaunchClientNowState
${EndIf} ${EndIf}
${If} @CLIENT_COMPONENT_CONDITIONAL@ ; check if the user asked for a clean install
; check if the user asked for a clean install ${NSD_GetState} $CleanInstallCheckbox $CleanInstallState
${NSD_GetState} $CleanInstallCheckbox $CleanInstallState
${EndIf}
FunctionEnd FunctionEnd
Function HandlePostInstallOptions Function HandlePostInstallOptions
@ -856,13 +852,23 @@ Function HandlePostInstallOptions
${EndIf} ${EndIf}
${EndIf} ${EndIf}
${If} @CLIENT_COMPONENT_CONDITIONAL@ ; check if the user asked for a clean install
; check if the user asked for a clean install ${If} $CleanInstallState == ${BST_CHECKED}
${If} $CleanInstallState == ${BST_CHECKED} SetShellVarContext current
SetShellVarContext current
RMDir /r "$APPDATA\@BUILD_ORGANIZATION@" ${If} @SERVER_COMPONENT_CONDITIONAL@
RMDir /r "$LOCALAPPDATA\@BUILD_ORGANIZATION@" RMDir /r "$APPDATA\@BUILD_ORGANIZATION@\Server Console"
RMDir /r "$APPDATA\@BUILD_ORGANIZATION@\assignment-client"
RMDir /r "$APPDATA\@BUILD_ORGANIZATION@\domain-server"
Delete "$APPDATA\@BUILD_ORGANIZATION@\domain-server.json"
${EndIf} ${EndIf}
${If} @CLIENT_COMPONENT_CONDITIONAL@
Delete "$APPDATA\@BUILD_ORGANIZATION@\Interface\AccountInfo.bin"
Delete "$APPDATA\@BUILD_ORGANIZATION@\Interface.json"
${EndIf}
RMDir /r "$LOCALAPPDATA\@BUILD_ORGANIZATION@"
${EndIf} ${EndIf}
${If} @PR_BUILD@ == 1 ${If} @PR_BUILD@ == 1
@ -976,6 +982,13 @@ Section "-Core installation"
;Store installation folder ;Store installation folder
WriteRegStr HKLM "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR WriteRegStr HKLM "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
;Write some information about this install to the installation folder
FileOpen $0 "$INSTDIR\installer.ini" w
FileWrite $0 "type=@INSTALLER_TYPE@$\r$\n"
FileWrite $0 "campaign=$CampaignName$\r$\n"
FileWrite $0 "exepath=$EXEPATH$\r$\n"
FileClose $0
;Package the signed uninstaller produced by the inner loop ;Package the signed uninstaller produced by the inner loop
!ifndef INNER !ifndef INNER
; this packages the signed uninstaller ; this packages the signed uninstaller

View file

@ -5,8 +5,25 @@
{ "from": "TouchscreenVirtualPad.LX", "when": "!Application.CameraIndependent", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.TranslateX" }, { "from": "TouchscreenVirtualPad.LX", "when": "!Application.CameraIndependent", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.TranslateX" },
{ "from": "TouchscreenVirtualPad.RX", "when": "!Application.CameraIndependent", "filters": [ {"type": "deadZone", "min": 0.05} , "invert" ], "to": "Actions.Yaw" }, { "from": "TouchscreenVirtualPad.JUMP_BUTTON_PRESS", "when": "!Application.CameraIndependent", "to": "Actions.VERTICAL_UP" },
{ "from": "TouchscreenVirtualPad.RX", "when": "!Application.CameraIndependent",
"filters": [
{ "type": "deadZone", "min": 0.000 },
{ "type": "scale", "scale": 0.06 },
"invert"
],
"to": "Actions.Yaw"
},
{ "from": "TouchscreenVirtualPad.RY", "when": "!Application.CameraIndependent",
"filters": [
{ "type": "deadZone", "min": 0.000 },
{ "type": "scale", "scale": 0.06 },
"invert"
],
"to": "Actions.Pitch"
}
{ "from": "TouchscreenVirtualPad.RY", "when": "!Application.CameraIndependent", "filters": [ {"type": "deadZone", "min": 0.05}, "invert" ], "to": "Actions.Pitch" }
] ]
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -272,6 +272,8 @@ ModalWindow {
root.canceled(); root.canceled();
// FIXME we are leaking memory to avoid a crash // FIXME we are leaking memory to avoid a crash
// root.destroy(); // root.destroy();
root.disableFade = true
visible = false; visible = false;
} }
} }
@ -296,6 +298,8 @@ ModalWindow {
root.selected(root.result); root.selected(root.result);
// FIXME we are leaking memory to avoid a crash // FIXME we are leaking memory to avoid a crash
// root.destroy(); // root.destroy();
root.disableFade = true
visible = false; visible = false;
} }
} }

View file

@ -171,6 +171,8 @@ ModalWindow {
root.canceled(); root.canceled();
// FIXME we are leaking memory to avoid a crash // FIXME we are leaking memory to avoid a crash
// root.destroy(); // root.destroy();
root.disableFade = true
visible = false; visible = false;
} }
} }
@ -183,6 +185,8 @@ ModalWindow {
root.selected(root.result); root.selected(root.result);
// FIXME we are leaking memory to avoid a crash // FIXME we are leaking memory to avoid a crash
// root.destroy(); // root.destroy();
root.disableFade = true
visible = false; visible = false;
} }
} }

View file

@ -51,7 +51,24 @@ Rectangle {
onCertificateInfoResult: { onCertificateInfoResult: {
if (result.status !== 'success') { if (result.status !== 'success') {
console.log("Failed to get certificate info", result.message); console.log("Failed to get certificate info", result.data.message);
// We should still tell the user that static cert verification failed
if (root.certificateStatus !== 3) { // CERTIFICATE_STATUS_STATIC_VERIFICATION_FAILED
root.useGoldCert = false;
root.certTitleTextColor = hifi.colors.redHighlight;
root.certTextColor = hifi.colors.redHighlight;
root.infoTextColor = hifi.colors.redHighlight;
titleBarText.text = "Certificate Unavailable";
popText.text = "";
showInMarketplaceButton.visible = false;
root.certInfoReplaceMode = 0;
root.itemName = "";
root.itemEdition = "";
root.itemOwner = "";
root.dateOfPurchase = "";
root.itemCost = "";
errorText.text = "Information about this certificate is currently unavailable. Please try again later.";
}
} else { } else {
root.marketplaceUrl = result.data.marketplace_item_url; root.marketplaceUrl = result.data.marketplace_item_url;
root.isMyCert = result.isMyCert ? result.isMyCert : false; root.isMyCert = result.isMyCert ? result.isMyCert : false;

View file

@ -141,7 +141,10 @@ StackView {
bottom: parent.bottom bottom: parent.bottom
} }
onHostChanged: updateLocationTextTimer.restart(); onHostChanged: {
updateLocationTextTimer.restart();
DialogsManager.hideAddressBar();
}
Rectangle { Rectangle {
id: navBar id: navBar

View file

@ -39,7 +39,7 @@ FocusScope {
// If someone directly set the visibility to false // If someone directly set the visibility to false
// toggle it back on and use the targetVisible flag to transition // toggle it back on and use the targetVisible flag to transition
// via fading. // via fading.
if ((!visible && fadeTargetProperty != 0.0) || (visible && fadeTargetProperty == 0.0)) { if (!disableFade && ((!visible && fadeTargetProperty != 0.0) || (visible && fadeTargetProperty == 0.0))) {
var target = visible; var target = visible;
visible = !visible; visible = !visible;
fadeTargetProperty = target ? 1.0 : 0.0; fadeTargetProperty = target ? 1.0 : 0.0;

View file

@ -35,12 +35,19 @@ QJsonObject Ledger::apiResponse(const QString& label, QNetworkReply& reply) {
QJsonObject Ledger::failResponse(const QString& label, QNetworkReply& reply) { QJsonObject Ledger::failResponse(const QString& label, QNetworkReply& reply) {
QString response = reply.readAll(); QString response = reply.readAll();
qWarning(commerce) << "FAILED" << label << response; qWarning(commerce) << "FAILED" << label << response;
QJsonObject result
{ // tempResult will be NULL if the response isn't valid JSON.
{ "status", "fail" }, QJsonDocument tempResult = QJsonDocument::fromJson(response.toLocal8Bit());
{ "message", response } if (tempResult.isNull()) {
}; QJsonObject result
return result; {
{ "status", "fail" },
{ "message", response }
};
return result;
} else {
return tempResult.object();
}
} }
#define ApiHandler(NAME) void Ledger::NAME##Success(QNetworkReply& reply) { emit NAME##Result(apiResponse(#NAME, reply)); } #define ApiHandler(NAME) void Ledger::NAME##Success(QNetworkReply& reply) { emit NAME##Result(apiResponse(#NAME, reply)); }
#define FailHandler(NAME) void Ledger::NAME##Failure(QNetworkReply& reply) { emit NAME##Result(failResponse(#NAME, reply)); } #define FailHandler(NAME) void Ledger::NAME##Failure(QNetworkReply& reply) { emit NAME##Result(failResponse(#NAME, reply)); }
@ -337,7 +344,9 @@ void Ledger::certificateInfoSuccess(QNetworkReply& reply) {
qInfo(commerce) << "certificateInfo" << "response" << QJsonDocument(replyObject).toJson(QJsonDocument::Compact); qInfo(commerce) << "certificateInfo" << "response" << QJsonDocument(replyObject).toJson(QJsonDocument::Compact);
emit certificateInfoResult(replyObject); emit certificateInfoResult(replyObject);
} }
void Ledger::certificateInfoFailure(QNetworkReply& reply) { failResponse("certificateInfo", reply); } void Ledger::certificateInfoFailure(QNetworkReply& reply) {
emit certificateInfoResult(failResponse("certificateInfo", reply));
}
void Ledger::certificateInfo(const QString& certificateId) { void Ledger::certificateInfo(const QString& certificateId) {
QString endpoint = "proof_of_purchase_status/transfer"; QString endpoint = "proof_of_purchase_status/transfer";
QJsonObject request; QJsonObject request;

View file

@ -15,6 +15,11 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
/**jsdoc
* The Settings API provides a facility to store and retrieve values that persist between Interface runs.
* @namespace Settings
*/
class SettingsScriptingInterface : public QObject { class SettingsScriptingInterface : public QObject {
Q_OBJECT Q_OBJECT
SettingsScriptingInterface() { }; SettingsScriptingInterface() { };
@ -22,8 +27,37 @@ public:
static SettingsScriptingInterface* getInstance(); static SettingsScriptingInterface* getInstance();
public slots: public slots:
/**jsdoc
* Retrieve the value from a named setting.
* @function Settings.getValue
* @param {string} key - The name of the setting.
* @param {string|number|boolean|object} [defaultValue=""] - The value to return if the setting doesn't exist.
* @returns {string|number|boolean|object} The value stored in the named setting if it exists, otherwise the
* <code>defaultValue</code>.
* @example <caption>Retrieve non-existent setting values.</caption>
* var value1 = Settings.getValue("Script Example/Nonexistent Key");
* print("Value: " + (typeof value1) + " " + JSON.stringify(value1)); // string ""
*
* var value2 = Settings.getValue("Script Example/Nonexistent Key", true);
* print("Value: " + (typeof value2) + " " + JSON.stringify(value2)); // boolean true
*/
QVariant getValue(const QString& setting); QVariant getValue(const QString& setting);
QVariant getValue(const QString& setting, const QVariant& defaultValue); QVariant getValue(const QString& setting, const QVariant& defaultValue);
/**jsdoc
* Store a value in a named setting. If the setting already exists its value is overwritten, otherwise a new setting is
* created. If the value is set to <code>null</code> or <code>undefined</code>, the setting is deleted.
* @function Settings.setValue
* @param {string} key - The name of the setting. Be sure to use a unique name if creating a new setting.
* @param {string|number|boolean|object|undefined} value - The value to store in the setting. If <code>null</code> or
* <code>undefined</code> is specified, the setting is deleted.
* @example <caption>Store and retrieve an object value.</caption>
* Settings.setValue("Script Example/My Key", { x: 0, y: 10, z: 0 });
*
* var value = Settings.getValue("Script Example/My Key");
* print("Value: " + (typeof value) + " " + JSON.stringify(value)); // object {"x":0,"y":10,"z":0}
*/
void setValue(const QString& setting, const QVariant& value); void setValue(const QString& setting, const QVariant& value);
}; };

View file

@ -51,7 +51,7 @@ WindowScriptingInterface::WindowScriptingInterface() {
} }
}); });
connect(qApp->getWindow(), &MainWindow::windowGeometryChanged, this, &WindowScriptingInterface::geometryChanged); connect(qApp->getWindow(), &MainWindow::windowGeometryChanged, this, &WindowScriptingInterface::onWindowGeometryChanged);
} }
WindowScriptingInterface::~WindowScriptingInterface() { WindowScriptingInterface::~WindowScriptingInterface() {
@ -390,11 +390,22 @@ glm::vec2 WindowScriptingInterface::getDeviceSize() const {
} }
int WindowScriptingInterface::getX() { int WindowScriptingInterface::getX() {
return qApp->getWindow()->x(); return qApp->getWindow()->geometry().x();
} }
int WindowScriptingInterface::getY() { int WindowScriptingInterface::getY() {
return qApp->getWindow()->y(); auto menu = qApp->getPrimaryMenu();
int menuHeight = menu ? menu->geometry().height() : 0;
return qApp->getWindow()->geometry().y() + menuHeight;
}
void WindowScriptingInterface::onWindowGeometryChanged(const QRect& windowGeometry) {
auto geometry = windowGeometry;
auto menu = qApp->getPrimaryMenu();
if (menu) {
geometry.setY(geometry.y() + menu->geometry().height());
}
emit geometryChanged(geometry);
} }
void WindowScriptingInterface::copyToClipboard(const QString& text) { void WindowScriptingInterface::copyToClipboard(const QString& text) {

View file

@ -33,8 +33,10 @@
* @property {number} innerHeight - The height of the drawable area of the Interface window (i.e., without borders or other * @property {number} innerHeight - The height of the drawable area of the Interface window (i.e., without borders or other
* chrome), in pixels. <em>Read-only.</em> * chrome), in pixels. <em>Read-only.</em>
* @property {object} location - Provides facilities for working with your current metaverse location. See {@link location}. * @property {object} location - Provides facilities for working with your current metaverse location. See {@link location}.
* @property {number} x - The x coordinate of the top left corner of the Interface window on the display. <em>Read-only.</em> * @property {number} x - The x display coordinate of the top left corner of the drawable area of the Interface window.
* @property {number} y - The y coordinate of the top left corner of the Interface window on the display. <em>Read-only.</em> * <em>Read-only.</em>
* @property {number} y - The y display coordinate of the top left corner of the drawable area of the Interface window.
* <em>Read-only.</em>
*/ */
class WindowScriptingInterface : public QObject, public Dependency { class WindowScriptingInterface : public QObject, public Dependency {
@ -522,6 +524,7 @@ public slots:
void closeMessageBox(int id); void closeMessageBox(int id);
private slots: private slots:
void onWindowGeometryChanged(const QRect& geometry);
void onMessageBoxSelected(int button); void onMessageBoxSelected(int button);
void disconnectedFromDomain(); void disconnectedFromDomain();

View file

@ -20,7 +20,8 @@
#include <AbstractViewStateInterface.h> #include <AbstractViewStateInterface.h>
const int FIXED_FONT_POINT_SIZE = 40; const int FIXED_FONT_POINT_SIZE = 40;
const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 80.0f; // this is a ratio determined through experimentation const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 92.0f; // Determined through experimentation to fit font to line
// height.
const float LINE_SCALE_RATIO = 1.2f; const float LINE_SCALE_RATIO = 1.2f;
QString const Text3DOverlay::TYPE = "text3d"; QString const Text3DOverlay::TYPE = "text3d";

View file

@ -128,6 +128,7 @@ namespace controller {
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"), makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"), makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"),
makeButtonPair(Action::TOGGLE_OVERLAY, "ToggleOverlay"), makeButtonPair(Action::TOGGLE_OVERLAY, "ToggleOverlay"),
makeButtonPair(Action::SPRINT, "Sprint"),
makeAxisPair(Action::RETICLE_CLICK, "ReticleClick"), makeAxisPair(Action::RETICLE_CLICK, "ReticleClick"),
makeAxisPair(Action::RETICLE_X, "ReticleX"), makeAxisPair(Action::RETICLE_X, "ReticleX"),

View file

@ -25,11 +25,11 @@ static const QString FULLSCREEN = "Fullscreen";
void Basic2DWindowOpenGLDisplayPlugin::customizeContext() { void Basic2DWindowOpenGLDisplayPlugin::customizeContext() {
#if defined(Q_OS_ANDROID) #if defined(Q_OS_ANDROID)
qreal dpi = getFullscreenTarget()->physicalDotsPerInch();
_virtualPadPixelSize = dpi * VirtualPad::Manager::BASE_DIAMETER_PIXELS / VirtualPad::Manager::DPI;
auto iconPath = PathUtils::resourcesPath() + "images/analog_stick.png"; auto iconPath = PathUtils::resourcesPath() + "images/analog_stick.png";
auto image = QImage(iconPath); auto image = QImage(iconPath);
qreal dpi = getFullscreenTarget()->physicalDotsPerInch();
_virtualPadPixelSize = dpi * VirtualPad::Manager::PIXEL_SIZE / VirtualPad::Manager::DPI;
if (image.format() != QImage::Format_ARGB32) { if (image.format() != QImage::Format_ARGB32) {
image = image.convertToFormat(QImage::Format_ARGB32); image = image.convertToFormat(QImage::Format_ARGB32);
} }
@ -69,6 +69,29 @@ void Basic2DWindowOpenGLDisplayPlugin::customizeContext() {
_virtualPadStickBaseTexture->assignStoredMip(0, image.byteCount(), image.constBits()); _virtualPadStickBaseTexture->assignStoredMip(0, image.byteCount(), image.constBits());
_virtualPadStickBaseTexture->setAutoGenerateMips(true); _virtualPadStickBaseTexture->setAutoGenerateMips(true);
} }
_virtualPadJumpBtnPixelSize = dpi * VirtualPad::Manager::JUMP_BTN_FULL_PIXELS / VirtualPad::Manager::DPI;
iconPath = PathUtils::resourcesPath() + "images/fly.png";
image = QImage(iconPath);
if (image.format() != QImage::Format_ARGB32) {
image = image.convertToFormat(QImage::Format_ARGB32);
}
if ((image.width() > 0) && (image.height() > 0)) {
image = image.scaled(_virtualPadJumpBtnPixelSize, _virtualPadJumpBtnPixelSize, Qt::KeepAspectRatio);
image = image.mirrored();
_virtualPadJumpBtnTexture = gpu::Texture::createStrict(
gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA),
image.width(), image.height(),
gpu::Texture::MAX_NUM_MIPS,
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR));
_virtualPadJumpBtnTexture->setSource("virtualPad jump");
auto usage = gpu::Texture::Usage::Builder().withColor().withAlpha();
_virtualPadJumpBtnTexture->setUsage(usage.build());
_virtualPadJumpBtnTexture->setStoredMipFormat(gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA));
_virtualPadJumpBtnTexture->assignStoredMip(0, image.byteCount(), image.constBits());
_virtualPadJumpBtnTexture->setAutoGenerateMips(true);
}
#endif #endif
Parent::customizeContext(); Parent::customizeContext();
} }
@ -124,6 +147,20 @@ void Basic2DWindowOpenGLDisplayPlugin::compositeExtra() {
batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize())); batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize()));
batch.draw(gpu::TRIANGLE_STRIP, 4); batch.draw(gpu::TRIANGLE_STRIP, 4);
}); });
// render stick head
auto jumpTransform = DependencyManager::get<CompositorHelper>()->getPoint2DTransform(virtualPadManager.getJumpButtonPosition(),
_virtualPadJumpBtnPixelSize, _virtualPadJumpBtnPixelSize);
render([&](gpu::Batch& batch) {
batch.enableStereo(false);
batch.setProjectionTransform(mat4());
batch.setPipeline(_cursorPipeline);
batch.setResourceTexture(0, _virtualPadJumpBtnTexture);
batch.resetViewTransform();
batch.setModelTransform(jumpTransform);
batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize()));
batch.draw(gpu::TRIANGLE_STRIP, 4);
});
} }
#endif #endif
Parent::compositeExtra(); Parent::compositeExtra();

View file

@ -46,5 +46,8 @@ private:
gpu::TexturePointer _virtualPadStickTexture; gpu::TexturePointer _virtualPadStickTexture;
gpu::TexturePointer _virtualPadStickBaseTexture; gpu::TexturePointer _virtualPadStickBaseTexture;
qreal _virtualPadPixelSize; qreal _virtualPadPixelSize;
gpu::TexturePointer _virtualPadJumpBtnTexture;
qreal _virtualPadJumpBtnPixelSize;
#endif #endif
}; };

View file

@ -135,10 +135,8 @@ void EntityRenderer::makeStatusGetters(const EntityItemPointer& entity, Item::St
template <typename T> template <typename T>
std::shared_ptr<T> make_renderer(const EntityItemPointer& entity) { std::shared_ptr<T> make_renderer(const EntityItemPointer& entity) {
T* rawResult = new T(entity);
// We want to use deleteLater so that renderer destruction gets pushed to the main thread // We want to use deleteLater so that renderer destruction gets pushed to the main thread
return std::shared_ptr<T>(rawResult, std::bind(&QObject::deleteLater, rawResult)); return std::shared_ptr<T>(new T(entity), [](T* ptr) { ptr->deleteLater(); });
} }
EntityRenderer::EntityRenderer(const EntityItemPointer& entity) : _entity(entity) { EntityRenderer::EntityRenderer(const EntityItemPointer& entity) : _entity(entity) {

View file

@ -34,7 +34,7 @@ static const QString WEB_ENTITY_QML = "controls/WebEntityView.qml";
const float METERS_TO_INCHES = 39.3701f; const float METERS_TO_INCHES = 39.3701f;
static uint32_t _currentWebCount{ 0 }; static uint32_t _currentWebCount{ 0 };
// Don't allow more than 100 concurrent web views // Don't allow more than 20 concurrent web views
static const uint32_t MAX_CONCURRENT_WEB_VIEWS = 20; static const uint32_t MAX_CONCURRENT_WEB_VIEWS = 20;
// If a web-view hasn't been rendered for 30 seconds, de-allocate the framebuffer // If a web-view hasn't been rendered for 30 seconds, de-allocate the framebuffer
static uint64_t MAX_NO_RENDER_INTERVAL = 30 * USECS_PER_SECOND; static uint64_t MAX_NO_RENDER_INTERVAL = 30 * USECS_PER_SECOND;
@ -88,8 +88,14 @@ bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointe
return true; return true;
} }
if (uvec2(getWindowSize(entity)) != toGlm(_webSurface->size())) { {
return true; QSharedPointer<OffscreenQmlSurface> webSurface;
withReadLock([&] {
webSurface = _webSurface;
});
if (webSurface && uvec2(getWindowSize(entity)) != toGlm(webSurface->size())) {
return true;
}
} }
if (_lastSourceUrl != entity->getSourceUrl()) { if (_lastSourceUrl != entity->getSourceUrl()) {
@ -108,9 +114,15 @@ bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointe
} }
bool WebEntityRenderer::needsRenderUpdate() const { bool WebEntityRenderer::needsRenderUpdate() const {
if (!_webSurface) { {
// If we have rendered recently, and there is no web surface, we're going to create one QSharedPointer<OffscreenQmlSurface> webSurface;
return true; withReadLock([&] {
webSurface = _webSurface;
});
if (!webSurface) {
// If we have rendered recently, and there is no web surface, we're going to create one
return true;
}
} }
return Parent::needsRenderUpdate(); return Parent::needsRenderUpdate();

View file

@ -502,6 +502,12 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
DEBUG_PROPERTY_IF_CHANGED(debug, properties, CertificateID, certificateID, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, CertificateID, certificateID, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, StaticCertificateVersion, staticCertificateVersion, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, StaticCertificateVersion, staticCertificateVersion, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, LocalPosition, localPosition, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, LocalRotation, localRotation, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, LocalVelocity, localVelocity, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, LocalAngularVelocity, localAngularVelocity, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, LocalDimensions, localDimensions, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, HazeMode, hazeMode, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, HazeMode, hazeMode, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, KeyLightMode, keyLightMode, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, KeyLightMode, keyLightMode, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, AmbientLightMode, ambientLightMode, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, AmbientLightMode, ambientLightMode, "");

View file

@ -477,6 +477,27 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
} }
} }
}); });
} else {
// Sometimes ESS don't have the entity they are trying to edit in their local tree. In this case,
// convertPropertiesFromScriptSemantics doesn't get called and local* edits will get dropped.
// This is because, on the script side, "position" is in world frame, but in the network
// protocol and in the internal data-structures, "position" is "relative to parent".
// Compensate here. The local* versions will get ignored during the edit-packet encoding.
if (properties.localPositionChanged()) {
properties.setPosition(properties.getLocalPosition());
}
if (properties.localRotationChanged()) {
properties.setRotation(properties.getLocalRotation());
}
if (properties.localVelocityChanged()) {
properties.setVelocity(properties.getLocalVelocity());
}
if (properties.localAngularVelocityChanged()) {
properties.setAngularVelocity(properties.getLocalAngularVelocity());
}
if (properties.localDimensionsChanged()) {
properties.setDimensions(properties.getLocalDimensions());
}
} }
}); });
if (!entityFound) { if (!entityFound) {

View file

@ -41,6 +41,7 @@ bool TouchscreenVirtualPadDevice::isSupported() const {
void TouchscreenVirtualPadDevice::init() { void TouchscreenVirtualPadDevice::init() {
_fixedPosition = true; // This should be config _fixedPosition = true; // This should be config
_viewTouchUpdateCount = 0;
QScreen* eventScreen = qApp->primaryScreen(); QScreen* eventScreen = qApp->primaryScreen();
if (_screenDPIProvided != eventScreen->physicalDotsPerInch()) { if (_screenDPIProvided != eventScreen->physicalDotsPerInch()) {
@ -50,12 +51,14 @@ void TouchscreenVirtualPadDevice::init() {
_screenDPIProvided = eventScreen->physicalDotsPerInch(); _screenDPIProvided = eventScreen->physicalDotsPerInch();
_screenDPI = eventScreen->physicalDotsPerInch(); _screenDPI = eventScreen->physicalDotsPerInch();
_fixedRadius = _screenDPI * 0.5f * VirtualPad::Manager::PIXEL_SIZE / VirtualPad::Manager::DPI; _fixedRadius = _screenDPI * 0.5f * VirtualPad::Manager::BASE_DIAMETER_PIXELS / VirtualPad::Manager::DPI;
_fixedRadiusForCalc = _fixedRadius - _screenDPI * VirtualPad::Manager::STICK_RADIUS / VirtualPad::Manager::DPI; _fixedRadiusForCalc = _fixedRadius - _screenDPI * VirtualPad::Manager::STICK_RADIUS_PIXELS / VirtualPad::Manager::DPI;
_jumpButtonRadius = _screenDPI * VirtualPad::Manager::JUMP_BTN_TRIMMED_RADIUS_PIXELS / VirtualPad::Manager::DPI;
} }
auto& virtualPadManager = VirtualPad::Manager::instance(); auto& virtualPadManager = VirtualPad::Manager::instance();
setupFixedCenter(virtualPadManager, true); setupControlsPositions(virtualPadManager, true);
if (_fixedPosition) { if (_fixedPosition) {
virtualPadManager.getLeftVirtualPad()->setShown(virtualPadManager.isEnabled() && !virtualPadManager.isHidden()); // Show whenever it's enabled virtualPadManager.getLeftVirtualPad()->setShown(virtualPadManager.isEnabled() && !virtualPadManager.isHidden()); // Show whenever it's enabled
@ -64,19 +67,23 @@ void TouchscreenVirtualPadDevice::init() {
KeyboardMouseDevice::enableTouch(false); // Touch for view controls is managed by this plugin KeyboardMouseDevice::enableTouch(false); // Touch for view controls is managed by this plugin
} }
void TouchscreenVirtualPadDevice::setupFixedCenter(VirtualPad::Manager& virtualPadManager, bool force) { void TouchscreenVirtualPadDevice::setupControlsPositions(VirtualPad::Manager& virtualPadManager, bool force) {
if (!_fixedPosition) return;
//auto& virtualPadManager = VirtualPad::Manager::instance();
if (_extraBottomMargin == virtualPadManager.extraBottomMargin() && !force) return; // Our only criteria to decide a center change is the bottom margin if (_extraBottomMargin == virtualPadManager.extraBottomMargin() && !force) return; // Our only criteria to decide a center change is the bottom margin
_extraBottomMargin = virtualPadManager.extraBottomMargin();
float margin = _screenDPI * VirtualPad::Manager::BASE_MARGIN / VirtualPad::Manager::DPI;
QScreen* eventScreen = qApp->primaryScreen(); // do not call every time QScreen* eventScreen = qApp->primaryScreen(); // do not call every time
_fixedCenterPosition = glm::vec2( _fixedRadius + margin, eventScreen->size().height() - margin - _fixedRadius - _extraBottomMargin); _extraBottomMargin = virtualPadManager.extraBottomMargin();
// Movement stick
float margin = _screenDPI * VirtualPad::Manager::BASE_MARGIN_PIXELS / VirtualPad::Manager::DPI;
_fixedCenterPosition = glm::vec2( _fixedRadius + margin, eventScreen->size().height() - margin - _fixedRadius - _extraBottomMargin);
_moveRefTouchPoint = _fixedCenterPosition; _moveRefTouchPoint = _fixedCenterPosition;
virtualPadManager.getLeftVirtualPad()->setFirstTouch(_moveRefTouchPoint); virtualPadManager.getLeftVirtualPad()->setFirstTouch(_moveRefTouchPoint);
// Jump button
float leftMargin = _screenDPI * VirtualPad::Manager::JUMP_BTN_LEFT_MARGIN_PIXELS / VirtualPad::Manager::DPI;
float bottomMargin = _screenDPI * VirtualPad::Manager::JUMP_BTN_BOTTOM_MARGIN_PIXELS/ VirtualPad::Manager::DPI;
_jumpButtonPosition = glm::vec2( _jumpButtonRadius + leftMargin, eventScreen->size().height() - bottomMargin - _jumpButtonRadius - _extraBottomMargin);
virtualPadManager.setJumpButtonPosition(_jumpButtonPosition);
} }
float clip(float n, float lower, float upper) { float clip(float n, float lower, float upper) {
@ -131,22 +138,15 @@ void TouchscreenVirtualPadDevice::processInputDeviceForMove(VirtualPad::Manager&
} }
void TouchscreenVirtualPadDevice::processInputDeviceForView() { void TouchscreenVirtualPadDevice::processInputDeviceForView() {
float rightDistanceScaleX, rightDistanceScaleY; // We use average across how many times we've got touchUpdate events.
rightDistanceScaleX = (_viewCurrentTouchPoint.x - _viewRefTouchPoint.x) / _screenDPIScale.x; // Using the average instead of the full deltaX and deltaY, makes deltaTime in MyAvatar dont't accelerate rotation when there is a low touchUpdate rate (heavier domains).
rightDistanceScaleY = (_viewCurrentTouchPoint.y - _viewRefTouchPoint.y) / _screenDPIScale.y; // (Because it multiplies this input value by deltaTime (with a coefficient)).
_inputDevice->_axisStateMap[controller::RX] = _viewTouchUpdateCount == 0 ? 0 : (_viewCurrentTouchPoint.x - _viewRefTouchPoint.x) / _viewTouchUpdateCount;
rightDistanceScaleX = clip(rightDistanceScaleX, -_viewStickRadiusInches, _viewStickRadiusInches); _inputDevice->_axisStateMap[controller::RY] = _viewTouchUpdateCount == 0 ? 0 : (_viewCurrentTouchPoint.y - _viewRefTouchPoint.y) / _viewTouchUpdateCount;
rightDistanceScaleY = clip(rightDistanceScaleY, -_viewStickRadiusInches, _viewStickRadiusInches);
// NOW BETWEEN -1 1
rightDistanceScaleX /= _viewStickRadiusInches;
rightDistanceScaleY /= _viewStickRadiusInches;
_inputDevice->_axisStateMap[controller::RX] = rightDistanceScaleX;
_inputDevice->_axisStateMap[controller::RY] = rightDistanceScaleY;
// after use, save last touch point as ref // after use, save last touch point as ref
_viewRefTouchPoint = _viewCurrentTouchPoint; _viewRefTouchPoint = _viewCurrentTouchPoint;
_viewTouchUpdateCount = 0;
} }
void TouchscreenVirtualPadDevice::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { void TouchscreenVirtualPadDevice::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
@ -156,7 +156,7 @@ void TouchscreenVirtualPadDevice::pluginUpdate(float deltaTime, const controller
}); });
auto& virtualPadManager = VirtualPad::Manager::instance(); auto& virtualPadManager = VirtualPad::Manager::instance();
setupFixedCenter(virtualPadManager); setupControlsPositions(virtualPadManager);
if (_moveHasValidTouch) { if (_moveHasValidTouch) {
processInputDeviceForMove(virtualPadManager); processInputDeviceForMove(virtualPadManager);
@ -221,6 +221,7 @@ void TouchscreenVirtualPadDevice::touchEndEvent(const QTouchEvent* event) {
if (!virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) { if (!virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) {
moveTouchEnd(); moveTouchEnd();
viewTouchEnd(); viewTouchEnd();
jumpTouchEnd();
return; return;
} }
// touch end here is a big reset -> resets both pads // touch end here is a big reset -> resets both pads
@ -229,7 +230,9 @@ void TouchscreenVirtualPadDevice::touchEndEvent(const QTouchEvent* event) {
debugPoints(event, " END ----------------"); debugPoints(event, " END ----------------");
moveTouchEnd(); moveTouchEnd();
viewTouchEnd(); viewTouchEnd();
jumpTouchEnd();
_inputDevice->_axisStateMap.clear(); _inputDevice->_axisStateMap.clear();
_inputDevice->_buttonPressedMap.clear();
} }
void TouchscreenVirtualPadDevice::processUnusedTouches(std::map<int, TouchType> unusedTouchesInEvent) { void TouchscreenVirtualPadDevice::processUnusedTouches(std::map<int, TouchType> unusedTouchesInEvent) {
@ -263,9 +266,11 @@ void TouchscreenVirtualPadDevice::touchUpdateEvent(const QTouchEvent* event) {
const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints(); const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();
bool moveTouchFound = false; bool moveTouchFound = false;
bool viewTouchFound = false; bool viewTouchFound = false;
bool jumpTouchFound = false;
int idxMoveStartingPointCandidate = -1; int idxMoveStartingPointCandidate = -1;
int idxViewStartingPointCandidate = -1; int idxViewStartingPointCandidate = -1;
int idxJumpStartingPointCandidate = -1;
glm::vec2 thisPoint; glm::vec2 thisPoint;
int thisPointId; int thisPointId;
@ -290,6 +295,13 @@ void TouchscreenVirtualPadDevice::touchUpdateEvent(const QTouchEvent* event) {
continue; continue;
} }
if (!jumpTouchFound && _jumpHasValidTouch && _jumpCurrentTouchId == thisPointId) {
// valid if it's an ongoing touch
jumpTouchFound = true;
jumpTouchUpdate(thisPoint);
continue;
}
if (!moveTouchFound && idxMoveStartingPointCandidate == -1 && moveTouchBeginIsValid(thisPoint) && if (!moveTouchFound && idxMoveStartingPointCandidate == -1 && moveTouchBeginIsValid(thisPoint) &&
(!_unusedTouches.count(thisPointId) || _unusedTouches[thisPointId] == MOVE )) { (!_unusedTouches.count(thisPointId) || _unusedTouches[thisPointId] == MOVE )) {
idxMoveStartingPointCandidate = i; idxMoveStartingPointCandidate = i;
@ -302,8 +314,16 @@ void TouchscreenVirtualPadDevice::touchUpdateEvent(const QTouchEvent* event) {
continue; continue;
} }
if (!jumpTouchFound && idxJumpStartingPointCandidate == -1 && jumpTouchBeginIsValid(thisPoint) &&
(!_unusedTouches.count(thisPointId) || _unusedTouches[thisPointId] == JUMP )) {
idxJumpStartingPointCandidate = i;
continue;
}
if (moveTouchBeginIsValid(thisPoint)) { if (moveTouchBeginIsValid(thisPoint)) {
unusedTouchesInEvent[thisPointId] = MOVE; unusedTouchesInEvent[thisPointId] = MOVE;
} else if (jumpTouchBeginIsValid(thisPoint)) {
unusedTouchesInEvent[thisPointId] = JUMP;
} else if (viewTouchBeginIsValid(thisPoint)) { } else if (viewTouchBeginIsValid(thisPoint)) {
unusedTouchesInEvent[thisPointId] = VIEW; unusedTouchesInEvent[thisPointId] = VIEW;
} }
@ -330,23 +350,58 @@ void TouchscreenVirtualPadDevice::touchUpdateEvent(const QTouchEvent* event) {
viewTouchEnd(); viewTouchEnd();
} }
} }
if (!jumpTouchFound) {
if (idxJumpStartingPointCandidate != -1) {
_jumpCurrentTouchId = tPoints[idxJumpStartingPointCandidate].id();
_unusedTouches.erase(_jumpCurrentTouchId);
jumpTouchBegin(thisPoint);
} else {
if (_jumpHasValidTouch) {
jumpTouchEnd();
}
}
}
} }
bool TouchscreenVirtualPadDevice::viewTouchBeginIsValid(glm::vec2 touchPoint) { bool TouchscreenVirtualPadDevice::viewTouchBeginIsValid(glm::vec2 touchPoint) {
return !moveTouchBeginIsValid(touchPoint); return !moveTouchBeginIsValid(touchPoint) && !jumpTouchBeginIsValid(touchPoint);
} }
bool TouchscreenVirtualPadDevice::moveTouchBeginIsValid(glm::vec2 touchPoint) { bool TouchscreenVirtualPadDevice::moveTouchBeginIsValid(glm::vec2 touchPoint) {
if (_fixedPosition) { if (_fixedPosition) {
// inside circle // inside circle
return pow(touchPoint.x - _fixedCenterPosition.x,2.0) + pow(touchPoint.y - _fixedCenterPosition.y, 2.0) < pow(_fixedRadius, 2.0); return glm::distance2(touchPoint, _fixedCenterPosition) < _fixedRadius * _fixedRadius;
} else { } else {
// left side // left side
return touchPoint.x < _screenWidthCenter; return touchPoint.x < _screenWidthCenter;
} }
} }
bool TouchscreenVirtualPadDevice::jumpTouchBeginIsValid(glm::vec2 touchPoint) {
// position of button and boundaries
return glm::distance2(touchPoint, _jumpButtonPosition) < _jumpButtonRadius * _jumpButtonRadius;
}
void TouchscreenVirtualPadDevice::jumpTouchBegin(glm::vec2 touchPoint) {
auto& virtualPadManager = VirtualPad::Manager::instance();
if (virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) {
_jumpHasValidTouch = true;
_inputDevice->_buttonPressedMap.insert(TouchButtonChannel::JUMP_BUTTON_PRESS);
}
}
void TouchscreenVirtualPadDevice::jumpTouchUpdate(glm::vec2 touchPoint) {}
void TouchscreenVirtualPadDevice::jumpTouchEnd() {
if (_jumpHasValidTouch) {
_jumpHasValidTouch = false;
_inputDevice->_buttonPressedMap.erase(TouchButtonChannel::JUMP_BUTTON_PRESS);
}
}
void TouchscreenVirtualPadDevice::moveTouchBegin(glm::vec2 touchPoint) { void TouchscreenVirtualPadDevice::moveTouchBegin(glm::vec2 touchPoint) {
auto& virtualPadManager = VirtualPad::Manager::instance(); auto& virtualPadManager = VirtualPad::Manager::instance();
if (virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) { if (virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) {
@ -376,12 +431,14 @@ void TouchscreenVirtualPadDevice::viewTouchBegin(glm::vec2 touchPoint) {
if (virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) { if (virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) {
_viewRefTouchPoint = touchPoint; _viewRefTouchPoint = touchPoint;
_viewCurrentTouchPoint = touchPoint; _viewCurrentTouchPoint = touchPoint;
_viewTouchUpdateCount++;
_viewHasValidTouch = true; _viewHasValidTouch = true;
} }
} }
void TouchscreenVirtualPadDevice::viewTouchUpdate(glm::vec2 touchPoint) { void TouchscreenVirtualPadDevice::viewTouchUpdate(glm::vec2 touchPoint) {
_viewCurrentTouchPoint = touchPoint; _viewCurrentTouchPoint = touchPoint;
_viewTouchUpdateCount++;
} }
void TouchscreenVirtualPadDevice::viewTouchEnd() { void TouchscreenVirtualPadDevice::viewTouchEnd() {
@ -403,13 +460,22 @@ void TouchscreenVirtualPadDevice::touchGestureEvent(const QGestureEvent* event)
} }
} }
controller::Input TouchscreenVirtualPadDevice::InputDevice::makeInput(TouchscreenVirtualPadDevice::TouchAxisChannel axis) const {
return controller::Input(_deviceID, axis, controller::ChannelType::AXIS);
}
controller::Input TouchscreenVirtualPadDevice::InputDevice::makeInput(TouchscreenVirtualPadDevice::TouchButtonChannel button) const {
return controller::Input(_deviceID, button, controller::ChannelType::BUTTON);
}
controller::Input::NamedVector TouchscreenVirtualPadDevice::InputDevice::getAvailableInputs() const { controller::Input::NamedVector TouchscreenVirtualPadDevice::InputDevice::getAvailableInputs() const {
using namespace controller; using namespace controller;
QVector<Input::NamedPair> availableInputs{ QVector<Input::NamedPair> availableInputs{
makePair(LX, "LX"), Input::NamedPair(makeInput(TouchAxisChannel::LX), "LX"),
makePair(LY, "LY"), Input::NamedPair(makeInput(TouchAxisChannel::LY), "LY"),
makePair(RX, "RX"), Input::NamedPair(makeInput(TouchAxisChannel::RX), "RX"),
makePair(RY, "RY") Input::NamedPair(makeInput(TouchAxisChannel::RY), "RY"),
Input::NamedPair(makeInput(TouchButtonChannel::JUMP_BUTTON_PRESS), "JUMP_BUTTON_PRESS")
}; };
return availableInputs; return availableInputs;
} }

View file

@ -41,6 +41,18 @@ public:
static const char* NAME; static const char* NAME;
int _viewTouchUpdateCount;
enum TouchAxisChannel {
LX,
LY,
RX,
RY
};
enum TouchButtonChannel {
JUMP_BUTTON_PRESS
};
protected: protected:
class InputDevice : public controller::InputDevice { class InputDevice : public controller::InputDevice {
@ -54,6 +66,9 @@ protected:
virtual void focusOutEvent() override; virtual void focusOutEvent() override;
friend class TouchscreenVirtualPadDevice; friend class TouchscreenVirtualPadDevice;
controller::Input makeInput(TouchAxisChannel axis) const;
controller::Input makeInput(TouchButtonChannel button) const;
}; };
public: public:
@ -63,7 +78,8 @@ protected:
enum TouchType { enum TouchType {
MOVE = 1, MOVE = 1,
VIEW VIEW,
JUMP
}; };
float _lastPinchScale; float _lastPinchScale;
@ -82,6 +98,9 @@ protected:
glm::vec2 _viewCurrentTouchPoint; glm::vec2 _viewCurrentTouchPoint;
int _viewCurrentTouchId; int _viewCurrentTouchId;
bool _jumpHasValidTouch;
int _jumpCurrentTouchId;
std::map<int, TouchType> _unusedTouches; std::map<int, TouchType> _unusedTouches;
int _touchPointCount; int _touchPointCount;
@ -94,7 +113,8 @@ protected:
float _fixedRadiusForCalc; float _fixedRadiusForCalc;
int _extraBottomMargin {0}; int _extraBottomMargin {0};
float _viewStickRadiusInches {0.1333f}; // agreed default glm::vec2 _jumpButtonPosition;
float _jumpButtonRadius;
void moveTouchBegin(glm::vec2 touchPoint); void moveTouchBegin(glm::vec2 touchPoint);
void moveTouchUpdate(glm::vec2 touchPoint); void moveTouchUpdate(glm::vec2 touchPoint);
@ -106,7 +126,12 @@ protected:
void viewTouchEnd(); void viewTouchEnd();
bool viewTouchBeginIsValid(glm::vec2 touchPoint); bool viewTouchBeginIsValid(glm::vec2 touchPoint);
void setupFixedCenter(VirtualPad::Manager& virtualPadManager, bool force = false); void jumpTouchBegin(glm::vec2 touchPoint);
void jumpTouchUpdate(glm::vec2 touchPoint);
void jumpTouchEnd();
bool jumpTouchBeginIsValid(glm::vec2 touchPoint);
void setupControlsPositions(VirtualPad::Manager& virtualPadManager, bool force = false);
void processInputDeviceForMove(VirtualPad::Manager& virtualPadManager); void processInputDeviceForMove(VirtualPad::Manager& virtualPadManager);
glm::vec2 clippedPointInCircle(float radius, glm::vec2 origin, glm::vec2 touchPoint); glm::vec2 clippedPointInCircle(float radius, glm::vec2 origin, glm::vec2 touchPoint);

View file

@ -22,7 +22,6 @@
#include <NumericalConstants.h> #include <NumericalConstants.h>
#include <SettingHandle.h> #include <SettingHandle.h>
#include <UUID.h> #include <UUID.h>
#include <PathUtils.h>
#include "AddressManager.h" #include "AddressManager.h"
#include "NodeList.h" #include "NodeList.h"
@ -309,8 +308,7 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
// lookupUrl.scheme() == URL_SCHEME_HTTPS || // lookupUrl.scheme() == URL_SCHEME_HTTPS ||
_previousLookup.clear(); _previousLookup.clear();
_shareablePlaceName.clear(); _shareablePlaceName.clear();
QUrl domainURL = PathUtils::expandToLocalDataAbsolutePath(lookupUrl); setDomainInfo(lookupUrl, trigger);
setDomainInfo(domainURL, trigger);
emit lookupResultsFinished(); emit lookupResultsFinished();
handlePath(DOMAIN_SPAWNING_POINT, LookupTrigger::Internal, false); handlePath(DOMAIN_SPAWNING_POINT, LookupTrigger::Internal, false);
return true; return true;
@ -768,14 +766,6 @@ bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16
return false; return false;
} }
QString AddressManager::getHost() const {
if (isPossiblePlaceName(_domainURL.host())) {
return QString();
}
return _domainURL.host();
}
bool AddressManager::setDomainInfo(const QUrl& domainURL, LookupTrigger trigger) { bool AddressManager::setDomainInfo(const QUrl& domainURL, LookupTrigger trigger) {
const QString hostname = domainURL.host(); const QString hostname = domainURL.host();
quint16 port = domainURL.port(); quint16 port = domainURL.port();

View file

@ -160,7 +160,7 @@ public:
QString getPlaceName() const; QString getPlaceName() const;
QString getDomainID() const; QString getDomainID() const;
QString getHost() const; QString getHost() const { return _domainURL.host(); }
void setPositionGetter(PositionGetter positionGetter) { _positionGetter = positionGetter; } void setPositionGetter(PositionGetter positionGetter) { _positionGetter = positionGetter; }
void setOrientationGetter(OrientationGetter orientationGetter) { _orientationGetter = orientationGetter; } void setOrientationGetter(OrientationGetter orientationGetter) { _orientationGetter = orientationGetter; }

View file

@ -9,8 +9,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "DomainHandler.h"
#include <math.h> #include <math.h>
#include <PathUtils.h>
#include <QtCore/QJsonDocument> #include <QtCore/QJsonDocument>
#include <QtCore/QDataStream> #include <QtCore/QDataStream>
@ -25,8 +29,6 @@
#include "UserActivityLogger.h" #include "UserActivityLogger.h"
#include "NetworkLogging.h" #include "NetworkLogging.h"
#include "DomainHandler.h"
DomainHandler::DomainHandler(QObject* parent) : DomainHandler::DomainHandler(QObject* parent) :
QObject(parent), QObject(parent),
_sockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)), _sockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
@ -157,6 +159,11 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
if (domainURL.scheme() != URL_SCHEME_HIFI) { if (domainURL.scheme() != URL_SCHEME_HIFI) {
_sockAddr.clear(); _sockAddr.clear();
// if this is a file URL we need to see if it has a ~ for us to expand
if (domainURL.scheme() == URL_SCHEME_FILE) {
domainURL = PathUtils::expandToLocalDataAbsolutePath(domainURL);
}
} }
if (_domainURL != domainURL || _sockAddr.getPort() != domainURL.port()) { if (_domainURL != domainURL || _sockAddr.getPort() != domainURL.port()) {

View file

@ -37,9 +37,8 @@ static const int MIN_TIMER_MS = 5;
using namespace hifi::qml; using namespace hifi::qml;
using namespace hifi::qml::impl; using namespace hifi::qml::impl;
TextureCache offscreenTextures;
TextureCache& SharedObject::getTextureCache() { TextureCache& SharedObject::getTextureCache() {
static TextureCache offscreenTextures;
return offscreenTextures; return offscreenTextures;
} }
@ -243,7 +242,7 @@ void SharedObject::releaseTextureAndFence() {
QMutexLocker lock(&_mutex); QMutexLocker lock(&_mutex);
// If the most recent texture was unused, we can directly recycle it // If the most recent texture was unused, we can directly recycle it
if (_latestTextureAndFence.first) { if (_latestTextureAndFence.first) {
offscreenTextures.releaseTexture(_latestTextureAndFence); getTextureCache().releaseTexture(_latestTextureAndFence);
_latestTextureAndFence = TextureAndFence{ 0, 0 }; _latestTextureAndFence = TextureAndFence{ 0, 0 };
} }
} }
@ -307,7 +306,10 @@ bool SharedObject::preRender() {
void SharedObject::shutdownRendering(OffscreenGLCanvas& canvas, const QSize& size) { void SharedObject::shutdownRendering(OffscreenGLCanvas& canvas, const QSize& size) {
QMutexLocker locker(&_mutex); QMutexLocker locker(&_mutex);
if (size != QSize(0, 0)) { if (size != QSize(0, 0)) {
offscreenTextures.releaseSize(size); getTextureCache().releaseSize(size);
if (_latestTextureAndFence.first) {
getTextureCache().releaseTexture(_latestTextureAndFence);
}
} }
_renderControl->invalidate(); _renderControl->invalidate();
canvas.doneCurrent(); canvas.doneCurrent();
@ -403,7 +405,7 @@ void SharedObject::onRender() {
} }
void SharedObject::onTimer() { void SharedObject::onTimer() {
offscreenTextures.report(); getTextureCache().report();
if (!_renderRequested) { if (!_renderRequested) {
return; return;
} }
@ -436,7 +438,7 @@ void SharedObject::updateTextureAndFence(const TextureAndFence& newTextureAndFen
QMutexLocker locker(&_mutex); QMutexLocker locker(&_mutex);
// If the most recent texture was unused, we can directly recycle it // If the most recent texture was unused, we can directly recycle it
if (_latestTextureAndFence.first) { if (_latestTextureAndFence.first) {
offscreenTextures.releaseTexture(_latestTextureAndFence); getTextureCache().releaseTexture(_latestTextureAndFence);
_latestTextureAndFence = { 0, 0 }; _latestTextureAndFence = { 0, 0 };
} }

View file

@ -11,10 +11,6 @@
using namespace hifi::qml::impl; using namespace hifi::qml::impl;
#if defined(Q_OS_ANDROID)
#define USE_GLES 1
#endif
uint64_t uvec2ToUint64(const QSize& size) { uint64_t uvec2ToUint64(const QSize& size) {
uint64_t result = size.width(); uint64_t result = size.width();
result <<= 32; result <<= 32;
@ -31,26 +27,23 @@ void TextureCache::acquireSize(const QSize& size) {
void TextureCache::releaseSize(const QSize& size) { void TextureCache::releaseSize(const QSize& size) {
auto sizeKey = uvec2ToUint64(size); auto sizeKey = uvec2ToUint64(size);
ValueList texturesToDelete;
{ {
Lock lock(_mutex); Lock lock(_mutex);
assert(_textures.count(sizeKey)); assert(_textures.count(sizeKey));
auto& textureSet = _textures[sizeKey]; auto& textureSet = _textures[sizeKey];
if (0 == --textureSet.clientCount) { if (0 == --textureSet.clientCount) {
texturesToDelete.swap(textureSet.returnedTextures); for (const auto& textureAndFence : textureSet.returnedTextures) {
destroy(textureAndFence);
}
_textures.erase(sizeKey); _textures.erase(sizeKey);
} }
} }
for (const auto& textureAndFence : texturesToDelete) {
destroy(textureAndFence);
}
} }
uint32_t TextureCache::acquireTexture(const QSize& size) { uint32_t TextureCache::acquireTexture(const QSize& size) {
Lock lock(_mutex); Lock lock(_mutex);
recycle(); recycle();
++_activeTextureCount; ++_activeTextureCount;
auto sizeKey = uvec2ToUint64(size); auto sizeKey = uvec2ToUint64(size);
assert(_textures.count(sizeKey)); assert(_textures.count(sizeKey));
@ -83,7 +76,12 @@ void TextureCache::report() {
} }
size_t TextureCache::getUsedTextureMemory() { size_t TextureCache::getUsedTextureMemory() {
return _totalTextureUsage; size_t toReturn;
{
Lock lock(_mutex);
toReturn = _totalTextureUsage;
}
return toReturn;
} }
size_t TextureCache::getMemoryForSize(const QSize& size) { size_t TextureCache::getMemoryForSize(const QSize& size) {
@ -122,8 +120,6 @@ uint32_t TextureCache::createTexture(const QSize& size) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8.0f);
#if !defined(USE_GLES) #if !defined(USE_GLES)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -0.2f); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -0.2f);
#endif #endif

View file

@ -41,7 +41,6 @@ public:
ValueList returnedTextures; ValueList returnedTextures;
}; };
void releaseSize(const QSize& size); void releaseSize(const QSize& size);
void acquireSize(const QSize& size); void acquireSize(const QSize& size);
uint32_t acquireTexture(const QSize& size); uint32_t acquireTexture(const QSize& size);

View file

@ -79,12 +79,12 @@ void MainWindow::closeEvent(QCloseEvent* event) {
} }
void MainWindow::moveEvent(QMoveEvent* event) { void MainWindow::moveEvent(QMoveEvent* event) {
emit windowGeometryChanged(QRect(event->pos(), size())); emit windowGeometryChanged(QRect(QPoint(geometry().x(), geometry().y()), size())); // Geometry excluding the window frame.
QMainWindow::moveEvent(event); QMainWindow::moveEvent(event);
} }
void MainWindow::resizeEvent(QResizeEvent* event) { void MainWindow::resizeEvent(QResizeEvent* event) {
emit windowGeometryChanged(QRect(QPoint(x(), y()), event->size())); emit windowGeometryChanged(QRect(QPoint(geometry().x(), geometry().y()), size())); // Geometry excluding the window frame.
QMainWindow::resizeEvent(event); QMainWindow::resizeEvent(event);
} }

View file

@ -35,9 +35,13 @@ namespace VirtualPad {
} }
const float Manager::DPI = 534.0f; const float Manager::DPI = 534.0f;
const float Manager::PIXEL_SIZE = 512.0f; const float Manager::BASE_DIAMETER_PIXELS = 512.0f;
const float Manager::STICK_RADIUS = 105.0f; const float Manager::BASE_MARGIN_PIXELS = 59.0f;
const float Manager::BASE_MARGIN = 59.0f; const float Manager::STICK_RADIUS_PIXELS = 105.0f;
const float Manager::JUMP_BTN_TRIMMED_RADIUS_PIXELS = 67.0f;
const float Manager::JUMP_BTN_FULL_PIXELS = 134.0f;
const float Manager::JUMP_BTN_BOTTOM_MARGIN_PIXELS = 67.0f;
const float Manager::JUMP_BTN_LEFT_MARGIN_PIXELS = 547.0f;
Manager::Manager() { Manager::Manager() {
@ -72,6 +76,14 @@ namespace VirtualPad {
_extraBottomMargin = margin; _extraBottomMargin = margin;
} }
glm::vec2 Manager::getJumpButtonPosition() {
return _jumpButtonPosition;
}
void Manager::setJumpButtonPosition(glm::vec2 point) {
_jumpButtonPosition = point;
}
Instance* Manager::getLeftVirtualPad() { Instance* Manager::getLeftVirtualPad() {
return &_leftVPadInstance; return &_leftVPadInstance;
} }

View file

@ -44,16 +44,23 @@ namespace VirtualPad {
void hide(bool hide); void hide(bool hide);
int extraBottomMargin(); int extraBottomMargin();
void setExtraBottomMargin(int margin); void setExtraBottomMargin(int margin);
glm::vec2 getJumpButtonPosition();
void setJumpButtonPosition(glm::vec2 point);
static const float DPI; static const float DPI;
static const float PIXEL_SIZE; static const float BASE_DIAMETER_PIXELS;
static const float STICK_RADIUS; static const float BASE_MARGIN_PIXELS;
static const float BASE_MARGIN; static const float STICK_RADIUS_PIXELS;
static const float JUMP_BTN_TRIMMED_RADIUS_PIXELS;
static const float JUMP_BTN_FULL_PIXELS;
static const float JUMP_BTN_BOTTOM_MARGIN_PIXELS;
static const float JUMP_BTN_LEFT_MARGIN_PIXELS;
private: private:
Instance _leftVPadInstance; Instance _leftVPadInstance;
bool _enabled; bool _enabled;
bool _hidden; bool _hidden;
glm::vec2 _jumpButtonPosition;
int _extraBottomMargin {0}; int _extraBottomMargin {0};
}; };
} }

View file

@ -116,11 +116,19 @@ var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus";
var MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "Show Lights and Particle Systems in Create Mode"; var MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "Show Lights and Particle Systems in Create Mode";
var MENU_SHOW_ZONES_IN_EDIT_MODE = "Show Zones in Create Mode"; var MENU_SHOW_ZONES_IN_EDIT_MODE = "Show Zones in Create Mode";
var MENU_CREATE_ENTITIES_GRABBABLE = "Create Entities As Grabbable (except Zones, Particles, and Lights)";
var MENU_ALLOW_SELECTION_LARGE = "Allow Selecting of Large Models";
var MENU_ALLOW_SELECTION_SMALL = "Allow Selecting of Small Models";
var MENU_ALLOW_SELECTION_LIGHTS = "Allow Selecting of Lights";
var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect"; var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect";
var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus"; var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus";
var SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "showLightsAndParticlesInEditMode"; var SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "showLightsAndParticlesInEditMode";
var SETTING_SHOW_ZONES_IN_EDIT_MODE = "showZonesInEditMode"; var SETTING_SHOW_ZONES_IN_EDIT_MODE = "showZonesInEditMode";
var SETTING_EDIT_PREFIX = "Edit/";
var CREATE_ENABLED_ICON = "icons/tablet-icons/edit-i.svg"; var CREATE_ENABLED_ICON = "icons/tablet-icons/edit-i.svg";
var CREATE_DISABLED_ICON = "icons/tablet-icons/edit-disabled.svg"; var CREATE_DISABLED_ICON = "icons/tablet-icons/edit-disabled.svg";
@ -226,7 +234,7 @@ function adjustPositionPerBoundingBox(position, direction, registration, dimensi
var TOOLS_PATH = Script.resolvePath("assets/images/tools/"); var TOOLS_PATH = Script.resolvePath("assets/images/tools/");
var GRABBABLE_ENTITIES_MENU_CATEGORY = "Edit"; var GRABBABLE_ENTITIES_MENU_CATEGORY = "Edit";
var GRABBABLE_ENTITIES_MENU_ITEM = "Create Entities As Grabbable (except Zones, Particles, and Lights)";
var toolBar = (function () { var toolBar = (function () {
var EDIT_SETTING = "io.highfidelity.isEditing"; // for communication with other scripts var EDIT_SETTING = "io.highfidelity.isEditing"; // for communication with other scripts
@ -280,7 +288,7 @@ var toolBar = (function () {
position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions); position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions);
properties.position = position; properties.position = position;
if (Menu.isOptionChecked(GRABBABLE_ENTITIES_MENU_ITEM) && if (Menu.isOptionChecked(MENU_CREATE_ENTITIES_GRABBABLE) &&
!(properties.type === "Zone" || properties.type === "Light" || properties.type === "ParticleEffect")) { !(properties.type === "Zone" || properties.type === "Light" || properties.type === "ParticleEffect")) {
properties.userData = JSON.stringify({ grabbableKey: { grabbable: true } }); properties.userData = JSON.stringify({ grabbableKey: { grabbable: true } });
} else { } else {
@ -338,7 +346,6 @@ var toolBar = (function () {
if (systemToolbar) { if (systemToolbar) {
systemToolbar.removeButton(EDIT_TOGGLE_BUTTON); systemToolbar.removeButton(EDIT_TOGGLE_BUTTON);
} }
Menu.removeMenuItem(GRABBABLE_ENTITIES_MENU_CATEGORY, GRABBABLE_ENTITIES_MENU_ITEM);
} }
var buttonHandlers = {}; // only used to tablet mode var buttonHandlers = {}; // only used to tablet mode
@ -1143,34 +1150,35 @@ function setupModelMenus() {
Menu.addMenuItem({ Menu.addMenuItem({
menuName: GRABBABLE_ENTITIES_MENU_CATEGORY, menuName: GRABBABLE_ENTITIES_MENU_CATEGORY,
menuItemName: GRABBABLE_ENTITIES_MENU_ITEM, menuItemName: MENU_CREATE_ENTITIES_GRABBABLE,
afterItem: "Unparent Entity", afterItem: "Unparent Entity",
isCheckable: true, isCheckable: true,
isChecked: true, isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_CREATE_ENTITIES_GRABBABLE, true),
grouping: "Advanced" grouping: "Advanced"
}); });
Menu.addMenuItem({ Menu.addMenuItem({
menuName: "Edit", menuName: "Edit",
menuItemName: "Allow Selecting of Large Models", menuItemName: MENU_ALLOW_SELECTION_LARGE,
afterItem: GRABBABLE_ENTITIES_MENU_ITEM, afterItem: MENU_CREATE_ENTITIES_GRABBABLE,
isCheckable: true, isCheckable: true,
isChecked: true, isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_LARGE, true),
grouping: "Advanced" grouping: "Advanced"
}); });
Menu.addMenuItem({ Menu.addMenuItem({
menuName: "Edit", menuName: "Edit",
menuItemName: "Allow Selecting of Small Models", menuItemName: MENU_ALLOW_SELECTION_SMALL,
afterItem: "Allow Selecting of Large Models", afterItem: MENU_ALLOW_SELECTION_LARGE,
isCheckable: true, isCheckable: true,
isChecked: true, isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_SMALL, true),
grouping: "Advanced" grouping: "Advanced"
}); });
Menu.addMenuItem({ Menu.addMenuItem({
menuName: "Edit", menuName: "Edit",
menuItemName: "Allow Selecting of Lights", menuItemName: MENU_ALLOW_SELECTION_LIGHTS,
afterItem: "Allow Selecting of Small Models", afterItem: MENU_ALLOW_SELECTION_SMALL,
isCheckable: true, isCheckable: true,
isChecked: Settings.getValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_LIGHTS, false),
grouping: "Advanced" grouping: "Advanced"
}); });
Menu.addMenuItem({ Menu.addMenuItem({
@ -1275,6 +1283,12 @@ Script.scriptEnding.connect(function () {
Settings.setValue(SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE, Menu.isOptionChecked(MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE)); Settings.setValue(SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE, Menu.isOptionChecked(MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE));
Settings.setValue(SETTING_SHOW_ZONES_IN_EDIT_MODE, Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE)); Settings.setValue(SETTING_SHOW_ZONES_IN_EDIT_MODE, Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
Settings.setValue(SETTING_EDIT_PREFIX + MENU_CREATE_ENTITIES_GRABBABLE, Menu.isOptionChecked(MENU_CREATE_ENTITIES_GRABBABLE));
Settings.setValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_LARGE, Menu.isOptionChecked(MENU_ALLOW_SELECTION_LARGE));
Settings.setValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_SMALL, Menu.isOptionChecked(MENU_ALLOW_SELECTION_SMALL));
Settings.setValue(SETTING_EDIT_PREFIX + MENU_ALLOW_SELECTION_LIGHTS, Menu.isOptionChecked(GRABBABLE_ENTITIES_MENU_ITEM));
progressDialog.cleanup(); progressDialog.cleanup();
cleanupModelMenus(); cleanupModelMenus();
tooltip.cleanup(); tooltip.cleanup();

View file

@ -2,15 +2,7 @@ var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html');
Grid = function(opts) { Grid = function(opts) {
var that = {}; var that = {};
var gridColor = { red: 0, green: 0, blue: 0 };
var colors = [
{ red: 0, green: 0, blue: 0 },
{ red: 255, green: 255, blue: 255 },
{ red: 255, green: 0, blue: 0 },
{ red: 0, green: 255, blue: 0 },
{ red: 0, green: 0, blue: 255 },
];
var colorIndex = 0;
var gridAlpha = 0.6; var gridAlpha = 0.6;
var origin = { x: 0, y: +MyAvatar.getJointPosition('LeftToeBase').y.toFixed(1) + 0.1, z: 0 }; var origin = { x: 0, y: +MyAvatar.getJointPosition('LeftToeBase').y.toFixed(1) + 0.1, z: 0 };
var scale = 500; var scale = 500;
@ -28,10 +20,10 @@ Grid = function(opts) {
position: origin, position: origin,
visible: false, visible: false,
drawInFront: false, drawInFront: false,
color: colors[0], color: gridColor,
alpha: gridAlpha, alpha: gridAlpha,
minorGridEvery: minorGridEvery, minorGridEvery: minorGridEvery,
majorGridEvery: majorGridEvery, majorGridEvery: majorGridEvery
}); });
that.visible = false; that.visible = false;
@ -39,26 +31,38 @@ Grid = function(opts) {
that.getOrigin = function() { that.getOrigin = function() {
return origin; return origin;
} };
that.getMinorIncrement = function() {
return minorGridEvery;
};
that.getMinorIncrement = function() { return minorGridEvery; };
that.setMinorIncrement = function(value) { that.setMinorIncrement = function(value) {
minorGridEvery = value; minorGridEvery = value;
updateGrid(); updateGrid();
} };
that.getMajorIncrement = function() { return majorGridEvery; };
that.getMajorIncrement = function() {
return majorGridEvery;
};
that.setMajorIncrement = function(value) { that.setMajorIncrement = function(value) {
majorGridEvery = value; majorGridEvery = value;
updateGrid(); updateGrid();
}; };
that.getColorIndex = function() { return colorIndex; }; that.getColor = function() {
that.setColorIndex = function(value) { return gridColor;
colorIndex = value; };
that.setColor = function(value) {
gridColor = value;
updateGrid(); updateGrid();
}; };
that.getSnapToGrid = function() { return snapToGrid; }; that.getSnapToGrid = function() {
return snapToGrid;
};
that.setSnapToGrid = function(value) { that.setSnapToGrid = function(value) {
snapToGrid = value; snapToGrid = value;
that.emitUpdate(); that.emitUpdate();
@ -67,9 +71,11 @@ Grid = function(opts) {
that.setEnabled = function(enabled) { that.setEnabled = function(enabled) {
that.enabled = enabled; that.enabled = enabled;
updateGrid(); updateGrid();
} };
that.getVisible = function() { return that.visible; }; that.getVisible = function() {
return that.visible;
};
that.setVisible = function(visible, noUpdate) { that.setVisible = function(visible, noUpdate) {
that.visible = visible; that.visible = visible;
updateGrid(); updateGrid();
@ -77,7 +83,7 @@ Grid = function(opts) {
if (!noUpdate) { if (!noUpdate) {
that.emitUpdate(); that.emitUpdate();
} }
} };
that.snapToSurface = function(position, dimensions, registration) { that.snapToSurface = function(position, dimensions, registration) {
if (!snapToGrid) { if (!snapToGrid) {
@ -97,7 +103,7 @@ Grid = function(opts) {
y: origin.y + (registration.y * dimensions.y), y: origin.y + (registration.y * dimensions.y),
z: position.z z: position.z
}; };
} };
that.snapToGrid = function(position, majorOnly, dimensions, registration) { that.snapToGrid = function(position, majorOnly, dimensions, registration) {
if (!snapToGrid) { if (!snapToGrid) {
@ -121,7 +127,7 @@ Grid = function(opts) {
position.z = Math.round(position.z / spacing) * spacing; position.z = Math.round(position.z / spacing) * spacing;
return Vec3.sum(Vec3.sum(position, Vec3.multiplyVbyV(registration, dimensions)), origin); return Vec3.sum(Vec3.sum(position, Vec3.multiplyVbyV(registration, dimensions)), origin);
} };
that.snapToSpacing = function(delta, majorOnly) { that.snapToSpacing = function(delta, majorOnly) {
if (!snapToGrid) { if (!snapToGrid) {
@ -133,11 +139,11 @@ Grid = function(opts) {
var snappedDelta = { var snappedDelta = {
x: Math.round(delta.x / spacing) * spacing, x: Math.round(delta.x / spacing) * spacing,
y: Math.round(delta.y / spacing) * spacing, y: Math.round(delta.y / spacing) * spacing,
z: Math.round(delta.z / spacing) * spacing, z: Math.round(delta.z / spacing) * spacing
}; };
return snappedDelta; return snappedDelta;
} };
that.setPosition = function(newPosition, noUpdate) { that.setPosition = function(newPosition, noUpdate) {
@ -157,7 +163,7 @@ Grid = function(opts) {
majorGridEvery: majorGridEvery, majorGridEvery: majorGridEvery,
gridSize: halfSize, gridSize: halfSize,
visible: that.visible, visible: that.visible,
snapToGrid: snapToGrid, snapToGrid: snapToGrid
}); });
} }
}; };
@ -183,8 +189,8 @@ Grid = function(opts) {
majorGridEvery = data.majorGridEvery; majorGridEvery = data.majorGridEvery;
} }
if (data.colorIndex !== undefined) { if (data.gridColor) {
colorIndex = data.colorIndex; gridColor = data.gridColor;
} }
if (data.gridSize) { if (data.gridSize) {
@ -196,7 +202,7 @@ Grid = function(opts) {
} }
updateGrid(true); updateGrid(true);
} };
function updateGrid(noUpdate) { function updateGrid(noUpdate) {
Overlays.editOverlay(gridOverlay, { Overlays.editOverlay(gridOverlay, {
@ -204,8 +210,8 @@ Grid = function(opts) {
visible: that.visible && that.enabled, visible: that.visible && that.enabled,
minorGridEvery: minorGridEvery, minorGridEvery: minorGridEvery,
majorGridEvery: majorGridEvery, majorGridEvery: majorGridEvery,
color: colors[colorIndex], color: gridColor,
alpha: gridAlpha, alpha: gridAlpha
}); });
if (!noUpdate) { if (!noUpdate) {
@ -219,7 +225,7 @@ Grid = function(opts) {
that.addListener = function(callback) { that.addListener = function(callback) {
that.onUpdate = callback; that.onUpdate = callback;
} };
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
updateGrid(); updateGrid();
@ -238,7 +244,7 @@ GridTool = function(opts) {
var webView = null; var webView = null;
webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); webView = Tablet.getTablet("com.highfidelity.interface.tablet.system");
webView.setVisible = function(value) {}; webView.setVisible = function(value) { };
horizontalGrid.addListener(function(data) { horizontalGrid.addListener(function(data) {
webView.emitScriptEvent(JSON.stringify(data)); webView.emitScriptEvent(JSON.stringify(data));
@ -250,8 +256,8 @@ GridTool = function(opts) {
webView.webEventReceived.connect(function(data) { webView.webEventReceived.connect(function(data) {
try { try {
data = JSON.parse(data); data = JSON.parse(data);
} catch(e) { } catch (e) {
print("gridTool.js: Error parsing JSON: " + e.name + " data " + data) print("gridTool.js: Error parsing JSON: " + e.name + " data " + data);
return; return;
} }
@ -280,11 +286,11 @@ GridTool = function(opts) {
that.addListener = function(callback) { that.addListener = function(callback) {
listeners.push(callback); listeners.push(callback);
} };
that.setVisible = function(visible) { that.setVisible = function(visible) {
webView.setVisible(visible); webView.setVisible(visible);
} };
return that; return that;
}; };

View file

@ -1,6 +1,16 @@
import os, json, sys, shutil, subprocess, shlex, time import os, json, sys, shutil, subprocess, shlex, time
EXE = os.environ['HIFI_OVEN'] EXE = os.environ['HIFI_OVEN']
def getRelativePath(path1, path2, stop):
parts1 = path1.split('/');
parts2 = path2.split('/');
if len(parts1) <= len(parts2):
for part in parts1:
if part != stop and part != '':
index = parts2.index(part)
parts2.pop(index)
return os.path.join(*parts2)
def listFiles(directory, extension): def listFiles(directory, extension):
items = os.listdir(directory) items = os.listdir(directory)
fileList = [] fileList = []
@ -44,18 +54,20 @@ def bakeFile(filePath, outputDirectory):
groupKTXFiles(outputDirectory, bakedFile) groupKTXFiles(outputDirectory, bakedFile)
def bakeFilesInDirectory(directory, outputDirectory): def bakeFilesInDirectory(directory, outputDirectory):
rootDirectory = os.path.basename(os.path.normpath(directory))
for root, subFolders, filenames in os.walk(directory): for root, subFolders, filenames in os.walk(directory):
for filename in filenames: for filename in filenames:
appendPath = getRelativePath(directory, root, rootDirectory);
if filename.endswith('.fbx'): if filename.endswith('.fbx'):
filePath = os.sep.join([root, filename]) filePath = os.sep.join([root, filename])
absFilePath = os.path.abspath(filePath) absFilePath = os.path.abspath(filePath)
outputFolder = os.path.join(outputDirectory, os.path.relpath(root)) outputFolder = os.path.join(outputDirectory, appendPath)
print "Baking file: " + filename print "Baking file: " + filename
bakeFile(absFilePath, outputFolder) bakeFile(absFilePath, outputFolder)
else: else:
filePath = os.sep.join([root, filename]) filePath = os.sep.join([root, filename])
absFilePath = os.path.abspath(filePath) absFilePath = os.path.abspath(filePath)
outputFolder = os.path.join(outputDirectory, os.path.relpath(root)) outputFolder = os.path.join(outputDirectory, appendPath)
newFilePath = os.sep.join([outputFolder, filename]) newFilePath = os.sep.join([outputFolder, filename])
createDirectory(outputFolder) createDirectory(outputFolder)
print "moving file: " + filename + " to: " + outputFolder print "moving file: " + filename + " to: " + outputFolder