mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 00:36:47 +02:00
Added dpi entity property for web-entities
This commit is contained in:
parent
6704ae9ad4
commit
31ed378dbf
9 changed files with 43 additions and 26 deletions
|
@ -335,6 +335,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
CHECK_PROPERTY_CHANGE(PROP_OWNING_AVATAR_ID, owningAvatarID);
|
CHECK_PROPERTY_CHANGE(PROP_OWNING_AVATAR_ID, owningAvatarID);
|
||||||
|
|
||||||
CHECK_PROPERTY_CHANGE(PROP_SHAPE, shape);
|
CHECK_PROPERTY_CHANGE(PROP_SHAPE, shape);
|
||||||
|
CHECK_PROPERTY_CHANGE(PROP_DPI, dpi);
|
||||||
|
|
||||||
changedProperties += _animation.getChangedProperties();
|
changedProperties += _animation.getChangedProperties();
|
||||||
changedProperties += _keyLight.getChangedProperties();
|
changedProperties += _keyLight.getChangedProperties();
|
||||||
|
@ -504,6 +505,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
// Web only
|
// Web only
|
||||||
if (_type == EntityTypes::Web) {
|
if (_type == EntityTypes::Web) {
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SOURCE_URL, sourceUrl);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SOURCE_URL, sourceUrl);
|
||||||
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_DPI, dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PolyVoxel only
|
// PolyVoxel only
|
||||||
|
@ -726,6 +728,8 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(clientOnly, bool, setClientOnly);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(clientOnly, bool, setClientOnly);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(owningAvatarID, QUuid, setOwningAvatarID);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(owningAvatarID, QUuid, setOwningAvatarID);
|
||||||
|
|
||||||
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(dpi, uint16_t, setDPI);
|
||||||
|
|
||||||
_lastEdited = usecTimestampNow();
|
_lastEdited = usecTimestampNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,6 +907,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
|
||||||
ADD_PROPERTY_TO_MAP(PROP_FLYING_ALLOWED, FlyingAllowed, flyingAllowed, bool);
|
ADD_PROPERTY_TO_MAP(PROP_FLYING_ALLOWED, FlyingAllowed, flyingAllowed, bool);
|
||||||
ADD_PROPERTY_TO_MAP(PROP_GHOSTING_ALLOWED, GhostingAllowed, ghostingAllowed, bool);
|
ADD_PROPERTY_TO_MAP(PROP_GHOSTING_ALLOWED, GhostingAllowed, ghostingAllowed, bool);
|
||||||
|
|
||||||
|
ADD_PROPERTY_TO_MAP(PROP_DPI, DPI, dpi, uint16_t);
|
||||||
|
|
||||||
// FIXME - these are not yet handled
|
// FIXME - these are not yet handled
|
||||||
//ADD_PROPERTY_TO_MAP(PROP_CREATED, Created, created, quint64);
|
//ADD_PROPERTY_TO_MAP(PROP_CREATED, Created, created, quint64);
|
||||||
|
|
||||||
|
@ -1065,6 +1071,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
|
||||||
|
|
||||||
if (properties.getType() == EntityTypes::Web) {
|
if (properties.getType() == EntityTypes::Web) {
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, properties.getSourceUrl());
|
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, properties.getSourceUrl());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_DPI, properties.getDPI());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.getType() == EntityTypes::Text) {
|
if (properties.getType() == EntityTypes::Text) {
|
||||||
|
@ -1364,6 +1371,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
||||||
|
|
||||||
if (properties.getType() == EntityTypes::Web) {
|
if (properties.getType() == EntityTypes::Web) {
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SOURCE_URL, QString, setSourceUrl);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SOURCE_URL, QString, setSourceUrl);
|
||||||
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_DPI, uint16_t, setDPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.getType() == EntityTypes::Text) {
|
if (properties.getType() == EntityTypes::Text) {
|
||||||
|
@ -1642,6 +1650,8 @@ void EntityItemProperties::markAllChanged() {
|
||||||
|
|
||||||
_clientOnlyChanged = true;
|
_clientOnlyChanged = true;
|
||||||
_owningAvatarIDChanged = true;
|
_owningAvatarIDChanged = true;
|
||||||
|
|
||||||
|
_dpiChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The minimum bounding box for the entity.
|
// The minimum bounding box for the entity.
|
||||||
|
@ -1977,6 +1987,10 @@ QList<QString> EntityItemProperties::listChangedProperties() {
|
||||||
out += "ghostingAllowed";
|
out += "ghostingAllowed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dpiChanged()) {
|
||||||
|
out += "dpi";
|
||||||
|
}
|
||||||
|
|
||||||
if (shapeChanged()) {
|
if (shapeChanged()) {
|
||||||
out += "shape";
|
out += "shape";
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,6 +215,8 @@ public:
|
||||||
DEFINE_PROPERTY(PROP_CLIENT_ONLY, ClientOnly, clientOnly, bool, false);
|
DEFINE_PROPERTY(PROP_CLIENT_ONLY, ClientOnly, clientOnly, bool, false);
|
||||||
DEFINE_PROPERTY_REF(PROP_OWNING_AVATAR_ID, OwningAvatarID, owningAvatarID, QUuid, UNKNOWN_ENTITY_ID);
|
DEFINE_PROPERTY_REF(PROP_OWNING_AVATAR_ID, OwningAvatarID, owningAvatarID, QUuid, UNKNOWN_ENTITY_ID);
|
||||||
|
|
||||||
|
DEFINE_PROPERTY_REF(PROP_DPI, DPI, dpi, uint16_t, ENTITY_ITEM_DEFAULT_DPI);
|
||||||
|
|
||||||
static QString getBackgroundModeString(BackgroundMode mode);
|
static QString getBackgroundModeString(BackgroundMode mode);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,4 +73,6 @@ const bool ENTITY_ITEM_DEFAULT_BILLBOARDED = false;
|
||||||
|
|
||||||
const QString ENTITY_ITEM_DEFAULT_NAME = QString("");
|
const QString ENTITY_ITEM_DEFAULT_NAME = QString("");
|
||||||
|
|
||||||
|
const uint16_t ENTITY_ITEM_DEFAULT_DPI = 30;
|
||||||
|
|
||||||
#endif // hifi_EntityItemPropertiesDefaults_h
|
#endif // hifi_EntityItemPropertiesDefaults_h
|
||||||
|
|
|
@ -176,6 +176,7 @@ enum EntityPropertyList {
|
||||||
PROP_OWNING_AVATAR_ID, // doesn't go over wire
|
PROP_OWNING_AVATAR_ID, // doesn't go over wire
|
||||||
|
|
||||||
PROP_SHAPE,
|
PROP_SHAPE,
|
||||||
|
PROP_DPI,
|
||||||
|
|
||||||
PROP_LOCAL_VELOCITY, // only used to convert values to and from scripts
|
PROP_LOCAL_VELOCITY, // only used to convert values to and from scripts
|
||||||
PROP_LOCAL_ANGULAR_VELOCITY, // only used to convert values to and from scripts
|
PROP_LOCAL_ANGULAR_VELOCITY, // only used to convert values to and from scripts
|
||||||
|
|
|
@ -21,26 +21,8 @@
|
||||||
#include "EntityTree.h"
|
#include "EntityTree.h"
|
||||||
#include "EntityTreeElement.h"
|
#include "EntityTreeElement.h"
|
||||||
|
|
||||||
const float DEFAULT_DPI = 30.47f;
|
|
||||||
|
|
||||||
const QString WebEntityItem::DEFAULT_SOURCE_URL("http://www.google.com");
|
const QString WebEntityItem::DEFAULT_SOURCE_URL("http://www.google.com");
|
||||||
|
|
||||||
static float parseDPIFromUserData(QString str) {
|
|
||||||
QJsonParseError error;
|
|
||||||
auto doc = QJsonDocument::fromJson(str.toUtf8(), &error);
|
|
||||||
if (error.error != QJsonParseError::NoError) {
|
|
||||||
return DEFAULT_DPI;
|
|
||||||
}
|
|
||||||
QJsonObject obj = doc.object();
|
|
||||||
|
|
||||||
QJsonValue dpiValue = obj.value("dpi");
|
|
||||||
if (!dpiValue.isDouble()) {
|
|
||||||
return DEFAULT_DPI;
|
|
||||||
}
|
|
||||||
double dpi = dpiValue.toDouble();
|
|
||||||
return (float)dpi;
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
EntityItemPointer entity { new WebEntityItem(entityID) };
|
EntityItemPointer entity { new WebEntityItem(entityID) };
|
||||||
entity->setProperties(properties);
|
entity->setProperties(properties);
|
||||||
|
@ -49,7 +31,7 @@ EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const Ent
|
||||||
|
|
||||||
WebEntityItem::WebEntityItem(const EntityItemID& entityItemID) : EntityItem(entityItemID) {
|
WebEntityItem::WebEntityItem(const EntityItemID& entityItemID) : EntityItem(entityItemID) {
|
||||||
_type = EntityTypes::Web;
|
_type = EntityTypes::Web;
|
||||||
_dpi = DEFAULT_DPI;
|
_dpi = ENTITY_ITEM_DEFAULT_DPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float WEB_ENTITY_ITEM_FIXED_DEPTH = 0.01f;
|
const float WEB_ENTITY_ITEM_FIXED_DEPTH = 0.01f;
|
||||||
|
@ -62,6 +44,7 @@ void WebEntityItem::setDimensions(const glm::vec3& value) {
|
||||||
EntityItemProperties WebEntityItem::getProperties(EntityPropertyFlags desiredProperties) const {
|
EntityItemProperties WebEntityItem::getProperties(EntityPropertyFlags desiredProperties) const {
|
||||||
EntityItemProperties properties = EntityItem::getProperties(desiredProperties); // get the properties from our base class
|
EntityItemProperties properties = EntityItem::getProperties(desiredProperties); // get the properties from our base class
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(sourceUrl, getSourceUrl);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(sourceUrl, getSourceUrl);
|
||||||
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(dpi, getDPI);
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +53,7 @@ bool WebEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
|
somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(sourceUrl, setSourceUrl);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(sourceUrl, setSourceUrl);
|
||||||
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(dpi, setDPI);
|
||||||
|
|
||||||
if (somethingChanged) {
|
if (somethingChanged) {
|
||||||
bool wantDebug = false;
|
bool wantDebug = false;
|
||||||
|
@ -82,9 +66,6 @@ bool WebEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
setLastEdited(properties._lastEdited);
|
setLastEdited(properties._lastEdited);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AJT: TODO MAKE THIS A REAL PROPERTY
|
|
||||||
_dpi = parseDPIFromUserData(getUserData());
|
|
||||||
|
|
||||||
return somethingChanged;
|
return somethingChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +78,7 @@ int WebEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, i
|
||||||
const unsigned char* dataAt = data;
|
const unsigned char* dataAt = data;
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_SOURCE_URL, QString, setSourceUrl);
|
READ_ENTITY_PROPERTY(PROP_SOURCE_URL, QString, setSourceUrl);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_DPI, uint16_t, setDPI);
|
||||||
|
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +88,7 @@ int WebEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, i
|
||||||
EntityPropertyFlags WebEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
EntityPropertyFlags WebEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
||||||
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
||||||
requestedProperties += PROP_SOURCE_URL;
|
requestedProperties += PROP_SOURCE_URL;
|
||||||
|
requestedProperties += PROP_DPI;
|
||||||
return requestedProperties;
|
return requestedProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +102,7 @@ void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst
|
||||||
|
|
||||||
bool successPropertyFits = true;
|
bool successPropertyFits = true;
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, _sourceUrl);
|
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, _sourceUrl);
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_DPI, _dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
bool WebEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||||
|
@ -146,3 +130,11 @@ void WebEntityItem::setSourceUrl(const QString& value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& WebEntityItem::getSourceUrl() const { return _sourceUrl; }
|
const QString& WebEntityItem::getSourceUrl() const { return _sourceUrl; }
|
||||||
|
|
||||||
|
void WebEntityItem::setDPI(uint16_t value) {
|
||||||
|
_dpi = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t WebEntityItem::getDPI() const {
|
||||||
|
return _dpi;
|
||||||
|
}
|
||||||
|
|
|
@ -54,9 +54,14 @@ public:
|
||||||
virtual void setSourceUrl(const QString& value);
|
virtual void setSourceUrl(const QString& value);
|
||||||
const QString& getSourceUrl() const;
|
const QString& getSourceUrl() const;
|
||||||
|
|
||||||
|
virtual bool wantsHandControllerPointerEvents() const override { return true; }
|
||||||
|
|
||||||
|
void setDPI(uint16_t value);
|
||||||
|
uint16_t getDPI() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString _sourceUrl;
|
QString _sourceUrl;
|
||||||
float _dpi;
|
uint16_t _dpi;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_WebEntityItem_h
|
#endif // hifi_WebEntityItem_h
|
||||||
|
|
|
@ -47,7 +47,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
case PacketType::EntityAdd:
|
case PacketType::EntityAdd:
|
||||||
case PacketType::EntityEdit:
|
case PacketType::EntityEdit:
|
||||||
case PacketType::EntityData:
|
case PacketType::EntityData:
|
||||||
return VERSION_MODEL_ENTITIES_SUPPORT_SIMPLE_HULLS;
|
return VERSION_WEB_ENTITIES_SUPPORT_DPI;
|
||||||
case PacketType::AvatarIdentity:
|
case PacketType::AvatarIdentity:
|
||||||
case PacketType::AvatarData:
|
case PacketType::AvatarData:
|
||||||
case PacketType::BulkAvatarData:
|
case PacketType::BulkAvatarData:
|
||||||
|
|
|
@ -186,6 +186,7 @@ const PacketVersion VERSION_ENTITIES_MORE_SHAPES = 59;
|
||||||
const PacketVersion VERSION_ENTITIES_PROPERLY_ENCODE_SHAPE_EDITS = 60;
|
const PacketVersion VERSION_ENTITIES_PROPERLY_ENCODE_SHAPE_EDITS = 60;
|
||||||
const PacketVersion VERSION_MODEL_ENTITIES_SUPPORT_STATIC_MESH = 61;
|
const PacketVersion VERSION_MODEL_ENTITIES_SUPPORT_STATIC_MESH = 61;
|
||||||
const PacketVersion VERSION_MODEL_ENTITIES_SUPPORT_SIMPLE_HULLS = 62;
|
const PacketVersion VERSION_MODEL_ENTITIES_SUPPORT_SIMPLE_HULLS = 62;
|
||||||
|
const PacketVersion VERSION_WEB_ENTITIES_SUPPORT_DPI = 63;
|
||||||
|
|
||||||
enum class AvatarMixerPacketVersion : PacketVersion {
|
enum class AvatarMixerPacketVersion : PacketVersion {
|
||||||
TranslationSupport = 17,
|
TranslationSupport = 17,
|
||||||
|
|
|
@ -34,10 +34,10 @@ WebBuddy = function (url) {
|
||||||
shapeType: "box",
|
shapeType: "box",
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
"grabbableKey": {"grabbable": true},
|
"grabbableKey": {"grabbable": true},
|
||||||
"dpi": 75
|
|
||||||
}),
|
}),
|
||||||
parentID: MyAvatar.sessionUUID,
|
parentID: MyAvatar.sessionUUID,
|
||||||
parentJointIndex: NEGATIVE_ONE
|
parentJointIndex: NEGATIVE_ONE,
|
||||||
|
dpi: 45
|
||||||
});
|
});
|
||||||
|
|
||||||
this.state = "idle";
|
this.state = "idle";
|
||||||
|
|
Loading…
Reference in a new issue