pub struct MPSPolygonBuffer { /* private fields */ }MPSPolygonBuffer only.Expand description
A vertex buffer and optional index and mask buffer for a set of polygons
See also Appleโs documentation
Implementationsยง
Sourceยงimpl MPSPolygonBuffer
impl MPSPolygonBuffer
Sourcepub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
MPSRayIntersector only.Initialize the polygon buffer
Sourcepub unsafe fn initWithCoder(
this: Allocated<Self>,
a_decoder: &NSCoder,
) -> Option<Retained<Self>>
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn initWithCoder( this: Allocated<Self>, a_decoder: &NSCoder, ) -> Option<Retained<Self>>
MPSRayIntersector only.Initialize the polygon buffer with an NSCoder. Buffer properties such as the vertex buffer, instance buffer, etc. are set to nil. Encode and decode these buffers along with the polygon buffer instead.
ยงSafety
a_decoder possibly has further requirements.
pub unsafe fn polygonBuffer() -> Retained<Self>
MPSRayIntersector only.Sourcepub unsafe fn copyWithZone(&self, zone: *mut NSZone) -> Retained<Self>
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn copyWithZone(&self, zone: *mut NSZone) -> Retained<Self>
MPSRayIntersector only.Create a a copy of this polygon buffer
Buffer properties of the polygon buffer such as the vertex buffer, instance, buffer, etc. are set to nil. Copy these buffers and assign them to the new polygon buffer or reassign the existing buffers to the new polygon buffer.
Parameter zone: This parameter is ignored. Memory zones are no longer used by Objective-C.
ยงSafety
zone must be a valid pointer or null.
Sourcepub unsafe fn vertexBuffer(
&self,
) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn vertexBuffer( &self, ) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
MPSRayIntersector only.Vertex buffer containing vertex data encoded as three 32 bit floats per vertex. Note that by default each vertex is aligned to the alignment of the vector_float3 type: 16 bytes. This can be changed using the vertexStride property. A vertex buffer must be provided before the acceleration structure is built.
When using triangle polygons, degenerate (zero or negative area) triangles are ignored during acceleration structure construction. This can be used to pad triangle indices if needed.
Quadrilateral polygons are internally treated as two triangles. If the quadrilateral has vertices v0, v1, v2, and v3, the two triangles will have vertices v0, v1, v2 and v0, v2, v3. A quadrilateral may be used to represent a triangle by repeating the last vertex. If the first triangle is degenerate (zero or negative area), the entire quadrilateral will be ignored. This can be used to pad quadrilateral indices if needed. All four vertices of a quadrilateral must be coplanar and the quadrilateral must be convex.
Sourcepub unsafe fn setVertexBuffer(
&self,
vertex_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
)
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn setVertexBuffer( &self, vertex_buffer: Option<&ProtocolObject<dyn MTLBuffer>>, )
MPSRayIntersector only.Setter for vertexBuffer.
ยงSafety
vertex_buffermay need to be synchronized.vertex_buffermay be unretained, you must ensure it is kept alive while in use.vertex_buffercontents should be of the correct type.
Sourcepub unsafe fn vertexBufferOffset(&self) -> NSUInteger
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn vertexBufferOffset(&self) -> NSUInteger
MPSRayIntersector only.Offset, in bytes, into the vertex buffer. Defaults to 0 bytes. Must be aligned to 4 bytes.
Sourcepub unsafe fn setVertexBufferOffset(&self, vertex_buffer_offset: NSUInteger)
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn setVertexBufferOffset(&self, vertex_buffer_offset: NSUInteger)
MPSRayIntersector only.Setter for vertexBufferOffset.
Sourcepub unsafe fn indexBuffer(
&self,
) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn indexBuffer( &self, ) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
MPSRayIntersector only.Index buffer containing index data. Each index references a vertex in the vertex buffer. May be nil.
Sourcepub unsafe fn setIndexBuffer(
&self,
index_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
)
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn setIndexBuffer( &self, index_buffer: Option<&ProtocolObject<dyn MTLBuffer>>, )
MPSRayIntersector only.Setter for indexBuffer.
ยงSafety
index_buffermay need to be synchronized.index_buffermay be unretained, you must ensure it is kept alive while in use.index_buffercontents should be of the correct type.
Sourcepub unsafe fn indexBufferOffset(&self) -> NSUInteger
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn indexBufferOffset(&self) -> NSUInteger
MPSRayIntersector only.Offset, in bytes, into the index buffer. Defaults to 0 bytes. Must be aligned to a multiple of the index type. Changes to this property require rebuilding the acceleration structure.
Sourcepub unsafe fn setIndexBufferOffset(&self, index_buffer_offset: NSUInteger)
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn setIndexBufferOffset(&self, index_buffer_offset: NSUInteger)
MPSRayIntersector only.Setter for indexBufferOffset.
Sourcepub unsafe fn maskBuffer(
&self,
) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn maskBuffer( &self, ) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
MPSRayIntersector only.Mask buffer containing one uint32_t mask per polygon. May be nil. Otherwise, the mask type must be specified on the MPSRayIntersector with which it is used.
Sourcepub unsafe fn setMaskBuffer(
&self,
mask_buffer: Option<&ProtocolObject<dyn MTLBuffer>>,
)
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn setMaskBuffer( &self, mask_buffer: Option<&ProtocolObject<dyn MTLBuffer>>, )
MPSRayIntersector only.Setter for maskBuffer.
ยงSafety
mask_buffermay need to be synchronized.mask_buffermay be unretained, you must ensure it is kept alive while in use.mask_buffercontents should be of the correct type.
Sourcepub unsafe fn maskBufferOffset(&self) -> NSUInteger
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn maskBufferOffset(&self) -> NSUInteger
MPSRayIntersector only.Offset, in bytes, into the mask buffer. Defaults to 0 bytes. Must be aligned to 4 bytes.
Sourcepub unsafe fn setMaskBufferOffset(&self, mask_buffer_offset: NSUInteger)
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn setMaskBufferOffset(&self, mask_buffer_offset: NSUInteger)
MPSRayIntersector only.Setter for maskBufferOffset.
Sourcepub unsafe fn polygonCount(&self) -> NSUInteger
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn polygonCount(&self) -> NSUInteger
MPSRayIntersector only.Number of polygons. Changes to this property require rebuilding the acceleration structure.
Sourcepub unsafe fn setPolygonCount(&self, polygon_count: NSUInteger)
๐DeprecatedAvailable on crate feature MPSRayIntersector only.
pub unsafe fn setPolygonCount(&self, polygon_count: NSUInteger)
MPSRayIntersector only.Setter for polygonCount.
Methods from Deref<Target = NSObject>ยง
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesnโt recognize.
See Appleโs documentation for details.
Methods from Deref<Target = AnyObject>ยง
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
ยงPanics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
ยงExample
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
๐Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
ยงSafety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
ยงMutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable โunder the hoodโ.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Appleโs documentation on mutability and on
isKindOfClass: for more details.
ยงGeneric classes
Objective-C generics are called โlightweight genericsโ, and thatโs because they arenโt exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
ยงPanics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you donโt need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
ยงExamples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementationsยง
Sourceยงimpl AsRef<AnyObject> for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl AsRef<AnyObject> for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl AsRef<MPSPolygonBuffer> for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl AsRef<MPSPolygonBuffer> for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl AsRef<NSObject> for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl AsRef<NSObject> for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl Borrow<AnyObject> for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl Borrow<AnyObject> for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl Borrow<NSObject> for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl Borrow<NSObject> for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl ClassType for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl ClassType for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงconst NAME: &'static str = "MPSPolygonBuffer"
const NAME: &'static str = "MPSPolygonBuffer"
Sourceยงtype ThreadKind = <<MPSPolygonBuffer as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<MPSPolygonBuffer as ClassType>::Super as ClassType>::ThreadKind
Sourceยงimpl CopyingHelper for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl CopyingHelper for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงtype Result = MPSPolygonBuffer
type Result = MPSPolygonBuffer
Self if the type has no
immutable counterpart. Read moreSourceยงimpl Debug for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl Debug for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl Deref for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl Deref for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl Hash for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl Hash for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl Message for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl Message for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl NSCoding for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl NSCoding for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl NSCopying for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl NSCopying for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl NSObjectProtocol for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl NSObjectProtocol for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงfn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Sourceยงfn hash(&self) -> usize
fn hash(&self) -> usize
Sourceยงfn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Sourceยงfn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_refSourceยงfn isMemberOfClass(&self, cls: &AnyClass) -> bool
fn isMemberOfClass(&self, cls: &AnyClass) -> bool
Sourceยงfn respondsToSelector(&self, aSelector: Sel) -> bool
fn respondsToSelector(&self, aSelector: Sel) -> bool
Sourceยงfn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
Sourceยงfn description(&self) -> Retained<NSObject>
fn description(&self) -> Retained<NSObject>
Sourceยงfn debugDescription(&self) -> Retained<NSObject>
fn debugDescription(&self) -> Retained<NSObject>
Sourceยงimpl NSSecureCoding for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl NSSecureCoding for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl PartialEq for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl PartialEq for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงimpl RefEncode for MPSPolygonBuffer
Available on crate feature MPSRayIntersector only.
impl RefEncode for MPSPolygonBuffer
MPSRayIntersector only.Sourceยงconst ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
impl DowncastTarget for MPSPolygonBuffer
MPSRayIntersector only.impl Eq for MPSPolygonBuffer
MPSRayIntersector only.