mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Added dpi parameter to userData (this is temporary)
This commit is contained in:
parent
9bafd82b2c
commit
6704ae9ad4
4 changed files with 30 additions and 5 deletions
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "EntityTreeRenderer.h"
|
||||
|
||||
const float DPI = 30.47f;
|
||||
const float METERS_TO_INCHES = 39.3701f;
|
||||
static uint32_t _currentWebCount { 0 };
|
||||
// Don't allow more than 100 concurrent web views
|
||||
|
@ -87,7 +86,7 @@ bool RenderableWebEntityItem::buildWebSurface(EntityTreeRenderer* renderer) {
|
|||
QTouchEvent::TouchPoint point;
|
||||
point.setId(event.getID());
|
||||
point.setState(Qt::TouchPointReleased);
|
||||
glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * DPI);
|
||||
glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * _dpi);
|
||||
QPointF windowPoint(windowPos.x, windowPos.y);
|
||||
point.setPos(windowPoint);
|
||||
QList<QTouchEvent::TouchPoint> touchPoints;
|
||||
|
@ -125,7 +124,8 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
|||
|
||||
_lastRenderTime = usecTimestampNow();
|
||||
glm::vec2 dims = glm::vec2(getDimensions());
|
||||
dims *= METERS_TO_INCHES * DPI;
|
||||
|
||||
dims *= METERS_TO_INCHES * _dpi;
|
||||
// The offscreen surface is idempotent for resizes (bails early
|
||||
// if it's a no-op), so it's safe to just call resize every frame
|
||||
// without worrying about excessive overhead.
|
||||
|
@ -185,7 +185,7 @@ void RenderableWebEntityItem::handlePointerEvent(const PointerEvent& event) {
|
|||
return;
|
||||
}
|
||||
|
||||
glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * DPI);
|
||||
glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * _dpi);
|
||||
QPointF windowPoint(windowPos.x, windowPos.y);
|
||||
|
||||
if (event.getType() == PointerEvent::Move) {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include <ByteCountCoding.h>
|
||||
#include <GeometryUtil.h>
|
||||
|
@ -20,8 +21,26 @@
|
|||
#include "EntityTree.h"
|
||||
#include "EntityTreeElement.h"
|
||||
|
||||
const float DEFAULT_DPI = 30.47f;
|
||||
|
||||
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 entity { new WebEntityItem(entityID) };
|
||||
entity->setProperties(properties);
|
||||
|
@ -30,6 +49,7 @@ EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const Ent
|
|||
|
||||
WebEntityItem::WebEntityItem(const EntityItemID& entityItemID) : EntityItem(entityItemID) {
|
||||
_type = EntityTypes::Web;
|
||||
_dpi = DEFAULT_DPI;
|
||||
}
|
||||
|
||||
const float WEB_ENTITY_ITEM_FIXED_DEPTH = 0.01f;
|
||||
|
@ -62,6 +82,9 @@ bool WebEntityItem::setProperties(const EntityItemProperties& properties) {
|
|||
setLastEdited(properties._lastEdited);
|
||||
}
|
||||
|
||||
// AJT: TODO MAKE THIS A REAL PROPERTY
|
||||
_dpi = parseDPIFromUserData(getUserData());
|
||||
|
||||
return somethingChanged;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
|
||||
protected:
|
||||
QString _sourceUrl;
|
||||
float _dpi;
|
||||
};
|
||||
|
||||
#endif // hifi_WebEntityItem_h
|
||||
|
|
|
@ -33,7 +33,8 @@ WebBuddy = function (url) {
|
|||
gravity: {x: 0, y: 0, z: 0},
|
||||
shapeType: "box",
|
||||
userData: JSON.stringify({
|
||||
"grabbableKey": {"grabbable": true}
|
||||
"grabbableKey": {"grabbable": true},
|
||||
"dpi": 75
|
||||
}),
|
||||
parentID: MyAvatar.sessionUUID,
|
||||
parentJointIndex: NEGATIVE_ONE
|
||||
|
|
Loading…
Reference in a new issue