objc2_gameplay_kit/generated/
GKMeshGraph.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Adjusts how graph nodes are created when you triangulate a GKMeshGrapk
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkmeshgraphtriangulationmode?language=objc)
13// NS_OPTIONS
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct GKMeshGraphTriangulationMode(pub NSUInteger);
17bitflags::bitflags! {
18    impl GKMeshGraphTriangulationMode: NSUInteger {
19        #[doc(alias = "GKMeshGraphTriangulationModeVertices")]
20        const Vertices = 1<<0;
21        #[doc(alias = "GKMeshGraphTriangulationModeCenters")]
22        const Centers = 1<<1;
23        #[doc(alias = "GKMeshGraphTriangulationModeEdgeMidpoints")]
24        const EdgeMidpoints = 1<<2;
25    }
26}
27
28unsafe impl Encode for GKMeshGraphTriangulationMode {
29    const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for GKMeshGraphTriangulationMode {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_class!(
37    /// A collection of GKGraphNodes that are governed by a mesh formed by the space between a set of GKPolygonObstacles
38    ///
39    /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkmeshgraph?language=objc)
40    #[unsafe(super(GKGraph, NSObject))]
41    #[derive(Debug, PartialEq, Eq, Hash)]
42    #[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
43    pub struct GKMeshGraph<NodeType: ?Sized = AnyObject>;
44);
45
46#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
47impl<NodeType: ?Sized + Message + AsRef<GKGraphNode2D>> GKMeshGraph<NodeType> {
48    /// Unchecked conversion of the generic parameter.
49    ///
50    /// # Safety
51    ///
52    /// The generic must be valid to reinterpret as the given type.
53    #[inline]
54    pub unsafe fn cast_unchecked<NewNodeType: ?Sized + Message + AsRef<GKGraphNode2D>>(
55        &self,
56    ) -> &GKMeshGraph<NewNodeType> {
57        unsafe { &*((self as *const Self).cast()) }
58    }
59}
60
61#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
62extern_conformance!(
63    unsafe impl<NodeType: ?Sized + NSCoding + AsRef<GKGraphNode2D>> NSCoding for GKMeshGraph<NodeType> {}
64);
65
66#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
67extern_conformance!(
68    unsafe impl<NodeType: ?Sized + AsRef<GKGraphNode2D>> NSCopying for GKMeshGraph<NodeType> {}
69);
70
71#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
72unsafe impl<NodeType: ?Sized + Message + AsRef<GKGraphNode2D>> CopyingHelper
73    for GKMeshGraph<NodeType>
74{
75    type Result = Self;
76}
77
78#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
79extern_conformance!(
80    unsafe impl<NodeType: ?Sized + AsRef<GKGraphNode2D>> NSObjectProtocol for GKMeshGraph<NodeType> {}
81);
82
83#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
84extern_conformance!(
85    unsafe impl<NodeType: ?Sized + NSSecureCoding + AsRef<GKGraphNode2D>> NSSecureCoding
86        for GKMeshGraph<NodeType>
87    {
88    }
89);
90
91#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
92impl<NodeType: Message + AsRef<GKGraphNode2D>> GKMeshGraph<NodeType> {
93    extern_methods!(
94        #[cfg(feature = "GKObstacle")]
95        /// Array of the extruded obstacles currently represented by this graph
96        #[unsafe(method(obstacles))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn obstacles(&self) -> Retained<NSArray<GKPolygonObstacle>>;
99
100        /// The distance by which all obstacles are extruded.
101        /// This is most commonly the spatial bounding radius of a potential traveler on this path
102        #[unsafe(method(bufferRadius))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn bufferRadius(&self) -> c_float;
105
106        /// Specifies how graph nodes are generated when you triangulate this graph.
107        /// You can combine triangulation modes using the | (OR) operator
108        ///
109        ///
110        /// See: GKMeshGraphTriangulationMode
111        #[unsafe(method(triangulationMode))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn triangulationMode(&self) -> GKMeshGraphTriangulationMode;
114
115        /// Setter for [`triangulationMode`][Self::triangulationMode].
116        #[unsafe(method(setTriangulationMode:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn setTriangulationMode(&self, triangulation_mode: GKMeshGraphTriangulationMode);
119
120        /// The number of triangles currently in this mesh graph
121        #[unsafe(method(triangleCount))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn triangleCount(&self) -> NSUInteger;
124
125        #[cfg(feature = "GKObstacle")]
126        /// Adds obstacles to this mesh graph.  Only reflected after the next triangulate call.
127        #[unsafe(method(addObstacles:))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn addObstacles(&self, obstacles: &NSArray<GKPolygonObstacle>);
130
131        #[cfg(feature = "GKObstacle")]
132        /// Removes obstacles from this graph.  Only reflected after the next triangulate call.
133        #[unsafe(method(removeObstacles:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn removeObstacles(&self, obstacles: &NSArray<GKPolygonObstacle>);
136
137        /// Connects the node to this graph by inserting it into an existing triangle and making the appropriate connections
138        /// Node must be in the space defined by the min and max coordinates of this graph.
139        ///
140        /// Parameter `node`: the node to connect
141        #[unsafe(method(connectNodeUsingObstacles:))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn connectNodeUsingObstacles(&self, node: &NodeType);
144
145        /// Generates a new triangle mesh for the given obstacles.
146        /// This should be called after some number of calls to addObstacle
147        /// The negative space between all input obstacles are triangulated to create a mesh
148        /// This mesh is turned into a set of connected graph nodes based on
149        #[unsafe(method(triangulate))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn triangulate(&self);
152
153        /// Returns the class of the specified generic index
154        #[unsafe(method(classForGenericArgumentAtIndex:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn classForGenericArgumentAtIndex(&self, index: NSUInteger)
157            -> &'static AnyClass;
158    );
159}
160
161/// Methods declared on superclass `GKGraph`.
162#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
163impl<NodeType: Message + AsRef<GKGraphNode2D>> GKMeshGraph<NodeType> {
164    extern_methods!(
165        /// Creates a graph with the provided array of nodes.
166        ///
167        /// Parameter `nodes`: the nodes to create the graph with
168        #[unsafe(method(graphWithNodes:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn graphWithNodes(nodes: &NSArray<GKGraphNode>) -> Retained<Self>;
171
172        #[unsafe(method(initWithNodes:))]
173        #[unsafe(method_family = init)]
174        pub unsafe fn initWithNodes(
175            this: Allocated<Self>,
176            nodes: &NSArray<GKGraphNode>,
177        ) -> Retained<Self>;
178    );
179}
180
181/// Methods declared on superclass `NSObject`.
182#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
183impl<NodeType: Message + AsRef<GKGraphNode2D>> GKMeshGraph<NodeType> {
184    extern_methods!(
185        #[unsafe(method(init))]
186        #[unsafe(method_family = init)]
187        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
188
189        #[unsafe(method(new))]
190        #[unsafe(method_family = new)]
191        pub unsafe fn new() -> Retained<Self>;
192    );
193}