line: use aabb for box intersect
This commit is contained in:
parent
50f1e79ed9
commit
a2055b30bf
6
line.cpp
6
line.cpp
@ -53,10 +53,10 @@ util::line<S,T>::intersect (plane<S,T> q) const
|
|||||||
/// returns -ve if behind
|
/// returns -ve if behind
|
||||||
template <size_t S, typename T>
|
template <size_t S, typename T>
|
||||||
T
|
T
|
||||||
util::line<S,T>::intersect (region<S,T> r) const
|
util::line<S,T>::intersect (AABB<S,T> r) const
|
||||||
{
|
{
|
||||||
auto t1 = (r.base () - p) / d;
|
auto t1 = (r.p0 - p) / d;
|
||||||
auto t2 = (r.away () - p) / d;
|
auto t2 = (r.p1 - p) / d;
|
||||||
|
|
||||||
auto vmin = min (t1, t2);
|
auto vmin = min (t1, t2);
|
||||||
auto vmax = max (t1, t2);
|
auto vmax = max (t1, t2);
|
||||||
|
6
line.hpp
6
line.hpp
@ -23,16 +23,16 @@
|
|||||||
#include "point.hpp"
|
#include "point.hpp"
|
||||||
#include "vector.hpp"
|
#include "vector.hpp"
|
||||||
#include "plane.hpp"
|
#include "plane.hpp"
|
||||||
#include "region.hpp"
|
#include "aabb.hpp"
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
template <size_t S, typename T>
|
template <size_t S, typename T>
|
||||||
struct line {
|
struct line {
|
||||||
line (util::point<S,T> place,
|
line (util::point<S,T> origin,
|
||||||
util::vector<S,T> direction);
|
util::vector<S,T> direction);
|
||||||
|
|
||||||
T intersect (plane<S,T>) const;
|
T intersect (plane<S,T>) const;
|
||||||
T intersect (region<S,T>) const;
|
T intersect (AABB<S,T>) const;
|
||||||
|
|
||||||
T closest (point<S,T>) const;
|
T closest (point<S,T>) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user