-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSceneObjectPlane.c
38 lines (24 loc) · 1.05 KB
/
SceneObjectPlane.c
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
#include "SceneObjectPlane.h"
const SceneObjectVTable sceneObjectPlaneVTable = (SceneObjectVTable) {
&sceneObjectPlaneIntersectRay,
&sceneObjectPlaneEmitPhotons,
&sceneObjectPlaneRadiantFlux
};
SceneObjectPlane makeSceneObjectPlane (const Plane plane, const Material *material) {
return (SceneObjectPlane) {makeSceneObject(&sceneObjectPlaneVTable), plane, material};
}
defineAllocator(SceneObjectPlane)
Intersection sceneObjectPlaneIntersectRay(const SceneObject *superobject, const Ray ray) {
SceneObjectPlane *object = (SceneObjectPlane *) superobject;
Intersection intersection = pIntersect(object->plane, ray);
intersection.material = object->material;
return intersection;
}
bool sceneObjectPlaneEmitPhotons(const SceneObject *superobject, const int numPhotons, PhotonContainer *photons) {
// You can't really emit a finite number of photons from an infinite plane.
return false;
}
Color sceneObjectPlaneRadiantFlux(const SceneObject *object) {
// Since a plane can't emit photons, it shouldn't have any flux.
return makeColorBlack();
}