mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:28:03 +02:00
don't bootstrap with a traits-based grab
This commit is contained in:
parent
9bf9e379a3
commit
05a80ae0e4
2 changed files with 37 additions and 21 deletions
|
@ -2096,6 +2096,35 @@ bool EntityItem::addAction(EntitySimulationPointer simulation, EntityDynamicPoin
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityItem::enableNoBootstrap() {
|
||||||
|
if (!(bool)(_flags & Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING)) {
|
||||||
|
_flags |= Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING;
|
||||||
|
_flags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar
|
||||||
|
forEachDescendant([&](SpatiallyNestablePointer child) {
|
||||||
|
if (child->getNestableType() == NestableType::Entity) {
|
||||||
|
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(child);
|
||||||
|
entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP);
|
||||||
|
entity->markSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EntityItem::disableNoBootstrap() {
|
||||||
|
if (!stillHasGrabActions()) {
|
||||||
|
_flags &= ~Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING;
|
||||||
|
_flags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar
|
||||||
|
forEachDescendant([&](SpatiallyNestablePointer child) {
|
||||||
|
if (child->getNestableType() == NestableType::Entity) {
|
||||||
|
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(child);
|
||||||
|
entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP);
|
||||||
|
entity->clearSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EntityItem::addActionInternal(EntitySimulationPointer simulation, EntityDynamicPointer action) {
|
bool EntityItem::addActionInternal(EntitySimulationPointer simulation, EntityDynamicPointer action) {
|
||||||
assert(action);
|
assert(action);
|
||||||
assert(simulation);
|
assert(simulation);
|
||||||
|
@ -2117,17 +2146,7 @@ bool EntityItem::addActionInternal(EntitySimulationPointer simulation, EntityDyn
|
||||||
|
|
||||||
auto actionType = action->getType();
|
auto actionType = action->getType();
|
||||||
if (actionType == DYNAMIC_TYPE_HOLD || actionType == DYNAMIC_TYPE_FAR_GRAB) {
|
if (actionType == DYNAMIC_TYPE_HOLD || actionType == DYNAMIC_TYPE_FAR_GRAB) {
|
||||||
if (!(bool)(_flags & Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING)) {
|
enableNoBootstrap();
|
||||||
_flags |= Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING;
|
|
||||||
_flags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar
|
|
||||||
forEachDescendant([&](SpatiallyNestablePointer child) {
|
|
||||||
if (child->getNestableType() == NestableType::Entity) {
|
|
||||||
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(child);
|
|
||||||
entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP);
|
|
||||||
entity->markSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCDebug(entities) << "EntityItem::addActionInternal -- serializeActions failed";
|
qCDebug(entities) << "EntityItem::addActionInternal -- serializeActions failed";
|
||||||
|
@ -2208,16 +2227,8 @@ bool EntityItem::removeActionInternal(const QUuid& actionID, EntitySimulationPoi
|
||||||
action->setIsMine(false);
|
action->setIsMine(false);
|
||||||
_objectActions.remove(actionID);
|
_objectActions.remove(actionID);
|
||||||
|
|
||||||
if ((removedActionType == DYNAMIC_TYPE_HOLD || removedActionType == DYNAMIC_TYPE_FAR_GRAB) && !stillHasGrabActions()) {
|
if (removedActionType == DYNAMIC_TYPE_HOLD || removedActionType == DYNAMIC_TYPE_FAR_GRAB) {
|
||||||
_flags &= ~Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING;
|
disableNoBootstrap();
|
||||||
_flags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar
|
|
||||||
forEachDescendant([&](SpatiallyNestablePointer child) {
|
|
||||||
if (child->getNestableType() == NestableType::Entity) {
|
|
||||||
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(child);
|
|
||||||
entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP);
|
|
||||||
entity->clearSpecialFlags(Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
// NO-OP: we assume SPECIAL_FLAGS_NO_BOOTSTRAPPING bits and collision group are correct
|
// NO-OP: we assume SPECIAL_FLAGS_NO_BOOTSTRAPPING bits and collision group are correct
|
||||||
// because they should have been set correctly when the action was added
|
// because they should have been set correctly when the action was added
|
||||||
|
@ -3299,6 +3310,7 @@ bool EntityItem::isWearable() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityItem::addGrab(GrabPointer grab) {
|
void EntityItem::addGrab(GrabPointer grab) {
|
||||||
|
enableNoBootstrap();
|
||||||
SpatiallyNestable::addGrab(grab);
|
SpatiallyNestable::addGrab(grab);
|
||||||
|
|
||||||
if (getDynamic() && getParentID().isNull()) {
|
if (getDynamic() && getParentID().isNull()) {
|
||||||
|
@ -3357,4 +3369,5 @@ void EntityItem::removeGrab(GrabPointer grab) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
disableNoBootstrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -670,6 +670,9 @@ protected:
|
||||||
bool _simulated { false }; // set by EntitySimulation
|
bool _simulated { false }; // set by EntitySimulation
|
||||||
bool _visuallyReady { true };
|
bool _visuallyReady { true };
|
||||||
|
|
||||||
|
void enableNoBootstrap();
|
||||||
|
void disableNoBootstrap();
|
||||||
|
|
||||||
bool addActionInternal(EntitySimulationPointer simulation, EntityDynamicPointer action);
|
bool addActionInternal(EntitySimulationPointer simulation, EntityDynamicPointer action);
|
||||||
bool removeActionInternal(const QUuid& actionID, EntitySimulationPointer simulation = nullptr);
|
bool removeActionInternal(const QUuid& actionID, EntitySimulationPointer simulation = nullptr);
|
||||||
void deserializeActionsInternal();
|
void deserializeActionsInternal();
|
||||||
|
|
Loading…
Reference in a new issue