added setLockEndUUID, update handControllerGrab and grab

This commit is contained in:
SamGondelman 2017-08-04 18:26:11 -07:00
parent bd942ec406
commit 8b1c24e636
7 changed files with 50 additions and 9 deletions

View file

@ -123,15 +123,36 @@ void LaserPointer::updateRenderState(const RenderState& renderState, const Inter
qApp->getOverlays().editOverlay(renderState.getStartID(), startProps);
}
glm::vec3 endVec;
if (defaultState || !_lockEnd || type == IntersectionType::HUD) {
if (((defaultState || !_lockEnd) && _objectLockEnd.first.isNull()) || type == IntersectionType::HUD) {
endVec = pickRay.origin + pickRay.direction * distance;
} else {
if (type == IntersectionType::ENTITY) {
endVec = DependencyManager::get<EntityScriptingInterface>()->getEntityTransform(objectID)[3];
} else if (type == IntersectionType::OVERLAY) {
endVec = vec3FromVariant(qApp->getOverlays().getProperty(objectID, "position").value);
} else if (type == IntersectionType::AVATAR) {
endVec = DependencyManager::get<AvatarHashMap>()->getAvatar(objectID)->getPosition();
if (!_objectLockEnd.first.isNull()) {
glm::vec3 pos;
glm::quat rot;
glm::vec3 dim;
glm::vec3 registrationPoint;
if (_objectLockEnd.second) {
pos = vec3FromVariant(qApp->getOverlays().getProperty(_objectLockEnd.first, "position").value);
rot = quatFromVariant(qApp->getOverlays().getProperty(_objectLockEnd.first, "rotation").value);
dim = vec3FromVariant(qApp->getOverlays().getProperty(_objectLockEnd.first, "dimensions").value);
registrationPoint = glm::vec3(0.5f);
} else {
EntityItemProperties props = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(_objectLockEnd.first);
pos = props.getPosition();
rot = props.getRotation();
dim = props.getDimensions();
registrationPoint = props.getRegistrationPoint();
}
const glm::vec3 DEFAULT_REGISTRATION_POINT = glm::vec3(0.5f);
endVec = pos + rot * (dim * (DEFAULT_REGISTRATION_POINT - registrationPoint));
} else {
if (type == IntersectionType::ENTITY) {
endVec = DependencyManager::get<EntityScriptingInterface>()->getEntityTransform(objectID)[3];
} else if (type == IntersectionType::OVERLAY) {
endVec = vec3FromVariant(qApp->getOverlays().getProperty(objectID, "position").value);
} else if (type == IntersectionType::AVATAR) {
endVec = DependencyManager::get<AvatarHashMap>()->getAvatar(objectID)->getPosition();
}
}
}
QVariant end = vec3toVariant(endVec);

View file

@ -68,6 +68,8 @@ public:
void setIgnoreAvatars(const QScriptValue& ignoreAvatars) { DependencyManager::get<RayPickManager>()->setIgnoreAvatars(_rayPickUID, ignoreAvatars); }
void setIncludeAvatars(const QScriptValue& includeAvatars) { DependencyManager::get<RayPickManager>()->setIncludeAvatars(_rayPickUID, includeAvatars); }
void setLockEndUUID(QUuid objectID, const bool isOverlay) { _objectLockEnd = QPair<QUuid, bool>(objectID, isOverlay); }
void update();
private:
@ -78,6 +80,7 @@ private:
bool _faceAvatar;
bool _centerEndY;
bool _lockEnd;
QPair<QUuid, bool> _objectLockEnd { QPair<QUuid, bool>(QUuid(), false)};
QUuid _rayPickUID;

View file

@ -143,4 +143,12 @@ void LaserPointerManager::setIncludeAvatars(QUuid uid, const QScriptValue& inclu
QWriteLocker laserLock(_laserPointerLocks[uid].get());
_laserPointers[uid]->setIncludeAvatars(includeAvatars);
}
}
}
void LaserPointerManager::setLockEndUUID(QUuid uid, QUuid objectID, const bool isOverlay) {
QReadLocker lock(&_containsLock);
if (_laserPointers.contains(uid)) {
QWriteLocker laserLock(_laserPointerLocks[uid].get());
_laserPointers[uid]->setLockEndUUID(objectID, isOverlay);
}
}

View file

@ -41,6 +41,8 @@ public:
void setIgnoreAvatars(QUuid uid, const QScriptValue& ignoreAvatars);
void setIncludeAvatars(QUuid uid, const QScriptValue& includeAvatars);
void setLockEndUUID(QUuid uid, QUuid objectID, const bool isOverlay);
void update();
private:

View file

@ -37,6 +37,8 @@ public slots:
Q_INVOKABLE void setIgnoreAvatars(QUuid uid, const QScriptValue& ignoreAvatars) { DependencyManager::get<LaserPointerManager>()->setIgnoreAvatars(uid, ignoreAvatars); }
Q_INVOKABLE void setIncludeAvatars(QUuid uid, const QScriptValue& includeAvatars) { DependencyManager::get<LaserPointerManager>()->setIncludeAvatars(uid, includeAvatars); }
Q_INVOKABLE void setLockEndUUID(QUuid uid, QUuid objectID, const bool isOverlay) { DependencyManager::get<LaserPointerManager>()->setLockEndUUID(uid, objectID, isOverlay); }
private:
const RenderState buildRenderState(const QVariantMap & propMap);

View file

@ -266,7 +266,6 @@ function Grabber() {
this.mouseRayEntities = LaserPointers.createLaserPointer({
joint: "Mouse",
filter: RayPick.PICK_ENTITIES,
lockEnd: true,
faceAvatar: true,
enabled: true
});
@ -341,6 +340,7 @@ Grabber.prototype.pressEvent = function(event) {
}
LaserPointers.setRenderState(this.mouseRayEntities, "grabbed");
LaserPointers.setLockEndUUID(this.mouseRayEntities, pickResults.objectID, false);
mouse.startDrag(event);

View file

@ -1438,6 +1438,11 @@ function MyController(hand) {
}
LaserPointers.enableLaserPointer(laserPointerID);
LaserPointers.setRenderState(laserPointerID, mode);
if (this.state === STATE_DISTANCE_HOLDING || this.state === STATE_DISTANCE_ROTATING) {
LaserPointers.setLockEndUUID(laserPointerID, this.grabbedThingID, this.grabbedIsOverlay);
} else {
LaserPointers.setLockEndUUID(laserPointerID, null, false);
}
};
this.laserPointerOff = function() {