when an entity's parent wasn't known and then becomes known, patch up the rigid-body and the render-item bounds

This commit is contained in:
Seth Alves 2017-05-18 14:13:33 -07:00
parent f35796259b
commit ef556fae9b
3 changed files with 6 additions and 2 deletions

View file

@ -1624,7 +1624,7 @@ void EntityItem::updateParentID(const QUuid& value) {
setParentID(value);
// children are forced to be kinematic
// may need to not collide with own avatar
markDirtyFlags(Simulation::DIRTY_MOTION_TYPE | Simulation::DIRTY_COLLISION_GROUP);
markDirtyFlags(Simulation::DIRTY_MOTION_TYPE | Simulation::DIRTY_COLLISION_GROUP | Simulation::DIRTY_POSITION);
}
}

View file

@ -475,6 +475,8 @@ public:
virtual bool getMeshes(MeshProxyList& result) { return true; }
virtual void locationChanged(bool tellPhysics = true) override;
protected:
void setSimulated(bool simulated) { _simulated = simulated; }
@ -482,7 +484,6 @@ protected:
const QByteArray getDynamicDataInternal() const;
void setDynamicDataInternal(QByteArray dynamicData);
virtual void locationChanged(bool tellPhysics = true) override;
virtual void dimensionsChanged() override;
EntityTypes::EntityType _type;

View file

@ -1249,6 +1249,9 @@ void EntityTree::fixupMissingParents() {
if (entity->isParentIDValid()) {
// this entity's parent was previously not known, and now is. Update its location in the EntityTree...
doMove = true;
// the bounds on the render-item may need to be updated, the rigid body in the physics engine may
// need to be moved.
entity->locationChanged(true);
} else if (getIsServer() && _avatarIDs.contains(entity->getParentID())) {
// this is a child of an avatar, which the entity server will never have
// a SpatiallyNestable object for. Add it to a list for cleanup when the avatar leaves.