use std::collections::HashMap;
use openconfiguration_derive::Visitable;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::{impl_visitable_noop, support::Visitor};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Visitable, Default)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "schema", schemars(deny_unknown_fields))]
#[serde(rename_all = "camelCase", rename = "igGeometry")]
pub struct Geometry {
pub preview_format: Option<GeometryPreviewFormat>,
#[visitable(visit_with = "crate::support::visit_path")]
pub preview: Option<String>,
pub collider_format: Option<GeometryColliderFormat>,
#[visitable(visit_with = "crate::support::visit_path")]
pub collider: Option<String>,
pub mesh_format: Option<GeometryMeshFormat>,
#[visitable(visit_with = "crate::support::visit_path")]
pub mesh: Option<String>,
pub normal_map_format: Option<GeometryNormalMapFormat>,
#[visitable(visit_with = "crate::support::visit_path")]
pub normal_map: Option<String>,
#[serde(
deserialize_with = "crate::utils::deserialize_optional_map_without_null_values",
default
)]
#[visitable(visit_with = "visit_map_with_paths")]
pub extra_normal_maps: Option<HashMap<String, String>>,
pub deformation_format: Option<GeometryDeformationFormat>,
#[visitable(visit_with = "crate::support::visit_path")]
pub deformation: Option<String>,
#[serde(rename = "deformationXDataFormat")]
pub deformation_xdata_format: Option<GeometryDeformationXDataFormat>,
#[serde(rename = "deformationXData")]
#[visitable(visit_with = "crate::support::visit_path")]
pub deformation_xdata: Option<String>,
#[serde(
deserialize_with = "crate::utils::deserialize_optional_map_without_null_values",
default
)]
pub parameters: Option<HashMap<String, Value>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum GeometryPreviewFormat {
OpenCTM,
OBJ,
GLB,
FBX,
}
impl_visitable_noop!(GeometryPreviewFormat);
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum GeometryColliderFormat {
OpenCTM,
OBJ,
GLB,
FBX,
}
impl_visitable_noop!(GeometryColliderFormat);
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum GeometryMeshFormat {
OpenCTM,
OBJ,
GLB,
FBX,
DWF,
}
impl_visitable_noop!(GeometryMeshFormat);
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum GeometryNormalMapFormat {
JPEG,
PNG,
}
impl_visitable_noop!(GeometryNormalMapFormat);
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum GeometryDeformationFormat {
FFD,
JSON,
}
impl_visitable_noop!(GeometryDeformationFormat);
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum GeometryDeformationXDataFormat {
#[serde(rename = "glTF")]
GLTF,
GLB,
}
impl_visitable_noop!(GeometryDeformationXDataFormat);
fn visit_map_with_paths(value: &mut Option<HashMap<String, String>>, visitor: &mut dyn Visitor) {
if let Some(map) = value {
for (_key, value) in map {
visitor.visit_path(value);
}
}
}