mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:24:22 +02:00
Merge pull request #4992 from howard-stearns/preload-collision-sounds
Preload collision sounds
This commit is contained in:
commit
f049dc37fc
3 changed files with 15 additions and 2 deletions
|
@ -2183,6 +2183,9 @@ void Application::init() {
|
|||
// initialize the GlowEffect with our widget
|
||||
bool glow = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect);
|
||||
DependencyManager::get<GlowEffect>()->init(glow);
|
||||
|
||||
// Make sure any new sounds are loaded as soon as know about them.
|
||||
connect(tree, &EntityTree::newCollisionSoundURL, DependencyManager::get<SoundCache>().data(), &SoundCache::getSound);
|
||||
}
|
||||
|
||||
void Application::closeMirrorView() {
|
||||
|
|
|
@ -84,6 +84,7 @@ void EntityTree::postAddEntity(EntityItemPointer entity) {
|
|||
_simulation->unlock();
|
||||
}
|
||||
_isDirty = true;
|
||||
maybeNotifyNewCollisionSoundURL("", entity->getCollisionSoundURL());
|
||||
emit addingEntity(entity->getEntityItemID());
|
||||
}
|
||||
|
||||
|
@ -184,6 +185,7 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
|
|||
// else client accepts what the server says
|
||||
|
||||
QString entityScriptBefore = entity->getScript();
|
||||
QString collisionSoundURLBefore = entity->getCollisionSoundURL();
|
||||
uint32_t preFlags = entity->getDirtyFlags();
|
||||
UpdateEntityOperator theOperator(this, containingElement, entity, properties);
|
||||
recurseTreeWithOperator(&theOperator);
|
||||
|
@ -206,8 +208,9 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
|
|||
QString entityScriptAfter = entity->getScript();
|
||||
if (entityScriptBefore != entityScriptAfter) {
|
||||
emitEntityScriptChanging(entity->getEntityItemID()); // the entity script has changed
|
||||
}
|
||||
}
|
||||
}
|
||||
maybeNotifyNewCollisionSoundURL(collisionSoundURLBefore, entity->getCollisionSoundURL());
|
||||
}
|
||||
|
||||
// TODO: this final containingElement check should eventually be removed (or wrapped in an #ifdef DEBUG).
|
||||
containingElement = getContainingElement(entity->getEntityItemID());
|
||||
|
@ -266,6 +269,11 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
|
|||
void EntityTree::emitEntityScriptChanging(const EntityItemID& entityItemID) {
|
||||
emit entityScriptChanging(entityItemID);
|
||||
}
|
||||
void EntityTree::maybeNotifyNewCollisionSoundURL(const QString& previousCollisionSoundURL, const QString& nextCollisionSoundURL) {
|
||||
if (!nextCollisionSoundURL.isEmpty() && (nextCollisionSoundURL != previousCollisionSoundURL)) {
|
||||
emit newCollisionSoundURL(QUrl(nextCollisionSoundURL));
|
||||
}
|
||||
}
|
||||
|
||||
void EntityTree::setSimulation(EntitySimulation* simulation) {
|
||||
if (simulation) {
|
||||
|
|
|
@ -171,6 +171,7 @@ signals:
|
|||
void deletingEntity(const EntityItemID& entityID);
|
||||
void addingEntity(const EntityItemID& entityID);
|
||||
void entityScriptChanging(const EntityItemID& entityItemID);
|
||||
void newCollisionSoundURL(const QUrl& url);
|
||||
void clearingEntities();
|
||||
|
||||
private:
|
||||
|
@ -199,6 +200,7 @@ private:
|
|||
EntitySimulation* _simulation;
|
||||
|
||||
bool _wantEditLogging = false;
|
||||
void maybeNotifyNewCollisionSoundURL(const QString& oldCollisionSoundURL, const QString& newCollisionSoundURL);
|
||||
};
|
||||
|
||||
#endif // hifi_EntityTree_h
|
||||
|
|
Loading…
Reference in a new issue