rename SpatiallyNestable::getPosition() to SpatiallyNestable::getWorldPosition()

This commit is contained in:
ZappoMan 2017-10-27 18:39:17 -07:00
parent 1000318dff
commit a7a0f03ede
62 changed files with 180 additions and 180 deletions

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

@ -893,7 +893,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);
@ -966,7 +966,7 @@ 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->setPositionGetter([this]{ return getMyAvatar()->getWorldPosition(); });
addressManager->setOrientationGetter([this]{ return getMyAvatar()->getOrientation(); });
connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
@ -1501,7 +1501,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();
@ -1629,7 +1629,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;
@ -1711,7 +1711,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;
@ -2455,11 +2455,11 @@ void Application::updateCamera(RenderArgs& renderArgs) {
glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
_myCamera.setOrientation(cameraEntity->getRotation() * 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.setPosition(cameraEntity->getWorldPosition());
}
}
}
@ -3871,7 +3871,7 @@ void Application::idle() {
auto entity = getEntities()->getTree()->findEntityByID(_keyboardFocusedEntity.get());
if (entity && _keyboardFocusHighlight) {
_keyboardFocusHighlight->setRotation(entity->getRotation());
_keyboardFocusHighlight->setPosition(entity->getPosition());
_keyboardFocusHighlight->setWorldPosition(entity->getWorldPosition());
}
} else {
// Only Web overlays can have focus.
@ -3879,7 +3879,7 @@ void Application::idle() {
std::dynamic_pointer_cast<Web3DOverlay>(getOverlays().getOverlay(_keyboardFocusedOverlay.get()));
if (overlay && _keyboardFocusHighlight) {
_keyboardFocusHighlight->setRotation(overlay->getRotation());
_keyboardFocusHighlight->setPosition(overlay->getPosition());
_keyboardFocusHighlight->setWorldPosition(overlay->getWorldPosition());
}
}
}
@ -4013,7 +4013,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);
@ -4216,7 +4216,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);
});
@ -4520,7 +4520,7 @@ void Application::setKeyboardFocusHighlight(const glm::vec3& position, const glm
// Position focus
_keyboardFocusHighlight->setRotation(rotation);
_keyboardFocusHighlight->setPosition(position);
_keyboardFocusHighlight->setWorldPosition(position);
_keyboardFocusHighlight->setDimensions(dimensions);
_keyboardFocusHighlight->setVisible(true);
}
@ -4557,7 +4557,7 @@ void Application::setKeyboardFocusEntity(const EntityItemID& entityItemID) {
}
_lastAcceptedKeyPress = usecTimestampNow();
setKeyboardFocusHighlight(entity->getPosition(), entity->getRotation(),
setKeyboardFocusHighlight(entity->getWorldPosition(), entity->getRotation(),
entity->getDimensions() * FOCUS_HIGHLIGHT_EXPANSION_FACTOR);
}
}
@ -4594,7 +4594,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->getRotation(), glm::vec3(size.x, size.y, OVERLAY_DEPTH));
} else if (_keyboardFocusHighlight) {
_keyboardFocusHighlight->setVisible(false);
}
@ -4686,7 +4686,7 @@ void Application::update(float deltaTime) {
controller::InputCalibrationData calibrationData = {
myAvatar->getSensorToWorldMatrix(),
createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()),
createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getWorldPosition()),
myAvatar->getHMDSensorMatrix(),
myAvatar->getCenterEyeCalibrationMat(),
myAvatar->getHeadCalibrationMat(),
@ -4796,7 +4796,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->getOrientation(), myAvatar->getWorldPosition());
glm::mat4 worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix());
glm::mat4 avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix;
for (auto& action : avatarControllerActions) {
@ -5412,7 +5412,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 {
@ -5624,7 +5624,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()) {
@ -6438,7 +6438,7 @@ void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) {
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.setPosition(getMyAvatar()->getWorldPosition() + positionOffset);
properties.setRotation(getMyAvatar()->getOrientation());
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);
}

View file

