fix SpatiallyNestable::getChildren

This commit is contained in:
Seth Alves 2016-02-28 12:15:26 -08:00
parent 5594f1e4e5
commit 5bf8670bc2
3 changed files with 6 additions and 3 deletions

View file

@ -1,3 +1,4 @@
"use strict";
// handControllerGrab.js // handControllerGrab.js
// //
// Created by Eric Levin on 9/2/15 // Created by Eric Levin on 9/2/15
@ -1766,7 +1767,7 @@ function MyController(hand) {
var handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"); var handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand");
var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, handJointIndex); var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, handJointIndex);
children.forEach(function(childID) { children.forEach(function(childID) {
print("disconnecting stray child of hand: " + childID); print("disconnecting stray child of hand: (" + _this.hand + ") " + childID);
Entities.editEntity(childID, {parentID: NULL_UUID}); Entities.editEntity(childID, {parentID: NULL_UUID});
}); });
} }

View file

@ -1084,7 +1084,9 @@ QVector<QUuid> EntityScriptingInterface::getChildrenIDsOfJoint(const QUuid& pare
return; return;
} }
parent->forEachChild([&](SpatiallyNestablePointer child) { parent->forEachChild([&](SpatiallyNestablePointer child) {
result.push_back(child->getID()); if (child->getParentJointIndex() == jointIndex) {
result.push_back(child->getID());
}
}); });
}); });
return result; return result;

View file

@ -682,7 +682,7 @@ QList<SpatiallyNestablePointer> SpatiallyNestable::getChildren() const {
_childrenLock.withReadLock([&] { _childrenLock.withReadLock([&] {
foreach(SpatiallyNestableWeakPointer childWP, _children.values()) { foreach(SpatiallyNestableWeakPointer childWP, _children.values()) {
SpatiallyNestablePointer child = childWP.lock(); SpatiallyNestablePointer child = childWP.lock();
if (child) { if (child && child->_parentKnowsMe && child->getParentID() == getID()) {
children << child; children << child;
} }
} }