Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/bvh/bvh_embree.cpp
| Show First 20 Lines • Show All 296 Lines • ▼ Show 20 Lines | |||||
| /* This is to have a shared device between all BVH instances. | /* This is to have a shared device between all BVH instances. | ||||
| It would be useful to actually to use a separte RTCDevice per Cycles instance␐. */ | It would be useful to actually to use a separte RTCDevice per Cycles instance␐. */ | ||||
| RTCDevice BVHEmbree::rtc_shared_device = NULL; | RTCDevice BVHEmbree::rtc_shared_device = NULL; | ||||
| int BVHEmbree::rtc_shared_users = 0; | int BVHEmbree::rtc_shared_users = 0; | ||||
| thread_mutex BVHEmbree::rtc_shared_mutex; | thread_mutex BVHEmbree::rtc_shared_mutex; | ||||
| static size_t count_primitives(Geometry *geom) | static size_t count_primitives(Geometry *geom) | ||||
| { | { | ||||
| if (geom->type == Geometry::MESH) { | if (geom->type == Geometry::MESH || geom->type == Geometry::VOLUME) { | ||||
| Mesh *mesh = static_cast<Mesh *>(geom); | Mesh *mesh = static_cast<Mesh *>(geom); | ||||
| return mesh->num_triangles(); | return mesh->num_triangles(); | ||||
| } | } | ||||
| else if (geom->type == Geometry::HAIR) { | else if (geom->type == Geometry::HAIR) { | ||||
| Hair *hair = static_cast<Hair *>(geom); | Hair *hair = static_cast<Hair *>(geom); | ||||
| return hair->num_segments(); | return hair->num_segments(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | BVHNode *BVHEmbree::widen_children_nodes(const BVHNode * /*root*/) | ||||
| assert(!"Must not be called."); | assert(!"Must not be called."); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| void BVHEmbree::add_object(Object *ob, int i) | void BVHEmbree::add_object(Object *ob, int i) | ||||
| { | { | ||||
| Geometry *geom = ob->geometry; | Geometry *geom = ob->geometry; | ||||
| if (geom->type == Geometry::MESH) { | if (geom->type == Geometry::MESH || geom->type == Geometry::VOLUME) { | ||||
| Mesh *mesh = static_cast<Mesh *>(geom); | Mesh *mesh = static_cast<Mesh *>(geom); | ||||
| if (mesh->num_triangles() > 0) { | if (mesh->num_triangles() > 0) { | ||||
| add_triangles(ob, mesh, i); | add_triangles(ob, mesh, i); | ||||
| } | } | ||||
| } | } | ||||
| else if (geom->type == Geometry::HAIR) { | else if (geom->type == Geometry::HAIR) { | ||||
| Hair *hair = static_cast<Hair *>(geom); | Hair *hair = static_cast<Hair *>(geom); | ||||
| if (hair->num_curves() > 0) { | if (hair->num_curves() > 0) { | ||||
| ▲ Show 20 Lines • Show All 431 Lines • ▼ Show 20 Lines | |||||
| void BVHEmbree::refit_nodes() | void BVHEmbree::refit_nodes() | ||||
| { | { | ||||
| /* Update all vertex buffers, then tell Embree to rebuild/-fit the BVHs. */ | /* Update all vertex buffers, then tell Embree to rebuild/-fit the BVHs. */ | ||||
| unsigned geom_id = 0; | unsigned geom_id = 0; | ||||
| foreach (Object *ob, objects) { | foreach (Object *ob, objects) { | ||||
| if (!params.top_level || (ob->is_traceable() && !ob->geometry->is_instanced())) { | if (!params.top_level || (ob->is_traceable() && !ob->geometry->is_instanced())) { | ||||
| Geometry *geom = ob->geometry; | Geometry *geom = ob->geometry; | ||||
| if (geom->type == Geometry::MESH) { | if (geom->type == Geometry::MESH || geom->type == Geometry::VOLUME) { | ||||
| Mesh *mesh = static_cast<Mesh *>(geom); | Mesh *mesh = static_cast<Mesh *>(geom); | ||||
| if (mesh->num_triangles() > 0) { | if (mesh->num_triangles() > 0) { | ||||
| update_tri_vertex_buffer(rtcGetGeometry(scene, geom_id), mesh); | update_tri_vertex_buffer(rtcGetGeometry(scene, geom_id), mesh); | ||||
| rtcCommitGeometry(rtcGetGeometry(scene, geom_id)); | rtcCommitGeometry(rtcGetGeometry(scene, geom_id)); | ||||
| } | } | ||||
| } | } | ||||
| else if (geom->type == Geometry::HAIR) { | else if (geom->type == Geometry::HAIR) { | ||||
| Hair *hair = static_cast<Hair *>(geom); | Hair *hair = static_cast<Hair *>(geom); | ||||
| Show All 13 Lines | |||||