mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 04:03:59 +02:00
edit.js can now manipulate children without flipping the table
This commit is contained in:
parent
02c4730388
commit
9b54924524
5 changed files with 32 additions and 2 deletions
|
@ -1789,3 +1789,7 @@ QList<QString> EntityItemProperties::listChangedProperties() {
|
|||
|
||||
return out;
|
||||
}
|
||||
|
||||
bool EntityItemProperties::parentDependentPropertyChanged() {
|
||||
return localPositionChanged() || positionChanged() || localRotationChanged() || rotationChanged();
|
||||
}
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
{ return (float)(usecTimestampNow() - getLastEdited()) / (float)USECS_PER_SECOND; }
|
||||
EntityPropertyFlags getChangedProperties() const;
|
||||
|
||||
bool parentDependentPropertyChanged(); // was there a changed in a property that requires parent info to interpret?
|
||||
|
||||
AACube getMaximumAACube() const;
|
||||
AABox getAABox() const;
|
||||
|
||||
|
|
|
@ -201,10 +201,31 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties script
|
|||
|
||||
bool updatedEntity = false;
|
||||
_entityTree->withWriteLock([&] {
|
||||
if (scriptSideProperties.parentDependentPropertyChanged()) {
|
||||
// if the script sets a location property but didn't include parent information, grab the needed
|
||||
// properties from the entity.
|
||||
bool recompute = false;
|
||||
EntityItemPointer entity = nullptr;
|
||||
if (!scriptSideProperties.parentIDChanged()) {
|
||||
entity = _entityTree->findEntityByEntityItemID(entityID);
|
||||
scriptSideProperties.setParentID(entity->getParentID());
|
||||
recompute = true;
|
||||
}
|
||||
if (!scriptSideProperties.parentJointIndexChanged()) {
|
||||
if (!entity) {
|
||||
entity = _entityTree->findEntityByEntityItemID(entityID);
|
||||
}
|
||||
scriptSideProperties.setParentJointIndex(entity->getParentJointIndex());
|
||||
recompute = true;
|
||||
}
|
||||
if (recompute) {
|
||||
properties = convertLocationFromScriptSemantics(scriptSideProperties);
|
||||
}
|
||||
}
|
||||
|
||||
updatedEntity = _entityTree->updateEntity(entityID, properties);
|
||||
});
|
||||
|
||||
|
||||
if (!updatedEntity) {
|
||||
return QUuid();
|
||||
}
|
||||
|
|
|
@ -218,6 +218,7 @@ void SpatiallyNestable::setOrientation(glm::quat orientation) {
|
|||
}
|
||||
|
||||
const Transform SpatiallyNestable::getTransform() const {
|
||||
// return a world-space transform for this object's location
|
||||
Transform parentTransform = getParentTransform();
|
||||
Transform result;
|
||||
_transformLock.withReadLock([&] {
|
||||
|
@ -227,6 +228,8 @@ const Transform SpatiallyNestable::getTransform() const {
|
|||
}
|
||||
|
||||
const Transform SpatiallyNestable::getTransform(int jointIndex) const {
|
||||
// this returns the world-space transform for this object. It find its parent's transform (which may
|
||||
// cause this object's parent to query its parent, etc) and multiplies this object's local transform onto it.
|
||||
Transform worldTransform = getTransform();
|
||||
Transform jointInObjectFrame = getJointTransformInObjectFrame(jointIndex);
|
||||
Transform jointInWorldFrame;
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
virtual glm::vec3 getScale() const;
|
||||
virtual void setScale(glm::vec3 scale);
|
||||
|
||||
// get world location of a specific joint
|
||||
// get world-frame values for a specific joint
|
||||
virtual const Transform getTransform(int jointIndex) const;
|
||||
virtual glm::vec3 getPosition(int jointIndex) const;
|
||||
virtual glm::vec3 getScale(int jointIndex) const;
|
||||
|
|
Loading…
Reference in a new issue