@ -435,7 +435,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,7 +106,7 @@ float AvatarMotionState::getObjectAngularDamping() const {
// virtual
glm::vec3 AvatarMotionState::getObjectPosition() const {
return _avatar->getPosition();
return _avatar->getWorldPosition();
}
// virtual

View file

@ -196,7 +196,7 @@ MyAvatar::MyAvatar(QThread* thread) :
setDisplayName(dummyAvatar.getDisplayName());
}
setPosition(dummyAvatar.getPosition());
setWorldPosition(dummyAvatar.getWorldPosition());
setOrientation(dummyAvatar.getOrientation());
if (!dummyAvatar.getAttachmentData().isEmpty()) {
@ -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,14 +321,14 @@ 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);
setWorldPosition(worldBodyPos);
setOrientation(worldBodyRot);
// reset the body in sensor space
@ -372,7 +372,7 @@ void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
auto worldBodyRot = glmExtractRotation(worldBodyMatrix);
// this will become our new position.
setPosition(worldBodyPos);
setWorldPosition(worldBodyPos);
setOrientation(worldBodyRot);
// now sample the new hmd orientation AFTER sensor reset, which should be identity.
@ -410,7 +410,7 @@ void MyAvatar::update(float deltaTime) {
#endif
if (_goToPending) {
setPosition(_goToPosition);
setWorldPosition(_goToPosition);
setOrientation(_goToOrientation);
_headControllerFacingMovingAverage = _headControllerFacing; // reset moving average
_goToPending = false;
@ -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), getOrientation(), getWorldPosition());
_sensorToWorldMatrix = desiredMat * glm::inverse(_bodySensorMatrix);
lateUpdatePalms();
@ -783,7 +783,7 @@ 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::vec3 jointPos = getWorldPosition();//default value if no or invalid joint specified
glm::quat jointRot = getRotation();//default value if no or invalid joint specified
if (jointIndex != -1) {
if (_skeletonModel->getJointPositionInWorldFrame(jointIndex, jointPos)) {
@ -818,7 +818,7 @@ glm::quat MyAvatar::worldToJointRotation(const glm::quat& worldRot, const int jo
}
glm::vec3 MyAvatar::jointToWorldPoint(const glm::vec3& jointSpacePos, const int jointIndex) const {
glm::vec3 jointPos = getPosition();//default value if no or invalid joint specified
glm::vec3 jointPos = getWorldPosition();//default value if no or invalid joint specified
glm::quat jointRot = getRotation();//default value if no or invalid joint specified
if (jointIndex != -1) {
@ -1230,7 +1230,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)) {
@ -1301,7 +1301,7 @@ eyeContactTarget MyAvatar::getEyeContactTarget() {
}
glm::vec3 MyAvatar::getDefaultEyePosition() const {
return getPosition() + getOrientation() * Quaternions::Y_180 * _skeletonModel->getDefaultEyeModelPosition();
return getWorldPosition() + getOrientation() * Quaternions::Y_180 * _skeletonModel->getDefaultEyeModelPosition();
}
const float SCRIPT_PRIORITY = 1.0f + 1.0f;
@ -1460,9 +1460,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() + getOrientation() * FLIP * _skeletonOffset;
}
return Avatar::getPosition();
return Avatar::getWorldPosition();
}
void MyAvatar::rebuildCollisionShape() {
@ -1508,7 +1508,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(getOrientation(), getWorldPosition()));
return pose.transform(invAvatarMatrix);
} else {
return controller::Pose(); // invalid pose
@ -1575,7 +1575,7 @@ void MyAvatar::prepareForPhysicsSimulation() {
_characterController.setParentVelocity(parentVelocity);
_characterController.setScaleFactor(getSensorToWorldScale());
_characterController.setPositionAndOrientation(getPosition(), getOrientation());
_characterController.setPositionAndOrientation(getWorldPosition(), getOrientation());
auto headPose = getControllerPoseInAvatarFrame(controller::Action::HEAD);
if (headPose.isValid()) {
_follow.prePhysicsUpdate(*this, deriveBodyFromHMDSensor(), _bodySensorMatrix, hasDriveInput());
@ -1609,7 +1609,7 @@ void MyAvatar::harvestResultsFromPhysicsSimulation(float deltaTime) {
if (_characterController.isEnabledAndReady()) {
_characterController.getPositionAndOrientation(position, orientation);
} else {
position = getPosition();
position = getWorldPosition();
orientation = getOrientation();
}
nextAttitude(position, orientation);
@ -1619,7 +1619,7 @@ void MyAvatar::harvestResultsFromPhysicsSimulation(float deltaTime) {
setVelocity(_characterController.getLinearVelocity() + _characterController.getFollowVelocity());
if (_characterController.isStuck()) {
_physicsSafetyPending = true;
_goToPosition = getPosition();
_goToPosition = getWorldPosition();
}
} else {
setVelocity(getVelocity() + _characterController.getFollowVelocity());
@ -1846,7 +1846,7 @@ void MyAvatar::postUpdate(float deltaTime, const render::ScenePointer& scene) {
}
}
DebugDraw::getInstance().updateMyAvatarPos(getPosition());
DebugDraw::getInstance().updateMyAvatarPos(getWorldPosition());
DebugDraw::getInstance().updateMyAvatarRot(getOrientation());
AnimPose postUpdateRoomPose(_sensorToWorldMatrix);
@ -1854,7 +1854,7 @@ void MyAvatar::postUpdate(float deltaTime, const render::ScenePointer& scene) {
updateHoldActions(_prePhysicsRoomPose, postUpdateRoomPose);
if (_enableDebugDrawDetailedCollision) {
AnimPose rigToWorldPose(glm::vec3(1.0f), getRotation() * Quaternions::Y_180, getPosition());
AnimPose rigToWorldPose(glm::vec3(1.0f), getRotation() * 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),
@ -2105,7 +2105,7 @@ 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);
_characterController.testRayShotgun(position, step, result);
@ -2916,7 +2916,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);
@ -2960,7 +2960,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(getOrientation(), getWorldPosition());
return glm::inverse(avatarMatrix) * controllerWorldMatrix;
}

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

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

View file

@ -28,7 +28,7 @@ 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::vec3 avatarPos = myAvatar->getWorldPosition();
glm::quat avatarRot = myAvatar->getOrientation();
glm::vec3 pos = useAvatarHead ? jointPos : avatarPos + (avatarRot * jointPos);

View file

@ -192,7 +192,7 @@ 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(yaw, myAvatar->getBodyYaw(), 0.1f);

View file

@ -114,7 +114,7 @@ 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());
@ -214,7 +214,7 @@ 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());

View file

@ -33,7 +33,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(); }
float getLineWidth() const { return _lineWidth; }
bool getIsSolid() const { return _isSolid; }

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, getRotation(), getWorldPosition(), dimensions, distance);
if (intersects) {
glm::vec3 hitPosition = origin + (distance * direction);
glm::vec3 localHitPosition = glm::inverse(getRotation()) * (hitPosition - getPosition());
glm::vec3 localHitPosition = glm::inverse(getRotation()) * (hitPosition - getWorldPosition());
localHitPosition.x /= getDimensions().x;
localHitPosition.y /= getDimensions().y;
float distanceToHit = glm::length(localHitPosition);

View file

@ -161,7 +161,7 @@ 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->setVisible(true);

View file

@ -144,7 +144,7 @@ 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();

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

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,7 +121,7 @@ void ModelOverlay::setDrawHUDLayer(bool drawHUDLayer) {
}
void ModelOverlay::setProperties(const QVariantMap& properties) {
auto origPosition = getPosition();
auto origPosition = getWorldPosition();
auto origRotation = getRotation();
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 != getRotation() || origDimensions != getDimensions() || origScale != getSNScale()) {
_updateModel = true;
}
@ -384,7 +384,7 @@ void ModelOverlay::locationChanged(bool tellPhysics) {
// FIXME Start using the _renderTransform instead of calling for Transform and Dimensions from here, do the custom things needed in evalRenderTransform()
if (_model && _model->isActive()) {
_model->setRotation(getRotation());
_model->setTranslation(getPosition());
_model->setTranslation(getWorldPosition());
}
}

View file

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

View file

@ -69,7 +69,7 @@ namespace render {
auto batch = args->_batch;
auto avatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
glm::quat myAvatarRotation = avatar->getOrientation();
glm::vec3 myAvatarPosition = avatar->getPosition();
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, getRotation(), getWorldPosition(), getDimensions(), distance);
}
Transform Planar3DOverlay::evalRenderTransform() {

View file

@ -58,7 +58,7 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
const float MAX_COLOR = 255.0f;
glm::vec4 rectangleColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glm::vec3 position = getPosition();
glm::vec3 position = getWorldPosition();
glm::vec2 dimensions = getDimensions();
glm::vec2 halfDimensions = dimensions * 0.5f;
glm::quat rotation = getRotation();

View file

@ -121,7 +121,7 @@ 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();

View file

@ -21,7 +21,7 @@ Volume3DOverlay::Volume3DOverlay(const Volume3DOverlay* volume3DOverlay) :
AABox Volume3DOverlay::getBounds() const {
auto extents = Extents{_localBoundingBox};
extents.rotate(getRotation());
extents.shiftBy(getPosition());
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);
}
@ -615,7 +615,7 @@ bool Web3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3&
// Don't call applyTransformTo() or setTransform() here because this code runs too frequently.
// 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, getRotation(), 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();
}
@ -359,9 +359,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);
}
@ -427,7 +427,7 @@ 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));
_lastVelocity = glm::vec3(0.0f);
@ -439,7 +439,7 @@ void Avatar::updateAttitude(const glm::quat& orientation) {
}
void Avatar::applyPositionDelta(const glm::vec3& delta) {
setPosition(getPosition() + delta);
setWorldPosition(getWorldPosition() + delta);
_positionDeltaAccumulator += delta;
}
@ -588,7 +588,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
@ -647,7 +647,7 @@ void Avatar::render(RenderArgs* renderArgs) {
}
ViewFrustum frustum = renderArgs->getViewFrustum();
if (!frustum.sphereIntersectsFrustum(getPosition(), getBoundingRadius())) {
if (!frustum.sphereIntersectsFrustum(getWorldPosition(), getBoundingRadius())) {
return;
}
@ -658,7 +658,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);
@ -721,7 +721,7 @@ void Avatar::simulateAttachments(float deltaTime) {
glm::quat jointRotation;
if (attachment.isSoft) {
// soft attachments do not have transform offsets
model->setTranslation(getPosition());
model->setTranslation(getWorldPosition());
model->setRotation(getOrientation() * Quaternions::Y_180);
model->simulate(deltaTime);
} else {
@ -775,9 +775,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))) {
@ -902,7 +902,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() + getOrientation() * FLIP * _skeletonOffset;
}
QVector<glm::quat> Avatar::getJointRotations() const {
@ -1166,7 +1166,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) {
@ -1254,12 +1254,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);
}
@ -1333,7 +1333,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;
@ -1378,8 +1378,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;
}
@ -1472,7 +1472,7 @@ glm::quat Avatar::getUncachedRightPalmRotation() const {
}
void Avatar::setPositionViaScript(const glm::vec3& position) {
setPosition(position);
setWorldPosition(position);
updateAttitude(getOrientation());
}

