Merge branch 'master' of https://github.com/highfidelity/hifi into blue

This commit is contained in:
samcake 2017-09-22 18:00:58 -07:00
commit 59006411c6
21 changed files with 135 additions and 91 deletions

View file

@ -49,9 +49,14 @@ ScrollingWindow {
Component.onCompleted: { Component.onCompleted: {
ApplicationInterface.uploadRequest.connect(uploadClicked); ApplicationInterface.uploadRequest.connect(uploadClicked);
assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError); assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError);
assetMappingsModel.autoRefreshEnabled = true;
reload(); reload();
} }
Component.onDestruction: {
assetMappingsModel.autoRefreshEnabled = false;
}
function doDeleteFile(path) { function doDeleteFile(path) {
console.log("Deleting " + path); console.log("Deleting " + path);
@ -146,7 +151,6 @@ ScrollingWindow {
function reload() { function reload() {
Assets.mappingModel.refresh(); Assets.mappingModel.refresh();
treeView.selection.clear();
} }
function handleGetMappingsError(errorString) { function handleGetMappingsError(errorString) {
@ -502,16 +506,6 @@ ScrollingWindow {
onClicked: root.deleteFile() onClicked: root.deleteFile()
enabled: treeView.selection.hasSelection enabled: treeView.selection.hasSelection
} }
HifiControls.GlyphButton {
glyph: hifi.glyphs.reload
color: hifi.buttons.black
colorScheme: root.colorScheme
width: hifi.dimensions.controlLineHeight
onClicked: root.reload()
}
} }
} }
@ -751,7 +745,7 @@ ScrollingWindow {
var path = assetProxyModel.data(index, 0x100); var path = assetProxyModel.data(index, 0x100);
mappings.push(path); mappings.push(path);
} }
print("Setting baking enabled:" + mappings + checked); print("Setting baking enabled:" + mappings + " " + checked);
Assets.setBakingEnabled(mappings, checked, function() { Assets.setBakingEnabled(mappings, checked, function() {
reload(); reload();
}); });

View file

@ -49,9 +49,15 @@ Rectangle {
isHMD = HMD.active; isHMD = HMD.active;
ApplicationInterface.uploadRequest.connect(uploadClicked); ApplicationInterface.uploadRequest.connect(uploadClicked);
assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError); assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError);
assetMappingsModel.autoRefreshEnabled = true;
reload(); reload();
} }
Component.onDestruction: {
assetMappingsModel.autoRefreshEnabled = false;
}
function doDeleteFile(path) { function doDeleteFile(path) {
console.log("Deleting " + path); console.log("Deleting " + path);
@ -145,7 +151,6 @@ Rectangle {
function reload() { function reload() {
Assets.mappingModel.refresh(); Assets.mappingModel.refresh();
treeView.selection.clear();
} }
function handleGetMappingsError(errorString) { function handleGetMappingsError(errorString) {
@ -502,16 +507,6 @@ Rectangle {
onClicked: root.deleteFile() onClicked: root.deleteFile()
enabled: treeView.selection.hasSelection enabled: treeView.selection.hasSelection
} }
HifiControls.GlyphButton {
glyph: hifi.glyphs.reload
color: hifi.buttons.black
colorScheme: root.colorScheme
width: hifi.dimensions.controlLineHeight
onClicked: root.reload()
}
} }
} }
@ -748,7 +743,7 @@ Rectangle {
var path = assetProxyModel.data(index, 0x100); var path = assetProxyModel.data(index, 0x100);
mappings.push(path); mappings.push(path);
} }
print("Setting baking enabled:" + mappings + checked); print("Setting baking enabled:" + mappings + " " + checked);
Assets.setBakingEnabled(mappings, checked, function() { Assets.setBakingEnabled(mappings, checked, function() {
reload(); reload();
}); });

View file

