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