Showing the changes to interface/src/scripting/SelectionScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -152,56 +152,51 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { · 151 unmodified lines | |||
| 152 | auto mainScene = qApp->getMain3DScene(); | 152 | auto mainScene = qApp->getMain3DScene(); |
| 153 | if (mainScene) { | 153 | if (mainScene) { |
| 154 | GameplayObjects thisList = DependencyManager::get<SelectionScriptingInterface>()->getList(_listName); | 154 | GameplayObjects thisList = DependencyManager::get<SelectionScriptingInterface>()->getList(_listName); |
| 155 | 155 | render::Transaction transaction; | |
| 156 | if (thisList.getContainsData()) { | 156 | render::ItemIDs finalList; |
| 157 | render::Transaction transaction; | 157 | render::ItemID currentID; |
| 158 | render::ItemIDs finalList; | 158 | auto entityTree = qApp->getEntities()->getTree(); |
| 159 | render::ItemID currentID; | 159 | auto& overlays = qApp->getOverlays(); |
| 160 | auto entityTree = qApp->getEntities()->getTree(); | 160 | |
| 161 | auto& overlays = qApp->getOverlays(); | 161 | for (QUuid& currentAvatarID : thisList.getAvatarIDs()) { |
| 162 | 162 | auto avatar = std::static_pointer_cast<Avatar>(DependencyManager::get<AvatarManager>()->getAvatarBySessionID(currentAvatarID)); | |
| 163 | for (QUuid& currentAvatarID : thisList.getAvatarIDs()) { | 163 | if (avatar) { |
| 164 | auto avatar = std::static_pointer_cast<Avatar>(DependencyManager::get<AvatarManager>()->getAvatarBySessionID(currentAvatarID)); | 164 | currentID = avatar->getRenderItemID(); |
| 165 | if (avatar) { | 165 | if (currentID != render::Item::INVALID_ITEM_ID) { |
| 166 | currentID = avatar->getRenderItemID(); | 166 | finalList.push_back(currentID); |
| 167 | if (currentID != render::Item::INVALID_ITEM_ID) { | ||
| 168 | finalList.push_back(currentID); | ||
| 169 | } | ||
| 170 | } | 167 | } |
| 171 | } | 168 | } |
| 169 | } | ||
| 172 | 170 | ||
| 173 | for (EntityItemID& currentEntityID : thisList.getEntityIDs()) { | 171 | for (EntityItemID& currentEntityID : thisList.getEntityIDs()) { |
| 174 | entityTree->withReadLock([&] { | 172 | entityTree->withReadLock([&] { |
| 175 | auto entityItem = entityTree->findEntityByEntityItemID(currentEntityID); | 173 | auto entityItem = entityTree->findEntityByEntityItemID(currentEntityID); |
| 176 | if (entityItem != NULL) { | 174 | if (entityItem != NULL) { |
| 177 | auto renderableInterface = entityItem->getRenderableInterface(); | 175 | auto renderableInterface = entityItem->getRenderableInterface(); |
| 178 | if (renderableInterface != NULL) { | 176 | if (renderableInterface != NULL) { |
| 179 | currentID = renderableInterface->getMetaRenderItemID(); | 177 | currentID = renderableInterface->getMetaRenderItemID(); |
| 180 | if (currentID != render::Item::INVALID_ITEM_ID) { | 178 | if (currentID != render::Item::INVALID_ITEM_ID) { |
| 181 | finalList.push_back(currentID); | 179 | finalList.push_back(currentID); |
| 182 | } | ||
| 183 | } | 180 | } |
| 184 | } | 181 | } |
| 185 | }); | 182 | } |
| 186 | } | 183 | }); |
| 184 | } | ||
| 187 | 185 | ||
| 188 | for (OverlayID& currentOverlayID : thisList.getOverlayIDs()) { | 186 | for (OverlayID& currentOverlayID : thisList.getOverlayIDs()) { |
| 189 | auto overlay = overlays.getOverlay(currentOverlayID); | 187 | auto overlay = overlays.getOverlay(currentOverlayID); |
| 190 | if (overlay != NULL) { | 188 | if (overlay != NULL) { |
| 191 | currentID = overlay->getRenderItemID(); | 189 | currentID = overlay->getRenderItemID(); |
| 192 | if (currentID != render::Item::INVALID_ITEM_ID) { | 190 | if (currentID != render::Item::INVALID_ITEM_ID) { |
| 193 | finalList.push_back(currentID); | 191 | finalList.push_back(currentID); |
| 194 | } | ||
| 195 | } | 192 | } |
| 196 | } | 193 | } |
| 194 | } | ||
| 197 | 195 | ||
| 198 | render::Selection selection(_listName.toStdString(), finalList); | 196 | render::Selection selection(_listName.toStdString(), finalList); |
| 199 | transaction.resetSelection(selection); | 197 | transaction.resetSelection(selection); |
| 200 | 198 | ||
| 201 | mainScene->enqueueTransaction(transaction); | 199 | mainScene->enqueueTransaction(transaction); |
| 202 | } else { | ||
| 203 | qWarning() << "List of GameplayObjects doesn't exist in thisList"; | ||
| 204 | } | ||
| 205 | } else { | 200 | } else { |
| 206 | qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; | 201 | qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; |
| 207 | } | 202 | } |