Skip to content

Commit

Permalink
Merge branch 'master' into zeno2-fixbug
Browse files Browse the repository at this point in the history
  • Loading branch information
legobadman committed Oct 13, 2023
2 parents 944474a + 7e746d7 commit d53ec55
Show file tree
Hide file tree
Showing 51 changed files with 996 additions and 573 deletions.
18 changes: 17 additions & 1 deletion projects/FBX/MayaCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,15 @@ struct LightNode : INode {

auto exposure = get_input2<float>("exposure");
auto intensity = get_input2<float>("intensity");
intensity *= pow(2.0, exposure);

auto scaler = powf(2.0f, exposure);

if (std::isnan(scaler) || std::isinf(scaler) || scaler < 0.0f) {
scaler = 1.0f;
printf("Light exposure = %f is invalid, fallback to 0.0 \n", exposure);
}

intensity *= scaler;

auto prim = std::make_shared<zeno::PrimitiveObject>();
auto &verts = prim->verts;
Expand Down Expand Up @@ -301,6 +309,14 @@ struct LightNode : INode {

auto &clr = prim->verts.add_attr<zeno::vec3f>("clr");
auto c = color * intensity;

for (size_t i=0; i<c.size(); ++i) {
if (std::isnan(c[i]) || std::isinf(c[i]) || c[i] < 0.0f) {
c[i] = 1.0f;
printf("Light color component %llu is invalid, fallback to 1.0 \n", i);
}
}

for(int i=0; i<verts.size(); i++){
clr[i] = c;
}
Expand Down
186 changes: 83 additions & 103 deletions ui/zenoedit/dock/docktabcontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <zeno/core/Session.h>
#include <zeno/types/UserData.h>
#include <zenovis/ObjectsManager.h>
#include <zenoui/comctrl/ztoolmenubutton.h>


ZToolBarButton::ZToolBarButton(bool bCheckable, const QString& icon, const QString& iconOn)
Expand Down Expand Up @@ -102,51 +103,6 @@ void ZToolRecordingButton::paintEvent(QPaintEvent *event)
}
#endif


ZToolMenuButton::ZToolMenuButton() {
setButtonOptions(ZToolButton::Opt_TextRightToIcon);
setArrowOption(ZStyleOptionToolButton::DOWNARROW);
menu = new QMenu(this);
run = new QAction(icon(), tr("Run"), this);
runLightCamera = new QAction(icon(), tr("RunLightCamera"), this);
runMaterial = new QAction(icon(), tr("RunMaterial"), this);
connect(run, &QAction::triggered, this, [=]() {
setText(tr("Run"));
this->setMinimumWidth(sizeHint().width());
});
connect(runLightCamera, &QAction::triggered, this, [=]() {
setText(tr("RunLightCamera"));
this->setMinimumWidth(sizeHint().width());
});
connect(runMaterial, &QAction::triggered, this, [=]() {
setText(tr("RunMaterial"));
this->setMinimumWidth(sizeHint().width());
});
menu->addAction(run);
menu->addAction(runLightCamera);
menu->addAction(runMaterial);
}


void ZToolMenuButton::mouseReleaseEvent(QMouseEvent *e) {
QSize size = ZToolButton::sizeHint();
if (e->x() >= (size.width() - ZenoStyle::dpiScaled(10)))
{
QPoint pos;
pos.setY(pos.y() + this->geometry().height());
menu->exec(this->mapToGlobal(pos));
return;
}
emit clicked();
}


QSize ZToolMenuButton::sizeHint() const {
QSize size = ZToolButton::sizeHint();
size.setWidth(size.width() + ZenoStyle::dpiScaled(12));
return size;
}

const int DockToolbarWidget::sToolbarHeight = 28;


Expand Down Expand Up @@ -294,7 +250,6 @@ DockContent_Editor::DockContent_Editor(QWidget* parent)
, m_pEditor(nullptr)
, m_btnRun(nullptr)
, m_btnKill(nullptr)
, m_btnAlways(nullptr)
{
}

Expand All @@ -312,6 +267,7 @@ void DockContent_Editor::initToolbar(QHBoxLayout* pToolLayout)
pSearchBtn = new ZToolBarButton(true, ":/icons/toolbar_search_idle.svg", ":/icons/toolbar_search_light.svg");
pSettings = new ZToolBarButton(false, ":/icons/toolbar_localSetting_idle.svg", ":/icons/toolbar_localSetting_light.svg");
pLinkLineShape = new ZToolBarButton(true, ":/icons/timeline-curvemap.svg",":/icons/timeline-curvemap.svg");
pAlways = new ZToolBarButton(true, ":/icons/Always.svg", ":/icons/AlwaysOn.svg");

pListView->setToolTip(tr("Subnet List"));
pTreeView->setToolTip(tr("Node List"));
Expand All @@ -322,20 +278,24 @@ void DockContent_Editor::initToolbar(QHBoxLayout* pToolLayout)
pGroup->setToolTip(tr("Create Group"));
pSearchBtn->setToolTip(tr("Search"));
pSettings->setToolTip(tr("Settings"));
pAlways->setToolTip(tr("Always mode"));

m_btnRun = new ZToolMenuButton;
m_btnRun = new ZToolMenuButton(this);
m_btnRun->addAction(tr("Run"), ":/icons/run_all.svg");
m_btnRun->addAction(tr("RunLightCamera"), ":/icons/run_lightcamera.svg");
m_btnRun->addAction(tr("RunMaterial"), ":/icons/run_material.svg");
m_btnKill = new ZToolButton;

QFont fnt = QApplication::font();

m_btnRun->setIcon(ZenoStyle::dpiScaledSize(QSize(14, 14)), ":/icons/timeline_run_thunder.svg",
":/icons/timeline_run_thunder.svg", "", "");
m_btnRun->setIcon(ZenoStyle::dpiScaledSize(QSize(16, 16)), ":/icons/run_all.svg",
":/icons/run_all.svg", "", "", ":/icons/run_all_disable.svg");
m_btnRun->setRadius(ZenoStyle::dpiScaled(2));
m_btnRun->setFont(fnt);
m_btnRun->setText(tr("Run"));
m_btnRun->setCursor(QCursor(Qt::PointingHandCursor));
m_btnRun->setMargins(ZenoStyle::dpiScaledMargins(QMargins(11, 5, 14, 5)));
m_btnRun->setBackgroundClr(QColor("#4578AC"), QColor("#4578AC"), QColor("#4578AC"), QColor("#4578AC"), QColor("#4D5561"));
m_btnRun->setBackgroundClr(QColor("#4073B6"), QColor("#4073B6"), QColor("#4073B6"), QColor("#4073B6"), QColor("#4D5561"));
m_btnRun->setTextClr(QColor("#FFFFFF"), QColor("#FFFFFF"), QColor("#FFFFFF"), QColor("#FFFFFF"));
ZenoSettingsManager &settings = ZenoSettingsManager::GetInstance();
m_btnRun->setShortcut(settings.getShortCut(ShortCut_Run));
Expand All @@ -356,59 +316,7 @@ void DockContent_Editor::initToolbar(QHBoxLayout* pToolLayout)
m_btnKill->setCursor(QCursor(Qt::PointingHandCursor));
m_btnKill->setEnabled(false);

QStringList runList{tr("disable"), tr("alwaysAll"), tr("alwaysLightCamera"), tr("alwaysMaterial")};
m_btnAlways = new ZComboBox(this);
m_btnAlways->addItems(runList);
m_btnAlways->setEditable(false);
m_btnAlways->setFixedHeight(ZenoStyle::dpiScaled(22));
m_btnAlways->setFont(fnt);
m_btnAlways->setProperty("focusBorder", "none");
QFontMetrics fontMetrics(fnt);
m_btnAlways->view()->setMinimumWidth(fontMetrics.horizontalAdvance(tr("alwaysLightCamera")) + ZenoStyle::dpiScaled(30));
QObject::connect(m_btnAlways, &ZComboBox::_textActivated, [=](const QString &text) {
std::shared_ptr<ZCacheMgr> mgr = zenoApp->cacheMgr();
ZASSERT_EXIT(mgr);
mgr->setCacheOpt(ZCacheMgr::Opt_AlwaysOn);
ZenoMainWindow *pMainWin = zenoApp->getMainWindow();
ZASSERT_EXIT(pMainWin);
std::function<void()> resetAlways = [=]() {
m_btnAlways->setCurrentText(tr("disable"));
pMainWin->setAlwaysLightCameraMaterial(false, false);
};
QVector<DisplayWidget *> views = pMainWin->viewports();
for (auto displayWid : views) {
if (!displayWid->isGLViewport()) {
displayWid->setRenderSeparately(false, false);
}
}
connect(zenoApp->graphsManagment(), &GraphsManagment::fileOpened, this, resetAlways);
connect(zenoApp->graphsManagment(), &GraphsManagment::modelInited, this, resetAlways);
if (text == tr("alwaysAll"))
{
pMainWin->setAlways(true);
pMainWin->setAlwaysLightCameraMaterial(false, false);
}
else if (text == tr("alwaysLightCamera") || text == tr("alwaysMaterial")) {
QSettings settings(zsCompanyName, zsEditor);
if (!settings.value("zencache-enable").toBool()) {
QMessageBox::warning(nullptr, text, tr("This function can only be used in cache mode."));
m_btnAlways->setCurrentIndex(0);
} else {
if (text == tr("alwaysLightCamera")) {
pMainWin->setAlwaysLightCameraMaterial(true, false);
} else if (text == tr("alwaysMaterial")) {
pMainWin->setAlwaysLightCameraMaterial(false, true);
}
pMainWin->setAlways(false);
}
}
else {
pMainWin->setAlways(false);
pMainWin->setAlwaysLightCameraMaterial(false, false);
}
m_btnAlways->setFixedWidth(fontMetrics.horizontalAdvance(text) + ZenoStyle::dpiScaled(26));
});
m_btnAlways->setFixedWidth(fontMetrics.horizontalAdvance(tr("disable")) + ZenoStyle::dpiScaled(26));

pListView->setChecked(false);
pShowGrid->setChecked(ZenoSettingsManager::GetInstance().getValue(zsShowGrid).toBool());
Expand Down Expand Up @@ -459,10 +367,10 @@ void DockContent_Editor::initToolbar(QHBoxLayout* pToolLayout)
pToolLayout->addWidget(pCustomParam);
pToolLayout->addWidget(pGroup);
pToolLayout->addWidget(pLinkLineShape);
pToolLayout->addWidget(pAlways);

pToolLayout->addWidget(new ZLineWidget(false, QColor("#121416")));

pToolLayout->addWidget(m_btnAlways);
pToolLayout->addWidget(m_btnRun);
pToolLayout->addWidget(m_btnKill);

Expand Down Expand Up @@ -532,6 +440,48 @@ void DockContent_Editor::initConnections()
connect(pLinkLineShape, &ZToolBarButton::toggled, this, [=](bool bChecked) {
ZenoSettingsManager::GetInstance().setValue(zsLinkLineShape, bChecked);
});

ZenoMainWindow* pMainWin = zenoApp->getMainWindow();
ZASSERT_EXIT(pMainWin);
std::function<void()> resetAlways = [=]() {
pAlways->toggle(false);
pMainWin->setAlways(false);
pMainWin->setAlwaysLightCameraMaterial(false, false);
};
connect(zenoApp->graphsManagment(), &GraphsManagment::fileOpened, this, resetAlways);
connect(zenoApp->graphsManagment(), &GraphsManagment::modelInited, this, resetAlways);
connect(pAlways, &ZToolBarButton::toggled, this, [=](bool bChecked) {
if (bChecked)
{
QSettings settings(zsCompanyName, zsEditor);
if (!settings.value("zencache-enable").toBool()) {
QMessageBox::warning(nullptr, tr("RunLightCamera"), tr("This function can only be used in cache mode."));
return;
}
QVector<DisplayWidget*> views = pMainWin->viewports();
for (auto displayWid : views) {
if (!displayWid->isGLViewport()) {
displayWid->setRenderSeparately(false, false);
}
}
if (m_btnRun->text() == tr("Run"))
{
pMainWin->setAlways(true);
pMainWin->setAlwaysLightCameraMaterial(false, false);
}
else {
if (m_btnRun->text() == tr("RunLightCamera"))
pMainWin->setAlwaysLightCameraMaterial(true, false);
else if (m_btnRun->text() == tr("RunMaterial"))
pMainWin->setAlwaysLightCameraMaterial(false, true);
pMainWin->setAlways(false);
}
}
else {
pMainWin->setAlways(false);
pMainWin->setAlwaysLightCameraMaterial(false, false);
}
});
connect(m_pEditor, &ZenoGraphsEditor::zoomed, [=](qreal newFactor) {
QString percent = QString::number(int(newFactor * 100));
percent += "%";
Expand All @@ -553,6 +503,9 @@ void DockContent_Editor::initConnections()
});

connect(m_btnRun, &ZToolMenuButton::clicked, this, [=]() {
IGraphsModel* pGraphsModel = zenoApp->graphsManagment()->currentModel();
if (!pGraphsModel)
return;
m_btnRun->setEnabled(false);
m_btnKill->setEnabled(true);
std::shared_ptr<ZCacheMgr> mgr = zenoApp->cacheMgr();
Expand Down Expand Up @@ -593,8 +546,35 @@ void DockContent_Editor::initConnections()
}
});

