-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgeom.h
90 lines (78 loc) · 2.78 KB
/
geom.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once
#include "core.h"
#include "node.h"
#include "embree.h"
class Material;
class AreaLight;
/**
* The base interface for all renderable geometry.
*/
class Geom {
static void embreeBoundsFunc(void* user, size_t i, RTCBounds& bounds);
static void embreeIntersectFunc(void* user, RTCRay& ray, size_t i);
static void embreeOccludedFunc(void* user , RTCRay& ray, size_t i);
static void embreeIntersectCallback(
const Embree::EmbreeObj* eo,
const RTCRay& ray,
Intersection* isectOut
);
protected:
/**
* Constructs a geom with the specified material.
*
* @param m the material used to render the geometry
* @param l the area light causing emission from the geometry
*/
Geom(const Material* m = nullptr, const AreaLight* l = nullptr);
/**
* Constructs a geom from the given node.
*/
Geom(const Node& n);
public:
const Material* mat; /**< The material used to render the geom. */
const AreaLight* light; /**< The area light causing emission from the geom. */
virtual ~Geom();
/**
* Finds an intersection between the geometry and the given ray.
*
* @param r the ray to find an intersection with
* @param isectOut [out] the intersection information if the ray hit the
* geometry, otherwise unmodified; the pointer must not
* be null
* @returns true if the ray hit the geometry, false otherwise
*/
virtual bool intersect(const Ray& r, Intersection* isectOut) const = 0;
/**
* Finds an intersection between the geometry and the given shadow ray.
*
* @param r the shadow ray to find an intersection with
* @param maxDist the maximum distance from the ray origin to the intersection
* @returns true if the ray hit the geometry within maxDist, false
* otherwise
*/
virtual bool intersectShadow(const Ray& r, float maxDist) const = 0;
/**
* A bounding box encapsulating the entire geometry.
*/
virtual BBox boundBox() const = 0;
/**
* A bounding sphere encapsulating the entire geometry.
* If this method is not overriden, then the bounding sphere is
* automatically calculated from the bounding box.
*/
virtual BSphere boundSphere() const;
/**
* Refines a composite object into its constituent parts until the
* parts can be intersected.
*/
virtual void refine(std::vector<const Geom*>& refined) const;
/**
* Makes an Embree geometry object from this geometry.
* Composite objects may choose to create one Embree object composed of
* multiple primitives if they can do so.
*
* @param scene the scene in which to create the Embree object
* @param eo the Embree object to populate
*/
virtual void makeEmbreeObject(RTCScene scene, Embree::EmbreeObj& eo) const;
};