mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 04:42:20 +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()) {
|
||||
GrabPointer grab = itr->second;
|
||||
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()) {
|
||||
continue; // the accumulated value isn't used, in this case.
|
||||
}
|
||||
if (grab->getDeleted()) {
|
||||
if (grab->getReleased()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
virtual bool isReadyForAdd() const { return true; }
|
||||
|
||||
bool isActive() { return _active; }
|
||||
void deactivate() { _active = false; }
|
||||
|
||||
virtual void removeFromSimulation(EntitySimulationPointer simulation) const = 0;
|
||||
virtual EntityItemWeakPointer getOwnerEntity() const = 0;
|
||||
|
|
|
@ -3506,3 +3506,13 @@ void EntityItem::removeGrab(GrabPointer grab) {
|
|||
}
|
||||
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 removeGrab(GrabPointer grab) override;
|
||||
virtual void disableGrab(GrabPointer grab) override;
|
||||
|
||||
signals:
|
||||
void requestRenderUpdate();
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
_hand(newHand),
|
||||
_positionalOffset(newPositionalOffset),
|
||||
_rotationalOffset(newRotationalOffset),
|
||||
_deleted(false) {}
|
||||
_released(false) {}
|
||||
|
||||
QByteArray toByteArray();
|
||||
bool fromByteArray(const QByteArray& grabData);
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
_positionalOffset = other->_positionalOffset;
|
||||
_rotationalOffset = other->_rotationalOffset;
|
||||
_actionID = other->_actionID;
|
||||
_deleted = other->_deleted;
|
||||
_released = other->_released;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,8 @@ public:
|
|||
glm::quat getRotationalOffset() const { return _rotationalOffset; }
|
||||
void setRotationalOffset(glm::quat rotationalOffset) { _rotationalOffset = rotationalOffset; }
|
||||
|
||||
bool getDeleted() const { return _deleted; }
|
||||
void setDeleted(bool value) { _deleted = value; }
|
||||
bool getReleased() const { return _released; }
|
||||
void setReleased(bool value) { _released = value; }
|
||||
|
||||
protected:
|
||||
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"
|
||||
glm::vec3 _positionalOffset; // 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 };
|
||||
_grabsLock.withReadLock([&] {
|
||||
foreach (const GrabPointer &grab, _grabs) {
|
||||
if (grab && !grab->getDeleted()) {
|
||||
if (grab && !grab->getReleased()) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -218,6 +218,7 @@ public:
|
|||
|
||||
virtual void addGrab(GrabPointer grab);
|
||||
virtual void removeGrab(GrabPointer grab);
|
||||
virtual void disableGrab(GrabPointer grab) {};
|
||||
bool hasGrabs();
|
||||
virtual QUuid getEditSenderID();
|
||||
|
||||
|
|
Loading…
Reference in a new issue