connect(m_btnRun, &ZToolMenuButton::textChanged, this, [=]() {
if (pAlways->isChecked())
emit pAlways->toggled(true);
QString text = m_btnRun->text();
QColor clr;
if (text == tr("Run"))
{
clr = QColor("#4073B6");
m_btnRun->setIcon(ZenoStyle::dpiScaledSize(QSize(16, 16)), ":/icons/run_all.svg",
":/icons/run_all.svg", "", "", ":/icons/run_all_disable.svg");
}
else if (text == tr("RunLightCamera"))
{
clr = QColor("#B66A40");
m_btnRun->setIcon(ZenoStyle::dpiScaledSize(QSize(16, 16)), ":/icons/run_lightcamera.svg",
":/icons/run_lightcamera.svg", "", "", ":/icons/run_lightcamera_disable.svg");
}
else if (text == tr("RunMaterial"))
{
clr = QColor("#9740B6");
m_btnRun->setIcon(ZenoStyle::dpiScaledSize(QSize(16, 16)), ":/icons/run_material.svg",
":/icons/run_material.svg", "", "", ":/icons/run_material_disable.svg");
}
m_btnRun->setBackgroundClr(clr, clr, clr, clr);
});
connect(m_btnKill, &ZToolButton::clicked, this, [=]() {
killProgram();
m_btnRun->setEnabled(true);
m_btnKill->setEnabled(false);
});

