mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:21:24 +02:00
deactivate grab action when grab is released
This commit is contained in:
parent
0846eb8ec6
commit
3ab2db96b6
8 changed files with 24 additions and 8 deletions
|
@ -5306,7 +5306,10 @@ void MyAvatar::releaseGrab(const QUuid& grabID) {
|
||||||
if (itr != _avatarGrabs.end()) {
|
if (itr != _avatarGrabs.end()) {
|
||||||
GrabPointer grab = itr->second;
|
GrabPointer grab = itr->second;
|
||||||
if (grab) {
|
if (grab) {
|
||||||
grab->setDeleted(true);
|
grab->setReleased(true);
|
||||||
|
bool success;
|
||||||
|
SpatiallyNestablePointer target = SpatiallyNestable::findByID(grab->getTargetID(), success);
|
||||||
|
target->disableGrab(grab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -412,7 +412,7 @@ void Avatar::accumulateGrabPositions(std::map<QUuid, GrabLocationAccumulator>& g
|
||||||
if (!grab || !grab->getActionID().isNull()) {
|
if (!grab || !grab->getActionID().isNull()) {
|
||||||
continue; // the accumulated value isn't used, in this case.
|
continue; // the accumulated value isn't used, in this case.
|
||||||
}
|
}
|
||||||
if (grab->getDeleted()) {
|
if (grab->getReleased()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
virtual bool isReadyForAdd() const { return true; }
|
virtual bool isReadyForAdd() const { return true; }
|
||||||
|
|
||||||
bool isActive() { return _active; }
|
bool isActive() { return _active; }
|
||||||
|
void deactivate() { _active = false; }
|
||||||
|
|
||||||
virtual void removeFromSimulation(EntitySimulationPointer simulation) const = 0;
|
virtual void removeFromSimulation(EntitySimulationPointer simulation) const = 0;
|
||||||
virtual EntityItemWeakPointer getOwnerEntity() const = 0;
|
virtual EntityItemWeakPointer getOwnerEntity() const = 0;
|
||||||
|
|
|
@ -3506,3 +3506,13 @@ void EntityItem::removeGrab(GrabPointer grab) {
|
||||||
}
|
}
|
||||||
disableNoBootstrap();
|
disableNoBootstrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityItem::disableGrab(GrabPointer grab) {
|
||||||
|
QUuid actionID = grab->getActionID();
|
||||||
|
if (!actionID.isNull()) {
|
||||||
|
EntityDynamicPointer action = _grabActions.value(actionID);
|
||||||
|
if (action) {
|
||||||
|
action->deactivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -561,6 +561,7 @@ public:
|
||||||
|
|
||||||
virtual void addGrab(GrabPointer grab) override;
|
virtual void addGrab(GrabPointer grab) override;
|
||||||
virtual void removeGrab(GrabPointer grab) override;
|
virtual void removeGrab(GrabPointer grab) override;
|
||||||
|
virtual void disableGrab(GrabPointer grab) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestRenderUpdate();
|
void requestRenderUpdate();
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
_hand(newHand),
|
_hand(newHand),
|
||||||
_positionalOffset(newPositionalOffset),
|
_positionalOffset(newPositionalOffset),
|
||||||
_rotationalOffset(newRotationalOffset),
|
_rotationalOffset(newRotationalOffset),
|
||||||
_deleted(false) {}
|
_released(false) {}
|
||||||
|
|
||||||
QByteArray toByteArray();
|
QByteArray toByteArray();
|
||||||
bool fromByteArray(const QByteArray& grabData);
|
bool fromByteArray(const QByteArray& grabData);
|
||||||
|
@ -62,7 +62,7 @@ public:
|
||||||
_positionalOffset = other->_positionalOffset;
|
_positionalOffset = other->_positionalOffset;
|
||||||
_rotationalOffset = other->_rotationalOffset;
|
_rotationalOffset = other->_rotationalOffset;
|
||||||
_actionID = other->_actionID;
|
_actionID = other->_actionID;
|
||||||
_deleted = other->_deleted;
|
_released = other->_released;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ public:
|
||||||
glm::quat getRotationalOffset() const { return _rotationalOffset; }
|
glm::quat getRotationalOffset() const { return _rotationalOffset; }
|
||||||
void setRotationalOffset(glm::quat rotationalOffset) { _rotationalOffset = rotationalOffset; }
|
void setRotationalOffset(glm::quat rotationalOffset) { _rotationalOffset = rotationalOffset; }
|
||||||
|
|
||||||
bool getDeleted() const { return _deleted; }
|
bool getReleased() const { return _released; }
|
||||||
void setDeleted(bool value) { _deleted = value; }
|
void setReleased(bool value) { _released = value; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QUuid _actionID; // if an action is created in bullet for this grab, this is the ID
|
QUuid _actionID; // if an action is created in bullet for this grab, this is the ID
|
||||||
|
@ -98,7 +98,7 @@ protected:
|
||||||
QString _hand; // "left" or "right"
|
QString _hand; // "left" or "right"
|
||||||
glm::vec3 _positionalOffset; // relative to joint
|
glm::vec3 _positionalOffset; // relative to joint
|
||||||
glm::quat _rotationalOffset; // relative to joint
|
glm::quat _rotationalOffset; // relative to joint
|
||||||
bool _deleted { false }; // scheduled for deletion
|
bool _released { false }; // released and scheduled for deletion
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1391,7 +1391,7 @@ bool SpatiallyNestable::hasGrabs() {
|
||||||
bool result { false };
|
bool result { false };
|
||||||
_grabsLock.withReadLock([&] {
|
_grabsLock.withReadLock([&] {
|
||||||
foreach (const GrabPointer &grab, _grabs) {
|
foreach (const GrabPointer &grab, _grabs) {
|
||||||
if (grab && !grab->getDeleted()) {
|
if (grab && !grab->getReleased()) {
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,6 +218,7 @@ public:
|
||||||
|
|
||||||
virtual void addGrab(GrabPointer grab);
|
virtual void addGrab(GrabPointer grab);
|
||||||
virtual void removeGrab(GrabPointer grab);
|
virtual void removeGrab(GrabPointer grab);
|
||||||
|
virtual void disableGrab(GrabPointer grab) {};
|
||||||
bool hasGrabs();
|
bool hasGrabs();
|
||||||
virtual QUuid getEditSenderID();
|
virtual QUuid getEditSenderID();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue