| 14 | // Embree helper functions /////////////////////////////////////////////////// |
| 15 | |
| 16 | static void addGeometryInstance(RTCScene &scene, |
| 17 | RTCScene instScene, |
| 18 | Instance *inst, |
| 19 | RTCDevice embreeDevice, |
| 20 | unsigned int id) |
| 21 | { |
| 22 | if (!embreeDevice) |
| 23 | throw std::runtime_error("invalid Embree device"); |
| 24 | |
| 25 | // Create parent scene if not yet created |
| 26 | if (!scene) |
| 27 | scene = rtcNewScene(embreeDevice); |
| 28 | |
| 29 | // Create geometry instance |
| 30 | auto eInst = rtcNewGeometry(embreeDevice, RTC_GEOMETRY_TYPE_INSTANCE); |
| 31 | rtcSetGeometryInstancedScene(eInst, instScene); |
| 32 | rtcAttachGeometryByID(scene, eInst, id); |
| 33 | inst->setEmbreeGeom(scene, id); |
| 34 | rtcReleaseGeometry(eInst); |
| 35 | } |
| 36 | |
| 37 | static void freeAndNullifyEmbreeScene(RTCScene &scene) |
| 38 | { |