twice materialChanged signal fixed

This commit is contained in:
2023-05-23 22:22:25 +03:00
parent 893910c431
commit fcc1e98a6e
8 changed files with 29 additions and 23 deletions

View File

@@ -141,7 +141,7 @@ void Framebuffer::queryPoints(int index, QRect rect_, GLenum pixel_format) {
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); f->glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
f->glReadBuffer(GL_COLOR_ATTACHMENT0 + index); f->glReadBuffer(GL_COLOR_ATTACHMENT0 + index);
pbo.bind(f); pbo.bind(f);
f->glReadPixels(rect_.x(), height() - rect_.bottom(), rect_.width(), rect_.height(), GL_RGBA, pixel_format, 0); f->glReadPixels(rect_.x(), height() - rect_.bottom() - 1, rect_.width(), rect_.height(), GL_RGBA, pixel_format, 0);
pbo_queried = rect_.width() * rect_.height(); pbo_queried = rect_.width() * rect_.height();
pbo.release(f); pbo.release(f);
} }

View File

@@ -519,10 +519,10 @@ void Renderer::renderScene() {
/// reload materials on change /// reload materials on change
phase.begin("scene reload"); phase.begin("scene reload");
if (scene_changed || scene.need_reload_materials) { if (scene_changed || scene.need_reload_materials) {
if (scene.need_reload_materials) emit view->materialsChanged();
rend_selection.generateObjectsID(scene); rend_selection.generateObjectsID(scene);
reloadMaterials(scene); reloadMaterials(scene);
if (edit_mode) recreateMaterialThumbnails(); if (edit_mode) recreateMaterialThumbnails();
emit view->materialsChanged();
} }
phase.end(); phase.end();

View File

@@ -74,10 +74,13 @@ QMatrix4x4 Camera::viewMatrix() const {
// qDebug() << pos() << aim(); // qDebug() << pos() << aim();
ret.translate(0., 0., -distance()); ret.translate(0., 0., -distance());
ret.rotate(-roll_, 0., 0., 1.); ret.rotate(-roll_, 0., 0., 1.);
ret *= trans.matrixRotateScale().inverted(); ret *= trans.matrixRotate().inverted();
if (parent_) { if (parent_) {
QMatrix4x4 pmat = parent_->worldTransform(); Transform tr;
offset_ = pmat.column(3).toVector3D(); tr.setMatrix(parent_->worldTransform());
tr.setDirty();
QMatrix4x4 pmat = tr.matrixRotate();
offset_ = parent_->worldTransform().column(3).toVector3D();
pmat(0, 3) = pmat(1, 3) = pmat(2, 3) = 0.; pmat(0, 3) = pmat(1, 3) = pmat(2, 3) = 0.;
pmat.translate(aim()); pmat.translate(aim());
ret *= pmat.inverted(); ret *= pmat.inverted();

View File

@@ -36,7 +36,7 @@ MaterialEditor::MaterialEditor(QWidget * parent): QWidget(parent) {
ui->label_13->hide(); ui->label_13->hide();
mat = 0; mat = 0;
active = true; active = true;
ignore_next = 0; ignore_next = false;
} }
@@ -51,7 +51,7 @@ void MaterialEditor::changeEvent(QEvent * e) {
void MaterialEditor::materialChanged() { void MaterialEditor::materialChanged() {
if (!active || !mat) return; if (!active || !mat) return;
ignore_next = 2; ignore_next = true;
mat->_changed = true; mat->_changed = true;
mat->color_diffuse = ui->mapDiffuse->color(); mat->color_diffuse = ui->mapDiffuse->color();
mat->color_emission = ui->mapEmission->color(); mat->color_emission = ui->mapEmission->color();
@@ -65,8 +65,8 @@ void MaterialEditor::materialChanged() {
void MaterialEditor::setMaterial(Material * m) { void MaterialEditor::setMaterial(Material * m) {
if (ignore_next > 0) { if (ignore_next) {
// ignore_next = false; ignore_next = false;
return; return;
} }
active = false; active = false;

View File

@@ -40,7 +40,7 @@ protected:
void changeEvent(QEvent * e); void changeEvent(QEvent * e);
bool active; bool active;
int ignore_next; bool ignore_next;
Ui::MaterialEditor * ui; Ui::MaterialEditor * ui;
Material * mat; Material * mat;

View File

@@ -94,10 +94,10 @@
<double>0.200000000000000</double> <double>0.200000000000000</double>
</property> </property>
<property name="spinMinimum"> <property name="spinMinimum">
<double>0.000000000000000</double> <double>-999.000000000000000</double>
</property> </property>
<property name="spinMaximum"> <property name="spinMaximum">
<double>1.000000000000000</double> <double>9999.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
@@ -192,10 +192,10 @@
<item row="1" column="1"> <item row="1" column="1">
<widget class="SpinSlider" name="sliderAmount"> <widget class="SpinSlider" name="sliderAmount">
<property name="minimum"> <property name="minimum">
<double>-1.000000000000000</double> <double>-2.000000000000000</double>
</property> </property>
<property name="maximum"> <property name="maximum">
<double>1.000000000000000</double> <double>2.000000000000000</double>
</property> </property>
<property name="value"> <property name="value">
<double>1.000000000000000</double> <double>1.000000000000000</double>
@@ -210,10 +210,10 @@
<double>0.200000000000000</double> <double>0.200000000000000</double>
</property> </property>
<property name="spinMinimum"> <property name="spinMinimum">
<double>-99.000000000000000</double> <double>-999.000000000000000</double>
</property> </property>
<property name="spinMaximum"> <property name="spinMaximum">
<double>99.000000000000000</double> <double>9999.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
@@ -242,10 +242,10 @@
<double>0.200000000000000</double> <double>0.200000000000000</double>
</property> </property>
<property name="spinMinimum"> <property name="spinMinimum">
<double>-99.000000000000000</double> <double>-999.000000000000000</double>
</property> </property>
<property name="spinMaximum"> <property name="spinMaximum">
<double>99.000000000000000</double> <double>9999.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>

View File

@@ -107,13 +107,14 @@ void MaterialsEditor::selectionChanged() {
if (!view) return; if (!view) return;
// qDebug() << "selectionChanged"; // qDebug() << "selectionChanged";
ObjectBase * o = view->selectedObject(); ObjectBase * o = view->selectedObject();
if (o) selectMaterial(o->material()); if (!o) return;
if (o->material()) selectMaterial(o->material());
} }
void MaterialsEditor::materialsChanged() { void MaterialsEditor::materialsChanged() {
if (ui->widgetMaterial->ignore_next > 0) { if (ui->widgetMaterial->ignore_next) {
ui->widgetMaterial->ignore_next--; ui->widgetMaterial->ignore_next = false;
return; return;
} }
Material * cm = currentMaterial(); Material * cm = currentMaterial();
@@ -153,6 +154,7 @@ void MaterialsEditor::on_buttonRename_clicked() {
int ind = ui->comboMaterial->currentIndex(); int ind = ui->comboMaterial->currentIndex();
ui->comboMaterial->setItemText(ind, QString("[%1] " + nn).arg(ind + 1)); ui->comboMaterial->setItemText(ind, QString("[%1] " + nn).arg(ind + 1));
ui->comboMaterial->setItemData(ind, nn); ui->comboMaterial->setItemData(ind, nn);
view->scene()->treeChanged();
} }
@@ -193,6 +195,7 @@ void MaterialsEditor::on_buttonAssign_clicked() {
ObjectBaseList ol = view->selectedObjects(); ObjectBaseList ol = view->selectedObjects();
foreach(ObjectBase * o, ol) foreach(ObjectBase * o, ol)
o->setMaterial(m, true); o->setMaterial(m, true);
view->scene()->treeChanged();
} }

View File

@@ -60,7 +60,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-287</y> <y>-300</y>
<width>444</width> <width>444</width>
<height>1100</height> <height>1100</height>
</rect> </rect>
@@ -590,7 +590,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="spinMaximum"> <property name="spinMaximum">
<double>999.000000000000000</double> <double>9999.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>