-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rotate tool should only show front facing rings #169
Changes from all commits
17ee71d
9f64663
007b9a3
749f062
2e529af
86de551
88f604c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,6 +261,8 @@ RotateTool::draw(SceneView& scene, Gesture& gesture) | |
|
||
gesture.graphics.addCommand(GL_LINES); | ||
|
||
glm::vec4 discPlane(camFrame.vz, -glm::dot(camFrame.vz, axis.p)); | ||
|
||
Comment on lines
+264
to
+265
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you break down what this line is doing? I'm assuming it's making a normal vector pointing towards the camera (to be the clipping plane's normal vector) but I'm not quite following how it's getting there. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is standard geometry/linear algebra. The construct for a plane: a normal vector and a distance from the origin. The plane equation is Ax+By+Cz=D. When you "dot" this plane vector with a point (x,y,z,1), you get a number that is positive or negative if the point is on either side of the plane. That's the equivalent to the value of Ax+By+Cz-D. if it's zero, the point is on the plane. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Clarification question, should this be units away from the origin? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, my mistake- it's in world space units from the origin, not from the eye. |
||
float axisscale = scale * 0.85f; | ||
// Draw the x ring in yz plane | ||
{ | ||
|
@@ -269,7 +271,7 @@ RotateTool::draw(SceneView& scene, Gesture& gesture) | |
if (m_activeCode == RotateTool::kRotateX) { | ||
color = glm::vec3(1, 1, 0); | ||
} | ||
gesture.drawCircle(axis.p, axis.l.vy * axisscale, axis.l.vz * axisscale, 48, color, 1, code); | ||
gesture.drawCircle(axis.p, axis.l.vy * axisscale, axis.l.vz * axisscale, 48, color, 1, code, &discPlane); | ||
} | ||
// Draw the y ring in xz plane | ||
{ | ||
|
@@ -278,7 +280,7 @@ RotateTool::draw(SceneView& scene, Gesture& gesture) | |
if (m_activeCode == RotateTool::kRotateY) { | ||
color = glm::vec3(1, 1, 0); | ||
} | ||
gesture.drawCircle(axis.p, axis.l.vz * axisscale, axis.l.vx * axisscale, 48, color, 1, code); | ||
gesture.drawCircle(axis.p, axis.l.vz * axisscale, axis.l.vx * axisscale, 48, color, 1, code, &discPlane); | ||
} | ||
// Draw the z ring in xy plane | ||
{ | ||
|
@@ -287,7 +289,7 @@ RotateTool::draw(SceneView& scene, Gesture& gesture) | |
if (m_activeCode == RotateTool::kRotateZ) { | ||
color = glm::vec3(1, 1, 0); | ||
} | ||
gesture.drawCircle(axis.p, axis.l.vx * axisscale, axis.l.vy * axisscale, 48, color, 1, code); | ||
gesture.drawCircle(axis.p, axis.l.vx * axisscale, axis.l.vy * axisscale, 48, color, 1, code, &discPlane); | ||
} | ||
|
||
// Draw the camera-axis rotation manipulator as a circle always facing the view | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,12 +248,18 @@ class ScopedGlVertexBuffer | |
}; | ||
|
||
void | ||
Gesture::Graphics::draw(SceneView& sceneView, const SelectionBuffer* selection) | ||
Gesture::Graphics::draw(SceneView& sceneView, SelectionBuffer* selection) | ||
{ | ||
// Gesture draw spans across the entire window and it is not restricted to a single | ||
// viewport. | ||
if (this->verts.empty()) { | ||
clearCommands(); | ||
|
||
// TODO: do this clear only once if verts empty on consecutive frames? | ||
// it would save some computation but this is really not a bottleneck here. | ||
if (selection) { | ||
selection->clear(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ignore; approved in previous PR and merged by accident into this one |
||
return; | ||
} | ||
|
||
|
@@ -616,7 +622,8 @@ Gesture::drawCircle(glm::vec3 center, | |
uint32_t numSegments, | ||
glm::vec3 color, | ||
float opacity, | ||
uint32_t code) | ||
uint32_t code, | ||
glm::vec4* clipPlane) | ||
{ | ||
for (int i = 0; i < numSegments; ++i) { | ||
float t0 = float(i) / float(numSegments); | ||
|
@@ -628,8 +635,15 @@ Gesture::drawCircle(glm::vec3 center, | |
glm::vec3 p0 = center + xaxis * cosf(theta0) + yaxis * sinf(theta0); | ||
glm::vec3 p1 = center + xaxis * cosf(theta1) + yaxis * sinf(theta1); | ||
|
||
graphics.addLine(Gesture::Graphics::VertsCode(p0, color, opacity, code), | ||
Gesture::Graphics::VertsCode(p1, color, opacity, code)); | ||
if (clipPlane) { | ||
if (glm::dot(*clipPlane, glm::vec4(p0, 1.0)) > 0 && glm::dot(*clipPlane, glm::vec4(p1, 1.0)) > 0) { | ||
graphics.addLine(Gesture::Graphics::VertsCode(p0, color, opacity, code), | ||
Gesture::Graphics::VertsCode(p1, color, opacity, code)); | ||
} | ||
Comment on lines
+639
to
+642
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of scope of this PR, but if you have a small number of segments or the segments are really large on screen, segments will be hidden if A nicer fix would be to move p0 or p1 to lie on the plane in that case, but it's more code and the bug is probably not visible in AGAVE. Is this current solution (discarding the whole line segment) the standard behavior when rendering with clipping planes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this is admittedly crude but it works if the circles use small enough segments. I'll refine it as needed for future usage. Currently there's nothing else that needs to clip, yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's also possible to use gpu clip planes and have this all done in the shader with good interpolation, but it would result in potentially splitting up the geometry into more draw calls. Currently the code can accumulate lots of line segments into a single draw call even if they are drawing many different things. And while things are still super cheap to draw right now, I didn't feel like routing all the data into the shader and splitting draw calls if they need different clip planes. |
||
} else { | ||
graphics.addLine(Gesture::Graphics::VertsCode(p0, color, opacity, code), | ||
Gesture::Graphics::VertsCode(p1, color, opacity, code)); | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,7 @@ readTiffNumScenes(TIFF* tiff, const std::string& filepath) | |
LOG_WARNING << "Failed to read imagedescription of TIFF: '" << filepath << "'; interpreting as single channel."; | ||
} | ||
|
||
std::string simagedescription = trim(imagedescription); | ||
std::string simagedescription = trim(imagedescription ? imagedescription : ""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ignore; approved in previous PR and merged by accident into this one |
||
|
||
// check for plain tiff with ImageJ imagedescription: | ||
if (startsWith(simagedescription, "ImageJ=")) { | ||
|
@@ -246,7 +246,7 @@ readTiffDimensions(TIFF* tiff, const std::string filepath, VolumeDimensions& dim | |
std::vector<std::string> channelNames; | ||
std::string dimensionOrder = "XYCZT"; | ||
|
||
std::string simagedescription = trim(imagedescription); | ||
std::string simagedescription = trim(imagedescription ? imagedescription : ""); | ||
|
||
// check for plain tiff with ImageJ imagedescription: | ||
if (startsWith(simagedescription, "ImageJ=")) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore; approved in previous PR and merged by accident into this one