mirror of
https://github.com/lubosz/overte.git
synced 2025-04-11 13:42:07 +02:00
Parent play area to teleport target unless underneath avatar
This commit is contained in:
parent
ed5e77df37
commit
c0dc70c076
9 changed files with 104 additions and 12 deletions
|
@ -366,3 +366,17 @@ QVector<QUuid> PathPointer::getOverlayIDs() {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QUuid PathPointer::getStartOverlayID(const QString& state) {
|
||||
if (_renderStates.find(_currentRenderState) != _renderStates.end()) {
|
||||
return _renderStates[_currentRenderState]->getStartID();
|
||||
}
|
||||
return QUuid();
|
||||
}
|
||||
|
||||
QUuid PathPointer::getEndOverlayID(const QString& state) {
|
||||
if (_renderStates.find(_currentRenderState) != _renderStates.end()) {
|
||||
return _renderStates[_currentRenderState]->getEndID();
|
||||
}
|
||||
return QUuid();
|
||||
}
|
||||
|
|
|
@ -77,6 +77,8 @@ public:
|
|||
void editRenderState(const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) override;
|
||||
|
||||
QVector<QUuid> getOverlayIDs() override;
|
||||
QUuid getStartOverlayID(const QString& state) override;
|
||||
QUuid getEndOverlayID(const QString& state) override;
|
||||
|
||||
void setLength(float length) override;
|
||||
void setLockEndUUID(const QUuid& objectID, bool isOverlay, const glm::mat4& offsetMat = glm::mat4()) override;
|
||||
|
|
|
@ -379,4 +379,12 @@ QVariantMap PointerScriptingInterface::getPrevPickResult(unsigned int uid) const
|
|||
|
||||
QVector<QUuid> PointerScriptingInterface::getOverlayIDs(unsigned int uid) {
|
||||
return DependencyManager::get<PointerManager>()->getOverlayIDs(uid);
|
||||
}
|
||||
}
|
||||
|
||||
QUuid PointerScriptingInterface::getStartOverlayID(unsigned int uid, const QString& state) {
|
||||
return DependencyManager::get<PointerManager>()->getStartOverlayID(uid, state);
|
||||
}
|
||||
|
||||
QUuid PointerScriptingInterface::getEndOverlayID(unsigned int uid, const QString& state) {
|
||||
return DependencyManager::get<PointerManager>()->getEndOverlayID(uid, state);
|
||||
}
|
||||
|
|
|
@ -207,9 +207,29 @@ public:
|
|||
* Get the IDs of the overlays used by a Pointer.
|
||||
* @function Pointers.getOverlayIDs
|
||||
* @param {number} uid The ID of the Pointer, as returned by {@link Pointers.createPointer}.
|
||||
* @returns {Uuid[]} The overlay IDs used by the Pointer.
|
||||
* @returns {Uuid[]} The overlay IDs used by the Pointer if a {@link PickType|Parabola}, otherwise null.
|
||||
*/
|
||||
Q_INVOKABLE QVector<QUuid> getOverlayIDs(unsigned int uid);
|
||||
|
||||
/**jsdoc
|
||||
* Get the ID of the start overlay for a particular state used by a {@link PickType|Path} or {@link PickType|Parabola}
|
||||
* Pointer.
|
||||
* @function Pointers.getStartOverlayID
|
||||
* @param {number} uid The ID of the Pointer, as returned by {@link Pointers.createPointer}.
|
||||
* @returns {Uuid} The ID of the start overlay used by the Pointer if a {@link PickType|Path} or {@link PickType|Parabola},
|
||||
* otherwise Uuid.NULL.
|
||||
*/
|
||||
Q_INVOKABLE QUuid getStartOverlayID(unsigned int uid, const QString& state);
|
||||
|
||||
/**jsdoc
|
||||
* Get the ID of the end overlay for a particular state used by a {@link PickType|Path} or {@link PickType|Parabola}
|
||||
* Pointer.
|
||||
* @function Pointers.getEndOverlayID
|
||||
* @param {number} uid The ID of the Pointer, as returned by {@link Pointers.createPointer}.
|
||||
* @returns {Uuid} The ID of the end overlay used by the Pointer if a {@link PickType|Path} or {@link PickType|Parabola},
|
||||
* otherwise Uuid.NULL.
|
||||
*/
|
||||
Q_INVOKABLE QUuid getEndOverlayID(unsigned int uid, const QString& state);
|
||||
};
|
||||
|
||||
#endif // hifi_PointerScriptingInterface_h
|
||||
|
|
|
@ -34,6 +34,8 @@ public:
|
|||
void editRenderState(const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) override {}
|
||||
|
||||
QVector<QUuid> getOverlayIDs() override;
|
||||
QUuid getStartOverlayID(const QString& state) override { return QUuid(); };
|
||||
QUuid getEndOverlayID(const QString& state) override { return QUuid(); };;
|
||||
|
||||
static OverlayID buildStylusOverlay(const QVariantMap& properties);
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ public:
|
|||
virtual void editRenderState(const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) = 0;
|
||||
|
||||
virtual QVector<QUuid> getOverlayIDs() = 0;
|
||||
virtual QUuid getStartOverlayID(const QString& state) = 0;
|
||||
virtual QUuid getEndOverlayID(const QString& state) = 0;
|
||||
|
||||
virtual void setPrecisionPicking(bool precisionPicking);
|
||||
virtual void setIgnoreItems(const QVector<QUuid>& ignoreItems) const;
|
||||
|
|
|
@ -154,3 +154,19 @@ QVector<QUuid> PointerManager::getOverlayIDs(unsigned int uid) {
|
|||
QVector<QUuid> empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
QUuid PointerManager::getStartOverlayID(unsigned int uid, const QString& state) {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
return pointer->getStartOverlayID(state);
|
||||
}
|
||||
return QUuid();
|
||||
}
|
||||
|
||||
QUuid PointerManager::getEndOverlayID(unsigned int uid, const QString& state) {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
return pointer->getEndOverlayID(state);
|
||||
}
|
||||
return QUuid();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ public:
|
|||
bool isMouse(unsigned int uid);
|
||||
|
||||
QVector<QUuid> getOverlayIDs(unsigned int uid);
|
||||
QUuid getStartOverlayID(unsigned int uid, const QString& state);
|
||||
QUuid getEndOverlayID(unsigned int uid, const QString& state);
|
||||
|
||||
static const unsigned int MOUSE_POINTER_ID { PointerEvent::INVALID_POINTER_ID + 1 };
|
||||
|
||||
|
|
|
@ -221,6 +221,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
this.playAreaCenterOffset = this.PLAY_AREA_OVERLAY_OFFSET;
|
||||
this.isPlayAreaVisible = false;
|
||||
this.isPlayAreaAvailable = false;
|
||||
this.targetOverlayID = null;
|
||||
|
||||
this.TELEPORT_SCALE_DURATION = 500;
|
||||
this.TELEPORT_SCALE_TIMEOUT = 20;
|
||||
|
@ -296,14 +297,17 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
}
|
||||
};
|
||||
|
||||
this.setPlayAreaVisible = function (visible) {
|
||||
this.setPlayAreaVisible = function (visible, targetOverlayID) {
|
||||
if (!this.isPlayAreaAvailable || this.isPlayAreaVisible === visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.isPlayAreaVisible = visible;
|
||||
this.targetOverlayID = targetOverlayID;
|
||||
|
||||
Overlays.editOverlay(this.playAreaOverlay, {
|
||||
visible: visible,
|
||||
dimensions: Vec3.ZERO
|
||||
dimensions: Vec3.ZERO,
|
||||
visible: visible
|
||||
});
|
||||
for (var i = 0; i < this.playAreaSensorPositionOverlays.length; i++) {
|
||||
Overlays.editOverlay(this.playAreaSensorPositionOverlays[i], {
|
||||
|
@ -349,12 +353,31 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
var avatarSensorPosition = Mat4.transformPoint(worldToSensorMatrix, MyAvatar.position);
|
||||
avatarSensorPosition.y = 0;
|
||||
|
||||
Overlays.editOverlay(this.playAreaOverlay, {
|
||||
position: Vec3.sum(position,
|
||||
Vec3.multiplyQbyV(sensorToWorldRotation,
|
||||
Vec3.multiply(MyAvatar.scale, Vec3.subtract(this.playAreaCenterOffset, avatarSensorPosition)))),
|
||||
rotation: sensorToWorldRotation
|
||||
});
|
||||
var targetXZPosition = { x: position.x, y: 0, z: position.z };
|
||||
var avatarXZPosition = MyAvatar.position;
|
||||
avatarXZPosition.y = 0;
|
||||
var MIN_PARENTING_DISTANCE = 0.2; // Parenting under this distance results in the play area's rotation jittering.
|
||||
if (Vec3.distance(targetXZPosition, avatarXZPosition) < MIN_PARENTING_DISTANCE) {
|
||||
// Set play area position and rotation in world coordinates with no parenting.
|
||||
Overlays.editOverlay(this.playAreaOverlay, {
|
||||
parentID: Uuid.NULL,
|
||||
position: Vec3.sum(position,
|
||||
Vec3.multiplyQbyV(sensorToWorldRotation,
|
||||
Vec3.multiply(MyAvatar.scale, Vec3.subtract(this.playAreaCenterOffset, avatarSensorPosition)))),
|
||||
rotation: sensorToWorldRotation
|
||||
});
|
||||
} else {
|
||||
// Set play area position and rotation in local coordinates with parenting.
|
||||
var targetRotation = Overlays.getProperty(this.targetOverlayID, "rotation");
|
||||
var sensorToTargetRotation = Quat.multiply(Quat.inverse(targetRotation), sensorToWorldRotation);
|
||||
Overlays.editOverlay(this.playAreaOverlay, {
|
||||
parentID: this.targetOverlayID,
|
||||
localPosition: Vec3.multiplyQbyV(Quat.inverse(targetRotation),
|
||||
Vec3.multiplyQbyV(sensorToWorldRotation,
|
||||
Vec3.multiply(MyAvatar.scale, Vec3.subtract(this.playAreaCenterOffset, avatarSensorPosition)))),
|
||||
localRotation: sensorToTargetRotation
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -538,14 +561,17 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
} else {
|
||||
Selection.disableListHighlight(this.teleporterSelectionName);
|
||||
}
|
||||
var pointerID;
|
||||
if (mode === 'head') {
|
||||
Pointers.setRenderState(_this.teleportParabolaHeadVisible, visibleState);
|
||||
Pointers.setRenderState(_this.teleportParabolaHeadInvisible, invisibleState);
|
||||
pointerID = _this.teleportParabolaHeadVisible;
|
||||
} else {
|
||||
Pointers.setRenderState(_this.teleportParabolaHandVisible, visibleState);
|
||||
Pointers.setRenderState(_this.teleportParabolaHandInvisible, invisibleState);
|
||||
pointerID = _this.teleportParabolaHandVisible;
|
||||
}
|
||||
this.setPlayAreaVisible(visible);
|
||||
this.setPlayAreaVisible(visible, Pointers.getEndOverlayID(pointerID, "teleport"));
|
||||
this.setTeleportVisible(visible);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue