mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 20:58:38 +02:00
first round of requested changes
This commit is contained in:
parent
de5a0a714b
commit
5c9a88868d
7 changed files with 49 additions and 64 deletions
|
@ -1387,7 +1387,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
});
|
});
|
||||||
connect(this, &Application::activeDisplayPluginChanged,
|
connect(this, &Application::activeDisplayPluginChanged,
|
||||||
reinterpret_cast<scripting::Audio*>(audioScriptingInterface.data()), &scripting::Audio::onContextChanged);
|
reinterpret_cast<scripting::Audio*>(audioScriptingInterface.data()), &scripting::Audio::onContextChanged);
|
||||||
connect(this, &Application::interstitialModeChanged, audioIO, &AudioClient::setInterstitialStatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the rendering engine. This can be slow on some machines due to lots of
|
// Create the rendering engine. This can be slow on some machines due to lots of
|
||||||
|
@ -3500,6 +3499,9 @@ bool Application::isInterstitialMode() const {
|
||||||
void Application::setIsInterstitialMode(bool interstitialMode) {
|
void Application::setIsInterstitialMode(bool interstitialMode) {
|
||||||
if (_interstitialMode != interstitialMode) {
|
if (_interstitialMode != interstitialMode) {
|
||||||
_interstitialMode = interstitialMode;
|
_interstitialMode = interstitialMode;
|
||||||
|
|
||||||
|
auto audioClient = DependencyManager::get<AudioClient>();
|
||||||
|
audioClient->setAudioPaused(_interstitialMode);
|
||||||
emit interstitialModeChanged(_interstitialMode);
|
emit interstitialModeChanged(_interstitialMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5581,8 +5583,7 @@ void Application::update(float deltaTime) {
|
||||||
// we haven't yet enabled physics. we wait until we think we have all the collision information
|
// we haven't yet enabled physics. we wait until we think we have all the collision information
|
||||||
// for nearby entities before starting bullet up.
|
// for nearby entities before starting bullet up.
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
bool renderReady = _octreeProcessor.isEntitiesRenderReady();
|
if (isServerlessMode() || _octreeProcessor.isLoadSequenceComplete()) {
|
||||||
if (isServerlessMode() || (_octreeProcessor.isLoadSequenceComplete() && renderReady)) {
|
|
||||||
// we've received a new full-scene octree stats packet, or it's been long enough to try again anyway
|
// we've received a new full-scene octree stats packet, or it's been long enough to try again anyway
|
||||||
_lastPhysicsCheckTime = now;
|
_lastPhysicsCheckTime = now;
|
||||||
_fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter;
|
_fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter;
|
||||||
|
|
|
@ -138,10 +138,6 @@ bool OctreePacketProcessor::isLoadSequenceComplete() const {
|
||||||
return _safeLanding->isLoadSequenceComplete();
|
return _safeLanding->isLoadSequenceComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OctreePacketProcessor::isEntitiesRenderReady() const {
|
|
||||||
return _safeLanding->entitiesRenderReady();
|
|
||||||
}
|
|
||||||
|
|
||||||
float OctreePacketProcessor::domainLoadingProgress() {
|
float OctreePacketProcessor::domainLoadingProgress() {
|
||||||
return _safeLanding->loadingProgressPercentage();
|
return _safeLanding->loadingProgressPercentage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ public:
|
||||||
|
|
||||||
void startEntitySequence();
|
void startEntitySequence();
|
||||||
bool isLoadSequenceComplete() const;
|
bool isLoadSequenceComplete() const;
|
||||||
bool isEntitiesRenderReady() const;
|
|
||||||
float domainLoadingProgress();
|
float domainLoadingProgress();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -37,7 +37,6 @@ void SafeLanding::startEntitySequence(QSharedPointer<EntityTreeRenderer> entityT
|
||||||
if (entityTree) {
|
if (entityTree) {
|
||||||
Locker lock(_lock);
|
Locker lock(_lock);
|
||||||
_entityTree = entityTree;
|
_entityTree = entityTree;
|
||||||
_trackedEntitiesRenderStatus.clear();
|
|
||||||
_trackedEntities.clear();
|
_trackedEntities.clear();
|
||||||
_trackingEntities = true;
|
_trackingEntities = true;
|
||||||
connect(std::const_pointer_cast<EntityTree>(_entityTree).get(),
|
connect(std::const_pointer_cast<EntityTree>(_entityTree).get(),
|
||||||
|
@ -67,35 +66,19 @@ void SafeLanding::addTrackedEntity(const EntityItemID& entityID) {
|
||||||
Locker lock(_lock);
|
Locker lock(_lock);
|
||||||
EntityItemPointer entity = _entityTree->findEntityByID(entityID);
|
EntityItemPointer entity = _entityTree->findEntityByID(entityID);
|
||||||
|
|
||||||
if (entity && !entity->getCollisionless()) {
|
_trackedEntities.emplace(entityID, entity);
|
||||||
const auto& entityType = entity->getType();
|
int trackedEntityCount = _trackedEntities.size();
|
||||||
if (entityType == EntityTypes::Model) {
|
|
||||||
ModelEntityItem * modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity).get();
|
|
||||||
static const std::set<ShapeType> downloadedCollisionTypes
|
|
||||||
{ SHAPE_TYPE_COMPOUND, SHAPE_TYPE_SIMPLE_COMPOUND, SHAPE_TYPE_STATIC_MESH, SHAPE_TYPE_SIMPLE_HULL };
|
|
||||||
bool hasAABox;
|
|
||||||
entity->getAABox(hasAABox);
|
|
||||||
if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) {
|
|
||||||
// Only track entities with downloaded collision bodies.
|
|
||||||
_trackedEntities.emplace(entityID, entity);
|
|
||||||
qCDebug(interfaceapp) << "Safe Landing: Tracking entity " << entity->getItemName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_trackedEntitiesRenderStatus.emplace(entityID, entity);
|
|
||||||
float trackedEntityCount = (float)_trackedEntitiesRenderStatus.size();
|
|
||||||
|
|
||||||
if (trackedEntityCount > _maxTrackedEntityCount) {
|
if (trackedEntityCount > _maxTrackedEntityCount) {
|
||||||
_maxTrackedEntityCount = trackedEntityCount;
|
_maxTrackedEntityCount = trackedEntityCount;
|
||||||
}
|
}
|
||||||
|
qCDebug(interfaceapp) << "Safe Landing: Tracking entity " << entity->getItemName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SafeLanding::deleteTrackedEntity(const EntityItemID& entityID) {
|
void SafeLanding::deleteTrackedEntity(const EntityItemID& entityID) {
|
||||||
Locker lock(_lock);
|
Locker lock(_lock);
|
||||||
_trackedEntities.erase(entityID);
|
_trackedEntities.erase(entityID);
|
||||||
_trackedEntitiesRenderStatus.erase(entityID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SafeLanding::setCompletionSequenceNumbers(int first, int last) {
|
void SafeLanding::setCompletionSequenceNumbers(int first, int last) {
|
||||||
|
@ -114,7 +97,7 @@ void SafeLanding::noteReceivedsequenceNumber(int sequenceNumber) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SafeLanding::isLoadSequenceComplete() {
|
bool SafeLanding::isLoadSequenceComplete() {
|
||||||
if (isEntityPhysicsComplete() && isSequenceNumbersComplete()) {
|
if (isEntityLoadingComplete() && isSequenceNumbersComplete()) {
|
||||||
Locker lock(_lock);
|
Locker lock(_lock);
|
||||||
_trackedEntities.clear();
|
_trackedEntities.clear();
|
||||||
_initialStart = INVALID_SEQUENCE;
|
_initialStart = INVALID_SEQUENCE;
|
||||||
|
@ -130,8 +113,8 @@ bool SafeLanding::isLoadSequenceComplete() {
|
||||||
float SafeLanding::loadingProgressPercentage() {
|
float SafeLanding::loadingProgressPercentage() {
|
||||||
Locker lock(_lock);
|
Locker lock(_lock);
|
||||||
if (_maxTrackedEntityCount > 0) {
|
if (_maxTrackedEntityCount > 0) {
|
||||||
float trackedEntityCount = (float)_trackedEntitiesRenderStatus.size();
|
int trackedEntityCount = _trackedEntities.size();
|
||||||
return ((_maxTrackedEntityCount - trackedEntityCount) / _maxTrackedEntityCount);
|
return ((_maxTrackedEntityCount - trackedEntityCount) / (float)_maxTrackedEntityCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
@ -155,38 +138,46 @@ bool SafeLanding::isSequenceNumbersComplete() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SafeLanding::isEntityPhysicsComplete() {
|
bool isEntityPhysicsReady(const EntityItemPointer& entity) {
|
||||||
Locker lock(_lock);
|
if (entity && !entity->getCollisionless()) {
|
||||||
for (auto entityMapIter = _trackedEntities.begin(); entityMapIter != _trackedEntities.end(); ++entityMapIter) {
|
const auto& entityType = entity->getType();
|
||||||
auto entity = entityMapIter->second;
|
if (entityType == EntityTypes::Model) {
|
||||||
if (!entity->shouldBePhysical() || entity->isReadyToComputeShape()) {
|
ModelEntityItem * modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity).get();
|
||||||
entityMapIter = _trackedEntities.erase(entityMapIter);
|
static const std::set<ShapeType> downloadedCollisionTypes
|
||||||
if (entityMapIter == _trackedEntities.end()) {
|
{ SHAPE_TYPE_COMPOUND, SHAPE_TYPE_SIMPLE_COMPOUND, SHAPE_TYPE_STATIC_MESH, SHAPE_TYPE_SIMPLE_HULL };
|
||||||
break;
|
bool hasAABox;
|
||||||
|
entity->getAABox(hasAABox);
|
||||||
|
if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) {
|
||||||
|
return entity->isReadyToComputeShape();
|
||||||
|
qCDebug(interfaceapp) << "Safe Landing: Tracking entity " << entity->getItemName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SafeLanding::isEntityLoadingComplete() {
|
||||||
|
Locker lock(_lock);
|
||||||
|
auto entityTree = qApp->getEntities();
|
||||||
|
auto entityMapIter = _trackedEntities.begin();
|
||||||
|
|
||||||
|
while (entityMapIter != _trackedEntities.end()) {
|
||||||
|
auto entity = entityMapIter->second;
|
||||||
|
bool isVisuallyReady = (entity->isVisuallyReady() || !entityTree->renderableForEntityId(entityMapIter->first));
|
||||||
|
if (isEntityPhysicsReady(entity) && isVisuallyReady) {
|
||||||
|
entityMapIter = _trackedEntities.erase(entityMapIter);
|
||||||
|
} else {
|
||||||
|
if (!isVisuallyReady) {
|
||||||
|
entity->requestRenderUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
entityMapIter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
return _trackedEntities.empty();
|
return _trackedEntities.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SafeLanding::entitiesRenderReady() {
|
|
||||||
Locker lock(_lock);
|
|
||||||
auto entityTree = qApp->getEntities();
|
|
||||||
for (auto entityMapIter = _trackedEntitiesRenderStatus.begin(); entityMapIter != _trackedEntitiesRenderStatus.end(); ++entityMapIter) {
|
|
||||||
auto entity = entityMapIter->second;
|
|
||||||
bool visuallyReady = entity->isVisuallyReady();
|
|
||||||
if (visuallyReady || !entityTree->renderableForEntityId(entityMapIter->first)) {
|
|
||||||
entityMapIter = _trackedEntitiesRenderStatus.erase(entityMapIter);
|
|
||||||
if (entityMapIter == _trackedEntitiesRenderStatus.end()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
entity->requestRenderUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _trackedEntitiesRenderStatus.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
float SafeLanding::ElevatedPriority(const EntityItem& entityItem) {
|
float SafeLanding::ElevatedPriority(const EntityItem& entityItem) {
|
||||||
return entityItem.getCollisionless() ? 0.0f : 10.0f;
|
return entityItem.getCollisionless() ? 0.0f : 10.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ public:
|
||||||
void setCompletionSequenceNumbers(int first, int last); // 'last' exclusive.
|
void setCompletionSequenceNumbers(int first, int last); // 'last' exclusive.
|
||||||
void noteReceivedsequenceNumber(int sequenceNumber);
|
void noteReceivedsequenceNumber(int sequenceNumber);
|
||||||
bool isLoadSequenceComplete();
|
bool isLoadSequenceComplete();
|
||||||
bool entitiesRenderReady();
|
|
||||||
float loadingProgressPercentage();
|
float loadingProgressPercentage();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -40,7 +39,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
bool isSequenceNumbersComplete();
|
bool isSequenceNumbersComplete();
|
||||||
void debugDumpSequenceIDs() const;
|
void debugDumpSequenceIDs() const;
|
||||||
bool isEntityPhysicsComplete();
|
bool isEntityLoadingComplete();
|
||||||
|
|
||||||
std::mutex _lock;
|
std::mutex _lock;
|
||||||
using Locker = std::lock_guard<std::mutex>;
|
using Locker = std::lock_guard<std::mutex>;
|
||||||
|
@ -48,12 +47,11 @@ private:
|
||||||
EntityTreePointer _entityTree;
|
EntityTreePointer _entityTree;
|
||||||
using EntityMap = std::map<EntityItemID, EntityItemPointer>;
|
using EntityMap = std::map<EntityItemID, EntityItemPointer>;
|
||||||
EntityMap _trackedEntities;
|
EntityMap _trackedEntities;
|
||||||
EntityMap _trackedEntitiesRenderStatus;
|
|
||||||
|
|
||||||
static constexpr int INVALID_SEQUENCE = -1;
|
static constexpr int INVALID_SEQUENCE = -1;
|
||||||
int _initialStart { INVALID_SEQUENCE };
|
int _initialStart { INVALID_SEQUENCE };
|
||||||
int _initialEnd { INVALID_SEQUENCE };
|
int _initialEnd { INVALID_SEQUENCE };
|
||||||
float _maxTrackedEntityCount { 0.0f };
|
int _maxTrackedEntityCount { 0 };
|
||||||
|
|
||||||
struct SequenceLessThan {
|
struct SequenceLessThan {
|
||||||
bool operator()(const int& a, const int& b) const;
|
bool operator()(const int& a, const int& b) const;
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioClient::handleAudioInput(QByteArray& audioBuffer) {
|
void AudioClient::handleAudioInput(QByteArray& audioBuffer) {
|
||||||
if (!_interstitialMode) {
|
if (!_audioPaused) {
|
||||||
if (_muted) {
|
if (_muted) {
|
||||||
_lastInputLoudness = 0.0f;
|
_lastInputLoudness = 0.0f;
|
||||||
_timeSinceLastClip = 0.0f;
|
_timeSinceLastClip = 0.0f;
|
||||||
|
|
|
@ -162,6 +162,7 @@ public:
|
||||||
|
|
||||||
bool startRecording(const QString& filename);
|
bool startRecording(const QString& filename);
|
||||||
void stopRecording();
|
void stopRecording();
|
||||||
|
void setAudioPaused(bool pause) { _audioPaused = pause; }
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -187,7 +188,6 @@ public slots:
|
||||||
void handleRecordedAudioInput(const QByteArray& audio);
|
void handleRecordedAudioInput(const QByteArray& audio);
|
||||||
void reset();
|
void reset();
|
||||||
void audioMixerKilled();
|
void audioMixerKilled();
|
||||||
void setInterstitialStatus(bool interstitialMode) { _interstitialMode = interstitialMode; }
|
|
||||||
|
|
||||||
void setMuted(bool muted, bool emitSignal = true);
|
void setMuted(bool muted, bool emitSignal = true);
|
||||||
bool isMuted() { return _muted; }
|
bool isMuted() { return _muted; }
|
||||||
|
@ -417,7 +417,7 @@ private:
|
||||||
QVector<AudioInjectorPointer> _activeLocalAudioInjectors;
|
QVector<AudioInjectorPointer> _activeLocalAudioInjectors;
|
||||||
|
|
||||||
bool _isPlayingBackRecording { false };
|
bool _isPlayingBackRecording { false };
|
||||||
bool _interstitialMode { true };
|
bool _audioPaused { false };
|
||||||
|
|
||||||
CodecPluginPointer _codec;
|
CodecPluginPointer _codec;
|
||||||
QString _selectedCodecName;
|
QString _selectedCodecName;
|
||||||
|
|
Loading…
Reference in a new issue