mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:08:47 +02:00
Merge pull request #5377 from samcake/punk
Removing extra gl calls and removing cruff from Application.cpp
This commit is contained in:
commit
57f9abe5c8
7 changed files with 20 additions and 114 deletions
|
@ -313,7 +313,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_previousScriptLocation("LastScriptLocation"),
|
_previousScriptLocation("LastScriptLocation"),
|
||||||
_scriptsLocationHandle("scriptsLocation"),
|
_scriptsLocationHandle("scriptsLocation"),
|
||||||
_fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES),
|
_fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES),
|
||||||
_viewTransform(),
|
|
||||||
_scaleMirror(1.0f),
|
_scaleMirror(1.0f),
|
||||||
_rotateMirror(0.0f),
|
_rotateMirror(0.0f),
|
||||||
_raiseMirror(0.0f),
|
_raiseMirror(0.0f),
|
||||||
|
@ -962,10 +961,6 @@ void Application::paintGL() {
|
||||||
// FIXME: it's happening again in the updateSHadow and it shouldn't, this should be the place
|
// FIXME: it's happening again in the updateSHadow and it shouldn't, this should be the place
|
||||||
loadViewFrustum(_myCamera, _viewFrustum);
|
loadViewFrustum(_myCamera, _viewFrustum);
|
||||||
|
|
||||||
if (getShadowsEnabled()) {
|
|
||||||
renderArgs._renderMode = RenderArgs::SHADOW_RENDER_MODE;
|
|
||||||
updateShadowMap(&renderArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
|
renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
|
||||||
|
|
||||||
|
@ -981,7 +976,6 @@ void Application::paintGL() {
|
||||||
} else {
|
} else {
|
||||||
PROFILE_RANGE(__FUNCTION__ "/mainRender");
|
PROFILE_RANGE(__FUNCTION__ "/mainRender");
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
gpu::Batch batch;
|
gpu::Batch batch;
|
||||||
auto primaryFbo = DependencyManager::get<TextureCache>()->getPrimaryFramebuffer();
|
auto primaryFbo = DependencyManager::get<TextureCache>()->getPrimaryFramebuffer();
|
||||||
|
@ -1086,7 +1080,8 @@ void Application::resizeGL() {
|
||||||
if (_renderResolution != toGlm(renderSize)) {
|
if (_renderResolution != toGlm(renderSize)) {
|
||||||
_renderResolution = toGlm(renderSize);
|
_renderResolution = toGlm(renderSize);
|
||||||
DependencyManager::get<TextureCache>()->setFrameBufferSize(renderSize);
|
DependencyManager::get<TextureCache>()->setFrameBufferSize(renderSize);
|
||||||
updateProjectionMatrix();
|
|
||||||
|
loadViewFrustum(_myCamera, _viewFrustum);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetCameras(_myCamera, _renderResolution);
|
resetCameras(_myCamera, _renderResolution);
|
||||||
|
@ -1099,18 +1094,6 @@ void Application::resizeGL() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateProjectionMatrix() {
|
|
||||||
updateProjectionMatrix(_myCamera);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) {
|
|
||||||
_projectionMatrix = camera.getProjection();
|
|
||||||
// Tell our viewFrustum about this change, using the application camera
|
|
||||||
if (updateViewFrustum) {
|
|
||||||
loadViewFrustum(camera, _viewFrustum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Application::importSVOFromURL(const QString& urlString) {
|
bool Application::importSVOFromURL(const QString& urlString) {
|
||||||
QUrl url(urlString);
|
QUrl url(urlString);
|
||||||
emit svoImportRequested(url.url());
|
emit svoImportRequested(url.url());
|
||||||
|
@ -2968,13 +2951,6 @@ glm::vec3 Application::getSunDirection() {
|
||||||
// FIXME, preprocessor guard this check to occur only in DEBUG builds
|
// FIXME, preprocessor guard this check to occur only in DEBUG builds
|
||||||
static QThread * activeRenderingThread = nullptr;
|
static QThread * activeRenderingThread = nullptr;
|
||||||
|
|
||||||
void Application::updateShadowMap(RenderArgs* renderArgs) {
|
|
||||||
// TODO fix shadows and make them use the GPU library
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::setupWorldLight(RenderArgs* renderArgs) {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
|
bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
|
||||||
return DependencyManager::get<LODManager>()->shouldRenderMesh(largestDimension, distanceToCamera);
|
return DependencyManager::get<LODManager>()->shouldRenderMesh(largestDimension, distanceToCamera);
|
||||||
}
|
}
|
||||||
|
@ -3219,30 +3195,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
// load the view frustum
|
// load the view frustum
|
||||||
loadViewFrustum(theCamera, _displayViewFrustum);
|
loadViewFrustum(theCamera, _displayViewFrustum);
|
||||||
|
|
||||||
// store view matrix without translation, which we'll use for precision-sensitive objects
|
|
||||||
updateUntranslatedViewMatrix(-theCamera.getPosition());
|
|
||||||
|
|
||||||
// Equivalent to what is happening with _untranslatedViewMatrix and the _viewMatrixTranslation
|
|
||||||
// the viewTransofmr object is updatded with the correct values and saved,
|
|
||||||
// this is what is used for rendering the Entities and avatars
|
|
||||||
Transform viewTransform;
|
|
||||||
viewTransform.setTranslation(theCamera.getPosition());
|
|
||||||
viewTransform.setRotation(theCamera.getRotation());
|
|
||||||
if (renderArgs->_renderSide != RenderArgs::MONO) {
|
|
||||||
glm::mat4 invView = glm::inverse(_untranslatedViewMatrix);
|
|
||||||
|
|
||||||
viewTransform.evalFromRawMatrix(invView);
|
|
||||||
viewTransform.preTranslate(_viewMatrixTranslation);
|
|
||||||
}
|
|
||||||
|
|
||||||
setViewTransform(viewTransform);
|
|
||||||
|
|
||||||
// Setup 3D lights (after the camera transform, so that they are positioned in world space)
|
|
||||||
{
|
|
||||||
PerformanceTimer perfTimer("lights");
|
|
||||||
setupWorldLight(renderArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO fix shadows and make them use the GPU library
|
// TODO fix shadows and make them use the GPU library
|
||||||
|
|
||||||
// The pending changes collecting the changes here
|
// The pending changes collecting the changes here
|
||||||
|
@ -3371,26 +3323,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
activeRenderingThread = nullptr;
|
activeRenderingThread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) {
|
|
||||||
_viewMatrixTranslation = viewMatrixTranslation;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::setViewTransform(const Transform& view) {
|
|
||||||
_viewTransform = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::loadTranslatedViewMatrix(const glm::vec3& translation) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::getModelViewMatrix(glm::dmat4* modelViewMatrix) {
|
|
||||||
(*modelViewMatrix) =_untranslatedViewMatrix;
|
|
||||||
(*modelViewMatrix)[3] = _untranslatedViewMatrix * glm::vec4(_viewMatrixTranslation, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::getProjectionMatrix(glm::dmat4* projectionMatrix) {
|
|
||||||
*projectionMatrix = _projectionMatrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||||
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
|
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
|
||||||
|
|
||||||
|
@ -3443,6 +3375,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
|
||||||
void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool billboard) {
|
void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool billboard) {
|
||||||
auto originalViewport = renderArgs->_viewport;
|
auto originalViewport = renderArgs->_viewport;
|
||||||
// Grab current viewport to reset it at the end
|
// Grab current viewport to reset it at the end
|
||||||
|
|
||||||
float aspect = (float)region.width() / region.height();
|
float aspect = (float)region.width() / region.height();
|
||||||
float fov = MIRROR_FIELD_OF_VIEW;
|
float fov = MIRROR_FIELD_OF_VIEW;
|
||||||
|
|
||||||
|
@ -3509,15 +3442,14 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi
|
||||||
}
|
}
|
||||||
|
|
||||||
bool updateViewFrustum = false;
|
bool updateViewFrustum = false;
|
||||||
updateProjectionMatrix(_mirrorCamera, updateViewFrustum);
|
loadViewFrustum(_mirrorCamera, _viewFrustum);
|
||||||
|
|
||||||
|
|
||||||
// render rear mirror view
|
// render rear mirror view
|
||||||
displaySide(renderArgs, _mirrorCamera, true, billboard);
|
displaySide(renderArgs, _mirrorCamera, true, billboard);
|
||||||
//{
|
|
||||||
// gpu::Batch batch;
|
renderArgs->_viewport = originalViewport;
|
||||||
// renderArgs->_viewport = originalViewport;
|
|
||||||
// batch.setViewportTransform(originalViewport);
|
|
||||||
// renderArgs->_context->render(batch);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::resetSensors() {
|
void Application::resetSensors() {
|
||||||
|
|
|
@ -236,11 +236,6 @@ public:
|
||||||
Overlays& getOverlays() { return _overlays; }
|
Overlays& getOverlays() { return _overlays; }
|
||||||
|
|
||||||
float getFps() const { return _fps; }
|
float getFps() const { return _fps; }
|
||||||
const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; }
|
|
||||||
void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; }
|
|
||||||
|
|
||||||
virtual const Transform& getViewTransform() const { return _viewTransform; }
|
|
||||||
void setViewTransform(const Transform& view);
|
|
||||||
|
|
||||||
float getFieldOfView() { return _fieldOfView.get(); }
|
float getFieldOfView() { return _fieldOfView.get(); }
|
||||||
void setFieldOfView(float fov) { _fieldOfView.set(fov); }
|
void setFieldOfView(float fov) { _fieldOfView.set(fov); }
|
||||||
|
@ -258,26 +253,12 @@ public:
|
||||||
|
|
||||||
void resetProfile(const QString& username);
|
void resetProfile(const QString& username);
|
||||||
|
|
||||||
virtual void setupWorldLight(RenderArgs* renderArgs);
|
|
||||||
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera);
|
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera);
|
||||||
|
|
||||||
QImage renderAvatarBillboard(RenderArgs* renderArgs);
|
QImage renderAvatarBillboard(RenderArgs* renderArgs);
|
||||||
|
|
||||||
void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false, bool billboard = false);
|
void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false, bool billboard = false);
|
||||||
|
|
||||||
/// Stores the current modelview matrix as the untranslated view matrix to use for transforms and the supplied vector as
|
|
||||||
/// the view matrix translation.
|
|
||||||
void updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation = glm::vec3());
|
|
||||||
|
|
||||||
const glm::mat4& getUntranslatedViewMatrix() const { return _untranslatedViewMatrix; }
|
|
||||||
|
|
||||||
/// Loads a view matrix that incorporates the specified model translation without the precision issues that can
|
|
||||||
/// result from matrix multiplication at high translation magnitudes.
|
|
||||||
void loadTranslatedViewMatrix(const glm::vec3& translation);
|
|
||||||
|
|
||||||
void getModelViewMatrix(glm::dmat4* modelViewMatrix);
|
|
||||||
void getProjectionMatrix(glm::dmat4* projectionMatrix);
|
|
||||||
|
|
||||||
virtual const glm::vec3& getShadowDistances() const { return _shadowDistances; }
|
virtual const glm::vec3& getShadowDistances() const { return _shadowDistances; }
|
||||||
|
|
||||||
/// Computes the off-axis frustum parameters for the view frustum, taking mirroring into account.
|
/// Computes the off-axis frustum parameters for the view frustum, taking mirroring into account.
|
||||||
|
@ -470,8 +451,6 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetCameras(Camera& camera, const glm::uvec2& size);
|
void resetCameras(Camera& camera, const glm::uvec2& size);
|
||||||
void updateProjectionMatrix();
|
|
||||||
void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true);
|
|
||||||
|
|
||||||
void sendPingPackets();
|
void sendPingPackets();
|
||||||
|
|
||||||
|
@ -502,7 +481,6 @@ private:
|
||||||
|
|
||||||
glm::vec3 getSunDirection();
|
glm::vec3 getSunDirection();
|
||||||
|
|
||||||
void updateShadowMap(RenderArgs* renderArgs);
|
|
||||||
void renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool billboard = false);
|
void renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool billboard = false);
|
||||||
void setMenuShortcutsEnabled(bool enabled);
|
void setMenuShortcutsEnabled(bool enabled);
|
||||||
|
|
||||||
|
@ -561,11 +539,6 @@ private:
|
||||||
Setting::Handle<QString> _scriptsLocationHandle;
|
Setting::Handle<QString> _scriptsLocationHandle;
|
||||||
Setting::Handle<float> _fieldOfView;
|
Setting::Handle<float> _fieldOfView;
|
||||||
|
|
||||||
Transform _viewTransform;
|
|
||||||
glm::mat4 _untranslatedViewMatrix;
|
|
||||||
glm::vec3 _viewMatrixTranslation;
|
|
||||||
glm::mat4 _projectionMatrix;
|
|
||||||
|
|
||||||
float _scaleMirror;
|
float _scaleMirror;
|
||||||
float _rotateMirror;
|
float _rotateMirror;
|
||||||
float _raiseMirror;
|
float _raiseMirror;
|
||||||
|
|
|
@ -789,12 +789,11 @@ void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha
|
||||||
// so no need to render it
|
// so no need to render it
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Application::getInstance()->loadTranslatedViewMatrix(_translation);
|
|
||||||
|
|
||||||
// draw a blue sphere at the capsule endpoint
|
// draw a blue sphere at the capsule endpoint
|
||||||
glm::vec3 endPoint;
|
glm::vec3 endPoint;
|
||||||
_boundingShape.getEndPoint(endPoint);
|
_boundingShape.getEndPoint(endPoint);
|
||||||
endPoint = endPoint - _translation;
|
endPoint = endPoint + _translation;
|
||||||
Transform transform = Transform();
|
Transform transform = Transform();
|
||||||
transform.setTranslation(endPoint);
|
transform.setTranslation(endPoint);
|
||||||
batch.setModelTransform(transform);
|
batch.setModelTransform(transform);
|
||||||
|
@ -805,7 +804,7 @@ void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha
|
||||||
// draw a yellow sphere at the capsule startpoint
|
// draw a yellow sphere at the capsule startpoint
|
||||||
glm::vec3 startPoint;
|
glm::vec3 startPoint;
|
||||||
_boundingShape.getStartPoint(startPoint);
|
_boundingShape.getStartPoint(startPoint);
|
||||||
startPoint = startPoint - _translation;
|
startPoint = startPoint + _translation;
|
||||||
glm::vec3 axis = endPoint - startPoint;
|
glm::vec3 axis = endPoint - startPoint;
|
||||||
Transform axisTransform = Transform();
|
Transform axisTransform = Transform();
|
||||||
axisTransform.setTranslation(-axis);
|
axisTransform.setTranslation(-axis);
|
||||||
|
|
|
@ -369,14 +369,14 @@ QPoint ApplicationCompositor::getPalmClickLocation(const PalmData *palm) const {
|
||||||
rv.ry() = point.y;
|
rv.ry() = point.y;
|
||||||
} else {
|
} else {
|
||||||
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||||
glm::dmat4 projection;
|
glm::mat4 projection;
|
||||||
qApp->getProjectionMatrix(&projection);
|
qApp->getDisplayViewFrustum()->evalProjectionMatrix(projection);
|
||||||
glm::quat invOrientation = glm::inverse(myAvatar->getOrientation());
|
glm::quat invOrientation = glm::inverse(myAvatar->getOrientation());
|
||||||
glm::vec3 eyePos = myAvatar->getDefaultEyePosition();
|
glm::vec3 eyePos = myAvatar->getDefaultEyePosition();
|
||||||
glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm);
|
glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm);
|
||||||
glm::vec3 tipPos = invOrientation * (tip - eyePos);
|
glm::vec3 tipPos = invOrientation * (tip - eyePos);
|
||||||
|
|
||||||
glm::vec4 clipSpacePos = glm::vec4(projection * glm::dvec4(tipPos, 1.0));
|
glm::vec4 clipSpacePos = glm::vec4(projection * glm::vec4(tipPos, 1.0f));
|
||||||
glm::vec3 ndcSpacePos;
|
glm::vec3 ndcSpacePos;
|
||||||
if (clipSpacePos.w != 0) {
|
if (clipSpacePos.w != 0) {
|
||||||
ndcSpacePos = glm::vec3(clipSpacePos) / clipSpacePos.w;
|
ndcSpacePos = glm::vec3(clipSpacePos) / clipSpacePos.w;
|
||||||
|
|
|
@ -34,6 +34,7 @@ void LocalModelsOverlay::render(RenderArgs* args) {
|
||||||
float glowLevel = getGlowLevel(); // FIXME, glowing removed for now
|
float glowLevel = getGlowLevel(); // FIXME, glowing removed for now
|
||||||
|
|
||||||
auto batch = args ->_batch;
|
auto batch = args ->_batch;
|
||||||
|
|
||||||
Transform transform = Transform();
|
Transform transform = Transform();
|
||||||
transform.setTranslation(args->_viewFrustum->getPosition() + getPosition());
|
transform.setTranslation(args->_viewFrustum->getPosition() + getPosition());
|
||||||
batch->setViewTransform(transform);
|
batch->setViewTransform(transform);
|
||||||
|
|
|
@ -32,7 +32,11 @@ void GLBackend::do_setProjectionTransform(Batch& batch, uint32 paramOffset) {
|
||||||
|
|
||||||
void GLBackend::do_setViewportTransform(Batch& batch, uint32 paramOffset) {
|
void GLBackend::do_setViewportTransform(Batch& batch, uint32 paramOffset) {
|
||||||
memcpy(&_transform._viewport, batch.editData(batch._params[paramOffset]._uint), sizeof(Vec4i));
|
memcpy(&_transform._viewport, batch.editData(batch._params[paramOffset]._uint), sizeof(Vec4i));
|
||||||
|
|
||||||
|
// Where we assign the GL viewport
|
||||||
glViewport(_transform._viewport.x, _transform._viewport.y, _transform._viewport.z, _transform._viewport.w);
|
glViewport(_transform._viewport.x, _transform._viewport.y, _transform._viewport.z, _transform._viewport.w);
|
||||||
|
|
||||||
|
// The Viewport is tagged invalid because the CameraTransformUBO is not up to date and willl need update on next drawcall
|
||||||
_transform._invalidViewport = true;
|
_transform._invalidViewport = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,9 +90,6 @@ void GLBackend::updateTransform() {
|
||||||
// Check all the dirty flags and update the state accordingly
|
// Check all the dirty flags and update the state accordingly
|
||||||
if (_transform._invalidViewport) {
|
if (_transform._invalidViewport) {
|
||||||
_transform._transformCamera._viewport = glm::vec4(_transform._viewport);
|
_transform._transformCamera._viewport = glm::vec4(_transform._viewport);
|
||||||
|
|
||||||
// Where we assign the GL viewport
|
|
||||||
glViewport(_transform._viewport.x, _transform._viewport.y, _transform._viewport.z, _transform._viewport.w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_transform._invalidProj) {
|
if (_transform._invalidProj) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
virtual bool getCascadeShadowsEnabled() = 0;
|
virtual bool getCascadeShadowsEnabled() = 0;
|
||||||
|
|
||||||
virtual QThread* getMainThread() = 0;
|
virtual QThread* getMainThread() = 0;
|
||||||
virtual const Transform& getViewTransform() const = 0;
|
|
||||||
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera) = 0;
|
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera) = 0;
|
||||||
virtual float getSizeScale() const = 0;
|
virtual float getSizeScale() const = 0;
|
||||||
virtual int getBoundaryLevelAdjust() const = 0;
|
virtual int getBoundaryLevelAdjust() const = 0;
|
||||||
|
|
Loading…
Reference in a new issue