Mikko Rasa [Mon, 17 Apr 2017 19:27:29 +0000 (22:27 +0300)]
Fix composite shape ray intersection logic
The test for start_nesting coalescence was written the wrong way, causing
intersection shapes to return spurious hits when the ray started inside
some part of the shape. Presumably union shapes did not return hits in
some cases when they should.
Mikko Rasa [Fri, 16 Sep 2016 22:38:05 +0000 (01:38 +0300)]
Use numeric literals in place of M_PI
Recent Windows headers require _USE_MATH_DEFINES to be #defined in order
to #define M_PI, but we can't guarantee that someone else won't #include
<cmath> before us.
Mikko Rasa [Sat, 2 Jul 2016 17:00:50 +0000 (20:00 +0300)]
Ensure that HyperBox does not produce duplicate intersections
In certain corner cases (literally) two coincident intersections could be
produced when the ray passed through the edge of the box, preventing
intersctions on the opposite side from being produced.
Mikko Rasa [Wed, 22 May 2013 20:03:07 +0000 (23:03 +0300)]
Make CompositeShape::get_intersections work with null points
This was a bit tricky, since it's necessary to inspect the points returned
by component shapes to see if they're actually on the composite surface.
To that end, a temporary buffer is allocated. This is most likely used in
interactive point-and-pick situations, so the performance loss should not
be significant.
Mikko Rasa [Wed, 22 May 2013 13:14:16 +0000 (16:14 +0300)]
Rewrite composite shape vector constructors with iterator ranges
Besides the issue of favoring one container type over others, constness
of the contents causes it to be a different, incompatible type. Iterators
solve this in an elegant way.
Mikko Rasa [Tue, 21 May 2013 18:41:15 +0000 (21:41 +0300)]
Make the check_intersection function non-virtual
Almost all shapes were implementing it with a call to get_intersections,
so might as well make the base class do that. Performance loss is likely
negligible.
Mikko Rasa [Tue, 21 May 2013 13:32:49 +0000 (16:32 +0300)]
Math function usage fixes
Add using declarations and #includes where needed, and clean up some
unnecessary ones. abs() is particularly annoying, as the int version
easily gets into the global namespace and doesn't give a warning if
used with floats or doubles.
Mikko Rasa [Sun, 19 May 2013 17:38:22 +0000 (20:38 +0300)]
Don't qualify potentially overloaded functions with the std namespace
Instead put a using std::func before the call. This makes things work if
the template argument is a user-defined type with these functions defined
in another namespace.
Mikko Rasa [Fri, 17 May 2013 10:55:57 +0000 (13:55 +0300)]
Redesign the Vector interface
The constructors from two and three components are now provided directly
by the Vector template, so Vector2 and Vector3 are no longer needed. In
addition, two- and three-component vectors now have named members.