From 45ec7fe3e115b85dbcd4c6bd2b4dd4df09c81063 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 9 Jan 2019 12:03:35 -0800 Subject: [PATCH] working on ignorePickIntersection and web entities --- libraries/entities/src/EntityItem.cpp | 17 +++++ libraries/entities/src/EntityItem.h | 4 + .../entities/src/EntityItemProperties.cpp | 74 +++++++++++++++++++ libraries/entities/src/EntityItemProperties.h | 26 ++++--- libraries/entities/src/EntityPropertyFlags.h | 4 + libraries/entities/src/EntityTree.cpp | 3 +- libraries/entities/src/EntityTreeElement.cpp | 8 ++ libraries/entities/src/WebEntityItem.cpp | 3 +- libraries/entities/src/WebEntityItem.h | 5 +- libraries/octree/src/OctreePacketData.h | 2 + libraries/shared/src/WebInputMode.cpp | 25 +++++++ libraries/shared/src/WebInputMode.h | 39 ++++++++++ 12 files changed, 196 insertions(+), 14 deletions(-) create mode 100644 libraries/shared/src/WebInputMode.cpp create mode 100644 libraries/shared/src/WebInputMode.h diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index e0749af4ba..90fc1b18e4 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -97,6 +97,7 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param // requestedProperties += PROP_VISIBLE_IN_SECONDARY_CAMERA; // not sent over the wire requestedProperties += PROP_RENDER_LAYER; requestedProperties += PROP_PRIMITIVE_MODE; + requestedProperties += PROP_IGNORE_PICK_INTERSECTION; withReadLock([&] { requestedProperties += _grabProperties.getEntityProperties(params); }); @@ -280,6 +281,7 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet // APPEND_ENTITY_PROPERTY(PROP_VISIBLE_IN_SECONDARY_CAMERA, getIsVisibleInSecondaryCamera()); // not sent over the wire APPEND_ENTITY_PROPERTY(PROP_RENDER_LAYER, (uint32_t)getRenderLayer()); APPEND_ENTITY_PROPERTY(PROP_PRIMITIVE_MODE, (uint32_t)getPrimitiveMode()); + APPEND_ENTITY_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, getIgnorePickIntersection()); withReadLock([&] { _grabProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties, propertyFlags, propertiesDidntFit, propertyCount, appendState); @@ -845,6 +847,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef // READ_ENTITY_PROPERTY(PROP_VISIBLE_IN_SECONDARY_CAMERA, bool, setIsVisibleInSecondaryCamera); // not sent over the wire READ_ENTITY_PROPERTY(PROP_RENDER_LAYER, RenderLayer, setRenderLayer); READ_ENTITY_PROPERTY(PROP_PRIMITIVE_MODE, PrimitiveMode, setPrimitiveMode); + READ_ENTITY_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, bool, setIgnorePickIntersection); withWriteLock([&] { int bytesFromGrab = _grabProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData, @@ -1318,6 +1321,7 @@ EntityItemProperties EntityItem::getProperties(const EntityPropertyFlags& desire COPY_ENTITY_PROPERTY_TO_PROPERTIES(isVisibleInSecondaryCamera, isVisibleInSecondaryCamera); COPY_ENTITY_PROPERTY_TO_PROPERTIES(renderLayer, getRenderLayer); COPY_ENTITY_PROPERTY_TO_PROPERTIES(primitiveMode, getPrimitiveMode); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(ignorePickIntersection, getIgnorePickIntersection); withReadLock([&] { _grabProperties.getProperties(properties); }); @@ -1464,6 +1468,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(isVisibleInSecondaryCamera, setIsVisibleInSecondaryCamera); SET_ENTITY_PROPERTY_FROM_PROPERTIES(renderLayer, setRenderLayer); SET_ENTITY_PROPERTY_FROM_PROPERTIES(primitiveMode, setPrimitiveMode); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(ignorePickIntersection, setIgnorePickIntersection); withWriteLock([&] { bool grabPropertiesChanged = _grabProperties.setProperties(properties); somethingChanged |= grabPropertiesChanged; @@ -2981,6 +2986,18 @@ void EntityItem::setPrimitiveMode(PrimitiveMode value) { } } +bool EntityItem::getIgnorePickIntersection() const { + return resultWithReadLock([&] { + return _ignorePickIntersection; + }); +} + +void EntityItem::setIgnorePickIntersection(bool value) { + withWriteLock([&] { + _ignorePickIntersection = value; + }); +} + bool EntityItem::getCanCastShadow() const { bool result; withReadLock([&] { diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index cac4192cd5..ec7ad78313 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -299,6 +299,9 @@ public: PrimitiveMode getPrimitiveMode() const; void setPrimitiveMode(PrimitiveMode value); + bool getIgnorePickIntersection() const; + void setIgnorePickIntersection(bool value); + bool getCanCastShadow() const; void setCanCastShadow(bool value); @@ -630,6 +633,7 @@ protected: RenderLayer _renderLayer { RenderLayer::WORLD }; PrimitiveMode _primitiveMode { PrimitiveMode::SOLID }; bool _canCastShadow{ ENTITY_ITEM_DEFAULT_CAN_CAST_SHADOW }; + bool _ignorePickIntersection { false }; bool _collisionless { ENTITY_ITEM_DEFAULT_COLLISIONLESS }; uint16_t _collisionMask { ENTITY_COLLISION_MASK_DEFAULT }; bool _dynamic { ENTITY_ITEM_DEFAULT_DYNAMIC }; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 194ba22b05..3ae3a647cf 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -393,6 +393,32 @@ void EntityItemProperties::setPrimitiveModeFromString(const QString& primitiveMo } } +QHash stringToWebInputModeLookup; + +void addWebInputMode(WebInputMode mode) { + stringToWebInputModeLookup[WebInputModeHelpers::getNameForWebInputMode(mode)] = mode; +} + +void buildStringToWebInputModeLookup() { + addWebInputMode(WebInputMode::TOUCH); + addWebInputMode(WebInputMode::MOUSE); +} + +QString EntityItemProperties::getInputModeAsString() const { + return WebInputModeHelpers::getNameForWebInputMode(_inputMode); +} + +void EntityItemProperties::setInputModeFromString(const QString& webInputMode) { + if (stringToWebInputModeLookup.empty()) { + buildStringToWebInputModeLookup(); + } + auto webInputModeItr = stringToWebInputModeLookup.find(webInputMode.toLower()); + if (webInputModeItr != stringToWebInputModeLookup.end()) { + _inputMode = webInputModeItr.value(); + _inputModeChanged = true; + } +} + EntityPropertyFlags EntityItemProperties::getChangedProperties() const { EntityPropertyFlags changedProperties; @@ -419,6 +445,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_VISIBLE_IN_SECONDARY_CAMERA, isVisibleInSecondaryCamera); CHECK_PROPERTY_CHANGE(PROP_RENDER_LAYER, renderLayer); CHECK_PROPERTY_CHANGE(PROP_PRIMITIVE_MODE, primitiveMode); + CHECK_PROPERTY_CHANGE(PROP_IGNORE_PICK_INTERSECTION, ignorePickIntersection); changedProperties += _grab.getChangedProperties(); // Physics @@ -573,6 +600,9 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { // Web CHECK_PROPERTY_CHANGE(PROP_SOURCE_URL, sourceUrl); CHECK_PROPERTY_CHANGE(PROP_DPI, dpi); + CHECK_PROPERTY_CHANGE(PROP_SCRIPT_URL, scriptURL); + CHECK_PROPERTY_CHANGE(PROP_MAX_FPS, maxFPS); + CHECK_PROPERTY_CHANGE(PROP_INPUT_MODE, inputMode); // Polyline CHECK_PROPERTY_CHANGE(PROP_LINE_POINTS, linePoints); @@ -658,6 +688,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { * @property {boolean} isVisibleInSecondaryCamera=true - Whether or not the entity is rendered in the secondary camera. If true then the entity is rendered. * @property {RenderLayer} renderLayer="world" - In which layer this entity renders. * @property {PrimitiveMode} primitiveMode="solid" - How this entity's geometry is rendered. + * @property {boolean} ignorePickIntersection=false - If true, picks ignore the entity. * * @property {Vec3} position=0,0,0 - The position of the entity. * @property {Quat} rotation=0,0,0,1 - The orientation of the entity with respect to world coordinates. @@ -1259,6 +1290,9 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { * @property {number} dpi=30 - The resolution to display the page at, in dots per inch. If you convert this to dots per meter * (multiply by 1 / 0.0254 = 39.3701) then multiply dimensions.x and dimensions.y by that value * you get the resolution in pixels. + * @property {string} scriptURL="" - The URL of a JavaScript file to inject into the Web page. + * @property {number} maxFPS=10 - The maximum update rate for the Web content, in frames/second. + * @property {WebInputMode} inputMode="touch" - The user input mode to use. * @example Create a Web entity displaying at 1920 x 1080 resolution. * var METERS_TO_INCHES = 39.3701; * var entity = Entities.addEntity({ @@ -1467,6 +1501,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_VISIBLE_IN_SECONDARY_CAMERA, isVisibleInSecondaryCamera); COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_RENDER_LAYER, renderLayer, getRenderLayerAsString()); COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_PRIMITIVE_MODE, primitiveMode, getPrimitiveModeAsString()); + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_IGNORE_PICK_INTERSECTION, ignorePickIntersection); _grab.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); // Physics @@ -1656,6 +1691,9 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool if (_type == EntityTypes::Web) { COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SOURCE_URL, sourceUrl); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_DPI, dpi); + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SCRIPT_URL, scriptURL); + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_MAX_FPS, maxFPS); + COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_INPUT_MODE, inputMode, getInputModeAsString()); } // PolyVoxel only @@ -1851,6 +1889,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(isVisibleInSecondaryCamera, bool, setIsVisibleInSecondaryCamera); COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(renderLayer, RenderLayer); COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(primitiveMode, PrimitiveMode); + COPY_PROPERTY_FROM_QSCRIPTVALUE(ignorePickIntersection, bool, setIgnorePickIntersection); _grab.copyFromScriptValue(object, _defaultSettings); // Physics @@ -2010,6 +2049,9 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool // Web COPY_PROPERTY_FROM_QSCRIPTVALUE(sourceUrl, QString, setSourceUrl); COPY_PROPERTY_FROM_QSCRIPTVALUE(dpi, uint16_t, setDPI); + COPY_PROPERTY_FROM_QSCRIPTVALUE(scriptURL, QString, setScriptURL); + COPY_PROPERTY_FROM_QSCRIPTVALUE(maxFPS, uint8_t, setMaxFPS); + COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(inputMode, InputMode); // Polyline COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints); @@ -2113,6 +2155,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) { COPY_PROPERTY_IF_CHANGED(isVisibleInSecondaryCamera); COPY_PROPERTY_IF_CHANGED(renderLayer); COPY_PROPERTY_IF_CHANGED(primitiveMode); + COPY_PROPERTY_IF_CHANGED(ignorePickIntersection); _grab.merge(other._grab); // Physics @@ -2267,6 +2310,9 @@ void EntityItemProperties::merge(const EntityItemProperties& other) { // Web COPY_PROPERTY_IF_CHANGED(sourceUrl); COPY_PROPERTY_IF_CHANGED(dpi); + COPY_PROPERTY_IF_CHANGED(scriptURL); + COPY_PROPERTY_IF_CHANGED(maxFPS); + COPY_PROPERTY_IF_CHANGED(inputMode); // Polyline COPY_PROPERTY_IF_CHANGED(linePoints); @@ -2387,6 +2433,7 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr ADD_PROPERTY_TO_MAP(PROP_VISIBLE_IN_SECONDARY_CAMERA, IsVisibleInSecondaryCamera, isVisibleInSecondaryCamera, bool); ADD_PROPERTY_TO_MAP(PROP_RENDER_LAYER, RenderLayer, renderLayer, RenderLayer); ADD_PROPERTY_TO_MAP(PROP_PRIMITIVE_MODE, PrimitiveMode, primitiveMode, PrimitiveMode); + ADD_PROPERTY_TO_MAP(PROP_IGNORE_PICK_INTERSECTION, IgnorePickIntersection, ignorePickIntersection, bool); { // Grab ADD_GROUP_PROPERTY_TO_MAP(PROP_GRAB_GRABBABLE, Grab, grab, Grabbable, grabbable); ADD_GROUP_PROPERTY_TO_MAP(PROP_GRAB_KINEMATIC, Grab, grab, GrabKinematic, grabKinematic); @@ -2637,6 +2684,9 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr // Web ADD_PROPERTY_TO_MAP(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString); ADD_PROPERTY_TO_MAP(PROP_DPI, DPI, dpi, uint16_t); + ADD_PROPERTY_TO_MAP(PROP_SCRIPT_URL, ScriptURL, scriptURL, QString); + ADD_PROPERTY_TO_MAP(PROP_MAX_FPS, MaxFPS, maxFPS, uint8_t); + ADD_PROPERTY_TO_MAP(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode); // Polyline ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector); @@ -2819,6 +2869,7 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy // APPEND_ENTITY_PROPERTY(PROP_VISIBLE_IN_SECONDARY_CAMERA, properties.getIsVisibleInSecondaryCamera()); // not sent over the wire APPEND_ENTITY_PROPERTY(PROP_RENDER_LAYER, (uint32_t)properties.getRenderLayer()); APPEND_ENTITY_PROPERTY(PROP_PRIMITIVE_MODE, (uint32_t)properties.getPrimitiveMode()); + APPEND_ENTITY_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, properties.getIgnorePickIntersection()); _staticGrab.setProperties(properties); _staticGrab.appendToEditPacket(packetData, requestedProperties, propertyFlags, propertiesDidntFit, propertyCount, appendState); @@ -3002,6 +3053,9 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy if (properties.getType() == EntityTypes::Web) { APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, properties.getSourceUrl()); APPEND_ENTITY_PROPERTY(PROP_DPI, properties.getDPI()); + APPEND_ENTITY_PROPERTY(PROP_SCRIPT_URL, properties.getScriptURL()); + APPEND_ENTITY_PROPERTY(PROP_MAX_FPS, properties.getMaxFPS()); + APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)properties.getInputMode()); } if (properties.getType() == EntityTypes::Line) { @@ -3263,6 +3317,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int // READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_VISIBLE_IN_SECONDARY_CAMERA, bool, setIsVisibleInSecondaryCamera); // not sent over the wire READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_RENDER_LAYER, RenderLayer, setRenderLayer); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_PRIMITIVE_MODE, PrimitiveMode, setPrimitiveMode); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_IGNORE_PICK_INTERSECTION, bool, setIgnorePickIntersection); properties.getGrab().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); // Physics @@ -3435,6 +3490,9 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int if (properties.getType() == EntityTypes::Web) { READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SOURCE_URL, QString, setSourceUrl); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_DPI, uint16_t, setDPI); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SCRIPT_URL, QString, setScriptURL); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MAX_FPS, uint8_t, setMaxFPS); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_INPUT_MODE, WebInputMode, setInputMode); } if (properties.getType() == EntityTypes::Line) { @@ -3648,6 +3706,7 @@ void EntityItemProperties::markAllChanged() { _isVisibleInSecondaryCameraChanged = true; _renderLayerChanged = true; _primitiveModeChanged = true; + _ignorePickIntersectionChanged = true; _grab.markAllChanged(); // Physics @@ -3795,6 +3854,9 @@ void EntityItemProperties::markAllChanged() { // Web _sourceUrlChanged = true; _dpiChanged = true; + _scriptURLChanged = true; + _maxFPSChanged = true; + _inputModeChanged = true; // Polyline _linePointsChanged = true; @@ -4027,6 +4089,9 @@ QList EntityItemProperties::listChangedProperties() { if (primitiveModeChanged()) { out += "primitiveMode"; } + if (ignorePickIntersectionChanged()) { + out += "ignorePickIntersection"; + } getGrab().listChangedProperties(out); // Physics @@ -4406,6 +4471,15 @@ QList EntityItemProperties::listChangedProperties() { if (dpiChanged()) { out += "dpi"; } + if (scriptURLChanged()) { + out += "scriptURL"; + } + if (maxFPSChanged()) { + out += "maxFPS"; + } + if (inputModeChanged()) { + out += "inputMode"; + } // Polyline if (linePointsChanged()) { diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 89cc87b8df..92df22183a 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -30,29 +30,33 @@ #include #include -#include "AnimationPropertyGroup.h" #include "EntityItemID.h" #include "EntityItemPropertiesDefaults.h" #include "EntityItemPropertiesMacros.h" #include "EntityTypes.h" #include "EntityPropertyFlags.h" #include "EntityPsuedoPropertyFlags.h" -#include "LightEntityItem.h" -#include "LineEntityItem.h" -#include "ParticleEffectEntityItem.h" -#include "PolyVoxEntityItem.h" #include "SimulationOwner.h" + +#include "TextEntityItem.h" +#include "WebEntityItem.h" +#include "ParticleEffectEntityItem.h" +#include "LineEntityItem.h" +#include "PolyVoxEntityItem.h" +#include "GridEntityItem.h" +#include "LightEntityItem.h" +#include "ZoneEntityItem.h" + +#include "AnimationPropertyGroup.h" #include "SkyboxPropertyGroup.h" #include "HazePropertyGroup.h" #include "BloomPropertyGroup.h" -#include "TextEntityItem.h" -#include "ZoneEntityItem.h" -#include "GridEntityItem.h" #include "MaterialMappingMode.h" #include "BillboardMode.h" #include "RenderLayer.h" #include "PrimitiveMode.h" +#include "WebInputMode.h" const quint64 UNKNOWN_CREATED_TIME = 0; @@ -167,6 +171,7 @@ public: DEFINE_PROPERTY(PROP_VISIBLE_IN_SECONDARY_CAMERA, IsVisibleInSecondaryCamera, isVisibleInSecondaryCamera, bool, ENTITY_ITEM_DEFAULT_VISIBLE_IN_SECONDARY_CAMERA); DEFINE_PROPERTY_REF_ENUM(PROP_RENDER_LAYER, RenderLayer, renderLayer, RenderLayer, RenderLayer::WORLD); DEFINE_PROPERTY_REF_ENUM(PROP_PRIMITIVE_MODE, PrimitiveMode, primitiveMode, PrimitiveMode, PrimitiveMode::SOLID); + DEFINE_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, IgnorePickIntersection, ignorePickIntersection, bool, false); DEFINE_PROPERTY_GROUP(Grab, grab, GrabPropertyGroup); // Physics @@ -319,8 +324,11 @@ public: DEFINE_PROPERTY_REF(PROP_Z_P_NEIGHBOR_ID, ZPNeighborID, zPNeighborID, EntityItemID, UNKNOWN_ENTITY_ID); // Web - DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString, ""); + DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString, WebEntityItem::DEFAULT_SOURCE_URL); DEFINE_PROPERTY_REF(PROP_DPI, DPI, dpi, uint16_t, ENTITY_ITEM_DEFAULT_DPI); + DEFINE_PROPERTY_REF(PROP_SCRIPT_URL, ScriptURL, scriptURL, QString, ""); + DEFINE_PROPERTY_REF(PROP_MAX_FPS, MaxFPS, maxFPS, uint8_t, WebEntityItem::DEFAULT_MAX_FPS); + DEFINE_PROPERTY_REF_ENUM(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode, WebInputMode::TOUCH); // Polyline DEFINE_PROPERTY_REF(PROP_LINE_POINTS, LinePoints, linePoints, QVector, ENTITY_ITEM_DEFAULT_EMPTY_VEC3_QVEC); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index a3d0d937cb..5c136c4820 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -41,6 +41,7 @@ enum EntityPropertyList { PROP_VISIBLE_IN_SECONDARY_CAMERA, // not sent over the wire PROP_RENDER_LAYER, PROP_PRIMITIVE_MODE, + PROP_IGNORE_PICK_INTERSECTION, // Grab PROP_GRAB_GRABBABLE, PROP_GRAB_KINEMATIC, @@ -287,6 +288,9 @@ enum EntityPropertyList { // Web PROP_SOURCE_URL = PROP_DERIVED_0, PROP_DPI = PROP_DERIVED_1, + PROP_SCRIPT_URL = PROP_DERIVED_2, + PROP_MAX_FPS = PROP_DERIVED_3, + PROP_INPUT_MODE = PROP_DERIVED_4, // Polyline PROP_LINE_POINTS = PROP_DERIVED_0, diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 0957b226e9..3f04850710 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -2669,7 +2669,6 @@ void convertGrabUserDataToProperties(EntityItemProperties& properties) { bool EntityTree::readFromMap(QVariantMap& map) { // These are needed to deal with older content (before adding inheritance modes) int contentVersion = map["Version"].toInt(); - bool needsConversion = (contentVersion < (int)EntityVersion::ZoneLightInheritModes); if (map.contains("Id")) { _persistID = map["Id"].toUuid(); @@ -2744,7 +2743,7 @@ bool EntityTree::readFromMap(QVariantMap& map) { } // Fix for older content not containing mode fields in the zones - if (needsConversion && (properties.getType() == EntityTypes::EntityType::Zone)) { + if (contentVersion < (int)EntityVersion::ZoneLightInheritModes && (properties.getType() == EntityTypes::EntityType::Zone)) { // The legacy version had no keylight mode - this is set to on properties.setKeyLightMode(COMPONENT_MODE_ENABLED); diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index 2ece6835ea..22bddaa1c6 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -187,6 +187,10 @@ EntityItemID EntityTreeElement::evalDetailedRayIntersection(const glm::vec3& ori // only called if we do intersect our bounding cube, but find if we actually intersect with entities... EntityItemID entityID; forEachEntity([&](EntityItemPointer entity) { + if (entity->getIgnorePickIntersection()) { + return; + } + // use simple line-sphere for broadphase check // (this is faster and more likely to cull results than the filter check below so we do it first) bool success; @@ -327,6 +331,10 @@ EntityItemID EntityTreeElement::evalDetailedParabolaIntersection(const glm::vec3 // only called if we do intersect our bounding cube, but find if we actually intersect with entities... EntityItemID entityID; forEachEntity([&](EntityItemPointer entity) { + if (entity->getIgnorePickIntersection()) { + return; + } + // use simple line-sphere for broadphase check // (this is faster and more likely to cull results than the filter check below so we do it first) bool success; diff --git a/libraries/entities/src/WebEntityItem.cpp b/libraries/entities/src/WebEntityItem.cpp index d20d36cd71..38ecbb03df 100644 --- a/libraries/entities/src/WebEntityItem.cpp +++ b/libraries/entities/src/WebEntityItem.cpp @@ -21,7 +21,8 @@ #include "EntityTree.h" #include "EntityTreeElement.h" -const QString WebEntityItem::DEFAULT_SOURCE_URL("http://www.google.com"); +const QString WebEntityItem::DEFAULT_SOURCE_URL = "http://www.google.com"; +const uint8_t WebEntityItem::DEFAULT_MAX_FPS = 10; EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer entity(new WebEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); diff --git a/libraries/entities/src/WebEntityItem.h b/libraries/entities/src/WebEntityItem.h index 10d06e6f4a..f1d1bbb313 100644 --- a/libraries/entities/src/WebEntityItem.h +++ b/libraries/entities/src/WebEntityItem.h @@ -13,8 +13,6 @@ class WebEntityItem : public EntityItem { public: - static const QString DEFAULT_SOURCE_URL; - static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties); WebEntityItem(const EntityItemID& entityItemID); @@ -54,12 +52,15 @@ public: BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo, bool precisionPicking) const override; + static const QString DEFAULT_SOURCE_URL; virtual void setSourceUrl(const QString& value); QString getSourceUrl() const; void setDPI(uint16_t value); uint16_t getDPI() const; + static const uint8_t DEFAULT_MAX_FPS; + protected: QString _sourceUrl; uint16_t _dpi; diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index debc6786f1..1dbb564fe9 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -37,6 +37,7 @@ #include "BillboardMode.h" #include "RenderLayer.h" #include "PrimitiveMode.h" +#include "WebInputMode.h" #include "OctreeConstants.h" #include "OctreeElement.h" @@ -267,6 +268,7 @@ public: static int unpackDataFromBytes(const unsigned char* dataBytes, BillboardMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, RenderLayer& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, PrimitiveMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } + static int unpackDataFromBytes(const unsigned char* dataBytes, WebInputMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, glm::vec2& result); static int unpackDataFromBytes(const unsigned char* dataBytes, glm::vec3& result); static int unpackDataFromBytes(const unsigned char* dataBytes, glm::u8vec3& result); diff --git a/libraries/shared/src/WebInputMode.cpp b/libraries/shared/src/WebInputMode.cpp new file mode 100644 index 0000000000..7b480424dc --- /dev/null +++ b/libraries/shared/src/WebInputMode.cpp @@ -0,0 +1,25 @@ +// +// Created by Sam Gondelman on 1/9/19 +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "WebInputMode.h" + +const char* webInputModeNames[] = { + "none", + "yaw", + "full" +}; + +static const size_t WEB_INPUT_MODE_NAMES = (sizeof(webInputModeNames) / sizeof(webInputModeNames[0])); + +QString WebInputModeHelpers::getNameForWebInputMode(WebInputMode mode) { + if (((int)mode <= 0) || ((int)mode >= (int)WEB_INPUT_MODE_NAMES)) { + mode = (WebInputMode)0; + } + + return webInputModeNames[(int)mode]; +} \ No newline at end of file diff --git a/libraries/shared/src/WebInputMode.h b/libraries/shared/src/WebInputMode.h new file mode 100644 index 0000000000..d97ccef519 --- /dev/null +++ b/libraries/shared/src/WebInputMode.h @@ -0,0 +1,39 @@ +// +// Created by Sam Gondelman on 1/9/19. +// Copyright 2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_WebInputMode_h +#define hifi_WebInputMode_h + +#include "QString" + +/**jsdoc + *

Controls how the web surface processed PointerEvents

+ * + * + * + * + * + * + * + * + *
ValueDescription
touchEvents are processed as touch events.
mouseEvents are processed as mouse events.
+ * @typedef {string} WebInputMode + */ + +enum class WebInputMode { + TOUCH = 0, + MOUSE, +}; + +class WebInputModeHelpers { +public: + static QString getNameForWebInputMode(WebInputMode mode); +}; + +#endif // hifi_WebInputMode_h +