scene/records/views.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include "chrono_batch_render/scene/records/products.h" | ||
| 5 | #include "chrono_batch_render/scene/records/sensors.h" | ||
| 6 | #include "chrono_batch_render/stage/schema/schema.h" | ||
| 7 | |||
| 8 | namespace chrono::batch_render { | ||
| 9 | |||
| 10 | static const uint kViewPinhole = 1u << 0; | ||
| 11 | |||
| 12 | 14 | struct ViewRecord { | |
| 13 | Float2 scale; | ||
| 14 | Float2 bias; | ||
| 15 | Float2 clipping; | ||
| 16 | float shutter; | ||
| 17 | float readout; | ||
| 18 | float spread; | ||
| 19 | float exposure; | ||
| 20 | uint flags; | ||
| 21 | uint padding; | ||
| 22 | ArrayRef clippingPlanes; | ||
| 23 | }; | ||
| 24 | |||
| 25 | CHRONO_BATCH_RENDER_CHECK_SIZE(ViewRecord, 64); | ||
| 26 | |||
| 27 | CHRONO_BATCH_RENDER_SHARED Float2 ConformAperture(Float2 aperture, ProductRecord product) { | ||
| 28 | const float image = float(product.width) * product.pixelAspect / float(max(product.height, 1u)); | ||
| 29 | const bool wider = aperture.x > aperture.y * image; | ||
| 30 | Float2 wide; | ||
| 31 | wide.x = aperture.y * image; | ||
| 32 | wide.y = aperture.y; | ||
| 33 | Float2 tall; | ||
| 34 | tall.x = aperture.x; | ||
| 35 | tall.y = aperture.x / image; | ||
| 36 | switch (AspectRatioConformPolicy(product.conform)) { | ||
| 37 | case AspectRatioConformPolicy::ExpandAperture: | ||
| 38 | return wider ? tall : wide; | ||
| 39 | case AspectRatioConformPolicy::CropAperture: | ||
| 40 | return wider ? wide : tall; | ||
| 41 | case AspectRatioConformPolicy::AdjustApertureWidth: | ||
| 42 | return wide; | ||
| 43 | case AspectRatioConformPolicy::AdjustApertureHeight: | ||
| 44 | return tall; | ||
| 45 | default: | ||
| 46 | return aperture; | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | } | ||
| 51 |