@ -19,8 +19,13 @@
#include <AssetUpload.h> #include <AssetUpload.h>
#include <MappingRequest.h> #include <MappingRequest.h>
#include <NetworkLogging.h> #include <NetworkLogging.h>
#include <NodeList.h>
#include <OffscreenUi.h> #include <OffscreenUi.h>
static const int AUTO_REFRESH_INTERVAL = 1000;
int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*");
AssetMappingsScriptingInterface::AssetMappingsScriptingInterface() { AssetMappingsScriptingInterface::AssetMappingsScriptingInterface() {
_proxyModel.setSourceModel(&_assetMappingModel); _proxyModel.setSourceModel(&_assetMappingModel);
_proxyModel.setSortRole(Qt::DisplayRole); _proxyModel.setSortRole(Qt::DisplayRole);
@ -189,6 +194,29 @@ void AssetMappingsScriptingInterface::setBakingEnabled(QStringList paths, bool e
AssetMappingModel::AssetMappingModel() { AssetMappingModel::AssetMappingModel() {
setupRoles(); setupRoles();
connect(&_autoRefreshTimer, &QTimer::timeout, this, [this] {
auto nodeList = DependencyManager::get<NodeList>();
auto assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
if (assetServer) {
refresh();
}
});
_autoRefreshTimer.setInterval(AUTO_REFRESH_INTERVAL);
}
bool AssetMappingModel::isAutoRefreshEnabled() {
return _autoRefreshTimer.isActive();
}
void AssetMappingModel::setAutoRefreshEnabled(bool enabled) {
if (enabled != _autoRefreshTimer.isActive()) {
if (enabled) {
_autoRefreshTimer.start();
} else {
_autoRefreshTimer.stop();
}
}
} }
bool AssetMappingModel::isKnownFolder(QString path) const { bool AssetMappingModel::isKnownFolder(QString path) const {
@ -205,10 +233,7 @@ bool AssetMappingModel::isKnownFolder(QString path) const {
return false; return false;
} }
int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*");
void AssetMappingModel::refresh() { void AssetMappingModel::refresh() {
qDebug() << "Refreshing asset mapping model";
auto assetClient = DependencyManager::get<AssetClient>(); auto assetClient = DependencyManager::get<AssetClient>();
auto request = assetClient->createGetAllMappingsRequest(); auto request = assetClient->createGetAllMappingsRequest();

View file

@ -25,11 +25,16 @@
class AssetMappingModel : public QStandardItemModel { class AssetMappingModel : public QStandardItemModel {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool autoRefreshEnabled READ isAutoRefreshEnabled WRITE setAutoRefreshEnabled)
public: public:
AssetMappingModel(); AssetMappingModel();
Q_INVOKABLE void refresh(); Q_INVOKABLE void refresh();
bool isAutoRefreshEnabled();
void setAutoRefreshEnabled(bool enabled);
bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); } bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); }
bool isKnownFolder(QString path) const; bool isKnownFolder(QString path) const;
@ -44,6 +49,7 @@ private:
void setupRoles(); void setupRoles();
QHash<QString, QStandardItem*> _pathToItemMap; QHash<QString, QStandardItem*> _pathToItemMap;
QTimer _autoRefreshTimer;
}; };
Q_DECLARE_METATYPE(AssetMappingModel*) Q_DECLARE_METATYPE(AssetMappingModel*)

View file

@ -15,6 +15,10 @@
#include <EntityTreeRenderer.h> #include <EntityTreeRenderer.h>
#include <NetworkingConstants.h> #include <NetworkingConstants.h>
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
static const float CONTEXT_OVERLAY_TABLET_OFFSET = 30.0f; // Degrees static const float CONTEXT_OVERLAY_TABLET_OFFSET = 30.0f; // Degrees
static const float CONTEXT_OVERLAY_TABLET_ORIENTATION = 210.0f; // Degrees static const float CONTEXT_OVERLAY_TABLET_ORIENTATION = 210.0f; // Degrees
static const float CONTEXT_OVERLAY_TABLET_DISTANCE = 0.65F; // Meters static const float CONTEXT_OVERLAY_TABLET_DISTANCE = 0.65F; // Meters
@ -38,11 +42,6 @@ ContextOverlayInterface::ContextOverlayInterface() {
_entityPropertyFlags += PROP_DIMENSIONS; _entityPropertyFlags += PROP_DIMENSIONS;
_entityPropertyFlags += PROP_REGISTRATION_POINT; _entityPropertyFlags += PROP_REGISTRATION_POINT;
// initially, set _enabled to match the switch. Later we enable/disable via the getter/setters
// if we are in edit or pal (for instance). Note this is temporary, as we expect to enable this all
// the time after getting edge highlighting, etc...
_enabled = _settingSwitch.get();
auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>().data(); auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>().data();
connect(entityTreeRenderer, SIGNAL(mousePressOnEntity(const EntityItemID&, const PointerEvent&)), this, SLOT(createOrDestroyContextOverlay(const EntityItemID&, const PointerEvent&))); connect(entityTreeRenderer, SIGNAL(mousePressOnEntity(const EntityItemID&, const PointerEvent&)), this, SLOT(createOrDestroyContextOverlay(const EntityItemID&, const PointerEvent&)));
connect(entityTreeRenderer, SIGNAL(hoverEnterEntity(const EntityItemID&, const PointerEvent&)), this, SLOT(contextOverlays_hoverEnterEntity(const EntityItemID&, const PointerEvent&))); connect(entityTreeRenderer, SIGNAL(hoverEnterEntity(const EntityItemID&, const PointerEvent&)), this, SLOT(contextOverlays_hoverEnterEntity(const EntityItemID&, const PointerEvent&)));
@ -65,40 +64,36 @@ ContextOverlayInterface::ContextOverlayInterface() {
connect(_selectionScriptingInterface.data(), &SelectionScriptingInterface::selectedItemsListChanged, &_selectionToSceneHandler, &SelectionToSceneHandler::selectedItemsListChanged); connect(_selectionScriptingInterface.data(), &SelectionScriptingInterface::selectedItemsListChanged, &_selectionToSceneHandler, &SelectionToSceneHandler::selectedItemsListChanged);
} }
static const uint32_t MOUSE_HW_ID = 0;
static const uint32_t LEFT_HAND_HW_ID = 1; static const uint32_t LEFT_HAND_HW_ID = 1;
static const xColor CONTEXT_OVERLAY_COLOR = { 255, 255, 255 }; static const xColor CONTEXT_OVERLAY_COLOR = { 255, 255, 255 };
static const float CONTEXT_OVERLAY_INSIDE_DISTANCE = 1.0f; // in meters static const float CONTEXT_OVERLAY_INSIDE_DISTANCE = 1.0f; // in meters
static const float CONTEXT_OVERLAY_CLOSE_DISTANCE = 1.5f; // in meters static const float CONTEXT_OVERLAY_SIZE = 0.09f; // in meters, same x and y dims
static const float CONTEXT_OVERLAY_CLOSE_SIZE = 0.12f; // in meters, same x and y dims static const float CONTEXT_OVERLAY_OFFSET_DISTANCE = 0.1f;
static const float CONTEXT_OVERLAY_FAR_SIZE = 0.08f; // in meters, same x and y dims static const float CONTEXT_OVERLAY_OFFSET_ANGLE = 5.0f;
static const float CONTEXT_OVERLAY_CLOSE_OFFSET_ANGLE = 20.0f;
static const float CONTEXT_OVERLAY_UNHOVERED_ALPHA = 0.85f; static const float CONTEXT_OVERLAY_UNHOVERED_ALPHA = 0.85f;
static const float CONTEXT_OVERLAY_HOVERED_ALPHA = 1.0f; static const float CONTEXT_OVERLAY_HOVERED_ALPHA = 1.0f;
static const float CONTEXT_OVERLAY_UNHOVERED_PULSEMIN = 0.6f; static const float CONTEXT_OVERLAY_UNHOVERED_PULSEMIN = 0.6f;
static const float CONTEXT_OVERLAY_UNHOVERED_PULSEMAX = 1.0f; static const float CONTEXT_OVERLAY_UNHOVERED_PULSEMAX = 1.0f;
static const float CONTEXT_OVERLAY_UNHOVERED_PULSEPERIOD = 1.0f; static const float CONTEXT_OVERLAY_UNHOVERED_PULSEPERIOD = 1.0f;
static const float CONTEXT_OVERLAY_UNHOVERED_COLORPULSE = 1.0f; static const float CONTEXT_OVERLAY_UNHOVERED_COLORPULSE = 1.0f;
static const float CONTEXT_OVERLAY_FAR_OFFSET = 0.1f;
void ContextOverlayInterface::setEnabled(bool enabled) { void ContextOverlayInterface::setEnabled(bool enabled) {
// only enable/disable if the setting in 'on'. If it is 'off', _enabled = enabled;
// make sure _enabled is always false.
if (_settingSwitch.get()) {
_enabled = enabled;
} else {
_enabled = false;
}
} }
bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event) { bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event) {
if (_enabled && event.getButton() == PointerEvent::SecondaryButton) { if (_enabled && event.getButton() == PointerEvent::SecondaryButton) {
if (contextOverlayFilterPassed(entityItemID)) { if (contextOverlayFilterPassed(entityItemID)) {
if (event.getID() == MOUSE_HW_ID) {
enableEntityHighlight(entityItemID);
}
qCDebug(context_overlay) << "Creating Context Overlay on top of entity with ID: " << entityItemID; qCDebug(context_overlay) << "Creating Context Overlay on top of entity with ID: " << entityItemID;
// Add all necessary variables to the stack // Add all necessary variables to the stack
EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(entityItemID, _entityPropertyFlags); EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(entityItemID, _entityPropertyFlags);
glm::vec3 cameraPosition = qApp->getCamera().getPosition(); glm::vec3 cameraPosition = qApp->getCamera().getPosition();
float distanceFromCameraToEntity = glm::distance(entityProperties.getPosition(), cameraPosition);
glm::vec3 entityDimensions = entityProperties.getDimensions(); glm::vec3 entityDimensions = entityProperties.getDimensions();
glm::vec3 entityPosition = entityProperties.getPosition(); glm::vec3 entityPosition = entityProperties.getPosition();
glm::vec3 contextOverlayPosition = entityProperties.getPosition(); glm::vec3 contextOverlayPosition = entityProperties.getPosition();
@ -131,27 +126,22 @@ bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID&
// If the camera is inside the box... // If the camera is inside the box...
// ...position the Context Overlay 1 meter in front of the camera. // ...position the Context Overlay 1 meter in front of the camera.
contextOverlayPosition = cameraPosition + CONTEXT_OVERLAY_INSIDE_DISTANCE * (qApp->getCamera().getOrientation() * Vectors::FRONT); contextOverlayPosition = cameraPosition + CONTEXT_OVERLAY_INSIDE_DISTANCE * (qApp->getCamera().getOrientation() * Vectors::FRONT);
contextOverlayDimensions = glm::vec2(CONTEXT_OVERLAY_CLOSE_SIZE, CONTEXT_OVERLAY_CLOSE_SIZE) * glm::distance(contextOverlayPosition, cameraPosition); contextOverlayDimensions = glm::vec2(CONTEXT_OVERLAY_SIZE, CONTEXT_OVERLAY_SIZE) * glm::distance(contextOverlayPosition, cameraPosition);
} else if (distanceFromCameraToEntity < CONTEXT_OVERLAY_CLOSE_DISTANCE) {
// Else if the entity is too close to the camera...
// ...rotate the Context Overlay to the right of the entity.
// This makes it easy to inspect things you're holding.
float offsetAngle = -CONTEXT_OVERLAY_CLOSE_OFFSET_ANGLE;
if (event.getID() == LEFT_HAND_HW_ID) {
offsetAngle *= -1;
}
contextOverlayPosition = (glm::quat(glm::radians(glm::vec3(0.0f, offsetAngle, 0.0f))) * (entityPosition - cameraPosition)) + cameraPosition;
contextOverlayDimensions = glm::vec2(CONTEXT_OVERLAY_CLOSE_SIZE, CONTEXT_OVERLAY_CLOSE_SIZE) * glm::distance(contextOverlayPosition, cameraPosition);
} else { } else {
// Else, place the Context Overlay some offset away from the entity's bounding // Rotate the Context Overlay some number of degrees offset from the entity
// box in the direction of the camera. // along the line cast from your head to the entity's bounding box.
glm::vec3 direction = glm::normalize(entityPosition - cameraPosition); glm::vec3 direction = glm::normalize(entityPosition - cameraPosition);
float distance; float distance;
BoxFace face; BoxFace face;
glm::vec3 normal; glm::vec3 normal;
boundingBox.findRayIntersection(cameraPosition, direction, distance, face, normal); boundingBox.findRayIntersection(cameraPosition, direction, distance, face, normal);
contextOverlayPosition = (cameraPosition + direction * distance) - direction * CONTEXT_OVERLAY_FAR_OFFSET; float offsetAngle = -CONTEXT_OVERLAY_OFFSET_ANGLE;
contextOverlayDimensions = glm::vec2(CONTEXT_OVERLAY_FAR_SIZE, CONTEXT_OVERLAY_FAR_SIZE) * glm::distance(contextOverlayPosition, cameraPosition); if (event.getID() == LEFT_HAND_HW_ID) {
offsetAngle *= -1;
}
contextOverlayPosition = (glm::quat(glm::radians(glm::vec3(0.0f, offsetAngle, 0.0f)))) *
((cameraPosition + direction * (distance - CONTEXT_OVERLAY_OFFSET_DISTANCE)));
contextOverlayDimensions = glm::vec2(CONTEXT_OVERLAY_SIZE, CONTEXT_OVERLAY_SIZE) * glm::distance(contextOverlayPosition, cameraPosition);
} }
// Finally, setup and draw the Context Overlay // Finally, setup and draw the Context Overlay
@ -176,6 +166,7 @@ bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID&
} }
} else { } else {
if (!_currentEntityWithContextOverlay.isNull()) { if (!_currentEntityWithContextOverlay.isNull()) {
disableEntityHighlight(_currentEntityWithContextOverlay);
return destroyContextOverlay(_currentEntityWithContextOverlay, event); return destroyContextOverlay(_currentEntityWithContextOverlay, event);
} }
return false; return false;
@ -237,13 +228,13 @@ void ContextOverlayInterface::contextOverlays_hoverLeaveOverlay(const OverlayID&
} }
void ContextOverlayInterface::contextOverlays_hoverEnterEntity(const EntityItemID& entityID, const PointerEvent& event) { void ContextOverlayInterface::contextOverlays_hoverEnterEntity(const EntityItemID& entityID, const PointerEvent& event) {
if (contextOverlayFilterPassed(entityID)) { if (contextOverlayFilterPassed(entityID) && _enabled && event.getID() != MOUSE_HW_ID) {
enableEntityHighlight(entityID); enableEntityHighlight(entityID);
} }
} }
void ContextOverlayInterface::contextOverlays_hoverLeaveEntity(const EntityItemID& entityID, const PointerEvent& event) { void ContextOverlayInterface::contextOverlays_hoverLeaveEntity(const EntityItemID& entityID, const PointerEvent& event) {
if (_currentEntityWithContextOverlay != entityID) { if (_currentEntityWithContextOverlay != entityID && _enabled && event.getID() != MOUSE_HW_ID) {
disableEntityHighlight(entityID); disableEntityHighlight(entityID);
} }
} }

