Added EntityItem::wantsHandControllerPointerEvents method

This commit is contained in:
Anthony J. Thibault 2016-08-16 16:23:45 -07:00
parent a595a72d0a
commit 36d87ddd7c
7 changed files with 34 additions and 15 deletions

View file

@ -2629,7 +2629,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
event->screenPos(), button,
buttons, event->modifiers());
if (!compositor.getReticleOverDesktop() || getOverlays().getOverlayAtPoint(glm::vec2(transformedPos.x(), transformedPos.y()))) {
if (!isHMDMode() || !compositor.getReticleOverDesktop() || getOverlays().getOverlayAtPoint(glm::vec2(transformedPos.x(), transformedPos.y()))) {
getEntities()->mouseMoveEvent(&mappedEvent);
}
_controllerScriptingInterface->emitMouseMoveEvent(&mappedEvent); // send events to any registered scripts

View file

@ -438,6 +438,8 @@ public:
virtual bool isTransparent() { return _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f : false; }
virtual bool wantsHandControllerPointerEvents() const { return false; }
protected:
void setSimulated(bool simulated) { _simulated = simulated; }

View file

@ -1230,6 +1230,19 @@ void EntityScriptingInterface::sendHoverLeaveEntity(QUuid id, PointerEvent event
QMetaObject::invokeMethod(qApp, "sendHoverLeaveEntity", Qt::QueuedConnection, Q_ARG(QUuid, id), Q_ARG(PointerEvent, event));
}
bool EntityScriptingInterface::wantsHandControllerPointerEvents(QUuid id) {
bool result = false;
if (_entityTree) {
_entityTree->withReadLock([&] {
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(EntityItemID(id));
if (entity) {
result = entity->wantsHandControllerPointerEvents();
}
});
}
return result;
}
float EntityScriptingInterface::calculateCost(float mass, float oldVelocity, float newVelocity) {
return std::abs(mass * (newVelocity - oldVelocity));
}

View file

@ -193,6 +193,8 @@ public slots:
Q_INVOKABLE void sendHoverOverEntity(QUuid id, PointerEvent event);
Q_INVOKABLE void sendHoverLeaveEntity(QUuid id, PointerEvent event);
Q_INVOKABLE bool wantsHandControllerPointerEvents(QUuid id);
signals:
void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);

View file

@ -61,7 +61,7 @@ bool WebEntityItem::setProperties(const EntityItemProperties& properties) {
}
setLastEdited(properties._lastEdited);
}
return somethingChanged;
}
@ -91,8 +91,8 @@ void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst
EntityPropertyFlags& requestedProperties,
EntityPropertyFlags& propertyFlags,
EntityPropertyFlags& propertiesDidntFit,
int& propertyCount,
OctreeElement::AppendState& appendState) const {
int& propertyCount,
OctreeElement::AppendState& appendState) const {
bool successPropertyFits = true;
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, _sourceUrl);

View file

@ -9,7 +9,7 @@
#ifndef hifi_WebEntityItem_h
#define hifi_WebEntityItem_h
#include "EntityItem.h"
#include "EntityItem.h"
class WebEntityItem : public EntityItem {
public:
@ -18,13 +18,13 @@ public:
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
WebEntityItem(const EntityItemID& entityItemID);
ALLOW_INSTANTIATION // This class can be instantiated
/// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately
virtual void setDimensions(const glm::vec3& value);
virtual ShapeType getShapeType() const { return SHAPE_TYPE_BOX; }
// methods for getting/setting all properties of an entity
virtual EntityItemProperties getProperties(EntityPropertyFlags desiredProperties = EntityPropertyFlags()) const;
virtual bool setProperties(const EntityItemProperties& properties);
@ -32,15 +32,15 @@ public:
// TODO: eventually only include properties changed since the params.lastViewFrustumSent time
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const;
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
EntityTreeElementExtraEncodeData* modelTreeElementExtraEncodeData,
EntityPropertyFlags& requestedProperties,
EntityPropertyFlags& propertyFlags,
EntityPropertyFlags& propertiesDidntFit,
int& propertyCount,
int& propertyCount,
OctreeElement::AppendState& appendState) const;
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
ReadBitstreamToTreeParams& args,
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
bool& somethingChanged);
@ -54,6 +54,8 @@ public:
virtual void setSourceUrl(const QString& value);
const QString& getSourceUrl() const;
bool wantsHandControllerPointerEvents() const override { return true; }
protected:
QString _sourceUrl;
};

View file

@ -246,7 +246,7 @@ function projectOntoEntityXYPlane(entityID, worldPos) {
y: (1 - normalizedPos.y) * props.dimensions.y }; // flip y-axis
}
function handLaserIntersectWebEntity(entityID, hand) {
function handLaserIntersectEntity(entityID, hand) {
var standardControllerValue = (hand === RIGHT_HAND) ? Controller.Standard.RightHand : Controller.Standard.LeftHand;
var pose = Controller.getPoseValue(standardControllerValue);
var worldHandPosition = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, pose.translation), MyAvatar.position);
@ -1403,7 +1403,7 @@ function MyController(hand) {
}
}
if (rayPickInfo.entityID && entityPropertiesCache.getProps(rayPickInfo.entityID).type === "Web") {
if (rayPickInfo.entityID && Entities.wantsHandControllerPointerEvents(rayPickInfo.entityID)) {
entity = rayPickInfo.entityID;
name = entityPropertiesCache.getProps(entity).name;
@ -2108,7 +2108,7 @@ function MyController(hand) {
this.entityTouchingEnter = function() {
// test for intersection between controller laser and web entity plane.
var intersectInfo = handLaserIntersectWebEntity(this.grabbedEntity, this.hand);
var intersectInfo = handLaserIntersectEntity(this.grabbedEntity, this.hand);
var pointerEvent = {
type: "Press",
@ -2129,7 +2129,7 @@ function MyController(hand) {
this.entityTouchingExit = function() {
// test for intersection between controller laser and web entity plane.
var intersectInfo = handLaserIntersectWebEntity(this.grabbedEntity, this.hand);
var intersectInfo = handLaserIntersectEntity(this.grabbedEntity, this.hand);
var pointerEvent = {
type: "Release",
@ -2159,7 +2159,7 @@ function MyController(hand) {
}
// test for intersection between controller laser and web entity plane.
var intersectInfo = handLaserIntersectWebEntity(this.grabbedEntity, this.hand);
var intersectInfo = handLaserIntersectEntity(this.grabbedEntity, this.hand);
if (Entities.keyboardFocusEntity != this.grabbedEntity) {
Entities.keyboardFocusEntity = this.grabbedEntity;