Type Alias SCNParticleEventBlock

Source
pub type SCNParticleEventBlock = *mut Block<dyn Fn(NonNull<NonNull<c_void>>, NonNull<usize>, *mut u32, NSInteger)>;
Available on crate features SCNParticleSystem and block2 only.
Expand description

Parameter data: array of particle properties data stripes, ordered by the given NSArray of properties name in [- handleEvent:forProperties:withBlock:]

Parameter dataStride: array of particle properties data stripes stride, with the same ordering than data.

Parameter indices: optional array of count indices referencing the particles affected by the event. Only SCNParticleEventDeath and SCNParticleEventCollision provide this array. For SCNParticleEventBirth the indices are implicitely [0,1,2,..,count-1]

Parameter count: number of particles affected by the event

This is a small example of usage of an event handling: [particleSystem handleEvent:SCNParticleEventCollision forProperties: @ [SCNParticlePropertyAngle, SCNParticlePropertyRotationAxis, SCNParticlePropertyContactNormal] withBlock:^(void **data, size_t *dataStride, uint32_t *indices, NSInteger count) { for (NSInteger i = 0; i < count; ++i) { // SCNParticlePropertyAngle (float) float *angle = (float *)((char *)data[0] + dataStride[0] * indices[i]); // SCNParticlePropertyRotationAxis (float3) float *axis = (float *)((char *)data[1] + dataStride[1] * indices[i]); // SCNParticlePropertyContactNormal (float3) float *colNrm = (float *)((char *)data[2] + dataStride[2] * indices[i]);

// rotate the particle (angle[0] and axis[0..2] based on the collision normal (colNrm[0..2]) // … } }];

See also Apple’s documentation