mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-24 07:13:47 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into controller-dispatcher-1
This commit is contained in:
commit
d78262f2f5
18 changed files with 241 additions and 158 deletions
|
@ -19,6 +19,7 @@ Flickable {
|
||||||
|
|
||||||
signal newViewRequestedCallback(var request)
|
signal newViewRequestedCallback(var request)
|
||||||
signal loadingChangedCallback(var loadRequest)
|
signal loadingChangedCallback(var loadRequest)
|
||||||
|
pressDelay: 300
|
||||||
|
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
|
||||||
|
@ -167,4 +168,11 @@ Flickable {
|
||||||
playing: visible
|
playing: visible
|
||||||
z: 10000
|
z: 10000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onWheel: {
|
||||||
|
flick.flick(0, wheel.angleDelta.y*10)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,12 +40,20 @@ Rectangle {
|
||||||
Hifi.QmlCommerce {
|
Hifi.QmlCommerce {
|
||||||
id: commerce;
|
id: commerce;
|
||||||
|
|
||||||
|
onAccountResult: {
|
||||||
|
if (result.status === "success") {
|
||||||
|
commerce.getKeyFilePathIfExists();
|
||||||
|
} else {
|
||||||
|
// unsure how to handle a failure here. We definitely cannot proceed.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onLoginStatusResult: {
|
onLoginStatusResult: {
|
||||||
if (!isLoggedIn && root.activeView !== "needsLogIn") {
|
if (!isLoggedIn && root.activeView !== "needsLogIn") {
|
||||||
root.activeView = "needsLogIn";
|
root.activeView = "needsLogIn";
|
||||||
} else if (isLoggedIn) {
|
} else if (isLoggedIn) {
|
||||||
root.activeView = "initialize";
|
root.activeView = "initialize";
|
||||||
commerce.getKeyFilePathIfExists();
|
commerce.account();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,20 @@ Rectangle {
|
||||||
Hifi.QmlCommerce {
|
Hifi.QmlCommerce {
|
||||||
id: commerce;
|
id: commerce;
|
||||||
|
|
||||||
|
onAccountResult: {
|
||||||
|
if (result.status === "success") {
|
||||||
|
commerce.getKeyFilePathIfExists();
|
||||||
|
} else {
|
||||||
|
// unsure how to handle a failure here. We definitely cannot proceed.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onLoginStatusResult: {
|
onLoginStatusResult: {
|
||||||
if (!isLoggedIn && root.activeView !== "needsLogIn") {
|
if (!isLoggedIn && root.activeView !== "needsLogIn") {
|
||||||
root.activeView = "needsLogIn";
|
root.activeView = "needsLogIn";
|
||||||
} else if (isLoggedIn) {
|
} else if (isLoggedIn) {
|
||||||
root.activeView = "initialize";
|
root.activeView = "initialize";
|
||||||
commerce.getKeyFilePathIfExists();
|
commerce.account();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,13 @@
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <openssl/aes.h>
|
#include <openssl/aes.h>
|
||||||
|
|
||||||
|
// I know, right? But per https://www.openssl.org/docs/faq.html
|
||||||
|
// this avoids OPENSSL_Uplink(00007FF847238000,08): no OPENSSL_Applink
|
||||||
|
// at runtime.
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <openssl/applink.c>
|
||||||
|
#endif
|
||||||
|
|
||||||
static const char* KEY_FILE = "hifikey";
|
static const char* KEY_FILE = "hifikey";
|
||||||
static const char* IMAGE_FILE = "hifi_image"; // eventually this will live in keyfile
|
static const char* IMAGE_FILE = "hifi_image"; // eventually this will live in keyfile
|
||||||
|
|
||||||
|
|
|
@ -144,25 +144,33 @@ int main(int argc, const char* argv[]) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME this method of checking the OpenGL version screws up the `QOpenGLContext::globalShareContext()` value, which in turn
|
||||||
|
// leads to crashes when creating the real OpenGL instance. Disabling for now until we come up with a better way of checking
|
||||||
|
// the GL version on the system without resorting to creating a full Qt application
|
||||||
|
#if 0
|
||||||
// Check OpenGL version.
|
// Check OpenGL version.
|
||||||
// This is done separately from the main Application so that start-up and shut-down logic within the main Application is
|
// This is done separately from the main Application so that start-up and shut-down logic within the main Application is
|
||||||
// not made more complicated than it already is.
|
// not made more complicated than it already is.
|
||||||
bool override = false;
|
bool overrideGLCheck = false;
|
||||||
|
|
||||||
QJsonObject glData;
|
QJsonObject glData;
|
||||||
{
|
{
|
||||||
OpenGLVersionChecker openGLVersionChecker(argc, const_cast<char**>(argv));
|
OpenGLVersionChecker openGLVersionChecker(argc, const_cast<char**>(argv));
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
glData = openGLVersionChecker.checkVersion(valid, override);
|
glData = openGLVersionChecker.checkVersion(valid, overrideGLCheck);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
if (override) {
|
if (overrideGLCheck) {
|
||||||
auto glVersion = glData["version"].toString();
|
auto glVersion = glData["version"].toString();
|
||||||
qCDebug(interfaceapp, "Running on insufficient OpenGL version: %s.", glVersion.toStdString().c_str());
|
qCWarning(interfaceapp, "Running on insufficient OpenGL version: %s.", glVersion.toStdString().c_str());
|
||||||
} else {
|
} else {
|
||||||
qCDebug(interfaceapp, "Early exit due to OpenGL version.");
|
qCWarning(interfaceapp, "Early exit due to OpenGL version.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Debug option to demonstrate that the client's local time does not
|
// Debug option to demonstrate that the client's local time does not
|
||||||
// need to be in sync with any other network node. This forces clock
|
// need to be in sync with any other network node. This forces clock
|
||||||
|
@ -223,8 +231,9 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
Application app(argcExtended, const_cast<char**>(argvExtended.data()), startupTime, runningMarkerExisted);
|
Application app(argcExtended, const_cast<char**>(argvExtended.data()), startupTime, runningMarkerExisted);
|
||||||
|
|
||||||
|
#if 0
|
||||||
// If we failed the OpenGLVersion check, log it.
|
// If we failed the OpenGLVersion check, log it.
|
||||||
if (override) {
|
if (overrideGLcheck) {
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
if (accountManager->isLoggedIn()) {
|
if (accountManager->isLoggedIn()) {
|
||||||
UserActivityLogger::getInstance().insufficientGLVersion(glData);
|
UserActivityLogger::getInstance().insufficientGLVersion(glData);
|
||||||
|
@ -238,6 +247,8 @@ int main(int argc, const char* argv[]) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Setup local server
|
// Setup local server
|
||||||
QLocalServer server { &app };
|
QLocalServer server { &app };
|
||||||
|
|
|
@ -91,7 +91,12 @@ void entitiesScriptEngineDeleter(ScriptEngine* engine) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wait for the scripting thread from the thread pool to avoid hanging the main thread
|
// Wait for the scripting thread from the thread pool to avoid hanging the main thread
|
||||||
QThreadPool::globalInstance()->start(new WaitRunnable(engine));
|
auto threadPool = QThreadPool::globalInstance();
|
||||||
|
if (threadPool) {
|
||||||
|
threadPool->start(new WaitRunnable(engine));
|
||||||
|
} else {
|
||||||
|
delete engine;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::resetEntitiesScriptEngine() {
|
void EntityTreeRenderer::resetEntitiesScriptEngine() {
|
||||||
|
|
|
@ -91,20 +91,27 @@ void ParticleEffectEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePoi
|
||||||
qCWarning(entitiesrenderer) << "Bad particle properties";
|
qCWarning(entitiesrenderer) << "Bad particle properties";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_particleProperties != newParticleProperties) {
|
|
||||||
|
if (resultWithReadLock<bool>([&]{ return _particleProperties != newParticleProperties; })) {
|
||||||
_timeUntilNextEmit = 0;
|
_timeUntilNextEmit = 0;
|
||||||
|
withWriteLock([&]{
|
||||||
_particleProperties = newParticleProperties;
|
_particleProperties = newParticleProperties;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
_emitting = entity->getIsEmitting();
|
_emitting = entity->getIsEmitting();
|
||||||
|
|
||||||
if (_particleProperties.textures.isEmpty()) {
|
bool hasTexture = resultWithReadLock<bool>([&]{ return _particleProperties.textures.isEmpty(); });
|
||||||
|
if (hasTexture) {
|
||||||
if (_networkTexture) {
|
if (_networkTexture) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_networkTexture.reset();
|
_networkTexture.reset();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!_networkTexture || _networkTexture->getURL() != QUrl(_particleProperties.textures)) {
|
bool textureNeedsUpdate = resultWithReadLock<bool>([&]{
|
||||||
|
return !_networkTexture || _networkTexture->getURL() != QUrl(_particleProperties.textures);
|
||||||
|
});
|
||||||
|
if (textureNeedsUpdate) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_networkTexture = DependencyManager::get<TextureCache>()->getTexture(_particleProperties.textures);
|
_networkTexture = DependencyManager::get<TextureCache>()->getTexture(_particleProperties.textures);
|
||||||
});
|
});
|
||||||
|
@ -115,6 +122,7 @@ void ParticleEffectEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePoi
|
||||||
void ParticleEffectEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
void ParticleEffectEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||||
// Fill in Uniforms structure
|
// Fill in Uniforms structure
|
||||||
ParticleUniforms particleUniforms;
|
ParticleUniforms particleUniforms;
|
||||||
|
withReadLock([&]{
|
||||||
particleUniforms.radius.start = _particleProperties.radius.range.start;
|
particleUniforms.radius.start = _particleProperties.radius.range.start;
|
||||||
particleUniforms.radius.middle = _particleProperties.radius.gradient.target;
|
particleUniforms.radius.middle = _particleProperties.radius.gradient.target;
|
||||||
particleUniforms.radius.finish = _particleProperties.radius.range.finish;
|
particleUniforms.radius.finish = _particleProperties.radius.range.finish;
|
||||||
|
@ -124,6 +132,7 @@ void ParticleEffectEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEn
|
||||||
particleUniforms.color.finish = _particleProperties.getColorFinish();
|
particleUniforms.color.finish = _particleProperties.getColorFinish();
|
||||||
particleUniforms.color.spread = _particleProperties.getColorSpread();
|
particleUniforms.color.spread = _particleProperties.getColorSpread();
|
||||||
particleUniforms.lifespan = _particleProperties.lifespan;
|
particleUniforms.lifespan = _particleProperties.lifespan;
|
||||||
|
});
|
||||||
// Update particle uniforms
|
// Update particle uniforms
|
||||||
memcpy(&_uniformBuffer.edit<ParticleUniforms>(), &particleUniforms, sizeof(ParticleUniforms));
|
memcpy(&_uniformBuffer.edit<ParticleUniforms>(), &particleUniforms, sizeof(ParticleUniforms));
|
||||||
}
|
}
|
||||||
|
@ -146,35 +155,26 @@ Item::Bound ParticleEffectEntityRenderer::getBound() {
|
||||||
|
|
||||||
static const size_t VERTEX_PER_PARTICLE = 4;
|
static const size_t VERTEX_PER_PARTICLE = 4;
|
||||||
|
|
||||||
bool ParticleEffectEntityRenderer::emitting() const {
|
ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createParticle(uint64_t now, const Transform& baseTransform, const particle::Properties& particleProperties) {
|
||||||
return (
|
|
||||||
_emitting &&
|
|
||||||
_particleProperties.emission.rate > 0.0f &&
|
|
||||||
_particleProperties.lifespan > 0.0f &&
|
|
||||||
_particleProperties.polar.start <= _particleProperties.polar.finish
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleEffectEntityRenderer::createParticle(uint64_t now) {
|
|
||||||
CpuParticle particle;
|
CpuParticle particle;
|
||||||
|
|
||||||
const auto& accelerationSpread = _particleProperties.emission.acceleration.spread;
|
const auto& accelerationSpread = particleProperties.emission.acceleration.spread;
|
||||||
const auto& azimuthStart = _particleProperties.azimuth.start;
|
const auto& azimuthStart = particleProperties.azimuth.start;
|
||||||
const auto& azimuthFinish = _particleProperties.azimuth.finish;
|
const auto& azimuthFinish = particleProperties.azimuth.finish;
|
||||||
const auto& emitDimensions = _particleProperties.emission.dimensions;
|
const auto& emitDimensions = particleProperties.emission.dimensions;
|
||||||
const auto& emitAcceleration = _particleProperties.emission.acceleration.target;
|
const auto& emitAcceleration = particleProperties.emission.acceleration.target;
|
||||||
auto emitOrientation = _particleProperties.emission.orientation;
|
auto emitOrientation = particleProperties.emission.orientation;
|
||||||
const auto& emitRadiusStart = glm::max(_particleProperties.radiusStart, EPSILON); // Avoid math complications at center
|
const auto& emitRadiusStart = glm::max(particleProperties.radiusStart, EPSILON); // Avoid math complications at center
|
||||||
const auto& emitSpeed = _particleProperties.emission.speed.target;
|
const auto& emitSpeed = particleProperties.emission.speed.target;
|
||||||
const auto& speedSpread = _particleProperties.emission.speed.spread;
|
const auto& speedSpread = particleProperties.emission.speed.spread;
|
||||||
const auto& polarStart = _particleProperties.polar.start;
|
const auto& polarStart = particleProperties.polar.start;
|
||||||
const auto& polarFinish = _particleProperties.polar.finish;
|
const auto& polarFinish = particleProperties.polar.finish;
|
||||||
|
|
||||||
particle.seed = randFloatInRange(-1.0f, 1.0f);
|
particle.seed = randFloatInRange(-1.0f, 1.0f);
|
||||||
particle.expiration = now + (uint64_t)(_particleProperties.lifespan * USECS_PER_SECOND);
|
particle.expiration = now + (uint64_t)(particleProperties.lifespan * USECS_PER_SECOND);
|
||||||
if (_particleProperties.emission.shouldTrail) {
|
if (particleProperties.emission.shouldTrail) {
|
||||||
particle.position = _modelTransform.getTranslation();
|
particle.position = baseTransform.getTranslation();
|
||||||
emitOrientation = _modelTransform.getRotation() * emitOrientation;
|
emitOrientation = baseTransform.getRotation() * emitOrientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position, velocity, and acceleration
|
// Position, velocity, and acceleration
|
||||||
|
@ -232,7 +232,7 @@ void ParticleEffectEntityRenderer::createParticle(uint64_t now) {
|
||||||
particle.acceleration = emitAcceleration + randFloatInRange(-1.0f, 1.0f) * accelerationSpread;
|
particle.acceleration = emitAcceleration + randFloatInRange(-1.0f, 1.0f) * accelerationSpread;
|
||||||
}
|
}
|
||||||
|
|
||||||
_cpuParticles.push_back(particle);
|
return particle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEffectEntityRenderer::stepSimulation() {
|
void ParticleEffectEntityRenderer::stepSimulation() {
|
||||||
|
@ -245,13 +245,18 @@ void ParticleEffectEntityRenderer::stepSimulation() {
|
||||||
const auto interval = std::min<uint64_t>(USECS_PER_SECOND / 60, now - _lastSimulated);
|
const auto interval = std::min<uint64_t>(USECS_PER_SECOND / 60, now - _lastSimulated);
|
||||||
_lastSimulated = now;
|
_lastSimulated = now;
|
||||||
|
|
||||||
if (emitting()) {
|
particle::Properties particleProperties;
|
||||||
uint64_t emitInterval = (uint64_t)(USECS_PER_SECOND / _particleProperties.emission.rate);
|
withReadLock([&]{
|
||||||
if (interval >= _timeUntilNextEmit) {
|
particleProperties = _particleProperties;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (_emitting && particleProperties.emitting()) {
|
||||||
|
uint64_t emitInterval = particleProperties.emitIntervalUsecs();
|
||||||
|
if (emitInterval > 0 && interval >= _timeUntilNextEmit) {
|
||||||
auto timeRemaining = interval;
|
auto timeRemaining = interval;
|
||||||
while (timeRemaining > _timeUntilNextEmit) {
|
while (timeRemaining > _timeUntilNextEmit) {
|
||||||
// emit particle
|
// emit particle
|
||||||
createParticle(now);
|
_cpuParticles.push_back(createParticle(now, _modelTransform, particleProperties));
|
||||||
_timeUntilNextEmit = emitInterval;
|
_timeUntilNextEmit = emitInterval;
|
||||||
if (emitInterval < timeRemaining) {
|
if (emitInterval < timeRemaining) {
|
||||||
timeRemaining -= emitInterval;
|
timeRemaining -= emitInterval;
|
||||||
|
@ -263,7 +268,7 @@ void ParticleEffectEntityRenderer::stepSimulation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill any particles that have expired or are over the max size
|
// Kill any particles that have expired or are over the max size
|
||||||
while (_cpuParticles.size() > _particleProperties.maxParticles || (!_cpuParticles.empty() && _cpuParticles.front().expiration <= now)) {
|
while (_cpuParticles.size() > particleProperties.maxParticles || (!_cpuParticles.empty() && _cpuParticles.front().expiration <= now)) {
|
||||||
_cpuParticles.pop_front();
|
_cpuParticles.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,9 +93,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void createParticle(uint64_t now);
|
static CpuParticle createParticle(uint64_t now, const Transform& baseTransform, const particle::Properties& particleProperties);
|
||||||
void stepSimulation();
|
void stepSimulation();
|
||||||
bool emitting() const;
|
|
||||||
|
|
||||||
particle::Properties _particleProperties;
|
particle::Properties _particleProperties;
|
||||||
CpuParticles _cpuParticles;
|
CpuParticles _cpuParticles;
|
||||||
|
|
|
@ -30,14 +30,11 @@ TextEntityRenderer::TextEntityRenderer(const EntityItemPointer& entity) :
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextEntityRenderer::~TextEntityRenderer() {
|
||||||
void TextEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity) {
|
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
if (_geometryID && geometryCache) {
|
if (_geometryID && geometryCache) {
|
||||||
geometryCache->releaseID(_geometryID);
|
geometryCache->releaseID(_geometryID);
|
||||||
}
|
}
|
||||||
delete _textRenderer;
|
|
||||||
_textRenderer = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
|
bool TextEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
|
||||||
|
|
|
@ -24,14 +24,13 @@ class TextEntityRenderer : public TypedEntityRenderer<TextEntityItem> {
|
||||||
using Pointer = std::shared_ptr<TextEntityRenderer>;
|
using Pointer = std::shared_ptr<TextEntityRenderer>;
|
||||||
public:
|
public:
|
||||||
TextEntityRenderer(const EntityItemPointer& entity);
|
TextEntityRenderer(const EntityItemPointer& entity);
|
||||||
|
~TextEntityRenderer();
|
||||||
private:
|
private:
|
||||||
virtual void onRemoveFromSceneTyped(const TypedEntityPointer& entity) override;
|
|
||||||
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
|
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
|
||||||
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
|
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
|
||||||
virtual void doRender(RenderArgs* args) override;
|
virtual void doRender(RenderArgs* args) override;
|
||||||
int _geometryID{ 0 };
|
int _geometryID{ 0 };
|
||||||
TextRenderer3D* _textRenderer;
|
std::shared_ptr<TextRenderer3D> _textRenderer;
|
||||||
bool _faceCamera;
|
bool _faceCamera;
|
||||||
glm::vec3 _dimensions;
|
glm::vec3 _dimensions;
|
||||||
glm::vec3 _textColor;
|
glm::vec3 _textColor;
|
||||||
|
|
|
@ -104,7 +104,7 @@ bool operator!=(const Properties& a, const Properties& b) {
|
||||||
return !(a == b);
|
return !(a == b);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool particle::Properties::valid() const {
|
bool Properties::valid() const {
|
||||||
if (glm::any(glm::isnan(emission.orientation))) {
|
if (glm::any(glm::isnan(emission.orientation))) {
|
||||||
qCWarning(entities) << "Bad particle data";
|
qCWarning(entities) << "Bad particle data";
|
||||||
return false;
|
return false;
|
||||||
|
@ -133,6 +133,19 @@ bool particle::Properties::valid() const {
|
||||||
(radius.gradient.spread == glm::clamp(radius.gradient.spread, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS));
|
(radius.gradient.spread == glm::clamp(radius.gradient.spread, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Properties::emitting() const {
|
||||||
|
return emission.rate > 0.0f && lifespan > 0.0f && polar.start <= polar.finish;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Properties::emitIntervalUsecs() const {
|
||||||
|
if (emission.rate > 0.0f) {
|
||||||
|
return (uint64_t)(USECS_PER_SECOND / emission.rate);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
EntityItemPointer entity { new ParticleEffectEntityItem(entityID) };
|
EntityItemPointer entity { new ParticleEffectEntityItem(entityID) };
|
||||||
entity->setProperties(properties);
|
entity->setProperties(properties);
|
||||||
|
|
|
@ -160,6 +160,8 @@ namespace particle {
|
||||||
Properties() {};
|
Properties() {};
|
||||||
Properties(const Properties& other) { *this = other; }
|
Properties(const Properties& other) { *this = other; }
|
||||||
bool valid() const;
|
bool valid() const;
|
||||||
|
bool emitting() const;
|
||||||
|
uint64_t emitIntervalUsecs() const;
|
||||||
|
|
||||||
Properties& operator =(const Properties& other) {
|
Properties& operator =(const Properties& other) {
|
||||||
color = other.color;
|
color = other.color;
|
||||||
|
|
|
@ -40,8 +40,11 @@ const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
|
||||||
|
|
||||||
int glVersionToInteger(QString glVersion) {
|
int glVersionToInteger(QString glVersion) {
|
||||||
QStringList versionParts = glVersion.split(QRegularExpression("[\\.\\s]"));
|
QStringList versionParts = glVersion.split(QRegularExpression("[\\.\\s]"));
|
||||||
int majorNumber = versionParts[0].toInt();
|
int majorNumber = 0, minorNumber = 0;
|
||||||
int minorNumber = versionParts[1].toInt();
|
if (versionParts.size() >= 2) {
|
||||||
|
majorNumber = versionParts[0].toInt();
|
||||||
|
minorNumber = versionParts[1].toInt();
|
||||||
|
}
|
||||||
return (majorNumber << 16) | minorNumber;
|
return (majorNumber << 16) | minorNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -467,6 +467,7 @@ void GLVariableAllocationSupport::updateMemoryPressure() {
|
||||||
_demoteQueue = WorkQueue();
|
_demoteQueue = WorkQueue();
|
||||||
|
|
||||||
// Populate the existing textures into the queue
|
// Populate the existing textures into the queue
|
||||||
|
if (_memoryPressureState != MemoryPressureState::Idle) {
|
||||||
for (const auto& texture : strongTextures) {
|
for (const auto& texture : strongTextures) {
|
||||||
// Race conditions can still leave nulls in the list, so we need to check
|
// Race conditions can still leave nulls in the list, so we need to check
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
|
@ -475,6 +476,7 @@ void GLVariableAllocationSupport::updateMemoryPressure() {
|
||||||
addToWorkQueue(texture);
|
addToWorkQueue(texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TexturePointer GLVariableAllocationSupport::getNextWorkQueueItem(WorkQueue& workQueue) {
|
TexturePointer GLVariableAllocationSupport::getNextWorkQueueItem(WorkQueue& workQueue) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ float Interpolate::simpleNonLinearBlend(float fraction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float Interpolate::calculateFadeRatio(quint64 start) {
|
float Interpolate::calculateFadeRatio(quint64 start) {
|
||||||
const float FADE_TIME = 1.0f;
|
const float FADE_TIME = 0.5f;
|
||||||
float t = 2.0f * std::min(((float)(usecTimestampNow() - start)) / ((float)(FADE_TIME * USECS_PER_SECOND)), 1.0f);
|
float t = 2.0f * std::min(((float)(usecTimestampNow() - start)) / ((float)(FADE_TIME * USECS_PER_SECOND)), 1.0f);
|
||||||
float fadeRatio = (t < 1.0f) ? 0.5f * powf(2.0f, 10.0f * (t - 1.0f)) : 0.5f * (-powf(2.0f, -10.0f * (t - 1.0f)) + 2.0f);
|
float fadeRatio = (t < 1.0f) ? 0.5f * powf(2.0f, 10.0f * (t - 1.0f)) : 0.5f * (-powf(2.0f, -10.0f * (t - 1.0f)) + 2.0f);
|
||||||
|
|
||||||
|
|
|
@ -528,6 +528,12 @@ void OffscreenQmlSurface::create() {
|
||||||
|
|
||||||
connect(_quickWindow, &QQuickWindow::focusObjectChanged, this, &OffscreenQmlSurface::onFocusObjectChanged);
|
connect(_quickWindow, &QQuickWindow::focusObjectChanged, this, &OffscreenQmlSurface::onFocusObjectChanged);
|
||||||
|
|
||||||
|
// acquireEngine interrogates the GL context, so we need to have the context current here
|
||||||
|
if (!_canvas->makeCurrent()) {
|
||||||
|
qFatal("Failed to make context current for QML Renderer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a QML engine.
|
// Create a QML engine.
|
||||||
auto qmlEngine = acquireEngine(_quickWindow);
|
auto qmlEngine = acquireEngine(_quickWindow);
|
||||||
|
|
||||||
|
@ -540,11 +546,6 @@ void OffscreenQmlSurface::create() {
|
||||||
// FIXME Compatibility mechanism for existing HTML and JS that uses eventBridgeWrapper
|
// FIXME Compatibility mechanism for existing HTML and JS that uses eventBridgeWrapper
|
||||||
// Find a way to flag older scripts using this mechanism and wanr that this is deprecated
|
// Find a way to flag older scripts using this mechanism and wanr that this is deprecated
|
||||||
_qmlContext->setContextProperty("eventBridgeWrapper", new EventBridgeWrapper(this, _qmlContext));
|
_qmlContext->setContextProperty("eventBridgeWrapper", new EventBridgeWrapper(this, _qmlContext));
|
||||||
|
|
||||||
if (!_canvas->makeCurrent()) {
|
|
||||||
qWarning("Failed to make context current for QML Renderer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_renderControl->initialize(_canvas->getContext());
|
_renderControl->initialize(_canvas->getContext());
|
||||||
|
|
||||||
// When Quick says there is a need to render, we will not render immediately. Instead,
|
// When Quick says there is a need to render, we will not render immediately. Instead,
|
||||||
|
@ -639,7 +640,7 @@ void OffscreenQmlSurface::setBaseUrl(const QUrl& baseUrl) {
|
||||||
_qmlContext->setBaseUrl(baseUrl);
|
_qmlContext->setBaseUrl(baseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::load(const QUrl& qmlSource, bool createNewContext, std::function<void(QQmlContext*, QObject*)> f) {
|
void OffscreenQmlSurface::load(const QUrl& qmlSource, bool createNewContext, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
qCWarning(uiLogging) << "Called load on a non-surface thread";
|
qCWarning(uiLogging) << "Called load on a non-surface thread";
|
||||||
}
|
}
|
||||||
|
@ -659,28 +660,28 @@ void OffscreenQmlSurface::load(const QUrl& qmlSource, bool createNewContext, std
|
||||||
auto qmlComponent = new QQmlComponent(_qmlContext->engine(), finalQmlSource, QQmlComponent::PreferSynchronous);
|
auto qmlComponent = new QQmlComponent(_qmlContext->engine(), finalQmlSource, QQmlComponent::PreferSynchronous);
|
||||||
if (qmlComponent->isLoading()) {
|
if (qmlComponent->isLoading()) {
|
||||||
connect(qmlComponent, &QQmlComponent::statusChanged, this,
|
connect(qmlComponent, &QQmlComponent::statusChanged, this,
|
||||||
[this, qmlComponent, targetContext, f](QQmlComponent::Status) {
|
[this, qmlComponent, targetContext, onQmlLoadedCallback](QQmlComponent::Status) {
|
||||||
finishQmlLoad(qmlComponent, targetContext, f);
|
finishQmlLoad(qmlComponent, targetContext, onQmlLoadedCallback);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
finishQmlLoad(qmlComponent, targetContext, f);
|
finishQmlLoad(qmlComponent, targetContext, onQmlLoadedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::loadInNewContext(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f) {
|
void OffscreenQmlSurface::loadInNewContext(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback) {
|
||||||
load(qmlSource, true, f);
|
load(qmlSource, true, onQmlLoadedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f) {
|
void OffscreenQmlSurface::load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback) {
|
||||||
load(qmlSource, false, f);
|
load(qmlSource, false, onQmlLoadedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::clearCache() {
|
void OffscreenQmlSurface::clearCache() {
|
||||||
_qmlContext->engine()->clearComponentCache();
|
_qmlContext->engine()->clearComponentCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext* qmlContext, std::function<void(QQmlContext*, QObject*)> f) {
|
void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext* qmlContext, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback) {
|
||||||
disconnect(qmlComponent, &QQmlComponent::statusChanged, this, 0);
|
disconnect(qmlComponent, &QQmlComponent::statusChanged, this, 0);
|
||||||
if (qmlComponent->isError()) {
|
if (qmlComponent->isError()) {
|
||||||
for (const auto& error : qmlComponent->errors()) {
|
for (const auto& error : qmlComponent->errors()) {
|
||||||
|
@ -690,7 +691,6 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QObject* newObject = qmlComponent->beginCreate(qmlContext);
|
QObject* newObject = qmlComponent->beginCreate(qmlContext);
|
||||||
if (qmlComponent->isError()) {
|
if (qmlComponent->isError()) {
|
||||||
for (const auto& error : qmlComponent->errors()) {
|
for (const auto& error : qmlComponent->errors()) {
|
||||||
|
@ -704,7 +704,20 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
}
|
}
|
||||||
|
|
||||||
qmlContext->engine()->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
qmlContext->engine()->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
||||||
f(qmlContext, newObject);
|
|
||||||
|
// All quick items should be focusable
|
||||||
|
QQuickItem* newItem = qobject_cast<QQuickItem*>(newObject);
|
||||||
|
if (newItem) {
|
||||||
|
// Make sure we make items focusable (critical for
|
||||||
|
// supporting keyboard shortcuts)
|
||||||
|
newItem->setFlag(QQuickItem::ItemIsFocusScope, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure we will call callback for this codepath
|
||||||
|
// Call this before qmlComponent->completeCreate() otherwise ghost window appears
|
||||||
|
if (newItem && _rootItem) {
|
||||||
|
onQmlLoadedCallback(qmlContext, newObject);
|
||||||
|
}
|
||||||
|
|
||||||
QObject* eventBridge = qmlContext->contextProperty("eventBridge").value<QObject*>();
|
QObject* eventBridge = qmlContext->contextProperty("eventBridge").value<QObject*>();
|
||||||
if (qmlContext != _qmlContext && eventBridge && eventBridge != this) {
|
if (qmlContext != _qmlContext && eventBridge && eventBridge != this) {
|
||||||
|
@ -716,15 +729,6 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
qmlComponent->completeCreate();
|
qmlComponent->completeCreate();
|
||||||
qmlComponent->deleteLater();
|
qmlComponent->deleteLater();
|
||||||
|
|
||||||
|
|
||||||
// All quick items should be focusable
|
|
||||||
QQuickItem* newItem = qobject_cast<QQuickItem*>(newObject);
|
|
||||||
if (newItem) {
|
|
||||||
// Make sure we make items focusable (critical for
|
|
||||||
// supporting keyboard shortcuts)
|
|
||||||
newItem->setFlag(QQuickItem::ItemIsFocusScope, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we already have a root, just set a couple of flags and the ancestry
|
// If we already have a root, just set a couple of flags and the ancestry
|
||||||
if (newItem && _rootItem) {
|
if (newItem && _rootItem) {
|
||||||
// Allow child windows to be destroyed from JS
|
// Allow child windows to be destroyed from JS
|
||||||
|
@ -747,6 +751,8 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
_rootItem = newItem;
|
_rootItem = newItem;
|
||||||
_rootItem->setParentItem(_quickWindow->contentItem());
|
_rootItem->setParentItem(_quickWindow->contentItem());
|
||||||
_rootItem->setSize(_quickWindow->renderTargetSize());
|
_rootItem->setSize(_quickWindow->renderTargetSize());
|
||||||
|
// Call this callback after rootitem is set, otherwise VrMenu wont work
|
||||||
|
onQmlLoadedCallback(qmlContext, newObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::updateQuick() {
|
void OffscreenQmlSurface::updateQuick() {
|
||||||
|
|
|
@ -50,11 +50,11 @@ public:
|
||||||
void resize(const QSize& size, bool forceResize = false);
|
void resize(const QSize& size, bool forceResize = false);
|
||||||
QSize size() const;
|
QSize size() const;
|
||||||
|
|
||||||
Q_INVOKABLE void load(const QUrl& qmlSource, bool createNewContext, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
Q_INVOKABLE void load(const QUrl& qmlSource, bool createNewContext, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback = [](QQmlContext*, QObject*) {});
|
||||||
Q_INVOKABLE void loadInNewContext(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
Q_INVOKABLE void loadInNewContext(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback = [](QQmlContext*, QObject*) {});
|
||||||
Q_INVOKABLE void load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
Q_INVOKABLE void load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback = [](QQmlContext*, QObject*) {});
|
||||||
Q_INVOKABLE void load(const QString& qmlSourceFile, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}) {
|
Q_INVOKABLE void load(const QString& qmlSourceFile, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback = [](QQmlContext*, QObject*) {}) {
|
||||||
return load(QUrl(qmlSourceFile), f);
|
return load(QUrl(qmlSourceFile), onQmlLoadedCallback);
|
||||||
}
|
}
|
||||||
void clearCache();
|
void clearCache();
|
||||||
void setMaxFps(uint8_t maxFps) { _maxFps = maxFps; }
|
void setMaxFps(uint8_t maxFps) { _maxFps = maxFps; }
|
||||||
|
@ -120,7 +120,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
static QOpenGLContext* getSharedContext();
|
static QOpenGLContext* getSharedContext();
|
||||||
|
|
||||||
void finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext* qmlContext, std::function<void(QQmlContext*, QObject*)> f);
|
void finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext* qmlContext, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback);
|
||||||
QPointF mapWindowToUi(const QPointF& sourcePosition, QObject* sourceObject);
|
QPointF mapWindowToUi(const QPointF& sourcePosition, QObject* sourceObject);
|
||||||
void setupFbo();
|
void setupFbo();
|
||||||
bool allowNewFrame(uint8_t fps);
|
bool allowNewFrame(uint8_t fps);
|
||||||
|
|
|
@ -54,6 +54,25 @@ SDL_JoystickID SDL2Manager::getInstanceId(SDL_GameController* controller) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL2Manager::init() {
|
void SDL2Manager::init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList SDL2Manager::getSubdeviceNames() {
|
||||||
|
return _subdeviceNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDL2Manager::deinit() {
|
||||||
|
_openJoysticks.clear();
|
||||||
|
|
||||||
|
SDL_Quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SDL2Manager::activate() {
|
||||||
|
|
||||||
|
// FIXME for some reason calling this code in the `init` function triggers a crash
|
||||||
|
// on OSX in PR builds, but not on my local debug build. Attempting a workaround by
|
||||||
|
//
|
||||||
|
static std::once_flag once;
|
||||||
|
std::call_once(once, [&]{
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
auto preferences = DependencyManager::get<Preferences>();
|
auto preferences = DependencyManager::get<Preferences>();
|
||||||
|
@ -93,25 +112,16 @@ void SDL2Manager::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_isInitialized = true;
|
_isInitialized = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
qDebug() << "Error initializing SDL2 Manager";
|
qDebug() << "Error initializing SDL2 Manager";
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
QStringList SDL2Manager::getSubdeviceNames() {
|
if (!_isInitialized) {
|
||||||
return _subdeviceNames;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL2Manager::deinit() {
|
|
||||||
_openJoysticks.clear();
|
|
||||||
|
|
||||||
SDL_Quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SDL2Manager::activate() {
|
|
||||||
InputPlugin::activate();
|
InputPlugin::activate();
|
||||||
|
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
for (auto joystick : _openJoysticks) {
|
for (auto joystick : _openJoysticks) {
|
||||||
userInputMapper->registerDevice(joystick);
|
userInputMapper->registerDevice(joystick);
|
||||||
|
|
Loading…
Reference in a new issue