-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathembree.h
49 lines (39 loc) · 1.15 KB
/
embree.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
#pragma once
#include "core.h"
#include "accelerator.h"
#include <vector>
#include <map>
#include <functional>
class Geom;
#include <embree2/rtcore.h>
#include <embree2/rtcore_ray.h>
class Embree : public Accelerator {
static bool embreeInited;
static RTCDevice device;
RTCScene scene;
public:
struct EmbreeVert { float x, y, z, a; };
struct EmbreeTri { int v0, v1, v2; };
struct EmbreeObj {
using IntersectionCallback =
std::function<void(const EmbreeObj*, const RTCRay&, Intersection*)>;
const Geom* geom;
unsigned geomId;
IntersectionCallback isectCallback;
EmbreeObj(const Geom* g, unsigned i, IntersectionCallback c)
: geom(g), geomId(i), isectCallback(c) {}
EmbreeObj()
: geom(nullptr), geomId(RTC_INVALID_GEOMETRY_ID), isectCallback() {}
};
Embree(const std::vector<const Geom*>& o);
static void init();
static void exit();
virtual bool intersect(
const Ray& r,
Intersection* isectOut
) const override;
virtual bool intersectShadow(const Ray& r, float maxDist) const override;
private:
std::vector<EmbreeObj> embreeObjStorage;
std::map<unsigned, const EmbreeObj*> embreeObjLookup;
};