mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-20 07:20:36 +02:00
Merge pull request #10206 from AndrewMeadows/avatar-renderer-001
Cleanup dependencies in Avatar class in preparation for migration to new lib
This commit is contained in:
commit
4df41ff7d3
36 changed files with 255 additions and 321 deletions
|
@ -1124,19 +1124,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
return qApp->isHMDMode() ? 1 : 0;
|
return qApp->isHMDMode() ? 1 : 0;
|
||||||
});
|
});
|
||||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_FULL_SCREEN_MIRROR, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_CAMERA_FULL_SCREEN_MIRROR, []() -> float {
|
||||||
return qApp->getCamera()->getMode() == CAMERA_MODE_MIRROR ? 1 : 0;
|
return qApp->getCamera().getMode() == CAMERA_MODE_MIRROR ? 1 : 0;
|
||||||
});
|
});
|
||||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_FIRST_PERSON, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_CAMERA_FIRST_PERSON, []() -> float {
|
||||||
return qApp->getCamera()->getMode() == CAMERA_MODE_FIRST_PERSON ? 1 : 0;
|
return qApp->getCamera().getMode() == CAMERA_MODE_FIRST_PERSON ? 1 : 0;
|
||||||
});
|
});
|
||||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_THIRD_PERSON, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_CAMERA_THIRD_PERSON, []() -> float {
|
||||||
return qApp->getCamera()->getMode() == CAMERA_MODE_THIRD_PERSON ? 1 : 0;
|
return qApp->getCamera().getMode() == CAMERA_MODE_THIRD_PERSON ? 1 : 0;
|
||||||
});
|
});
|
||||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_ENTITY, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_CAMERA_ENTITY, []() -> float {
|
||||||
return qApp->getCamera()->getMode() == CAMERA_MODE_ENTITY ? 1 : 0;
|
return qApp->getCamera().getMode() == CAMERA_MODE_ENTITY ? 1 : 0;
|
||||||
});
|
});
|
||||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_INDEPENDENT, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_CAMERA_INDEPENDENT, []() -> float {
|
||||||
return qApp->getCamera()->getMode() == CAMERA_MODE_INDEPENDENT ? 1 : 0;
|
return qApp->getCamera().getMode() == CAMERA_MODE_INDEPENDENT ? 1 : 0;
|
||||||
});
|
});
|
||||||
_applicationStateDevice->setInputVariant(STATE_SNAP_TURN, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_SNAP_TURN, []() -> float {
|
||||||
return qApp->getMyAvatar()->getSnapTurn() ? 1 : 0;
|
return qApp->getMyAvatar()->getSnapTurn() ? 1 : 0;
|
||||||
|
@ -1785,14 +1785,23 @@ void Application::cleanupBeforeQuit() {
|
||||||
DependencyManager::destroy<AudioClient>();
|
DependencyManager::destroy<AudioClient>();
|
||||||
DependencyManager::destroy<AudioInjectorManager>();
|
DependencyManager::destroy<AudioInjectorManager>();
|
||||||
|
|
||||||
// shutdown render engine
|
|
||||||
_main3DScene = nullptr;
|
|
||||||
_renderEngine = nullptr;
|
|
||||||
|
|
||||||
qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
|
qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application() {
|
Application::~Application() {
|
||||||
|
// remove avatars from physics engine
|
||||||
|
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
|
||||||
|
VectorOfMotionStates motionStates;
|
||||||
|
DependencyManager::get<AvatarManager>()->getObjectsToRemoveFromPhysics(motionStates);
|
||||||
|
_physicsEngine->removeObjects(motionStates);
|
||||||
|
DependencyManager::get<AvatarManager>()->deleteAllAvatars();
|
||||||
|
|
||||||
|
_physicsEngine->setCharacterController(nullptr);
|
||||||
|
|
||||||
|
// shutdown render engine
|
||||||
|
_main3DScene = nullptr;
|
||||||
|
_renderEngine = nullptr;
|
||||||
|
|
||||||
DependencyManager::destroy<Preferences>();
|
DependencyManager::destroy<Preferences>();
|
||||||
|
|
||||||
_entityClipboard->eraseAllOctreeElements();
|
_entityClipboard->eraseAllOctreeElements();
|
||||||
|
@ -1804,14 +1813,6 @@ Application::~Application() {
|
||||||
_octreeProcessor.terminate();
|
_octreeProcessor.terminate();
|
||||||
_entityEditSender.terminate();
|
_entityEditSender.terminate();
|
||||||
|
|
||||||
_physicsEngine->setCharacterController(nullptr);
|
|
||||||
|
|
||||||
// remove avatars from physics engine
|
|
||||||
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
|
|
||||||
VectorOfMotionStates motionStates;
|
|
||||||
DependencyManager::get<AvatarManager>()->getObjectsToRemoveFromPhysics(motionStates);
|
|
||||||
_physicsEngine->removeObjects(motionStates);
|
|
||||||
DependencyManager::get<AvatarManager>()->deleteAllAvatars();
|
|
||||||
|
|
||||||
DependencyManager::destroy<AvatarManager>();
|
DependencyManager::destroy<AvatarManager>();
|
||||||
DependencyManager::destroy<AnimationCache>();
|
DependencyManager::destroy<AnimationCache>();
|
||||||
|
@ -2440,7 +2441,7 @@ void Application::resizeGL() {
|
||||||
// Possible change in aspect ratio
|
// Possible change in aspect ratio
|
||||||
{
|
{
|
||||||
QMutexLocker viewLocker(&_viewMutex);
|
QMutexLocker viewLocker(&_viewMutex);
|
||||||
loadViewFrustum(_myCamera, _viewFrustum);
|
_myCamera.loadViewFrustum(_viewFrustum);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
@ -4525,7 +4526,7 @@ void Application::update(float deltaTime) {
|
||||||
// to the server.
|
// to the server.
|
||||||
{
|
{
|
||||||
QMutexLocker viewLocker(&_viewMutex);
|
QMutexLocker viewLocker(&_viewMutex);
|
||||||
loadViewFrustum(_myCamera, _viewFrustum);
|
_myCamera.loadViewFrustum(_viewFrustum);
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
|
@ -4853,24 +4854,6 @@ QRect Application::getDesirableApplicationGeometry() const {
|
||||||
return applicationGeometry;
|
return applicationGeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// loadViewFrustum()
|
|
||||||
//
|
|
||||||
// Description: this will load the view frustum bounds for EITHER the head
|
|
||||||
// or the "myCamera".
|
|
||||||
//
|
|
||||||
void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) {
|
|
||||||
// We will use these below, from either the camera or head vectors calculated above
|
|
||||||
viewFrustum.setProjection(camera.getProjection());
|
|
||||||
|
|
||||||
// Set the viewFrustum up with the correct position and orientation of the camera
|
|
||||||
viewFrustum.setPosition(camera.getPosition());
|
|
||||||
viewFrustum.setOrientation(camera.getOrientation());
|
|
||||||
|
|
||||||
// Ask the ViewFrustum class to calculate our corners
|
|
||||||
viewFrustum.calculate();
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 Application::getSunDirection() const {
|
glm::vec3 Application::getSunDirection() const {
|
||||||
// Sun direction is in fact just the location of the sun relative to the origin
|
// Sun direction is in fact just the location of the sun relative to the origin
|
||||||
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
|
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
|
||||||
|
@ -5042,7 +5025,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
// load the view frustum
|
// load the view frustum
|
||||||
{
|
{
|
||||||
QMutexLocker viewLocker(&_viewMutex);
|
QMutexLocker viewLocker(&_viewMutex);
|
||||||
loadViewFrustum(theCamera, _displayViewFrustum);
|
theCamera.loadViewFrustum(_displayViewFrustum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO fix shadows and make them use the GPU library
|
// TODO fix shadows and make them use the GPU library
|
||||||
|
@ -5059,7 +5042,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
transaction.resetItem(BackgroundRenderData::_item, backgroundRenderPayload);
|
transaction.resetItem(BackgroundRenderData::_item, backgroundRenderPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assuming nothing get's rendered through that
|
// Assuming nothing gets rendered through that
|
||||||
if (!selfAvatarOnly) {
|
if (!selfAvatarOnly) {
|
||||||
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
|
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
|
||||||
// render models...
|
// render models...
|
||||||
|
@ -5115,6 +5098,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
QMutexLocker viewLocker(&_viewMutex);
|
QMutexLocker viewLocker(&_viewMutex);
|
||||||
renderArgs->setViewFrustum(_displayViewFrustum);
|
renderArgs->setViewFrustum(_displayViewFrustum);
|
||||||
}
|
}
|
||||||
|
renderArgs->_cameraMode = (int8_t)theCamera.getMode(); // HACK
|
||||||
|
renderArgs->_scene = getMain3DScene();
|
||||||
_renderEngine->getRenderContext()->args = renderArgs;
|
_renderEngine->getRenderContext()->args = renderArgs;
|
||||||
|
|
||||||
// Before the deferred pass, let's try to use the render engine
|
// Before the deferred pass, let's try to use the render engine
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
#include "avatar/MyAvatar.h"
|
#include "avatar/MyAvatar.h"
|
||||||
#include "BandwidthRecorder.h"
|
#include "BandwidthRecorder.h"
|
||||||
#include "Camera.h"
|
#include "FancyCamera.h"
|
||||||
#include "ConnectionMonitor.h"
|
#include "ConnectionMonitor.h"
|
||||||
#include "gpu/Context.h"
|
#include "gpu/Context.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
|
@ -174,8 +174,8 @@ public:
|
||||||
|
|
||||||
bool isThrottleRendering() const;
|
bool isThrottleRendering() const;
|
||||||
|
|
||||||
Camera* getCamera() { return &_myCamera; }
|
Camera& getCamera() { return _myCamera; }
|
||||||
const Camera* getCamera() const { return &_myCamera; }
|
const Camera& getCamera() const { return _myCamera; }
|
||||||
// Represents the current view frustum of the avatar.
|
// Represents the current view frustum of the avatar.
|
||||||
void copyViewFrustum(ViewFrustum& viewOut) const;
|
void copyViewFrustum(ViewFrustum& viewOut) const;
|
||||||
// Represents the view frustum of the current rendering pass,
|
// Represents the view frustum of the current rendering pass,
|
||||||
|
@ -268,7 +268,7 @@ public:
|
||||||
int getMaxOctreePacketsPerSecond() const;
|
int getMaxOctreePacketsPerSecond() const;
|
||||||
|
|
||||||
render::ScenePointer getMain3DScene() override { return _main3DScene; }
|
render::ScenePointer getMain3DScene() override { return _main3DScene; }
|
||||||
render::ScenePointer getMain3DScene() const { return _main3DScene; }
|
const render::ScenePointer& getMain3DScene() const { return _main3DScene; }
|
||||||
render::EnginePointer getRenderEngine() override { return _renderEngine; }
|
render::EnginePointer getRenderEngine() override { return _renderEngine; }
|
||||||
gpu::ContextPointer getGPUContext() const { return _gpuContext; }
|
gpu::ContextPointer getGPUContext() const { return _gpuContext; }
|
||||||
|
|
||||||
|
@ -462,7 +462,6 @@ private:
|
||||||
void updateDialogs(float deltaTime) const;
|
void updateDialogs(float deltaTime) const;
|
||||||
|
|
||||||
void queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions, bool forceResend = false);
|
void queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions, bool forceResend = false);
|
||||||
static void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum);
|
|
||||||
|
|
||||||
glm::vec3 getSunDirection() const;
|
glm::vec3 getSunDirection() const;
|
||||||
|
|
||||||
|
@ -558,7 +557,7 @@ private:
|
||||||
SimpleMovingAverage _avatarSimsPerSecond {10};
|
SimpleMovingAverage _avatarSimsPerSecond {10};
|
||||||
int _avatarSimsPerSecondReport {0};
|
int _avatarSimsPerSecondReport {0};
|
||||||
quint64 _lastAvatarSimsPerSecondUpdate {0};
|
quint64 _lastAvatarSimsPerSecondUpdate {0};
|
||||||
Camera _myCamera; // My view onto the world
|
FancyCamera _myCamera; // My view onto the world
|
||||||
|
|
||||||
Setting::Handle<QString> _previousScriptLocation;
|
Setting::Handle<QString> _previousScriptLocation;
|
||||||
Setting::Handle<float> _fieldOfView;
|
Setting::Handle<float> _fieldOfView;
|
||||||
|
|
|
@ -98,17 +98,6 @@ void Camera::setMode(CameraMode mode) {
|
||||||
emit modeUpdated(modeToString(mode));
|
emit modeUpdated(modeToString(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid Camera::getCameraEntity() const {
|
|
||||||
if (_cameraEntity != nullptr) {
|
|
||||||
return _cameraEntity->getID();
|
|
||||||
}
|
|
||||||
return QUuid();
|
|
||||||
};
|
|
||||||
|
|
||||||
void Camera::setCameraEntity(QUuid entityID) {
|
|
||||||
_cameraEntity = qApp->getEntities()->getTree()->findEntityByID(entityID);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Camera::setProjection(const glm::mat4& projection) {
|
void Camera::setProjection(const glm::mat4& projection) {
|
||||||
_projection = projection;
|
_projection = projection;
|
||||||
}
|
}
|
||||||
|
@ -177,12 +166,6 @@ void Camera::loadViewFrustum(ViewFrustum& frustum) const {
|
||||||
frustum.calculate();
|
frustum.calculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewFrustum Camera::toViewFrustum() const {
|
|
||||||
ViewFrustum result;
|
|
||||||
loadViewFrustum(result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap Camera::getViewFrustum() {
|
QVariantMap Camera::getViewFrustum() {
|
||||||
ViewFrustum frustum;
|
ViewFrustum frustum;
|
||||||
loadViewFrustum(frustum);
|
loadViewFrustum(frustum);
|
||||||
|
|
|
@ -43,15 +43,11 @@ class Camera : public QObject {
|
||||||
* @property position {Vec3} The position of the camera.
|
* @property position {Vec3} The position of the camera.
|
||||||
* @property orientation {Quat} The orientation of the camera.
|
* @property orientation {Quat} The orientation of the camera.
|
||||||
* @property mode {string} The current camera mode.
|
* @property mode {string} The current camera mode.
|
||||||
* @property cameraEntity {EntityID} The position and rotation properties of
|
|
||||||
* the entity specified by this ID are then used as the camera's position and
|
|
||||||
* orientation. Only works when <code>mode</code> is "entity".
|
|
||||||
* @property frustum {Object} The frustum of the camera.
|
* @property frustum {Object} The frustum of the camera.
|
||||||
*/
|
*/
|
||||||
Q_PROPERTY(glm::vec3 position READ getPosition WRITE setPosition)
|
Q_PROPERTY(glm::vec3 position READ getPosition WRITE setPosition)
|
||||||
Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation)
|
Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation)
|
||||||
Q_PROPERTY(QString mode READ getModeString WRITE setModeString)
|
Q_PROPERTY(QString mode READ getModeString WRITE setModeString)
|
||||||
Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity)
|
|
||||||
Q_PROPERTY(QVariantMap frustum READ getViewFrustum CONSTANT)
|
Q_PROPERTY(QVariantMap frustum READ getViewFrustum CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -65,9 +61,6 @@ public:
|
||||||
void setMode(CameraMode m);
|
void setMode(CameraMode m);
|
||||||
|
|
||||||
void loadViewFrustum(ViewFrustum& frustum) const;
|
void loadViewFrustum(ViewFrustum& frustum) const;
|
||||||
ViewFrustum toViewFrustum() const;
|
|
||||||
|
|
||||||
EntityItemPointer getCameraEntityPointer() const { return _cameraEntity; }
|
|
||||||
|
|
||||||
const glm::mat4& getTransform() const { return _transform; }
|
const glm::mat4& getTransform() const { return _transform; }
|
||||||
void setTransform(const glm::mat4& transform);
|
void setTransform(const glm::mat4& transform);
|
||||||
|
@ -87,9 +80,6 @@ public slots:
|
||||||
glm::quat getOrientation() const { return _orientation; }
|
glm::quat getOrientation() const { return _orientation; }
|
||||||
void setOrientation(const glm::quat& orientation);
|
void setOrientation(const glm::quat& orientation);
|
||||||
|
|
||||||
QUuid getCameraEntity() const;
|
|
||||||
void setCameraEntity(QUuid entityID);
|
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Compute a {PickRay} based on the current camera configuration and the position x,y on the screen.
|
* Compute a {PickRay} based on the current camera configuration and the position x,y on the screen.
|
||||||
* @function Camera.computePickRay
|
* @function Camera.computePickRay
|
||||||
|
@ -143,7 +133,6 @@ private:
|
||||||
glm::quat _orientation;
|
glm::quat _orientation;
|
||||||
bool _isKeepLookingAt{ false };
|
bool _isKeepLookingAt{ false };
|
||||||
glm::vec3 _lookingAt;
|
glm::vec3 _lookingAt;
|
||||||
EntityItemPointer _cameraEntity;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Camera_h
|
#endif // hifi_Camera_h
|
||||||
|
|
25
interface/src/FancyCamera.cpp
Normal file
25
interface/src/FancyCamera.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// FancyCamera.cpp
|
||||||
|
// interface/src
|
||||||
|
//
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "FancyCamera.h"
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
|
|
||||||
|
QUuid FancyCamera::getCameraEntity() const {
|
||||||
|
if (_cameraEntity != nullptr) {
|
||||||
|
return _cameraEntity->getID();
|
||||||
|
}
|
||||||
|
return QUuid();
|
||||||
|
};
|
||||||
|
|
||||||
|
void FancyCamera::setCameraEntity(QUuid entityID) {
|
||||||
|
_cameraEntity = qApp->getEntities()->getTree()->findEntityByID(entityID);
|
||||||
|
}
|
43
interface/src/FancyCamera.h
Normal file
43
interface/src/FancyCamera.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// FancyCamera.h
|
||||||
|
// interface/src
|
||||||
|
//
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_FancyCamera_h
|
||||||
|
#define hifi_FancyCamera_h
|
||||||
|
|
||||||
|
#include "Camera.h"
|
||||||
|
|
||||||
|
#include <EntityItem.h>
|
||||||
|
|
||||||
|
// TODO: come up with a better name than "FancyCamera"
|
||||||
|
class FancyCamera : public Camera {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* @namespace Camera
|
||||||
|
* @property cameraEntity {EntityID} The position and rotation properties of
|
||||||
|
* the entity specified by this ID are then used as the camera's position and
|
||||||
|
* orientation. Only works when <code>mode</code> is "entity".
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity)
|
||||||
|
|
||||||
|
public:
|
||||||
|
FancyCamera() : Camera() {}
|
||||||
|
|
||||||
|
EntityItemPointer getCameraEntityPointer() const { return _cameraEntity; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
QUuid getCameraEntity() const;
|
||||||
|
void setCameraEntity(QUuid entityID);
|
||||||
|
|
||||||
|
private:
|
||||||
|
EntityItemPointer _cameraEntity;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_FancyCamera_h
|
|
@ -1,44 +0,0 @@
|
||||||
//
|
|
||||||
// Physics.cpp
|
|
||||||
// interface/src
|
|
||||||
//
|
|
||||||
// Copyright 2013 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include <SharedUtil.h>
|
|
||||||
|
|
||||||
#include "Util.h"
|
|
||||||
#include "world.h"
|
|
||||||
#include "Physics.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Applies static friction: maxVelocity is the largest velocity for which there
|
|
||||||
// there is friction, and strength is the amount of friction force applied to reduce
|
|
||||||
// velocity.
|
|
||||||
//
|
|
||||||
void applyStaticFriction(float deltaTime, glm::vec3& velocity, float maxVelocity, float strength) {
|
|
||||||
float v = glm::length(velocity);
|
|
||||||
if (v < maxVelocity) {
|
|
||||||
velocity *= glm::clamp((1.0f - deltaTime * strength * (1.0f - v / maxVelocity)), 0.0f, 1.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Applies velocity damping, with a strength value for linear and squared velocity damping
|
|
||||||
//
|
|
||||||
|
|
||||||
void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, float squaredStrength) {
|
|
||||||
if (squaredStrength == 0.0f) {
|
|
||||||
velocity *= glm::clamp(1.0f - deltaTime * linearStrength, 0.0f, 1.0f);
|
|
||||||
} else {
|
|
||||||
velocity *= glm::clamp(1.0f - deltaTime * (linearStrength + glm::length(velocity) * squaredStrength), 0.0f, 1.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyDampedSpring(float deltaTime, glm::vec3& velocity, glm::vec3& position, glm::vec3& targetPosition, float k, float damping) {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
//
|
|
||||||
// Physics.h
|
|
||||||
// interface/src
|
|
||||||
//
|
|
||||||
// Created by Philip on 4/25/13.
|
|
||||||
// Copyright 2013 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef hifi_Physics_h
|
|
||||||
#define hifi_Physics_h
|
|
||||||
|
|
||||||
void applyStaticFriction(float deltaTime, glm::vec3& velocity, float maxVelocity, float strength);
|
|
||||||
void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, float squaredStrength);
|
|
||||||
|
|
||||||
#endif // hifi_Physics_h
|
|
|
@ -9,44 +9,32 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <vector>
|
#include "Avatar.h"
|
||||||
|
|
||||||
#include <QDesktopWidget>
|
#include <QtCore/QThread>
|
||||||
#include <QWindow>
|
#include <glm/gtx/transform.hpp>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include <glm/gtx/quaternion.hpp>
|
|
||||||
#include <glm/gtx/vector_angle.hpp>
|
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
|
||||||
#include <glm/gtx/vector_query.hpp>
|
#include <glm/gtx/vector_query.hpp>
|
||||||
|
|
||||||
#include <DeferredLightingEffect.h>
|
#include <DeferredLightingEffect.h>
|
||||||
#include <GeometryUtil.h>
|
#include <EntityTreeRenderer.h>
|
||||||
#include <LODManager.h>
|
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <NumericalConstants.h>
|
#include <NumericalConstants.h>
|
||||||
#include <OctreeUtils.h>
|
#include <OctreeUtils.h>
|
||||||
#include <udt/PacketHeaders.h>
|
#include <udt/PacketHeaders.h>
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
|
#include <Rig.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <TextRenderer3D.h>
|
#include <TextRenderer3D.h>
|
||||||
#include <TextureCache.h>
|
|
||||||
#include <VariantMapToScriptValue.h>
|
#include <VariantMapToScriptValue.h>
|
||||||
#include <DebugDraw.h>
|
#include <DebugDraw.h>
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "Avatar.h"
|
|
||||||
#include "AvatarManager.h"
|
#include "AvatarManager.h"
|
||||||
#include "AvatarMotionState.h"
|
#include "AvatarMotionState.h"
|
||||||
#include "Head.h"
|
#include "Camera.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "Physics.h"
|
|
||||||
#include "Util.h"
|
|
||||||
#include "world.h"
|
|
||||||
#include "InterfaceLogging.h"
|
#include "InterfaceLogging.h"
|
||||||
#include "SceneScriptingInterface.h"
|
#include "SceneScriptingInterface.h"
|
||||||
#include "SoftAttachmentModel.h"
|
#include "SoftAttachmentModel.h"
|
||||||
#include <Rig.h>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -71,7 +59,8 @@ namespace render {
|
||||||
auto avatarPtr = static_pointer_cast<Avatar>(avatar);
|
auto avatarPtr = static_pointer_cast<Avatar>(avatar);
|
||||||
if (avatarPtr->isInitialized() && args) {
|
if (avatarPtr->isInitialized() && args) {
|
||||||
PROFILE_RANGE_BATCH(*args->_batch, "renderAvatarPayload");
|
PROFILE_RANGE_BATCH(*args->_batch, "renderAvatarPayload");
|
||||||
avatarPtr->render(args, qApp->getCamera()->getPosition());
|
// TODO AVATARS_RENDERER: remove need for qApp
|
||||||
|
avatarPtr->render(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems) {
|
template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems) {
|
||||||
|
@ -85,7 +74,7 @@ namespace render {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Avatar::Avatar(RigPointer rig) :
|
Avatar::Avatar(QThread* thread, RigPointer rig) :
|
||||||
AvatarData(),
|
AvatarData(),
|
||||||
_skeletonOffset(0.0f),
|
_skeletonOffset(0.0f),
|
||||||
_bodyYawDelta(0.0f),
|
_bodyYawDelta(0.0f),
|
||||||
|
@ -108,7 +97,7 @@ Avatar::Avatar(RigPointer rig) :
|
||||||
_voiceSphereID(GeometryCache::UNKNOWN_ID)
|
_voiceSphereID(GeometryCache::UNKNOWN_ID)
|
||||||
{
|
{
|
||||||
// we may have been created in the network thread, but we live in the main thread
|
// we may have been created in the network thread, but we live in the main thread
|
||||||
moveToThread(qApp->thread());
|
moveToThread(thread);
|
||||||
|
|
||||||
setScale(glm::vec3(1.0f)); // avatar scale is uniform
|
setScale(glm::vec3(1.0f)); // avatar scale is uniform
|
||||||
|
|
||||||
|
@ -128,7 +117,7 @@ Avatar::Avatar(RigPointer rig) :
|
||||||
Avatar::~Avatar() {
|
Avatar::~Avatar() {
|
||||||
assert(isDead()); // mark dead before calling the dtor
|
assert(isDead()); // mark dead before calling the dtor
|
||||||
|
|
||||||
auto treeRenderer = qApp->getEntities();
|
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||||
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
||||||
if (entityTree) {
|
if (entityTree) {
|
||||||
entityTree->withWriteLock([&] {
|
entityTree->withWriteLock([&] {
|
||||||
|
@ -237,7 +226,7 @@ void Avatar::updateAvatarEntities() {
|
||||||
return; // wait until MyAvatar gets an ID before doing this.
|
return; // wait until MyAvatar gets an ID before doing this.
|
||||||
}
|
}
|
||||||
|
|
||||||
auto treeRenderer = qApp->getEntities();
|
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||||
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
||||||
if (!entityTree) {
|
if (!entityTree) {
|
||||||
return;
|
return;
|
||||||
|
@ -518,7 +507,7 @@ static TextRenderer3D* textRenderer(TextRendererType type) {
|
||||||
return displayNameRenderer;
|
return displayNameRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::addToScene(AvatarSharedPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
void Avatar::addToScene(AvatarSharedPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
auto avatarPayload = new render::Payload<AvatarData>(self);
|
auto avatarPayload = new render::Payload<AvatarData>(self);
|
||||||
auto avatarPayloadPointer = Avatar::PayloadPointer(avatarPayload);
|
auto avatarPayloadPointer = Avatar::PayloadPointer(avatarPayload);
|
||||||
_renderItemID = scene->allocateID();
|
_renderItemID = scene->allocateID();
|
||||||
|
@ -530,7 +519,7 @@ void Avatar::addToScene(AvatarSharedPointer self, std::shared_ptr<render::Scene>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::removeFromScene(AvatarSharedPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
void Avatar::removeFromScene(AvatarSharedPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
transaction.removeItem(_renderItemID);
|
transaction.removeItem(_renderItemID);
|
||||||
render::Item::clearID(_renderItemID);
|
render::Item::clearID(_renderItemID);
|
||||||
_skeletonModel->removeFromScene(scene, transaction);
|
_skeletonModel->removeFromScene(scene, transaction);
|
||||||
|
@ -578,11 +567,13 @@ void Avatar::postUpdate(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
|
void Avatar::render(RenderArgs* renderArgs) {
|
||||||
auto& batch = *renderArgs->_batch;
|
auto& batch = *(renderArgs->_batch);
|
||||||
PROFILE_RANGE_BATCH(batch, __FUNCTION__);
|
PROFILE_RANGE_BATCH(batch, __FUNCTION__);
|
||||||
|
|
||||||
if (glm::distance(DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition(), getPosition()) < 10.0f) {
|
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) {
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
|
||||||
// render pointing lasers
|
// render pointing lasers
|
||||||
|
@ -641,23 +632,16 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // simple frustum check
|
ViewFrustum frustum = renderArgs->getViewFrustum();
|
||||||
ViewFrustum frustum;
|
|
||||||
if (renderArgs->_renderMode == RenderArgs::SHADOW_RENDER_MODE) {
|
|
||||||
qApp->copyShadowViewFrustum(frustum);
|
|
||||||
} else {
|
|
||||||
qApp->copyDisplayViewFrustum(frustum);
|
|
||||||
}
|
|
||||||
if (!frustum.sphereIntersectsFrustum(getPosition(), getBoundingRadius())) {
|
if (!frustum.sphereIntersectsFrustum(getPosition(), getBoundingRadius())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 toTarget = cameraPosition - getPosition();
|
glm::vec3 toTarget = frustum.getPosition() - getPosition();
|
||||||
float distanceToTarget = glm::length(toTarget);
|
float distanceToTarget = glm::length(toTarget);
|
||||||
|
|
||||||
{
|
{
|
||||||
fixupModelsInScene();
|
fixupModelsInScene(renderArgs->_scene);
|
||||||
|
|
||||||
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE) {
|
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE) {
|
||||||
// add local lights
|
// add local lights
|
||||||
|
@ -686,8 +670,7 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
|
||||||
const float DISPLAYNAME_DISTANCE = 20.0f;
|
const float DISPLAYNAME_DISTANCE = 20.0f;
|
||||||
setShowDisplayName(distanceToTarget < DISPLAYNAME_DISTANCE);
|
setShowDisplayName(distanceToTarget < DISPLAYNAME_DISTANCE);
|
||||||
|
|
||||||
auto cameraMode = qApp->getCamera()->getMode();
|
if (!isMyAvatar() || renderArgs->_cameraMode != (int8_t)CAMERA_MODE_FIRST_PERSON) {
|
||||||
if (!isMyAvatar() || cameraMode != CAMERA_MODE_FIRST_PERSON) {
|
|
||||||
auto& frustum = renderArgs->getViewFrustum();
|
auto& frustum = renderArgs->getViewFrustum();
|
||||||
auto textPosition = getDisplayNamePosition();
|
auto textPosition = getDisplayNamePosition();
|
||||||
if (frustum.pointIntersectsFrustum(textPosition)) {
|
if (frustum.pointIntersectsFrustum(textPosition)) {
|
||||||
|
@ -712,12 +695,11 @@ glm::quat Avatar::computeRotationFromBodyToWorldUp(float proportion) const {
|
||||||
return glm::angleAxis(angle * proportion, axis);
|
return glm::angleAxis(angle * proportion, axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::fixupModelsInScene() {
|
void Avatar::fixupModelsInScene(const render::ScenePointer& scene) {
|
||||||
_attachmentsToDelete.clear();
|
_attachmentsToDelete.clear();
|
||||||
|
|
||||||
// check to see if when we added our models to the scene they were ready, if they were not ready, then
|
// check to see if when we added our models to the scene they were ready, if they were not ready, then
|
||||||
// fix them up in the scene
|
// fix them up in the scene
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
if (_skeletonModel->isRenderable() && _skeletonModel->needsFixupInScene()) {
|
if (_skeletonModel->isRenderable() && _skeletonModel->needsFixupInScene()) {
|
||||||
_skeletonModel->removeFromScene(scene, transaction);
|
_skeletonModel->removeFromScene(scene, transaction);
|
||||||
|
@ -1490,8 +1472,7 @@ QList<QVariant> Avatar::getSkeleton() {
|
||||||
return QList<QVariant>();
|
return QList<QVariant>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::addToScene(AvatarSharedPointer myHandle) {
|
void Avatar::addToScene(AvatarSharedPointer myHandle, const render::ScenePointer& scene) {
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
|
||||||
if (scene) {
|
if (scene) {
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
auto nodelist = DependencyManager::get<NodeList>();
|
auto nodelist = DependencyManager::get<NodeList>();
|
||||||
|
@ -1505,8 +1486,9 @@ void Avatar::addToScene(AvatarSharedPointer myHandle) {
|
||||||
qCWarning(interfaceapp) << "AvatarManager::addAvatar() : Unexpected null scene, possibly during application shutdown";
|
qCWarning(interfaceapp) << "AvatarManager::addAvatar() : Unexpected null scene, possibly during application shutdown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Avatar::ensureInScene(AvatarSharedPointer self) {
|
|
||||||
|
void Avatar::ensureInScene(AvatarSharedPointer self, const render::ScenePointer& scene) {
|
||||||
if (!render::Item::isValidID(_renderItemID)) {
|
if (!render::Item::isValidID(_renderItemID)) {
|
||||||
addToScene(self);
|
addToScene(self, scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,17 +14,15 @@
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
#include <QtCore/QScopedPointer>
|
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
|
||||||
#include <AvatarData.h>
|
#include <AvatarData.h>
|
||||||
#include <ShapeInfo.h>
|
#include <ShapeInfo.h>
|
||||||
|
|
||||||
#include <render/Scene.h>
|
#include <render/Scene.h>
|
||||||
|
|
||||||
|
|
||||||
#include "Head.h"
|
#include "Head.h"
|
||||||
#include "SkeletonModel.h"
|
#include "SkeletonModel.h"
|
||||||
#include "world.h"
|
|
||||||
#include "Rig.h"
|
#include "Rig.h"
|
||||||
#include <ThreadSafeValueCache.h>
|
#include <ThreadSafeValueCache.h>
|
||||||
|
|
||||||
|
@ -68,7 +66,7 @@ class Avatar : public AvatarData {
|
||||||
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
|
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Avatar(RigPointer rig = nullptr);
|
explicit Avatar(QThread* thread, RigPointer rig = nullptr);
|
||||||
~Avatar();
|
~Avatar();
|
||||||
|
|
||||||
typedef render::Payload<AvatarData> Payload;
|
typedef render::Payload<AvatarData> Payload;
|
||||||
|
@ -79,12 +77,12 @@ public:
|
||||||
void simulate(float deltaTime, bool inView);
|
void simulate(float deltaTime, bool inView);
|
||||||
virtual void simulateAttachments(float deltaTime);
|
virtual void simulateAttachments(float deltaTime);
|
||||||
|
|
||||||
virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPosition);
|
virtual void render(RenderArgs* renderArgs);
|
||||||
|
|
||||||
void addToScene(AvatarSharedPointer self, std::shared_ptr<render::Scene> scene,
|
void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction);
|
render::Transaction& transaction);
|
||||||
|
|
||||||
void removeFromScene(AvatarSharedPointer self, std::shared_ptr<render::Scene> scene,
|
void removeFromScene(AvatarSharedPointer self, const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction);
|
render::Transaction& transaction);
|
||||||
|
|
||||||
void updateRenderItem(render::Transaction& transaction);
|
void updateRenderItem(render::Transaction& transaction);
|
||||||
|
@ -305,7 +303,7 @@ protected:
|
||||||
Transform calculateDisplayNameTransform(const ViewFrustum& view, const glm::vec3& textPosition) const;
|
Transform calculateDisplayNameTransform(const ViewFrustum& view, const glm::vec3& textPosition) const;
|
||||||
void renderDisplayName(gpu::Batch& batch, const ViewFrustum& view, const glm::vec3& textPosition) const;
|
void renderDisplayName(gpu::Batch& batch, const ViewFrustum& view, const glm::vec3& textPosition) const;
|
||||||
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const;
|
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const;
|
||||||
virtual void fixupModelsInScene();
|
virtual void fixupModelsInScene(const render::ScenePointer& scene);
|
||||||
|
|
||||||
virtual void updatePalms();
|
virtual void updatePalms();
|
||||||
|
|
||||||
|
@ -316,8 +314,8 @@ protected:
|
||||||
ThreadSafeValueCache<glm::vec3> _rightPalmPositionCache { glm::vec3() };
|
ThreadSafeValueCache<glm::vec3> _rightPalmPositionCache { glm::vec3() };
|
||||||
ThreadSafeValueCache<glm::quat> _rightPalmRotationCache { glm::quat() };
|
ThreadSafeValueCache<glm::quat> _rightPalmRotationCache { glm::quat() };
|
||||||
|
|
||||||
void addToScene(AvatarSharedPointer self);
|
void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene);
|
||||||
void ensureInScene(AvatarSharedPointer self);
|
void ensureInScene(AvatarSharedPointer self, const render::ScenePointer& scene);
|
||||||
bool isInScene() const { return render::Item::isValidID(_renderItemID); }
|
bool isInScene() const { return render::Item::isValidID(_renderItemID); }
|
||||||
|
|
||||||
// Some rate tracking support
|
// Some rate tracking support
|
||||||
|
|
|
@ -69,7 +69,7 @@ void AvatarManager::registerMetaTypes(QScriptEngine* engine) {
|
||||||
|
|
||||||
AvatarManager::AvatarManager(QObject* parent) :
|
AvatarManager::AvatarManager(QObject* parent) :
|
||||||
_avatarsToFade(),
|
_avatarsToFade(),
|
||||||
_myAvatar(std::make_shared<MyAvatar>(std::make_shared<Rig>()))
|
_myAvatar(std::make_shared<MyAvatar>(qApp->thread(), std::make_shared<Rig>()))
|
||||||
{
|
{
|
||||||
// register a meta type for the weak pointer we'll use for the owning avatar mixer for each avatar
|
// register a meta type for the weak pointer we'll use for the owning avatar mixer for each avatar
|
||||||
qRegisterMetaType<QWeakPointer<Node> >("NodeWeakPointer");
|
qRegisterMetaType<QWeakPointer<Node> >("NodeWeakPointer");
|
||||||
|
@ -105,7 +105,7 @@ void AvatarManager::init() {
|
||||||
this, &AvatarManager::updateAvatarRenderStatus, Qt::QueuedConnection);
|
this, &AvatarManager::updateAvatarRenderStatus, Qt::QueuedConnection);
|
||||||
|
|
||||||
if (_shouldRender) {
|
if (_shouldRender) {
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
_myAvatar->addToScene(_myAvatar, scene, transaction);
|
_myAvatar->addToScene(_myAvatar, scene, transaction);
|
||||||
scene->enqueueTransaction(transaction);
|
scene->enqueueTransaction(transaction);
|
||||||
|
@ -198,7 +198,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
||||||
|
|
||||||
// for ALL avatars...
|
// for ALL avatars...
|
||||||
if (_shouldRender) {
|
if (_shouldRender) {
|
||||||
avatar->ensureInScene(avatar);
|
avatar->ensureInScene(avatar, qApp->getMain3DScene());
|
||||||
}
|
}
|
||||||
if (!avatar->getMotionState()) {
|
if (!avatar->getMotionState()) {
|
||||||
ShapeInfo shapeInfo;
|
ShapeInfo shapeInfo;
|
||||||
|
@ -306,13 +306,11 @@ void AvatarManager::simulateAvatarFades(float deltaTime) {
|
||||||
if (avatar->getTargetScale() <= MIN_FADE_SCALE) {
|
if (avatar->getTargetScale() <= MIN_FADE_SCALE) {
|
||||||
// fading to zero is such a rare event we push unique transaction for each one
|
// fading to zero is such a rare event we push unique transaction for each one
|
||||||
if (avatar->isInScene()) {
|
if (avatar->isInScene()) {
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
avatar->removeFromScene(*itr, scene, transaction);
|
avatar->removeFromScene(*itr, scene, transaction);
|
||||||
if (scene) {
|
|
||||||
scene->enqueueTransaction(transaction);
|
scene->enqueueTransaction(transaction);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// only remove from _avatarsToFade if we're sure its motionState has been removed from PhysicsEngine
|
// only remove from _avatarsToFade if we're sure its motionState has been removed from PhysicsEngine
|
||||||
if (_motionStatesToRemoveFromPhysics.empty()) {
|
if (_motionStatesToRemoveFromPhysics.empty()) {
|
||||||
|
@ -329,7 +327,7 @@ void AvatarManager::simulateAvatarFades(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarSharedPointer AvatarManager::newSharedAvatar() {
|
AvatarSharedPointer AvatarManager::newSharedAvatar() {
|
||||||
return std::make_shared<Avatar>(std::make_shared<Rig>());
|
return std::make_shared<Avatar>(qApp->thread(), std::make_shared<Rig>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarManager::processAvatarDataPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
void AvatarManager::processAvatarDataPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
||||||
|
@ -343,19 +341,19 @@ void AvatarManager::processAvatarDataPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
if (avatar->isInScene()) {
|
if (avatar->isInScene()) {
|
||||||
if (!_shouldRender) {
|
if (!_shouldRender) {
|
||||||
// rare transition so we process the transaction immediately
|
// rare transition so we process the transaction immediately
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||||
if (scene) {
|
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
avatar->removeFromScene(avatar, scene, transaction);
|
avatar->removeFromScene(avatar, scene, transaction);
|
||||||
|
if (scene) {
|
||||||
scene->enqueueTransaction(transaction);
|
scene->enqueueTransaction(transaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_shouldRender) {
|
} else if (_shouldRender) {
|
||||||
// very rare transition so we process the transaction immediately
|
// very rare transition so we process the transaction immediately
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||||
if (scene) {
|
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
avatar->addToScene(avatar, scene, transaction);
|
avatar->addToScene(avatar, scene, transaction);
|
||||||
|
if (scene) {
|
||||||
scene->enqueueTransaction(transaction);
|
scene->enqueueTransaction(transaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,7 +392,7 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar
|
||||||
void AvatarManager::clearOtherAvatars() {
|
void AvatarManager::clearOtherAvatars() {
|
||||||
// Remove other avatars from the world but don't actually remove them from _avatarHash
|
// Remove other avatars from the world but don't actually remove them from _avatarHash
|
||||||
// each will either be removed on timeout or will re-added to the world on receipt of update.
|
// each will either be removed on timeout or will re-added to the world on receipt of update.
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
|
|
||||||
QReadLocker locker(&_hashLock);
|
QReadLocker locker(&_hashLock);
|
||||||
|
@ -414,9 +412,7 @@ void AvatarManager::clearOtherAvatars() {
|
||||||
}
|
}
|
||||||
++avatarIterator;
|
++avatarIterator;
|
||||||
}
|
}
|
||||||
if (scene) {
|
|
||||||
scene->enqueueTransaction(transaction);
|
scene->enqueueTransaction(transaction);
|
||||||
}
|
|
||||||
_myAvatar->clearLookAtTargetAvatar();
|
_myAvatar->clearLookAtTargetAvatar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,7 +518,7 @@ void AvatarManager::handleCollisionEvents(const CollisionEvents& collisionEvents
|
||||||
|
|
||||||
void AvatarManager::updateAvatarRenderStatus(bool shouldRenderAvatars) {
|
void AvatarManager::updateAvatarRenderStatus(bool shouldRenderAvatars) {
|
||||||
_shouldRender = shouldRenderAvatars;
|
_shouldRender = shouldRenderAvatars;
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
if (_shouldRender) {
|
if (_shouldRender) {
|
||||||
for (auto avatarData : _avatarHash) {
|
for (auto avatarData : _avatarHash) {
|
||||||
|
@ -535,9 +531,7 @@ void AvatarManager::updateAvatarRenderStatus(bool shouldRenderAvatars) {
|
||||||
avatar->removeFromScene(avatar, scene, transaction);
|
avatar->removeFromScene(avatar, scene, transaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (scene) {
|
|
||||||
scene->enqueueTransaction(transaction);
|
scene->enqueueTransaction(transaction);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarSharedPointer AvatarManager::getAvatarBySessionID(const QUuid& sessionID) const {
|
AvatarSharedPointer AvatarManager::getAvatarBySessionID(const QUuid& sessionID) const {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <shared/RateCounter.h>
|
#include <shared/RateCounter.h>
|
||||||
|
|
||||||
#include "Avatar.h"
|
#include "Avatar.h"
|
||||||
|
#include "MyAvatar.h"
|
||||||
#include "AvatarMotionState.h"
|
#include "AvatarMotionState.h"
|
||||||
#include "ScriptAvatar.h"
|
#include "ScriptAvatar.h"
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
std::shared_ptr<MyAvatar> getMyAvatar() { return _myAvatar; }
|
std::shared_ptr<MyAvatar> getMyAvatar() { return _myAvatar; }
|
||||||
|
glm::vec3 getMyAvatarPosition() const { return _myAvatar->getPosition(); }
|
||||||
|
|
||||||
// Null/Default-constructed QUuids will return MyAvatar
|
// Null/Default-constructed QUuids will return MyAvatar
|
||||||
Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) override { return new ScriptAvatar(getAvatarBySessionID(avatarID)); }
|
Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) override { return new ScriptAvatar(getAvatarBySessionID(avatarID)); }
|
||||||
|
@ -110,7 +112,7 @@ private:
|
||||||
|
|
||||||
QVector<AvatarSharedPointer> _avatarsToFade;
|
QVector<AvatarSharedPointer> _avatarsToFade;
|
||||||
|
|
||||||
SetOfAvatarMotionStates _motionStatesThatMightUpdate;
|
QSet<AvatarMotionState*> _motionStatesThatMightUpdate;
|
||||||
VectorOfMotionStates _motionStatesToRemoveFromPhysics;
|
VectorOfMotionStates _motionStatesToRemoveFromPhysics;
|
||||||
SetOfMotionStates _motionStatesToAddToPhysics;
|
SetOfMotionStates _motionStatesToAddToPhysics;
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,4 @@ protected:
|
||||||
uint32_t _dirtyFlags;
|
uint32_t _dirtyFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSet<AvatarMotionState*> SetOfAvatarMotionStates;
|
|
||||||
|
|
||||||
#endif // hifi_AvatarMotionState_h
|
#endif // hifi_AvatarMotionState_h
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
#include "AvatarActionHold.h"
|
#include "AvatarActionHold.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "MyAvatar.h"
|
#include "MyAvatar.h"
|
||||||
#include "Physics.h"
|
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "InterfaceLogging.h"
|
#include "InterfaceLogging.h"
|
||||||
#include "DebugDraw.h"
|
#include "DebugDraw.h"
|
||||||
|
@ -83,8 +82,8 @@ const float MyAvatar::ZOOM_MIN = 0.5f;
|
||||||
const float MyAvatar::ZOOM_MAX = 25.0f;
|
const float MyAvatar::ZOOM_MAX = 25.0f;
|
||||||
const float MyAvatar::ZOOM_DEFAULT = 1.5f;
|
const float MyAvatar::ZOOM_DEFAULT = 1.5f;
|
||||||
|
|
||||||
MyAvatar::MyAvatar(RigPointer rig) :
|
MyAvatar::MyAvatar(QThread* thread, RigPointer rig) :
|
||||||
Avatar(rig),
|
Avatar(thread, rig),
|
||||||
_wasPushing(false),
|
_wasPushing(false),
|
||||||
_isPushing(false),
|
_isPushing(false),
|
||||||
_isBeingPushed(false),
|
_isBeingPushed(false),
|
||||||
|
@ -260,7 +259,7 @@ void MyAvatar::simulateAttachments(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray MyAvatar::toByteArrayStateful(AvatarDataDetail dataDetail) {
|
QByteArray MyAvatar::toByteArrayStateful(AvatarDataDetail dataDetail) {
|
||||||
CameraMode mode = qApp->getCamera()->getMode();
|
CameraMode mode = qApp->getCamera().getMode();
|
||||||
_globalPosition = getPosition();
|
_globalPosition = getPosition();
|
||||||
_globalBoundingBoxDimensions.x = _characterController.getCapsuleRadius();
|
_globalBoundingBoxDimensions.x = _characterController.getCapsuleRadius();
|
||||||
_globalBoundingBoxDimensions.y = _characterController.getCapsuleHalfHeight();
|
_globalBoundingBoxDimensions.y = _characterController.getCapsuleHalfHeight();
|
||||||
|
@ -752,13 +751,12 @@ controller::Pose MyAvatar::getRightHandTipPose() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
void MyAvatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
|
void MyAvatar::render(RenderArgs* renderArgs) {
|
||||||
// don't render if we've been asked to disable local rendering
|
// don't render if we've been asked to disable local rendering
|
||||||
if (!_shouldRender) {
|
if (!_shouldRender) {
|
||||||
return; // exit early
|
return; // exit early
|
||||||
}
|
}
|
||||||
|
Avatar::render(renderArgs);
|
||||||
Avatar::render(renderArgs, cameraPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::overrideAnimation(const QString& url, float fps, bool loop, float firstFrame, float lastFrame) {
|
void MyAvatar::overrideAnimation(const QString& url, float fps, bool loop, float firstFrame, float lastFrame) {
|
||||||
|
@ -927,8 +925,7 @@ void MyAvatar::setEnableDebugDrawIKTargets(bool isEnabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setEnableMeshVisible(bool isEnabled) {
|
void MyAvatar::setEnableMeshVisible(bool isEnabled) {
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
_skeletonModel->setVisibleInScene(isEnabled, qApp->getMain3DScene());
|
||||||
_skeletonModel->setVisibleInScene(isEnabled, scene);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setUseAnimPreAndPostRotations(bool isEnabled) {
|
void MyAvatar::setUseAnimPreAndPostRotations(bool isEnabled) {
|
||||||
|
@ -1079,7 +1076,7 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
||||||
_targetAvatarPosition = glm::vec3(0.0f);
|
_targetAvatarPosition = glm::vec3(0.0f);
|
||||||
|
|
||||||
glm::vec3 lookForward = getHead()->getFinalOrientationInWorldFrame() * IDENTITY_FORWARD;
|
glm::vec3 lookForward = getHead()->getFinalOrientationInWorldFrame() * IDENTITY_FORWARD;
|
||||||
glm::vec3 cameraPosition = qApp->getCamera()->getPosition();
|
glm::vec3 cameraPosition = qApp->getCamera().getPosition();
|
||||||
|
|
||||||
float smallestAngleTo = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES) / 2.0f;
|
float smallestAngleTo = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES) / 2.0f;
|
||||||
const float KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR = 1.3f;
|
const float KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR = 1.3f;
|
||||||
|
@ -1225,8 +1222,7 @@ void MyAvatar::clearJointsData() {
|
||||||
|
|
||||||
void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
|
void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
|
||||||
Avatar::setSkeletonModelURL(skeletonModelURL);
|
Avatar::setSkeletonModelURL(skeletonModelURL);
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
_skeletonModel->setVisibleInScene(true, qApp->getMain3DScene());
|
||||||
_skeletonModel->setVisibleInScene(true, scene);
|
|
||||||
_headBoneSet.clear();
|
_headBoneSet.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1275,7 +1271,7 @@ void MyAvatar::setAttachmentData(const QVector<AttachmentData>& attachmentData)
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 MyAvatar::getSkeletonPosition() const {
|
glm::vec3 MyAvatar::getSkeletonPosition() const {
|
||||||
CameraMode mode = qApp->getCamera()->getMode();
|
CameraMode mode = qApp->getCamera().getMode();
|
||||||
if (mode == CAMERA_MODE_THIRD_PERSON || mode == CAMERA_MODE_INDEPENDENT) {
|
if (mode == CAMERA_MODE_THIRD_PERSON || mode == CAMERA_MODE_INDEPENDENT) {
|
||||||
// The avatar is rotated PI about the yAxis, so we have to correct for it
|
// The avatar is rotated PI about the yAxis, so we have to correct for it
|
||||||
// to get the skeleton offset contribution in the world-frame.
|
// to get the skeleton offset contribution in the world-frame.
|
||||||
|
@ -1540,7 +1536,7 @@ void MyAvatar::attach(const QString& modelURL, const QString& jointName,
|
||||||
Avatar::attach(modelURL, jointName, translation, rotation, scale, isSoft, allowDuplicates, useSaved);
|
Avatar::attach(modelURL, jointName, translation, rotation, scale, isSoft, allowDuplicates, useSaved);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setVisibleInSceneIfReady(Model* model, render::ScenePointer scene, bool visible) {
|
void MyAvatar::setVisibleInSceneIfReady(Model* model, const render::ScenePointer& scene, bool visible) {
|
||||||
if (model->isActive() && model->isRenderable()) {
|
if (model->isActive() && model->isRenderable()) {
|
||||||
model->setVisibleInScene(visible, scene);
|
model->setVisibleInScene(visible, scene);
|
||||||
}
|
}
|
||||||
|
@ -1634,8 +1630,7 @@ void MyAvatar::postUpdate(float deltaTime) {
|
||||||
|
|
||||||
Avatar::postUpdate(deltaTime);
|
Avatar::postUpdate(deltaTime);
|
||||||
|
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderAvatars() && _skeletonModel->initWhenReady(qApp->getMain3DScene())) {
|
||||||
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderAvatars() && _skeletonModel->initWhenReady(scene)) {
|
|
||||||
initHeadBones();
|
initHeadBones();
|
||||||
_skeletonModel->setCauterizeBoneSet(_headBoneSet);
|
_skeletonModel->setCauterizeBoneSet(_headBoneSet);
|
||||||
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
||||||
|
@ -1704,13 +1699,13 @@ void MyAvatar::preDisplaySide(RenderArgs* renderArgs) {
|
||||||
const float RENDER_HEAD_CUTOFF_DISTANCE = 0.3f;
|
const float RENDER_HEAD_CUTOFF_DISTANCE = 0.3f;
|
||||||
|
|
||||||
bool MyAvatar::cameraInsideHead() const {
|
bool MyAvatar::cameraInsideHead() const {
|
||||||
const glm::vec3 cameraPosition = qApp->getCamera()->getPosition();
|
const glm::vec3 cameraPosition = qApp->getCamera().getPosition();
|
||||||
return glm::length(cameraPosition - getHeadPosition()) < (RENDER_HEAD_CUTOFF_DISTANCE * getUniformScale());
|
return glm::length(cameraPosition - getHeadPosition()) < (RENDER_HEAD_CUTOFF_DISTANCE * getUniformScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyAvatar::shouldRenderHead(const RenderArgs* renderArgs) const {
|
bool MyAvatar::shouldRenderHead(const RenderArgs* renderArgs) const {
|
||||||
bool defaultMode = renderArgs->_renderMode == RenderArgs::DEFAULT_RENDER_MODE;
|
bool defaultMode = renderArgs->_renderMode == RenderArgs::DEFAULT_RENDER_MODE;
|
||||||
bool firstPerson = qApp->getCamera()->getMode() == CAMERA_MODE_FIRST_PERSON;
|
bool firstPerson = qApp->getCamera().getMode() == CAMERA_MODE_FIRST_PERSON;
|
||||||
bool insideHead = cameraInsideHead();
|
bool insideHead = cameraInsideHead();
|
||||||
return !defaultMode || !firstPerson || !insideHead;
|
return !defaultMode || !firstPerson || !insideHead;
|
||||||
}
|
}
|
||||||
|
@ -2265,7 +2260,7 @@ glm::vec3 MyAvatar::getPositionForAudio() {
|
||||||
case AudioListenerMode::FROM_HEAD:
|
case AudioListenerMode::FROM_HEAD:
|
||||||
return getHead()->getPosition();
|
return getHead()->getPosition();
|
||||||
case AudioListenerMode::FROM_CAMERA:
|
case AudioListenerMode::FROM_CAMERA:
|
||||||
return qApp->getCamera()->getPosition();
|
return qApp->getCamera().getPosition();
|
||||||
case AudioListenerMode::CUSTOM:
|
case AudioListenerMode::CUSTOM:
|
||||||
return _customListenPosition;
|
return _customListenPosition;
|
||||||
}
|
}
|
||||||
|
@ -2277,7 +2272,7 @@ glm::quat MyAvatar::getOrientationForAudio() {
|
||||||
case AudioListenerMode::FROM_HEAD:
|
case AudioListenerMode::FROM_HEAD:
|
||||||
return getHead()->getFinalOrientationInWorldFrame();
|
return getHead()->getFinalOrientationInWorldFrame();
|
||||||
case AudioListenerMode::FROM_CAMERA:
|
case AudioListenerMode::FROM_CAMERA:
|
||||||
return qApp->getCamera()->getOrientation();
|
return qApp->getCamera().getOrientation();
|
||||||
case AudioListenerMode::CUSTOM:
|
case AudioListenerMode::CUSTOM:
|
||||||
return _customListenOrientation;
|
return _customListenOrientation;
|
||||||
}
|
}
|
||||||
|
@ -2367,7 +2362,7 @@ void MyAvatar::FollowHelper::decrementTimeRemaining(float dt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyAvatar::FollowHelper::shouldActivateRotation(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const {
|
bool MyAvatar::FollowHelper::shouldActivateRotation(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const {
|
||||||
auto cameraMode = qApp->getCamera()->getMode();
|
auto cameraMode = qApp->getCamera().getMode();
|
||||||
if (cameraMode == CAMERA_MODE_THIRD_PERSON) {
|
if (cameraMode == CAMERA_MODE_THIRD_PERSON) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2515,8 +2510,8 @@ void MyAvatar::setAway(bool value) {
|
||||||
glm::mat4 MyAvatar::computeCameraRelativeHandControllerMatrix(const glm::mat4& controllerSensorMatrix) const {
|
glm::mat4 MyAvatar::computeCameraRelativeHandControllerMatrix(const glm::mat4& controllerSensorMatrix) const {
|
||||||
|
|
||||||
// Fetch the current camera transform.
|
// Fetch the current camera transform.
|
||||||
glm::mat4 cameraWorldMatrix = qApp->getCamera()->getTransform();
|
glm::mat4 cameraWorldMatrix = qApp->getCamera().getTransform();
|
||||||
if (qApp->getCamera()->getMode() == CAMERA_MODE_MIRROR) {
|
if (qApp->getCamera().getMode() == CAMERA_MODE_MIRROR) {
|
||||||
cameraWorldMatrix *= createMatFromScaleQuatAndPos(vec3(-1.0f, 1.0f, 1.0f), glm::quat(), glm::vec3());
|
cameraWorldMatrix *= createMatFromScaleQuatAndPos(vec3(-1.0f, 1.0f, 1.0f), glm::quat(), glm::vec3());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2561,7 +2556,7 @@ glm::quat MyAvatar::getAbsoluteJointRotationInObjectFrame(int index) const {
|
||||||
Transform avatarTransform;
|
Transform avatarTransform;
|
||||||
Transform::mult(avatarTransform, getParentTransform(success), getLocalTransform());
|
Transform::mult(avatarTransform, getParentTransform(success), getLocalTransform());
|
||||||
glm::mat4 invAvatarMat = avatarTransform.getInverseMatrix();
|
glm::mat4 invAvatarMat = avatarTransform.getInverseMatrix();
|
||||||
return glmExtractRotation(invAvatarMat * qApp->getCamera()->getTransform());
|
return glmExtractRotation(invAvatarMat * qApp->getCamera().getTransform());
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return Avatar::getAbsoluteJointRotationInObjectFrame(index);
|
return Avatar::getAbsoluteJointRotationInObjectFrame(index);
|
||||||
|
@ -2598,7 +2593,7 @@ glm::vec3 MyAvatar::getAbsoluteJointTranslationInObjectFrame(int index) const {
|
||||||
Transform avatarTransform;
|
Transform avatarTransform;
|
||||||
Transform::mult(avatarTransform, getParentTransform(success), getLocalTransform());
|
Transform::mult(avatarTransform, getParentTransform(success), getLocalTransform());
|
||||||
glm::mat4 invAvatarMat = avatarTransform.getInverseMatrix();
|
glm::mat4 invAvatarMat = avatarTransform.getInverseMatrix();
|
||||||
return extractTranslation(invAvatarMat * qApp->getCamera()->getTransform());
|
return extractTranslation(invAvatarMat * qApp->getCamera().getTransform());
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return Avatar::getAbsoluteJointTranslationInObjectFrame(index);
|
return Avatar::getAbsoluteJointTranslationInObjectFrame(index);
|
||||||
|
|
|
@ -146,7 +146,7 @@ public:
|
||||||
};
|
};
|
||||||
Q_ENUM(DriveKeys)
|
Q_ENUM(DriveKeys)
|
||||||
|
|
||||||
explicit MyAvatar(RigPointer rig);
|
explicit MyAvatar(QThread* thread, RigPointer rig);
|
||||||
~MyAvatar();
|
~MyAvatar();
|
||||||
|
|
||||||
void registerMetaTypes(QScriptEngine* engine);
|
void registerMetaTypes(QScriptEngine* engine);
|
||||||
|
@ -525,7 +525,7 @@ private:
|
||||||
|
|
||||||
void simulate(float deltaTime);
|
void simulate(float deltaTime);
|
||||||
void updateFromTrackers(float deltaTime);
|
void updateFromTrackers(float deltaTime);
|
||||||
virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPositio) override;
|
virtual void render(RenderArgs* renderArgs) override;
|
||||||
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const override;
|
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const override;
|
||||||
void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; setEnableMeshVisible(shouldRender); }
|
void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; setEnableMeshVisible(shouldRender); }
|
||||||
bool getShouldRenderLocally() const { return _shouldRender; }
|
bool getShouldRenderLocally() const { return _shouldRender; }
|
||||||
|
@ -551,7 +551,7 @@ private:
|
||||||
// These are made private for MyAvatar so that you will use the "use" methods instead
|
// These are made private for MyAvatar so that you will use the "use" methods instead
|
||||||
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL) override;
|
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL) override;
|
||||||
|
|
||||||
void setVisibleInSceneIfReady(Model* model, render::ScenePointer scene, bool visiblity);
|
void setVisibleInSceneIfReady(Model* model, const render::ScenePointer& scene, bool visiblity);
|
||||||
|
|
||||||
// derive avatar body position and orientation from the current HMD Sensor location.
|
// derive avatar body position and orientation from the current HMD Sensor location.
|
||||||
// results are in HMD frame
|
// results are in HMD frame
|
||||||
|
|
|
@ -105,9 +105,9 @@ QScriptValue HMDScriptingInterface::getHUDLookAtPosition3D(QScriptContext* conte
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HMDScriptingInterface::getHUDLookAtPosition3D(glm::vec3& result) const {
|
bool HMDScriptingInterface::getHUDLookAtPosition3D(glm::vec3& result) const {
|
||||||
Camera* camera = qApp->getCamera();
|
const Camera& camera = qApp->getCamera();
|
||||||
glm::vec3 position = camera->getPosition();
|
glm::vec3 position = camera.getPosition();
|
||||||
glm::quat orientation = camera->getOrientation();
|
glm::quat orientation = camera.getOrientation();
|
||||||
|
|
||||||
glm::vec3 direction = orientation * glm::vec3(0.0f, 0.0f, -1.0f);
|
glm::vec3 direction = orientation * glm::vec3(0.0f, 0.0f, -1.0f);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ QVariant Billboardable::getProperty(const QString &property) {
|
||||||
void Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offsetRotation) {
|
void Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offsetRotation) {
|
||||||
if (isFacingAvatar()) {
|
if (isFacingAvatar()) {
|
||||||
glm::vec3 billboardPos = transform.getTranslation();
|
glm::vec3 billboardPos = transform.getTranslation();
|
||||||
glm::vec3 cameraPos = qApp->getCamera()->getPosition();
|
glm::vec3 cameraPos = qApp->getCamera().getPosition();
|
||||||
glm::vec3 look = cameraPos - billboardPos;
|
glm::vec3 look = cameraPos - billboardPos;
|
||||||
float elevation = -asinf(look.y / glm::length(look));
|
float elevation = -asinf(look.y / glm::length(look));
|
||||||
float azimuth = atan2f(look.x, look.z);
|
float azimuth = atan2f(look.x, look.z);
|
||||||
|
|
|
@ -58,13 +58,13 @@ void ModelOverlay::update(float deltatime) {
|
||||||
_isLoaded = _model->isActive();
|
_isLoaded = _model->isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelOverlay::addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
bool ModelOverlay::addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
Volume3DOverlay::addToScene(overlay, scene, transaction);
|
Volume3DOverlay::addToScene(overlay, scene, transaction);
|
||||||
_model->addToScene(scene, transaction);
|
_model->addToScene(scene, transaction);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelOverlay::removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
void ModelOverlay::removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
Volume3DOverlay::removeFromScene(overlay, scene, transaction);
|
Volume3DOverlay::removeFromScene(overlay, scene, transaction);
|
||||||
_model->removeFromScene(scene, transaction);
|
_model->removeFromScene(scene, transaction);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ public:
|
||||||
|
|
||||||
virtual ModelOverlay* createClone() const override;
|
virtual ModelOverlay* createClone() const override;
|
||||||
|
|
||||||
virtual bool addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
virtual bool addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
virtual void removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
virtual void removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
|
|
||||||
void locationChanged(bool tellPhysics) override;
|
void locationChanged(bool tellPhysics) override;
|
||||||
|
|
||||||
|
|
|
@ -196,13 +196,13 @@ float Overlay::updatePulse() {
|
||||||
return _pulse;
|
return _pulse;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Overlay::addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
bool Overlay::addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
_renderItemID = scene->allocateID();
|
_renderItemID = scene->allocateID();
|
||||||
transaction.resetItem(_renderItemID, std::make_shared<Overlay::Payload>(overlay));
|
transaction.resetItem(_renderItemID, std::make_shared<Overlay::Payload>(overlay));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
void Overlay::removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
transaction.removeItem(_renderItemID);
|
transaction.removeItem(_renderItemID);
|
||||||
render::Item::clearID(_renderItemID);
|
render::Item::clearID(_renderItemID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,8 @@ public:
|
||||||
virtual AABox getBounds() const = 0;
|
virtual AABox getBounds() const = 0;
|
||||||
virtual bool supportsGetProperty() const { return true; }
|
virtual bool supportsGetProperty() const { return true; }
|
||||||
|
|
||||||
virtual bool addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction);
|
virtual bool addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction);
|
||||||
virtual void removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction);
|
virtual void removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction);
|
||||||
|
|
||||||
virtual const render::ShapeKey getShapeKey() { return render::ShapeKey::Builder::ownPipeline(); }
|
virtual const render::ShapeKey getShapeKey() { return render::ShapeKey::Builder::ownPipeline(); }
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace render {
|
||||||
// Mixin class for implementing basic single item rendering
|
// Mixin class for implementing basic single item rendering
|
||||||
class SimpleRenderableEntityItem {
|
class SimpleRenderableEntityItem {
|
||||||
public:
|
public:
|
||||||
bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
_myItem = scene->allocateID();
|
_myItem = scene->allocateID();
|
||||||
|
|
||||||
auto renderData = std::make_shared<RenderableEntityItemProxy>(self, _myItem);
|
auto renderData = std::make_shared<RenderableEntityItemProxy>(self, _myItem);
|
||||||
|
@ -69,7 +69,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
transaction.removeItem(_myItem);
|
transaction.removeItem(_myItem);
|
||||||
render::Item::clearID(_myItem);
|
render::Item::clearID(_myItem);
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,8 @@ private:
|
||||||
|
|
||||||
#define SIMPLE_RENDERABLE() \
|
#define SIMPLE_RENDERABLE() \
|
||||||
public: \
|
public: \
|
||||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override { return _renderHelper.addToScene(self, scene, transaction); } \
|
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override { return _renderHelper.addToScene(self, scene, transaction); } \
|
||||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override { _renderHelper.removeFromScene(self, scene, transaction); } \
|
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override { _renderHelper.removeFromScene(self, scene, transaction); } \
|
||||||
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); _renderHelper.notifyChanged(); } \
|
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); _renderHelper.notifyChanged(); } \
|
||||||
virtual void dimensionsChanged() override { EntityItem::dimensionsChanged(); _renderHelper.notifyChanged(); } \
|
virtual void dimensionsChanged() override { EntityItem::dimensionsChanged(); _renderHelper.notifyChanged(); } \
|
||||||
void checkFading() { \
|
void checkFading() { \
|
||||||
|
|
|
@ -27,7 +27,7 @@ RenderableLightEntityItem::RenderableLightEntityItem(const EntityItemID& entityI
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderableLightEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
bool RenderableLightEntityItem::addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
_myItem = scene->allocateID();
|
_myItem = scene->allocateID();
|
||||||
|
|
||||||
auto renderItem = std::make_shared<LightPayload>();
|
auto renderItem = std::make_shared<LightPayload>();
|
||||||
|
@ -51,7 +51,7 @@ void RenderableLightEntityItem::somethingChangedNotification() {
|
||||||
LightEntityItem::somethingChangedNotification();
|
LightEntityItem::somethingChangedNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableLightEntityItem::removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
void RenderableLightEntityItem::removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
transaction.removeItem(_myItem);
|
transaction.removeItem(_myItem);
|
||||||
render::Item::clearID(_myItem);
|
render::Item::clearID(_myItem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@ public:
|
||||||
|
|
||||||
void updateLightFromEntity(render::Transaction& transaction);
|
void updateLightFromEntity(render::Transaction& transaction);
|
||||||
|
|
||||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
|
|
||||||
virtual void somethingChangedNotification() override;
|
virtual void somethingChangedNotification() override;
|
||||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
|
|
||||||
virtual void locationChanged(bool tellPhysics = true) override;
|
virtual void locationChanged(bool tellPhysics = true) override;
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@ namespace render {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
bool RenderableModelEntityItem::addToScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) {
|
render::Transaction& transaction) {
|
||||||
_myMetaItem = scene->allocateID();
|
_myMetaItem = scene->allocateID();
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_p
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableModelEntityItem::removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
void RenderableModelEntityItem::removeFromScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) {
|
render::Transaction& transaction) {
|
||||||
transaction.removeItem(_myMetaItem);
|
transaction.removeItem(_myMetaItem);
|
||||||
render::Item::clearID(_myMetaItem);
|
render::Item::clearID(_myMetaItem);
|
||||||
|
@ -437,7 +437,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
||||||
_model->renderDebugMeshBoxes(batch);
|
_model->renderDebugMeshBoxes(batch);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||||
|
|
||||||
// FIXME: this seems like it could be optimized if we tracked our last known visible state in
|
// FIXME: this seems like it could be optimized if we tracked our last known visible state in
|
||||||
// the renderable item. As it stands now the model checks it's visible/invisible state
|
// the renderable item. As it stands now the model checks it's visible/invisible state
|
||||||
|
@ -526,7 +526,7 @@ ModelPointer RenderableModelEntityItem::getModel(QSharedPointer<EntityTreeRender
|
||||||
// If we have no URL, then we can delete any model we do have...
|
// If we have no URL, then we can delete any model we do have...
|
||||||
} else if (_model) {
|
} else if (_model) {
|
||||||
// remove from scene
|
// remove from scene
|
||||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
_model->removeFromScene(scene, transaction);
|
_model->removeFromScene(scene, transaction);
|
||||||
scene->enqueueTransaction(transaction);
|
scene->enqueueTransaction(transaction);
|
||||||
|
@ -1239,11 +1239,10 @@ void RenderableModelEntityItem::locationChanged(bool tellPhysics) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
|
|
||||||
transaction.updateItem(myMetaItem);
|
transaction.updateItem(myMetaItem);
|
||||||
scene->enqueueTransaction(transaction);
|
AbstractViewStateInterface::instance()->getMain3DScene()->enqueueTransaction(transaction);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ public:
|
||||||
|
|
||||||
void doInitialModelSimulation();
|
void doInitialModelSimulation();
|
||||||
|
|
||||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
|
|
||||||
|
|
||||||
void updateModelBounds();
|
void updateModelBounds();
|
||||||
|
|
|
@ -161,7 +161,7 @@ RenderableParticleEffectEntityItem::RenderableParticleEffectEntityItem(const Ent
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderableParticleEffectEntityItem::addToScene(EntityItemPointer self,
|
bool RenderableParticleEffectEntityItem::addToScene(EntityItemPointer self,
|
||||||
render::ScenePointer scene,
|
const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) {
|
render::Transaction& transaction) {
|
||||||
_scene = scene;
|
_scene = scene;
|
||||||
_renderItemId = _scene->allocateID();
|
_renderItemId = _scene->allocateID();
|
||||||
|
@ -176,7 +176,7 @@ bool RenderableParticleEffectEntityItem::addToScene(EntityItemPointer self,
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableParticleEffectEntityItem::removeFromScene(EntityItemPointer self,
|
void RenderableParticleEffectEntityItem::removeFromScene(EntityItemPointer self,
|
||||||
render::ScenePointer scene,
|
const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) {
|
render::Transaction& transaction) {
|
||||||
transaction.removeItem(_renderItemId);
|
transaction.removeItem(_renderItemId);
|
||||||
_scene = nullptr;
|
_scene = nullptr;
|
||||||
|
|
|
@ -25,8 +25,8 @@ public:
|
||||||
|
|
||||||
void updateRenderItem();
|
void updateRenderItem();
|
||||||
|
|
||||||
virtual bool addToScene(EntityItemPointer self, render::ScenePointer scene, render::Transaction& transaction) override;
|
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
virtual void removeFromScene(EntityItemPointer self, render::ScenePointer scene, render::Transaction& transaction) override;
|
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); notifyBoundChanged(); }
|
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); notifyBoundChanged(); }
|
||||||
|
|
|
@ -816,7 +816,7 @@ void RenderablePolyVoxEntityItem::render(RenderArgs* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderablePolyVoxEntityItem::addToScene(EntityItemPointer self,
|
bool RenderablePolyVoxEntityItem::addToScene(EntityItemPointer self,
|
||||||
std::shared_ptr<render::Scene> scene,
|
const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) {
|
render::Transaction& transaction) {
|
||||||
_myItem = scene->allocateID();
|
_myItem = scene->allocateID();
|
||||||
|
|
||||||
|
@ -834,7 +834,7 @@ bool RenderablePolyVoxEntityItem::addToScene(EntityItemPointer self,
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderablePolyVoxEntityItem::removeFromScene(EntityItemPointer self,
|
void RenderablePolyVoxEntityItem::removeFromScene(EntityItemPointer self,
|
||||||
std::shared_ptr<render::Scene> scene,
|
const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) {
|
render::Transaction& transaction) {
|
||||||
transaction.removeItem(_myItem);
|
transaction.removeItem(_myItem);
|
||||||
render::Item::clearID(_myItem);
|
render::Item::clearID(_myItem);
|
||||||
|
|
|
@ -106,10 +106,10 @@ public:
|
||||||
virtual void setZTextureURL(const QString& zTextureURL) override;
|
virtual void setZTextureURL(const QString& zTextureURL) override;
|
||||||
|
|
||||||
virtual bool addToScene(EntityItemPointer self,
|
virtual bool addToScene(EntityItemPointer self,
|
||||||
std::shared_ptr<render::Scene> scene,
|
const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) override;
|
render::Transaction& transaction) override;
|
||||||
virtual void removeFromScene(EntityItemPointer self,
|
virtual void removeFromScene(EntityItemPointer self,
|
||||||
std::shared_ptr<render::Scene> scene,
|
const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) override;
|
render::Transaction& transaction) override;
|
||||||
|
|
||||||
virtual void setXNNeighborID(const EntityItemID& xNNeighborID) override;
|
virtual void setXNNeighborID(const EntityItemID& xNNeighborID) override;
|
||||||
|
|
|
@ -217,7 +217,7 @@ namespace render {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderableZoneEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
bool RenderableZoneEntityItem::addToScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) {
|
render::Transaction& transaction) {
|
||||||
_myMetaItem = scene->allocateID();
|
_myMetaItem = scene->allocateID();
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ bool RenderableZoneEntityItem::addToScene(EntityItemPointer self, std::shared_pt
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableZoneEntityItem::removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
void RenderableZoneEntityItem::removeFromScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) {
|
render::Transaction& transaction) {
|
||||||
transaction.removeItem(_myMetaItem);
|
transaction.removeItem(_myMetaItem);
|
||||||
render::Item::clearID(_myMetaItem);
|
render::Item::clearID(_myMetaItem);
|
||||||
|
|
|
@ -38,8 +38,8 @@ public:
|
||||||
virtual void render(RenderArgs* args) override;
|
virtual void render(RenderArgs* args) override;
|
||||||
virtual bool contains(const glm::vec3& point) const override;
|
virtual bool contains(const glm::vec3& point) const override;
|
||||||
|
|
||||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||||
|
|
||||||
render::ItemID getRenderItemID() const { return _myMetaItem; }
|
render::ItemID getRenderItemID() const { return _myMetaItem; }
|
||||||
|
|
||||||
|
|
|
@ -151,9 +151,9 @@ public:
|
||||||
bool& somethingChanged)
|
bool& somethingChanged)
|
||||||
{ somethingChanged = false; return 0; }
|
{ somethingChanged = false; return 0; }
|
||||||
|
|
||||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) { return false; } // by default entity items don't add to scene
|
render::Transaction& transaction) { return false; } // by default entity items don't add to scene
|
||||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) { } // by default entity items don't add to scene
|
render::Transaction& transaction) { } // by default entity items don't add to scene
|
||||||
virtual void render(RenderArgs* args) { } // by default entity items don't know how to render
|
virtual void render(RenderArgs* args) { } // by default entity items don't know how to render
|
||||||
|
|
||||||
|
|
|
@ -231,8 +231,6 @@ void Model::updateRenderItems() {
|
||||||
// We need to update them here so we can correctly update the bounding box.
|
// We need to update them here so we can correctly update the bounding box.
|
||||||
self->updateClusterMatrices();
|
self->updateClusterMatrices();
|
||||||
|
|
||||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
|
||||||
|
|
||||||
uint32_t deleteGeometryCounter = self->_deleteGeometryCounter;
|
uint32_t deleteGeometryCounter = self->_deleteGeometryCounter;
|
||||||
|
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
|
@ -266,7 +264,7 @@ void Model::updateRenderItems() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
scene->enqueueTransaction(transaction);
|
AbstractViewStateInterface::instance()->getMain3DScene()->enqueueTransaction(transaction);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,7 +532,7 @@ void Model::calculateTriangleSets() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::setVisibleInScene(bool newValue, std::shared_ptr<render::Scene> scene) {
|
void Model::setVisibleInScene(bool newValue, const render::ScenePointer& scene) {
|
||||||
if (_isVisible != newValue) {
|
if (_isVisible != newValue) {
|
||||||
_isVisible = newValue;
|
_isVisible = newValue;
|
||||||
|
|
||||||
|
@ -550,7 +548,7 @@ void Model::setVisibleInScene(bool newValue, std::shared_ptr<render::Scene> scen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Model::setLayeredInFront(bool layered, std::shared_ptr<render::Scene> scene) {
|
void Model::setLayeredInFront(bool layered, const render::ScenePointer& scene) {
|
||||||
if (_isLayeredInFront != layered) {
|
if (_isLayeredInFront != layered) {
|
||||||
_isLayeredInFront = layered;
|
_isLayeredInFront = layered;
|
||||||
|
|
||||||
|
@ -565,7 +563,7 @@ void Model::setLayeredInFront(bool layered, std::shared_ptr<render::Scene> scene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Model::addToScene(std::shared_ptr<render::Scene> scene,
|
bool Model::addToScene(const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction,
|
render::Transaction& transaction,
|
||||||
render::Item::Status::Getters& statusGetters) {
|
render::Item::Status::Getters& statusGetters) {
|
||||||
bool readyToRender = _collisionGeometry || isLoaded();
|
bool readyToRender = _collisionGeometry || isLoaded();
|
||||||
|
@ -622,7 +620,7 @@ bool Model::addToScene(std::shared_ptr<render::Scene> scene,
|
||||||
return somethingAdded;
|
return somethingAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::removeFromScene(std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
void Model::removeFromScene(const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||||
foreach (auto item, _modelMeshRenderItemsMap.keys()) {
|
foreach (auto item, _modelMeshRenderItemsMap.keys()) {
|
||||||
transaction.removeItem(item);
|
transaction.removeItem(item);
|
||||||
}
|
}
|
||||||
|
@ -795,7 +793,7 @@ void Model::setURL(const QUrl& url) {
|
||||||
|
|
||||||
{
|
{
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||||
if (scene) {
|
if (scene) {
|
||||||
removeFromScene(scene, transaction);
|
removeFromScene(scene, transaction);
|
||||||
scene->enqueueTransaction(transaction);
|
scene->enqueueTransaction(transaction);
|
||||||
|
@ -1271,7 +1269,7 @@ bool Model::isRenderable() const {
|
||||||
return !_meshStates.isEmpty() || (isLoaded() && _renderGeometry->getMeshes().empty());
|
return !_meshStates.isEmpty() || (isLoaded() && _renderGeometry->getMeshes().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Model::initWhenReady(render::ScenePointer scene) {
|
bool Model::initWhenReady(const render::ScenePointer& scene) {
|
||||||
// NOTE: this only called by SkeletonModel
|
// NOTE: this only called by SkeletonModel
|
||||||
if (_addedToScene || !isRenderable()) {
|
if (_addedToScene || !isRenderable()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -81,21 +81,21 @@ public:
|
||||||
const QUrl& getURL() const { return _url; }
|
const QUrl& getURL() const { return _url; }
|
||||||
|
|
||||||
// new Scene/Engine rendering support
|
// new Scene/Engine rendering support
|
||||||
void setVisibleInScene(bool newValue, std::shared_ptr<render::Scene> scene);
|
void setVisibleInScene(bool newValue, const render::ScenePointer& scene);
|
||||||
void setLayeredInFront(bool layered, std::shared_ptr<render::Scene> scene);
|
void setLayeredInFront(bool layered, const render::ScenePointer& scene);
|
||||||
bool needsFixupInScene() const;
|
bool needsFixupInScene() const;
|
||||||
|
|
||||||
bool needsReload() const { return _needsReload; }
|
bool needsReload() const { return _needsReload; }
|
||||||
bool initWhenReady(render::ScenePointer scene);
|
bool initWhenReady(const render::ScenePointer& scene);
|
||||||
bool addToScene(std::shared_ptr<render::Scene> scene,
|
bool addToScene(const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction) {
|
render::Transaction& transaction) {
|
||||||
auto getters = render::Item::Status::Getters(0);
|
auto getters = render::Item::Status::Getters(0);
|
||||||
return addToScene(scene, transaction, getters);
|
return addToScene(scene, transaction, getters);
|
||||||
}
|
}
|
||||||
bool addToScene(std::shared_ptr<render::Scene> scene,
|
bool addToScene(const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction,
|
render::Transaction& transaction,
|
||||||
render::Item::Status::Getters& statusGetters);
|
render::Item::Status::Getters& statusGetters);
|
||||||
void removeFromScene(std::shared_ptr<render::Scene> scene, render::Transaction& transaction);
|
void removeFromScene(const render::ScenePointer& scene, render::Transaction& transaction);
|
||||||
bool isRenderable() const;
|
bool isRenderable() const;
|
||||||
|
|
||||||
bool isVisible() const { return _isVisible; }
|
bool isVisible() const { return _isVisible; }
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
|
|
||||||
class AABox;
|
class AABox;
|
||||||
class OctreeRenderer;
|
class OctreeRenderer;
|
||||||
|
namespace render {
|
||||||
|
class Scene;
|
||||||
|
using ScenePointer = std::shared_ptr<Scene>;
|
||||||
|
}
|
||||||
|
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
class Batch;
|
class Batch;
|
||||||
|
@ -126,6 +130,8 @@ public:
|
||||||
bool _enableTexturing { true };
|
bool _enableTexturing { true };
|
||||||
|
|
||||||
RenderDetails _details;
|
RenderDetails _details;
|
||||||
|
render::ScenePointer _scene; // HACK
|
||||||
|
int8_t _cameraMode { -1 }; // HACK
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_RenderArgs_h
|
#endif // hifi_RenderArgs_h
|
||||||
|
|
Loading…
Reference in a new issue