Teleport bugs

* made HMD.setPosition thread safe
* changed script to use HMD.position = foo;
This commit is contained in:
Anthony J. Thibault 2016-09-09 17:31:11 -07:00
parent 82522fbbb1
commit 86351ca21c
3 changed files with 14 additions and 9 deletions

View file

@ -91,13 +91,18 @@ glm::vec3 HMDScriptingInterface::getPosition() const {
}
void HMDScriptingInterface::setPosition(const glm::vec3& position) {
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
glm::mat4 hmdToSensor = myAvatar->getHMDSensorMatrix();
glm::mat4 sensorToWorld = myAvatar->getSensorToWorldMatrix();
glm::mat4 hmdToWorld = sensorToWorld * hmdToSensor;
setTranslation(hmdToWorld, position);
sensorToWorld = hmdToWorld * glm::inverse(hmdToSensor);
myAvatar->setSensorToWorldMatrix(sensorToWorld);
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "setPosition", Qt::QueuedConnection, Q_ARG(const glm::vec3&, position));
return;
} else {
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
glm::mat4 hmdToSensor = myAvatar->getHMDSensorMatrix();
glm::mat4 sensorToWorld = myAvatar->getSensorToWorldMatrix();
glm::mat4 hmdToWorld = sensorToWorld * hmdToSensor;
setTranslation(hmdToWorld, position);
sensorToWorld = hmdToWorld * glm::inverse(hmdToSensor);
myAvatar->setSensorToWorldMatrix(sensorToWorld);
}
}
glm::quat HMDScriptingInterface::getOrientation() const {

View file

@ -72,7 +72,7 @@ private:
glm::vec3 getPosition() const;
// Set the position of the HMD
void setPosition(const glm::vec3& position);
Q_INVOKABLE void setPosition(const glm::vec3& position);
// Get the orientation of the HMD
glm::quat getOrientation() const;

View file

@ -564,7 +564,7 @@ function Teleporter() {
} else if (this.teleportMode === "HMDFirstAvatarWillFollow") {
var eyeOffset = Vec3.subtract(MyAvatar.getEyePosition(), MyAvatar.position);
landingPoint = Vec3.sum(landingPoint, eyeOffset);
HMD.setPosition(landingPoint);
HMD.position = landingPoint;
}
}