void BVHSceneTree::findVisible(BVHSceneNode* node, Math::Frustum const& frustum, std::vector<SceneObject*>& objects) const { if(node) { if(frustum.contains(node->bounds)) { if((node->type == SceneNodeType::Leaf) && (node->object) && (node->object->isActive())) { node->object->setVisible(true); objects.emplace_back(node->object); } else { findVisible(node->left, frustum, objects); findVisible(node->right, frustum, objects); } } else if((node->type == SceneNodeType::Leaf) && (node->object)) { node->object->setVisible(false); } } }
LONGSCROLLQT_NAMESPACE_BEGIN /*! * \class NotifyingScrollArea * \brief Scroll area that informs widgets inside about their visible region. * When the the content is scrolled, resized, shown or hidden, the widget searches for instances of NotifyableScrollContentWidget and * informs them about their current visible rectangle by calling NotifyableScrollContentWidget::showingRect(). * However it does not informa all children. If the \ref widget() returns an instance of NotifyableScrollContentWidget, only that * one will be informed, otherwise all direct children of widget() that derive from NotifyableScrollContentWidget will be informed. * * Note: A widget can determine its visible region on its own, but it does not now when it changes. * It is also slightly more effective to determine the visible rectangle for all children than let it do every widget. */ /*! * \reimp{QScrollArea::scrollContentsBy} */ void NotifyingScrollArea::scrollContentsBy(int dx, int dy) { QScrollArea::scrollContentsBy(dx, dy); findVisible(); }
/*! * \reimp{QScrollArea::hideEvent} */ void NotifyingScrollArea::hideEvent(QHideEvent * event) { QScrollArea::hideEvent(event); findVisible(); }
/*! * \reimp{QScrollArea::showEvent} */ void NotifyingScrollArea::showEvent(QShowEvent * event) { QScrollArea::showEvent(event); findVisible(); }
/*! * \reimp{QScrollArea::resizeEvent} */ void NotifyingScrollArea::resizeEvent(QResizeEvent * event) { QScrollArea::resizeEvent(event); findVisible(); }
void BVHSceneTree::getAllVisibleObjects(Math::Frustum const& frustum, std::vector<SceneObject*>& objects) const { objects.reserve(m_AllObjects.size() + m_AllObjects.size()); findVisible(m_Root, frustum, objects); }
bool EntitiesEditor::onMouseDrag(const InputState &state, int2 start, int2 current, int key, int is_final) { bool shift_pressed = state.isKeyPressed(InputKey::lshift); if(key == 0 && !state.isKeyPressed(InputKey::lctrl)) { computeCursor(start, current, shift_pressed); m_is_selecting = !is_final; if(m_mode == Mode::selecting && is_final && is_final != -1) { findVisible(m_selected_ids, m_selection); computeCursor(current, current, shift_pressed); } else if(m_mode == Mode::placing) { if(m_proto->typeId() == EntityId::trigger) { Trigger *trigger = static_cast<Trigger*>(m_proto.get()); if(m_trigger_mode == 0) { m_trigger_box = m_view.computeCursor(start, current, int3(1, 1, 1), m_cursor_pos.y, 0); if(state.isMouseButtonDown(InputButton::right)) { m_trigger_mode = 1; m_trigger_offset = current; } } IBox new_box = m_trigger_box; if(m_trigger_mode == 1) { int offset = screenToWorld(int2(0, m_trigger_offset.y - current.y)).y; if(offset < 0) new_box.min.y += offset; else new_box.max.y += offset; } trigger->setBox((FBox)new_box); m_cursor_pos = trigger->pos(); if(is_final > 0) { m_entity_map.add(PEntity(m_proto->clone())); } if(is_final) { m_trigger_mode = 0; trigger->setBox(FBox(0, 0, 0, 1, 1, 1) + trigger->pos()); } } else if(is_final > 0) m_entity_map.add(PEntity(m_proto->clone())); } return true; } else if(key == 1 && m_mode == Mode::selecting) { if(!m_is_moving) { m_is_moving_vertically = state.isKeyPressed(InputKey::lshift); m_is_moving = true; } if(m_is_moving_vertically) m_move_offset = int3(0, screenToWorld(int2(0, start.y - current.y)).y, 0); else m_move_offset = asXZY(screenToWorld(current - start), 0); if(is_final) m_is_moving = false; if(is_final > 0) { for(int n = 0; n < (int)m_selected_ids.size(); n++) { auto &object = m_entity_map[m_selected_ids[n]]; object.ptr->setPos(object.ptr->pos() + float3(m_move_offset)); m_entity_map.update(m_selected_ids[n]); } } return true; } return false; }
void Character::checkView(){ seen.clear(); map->clearVision(KNOWN, false); findVisible(); }