use objc2::{
extern_class, extern_conformance, extern_methods, msg_send,
rc::{Allocated, Retained},
runtime::{NSObject, ProtocolObject},
};
use objc2_foundation::{CopyingHelper, NSArray, NSCopying, NSObjectProtocol};
use crate::{
MTLAccelerationStructureGeometryDescriptor, MTLAttributeFormat, MTLBuffer, MTLIndexType, MTLMatrixLayout,
MTLMotionKeyframeData,
};
extern_class!(
#[unsafe(super(MTLAccelerationStructureGeometryDescriptor, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTLAccelerationStructureMotionTriangleGeometryDescriptor;
);
extern_conformance!(
unsafe impl NSCopying for MTLAccelerationStructureMotionTriangleGeometryDescriptor {}
);
unsafe impl CopyingHelper for MTLAccelerationStructureMotionTriangleGeometryDescriptor {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for MTLAccelerationStructureMotionTriangleGeometryDescriptor {}
);
impl MTLAccelerationStructureMotionTriangleGeometryDescriptor {
extern_methods!(
#[unsafe(method(vertexFormat))]
#[unsafe(method_family = none)]
pub fn vertex_format(&self) -> MTLAttributeFormat;
#[unsafe(method(setVertexFormat:))]
#[unsafe(method_family = none)]
pub fn set_vertex_format(
&self,
vertex_format: MTLAttributeFormat,
);
#[unsafe(method(vertexStride))]
#[unsafe(method_family = none)]
pub fn vertex_stride(&self) -> usize;
#[unsafe(method(setVertexStride:))]
#[unsafe(method_family = none)]
pub fn set_vertex_stride(
&self,
vertex_stride: usize,
);
#[unsafe(method(indexBuffer))]
#[unsafe(method_family = none)]
pub fn index_buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
#[unsafe(method(setIndexBuffer:))]
#[unsafe(method_family = none)]
pub fn set_index_buffer(
&self,
index_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
);
#[unsafe(method(indexBufferOffset))]
#[unsafe(method_family = none)]
pub fn index_buffer_offset(&self) -> usize;
#[unsafe(method(setIndexBufferOffset:))]
#[unsafe(method_family = none)]
pub fn set_index_buffer_offset(
&self,
index_buffer_offset: usize,
);
#[unsafe(method(indexType))]
#[unsafe(method_family = none)]
pub fn index_type(&self) -> MTLIndexType;
#[unsafe(method(setIndexType:))]
#[unsafe(method_family = none)]
pub fn set_index_type(
&self,
index_type: MTLIndexType,
);
#[unsafe(method(triangleCount))]
#[unsafe(method_family = none)]
pub fn triangle_count(&self) -> usize;
#[unsafe(method(setTriangleCount:))]
#[unsafe(method_family = none)]
pub fn set_triangle_count(
&self,
triangle_count: usize,
);
#[unsafe(method(transformationMatrixBuffer))]
#[unsafe(method_family = none)]
pub fn transformation_matrix_buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
#[unsafe(method(setTransformationMatrixBuffer:))]
#[unsafe(method_family = none)]
pub fn set_transformation_matrix_buffer(
&self,
transformation_matrix_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
);
#[unsafe(method(transformationMatrixBufferOffset))]
#[unsafe(method_family = none)]
pub fn transformation_matrix_buffer_offset(&self) -> usize;
#[unsafe(method(setTransformationMatrixBufferOffset:))]
#[unsafe(method_family = none)]
pub fn set_transformation_matrix_buffer_offset(
&self,
transformation_matrix_buffer_offset: usize,
);
#[unsafe(method(transformationMatrixLayout))]
#[unsafe(method_family = none)]
pub fn transformation_matrix_layout(&self) -> MTLMatrixLayout;
#[unsafe(method(setTransformationMatrixLayout:))]
#[unsafe(method_family = none)]
pub fn set_transformation_matrix_layout(
&self,
transformation_matrix_layout: MTLMatrixLayout,
);
#[unsafe(method(descriptor))]
#[unsafe(method_family = none)]
pub fn descriptor() -> Retained<Self>;
);
pub fn vertex_buffers(&self) -> Box<[Retained<MTLMotionKeyframeData>]> {
let vertex_buffers: Retained<NSArray<MTLMotionKeyframeData>> = unsafe { msg_send![self, vertexBuffers] };
vertex_buffers.to_vec().into_boxed_slice()
}
pub fn set_vertex_buffers(
&self,
vertex_buffers: &[&MTLMotionKeyframeData],
) {
let vertex_buffers = NSArray::from_slice(vertex_buffers);
unsafe {
let _: () = msg_send![self, setVertexBuffers: &*vertex_buffers];
}
}
}
impl MTLAccelerationStructureMotionTriangleGeometryDescriptor {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}