| 72 | } // namespace |
| 73 | |
| 74 | SciVisData::SciVisData(const World &world) |
| 75 | : AddStructShared(world.getISPCDevice().getDRTDevice()) |
| 76 | { |
| 77 | std::vector<ispc::Light *> lightShs; |
| 78 | vec3f aoColor = vec3f(0.f); |
| 79 | uint32_t visibleOnly = 0; |
| 80 | |
| 81 | // Add lights not assigned to any instance |
| 82 | if (world.lights) |
| 83 | aoColor += addLightsToArray(lightShs, visibleOnly, world.lights, nullptr); |
| 84 | |
| 85 | // Iterate through all world instances |
| 86 | if (world.instances) { |
| 87 | for (auto &&inst : *world.instances) { |
| 88 | // Skip instances without lights |
| 89 | if (!inst->group->lights) |
| 90 | continue; |
| 91 | |
| 92 | // Add instance lights to array |
| 93 | aoColor += addLightsToArray( |
| 94 | lightShs, visibleOnly, inst->group->lights, inst->getSh()); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // Then create shared buffer from the temporary std::vector |
| 99 | lightArray = devicert::make_buffer_shared_unique<ispc::Light *>( |
| 100 | world.getISPCDevice().getDRTDevice(), lightShs); |
| 101 | getSh()->lights = lightArray->sharedPtr(); |
| 102 | getSh()->numLights = lightArray->size(); |
| 103 | getSh()->numLightsVisibleOnly = visibleOnly; |
| 104 | getSh()->aoColorPi = aoColor * float(pi); |
| 105 | } |
| 106 | |
| 107 | SciVisData::~SciVisData() |
| 108 | { |
nothing calls this directly
no test coverage detected