Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt3D update scene

Qt3D update scene

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 248 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    ValeriaAme
    wrote on last edited by ValeriaAme
    #1

    Hello everyone. I'm a newbie to Qt3D. I load surfaces from 3D scanner to scene and they look like overlapping one on another, furthermore appearing too slow. I made a function which deletes all children and components of a given node.

    void SceneRenderer::deleteChildrenRecursively(Qt3DCore::QNode* node)
    {
            Qt3DCore::QEntity* entity = (Qt3DCore::QEntity*)node;
    
            if (entity == nullptr) {
                return;
            }
             auto components = entity->components();
            foreach(Qt3DCore::QComponent * component, components) {
                const auto componentChildren = component->childNodes();
            
                foreach(auto * child, componentChildren)
                {
                    delete (child);
                    child = NULL;
                }
                const auto compChildrenSie = componentChildren.size();
                entity->removeComponent(component);
                delete(component);
                component = NULL;
            }
    
            const auto childNodes = node->childNodes();
            const auto childNodesSize = node->childNodes().size();
    
            const auto childentities = entity->childNodes();
            const auto childentitiesSize = entity->childNodes().size();
    
            auto componentsAfter = entity->components();
            auto parentEntity = entity->parentEntity();
            for (auto* child: childNodes)
            {
                deleteChildrenRecursively(child);
            }
            delete(entity);
            entity = NULL;
    }
    

    Usage:

        render_->loadSurfaceToScene(surface);
        Qt3DCore::QNodeVector rootEntityChildren;
        rootEntityChildren.reserve(render_->rootEntity_->childNodes().size());
        rootEntityChildren = render_->rootEntity_->childNodes();
        render_->deleteChildrenRecursively(rootEntityChildren[1]);
    

    So I pass added object to function deleteChildrenRecursively()
    Now scene is empty, nothing renders. Could you help me how to fix this problem and update scene manually? Maybe slow performance is not the issue of not deleting nodes from scene? Thank you in advance.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved