pbrt/src/shapes/disk.rs

37 lines
1.2 KiB
Rust

use crate::core::shape::CreateShape;
use crate::core::texture::FloatTexture;
use crate::utils::{Arena, FileLoc, ParameterDictionary};
use shared::core::shape::Shape;
use shared::shapes::DiskShape;
use shared::utils::Transform;
use std::collections::HashMap;
impl CreateShape for DiskShape {
fn create(
name: &str,
render_from_object: Transform,
object_from_render: Transform,
reverse_orientation: bool,
parameters: ParameterDictionary,
float_textures: HashMap<String, FloatTexture>,
loc: FileLoc,
arena: &mut Arena,
) -> Result<Vec<Shape>, String> {
let height = parameters.get_one_float("height", 0.);
let radius = parameters.get_one_float("radius", 1.);
let inner_radius = parameters.get_one_float("innerradius", 0.);
let phi_max = parameters.get_one_float("phimax", 360.);
let shape = DiskShape::new(
radius,
inner_radius,
height,
phi_max,
render_from_object,
object_from_render,
reverse_orientation,
);
arena.alloc(Shape::Disk(shape));
Ok(vec![Shape::Disk(shape)])
}
}