mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 03:06:35 +02:00
Add debug icon which shows on render items with transitions
This commit is contained in:
parent
f360789b33
commit
fa7621896a
4 changed files with 70 additions and 29 deletions
|
@ -522,6 +522,12 @@ Menu::Menu() {
|
|||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ComputeBlendshapes, 0, true,
|
||||
DependencyManager::get<ModelBlender>().data(), SLOT(setComputeBlendshapes(bool)));
|
||||
|
||||
{
|
||||
auto drawStatusConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<render::DrawStatus>("RenderMainView.DrawStatus");
|
||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::HighlightTransitions, 0, false,
|
||||
drawStatusConfig, SLOT(setShowFade(bool)));
|
||||
}
|
||||
|
||||
// Developer > Assets >>>
|
||||
// Menu item is not currently needed but code should be kept in case it proves useful again at some stage.
|
||||
//#define WANT_ASSET_MIGRATION
|
||||
|
|
|
@ -228,6 +228,7 @@ namespace MenuOption {
|
|||
const QString NotificationSoundsTablet = "play_notification_sounds_tablet";
|
||||
const QString ForceCoarsePicking = "Force Coarse Picking";
|
||||
const QString ComputeBlendshapes = "Compute Blendshapes";
|
||||
const QString HighlightTransitions = "Highlight Transitions";
|
||||
}
|
||||
|
||||
#endif // hifi_Menu_h
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
using namespace render;
|
||||
|
||||
void DrawStatusConfig::dirtyHelper() {
|
||||
_isEnabled = showNetwork || showDisplay;
|
||||
_isEnabled = showNetwork || showDisplay || showFade;
|
||||
emit dirty();
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ const gpu::TexturePointer DrawStatus::getStatusIconMap() const {
|
|||
void DrawStatus::configure(const Config& config) {
|
||||
_showDisplay = config.showDisplay;
|
||||
_showNetwork = config.showNetwork;
|
||||
_showFade = config.showFade;
|
||||
}
|
||||
|
||||
void DrawStatus::run(const RenderContextPointer& renderContext, const Input& input) {
|
||||
|
@ -96,40 +97,70 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const Input& inp
|
|||
int nbItems = 0;
|
||||
render::ItemBounds itemBounds;
|
||||
std::vector<std::pair<glm::ivec4, glm::ivec4>> itemStatus;
|
||||
{
|
||||
for (size_t i = 0; i < inItems.size(); ++i) {
|
||||
const auto& item = inItems[i];
|
||||
if (!item.bound.isInvalid()) {
|
||||
if (!item.bound.isNull()) {
|
||||
itemBounds.emplace_back(render::ItemBound(item.id, item.bound));
|
||||
} else {
|
||||
itemBounds.emplace_back(item.id, AABox(item.bound.getCorner(), 0.1f));
|
||||
}
|
||||
|
||||
auto& itemScene = scene->getItem(item.id);
|
||||
for (size_t i = 0; i < inItems.size(); ++i) {
|
||||
const auto& item = inItems[i];
|
||||
if (!item.bound.isInvalid()) {
|
||||
if (!item.bound.isNull()) {
|
||||
itemBounds.emplace_back(render::ItemBound(item.id, item.bound));
|
||||
} else {
|
||||
itemBounds.emplace_back(item.id, AABox(item.bound.getCorner(), 0.1f));
|
||||
}
|
||||
|
||||
auto itemStatusPointer = itemScene.getStatus();
|
||||
if (itemStatusPointer) {
|
||||
itemStatus.push_back(std::pair<glm::ivec4, glm::ivec4>());
|
||||
// Query the current status values, this is where the statusGetter lambda get called
|
||||
auto&& currentStatusValues = itemStatusPointer->getCurrentValues();
|
||||
int valueNum = 0;
|
||||
for (int vec4Num = 0; vec4Num < NUM_STATUS_VEC4_PER_ITEM; vec4Num++) {
|
||||
auto& value = (vec4Num ? itemStatus[nbItems].first : itemStatus[nbItems].second);
|
||||
value = glm::ivec4(Item::Status::Value::INVALID.getPackedData());
|
||||
for (int component = 0; component < VEC4_LENGTH; component++) {
|
||||
valueNum = vec4Num * VEC4_LENGTH + component;
|
||||
if (valueNum < (int)currentStatusValues.size()) {
|
||||
value[component] = currentStatusValues[valueNum].getPackedData();
|
||||
auto& itemScene = scene->getItem(item.id);
|
||||
|
||||
if (_showNetwork || _showFade) {
|
||||
const static auto invalid = glm::ivec4(Item::Status::Value::INVALID.getPackedData());
|
||||
itemStatus.emplace_back(invalid, invalid);
|
||||
int vec4Num = 0;
|
||||
int vec4Component = 0;
|
||||
|
||||
if (_showNetwork) {
|
||||
auto itemStatusPointer = itemScene.getStatus();
|
||||
if (itemStatusPointer) {
|
||||
// Query the current status values, this is where the statusGetter lambda get called
|
||||
auto&& currentStatusValues = itemStatusPointer->getCurrentValues();
|
||||
for (const auto& statusValue : currentStatusValues) {
|
||||
if (vec4Num == NUM_STATUS_VEC4_PER_ITEM) {
|
||||
// Ran out of space
|
||||
break;
|
||||
}
|
||||
|
||||
auto& value = (vec4Num == 0 ? itemStatus[nbItems].first : itemStatus[nbItems].second);
|
||||
value[vec4Component] = statusValue.getPackedData();
|
||||
|
||||
++vec4Component;
|
||||
if (vec4Component == VEC4_LENGTH) {
|
||||
vec4Component = 0;
|
||||
++vec4Num;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto invalid = glm::ivec4(Item::Status::Value::INVALID.getPackedData());
|
||||
itemStatus.emplace_back(invalid, invalid);
|
||||
}
|
||||
nbItems++;
|
||||
|
||||
if (_showFade && vec4Num != NUM_STATUS_VEC4_PER_ITEM) {
|
||||
auto& value = (vec4Num == 0 ? itemStatus[nbItems].first : itemStatus[nbItems].second);
|
||||
|
||||
Item::Status::Value status;
|
||||
status.setColor(Item::Status::Value::CYAN);
|
||||
status.setIcon(3); // RenderItemStatusIcon::SIMULATION_OWNER (RenderableModelEntityItem.cpp)
|
||||
if (itemScene.getTransitionId() != INVALID_INDEX) {
|
||||
// We have a transition. Show this icon.
|
||||
status.setScale(1.0f);
|
||||
} else {
|
||||
status.setScale(0.0f);
|
||||
}
|
||||
value[vec4Component] = status.getPackedData();
|
||||
|
||||
++vec4Component;
|
||||
if (vec4Component == VEC4_LENGTH) {
|
||||
vec4Component = 0;
|
||||
++vec4Num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nbItems++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +200,7 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const Input& inp
|
|||
|
||||
batch.setPipeline(getDrawItemStatusPipeline());
|
||||
|
||||
if (_showNetwork) {
|
||||
if (_showNetwork || _showFade) {
|
||||
if (!_instanceBuffer) {
|
||||
_instanceBuffer = std::make_shared<gpu::Buffer>();
|
||||
}
|
||||
|
|
|
@ -27,10 +27,12 @@ namespace render {
|
|||
|
||||
bool showDisplay{ false };
|
||||
bool showNetwork{ false };
|
||||
bool showFade{ false };
|
||||
|
||||
public slots:
|
||||
void setShowDisplay(bool enabled) { showDisplay = enabled; dirtyHelper(); }
|
||||
void setShowNetwork(bool enabled) { showNetwork = enabled; dirtyHelper(); }
|
||||
void setShowFade(bool enabled) { showFade = enabled; dirtyHelper(); }
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
|
@ -57,6 +59,7 @@ namespace render {
|
|||
protected:
|
||||
bool _showDisplay; // initialized by Config
|
||||
bool _showNetwork; // initialized by Config
|
||||
bool _showFade; // initialized by Config
|
||||
|
||||
gpu::Stream::FormatPointer _drawItemFormat;
|
||||
gpu::PipelinePointer _drawItemBoundsPipeline;
|
||||
|
|
Loading…
Reference in a new issue