Skip to content

Commit 8e315a1

Browse files
author
Sharjith Naramparambath
committed
Load floor image in constructor instead of loadFloor method to avoid default image being displayed again and overwriting user selected one after bounding box change.
1 parent 9b31de4 commit 8e315a1

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

include/GLWidget.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ private slots:
447447
bool _viewPanning;
448448
bool _viewRotating;
449449
int _modelNum;
450-
QImage _texImage, _texBuffer, _floorTexImage;
450+
QImage _texImage, _texBuffer;
451451
float _floorTexRepeatS, _floorTexRepeatT;
452452
TextRenderer* _textRenderer;
453453
TextRenderer* _axisTextRenderer;
@@ -600,6 +600,7 @@ private slots:
600600
unsigned int _skyboxColorTexture = 0;
601601
unsigned int _skyboxDepthBuffer = 0;
602602

603+
QImage _floorTexImage;
603604
float _floorSize;
604605
float _floorSizeFactor;
605606
float _floorOffsetPercent;

src/GLWidget.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,21 @@ _assimpModelLoader(nullptr)
214214
_floorDisplayed = false;
215215
_floorTextureDisplayed = true;
216216
_floorTexRepeatS = _floorTexRepeatT = 1;
217-
_floorOffsetPercent = 0.05f;
217+
_floorOffsetPercent = 0.0f;
218+
219+
// Floor texture
220+
if (!_texBuffer.load(QString(MODELVIEWER_DATA_DIR) + "/" + "textures/envmap/floor/Grey-White-Checkered-Squares1800x1800.jpg"))
221+
{ // Load first image from file
222+
qWarning("GLWidget::loadFloor - Could not read image file, using single-color instead.");
223+
QImage dummy(128, 128, QImage::Format_ARGB32);
224+
dummy.fill(Qt::white);
225+
_floorTexImage = dummy;
226+
}
227+
else
228+
{
229+
_floorTexImage = convertToGLFormat(_texBuffer);
230+
}
231+
218232
_skyBoxEnabled = false;
219233
_skyBoxFOV = 45.0f;
220234
_skyBoxTextureHDRI = false;
@@ -3199,20 +3213,6 @@ void GLWidget::loadFloor()
31993213
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, defaultFramebufferObject());
32003214
}
32013215

3202-
// Floor texture
3203-
const QString path = QString(MODELVIEWER_DATA_DIR) + "/";
3204-
if (!_texBuffer.load(QString(path + "textures/envmap/floor/Grey-white-checkered-squares1800x1800.jpg")))
3205-
{ // Load first image from file
3206-
qWarning("GLWidget::loadFloor - Could not read image file, using single-color instead.");
3207-
QImage dummy(128, 128, QImage::Format_ARGB32);
3208-
dummy.fill(Qt::white);
3209-
_floorTexImage = dummy;
3210-
}
3211-
else
3212-
{
3213-
_floorTexImage = convertToGLFormat(_texBuffer);
3214-
}
3215-
32163216
_floorSize = _boundingSphere.getRadius();
32173217
_floorCenter = _boundingSphere.getCenter();
32183218
_lightPosition.setZ(_floorSize + _lightOffsetZ);

ui/ModelViewer.ui

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@
272272
<rect>
273273
<x>0</x>
274274
<y>0</y>
275-
<width>428</width>
276-
<height>738</height>
275+
<width>432</width>
276+
<height>737</height>
277277
</rect>
278278
</property>
279279
<property name="sizePolicy">
@@ -1016,8 +1016,8 @@
10161016
<rect>
10171017
<x>0</x>
10181018
<y>0</y>
1019-
<width>428</width>
1020-
<height>738</height>
1019+
<width>188</width>
1020+
<height>174</height>
10211021
</rect>
10221022
</property>
10231023
<attribute name="label">
@@ -1182,8 +1182,8 @@
11821182
<rect>
11831183
<x>0</x>
11841184
<y>0</y>
1185-
<width>428</width>
1186-
<height>738</height>
1185+
<width>96</width>
1186+
<height>26</height>
11871187
</rect>
11881188
</property>
11891189
<attribute name="label">
@@ -1212,8 +1212,8 @@
12121212
<rect>
12131213
<x>0</x>
12141214
<y>0</y>
1215-
<width>428</width>
1216-
<height>738</height>
1215+
<width>96</width>
1216+
<height>26</height>
12171217
</rect>
12181218
</property>
12191219
<attribute name="label">
@@ -1249,8 +1249,8 @@
12491249
<rect>
12501250
<x>0</x>
12511251
<y>0</y>
1252-
<width>428</width>
1253-
<height>738</height>
1252+
<width>212</width>
1253+
<height>612</height>
12541254
</rect>
12551255
</property>
12561256
<property name="sizePolicy">
@@ -1625,9 +1625,9 @@
16251625
<property name="geometry">
16261626
<rect>
16271627
<x>0</x>
1628-
<y>0</y>
1629-
<width>428</width>
1630-
<height>738</height>
1628+
<y>-45</y>
1629+
<width>432</width>
1630+
<height>775</height>
16311631
</rect>
16321632
</property>
16331633
<attribute name="label">
@@ -2130,7 +2130,7 @@
21302130
<double>100.000000000000000</double>
21312131
</property>
21322132
<property name="value">
2133-
<double>5.000000000000000</double>
2133+
<double>0.000000000000000</double>
21342134
</property>
21352135
</widget>
21362136
</item>

0 commit comments

Comments
 (0)