mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 18:44:00 +02:00
allow entities to tell us if they support proper scene rendering
This commit is contained in:
parent
bcc24c9762
commit
5ad9efbee4
6 changed files with 26 additions and 13 deletions
|
@ -96,9 +96,16 @@ void EntityTreeRenderer::clear() {
|
|||
OctreeRenderer::clear();
|
||||
_entityScripts.clear();
|
||||
|
||||
// TODO/FIXME - this needs to be fixed... we need to clear all items out of the scene in this case.
|
||||
qDebug() << "EntityTreeRenderer::clear() need to clear the scene... ";
|
||||
|
||||
render::Scene::PendingChanges pendingChanges;
|
||||
QHashIterator<EntityItemID, render::ItemID> i(_entityToSceneItems);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
render::ItemID renderItem = i.value();
|
||||
pendingChanges.removeItem(renderItem);
|
||||
}
|
||||
_entityToSceneItems.clear();
|
||||
_viewState->getMain3DScene()->enqueuePendingChanges(pendingChanges);
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::init() {
|
||||
|
@ -704,8 +711,8 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
|
|||
}
|
||||
}
|
||||
|
||||
// hack for models. :(
|
||||
if (entityItem->getType() == EntityTypes::Model) {
|
||||
// hack for models and other entities that don't yet play well with others. :(
|
||||
if (!entityItem->canRenderInScene()) {
|
||||
// render entityItem
|
||||
AABox entityBox = entityItem->getAABox();
|
||||
|
||||
|
@ -1076,19 +1083,20 @@ void EntityTreeRenderer::addingEntity(const EntityItemID& entityID) {
|
|||
checkAndCallPreload(entityID);
|
||||
|
||||
// here's where we add the entity payload to the scene
|
||||
|
||||
render::Scene::PendingChanges pendingChanges;
|
||||
render::ItemID renderItem = _viewState->getMain3DScene()->allocateID();
|
||||
_entityToSceneItems[entityID] = renderItem;
|
||||
EntityItemPointer entity = static_cast<EntityTree*>(_tree)->findEntityByID(entityID);
|
||||
if (entity->canRenderInScene()) {
|
||||
render::Scene::PendingChanges pendingChanges;
|
||||
render::ItemID renderItem = _viewState->getMain3DScene()->allocateID();
|
||||
_entityToSceneItems[entityID] = renderItem;
|
||||
|
||||
auto renderData = RenderableEntityItem::Pointer(new RenderableEntityItem(entity));
|
||||
auto renderPayload = render::PayloadPointer(new RenderableEntityItem::Payload(renderData));
|
||||
auto renderData = RenderableEntityItem::Pointer(new RenderableEntityItem(entity));
|
||||
auto renderPayload = render::PayloadPointer(new RenderableEntityItem::Payload(renderData));
|
||||
|
||||
pendingChanges.resetItem(renderItem, renderPayload);
|
||||
pendingChanges.resetItem(renderItem, renderPayload);
|
||||
|
||||
_viewState->getMain3DScene()->enqueuePendingChanges(pendingChanges);
|
||||
_viewState->getMain3DScene()->processPendingChangesQueue();
|
||||
_viewState->getMain3DScene()->enqueuePendingChanges(pendingChanges);
|
||||
_viewState->getMain3DScene()->processPendingChangesQueue();
|
||||
}
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::entitySciptChanging(const EntityItemID& entityID) {
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
LightEntityItem(entityItemID, properties)
|
||||
{ }
|
||||
|
||||
virtual bool canRenderInScene() { return false; } // we don't yet play well with others
|
||||
virtual void render(RenderArgs* args);
|
||||
virtual bool supportsDetailedRayIntersection() const { return true; }
|
||||
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
|
||||
virtual void somethingChangedNotification() { _needsInitialSimulation = true; }
|
||||
|
||||
virtual bool canRenderInScene() { return false; } // we don't yet play well with others
|
||||
virtual void render(RenderArgs* args);
|
||||
virtual bool supportsDetailedRayIntersection() const { return true; }
|
||||
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
~RenderableTextEntityItem() { delete _textRenderer; }
|
||||
|
||||
virtual void render(RenderArgs* args);
|
||||
virtual bool canRenderInScene() { return false; } // we don't yet play well with others
|
||||
|
||||
private:
|
||||
TextRenderer* _textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE / 2.0f);
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
|
||||
virtual void render(RenderArgs* args);
|
||||
virtual void setSourceUrl(const QString& value);
|
||||
virtual bool canRenderInScene() { return false; } // we don't yet play well with others
|
||||
|
||||
private:
|
||||
OffscreenQmlSurface* _webSurface{ nullptr };
|
||||
|
|
|
@ -151,6 +151,7 @@ public:
|
|||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData)
|
||||
{ return 0; }
|
||||
|
||||
virtual bool canRenderInScene() { return true; } // does your entity property render using Render Items and Payloads
|
||||
virtual void render(RenderArgs* args) { } // by default entity items don't know how to render
|
||||
|
||||
static int expectedBytes();
|
||||
|
|
Loading…
Reference in a new issue