mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into raypick-avatars
This commit is contained in:
commit
5e7e6d2f3e
10 changed files with 144 additions and 67 deletions
72
.eslintrc.js
Normal file
72
.eslintrc.js
Normal file
|
@ -0,0 +1,72 @@
|
|||
module.exports = {
|
||||
"root": true,
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 5
|
||||
},
|
||||
"globals": {
|
||||
"Account": false,
|
||||
"AnimationCache": false,
|
||||
"Assets": false,
|
||||
"Audio": false,
|
||||
"AudioDevice": false,
|
||||
"AudioEffectOptions": false,
|
||||
"AvatarList": false,
|
||||
"AvatarManager": false,
|
||||
"Camera": false,
|
||||
"Clipboard": false,
|
||||
"Controller": false,
|
||||
"DialogsManager": false,
|
||||
"Entities": false,
|
||||
"FaceTracker": false,
|
||||
"GlobalServices": false,
|
||||
"HMD": false,
|
||||
"LODManager": false,
|
||||
"Mat4": false,
|
||||
"Menu": false,
|
||||
"Messages": false,
|
||||
"ModelCache": false,
|
||||
"MyAvatar": false,
|
||||
"Overlays": false,
|
||||
"Paths": false,
|
||||
"Quat": false,
|
||||
"Rates": false,
|
||||
"Recording": false,
|
||||
"Reticle": false,
|
||||
"Scene": false,
|
||||
"Script": false,
|
||||
"ScriptDiscoveryService": false,
|
||||
"Settings": false,
|
||||
"SoundCache": false,
|
||||
"Stats": false,
|
||||
"TextureCache": false,
|
||||
"Uuid": false,
|
||||
"UndoStack": false,
|
||||
"Vec3": false,
|
||||
"WebSocket": false,
|
||||
"WebWindow": false,
|
||||
"Window": false,
|
||||
"XMLHttpRequest": false,
|
||||
"location": false,
|
||||
"print": false
|
||||
},
|
||||
"rules": {
|
||||
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],
|
||||
"comma-dangle": ["error", "only-multiline"],
|
||||
"camelcase": ["error"],
|
||||
"curly": ["error", "all"],
|
||||
"indent": ["error", 4, { "SwitchCase": 1 }],
|
||||
"keyword-spacing": ["error", { "before": true, "after": true }],
|
||||
"max-len": ["error", 128, 4],
|
||||
"new-cap": ["error"],
|
||||
//"no-magic-numbers": ["error", { "ignore": [0, 1], "ignoreArrayIndexes": true }],
|
||||
"no-multiple-empty-lines": ["error"],
|
||||
"no-multi-spaces": ["error"],
|
||||
"no-unused-vars": ["error", { "args": "none", "vars": "local" }],
|
||||
"semi": ["error", "always"],
|
||||
"spaced-comment": ["error", "always", {
|
||||
"line": { "markers": ["/"] }
|
||||
}],
|
||||
"space-before-function-paren": ["error", "never"]
|
||||
}
|
||||
};
|
|
@ -1579,13 +1579,7 @@ void Application::initializeUi() {
|
|||
});
|
||||
offscreenUi->resume();
|
||||
connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){
|
||||
static qreal oldDevicePixelRatio = 0;
|
||||
qreal devicePixelRatio = getActiveDisplayPlugin()->devicePixelRatio();
|
||||
if (devicePixelRatio != oldDevicePixelRatio) {
|
||||
oldDevicePixelRatio = devicePixelRatio;
|
||||
qDebug() << "Device pixel ratio changed, triggering GL resize";
|
||||
resizeGL();
|
||||
}
|
||||
resizeGL();
|
||||
});
|
||||
|
||||
// This will set up the input plugins UI
|
||||
|
@ -1717,22 +1711,22 @@ void Application::paintGL() {
|
|||
if (isHMDMode()) {
|
||||
mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
|
||||
_myCamera.setPosition(extractTranslation(camMat));
|
||||
_myCamera.setRotation(glm::quat_cast(camMat));
|
||||
_myCamera.setOrientation(glm::quat_cast(camMat));
|
||||
} else {
|
||||
_myCamera.setPosition(myAvatar->getDefaultEyePosition());
|
||||
_myCamera.setRotation(myAvatar->getHead()->getCameraOrientation());
|
||||
_myCamera.setOrientation(myAvatar->getHead()->getCameraOrientation());
|
||||
}
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
if (isHMDMode()) {
|
||||
auto hmdWorldMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
|
||||
_myCamera.setRotation(glm::normalize(glm::quat_cast(hmdWorldMat)));
|
||||
_myCamera.setOrientation(glm::normalize(glm::quat_cast(hmdWorldMat)));
|
||||
_myCamera.setPosition(extractTranslation(hmdWorldMat) +
|
||||
myAvatar->getOrientation() * boomOffset);
|
||||
} else {
|
||||
_myCamera.setRotation(myAvatar->getHead()->getOrientation());
|
||||
_myCamera.setOrientation(myAvatar->getHead()->getOrientation());
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
|
||||
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
||||
+ _myCamera.getRotation() * boomOffset);
|
||||
+ _myCamera.getOrientation() * boomOffset);
|
||||
} else {
|
||||
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
||||
+ myAvatar->getOrientation() * boomOffset);
|
||||
|
@ -1751,7 +1745,7 @@ void Application::paintGL() {
|
|||
|
||||
glm::quat worldMirrorRotation = mirrorBodyOrientation * mirrorHmdRotation;
|
||||
|
||||
_myCamera.setRotation(worldMirrorRotation);
|
||||
_myCamera.setOrientation(worldMirrorRotation);
|
||||
|
||||
glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
|
||||
// Mirror HMD lateral offsets
|
||||
|
@ -1762,7 +1756,7 @@ void Application::paintGL() {
|
|||
+ mirrorBodyOrientation * glm::vec3(0.0f, 0.0f, 1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
|
||||
+ mirrorBodyOrientation * hmdOffset);
|
||||
} else {
|
||||
_myCamera.setRotation(myAvatar->getWorldAlignedOrientation()
|
||||
_myCamera.setOrientation(myAvatar->getWorldAlignedOrientation()
|
||||
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
|
||||
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
||||
+ glm::vec3(0, _raiseMirror * myAvatar->getUniformScale(), 0)
|
||||
|
@ -1775,11 +1769,11 @@ void Application::paintGL() {
|
|||
if (cameraEntity != nullptr) {
|
||||
if (isHMDMode()) {
|
||||
glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix());
|
||||
_myCamera.setRotation(cameraEntity->getRotation() * hmdRotation);
|
||||
_myCamera.setOrientation(cameraEntity->getRotation() * hmdRotation);
|
||||
glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix());
|
||||
_myCamera.setPosition(cameraEntity->getPosition() + (hmdRotation * hmdOffset));
|
||||
} else {
|
||||
_myCamera.setRotation(cameraEntity->getRotation());
|
||||
_myCamera.setOrientation(cameraEntity->getRotation());
|
||||
_myCamera.setPosition(cameraEntity->getPosition());
|
||||
}
|
||||
}
|
||||
|
@ -1960,7 +1954,8 @@ void Application::resizeGL() {
|
|||
static qreal lastDevicePixelRatio = 0;
|
||||
qreal devicePixelRatio = _window->devicePixelRatio();
|
||||
if (offscreenUi->size() != fromGlm(uiSize) || devicePixelRatio != lastDevicePixelRatio) {
|
||||
offscreenUi->resize(fromGlm(uiSize));
|
||||
qDebug() << "Device pixel ratio changed, triggering resize";
|
||||
offscreenUi->resize(fromGlm(uiSize), true);
|
||||
_offscreenContext->makeCurrent();
|
||||
lastDevicePixelRatio = devicePixelRatio;
|
||||
}
|
||||
|
@ -3314,9 +3309,9 @@ void Application::updateMyAvatarLookAtPosition() {
|
|||
if (isLookingAtSomeone) {
|
||||
deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT;
|
||||
}
|
||||
lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3(
|
||||
lookAtSpot = origin + _myCamera.getOrientation() * glm::quat(glm::radians(glm::vec3(
|
||||
eyePitch * deflection, eyeYaw * deflection, 0.0f))) *
|
||||
glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin);
|
||||
glm::inverse(_myCamera.getOrientation()) * (lookAtSpot - origin);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4032,7 +4027,7 @@ void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) {
|
|||
|
||||
// Set the viewFrustum up with the correct position and orientation of the camera
|
||||
viewFrustum.setPosition(camera.getPosition());
|
||||
viewFrustum.setOrientation(camera.getRotation());
|
||||
viewFrustum.setOrientation(camera.getOrientation());
|
||||
|
||||
// Ask the ViewFrustum class to calculate our corners
|
||||
viewFrustum.calculate();
|
||||
|
@ -4305,7 +4300,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi
|
|||
myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_DISTANCE * myAvatar->getScale());
|
||||
}
|
||||
_mirrorCamera.setProjection(glm::perspective(glm::radians(fov), aspect, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));
|
||||
_mirrorCamera.setRotation(myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
|
||||
_mirrorCamera.setOrientation(myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
|
||||
|
||||
|
||||
// set the bounds of rear mirror view
|
||||
|
|
|
@ -62,14 +62,14 @@ void Camera::update(float deltaTime) {
|
|||
}
|
||||
|
||||
void Camera::recompose() {
|
||||
mat4 orientation = glm::mat4_cast(_rotation);
|
||||
mat4 orientation = glm::mat4_cast(_orientation);
|
||||
mat4 translation = glm::translate(mat4(), _position);
|
||||
_transform = translation * orientation;
|
||||
}
|
||||
|
||||
void Camera::decompose() {
|
||||
_position = vec3(_transform[3]);
|
||||
_rotation = glm::quat_cast(_transform);
|
||||
_orientation = glm::quat_cast(_transform);
|
||||
}
|
||||
|
||||
void Camera::setTransform(const glm::mat4& transform) {
|
||||
|
@ -85,8 +85,8 @@ void Camera::setPosition(const glm::vec3& position) {
|
|||
}
|
||||
}
|
||||
|
||||
void Camera::setRotation(const glm::quat& rotation) {
|
||||
_rotation = rotation;
|
||||
void Camera::setOrientation(const glm::quat& orientation) {
|
||||
_orientation = orientation;
|
||||
recompose();
|
||||
if (_isKeepLookingAt) {
|
||||
lookAt(_lookingAt);
|
||||
|
@ -154,9 +154,9 @@ QString Camera::getModeString() const {
|
|||
void Camera::lookAt(const glm::vec3& lookAt) {
|
||||
glm::vec3 up = IDENTITY_UP;
|
||||
glm::mat4 lookAtMatrix = glm::lookAt(_position, lookAt, up);
|
||||
glm::quat rotation = glm::quat_cast(lookAtMatrix);
|
||||
rotation.w = -rotation.w; // Rosedale approved
|
||||
_rotation = rotation;
|
||||
glm::quat orientation = glm::quat_cast(lookAtMatrix);
|
||||
orientation.w = -orientation.w; // Rosedale approved
|
||||
_orientation = orientation;
|
||||
}
|
||||
|
||||
void Camera::keepLookingAt(const glm::vec3& point) {
|
||||
|
@ -171,7 +171,7 @@ void Camera::loadViewFrustum(ViewFrustum& frustum) const {
|
|||
|
||||
// Set the viewFrustum up with the correct position and orientation of the camera
|
||||
frustum.setPosition(getPosition());
|
||||
frustum.setOrientation(getRotation());
|
||||
frustum.setOrientation(getOrientation());
|
||||
|
||||
// Ask the ViewFrustum class to calculate our corners
|
||||
frustum.calculate();
|
||||
|
|
|
@ -45,7 +45,7 @@ class Camera : public QObject {
|
|||
public:
|
||||
Camera();
|
||||
|
||||
void initialize(); // instantly put the camera at the ideal position and rotation.
|
||||
void initialize(); // instantly put the camera at the ideal position and orientation.
|
||||
|
||||
void update( float deltaTime );
|
||||
|
||||
|
@ -57,25 +57,22 @@ public:
|
|||
|
||||
EntityItemPointer getCameraEntityPointer() const { return _cameraEntity; }
|
||||
|
||||
public slots:
|
||||
QString getModeString() const;
|
||||
void setModeString(const QString& mode);
|
||||
|
||||
glm::quat getRotation() const { return _rotation; }
|
||||
void setRotation(const glm::quat& rotation);
|
||||
|
||||
glm::vec3 getPosition() const { return _position; }
|
||||
void setPosition(const glm::vec3& position);
|
||||
|
||||
glm::quat getOrientation() const { return getRotation(); }
|
||||
void setOrientation(const glm::quat& orientation) { setRotation(orientation); }
|
||||
|
||||
const glm::mat4& getTransform() const { return _transform; }
|
||||
void setTransform(const glm::mat4& transform);
|
||||
|
||||
const glm::mat4& getProjection() const { return _projection; }
|
||||
void setProjection(const glm::mat4& projection);
|
||||
|
||||
public slots:
|
||||
QString getModeString() const;
|
||||
void setModeString(const QString& mode);
|
||||
|
||||
glm::vec3 getPosition() const { return _position; }
|
||||
void setPosition(const glm::vec3& position);
|
||||
|
||||
glm::quat getOrientation() const { return _orientation; }
|
||||
void setOrientation(const glm::quat& orientation);
|
||||
|
||||
QUuid getCameraEntity() const;
|
||||
void setCameraEntity(QUuid entityID);
|
||||
|
||||
|
@ -105,7 +102,7 @@ private:
|
|||
|
||||
// derived
|
||||
glm::vec3 _position;
|
||||
glm::quat _rotation;
|
||||
glm::quat _orientation;
|
||||
bool _isKeepLookingAt{ false };
|
||||
glm::vec3 _lookingAt;
|
||||
EntityItemPointer _cameraEntity;
|
||||
|
|
|
@ -150,7 +150,8 @@ void ApplicationOverlay::renderRearViewToFbo(RenderArgs* renderArgs) {
|
|||
}
|
||||
|
||||
void ApplicationOverlay::renderRearView(RenderArgs* renderArgs) {
|
||||
if (!qApp->isHMDMode() && Menu::getInstance()->isOptionChecked(MenuOption::MiniMirror)) {
|
||||
if (!qApp->isHMDMode() && Menu::getInstance()->isOptionChecked(MenuOption::MiniMirror) &&
|
||||
!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||
gpu::Batch& batch = *renderArgs->_batch;
|
||||
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
|
@ -166,7 +167,7 @@ void ApplicationOverlay::renderRearView(RenderArgs* renderArgs) {
|
|||
batch.setViewTransform(Transform());
|
||||
|
||||
float screenRatio = ((float)qApp->getDevicePixelRatio());
|
||||
float renderRatio = ((float)screenRatio * qApp->getRenderResolutionScale());
|
||||
float renderRatio = ((float)qApp->getRenderResolutionScale());
|
||||
|
||||
auto viewport = qApp->getMirrorViewRect();
|
||||
glm::vec2 bottomLeft(viewport.left(), viewport.top() + viewport.height());
|
||||
|
|
|
@ -191,9 +191,11 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
|
|||
if (success) {
|
||||
emit debitEnergySource(cost);
|
||||
queueEntityMessage(PacketType::EntityAdd, id, propertiesWithSimID);
|
||||
}
|
||||
|
||||
return id;
|
||||
return id;
|
||||
} else {
|
||||
return QUuid();
|
||||
}
|
||||
}
|
||||
|
||||
QUuid EntityScriptingInterface::addModelEntity(const QString& name, const QString& modelUrl, const glm::vec3& position) {
|
||||
|
|
|
@ -320,6 +320,11 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (!properties.getClientOnly() && getIsClient() &&
|
||||
!nodeList->getThisNodeCanRez() && !nodeList->getThisNodeCanRezTmp()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool recordCreationTime = false;
|
||||
if (props.getCreated() == UNKNOWN_CREATED_TIME) {
|
||||
// the entity's creation time was not specified in properties, which means this is a NEW entity
|
||||
|
|
|
@ -416,7 +416,7 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) {
|
|||
_updateTimer.start();
|
||||
}
|
||||
|
||||
void OffscreenQmlSurface::resize(const QSize& newSize_) {
|
||||
void OffscreenQmlSurface::resize(const QSize& newSize_, bool forceResize) {
|
||||
|
||||
if (!_renderer || !_renderer->_quickWindow) {
|
||||
return;
|
||||
|
@ -435,7 +435,7 @@ void OffscreenQmlSurface::resize(const QSize& newSize_) {
|
|||
}
|
||||
|
||||
QSize currentSize = _renderer->_quickWindow->geometry().size();
|
||||
if (newSize == currentSize) {
|
||||
if (newSize == currentSize && !forceResize) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
using MouseTranslator = std::function<QPoint(const QPointF&)>;
|
||||
|
||||
virtual void create(QOpenGLContext* context);
|
||||
void resize(const QSize& size);
|
||||
void resize(const QSize& size, bool forceResize = false);
|
||||
QSize size() const;
|
||||
Q_INVOKABLE QObject* load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
||||
Q_INVOKABLE QObject* load(const QString& qmlSourceFile, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}) {
|
||||
|
|
|
@ -141,7 +141,9 @@ CameraManager = function() {
|
|||
};
|
||||
|
||||
that.enable = function() {
|
||||
if (Camera.mode == "independent" || that.enabled) return;
|
||||
if (Camera.mode == "independent" || that.enabled || HMD.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < CAPTURED_KEYS.length; i++) {
|
||||
Controller.captureKeyEvents({
|
||||
|
@ -179,7 +181,9 @@ CameraManager = function() {
|
|||
}
|
||||
|
||||
that.disable = function(ignoreCamera) {
|
||||
if (!that.enabled) return;
|
||||
if (!that.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < CAPTURED_KEYS.length; i++) {
|
||||
Controller.releaseKeyEvents({
|
||||
|
@ -352,27 +356,21 @@ CameraManager = function() {
|
|||
that.mousePressEvent = function(event) {
|
||||
|
||||
if (cameraTool.mousePressEvent(event)) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!that.enabled) return;
|
||||
if (!that.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.isRightButton || (event.isLeftButton && event.isControl && !event.isShifted)) {
|
||||
|
||||
that.mode = MODE_ORBIT;
|
||||
} else if (event.isMiddleButton || (event.isLeftButton && event.isControl && event.isShifted)) {
|
||||
|
||||
|
||||
that.mode = MODE_PAN;
|
||||
}
|
||||
|
||||
if (that.mode !== MODE_INACTIVE) {
|
||||
|
||||
|
||||
hasDragged = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -381,7 +379,9 @@ CameraManager = function() {
|
|||
|
||||
that.mouseReleaseEvent = function(event) {
|
||||
|
||||
if (!that.enabled) return;
|
||||
if (!that.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
that.mode = MODE_INACTIVE;
|
||||
Reticle.setVisible(true);
|
||||
|
@ -403,7 +403,9 @@ CameraManager = function() {
|
|||
};
|
||||
|
||||
that.wheelEvent = function(event) {
|
||||
if (!that.enabled) return;
|
||||
if (!that.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dZoom = -event.delta * SCROLL_SENSITIVITY;
|
||||
|
||||
|
@ -459,8 +461,12 @@ CameraManager = function() {
|
|||
}
|
||||
|
||||
function normalizeDegrees(degrees) {
|
||||
while (degrees > 180) degrees -= 360;
|
||||
while (degrees < -180) degrees += 360;
|
||||
while (degrees > 180) {
|
||||
degrees -= 360;
|
||||
}
|
||||
while (degrees < -180) {
|
||||
degrees += 360;
|
||||
}
|
||||
return degrees;
|
||||
}
|
||||
|
||||
|
@ -483,7 +489,6 @@ CameraManager = function() {
|
|||
that.targetZoomDistance = clamp(that.targetZoomDistance, MIN_ZOOM_DISTANCE, MAX_ZOOM_DISTANCE);
|
||||
}
|
||||
|
||||
|
||||
if (easing) {
|
||||
easingTime = Math.min(EASE_TIME, easingTime + dt);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue