Skip to content

Commit 3a7ef69

Browse files
committed
Fixes basic clipping plane issues
Not the glyph problem--disabled for now
1 parent e8288d0 commit 3a7ef69

File tree

7 files changed

+46
-37
lines changed

7 files changed

+46
-37
lines changed

src/Core/GeometryPrimitives/BBox.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void SCIRun::Core::Geometry::Pio(Piostream &stream, BBox & box)
147147

148148
if(stream.reading())
149149
{
150-
box.set_valid(tmp);
150+
box.setValid(tmp);
151151
if (tmp)
152152
{
153153
box.extend(min);

src/Core/GeometryPrimitives/BBoxBase.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,28 @@
3535
namespace SCIRun {
3636
namespace Core {
3737
namespace Geometry {
38+
3839
class SCISHARE BBoxBase
3940
{
4041
protected:
41-
Point cmin_;
42-
Point cmax_;
43-
bool is_valid_;
42+
Point cmin_;
43+
Point cmax_;
44+
bool is_valid_;
4445
public:
4546
explicit BBoxBase(bool valid);
4647
BBoxBase(bool valid, const Point& cmin, const Point& cmax);
4748
virtual ~BBoxBase() {}
48-
inline bool valid() const { return is_valid_; }
49-
inline void set_valid(bool v) { is_valid_ = v; }
50-
inline void reset() { is_valid_ = false; }
49+
bool valid() const { return is_valid_; }
50+
void setValid(bool v) { is_valid_ = v; }
51+
void reset() { is_valid_ = false; }
5152
virtual void extend(const Point& p) = 0;
5253
virtual void extend(double val) = 0;
5354
virtual Vector diagonal() const = 0;
5455
virtual Point get_min() const = 0;
5556
virtual Point get_max() const = 0;
5657
virtual Point center() const = 0;
5758
};
59+
5860
}}}
5961

6062
#endif

src/Interface/Modules/Render/ES/SRInterface.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,10 @@ glm::vec2 ScreenParams::positionFromClick(int x, int y) const
780780
//----------------------------------------------------------------------------------------------
781781
double SRInterface::getMaxProjLength(const glm::vec3 &n)
782782
{
783-
glm::vec3 a1(-1.0, 1.0, -1.0);
784-
glm::vec3 a2(-1.0, 1.0, 1.0);
785-
glm::vec3 a3(1.0, 1.0, -1.0);
786-
glm::vec3 a4(1.0, 1.0, 1.0);
783+
static const glm::vec3 a1(-1.0, 1.0, -1.0);
784+
static const glm::vec3 a2(-1.0, 1.0, 1.0);
785+
static const glm::vec3 a3(1.0, 1.0, -1.0);
786+
static const glm::vec3 a4(1.0, 1.0, 1.0);
787787
return std::max(
788788
std::max(
789789
std::abs(dot(n, a1)),
@@ -796,15 +796,15 @@ glm::vec2 ScreenParams::positionFromClick(int x, int y) const
796796
//----------------------------------------------------------------------------------------------
797797
void SRInterface::updateClippingPlanes()
798798
{
799-
StaticClippingPlanes* clippingPlanes = mCore.getStaticComponent<StaticClippingPlanes>();
800-
if (clippingPlanes)
799+
auto* clippingPlanes = mCore.getStaticComponent<StaticClippingPlanes>();
800+
if (clippingPlanes && sceneBBox_.valid())
801801
{
802802
clippingPlanes->clippingPlanes.clear();
803803
clippingPlanes->clippingPlaneCtrls.clear();
804804
//boundbox transformation
805805
glm::mat4 trans_bb = glm::mat4(1.0f);
806-
glm::vec3 scale_bb(mSceneBBox.x_length() / 2.0, mSceneBBox.y_length() / 2.0, mSceneBBox.z_length() / 2.0);
807-
glm::vec3 center_bb(mSceneBBox.center().x(), mSceneBBox.center().y(), mSceneBBox.center().z());
806+
glm::vec3 scale_bb(sceneBBox_.x_length() / 2.0, sceneBBox_.y_length() / 2.0, sceneBBox_.z_length() / 2.0);
807+
glm::vec3 center_bb(sceneBBox_.center().x(), sceneBBox_.center().y(), sceneBBox_.center().z());
808808
glm::mat4 temp = scale(glm::mat4(1.0f), scale_bb);
809809
trans_bb = temp * trans_bb;
810810
temp = translate(glm::mat4(1.0f), center_bb);
@@ -1085,12 +1085,12 @@ glm::vec2 ScreenParams::positionFromClick(int x, int y) const
10851085
if (auto shaderMan = sm.lock())
10861086
{
10871087
RENDERER_LOG("Recalculate scene bounding box. Should only be done when an object is added.");
1088-
mSceneBBox.reset();
1088+
sceneBBox_.reset();
10891089
for (auto it = mSRObjects.begin(); it != mSRObjects.end(); ++it)
10901090
{
10911091
if (it->mBBox.valid())
10921092
{
1093-
mSceneBBox.extend(it->mBBox);
1093+
sceneBBox_.extend(it->mBBox);
10941094
}
10951095
}
10961096

@@ -1192,7 +1192,7 @@ glm::vec2 ScreenParams::positionFromClick(int x, int y) const
11921192
mCore.addComponent(entityID, pass);
11931193
}
11941194
}
1195-
mCamera->setSceneBoundingBox(mSceneBBox);
1195+
mCamera->setSceneBoundingBox(sceneBBox_);
11961196
}
11971197
}
11981198
DEBUG_LOG_LINE_INFO
@@ -1717,7 +1717,7 @@ glm::vec2 ScreenParams::positionFromClick(int x, int y) const
17171717
{
17181718
if (uniform.name == "uFogSettings")
17191719
{
1720-
float radius = mSceneBBox.diagonal().length() * 2.0;
1720+
float radius = sceneBBox_.diagonal().length() * 2.0;
17211721
float start = radius * mFogStart;
17221722
float end = radius * mFogEnd;
17231723
uniform.data = glm::vec4(mFogIntensity, start, end, 0.0);

src/Interface/Modules/Render/ES/SRInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ namespace SCIRun
144144
bool hasObject(const std::string& object) override;
145145
// Garbage collect all invalid objects not given in the valid objects vector.
146146
void gcInvalidObjects(const std::vector<std::string>& validObjects) override;
147-
Core::Geometry::BBox getSceneBox() override {return mSceneBBox;}
147+
Core::Geometry::BBox getSceneBox() override { return sceneBBox_; }
148148
void cleanupSelect() override;
149149

150150
bool hasShaderPromise() const override;
@@ -239,7 +239,7 @@ namespace SCIRun
239239

240240
int axesFailCount_ {0};
241241
std::vector<SRObject> mSRObjects {}; // All SCIRun objects.
242-
Core::Geometry::BBox mSceneBBox {}; // Scene's AABB. Recomputed per-frame.
242+
Core::Geometry::BBox sceneBBox_ {}; // Scene's AABB. Recomputed per-frame.
243243
std::unordered_map<std::string, uint64_t> mEntityIdMap {};
244244

245245
ESCore mCore {}; // Entity system core.

src/Interface/Modules/Render/ViewScene.cc

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,11 +1880,11 @@ bool ViewSceneDialog::checkForSelectedWidget(WidgetHandle widget)
18801880
//--------------------------------------------------------------------------------------------------
18811881
void ViewSceneDialog::restoreObjColor()
18821882
{
1883-
LOG_DEBUG("ViewSceneDialog::asyncExecute before locking");
1883+
LOG_DEBUG("ViewSceneDialog::restoreObjColor before locking");
18841884

18851885
Guard lock(Modules::Render::ViewScene::mutex_.get());
18861886

1887-
LOG_DEBUG("ViewSceneDialog::asyncExecute after locking");
1887+
LOG_DEBUG("ViewSceneDialog::restoreObjColor after locking");
18881888

18891889
widgetColorChanger_.reset();
18901890
}
@@ -1904,7 +1904,7 @@ void ViewSceneDialog::setClippingPlaneIndex(int index)
19041904
clippingPlanes_[clippingPlaneIndex_].visible,
19051905
clippingPlanes_[clippingPlaneIndex_].showFrame,
19061906
clippingPlanes_[clippingPlaneIndex_].reverseNormal);
1907-
updatClippingPlaneDisplay();
1907+
updateClippingPlaneDisplay();
19081908
}
19091909

19101910
//--------------------------------------------------------------------------------------------------
@@ -1914,7 +1914,7 @@ void ViewSceneDialog::setClippingPlaneVisible(bool value)
19141914
auto spire = mSpire.lock();
19151915
if (spire)
19161916
spire->setClippingPlaneVisible(clippingPlanes_[clippingPlaneIndex_].visible);
1917-
updatClippingPlaneDisplay();
1917+
updateClippingPlaneDisplay();
19181918
}
19191919

19201920
//--------------------------------------------------------------------------------------------------
@@ -1925,7 +1925,7 @@ void ViewSceneDialog::setClippingPlaneFrameOn(bool value)
19251925
auto spire = mSpire.lock();
19261926
if (spire)
19271927
spire->setClippingPlaneFrameOn(clippingPlanes_[clippingPlaneIndex_].showFrame);
1928-
updatClippingPlaneDisplay();
1928+
updateClippingPlaneDisplay();
19291929
}
19301930

19311931
//--------------------------------------------------------------------------------------------------
@@ -1935,7 +1935,7 @@ void ViewSceneDialog::reverseClippingPlaneNormal(bool value)
19351935
auto spire = mSpire.lock();
19361936
if (spire)
19371937
spire->reverseClippingPlaneNormal(clippingPlanes_[clippingPlaneIndex_].reverseNormal);
1938-
updatClippingPlaneDisplay();
1938+
updateClippingPlaneDisplay();
19391939
}
19401940

19411941
//--------------------------------------------------------------------------------------------------
@@ -1945,7 +1945,7 @@ void ViewSceneDialog::setClippingPlaneX(int index)
19451945
auto spire = mSpire.lock();
19461946
if (spire)
19471947
spire->setClippingPlaneX(clippingPlanes_[clippingPlaneIndex_].x);
1948-
updatClippingPlaneDisplay();
1948+
updateClippingPlaneDisplay();
19491949
}
19501950

19511951
//--------------------------------------------------------------------------------------------------
@@ -1955,7 +1955,7 @@ void ViewSceneDialog::setClippingPlaneY(int index)
19551955
auto spire = mSpire.lock();
19561956
if (spire)
19571957
spire->setClippingPlaneY(clippingPlanes_[clippingPlaneIndex_].y);
1958-
updatClippingPlaneDisplay();
1958+
updateClippingPlaneDisplay();
19591959
}
19601960

19611961
//--------------------------------------------------------------------------------------------------
@@ -1965,7 +1965,7 @@ void ViewSceneDialog::setClippingPlaneZ(int index)
19651965
auto spire = mSpire.lock();
19661966
if (spire)
19671967
spire->setClippingPlaneZ(clippingPlanes_[clippingPlaneIndex_].z);
1968-
updatClippingPlaneDisplay();
1968+
updateClippingPlaneDisplay();
19691969
}
19701970

19711971
//--------------------------------------------------------------------------------------------------
@@ -1975,7 +1975,7 @@ void ViewSceneDialog::setClippingPlaneD(int index)
19751975
auto spire = mSpire.lock();
19761976
if (spire)
19771977
spire->setClippingPlaneD(clippingPlanes_[clippingPlaneIndex_].d);
1978-
updatClippingPlaneDisplay();
1978+
updateClippingPlaneDisplay();
19791979
}
19801980

19811981
//--------------------------------------------------------------------------------------------------
@@ -1985,7 +1985,7 @@ void ViewSceneDialog::useClipChecked(bool value)
19851985
}
19861986

19871987
//--------------------------------------------------------------------------------------------------
1988-
void ViewSceneDialog::updatClippingPlaneDisplay()
1988+
void ViewSceneDialog::updateClippingPlaneDisplay()
19891989
{
19901990
mConfigurationDock->updatePlaneControlDisplay(
19911991
clippingPlanes_[clippingPlaneIndex_].x,
@@ -2025,7 +2025,8 @@ void ViewSceneDialog::buildGeomClippingPlanes()
20252025
//--------------------------------------------------------------------------------------------------
20262026
void ViewSceneDialog::buildGeometryClippingPlane(int index, const glm::vec4& plane, const BBox& bbox)
20272027
{
2028-
if (!bbox.valid()) return;
2028+
if (!bbox.valid())
2029+
return;
20292030
Vector diag(bbox.diagonal());
20302031
Point c(bbox.center());
20312032
Vector n(plane.x, plane.y, plane.z);

src/Interface/Modules/Render/ViewScene.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ namespace SCIRun {
271271
void updateCursor();
272272

273273
//---------------- Clipping Planes -----------------------------------------------------------
274-
void updatClippingPlaneDisplay();
274+
void updateClippingPlaneDisplay();
275275
void buildGeomClippingPlanes();
276276
void buildGeometryClippingPlane(int index, const glm::vec4& plane, const Core::Geometry::BBox& bbox);
277277

src/Interface/Modules/Render/ViewSceneControls.ui

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>660</width>
9+
<width>704</width>
1010
<height>662</height>
1111
</rect>
1212
</property>
1313
<property name="minimumSize">
1414
<size>
15-
<width>567</width>
15+
<width>704</width>
1616
<height>662</height>
1717
</size>
1818
</property>
@@ -39,7 +39,7 @@
3939
</font>
4040
</property>
4141
<property name="currentIndex">
42-
<number>1</number>
42+
<number>3</number>
4343
</property>
4444
<widget class="QWidget" name="ObjectTab">
4545
<attribute name="title">
@@ -792,6 +792,12 @@
792792
</item>
793793
<item>
794794
<widget class="QCheckBox" name="showPlaneFrameCheckBox_">
795+
<property name="enabled">
796+
<bool>false</bool>
797+
</property>
798+
<property name="toolTip">
799+
<string>BROKEN: See issue https://github.com/SCIInstitute/SCIRun/issues/2248</string>
800+
</property>
795801
<property name="accessibleDescription">
796802
<string/>
797803
</property>

0 commit comments

Comments
 (0)