mirror of
https://github.com/lubosz/overte.git
synced 2025-04-16 17:38:15 +02:00
fix shapes app
This commit is contained in:
parent
96eb137df2
commit
380df059ff
12 changed files with 60 additions and 31 deletions
|
@ -910,7 +910,7 @@ void MyAvatar::simulate(float deltaTime, bool inView) {
|
|||
recorder->recordFrame(FRAME_TYPE, toFrame(*this));
|
||||
}
|
||||
|
||||
locationChanged();
|
||||
locationChanged(true, false);
|
||||
// if a entity-child of this avatar has moved outside of its queryAACube, update the cube and tell the entity server.
|
||||
auto entityTreeRenderer = qApp->getEntities();
|
||||
EntityTreePointer entityTree = entityTreeRenderer ? entityTreeRenderer->getTree() : nullptr;
|
||||
|
@ -920,6 +920,7 @@ void MyAvatar::simulate(float deltaTime, bool inView) {
|
|||
zoneInteractionProperties = entityTreeRenderer->getZoneInteractionProperties();
|
||||
EntityEditPacketSender* packetSender = qApp->getEntityEditPacketSender();
|
||||
forEachDescendant([&](SpatiallyNestablePointer object) {
|
||||
locationChanged(true, false);
|
||||
// we need to update attached queryAACubes in our own local tree so point-select always works
|
||||
// however we don't want to flood the update pipeline with AvatarEntity updates, so we assume
|
||||
// others have all info required to properly update queryAACube of AvatarEntities on their end
|
||||
|
|
|
@ -494,15 +494,34 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
|
|||
RENAME_PROP_CONVERT(p1, p1, [](const QVariant& v) { return vec3toVariant(glm::vec3(0.0f)); });
|
||||
RENAME_PROP_CONVERT(p2, p2, [=](const QVariant& v) {
|
||||
glm::vec3 position;
|
||||
bool hasPosition = false;
|
||||
glm::quat rotation;
|
||||
bool hasRotation = false;
|
||||
|
||||
auto iter2 = overlayProps.find("position");
|
||||
if (iter2 != overlayProps.end()) {
|
||||
position = vec3FromVariant(iter2.value());
|
||||
} else if (!add) {
|
||||
EntityPropertyFlags desiredProperties;
|
||||
desiredProperties += PROP_POSITION;
|
||||
position = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(id, desiredProperties).getPosition();
|
||||
hasPosition = true;
|
||||
}
|
||||
return vec3toVariant(vec3FromVariant(v) - position);
|
||||
iter2 = overlayProps.find("rotation");
|
||||
if (iter2 != overlayProps.end()) {
|
||||
rotation = quatFromVariant(iter2.value());
|
||||
hasRotation = true;
|
||||
}
|
||||
|
||||
if (!add && !(hasPosition && hasRotation)) {
|
||||
auto entity = DependencyManager::get<EntityTreeRenderer>()->getEntity(id);
|
||||
if (entity) {
|
||||
if (!hasPosition) {
|
||||
position = entity->getWorldPosition();
|
||||
}
|
||||
if (!hasRotation) {
|
||||
rotation = entity->getWorldOrientation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vec3toVariant(glm::inverse(rotation) * (vec3FromVariant(v) - position));
|
||||
});
|
||||
|
||||
RENAME_PROP(localStart, p1);
|
||||
|
|
|
@ -928,9 +928,9 @@ void RenderableModelEntityItem::setJointTranslationsSet(const QVector<bool>& tra
|
|||
_needsJointSimulation = true;
|
||||
}
|
||||
|
||||
void RenderableModelEntityItem::locationChanged(bool tellPhysics) {
|
||||
void RenderableModelEntityItem::locationChanged(bool tellPhysics, bool tellChildren) {
|
||||
DETAILED_PERFORMANCE_TIMER("locationChanged");
|
||||
EntityItem::locationChanged(tellPhysics);
|
||||
EntityItem::locationChanged(tellPhysics, tellChildren);
|
||||
auto model = getModel();
|
||||
if (model && model->isLoaded()) {
|
||||
model->updateRenderItems();
|
||||
|
@ -1032,9 +1032,7 @@ void RenderableModelEntityItem::copyAnimationJointDataToModel() {
|
|||
});
|
||||
|
||||
if (changed) {
|
||||
forEachChild([&](SpatiallyNestablePointer object) {
|
||||
object->locationChanged(false);
|
||||
});
|
||||
locationChanged(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public:
|
|||
virtual void setJointTranslations(const QVector<glm::vec3>& translations) override;
|
||||
virtual void setJointTranslationsSet(const QVector<bool>& translationsSet) override;
|
||||
|
||||
virtual void locationChanged(bool tellPhysics = true) override;
|
||||
virtual void locationChanged(bool tellPhysics = true, bool tellChildren = true) override;
|
||||
|
||||
virtual int getJointIndex(const QString& name) const override;
|
||||
virtual QStringList getJointNames() const override;
|
||||
|
|
|
@ -150,7 +150,7 @@ public:
|
|||
virtual bool addToScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(const EntityItemPointer& self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
private:
|
||||
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); notifyBoundChanged(); }
|
||||
virtual void locationChanged(bool tellPhysics = true, bool tellChildren = true) override { EntityItem::locationChanged(tellPhysics, tellChildren); notifyBoundChanged(); }
|
||||
virtual void dimensionsChanged() override { EntityItem::dimensionsChanged(); notifyBoundChanged(); }
|
||||
void notifyBoundChanged();
|
||||
void notifyChangedRenderItem();
|
||||
|
|
|
@ -2593,7 +2593,7 @@ QList<EntityDynamicPointer> EntityItem::getActionsOfType(EntityDynamicType typeT
|
|||
return result;
|
||||
}
|
||||
|
||||
void EntityItem::locationChanged(bool tellPhysics) {
|
||||
void EntityItem::locationChanged(bool tellPhysics, bool tellChildren) {
|
||||
requiresRecalcBoxes();
|
||||
if (tellPhysics) {
|
||||
_flags |= Simulation::DIRTY_TRANSFORM;
|
||||
|
@ -2602,7 +2602,7 @@ void EntityItem::locationChanged(bool tellPhysics) {
|
|||
tree->entityChanged(getThisPointer());
|
||||
}
|
||||
}
|
||||
SpatiallyNestable::locationChanged(tellPhysics); // tell all the children, also
|
||||
SpatiallyNestable::locationChanged(tellPhysics, tellChildren);
|
||||
std::pair<int32_t, glm::vec4> data(_spaceIndex, glm::vec4(getWorldPosition(), _boundingRadius));
|
||||
emit spaceUpdate(data);
|
||||
somethingChangedNotification();
|
||||
|
|
|
@ -518,7 +518,7 @@ public:
|
|||
|
||||
virtual bool getMeshes(MeshProxyList& result) { return true; }
|
||||
|
||||
virtual void locationChanged(bool tellPhysics = true) override;
|
||||
virtual void locationChanged(bool tellPhysics = true, bool tellChildren = true) override;
|
||||
|
||||
virtual bool getScalesWithParent() const override;
|
||||
|
||||
|
|
|
@ -2039,6 +2039,8 @@ void EntityTree::fixupNeedsParentFixups() {
|
|||
Simulation::DIRTY_COLLISION_GROUP |
|
||||
Simulation::DIRTY_TRANSFORM);
|
||||
entityChanged(entity);
|
||||
entity->locationChanged(true, false);
|
||||
|
||||
entity->forEachDescendant([&](SpatiallyNestablePointer object) {
|
||||
if (object->getNestableType() == NestableType::Entity) {
|
||||
EntityItemPointer descendantEntity = std::static_pointer_cast<EntityItem>(object);
|
||||
|
@ -2047,8 +2049,8 @@ void EntityTree::fixupNeedsParentFixups() {
|
|||
Simulation::DIRTY_TRANSFORM);
|
||||
entityChanged(descendantEntity);
|
||||
}
|
||||
object->locationChanged(true, false);
|
||||
});
|
||||
entity->locationChanged(true);
|
||||
|
||||
// Update our parent's bounding box
|
||||
bool success = false;
|
||||
|
@ -3002,8 +3004,19 @@ void EntityTree::updateEntityQueryAACubeWorker(SpatiallyNestablePointer object,
|
|||
// if the queryBox has changed, tell the entity-server
|
||||
EntityItemPointer entity = std::dynamic_pointer_cast<EntityItem>(object);
|
||||
if (entity) {
|
||||
// NOTE: we rely on side-effects of the entity->updateQueryAACube() call in the following if() conditional:
|
||||
if (entity->updateQueryAACube() || force) {
|
||||
bool queryAACubeChanged = false;
|
||||
if (!entity->hasChildren()) {
|
||||
// updateQueryAACube will also update all ancestors' AACubes, so we only need to call this for leaf nodes
|
||||
queryAACubeChanged = entity->updateQueryAACube();
|
||||
} else {
|
||||
AACube oldCube = entity->getQueryAACube();
|
||||
object->forEachDescendant([&](SpatiallyNestablePointer descendant) {
|
||||
updateEntityQueryAACubeWorker(descendant, packetSender, moveOperator, force, tellServer);
|
||||
});
|
||||
queryAACubeChanged = oldCube != entity->getQueryAACube();
|
||||
}
|
||||
|
||||
if (queryAACubeChanged || force) {
|
||||
bool success;
|
||||
AACube newCube = entity->getQueryAACube(success);
|
||||
if (success) {
|
||||
|
@ -3027,10 +3040,6 @@ void EntityTree::updateEntityQueryAACubeWorker(SpatiallyNestablePointer object,
|
|||
entityChanged(entity);
|
||||
}
|
||||
}
|
||||
|
||||
object->forEachDescendant([&](SpatiallyNestablePointer descendant) {
|
||||
updateEntityQueryAACubeWorker(descendant, packetSender, moveOperator, force, tellServer);
|
||||
});
|
||||
}
|
||||
|
||||
void EntityTree::updateEntityQueryAACube(SpatiallyNestablePointer object, EntityEditPacketSender* packetSender,
|
||||
|
|
|
@ -55,8 +55,8 @@ void LightEntityItem::setUnscaledDimensions(const glm::vec3& value) {
|
|||
}
|
||||
}
|
||||
|
||||
void LightEntityItem::locationChanged(bool tellPhysics) {
|
||||
EntityItem::locationChanged(tellPhysics);
|
||||
void LightEntityItem::locationChanged(bool tellPhysics, bool tellChildren) {
|
||||
EntityItem::locationChanged(tellPhysics, tellChildren);
|
||||
withWriteLock([&] {
|
||||
_lightPropertiesChanged = true;
|
||||
});
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
static bool getLightsArePickable() { return _lightsArePickable; }
|
||||
static void setLightsArePickable(bool value) { _lightsArePickable = value; }
|
||||
|
||||
virtual void locationChanged(bool tellPhysics) override;
|
||||
virtual void locationChanged(bool tellPhysics, bool tellChildren) override;
|
||||
virtual void dimensionsChanged() override;
|
||||
|
||||
bool lightPropertiesChanged() const { return _lightPropertiesChanged; }
|
||||
|
|
|
@ -1100,10 +1100,12 @@ void SpatiallyNestable::forEachDescendantTest(const ChildLambdaTest& actor) cons
|
|||
}
|
||||
}
|
||||
|
||||
void SpatiallyNestable::locationChanged(bool tellPhysics) {
|
||||
forEachChild([&](SpatiallyNestablePointer object) {
|
||||
object->locationChanged(tellPhysics);
|
||||
});
|
||||
void SpatiallyNestable::locationChanged(bool tellPhysics, bool tellChildren) {
|
||||
if (tellChildren) {
|
||||
forEachChild([&](SpatiallyNestablePointer object) {
|
||||
object->locationChanged(tellPhysics, tellChildren);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
AACube SpatiallyNestable::getMaximumAACube(bool& success) const {
|
||||
|
|
|
@ -211,7 +211,7 @@ public:
|
|||
|
||||
void dump(const QString& prefix = "") const;
|
||||
|
||||
virtual void locationChanged(bool tellPhysics = true); // called when a this object's location has changed
|
||||
virtual void locationChanged(bool tellPhysics = true, bool tellChildren = true); // called when a this object's location has changed
|
||||
virtual void dimensionsChanged() { _queryAACubeSet = false; } // called when a this object's dimensions have changed
|
||||
virtual void parentDeleted() { } // called on children of a deleted parent
|
||||
|
||||
|
|
Loading…
Reference in a new issue