#![allow(dead_code)]
use anyhow::Result;
use crate::sdf::{Path, Value, Variability};
use crate::usd::{Attribute, Prim, Stage};
pub(crate) fn author_float(stage: &Stage, prim: &Path, name: &str, value: f32) -> Result<()> {
let attr_path = prim.append_property(name)?;
stage
.create_attribute(attr_path, "float")?
.set_custom(false)?
.set(Value::Float(value))?;
Ok(())
}
pub(crate) fn author_bool(stage: &Stage, prim: &Path, name: &str, value: bool) -> Result<()> {
let attr_path = prim.append_property(name)?;
stage
.create_attribute(attr_path, "bool")?
.set_custom(false)?
.set(Value::Bool(value))?;
Ok(())
}
pub(crate) fn author_uniform_token(stage: &Stage, prim: &Path, name: &str, value: impl Into<String>) -> Result<()> {
let attr_path = prim.append_property(name)?;
stage
.create_attribute(attr_path, "token")?
.set_variability(Variability::Uniform)?
.set_custom(false)?
.set(Value::Token(value.into()))?;
Ok(())
}
pub(crate) fn author_uniform_token_vec(stage: &Stage, prim: &Path, name: &str, tokens: Vec<String>) -> Result<()> {
let attr_path = prim.append_property(name)?;
stage
.create_attribute(attr_path, "token[]")?
.set_variability(Variability::Uniform)?
.set_custom(false)?
.set(Value::TokenVec(tokens))?;
Ok(())
}
pub(crate) fn author_rel_targets<I, P>(stage: &Stage, prim: &Path, name: &str, targets: I) -> Result<()>
where
I: IntoIterator<Item = P>,
P: Into<Path>,
{
Prim::new(stage, prim.clone()).author_relationship_targets(name, targets)?;
Ok(())
}
pub(crate) fn varying_attribute<'s>(
stage: &'s Stage,
prim: &Path,
name: &str,
type_name: &str,
) -> Result<Attribute<'s>> {
Ok(Prim::new(stage, prim.clone())
.create_attribute(name, type_name)?
.set_custom(false)?)
}