fix off-hand adjustment of equipped entities. make traits-based grabbing be enabled by default, again

This commit is contained in:
Seth Alves 2018-12-14 11:47:57 -08:00
parent bc5079e5d7
commit 895e8cdba1
6 changed files with 43 additions and 43 deletions

View file

@ -32,7 +32,7 @@ void GrabManager::simulateGrabs() {
if (success && grabbedThing) {
glm::vec3 finalPosition = acc.finalizePosition();
glm::quat finalOrientation = acc.finalizeOrientation();
grabbedThing->setWorldTransform(finalPosition, finalOrientation);
grabbedThing->setTransform(createMatFromQuatAndPos(finalOrientation, finalPosition));
}
}
});

View file

@ -680,7 +680,6 @@ void Avatar::simulate(float deltaTime, bool inView) {
head->setScale(getModelScale());
head->simulate(deltaTime);
relayJointDataToChildren();
updateGrabs();
} else {
// a non-full update is still required so that the position, rotation, scale and bounds of the skeletonModel are updated.
_skeletonModel->simulate(deltaTime, false);
@ -716,6 +715,11 @@ void Avatar::simulate(float deltaTime, bool inView) {
updateAvatarEntities();
}
{
PROFILE_RANGE(simulation, "grabs");
updateGrabs();
}
updateFadingStatus();
}

View file

@ -3301,7 +3301,7 @@ bool EntityItem::isWearable() const {
void EntityItem::addGrab(GrabPointer grab) {
SpatiallyNestable::addGrab(grab);
if (getDynamic()) {
if (getDynamic() && getParentID().isNull()) {
EntityTreePointer entityTree = getTree();
assert(entityTree);
EntitySimulationPointer simulation = entityTree ? entityTree->getSimulation() : nullptr;

View file

@ -481,27 +481,29 @@ void SpatiallyNestable::setWorldTransform(const glm::vec3& position, const glm::
return;
}
bool changed = false;
bool success = true;
Transform parentTransform = getParentTransform(success);
_transformLock.withWriteLock([&] {
Transform myWorldTransform;
Transform::mult(myWorldTransform, parentTransform, _transform);
if (myWorldTransform.getRotation() != orientation) {
changed = true;
myWorldTransform.setRotation(orientation);
}
if (myWorldTransform.getTranslation() != position) {
changed = true;
myWorldTransform.setTranslation(position);
}
if (success) {
bool changed = false;
_transformLock.withWriteLock([&] {
Transform myWorldTransform;
Transform::mult(myWorldTransform, parentTransform, _transform);
if (myWorldTransform.getRotation() != orientation) {
changed = true;
myWorldTransform.setRotation(orientation);
}
if (myWorldTransform.getTranslation() != position) {
changed = true;
myWorldTransform.setTranslation(position);
}
if (changed) {
Transform::inverseMult(_transform, parentTransform, myWorldTransform);
_translationChanged = usecTimestampNow();
}
});
if (changed) {
Transform::inverseMult(_transform, parentTransform, myWorldTransform);
_translationChanged = usecTimestampNow();
locationChanged(false);
}
});
if (success && changed) {
locationChanged(false);
}
}
@ -788,19 +790,21 @@ void SpatiallyNestable::setTransform(const Transform& transform, bool& success)
return;
}
bool changed = false;
Transform parentTransform = getParentTransform(success);
_transformLock.withWriteLock([&] {
Transform beforeTransform = _transform;
Transform::inverseMult(_transform, parentTransform, transform);
if (_transform != beforeTransform) {
changed = true;
_translationChanged = usecTimestampNow();
_rotationChanged = usecTimestampNow();
if (success) {
bool changed = false;
_transformLock.withWriteLock([&] {
Transform beforeTransform = _transform;
Transform::inverseMult(_transform, parentTransform, transform);
if (_transform != beforeTransform) {
changed = true;
_translationChanged = usecTimestampNow();
_rotationChanged = usecTimestampNow();
}
});
if (changed) {
locationChanged();
}
});
if (success && changed) {
locationChanged();
}
}

View file

@ -35,7 +35,7 @@ var CONTOLLER_SCRIPTS = [
"controllerModules/nearTabletHighlight.js"
];
if (Settings.getValue("useTraitsGrab", false)) {
if (Settings.getValue("useTraitsGrab", true)) {
CONTOLLER_SCRIPTS.push("controllerModules/nearGrabEntity.js");
CONTOLLER_SCRIPTS.push("controllerModules/farGrabEntity.js");
} else {

View file

@ -332,17 +332,9 @@ getControllerJointIndex = function (hand) {
var now = Date.now();
if (now - getControllerJointIndexCacheTime[hand] > GET_CONTROLLERJOINTINDEX_CACHE_REFRESH_TIME) {
if (HMD.isHandControllerAvailable()) {
var controllerJointIndex = -1;
// if (Camera.mode === "first person") {
// controllerJointIndex = MyAvatar.getJointIndex(hand === RIGHT_HAND ?
// "_CONTROLLER_RIGHTHAND" :
// "_CONTROLLER_LEFTHAND");
// } else if (Camera.mode === "third person") {
controllerJointIndex = MyAvatar.getJointIndex(hand === RIGHT_HAND ?
"_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" :
"_CAMERA_RELATIVE_CONTROLLER_LEFTHAND");
// }
var controllerJointIndex = MyAvatar.getJointIndex(hand === RIGHT_HAND ?
"_CONTROLLER_RIGHTHAND" :
"_CONTROLLER_LEFTHAND");
getControllerJointIndexCacheTime[hand] = now;
getControllerJointIndexCache[hand] = controllerJointIndex;
return controllerJointIndex;