mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:03:35 +02:00
Merge branch 'master' of git://github.com/highfidelity/hifi into bloom
This commit is contained in:
commit
544ec63a08
8 changed files with 68 additions and 9 deletions
|
@ -29,12 +29,22 @@ RowLayout {
|
||||||
function playSound() {
|
function playSound() {
|
||||||
// FIXME: MyAvatar is not properly exposed to QML; MyAvatar.qmlPosition is a stopgap
|
// FIXME: MyAvatar is not properly exposed to QML; MyAvatar.qmlPosition is a stopgap
|
||||||
// FIXME: Audio.playSystemSound should not require position
|
// FIXME: Audio.playSystemSound should not require position
|
||||||
sample = Audio.playSystemSound(sound, MyAvatar.qmlPosition);
|
if (sample === null && !isPlaying) {
|
||||||
isPlaying = true;
|
sample = Audio.playSystemSound(sound, MyAvatar.qmlPosition);
|
||||||
sample.finished.connect(function() { isPlaying = false; sample = null; });
|
isPlaying = true;
|
||||||
|
sample.finished.connect(reset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function stopSound() {
|
function stopSound() {
|
||||||
sample && sample.stop();
|
if (sample && isPlaying) {
|
||||||
|
sample.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
sample.finished.disconnect(reset);
|
||||||
|
isPlaying = false;
|
||||||
|
sample = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: createSampleSound();
|
Component.onCompleted: createSampleSound();
|
||||||
|
|
|
@ -5639,14 +5639,37 @@ bool Application::nearbyEntitiesAreReadyForPhysics() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We don't want to use EntityTree::findEntities(AABox, ...) method because that scan will snarf parented entities
|
||||||
|
// whose bounding boxes cannot be computed (it is too loose for our purposes here). Instead we manufacture
|
||||||
|
// custom filters and use the general-purpose EntityTree::findEntities(filter, ...)
|
||||||
QVector<EntityItemPointer> entities;
|
QVector<EntityItemPointer> entities;
|
||||||
|
AABox avatarBox(getMyAvatar()->getPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
|
||||||
|
// create two functions that use avatarBox (entityScan and elementScan), the second calls the first
|
||||||
|
std::function<bool (EntityItemPointer&)> entityScan = [=](EntityItemPointer& entity) {
|
||||||
|
if (entity->shouldBePhysical()) {
|
||||||
|
bool success = false;
|
||||||
|
AABox entityBox = entity->getAABox(success);
|
||||||
|
// important: bail for entities that cannot supply a valid AABox
|
||||||
|
return success && avatarBox.touches(entityBox);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
std::function<bool(const OctreeElementPointer&, void*)> elementScan = [&](const OctreeElementPointer& element, void* unused) {
|
||||||
|
if (element->getAACube().touches(avatarBox)) {
|
||||||
|
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
|
||||||
|
entityTreeElement->getEntities(entityScan, entities);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
entityTree->withReadLock([&] {
|
entityTree->withReadLock([&] {
|
||||||
AABox box(getMyAvatar()->getPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
|
// Pass the second function to the general-purpose EntityTree::findEntities()
|
||||||
entityTree->findEntities(box, entities);
|
// which will traverse the tree, apply the two filter functions (to element, then to entities)
|
||||||
|
// as it traverses. The end result will be a list of entities that match.
|
||||||
|
entityTree->findEntities(elementScan, entities);
|
||||||
});
|
});
|
||||||
|
|
||||||
// For reasons I haven't found, we don't necessarily have the full scene when we receive a stats packet. Apply
|
|
||||||
// a heuristic to try to decide when we actually know about all of the nearby entities.
|
|
||||||
uint32_t nearbyCount = entities.size();
|
uint32_t nearbyCount = entities.size();
|
||||||
if (nearbyCount == _nearbyEntitiesCountAtLastPhysicsCheck) {
|
if (nearbyCount == _nearbyEntitiesCountAtLastPhysicsCheck) {
|
||||||
_nearbyEntitiesStabilityCount++;
|
_nearbyEntitiesStabilityCount++;
|
||||||
|
|
|
@ -78,7 +78,7 @@ void ATPAssetMigrator::loadEntityServerFile() {
|
||||||
request->send();
|
request->send();
|
||||||
} else {
|
} else {
|
||||||
++_errorCount;
|
++_errorCount;
|
||||||
qWarning() << "Count not create request for asset at" << migrationURL.toString();
|
qWarning() << "Could not create request for asset at" << migrationURL.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1240,6 +1240,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
mapJoints(entity, model->getJointNames());
|
mapJoints(entity, model->getJointNames());
|
||||||
}
|
}
|
||||||
animate(entity);
|
animate(entity);
|
||||||
|
emit requestRenderUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -864,6 +864,12 @@ void EntityTree::findEntities(const ViewFrustum& frustum, QVector<EntityItemPoin
|
||||||
foundEntities.swap(args.entities);
|
foundEntities.swap(args.entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: assumes caller has handled locking
|
||||||
|
void EntityTree::findEntities(RecurseOctreeOperation& elementFilter,
|
||||||
|
QVector<EntityItemPointer>& foundEntities) {
|
||||||
|
recurseTreeWithOperation(elementFilter, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
EntityItemPointer EntityTree::findEntityByID(const QUuid& id) {
|
EntityItemPointer EntityTree::findEntityByID(const QUuid& id) {
|
||||||
EntityItemID entityID(id);
|
EntityItemID entityID(id);
|
||||||
return findEntityByEntityItemID(entityID);
|
return findEntityByEntityItemID(entityID);
|
||||||
|
|
|
@ -165,6 +165,11 @@ public:
|
||||||
/// \param foundEntities[out] vector of EntityItemPointer
|
/// \param foundEntities[out] vector of EntityItemPointer
|
||||||
void findEntities(const ViewFrustum& frustum, QVector<EntityItemPointer>& foundEntities);
|
void findEntities(const ViewFrustum& frustum, QVector<EntityItemPointer>& foundEntities);
|
||||||
|
|
||||||
|
/// finds all entities that match scanOperator
|
||||||
|
/// \parameter scanOperator function that scans entities that match criteria
|
||||||
|
/// \parameter foundEntities[out] vector of EntityItemPointer
|
||||||
|
void findEntities(RecurseOctreeOperation& scanOperator, QVector<EntityItemPointer>& foundEntities);
|
||||||
|
|
||||||
void addNewlyCreatedHook(NewlyCreatedEntityHook* hook);
|
void addNewlyCreatedHook(NewlyCreatedEntityHook* hook);
|
||||||
void removeNewlyCreatedHook(NewlyCreatedEntityHook* hook);
|
void removeNewlyCreatedHook(NewlyCreatedEntityHook* hook);
|
||||||
|
|
||||||
|
|
|
@ -869,6 +869,14 @@ void EntityTreeElement::getEntities(const ViewFrustum& frustum, QVector<EntityIt
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityTreeElement::getEntities(EntityItemFilter& filter, QVector<EntityItemPointer>& foundEntities) {
|
||||||
|
forEachEntity([&](EntityItemPointer entity) {
|
||||||
|
if (filter(entity)) {
|
||||||
|
foundEntities.push_back(entity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
EntityItemPointer EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id) const {
|
EntityItemPointer EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id) const {
|
||||||
EntityItemPointer foundEntity = NULL;
|
EntityItemPointer foundEntity = NULL;
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
|
|
|
@ -27,6 +27,7 @@ class EntityTreeElement;
|
||||||
using EntityItems = QVector<EntityItemPointer>;
|
using EntityItems = QVector<EntityItemPointer>;
|
||||||
using EntityTreeElementWeakPointer = std::weak_ptr<EntityTreeElement>;
|
using EntityTreeElementWeakPointer = std::weak_ptr<EntityTreeElement>;
|
||||||
using EntityTreeElementPointer = std::shared_ptr<EntityTreeElement>;
|
using EntityTreeElementPointer = std::shared_ptr<EntityTreeElement>;
|
||||||
|
using EntityItemFilter = std::function<bool(EntityItemPointer&)>;
|
||||||
|
|
||||||
class EntityTreeUpdateArgs {
|
class EntityTreeUpdateArgs {
|
||||||
public:
|
public:
|
||||||
|
@ -199,6 +200,11 @@ public:
|
||||||
/// \param entities[out] vector of non-const EntityItemPointer
|
/// \param entities[out] vector of non-const EntityItemPointer
|
||||||
void getEntities(const ViewFrustum& frustum, QVector<EntityItemPointer>& foundEntities);
|
void getEntities(const ViewFrustum& frustum, QVector<EntityItemPointer>& foundEntities);
|
||||||
|
|
||||||
|
/// finds all entities that match filter
|
||||||
|
/// \param filter function that adds matching entities to foundEntities
|
||||||
|
/// \param entities[out] vector of non-const EntityItemPointer
|
||||||
|
void getEntities(EntityItemFilter& filter, QVector<EntityItemPointer>& foundEntities);
|
||||||
|
|
||||||
EntityItemPointer getEntityWithID(uint32_t id) const;
|
EntityItemPointer getEntityWithID(uint32_t id) const;
|
||||||
EntityItemPointer getEntityWithEntityItemID(const EntityItemID& id) const;
|
EntityItemPointer getEntityWithEntityItemID(const EntityItemID& id) const;
|
||||||
void getEntitiesInside(const AACube& box, QVector<EntityItemPointer>& foundEntities);
|
void getEntitiesInside(const AACube& box, QVector<EntityItemPointer>& foundEntities);
|
||||||
|
|
Loading…
Reference in a new issue