Skip to content
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

add clip plane changes #230

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

add clip plane changes #230

wants to merge 19 commits into from

Conversation

toloudis
Copy link
Contributor

@toloudis toloudis commented Nov 19, 2024

Resolves #228
Add user clipping plane functionality.

  • Add SceneClipPlane which represents a clipping plane in the scene.
  • Add functionality to volume rendering shaders to apply the clipping plane.
  • Add ClipPlaneTool which displays a grid shape to show where the user clip plane is positioned.
  • Make sure the plane can be rotated and translated into any position in 3d space.

Also adds some basic UI for enabling, showing/hiding, and manipulating the clip plane but the UI will be more or less completely redone. See #233

Note: gh-actions build is broken on windows but due to dependencies and not this code change.

Base automatically changed from feature/refactor-for-clip-plane to main November 22, 2024 23:20
@toloudis toloudis marked this pull request as ready for review January 18, 2025 02:30
@toloudis toloudis requested a review from a team as a code owner January 18, 2025 02:30
@toloudis toloudis requested review from meganrm and ShrimpCryptid and removed request for a team January 18, 2025 02:30
Copy link
Contributor

@ShrimpCryptid ShrimpCryptid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some non-blocking comments and questions!

.github/workflows/build_and_test.yml Outdated Show resolved Hide resolved
Comment on lines +309 to +319
float denom = dot(R.m_D, g_clipPlane.xyz);
if (abs(denom) > 0.0001f) // your favorite epsilon
{
float tClip = dot(g_clipPlane.xyz*(-g_clipPlane.w) - R.m_O, g_clipPlane.xyz) / denom;
if (denom < 0.0f) {
pNearT = max(pNearT, tClip);
}
else {
pFarT = min(pFarT, tClip);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might ask you this in-person, but can you walk me through what this calculation is doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started to type out a text explanation but it was getting long so in person will be more efficient. If you know how ray-plane intersection works that's most of what you are seeing here, and then some logic to combine the ray-plane intersection with the ray-boundingbox intersection.

agave_app/AppearanceSettingsWidget.cpp Show resolved Hide resolved
agave_app/icons/dark/rotate.svg Outdated Show resolved Hide resolved
agave_app/icons/dark/translate.svg Outdated Show resolved Hide resolved
Comment on lines +8 to +15
ClipPlaneTool(Plane plane, glm::vec3& pos)
: ManipulationTool(0)
, m_plane(plane)
, m_pos(pos)
{
// assumes pos is in plane! if not, there will be trouble.
// assert(glm::dot(m_plane.normal, m_pos) == m_plane.d);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to like, project m_pos onto the provided plane?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the pos data stored by the clip plane tool doesn't have to precisely match the m_plane anymore. At init, I forget why I commented this out (and it may just be because I needed an epsilon). I'll have to put the code back and see why.

renderlib/ClipPlaneTool.cpp Show resolved Hide resolved
renderlib/ClipPlaneTool.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

user clip plane
2 participants