MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ read_bounds()

MAYAFLUX_API std::optional< Kinesis::AABB3D > MayaFlux::Nexus::read_bounds ( const std::shared_ptr< Buffers::VKBuffer > &  buf,
const std::optional< uint32_t > &  collection = std::nullopt 
)

Bounds of a buffer's geometry in its own stored coordinates.

A VolumeGridBuffer reports its lattice bounds. A NetworkGeometryBuffer reports its vertices, or those of one collection. The primary operator only knows the authored positions and the CPU updates it dispatched, so once the chain holds a GpuFieldOperator the bytes are downloaded from the device instead, as the spatial export does; before the device buffer exists the operator's bytes are used. A GeometryBuffer on a node other than a MeshWriterNode, a point or path node for example, reports the node's own vertices, downloaded from the device when a VertexFieldProcessor is on the buffer. An InstanceNetworkBuffer reports the union of its slots' bounds through the slot transforms as the CPU holds them; the eight corners are placed, so a rotated slot is bounded loosely, and a transform a GPU kernel drives is not seen. Other mesh buffers are read as read_anchor reads them. Blocks for a ComputeMeshBuffer and for a buffer a field processor drives: call it from a FRAME_ACCURATE metro or the main thread, never the graphics thread.

Parameters
bufBuffer to read.
collectionCollection of a NetworkGeometryBuffer to bound, if not all of it. Ignored for other buffers.
Returns
The bounds, or nullopt when no geometry can be read from the buffer.

Definition at line 256 of file Survey.cpp.

259{
260 if (const auto volume = std::dynamic_pointer_cast<Buffers::VolumeGridBuffer>(buf)) {
261 return volume->get_bounds();
262 }
263
264 if (const auto network_buffer = std::dynamic_pointer_cast<Buffers::NetworkGeometryBuffer>(buf)) {
265 const auto cloud = network_cloud(network_buffer);
266 if (!cloud || cloud->positions.empty()) {
267 return std::nullopt;
268 }
269 if (!collection) {
270 return Kinesis::aabb(cloud->positions);
271 }
272
273 std::vector<glm::vec3> chosen;
274 const size_t count = std::min(cloud->positions.size(), cloud->clusters.size());
275 for (size_t i = 0; i < count; ++i) {
276 if (cloud->clusters.at(i) == *collection) {
277 chosen.push_back(cloud->positions.at(i));
278 }
279 }
280 return chosen.empty() ? std::nullopt : std::optional<Kinesis::AABB3D> { Kinesis::aabb(chosen) };
281 }
282
283 if (const auto geometry = std::dynamic_pointer_cast<Buffers::GeometryBuffer>(buf)) {
284 if (const auto cloud = node_cloud(geometry); cloud && !cloud->positions.empty()) {
285 return Kinesis::aabb(cloud->positions);
286 }
287 }
288
289 if (const auto instances = std::dynamic_pointer_cast<Buffers::InstanceNetworkBuffer>(buf)) {
290 return instance_bounds(instances);
291 }
292
293 const auto mesh = snapshot_mesh(buf);
294 const auto* vertices = mesh ? std::get_if<std::vector<uint8_t>>(&mesh->vertex_variant) : nullptr;
295 if (!vertices) {
296 return std::nullopt;
297 }
298
299 const auto positions = decode_positions(*vertices, mesh->layout);
300 return positions && !positions->empty() ? std::optional<Kinesis::AABB3D> { Kinesis::aabb(*positions) } : std::nullopt;
301}
std::vector< glm::vec3 > positions
Definition Survey.cpp:89
size_t count

References count, positions, and read_bounds().

Referenced by MayaFlux::Nexus::Hull::Hull(), MayaFlux::Nexus::Mantle::Mantle(), read_bounds(), MayaFlux::Nexus::Hull::refit(), and MayaFlux::Nexus::Mantle::refit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: