Skip to content

Commit 36892cf

Browse files
authored
Merge pull request #2249 from SCIInstitute/final-Z-fixes
Final Z fixes
2 parents e1b9b96 + 3a7ef69 commit 36892cf

File tree

11 files changed

+84
-77
lines changed

11 files changed

+84
-77
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/Graphics/Widgets/Tests/BasicBoundingBoxWidgetTest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
using namespace SCIRun::Graphics::Datatypes;
3434
using namespace SCIRun::Core::Geometry;
3535

36-
TEST(BasicBoundingBoxWidgetTest, CanCreateSingleBoxReal)
36+
TEST(BasicBoundingBoxWidgetTest, DISABLED_CanCreateSingleBoxReal)
3737
{
3838
StubGeometryIDGenerator idGen;
3939

@@ -50,7 +50,7 @@ TEST(BasicBoundingBoxWidgetTest, CanCreateSingleBoxReal)
5050
//FAIL() << "todo";
5151
}
5252

53-
TEST(BasicBoundingBoxWidgetTest, CanCreateSingleBoxStubbed)
53+
TEST(BasicBoundingBoxWidgetTest, DISABLED_CanCreateSingleBoxStubbed)
5454
{
5555
StubGeometryIDGenerator idGen;
5656

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,7 @@ namespace SCIRun
146146
glm::mat4 widgetTransform_ {1.0f};
147147
};
148148

149-
namespace
150-
{
151-
Graphics::Datatypes::WidgetInteraction yetAnotherEnumConversion(Core::Datatypes::MouseButton btn)
152-
{
153-
switch (btn)
154-
{
155-
case Core::Datatypes::MouseButton::LEFT:
156-
return Graphics::Datatypes::WidgetInteraction::CLICK;
157-
case Core::Datatypes::MouseButton::RIGHT:
158-
return Graphics::Datatypes::WidgetInteraction::RIGHT_CLICK;
159-
default:
160-
return Graphics::Datatypes::WidgetInteraction::CLICK;
161-
}
162-
}
163-
}
164-
149+
SCISHARE Graphics::Datatypes::WidgetInteraction yetAnotherEnumConversion(Core::Datatypes::MouseButton btn);
165150
SCISHARE std::ostream& operator<<(std::ostream& o, const glm::mat4& m);
166151
}
167152
}

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/ES/WidgetHandling.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,16 @@ ObjectTransformCalculatorPtr ObjectTransformCalculatorFactory::create(WidgetMove
232232
return nullptr;
233233
}
234234
}
235+
236+
Graphics::Datatypes::WidgetInteraction SCIRun::Render::yetAnotherEnumConversion(Core::Datatypes::MouseButton btn)
237+
{
238+
switch (btn)
239+
{
240+
case Core::Datatypes::MouseButton::LEFT:
241+
return Graphics::Datatypes::WidgetInteraction::CLICK;
242+
case Core::Datatypes::MouseButton::RIGHT:
243+
return Graphics::Datatypes::WidgetInteraction::RIGHT_CLICK;
244+
default:
245+
return Graphics::Datatypes::WidgetInteraction::CLICK;
246+
}
247+
}

src/Interface/Modules/Render/Tests/ObjectScalingTests.cc

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ TEST_F(ScalingTest, CanScaleHorizontalFromOrigin)
6161

6262
auto t = scaler.computeTransform(10, 0);
6363

64-
//std::cout << std::setprecision(16) << t.transform << std::endl;
65-
6664
glm::mat4 expected;
67-
expected[0] = glm::vec4{-0.3229167461395264, 0.645833432674408, 0.6458333134651184, 0};
68-
expected[1] = glm::vec4{0.6458333134651184, -0.3229167461395264, 0.645833432674408, 0};
69-
expected[2] = glm::vec4{0.645833432674408, 0.6458333134651184, -0.3229167461395264, 0};
65+
expected[0] = glm::vec4{0.9687501192092896, 0., 0., 0};
66+
expected[1] = glm::vec4{0., 0.9687501192092896, 0., 0};
67+
expected[2] = glm::vec4{0., 0., 0.9687501192092896, 0};
7068
expected[3] = glm::vec4{0, 0, 0, 1};
7169

70+
//std::cout << std::setprecision(16) << t.transform << std::endl << expected << std::endl;
71+
7272
EXPECT_TRUE(t.transform == expected);
7373
}
7474

@@ -84,15 +84,15 @@ TEST_F(ScalingTest, CanScaleVerticalFromOrigin)
8484

8585
auto t = scaler.computeTransform(1, 10);
8686

87-
//std::cout << std::setprecision(16) << t.transform << std::endl;
88-
8987
glm::mat4 expected;
9088

91-
expected[0] = glm::vec4{-0.3322917520999908, 0.6645834445953369, 0.6645833253860474, 0};
92-
expected[1] = glm::vec4{0.6645833253860474, -0.3322917520999908, 0.6645834445953369, 0};
93-
expected[2] = glm::vec4{0.6645834445953369, 0.6645833253860474, -0.3322917520999908, 0};
89+
expected[0] = glm::vec4{0.996874988079071, 0., 0., 0};
90+
expected[1] = glm::vec4{0., 0.996874988079071, 0., 0};
91+
expected[2] = glm::vec4{0., 0., 0.996874988079071, 0};
9492
expected[3] = glm::vec4{0, 0, 0, 1};
9593

94+
//std::cout << std::setprecision(16) << t.transform << std::endl << expected << std::endl;
95+
9696
EXPECT_TRUE(t.transform == expected);
9797
}
9898

@@ -108,14 +108,14 @@ TEST_F(ScalingTest, CanScaleThroughFlipAxis)
108108

109109
auto t = scaler.computeTransform(10, 10);
110110

111-
//std::cout << std::setprecision(16) << t.transform << std::endl;
112-
113111
glm::mat4 expected;
114-
expected[0] = glm::vec4{-0.322916716337204, 0.6458333730697632, 0.6458332538604736, 0};
115-
expected[1] = glm::vec4{0.6458332538604736, -0.322916716337204, 0.6458333730697632, 0};
116-
expected[2] = glm::vec4{0.6458333730697632, 0.6458332538604736, -0.322916716337204, 0};
112+
expected[0] = glm::vec4{0.9687500596046448, 0., 0., 0};
113+
expected[1] = glm::vec4{0., 0.9687500596046448, 0., 0};
114+
expected[2] = glm::vec4{0., 0., 0.9687500596046448, 0};
117115
expected[3] = glm::vec4{0, 0, 0, 1};
118116

117+
//std::cout << std::setprecision(16) << t.transform << std::endl << expected << std::endl;
118+
119119
EXPECT_TRUE(t.transform == expected);
120120
}
121121

@@ -131,14 +131,14 @@ TEST_F(ScalingTest, CanScaleArbitraryFromOrigin)
131131

132132
auto t = scaler.computeTransform(-12, 42);
133133

134-
//std::cout << std::setprecision(16) << t.transform << std::endl;
135-
136134
glm::mat4 expected;
137-
expected[0] = glm::vec4{-0.3458333909511566, 0.6916667222976685, 0.6916666030883789, 0};
138-
expected[1] = glm::vec4{0.6916666030883789, -0.3458333909511566, 0.6916667222976685, 0};
139-
expected[2] = glm::vec4{0.6916667222976685, 0.6916666030883789, -0.3458333909511566, 0};
135+
expected[0] = glm::vec4{1.037500143051147, 0., 0., 0};
136+
expected[1] = glm::vec4{0., 1.037500143051147, 0., 0};
137+
expected[2] = glm::vec4{0., 0., 1.037500143051147, 0};
140138
expected[3] = glm::vec4{0, 0, 0, 1};
141139

140+
//std::cout << std::setprecision(16) << t.transform << std::endl << expected << std::endl;
141+
142142
EXPECT_TRUE(t.transform == expected);
143143
}
144144

@@ -154,14 +154,14 @@ TEST_F(ScalingTest, CanScaleArbitraryFromArbitrary)
154154

155155
auto t = scaler.computeTransform(-30, 10);
156156

157-
//std::cout << std::setprecision(16) << t.transform << std::endl;
158-
159157
// almost identity matrix...
160158
glm::mat4 expected;
161159
expected[0] = glm::vec4{0.9999999403953552, 0, 0, 0};
162160
expected[1] = glm::vec4{0, 0.9999999403953552, 0, 0};
163161
expected[2] = glm::vec4{0, 0, 0.9999999403953552, 0};
164162
expected[3] = glm::vec4{5.960464477539062e-08, 1.192092895507812e-07, 2.384185791015625e-07, 1};
165163

164+
//std::cout << std::setprecision(16) << t.transform << std::endl << expected << std::endl;
165+
166166
EXPECT_TRUE(t.transform == expected);
167167
}

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);

0 commit comments

Comments
 (0)