-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Optimized the collision detection logic behind the clipline
function
#4054
base: main
Are you sure you want to change the base?
Conversation
…ions in rect.c file to fix the problem of the rays colliding with 4 or more rectangles
Hey hey. Thanks for this :) There's some warnings different compilers spotted. You can see them in the failed checks if you search for rect.c. Pasted here for your convenience.
|
I have roll back the code into the original to tackle this problem. And for fixing the collision detecting bugs, i have just optimized the code for dealing with the intection between the line and rectangles, create a new function |
Sheepfan0828 Great. Now it seems to be compiling and running the tests :) Now the next step is seeing why these tests are failing? |
Thanks for your responding! I have just reviewed some of error messages from failed checks in CI, it says the problem also exist in existing files in |
hi. It looks like there are a number of tests failing. See below.
|
Let me know if you want some help continuing this? |
Contributor
Name: Yilun Fan (u7277320)
Issue Addressed
#3999
PR Summary
The issue i am fixing now is about the bug occurs in
Rect.clipline()
function dealing with the collision between lines of different angles, and 4 or more than 4 rectangles. For dealing with this, i have reproduced the problem at first, by creating 4 rectangles and lines of the angle within 0-180 degrees inclusive so that we can useRect.clipline
function to check whether a collision has been occured. The result is shown below and we supposed line has the red color if a collision has benn dectected and green color otherwise.We can observe that most of the lines are still green although the line is actually colliding with the other rectangles.
And then, according to the issue description, we have two tasks to deal with:
For task 1, I have added the unittest for
Rect.clipline()
intest/test_rect.py
file (i cannot findrect.py
intest
folder and only find this). This unittest is mainly testing the case of the collision with 4 or more rectangles using the functionRect.clipline()
and get the following failure:For task 2, I have modified the code in rect.c@pg_rect_clipline to optimize the Intersection collision detection logic with the basic argument analysis unchanged. I have created my own
IntersectRectAndLine
function so that it will be integrated intp thepg_rect_clipline
function to improve the accuracy of the collision dectection between the line and the rectangles.