Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/bvh/bvh.cpp
| Show First 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size) | ||||
| size_t object_offset = 0; | size_t object_offset = 0; | ||||
| map<Mesh*, int> mesh_map; | map<Mesh*, int> mesh_map; | ||||
| foreach(Object *ob, objects) { | foreach(Object *ob, objects) { | ||||
| Mesh *mesh = ob->mesh; | Mesh *mesh = ob->mesh; | ||||
| BVH *bvh = mesh->bvh; | BVH *bvh = mesh->bvh; | ||||
| if(!mesh->transform_applied) { | if(mesh->need_build_bvh()) { | ||||
| if(mesh_map.find(mesh) == mesh_map.end()) { | if(mesh_map.find(mesh) == mesh_map.end()) { | ||||
| prim_index_size += bvh->pack.prim_index.size(); | prim_index_size += bvh->pack.prim_index.size(); | ||||
| tri_woop_size += bvh->pack.tri_woop.size(); | tri_woop_size += bvh->pack.tri_woop.size(); | ||||
| nodes_size += bvh->pack.nodes.size(); | nodes_size += bvh->pack.nodes.size(); | ||||
| leaf_nodes_size += bvh->pack.leaf_nodes.size(); | leaf_nodes_size += bvh->pack.leaf_nodes.size(); | ||||
| mesh_map[mesh] = 1; | mesh_map[mesh] = 1; | ||||
| } | } | ||||
| Show All 18 Lines | void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size) | ||||
| float4 *pack_tri_woop = (pack.tri_woop.size())? &pack.tri_woop[0]: NULL; | float4 *pack_tri_woop = (pack.tri_woop.size())? &pack.tri_woop[0]: NULL; | ||||
| int4 *pack_nodes = (pack.nodes.size())? &pack.nodes[0]: NULL; | int4 *pack_nodes = (pack.nodes.size())? &pack.nodes[0]: NULL; | ||||
| int4 *pack_leaf_nodes = (pack.leaf_nodes.size())? &pack.leaf_nodes[0]: NULL; | int4 *pack_leaf_nodes = (pack.leaf_nodes.size())? &pack.leaf_nodes[0]: NULL; | ||||
| /* merge */ | /* merge */ | ||||
| foreach(Object *ob, objects) { | foreach(Object *ob, objects) { | ||||
| Mesh *mesh = ob->mesh; | Mesh *mesh = ob->mesh; | ||||
| /* if mesh transform is applied, that means it's already in the top | /* We assume that if mesh doesn't need own BVH it was already included | ||||
| * level BVH, and we don't need to merge it in */ | * into a top-level BVH and no packing here is needed. | ||||
| if(mesh->transform_applied) { | */ | ||||
| if(!mesh->need_build_bvh()) { | |||||
| pack.object_node[object_offset++] = 0; | pack.object_node[object_offset++] = 0; | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* if mesh already added once, don't add it again, but used set | /* if mesh already added once, don't add it again, but used set | ||||
| * node offset for this object */ | * node offset for this object */ | ||||
| map<Mesh*, int>::iterator it = mesh_map.find(mesh); | map<Mesh*, int>::iterator it = mesh_map.find(mesh); | ||||
| ▲ Show 20 Lines • Show All 604 Lines • Show Last 20 Lines | |||||