View file

@ -118,12 +118,12 @@ void AvatarData::setTargetScale(float targetScale) {
}
glm::vec3 AvatarData::getHandPosition() const {
return getOrientation() * _handPosition + getPosition();
return getOrientation() * _handPosition + getWorldPosition();
}
void AvatarData::setHandPosition(const glm::vec3& handPosition) {
// store relative to position/orientation
_handPosition = glm::inverse(getOrientation()) * (handPosition - getPosition());
_handPosition = glm::inverse(getOrientation()) * (handPosition - getWorldPosition());
}
void AvatarData::lazyInitHeadData() const {
@ -1901,7 +1901,7 @@ void AvatarData::setRecordingBasis(std::shared_ptr<Transform> recordingBasis) {
if (!recordingBasis) {
recordingBasis = std::make_shared<Transform>();
recordingBasis->setRotation(getOrientation());
recordingBasis->setTranslation(getPosition());
recordingBasis->setTranslation(getWorldPosition());
// TODO: find a different way to record/playback the Scale of the avatar
//recordingBasis->setScale(getTargetScale());
}
@ -2059,11 +2059,11 @@ 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);
@ -2186,7 +2186,7 @@ void AvatarData::setBodyRoll(float bodyRoll) {
}
void AvatarData::setPositionViaScript(const glm::vec3& position) {
SpatiallyNestable::setPosition(position);
SpatiallyNestable::setWorldPosition(position);
}
void AvatarData::setOrientationViaScript(const glm::quat& orientation) {
@ -2413,7 +2413,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

@ -351,7 +351,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)

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

@ -155,7 +155,7 @@ QJsonObject HeadData::toJson() const {
auto lookat = getLookAtPosition();
if (lookat != vec3()) {
vec3 relativeLookAt = glm::inverse(_owningAvatar->getOrientation()) *
(getLookAtPosition() - _owningAvatar->getPosition());
(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->getOrientation() * 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();
}

View file

@ -509,7 +509,7 @@ static glm::vec2 projectOntoEntityXYPlane(EntityItemPointer entity, const PickRa
if (entity) {
glm::vec3 entityPosition = entity->getPosition();
glm::vec3 entityPosition = entity->getWorldPosition();
glm::quat entityRotation = entity->getRotation();
glm::vec3 entityDimensions = entity->getDimensions();
glm::vec3 entityRegistrationPoint = entity->getRegistrationPoint();

View file

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

View file

@ -124,7 +124,7 @@ void RenderableModelEntityItem::doInitialModelSimulation() {
model->setScaleToFit(true, getDimensions());
model->setSnapModelToRegistrationPoint(true, getRegistrationPoint());
model->setRotation(getRotation());
model->setTranslation(getPosition());
model->setTranslation(getWorldPosition());
if (_needsInitialSimulation) {
model->simulate(0.0f);

View file

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

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();
@ -248,7 +248,7 @@ 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 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);

View file

@ -81,7 +81,7 @@ 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();
_renderTransform = getModelTransform();

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

@ -200,7 +200,7 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
bool hazeChanged = entity->hazePropertiesChanged();
entity->resetRenderingPropertiesChanged();
_lastPosition = entity->getPosition();
_lastPosition = entity->getWorldPosition();
_lastRotation = entity->getRotation();
_lastDimensions = entity->getDimensions();
@ -271,7 +271,7 @@ bool ZoneEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint
return true;
}
if (entity->getPosition() != _lastPosition) {
if (entity->getWorldPosition() != _lastPosition) {
return true;
}
if (entity->getDimensions() != _lastDimensions) {

View file

@ -888,7 +888,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);
@ -1168,7 +1168,7 @@ bool EntityItem::wantTerseEditLogging() const {
}
glm::mat4 EntityItem::getEntityToWorldMatrix() const {
glm::mat4 translation = glm::translate(getPosition());
glm::mat4 translation = glm::translate(getWorldPosition());
glm::mat4 rotation = glm::mat4_cast(getRotation());
glm::mat4 scale = glm::scale(getDimensions());
glm::mat4 registration = glm::translate(ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - getRegistrationPoint());
@ -1429,7 +1429,7 @@ const Transform EntityItem::getTransformToCenter(bool& success) const {
///
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"
@ -1457,7 +1457,7 @@ 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();
@ -1487,7 +1487,7 @@ 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();
@ -2381,7 +2381,7 @@ 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());

View file

@ -385,7 +385,7 @@ 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());
@ -1797,7 +1797,7 @@ 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 translation = glm::translate(entity->getWorldPosition());
glm::mat4 rotation = glm::mat4_cast(entity->getRotation());
result = translation * rotation;
}

View file

@ -681,7 +681,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
@ -1054,7 +1054,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

@ -663,7 +663,7 @@ 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 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;
}
@ -788,7 +788,7 @@ void EntityTreeElement::getEntities(const glm::vec3& searchPosition, float searc
// 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 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

@ -591,7 +591,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

@ -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();
@ -412,7 +412,7 @@ 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 translation = glm::translate(getWorldPosition());
return translation * rotation * voxelToLocalMatrix();
}

View file

@ -235,7 +235,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

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

View file

@ -112,7 +112,7 @@ bool WebEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const g
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::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,7 +108,7 @@ 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.setOrigin(glmToBullet(_entity->getWorldPosition()));
worldTrans.setRotation(glmToBullet(_entity->getRotation()));
_body->setWorldTransform(worldTrans);
// no need to update velocities... should already be zero
@ -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 "

View file

@ -57,7 +57,7 @@ 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::vec3 getObjectPosition() const override { return _entity->getWorldPosition() - 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(); }

View file

@ -55,7 +55,7 @@ bool ObjectActionTractor::getTarget(float deltaTimeStep, glm::quat& rotation, gl
if (!_otherID.isNull()) {
if (other) {
rotation = _desiredRotationalTarget * other->getRotation();
position = other->getRotation() * _desiredPositionalTarget + other->getPosition();
position = other->getRotation() * _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

@ -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,12 +410,12 @@ 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
}
@ -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,10 +78,10 @@ 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;
@ -122,7 +122,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