View file

@ -76,8 +76,6 @@ private:
bool _isInMarketplaceInspectionMode { false }; bool _isInMarketplaceInspectionMode { false };
Setting::Handle<bool> _settingSwitch { "inspectionMode", false };
void openMarketplace(); void openMarketplace();
void enableEntityHighlight(const EntityItemID& entityItemID); void enableEntityHighlight(const EntityItemID& entityItemID);
void disableEntityHighlight(const EntityItemID& entityItemID); void disableEntityHighlight(const EntityItemID& entityItemID);

View file

@ -102,7 +102,7 @@ void TextEntityRenderer::doRender(RenderArgs* args) {
glm::quat orientation = glm::quat(glm::vec3(0.0f, yawRotation, 0.0f)); glm::quat orientation = glm::quat(glm::vec3(0.0f, yawRotation, 0.0f));
transformToTopLeft.setRotation(orientation); transformToTopLeft.setRotation(orientation);
} }
transformToTopLeft.postTranslate(glm::vec3(-0.5f, 0.5f, 0.0f)); // Go to the top left transformToTopLeft.postTranslate(dimensions * glm::vec3(-0.5f, 0.5f, 0.0f)); // Go to the top left
transformToTopLeft.setScale(1.0f); // Use a scale of one so that the text is not deformed transformToTopLeft.setScale(1.0f); // Use a scale of one so that the text is not deformed
batch.setModelTransform(transformToTopLeft); batch.setModelTransform(transformToTopLeft);

