mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 12:35:19 +02:00
Moved keyboardFocus, mouse/touch event methods from Reticle to Entities
This commit is contained in:
parent
8dac45c99e
commit
1ddbd7022a
5 changed files with 57 additions and 54 deletions
|
@ -451,37 +451,3 @@ QVariant ReticleInterface::getPosition() const {
|
|||
void ReticleInterface::setPosition(QVariant position) {
|
||||
_compositor->setReticlePosition(vec2FromVariant(position));
|
||||
}
|
||||
|
||||
QUuid ReticleInterface::getKeyboardFocusEntity() const {
|
||||
QUuid result;
|
||||
QMetaObject::invokeMethod(qApp, "getKeyboardFocusEntity", Qt::DirectConnection, Q_RETURN_ARG(QUuid, result));
|
||||
return result;
|
||||
}
|
||||
|
||||
void ReticleInterface::setKeyboardFocusEntity(QUuid id) {
|
||||
QMetaObject::invokeMethod(qApp, "setKeyboardFocusEntity", Qt::QueuedConnection, Q_ARG(QUuid, id));
|
||||
}
|
||||
|
||||
void ReticleInterface::sendEntityMouseMoveEvent(QUuid id, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityMouseMoveEvent", Qt::QueuedConnection, Q_ARG(QUuid, id), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
void ReticleInterface::sendEntityLeftMouseDownEvent(QUuid id, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityLeftMouseDownEvent", Qt::QueuedConnection, Q_ARG(QUuid, id), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
void ReticleInterface::sendEntityLeftMouseUpEvent(QUuid id, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityLeftMouseUpEvent", Qt::QueuedConnection, Q_ARG(QUuid, id), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
void ReticleInterface::sendEntityTouchUpdateEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityTouchUpdateEvent", Qt::QueuedConnection, Q_ARG(QUuid, entityID), Q_ARG(int, fingerID), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
void ReticleInterface::sendEntityTouchBeginEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityTouchBeginEvent", Qt::QueuedConnection, Q_ARG(QUuid, entityID), Q_ARG(int, fingerID), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
void ReticleInterface::sendEntityTouchEndEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityTouchEndEvent", Qt::QueuedConnection, Q_ARG(QUuid, entityID), Q_ARG(int, fingerID), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
|
|
@ -181,7 +181,6 @@ class ReticleInterface : public QObject {
|
|||
Q_PROPERTY(bool mouseCaptured READ isMouseCaptured)
|
||||
Q_PROPERTY(bool allowMouseCapture READ getAllowMouseCapture WRITE setAllowMouseCapture)
|
||||
Q_PROPERTY(bool pointingAtSystemOverlay READ isPointingAtSystemOverlay)
|
||||
Q_PROPERTY(QUuid keyboardFocusEntity READ getKeyboardFocusEntity WRITE setKeyboardFocusEntity)
|
||||
|
||||
public:
|
||||
ReticleInterface(CompositorHelper* outer) : QObject(outer), _compositor(outer) {}
|
||||
|
@ -204,16 +203,6 @@ public:
|
|||
|
||||
Q_INVOKABLE glm::vec2 getMaximumPosition() { return _compositor->getReticleMaximumPosition(); }
|
||||
|
||||
Q_INVOKABLE QUuid getKeyboardFocusEntity() const;
|
||||
Q_INVOKABLE void setKeyboardFocusEntity(QUuid id);
|
||||
Q_INVOKABLE void sendEntityMouseMoveEvent(QUuid id, glm::vec3 intersectionPoint);
|
||||
Q_INVOKABLE void sendEntityLeftMouseDownEvent(QUuid id, glm::vec3 intersectionPoint);
|
||||
Q_INVOKABLE void sendEntityLeftMouseUpEvent(QUuid id, glm::vec3 intersectionPoint);
|
||||
|
||||
Q_INVOKABLE void sendEntityTouchUpdateEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint);
|
||||
Q_INVOKABLE void sendEntityTouchBeginEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint);
|
||||
Q_INVOKABLE void sendEntityTouchEndEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint);
|
||||
|
||||
private:
|
||||
CompositorHelper* _compositor;
|
||||
};
|
||||
|
|
|
@ -1184,6 +1184,40 @@ QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& pare
|
|||
return result;
|
||||
}
|
||||
|
||||
QUuid EntityScriptingInterface::getKeyboardFocusEntity() const {
|
||||
QUuid result;
|
||||
QMetaObject::invokeMethod(qApp, "getKeyboardFocusEntity", Qt::DirectConnection, Q_RETURN_ARG(QUuid, result));
|
||||
return result;
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::setKeyboardFocusEntity(QUuid id) {
|
||||
QMetaObject::invokeMethod(qApp, "setKeyboardFocusEntity", Qt::QueuedConnection, Q_ARG(QUuid, id));
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::sendEntityMouseMoveEvent(QUuid id, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityMouseMoveEvent", Qt::QueuedConnection, Q_ARG(QUuid, id), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::sendEntityLeftMouseDownEvent(QUuid id, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityLeftMouseDownEvent", Qt::QueuedConnection, Q_ARG(QUuid, id), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::sendEntityLeftMouseUpEvent(QUuid id, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityLeftMouseUpEvent", Qt::QueuedConnection, Q_ARG(QUuid, id), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::sendEntityTouchUpdateEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityTouchUpdateEvent", Qt::QueuedConnection, Q_ARG(QUuid, entityID), Q_ARG(int, fingerID), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::sendEntityTouchBeginEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityTouchBeginEvent", Qt::QueuedConnection, Q_ARG(QUuid, entityID), Q_ARG(int, fingerID), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::sendEntityTouchEndEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint) {
|
||||
QMetaObject::invokeMethod(qApp, "sendEntityTouchEndEvent", Qt::QueuedConnection, Q_ARG(QUuid, entityID), Q_ARG(int, fingerID), Q_ARG(glm::vec3, intersectionPoint));
|
||||
}
|
||||
|
||||
float EntityScriptingInterface::calculateCost(float mass, float oldVelocity, float newVelocity) {
|
||||
return std::abs(mass * (newVelocity - oldVelocity));
|
||||
}
|
||||
|
|
|
@ -59,9 +59,11 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra
|
|||
/// handles scripting of Entity commands from JS passed to assigned clients
|
||||
class EntityScriptingInterface : public OctreeScriptingInterface, public Dependency {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Q_PROPERTY(float currentAvatarEnergy READ getCurrentAvatarEnergy WRITE setCurrentAvatarEnergy)
|
||||
Q_PROPERTY(float costMultiplier READ getCostMultiplier WRITE setCostMultiplier)
|
||||
Q_PROPERTY(QUuid keyboardFocusEntity READ getKeyboardFocusEntity WRITE setKeyboardFocusEntity)
|
||||
|
||||
public:
|
||||
EntityScriptingInterface(bool bidOnSimulationOwnership);
|
||||
|
||||
|
@ -176,6 +178,18 @@ public slots:
|
|||
Q_INVOKABLE QVector<QUuid> getChildrenIDs(const QUuid& parentID);
|
||||
Q_INVOKABLE QVector<QUuid> getChildrenIDsOfJoint(const QUuid& parentID, int jointIndex);
|
||||
|
||||
Q_INVOKABLE QUuid getKeyboardFocusEntity() const;
|
||||
Q_INVOKABLE void setKeyboardFocusEntity(QUuid id);
|
||||
|
||||
Q_INVOKABLE void sendEntityMouseMoveEvent(QUuid id, glm::vec3 intersectionPoint);
|
||||
Q_INVOKABLE void sendEntityLeftMouseDownEvent(QUuid id, glm::vec3 intersectionPoint);
|
||||
Q_INVOKABLE void sendEntityLeftMouseUpEvent(QUuid id, glm::vec3 intersectionPoint);
|
||||
|
||||
Q_INVOKABLE void sendEntityTouchUpdateEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint);
|
||||
Q_INVOKABLE void sendEntityTouchBeginEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint);
|
||||
Q_INVOKABLE void sendEntityTouchEndEvent(QUuid entityID, int fingerID, glm::vec3 intersectionPoint);
|
||||
|
||||
|
||||
signals:
|
||||
void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||
|
||||
|
|
|
@ -1392,8 +1392,8 @@ function MyController(hand) {
|
|||
entity = rayPickInfo.entityID;
|
||||
name = entityPropertiesCache.getProps(entity).name;
|
||||
|
||||
if (Reticle.keyboardFocusEntity != entity) {
|
||||
Reticle.keyboardFocusEntity = entity;
|
||||
if (Entities.keyboardFocusEntity != entity) {
|
||||
Entities.keyboardFocusEntity = entity;
|
||||
}
|
||||
|
||||
// send mouse events for button highlights and tooltips.
|
||||
|
@ -1401,7 +1401,7 @@ function MyController(hand) {
|
|||
this.getOtherHandController().state !== STATE_SEARCHING &&
|
||||
this.getOtherHandController().state !== STATE_ENTITY_TOUCHING)) {
|
||||
// most recently searching hand has priority over other hand, for the purposes of button highlighting.
|
||||
Reticle.sendEntityMouseMoveEvent(entity, rayPickInfo.intersection);
|
||||
Entities.sendEntityMouseMoveEvent(entity, rayPickInfo.intersection);
|
||||
}
|
||||
|
||||
if (this.triggerSmoothedGrab() && !isEditing()) {
|
||||
|
@ -2054,13 +2054,13 @@ function MyController(hand) {
|
|||
this.entityTouchingEnter = function() {
|
||||
// test for intersection between controller laser and web entity plane.
|
||||
var intersectInfo = handLaserIntersectWebEntity(this.grabbedEntity, this.hand);
|
||||
Reticle.sendEntityTouchBeginEvent(this.grabbedEntity, this.hand, intersectInfo.point);
|
||||
Entities.sendEntityTouchBeginEvent(this.grabbedEntity, this.hand, intersectInfo.point);
|
||||
};
|
||||
|
||||
this.entityTouchingExit = function() {
|
||||
// test for intersection between controller laser and web entity plane.
|
||||
var intersectInfo = handLaserIntersectWebEntity(this.grabbedEntity, this.hand);
|
||||
Reticle.sendEntityTouchEndEvent(this.grabbedEntity, this.hand, intersectInfo.point);
|
||||
Entities.sendEntityTouchEndEvent(this.grabbedEntity, this.hand, intersectInfo.point);
|
||||
};
|
||||
|
||||
this.entityTouching = function() {
|
||||
|
@ -2074,11 +2074,11 @@ function MyController(hand) {
|
|||
// test for intersection between controller laser and web entity plane.
|
||||
var intersectInfo = handLaserIntersectWebEntity(this.grabbedEntity, this.hand);
|
||||
|
||||
if (Reticle.keyboardFocusEntity != this.grabbedEntity) {
|
||||
Reticle.keyboardFocusEntity = this.grabbedEntity;
|
||||
if (Entities.keyboardFocusEntity != this.grabbedEntity) {
|
||||
Entities.keyboardFocusEntity = this.grabbedEntity;
|
||||
}
|
||||
|
||||
Reticle.sendEntityTouchUpdateEvent(this.grabbedEntity, this.hand, intersectInfo.point);
|
||||
Entities.sendEntityTouchUpdateEvent(this.grabbedEntity, this.hand, intersectInfo.point);
|
||||
|
||||
this.intersectionDistance = intersectInfo.distance;
|
||||
this.searchIndicatorOn(intersectInfo.searchRay);
|
||||
|
|
Loading…
Reference in a new issue