connect(&ZenoSettingsManager::GetInstance(), &ZenoSettingsManager::valueChanged, this, [=](QString name) {
Expand Down
17 changes: 2 additions & 15 deletions ui/zenoedit/dock/docktabcontent.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ZTextLabel;
class DisplayWidget;
class ZComboBox;
class ZLineEdit;
class ZToolMenuButton;

class ZToolBarButton : public ZToolButton
{
Expand All @@ -33,20 +34,6 @@ class ZToolRecordingButton : public ZToolButton {
};
#endif

class ZToolMenuButton : public ZToolButton {
Q_OBJECT
public:
ZToolMenuButton();

protected:
virtual void mouseReleaseEvent(QMouseEvent* e) override;
virtual QSize sizeHint() const override;
private:
QMenu *menu;
QAction *run;
QAction *runLightCamera;
QAction *runMaterial;
};

class DockToolbarWidget : public QWidget
{
Expand Down Expand Up @@ -111,12 +98,12 @@ class DockContent_Editor : public DockToolbarWidget
ZToolBarButton *pCustomParam;
ZToolBarButton *pGroup;
ZToolBarButton *pLinkLineShape;
ZToolBarButton *pAlways;
ZToolBarButton *pSearchBtn;
ZToolBarButton *pSettings;

ZToolMenuButton *m_btnRun;
ZToolButton* m_btnKill;
ZComboBox *m_btnAlways;

QComboBox* cbZoom;
};
Expand Down
2 changes: 1 addition & 1 deletion ui/zenoedit/nodesys/searchview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ void SearchResultWidget::resizeCount(int count)

void SearchResultWidget::moveToTop()
{
setCurrentIndex(model()->index(0, 0));
clearSelection();
setCurrentIndex(model()->index(0, 0));
}

void SearchResultWidget::keyPressEvent(QKeyEvent* event)
Expand Down
9 changes: 8 additions & 1 deletion ui/zenoedit/nodesys/zenonewmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,17 @@ bool ZenoNewnodeMenu::eventFilter(QObject* watched, QEvent* event)
if (m_preSearchMode)
{
m_searchView->setFocus();
m_searchView->setCurrentRow(0);
m_searchView->setCurrentRow(m_searchView->currentRow() + 1);
return true;
}
}
else if (watched == m_searchEdit && (pKeyEvent->key() == Qt::Key_Return || pKeyEvent->key() == Qt::Key_Enter))
{
if (m_searchView->isVisible() && m_searchView->count() > 0)
{
emit m_searchView->pressed(m_searchView->currentIndex());
}
}
}
else if (watched == m_searchEdit && event->type() == QEvent::Show)
{
Expand Down
8 changes: 8 additions & 0 deletions ui/zenoedit/nodesys/zenonode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,14 @@ QVariant ZenoNode::itemChange(GraphicsItemChange change, const QVariant &value)
emit inSocketPosChanged();
emit outSocketPosChanged();
}
else if (change == ItemZValueHasChanged)
{
int type = m_index.data(ROLE_NODETYPE).toInt();
if ((type == BLACKBOARD_NODE || type == GROUP_NODE) && zValue() != ZVALUE_BLACKBOARD)
{
setZValue(ZVALUE_BLACKBOARD);
}
}
return value;
}

Expand Down
Loading

0 comments on commit d53ec55

Please sign in to comment.