edit.js can now manipulate children without flipping the table

This commit is contained in:
Seth Alves 2015-11-30 16:21:14 -08:00
parent 02c4730388
commit 9b54924524
5 changed files with 32 additions and 2 deletions

View file

@ -1789,3 +1789,7 @@ QList<QString> EntityItemProperties::listChangedProperties() {
return out;
}
bool EntityItemProperties::parentDependentPropertyChanged() {
return localPositionChanged() || positionChanged() || localRotationChanged() || rotationChanged();
}

View file

@ -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;

View file

@ -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();
}

View file

@ -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;

View file

@ -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;