mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-11 17:11:15 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
9626bed8ca
21 changed files with 193 additions and 151 deletions
|
@ -1037,6 +1037,8 @@ void Application::initializeUi() {
|
|||
|
||||
void Application::paintGL() {
|
||||
PROFILE_RANGE(__FUNCTION__);
|
||||
PerformanceTimer perfTimer("paintGL");
|
||||
|
||||
if (nullptr == _displayPlugin) {
|
||||
return;
|
||||
}
|
||||
|
@ -1063,18 +1065,19 @@ void Application::paintGL() {
|
|||
lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
|
||||
RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
|
||||
|
||||
PerformanceTimer perfTimer("paintGL");
|
||||
|
||||
|
||||
PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
|
||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||
PerformanceWarning warn(showWarnings, "Application::paintGL()");
|
||||
resizeGL();
|
||||
|
||||
// Before anything else, let's sync up the gpuContext with the true glcontext used in case anything happened
|
||||
renderArgs._context->syncCache();
|
||||
{
|
||||
PerformanceTimer perfTimer("syncCache");
|
||||
renderArgs._context->syncCache();
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
|
||||
PerformanceTimer perfTimer("Mirror");
|
||||
auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();
|
||||
|
||||
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
||||
|
@ -1088,7 +1091,7 @@ void Application::paintGL() {
|
|||
auto mirrorRectDest = glm::ivec4(mirrorRect.z, mirrorRect.y, mirrorRect.x, mirrorRect.w);
|
||||
|
||||
auto selfieFbo = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer();
|
||||
doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
|
||||
batch.setFramebuffer(selfieFbo);
|
||||
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
batch.blit(primaryFbo, mirrorRect, selfieFbo, mirrorRectDest);
|
||||
|
@ -1106,81 +1109,86 @@ void Application::paintGL() {
|
|||
_applicationOverlay.renderOverlay(&renderArgs);
|
||||
}
|
||||
|
||||
_myAvatar->startCapture();
|
||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
|
||||
Application::getInstance()->cameraMenuChanged();
|
||||
}
|
||||
{
|
||||
PerformanceTimer perfTimer("CameraUpdates");
|
||||
|
||||
// The render mode is default or mirror if the camera is in mirror mode, assigned further below
|
||||
renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
|
||||
|
||||
// Always use the default eye position, not the actual head eye position.
|
||||
// Using the latter will cause the camera to wobble with idle animations,
|
||||
// or with changes from the face tracker
|
||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||
if (isHMDMode()) {
|
||||
mat4 camMat = _myAvatar->getSensorToWorldMatrix() * _myAvatar->getHMDSensorMatrix();
|
||||
_myCamera.setPosition(extractTranslation(camMat));
|
||||
_myCamera.setRotation(glm::quat_cast(camMat));
|
||||
} else {
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition());
|
||||
_myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation());
|
||||
_myAvatar->startCapture();
|
||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
|
||||
Application::getInstance()->cameraMenuChanged();
|
||||
}
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
if (isHMDMode()) {
|
||||
glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix());
|
||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * hmdRotation);
|
||||
// Ignore MenuOption::CenterPlayerInView in HMD view
|
||||
glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix());
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||
+ _myAvatar->getOrientation()
|
||||
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f) + hmdOffset));
|
||||
} else {
|
||||
_myCamera.setRotation(_myAvatar->getHead()->getOrientation());
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||
+ _myCamera.getRotation()
|
||||
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));
|
||||
|
||||
// The render mode is default or mirror if the camera is in mirror mode, assigned further below
|
||||
renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
|
||||
|
||||
// Always use the default eye position, not the actual head eye position.
|
||||
// Using the latter will cause the camera to wobble with idle animations,
|
||||
// or with changes from the face tracker
|
||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||
if (isHMDMode()) {
|
||||
mat4 camMat = _myAvatar->getSensorToWorldMatrix() * _myAvatar->getHMDSensorMatrix();
|
||||
_myCamera.setPosition(extractTranslation(camMat));
|
||||
_myCamera.setRotation(glm::quat_cast(camMat));
|
||||
} else {
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition());
|
||||
_myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation());
|
||||
}
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
if (isHMDMode()) {
|
||||
glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix());
|
||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * hmdRotation);
|
||||
// Ignore MenuOption::CenterPlayerInView in HMD view
|
||||
glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix());
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||
+ _myAvatar->getOrientation()
|
||||
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));
|
||||
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f) + hmdOffset));
|
||||
} else {
|
||||
_myCamera.setRotation(_myAvatar->getHead()->getOrientation());
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||
+ _myCamera.getRotation()
|
||||
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));
|
||||
} else {
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||
+ _myAvatar->getOrientation()
|
||||
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));
|
||||
}
|
||||
}
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
if (isHMDMode()) {
|
||||
glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix());
|
||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()
|
||||
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation);
|
||||
glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix());
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||
+ glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)
|
||||
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
||||
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
|
||||
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset);
|
||||
} else {
|
||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()
|
||||
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||
+ glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)
|
||||
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
||||
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
|
||||
}
|
||||
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
||||
}
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
if (isHMDMode()) {
|
||||
glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix());
|
||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()
|
||||
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation);
|
||||
glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix());
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||
+ glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)
|
||||
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
||||
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
|
||||
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset);
|
||||
} else {
|
||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()
|
||||
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||
+ glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)
|
||||
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
||||
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
|
||||
// Update camera position
|
||||
if (!isHMDMode()) {
|
||||
_myCamera.update(1.0f / _fps);
|
||||
}
|
||||
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
||||
_myAvatar->endCapture();
|
||||
}
|
||||
// Update camera position
|
||||
if (!isHMDMode()) {
|
||||
_myCamera.update(1.0f / _fps);
|
||||
}
|
||||
_myAvatar->endCapture();
|
||||
|
||||
// Primary rendering pass
|
||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||
const QSize size = framebufferCache->getFrameBufferSize();
|
||||
{
|
||||
PROFILE_RANGE(__FUNCTION__ "/mainRender");
|
||||
PerformanceTimer perfTimer("mainRender");
|
||||
// Viewport is assigned to the size of the framebuffer
|
||||
renderArgs._viewport = ivec4(0, 0, size.width(), size.height());
|
||||
if (displayPlugin->isStereo()) {
|
||||
|
@ -1217,7 +1225,7 @@ void Application::paintGL() {
|
|||
}
|
||||
displaySide(&renderArgs, _myCamera);
|
||||
renderArgs._context->enableStereo(false);
|
||||
doInBatch(renderArgs._context, [](gpu::Batch& batch) {
|
||||
gpu::doInBatch(renderArgs._context, [](gpu::Batch& batch) {
|
||||
batch.setFramebuffer(nullptr);
|
||||
});
|
||||
}
|
||||
|
@ -1225,6 +1233,7 @@ void Application::paintGL() {
|
|||
// Overlay Composition, needs to occur after screen space effects have completed
|
||||
{
|
||||
PROFILE_RANGE(__FUNCTION__ "/compositor");
|
||||
PerformanceTimer perfTimer("compositor");
|
||||
auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo));
|
||||
if (displayPlugin->isStereo()) {
|
||||
|
@ -1249,6 +1258,7 @@ void Application::paintGL() {
|
|||
// deliver final composited scene to the display plugin
|
||||
{
|
||||
PROFILE_RANGE(__FUNCTION__ "/pluginOutput");
|
||||
PerformanceTimer perfTimer("pluginOutput");
|
||||
auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
|
||||
GLuint finalTexture = gpu::GLBackend::getTextureID(primaryFbo->getRenderBuffer(0));
|
||||
// Ensure the rendering context commands are completed when rendering
|
||||
|
@ -1266,24 +1276,29 @@ void Application::paintGL() {
|
|||
|
||||
{
|
||||
PROFILE_RANGE(__FUNCTION__ "/pluginDisplay");
|
||||
PerformanceTimer perfTimer("pluginDisplay");
|
||||
displayPlugin->display(finalTexture, toGlm(size));
|
||||
}
|
||||
|
||||
{
|
||||
PROFILE_RANGE(__FUNCTION__ "/bufferSwap");
|
||||
PerformanceTimer perfTimer("bufferSwap");
|
||||
displayPlugin->finishFrame();
|
||||
}
|
||||
}
|
||||
|
||||
_offscreenContext->makeCurrent();
|
||||
_frameCount++;
|
||||
Stats::getInstance()->setRenderDetails(renderArgs._details);
|
||||
{
|
||||
PerformanceTimer perfTimer("makeCurrent");
|
||||
_offscreenContext->makeCurrent();
|
||||
_frameCount++;
|
||||
Stats::getInstance()->setRenderDetails(renderArgs._details);
|
||||
|
||||
// Reset the gpu::Context Stages
|
||||
// Back to the default framebuffer;
|
||||
doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
|
||||
batch.resetStages();
|
||||
});
|
||||
// Reset the gpu::Context Stages
|
||||
// Back to the default framebuffer;
|
||||
gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
|
||||
batch.resetStages();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Application::runTests() {
|
||||
|
|
|
@ -151,6 +151,25 @@ void MyAvatar::reset() {
|
|||
eulers.x = 0.0f;
|
||||
eulers.z = 0.0f;
|
||||
setOrientation(glm::quat(eulers));
|
||||
|
||||
// This should be simpler when we have only graph animations always on.
|
||||
bool isRig = _rig->getEnableRig();
|
||||
bool isGraph = _rig->getEnableAnimGraph();
|
||||
qApp->setRawAvatarUpdateThreading(false);
|
||||
_rig->disableHands = true;
|
||||
setEnableRigAnimations(true);
|
||||
_skeletonModel.simulate(0.1f); // non-zero
|
||||
setEnableRigAnimations(false);
|
||||
_skeletonModel.simulate(0.1f);
|
||||
if (isRig) {
|
||||
setEnableRigAnimations(true);
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::EnableRigAnimations, true);
|
||||
} else if (isGraph) {
|
||||
setEnableAnimGraph(true);
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::EnableAnimGraph, true);
|
||||
}
|
||||
_rig->disableHands = false;
|
||||
qApp->setRawAvatarUpdateThreading();
|
||||
}
|
||||
|
||||
void MyAvatar::update(float deltaTime) {
|
||||
|
|
|
@ -207,7 +207,7 @@ void ApplicationCompositor::displayOverlayTexture(RenderArgs* renderArgs) {
|
|||
updateTooltips();
|
||||
|
||||
//Handle fading and deactivation/activation of UI
|
||||
doInBatch(renderArgs->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(renderArgs->_context, [=](gpu::Batch& batch) {
|
||||
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
|
||||
|
@ -278,7 +278,7 @@ void ApplicationCompositor::displayOverlayTextureHmd(RenderArgs* renderArgs, int
|
|||
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
|
||||
doInBatch(renderArgs->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(renderArgs->_context, [=](gpu::Batch& batch) {
|
||||
geometryCache->useSimpleDrawPipeline(batch);
|
||||
|
||||
batch.setResourceTexture(0, overlayFramebuffer->getRenderBuffer(0));
|
||||
|
|
|
@ -70,29 +70,28 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
|
|||
}
|
||||
|
||||
// Execute the batch into our framebuffer
|
||||
gpu::Batch batch;
|
||||
renderArgs->_batch = &batch;
|
||||
doInBatch(renderArgs->_context, [=](gpu::Batch& batch) {
|
||||
renderArgs->_batch = &batch;
|
||||
|
||||
int width = _overlayFramebuffer->getWidth();
|
||||
int height = _overlayFramebuffer->getHeight();
|
||||
int width = _overlayFramebuffer->getWidth();
|
||||
int height = _overlayFramebuffer->getHeight();
|
||||
|
||||
batch.setViewportTransform(glm::ivec4(0, 0, width, height));
|
||||
batch.setFramebuffer(_overlayFramebuffer);
|
||||
batch.setViewportTransform(glm::ivec4(0, 0, width, height));
|
||||
batch.setFramebuffer(_overlayFramebuffer);
|
||||
|
||||
glm::vec4 color { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
float depth = 1.0f;
|
||||
int stencil = 0;
|
||||
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH, color, depth, stencil);
|
||||
glm::vec4 color { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
float depth = 1.0f;
|
||||
int stencil = 0;
|
||||
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH, color, depth, stencil);
|
||||
|
||||
// Now render the overlay components together into a single texture
|
||||
renderDomainConnectionStatusBorder(renderArgs); // renders the connected domain line
|
||||
renderAudioScope(renderArgs); // audio scope in the very back
|
||||
renderRearView(renderArgs); // renders the mirror view selfie
|
||||
renderQmlUi(renderArgs); // renders a unit quad with the QML UI texture, and the text overlays from scripts
|
||||
renderOverlays(renderArgs); // renders Scripts Overlay and AudioScope
|
||||
renderStatsAndLogs(renderArgs); // currently renders nothing
|
||||
|
||||
renderArgs->_context->render(batch);
|
||||
// Now render the overlay components together into a single texture
|
||||
renderDomainConnectionStatusBorder(renderArgs); // renders the connected domain line
|
||||
renderAudioScope(renderArgs); // audio scope in the very back
|
||||
renderRearView(renderArgs); // renders the mirror view selfie
|
||||
renderQmlUi(renderArgs); // renders a unit quad with the QML UI texture, and the text overlays from scripts
|
||||
renderOverlays(renderArgs); // renders Scripts Overlay and AudioScope
|
||||
renderStatsAndLogs(renderArgs); // currently renders nothing
|
||||
});
|
||||
|
||||
renderArgs->_batch = nullptr; // so future users of renderArgs don't try to use our batch
|
||||
|
||||
|
|
|
@ -738,7 +738,7 @@ void Rig::inverseKinematics(int endIndex, glm::vec3 targetPosition, const glm::q
|
|||
return;
|
||||
}
|
||||
|
||||
if (_enableAnimGraph && _animSkeleton) {
|
||||
if (disableHands || (_enableAnimGraph && _animSkeleton)) {
|
||||
// the hand data goes through a different path: Rig::updateFromHandParameters() --> early-exit
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -193,6 +193,7 @@ public:
|
|||
|
||||
AnimNode::ConstPointer getAnimNode() const { return _animNode; }
|
||||
AnimSkeleton::ConstPointer getAnimSkeleton() const { return _animSkeleton; }
|
||||
bool disableHands {false}; // should go away with rig animation (and Rig::inverseKinematics)
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -682,9 +682,9 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
|||
}
|
||||
updateRadius(i, 0.0f);
|
||||
|
||||
// Velocity and acceleration
|
||||
if (_polarStart == 0.0f && _polarFinish == 0.0f) {
|
||||
// Emit along z-axis
|
||||
// Position, velocity, and acceleration
|
||||
if (_polarStart == 0.0f && _polarFinish == 0.0f && _emitDimensions.z == 0.0f) {
|
||||
// Emit along z-axis from position
|
||||
_particlePositions[i] = getPosition();
|
||||
_particleVelocities[i] =
|
||||
(_emitSpeed + (2.0f * randFloat() - 1.0f) * _speedSpread) * (_emitOrientation * Z_AXIS);
|
||||
|
@ -711,10 +711,10 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
|||
|
||||
if (_emitDimensions == glm::vec3()) {
|
||||
// Point
|
||||
emitDirection = _emitOrientation * fromSpherical(elevation, azimuth);
|
||||
emitDirection = glm::angleAxis(PI_OVER_TWO - elevation, X_AXIS) * Z_AXIS;
|
||||
emitDirection = glm::angleAxis(azimuth, Z_AXIS) * emitDirection;
|
||||
|
||||
_particlePositions[i] = getPosition();
|
||||
|
||||
} else {
|
||||
// Ellipsoid
|
||||
float radiusScale = 1.0f;
|
||||
|
@ -730,9 +730,9 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
|||
float z = radiuses.z * glm::sin(elevation);
|
||||
glm::vec3 emitPosition = glm::vec3(x, y, z);
|
||||
emitDirection = glm::normalize(glm::vec3(
|
||||
x / (radiuses.x * radiuses.x),
|
||||
y / (radiuses.y * radiuses.y),
|
||||
z / (radiuses.z * radiuses.z)
|
||||
radiuses.x > 0.0f ? x / (radiuses.x * radiuses.x) : 0.0f,
|
||||
radiuses.y > 0.0f ? y / (radiuses.y * radiuses.y) : 0.0f,
|
||||
radiuses.z > 0.0f ? z / (radiuses.z * radiuses.z) : 0.0f
|
||||
));
|
||||
|
||||
_particlePositions[i] = getPosition() + _emitOrientation * emitPosition;
|
||||
|
|
|
@ -215,8 +215,6 @@ protected:
|
|||
};
|
||||
typedef std::shared_ptr<Context> ContextPointer;
|
||||
|
||||
};
|
||||
|
||||
template<typename F>
|
||||
void doInBatch(std::shared_ptr<gpu::Context> context, F f) {
|
||||
static gpu::Batch::CacheState cacheState;
|
||||
|
@ -226,4 +224,7 @@ void doInBatch(std::shared_ptr<gpu::Context> context, F f) {
|
|||
cacheState = batch.getCacheState();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -173,7 +173,7 @@ void ViveControllerManager::updateRendering(RenderArgs* args, render::ScenePoint
|
|||
UserInputMapper::PoseValue leftHand = _poseStateMap[makeInput(JointChannel::LEFT_HAND).getChannel()];
|
||||
UserInputMapper::PoseValue rightHand = _poseStateMap[makeInput(JointChannel::RIGHT_HAND).getChannel()];
|
||||
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
geometryCache->useSimpleDrawPipeline(batch);
|
||||
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, true);
|
||||
|
|
|
@ -179,7 +179,7 @@ void AmbientOcclusion::run(const render::SceneContextPointer& sceneContext, cons
|
|||
assert(renderContext->args->_viewFrustum);
|
||||
|
||||
RenderArgs* args = renderContext->args;
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||
QSize framebufferSize = framebufferCache->getFrameBufferSize();
|
||||
float fbWidth = framebufferSize.width();
|
||||
|
|
|
@ -101,7 +101,7 @@ void Antialiasing::run(const render::SceneContextPointer& sceneContext, const re
|
|||
}
|
||||
|
||||
RenderArgs* args = renderContext->args;
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
batch.enableStereo(false);
|
||||
|
||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||
|
|
|
@ -340,7 +340,7 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu
|
|||
}
|
||||
|
||||
void DeferredLightingEffect::prepare(RenderArgs* args) {
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
batch.enableStereo(false);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
|
||||
|
@ -357,7 +357,7 @@ void DeferredLightingEffect::prepare(RenderArgs* args) {
|
|||
gpu::FramebufferPointer _copyFBO;
|
||||
|
||||
void DeferredLightingEffect::render(RenderArgs* args) {
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
|
||||
// Allocate the parameters buffer used by all the deferred shaders
|
||||
if (!_deferredTransformBuffer[0]._buffer) {
|
||||
|
@ -685,7 +685,7 @@ void DeferredLightingEffect::render(RenderArgs* args) {
|
|||
|
||||
void DeferredLightingEffect::copyBack(RenderArgs* args) {
|
||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
batch.enableStereo(false);
|
||||
QSize framebufferSize = framebufferCache->getFrameBufferSize();
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ void HitEffect::run(const render::SceneContextPointer& sceneContext, const rende
|
|||
assert(renderContext->args);
|
||||
assert(renderContext->args->_viewFrustum);
|
||||
RenderArgs* args = renderContext->args;
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
|
||||
glm::mat4 projMat;
|
||||
Transform viewMat;
|
||||
|
|
|
@ -1272,6 +1272,8 @@ void Model::simulateInternal(float deltaTime) {
|
|||
updateRig(deltaTime, parentTransform);
|
||||
}
|
||||
void Model::updateClusterMatrices() {
|
||||
PerformanceTimer perfTimer("Model::updateClusterMatrices");
|
||||
|
||||
if (!_needsUpdateClusterMatrices) {
|
||||
return;
|
||||
}
|
||||
|
@ -1528,6 +1530,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape
|
|||
|
||||
{
|
||||
if (!_showTrueJointTransforms) {
|
||||
PerformanceTimer perfTimer("_rig->updateVisibleJointStates()");
|
||||
_rig->updateVisibleJointStates();
|
||||
} // else no need to update visible transforms
|
||||
}
|
||||
|
@ -1692,6 +1695,8 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape
|
|||
|
||||
// TODO: We should be able to do that just in the renderTransparentJob
|
||||
if (translucentMesh && locations->lightBufferUnit >= 0) {
|
||||
PerformanceTimer perfTimer("DLE->setupTransparent()");
|
||||
|
||||
DependencyManager::get<DeferredLightingEffect>()->setupTransparent(args, locations->lightBufferUnit);
|
||||
}
|
||||
|
||||
|
@ -1702,8 +1707,11 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape
|
|||
}
|
||||
}
|
||||
|
||||
batch.setIndexBuffer(gpu::UINT32, part.getMergedTriangles(), 0);
|
||||
batch.drawIndexed(gpu::TRIANGLES, part.mergedTrianglesIndicesCount, 0);
|
||||
{
|
||||
PerformanceTimer perfTimer("batch.drawIndexed()");
|
||||
batch.setIndexBuffer(gpu::UINT32, part.getMergedTriangles(), 0);
|
||||
batch.drawIndexed(gpu::TRIANGLES, part.mergedTrianglesIndicesCount, 0);
|
||||
}
|
||||
|
||||
if (args) {
|
||||
const int INDICES_PER_TRIANGLE = 3;
|
||||
|
@ -1743,6 +1751,9 @@ void Model::pickPrograms(gpu::Batch& batch, RenderMode mode, bool translucent, f
|
|||
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, bool isWireframe, RenderArgs* args,
|
||||
Locations*& locations) {
|
||||
|
||||
PerformanceTimer perfTimer("Model::pickPrograms");
|
||||
|
||||
|
||||
RenderKey key(mode, translucent, alphaThreshold, hasLightmap, hasTangents, hasSpecular, isSkinned, isWireframe);
|
||||
if (mode == RenderArgs::MIRROR_RENDER_MODE) {
|
||||
key = RenderKey(key.getRaw() | RenderKey::IS_MIRROR);
|
||||
|
|
|
@ -32,7 +32,7 @@ using namespace render;
|
|||
|
||||
void SetupDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
||||
RenderArgs* args = renderContext->args;
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
|
||||
auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();
|
||||
|
||||
|
@ -166,7 +166,7 @@ void DrawOpaqueDeferred::run(const SceneContextPointer& sceneContext, const Rend
|
|||
assert(renderContext->args->_viewFrustum);
|
||||
|
||||
RenderArgs* args = renderContext->args;
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
args->_batch = &batch;
|
||||
|
@ -195,7 +195,7 @@ void DrawTransparentDeferred::run(const SceneContextPointer& sceneContext, const
|
|||
assert(renderContext->args->_viewFrustum);
|
||||
|
||||
RenderArgs* args = renderContext->args;
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
args->_batch = &batch;
|
||||
|
@ -267,7 +267,7 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon
|
|||
}
|
||||
|
||||
// Render the items
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
args->_batch = &batch;
|
||||
args->_whiteTexture = DependencyManager::get<TextureCache>()->getWhiteTexture();
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ void DrawStatus::run(const SceneContextPointer& sceneContext, const RenderContex
|
|||
}
|
||||
|
||||
// Allright, something to render let's do it
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
glm::mat4 projMat;
|
||||
Transform viewMat;
|
||||
args->_viewFrustum->evalProjectionMatrix(projMat);
|
||||
|
|
|
@ -236,7 +236,7 @@ void DrawLight::run(const SceneContextPointer& sceneContext, const RenderContext
|
|||
cullItems(sceneContext, renderContext, inItems, culledItems);
|
||||
|
||||
RenderArgs* args = renderContext->args;
|
||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||
args->_batch = &batch;
|
||||
renderItems(sceneContext, renderContext, culledItems);
|
||||
});
|
||||
|
|
|
@ -58,3 +58,27 @@ glm::vec3 Vec3::toPolar(const glm::vec3& v) {
|
|||
|
||||
return glm::vec3(elevation, azimuth, radius);
|
||||
}
|
||||
|
||||
glm::vec3 Vec3::fromPolar(const glm::vec3& polar) {
|
||||
float x = glm::cos(polar.x) * glm::sin(polar.y);
|
||||
float y = glm::sin(-polar.x);
|
||||
float z = glm::cos(polar.x) * glm::cos(polar.y);
|
||||
|
||||
// Round small values to 0
|
||||
if (glm::abs(x) < EPSILON) {
|
||||
x = 0.0f;
|
||||
}
|
||||
if (glm::abs(y) < EPSILON) {
|
||||
y = 0.0f;
|
||||
}
|
||||
if (glm::abs(z) < EPSILON) {
|
||||
z = 0.0f;
|
||||
}
|
||||
|
||||
return polar.z * glm::vec3(x, y, z);
|
||||
}
|
||||
|
||||
glm::vec3 Vec3::fromPolar(float elevation, float azimuth) {
|
||||
glm::vec3 v = glm::vec3(elevation, azimuth, 1.0f);
|
||||
return fromPolar(v);
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ public slots:
|
|||
bool withinEpsilon(const glm::vec3& v1, const glm::vec3& v2, float epsilon);
|
||||
// FIXME misnamed, should be 'spherical' or 'euler' depending on the implementation
|
||||
glm::vec3 toPolar(const glm::vec3& v);
|
||||
glm::vec3 fromPolar(const glm::vec3& polar) { return fromSpherical(polar); }
|
||||
glm::vec3 fromPolar(float elevation, float azimuth) { return fromSpherical(elevation, azimuth); }
|
||||
glm::vec3 fromPolar(const glm::vec3& polar);
|
||||
glm::vec3 fromPolar(float elevation, float azimuth);
|
||||
const glm::vec3& UNIT_X() { return Vectors::UNIT_X; }
|
||||
const glm::vec3& UNIT_Y() { return Vectors::UNIT_Y; }
|
||||
const glm::vec3& UNIT_Z() { return Vectors::UNIT_Z; }
|
||||
|
|
|
@ -225,30 +225,6 @@ glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2) {
|
|||
return glm::angleAxis(angle, axis);
|
||||
}
|
||||
|
||||
glm::vec3 fromSpherical(const glm::vec3& spherical) {
|
||||
float x = glm::cos(spherical.x) * glm::sin(spherical.y);
|
||||
float y = glm::sin(-spherical.x);
|
||||
float z = glm::cos(spherical.x) * glm::cos(spherical.y);
|
||||
|
||||
// Round small values to 0
|
||||
if (glm::abs(x) < EPSILON) {
|
||||
x = 0.0f;
|
||||
}
|
||||
if (glm::abs(y) < EPSILON) {
|
||||
y = 0.0f;
|
||||
}
|
||||
if (glm::abs(z) < EPSILON) {
|
||||
z = 0.0f;
|
||||
}
|
||||
|
||||
return spherical.z * glm::vec3(x, y, z);
|
||||
}
|
||||
|
||||
glm::vec3 fromSpherical(float elevation, float azimuth) {
|
||||
glm::vec3 v = glm::vec3(elevation, azimuth, 1.0f);
|
||||
return fromSpherical(v);
|
||||
}
|
||||
|
||||
bool isPointBehindTrianglesPlane(glm::vec3 point, glm::vec3 p0, glm::vec3 p1, glm::vec3 p2) {
|
||||
glm::vec3 v1 = p0 - p1, v2 = p2 - p1; // Non-collinear vectors contained in the plane
|
||||
glm::vec3 n = glm::cross(v1, v2); // Plane's normal vector, pointing out of the triangle
|
||||
|
|
|
@ -117,10 +117,6 @@ float angleBetween(const glm::vec3& v1, const glm::vec3& v2);
|
|||
|
||||
glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2);
|
||||
|
||||
glm::vec3 fromSpherical(const glm::vec3& spherical);
|
||||
|
||||
glm::vec3 fromSpherical(float elevation, float azimuth);
|
||||
|
||||
bool isPointBehindTrianglesPlane(glm::vec3 point, glm::vec3 p0, glm::vec3 p1, glm::vec3 p2);
|
||||
|
||||
glm::vec3 extractTranslation(const glm::mat4& matrix);
|
||||
|
|
Loading…
Reference in a new issue