mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:53:25 +02:00
move the best zone logic out of EntityTreeRenderer::render()
This commit is contained in:
parent
0ba1e8c945
commit
6edc817bf2
2 changed files with 33 additions and 54 deletions
|
@ -165,12 +165,41 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
|
||||||
_tree->withReadLock([&] {
|
_tree->withReadLock([&] {
|
||||||
std::static_pointer_cast<EntityTree>(_tree)->findEntities(avatarPosition, radius, foundEntities);
|
std::static_pointer_cast<EntityTree>(_tree)->findEntities(avatarPosition, radius, foundEntities);
|
||||||
|
|
||||||
|
// Whenever you're in an intersection between zones, we will always choose the smallest zone.
|
||||||
|
_bestZone = NULL; // NOTE: Is this what we want?
|
||||||
|
_bestZoneVolume = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
// create a list of entities that actually contain the avatar's position
|
// create a list of entities that actually contain the avatar's position
|
||||||
foreach(EntityItemPointer entity, foundEntities) {
|
foreach(EntityItemPointer entity, foundEntities) {
|
||||||
if (entity->contains(avatarPosition)) {
|
if (entity->contains(avatarPosition)) {
|
||||||
entitiesContainingAvatar << entity->getEntityItemID();
|
entitiesContainingAvatar << entity->getEntityItemID();
|
||||||
|
|
||||||
|
// if this entity is a zone, use this time to determine the bestZone
|
||||||
|
if (entity->getType() == EntityTypes::Zone) {
|
||||||
|
float entityVolumeEstimate = entity->getVolumeEstimate();
|
||||||
|
if (entityVolumeEstimate < _bestZoneVolume) {
|
||||||
|
_bestZoneVolume = entityVolumeEstimate;
|
||||||
|
_bestZone = std::dynamic_pointer_cast<ZoneEntityItem>(entity);
|
||||||
|
} else if (entityVolumeEstimate == _bestZoneVolume) {
|
||||||
|
if (!_bestZone) {
|
||||||
|
_bestZoneVolume = entityVolumeEstimate;
|
||||||
|
_bestZone = std::dynamic_pointer_cast<ZoneEntityItem>(entity);
|
||||||
|
} else {
|
||||||
|
// in the case of the volume being equal, we will use the
|
||||||
|
// EntityItemID to deterministically pick one entity over the other
|
||||||
|
if (entity->getEntityItemID() < _bestZone->getEntityItemID()) {
|
||||||
|
_bestZoneVolume = entityVolumeEstimate;
|
||||||
|
_bestZone = std::dynamic_pointer_cast<ZoneEntityItem>(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applyZonePropertiesToScene(_bestZone);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Note: at this point we don't need to worry about the tree being locked, because we only deal with
|
// Note: at this point we don't need to worry about the tree being locked, because we only deal with
|
||||||
|
@ -306,23 +335,9 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::render(RenderArgs* renderArgs) {
|
void EntityTreeRenderer::render(RenderArgs* renderArgs) {
|
||||||
|
// FIXME - currently the EntityItem rendering code still depends on knowing about the EntityTreeRenderer
|
||||||
if (_tree && !_shuttingDown) {
|
// because it uses it as a model loading service. We don't actually do anything in rendering other than this.
|
||||||
renderArgs->_renderer = this;
|
renderArgs->_renderer = this;
|
||||||
_tree->withReadLock([&] {
|
|
||||||
// Whenever you're in an intersection between zones, we will always choose the smallest zone.
|
|
||||||
_bestZone = NULL; // NOTE: Is this what we want?
|
|
||||||
_bestZoneVolume = std::numeric_limits<float>::max();
|
|
||||||
|
|
||||||
// FIX ME: right now the renderOperation does the following:
|
|
||||||
// 1) determining the best zone (not really rendering)
|
|
||||||
// 2) render the debug cell details
|
|
||||||
// we should clean this up
|
|
||||||
_tree->recurseTreeWithOperation(renderOperation, renderArgs);
|
|
||||||
|
|
||||||
applyZonePropertiesToScene(_bestZone);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
deleteReleasedModels(); // seems like as good as any other place to do some memory cleanup
|
deleteReleasedModels(); // seems like as good as any other place to do some memory cleanup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,42 +385,6 @@ const FBXGeometry* EntityTreeRenderer::getCollisionGeometryForEntity(EntityItemP
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::renderElement(OctreeElementPointer element, RenderArgs* args) {
|
|
||||||
// actually render it here...
|
|
||||||
// we need to iterate the actual entityItems of the element
|
|
||||||
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
|
|
||||||
|
|
||||||
bool isShadowMode = args->_renderMode == RenderArgs::SHADOW_RENDER_MODE;
|
|
||||||
|
|
||||||
entityTreeElement->forEachEntity([&](EntityItemPointer entityItem) {
|
|
||||||
if (entityItem->isVisible()) {
|
|
||||||
// NOTE: Zone Entities are a special case we handle here...
|
|
||||||
if (entityItem->getType() == EntityTypes::Zone) {
|
|
||||||
if (entityItem->contains(_viewState->getAvatarPosition())) {
|
|
||||||
float entityVolumeEstimate = entityItem->getVolumeEstimate();
|
|
||||||
if (entityVolumeEstimate < _bestZoneVolume) {
|
|
||||||
_bestZoneVolume = entityVolumeEstimate;
|
|
||||||
_bestZone = std::dynamic_pointer_cast<ZoneEntityItem>(entityItem);
|
|
||||||
} else if (entityVolumeEstimate == _bestZoneVolume) {
|
|
||||||
if (!_bestZone) {
|
|
||||||
_bestZoneVolume = entityVolumeEstimate;
|
|
||||||
_bestZone = std::dynamic_pointer_cast<ZoneEntityItem>(entityItem);
|
|
||||||
} else {
|
|
||||||
// in the case of the volume being equal, we will use the
|
|
||||||
// EntityItemID to deterministically pick one entity over the other
|
|
||||||
if (entityItem->getEntityItemID() < _bestZone->getEntityItemID()) {
|
|
||||||
_bestZoneVolume = entityVolumeEstimate;
|
|
||||||
_bestZone = std::dynamic_pointer_cast<ZoneEntityItem>(entityItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
float EntityTreeRenderer::getSizeScale() const {
|
float EntityTreeRenderer::getSizeScale() const {
|
||||||
return _viewState->getSizeScale();
|
return _viewState->getSizeScale();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
virtual char getMyNodeType() const { return NodeType::EntityServer; }
|
virtual char getMyNodeType() const { return NodeType::EntityServer; }
|
||||||
virtual PacketType getMyQueryMessageType() const { return PacketType::EntityQuery; }
|
virtual PacketType getMyQueryMessageType() const { return PacketType::EntityQuery; }
|
||||||
virtual PacketType getExpectedPacketType() const { return PacketType::EntityData; }
|
virtual PacketType getExpectedPacketType() const { return PacketType::EntityData; }
|
||||||
virtual void renderElement(OctreeElementPointer element, RenderArgs* args);
|
virtual void renderElement(OctreeElementPointer element, RenderArgs* args) { }
|
||||||
virtual float getSizeScale() const;
|
virtual float getSizeScale() const;
|
||||||
virtual int getBoundaryLevelAdjust() const;
|
virtual int getBoundaryLevelAdjust() const;
|
||||||
virtual void setTree(OctreePointer newTree);
|
virtual void setTree(OctreePointer newTree);
|
||||||
|
|
Loading…
Reference in a new issue