-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Add routine to test circle-rectangle collision
I'm doing this because Raylib's built-in routine for collision detection seems to be erroneous. (Additionally, it's never performed well. In my 1,000 particle test runs, circle testing has been one of the more consistent bottlenecks despite the O(n^2) vs. O(n) time complexities [n = number of particles]. According to my inexpert reading of the profiler's reports, because of the time the CPU spends in converting between integers and floating-points as part of the implementation detail of the routine, which may be causing certain unknown effects that propagate outward.) Or, more precisely, disk-rectangle collision (two-dimensional figures), which means that, if one figure is contained in the other, they are said to be colliding (intersecting). (As opposed to the one-dimensional case where it would be considered not intersecting because no point of intersection is created on the respective curves.) Remaining: 1. At least one affirmative case. 2. Coverage of every branch. 3. Rotated version of each test. Later, I will compute the branch coverage for all tests.
- Loading branch information
1 parent
adf49c6
commit e462fb4
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "gtest/gtest.h" | ||
|
||
#include <complex> | ||
|
||
#include <circle.h> | ||
|
||
/// @brief See `CircleTest0.png` for reference. | ||
class CircleTest0 : public testing::Test { | ||
protected: | ||
const dyn::Circle<float> circle{0, 2.4f}; | ||
// Rectangle's less-less corner | ||
const std::complex<float> less_less{-4.0f, -4.0f}; | ||
// Rectangle's greater-greater corner | ||
const std::complex<float> greater_greater{-2.0f, -2.0f}; | ||
}; | ||
|
||
TEST_F(CircleTest0, Disjoint0) { | ||
ASSERT_FALSE(dyn::disk_rect_intersect(circle, less_less, greater_greater)); | ||
} |