Merge branch 'master' of github.com:highfidelity/hifi into fix-modal

This commit is contained in:
Dante Ruiz 2017-11-21 13:56:22 -08:00
commit c9ad7b1db5
86 changed files with 704 additions and 642 deletions
assignment-client/src
interface
libraries
plugins/hifiSixense
tests
controllers
entities
gpu-test
qt59
recording
render-perf
render-texture-load
render-utils
shaders

View file

@ -441,7 +441,7 @@ void Agent::executeScript() {
Transform audioTransform;
auto headOrientation = scriptedAvatar->getHeadOrientation();
audioTransform.setTranslation(scriptedAvatar->getPosition());
audioTransform.setTranslation(scriptedAvatar->getWorldPosition());
audioTransform.setRotation(headOrientation);
QByteArray encodedBuffer;
@ -452,7 +452,7 @@ void Agent::executeScript() {
}
AbstractAudioInterface::emitAudioPacket(encodedBuffer.data(), encodedBuffer.size(), audioSequenceNumber,
audioTransform, scriptedAvatar->getPosition(), glm::vec3(0),
audioTransform, scriptedAvatar->getWorldPosition(), glm::vec3(0),
packetType, _selectedCodecName);
});
@ -742,10 +742,10 @@ void Agent::processAgentAvatarAudio() {
audioPacket->writePrimitive(numAvailableSamples);
// use the orientation and position of this avatar for the source of this audio
audioPacket->writePrimitive(scriptedAvatar->getPosition());
audioPacket->writePrimitive(scriptedAvatar->getWorldPosition());
glm::quat headOrientation = scriptedAvatar->getHeadOrientation();
audioPacket->writePrimitive(headOrientation);
audioPacket->writePrimitive(scriptedAvatar->getPosition());
audioPacket->writePrimitive(scriptedAvatar->getWorldPosition());
audioPacket->writePrimitive(glm::vec3(0));
// no matter what, the loudness should be set to 0
@ -759,10 +759,10 @@ void Agent::processAgentAvatarAudio() {
audioPacket->writePrimitive((quint8)0);
// use the orientation and position of this avatar for the source of this audio
audioPacket->writePrimitive(scriptedAvatar->getPosition());
audioPacket->writePrimitive(scriptedAvatar->getWorldPosition());
glm::quat headOrientation = scriptedAvatar->getHeadOrientation();
audioPacket->writePrimitive(headOrientation);
audioPacket->writePrimitive(scriptedAvatar->getPosition());
audioPacket->writePrimitive(scriptedAvatar->getWorldPosition()); // HUH? why do we write this twice??
audioPacket->writePrimitive(glm::vec3(0));
QByteArray encodedBuffer;

View file

@ -91,7 +91,7 @@ public:
void loadJSONStats(QJsonObject& jsonObject) const;
glm::vec3 getPosition() const { return _avatar ? _avatar->getPosition() : glm::vec3(0); }
glm::vec3 getPosition() const { return _avatar ? _avatar->getWorldPosition() : glm::vec3(0); }
glm::vec3 getGlobalBoundingBoxCorner() const { return _avatar ? _avatar->getGlobalBoundingBoxCorner() : glm::vec3(0); }
bool isRadiusIgnoring(const QUuid& other) const { return _radiusIgnoredOthers.find(other) != _radiusIgnoredOthers.end(); }
void addToRadiusIgnoringSet(const QUuid& other) { _radiusIgnoredOthers.insert(other); }

View file

@ -209,7 +209,7 @@ void AvatarMixerSlave::broadcastAvatarDataToAgent(const SharedNodePointer& node)
assert(avatarNode); // we can't have gotten here without the avatarData being a valid key in the map
return nodeData->getLastBroadcastTime(avatarNode->getUUID());
}, [&](AvatarSharedPointer avatar)->float{
glm::vec3 nodeBoxHalfScale = (avatar->getPosition() - avatar->getGlobalBoundingBoxCorner() * avatar->getSensorToWorldScale());
glm::vec3 nodeBoxHalfScale = (avatar->getWorldPosition() - avatar->getGlobalBoundingBoxCorner() * avatar->getSensorToWorldScale());
return glm::max(nodeBoxHalfScale.x, glm::max(nodeBoxHalfScale.y, nodeBoxHalfScale.z));
}, [&](AvatarSharedPointer avatar)->bool {
if (avatar == thisAvatar) {

View file

@ -20,7 +20,7 @@
QByteArray ScriptableAvatar::toByteArrayStateful(AvatarDataDetail dataDetail, bool dropFaceTracking) {
_globalPosition = getPosition();
_globalPosition = getWorldPosition();
return AvatarData::toByteArrayStateful(dataDetail);
}

View file

@ -33,6 +33,54 @@ var EventBridge;
// replace the TempEventBridge with the real one.
var tempEventBridge = EventBridge;
EventBridge = channel.objects.eventBridge;
EventBridge.audioOutputDeviceChanged.connect(function(deviceName) {
navigator.mediaDevices.getUserMedia({ audio: true, video: true }).then(function(mediaStream) {
navigator.mediaDevices.enumerateDevices().then(function(devices) {
devices.forEach(function(device) {
if (device.kind == "audiooutput") {
if (device.label == deviceName){
console.log("Changing HTML audio output to device " + device.label);
var deviceId = device.deviceId;
var videos = document.getElementsByTagName("video");
for (var i = 0; i < videos.length; i++){
videos[i].setSinkId(deviceId);
}
var audios = document.getElementsByTagName("audio");
for (var i = 0; i < audios.length; i++){
audios[i].setSinkId(deviceId);
}
}
}
});
}).catch(function(err) {
console.log("Error getting media devices"+ err.name + ": " + err.message);
});
}).catch(function(err) {
console.log("Error getting user media"+ err.name + ": " + err.message);
});
});
// To be able to update the state of the output device selection for every element added to the DOM
// we need to listen to events that might precede the addition of this elements.
// A more robust hack will be to add a setInterval that look for DOM changes every 100-300 ms (low performance?)
window.onload = function(){
setTimeout(function() {
EventBridge.forceHtmlAudioOutputDeviceUpdate();
}, 1200);
};
document.onclick = function(){
setTimeout(function() {
EventBridge.forceHtmlAudioOutputDeviceUpdate();
}, 1200);
};
document.onchange = function(){
setTimeout(function() {
EventBridge.forceHtmlAudioOutputDeviceUpdate();
}, 1200);
};
tempEventBridge._callbacks.forEach(function (callback) {
EventBridge.scriptEventReceived.connect(callback);
});

View file

@ -212,7 +212,7 @@ ScrollingWindow {
WebEngineScript {
id: createGlobalEventBridge
sourceCode: eventBridgeJavaScriptToInject
injectionPoint: WebEngineScript.DocumentCreation
injectionPoint: WebEngineScript.Deferred
worldId: WebEngineScript.MainWorld
}
@ -233,9 +233,13 @@ ScrollingWindow {
anchors.right: parent.right
onFeaturePermissionRequested: {
permissionsBar.securityOrigin = securityOrigin;
permissionsBar.feature = feature;
root.showPermissionsBar();
if (feature == 2) { // QWebEnginePage::MediaAudioCapture
grantFeaturePermission(securityOrigin, feature, true);
} else {
permissionsBar.securityOrigin = securityOrigin;
permissionsBar.feature = feature;
root.showPermissionsBar();
}
}
onLoadingChanged: {

View file

@ -895,7 +895,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(audioIO.data(), &AudioClient::muteEnvironmentRequested, [](glm::vec3 position, float radius) {
auto audioClient = DependencyManager::get<AudioClient>();
auto audioScriptingInterface = DependencyManager::get<AudioScriptingInterface>();
auto myAvatarPosition = DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition();
auto myAvatarPosition = DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldPosition();
float distance = glm::distance(myAvatarPosition, position);
bool shouldMute = !audioClient->isMuted() && (distance < radius);
@ -968,8 +968,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
auto addressManager = DependencyManager::get<AddressManager>();
// use our MyAvatar position and quat for address manager path
addressManager->setPositionGetter([this]{ return getMyAvatar()->getPosition(); });
addressManager->setOrientationGetter([this]{ return getMyAvatar()->getOrientation(); });
addressManager->setPositionGetter([this]{ return getMyAvatar()->getWorldPosition(); });
addressManager->setOrientationGetter([this]{ return getMyAvatar()->getWorldOrientation(); });
connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
@ -1507,7 +1507,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
static const QString FAST_STATS_ARG = "--fast-heartbeat";
static int SEND_STATS_INTERVAL_MS = arguments().indexOf(FAST_STATS_ARG) != -1 ? 1000 : 10000;
static glm::vec3 lastAvatarPosition = myAvatar->getPosition();
static glm::vec3 lastAvatarPosition = myAvatar->getWorldPosition();
static glm::mat4 lastHMDHeadPose = getHMDSensorPose();
static controller::Pose lastLeftHandPose = myAvatar->getLeftHandPose();
static controller::Pose lastRightHandPose = myAvatar->getRightHandPose();
@ -1635,7 +1635,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
properties["bytes_downloaded"] = bytesDownloaded;
auto myAvatar = getMyAvatar();
glm::vec3 avatarPosition = myAvatar->getPosition();
glm::vec3 avatarPosition = myAvatar->getWorldPosition();
properties["avatar_has_moved"] = lastAvatarPosition != avatarPosition;
lastAvatarPosition = avatarPosition;
@ -1715,7 +1715,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
checkNearbyAvatarsTimer->setInterval(CHECK_NEARBY_AVATARS_INTERVAL_MS); // 10 seconds, Qt::CoarseTimer ok
connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, [this]() {
auto avatarManager = DependencyManager::get<AvatarManager>();
int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getPosition(),
int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getWorldPosition(),
NEARBY_AVATAR_RADIUS_METERS) - 1;
if (nearbyAvatars != lastCountOfNearbyAvatars) {
lastCountOfNearbyAvatars = nearbyAvatars;
@ -2408,7 +2408,7 @@ void Application::updateCamera(RenderArgs& renderArgs) {
auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
_myCamera.setOrientation(glm::normalize(glmExtractRotation(hmdWorldMat)));
_myCamera.setPosition(extractTranslation(hmdWorldMat) +
myAvatar->getOrientation() * boomOffset);
myAvatar->getWorldOrientation() * boomOffset);
}
else {
_myCamera.setOrientation(myAvatar->getHead()->getOrientation());
@ -2418,13 +2418,13 @@ void Application::updateCamera(RenderArgs& renderArgs) {
}
else {
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
+ myAvatar->getOrientation() * boomOffset);
+ myAvatar->getWorldOrientation() * boomOffset);
}
}
}
else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
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());
// Mirror HMD yaw and roll
@ -2447,11 +2447,11 @@ void Application::updateCamera(RenderArgs& renderArgs) {
+ mirrorBodyOrientation * hmdOffset);
}
else {
_myCamera.setOrientation(myAvatar->getOrientation()
_myCamera.setOrientation(myAvatar->getWorldOrientation()
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
+ 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);
}
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
@ -2461,13 +2461,13 @@ void Application::updateCamera(RenderArgs& renderArgs) {
if (cameraEntity != nullptr) {
if (isHMDMode()) {
glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
_myCamera.setOrientation(cameraEntity->getRotation() * hmdRotation);
_myCamera.setOrientation(cameraEntity->getWorldOrientation() * hmdRotation);
glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
_myCamera.setPosition(cameraEntity->getPosition() + (hmdRotation * hmdOffset));
_myCamera.setPosition(cameraEntity->getWorldPosition() + (hmdRotation * hmdOffset));
}
else {
_myCamera.setOrientation(cameraEntity->getRotation());
_myCamera.setPosition(cameraEntity->getPosition());
_myCamera.setOrientation(cameraEntity->getWorldOrientation());
_myCamera.setPosition(cameraEntity->getWorldPosition());
}
}
}
@ -3878,16 +3878,16 @@ void Application::idle() {
if (!_keyboardFocusedEntity.get().isInvalidID()) {
auto entity = getEntities()->getTree()->findEntityByID(_keyboardFocusedEntity.get());
if (entity && _keyboardFocusHighlight) {
_keyboardFocusHighlight->setRotation(entity->getRotation());
_keyboardFocusHighlight->setPosition(entity->getPosition());
_keyboardFocusHighlight->setWorldOrientation(entity->getWorldOrientation());
_keyboardFocusHighlight->setWorldPosition(entity->getWorldPosition());
}
} else {
// Only Web overlays can have focus.
auto overlay =
std::dynamic_pointer_cast<Web3DOverlay>(getOverlays().getOverlay(_keyboardFocusedOverlay.get()));
if (overlay && _keyboardFocusHighlight) {
_keyboardFocusHighlight->setRotation(overlay->getRotation());
_keyboardFocusHighlight->setPosition(overlay->getPosition());
_keyboardFocusHighlight->setWorldOrientation(overlay->getWorldOrientation());
_keyboardFocusHighlight->setWorldPosition(overlay->getWorldPosition());
}
}
}
@ -4022,7 +4022,7 @@ bool Application::exportEntities(const QString& filename,
!entityIDs.contains(parentID) ||
!entityTree->findEntityByEntityItemID(parentID))) {
// If parent wasn't selected, we want absolute position, which isn't in properties.
auto position = entityItem->getPosition();
auto position = entityItem->getWorldPosition();
root.x = glm::min(root.x, position.x);
root.y = glm::min(root.y, position.y);
root.z = glm::min(root.z, position.z);
@ -4225,7 +4225,7 @@ void Application::init() {
return 0.0f;
}
auto distance = glm::distance(getMyAvatar()->getPosition(), item.getPosition());
auto distance = glm::distance(getMyAvatar()->getWorldPosition(), item.getWorldPosition());
return atan2(maxSize, distance);
});
@ -4302,7 +4302,7 @@ void Application::updateMyAvatarLookAtPosition() {
// TODO -- this code is probably wrong, getHeadPose() returns something in sensor frame, not avatar
glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
glm::quat hmdRotation = glm::quat_cast(headPose);
lookAtSpot = _myCamera.getPosition() + myAvatar->getOrientation() * (hmdRotation * lookAtPosition);
lookAtSpot = _myCamera.getPosition() + myAvatar->getWorldOrientation() * (hmdRotation * lookAtPosition);
} else {
lookAtSpot = myAvatar->getHead()->getEyePosition()
+ (myAvatar->getHead()->getFinalOrientationInWorldFrame() * lookAtPosition);
@ -4531,8 +4531,8 @@ void Application::setKeyboardFocusHighlight(const glm::vec3& position, const glm
}
// Position focus
_keyboardFocusHighlight->setRotation(rotation);
_keyboardFocusHighlight->setPosition(position);
_keyboardFocusHighlight->setWorldOrientation(rotation);
_keyboardFocusHighlight->setWorldPosition(position);
_keyboardFocusHighlight->setDimensions(dimensions);
_keyboardFocusHighlight->setVisible(true);
}
@ -4569,7 +4569,7 @@ void Application::setKeyboardFocusEntity(const EntityItemID& entityItemID) {
}
_lastAcceptedKeyPress = usecTimestampNow();
setKeyboardFocusHighlight(entity->getPosition(), entity->getRotation(),
setKeyboardFocusHighlight(entity->getWorldPosition(), entity->getWorldOrientation(),
entity->getDimensions() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR);
}
}
@ -4606,7 +4606,7 @@ void Application::setKeyboardFocusOverlay(const OverlayID& overlayID) {
if (overlay->getProperty("showKeyboardFocusHighlight").toBool()) {
auto size = overlay->getSize() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR;
const float OVERLAY_DEPTH = 0.0105f;
setKeyboardFocusHighlight(overlay->getPosition(), 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) {
_keyboardFocusHighlight->setVisible(false);
}
@ -4698,7 +4698,7 @@ void Application::update(float deltaTime) {
controller::InputCalibrationData calibrationData = {
myAvatar->getSensorToWorldMatrix(),
createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()),
createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition()),
myAvatar->getHMDSensorMatrix(),
myAvatar->getCenterEyeCalibrationMat(),
myAvatar->getHeadCalibrationMat(),
@ -4808,7 +4808,7 @@ void Application::update(float deltaTime) {
};
// copy controller poses from userInputMapper to myAvatar.
glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition());
glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition());
glm::mat4 worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix());
glm::mat4 avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;
for (auto& action : avatarControllerActions) {
@ -5424,7 +5424,7 @@ std::shared_ptr<MyAvatar> Application::getMyAvatar() const {
}
glm::vec3 Application::getAvatarPosition() const {
return getMyAvatar()->getPosition();
return getMyAvatar()->getWorldPosition();
}
void Application::copyViewFrustum(ViewFrustum& viewOut) const {
@ -5639,7 +5639,7 @@ bool Application::nearbyEntitiesAreReadyForPhysics() {
// whose bounding boxes cannot be computed (it is too loose for our purposes here). Instead we manufacture
// custom filters and use the general-purpose EntityTree::findEntities(filter, ...)
QVector<EntityItemPointer> entities;
AABox avatarBox(getMyAvatar()->getPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
AABox avatarBox(getMyAvatar()->getWorldPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
// create two functions that use avatarBox (entityScan and elementScan), the second calls the first
std::function<bool (EntityItemPointer&)> entityScan = [=](EntityItemPointer& entity) {
if (entity->shouldBePhysical()) {
@ -6466,9 +6466,9 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) {
properties.setShapeType(SHAPE_TYPE_SIMPLE_COMPOUND);
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.
glm::vec3 positionOffset = getMyAvatar()->getOrientation() * (getMyAvatar()->getSensorToWorldScale() * glm::vec3(0.0f, 0.0f, -2.0f));
properties.setPosition(getMyAvatar()->getPosition() + positionOffset);
properties.setRotation(getMyAvatar()->getOrientation());
glm::vec3 positionOffset = getMyAvatar()->getWorldOrientation() * (getMyAvatar()->getSensorToWorldScale() * glm::vec3(0.0f, 0.0f, -2.0f));
properties.setPosition(getMyAvatar()->getWorldPosition() + positionOffset);
properties.setRotation(getMyAvatar()->getWorldOrientation());
properties.setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
auto entityID = DependencyManager::get<EntityScriptingInterface>()->addEntity(properties);

View file

@ -529,7 +529,7 @@ void AvatarActionHold::lateAvatarUpdate(const AnimPose& prePhysicsRoomPose, cons
rigidBody->setWorldTransform(worldTrans);
bool positionSuccess;
ownerEntity->setPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset(), positionSuccess, false);
ownerEntity->setWorldPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset(), positionSuccess, false);
bool orientationSuccess;
ownerEntity->setOrientation(bulletToGLM(worldTrans.getRotation()), orientationSuccess, false);
ownerEntity->setWorldOrientation(bulletToGLM(worldTrans.getRotation()), orientationSuccess, false);
}

View file

@ -441,7 +441,7 @@ void AvatarManager::handleCollisionEvents(const CollisionEvents& collisionEvents
static const int MAX_INJECTOR_COUNT = 3;
if (_collisionInjectors.size() < MAX_INJECTOR_COUNT) {
auto injector = AudioInjector::playSound(collisionSound, energyFactorOfFull, AVATAR_STRETCH_FACTOR,
myAvatar->getPosition());
myAvatar->getWorldPosition());
_collisionInjectors.emplace_back(injector);
}
myAvatar->collisionWithEntity(collision);

View file

@ -41,7 +41,7 @@ public:
void init();
std::shared_ptr<MyAvatar> getMyAvatar() { return _myAvatar; }
glm::vec3 getMyAvatarPosition() const { return _myAvatar->getPosition(); }
glm::vec3 getMyAvatarPosition() const { return _myAvatar->getWorldPosition(); }
// Null/Default-constructed QUuids will return MyAvatar
Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) override { return new ScriptAvatar(getAvatarBySessionID(avatarID)); }

View file

@ -106,22 +106,22 @@ float AvatarMotionState::getObjectAngularDamping() const {
// virtual
glm::vec3 AvatarMotionState::getObjectPosition() const {
return _avatar->getPosition();
return _avatar->getWorldPosition();
}
// virtual
glm::quat AvatarMotionState::getObjectRotation() const {
return _avatar->getOrientation();
return _avatar->getWorldOrientation();
}
// virtual
glm::vec3 AvatarMotionState::getObjectLinearVelocity() const {
return _avatar->getVelocity();
return _avatar->getWorldVelocity();
}
// virtual
glm::vec3 AvatarMotionState::getObjectAngularVelocity() const {
return _avatar->getAngularVelocity();
return _avatar->getWorldAngularVelocity();
}
// virtual

View file

@ -196,8 +196,8 @@ MyAvatar::MyAvatar(QThread* thread) :
setDisplayName(dummyAvatar.getDisplayName());
}
setPosition(dummyAvatar.getPosition());
setOrientation(dummyAvatar.getOrientation());
setWorldPosition(dummyAvatar.getWorldPosition());
setWorldOrientation(dummyAvatar.getWorldOrientation());
if (!dummyAvatar.getAttachmentData().isEmpty()) {
setAttachmentData(dummyAvatar.getAttachmentData());
@ -250,11 +250,11 @@ void MyAvatar::registerMetaTypes(ScriptEnginePointer engine) {
}
void MyAvatar::setOrientationVar(const QVariant& newOrientationVar) {
Avatar::setOrientation(quatFromVariant(newOrientationVar));
Avatar::setWorldOrientation(quatFromVariant(newOrientationVar));
}
QVariant MyAvatar::getOrientationVar() const {
return quatToVariant(Avatar::getOrientation());
return quatToVariant(Avatar::getWorldOrientation());
}
glm::quat MyAvatar::getOrientationOutbound() const {
@ -276,7 +276,7 @@ void MyAvatar::simulateAttachments(float deltaTime) {
QByteArray MyAvatar::toByteArrayStateful(AvatarDataDetail dataDetail, bool dropFaceTracking) {
CameraMode mode = qApp->getCamera().getMode();
_globalPosition = getPosition();
_globalPosition = getWorldPosition();
// This might not be right! Isn't the capsule local offset in avatar space, and don't we need to add the radius to the y as well? -HRS 5/26/17
_globalBoundingBoxDimensions.x = _characterController.getCapsuleRadius();
_globalBoundingBoxDimensions.y = _characterController.getCapsuleHalfHeight();
@ -284,11 +284,11 @@ QByteArray MyAvatar::toByteArrayStateful(AvatarDataDetail dataDetail, bool dropF
_globalBoundingBoxOffset = _characterController.getCapsuleLocalOffset();
if (mode == CAMERA_MODE_THIRD_PERSON || mode == CAMERA_MODE_INDEPENDENT) {
// fake the avatar position that is sent up to the AvatarMixer
glm::vec3 oldPosition = getPosition();
setPosition(getSkeletonPosition());
glm::vec3 oldPosition = getWorldPosition();
setWorldPosition(getSkeletonPosition());
QByteArray array = AvatarData::toByteArrayStateful(dataDetail);
// copy the correct position back
setPosition(oldPosition);
setWorldPosition(oldPosition);
return array;
}
return AvatarData::toByteArrayStateful(dataDetail);
@ -321,15 +321,15 @@ void MyAvatar::centerBody() {
if (_characterController.getState() == CharacterController::State::Ground) {
// the avatar's physical aspect thinks it is standing on something
// therefore need to be careful to not "center" the body below the floor
float downStep = glm::dot(worldBodyPos - getPosition(), _worldUpDirection);
float downStep = glm::dot(worldBodyPos - getWorldPosition(), _worldUpDirection);
if (downStep < -0.5f * _characterController.getCapsuleHalfHeight() + _characterController.getCapsuleRadius()) {
worldBodyPos -= downStep * _worldUpDirection;
}
}
// this will become our new position.
setPosition(worldBodyPos);
setOrientation(worldBodyRot);
setWorldPosition(worldBodyPos);
setWorldOrientation(worldBodyRot);
// reset the body in sensor space
_bodySensorMatrix = newBodySensorMatrix;
@ -372,8 +372,8 @@ void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
auto worldBodyRot = glmExtractRotation(worldBodyMatrix);
// this will become our new position.
setPosition(worldBodyPos);
setOrientation(worldBodyRot);
setWorldPosition(worldBodyPos);
setWorldOrientation(worldBodyRot);
// now sample the new hmd orientation AFTER sensor reset, which should be identity.
glm::mat4 identity;
@ -410,8 +410,8 @@ void MyAvatar::update(float deltaTime) {
#endif
if (_goToPending) {
setPosition(_goToPosition);
setOrientation(_goToOrientation);
setWorldPosition(_goToPosition);
setWorldOrientation(_goToOrientation);
_headControllerFacingMovingAverage = _headControllerFacing; // reset moving average
_goToPending = false;
// updateFromHMDSensorMatrix (called from paintGL) expects that the sensorToWorldMatrix is updated for any position changes
@ -444,7 +444,7 @@ void MyAvatar::update(float deltaTime) {
// This might not be right! Isn't the capsule local offset in avatar space? -HRS 5/26/17
halfBoundingBoxDimensions += _characterController.getCapsuleLocalOffset();
QMetaObject::invokeMethod(audio.data(), "setAvatarBoundingBoxParameters",
Q_ARG(glm::vec3, (getPosition() - halfBoundingBoxDimensions)),
Q_ARG(glm::vec3, (getWorldPosition() - halfBoundingBoxDimensions)),
Q_ARG(glm::vec3, (halfBoundingBoxDimensions*2.0f)));
if (getIdentityDataChanged()) {
@ -537,7 +537,7 @@ void MyAvatar::simulate(float deltaTime) {
if (!_skeletonModel->hasSkeleton()) {
// All the simulation that can be done has been done
getHead()->setPosition(getPosition()); // so audio-position isn't 0,0,0
getHead()->setPosition(getWorldPosition()); // so audio-position isn't 0,0,0
return;
}
@ -555,7 +555,7 @@ void MyAvatar::simulate(float deltaTime) {
Head* head = getHead();
glm::vec3 headPosition;
if (!_skeletonModel->getHeadPosition(headPosition)) {
headPosition = getPosition();
headPosition = getWorldPosition();
}
head->setPosition(headPosition);
head->setScale(getModelScale());
@ -666,7 +666,7 @@ void MyAvatar::updateSensorToWorldMatrix() {
// update the sensor mat so that the body position will end up in the desired
// position when driven from the head.
float sensorToWorldScale = getEyeHeight() / getUserEyeHeight();
glm::mat4 desiredMat = createMatFromScaleQuatAndPos(glm::vec3(sensorToWorldScale), getOrientation(), getPosition());
glm::mat4 desiredMat = createMatFromScaleQuatAndPos(glm::vec3(sensorToWorldScale), getWorldOrientation(), getWorldPosition());
_sensorToWorldMatrix = desiredMat * glm::inverse(_bodySensorMatrix);
lateUpdatePalms();
@ -783,8 +783,8 @@ controller::Pose MyAvatar::getRightHandTipPose() const {
}
glm::vec3 MyAvatar::worldToJointPoint(const glm::vec3& position, const int jointIndex) const {
glm::vec3 jointPos = getPosition();//default value if no or invalid joint specified
glm::quat jointRot = getRotation();//default value if no or invalid joint specified
glm::vec3 jointPos = getWorldPosition();//default value if no or invalid joint specified
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
if (jointIndex != -1) {
if (_skeletonModel->getJointPositionInWorldFrame(jointIndex, jointPos)) {
_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::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))) {
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 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))) {
qWarning() << "Invalid joint index specified: " << jointIndex;
}
@ -818,8 +818,8 @@ 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 jointPos = getPosition();//default value if no or invalid joint specified
glm::quat jointRot = getRotation();//default value if no or invalid joint specified
glm::vec3 jointPos = getWorldPosition();//default value if no or invalid joint specified
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
if (jointIndex != -1) {
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::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))) {
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 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))) {
qWarning() << "Invalid joint index specified: " << jointIndex;
}
@ -1226,7 +1226,7 @@ void MyAvatar::updateLookAtTargetAvatar() {
float angleTo = coneSphereAngle(getHead()->getEyePosition(), lookForward, avatar->getHead()->getEyePosition(), radius);
if (angleTo < (smallestAngleTo * (isCurrentTarget ? KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR : 1.0f))) {
_lookAtTargetAvatar = avatarPointer;
_targetAvatarPosition = avatarPointer->getPosition();
_targetAvatarPosition = avatarPointer->getWorldPosition();
}
if (_lookAtSnappingEnabled && avatar->getLookAtSnappingEnabled() && isLookingAtMe(avatar)) {
@ -1297,7 +1297,7 @@ eyeContactTarget MyAvatar::getEyeContactTarget() {
}
glm::vec3 MyAvatar::getDefaultEyePosition() const {
return getPosition() + getOrientation() * Quaternions::Y_180 * _skeletonModel->getDefaultEyeModelPosition();
return getWorldPosition() + getWorldOrientation() * Quaternions::Y_180 * _skeletonModel->getDefaultEyeModelPosition();
}
const float SCRIPT_PRIORITY = 1.0f + 1.0f;
@ -1457,9 +1457,9 @@ glm::vec3 MyAvatar::getSkeletonPosition() const {
// 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.
const glm::quat FLIP = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
return getPosition() + getOrientation() * FLIP * _skeletonOffset;
return getWorldPosition() + getWorldOrientation() * FLIP * _skeletonOffset;
}
return Avatar::getPosition();
return Avatar::getWorldPosition();
}
void MyAvatar::rebuildCollisionShape() {
@ -1505,7 +1505,7 @@ controller::Pose MyAvatar::getControllerPoseInWorldFrame(controller::Action acti
controller::Pose MyAvatar::getControllerPoseInAvatarFrame(controller::Action action) const {
auto pose = getControllerPoseInWorldFrame(action);
if (pose.valid) {
glm::mat4 invAvatarMatrix = glm::inverse(createMatFromQuatAndPos(getOrientation(), getPosition()));
glm::mat4 invAvatarMatrix = glm::inverse(createMatFromQuatAndPos(getWorldOrientation(), getWorldPosition()));
return pose.transform(invAvatarMatrix);
} else {
return controller::Pose(); // invalid pose
@ -1524,7 +1524,7 @@ void MyAvatar::updateMotors() {
// we decompose camera's rotation and store the twist part in motorRotation
// however, we need to perform the decomposition in the avatar-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 liftRotation;
swingTwistDecomposition(headOrientation, Vectors::UNIT_Y, liftRotation, motorRotation);
@ -1544,7 +1544,7 @@ void MyAvatar::updateMotors() {
if (_scriptedMotorFrame == SCRIPTED_MOTOR_CAMERA_FRAME) {
motorRotation = getMyHead()->getHeadOrientation() * glm::angleAxis(PI, Vectors::UNIT_Y);
} else if (_scriptedMotorFrame == SCRIPTED_MOTOR_AVATAR_FRAME) {
motorRotation = getOrientation() * glm::angleAxis(PI, Vectors::UNIT_Y);
motorRotation = getWorldOrientation() * glm::angleAxis(PI, Vectors::UNIT_Y);
} else {
// world-frame
motorRotation = glm::quat();
@ -1572,7 +1572,7 @@ void MyAvatar::prepareForPhysicsSimulation() {
_characterController.setParentVelocity(parentVelocity);
_characterController.setScaleFactor(getSensorToWorldScale());
_characterController.setPositionAndOrientation(getPosition(), getOrientation());
_characterController.setPositionAndOrientation(getWorldPosition(), getWorldOrientation());
auto headPose = getControllerPoseInAvatarFrame(controller::Action::HEAD);
if (headPose.isValid()) {
_follow.prePhysicsUpdate(*this, deriveBodyFromHMDSensor(), _bodySensorMatrix, hasDriveInput());
@ -1606,20 +1606,20 @@ void MyAvatar::harvestResultsFromPhysicsSimulation(float deltaTime) {
if (_characterController.isEnabledAndReady()) {
_characterController.getPositionAndOrientation(position, orientation);
} else {
position = getPosition();
orientation = getOrientation();
position = getWorldPosition();
orientation = getWorldOrientation();
}
nextAttitude(position, orientation);
_bodySensorMatrix = _follow.postPhysicsUpdate(*this, _bodySensorMatrix);
if (_characterController.isEnabledAndReady()) {
setVelocity(_characterController.getLinearVelocity() + _characterController.getFollowVelocity());
setWorldVelocity(_characterController.getLinearVelocity() + _characterController.getFollowVelocity());
if (_characterController.isStuck()) {
_physicsSafetyPending = true;
_goToPosition = getPosition();
_goToPosition = getWorldPosition();
}
} else {
setVelocity(getVelocity() + _characterController.getFollowVelocity());
setWorldVelocity(getWorldVelocity() + _characterController.getFollowVelocity());
}
}
@ -1843,15 +1843,15 @@ void MyAvatar::postUpdate(float deltaTime, const render::ScenePointer& scene) {
}
}
DebugDraw::getInstance().updateMyAvatarPos(getPosition());
DebugDraw::getInstance().updateMyAvatarRot(getOrientation());
DebugDraw::getInstance().updateMyAvatarPos(getWorldPosition());
DebugDraw::getInstance().updateMyAvatarRot(getWorldOrientation());
AnimPose postUpdateRoomPose(_sensorToWorldMatrix);
updateHoldActions(_prePhysicsRoomPose, postUpdateRoomPose);
if (_enableDebugDrawDetailedCollision) {
AnimPose rigToWorldPose(glm::vec3(1.0f), getRotation() * Quaternions::Y_180, getPosition());
AnimPose rigToWorldPose(glm::vec3(1.0f), getWorldOrientation() * Quaternions::Y_180, getWorldPosition());
const int NUM_DEBUG_COLORS = 8;
const glm::vec4 DEBUG_COLORS[NUM_DEBUG_COLORS] = {
glm::vec4(1.0f, 1.0f, 1.0f, 1.0f),
@ -1958,7 +1958,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
if (qApp->isHMDMode() && getCharacterController()->getState() == CharacterController::State::Hover && _hmdRollControlEnabled && hasDriveInput()) {
// Turn with head roll.
const float MIN_CONTROL_SPEED = 0.01f;
float speed = glm::length(getVelocity());
float speed = glm::length(getWorldVelocity());
if (speed >= MIN_CONTROL_SPEED) {
// Feather turn when stopping moving.
float speedFactor;
@ -1969,7 +1969,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
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(getWorldVelocity(), getWorldOrientation() * Vectors::UNIT_NEG_Z) > 0.0f ? 1.0f : -1.0f;
float rollAngle = glm::degrees(asinf(glm::dot(IDENTITY_UP, _hmdSensorOrientation * IDENTITY_RIGHT)));
float rollSign = rollAngle < 0.0f ? -1.0f : 1.0f;
@ -1982,12 +1982,12 @@ void MyAvatar::updateOrientation(float deltaTime) {
// update body orientation by movement inputs
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) {
// 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;
_smoothOrientationTarget = getOrientation();
_smoothOrientationTarget = getWorldOrientation();
_smoothOrientationTimer = 0.0f;
}
@ -2080,7 +2080,7 @@ void MyAvatar::updatePosition(float deltaTime) {
updateActionMotor(deltaTime);
}
vec3 velocity = getVelocity();
vec3 velocity = getWorldVelocity();
float sensorToWorldScale = getSensorToWorldScale();
float sensorToWorldScale2 = sensorToWorldScale * sensorToWorldScale;
const float MOVING_SPEED_THRESHOLD_SQUARED = 0.0001f; // 0.01 m/s
@ -2102,9 +2102,9 @@ void MyAvatar::updatePosition(float deltaTime) {
if (_moving) {
// scan for walkability
glm::vec3 position = getPosition();
glm::vec3 position = getWorldPosition();
MyCharacterController::RayShotgunResult result;
glm::vec3 step = deltaTime * (getRotation() * _actionMotorVelocity);
glm::vec3 step = deltaTime * (getWorldOrientation() * _actionMotorVelocity);
_characterController.testRayShotgun(position, step, result);
_characterController.setStepUpEnabled(result.walkable);
}
@ -2335,7 +2335,7 @@ void MyAvatar::goToLocation(const glm::vec3& newPosition,
_goToPending = true;
_goToPosition = newPosition;
_goToOrientation = getOrientation();
_goToOrientation = getWorldOrientation();
if (hasOrientation) {
qCDebug(interfaceapp).nospace() << "MyAvatar goToLocation - new orientation is "
<< newOrientation.x << ", " << newOrientation.y << ", " << newOrientation.z << ", " << newOrientation.w;
@ -2404,7 +2404,7 @@ bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& bette
return false; // no entity tree
}
// More utilities.
const auto offset = getOrientation() *_characterController.getCapsuleLocalOffset();
const auto offset = getWorldOrientation() *_characterController.getCapsuleLocalOffset();
const auto capsuleCenter = positionIn + offset;
const auto up = _worldUpDirection, down = -up;
glm::vec3 upperIntersection, upperNormal, lowerIntersection, lowerNormal;
@ -2905,7 +2905,7 @@ glm::mat4 MyAvatar::FollowHelper::postPhysicsUpdate(const MyAvatar& myAvatar, co
}
float MyAvatar::getAccelerationEnergy() {
glm::vec3 velocity = getVelocity();
glm::vec3 velocity = getWorldVelocity();
int changeInVelocity = abs(velocity.length() - priorVelocity.length());
float changeInEnergy = priorVelocity.length() * changeInVelocity * AVATAR_MOVEMENT_ENERGY_CONSTANT;
priorVelocity = velocity;
@ -2926,7 +2926,7 @@ float MyAvatar::getAudioEnergy() {
}
bool MyAvatar::didTeleport() {
glm::vec3 pos = getPosition();
glm::vec3 pos = getWorldPosition();
glm::vec3 changeInPosition = pos - lastPosition;
lastPosition = pos;
return (changeInPosition.length() > MAX_AVATAR_MOVEMENT_PER_FRAME);
@ -2970,7 +2970,7 @@ glm::mat4 MyAvatar::computeCameraRelativeHandControllerMatrix(const glm::mat4& c
glm::mat4 controllerWorldMatrix = getSensorToWorldMatrix() * delta * controllerSensorMatrix;
// transform controller into avatar space
glm::mat4 avatarMatrix = createMatFromQuatAndPos(getOrientation(), getPosition());
glm::mat4 avatarMatrix = createMatFromQuatAndPos(getWorldOrientation(), getWorldPosition());
return glm::inverse(avatarMatrix) * controllerWorldMatrix;
}
@ -3174,7 +3174,7 @@ bool MyAvatar::pinJoint(int index, const glm::vec3& position, const glm::quat& o
}
slamPosition(position);
setOrientation(orientation);
setWorldOrientation(orientation);
_skeletonModel->getRig().setMaxHipsOffsetLength(0.05f);

View file

@ -114,7 +114,7 @@ class MyAvatar : public Avatar {
// FIXME: `glm::vec3 position` is not accessible from QML, so this exposes position in a QML-native type
Q_PROPERTY(QVector3D qmlPosition READ getQmlPosition)
QVector3D getQmlPosition() { auto p = getPosition(); return QVector3D(p.x, p.y, p.z); }
QVector3D getQmlPosition() { auto p = getWorldPosition(); return QVector3D(p.x, p.y, p.z); }
Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally)
Q_PROPERTY(glm::vec3 motorVelocity READ getScriptedMotorVelocity WRITE setScriptedMotorVelocity)

View file

@ -64,8 +64,8 @@ void MyCharacterController::updateShapeIfNecessary() {
_rigidBody->setSleepingThresholds(0.0f, 0.0f);
_rigidBody->setAngularFactor(0.0f);
_rigidBody->setWorldTransform(btTransform(glmToBullet(_avatar->getOrientation()),
glmToBullet(_avatar->getPosition())));
_rigidBody->setWorldTransform(btTransform(glmToBullet(_avatar->getWorldOrientation()),
glmToBullet(_avatar->getWorldPosition())));
_rigidBody->setDamping(0.0f, 0.0f);
if (_state == State::Hover) {
_rigidBody->setGravity(btVector3(0.0f, 0.0f, 0.0f));

View file

@ -39,7 +39,7 @@ glm::quat MyHead::getHeadOrientation() const {
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) {

View file

@ -28,8 +28,8 @@ const PickRay JointRayPick::getPickRay(bool& valid) const {
if (jointIndex != INVALID_JOINT || useAvatarHead) {
glm::vec3 jointPos = useAvatarHead ? myAvatar->getHeadPosition() : myAvatar->getAbsoluteJointTranslationInObjectFrame(jointIndex);
glm::quat jointRot = useAvatarHead ? myAvatar->getHeadOrientation() : myAvatar->getAbsoluteJointRotationInObjectFrame(jointIndex);
glm::vec3 avatarPos = myAvatar->getPosition();
glm::quat avatarRot = myAvatar->getOrientation();
glm::vec3 avatarPos = myAvatar->getWorldPosition();
glm::quat avatarRot = myAvatar->getWorldOrientation();
glm::vec3 pos = useAvatarHead ? jointPos : avatarPos + (avatarRot * jointPos);
glm::quat rot = useAvatarHead ? jointRot * glm::angleAxis(-PI / 2.0f, Vectors::RIGHT) : avatarRot * jointRot;

View file

@ -172,7 +172,7 @@ void LaserPointer::updateRenderState(const RenderState& renderState, const Inter
}
if (!renderState.getEndID().isNull()) {
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);
if (_distanceScaleEnd) {
dim = renderState.getEndDim() * glm::distance(pickRay.origin, endVec);

View file

@ -49,7 +49,7 @@ bool OverlayConductor::updateAvatarIsAtRest() {
const quint64 REST_DISABLE_TIME_USECS = 200 * 1000; // 200 ms
const float AT_REST_THRESHOLD = 0.01f;
bool desiredAtRest = glm::length(myAvatar->getVelocity()) < AT_REST_THRESHOLD;
bool desiredAtRest = glm::length(myAvatar->getWorldVelocity()) < AT_REST_THRESHOLD;
if (desiredAtRest != _desiredAtRest) {
// start timer
_desiredAtRestTimer = usecTimestampNow() + (desiredAtRest ? REST_ENABLE_TIME_USECS : REST_DISABLE_TIME_USECS);

View file

@ -192,9 +192,9 @@ void Stats::updateStats(bool force) {
// Third column, avatar stats
auto myAvatar = avatarManager->getMyAvatar();
glm::vec3 avatarPos = myAvatar->getPosition();
glm::vec3 avatarPos = myAvatar->getWorldPosition();
STAT_UPDATE(position, QVector3D(avatarPos.x, avatarPos.y, avatarPos.z));
STAT_UPDATE_FLOAT(speed, glm::length(myAvatar->getVelocity()), 0.01f);
STAT_UPDATE_FLOAT(speed, glm::length(myAvatar->getWorldVelocity()), 0.01f);
STAT_UPDATE_FLOAT(yaw, myAvatar->getBodyYaw(), 0.1f);
if (_expanded || force) {
SharedNodePointer avatarMixer = nodeList->soloNodeOfType(NodeType::AvatarMixer);

View file

@ -111,10 +111,10 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
properties["parentJointIndex"] = getParentJointIndex();
}
if (!properties["position"].isValid() && !properties["localPosition"].isValid()) {
properties["position"] = vec3toVariant(getPosition());
properties["position"] = vec3toVariant(getWorldPosition());
}
if (!properties["orientation"].isValid() && !properties["localOrientation"].isValid()) {
properties["orientation"] = quatToVariant(getOrientation());
properties["orientation"] = quatToVariant(getWorldOrientation());
}
}
@ -205,13 +205,13 @@ QVariant Base3DOverlay::getProperty(const QString& property) {
return _name;
}
if (property == "position" || property == "start" || property == "p1" || property == "point") {
return vec3toVariant(getPosition());
return vec3toVariant(getWorldPosition());
}
if (property == "localPosition") {
return vec3toVariant(getLocalPosition());
}
if (property == "rotation" || property == "orientation") {
return quatToVariant(getOrientation());
return quatToVariant(getWorldOrientation());
}
if (property == "localRotation" || property == "localOrientation") {
return quatToVariant(getLocalOrientation());

View file

@ -36,7 +36,7 @@ public:
virtual bool is3D() const override { return true; }
// TODO: consider implementing registration points in this class
glm::vec3 getCenter() const { return getPosition(); }
glm::vec3 getCenter() const { return getWorldPosition(); }
bool getIsSolid() const { return _isSolid; }
bool getIsDashedLine() const { return _isDashedLine; }

View file

@ -35,7 +35,7 @@ bool Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offse
glm::vec3 billboardPos = transform.getTranslation();
glm::vec3 cameraPos = qApp->getCamera().getPosition();
// 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(cameraPos, billboardPos, avatarUP))));

View file

@ -415,11 +415,11 @@ bool Circle3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::ve
// Scale the dimensions by the diameter
glm::vec2 dimensions = getOuterRadius() * 2.0f * getDimensions();
bool intersects = findRayRectangleIntersection(origin, direction, getRotation(), getPosition(), dimensions, distance);
bool intersects = findRayRectangleIntersection(origin, direction, getWorldOrientation(), getWorldPosition(), dimensions, distance);
if (intersects) {
glm::vec3 hitPosition = origin + (distance * direction);
glm::vec3 localHitPosition = glm::inverse(getRotation()) * (hitPosition - getPosition());
glm::vec3 localHitPosition = glm::inverse(getWorldOrientation()) * (hitPosition - getWorldPosition());
localHitPosition.x /= getDimensions().x;
localHitPosition.y /= getDimensions().y;
float distanceToHit = glm::length(localHitPosition);

View file

@ -185,9 +185,9 @@ bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID&
_contextOverlay->setIsFacingAvatar(true);
_contextOverlayID = qApp->getOverlays().addOverlay(_contextOverlay);
}
_contextOverlay->setPosition(contextOverlayPosition);
_contextOverlay->setWorldPosition(contextOverlayPosition);
_contextOverlay->setDimensions(contextOverlayDimensions);
_contextOverlay->setRotation(entityProperties.getRotation());
_contextOverlay->setWorldOrientation(entityProperties.getRotation());
_contextOverlay->setVisible(true);
return true;

View file

@ -144,9 +144,9 @@ QVariant Cube3DOverlay::getProperty(const QString& property) {
Transform Cube3DOverlay::evalRenderTransform() {
// TODO: handle registration point??
glm::vec3 position = getPosition();
glm::vec3 position = getWorldPosition();
glm::vec3 dimensions = getDimensions();
glm::quat rotation = getRotation();
glm::quat rotation = getWorldOrientation();
Transform transform;
transform.setScale(dimensions);

View file

@ -69,7 +69,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
auto minCorner = glm::vec2(-0.5f, -0.5f);
auto maxCorner = glm::vec2(0.5f, 0.5f);
auto position = getPosition();
auto position = getWorldPosition();
if (_followCamera) {
// Get the camera position rounded to the nearest major grid line
// This grid is for UI and should lie on worldlines
@ -146,7 +146,7 @@ void Grid3DOverlay::updateGrid() {
Transform Grid3DOverlay::evalRenderTransform() {
Transform transform;
transform.setRotation(getRotation());
transform.setRotation(getWorldOrientation());
transform.setScale(glm::vec3(getDimensions(), 1.0f));
return transform;
}

View file

@ -45,7 +45,7 @@ Line3DOverlay::~Line3DOverlay() {
}
glm::vec3 Line3DOverlay::getStart() const {
return getPosition();
return getWorldPosition();
}
glm::vec3 Line3DOverlay::getEnd() const {
@ -69,7 +69,7 @@ glm::vec3 Line3DOverlay::getEnd() const {
}
void Line3DOverlay::setStart(const glm::vec3& start) {
setPosition(start);
setWorldPosition(start);
}
void Line3DOverlay::setEnd(const glm::vec3& end) {

View file

@ -121,8 +121,8 @@ void ModelOverlay::setDrawHUDLayer(bool drawHUDLayer) {
}
void ModelOverlay::setProperties(const QVariantMap& properties) {
auto origPosition = getPosition();
auto origRotation = getRotation();
auto origPosition = getWorldPosition();
auto origRotation = getWorldOrientation();
auto origDimensions = getDimensions();
auto origScale = getSNScale();
@ -143,7 +143,7 @@ void ModelOverlay::setProperties(const QVariantMap& properties) {
_scaleToFit = false;
}
if (origPosition != getPosition() || origRotation != getRotation() || origDimensions != getDimensions() || origScale != getSNScale()) {
if (origPosition != getWorldPosition() || origRotation != getWorldOrientation() || origDimensions != getDimensions() || origScale != getSNScale()) {
_updateModel = true;
}
@ -383,8 +383,8 @@ 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()
if (_model && _model->isActive()) {
_model->setRotation(getRotation());
_model->setTranslation(getPosition());
_model->setRotation(getWorldOrientation());
_model->setTranslation(getWorldPosition());
}
}

View file

@ -827,8 +827,8 @@ PointerEvent Overlays::calculateOverlayPointerEvent(OverlayID overlayID, PickRay
if (!overlay) {
return PointerEvent();
}
glm::vec3 position = overlay->getPosition();
glm::quat rotation = overlay->getRotation();
glm::vec3 position = overlay->getWorldPosition();
glm::quat rotation = overlay->getWorldOrientation();
glm::vec2 dimensions = overlay->getSize();

View file

@ -68,8 +68,8 @@ namespace render {
if (overlay->getAnchor() == Overlay::MY_AVATAR) {
auto batch = args->_batch;
auto avatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
glm::quat myAvatarRotation = avatar->getOrientation();
glm::vec3 myAvatarPosition = avatar->getPosition();
glm::quat myAvatarRotation = avatar->getWorldOrientation();
glm::vec3 myAvatarPosition = avatar->getWorldPosition();
float angle = glm::degrees(glm::angle(myAvatarRotation));
glm::vec3 axis = glm::axis(myAvatarRotation);
float myAvatarScale = avatar->getModelScale();

View file

@ -69,7 +69,7 @@ QVariant Planar3DOverlay::getProperty(const QString& property) {
bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
// FIXME - face and surfaceNormal not being returned
return findRayRectangleIntersection(origin, direction, getRotation(), getPosition(), getDimensions(), distance);
return findRayRectangleIntersection(origin, direction, getWorldOrientation(), getWorldPosition(), getDimensions(), distance);
}
Transform Planar3DOverlay::evalRenderTransform() {

View file

@ -121,9 +121,9 @@ QVariant Shape3DOverlay::getProperty(const QString& property) {
Transform Shape3DOverlay::evalRenderTransform() {
// TODO: handle registration point??
glm::vec3 position = getPosition();
glm::vec3 position = getWorldPosition();
glm::vec3 dimensions = getDimensions();
glm::quat rotation = getRotation();
glm::quat rotation = getWorldOrientation();
Transform transform;
transform.setScale(dimensions);

View file

@ -20,8 +20,8 @@ Volume3DOverlay::Volume3DOverlay(const Volume3DOverlay* volume3DOverlay) :
AABox Volume3DOverlay::getBounds() const {
auto extents = Extents{_localBoundingBox};
extents.rotate(getRotation());
extents.shiftBy(getPosition());
extents.rotate(getWorldOrientation());
extents.shiftBy(getWorldPosition());
return AABox(extents);
}

View file

@ -151,7 +151,7 @@ void Web3DOverlay::buildWebSurface() {
_webSurface = DependencyManager::get<OffscreenQmlSurfaceCache>()->acquire(_url);
setupQmlSurface();
}
_webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(getPosition()));
_webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(getWorldPosition()));
_webSurface->resize(QSize(_resolution.x, _resolution.y));
_webSurface->resume();
});
@ -171,7 +171,7 @@ void Web3DOverlay::hoverLeaveOverlay(const PointerEvent& event) {
void Web3DOverlay::update(float deltatime) {
if (_webSurface) {
// update globalPosition
_webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(getPosition()));
_webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(getWorldPosition()));
}
Parent::update(deltatime);
}
@ -632,7 +632,7 @@ bool Web3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3&
// 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.
return findRayRectangleIntersection(origin, direction, getRotation(), getPosition(), getSize(), distance);
return findRayRectangleIntersection(origin, direction, getWorldOrientation(), getWorldPosition(), getSize(), distance);
}
Web3DOverlay* Web3DOverlay::createClone() const {

View file

@ -145,18 +145,18 @@ void Avatar::init() {
glm::vec3 Avatar::getChestPosition() const {
// for now, let's just assume that the "chest" is halfway between the root and the neck
glm::vec3 neckPosition;
return _skeletonModel->getNeckPosition(neckPosition) ? (getPosition() + neckPosition) * 0.5f : getPosition();
return _skeletonModel->getNeckPosition(neckPosition) ? (getWorldPosition() + neckPosition) * 0.5f : getWorldPosition();
}
glm::vec3 Avatar::getNeckPosition() const {
glm::vec3 neckPosition;
return _skeletonModel->getNeckPosition(neckPosition) ? neckPosition : getPosition();
return _skeletonModel->getNeckPosition(neckPosition) ? neckPosition : getWorldPosition();
}
AABox Avatar::getBounds() const {
if (!_skeletonModel->isRenderable() || _skeletonModel->needsFixupInScene()) {
// approximately 2m tall, scaled to user request.
return AABox(getPosition() - glm::vec3(getModelScale()), getModelScale() * 2.0f);
return AABox(getWorldPosition() - glm::vec3(getModelScale()), getModelScale() * 2.0f);
}
return _skeletonModel->getRenderableMeshBound();
}
@ -371,9 +371,9 @@ void Avatar::simulate(float deltaTime, bool inView) {
locationChanged(); // joints changed, so if there are any children, update them.
_hasNewJointData = false;
glm::vec3 headPosition = getPosition();
glm::vec3 headPosition = getWorldPosition();
if (!_skeletonModel->getHeadPosition(headPosition)) {
headPosition = getPosition();
headPosition = getWorldPosition();
}
head->setPosition(headPosition);
}
@ -439,9 +439,9 @@ bool Avatar::isLookingAtMe(AvatarSharedPointer avatar) const {
}
void Avatar::slamPosition(const glm::vec3& newPosition) {
setPosition(newPosition);
setWorldPosition(newPosition);
_positionDeltaAccumulator = glm::vec3(0.0f);
setVelocity(glm::vec3(0.0f));
setWorldVelocity(glm::vec3(0.0f));
_lastVelocity = glm::vec3(0.0f);
}
@ -451,7 +451,7 @@ void Avatar::updateAttitude(const glm::quat& orientation) {
}
void Avatar::applyPositionDelta(const glm::vec3& delta) {
setPosition(getPosition() + delta);
setWorldPosition(getWorldPosition() + delta);
_positionDeltaAccumulator += delta;
}
@ -467,14 +467,14 @@ void Avatar::measureMotionDerivatives(float deltaTime) {
_positionDeltaAccumulator = glm::vec3(0.0f);
_acceleration = (velocity - _lastVelocity) * invDeltaTime;
_lastVelocity = velocity;
setVelocity(velocity);
setWorldVelocity(velocity);
// angular
glm::quat orientation = getOrientation();
glm::quat orientation = getWorldOrientation();
glm::quat delta = glm::inverse(_lastOrientation) * orientation;
glm::vec3 angularVelocity = glm::axis(delta) * glm::angle(delta) * invDeltaTime;
setAngularVelocity(angularVelocity);
_lastOrientation = getOrientation();
setWorldAngularVelocity(angularVelocity);
_lastOrientation = getWorldOrientation();
}
enum TextRendererType {
@ -602,7 +602,7 @@ void Avatar::render(RenderArgs* renderArgs) {
glm::vec3 viewPos = renderArgs->getViewFrustum().getPosition();
const float MAX_DISTANCE_SQUARED_FOR_SHOWING_POINTING_LASERS = 100.0f; // 10^2
if (glm::distance2(viewPos, getPosition()) < MAX_DISTANCE_SQUARED_FOR_SHOWING_POINTING_LASERS) {
if (glm::distance2(viewPos, getWorldPosition()) < MAX_DISTANCE_SQUARED_FOR_SHOWING_POINTING_LASERS) {
auto geometryCache = DependencyManager::get<GeometryCache>();
// render pointing lasers
@ -661,7 +661,7 @@ void Avatar::render(RenderArgs* renderArgs) {
}
ViewFrustum frustum = renderArgs->getViewFrustum();
if (!frustum.sphereIntersectsFrustum(getPosition(), getBoundingRadius())) {
if (!frustum.sphereIntersectsFrustum(getWorldPosition(), getBoundingRadius())) {
return;
}
@ -672,7 +672,7 @@ void Avatar::render(RenderArgs* renderArgs) {
}
if (showReceiveStats || showNamesAboveHeads) {
glm::vec3 toTarget = frustum.getPosition() - getPosition();
glm::vec3 toTarget = frustum.getPosition() - getWorldPosition();
float distanceToTarget = glm::length(toTarget);
const float DISPLAYNAME_DISTANCE = 20.0f;
updateDisplayNameAlpha(distanceToTarget < DISPLAYNAME_DISTANCE);
@ -735,7 +735,7 @@ void Avatar::simulateAttachments(float deltaTime) {
glm::quat jointRotation;
if (attachment.isSoft) {
// soft attachments do not have transform offsets
model->setTransformNoUpdateRenderItems(Transform(getOrientation() * Quaternions::Y_180, glm::vec3(1.0), getPosition()));
model->setTransformNoUpdateRenderItems(Transform(getWorldOrientation() * Quaternions::Y_180, glm::vec3(1.0), getWorldPosition()));
model->simulate(deltaTime);
model->updateRenderItems();
} else {
@ -789,9 +789,9 @@ glm::vec3 Avatar::getDisplayNamePosition() const {
const float HEAD_PROPORTION = 0.75f;
float size = getBoundingRadius();
DEBUG_VALUE("_position =", getPosition());
DEBUG_VALUE("_position =", getWorldPosition());
DEBUG_VALUE("size =", size);
namePosition = getPosition() + bodyUpDirection * (size * HEAD_PROPORTION);
namePosition = getWorldPosition() + bodyUpDirection * (size * HEAD_PROPORTION);
}
if (glm::any(glm::isnan(namePosition)) || glm::any(glm::isinf(namePosition))) {
@ -916,7 +916,7 @@ glm::vec3 Avatar::getSkeletonPosition() const {
// 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.
const glm::quat FLIP = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
return getPosition() + getOrientation() * FLIP * _skeletonOffset;
return getWorldPosition() + getWorldOrientation() * FLIP * _skeletonOffset;
}
QVector<glm::quat> Avatar::getJointRotations() const {
@ -1180,7 +1180,7 @@ glm::vec3 Avatar::getJointPosition(const QString& name) const {
void Avatar::scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const {
//Scale a world space vector as if it was relative to the position
positionToScale = getPosition() + getModelScale() * (positionToScale - getPosition());
positionToScale = getWorldPosition() + getModelScale() * (positionToScale - getWorldPosition());
}
void Avatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
@ -1268,12 +1268,12 @@ int Avatar::parseDataFromBuffer(const QByteArray& buffer) {
}
// change in position implies movement
glm::vec3 oldPosition = getPosition();
glm::vec3 oldPosition = getWorldPosition();
int bytesRead = AvatarData::parseDataFromBuffer(buffer);
const float MOVE_DISTANCE_THRESHOLD = 0.001f;
_moving = glm::distance(oldPosition, getPosition()) > MOVE_DISTANCE_THRESHOLD;
_moving = glm::distance(oldPosition, getWorldPosition()) > MOVE_DISTANCE_THRESHOLD;
if (_moving) {
addPhysicsFlags(Simulation::DIRTY_POSITION);
}
@ -1347,7 +1347,7 @@ float Avatar::getHeadHeight() const {
Extents extents = _skeletonModel->getMeshExtents();
glm::vec3 neckPosition;
if (!extents.isEmpty() && extents.isValid() && _skeletonModel->getNeckPosition(neckPosition)) {
return extents.maximum.y / 2.0f - neckPosition.y + getPosition().y;
return extents.maximum.y / 2.0f - neckPosition.y + getWorldPosition().y;
}
const float DEFAULT_HEAD_HEIGHT = 0.25f;
@ -1392,8 +1392,8 @@ void Avatar::getCapsule(glm::vec3& start, glm::vec3& end, float& radius) {
ShapeInfo shapeInfo;
computeShapeInfo(shapeInfo);
glm::vec3 halfExtents = shapeInfo.getHalfExtents(); // x = radius, y = halfHeight
start = getPosition() - glm::vec3(0, halfExtents.y, 0) + shapeInfo.getOffset();
end = getPosition() + glm::vec3(0, halfExtents.y, 0) + shapeInfo.getOffset();
start = getWorldPosition() - glm::vec3(0, halfExtents.y, 0) + shapeInfo.getOffset();
end = getWorldPosition() + glm::vec3(0, halfExtents.y, 0) + shapeInfo.getOffset();
radius = halfExtents.x;
}
@ -1486,12 +1486,12 @@ glm::quat Avatar::getUncachedRightPalmRotation() const {
}
void Avatar::setPositionViaScript(const glm::vec3& position) {
setPosition(position);
updateAttitude(getOrientation());
setWorldPosition(position);
updateAttitude(getWorldOrientation());
}
void Avatar::setOrientationViaScript(const glm::quat& orientation) {
setOrientation(orientation);
setWorldOrientation(orientation);
updateAttitude(orientation);
}

View file

@ -320,8 +320,8 @@ protected:
void fade(render::Transaction& transaction, render::Transition::Type type);
glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
glm::vec3 getBodyUpDirection() const { return getOrientation() * IDENTITY_UP; }
glm::vec3 getBodyRightDirection() const { return getWorldOrientation() * IDENTITY_RIGHT; }
glm::vec3 getBodyUpDirection() const { return getWorldOrientation() * IDENTITY_UP; }
void measureMotionDerivatives(float deltaTime);
float getSkeletonHeight() const;

View file

@ -253,7 +253,7 @@ void Head::setScale (float scale) {
}
glm::quat Head::getFinalOrientationInWorldFrame() const {
return _owningAvatar->getOrientation() * getFinalOrientationInLocalFrame();
return _owningAvatar->getWorldOrientation() * getFinalOrientationInLocalFrame();
}
glm::quat Head::getFinalOrientationInLocalFrame() const {

View file

@ -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),
// but just before head has been simulated.
void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
updateAttitude(_owningAvatar->getOrientation());
updateAttitude(_owningAvatar->getWorldOrientation());
if (fullUpdate) {
setBlendshapeCoefficients(_owningAvatar->getHead()->getSummedBlendshapeCoefficients());

View file

@ -118,12 +118,12 @@ void AvatarData::setTargetScale(float targetScale) {
}
glm::vec3 AvatarData::getHandPosition() const {
return getOrientation() * _handPosition + getPosition();
return getWorldOrientation() * _handPosition + getWorldPosition();
}
void AvatarData::setHandPosition(const glm::vec3& handPosition) {
// store relative to position/orientation
_handPosition = glm::inverse(getOrientation()) * (handPosition - getPosition());
_handPosition = glm::inverse(getWorldOrientation()) * (handPosition - getWorldPosition());
}
void AvatarData::lazyInitHeadData() const {
@ -1900,8 +1900,8 @@ void registerAvatarTypes(QScriptEngine* engine) {
void AvatarData::setRecordingBasis(std::shared_ptr<Transform> recordingBasis) {
if (!recordingBasis) {
recordingBasis = std::make_shared<Transform>();
recordingBasis->setRotation(getOrientation());
recordingBasis->setTranslation(getPosition());
recordingBasis->setRotation(getWorldOrientation());
recordingBasis->setTranslation(getWorldPosition());
// TODO: find a different way to record/playback the Scale of the avatar
//recordingBasis->setScale(getTargetScale());
}
@ -2059,14 +2059,14 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) {
auto relativeTransform = Transform::fromJson(json[JSON_AVATAR_RELATIVE]);
auto worldTransform = currentBasis->worldTransform(relativeTransform);
setPosition(worldTransform.getTranslation());
setWorldPosition(worldTransform.getTranslation());
orientation = worldTransform.getRotation();
} else {
// We still set the position in the case that there is no movement.
setPosition(currentBasis->getTranslation());
setWorldPosition(currentBasis->getTranslation());
orientation = currentBasis->getRotation();
}
setOrientation(orientation);
setWorldOrientation(orientation);
updateAttitude(orientation);
// Do after avatar orientation because head look-at needs avatar orientation.
@ -2153,44 +2153,44 @@ void AvatarData::fromFrame(const QByteArray& frameData, AvatarData& result, bool
}
float AvatarData::getBodyYaw() const {
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
return eulerAngles.y;
}
void AvatarData::setBodyYaw(float bodyYaw) {
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
eulerAngles.y = bodyYaw;
setOrientation(glm::quat(glm::radians(eulerAngles)));
setWorldOrientation(glm::quat(glm::radians(eulerAngles)));
}
float AvatarData::getBodyPitch() const {
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
return eulerAngles.x;
}
void AvatarData::setBodyPitch(float bodyPitch) {
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
eulerAngles.x = bodyPitch;
setOrientation(glm::quat(glm::radians(eulerAngles)));
setWorldOrientation(glm::quat(glm::radians(eulerAngles)));
}
float AvatarData::getBodyRoll() const {
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
return eulerAngles.z;
}
void AvatarData::setBodyRoll(float bodyRoll) {
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getOrientation()));
glm::vec3 eulerAngles = glm::degrees(safeEulerAngles(getWorldOrientation()));
eulerAngles.z = bodyRoll;
setOrientation(glm::quat(glm::radians(eulerAngles)));
setWorldOrientation(glm::quat(glm::radians(eulerAngles)));
}
void AvatarData::setPositionViaScript(const glm::vec3& position) {
SpatiallyNestable::setPosition(position);
SpatiallyNestable::setWorldPosition(position);
}
void AvatarData::setOrientationViaScript(const glm::quat& orientation) {
SpatiallyNestable::setOrientation(orientation);
SpatiallyNestable::setWorldOrientation(orientation);
}
glm::quat AvatarData::getAbsoluteJointRotationInObjectFrame(int index) const {
@ -2415,7 +2415,7 @@ void AvatarData::sortAvatars(
// (a) apparentSize
// (b) proximity to center of view
// (c) time since last update
glm::vec3 avatarPosition = avatar->getPosition();
glm::vec3 avatarPosition = avatar->getWorldPosition();
glm::vec3 offset = avatarPosition - frustumCenter;
float distance = glm::length(offset) + 0.001f; // add 1mm to avoid divide by zero

View file

@ -337,7 +337,7 @@ public:
class AvatarData : public QObject, public SpatiallyNestable {
Q_OBJECT
Q_PROPERTY(glm::vec3 position READ getPosition WRITE setPositionViaScript)
Q_PROPERTY(glm::vec3 position READ getWorldPosition WRITE setPositionViaScript)
Q_PROPERTY(float scale READ getTargetScale WRITE setTargetScale)
Q_PROPERTY(float density READ getDensity)
Q_PROPERTY(glm::vec3 handPosition READ getHandPosition WRITE setHandPosition)
@ -345,14 +345,14 @@ class AvatarData : public QObject, public SpatiallyNestable {
Q_PROPERTY(float bodyPitch READ getBodyPitch WRITE setBodyPitch)
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(float headPitch READ getHeadPitch WRITE setHeadPitch)
Q_PROPERTY(float headYaw READ getHeadYaw WRITE setHeadYaw)
Q_PROPERTY(float headRoll READ getHeadRoll WRITE setHeadRoll)
Q_PROPERTY(glm::vec3 velocity READ getVelocity WRITE setVelocity)
Q_PROPERTY(glm::vec3 angularVelocity READ getAngularVelocity WRITE setAngularVelocity)
Q_PROPERTY(glm::vec3 velocity READ getWorldVelocity WRITE setWorldVelocity)
Q_PROPERTY(glm::vec3 angularVelocity READ getWorldAngularVelocity WRITE setWorldAngularVelocity)
Q_PROPERTY(float audioLoudness READ getAudioLoudness WRITE setAudioLoudness)
Q_PROPERTY(float audioAverageLoudness READ getAudioAverageLoudness WRITE setAudioAverageLoudness)

View file

@ -33,7 +33,7 @@ QVector<QUuid> AvatarHashMap::getAvatarIdentifiers() {
bool AvatarHashMap::isAvatarInRange(const glm::vec3& position, const float range) {
auto hashCopy = getHashCopy();
foreach(const AvatarSharedPointer& sharedAvatar, hashCopy) {
glm::vec3 avatarPosition = sharedAvatar->getPosition();
glm::vec3 avatarPosition = sharedAvatar->getWorldPosition();
float distance = glm::distance(avatarPosition, position);
if (distance < range) {
return true;
@ -47,7 +47,7 @@ int AvatarHashMap::numberOfAvatarsInRange(const glm::vec3& position, float range
auto rangeMeters2 = rangeMeters * rangeMeters;
int count = 0;
for (const AvatarSharedPointer& sharedAvatar : hashCopy) {
glm::vec3 avatarPosition = sharedAvatar->getPosition();
glm::vec3 avatarPosition = sharedAvatar->getWorldPosition();
auto distance2 = glm::distance2(avatarPosition, position);
if (distance2 < rangeMeters2) {
++count;

View file

@ -49,11 +49,11 @@ void HeadData::setRawOrientation(const glm::quat& q) {
glm::quat HeadData::getOrientation() const {
return _owningAvatar->getOrientation() * getRawOrientation();
return _owningAvatar->getWorldOrientation() * getRawOrientation();
}
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));
_basePitch = eulers.x;
_baseYaw = eulers.y;
@ -62,10 +62,10 @@ void HeadData::setHeadOrientation(const glm::quat& orientation) {
void HeadData::setOrientation(const glm::quat& orientation) {
// rotate body about vertical axis
glm::quat bodyOrientation = _owningAvatar->getOrientation();
glm::quat bodyOrientation = _owningAvatar->getWorldOrientation();
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));
_owningAvatar->setOrientation(bodyOrientation);
_owningAvatar->setWorldOrientation(bodyOrientation);
// the rest goes to the head
setHeadOrientation(orientation);
@ -154,8 +154,8 @@ QJsonObject HeadData::toJson() const {
}
auto lookat = getLookAtPosition();
if (lookat != vec3()) {
vec3 relativeLookAt = glm::inverse(_owningAvatar->getOrientation()) *
(getLookAtPosition() - _owningAvatar->getPosition());
vec3 relativeLookAt = glm::inverse(_owningAvatar->getWorldOrientation()) *
(getLookAtPosition() - _owningAvatar->getWorldPosition());
headJson[JSON_AVATAR_HEAD_LOOKAT] = toJsonValue(relativeLookAt);
}
return headJson;
@ -185,7 +185,7 @@ void HeadData::fromJson(const QJsonObject& json) {
if (json.contains(JSON_AVATAR_HEAD_LOOKAT)) {
auto relativeLookAt = vec3FromJsonValue(json[JSON_AVATAR_HEAD_LOOKAT]);
if (glm::length2(relativeLookAt) > 0.01f) {
setLookAtPosition((_owningAvatar->getOrientation() * relativeLookAt) + _owningAvatar->getPosition());
setLookAtPosition((_owningAvatar->getWorldOrientation() * relativeLookAt) + _owningAvatar->getWorldPosition());
}
}

View file

@ -24,7 +24,7 @@ ScriptAvatarData::ScriptAvatarData(AvatarSharedPointer avatarData) :
//
glm::vec3 ScriptAvatarData::getPosition() const {
if (AvatarSharedPointer sharedAvatarData = _avatarData.lock()) {
return sharedAvatarData->getPosition();
return sharedAvatarData->getWorldPosition();
} else {
return glm::vec3();
}
@ -66,7 +66,7 @@ float ScriptAvatarData::getBodyRoll() const {
}
glm::quat ScriptAvatarData::getOrientation() const {
if (AvatarSharedPointer sharedAvatarData = _avatarData.lock()) {
return sharedAvatarData->getOrientation();
return sharedAvatarData->getWorldOrientation();
} else {
return glm::quat();
}
@ -110,14 +110,14 @@ float ScriptAvatarData::getHeadRoll() const {
//
glm::vec3 ScriptAvatarData::getVelocity() const {
if (AvatarSharedPointer sharedAvatarData = _avatarData.lock()) {
return sharedAvatarData->getVelocity();
return sharedAvatarData->getWorldVelocity();
} else {
return glm::vec3();
}
}
glm::vec3 ScriptAvatarData::getAngularVelocity() const {
if (AvatarSharedPointer sharedAvatarData = _avatarData.lock()) {
return sharedAvatarData->getAngularVelocity();
return sharedAvatarData->getWorldAngularVelocity();
} else {
return glm::vec3();
}

View file

@ -324,7 +324,7 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene
public:
SortableRenderer(const EntityRendererPointer& renderer) : _renderer(renderer) { }
glm::vec3 getPosition() const override { return _renderer->getEntity()->getPosition(); }
glm::vec3 getPosition() const override { return _renderer->getEntity()->getWorldPosition(); }
float getRadius() const override { return 0.5f * _renderer->getEntity()->getQueryAACube().getScale(); }
uint64_t getTimestamp() const override { return _renderer->getUpdateTime(); }
@ -587,8 +587,8 @@ static glm::vec2 projectOntoEntityXYPlane(EntityItemPointer entity, const PickRa
if (entity) {
glm::vec3 entityPosition = entity->getPosition();
glm::quat entityRotation = entity->getRotation();
glm::vec3 entityPosition = entity->getWorldPosition();
glm::quat entityRotation = entity->getWorldOrientation();
glm::vec3 entityDimensions = entity->getDimensions();
glm::vec3 entityRegistrationPoint = entity->getRegistrationPoint();

View file

@ -28,8 +28,8 @@ void LightEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
lightPayload.setVisible(_visible);
auto light = lightPayload.editLight();
light->setPosition(entity->getPosition());
light->setOrientation(entity->getRotation());
light->setPosition(entity->getWorldPosition());
light->setOrientation(entity->getWorldOrientation());
bool success;
lightPayload.editBound() = entity->getAABox(success);

View file

@ -123,8 +123,8 @@ void RenderableModelEntityItem::doInitialModelSimulation() {
// now recalculate the bounds and registration
model->setScaleToFit(true, getDimensions());
model->setSnapModelToRegistrationPoint(true, getRegistrationPoint());
model->setRotation(getRotation());
model->setTranslation(getPosition());
model->setRotation(getWorldOrientation());
model->setTranslation(getWorldPosition());
if (_needsInitialSimulation) {
model->simulate(0.0f);

View file

@ -154,8 +154,8 @@ void PolyLineEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPo
entity->resetPolyLineChanged();
_polylineTransform = Transform();
_polylineTransform.setTranslation(entity->getPosition());
_polylineTransform.setRotation(entity->getRotation());
_polylineTransform.setTranslation(entity->getWorldPosition());
_polylineTransform.setRotation(entity->getWorldOrientation());
if (pointsChanged) {
_lastPoints = entity->getLinePoints();

View file

@ -232,7 +232,7 @@ glm::mat4 RenderablePolyVoxEntityItem::voxelToLocalMatrix() const {
glm::vec3 scale = dimensions / voxelVolumeSize; // meters / voxel-units
bool success; // TODO -- Does this actually have to happen in world space?
glm::vec3 center = getCenterPosition(success); // this handles registrationPoint changes
glm::vec3 position = getPosition(success);
glm::vec3 position = getWorldPosition(success);
glm::vec3 positionToCenter = center - position;
positionToCenter -= dimensions * Vectors::HALF - getSurfacePositionAdjustment();
@ -247,8 +247,8 @@ glm::mat4 RenderablePolyVoxEntityItem::localToVoxelMatrix() const {
}
glm::mat4 RenderablePolyVoxEntityItem::voxelToWorldMatrix() const {
glm::mat4 rotation = glm::mat4_cast(getRotation());
glm::mat4 translation = glm::translate(getPosition());
glm::mat4 rotation = glm::mat4_cast(getWorldOrientation());
glm::mat4 translation = glm::translate(getWorldPosition());
return translation * rotation * voxelToLocalMatrix();
}
@ -579,7 +579,7 @@ bool RenderablePolyVoxEntityItem::findDetailedRayIntersection(const glm::vec3& o
// the PolyVox ray intersection code requires a near and far point.
// set ray cast length to long enough to cover all of the voxel space
float distanceToEntity = glm::distance(origin, getPosition());
float distanceToEntity = glm::distance(origin, getWorldPosition());
glm::vec3 dimensions = getDimensions();
float largestDimension = glm::compMax(dimensions) * 2.0f;
glm::vec3 farPoint = origin + normDirection * (distanceToEntity + largestDimension);
@ -641,10 +641,10 @@ ShapeType RenderablePolyVoxEntityItem::getShapeType() const {
return SHAPE_TYPE_COMPOUND;
}
void RenderablePolyVoxEntityItem::updateRegistrationPoint(const glm::vec3& value) {
void RenderablePolyVoxEntityItem::setRegistrationPoint(const glm::vec3& value) {
if (value != _registrationPoint) {
_meshDirty = true;
EntityItem::updateRegistrationPoint(value);
EntityItem::setRegistrationPoint(value);
}
}

View file

@ -98,7 +98,7 @@ public:
std::shared_ptr<RenderablePolyVoxEntityItem> getYPNeighbor();
std::shared_ptr<RenderablePolyVoxEntityItem> getZPNeighbor();
virtual void updateRegistrationPoint(const glm::vec3& value) override;
virtual void setRegistrationPoint(const glm::vec3& value) override;
void setVoxelsFromData(QByteArray uncompressedData, quint16 voxelXSize, quint16 voxelYSize, quint16 voxelZSize);
void forEachVoxelValue(const ivec3& voxelSize, std::function<void(const ivec3&, uint8_t)> thunk);

View file

@ -81,9 +81,9 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
_color = vec4(toGlm(entity->getXColor()), entity->getLocalRenderAlpha());
_shape = entity->getShape();
_position = entity->getPosition();
_position = entity->getWorldPosition();
_dimensions = entity->getDimensions();
_orientation = entity->getOrientation();
_orientation = entity->getWorldOrientation();
_renderTransform = getModelTransform();
if (_shape == entity::Sphere) {

View file

@ -69,7 +69,7 @@ void WebEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity)
}
bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
if (_contextPosition != entity->getPosition()) {
if (_contextPosition != entity->getWorldPosition()) {
return true;
}
@ -127,9 +127,9 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
buildWebSurface(entity);
}
if (_contextPosition != entity->getPosition()) {
if (_contextPosition != entity->getWorldPosition()) {
// update globalPosition
_contextPosition = entity->getPosition();
_contextPosition = entity->getWorldPosition();
_webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(_contextPosition));
}

View file

@ -204,8 +204,8 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
bool hazeChanged = entity->hazePropertiesChanged();
entity->resetRenderingPropertiesChanged();
_lastPosition = entity->getPosition();
_lastRotation = entity->getRotation();
_lastPosition = entity->getWorldPosition();
_lastRotation = entity->getWorldOrientation();
_lastDimensions = entity->getDimensions();
_keyLightProperties = entity->getKeyLightProperties();
@ -275,13 +275,13 @@ bool ZoneEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint
return true;
}
if (entity->getPosition() != _lastPosition) {
if (entity->getWorldPosition() != _lastPosition) {
return true;
}
if (entity->getDimensions() != _lastDimensions) {
return true;
}
if (entity->getRotation() != _lastRotation) {
if (entity->getWorldOrientation() != _lastRotation) {
return true;
}

View file

@ -731,7 +731,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
// reasons and the contract is that the client handles them in an idempotent manner.
auto customUpdatePositionFromNetwork = [this, shouldUpdate, lastEdited](glm::vec3 value){
if (shouldUpdate(_lastUpdatedPositionTimestamp, value != _lastUpdatedPositionValue)) {
updatePosition(value);
setPosition(value);
_lastUpdatedPositionTimestamp = lastEdited;
_lastUpdatedPositionValue = value;
}
@ -739,7 +739,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
auto customUpdateRotationFromNetwork = [this, shouldUpdate, lastEdited](glm::quat value){
if (shouldUpdate(_lastUpdatedRotationTimestamp, value != _lastUpdatedRotationValue)) {
updateRotation(value);
setRotation(value);
_lastUpdatedRotationTimestamp = lastEdited;
_lastUpdatedRotationValue = value;
}
@ -747,7 +747,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
auto customUpdateVelocityFromNetwork = [this, shouldUpdate, lastEdited](glm::vec3 value){
if (shouldUpdate(_lastUpdatedVelocityTimestamp, value != _lastUpdatedVelocityValue)) {
updateVelocity(value);
setVelocity(value);
_lastUpdatedVelocityTimestamp = lastEdited;
_lastUpdatedVelocityValue = value;
}
@ -755,7 +755,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
auto customUpdateAngularVelocityFromNetwork = [this, shouldUpdate, lastEdited](glm::vec3 value){
if (shouldUpdate(_lastUpdatedAngularVelocityTimestamp, value != _lastUpdatedAngularVelocityValue)) {
updateAngularVelocity(value);
setAngularVelocity(value);
_lastUpdatedAngularVelocityTimestamp = lastEdited;
_lastUpdatedAngularVelocityValue = value;
}
@ -776,14 +776,14 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
READ_ENTITY_PROPERTY(PROP_ACCELERATION, glm::vec3, customSetAcceleration);
}
READ_ENTITY_PROPERTY(PROP_DIMENSIONS, glm::vec3, updateDimensions);
READ_ENTITY_PROPERTY(PROP_DENSITY, float, updateDensity);
READ_ENTITY_PROPERTY(PROP_GRAVITY, glm::vec3, updateGravity);
READ_ENTITY_PROPERTY(PROP_DIMENSIONS, glm::vec3, setDimensions);
READ_ENTITY_PROPERTY(PROP_DENSITY, float, setDensity);
READ_ENTITY_PROPERTY(PROP_GRAVITY, glm::vec3, setGravity);
READ_ENTITY_PROPERTY(PROP_DAMPING, float, updateDamping);
READ_ENTITY_PROPERTY(PROP_RESTITUTION, float, updateRestitution);
READ_ENTITY_PROPERTY(PROP_FRICTION, float, updateFriction);
READ_ENTITY_PROPERTY(PROP_LIFETIME, float, updateLifetime);
READ_ENTITY_PROPERTY(PROP_DAMPING, float, setDamping);
READ_ENTITY_PROPERTY(PROP_RESTITUTION, float, setRestitution);
READ_ENTITY_PROPERTY(PROP_FRICTION, float, setFriction);
READ_ENTITY_PROPERTY(PROP_LIFETIME, float, setLifetime);
READ_ENTITY_PROPERTY(PROP_SCRIPT, QString, setScript);
READ_ENTITY_PROPERTY(PROP_SCRIPT_TIMESTAMP, quint64, setScriptTimestamp);
@ -799,14 +799,14 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
READ_ENTITY_PROPERTY(PROP_SERVER_SCRIPTS, QString, setServerScripts);
}
READ_ENTITY_PROPERTY(PROP_REGISTRATION_POINT, glm::vec3, updateRegistrationPoint);
READ_ENTITY_PROPERTY(PROP_REGISTRATION_POINT, glm::vec3, setRegistrationPoint);
READ_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, float, updateAngularDamping);
READ_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, float, setAngularDamping);
READ_ENTITY_PROPERTY(PROP_VISIBLE, bool, setVisible);
READ_ENTITY_PROPERTY(PROP_COLLISIONLESS, bool, updateCollisionless);
READ_ENTITY_PROPERTY(PROP_COLLISION_MASK, uint8_t, updateCollisionMask);
READ_ENTITY_PROPERTY(PROP_DYNAMIC, bool, updateDynamic);
READ_ENTITY_PROPERTY(PROP_LOCKED, bool, updateLocked);
READ_ENTITY_PROPERTY(PROP_COLLISIONLESS, bool, setCollisionless);
READ_ENTITY_PROPERTY(PROP_COLLISION_MASK, uint8_t, setCollisionMask);
READ_ENTITY_PROPERTY(PROP_DYNAMIC, bool, setDynamic);
READ_ENTITY_PROPERTY(PROP_LOCKED, bool, setLocked);
READ_ENTITY_PROPERTY(PROP_USER_DATA, QString, setUserData);
READ_ENTITY_PROPERTY(PROP_MARKETPLACE_ID, QString, setMarketplaceID);
@ -829,7 +829,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
{ // parentID and parentJointIndex are also protected by simulation ownership
bool oldOverwrite = overwriteLocalData;
overwriteLocalData = overwriteLocalData && !weOwnSimulation;
READ_ENTITY_PROPERTY(PROP_PARENT_ID, QUuid, updateParentID);
READ_ENTITY_PROPERTY(PROP_PARENT_ID, QUuid, setParentID);
READ_ENTITY_PROPERTY(PROP_PARENT_JOINT_INDEX, quint16, setParentJointIndex);
overwriteLocalData = oldOverwrite;
}
@ -890,7 +890,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
}
void EntityItem::debugDump() const {
auto position = getPosition();
auto position = getWorldPosition();
qCDebug(entities) << "EntityItem id:" << getEntityItemID();
qCDebug(entities, " edited ago:%f", (double)getEditedAgo());
qCDebug(entities, " position:%f,%f,%f", (double)position.x, (double)position.y, (double)position.z);
@ -924,12 +924,6 @@ float EntityItem::computeMass() const {
}
void EntityItem::setDensity(float density) {
withWriteLock([&] {
_density = glm::max(glm::min(density, ENTITY_ITEM_MAX_DENSITY), ENTITY_ITEM_MIN_DENSITY);
});
}
void EntityItem::updateDensity(float density) {
float clampedDensity = glm::max(glm::min(density, ENTITY_ITEM_MAX_DENSITY), ENTITY_ITEM_MIN_DENSITY);
withWriteLock([&] {
if (_density != clampedDensity) {
@ -1176,8 +1170,8 @@ bool EntityItem::wantTerseEditLogging() const {
}
glm::mat4 EntityItem::getEntityToWorldMatrix() const {
glm::mat4 translation = glm::translate(getPosition());
glm::mat4 rotation = glm::mat4_cast(getRotation());
glm::mat4 translation = glm::translate(getWorldPosition());
glm::mat4 rotation = glm::mat4_cast(getWorldOrientation());
glm::mat4 scale = glm::scale(getDimensions());
glm::mat4 registration = glm::translate(ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint());
return translation * rotation * scale * registration;
@ -1317,30 +1311,30 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
bool somethingChanged = false;
// these affect TerseUpdate properties
SET_ENTITY_PROPERTY_FROM_PROPERTIES(simulationOwner, updateSimulationOwner);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(position, updatePosition);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(rotation, updateRotation);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(velocity, updateVelocity);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularVelocity, updateAngularVelocity);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(simulationOwner, setSimulationOwner);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(position, setPosition);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(rotation, setRotation);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(velocity, setVelocity);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularVelocity, setAngularVelocity);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(acceleration, setAcceleration);
// these (along with "position" above) affect tree structure
SET_ENTITY_PROPERTY_FROM_PROPERTIES(dimensions, updateDimensions);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(registrationPoint, updateRegistrationPoint);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(dimensions, setDimensions);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(registrationPoint, setRegistrationPoint);
// these (along with all properties above) affect the simulation
SET_ENTITY_PROPERTY_FROM_PROPERTIES(density, updateDensity);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(gravity, updateGravity);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(damping, updateDamping);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularDamping, updateAngularDamping);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(restitution, updateRestitution);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(friction, updateFriction);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(collisionless, updateCollisionless);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(collisionMask, updateCollisionMask);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(dynamic, updateDynamic);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(created, updateCreated);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(lifetime, updateLifetime);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(locked, updateLocked);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(density, setDensity);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(gravity, setGravity);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(damping, setDamping);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularDamping, setAngularDamping);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(restitution, setRestitution);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(friction, setFriction);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(collisionless, setCollisionless);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(collisionMask, setCollisionMask);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(dynamic, setDynamic);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(created, setCreated);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(lifetime, setLifetime);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(locked, setLocked);
// non-simulation properties below
SET_ENTITY_PROPERTY_FROM_PROPERTIES(script, setScript);
@ -1367,7 +1361,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(href, setHref);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(description, setDescription);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(actionData, setDynamicData);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(parentID, updateParentID);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(parentID, setParentID);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(parentJointIndex, setParentJointIndex);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(queryAACube, setQueryAACube);
@ -1432,23 +1426,12 @@ const Transform EntityItem::getTransformToCenter(bool& success) const {
return result;
}
void EntityItem::setDimensions(const glm::vec3& value) {
if (value.x <= 0.0f || value.y <= 0.0f || value.z <= 0.0f) {
return;
}
if (_dimensions != value) {
_dimensions = value;
locationChanged();
dimensionsChanged();
}
}
/// The maximum bounding cube for the entity, independent of it's rotation.
/// This accounts for the registration point (upon which rotation occurs around).
///
AACube EntityItem::getMaximumAACube(bool& success) const {
if (_recalcMaxAACube) {
glm::vec3 centerOfRotation = getPosition(success); // also where _registration point is
glm::vec3 centerOfRotation = getWorldPosition(success); // also where _registration point is
if (success) {
_recalcMaxAACube = false;
// we want to compute the furthestExtent that an entity can extend out from its "position"
@ -1476,14 +1459,14 @@ AACube EntityItem::getMaximumAACube(bool& success) const {
AACube EntityItem::getMinimumAACube(bool& success) const {
if (_recalcMinAACube) {
// position represents the position of the registration point.
glm::vec3 position = getPosition(success);
glm::vec3 position = getWorldPosition(success);
if (success) {
_recalcMinAACube = false;
glm::vec3 dimensions = getDimensions();
glm::vec3 unrotatedMinRelativeToEntity = - (dimensions * _registrationPoint);
glm::vec3 unrotatedMaxRelativeToEntity = dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint);
Extents extents = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity };
extents.rotate(getRotation());
extents.rotate(getWorldOrientation());
// shift the extents to be relative to the position/registration point
extents.shiftBy(position);
@ -1506,14 +1489,14 @@ AACube EntityItem::getMinimumAACube(bool& success) const {
AABox EntityItem::getAABox(bool& success) const {
if (_recalcAABox) {
// position represents the position of the registration point.
glm::vec3 position = getPosition(success);
glm::vec3 position = getWorldPosition(success);
if (success) {
_recalcAABox = false;
glm::vec3 dimensions = getDimensions();
glm::vec3 unrotatedMinRelativeToEntity = - (dimensions * _registrationPoint);
glm::vec3 unrotatedMaxRelativeToEntity = dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint);
Extents extents = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity };
extents.rotate(getRotation());
extents.rotate(getWorldOrientation());
// shift the extents to be relative to the position/registration point
extents.shiftBy(position);
@ -1544,25 +1527,6 @@ bool EntityItem::shouldPuffQueryAACube() const {
return hasActions() || isChildOfMyAvatar() || isMovingRelativeToParent();
}
// NOTE: This should only be used in cases of old bitstreams which only contain radius data
// 0,0,0 --> maxDimension,maxDimension,maxDimension
// ... has a corner to corner distance of glm::length(maxDimension,maxDimension,maxDimension)
// ... radius = cornerToCornerLength / 2.0f
// ... radius * 2.0f = cornerToCornerLength
// ... cornerToCornerLength = sqrt(3 x maxDimension ^ 2)
// ... cornerToCornerLength = sqrt(3 x maxDimension ^ 2)
// ... radius * 2.0f = sqrt(3 x maxDimension ^ 2)
// ... (radius * 2.0f) ^2 = 3 x maxDimension ^ 2
// ... ((radius * 2.0f) ^2) / 3 = maxDimension ^ 2
// ... sqrt(((radius * 2.0f) ^2) / 3) = maxDimension
// ... sqrt((diameter ^2) / 3) = maxDimension
//
void EntityItem::setRadius(float value) {
float diameter = value * 2.0f;
float maxDimension = sqrt((diameter * diameter) / 3.0f);
setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension));
}
// TODO: get rid of all users of this function...
// ... radius = cornerToCornerLength / 2.0f
// ... cornerToCornerLength = sqrt(3 x maxDimension ^ 2)
@ -1603,14 +1567,17 @@ float EntityItem::getVolumeEstimate() const {
return dimensions.x * dimensions.y * dimensions.z;
}
void EntityItem::updateRegistrationPoint(const glm::vec3& value) {
void EntityItem::setRegistrationPoint(const glm::vec3& value) {
if (value != _registrationPoint) {
setRegistrationPoint(value);
withWriteLock([&] {
_registrationPoint = glm::clamp(value, 0.0f, 1.0f);
});
dimensionsChanged(); // Registration Point affects the bounding box
markDirtyFlags(Simulation::DIRTY_SHAPE);
}
}
void EntityItem::updatePosition(const glm::vec3& value) {
void EntityItem::setPosition(const glm::vec3& value) {
if (getLocalPosition() != value) {
setLocalPosition(value);
@ -1631,14 +1598,14 @@ void EntityItem::updatePosition(const glm::vec3& value) {
}
}
void EntityItem::updateParentID(const QUuid& value) {
void EntityItem::setParentID(const QUuid& value) {
QUuid oldParentID = getParentID();
if (oldParentID != value) {
EntityTreePointer tree = getTree();
if (!oldParentID.isNull()) {
tree->removeFromChildrenOfAvatars(getThisPointer());
}
setParentID(value);
SpatiallyNestable::setParentID(value);
// children are forced to be kinematic
// may need to not collide with own avatar
markDirtyFlags(Simulation::DIRTY_MOTION_TYPE | Simulation::DIRTY_COLLISION_GROUP);
@ -1650,15 +1617,20 @@ void EntityItem::updateParentID(const QUuid& value) {
}
}
void EntityItem::updateDimensions(const glm::vec3& value) {
if (getDimensions() != value) {
setDimensions(value);
markDirtyFlags(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS);
_queryAACubeSet = false;
void EntityItem::setDimensions(const glm::vec3& value) {
glm::vec3 newDimensions = glm::max(value, glm::vec3(0.0f)); // can never have negative dimensions
if (getDimensions() != newDimensions) {
withWriteLock([&] {
_dimensions = newDimensions;
_dirtyFlags |= (Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS);
_queryAACubeSet = false;
});
locationChanged();
dimensionsChanged();
}
}
void EntityItem::updateRotation(const glm::quat& rotation) {
void EntityItem::setRotation(glm::quat rotation) {
if (getLocalOrientation() != rotation) {
setLocalOrientation(rotation);
_dirtyFlags |= Simulation::DIRTY_ROTATION;
@ -1671,31 +1643,7 @@ void EntityItem::updateRotation(const glm::quat& rotation) {
}
}
void EntityItem::updateMass(float mass) {
// Setting the mass actually changes the _density (at fixed volume), however
// we must protect the density range to help maintain stability of physics simulation
// therefore this method might not accept the mass that is supplied.
glm::vec3 dimensions = getDimensions();
float volume = _volumeMultiplier * dimensions.x * dimensions.y * dimensions.z;
// compute new density
float newDensity = _density;
const float MIN_VOLUME = 1.0e-6f; // 0.001mm^3
if (volume < 1.0e-6f) {
// avoid divide by zero
newDensity = glm::min(mass / MIN_VOLUME, ENTITY_ITEM_MAX_DENSITY);
} else {
newDensity = glm::max(glm::min(mass / volume, ENTITY_ITEM_MAX_DENSITY), ENTITY_ITEM_MIN_DENSITY);
}
if (_density != newDensity) {
_density = newDensity;
_dirtyFlags |= Simulation::DIRTY_MASS;
}
}
void EntityItem::updateVelocity(const glm::vec3& value) {
void EntityItem::setVelocity(const glm::vec3& value) {
glm::vec3 velocity = getLocalVelocity();
if (velocity != value) {
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
@ -1721,34 +1669,38 @@ void EntityItem::updateVelocity(const glm::vec3& value) {
}
}
void EntityItem::updateDamping(float value) {
void EntityItem::setDamping(float value) {
auto clampedDamping = glm::clamp(value, 0.0f, 1.0f);
if (_damping != clampedDamping) {
_damping = clampedDamping;
_dirtyFlags |= Simulation::DIRTY_MATERIAL;
}
withWriteLock([&] {
if (_damping != clampedDamping) {
_damping = clampedDamping;
_dirtyFlags |= Simulation::DIRTY_MATERIAL;
}
});
}
void EntityItem::updateGravity(const glm::vec3& value) {
if (_gravity != value) {
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
_gravity = Vectors::ZERO;
} else {
float magnitude = glm::length(value);
if (!glm::isnan(magnitude)) {
const float MAX_ACCELERATION_OF_GRAVITY = 10.0f * 9.8f; // 10g
if (magnitude > MAX_ACCELERATION_OF_GRAVITY) {
_gravity = (MAX_ACCELERATION_OF_GRAVITY / magnitude) * value;
} else {
_gravity = value;
void EntityItem::setGravity(const glm::vec3& value) {
withWriteLock([&] {
if (_gravity != value) {
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
_gravity = Vectors::ZERO;
} else {
float magnitude = glm::length(value);
if (!glm::isnan(magnitude)) {
const float MAX_ACCELERATION_OF_GRAVITY = 10.0f * 9.8f; // 10g
if (magnitude > MAX_ACCELERATION_OF_GRAVITY) {
_gravity = (MAX_ACCELERATION_OF_GRAVITY / magnitude) * value;
} else {
_gravity = value;
}
_dirtyFlags |= Simulation::DIRTY_LINEAR_VELOCITY;
}
_dirtyFlags |= Simulation::DIRTY_LINEAR_VELOCITY;
}
}
}
});
}
void EntityItem::updateAngularVelocity(const glm::vec3& value) {
void EntityItem::setAngularVelocity(const glm::vec3& value) {
glm::vec3 angularVelocity = getLocalAngularVelocity();
if (angularVelocity != value) {
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
@ -1772,52 +1724,63 @@ void EntityItem::updateAngularVelocity(const glm::vec3& value) {
}
}
void EntityItem::updateAngularDamping(float value) {
void EntityItem::setAngularDamping(float value) {
auto clampedDamping = glm::clamp(value, 0.0f, 1.0f);
if (_angularDamping != clampedDamping) {
_angularDamping = clampedDamping;
_dirtyFlags |= Simulation::DIRTY_MATERIAL;
}
withWriteLock([&] {
if (_angularDamping != clampedDamping) {
_angularDamping = clampedDamping;
_dirtyFlags |= Simulation::DIRTY_MATERIAL;
}
});
}
void EntityItem::updateCollisionless(bool value) {
if (_collisionless != value) {
_collisionless = value;
_dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP;
}
void EntityItem::setCollisionless(bool value) {
withWriteLock([&] {
if (_collisionless != value) {
_collisionless = value;
_dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP;
}
});
}
void EntityItem::updateCollisionMask(uint8_t value) {
if ((_collisionMask & ENTITY_COLLISION_MASK_DEFAULT) != (value & ENTITY_COLLISION_MASK_DEFAULT)) {
_collisionMask = (value & ENTITY_COLLISION_MASK_DEFAULT);
_dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP;
}
void EntityItem::setCollisionMask(uint8_t value) {
withWriteLock([&] {
if ((_collisionMask & ENTITY_COLLISION_MASK_DEFAULT) != (value & ENTITY_COLLISION_MASK_DEFAULT)) {
_collisionMask = (value & ENTITY_COLLISION_MASK_DEFAULT);
_dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP;
}
});
}
void EntityItem::updateDynamic(bool value) {
void EntityItem::setDynamic(bool value) {
if (getDynamic() != value) {
// dynamic and STATIC_MESH are incompatible so we check for that case
if (value && getShapeType() == SHAPE_TYPE_STATIC_MESH) {
if (_dynamic) {
_dynamic = false;
withWriteLock([&] {
// dynamic and STATIC_MESH are incompatible so we check for that case
if (value && getShapeType() == SHAPE_TYPE_STATIC_MESH) {
if (_dynamic) {
_dynamic = false;
_dirtyFlags |= Simulation::DIRTY_MOTION_TYPE;
}
} else {
_dynamic = value;
_dirtyFlags |= Simulation::DIRTY_MOTION_TYPE;
}
} else {
_dynamic = value;
_dirtyFlags |= Simulation::DIRTY_MOTION_TYPE;
}
});
}
}
void EntityItem::updateRestitution(float value) {
void EntityItem::setRestitution(float value) {
float clampedValue = glm::max(glm::min(ENTITY_ITEM_MAX_RESTITUTION, value), ENTITY_ITEM_MIN_RESTITUTION);
if (_restitution != clampedValue) {
_restitution = clampedValue;
_dirtyFlags |= Simulation::DIRTY_MATERIAL;
}
withWriteLock([&] {
if (_restitution != clampedValue) {
_restitution = clampedValue;
_dirtyFlags |= Simulation::DIRTY_MATERIAL;
}
});
}
void EntityItem::updateFriction(float value) {
void EntityItem::setFriction(float value) {
float clampedValue = glm::max(glm::min(ENTITY_ITEM_MAX_FRICTION, value), ENTITY_ITEM_MIN_FRICTION);
withWriteLock([&] {
if (_friction != clampedValue) {
@ -1827,34 +1790,24 @@ void EntityItem::updateFriction(float value) {
});
}
void EntityItem::setRestitution(float value) {
float clampedValue = glm::max(glm::min(ENTITY_ITEM_MAX_RESTITUTION, value), ENTITY_ITEM_MIN_RESTITUTION);
void EntityItem::setLifetime(float value) {
withWriteLock([&] {
_restitution = clampedValue;
if (_lifetime != value) {
_lifetime = value;
_dirtyFlags |= Simulation::DIRTY_LIFETIME;
}
});
}
void EntityItem::setFriction(float value) {
float clampedValue = glm::max(glm::min(ENTITY_ITEM_MAX_FRICTION, value), ENTITY_ITEM_MIN_FRICTION);
void EntityItem::setCreated(quint64 value) {
withWriteLock([&] {
_friction = clampedValue;
if (_created != value) {
_created = value;
_dirtyFlags |= Simulation::DIRTY_LIFETIME;
}
});
}
void EntityItem::updateLifetime(float value) {
if (_lifetime != value) {
_lifetime = value;
_dirtyFlags |= Simulation::DIRTY_LIFETIME;
}
}
void EntityItem::updateCreated(uint64_t value) {
if (_created != value) {
_created = value;
_dirtyFlags |= Simulation::DIRTY_LIFETIME;
}
}
void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask) const {
if (_collisionless) {
group = BULLET_COLLISION_GROUP_COLLISIONLESS;
@ -1925,14 +1878,6 @@ void EntityItem::setSimulationOwner(const QUuid& id, quint8 priority) {
}
void EntityItem::setSimulationOwner(const SimulationOwner& owner) {
if (wantTerseEditLogging() && _simulationOwner != owner) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << owner;
}
_simulationOwner.set(owner);
}
void EntityItem::updateSimulationOwner(const SimulationOwner& owner) {
// NOTE: this method only used by EntityServer. The Interface uses special code in readEntityDataFromBuffer().
if (wantTerseEditLogging() && _simulationOwner != owner) {
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << owner;
@ -2348,10 +2293,10 @@ void EntityItem::dimensionsChanged() {
void EntityItem::globalizeProperties(EntityItemProperties& properties, const QString& messageTemplate, const glm::vec3& offset) const {
// TODO -- combine this with convertLocationToScriptSemantics
bool success;
auto globalPosition = getPosition(success);
auto globalPosition = getWorldPosition(success);
if (success) {
properties.setPosition(globalPosition + offset);
properties.setRotation(getRotation());
properties.setRotation(getWorldOrientation());
properties.setDimensions(getDimensions());
// Should we do velocities and accelerations, too? This could end up being quite involved, which is why the method exists.
} else {
@ -2518,12 +2463,6 @@ glm::vec3 EntityItem::getGravity() const {
return result;
}
void EntityItem::setGravity(const glm::vec3& value) {
withWriteLock([&] {
_gravity = value;
});
}
glm::vec3 EntityItem::getAcceleration() const {
glm::vec3 result;
withReadLock([&] {
@ -2545,11 +2484,6 @@ float EntityItem::getDamping() const {
});
return result;
}
void EntityItem::setDamping(float value) {
withWriteLock([&] {
_damping = value;
});
}
float EntityItem::getRestitution() const {
float result;
@ -2576,12 +2510,6 @@ float EntityItem::getLifetime() const {
return result;
}
void EntityItem::setLifetime(float value) {
withWriteLock([&] {
_lifetime = value;
});
}
quint64 EntityItem::getCreated() const {
quint64 result;
withReadLock([&] {
@ -2590,12 +2518,6 @@ quint64 EntityItem::getCreated() const {
return result;
}
void EntityItem::setCreated(quint64 value) {
withWriteLock([&] {
_created = value;
});
}
QString EntityItem::getScript() const {
QString result;
withReadLock([&] {
@ -2655,13 +2577,6 @@ glm::vec3 EntityItem::getRegistrationPoint() const {
return result;
}
void EntityItem::setRegistrationPoint(const glm::vec3& value) {
withWriteLock([&] {
_registrationPoint = glm::clamp(value, 0.0f, 1.0f);
});
dimensionsChanged(); // Registration Point affects the bounding box
}
float EntityItem::getAngularDamping() const {
float result;
withReadLock([&] {
@ -2670,12 +2585,6 @@ float EntityItem::getAngularDamping() const {
return result;
}
void EntityItem::setAngularDamping(float value) {
withWriteLock([&] {
_angularDamping = value;
});
}
QString EntityItem::getName() const {
QString result;
withReadLock([&] {
@ -2725,12 +2634,6 @@ bool EntityItem::getCollisionless() const {
return result;
}
void EntityItem::setCollisionless(bool value) {
withWriteLock([&] {
_collisionless = value;
});
}
uint8_t EntityItem::getCollisionMask() const {
uint8_t result;
withReadLock([&] {
@ -2739,12 +2642,6 @@ uint8_t EntityItem::getCollisionMask() const {
return result;
}
void EntityItem::setCollisionMask(uint8_t value) {
withWriteLock([&] {
_collisionMask = value;
});
}
bool EntityItem::getDynamic() const {
if (SHAPE_TYPE_STATIC_MESH == getShapeType()) {
return false;
@ -2756,12 +2653,6 @@ bool EntityItem::getDynamic() const {
return result;
}
void EntityItem::setDynamic(bool value) {
withWriteLock([&] {
_dynamic = value;
});
}
bool EntityItem::getLocked() const {
bool result;
withReadLock([&] {
@ -2771,12 +2662,6 @@ bool EntityItem::getLocked() const {
}
void EntityItem::setLocked(bool value) {
withWriteLock([&] {
_locked = value;
});
}
void EntityItem::updateLocked(bool value) {
bool changed { false };
withWriteLock([&] {
if (_locked != value) {

View file

@ -192,7 +192,7 @@ public:
float getDensity() const;
bool hasVelocity() const { return getVelocity() != ENTITY_ITEM_ZERO_VEC3; }
bool hasVelocity() const { return getWorldVelocity() != ENTITY_ITEM_ZERO_VEC3; }
bool hasLocalVelocity() const { return getLocalVelocity() != ENTITY_ITEM_ZERO_VEC3; }
glm::vec3 getGravity() const; /// get gravity in meters
@ -254,11 +254,13 @@ public:
glm::vec3 getRegistrationPoint() const; /// registration point as ratio of entity
/// registration point as ratio of entity
virtual void setRegistrationPoint(const glm::vec3& value);
virtual void setRegistrationPoint(const glm::vec3& value); // FIXME: this is suspicious!
bool hasAngularVelocity() const { return getAngularVelocity() != ENTITY_ITEM_ZERO_VEC3; }
bool hasAngularVelocity() const { return getWorldAngularVelocity() != ENTITY_ITEM_ZERO_VEC3; }
bool hasLocalAngularVelocity() const { return getLocalAngularVelocity() != ENTITY_ITEM_ZERO_VEC3; }
virtual void setAngularVelocity(const glm::vec3& angularVelocity);
float getAngularDamping() const;
void setAngularDamping(float value);
@ -288,10 +290,9 @@ public:
bool getLocked() const;
void setLocked(bool value);
void updateLocked(bool value);
QString getUserData() const;
virtual void setUserData(const QString& value);
virtual void setUserData(const QString& value); // FIXME: This is suspicious
// FIXME not thread safe?
const SimulationOwner& getSimulationOwner() const { return _simulationOwner; }
@ -301,7 +302,6 @@ public:
quint8 getSimulationPriority() const { return _simulationOwner.getPriority(); }
QUuid getSimulatorID() const { return _simulationOwner.getID(); }
void updateSimulationOwner(const SimulationOwner& owner);
void clearSimulationOwnership();
void setPendingOwnershipPriority(quint8 priority, const quint64& timestamp);
uint8_t getPendingOwnershipPriority() const { return _simulationOwner.getPendingPriority(); }
@ -344,28 +344,13 @@ public:
virtual void setCollisionShape(const btCollisionShape* shape) {}
// updateFoo() methods to be used when changes need to be accumulated in the _dirtyFlags
virtual void updateRegistrationPoint(const glm::vec3& value);
void updatePosition(const glm::vec3& value);
void updateParentID(const QUuid& value);
void updateDimensions(const glm::vec3& value);
void updateRotation(const glm::quat& rotation);
void updateDensity(float value);
void updateMass(float value);
void updateVelocity(const glm::vec3& value);
void updateDamping(float value);
void updateRestitution(float value);
void updateFriction(float value);
void updateGravity(const glm::vec3& value);
void updateAngularVelocity(const glm::vec3& value);
void updateAngularDamping(float value);
void updateCollisionless(bool value);
void updateCollisionMask(uint8_t value);
void updateDynamic(bool value);
void updateLifetime(float value);
void updateCreated(uint64_t value);
void setPosition(const glm::vec3& value);
virtual void setParentID(const QUuid& parentID) override;
virtual void setShapeType(ShapeType type) { /* do nothing */ }
void setRotation(glm::quat orientation);
void setVelocity(const glm::vec3& velocity);
uint32_t getDirtyFlags() const;
void markDirtyFlags(uint32_t mask);
void clearDirtyFlags(uint32_t mask = 0xffffffff);
@ -573,12 +558,6 @@ protected:
// damping = 1 - exp(-1 / timescale)
//
// NOTE: Radius support is obsolete, but these private helper functions are available for this class to
// parse old data streams
/// set radius in domain scale units (0.0 - 1.0) this will also reset dimensions to be equal for each axis
void setRadius(float value);
// DirtyFlags are set whenever a property changes that the EntitySimulation needs to know about.
uint32_t _dirtyFlags { 0 }; // things that have changed from EXTERNAL changes (via script or packet) but NOT from simulation

View file

@ -376,7 +376,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
// If any of these changed, pull any missing properties from the entity.
//existing entity, retrieve old velocity for check down below
oldVelocity = entity->getVelocity().length();
oldVelocity = entity->getWorldVelocity().length();
if (!scriptSideProperties.parentIDChanged()) {
properties.setParentID(entity->getParentID());
@ -385,10 +385,10 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
properties.setParentJointIndex(entity->getParentJointIndex());
}
if (!scriptSideProperties.localPositionChanged() && !scriptSideProperties.positionChanged()) {
properties.setPosition(entity->getPosition());
properties.setPosition(entity->getWorldPosition());
}
if (!scriptSideProperties.localRotationChanged() && !scriptSideProperties.rotationChanged()) {
properties.setRotation(entity->getOrientation());
properties.setRotation(entity->getWorldOrientation());
}
}
properties = convertLocationFromScriptSemantics(properties);
@ -532,7 +532,7 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
auto dimensions = entity->getDimensions();
float volume = dimensions.x * dimensions.y * dimensions.z;
auto density = entity->getDensity();
auto velocity = entity->getVelocity().length();
auto velocity = entity->getWorldVelocity().length();
float cost = calculateCost(density * volume, velocity, 0);
cost *= costMultiplier;
@ -1797,8 +1797,8 @@ glm::mat4 EntityScriptingInterface::getEntityTransform(const QUuid& entityID) {
_entityTree->withReadLock([&] {
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(EntityItemID(entityID));
if (entity) {
glm::mat4 translation = glm::translate(entity->getPosition());
glm::mat4 rotation = glm::mat4_cast(entity->getRotation());
glm::mat4 translation = glm::translate(entity->getWorldPosition());
glm::mat4 rotation = glm::mat4_cast(entity->getWorldOrientation());
result = translation * rotation;
}
});

View file

@ -726,7 +726,7 @@ bool EntityTree::findNearPointOperation(const OctreeElementPointer& element, voi
// we may have gotten NULL back, meaning no entity was available
if (thisClosestEntity) {
glm::vec3 entityPosition = thisClosestEntity->getPosition();
glm::vec3 entityPosition = thisClosestEntity->getWorldPosition();
float distanceFromPointToEntity = glm::distance(entityPosition, args->position);
// If we're within our target radius
@ -1099,7 +1099,7 @@ bool EntityTree::filterProperties(EntityItemPointer& existingEntity, EntityItemP
bool accepted = true;
auto entityEditFilters = DependencyManager::get<EntityEditFilters>();
if (entityEditFilters) {
auto position = existingEntity ? existingEntity->getPosition() : propertiesIn.getPosition();
auto position = existingEntity ? existingEntity->getWorldPosition() : propertiesIn.getPosition();
auto entityID = existingEntity ? existingEntity->getEntityItemID() : EntityItemID();
accepted = entityEditFilters->filter(position, propertiesIn, propertiesOut, wasChanged, filterType, entityID);
}

View file

@ -662,8 +662,8 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con
}
// extents is the entity relative, scaled, centered extents of the entity
glm::mat4 rotation = glm::mat4_cast(entity->getRotation());
glm::mat4 translation = glm::translate(entity->getPosition());
glm::mat4 rotation = glm::mat4_cast(entity->getWorldOrientation());
glm::mat4 translation = glm::translate(entity->getWorldPosition());
glm::mat4 entityToWorldMatrix = translation * rotation;
glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix);
@ -718,7 +718,7 @@ bool EntityTreeElement::findSpherePenetration(const glm::vec3& center, float rad
bool result = false;
withReadLock([&] {
foreach(EntityItemPointer entity, _entityItems) {
glm::vec3 entityCenter = entity->getPosition();
glm::vec3 entityCenter = entity->getWorldPosition();
float entityRadius = entity->getRadius();
// don't penetrate yourself
@ -743,7 +743,7 @@ EntityItemPointer EntityTreeElement::getClosestEntity(glm::vec3 position) const
float closestEntityDistance = FLT_MAX;
withReadLock([&] {
foreach(EntityItemPointer entity, _entityItems) {
float distanceToEntity = glm::distance2(position, entity->getPosition());
float distanceToEntity = glm::distance2(position, entity->getWorldPosition());
if (distanceToEntity < closestEntityDistance) {
closestEntity = entity;
}
@ -787,8 +787,8 @@ void EntityTreeElement::getEntities(const glm::vec3& searchPosition, float searc
} else {
// determine the worldToEntityMatrix that doesn't include scale because
// we're going to use the registration aware aa box in the entity frame
glm::mat4 rotation = glm::mat4_cast(entity->getRotation());
glm::mat4 translation = glm::translate(entity->getPosition());
glm::mat4 rotation = glm::mat4_cast(entity->getWorldOrientation());
glm::mat4 translation = glm::translate(entity->getWorldPosition());
glm::mat4 entityToWorldMatrix = translation * rotation;
glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix);

View file

@ -156,7 +156,7 @@ void LineEntityItem::debugDump() const {
quint64 now = usecTimestampNow();
qCDebug(entities) << " LINE EntityItem id:" << getEntityItemID() << "---------------------------------------------";
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
qCDebug(entities) << " position:" << debugTreeVector(getWorldPosition());
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
}

View file

@ -189,7 +189,7 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
void ModelEntityItem::debugDump() const {
qCDebug(entities) << "ModelEntityItem id:" << getEntityItemID();
qCDebug(entities) << " edited ago:" << getEditedAgo();
qCDebug(entities) << " position:" << getPosition();
qCDebug(entities) << " position:" << getWorldPosition();
qCDebug(entities) << " dimensions:" << getDimensions();
qCDebug(entities) << " model URL:" << getModelURL();
qCDebug(entities) << " compound shape URL:" << getCompoundShapeURL();

View file

@ -592,7 +592,7 @@ void ParticleEffectEntityItem::debugDump() const {
_particleProperties.color.gradient.target.red << "," <<
_particleProperties.color.gradient.target.green << "," <<
_particleProperties.color.gradient.target.blue;
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
qCDebug(entities) << " position:" << debugTreeVector(getWorldPosition());
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
}

View file

@ -256,7 +256,7 @@ void PolyLineEntityItem::debugDump() const {
quint64 now = usecTimestampNow();
qCDebug(entities) << " QUAD EntityItem id:" << getEntityItemID() << "---------------------------------------------";
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
qCDebug(entities) << " position:" << debugTreeVector(getWorldPosition());
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
}

View file

@ -99,7 +99,7 @@ class PolyLineEntityItem : public EntityItem {
void** intersectedObject, bool precisionPicking) const override { return false; }
// disable these external interfaces as PolyLineEntities caculate their own dimensions based on the points they contain
virtual void setRegistrationPoint(const glm::vec3& value) override {};
virtual void setRegistrationPoint(const glm::vec3& value) override {}; // FIXME: this is suspicious!
virtual void debugDump() const override;
static const float DEFAULT_LINE_WIDTH;

View file

@ -228,7 +228,7 @@ void PolyVoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeB
void PolyVoxEntityItem::debugDump() const {
quint64 now = usecTimestampNow();
qCDebug(entities) << " POLYVOX EntityItem id:" << getEntityItemID() << "---------------------------------------------";
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
qCDebug(entities) << " position:" << debugTreeVector(getWorldPosition());
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
}
@ -396,7 +396,7 @@ glm::mat4 PolyVoxEntityItem::voxelToLocalMatrix() const {
glm::vec3 scale = dimensions / voxelVolumeSize; // meters / voxel-units
bool success; // TODO -- Does this actually have to happen in world space?
glm::vec3 center = getCenterPosition(success); // this handles registrationPoint changes
glm::vec3 position = getPosition(success);
glm::vec3 position = getWorldPosition(success);
glm::vec3 positionToCenter = center - position;
positionToCenter -= dimensions * Vectors::HALF - getSurfacePositionAdjustment();
@ -411,8 +411,8 @@ glm::mat4 PolyVoxEntityItem::localToVoxelMatrix() const {
}
glm::mat4 PolyVoxEntityItem::voxelToWorldMatrix() const {
glm::mat4 rotation = glm::mat4_cast(getRotation());
glm::mat4 translation = glm::translate(getPosition());
glm::mat4 rotation = glm::mat4_cast(getWorldOrientation());
glm::mat4 translation = glm::translate(getWorldPosition());
return translation * rotation * voxelToLocalMatrix();
}

View file

@ -255,7 +255,7 @@ void ShapeEntityItem::debugDump() const {
qCDebug(entities) << " shape:" << stringFromShape(_shape) << " (EnumId: " << _shape << " )";
qCDebug(entities) << " collisionShapeType:" << ShapeInfo::getNameForShapeType(getShapeType());
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
qCDebug(entities) << " position:" << debugTreeVector(getWorldPosition());
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
qCDebug(entities) << "SHAPE EntityItem Ptr:" << this;

View file

@ -134,8 +134,8 @@ bool TextEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const
void** intersectedObject, bool precisionPicking) const {
glm::vec3 dimensions = getDimensions();
glm::vec2 xyDimensions(dimensions.x, dimensions.y);
glm::quat rotation = getRotation();
glm::vec3 position = getPosition() + rotation *
glm::quat rotation = getWorldOrientation();
glm::vec3 position = getWorldPosition() + rotation *
(dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()));
// FIXME - should set face and surfaceNormal

View file

@ -111,8 +111,8 @@ bool WebEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const g
void** intersectedObject, bool precisionPicking) const {
glm::vec3 dimensions = getDimensions();
glm::vec2 xyDimensions(dimensions.x, dimensions.y);
glm::quat rotation = getRotation();
glm::vec3 position = getPosition() + rotation * (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()));
glm::quat rotation = getWorldOrientation();
glm::vec3 position = getWorldPosition() + rotation * (dimensions * (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint()));
if (findRayRectangleIntersection(origin, direction, rotation, position, xyDimensions, distance)) {
surfaceNormal = rotation * Vectors::UNIT_Z;

View file

@ -241,7 +241,7 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
void ZoneEntityItem::debugDump() const {
quint64 now = usecTimestampNow();
qCDebug(entities) << " ZoneEntityItem id:" << getEntityItemID() << "---------------------------------------------";
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
qCDebug(entities) << " position:" << debugTreeVector(getWorldPosition());
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
qCDebug(entities) << " _backgroundMode:" << EntityItemProperties::getBackgroundModeString(_backgroundMode);

View file

@ -108,8 +108,8 @@ void EntityMotionState::handleDeactivation() {
_entity->setLocalTransformAndVelocities(localTransform, ENTITY_ITEM_ZERO_VEC3, ENTITY_ITEM_ZERO_VEC3);
// and also to RigidBody
btTransform worldTrans;
worldTrans.setOrigin(glmToBullet(_entity->getPosition()));
worldTrans.setRotation(glmToBullet(_entity->getRotation()));
worldTrans.setOrigin(glmToBullet(_entity->getWorldPosition()));
worldTrans.setRotation(glmToBullet(_entity->getWorldOrientation()));
_body->setWorldTransform(worldTrans);
// no need to update velocities... should already be zero
}
@ -125,7 +125,7 @@ void EntityMotionState::handleEasyChanges(uint32_t& flags) {
if (flags & Simulation::DIRTY_SIMULATOR_ID) {
if (_entity->getSimulatorID().isNull()) {
// simulation ownership has been removed by an external simulator
if (glm::length2(_entity->getVelocity()) == 0.0f) {
if (glm::length2(_entity->getWorldVelocity()) == 0.0f) {
// this object is coming to rest --> clear the ACTIVATION flag and _outgoingPriority
flags &= ~Simulation::DIRTY_PHYSICS_ACTIVATION;
_body->setActivationState(WANTS_DEACTIVATION);
@ -246,7 +246,7 @@ void EntityMotionState::getWorldTransform(btTransform& worldTrans) const {
_accelerationNearlyGravityCount = (uint8_t)(-1);
}
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...
@ -256,7 +256,7 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) {
assert(entityTreeIsLocked());
measureBodyAcceleration();
bool positionSuccess;
_entity->setPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset(), positionSuccess, false);
_entity->setWorldPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset(), positionSuccess, false);
if (!positionSuccess) {
static QString repeatedMessage =
LogHandler::getInstance().addRepeatedMessageRegex("EntityMotionState::setWorldTransform "
@ -264,7 +264,7 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) {
qCDebug(physics) << "EntityMotionState::setWorldTransform setPosition failed" << _entity->getID();
}
bool orientationSuccess;
_entity->setOrientation(bulletToGLM(worldTrans.getRotation()), orientationSuccess, false);
_entity->setWorldOrientation(bulletToGLM(worldTrans.getRotation()), orientationSuccess, false);
if (!orientationSuccess) {
static QString repeatedMessage =
LogHandler::getInstance().addRepeatedMessageRegex("EntityMotionState::setWorldTransform "
@ -542,8 +542,8 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
const float DYNAMIC_ANGULAR_VELOCITY_THRESHOLD = 0.087266f; // ~5 deg/sec
bool movingSlowlyLinear =
glm::length2(_entity->getVelocity()) < (DYNAMIC_LINEAR_VELOCITY_THRESHOLD * DYNAMIC_LINEAR_VELOCITY_THRESHOLD);
bool movingSlowlyAngular = glm::length2(_entity->getAngularVelocity()) <
glm::length2(_entity->getWorldVelocity()) < (DYNAMIC_LINEAR_VELOCITY_THRESHOLD * DYNAMIC_LINEAR_VELOCITY_THRESHOLD);
bool movingSlowlyAngular = glm::length2(_entity->getWorldAngularVelocity()) <
(DYNAMIC_ANGULAR_VELOCITY_THRESHOLD * DYNAMIC_ANGULAR_VELOCITY_THRESHOLD);
bool movingSlowly = movingSlowlyLinear && movingSlowlyAngular && _entity->getAcceleration() == Vectors::ZERO;

View file

@ -57,10 +57,10 @@ public:
virtual float getObjectLinearDamping() const override { return _entity->getDamping(); }
virtual float getObjectAngularDamping() const override { return _entity->getAngularDamping(); }
virtual glm::vec3 getObjectPosition() const override { return _entity->getPosition() - ObjectMotionState::getWorldOffset(); }
virtual glm::quat getObjectRotation() const override { return _entity->getRotation(); }
virtual glm::vec3 getObjectLinearVelocity() const override { return _entity->getVelocity(); }
virtual glm::vec3 getObjectAngularVelocity() const override { return _entity->getAngularVelocity(); }
virtual glm::vec3 getObjectPosition() const override { return _entity->getWorldPosition() - ObjectMotionState::getWorldOffset(); }
virtual glm::quat getObjectRotation() const override { return _entity->getWorldOrientation(); }
virtual glm::vec3 getObjectLinearVelocity() const override { return _entity->getWorldVelocity(); }
virtual glm::vec3 getObjectAngularVelocity() const override { return _entity->getWorldAngularVelocity(); }
virtual glm::vec3 getObjectGravity() const override { return _entity->getGravity(); }
virtual glm::vec3 getObjectLinearVelocityChange() const override;

View file

@ -54,8 +54,8 @@ bool ObjectActionTractor::getTarget(float deltaTimeStep, glm::quat& rotation, gl
if (!_otherID.isNull()) {
if (other) {
rotation = _desiredRotationalTarget * other->getRotation();
position = other->getRotation() * _desiredPositionalTarget + other->getPosition();
rotation = _desiredRotationalTarget * other->getWorldOrientation();
position = other->getWorldOrientation() * _desiredPositionalTarget + other->getWorldPosition();
} else {
// we should have an "other" but can't find it, so disable the tractor.
linearTimeScale = FLT_MAX;

View file

@ -223,7 +223,7 @@ void PhysicalEntitySimulation::getObjectsToAddToPhysics(VectorOfMotionStates& re
if (numPoints > MAX_HULL_POINTS) {
qWarning() << "convex hull with" << numPoints
<< "points for entity" << entity->getName()
<< "at" << entity->getPosition() << " will be reduced";
<< "at" << entity->getWorldPosition() << " will be reduced";
}
}
btCollisionShape* shape = const_cast<btCollisionShape*>(ObjectMotionState::getShapeManager()->getShape(shapeInfo));

View file

@ -240,7 +240,7 @@ glm::vec3 SpatiallyNestable::worldToLocalVelocity(const glm::vec3& velocity, con
if (!success) {
return velocity;
}
glm::vec3 parentVelocity = parent->getVelocity(success);
glm::vec3 parentVelocity = parent->getWorldVelocity(success);
if (!success) {
return velocity;
}
@ -345,7 +345,7 @@ glm::vec3 SpatiallyNestable::localToWorldVelocity(const glm::vec3& velocity, con
if (!success) {
return velocity;
}
glm::vec3 parentVelocity = parent->getVelocity(success);
glm::vec3 parentVelocity = parent->getWorldVelocity(success);
if (!success) {
return velocity;
}
@ -367,26 +367,26 @@ glm::vec3 SpatiallyNestable::localToWorldAngularVelocity(const glm::vec3& angula
return parentTransform.getRotation() * angularVelocity;
}
glm::vec3 SpatiallyNestable::getPosition(bool& success) const {
glm::vec3 SpatiallyNestable::getWorldPosition(bool& success) const {
return getTransform(success).getTranslation();
}
glm::vec3 SpatiallyNestable::getPosition() const {
glm::vec3 SpatiallyNestable::getWorldPosition() const {
bool success;
auto result = getPosition(success);
auto result = getWorldPosition(success);
#ifdef WANT_DEBUG
if (!success) {
qCDebug(shared) << "Warning -- getPosition failed" << getID();
qCDebug(shared) << "Warning -- getWorldPosition failed" << getID();
}
#endif
return result;
}
glm::vec3 SpatiallyNestable::getPosition(int jointIndex, bool& success) const {
glm::vec3 SpatiallyNestable::getWorldPosition(int jointIndex, bool& success) const {
return getTransform(jointIndex, success).getTranslation();
}
void SpatiallyNestable::setPosition(const glm::vec3& position, bool& success, bool tellPhysics) {
void SpatiallyNestable::setWorldPosition(const glm::vec3& position, bool& success, bool tellPhysics) {
// guard against introducing NaN into the transform
if (isNaN(position)) {
success = false;
@ -410,23 +410,23 @@ void SpatiallyNestable::setPosition(const glm::vec3& position, bool& success, bo
}
}
void SpatiallyNestable::setPosition(const glm::vec3& position) {
void SpatiallyNestable::setWorldPosition(const glm::vec3& position) {
bool success;
setPosition(position, success);
setWorldPosition(position, success);
#ifdef WANT_DEBUG
if (!success) {
qCDebug(shared) << "Warning -- setPosition failed" << getID();
qCDebug(shared) << "Warning -- setWorldPosition failed" << getID();
}
#endif
}
glm::quat SpatiallyNestable::getOrientation(bool& success) const {
glm::quat SpatiallyNestable::getWorldOrientation(bool& success) const {
return getTransform(success).getRotation();
}
glm::quat SpatiallyNestable::getOrientation() const {
glm::quat SpatiallyNestable::getWorldOrientation() const {
bool success;
auto result = getOrientation(success);
auto result = getWorldOrientation(success);
#ifdef WANT_DEBUG
if (!success) {
qCDebug(shared) << "Warning -- getOrientation failed" << getID();
@ -435,11 +435,11 @@ glm::quat SpatiallyNestable::getOrientation() const {
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();
}
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
if (isNaN(orientation)) {
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;
setOrientation(orientation, success);
setWorldOrientation(orientation, success);
#ifdef WANT_DEBUG
if (!success) {
qCDebug(shared) << "Warning -- setOrientation failed" << getID();
@ -473,7 +473,7 @@ void SpatiallyNestable::setOrientation(const glm::quat& orientation) {
#endif
}
glm::vec3 SpatiallyNestable::getVelocity(bool& success) const {
glm::vec3 SpatiallyNestable::getWorldVelocity(bool& success) const {
glm::vec3 result;
Transform parentTransform = getParentTransform(success);
if (!success) {
@ -490,16 +490,16 @@ glm::vec3 SpatiallyNestable::getVelocity(bool& success) const {
return result;
}
glm::vec3 SpatiallyNestable::getVelocity() const {
glm::vec3 SpatiallyNestable::getWorldVelocity() const {
bool success;
glm::vec3 result = getVelocity(success);
glm::vec3 result = getWorldVelocity(success);
if (!success) {
qCDebug(shared) << "Warning -- getVelocity failed" << getID();
qCDebug(shared) << "Warning -- getWorldVelocity failed" << getID();
}
return result;
}
void SpatiallyNestable::setVelocity(const glm::vec3& velocity, bool& success) {
void SpatiallyNestable::setWorldVelocity(const glm::vec3& velocity, bool& success) {
glm::vec3 parentVelocity = getParentVelocity(success);
Transform parentTransform = getParentTransform(success);
_velocityLock.withWriteLock([&] {
@ -518,9 +518,9 @@ void SpatiallyNestable::setVelocity(const glm::vec3& velocity, bool& success) {
});
}
void SpatiallyNestable::setVelocity(const glm::vec3& velocity) {
void SpatiallyNestable::setWorldVelocity(const glm::vec3& velocity) {
bool success;
setVelocity(velocity, success);
setWorldVelocity(velocity, success);
if (!success) {
qCDebug(shared) << "Warning -- setVelocity failed" << getID();
}
@ -533,12 +533,12 @@ glm::vec3 SpatiallyNestable::getParentVelocity(bool& success) const {
return result;
}
if (parent) {
result = parent->getVelocity(success);
result = parent->getWorldVelocity(success);
}
return result;
}
glm::vec3 SpatiallyNestable::getAngularVelocity(bool& success) const {
glm::vec3 SpatiallyNestable::getWorldAngularVelocity(bool& success) const {
glm::vec3 result;
Transform parentTransform = getParentTransform(success);
if (!success) {
@ -554,16 +554,16 @@ glm::vec3 SpatiallyNestable::getAngularVelocity(bool& success) const {
return result;
}
glm::vec3 SpatiallyNestable::getAngularVelocity() const {
glm::vec3 SpatiallyNestable::getWorldAngularVelocity() const {
bool success;
glm::vec3 result = getAngularVelocity(success);
glm::vec3 result = getWorldAngularVelocity(success);
if (!success) {
qCDebug(shared) << "Warning -- getAngularVelocity failed" << getID();
}
return result;
}
void SpatiallyNestable::setAngularVelocity(const glm::vec3& angularVelocity, bool& success) {
void SpatiallyNestable::setWorldAngularVelocity(const glm::vec3& angularVelocity, bool& success) {
glm::vec3 parentAngularVelocity = getParentAngularVelocity(success);
Transform parentTransform = getParentTransform(success);
_angularVelocityLock.withWriteLock([&] {
@ -571,9 +571,9 @@ void SpatiallyNestable::setAngularVelocity(const glm::vec3& angularVelocity, boo
});
}
void SpatiallyNestable::setAngularVelocity(const glm::vec3& angularVelocity) {
void SpatiallyNestable::setWorldAngularVelocity(const glm::vec3& angularVelocity) {
bool success;
setAngularVelocity(angularVelocity, success);
setWorldAngularVelocity(angularVelocity, success);
if (!success) {
qCDebug(shared) << "Warning -- setAngularVelocity failed" << getID();
}
@ -586,7 +586,7 @@ glm::vec3 SpatiallyNestable::getParentAngularVelocity(bool& success) const {
return result;
}
if (parent) {
result = parent->getAngularVelocity(success);
result = parent->getWorldAngularVelocity(success);
}
return result;
}
@ -624,7 +624,7 @@ const Transform SpatiallyNestable::getTransform(int jointIndex, bool& success, i
bool setPositionSuccess;
AACube aaCube = getQueryAACube(setPositionSuccess);
if (setPositionSuccess) {
_this->setPosition(aaCube.calcCenter());
_this->setWorldPosition(aaCube.calcCenter());
}
return jointInWorldFrame;
}
@ -958,7 +958,7 @@ void SpatiallyNestable::locationChanged(bool tellPhysics) {
}
AACube SpatiallyNestable::getMaximumAACube(bool& success) const {
return AACube(getPosition(success) - glm::vec3(defaultAACubeSize / 2.0f), defaultAACubeSize);
return AACube(getWorldPosition(success) - glm::vec3(defaultAACubeSize / 2.0f), defaultAACubeSize);
}
const float PARENTED_EXPANSION_FACTOR = 3.0f;
@ -1044,7 +1044,7 @@ AACube SpatiallyNestable::getQueryAACube(bool& success) const {
}
success = false;
bool getPositionSuccess;
return AACube(getPosition(getPositionSuccess) - glm::vec3(defaultAACubeSize / 2.0f), defaultAACubeSize);
return AACube(getWorldPosition(getPositionSuccess) - glm::vec3(defaultAACubeSize / 2.0f), defaultAACubeSize);
}
AACube SpatiallyNestable::getQueryAACube() const {

View file

@ -78,31 +78,27 @@ public:
virtual Transform getParentTransform(bool& success, int depth = 0) const;
virtual glm::vec3 getPosition(bool& success) const;
virtual glm::vec3 getPosition() const;
virtual void setPosition(const glm::vec3& position, bool& success, bool tellPhysics = true);
virtual void setPosition(const glm::vec3& position);
virtual glm::vec3 getWorldPosition(bool& success) const;
virtual glm::vec3 getWorldPosition() const;
virtual void setWorldPosition(const glm::vec3& position, bool& success, bool tellPhysics = true);
virtual void setWorldPosition(const glm::vec3& position);
virtual glm::quat getOrientation(bool& success) const;
virtual glm::quat getOrientation() const;
virtual glm::quat getOrientation(int jointIndex, bool& success) const;
virtual void setOrientation(const glm::quat& orientation, bool& success, bool tellPhysics = true);
virtual void setOrientation(const glm::quat& orientation);
virtual glm::quat getWorldOrientation(bool& success) const;
virtual glm::quat getWorldOrientation() const;
virtual glm::quat getWorldOrientation(int jointIndex, bool& success) const;
virtual void setWorldOrientation(const glm::quat& orientation, bool& success, bool tellPhysics = true);
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() const;
virtual void setVelocity(const glm::vec3& velocity, bool& success);
virtual void setVelocity(const glm::vec3& velocity);
virtual glm::vec3 getWorldVelocity(bool& success) const;
virtual glm::vec3 getWorldVelocity() const;
virtual void setWorldVelocity(const glm::vec3& velocity, bool& success);
virtual void setWorldVelocity(const glm::vec3& velocity);
virtual glm::vec3 getParentVelocity(bool& success) const;
virtual glm::vec3 getAngularVelocity(bool& success) const;
virtual glm::vec3 getAngularVelocity() const;
virtual void setAngularVelocity(const glm::vec3& angularVelocity, bool& success);
virtual void setAngularVelocity(const glm::vec3& angularVelocity);
virtual glm::vec3 getWorldAngularVelocity(bool& success) const;
virtual glm::vec3 getWorldAngularVelocity() const;
virtual void setWorldAngularVelocity(const glm::vec3& angularVelocity, bool& success);
virtual void setWorldAngularVelocity(const glm::vec3& angularVelocity);
virtual glm::vec3 getParentAngularVelocity(bool& success) const;
virtual AACube getMaximumAACube(bool& success) const;
@ -122,7 +118,7 @@ public:
// get world-frame values for a specific joint
virtual const Transform getTransform(int jointIndex, bool& success, int depth = 0) const;
virtual glm::vec3 getPosition(int jointIndex, bool& success) const;
virtual glm::vec3 getWorldPosition(int jointIndex, bool& success) const;
virtual glm::vec3 getSNScale(int jointIndex, bool& success) const;
// object's parent's frame

View file

@ -1,6 +1,6 @@
set(TARGET_NAME ui)
setup_hifi_library(OpenGL Network Qml Quick Script WebChannel WebEngine WebSockets XmlPatterns)
link_hifi_libraries(shared networking gl audio)
setup_hifi_library(OpenGL Multimedia Network Qml Quick Script WebChannel WebEngine WebSockets XmlPatterns)
link_hifi_libraries(shared networking gl audio audio-client plugins)
# Required for some low level GL interaction in the OffscreenQMLSurface
target_opengl()

View file

@ -24,7 +24,11 @@
#include <QtCore/QThread>
#include <QtCore/QMutex>
#include <QtCore/QWaitCondition>
#include <QtMultimedia/QMediaService>
#include <QtMultimedia/QAudioOutputSelectorControl>
#include <QtMultimedia/QMediaPlayer>
#include <AudioClient.h>
#include <shared/NsightHelpers.h>
#include <shared/GlobalAppProperties.h>
#include <shared/QtHelpers.h>
@ -113,6 +117,69 @@ uint64_t uvec2ToUint64(const uvec2& v) {
return result;
}
// Class to handle changing QML audio output device using another thread
class AudioHandler : public QObject, QRunnable {
Q_OBJECT
public:
AudioHandler(QObject* container, const QString& deviceName, int runDelayMs = 0, QObject* parent = nullptr) : QObject(parent) {
_container = container;
_newTargetDevice = deviceName;
_runDelayMs = runDelayMs;
setAutoDelete(true);
QThreadPool::globalInstance()->start(this);
}
virtual ~AudioHandler() {
qDebug() << "Audio Handler Destroyed";
}
void run() override {
if (_newTargetDevice.isEmpty()) {
return;
}
if (_runDelayMs > 0) {
QThread::msleep(_runDelayMs);
}
auto audioIO = DependencyManager::get<AudioClient>();
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
for (auto player : _container->findChildren<QMediaPlayer*>()) {
auto mediaState = player->state();
QMediaService *svc = player->service();
if (nullptr == svc) {
return;
}
QAudioOutputSelectorControl *out = qobject_cast<QAudioOutputSelectorControl *>
(svc->requestControl(QAudioOutputSelectorControl_iid));
if (nullptr == out) {
return;
}
QString deviceOuput;
auto outputs = out->availableOutputs();
for (int i = 0; i < outputs.size(); i++) {
QString output = outputs[i];
QString description = out->outputDescription(output);
if (description == deviceName) {
deviceOuput = output;
break;
}
}
out->setActiveOutput(deviceOuput);
svc->releaseControl(out);
// if multimedia was paused, it will start playing automatically after changing audio device
// this will reset it back to a paused state
if (mediaState == QMediaPlayer::State::PausedState) {
player->pause();
} else if (mediaState == QMediaPlayer::State::StoppedState) {
player->stop();
}
}
qDebug() << "QML Audio changed to " << deviceName;
}
private:
QString _newTargetDevice;
QObject* _container;
int _runDelayMs;
};
class OffscreenTextures {
public:
GLuint getNextTexture(const uvec2& size) {
@ -595,6 +662,14 @@ void OffscreenQmlSurface::create() {
// Find a way to flag older scripts using this mechanism and wanr that this is deprecated
_qmlContext->setContextProperty("eventBridgeWrapper", new EventBridgeWrapper(this, _qmlContext));
_renderControl->initialize(_canvas->getContext());
// Connect with the audio client and listen for audio device changes
auto audioIO = DependencyManager::get<AudioClient>();
connect(audioIO.data(), &AudioClient::deviceChanged, this, [&](QAudio::Mode mode, const QAudioDeviceInfo& device) {
if (mode == QAudio::Mode::AudioOutput) {
QMetaObject::invokeMethod(this, "changeAudioOutputDevice", Qt::QueuedConnection, Q_ARG(QString, device.deviceName()));
}
});
// When Quick says there is a need to render, we will not render immediately. Instead,
// a timer with a small interval is used to get better performance.
@ -605,6 +680,32 @@ void OffscreenQmlSurface::create() {
_updateTimer.start();
}
void OffscreenQmlSurface::changeAudioOutputDevice(const QString& deviceName, bool isHtmlUpdate) {
if (_rootItem != nullptr && !isHtmlUpdate) {
QMetaObject::invokeMethod(this, "forceQmlAudioOutputDeviceUpdate", Qt::QueuedConnection);
}
emit audioOutputDeviceChanged(deviceName);
}
void OffscreenQmlSurface::forceHtmlAudioOutputDeviceUpdate() {
auto audioIO = DependencyManager::get<AudioClient>();
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
QMetaObject::invokeMethod(this, "changeAudioOutputDevice", Qt::QueuedConnection,
Q_ARG(QString, deviceName), Q_ARG(bool, true));
}
void OffscreenQmlSurface::forceQmlAudioOutputDeviceUpdate() {
if (QThread::currentThread() != qApp->thread()) {
QMetaObject::invokeMethod(this, "forceQmlAudioOutputDeviceUpdate", Qt::QueuedConnection);
} else {
auto audioIO = DependencyManager::get<AudioClient>();
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
int waitForAudioQmlMs = 500;
// The audio device need to be change using oth
new AudioHandler(_rootItem, deviceName, waitForAudioQmlMs);
}
}
static uvec2 clampSize(const uvec2& size, uint32_t maxDimension) {
return glm::clamp(size, glm::uvec2(1), glm::uvec2(maxDimension));
}
@ -798,6 +899,7 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
if (newItem) {
newItem->setParentItem(_rootItem);
}
QMetaObject::invokeMethod(this, "forceQmlAudioOutputDeviceUpdate", Qt::QueuedConnection);
return;
}
@ -817,6 +919,7 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
for (const auto& callback : callbacks) {
callback(qmlContext, newObject);
}
QMetaObject::invokeMethod(this, "forceQmlAudioOutputDeviceUpdate", Qt::QueuedConnection);
}
void OffscreenQmlSurface::updateQuick() {

View file

@ -104,6 +104,14 @@ public slots:
void onAboutToQuit();
void focusDestroyed(QObject *obj);
// audio output device
public slots:
void changeAudioOutputDevice(const QString& deviceName, bool isHtmlUpdate = false);
void forceHtmlAudioOutputDeviceUpdate();
void forceQmlAudioOutputDeviceUpdate();
signals:
void audioOutputDeviceChanged(const QString& deviceName);
// event bridge
public slots:
void emitScriptEvent(const QVariant& scriptMessage);

View file

@ -15,4 +15,7 @@ if (NOT ANDROID)
setup_hifi_plugin(Script Qml Widgets)
link_hifi_libraries(shared controllers ui plugins ui-plugins input-plugins)
target_sixense()
if (WIN32)
target_link_libraries(${TARGET_NAME} Winmm.lib)
endif()
endif ()

View file

@ -17,5 +17,9 @@ if (WIN32)
target_include_directories(${TARGET_NAME} PRIVATE ${OPENVR_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${OPENVR_LIBRARIES})
endif()
if (WIN32)
target_link_libraries(${TARGET_NAME} Winmm.lib)
add_dependency_external_projects(wasapi)
endif()
package_libraries_for_deployment()

View file

@ -9,4 +9,8 @@ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
# link in the shared libraries
link_hifi_libraries(entities avatars shared octree gpu model fbx networking animation audio gl)
if (WIN32)
add_dependency_external_projects(wasapi)
endif ()
package_libraries_for_deployment()

View file

@ -5,6 +5,11 @@ setup_hifi_project(Quick Gui OpenGL Script Widgets)
setup_memory_debugger()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
link_hifi_libraries(networking gl gpu gpu-gl procedural shared fbx model model-networking animation script-engine render render-utils octree image ktx)
if (WIN32)
add_dependency_external_projects(wasapi)
endif ()
package_libraries_for_deployment()
target_nsight()

View file

@ -11,7 +11,12 @@ setup_memory_debugger()
setup_hifi_project(Gui)
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
# link in the shared libraries
link_hifi_libraries(shared networking)
if (WIN32)
add_dependency_external_projects(wasapi)
endif()
package_libraries_for_deployment()

View file

@ -4,6 +4,10 @@ setup_hifi_project(Test)
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
setup_memory_debugger()
link_hifi_libraries(shared recording)
if (WIN32)
target_link_libraries(${TARGET_NAME} Winmm.lib)
add_dependency_external_projects(wasapi)
endif()
package_libraries_for_deployment()
# FIXME convert to unit tests
@ -14,4 +18,4 @@ package_libraries_for_deployment()
#
# package_libraries_for_deployment()
#endmacro ()
#setup_hifi_testcase()
#setup_hifi_testcase()

View file

@ -14,6 +14,11 @@ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
# link in the shared libraries
link_hifi_libraries(shared networking model fbx ktx image octree gl gpu gpu-gl render model-networking networking render-utils entities entities-renderer animation audio avatars script-engine physics procedural midi ui)
if (WIN32)
target_link_libraries(${TARGET_NAME} Winmm.lib)
add_dependency_external_projects(wasapi)
endif()
package_libraries_for_deployment()

View file

@ -26,7 +26,8 @@ target_include_directories(${TARGET_NAME} SYSTEM PUBLIC ${QUAZIP_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${QUAZIP_LIBRARIES})
if (WIN32)
add_paths_to_fixup_libs(${QUAZIP_DLL_PATH})
add_paths_to_fixup_libs(${QUAZIP_DLL_PATH})
add_dependency_external_projects(wasapi)
endif ()

View file

@ -11,4 +11,8 @@ setup_memory_debugger()
link_hifi_libraries(render-utils gl gpu gpu-gl shared)
target_link_libraries(${TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT})
if (WIN32)
add_dependency_external_projects(wasapi)
endif ()
package_libraries_for_deployment()

View file

@ -17,4 +17,8 @@ include_directories("${PROJECT_BINARY_DIR}/../../libraries/render-utils/")
include_directories("${PROJECT_BINARY_DIR}/../../libraries/entities-renderer/")
include_directories("${PROJECT_BINARY_DIR}/../../libraries/model/")
if (WIN32)
add_dependency_external_projects(wasapi)
endif ()
package_libraries_for_deployment()