mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +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
|
// initialize the GlowEffect with our widget
|
||||||
bool glow = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect);
|
bool glow = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect);
|
||||||
DependencyManager::get<GlowEffect>()->init(glow);
|
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() {
|
void Application::closeMirrorView() {
|
||||||
|
|
|
@ -84,6 +84,7 @@ void EntityTree::postAddEntity(EntityItemPointer entity) {
|
||||||
_simulation->unlock();
|
_simulation->unlock();
|
||||||
}
|
}
|
||||||
_isDirty = true;
|
_isDirty = true;
|
||||||
|
maybeNotifyNewCollisionSoundURL("", entity->getCollisionSoundURL());
|
||||||
emit addingEntity(entity->getEntityItemID());
|
emit addingEntity(entity->getEntityItemID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +185,7 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
|
||||||
// else client accepts what the server says
|
// else client accepts what the server says
|
||||||
|
|
||||||
QString entityScriptBefore = entity->getScript();
|
QString entityScriptBefore = entity->getScript();
|
||||||
|
QString collisionSoundURLBefore = entity->getCollisionSoundURL();
|
||||||
uint32_t preFlags = entity->getDirtyFlags();
|
uint32_t preFlags = entity->getDirtyFlags();
|
||||||
UpdateEntityOperator theOperator(this, containingElement, entity, properties);
|
UpdateEntityOperator theOperator(this, containingElement, entity, properties);
|
||||||
recurseTreeWithOperator(&theOperator);
|
recurseTreeWithOperator(&theOperator);
|
||||||
|
@ -206,8 +208,9 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
|
||||||
QString entityScriptAfter = entity->getScript();
|
QString entityScriptAfter = entity->getScript();
|
||||||
if (entityScriptBefore != entityScriptAfter) {
|
if (entityScriptBefore != entityScriptAfter) {
|
||||||
emitEntityScriptChanging(entity->getEntityItemID()); // the entity script has changed
|
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).
|
// TODO: this final containingElement check should eventually be removed (or wrapped in an #ifdef DEBUG).
|
||||||
containingElement = getContainingElement(entity->getEntityItemID());
|
containingElement = getContainingElement(entity->getEntityItemID());
|
||||||
|
@ -266,6 +269,11 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
|
||||||
void EntityTree::emitEntityScriptChanging(const EntityItemID& entityItemID) {
|
void EntityTree::emitEntityScriptChanging(const EntityItemID& entityItemID) {
|
||||||
emit entityScriptChanging(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) {
|
void EntityTree::setSimulation(EntitySimulation* simulation) {
|
||||||
if (simulation) {
|
if (simulation) {
|
||||||
|
|
|
@ -171,6 +171,7 @@ signals:
|
||||||
void deletingEntity(const EntityItemID& entityID);
|
void deletingEntity(const EntityItemID& entityID);
|
||||||
void addingEntity(const EntityItemID& entityID);
|
void addingEntity(const EntityItemID& entityID);
|
||||||
void entityScriptChanging(const EntityItemID& entityItemID);
|
void entityScriptChanging(const EntityItemID& entityItemID);
|
||||||
|
void newCollisionSoundURL(const QUrl& url);
|
||||||
void clearingEntities();
|
void clearingEntities();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -199,6 +200,7 @@ private:
|
||||||
EntitySimulation* _simulation;
|
EntitySimulation* _simulation;
|
||||||
|
|
||||||
bool _wantEditLogging = false;
|
bool _wantEditLogging = false;
|
||||||
|
void maybeNotifyNewCollisionSoundURL(const QString& oldCollisionSoundURL, const QString& newCollisionSoundURL);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_EntityTree_h
|
#endif // hifi_EntityTree_h
|
||||||
|
|
Loading…
Reference in a new issue