mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 07:24:59 +02:00
keep debuging the seelction highlight
This commit is contained in:
parent
76cfacef6b
commit
e0740b323d
5 changed files with 67 additions and 34 deletions
|
@ -73,12 +73,11 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& lis
|
||||||
|
|
||||||
bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName) {
|
bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName) {
|
||||||
_selectedItemsListMap.insert(listName, GameplayObjects());
|
_selectedItemsListMap.insert(listName, GameplayObjects());
|
||||||
emit selectedItemsListChanged(listName);
|
onSelectedItemsListChanged(listName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) {
|
bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) {
|
||||||
bool doSetupHandler = false;
|
|
||||||
|
|
||||||
auto highlightStyle = _highlightedListMap.find(listName);
|
auto highlightStyle = _highlightedListMap.find(listName);
|
||||||
if (highlightStyle == _highlightedListMap.end()) {
|
if (highlightStyle == _highlightedListMap.end()) {
|
||||||
|
@ -90,18 +89,14 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c
|
||||||
auto currentList = _selectedItemsListMap.find(listName);
|
auto currentList = _selectedItemsListMap.find(listName);
|
||||||
if (currentList == _selectedItemsListMap.end()) {
|
if (currentList == _selectedItemsListMap.end()) {
|
||||||
_selectedItemsListMap.insert(listName, GameplayObjects());
|
_selectedItemsListMap.insert(listName, GameplayObjects());
|
||||||
setupHandler(listName);
|
|
||||||
// doSetupHandler = true;
|
|
||||||
}
|
}
|
||||||
|
setupHandler(listName);
|
||||||
|
|
||||||
(*highlightStyle).setBoundToList(true);
|
(*highlightStyle).setBoundToList(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*highlightStyle).fromVariantMap(highlightStyleValues);
|
(*highlightStyle).fromVariantMap(highlightStyleValues);
|
||||||
|
|
||||||
/* if (doSetupHandler) {
|
|
||||||
setupHandler(listName);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
auto mainScene = qApp->getMain3DScene();
|
auto mainScene = qApp->getMain3DScene();
|
||||||
if (mainScene) {
|
if (mainScene) {
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
|
@ -139,7 +134,12 @@ bool SelectionScriptingInterface::disableListHighlight(const QString& listName)
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& listName) const {
|
QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& listName) const {
|
||||||
|
auto highlightStyle = _highlightedListMap.find(listName);
|
||||||
|
if (highlightStyle == _highlightedListMap.end()) {
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
|
} else {
|
||||||
|
return (*highlightStyle).toVariantMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const {
|
render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const {
|
||||||
|
@ -156,7 +156,7 @@ template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const
|
||||||
currentList.addToGameplayObjects(idToAdd);
|
currentList.addToGameplayObjects(idToAdd);
|
||||||
_selectedItemsListMap.insert(listName, currentList);
|
_selectedItemsListMap.insert(listName, currentList);
|
||||||
|
|
||||||
emit selectedItemsListChanged(listName);
|
onSelectedItemsListChanged(listName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) {
|
template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) {
|
||||||
|
@ -165,7 +165,7 @@ template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(c
|
||||||
currentList.removeFromGameplayObjects(idToRemove);
|
currentList.removeFromGameplayObjects(idToRemove);
|
||||||
_selectedItemsListMap.insert(listName, currentList);
|
_selectedItemsListMap.insert(listName, currentList);
|
||||||
|
|
||||||
emit selectedItemsListChanged(listName);
|
onSelectedItemsListChanged(listName);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -180,26 +180,32 @@ GameplayObjects SelectionScriptingInterface::getList(const QString& listName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionScriptingInterface::printList(const QString& listName) {
|
void SelectionScriptingInterface::printList(const QString& listName) {
|
||||||
GameplayObjects currentList = _selectedItemsListMap.value(listName);
|
auto currentList = _selectedItemsListMap.find(listName);
|
||||||
if (currentList.getContainsData()) {
|
if (currentList != _selectedItemsListMap.end()) {
|
||||||
|
if ((*currentList).getContainsData()) {
|
||||||
|
|
||||||
|
qDebug() << "List named " << listName << ":";
|
||||||
qDebug() << "Avatar IDs:";
|
qDebug() << "Avatar IDs:";
|
||||||
for (auto i : currentList.getAvatarIDs()) {
|
for (auto i : (*currentList).getAvatarIDs()) {
|
||||||
qDebug() << i << ';';
|
qDebug() << i << ';';
|
||||||
}
|
}
|
||||||
qDebug() << "";
|
qDebug() << "";
|
||||||
|
|
||||||
qDebug() << "Entity IDs:";
|
qDebug() << "Entity IDs:";
|
||||||
for (auto j : currentList.getEntityIDs()) {
|
for (auto j : (*currentList).getEntityIDs()) {
|
||||||
qDebug() << j << ';';
|
qDebug() << j << ';';
|
||||||
}
|
}
|
||||||
qDebug() << "";
|
qDebug() << "";
|
||||||
|
|
||||||
qDebug() << "Overlay IDs:";
|
qDebug() << "Overlay IDs:";
|
||||||
for (auto k : currentList.getOverlayIDs()) {
|
for (auto k : (*currentList).getOverlayIDs()) {
|
||||||
qDebug() << k << ';';
|
qDebug() << k << ';';
|
||||||
}
|
}
|
||||||
qDebug() << "";
|
qDebug() << "";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "List named " << listName << " empty";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "List named " << listName << " doesn't exist.";
|
qDebug() << "List named " << listName << " doesn't exist.";
|
||||||
}
|
}
|
||||||
|
@ -207,7 +213,7 @@ void SelectionScriptingInterface::printList(const QString& listName) {
|
||||||
|
|
||||||
bool SelectionScriptingInterface::removeListFromMap(const QString& listName) {
|
bool SelectionScriptingInterface::removeListFromMap(const QString& listName) {
|
||||||
if (_selectedItemsListMap.remove(listName)) {
|
if (_selectedItemsListMap.remove(listName)) {
|
||||||
emit selectedItemsListChanged(listName);
|
onSelectedItemsListChanged(listName);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -222,9 +228,17 @@ void SelectionScriptingInterface::setupHandler(const QString& selectionName) {
|
||||||
|
|
||||||
|
|
||||||
(*handler)->initialize(selectionName);
|
(*handler)->initialize(selectionName);
|
||||||
|
// connect(this, &SelectionScriptingInterface::selectedItemsListChanged, handler.value(), &SelectionToSceneHandler::selectedItemsListChanged);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) {
|
||||||
|
auto handler = _handlerMap.find(listName);
|
||||||
|
if (handler != _handlerMap.end()) {
|
||||||
|
(*handler)->updateSceneFromSelectedList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SelectionToSceneHandler::SelectionToSceneHandler() {
|
SelectionToSceneHandler::SelectionToSceneHandler() {
|
||||||
}
|
}
|
||||||
|
@ -232,10 +246,8 @@ SelectionToSceneHandler::SelectionToSceneHandler() {
|
||||||
void SelectionToSceneHandler::initialize(const QString& listName) {
|
void SelectionToSceneHandler::initialize(const QString& listName) {
|
||||||
_listName = listName;
|
_listName = listName;
|
||||||
|
|
||||||
connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged);
|
|
||||||
// connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged);
|
|
||||||
// connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleRemoved, this, &SelectionToSceneHandler::highlightStyleRemoved);
|
|
||||||
|
|
||||||
|
updateSceneFromSelectedList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) {
|
void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) {
|
||||||
|
|
|
@ -138,6 +138,8 @@ public:
|
||||||
|
|
||||||
render::HighlightStyle getHighlightStyle(const QString& listName) const;
|
render::HighlightStyle getHighlightStyle(const QString& listName) const;
|
||||||
|
|
||||||
|
void onSelectedItemsListChanged(const QString& listName);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void selectedItemsListChanged(const QString& listName);
|
void selectedItemsListChanged(const QString& listName);
|
||||||
// void highlightStyleChanged(const QString& listName);
|
// void highlightStyleChanged(const QString& listName);
|
||||||
|
|
|
@ -432,6 +432,24 @@ void SelectionToHighlight::run(const render::RenderContextPointer& renderContext
|
||||||
outputs.clear();
|
outputs.clear();
|
||||||
_sharedParameters->_highlightIds.fill(render::HighlightStage::INVALID_INDEX);
|
_sharedParameters->_highlightIds.fill(render::HighlightStage::INVALID_INDEX);
|
||||||
|
|
||||||
|
int numLayers = 0;
|
||||||
|
auto highlightList = highlightStage->getActiveHighlightIds();
|
||||||
|
|
||||||
|
for (auto styleId : highlightList) {
|
||||||
|
auto highlight = highlightStage->getHighlight(styleId);
|
||||||
|
|
||||||
|
if (!scene->isSelectionEmpty(highlight._selectionName)) {
|
||||||
|
auto highlightId = highlightStage->getHighlightIdBySelection(highlight._selectionName);
|
||||||
|
_sharedParameters->_highlightIds[outputs.size()] = highlightId;
|
||||||
|
outputs.emplace_back(highlight._selectionName);
|
||||||
|
numLayers++;
|
||||||
|
|
||||||
|
if (numLayers == HighlightSharedParameters::MAX_PASS_COUNT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
for (auto i = 0; i < HighlightSharedParameters::MAX_PASS_COUNT; i++) {
|
for (auto i = 0; i < HighlightSharedParameters::MAX_PASS_COUNT; i++) {
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
|
@ -447,7 +465,7 @@ void SelectionToHighlight::run(const render::RenderContextPointer& renderContext
|
||||||
outputs.emplace_back(selectionName);
|
outputs.emplace_back(selectionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtractSelectionName::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
void ExtractSelectionName::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace render {
|
||||||
|
|
||||||
HighlightIdList::iterator begin() { return _activeHighlightIds.begin(); }
|
HighlightIdList::iterator begin() { return _activeHighlightIds.begin(); }
|
||||||
HighlightIdList::iterator end() { return _activeHighlightIds.end(); }
|
HighlightIdList::iterator end() { return _activeHighlightIds.end(); }
|
||||||
|
const HighlightIdList& getActiveHighlightIds() const { return _activeHighlightIds; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -442,7 +442,7 @@ bool Scene::isSelectionEmpty(const Selection::Name& name) const {
|
||||||
std::unique_lock<std::mutex> lock(_selectionsMutex);
|
std::unique_lock<std::mutex> lock(_selectionsMutex);
|
||||||
auto found = _selections.find(name);
|
auto found = _selections.find(name);
|
||||||
if (found == _selections.end()) {
|
if (found == _selections.end()) {
|
||||||
return false;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return (*found).second.isEmpty();
|
return (*found).second.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue