Merge pull request #14100 from danteruiz/soft-entities-updates

update soft entities and fix deadlock from qml.
This commit is contained in:
John Conklin II 2018-10-04 13:33:34 -07:00 committed by GitHub
commit afe6d97b00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 8 deletions

View file

@ -100,6 +100,25 @@ Rectangle {
wearablesModel.setProperty(wearableIndex, 'properties', wearableModelItemProperties); wearablesModel.setProperty(wearableIndex, 'properties', wearableModelItemProperties);
} }
function entityHasAvatarJoints(entityID) {
var hasAvatarJoint = false;
var props = Entities.getEntityProperties(entityID);
var avatarJointsCount = MyAvatar.getJointNames().length;
if (props && avatarJointsCount >= 0 ) {
var entityJointNames = Entities.getJointNames(entityID);
for (var index = 0; index < entityJointNames.length; index++) {
var avatarJointIndex = MyAvatar.getJointIndex(entityJointNames[index]);
if (avatarJointIndex >= 0) {
hasAvatarJoint = true;
break;
}
}
}
return hasAvatarJoint;
}
function getCurrentWearable() { function getCurrentWearable() {
return wearablesCombobox.currentIndex !== -1 ? wearablesCombobox.model.get(wearablesCombobox.currentIndex) : null; return wearablesCombobox.currentIndex !== -1 ? wearablesCombobox.model.get(wearablesCombobox.currentIndex) : null;
} }
@ -109,6 +128,7 @@ Rectangle {
var wearable = wearablesCombobox.model.get(i); var wearable = wearablesCombobox.model.get(i);
if (wearable.id === entityID) { if (wearable.id === entityID) {
wearablesCombobox.currentIndex = i; wearablesCombobox.currentIndex = i;
softWearableTimer.restart();
break; break;
} }
} }
@ -119,6 +139,7 @@ Rectangle {
adjustWearablesClosed(status, avatarName); adjustWearablesClosed(status, avatarName);
} }
HifiConstants { id: hifi } HifiConstants { id: hifi }
// This object is always used in a popup. // This object is always used in a popup.
@ -130,6 +151,20 @@ Rectangle {
hoverEnabled: true; hoverEnabled: true;
} }
Timer {
id: softWearableTimer
interval: 1000
running: false
repeat: true
onTriggered: {
var currentWearable = getCurrentWearable();
var soft = currentWearable ? currentWearable.relayParentJoints : false;
var softEnabled = currentWearable ? entityHasAvatarJoints(currentWearable.id) : false;
isSoft.set(soft);
isSoft.enabled = softEnabled;
}
}
Column { Column {
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 12 anchors.topMargin: 12
@ -247,13 +282,13 @@ Rectangle {
var rotation = currentWearable ? currentWearable.localRotationAngles : { x : 0, y : 0, z : 0 }; var rotation = currentWearable ? currentWearable.localRotationAngles : { x : 0, y : 0, z : 0 };
var scale = currentWearable ? currentWearable.dimensions.x / currentWearable.naturalDimensions.x : 1.0; var scale = currentWearable ? currentWearable.dimensions.x / currentWearable.naturalDimensions.x : 1.0;
var joint = currentWearable ? currentWearable.parentJointIndex : -1; var joint = currentWearable ? currentWearable.parentJointIndex : -1;
var soft = currentWearable ? currentWearable.relayParentJoints : false; softWearableTimer.restart();
positionVector.set(position); positionVector.set(position);
rotationVector.set(rotation); rotationVector.set(rotation);
scalespinner.set(scale); scalespinner.set(scale);
jointsCombobox.set(joint); jointsCombobox.set(joint);
isSoft.set(soft);
if (currentWearable) { if (currentWearable) {
wearableSelected(currentWearable.id); wearableSelected(currentWearable.id);

View file

@ -520,9 +520,13 @@ void Avatar::relayJointDataToChildren() {
modelEntity->setLocalJointTranslation(jointIndex, jointTranslation); modelEntity->setLocalJointTranslation(jointIndex, jointTranslation);
} }
} }
Transform finalTransform;
Transform avatarTransform = _skeletonModel->getTransform(); Transform avatarTransform = _skeletonModel->getTransform();
avatarTransform.setScale(_skeletonModel->getScale()); Transform entityTransform = modelEntity->getLocalTransform();
modelEntity->setOverrideTransform(avatarTransform, _skeletonModel->getOffset()); Transform::mult(finalTransform, avatarTransform, entityTransform);
finalTransform.setScale(_skeletonModel->getScale());
modelEntity->setOverrideTransform(finalTransform, _skeletonModel->getOffset());
modelEntity->simulateRelayedJoints(); modelEntity->simulateRelayedJoints();
} }
} }

View file

@ -1754,8 +1754,9 @@ int EntityScriptingInterface::getJointIndex(const QUuid& entityID, const QString
return -1; return -1;
} }
int result; int result;
BLOCKING_INVOKE_METHOD(_entityTree.get(), "getJointIndex", _entityTree->withReadLock([&] {
Q_RETURN_ARG(int, result), Q_ARG(QUuid, entityID), Q_ARG(QString, name)); result = _entityTree->getJointIndex(entityID, name);
});
return result; return result;
} }
@ -1764,8 +1765,9 @@ QStringList EntityScriptingInterface::getJointNames(const QUuid& entityID) {
return QStringList(); return QStringList();
} }
QStringList result; QStringList result;
BLOCKING_INVOKE_METHOD(_entityTree.get(), "getJointNames", _entityTree->withReadLock([&] {
Q_RETURN_ARG(QStringList, result), Q_ARG(QUuid, entityID)); result = _entityTree->getJointNames(entityID);
});
return result; return result;
} }