50#ifndef LASS_GUARDIAN_OF_INCLUSION_SPAT_DEFAULT_OBJECT_TRAITS_H
51#define LASS_GUARDIAN_OF_INCLUSION_SPAT_DEFAULT_OBJECT_TRAITS_H
67struct DefaultAabbRayTraits
69 typedef AabbType TAabb;
72 typedef typename TAabb::TPoint TPoint;
73 typedef typename TAabb::TVector TVector;
74 typedef typename TAabb::TValue TValue;
75 typedef typename TAabb::TParam TParam;
76 typedef typename TAabb::TReference TReference;
77 typedef typename TAabb::TConstReference TConstReference;
79 enum { dimension = TAabb::dimension };
85 static const TAabb aabbEmpty()
90 static const TAabb aabbMake(
const TPoint& min,
const TPoint& max)
92 return TAabb(min, max);
97 static bool aabbContains(
const TAabb& aabb,
const TPoint& point)
99 return aabb.contains(point);
102 static bool aabbContains(
const TAabb& aabb,
const TAabb& other)
104 return aabb.contains(other);
107 static bool aabbIntersects(
const TAabb& aabb,
const TAabb& other)
109 return aabb.intersects(other);
114 static bool aabbIntersect(
const TAabb& aabb,
const TRay& ray, TReference t,
const TParam tMin)
116 return intersect(aabb, ray, t, tMin) !=
prim::rNone;
121 static bool aabbIntersect(
const TAabb& aabb,
const TRay& ray,
const TVector& invDirection, TReference t,
const TParam tMin)
123 return intersect(aabb, ray, invDirection, t, tMin) !=
prim::rNone;
128 static const TAabb aabbJoin(
const TAabb& a,
const TAabb& b)
135 static const TPoint aabbMin(
const TAabb& aabb)
142 static const TPoint aabbMax(
const TAabb& aabb)
149 static TValue aabbSurfaceArea(
const TAabb& aabb)
151 return aabbSurfaceArea(aabb, meta::Int<dimension>());
159 static const TPoint raySupport(
const TRay& ray)
161 return ray.support();
166 static const TVector rayDirection(
const TRay& ray)
168 return ray.direction();
173 static const TPoint rayPoint(
const TRay& ray, TParam t)
183 static const TValue coord(
const TPoint& point,
size_t axis)
190 static void coord(TPoint& point,
size_t axis, TParam value)
197 static const TValue coord(
const TVector& vector,
size_t axis)
204 static void coord(TVector& vector,
size_t axis, TParam value)
206 vector[axis] = value;
211 static const TVector vectorReciprocal(
const TVector& vector)
213 return vector.reciprocal();
218 static TValue aabbSurfaceArea(
const TAabb& aabb, meta::Int<2>)
220 return aabb.perimeter();
222 static TValue aabbSurfaceArea(
const TAabb& aabb, meta::Int<3>)
233 typename AabbType =
typename ObjectType::TAabb,
234 typename RayType =
typename ObjectType::TRay,
235 typename ObjectIterator =
const ObjectType*
244 typedef typename DefaultAabbRayTraits<AabbType, RayType>::TAabb TAabb;
245 typedef typename DefaultAabbRayTraits<AabbType, RayType>::TRay TRay;
246 typedef typename DefaultAabbRayTraits<AabbType, RayType>::TPoint TPoint;
247 typedef typename DefaultAabbRayTraits<AabbType, RayType>::TVector TVector;
248 typedef typename DefaultAabbRayTraits<AabbType, RayType>::TValue TValue;
249 typedef typename DefaultAabbRayTraits<AabbType, RayType>::TParam TParam;
250 typedef typename DefaultAabbRayTraits<AabbType, RayType>::TReference TReference;
251 typedef typename DefaultAabbRayTraits<AabbType, RayType>::TConstReference TConstReference;
264 return aabb(
object(it));
271 return object(it).contains(point);
278 return intersect(
object(it), ray, t, tMin) !=
prim::rNone;
286 return intersect(
object(it), ray, t, tMin) !=
prim::rNone && t < tMax;
293 return intersects(
object(it), aabb);
300 return squaredDistance(
object(it), point);
@ rNone
operation has no answer, output arguments are meaningless
spatial subdivisions, quadtrees, octrees, meshes in 2D and 3D, triangulators, ...
Library for Assembled Shared Sources.
default traits for objects to be stored in spatial subdivision trees
static const TValue objectSquaredDistance(TObjectIterator it, const TPoint &point, const TInfo *)
return squared distance between object and point)
ObjectIterator TObjectIterator
iterator to object
static bool objectIntersect(TObjectIterator it, const TRay &ray, TReference t, TParam tMin, const TInfo *)
return true if object is intersected by ray
static const TAabb objectAabb(TObjectIterator it)
return the AABB of an object
static bool objectIntersects(TObjectIterator it, const TAabb &aabb, const TInfo *)
return true if part of the object is inside the bounding box
void TInfo
extra info for contain/intersect operations
static TValue objectSurfaceArea(TObjectIterator it)
return surface area of object
const TObject & TObjectReference
const reference to object
static bool objectIntersects(TObjectIterator it, const TRay &ray, TParam tMin, TParam tMax, const TInfo *)
return true if object is intersected by ray
static bool objectContains(TObjectIterator it, const TPoint &point, const TInfo *)
return true if object contains a point, return false otherwise
ObjectType TObject
type of nD object
static TObjectReference object(TObjectIterator it)
return reference to object