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 ray intersection tests for primitive shapes #199

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from

Conversation

matt439
Copy link
Contributor

@matt439 matt439 commented Dec 13, 2024

Description

There has been growing interest in using SplashKit to perform ray-tracing in both 2D and 3D environments. However, there is a lack of ray-based intersection functions with primitive shapes. I have added ray intersection functions for rectangles, circles, triangles, and quads.

Each shape has been given a function which can output the the intersection position and distance. I have also included an overload of each function that only returns a Boolean. By including the overload, the user is not required to pass arguments by reference which may be confusing to SIT102 students.

I collaborated with Shaun Ratcliff to complete the logic for the intersection functions.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I added a new real-time graphical test to sktest in test_geometry.cpp to demonstrate the functions. It allows the user to move a ray's origin with the arrow keys, while the heading is determined by the mouse cursor's position. All four shapes are present for testing. If an intersection occurs, the corresponding shape is highlighted and the intersection point is shown.

Testing Checklist

  • Tested with sktest

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

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.

1 participant