mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:42:58 +02:00
migrate SpatiallyNestable::getOrientation to getWorldOrientation, remove redundant getRotation
This commit is contained in:
parent
a7a0f03ede
commit
f63db42c0e
48 changed files with 141 additions and 145 deletions
|
@ -967,7 +967,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
|
|
||||||
// use our MyAvatar position and quat for address manager path
|
// use our MyAvatar position and quat for address manager path
|
||||||
addressManager->setPositionGetter([this]{ return getMyAvatar()->getWorldPosition(); });
|
addressManager->setPositionGetter([this]{ return getMyAvatar()->getWorldPosition(); });
|
||||||
addressManager->setOrientationGetter([this]{ return getMyAvatar()->getOrientation(); });
|
addressManager->setOrientationGetter([this]{ return getMyAvatar()->getWorldOrientation(); });
|
||||||
|
|
||||||
connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
|
connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
|
||||||
connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
|
connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
|
||||||
|
@ -2400,7 +2400,7 @@ void Application::updateCamera(RenderArgs& renderArgs) {
|
||||||
auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
|
auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
|
||||||
_myCamera.setOrientation(glm::normalize(glmExtractRotation(hmdWorldMat)));
|
_myCamera.setOrientation(glm::normalize(glmExtractRotation(hmdWorldMat)));
|
||||||
_myCamera.setPosition(extractTranslation(hmdWorldMat) +
|
_myCamera.setPosition(extractTranslation(hmdWorldMat) +
|
||||||
myAvatar->getOrientation() * boomOffset);
|
myAvatar->getWorldOrientation() * boomOffset);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_myCamera.setOrientation(myAvatar->getHead()->getOrientation());
|
_myCamera.setOrientation(myAvatar->getHead()->getOrientation());
|
||||||
|
@ -2410,13 +2410,13 @@ void Application::updateCamera(RenderArgs& renderArgs) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
||||||
+ myAvatar->getOrientation() * boomOffset);
|
+ myAvatar->getWorldOrientation() * boomOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
if (isHMDMode()) {
|
if (isHMDMode()) {
|
||||||
auto mirrorBodyOrientation = myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
|
auto mirrorBodyOrientation = myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f));
|
||||||
|
|
||||||
glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
|
glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
|
||||||
// Mirror HMD yaw and roll
|
// Mirror HMD yaw and roll
|
||||||
|
@ -2439,11 +2439,11 @@ void Application::updateCamera(RenderArgs& renderArgs) {
|
||||||
+ mirrorBodyOrientation * hmdOffset);
|
+ mirrorBodyOrientation * hmdOffset);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_myCamera.setOrientation(myAvatar->getOrientation()
|
_myCamera.setOrientation(myAvatar->getWorldOrientation()
|
||||||
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
|
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
|
||||||
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
||||||
+ glm::vec3(0, _raiseMirror * myAvatar->getModelScale(), 0)
|
+ glm::vec3(0, _raiseMirror * myAvatar->getModelScale(), 0)
|
||||||
+ (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
+ (myAvatar->getWorldOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
||||||
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
|
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
|
||||||
}
|
}
|
||||||
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
||||||
|
@ -2453,12 +2453,12 @@ void Application::updateCamera(RenderArgs& renderArgs) {
|
||||||
if (cameraEntity != nullptr) {
|
if (cameraEntity != nullptr) {
|
||||||
if (isHMDMode()) {
|
if (isHMDMode()) {
|
||||||
glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
|
glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
|
||||||
_myCamera.setOrientation(cameraEntity->getRotation() * hmdRotation);
|
_myCamera.setOrientation(cameraEntity->getWorldOrientation() * hmdRotation);
|
||||||
glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
|
glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
|
||||||
_myCamera.setPosition(cameraEntity->getWorldPosition() + (hmdRotation * hmdOffset));
|
_myCamera.setPosition(cameraEntity->getWorldPosition() + (hmdRotation * hmdOffset));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_myCamera.setOrientation(cameraEntity->getRotation());
|
_myCamera.setOrientation(cameraEntity->getWorldOrientation());
|
||||||
_myCamera.setPosition(cameraEntity->getWorldPosition());
|
_myCamera.setPosition(cameraEntity->getWorldPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3870,7 +3870,7 @@ void Application::idle() {
|
||||||
if (!_keyboardFocusedEntity.get().isInvalidID()) {
|
if (!_keyboardFocusedEntity.get().isInvalidID()) {
|
||||||
auto entity = getEntities()->getTree()->findEntityByID(_keyboardFocusedEntity.get());
|
auto entity = getEntities()->getTree()->findEntityByID(_keyboardFocusedEntity.get());
|
||||||
if (entity && _keyboardFocusHighlight) {
|
if (entity && _keyboardFocusHighlight) {
|
||||||
_keyboardFocusHighlight->setRotation(entity->getRotation());
|
_keyboardFocusHighlight->setWorldOrientation(entity->getWorldOrientation());
|
||||||
_keyboardFocusHighlight->setWorldPosition(entity->getWorldPosition());
|
_keyboardFocusHighlight->setWorldPosition(entity->getWorldPosition());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -3878,7 +3878,7 @@ void Application::idle() {
|
||||||
auto overlay =
|
auto overlay =
|
||||||
std::dynamic_pointer_cast<Web3DOverlay>(getOverlays().getOverlay(_keyboardFocusedOverlay.get()));
|
std::dynamic_pointer_cast<Web3DOverlay>(getOverlays().getOverlay(_keyboardFocusedOverlay.get()));
|
||||||
if (overlay && _keyboardFocusHighlight) {
|
if (overlay && _keyboardFocusHighlight) {
|
||||||
_keyboardFocusHighlight->setRotation(overlay->getRotation());
|
_keyboardFocusHighlight->setWorldOrientation(overlay->getWorldOrientation());
|
||||||
_keyboardFocusHighlight->setWorldPosition(overlay->getWorldPosition());
|
_keyboardFocusHighlight->setWorldPosition(overlay->getWorldPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4293,7 +4293,7 @@ void Application::updateMyAvatarLookAtPosition() {
|
||||||
// TODO -- this code is probably wrong, getHeadPose() returns something in sensor frame, not avatar
|
// TODO -- this code is probably wrong, getHeadPose() returns something in sensor frame, not avatar
|
||||||
glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
|
glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
|
||||||
glm::quat hmdRotation = glm::quat_cast(headPose);
|
glm::quat hmdRotation = glm::quat_cast(headPose);
|
||||||
lookAtSpot = _myCamera.getPosition() + myAvatar->getOrientation() * (hmdRotation * lookAtPosition);
|
lookAtSpot = _myCamera.getPosition() + myAvatar->getWorldOrientation() * (hmdRotation * lookAtPosition);
|
||||||
} else {
|
} else {
|
||||||
lookAtSpot = myAvatar->getHead()->getEyePosition()
|
lookAtSpot = myAvatar->getHead()->getEyePosition()
|
||||||
+ (myAvatar->getHead()->getFinalOrientationInWorldFrame() * lookAtPosition);
|
+ (myAvatar->getHead()->getFinalOrientationInWorldFrame() * lookAtPosition);
|
||||||
|
@ -4519,7 +4519,7 @@ void Application::setKeyboardFocusHighlight(const glm::vec3& position, const glm
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position focus
|
// Position focus
|
||||||
_keyboardFocusHighlight->setRotation(rotation);
|
_keyboardFocusHighlight->setWorldOrientation(rotation);
|
||||||
_keyboardFocusHighlight->setWorldPosition(position);
|
_keyboardFocusHighlight->setWorldPosition(position);
|
||||||
_keyboardFocusHighlight->setDimensions(dimensions);
|
_keyboardFocusHighlight->setDimensions(dimensions);
|
||||||
_keyboardFocusHighlight->setVisible(true);
|
_keyboardFocusHighlight->setVisible(true);
|
||||||
|
@ -4557,7 +4557,7 @@ void Application::setKeyboardFocusEntity(const EntityItemID& entityItemID) {
|
||||||
}
|
}
|
||||||
_lastAcceptedKeyPress = usecTimestampNow();
|
_lastAcceptedKeyPress = usecTimestampNow();
|
||||||
|
|
||||||
setKeyboardFocusHighlight(entity->getWorldPosition(), entity->getRotation(),
|
setKeyboardFocusHighlight(entity->getWorldPosition(), entity->getWorldOrientation(),
|
||||||
entity->getDimensions() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR);
|
entity->getDimensions() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4594,7 +4594,7 @@ void Application::setKeyboardFocusOverlay(const OverlayID& overlayID) {
|
||||||
if (overlay->getProperty("showKeyboardFocusHighlight").toBool()) {
|
if (overlay->getProperty("showKeyboardFocusHighlight").toBool()) {
|
||||||
auto size = overlay->getSize() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR;
|
auto size = overlay->getSize() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR;
|
||||||
const float OVERLAY_DEPTH = 0.0105f;
|
const float OVERLAY_DEPTH = 0.0105f;
|
||||||
setKeyboardFocusHighlight(overlay->getWorldPosition(), overlay->getRotation(), glm::vec3(size.x, size.y, OVERLAY_DEPTH));
|
setKeyboardFocusHighlight(overlay->getWorldPosition(), overlay->getWorldOrientation(), glm::vec3(size.x, size.y, OVERLAY_DEPTH));
|
||||||
} else if (_keyboardFocusHighlight) {
|
} else if (_keyboardFocusHighlight) {
|
||||||
_keyboardFocusHighlight->setVisible(false);
|
_keyboardFocusHighlight->setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -4686,7 +4686,7 @@ void Application::update(float deltaTime) {
|
||||||
|
|
||||||
controller::InputCalibrationData calibrationData = {
|
controller::InputCalibrationData calibrationData = {
|
||||||
myAvatar->getSensorToWorldMatrix(),
|
myAvatar->getSensorToWorldMatrix(),
|
||||||
createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getWorldPosition()),
|
createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition()),
|
||||||
myAvatar->getHMDSensorMatrix(),
|
myAvatar->getHMDSensorMatrix(),
|
||||||
myAvatar->getCenterEyeCalibrationMat(),
|
myAvatar->getCenterEyeCalibrationMat(),
|
||||||
myAvatar->getHeadCalibrationMat(),
|
myAvatar->getHeadCalibrationMat(),
|
||||||
|
@ -4796,7 +4796,7 @@ void Application::update(float deltaTime) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// copy controller poses from userInputMapper to myAvatar.
|
// copy controller poses from userInputMapper to myAvatar.
|
||||||
glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getWorldPosition());
|
glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition());
|
||||||
glm::mat4 worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix());
|
glm::mat4 worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix());
|
||||||
glm::mat4 avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;
|
glm::mat4 avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;
|
||||||
for (auto& action : avatarControllerActions) {
|
for (auto& action : avatarControllerActions) {
|
||||||
|
@ -6437,9 +6437,9 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) {
|
||||||
properties.setShapeType(SHAPE_TYPE_SIMPLE_COMPOUND);
|
properties.setShapeType(SHAPE_TYPE_SIMPLE_COMPOUND);
|
||||||
properties.setCollisionless(true); // Temporarily set so that doesn't collide with avatar.
|
properties.setCollisionless(true); // Temporarily set so that doesn't collide with avatar.
|
||||||
properties.setVisible(false); // Temporarily set so that don't see at large unresized dimensions.
|
properties.setVisible(false); // Temporarily set so that don't see at large unresized dimensions.
|
||||||
glm::vec3 positionOffset = getMyAvatar()->getOrientation() * (getMyAvatar()->getSensorToWorldScale() * glm::vec3(0.0f, 0.0f, -2.0f));
|
glm::vec3 positionOffset = getMyAvatar()->getWorldOrientation() * (getMyAvatar()->getSensorToWorldScale() * glm::vec3(0.0f, 0.0f, -2.0f));
|
||||||
properties.setPosition(getMyAvatar()->getWorldPosition() + positionOffset);
|
properties.setPosition(getMyAvatar()->getWorldPosition() + positionOffset);
|
||||||
properties.setRotation(getMyAvatar()->getOrientation());
|
properties.setRotation(getMyAvatar()->getWorldOrientation());
|
||||||
properties.setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
|
properties.setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
auto entityID = DependencyManager::get<EntityScriptingInterface>()->addEntity(properties);
|
auto entityID = DependencyManager::get<EntityScriptingInterface>()->addEntity(properties);
|
||||||
|
|
||||||
|
|
|
@ -531,5 +531,5 @@ void AvatarActionHold::lateAvatarUpdate(const AnimPose& prePhysicsRoomPose, cons
|
||||||
bool positionSuccess;
|
bool positionSuccess;
|
||||||
ownerEntity->setWorldPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset(), positionSuccess, false);
|
ownerEntity->setWorldPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset(), positionSuccess, false);
|
||||||
bool orientationSuccess;
|
bool orientationSuccess;
|
||||||
ownerEntity->setOrientation(bulletToGLM(worldTrans.getRotation()), orientationSuccess, false);
|
ownerEntity->setWorldOrientation(bulletToGLM(worldTrans.getRotation()), orientationSuccess, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ glm::vec3 AvatarMotionState::getObjectPosition() const {
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
glm::quat AvatarMotionState::getObjectRotation() const {
|
glm::quat AvatarMotionState::getObjectRotation() const {
|
||||||
return _avatar->getOrientation();
|
return _avatar->getWorldOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
|
|
|
@ -197,7 +197,7 @@ MyAvatar::MyAvatar(QThread* thread) :
|
||||||
}
|
}
|
||||||
|
|
||||||
setWorldPosition(dummyAvatar.getWorldPosition());
|
setWorldPosition(dummyAvatar.getWorldPosition());
|
||||||
setOrientation(dummyAvatar.getOrientation());
|
setWorldOrientation(dummyAvatar.getWorldOrientation());
|
||||||
|
|
||||||
if (!dummyAvatar.getAttachmentData().isEmpty()) {
|
if (!dummyAvatar.getAttachmentData().isEmpty()) {
|
||||||
setAttachmentData(dummyAvatar.getAttachmentData());
|
setAttachmentData(dummyAvatar.getAttachmentData());
|
||||||
|
@ -250,11 +250,11 @@ void MyAvatar::registerMetaTypes(ScriptEnginePointer engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setOrientationVar(const QVariant& newOrientationVar) {
|
void MyAvatar::setOrientationVar(const QVariant& newOrientationVar) {
|
||||||
Avatar::setOrientation(quatFromVariant(newOrientationVar));
|
Avatar::setWorldOrientation(quatFromVariant(newOrientationVar));
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant MyAvatar::getOrientationVar() const {
|
QVariant MyAvatar::getOrientationVar() const {
|
||||||
return quatToVariant(Avatar::getOrientation());
|
return quatToVariant(Avatar::getWorldOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat MyAvatar::getOrientationOutbound() const {
|
glm::quat MyAvatar::getOrientationOutbound() const {
|
||||||
|
@ -329,7 +329,7 @@ void MyAvatar::centerBody() {
|
||||||
|
|
||||||
// this will become our new position.
|
// this will become our new position.
|
||||||
setWorldPosition(worldBodyPos);
|
setWorldPosition(worldBodyPos);
|
||||||
setOrientation(worldBodyRot);
|
setWorldOrientation(worldBodyRot);
|
||||||
|
|
||||||
// reset the body in sensor space
|
// reset the body in sensor space
|
||||||
_bodySensorMatrix = newBodySensorMatrix;
|
_bodySensorMatrix = newBodySensorMatrix;
|
||||||
|
@ -373,7 +373,7 @@ void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
|
||||||
|
|
||||||
// this will become our new position.
|
// this will become our new position.
|
||||||
setWorldPosition(worldBodyPos);
|
setWorldPosition(worldBodyPos);
|
||||||
setOrientation(worldBodyRot);
|
setWorldOrientation(worldBodyRot);
|
||||||
|
|
||||||
// now sample the new hmd orientation AFTER sensor reset, which should be identity.
|
// now sample the new hmd orientation AFTER sensor reset, which should be identity.
|
||||||
glm::mat4 identity;
|
glm::mat4 identity;
|
||||||
|
@ -411,7 +411,7 @@ void MyAvatar::update(float deltaTime) {
|
||||||
|
|
||||||
if (_goToPending) {
|
if (_goToPending) {
|
||||||
setWorldPosition(_goToPosition);
|
setWorldPosition(_goToPosition);
|
||||||
setOrientation(_goToOrientation);
|
setWorldOrientation(_goToOrientation);
|
||||||
_headControllerFacingMovingAverage = _headControllerFacing; // reset moving average
|
_headControllerFacingMovingAverage = _headControllerFacing; // reset moving average
|
||||||
_goToPending = false;
|
_goToPending = false;
|
||||||
// updateFromHMDSensorMatrix (called from paintGL) expects that the sensorToWorldMatrix is updated for any position changes
|
// updateFromHMDSensorMatrix (called from paintGL) expects that the sensorToWorldMatrix is updated for any position changes
|
||||||
|
@ -666,7 +666,7 @@ void MyAvatar::updateSensorToWorldMatrix() {
|
||||||
// update the sensor mat so that the body position will end up in the desired
|
// update the sensor mat so that the body position will end up in the desired
|
||||||
// position when driven from the head.
|
// position when driven from the head.
|
||||||
float sensorToWorldScale = getEyeHeight() / getUserEyeHeight();
|
float sensorToWorldScale = getEyeHeight() / getUserEyeHeight();
|
||||||
glm::mat4 desiredMat = createMatFromScaleQuatAndPos(glm::vec3(sensorToWorldScale), getOrientation(), getWorldPosition());
|
glm::mat4 desiredMat = createMatFromScaleQuatAndPos(glm::vec3(sensorToWorldScale), getWorldOrientation(), getWorldPosition());
|
||||||
_sensorToWorldMatrix = desiredMat * glm::inverse(_bodySensorMatrix);
|
_sensorToWorldMatrix = desiredMat * glm::inverse(_bodySensorMatrix);
|
||||||
|
|
||||||
lateUpdatePalms();
|
lateUpdatePalms();
|
||||||
|
@ -784,7 +784,7 @@ controller::Pose MyAvatar::getRightHandTipPose() const {
|
||||||
|
|
||||||
glm::vec3 MyAvatar::worldToJointPoint(const glm::vec3& position, const int jointIndex) const {
|
glm::vec3 MyAvatar::worldToJointPoint(const glm::vec3& position, const int jointIndex) const {
|
||||||
glm::vec3 jointPos = getWorldPosition();//default value if no or invalid joint specified
|
glm::vec3 jointPos = getWorldPosition();//default value if no or invalid joint specified
|
||||||
glm::quat jointRot = getRotation();//default value if no or invalid joint specified
|
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
|
||||||
if (jointIndex != -1) {
|
if (jointIndex != -1) {
|
||||||
if (_skeletonModel->getJointPositionInWorldFrame(jointIndex, jointPos)) {
|
if (_skeletonModel->getJointPositionInWorldFrame(jointIndex, jointPos)) {
|
||||||
_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot);
|
_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot);
|
||||||
|
@ -799,7 +799,7 @@ glm::vec3 MyAvatar::worldToJointPoint(const glm::vec3& position, const int joint
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 MyAvatar::worldToJointDirection(const glm::vec3& worldDir, const int jointIndex) const {
|
glm::vec3 MyAvatar::worldToJointDirection(const glm::vec3& worldDir, const int jointIndex) const {
|
||||||
glm::quat jointRot = getRotation();//default value if no or invalid joint specified
|
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
|
||||||
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
||||||
qWarning() << "Invalid joint index specified: " << jointIndex;
|
qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||||
}
|
}
|
||||||
|
@ -809,7 +809,7 @@ glm::vec3 MyAvatar::worldToJointDirection(const glm::vec3& worldDir, const int j
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat MyAvatar::worldToJointRotation(const glm::quat& worldRot, const int jointIndex) const {
|
glm::quat MyAvatar::worldToJointRotation(const glm::quat& worldRot, const int jointIndex) const {
|
||||||
glm::quat jointRot = getRotation();//default value if no or invalid joint specified
|
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
|
||||||
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
||||||
qWarning() << "Invalid joint index specified: " << jointIndex;
|
qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||||
}
|
}
|
||||||
|
@ -819,7 +819,7 @@ glm::quat MyAvatar::worldToJointRotation(const glm::quat& worldRot, const int jo
|
||||||
|
|
||||||
glm::vec3 MyAvatar::jointToWorldPoint(const glm::vec3& jointSpacePos, const int jointIndex) const {
|
glm::vec3 MyAvatar::jointToWorldPoint(const glm::vec3& jointSpacePos, const int jointIndex) const {
|
||||||
glm::vec3 jointPos = getWorldPosition();//default value if no or invalid joint specified
|
glm::vec3 jointPos = getWorldPosition();//default value if no or invalid joint specified
|
||||||
glm::quat jointRot = getRotation();//default value if no or invalid joint specified
|
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
|
||||||
|
|
||||||
if (jointIndex != -1) {
|
if (jointIndex != -1) {
|
||||||
if (_skeletonModel->getJointPositionInWorldFrame(jointIndex, jointPos)) {
|
if (_skeletonModel->getJointPositionInWorldFrame(jointIndex, jointPos)) {
|
||||||
|
@ -836,7 +836,7 @@ glm::vec3 MyAvatar::jointToWorldPoint(const glm::vec3& jointSpacePos, const int
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 MyAvatar::jointToWorldDirection(const glm::vec3& jointSpaceDir, const int jointIndex) const {
|
glm::vec3 MyAvatar::jointToWorldDirection(const glm::vec3& jointSpaceDir, const int jointIndex) const {
|
||||||
glm::quat jointRot = getRotation();//default value if no or invalid joint specified
|
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
|
||||||
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
||||||
qWarning() << "Invalid joint index specified: " << jointIndex;
|
qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||||
}
|
}
|
||||||
|
@ -845,7 +845,7 @@ glm::vec3 MyAvatar::jointToWorldDirection(const glm::vec3& jointSpaceDir, const
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat MyAvatar::jointToWorldRotation(const glm::quat& jointSpaceRot, const int jointIndex) const {
|
glm::quat MyAvatar::jointToWorldRotation(const glm::quat& jointSpaceRot, const int jointIndex) const {
|
||||||
glm::quat jointRot = getRotation();//default value if no or invalid joint specified
|
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
|
||||||
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
||||||
qWarning() << "Invalid joint index specified: " << jointIndex;
|
qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||||
}
|
}
|
||||||
|
@ -1301,7 +1301,7 @@ eyeContactTarget MyAvatar::getEyeContactTarget() {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 MyAvatar::getDefaultEyePosition() const {
|
glm::vec3 MyAvatar::getDefaultEyePosition() const {
|
||||||
return getWorldPosition() + getOrientation() * Quaternions::Y_180 * _skeletonModel->getDefaultEyeModelPosition();
|
return getWorldPosition() + getWorldOrientation() * Quaternions::Y_180 * _skeletonModel->getDefaultEyeModelPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
const float SCRIPT_PRIORITY = 1.0f + 1.0f;
|
const float SCRIPT_PRIORITY = 1.0f + 1.0f;
|
||||||
|
@ -1460,7 +1460,7 @@ glm::vec3 MyAvatar::getSkeletonPosition() const {
|
||||||
// The avatar is rotated PI about the yAxis, so we have to correct for it
|
// The avatar is rotated PI about the yAxis, so we have to correct for it
|
||||||
// to get the skeleton offset contribution in the world-frame.
|
// to get the skeleton offset contribution in the world-frame.
|
||||||
const glm::quat FLIP = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
const glm::quat FLIP = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
return getWorldPosition() + getOrientation() * FLIP * _skeletonOffset;
|
return getWorldPosition() + getWorldOrientation() * FLIP * _skeletonOffset;
|
||||||
}
|
}
|
||||||
return Avatar::getWorldPosition();
|
return Avatar::getWorldPosition();
|
||||||
}
|
}
|
||||||
|
@ -1508,7 +1508,7 @@ controller::Pose MyAvatar::getControllerPoseInWorldFrame(controller::Action acti
|
||||||
controller::Pose MyAvatar::getControllerPoseInAvatarFrame(controller::Action action) const {
|
controller::Pose MyAvatar::getControllerPoseInAvatarFrame(controller::Action action) const {
|
||||||
auto pose = getControllerPoseInWorldFrame(action);
|
auto pose = getControllerPoseInWorldFrame(action);
|
||||||
if (pose.valid) {
|
if (pose.valid) {
|
||||||
glm::mat4 invAvatarMatrix = glm::inverse(createMatFromQuatAndPos(getOrientation(), getWorldPosition()));
|
glm::mat4 invAvatarMatrix = glm::inverse(createMatFromQuatAndPos(getWorldOrientation(), getWorldPosition()));
|
||||||
return pose.transform(invAvatarMatrix);
|
return pose.transform(invAvatarMatrix);
|
||||||
} else {
|
} else {
|
||||||
return controller::Pose(); // invalid pose
|
return controller::Pose(); // invalid pose
|
||||||
|
@ -1527,7 +1527,7 @@ void MyAvatar::updateMotors() {
|
||||||
// we decompose camera's rotation and store the twist part in motorRotation
|
// we decompose camera's rotation and store the twist part in motorRotation
|
||||||
// however, we need to perform the decomposition in the avatar-frame
|
// however, we need to perform the decomposition in the avatar-frame
|
||||||
// using the local UP axis and then transform back into world-frame
|
// using the local UP axis and then transform back into world-frame
|
||||||
glm::quat orientation = getOrientation();
|
glm::quat orientation = getWorldOrientation();
|
||||||
glm::quat headOrientation = glm::inverse(orientation) * getMyHead()->getHeadOrientation(); // avatar-frame
|
glm::quat headOrientation = glm::inverse(orientation) * getMyHead()->getHeadOrientation(); // avatar-frame
|
||||||
glm::quat liftRotation;
|
glm::quat liftRotation;
|
||||||
swingTwistDecomposition(headOrientation, Vectors::UNIT_Y, liftRotation, motorRotation);
|
swingTwistDecomposition(headOrientation, Vectors::UNIT_Y, liftRotation, motorRotation);
|
||||||
|
@ -1547,7 +1547,7 @@ void MyAvatar::updateMotors() {
|
||||||
if (_scriptedMotorFrame == SCRIPTED_MOTOR_CAMERA_FRAME) {
|
if (_scriptedMotorFrame == SCRIPTED_MOTOR_CAMERA_FRAME) {
|
||||||
motorRotation = getMyHead()->getHeadOrientation() * glm::angleAxis(PI, Vectors::UNIT_Y);
|
motorRotation = getMyHead()->getHeadOrientation() * glm::angleAxis(PI, Vectors::UNIT_Y);
|
||||||
} else if (_scriptedMotorFrame == SCRIPTED_MOTOR_AVATAR_FRAME) {
|
} else if (_scriptedMotorFrame == SCRIPTED_MOTOR_AVATAR_FRAME) {
|
||||||
motorRotation = getOrientation() * glm::angleAxis(PI, Vectors::UNIT_Y);
|
motorRotation = getWorldOrientation() * glm::angleAxis(PI, Vectors::UNIT_Y);
|
||||||
} else {
|
} else {
|
||||||
// world-frame
|
// world-frame
|
||||||
motorRotation = glm::quat();
|
motorRotation = glm::quat();
|
||||||
|
@ -1575,7 +1575,7 @@ void MyAvatar::prepareForPhysicsSimulation() {
|
||||||
_characterController.setParentVelocity(parentVelocity);
|
_characterController.setParentVelocity(parentVelocity);
|
||||||
_characterController.setScaleFactor(getSensorToWorldScale());
|
_characterController.setScaleFactor(getSensorToWorldScale());
|
||||||
|
|
||||||
_characterController.setPositionAndOrientation(getWorldPosition(), getOrientation());
|
_characterController.setPositionAndOrientation(getWorldPosition(), getWorldOrientation());
|
||||||
auto headPose = getControllerPoseInAvatarFrame(controller::Action::HEAD);
|
auto headPose = getControllerPoseInAvatarFrame(controller::Action::HEAD);
|
||||||
if (headPose.isValid()) {
|
if (headPose.isValid()) {
|
||||||
_follow.prePhysicsUpdate(*this, deriveBodyFromHMDSensor(), _bodySensorMatrix, hasDriveInput());
|
_follow.prePhysicsUpdate(*this, deriveBodyFromHMDSensor(), _bodySensorMatrix, hasDriveInput());
|
||||||
|
@ -1610,7 +1610,7 @@ void MyAvatar::harvestResultsFromPhysicsSimulation(float deltaTime) {
|
||||||
_characterController.getPositionAndOrientation(position, orientation);
|
_characterController.getPositionAndOrientation(position, orientation);
|
||||||
} else {
|
} else {
|
||||||
position = getWorldPosition();
|
position = getWorldPosition();
|
||||||
orientation = getOrientation();
|
orientation = getWorldOrientation();
|
||||||
}
|
}
|
||||||
nextAttitude(position, orientation);
|
nextAttitude(position, orientation);
|
||||||
_bodySensorMatrix = _follow.postPhysicsUpdate(*this, _bodySensorMatrix);
|
_bodySensorMatrix = _follow.postPhysicsUpdate(*this, _bodySensorMatrix);
|
||||||
|
@ -1847,14 +1847,14 @@ void MyAvatar::postUpdate(float deltaTime, const render::ScenePointer& scene) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugDraw::getInstance().updateMyAvatarPos(getWorldPosition());
|
DebugDraw::getInstance().updateMyAvatarPos(getWorldPosition());
|
||||||
DebugDraw::getInstance().updateMyAvatarRot(getOrientation());
|
DebugDraw::getInstance().updateMyAvatarRot(getWorldOrientation());
|
||||||
|
|
||||||
AnimPose postUpdateRoomPose(_sensorToWorldMatrix);
|
AnimPose postUpdateRoomPose(_sensorToWorldMatrix);
|
||||||
|
|
||||||
updateHoldActions(_prePhysicsRoomPose, postUpdateRoomPose);
|
updateHoldActions(_prePhysicsRoomPose, postUpdateRoomPose);
|
||||||
|
|
||||||
if (_enableDebugDrawDetailedCollision) {
|
if (_enableDebugDrawDetailedCollision) {
|
||||||
AnimPose rigToWorldPose(glm::vec3(1.0f), getRotation() * Quaternions::Y_180, getWorldPosition());
|
AnimPose rigToWorldPose(glm::vec3(1.0f), getWorldOrientation() * Quaternions::Y_180, getWorldPosition());
|
||||||
const int NUM_DEBUG_COLORS = 8;
|
const int NUM_DEBUG_COLORS = 8;
|
||||||
const glm::vec4 DEBUG_COLORS[NUM_DEBUG_COLORS] = {
|
const glm::vec4 DEBUG_COLORS[NUM_DEBUG_COLORS] = {
|
||||||
glm::vec4(1.0f, 1.0f, 1.0f, 1.0f),
|
glm::vec4(1.0f, 1.0f, 1.0f, 1.0f),
|
||||||
|
@ -1972,7 +1972,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
speedFactor = glm::min(speed / _lastDrivenSpeed, 1.0f);
|
speedFactor = glm::min(speed / _lastDrivenSpeed, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float direction = glm::dot(getVelocity(), getRotation() * Vectors::UNIT_NEG_Z) > 0.0f ? 1.0f : -1.0f;
|
float direction = glm::dot(getVelocity(), getWorldOrientation() * Vectors::UNIT_NEG_Z) > 0.0f ? 1.0f : -1.0f;
|
||||||
|
|
||||||
float rollAngle = glm::degrees(asinf(glm::dot(IDENTITY_UP, _hmdSensorOrientation * IDENTITY_RIGHT)));
|
float rollAngle = glm::degrees(asinf(glm::dot(IDENTITY_UP, _hmdSensorOrientation * IDENTITY_RIGHT)));
|
||||||
float rollSign = rollAngle < 0.0f ? -1.0f : 1.0f;
|
float rollSign = rollAngle < 0.0f ? -1.0f : 1.0f;
|
||||||
|
@ -1985,12 +1985,12 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
|
|
||||||
// update body orientation by movement inputs
|
// update body orientation by movement inputs
|
||||||
glm::quat initialOrientation = getOrientationOutbound();
|
glm::quat initialOrientation = getOrientationOutbound();
|
||||||
setOrientation(getOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
|
setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
|
||||||
|
|
||||||
if (snapTurn) {
|
if (snapTurn) {
|
||||||
// Whether or not there is an existing smoothing going on, just reset the smoothing timer and set the starting position as the avatar's current position, then smooth to the new position.
|
// Whether or not there is an existing smoothing going on, just reset the smoothing timer and set the starting position as the avatar's current position, then smooth to the new position.
|
||||||
_smoothOrientationInitial = initialOrientation;
|
_smoothOrientationInitial = initialOrientation;
|
||||||
_smoothOrientationTarget = getOrientation();
|
_smoothOrientationTarget = getWorldOrientation();
|
||||||
_smoothOrientationTimer = 0.0f;
|
_smoothOrientationTimer = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2107,7 +2107,7 @@ void MyAvatar::updatePosition(float deltaTime) {
|
||||||
// scan for walkability
|
// scan for walkability
|
||||||
glm::vec3 position = getWorldPosition();
|
glm::vec3 position = getWorldPosition();
|
||||||
MyCharacterController::RayShotgunResult result;
|
MyCharacterController::RayShotgunResult result;
|
||||||
glm::vec3 step = deltaTime * (getRotation() * _actionMotorVelocity);
|
glm::vec3 step = deltaTime * (getWorldOrientation() * _actionMotorVelocity);
|
||||||
_characterController.testRayShotgun(position, step, result);
|
_characterController.testRayShotgun(position, step, result);
|
||||||
_characterController.setStepUpEnabled(result.walkable);
|
_characterController.setStepUpEnabled(result.walkable);
|
||||||
}
|
}
|
||||||
|
@ -2325,7 +2325,7 @@ void MyAvatar::goToLocation(const glm::vec3& newPosition,
|
||||||
|
|
||||||
_goToPending = true;
|
_goToPending = true;
|
||||||
_goToPosition = newPosition;
|
_goToPosition = newPosition;
|
||||||
_goToOrientation = getOrientation();
|
_goToOrientation = getWorldOrientation();
|
||||||
if (hasOrientation) {
|
if (hasOrientation) {
|
||||||
qCDebug(interfaceapp).nospace() << "MyAvatar goToLocation - new orientation is "
|
qCDebug(interfaceapp).nospace() << "MyAvatar goToLocation - new orientation is "
|
||||||
<< newOrientation.x << ", " << newOrientation.y << ", " << newOrientation.z << ", " << newOrientation.w;
|
<< newOrientation.x << ", " << newOrientation.y << ", " << newOrientation.z << ", " << newOrientation.w;
|
||||||
|
@ -2394,7 +2394,7 @@ bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& bette
|
||||||
return false; // no entity tree
|
return false; // no entity tree
|
||||||
}
|
}
|
||||||
// More utilities.
|
// More utilities.
|
||||||
const auto offset = getOrientation() *_characterController.getCapsuleLocalOffset();
|
const auto offset = getWorldOrientation() *_characterController.getCapsuleLocalOffset();
|
||||||
const auto capsuleCenter = positionIn + offset;
|
const auto capsuleCenter = positionIn + offset;
|
||||||
const auto up = _worldUpDirection, down = -up;
|
const auto up = _worldUpDirection, down = -up;
|
||||||
glm::vec3 upperIntersection, upperNormal, lowerIntersection, lowerNormal;
|
glm::vec3 upperIntersection, upperNormal, lowerIntersection, lowerNormal;
|
||||||
|
@ -2960,7 +2960,7 @@ glm::mat4 MyAvatar::computeCameraRelativeHandControllerMatrix(const glm::mat4& c
|
||||||
glm::mat4 controllerWorldMatrix = getSensorToWorldMatrix() * delta * controllerSensorMatrix;
|
glm::mat4 controllerWorldMatrix = getSensorToWorldMatrix() * delta * controllerSensorMatrix;
|
||||||
|
|
||||||
// transform controller into avatar space
|
// transform controller into avatar space
|
||||||
glm::mat4 avatarMatrix = createMatFromQuatAndPos(getOrientation(), getWorldPosition());
|
glm::mat4 avatarMatrix = createMatFromQuatAndPos(getWorldOrientation(), getWorldPosition());
|
||||||
return glm::inverse(avatarMatrix) * controllerWorldMatrix;
|
return glm::inverse(avatarMatrix) * controllerWorldMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3164,7 +3164,7 @@ bool MyAvatar::pinJoint(int index, const glm::vec3& position, const glm::quat& o
|
||||||
}
|
}
|
||||||
|
|
||||||
slamPosition(position);
|
slamPosition(position);
|
||||||
setOrientation(orientation);
|
setWorldOrientation(orientation);
|
||||||
|
|
||||||
_skeletonModel->getRig().setMaxHipsOffsetLength(0.05f);
|
_skeletonModel->getRig().setMaxHipsOffsetLength(0.05f);
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ void MyCharacterController::updateShapeIfNecessary() {
|
||||||
|
|
||||||
_rigidBody->setSleepingThresholds(0.0f, 0.0f);
|
_rigidBody->setSleepingThresholds(0.0f, 0.0f);
|
||||||
_rigidBody->setAngularFactor(0.0f);
|
_rigidBody->setAngularFactor(0.0f);
|
||||||
_rigidBody->setWorldTransform(btTransform(glmToBullet(_avatar->getOrientation()),
|
_rigidBody->setWorldTransform(btTransform(glmToBullet(_avatar->getWorldOrientation()),
|
||||||
glmToBullet(_avatar->getWorldPosition())));
|
glmToBullet(_avatar->getWorldPosition())));
|
||||||
_rigidBody->setDamping(0.0f, 0.0f);
|
_rigidBody->setDamping(0.0f, 0.0f);
|
||||||
if (_state == State::Hover) {
|
if (_state == State::Hover) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ glm::quat MyHead::getHeadOrientation() const {
|
||||||
return headPose.rotation * Quaternions::Y_180;
|
return headPose.rotation * Quaternions::Y_180;
|
||||||
}
|
}
|
||||||
|
|
||||||
return myAvatar->getOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.0f, 0.0f)));
|
return myAvatar->getWorldOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.0f, 0.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyHead::simulate(float deltaTime) {
|
void MyHead::simulate(float deltaTime) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ const PickRay JointRayPick::getPickRay(bool& valid) const {
|
||||||
glm::vec3 jointPos = useAvatarHead ? myAvatar->getHeadPosition() : myAvatar->getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
glm::vec3 jointPos = useAvatarHead ? myAvatar->getHeadPosition() : myAvatar->getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
||||||
glm::quat jointRot = useAvatarHead ? myAvatar->getHeadOrientation() : myAvatar->getAbsoluteJointRotationInObjectFrame(jointIndex);
|
glm::quat jointRot = useAvatarHead ? myAvatar->getHeadOrientation() : myAvatar->getAbsoluteJointRotationInObjectFrame(jointIndex);
|
||||||
glm::vec3 avatarPos = myAvatar->getWorldPosition();
|
glm::vec3 avatarPos = myAvatar->getWorldPosition();
|
||||||
glm::quat avatarRot = myAvatar->getOrientation();
|
glm::quat avatarRot = myAvatar->getWorldOrientation();
|
||||||
|
|
||||||
glm::vec3 pos = useAvatarHead ? jointPos : avatarPos + (avatarRot * jointPos);
|
glm::vec3 pos = useAvatarHead ? jointPos : avatarPos + (avatarRot * jointPos);
|
||||||
glm::quat rot = useAvatarHead ? jointRot * glm::angleAxis(-PI / 2.0f, Vectors::RIGHT) : avatarRot * jointRot;
|
glm::quat rot = useAvatarHead ? jointRot * glm::angleAxis(-PI / 2.0f, Vectors::RIGHT) : avatarRot * jointRot;
|
||||||
|
|
|
@ -162,7 +162,7 @@ void LaserPointer::updateRenderState(const RenderState& renderState, const Inter
|
||||||
}
|
}
|
||||||
if (!renderState.getEndID().isNull()) {
|
if (!renderState.getEndID().isNull()) {
|
||||||
QVariantMap endProps;
|
QVariantMap endProps;
|
||||||
glm::quat faceAvatarRotation = DependencyManager::get<AvatarManager>()->getMyAvatar()->getOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, 180.0f, 0.0f)));
|
glm::quat faceAvatarRotation = DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, 180.0f, 0.0f)));
|
||||||
glm::vec3 dim = vec3FromVariant(qApp->getOverlays().getProperty(renderState.getEndID(), "dimensions").value);
|
glm::vec3 dim = vec3FromVariant(qApp->getOverlays().getProperty(renderState.getEndID(), "dimensions").value);
|
||||||
if (_distanceScaleEnd) {
|
if (_distanceScaleEnd) {
|
||||||
dim = renderState.getEndDim() * glm::distance(pickRay.origin, endVec) * DependencyManager::get<AvatarManager>()->getMyAvatar()->getSensorToWorldScale();
|
dim = renderState.getEndDim() * glm::distance(pickRay.origin, endVec) * DependencyManager::get<AvatarManager>()->getMyAvatar()->getSensorToWorldScale();
|
||||||
|
|
|
@ -117,7 +117,7 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
|
||||||
properties["position"] = vec3toVariant(getWorldPosition());
|
properties["position"] = vec3toVariant(getWorldPosition());
|
||||||
}
|
}
|
||||||
if (!properties["orientation"].isValid() && !properties["localOrientation"].isValid()) {
|
if (!properties["orientation"].isValid() && !properties["localOrientation"].isValid()) {
|
||||||
properties["orientation"] = quatToVariant(getOrientation());
|
properties["orientation"] = quatToVariant(getWorldOrientation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ QVariant Base3DOverlay::getProperty(const QString& property) {
|
||||||
return vec3toVariant(getLocalPosition());
|
return vec3toVariant(getLocalPosition());
|
||||||
}
|
}
|
||||||
if (property == "rotation" || property == "orientation") {
|
if (property == "rotation" || property == "orientation") {
|
||||||
return quatToVariant(getOrientation());
|
return quatToVariant(getWorldOrientation());
|
||||||
}
|
}
|
||||||
if (property == "localRotation" || property == "localOrientation") {
|
if (property == "localRotation" || property == "localOrientation") {
|
||||||
return quatToVariant(getLocalOrientation());
|
return quatToVariant(getLocalOrientation());
|
||||||
|
|
|
@ -35,7 +35,7 @@ bool Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offse
|
||||||
glm::vec3 billboardPos = transform.getTranslation();
|
glm::vec3 billboardPos = transform.getTranslation();
|
||||||
glm::vec3 cameraPos = qApp->getCamera().getPosition();
|
glm::vec3 cameraPos = qApp->getCamera().getPosition();
|
||||||
// use the referencial from the avatar, y isn't always up
|
// use the referencial from the avatar, y isn't always up
|
||||||
glm::vec3 avatarUP = DependencyManager::get<AvatarManager>()->getMyAvatar()->getOrientation()*Vectors::UP;
|
glm::vec3 avatarUP = DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldOrientation()*Vectors::UP;
|
||||||
|
|
||||||
glm::quat rotation(conjugate(toQuat(glm::lookAt(billboardPos, cameraPos, avatarUP))));
|
glm::quat rotation(conjugate(toQuat(glm::lookAt(billboardPos, cameraPos, avatarUP))));
|
||||||
|
|
||||||
|
|
|
@ -415,11 +415,11 @@ bool Circle3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::ve
|
||||||
|
|
||||||
// Scale the dimensions by the diameter
|
// Scale the dimensions by the diameter
|
||||||
glm::vec2 dimensions = getOuterRadius() * 2.0f * getDimensions();
|
glm::vec2 dimensions = getOuterRadius() * 2.0f * getDimensions();
|
||||||
bool intersects = findRayRectangleIntersection(origin, direction, getRotation(), getWorldPosition(), dimensions, distance);
|
bool intersects = findRayRectangleIntersection(origin, direction, getWorldOrientation(), getWorldPosition(), dimensions, distance);
|
||||||
|
|
||||||
if (intersects) {
|
if (intersects) {
|
||||||
glm::vec3 hitPosition = origin + (distance * direction);
|
glm::vec3 hitPosition = origin + (distance * direction);
|
||||||
glm::vec3 localHitPosition = glm::inverse(getRotation()) * (hitPosition - getWorldPosition());
|
glm::vec3 localHitPosition = glm::inverse(getWorldOrientation()) * (hitPosition - getWorldPosition());
|
||||||
localHitPosition.x /= getDimensions().x;
|
localHitPosition.x /= getDimensions().x;
|
||||||
localHitPosition.y /= getDimensions().y;
|
localHitPosition.y /= getDimensions().y;
|
||||||
float distanceToHit = glm::length(localHitPosition);
|
float distanceToHit = glm::length(localHitPosition);
|
||||||
|
|
|
@ -163,7 +163,7 @@ bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID&
|
||||||
}
|
}
|
||||||
_contextOverlay->setWorldPosition(contextOverlayPosition);
|
_contextOverlay->setWorldPosition(contextOverlayPosition);
|
||||||
_contextOverlay->setDimensions(contextOverlayDimensions);
|
_contextOverlay->setDimensions(contextOverlayDimensions);
|
||||||
_contextOverlay->setRotation(entityProperties.getRotation());
|
_contextOverlay->setWorldOrientation(entityProperties.getRotation());
|
||||||
_contextOverlay->setVisible(true);
|
_contextOverlay->setVisible(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -146,7 +146,7 @@ Transform Cube3DOverlay::evalRenderTransform() {
|
||||||
// TODO: handle registration point??
|
// TODO: handle registration point??
|
||||||
glm::vec3 position = getWorldPosition();
|
glm::vec3 position = getWorldPosition();
|
||||||
glm::vec3 dimensions = getDimensions();
|
glm::vec3 dimensions = getDimensions();
|
||||||
glm::quat rotation = getRotation();
|
glm::quat rotation = getWorldOrientation();
|
||||||
|
|
||||||
Transform transform;
|
Transform transform;
|
||||||
transform.setScale(dimensions);
|
transform.setScale(dimensions);
|
||||||
|
|
|
@ -146,7 +146,7 @@ void Grid3DOverlay::updateGrid() {
|
||||||
|
|
||||||
Transform Grid3DOverlay::evalRenderTransform() {
|
Transform Grid3DOverlay::evalRenderTransform() {
|
||||||
Transform transform;
|
Transform transform;
|
||||||
transform.setRotation(getRotation());
|
transform.setRotation(getWorldOrientation());
|
||||||
transform.setScale(glm::vec3(getDimensions(), 1.0f));
|
transform.setScale(glm::vec3(getDimensions(), 1.0f));
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ void ModelOverlay::setDrawHUDLayer(bool drawHUDLayer) {
|
||||||
|
|
||||||
void ModelOverlay::setProperties(const QVariantMap& properties) {
|
void ModelOverlay::setProperties(const QVariantMap& properties) {
|
||||||
auto origPosition = getWorldPosition();
|
auto origPosition = getWorldPosition();
|
||||||
auto origRotation = getRotation();
|
auto origRotation = getWorldOrientation();
|
||||||
auto origDimensions = getDimensions();
|
auto origDimensions = getDimensions();
|
||||||
auto origScale = getSNScale();
|
auto origScale = getSNScale();
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ void ModelOverlay::setProperties(const QVariantMap& properties) {
|
||||||
_scaleToFit = false;
|
_scaleToFit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (origPosition != getWorldPosition() || origRotation != getRotation() || origDimensions != getDimensions() || origScale != getSNScale()) {
|
if (origPosition != getWorldPosition() || origRotation != getWorldOrientation() || origDimensions != getDimensions() || origScale != getSNScale()) {
|
||||||
_updateModel = true;
|
_updateModel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ void ModelOverlay::locationChanged(bool tellPhysics) {
|
||||||
|
|
||||||
// FIXME Start using the _renderTransform instead of calling for Transform and Dimensions from here, do the custom things needed in evalRenderTransform()
|
// FIXME Start using the _renderTransform instead of calling for Transform and Dimensions from here, do the custom things needed in evalRenderTransform()
|
||||||
if (_model && _model->isActive()) {
|
if (_model && _model->isActive()) {
|
||||||
_model->setRotation(getRotation());
|
_model->setRotation(getWorldOrientation());
|
||||||
_model->setTranslation(getWorldPosition());
|
_model->setTranslation(getWorldPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -828,7 +828,7 @@ PointerEvent Overlays::calculateOverlayPointerEvent(OverlayID overlayID, PickRay
|
||||||
return PointerEvent();
|
return PointerEvent();
|
||||||
}
|
}
|
||||||
glm::vec3 position = overlay->getWorldPosition();
|
glm::vec3 position = overlay->getWorldPosition();
|
||||||
glm::quat rotation = overlay->getRotation();
|
glm::quat rotation = overlay->getWorldOrientation();
|
||||||
glm::vec2 dimensions = overlay->getSize();
|
glm::vec2 dimensions = overlay->getSize();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace render {
|
||||||
if (overlay->getAnchor() == Overlay::MY_AVATAR) {
|
if (overlay->getAnchor() == Overlay::MY_AVATAR) {
|
||||||
auto batch = args->_batch;
|
auto batch = args->_batch;
|
||||||
auto avatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
auto avatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||||
glm::quat myAvatarRotation = avatar->getOrientation();
|
glm::quat myAvatarRotation = avatar->getWorldOrientation();
|
||||||
glm::vec3 myAvatarPosition = avatar->getWorldPosition();
|
glm::vec3 myAvatarPosition = avatar->getWorldPosition();
|
||||||
float angle = glm::degrees(glm::angle(myAvatarRotation));
|
float angle = glm::degrees(glm::angle(myAvatarRotation));
|
||||||
glm::vec3 axis = glm::axis(myAvatarRotation);
|
glm::vec3 axis = glm::axis(myAvatarRotation);
|
||||||
|
|
|
@ -69,7 +69,7 @@ QVariant Planar3DOverlay::getProperty(const QString& property) {
|
||||||
bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
|
float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
|
||||||
// FIXME - face and surfaceNormal not being returned
|
// FIXME - face and surfaceNormal not being returned
|
||||||
return findRayRectangleIntersection(origin, direction, getRotation(), getWorldPosition(), getDimensions(), distance);
|
return findRayRectangleIntersection(origin, direction, getWorldOrientation(), getWorldPosition(), getDimensions(), distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform Planar3DOverlay::evalRenderTransform() {
|
Transform Planar3DOverlay::evalRenderTransform() {
|
||||||
|
|
|
@ -61,7 +61,7 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
|
||||||
glm::vec3 position = getWorldPosition();
|
glm::vec3 position = getWorldPosition();
|
||||||
glm::vec2 dimensions = getDimensions();
|
glm::vec2 dimensions = getDimensions();
|
||||||
glm::vec2 halfDimensions = dimensions * 0.5f;
|
glm::vec2 halfDimensions = dimensions * 0.5f;
|
||||||
glm::quat rotation = getRotation();
|
glm::quat rotation = getWorldOrientation();
|
||||||
|
|
||||||
auto batch = args->_batch;
|
auto batch = args->_batch;
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ Transform Shape3DOverlay::evalRenderTransform() {
|
||||||
// TODO: handle registration point??
|
// TODO: handle registration point??
|
||||||
glm::vec3 position = getWorldPosition();
|
glm::vec3 position = getWorldPosition();
|
||||||
glm::vec3 dimensions = getDimensions();
|
glm::vec3 dimensions = getDimensions();
|
||||||
glm::quat rotation = getRotation();
|
glm::quat rotation = getWorldOrientation();
|
||||||
|
|
||||||
Transform transform;
|
Transform transform;
|
||||||
transform.setScale(dimensions);
|
transform.setScale(dimensions);
|
||||||
|
|
|
@ -20,7 +20,7 @@ Volume3DOverlay::Volume3DOverlay(const Volume3DOverlay* volume3DOverlay) :
|
||||||
|
|
||||||
AABox Volume3DOverlay::getBounds() const {
|
AABox Volume3DOverlay::getBounds() const {
|
||||||
auto extents = Extents{_localBoundingBox};
|
auto extents = Extents{_localBoundingBox};
|
||||||
extents.rotate(getRotation());
|
extents.rotate(getWorldOrientation());
|
||||||
extents.shiftBy(getWorldPosition());
|
extents.shiftBy(getWorldPosition());
|
||||||
|
|
||||||
return AABox(extents);
|
return AABox(extents);
|
||||||
|
|
|
@ -615,7 +615,7 @@ bool Web3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3&
|
||||||
// Don't call applyTransformTo() or setTransform() here because this code runs too frequently.
|
// Don't call applyTransformTo() or setTransform() here because this code runs too frequently.
|
||||||
|
|
||||||
// Produce the dimensions of the overlay based on the image's aspect ratio and the overlay's scale.
|
// Produce the dimensions of the overlay based on the image's aspect ratio and the overlay's scale.
|
||||||
return findRayRectangleIntersection(origin, direction, getRotation(), getWorldPosition(), getSize(), distance);
|
return findRayRectangleIntersection(origin, direction, getWorldOrientation(), getWorldPosition(), getSize(), distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
Web3DOverlay* Web3DOverlay::createClone() const {
|
Web3DOverlay* Web3DOverlay::createClone() const {
|
||||||
|
|
|
@ -456,11 +456,11 @@ void Avatar::measureMotionDerivatives(float deltaTime) {
|
||||||
setVelocity(velocity);
|
setVelocity(velocity);
|
||||||
|
|
||||||
// angular
|
// angular
|
||||||
glm::quat orientation = getOrientation();
|
glm::quat orientation = getWorldOrientation();
|
||||||
glm::quat delta = glm::inverse(_lastOrientation) * orientation;
|
glm::quat delta = glm::inverse(_lastOrientation) * orientation;
|
||||||
glm::vec3 angularVelocity = glm::axis(delta) * glm::angle(delta) * invDeltaTime;
|
glm::vec3 angularVelocity = glm::axis(delta) * glm::angle(delta) * invDeltaTime;
|
||||||
setAngularVelocity(angularVelocity);
|
setAngularVelocity(angularVelocity);
|
||||||
_lastOrientation = getOrientation();
|
_lastOrientation = getWorldOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TextRendererType {
|
enum TextRendererType {
|
||||||
|
@ -722,7 +722,7 @@ void Avatar::simulateAttachments(float deltaTime) {
|
||||||
if (attachment.isSoft) {
|
if (attachment.isSoft) {
|
||||||
// soft attachments do not have transform offsets
|
// soft attachments do not have transform offsets
|
||||||
model->setTranslation(getWorldPosition());
|
model->setTranslation(getWorldPosition());
|
||||||
model->setRotation(getOrientation() * Quaternions::Y_180);
|
model->setRotation(getWorldOrientation() * Quaternions::Y_180);
|
||||||
model->simulate(deltaTime);
|
model->simulate(deltaTime);
|
||||||
} else {
|
} else {
|
||||||
if (_skeletonModel->getJointPositionInWorldFrame(jointIndex, jointPosition) &&
|
if (_skeletonModel->getJointPositionInWorldFrame(jointIndex, jointPosition) &&
|
||||||
|
@ -902,7 +902,7 @@ glm::vec3 Avatar::getSkeletonPosition() const {
|
||||||
// The avatar is rotated PI about the yAxis, so we have to correct for it
|
// The avatar is rotated PI about the yAxis, so we have to correct for it
|
||||||
// to get the skeleton offset contribution in the world-frame.
|
// to get the skeleton offset contribution in the world-frame.
|
||||||
const glm::quat FLIP = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
const glm::quat FLIP = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
return getWorldPosition() + getOrientation() * FLIP * _skeletonOffset;
|
return getWorldPosition() + getWorldOrientation() * FLIP * _skeletonOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<glm::quat> Avatar::getJointRotations() const {
|
QVector<glm::quat> Avatar::getJointRotations() const {
|
||||||
|
@ -1473,11 +1473,11 @@ glm::quat Avatar::getUncachedRightPalmRotation() const {
|
||||||
|
|
||||||
void Avatar::setPositionViaScript(const glm::vec3& position) {
|
void Avatar::setPositionViaScript(const glm::vec3& position) {
|
||||||
setWorldPosition(position);
|
setWorldPosition(position);
|
||||||
updateAttitude(getOrientation());
|
updateAttitude(getWorldOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::setOrientationViaScript(const glm::quat& orientation) {
|
void Avatar::setOrientationViaScript(const glm::quat& orientation) {
|
||||||
setOrientation(orientation);
|
setWorldOrientation(orientation);
|
||||||
updateAttitude(orientation);
|
updateAttitude(orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -318,8 +318,8 @@ protected:
|
||||||
|
|
||||||
void fade(render::Transaction& transaction, render::Transition::Type type);
|
void fade(render::Transaction& transaction, render::Transition::Type type);
|
||||||
|
|
||||||
glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
glm::vec3 getBodyRightDirection() const { return getWorldOrientation() * IDENTITY_RIGHT; }
|
||||||
glm::vec3 getBodyUpDirection() const { return getOrientation() * IDENTITY_UP; }
|
glm::vec3 getBodyUpDirection() const { return getWorldOrientation() * IDENTITY_UP; }
|
||||||
void measureMotionDerivatives(float deltaTime);
|
void measureMotionDerivatives(float deltaTime);
|
||||||
|
|
||||||
float getSkeletonHeight() const;
|
float getSkeletonHeight() const;
|
||||||
|
|
|
@ -253,7 +253,7 @@ void Head::setScale (float scale) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat Head::getFinalOrientationInWorldFrame() const {
|
glm::quat Head::getFinalOrientationInWorldFrame() const {
|
||||||
return _owningAvatar->getOrientation() * getFinalOrientationInLocalFrame();
|
return _owningAvatar->getWorldOrientation() * getFinalOrientationInLocalFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat Head::getFinalOrientationInLocalFrame() const {
|
glm::quat Head::getFinalOrientationInLocalFrame() const {
|
||||||
|
|
|
@ -127,7 +127,7 @@ void SkeletonModel::updateAttitude(const glm::quat& orientation) {
|
||||||
// Called by Avatar::simulate after it has set the joint states (fullUpdate true if changed),
|
// Called by Avatar::simulate after it has set the joint states (fullUpdate true if changed),
|
||||||
// but just before head has been simulated.
|
// but just before head has been simulated.
|
||||||
void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
|
void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
|
||||||
updateAttitude(_owningAvatar->getOrientation());
|
updateAttitude(_owningAvatar->getWorldOrientation());
|
||||||
if (fullUpdate) {
|
if (fullUpdate) {
|
||||||
setBlendshapeCoefficients(_owningAvatar->getHead()->getSummedBlendshapeCoefficients());
|
setBlendshapeCoefficients(_owningAvatar->getHead()->getSummedBlendshapeCoefficients());
|
||||||
|
|
||||||
|
|
|
@ -118,12 +118,12 @@ void AvatarData::setTargetScale(float targetScale) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 AvatarData::getHandPosition() const {
|
glm::vec3 AvatarData::getHandPosition() const {
|
||||||
return getOrientation() * _handPosition + getWorldPosition();
|
return getWorldOrientation() * _handPosition + getWorldPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setHandPosition(const glm::vec3& handPosition) {
|
void AvatarData::setHandPosition(const glm::vec3& handPosition) {
|
||||||
// store relative to position/orientation
|
// store relative to position/orientation
|
||||||
_handPosition = glm::inverse(getOrientation()) * (handPosition - getWorldPosition());
|
_handPosition = glm::inverse(getWorldOrientation()) * (handPosition - getWorldPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::lazyInitHeadData() const {
|
void AvatarData::lazyInitHeadData() const {
|
||||||
|
@ -1900,7 +1900,7 @@ void registerAvatarTypes(QScriptEngine* engine) {
|
||||||
void AvatarData::setRecordingBasis(std::shared_ptr<Transform> recordingBasis) {
|
void AvatarData::setRecordingBasis(std::shared_ptr<Transform> recordingBasis) {
|
||||||
if (!recordingBasis) {
|
if (!recordingBasis) {
|
||||||
recordingBasis = std::make_shared<Transform>();
|
recordingBasis = std::make_shared<Transform>();
|
||||||
recordingBasis->setRotation(getOrientation());
|
recordingBasis->setRotation(getWorldOrientation());
|
||||||
recordingBasis->setTranslation(getWorldPosition());
|
recordingBasis->setTranslation(getWorldPosition());
|
||||||
// TODO: find a different way to record/playback the Scale of the avatar
|
// TODO: find a different way to record/playback the Scale of the avatar
|
||||||
//recordingBasis->setScale(getTargetScale());
|
//recordingBasis->setScale(getTargetScale());
|
||||||
|
@ -2066,7 +2066,7 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) {
|
||||||
setWorldPosition(currentBasis->getTranslation());
|
setWorldPosition(currentBasis->getTranslation());
|
||||||
orientation = currentBasis->getRotation();
|
orientation = currentBasis->getRotation();
|
||||||
}
|
}
|
||||||
setOrientation(orientation);
|
setWorldOrientation(orientation);
|
||||||
updateAttitude(orientation);
|
updateAttitude(orientation);
|
||||||
|
|
||||||
// Do after avatar orientation because head look-at needs avatar orientation.
|
// Do after avatar orientation because head look-at needs avatar orientation.
|
||||||
|
@ -2153,36 +2153,36 @@ void AvatarData::fromFrame(const QByteArray& frameData, AvatarData& result, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
float AvatarData::getBodyYaw() const {
|
float AvatarData::getBodyYaw() const {
|
||||||
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
|
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
|
||||||
return eulerAngles.y;
|
return eulerAngles.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setBodyYaw(float bodyYaw) {
|
void AvatarData::setBodyYaw(float bodyYaw) {
|
||||||
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
|
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
|
||||||
eulerAngles.y = bodyYaw;
|
eulerAngles.y = bodyYaw;
|
||||||
setOrientation(glm::quat(glm::radians(eulerAngles)));
|
setWorldOrientation(glm::quat(glm::radians(eulerAngles)));
|
||||||
}
|
}
|
||||||
|
|
||||||
float AvatarData::getBodyPitch() const {
|
float AvatarData::getBodyPitch() const {
|
||||||
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
|
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
|
||||||
return eulerAngles.x;
|
return eulerAngles.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setBodyPitch(float bodyPitch) {
|
void AvatarData::setBodyPitch(float bodyPitch) {
|
||||||
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
|
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
|
||||||
eulerAngles.x = bodyPitch;
|
eulerAngles.x = bodyPitch;
|
||||||
setOrientation(glm::quat(glm::radians(eulerAngles)));
|
setWorldOrientation(glm::quat(glm::radians(eulerAngles)));
|
||||||
}
|
}
|
||||||
|
|
||||||
float AvatarData::getBodyRoll() const {
|
float AvatarData::getBodyRoll() const {
|
||||||
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
|
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
|
||||||
return eulerAngles.z;
|
return eulerAngles.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setBodyRoll(float bodyRoll) {
|
void AvatarData::setBodyRoll(float bodyRoll) {
|
||||||
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
|
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
|
||||||
eulerAngles.z = bodyRoll;
|
eulerAngles.z = bodyRoll;
|
||||||
setOrientation(glm::quat(glm::radians(eulerAngles)));
|
setWorldOrientation(glm::quat(glm::radians(eulerAngles)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setPositionViaScript(const glm::vec3& position) {
|
void AvatarData::setPositionViaScript(const glm::vec3& position) {
|
||||||
|
@ -2190,7 +2190,7 @@ void AvatarData::setPositionViaScript(const glm::vec3& position) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setOrientationViaScript(const glm::quat& orientation) {
|
void AvatarData::setOrientationViaScript(const glm::quat& orientation) {
|
||||||
SpatiallyNestable::setOrientation(orientation);
|
SpatiallyNestable::setWorldOrientation(orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat AvatarData::getAbsoluteJointRotationInObjectFrame(int index) const {
|
glm::quat AvatarData::getAbsoluteJointRotationInObjectFrame(int index) const {
|
||||||
|
|
|
@ -359,7 +359,7 @@ class AvatarData : public QObject, public SpatiallyNestable {
|
||||||
Q_PROPERTY(float bodyPitch READ getBodyPitch WRITE setBodyPitch)
|
Q_PROPERTY(float bodyPitch READ getBodyPitch WRITE setBodyPitch)
|
||||||
Q_PROPERTY(float bodyRoll READ getBodyRoll WRITE setBodyRoll)
|
Q_PROPERTY(float bodyRoll READ getBodyRoll WRITE setBodyRoll)
|
||||||
|
|
||||||
Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientationViaScript)
|
Q_PROPERTY(glm::quat orientation READ getWorldOrientation WRITE setOrientationViaScript)
|
||||||
Q_PROPERTY(glm::quat headOrientation READ getHeadOrientation WRITE setHeadOrientation)
|
Q_PROPERTY(glm::quat headOrientation READ getHeadOrientation WRITE setHeadOrientation)
|
||||||
Q_PROPERTY(float headPitch READ getHeadPitch WRITE setHeadPitch)
|
Q_PROPERTY(float headPitch READ getHeadPitch WRITE setHeadPitch)
|
||||||
Q_PROPERTY(float headYaw READ getHeadYaw WRITE setHeadYaw)
|
Q_PROPERTY(float headYaw READ getHeadYaw WRITE setHeadYaw)
|
||||||
|
|
|
@ -49,11 +49,11 @@ void HeadData::setRawOrientation(const glm::quat& q) {
|
||||||
|
|
||||||
|
|
||||||
glm::quat HeadData::getOrientation() const {
|
glm::quat HeadData::getOrientation() const {
|
||||||
return _owningAvatar->getOrientation() * getRawOrientation();
|
return _owningAvatar->getWorldOrientation() * getRawOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeadData::setHeadOrientation(const glm::quat& orientation) {
|
void HeadData::setHeadOrientation(const glm::quat& orientation) {
|
||||||
glm::quat bodyOrientation = _owningAvatar->getOrientation();
|
glm::quat bodyOrientation = _owningAvatar->getWorldOrientation();
|
||||||
glm::vec3 eulers = glm::degrees(safeEulerAngles(glm::inverse(bodyOrientation) * orientation));
|
glm::vec3 eulers = glm::degrees(safeEulerAngles(glm::inverse(bodyOrientation) * orientation));
|
||||||
_basePitch = eulers.x;
|
_basePitch = eulers.x;
|
||||||
_baseYaw = eulers.y;
|
_baseYaw = eulers.y;
|
||||||
|
@ -62,10 +62,10 @@ void HeadData::setHeadOrientation(const glm::quat& orientation) {
|
||||||
|
|
||||||
void HeadData::setOrientation(const glm::quat& orientation) {
|
void HeadData::setOrientation(const glm::quat& orientation) {
|
||||||
// rotate body about vertical axis
|
// rotate body about vertical axis
|
||||||
glm::quat bodyOrientation = _owningAvatar->getOrientation();
|
glm::quat bodyOrientation = _owningAvatar->getWorldOrientation();
|
||||||
glm::vec3 newForward = glm::inverse(bodyOrientation) * (orientation * IDENTITY_FORWARD);
|
glm::vec3 newForward = glm::inverse(bodyOrientation) * (orientation * IDENTITY_FORWARD);
|
||||||
bodyOrientation = bodyOrientation * glm::angleAxis(atan2f(-newForward.x, -newForward.z), glm::vec3(0.0f, 1.0f, 0.0f));
|
bodyOrientation = bodyOrientation * glm::angleAxis(atan2f(-newForward.x, -newForward.z), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
_owningAvatar->setOrientation(bodyOrientation);
|
_owningAvatar->setWorldOrientation(bodyOrientation);
|
||||||
|
|
||||||
// the rest goes to the head
|
// the rest goes to the head
|
||||||
setHeadOrientation(orientation);
|
setHeadOrientation(orientation);
|
||||||
|
@ -154,7 +154,7 @@ QJsonObject HeadData::toJson() const {
|
||||||
}
|
}
|
||||||
auto lookat = getLookAtPosition();
|
auto lookat = getLookAtPosition();
|
||||||
if (lookat != vec3()) {
|
if (lookat != vec3()) {
|
||||||
vec3 relativeLookAt = glm::inverse(_owningAvatar->getOrientation()) *
|
vec3 relativeLookAt = glm::inverse(_owningAvatar->getWorldOrientation()) *
|
||||||
(getLookAtPosition() - _owningAvatar->getWorldPosition());
|
(getLookAtPosition() - _owningAvatar->getWorldPosition());
|
||||||
headJson[JSON_AVATAR_HEAD_LOOKAT] = toJsonValue(relativeLookAt);
|
headJson[JSON_AVATAR_HEAD_LOOKAT] = toJsonValue(relativeLookAt);
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ void HeadData::fromJson(const QJsonObject& json) {
|
||||||
if (json.contains(JSON_AVATAR_HEAD_LOOKAT)) {
|
if (json.contains(JSON_AVATAR_HEAD_LOOKAT)) {
|
||||||
auto relativeLookAt = vec3FromJsonValue(json[JSON_AVATAR_HEAD_LOOKAT]);
|
auto relativeLookAt = vec3FromJsonValue(json[JSON_AVATAR_HEAD_LOOKAT]);
|
||||||
if (glm::length2(relativeLookAt) > 0.01f) {
|
if (glm::length2(relativeLookAt) > 0.01f) {
|
||||||
setLookAtPosition((_owningAvatar->getOrientation() * relativeLookAt) + _owningAvatar->getWorldPosition());
|
setLookAtPosition((_owningAvatar->getWorldOrientation() * relativeLookAt) + _owningAvatar->getWorldPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ float ScriptAvatarData::getBodyRoll() const {
|
||||||
}
|
}
|
||||||
glm::quat ScriptAvatarData::getOrientation() const {
|
glm::quat ScriptAvatarData::getOrientation() const {
|
||||||
if (AvatarSharedPointer sharedAvatarData = _avatarData.lock()) {
|
if (AvatarSharedPointer sharedAvatarData = _avatarData.lock()) {
|
||||||
return sharedAvatarData->getOrientation();
|
return sharedAvatarData->getWorldOrientation();
|
||||||
} else {
|
} else {
|
||||||
return glm::quat();
|
return glm::quat();
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,7 +510,7 @@ static glm::vec2 projectOntoEntityXYPlane(EntityItemPointer entity, const PickRa
|
||||||
if (entity) {
|
if (entity) {
|
||||||
|
|
||||||
glm::vec3 entityPosition = entity->getWorldPosition();
|
glm::vec3 entityPosition = entity->getWorldPosition();
|
||||||
glm::quat entityRotation = entity->getRotation();
|
glm::quat entityRotation = entity->getWorldOrientation();
|
||||||
glm::vec3 entityDimensions = entity->getDimensions();
|
glm::vec3 entityDimensions = entity->getDimensions();
|
||||||
glm::vec3 entityRegistrationPoint = entity->getRegistrationPoint();
|
glm::vec3 entityRegistrationPoint = entity->getRegistrationPoint();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ void LightEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
|
||||||
|
|
||||||
auto light = lightPayload.editLight();
|
auto light = lightPayload.editLight();
|
||||||
light->setPosition(entity->getWorldPosition());
|
light->setPosition(entity->getWorldPosition());
|
||||||
light->setOrientation(entity->getRotation());
|
light->setOrientation(entity->getWorldOrientation());
|
||||||
|
|
||||||
bool success;
|
bool success;
|
||||||
lightPayload.editBound() = entity->getAABox(success);
|
lightPayload.editBound() = entity->getAABox(success);
|
||||||
|
|
|
@ -123,7 +123,7 @@ void RenderableModelEntityItem::doInitialModelSimulation() {
|
||||||
// now recalculate the bounds and registration
|
// now recalculate the bounds and registration
|
||||||
model->setScaleToFit(true, getDimensions());
|
model->setScaleToFit(true, getDimensions());
|
||||||
model->setSnapModelToRegistrationPoint(true, getRegistrationPoint());
|
model->setSnapModelToRegistrationPoint(true, getRegistrationPoint());
|
||||||
model->setRotation(getRotation());
|
model->setRotation(getWorldOrientation());
|
||||||
model->setTranslation(getWorldPosition());
|
model->setTranslation(getWorldPosition());
|
||||||
|
|
||||||
if (_needsInitialSimulation) {
|
if (_needsInitialSimulation) {
|
||||||
|
|
|
@ -155,7 +155,7 @@ void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo
|
||||||
|
|
||||||
_polylineTransform = Transform();
|
_polylineTransform = Transform();
|
||||||
_polylineTransform.setTranslation(entity->getWorldPosition());
|
_polylineTransform.setTranslation(entity->getWorldPosition());
|
||||||
_polylineTransform.setRotation(entity->getRotation());
|
_polylineTransform.setRotation(entity->getWorldOrientation());
|
||||||
|
|
||||||
if (pointsChanged) {
|
if (pointsChanged) {
|
||||||
_lastPoints = entity->getLinePoints();
|
_lastPoints = entity->getLinePoints();
|
||||||
|
|
|
@ -247,7 +247,7 @@ glm::mat4 RenderablePolyVoxEntityItem::localToVoxelMatrix() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 RenderablePolyVoxEntityItem::voxelToWorldMatrix() const {
|
glm::mat4 RenderablePolyVoxEntityItem::voxelToWorldMatrix() const {
|
||||||
glm::mat4 rotation = glm::mat4_cast(getRotation());
|
glm::mat4 rotation = glm::mat4_cast(getWorldOrientation());
|
||||||
glm::mat4 translation = glm::translate(getWorldPosition());
|
glm::mat4 translation = glm::translate(getWorldPosition());
|
||||||
return translation * rotation * voxelToLocalMatrix();
|
return translation * rotation * voxelToLocalMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
_shape = entity->getShape();
|
_shape = entity->getShape();
|
||||||
_position = entity->getWorldPosition();
|
_position = entity->getWorldPosition();
|
||||||
_dimensions = entity->getDimensions();
|
_dimensions = entity->getDimensions();
|
||||||
_orientation = entity->getOrientation();
|
_orientation = entity->getWorldOrientation();
|
||||||
_renderTransform = getModelTransform();
|
_renderTransform = getModelTransform();
|
||||||
|
|
||||||
if (_shape == entity::Sphere) {
|
if (_shape == entity::Sphere) {
|
||||||
|
|
|
@ -201,7 +201,7 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
|
||||||
|
|
||||||
entity->resetRenderingPropertiesChanged();
|
entity->resetRenderingPropertiesChanged();
|
||||||
_lastPosition = entity->getWorldPosition();
|
_lastPosition = entity->getWorldPosition();
|
||||||
_lastRotation = entity->getRotation();
|
_lastRotation = entity->getWorldOrientation();
|
||||||
_lastDimensions = entity->getDimensions();
|
_lastDimensions = entity->getDimensions();
|
||||||
|
|
||||||
_keyLightProperties = entity->getKeyLightProperties();
|
_keyLightProperties = entity->getKeyLightProperties();
|
||||||
|
@ -277,7 +277,7 @@ bool ZoneEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint
|
||||||
if (entity->getDimensions() != _lastDimensions) {
|
if (entity->getDimensions() != _lastDimensions) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (entity->getRotation() != _lastRotation) {
|
if (entity->getWorldOrientation() != _lastRotation) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1169,7 +1169,7 @@ bool EntityItem::wantTerseEditLogging() const {
|
||||||
|
|
||||||
glm::mat4 EntityItem::getEntityToWorldMatrix() const {
|
glm::mat4 EntityItem::getEntityToWorldMatrix() const {
|
||||||
glm::mat4 translation = glm::translate(getWorldPosition());
|
glm::mat4 translation = glm::translate(getWorldPosition());
|
||||||
glm::mat4 rotation = glm::mat4_cast(getRotation());
|
glm::mat4 rotation = glm::mat4_cast(getWorldOrientation());
|
||||||
glm::mat4 scale = glm::scale(getDimensions());
|
glm::mat4 scale = glm::scale(getDimensions());
|
||||||
glm::mat4 registration = glm::translate(ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint());
|
glm::mat4 registration = glm::translate(ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint());
|
||||||
return translation * rotation * scale * registration;
|
return translation * rotation * scale * registration;
|
||||||
|
@ -1464,7 +1464,7 @@ AACube EntityItem::getMinimumAACube(bool& success) const {
|
||||||
glm::vec3 unrotatedMinRelativeToEntity = - (dimensions * _registrationPoint);
|
glm::vec3 unrotatedMinRelativeToEntity = - (dimensions * _registrationPoint);
|
||||||
glm::vec3 unrotatedMaxRelativeToEntity = dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint);
|
glm::vec3 unrotatedMaxRelativeToEntity = dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint);
|
||||||
Extents extents = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity };
|
Extents extents = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity };
|
||||||
extents.rotate(getRotation());
|
extents.rotate(getWorldOrientation());
|
||||||
|
|
||||||
// shift the extents to be relative to the position/registration point
|
// shift the extents to be relative to the position/registration point
|
||||||
extents.shiftBy(position);
|
extents.shiftBy(position);
|
||||||
|
@ -1494,7 +1494,7 @@ AABox EntityItem::getAABox(bool& success) const {
|
||||||
glm::vec3 unrotatedMinRelativeToEntity = - (dimensions * _registrationPoint);
|
glm::vec3 unrotatedMinRelativeToEntity = - (dimensions * _registrationPoint);
|
||||||
glm::vec3 unrotatedMaxRelativeToEntity = dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint);
|
glm::vec3 unrotatedMaxRelativeToEntity = dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint);
|
||||||
Extents extents = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity };
|
Extents extents = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity };
|
||||||
extents.rotate(getRotation());
|
extents.rotate(getWorldOrientation());
|
||||||
|
|
||||||
// shift the extents to be relative to the position/registration point
|
// shift the extents to be relative to the position/registration point
|
||||||
extents.shiftBy(position);
|
extents.shiftBy(position);
|
||||||
|
@ -2384,7 +2384,7 @@ void EntityItem::globalizeProperties(EntityItemProperties& properties, const QSt
|
||||||
auto globalPosition = getWorldPosition(success);
|
auto globalPosition = getWorldPosition(success);
|
||||||
if (success) {
|
if (success) {
|
||||||
properties.setPosition(globalPosition + offset);
|
properties.setPosition(globalPosition + offset);
|
||||||
properties.setRotation(getRotation());
|
properties.setRotation(getWorldOrientation());
|
||||||
properties.setDimensions(getDimensions());
|
properties.setDimensions(getDimensions());
|
||||||
// Should we do velocities and accelerations, too? This could end up being quite involved, which is why the method exists.
|
// Should we do velocities and accelerations, too? This could end up being quite involved, which is why the method exists.
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -388,7 +388,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
||||||
properties.setPosition(entity->getWorldPosition());
|
properties.setPosition(entity->getWorldPosition());
|
||||||
}
|
}
|
||||||
if (!scriptSideProperties.localRotationChanged() && !scriptSideProperties.rotationChanged()) {
|
if (!scriptSideProperties.localRotationChanged() && !scriptSideProperties.rotationChanged()) {
|
||||||
properties.setRotation(entity->getOrientation());
|
properties.setRotation(entity->getWorldOrientation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
properties = convertLocationFromScriptSemantics(properties);
|
properties = convertLocationFromScriptSemantics(properties);
|
||||||
|
@ -1798,7 +1798,7 @@ glm::mat4 EntityScriptingInterface::getEntityTransform(const QUuid& entityID) {
|
||||||
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(EntityItemID(entityID));
|
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(EntityItemID(entityID));
|
||||||
if (entity) {
|
if (entity) {
|
||||||
glm::mat4 translation = glm::translate(entity->getWorldPosition());
|
glm::mat4 translation = glm::translate(entity->getWorldPosition());
|
||||||
glm::mat4 rotation = glm::mat4_cast(entity->getRotation());
|
glm::mat4 rotation = glm::mat4_cast(entity->getWorldOrientation());
|
||||||
result = translation * rotation;
|
result = translation * rotation;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -662,7 +662,7 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con
|
||||||
}
|
}
|
||||||
|
|
||||||
// extents is the entity relative, scaled, centered extents of the entity
|
// extents is the entity relative, scaled, centered extents of the entity
|
||||||
glm::mat4 rotation = glm::mat4_cast(entity->getRotation());
|
glm::mat4 rotation = glm::mat4_cast(entity->getWorldOrientation());
|
||||||
glm::mat4 translation = glm::translate(entity->getWorldPosition());
|
glm::mat4 translation = glm::translate(entity->getWorldPosition());
|
||||||
glm::mat4 entityToWorldMatrix = translation * rotation;
|
glm::mat4 entityToWorldMatrix = translation * rotation;
|
||||||
glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix);
|
glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix);
|
||||||
|
@ -787,7 +787,7 @@ void EntityTreeElement::getEntities(const glm::vec3& searchPosition, float searc
|
||||||
} else {
|
} else {
|
||||||
// determine the worldToEntityMatrix that doesn't include scale because
|
// determine the worldToEntityMatrix that doesn't include scale because
|
||||||
// we're going to use the registration aware aa box in the entity frame
|
// we're going to use the registration aware aa box in the entity frame
|
||||||
glm::mat4 rotation = glm::mat4_cast(entity->getRotation());
|
glm::mat4 rotation = glm::mat4_cast(entity->getWorldOrientation());
|
||||||
glm::mat4 translation = glm::translate(entity->getWorldPosition());
|
glm::mat4 translation = glm::translate(entity->getWorldPosition());
|
||||||
glm::mat4 entityToWorldMatrix = translation * rotation;
|
glm::mat4 entityToWorldMatrix = translation * rotation;
|
||||||
glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix);
|
glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix);
|
||||||
|
|
|
@ -411,7 +411,7 @@ glm::mat4 PolyVoxEntityItem::localToVoxelMatrix() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 PolyVoxEntityItem::voxelToWorldMatrix() const {
|
glm::mat4 PolyVoxEntityItem::voxelToWorldMatrix() const {
|
||||||
glm::mat4 rotation = glm::mat4_cast(getRotation());
|
glm::mat4 rotation = glm::mat4_cast(getWorldOrientation());
|
||||||
glm::mat4 translation = glm::translate(getWorldPosition());
|
glm::mat4 translation = glm::translate(getWorldPosition());
|
||||||
return translation * rotation * voxelToLocalMatrix();
|
return translation * rotation * voxelToLocalMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ bool TextEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const
|
||||||
void** intersectedObject, bool precisionPicking) const {
|
void** intersectedObject, bool precisionPicking) const {
|
||||||
glm::vec3 dimensions = getDimensions();
|
glm::vec3 dimensions = getDimensions();
|
||||||
glm::vec2 xyDimensions(dimensions.x, dimensions.y);
|
glm::vec2 xyDimensions(dimensions.x, dimensions.y);
|
||||||
glm::quat rotation = getRotation();
|
glm::quat rotation = getWorldOrientation();
|
||||||
glm::vec3 position = getWorldPosition() + rotation *
|
glm::vec3 position = getWorldPosition() + rotation *
|
||||||
(dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()));
|
(dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()));
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ bool WebEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const g
|
||||||
void** intersectedObject, bool precisionPicking) const {
|
void** intersectedObject, bool precisionPicking) const {
|
||||||
glm::vec3 dimensions = getDimensions();
|
glm::vec3 dimensions = getDimensions();
|
||||||
glm::vec2 xyDimensions(dimensions.x, dimensions.y);
|
glm::vec2 xyDimensions(dimensions.x, dimensions.y);
|
||||||
glm::quat rotation = getRotation();
|
glm::quat rotation = getWorldOrientation();
|
||||||
glm::vec3 position = getWorldPosition() + rotation * (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()));
|
glm::vec3 position = getWorldPosition() + rotation * (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()));
|
||||||
|
|
||||||
if (findRayRectangleIntersection(origin, direction, rotation, position, xyDimensions, distance)) {
|
if (findRayRectangleIntersection(origin, direction, rotation, position, xyDimensions, distance)) {
|
||||||
|
|
|
@ -109,7 +109,7 @@ void EntityMotionState::handleDeactivation() {
|
||||||
// and also to RigidBody
|
// and also to RigidBody
|
||||||
btTransform worldTrans;
|
btTransform worldTrans;
|
||||||
worldTrans.setOrigin(glmToBullet(_entity->getWorldPosition()));
|
worldTrans.setOrigin(glmToBullet(_entity->getWorldPosition()));
|
||||||
worldTrans.setRotation(glmToBullet(_entity->getRotation()));
|
worldTrans.setRotation(glmToBullet(_entity->getWorldOrientation()));
|
||||||
_body->setWorldTransform(worldTrans);
|
_body->setWorldTransform(worldTrans);
|
||||||
// no need to update velocities... should already be zero
|
// no need to update velocities... should already be zero
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ void EntityMotionState::getWorldTransform(btTransform& worldTrans) const {
|
||||||
_accelerationNearlyGravityCount = (uint8_t)(-1);
|
_accelerationNearlyGravityCount = (uint8_t)(-1);
|
||||||
}
|
}
|
||||||
worldTrans.setOrigin(glmToBullet(getObjectPosition()));
|
worldTrans.setOrigin(glmToBullet(getObjectPosition()));
|
||||||
worldTrans.setRotation(glmToBullet(_entity->getRotation()));
|
worldTrans.setRotation(glmToBullet(_entity->getWorldOrientation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This callback is invoked by the physics simulation at the end of each simulation step...
|
// This callback is invoked by the physics simulation at the end of each simulation step...
|
||||||
|
@ -264,7 +264,7 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) {
|
||||||
qCDebug(physics) << "EntityMotionState::setWorldTransform setPosition failed" << _entity->getID();
|
qCDebug(physics) << "EntityMotionState::setWorldTransform setPosition failed" << _entity->getID();
|
||||||
}
|
}
|
||||||
bool orientationSuccess;
|
bool orientationSuccess;
|
||||||
_entity->setOrientation(bulletToGLM(worldTrans.getRotation()), orientationSuccess, false);
|
_entity->setWorldOrientation(bulletToGLM(worldTrans.getRotation()), orientationSuccess, false);
|
||||||
if (!orientationSuccess) {
|
if (!orientationSuccess) {
|
||||||
static QString repeatedMessage =
|
static QString repeatedMessage =
|
||||||
LogHandler::getInstance().addRepeatedMessageRegex("EntityMotionState::setWorldTransform "
|
LogHandler::getInstance().addRepeatedMessageRegex("EntityMotionState::setWorldTransform "
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
virtual float getObjectAngularDamping() const override { return _entity->getAngularDamping(); }
|
virtual float getObjectAngularDamping() const override { return _entity->getAngularDamping(); }
|
||||||
|
|
||||||
virtual glm::vec3 getObjectPosition() const override { return _entity->getWorldPosition() - ObjectMotionState::getWorldOffset(); }
|
virtual glm::vec3 getObjectPosition() const override { return _entity->getWorldPosition() - ObjectMotionState::getWorldOffset(); }
|
||||||
virtual glm::quat getObjectRotation() const override { return _entity->getRotation(); }
|
virtual glm::quat getObjectRotation() const override { return _entity->getWorldOrientation(); }
|
||||||
virtual glm::vec3 getObjectLinearVelocity() const override { return _entity->getVelocity(); }
|
virtual glm::vec3 getObjectLinearVelocity() const override { return _entity->getVelocity(); }
|
||||||
virtual glm::vec3 getObjectAngularVelocity() const override { return _entity->getAngularVelocity(); }
|
virtual glm::vec3 getObjectAngularVelocity() const override { return _entity->getAngularVelocity(); }
|
||||||
virtual glm::vec3 getObjectGravity() const override { return _entity->getGravity(); }
|
virtual glm::vec3 getObjectGravity() const override { return _entity->getGravity(); }
|
||||||
|
|
|
@ -54,8 +54,8 @@ bool ObjectActionTractor::getTarget(float deltaTimeStep, glm::quat& rotation, gl
|
||||||
|
|
||||||
if (!_otherID.isNull()) {
|
if (!_otherID.isNull()) {
|
||||||
if (other) {
|
if (other) {
|
||||||
rotation = _desiredRotationalTarget * other->getRotation();
|
rotation = _desiredRotationalTarget * other->getWorldOrientation();
|
||||||
position = other->getRotation() * _desiredPositionalTarget + other->getWorldPosition();
|
position = other->getWorldOrientation() * _desiredPositionalTarget + other->getWorldPosition();
|
||||||
} else {
|
} else {
|
||||||
// we should have an "other" but can't find it, so disable the tractor.
|
// we should have an "other" but can't find it, so disable the tractor.
|
||||||
linearTimeScale = FLT_MAX;
|
linearTimeScale = FLT_MAX;
|
||||||
|
|
|
@ -420,13 +420,13 @@ void SpatiallyNestable::setWorldPosition(const glm::vec3& position) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat SpatiallyNestable::getOrientation(bool& success) const {
|
glm::quat SpatiallyNestable::getWorldOrientation(bool& success) const {
|
||||||
return getTransform(success).getRotation();
|
return getTransform(success).getRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat SpatiallyNestable::getOrientation() const {
|
glm::quat SpatiallyNestable::getWorldOrientation() const {
|
||||||
bool success;
|
bool success;
|
||||||
auto result = getOrientation(success);
|
auto result = getWorldOrientation(success);
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qCDebug(shared) << "Warning -- getOrientation failed" << getID();
|
qCDebug(shared) << "Warning -- getOrientation failed" << getID();
|
||||||
|
@ -435,11 +435,11 @@ glm::quat SpatiallyNestable::getOrientation() const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat SpatiallyNestable::getOrientation(int jointIndex, bool& success) const {
|
glm::quat SpatiallyNestable::getWorldOrientation(int jointIndex, bool& success) const {
|
||||||
return getTransform(jointIndex, success).getRotation();
|
return getTransform(jointIndex, success).getRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpatiallyNestable::setOrientation(const glm::quat& orientation, bool& success, bool tellPhysics) {
|
void SpatiallyNestable::setWorldOrientation(const glm::quat& orientation, bool& success, bool tellPhysics) {
|
||||||
// guard against introducing NaN into the transform
|
// guard against introducing NaN into the transform
|
||||||
if (isNaN(orientation)) {
|
if (isNaN(orientation)) {
|
||||||
success = false;
|
success = false;
|
||||||
|
@ -463,9 +463,9 @@ void SpatiallyNestable::setOrientation(const glm::quat& orientation, bool& succe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpatiallyNestable::setOrientation(const glm::quat& orientation) {
|
void SpatiallyNestable::setWorldOrientation(const glm::quat& orientation) {
|
||||||
bool success;
|
bool success;
|
||||||
setOrientation(orientation, success);
|
setWorldOrientation(orientation, success);
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qCDebug(shared) << "Warning -- setOrientation failed" << getID();
|
qCDebug(shared) << "Warning -- setOrientation failed" << getID();
|
||||||
|
|
|
@ -83,15 +83,11 @@ public:
|
||||||
virtual void setWorldPosition(const glm::vec3& position, bool& success, bool tellPhysics = true);
|
virtual void setWorldPosition(const glm::vec3& position, bool& success, bool tellPhysics = true);
|
||||||
virtual void setWorldPosition(const glm::vec3& position);
|
virtual void setWorldPosition(const glm::vec3& position);
|
||||||
|
|
||||||
virtual glm::quat getOrientation(bool& success) const;
|
virtual glm::quat getWorldOrientation(bool& success) const;
|
||||||
virtual glm::quat getOrientation() const;
|
virtual glm::quat getWorldOrientation() const;
|
||||||
virtual glm::quat getOrientation(int jointIndex, bool& success) const;
|
virtual glm::quat getWorldOrientation(int jointIndex, bool& success) const;
|
||||||
virtual void setOrientation(const glm::quat& orientation, bool& success, bool tellPhysics = true);
|
virtual void setWorldOrientation(const glm::quat& orientation, bool& success, bool tellPhysics = true);
|
||||||
virtual void setOrientation(const glm::quat& orientation);
|
virtual void setWorldOrientation(const glm::quat& orientation);
|
||||||
|
|
||||||
// these are here because some older code uses rotation rather than orientation
|
|
||||||
virtual const glm::quat getRotation() const { return getOrientation(); }
|
|
||||||
virtual void setRotation(glm::quat orientation) { setOrientation(orientation); }
|
|
||||||
|
|
||||||
virtual glm::vec3 getVelocity(bool& success) const;
|
virtual glm::vec3 getVelocity(bool& success) const;
|
||||||
virtual glm::vec3 getVelocity() const;
|
virtual glm::vec3 getVelocity() const;
|
||||||
|
|
Loading…
Reference in a new issue