inline ExtrudedShape<T, D>::ExtrudedShape(const Shape<T, D-1> &b, T l):
length(l)
{
- if(l<=0)
+ if(l<=T(0))
throw std::invalid_argument("ExtrudedShape::ExtrudedShape");
base = b.clone();
{
BoundingBox<T, D-1> base_bbox = base->get_axis_aligned_bounding_box();
T half_length = length/T(2);
- return BoundingBox<T, D>(LinAl::Vector<T, D>(base_bbox.get_minimum_point(), -half_length),
- LinAl::Vector<T, D>(base_bbox.get_maximum_point(), half_length));
+ return BoundingBox<T, D>(compose(base_bbox.get_minimum_point(), -half_length),
+ compose(base_bbox.get_maximum_point(), half_length));
}
template<typename T, unsigned D>
if(abs(point[D-1])>length/T(2))
return false;
- return base->contains(LinAl::Vector<T, D-1>(point));
+ return base->contains(point.template slice<D-1>(0));
}
template<typename T, unsigned D>
T half_length = length/T(2);
const LinAl::Vector<T, D> &ray_start = ray.get_start();
const LinAl::Vector<T, D> &ray_direction = ray.get_direction();
- LinAl::Vector<T, D-1> base_dir(ray_direction);
+ LinAl::Vector<T, D-1> base_dir = ray_direction.template slice<D-1>(0);
/* If the ray does not degenerate to a point in the base space, it could
intersect the base shape. */
if(limit>=offset)
{
T distortion = base_dir.norm();
- Ray<T, D-1> base_ray(LinAl::Vector<T, D-1>(ray_start+ray_direction*offset),
+ Ray<T, D-1> base_ray((ray_start+ray_direction*offset).template slice<D-1>(0),
base_dir, (limit-offset)*distortion);
SurfacePoint<T, D-1> *base_points = 0;
if(points)
- /* Shamelessly reuse the provided storage. Align to the end of the array
- so processing can start from the first (nearest) point. */
+ /* Shamelessly reuse the provided storage. Align to the end of the
+ array so processing can start from the first (nearest) point. */
base_points = reinterpret_cast<SurfacePoint<T, D-1> *>(points+size)-size;
unsigned count = base->get_intersections(base_ray, base_points, size);
{
T x = offset+base_points[i].distance/distortion;
points[n].position = ray_start+ray_direction*x;
- points[n].normal = LinAl::Vector<T, D>(base_points[i].normal, T(0));
+ points[n].normal = compose(base_points[i].normal, T(0));
points[n].distance = x;
+ points[n].entry = base_points[i].entry;
}
++n;
continue;
LinAl::Vector<T, D> p = ray_start+ray_direction*x;
- if(base->contains(LinAl::Vector<T, D-1>(p)))
+ if(base->contains(p.template slice<D-1>(0)))
{
if(points)
{
points[n].normal = LinAl::Vector<T, D>();
points[n].normal[D-1] = i;
points[n].distance = x;
+ points[n].entry = (T(i)*ray_direction[D-1]<T(0));
}
++n;