View file

@ -140,6 +140,11 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
_webSurface->resize(QSize(windowSize.x, windowSize.y)); _webSurface->resize(QSize(windowSize.x, windowSize.y));
} }
void WebEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
Parent::doRenderUpdateAsynchronousTyped(entity);
_modelTransform.postScale(entity->getDimensions());
}
void WebEntityRenderer::doRender(RenderArgs* args) { void WebEntityRenderer::doRender(RenderArgs* args) {
withWriteLock([&] { withWriteLock([&] {
_lastRenderTime = usecTimestampNow(); _lastRenderTime = usecTimestampNow();

View file

@ -29,6 +29,7 @@ protected:
virtual bool needsRenderUpdate() const override; virtual bool needsRenderUpdate() const override;
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override; virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override; virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
virtual void doRender(RenderArgs* args) override; virtual void doRender(RenderArgs* args) override;
virtual bool isTransparent() const override; virtual bool isTransparent() const override;

View file

@ -81,10 +81,10 @@ public:
float getColorB() const { return color.b; } float getColorB() const { return color.b; }
glm::vec3 color{ 1.f, 0.7f, 0.2f }; glm::vec3 color{ 1.f, 0.7f, 0.2f };
float width{ 3.f }; float width{ 2.0f };
float intensity{ 1.f }; float intensity{ 0.9f };
float fillOpacityUnoccluded{ 0.35f }; float fillOpacityUnoccluded{ 0.0f };
float fillOpacityOccluded{ 0.1f }; float fillOpacityOccluded{ 0.0f };
bool glow{ false }; bool glow{ false };
signals: signals:

View file

@ -9,7 +9,8 @@
// 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
// //
layout(location = 0) in vec4 inColor; in vec4 _color;
in float distanceFromCenter;
out vec4 _fragColor; out vec4 _fragColor;
@ -17,10 +18,10 @@ void main(void) {
// The incoming value actually ranges from -1 to 1, so modify it // The incoming value actually ranges from -1 to 1, so modify it
// so that it goes from 0 -> 1 -> 0 with the solid alpha being at // so that it goes from 0 -> 1 -> 0 with the solid alpha being at
// the center of the line // the center of the line
float alpha = 1.0 - abs(inColor.a); float alpha = 1.0 - abs(distanceFromCenter);
// Convert from a linear alpha curve to a sharp peaked one // Convert from a linear alpha curve to a sharp peaked one
alpha = pow(alpha, 10); alpha = _color.a * pow(alpha, 10);
// Drop everything where the curve falls off to nearly nothing // Drop everything where the curve falls off to nearly nothing
if (alpha <= 0.05) { if (alpha <= 0.05) {
@ -28,6 +29,5 @@ void main(void) {
} }
// Emit the color // Emit the color
_fragColor = vec4(inColor.rgb, alpha); _fragColor = vec4(_color.rgb, alpha);
return;
} }

View file

@ -18,7 +18,9 @@ layout(std140) uniform lineData {
vec4 color; vec4 color;
}; };
layout(location = 0) out vec4 _color; out vec4 _color;
// the distance from the center in 'quad space'
out float distanceFromCenter;
void main(void) { void main(void) {
_color = color; _color = color;
@ -45,11 +47,10 @@ void main(void) {
// Add or subtract the orthogonal vector based on a different vertex ID // Add or subtract the orthogonal vector based on a different vertex ID
// calculation // calculation
if (gl_VertexID < 2) { if (gl_VertexID < 2) {
// Use the alpha channel to store the distance from the center in 'quad space' distanceFromCenter = -1.0;
_color.a = -1.0;
eye.xyz -= orthogonal; eye.xyz -= orthogonal;
} else { } else {
_color.a = 1.0; distanceFromCenter = 1.0;
eye.xyz += orthogonal; eye.xyz += orthogonal;
} }

View file

@ -211,12 +211,12 @@ class UrlHandler : public QObject {
public: public:
Q_INVOKABLE bool canHandleUrl(const QString& url) { Q_INVOKABLE bool canHandleUrl(const QString& url) {
static auto handler = dynamic_cast<AbstractUriHandler*>(qApp); static auto handler = dynamic_cast<AbstractUriHandler*>(qApp);
return handler->canAcceptURL(url); return handler && handler->canAcceptURL(url);
} }
Q_INVOKABLE bool handleUrl(const QString& url) { Q_INVOKABLE bool handleUrl(const QString& url) {
static auto handler = dynamic_cast<AbstractUriHandler*>(qApp); static auto handler = dynamic_cast<AbstractUriHandler*>(qApp);
return handler->acceptURL(url); return handler && handler->acceptURL(url);
} }
}; };

View file

@ -61,7 +61,7 @@ void RequestFilters::interceptHFWebEngineRequest(QWebEngineUrlRequestInfo& info)
// During the period in which we have HFC commerce in the system, but not applied everywhere: // During the period in which we have HFC commerce in the system, but not applied everywhere:
const QString tokenStringCommerce{ "Chrome/48.0 (HighFidelityInterface WithHFC)" }; const QString tokenStringCommerce{ "Chrome/48.0 (HighFidelityInterface WithHFC)" };
static Setting::Handle<bool> _settingSwitch{ "inspectionMode", false }; static Setting::Handle<bool> _settingSwitch{ "commerce", false };
bool isMoney = _settingSwitch.get(); bool isMoney = _settingSwitch.get();
const QString tokenString = !isAuthable ? tokenStringMobile : (isMoney ? tokenStringCommerce : tokenStringMetaverse); const QString tokenString = !isAuthable ? tokenStringMobile : (isMoney ? tokenStringCommerce : tokenStringMetaverse);

View file

@ -131,7 +131,7 @@
var button; var button;
var buttonName = "WALLET"; var buttonName = "WALLET";
var tablet = null; var tablet = null;
var walletEnabled = Settings.getValue("inspectionMode", false); var walletEnabled = Settings.getValue("commerce", false);
function startup() { function startup() {
if (walletEnabled) { if (walletEnabled) {
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");

View file

@ -148,7 +148,9 @@ Script.include("/~/system/libraries/controllers.js");
if (mode === "full") { if (mode === "full") {
var fullEndToEdit = PICK_WITH_HAND_RAY ? this.fullEnd : fullEnd; var fullEndToEdit = PICK_WITH_HAND_RAY ? this.fullEnd : fullEnd;
fullEndToEdit.dimensions = dim; fullEndToEdit.dimensions = dim;
LaserPointers.editRenderState(laserPointerID, mode, {path: fullPath, end: fullEndToEdit}); LaserPointers.editRenderState(laserPointerID, mode, { path: fullPath, end: fullEndToEdit });
this.contextOverlayTimer = false;
this.destroyContextOverlay();
} else if (mode === "half") { } else if (mode === "half") {
var halfEndToEdit = PICK_WITH_HAND_RAY ? this.halfEnd : halfEnd; var halfEndToEdit = PICK_WITH_HAND_RAY ? this.halfEnd : halfEnd;
halfEndToEdit.dimensions = dim; halfEndToEdit.dimensions = dim;

View file

@ -298,6 +298,9 @@ Script.include("/~/system/libraries/controllers.js");
var intersection = controllerData.rayPicks[this.hand]; var intersection = controllerData.rayPicks[this.hand];
var offOverlay = (intersection.type !== RayPick.INTERSECTED_OVERLAY); var offOverlay = (intersection.type !== RayPick.INTERSECTED_OVERLAY);
var triggerOff = (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE); var triggerOff = (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE);
if (triggerOff) {
this.deleteContextOverlay();
}
var grabbingOverlay = this.grabModuleWantsNearbyOverlay(controllerData); var grabbingOverlay = this.grabModuleWantsNearbyOverlay(controllerData);
return offOverlay || grabbingOverlay || triggerOff; return offOverlay || grabbingOverlay || triggerOff;
}; };
@ -308,7 +311,6 @@ Script.include("/~/system/libraries/controllers.js");
this.laserPressExit(); this.laserPressExit();
this.laserPressingTarget = false; this.laserPressingTarget = false;
} }
this.deleteContextOverlay();
this.relinquishTouchFocus(); this.relinquishTouchFocus();
this.reset(); this.reset();
this.updateLaserPointer(); this.updateLaserPointer();

View file

@ -450,7 +450,7 @@
var parsedJsonMessage = JSON.parse(message); var parsedJsonMessage = JSON.parse(message);
if (parsedJsonMessage.type === "marketplaces") { if (parsedJsonMessage.type === "marketplaces") {
if (parsedJsonMessage.action === "inspectionModeSetting") { if (parsedJsonMessage.action === "commerceSetting") {
confirmAllPurchases = !!parsedJsonMessage.data; confirmAllPurchases = !!parsedJsonMessage.data;
injectCode(); injectCode();
} }
@ -458,7 +458,7 @@
} }
}); });
// Request inspection mode setting // Request commerce setting
// Code is injected into the webpage after the setting comes back. // Code is injected into the webpage after the setting comes back.
EventBridge.emitWebEvent(JSON.stringify({ EventBridge.emitWebEvent(JSON.stringify({
type: "REQUEST_SETTING" type: "REQUEST_SETTING"

View file

@ -138,8 +138,8 @@
} else if (parsedJsonMessage.type === "REQUEST_SETTING") { } else if (parsedJsonMessage.type === "REQUEST_SETTING") {
tablet.emitScriptEvent(JSON.stringify({ tablet.emitScriptEvent(JSON.stringify({
type: "marketplaces", type: "marketplaces",
action: "inspectionModeSetting", action: "commerceSetting",
data: Settings.getValue("inspectionMode", false) data: Settings.getValue("commerce", false)
})); }));
} else if (parsedJsonMessage.type === "PURCHASES") { } else if (parsedJsonMessage.type === "PURCHASES") {
tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH); tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH);

View file

@ -12,7 +12,7 @@ setup_hifi_project(Quick Gui OpenGL)
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
# link in the shared libraries # link in the shared libraries
link_hifi_libraries(shared networking model fbx ktx image octree gl gpu gpu-gl render model-networking networking render-utils entities entities-renderer animation audio avatars script-engine physics procedural midi) link_hifi_libraries(shared networking model fbx ktx image octree gl gpu gpu-gl render model-networking networking render-utils entities entities-renderer animation audio avatars script-engine physics procedural midi ui)
package_libraries_for_deployment() package_libraries_for_deployment()

View file

@ -42,11 +42,15 @@
#include <LogHandler.h> #include <LogHandler.h>
#include <AssetClient.h> #include <AssetClient.h>
#include <gl/OffscreenGLCanvas.h>
#include <gpu/gl/GLBackend.h> #include <gpu/gl/GLBackend.h>
#include <gpu/gl/GLFramebuffer.h> #include <gpu/gl/GLFramebuffer.h>
#include <gpu/gl/GLTexture.h> #include <gpu/gl/GLTexture.h>
#include <gpu/StandardShaderLib.h> #include <gpu/StandardShaderLib.h>
#include <ui/OffscreenQmlSurface.h>
#include <AnimationCache.h> #include <AnimationCache.h>
#include <SimpleEntitySimulation.h> #include <SimpleEntitySimulation.h>
#include <EntityDynamicInterface.h> #include <EntityDynamicInterface.h>
@ -427,6 +431,10 @@ namespace render {
} }
} }
OffscreenGLCanvas* _chromiumShareContext{ nullptr };
Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
// Create a simple OpenGL window that renders text in various ways // Create a simple OpenGL window that renders text in various ways
class QTestWindow : public QWindow, public AbstractViewStateInterface { class QTestWindow : public QWindow, public AbstractViewStateInterface {
@ -506,8 +514,6 @@ public:
AbstractViewStateInterface::setInstance(this); AbstractViewStateInterface::setInstance(this);
_octree = DependencyManager::set<EntityTreeRenderer>(false, this, nullptr); _octree = DependencyManager::set<EntityTreeRenderer>(false, this, nullptr);
_octree->init(); _octree->init();
// Prevent web entities from rendering
REGISTER_ENTITY_TYPE_WITH_FACTORY(Web, WebEntityItem::factory);
DependencyManager::set<ParentFinder>(_octree->getTree()); DependencyManager::set<ParentFinder>(_octree->getTree());
auto nodeList = DependencyManager::get<LimitedNodeList>(); auto nodeList = DependencyManager::get<LimitedNodeList>();
@ -535,6 +541,23 @@ public:
_renderThread.initialize(this, _initContext); _renderThread.initialize(this, _initContext);
_initContext.makeCurrent(); _initContext.makeCurrent();
if (nsightActive()) {
// Prevent web entities from rendering
REGISTER_ENTITY_TYPE_WITH_FACTORY(Web, WebEntityItem::factory);
} else {
_chromiumShareContext = new OffscreenGLCanvas();
_chromiumShareContext->setObjectName("ChromiumShareContext");
_chromiumShareContext->create(_initContext.qglContext());
_chromiumShareContext->makeCurrent();
qt_gl_set_global_share_context(_chromiumShareContext->getContext());
// Make sure all QML surfaces share the main thread GL context
OffscreenQmlSurface::setSharedContext(_initContext.qglContext());
_initContext.makeCurrent();
}
// FIXME use a wait condition // FIXME use a wait condition
QThread::msleep(1000); QThread::msleep(1000);
_renderThread.submitFrame(gpu::FramePointer()); _renderThread.submitFrame(gpu::FramePointer());
@ -679,6 +702,7 @@ private:
_renderCount = _renderThread._presentCount.load(); _renderCount = _renderThread._presentCount.load();
update(); update();
_initContext.makeCurrent();
RenderArgs renderArgs(_renderThread._gpuContext, DEFAULT_OCTREE_SIZE_SCALE, RenderArgs renderArgs(_renderThread._gpuContext, DEFAULT_OCTREE_SIZE_SCALE,
0, RenderArgs::DEFAULT_RENDER_MODE, 0, RenderArgs::DEFAULT_RENDER_MODE,
RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE); RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);