mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Teleport bugs
* made HMD.setPosition thread safe * changed script to use HMD.position = foo;
This commit is contained in:
parent
82522fbbb1
commit
86351ca21c
3 changed files with 14 additions and 9 deletions
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue