#![allow(clippy::panic)]
define_api_id!(9006, "world-v0");
pub type EntityHandle = u64;
pub type MeshHandle = u64;
pub type PlayerId = u64;
pub const ENTITY_HANDLE_INVALID: EntityHandle = 0x0000_0001_FFFF_FFFF;
pub use crate::world_v2::ComponentType;
use crate::PodBool;
use crate::TransparentPad;
use bytemuck::CheckedBitPattern;
use bytemuck::NoUninit;
use bytemuck::Pod;
use bytemuck::Zeroable;
use num_enum::IntoPrimitive;
use num_enum::TryFromPrimitive;
#[derive(Copy, Clone, Default, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct Ray {
pub origin: [f32; 3],
pub dir: [f32; 3],
}
#[derive(Debug, Copy, Clone, Default, Pod, Zeroable)]
#[repr(C)]
pub struct MeshProperties {
pub bbox_min: [f32; 3],
pub bbox_max: [f32; 3],
pub bounding_radius: f32,
pub semantic_flags: u32, }
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum ValueType {
None = 0,
Float32 = 1,
Vec2 = 2,
Vec3 = 3,
Vec4 = 4,
Quat = 5,
Bool = 6,
Int64 = 7,
}
#[derive(Copy, Clone)]
#[repr(C)]
#[ark_api_macros::ffi_union(size = 16, pod_accessors)]
pub union ValueData {
pub data_f32: f32,
pub data_vec2: [f32; 2],
pub data_vec3: [f32; 3],
pub data_vec4: [f32; 4],
pub data_quat: [f32; 4],
pub data_bool: PodBool,
pub data_i64: i64,
}
impl core::fmt::Debug for ValueData {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let bytes = bytemuck::cast_ref::<Self, [u8; 16]>(self);
write!(f, "ValueData {{ <opaque>: {bytes:?} }}")
}
}
#[derive(Copy, Clone, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct Value {
pub value_type: ValueType,
pub _pad: u32,
pub value_data: ValueData,
}
impl std::fmt::Debug for Value {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.value_type {
ValueType::None => write!(f, "None"),
ValueType::Float32 => write!(f, "Float32 {:?}", self.as_f32()),
ValueType::Vec2 => write!(f, "Vec2 {:?}", self.as_vec2()),
ValueType::Vec3 => write!(f, "Vec3 {:?}", self.as_vec3()),
ValueType::Vec4 => write!(f, "Vec4 {:?}", self.as_vec4()),
ValueType::Quat => write!(f, "Quat {:?}", self.as_quat()),
ValueType::Bool => write!(f, "Bool {:?}", self.as_bool()),
ValueType::Int64 => write!(f, "Int64 {:?}", self.as_i64()),
}
}
}
macro_rules! impl_value {
($as_function: ident, $from_function: ident, $value_data:ident, $data_accessor:ident, $base_type:ty, $value_type:ident) => {
#[inline]
pub fn $as_function(&self) -> $base_type {
assert_eq!(self.value_type, ValueType::$value_type);
*(ValueData::$data_accessor(&self.value_data))
}
#[inline]
pub fn $from_function(v: $base_type) -> Self {
Self {
value_type: ValueType::$value_type,
_pad: 0,
value_data: ValueData {
$value_data: TransparentPad::new(v),
},
}
}
};
}
impl Value {
impl_value!(as_i64, from_i64, data_i64, as_data_i64, i64, Int64);
impl_value!(as_f32, from_f32, data_f32, as_data_f32, f32, Float32);
impl_value!(as_vec2, from_vec2, data_vec2, as_data_vec2, [f32; 2], Vec2);
impl_value!(as_vec3, from_vec3, data_vec3, as_data_vec3, [f32; 3], Vec3);
impl_value!(as_vec4, from_vec4, data_vec4, as_data_vec4, [f32; 4], Vec4);
impl_value!(as_quat, from_quat, data_quat, as_data_quat, [f32; 4], Quat);
pub fn none() -> Self {
Self {
value_type: ValueType::None,
value_data: ValueData {
data_i64: TransparentPad::new(0),
},
_pad: 0,
}
}
#[inline]
pub fn as_bool(&self) -> bool {
assert_eq!(self.value_type, ValueType::Bool);
#[allow(clippy::expect_used)]
self.value_data.as_data_bool().as_bool()
}
#[inline]
pub fn from_bool(v: bool) -> Self {
Self {
value_type: ValueType::Bool,
_pad: 0,
value_data: ValueData {
data_bool: TransparentPad::new(PodBool::from(v)),
},
}
}
}
#[derive(
Copy, Clone, Debug, PartialEq, Eq, IntoPrimitive, TryFromPrimitive, NoUninit, CheckedBitPattern,
)]
#[repr(u64)]
#[non_exhaustive]
pub enum JointType {
Fixed = 0,
Ball = 1,
Hinge = 2,
Slider = 3,
Distance = 4,
}
bitflags! {
#[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "with_speedy", derive(speedy::Writable, speedy::Readable))]
#[cfg_attr(feature = "with_arbitrary", derive(arbitrary::Arbitrary))]
#[repr(C)]
#[derive(Pod, Zeroable)]
pub struct DynamicLockFlags : u8 {
const LINEAR_X = 0b0000_0001;
const LINEAR_Y = 0b0000_0010;
const LINEAR_Z = 0b0000_0100;
const ANGULAR_X = 0b0000_1000;
const ANGULAR_Y = 0b0001_0000;
const ANGULAR_Z = 0b0010_0000;
}
}
bitflags! {
#[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "with_speedy", derive(speedy::Writable, speedy::Readable))]
#[cfg_attr(feature = "with_arbitrary", derive(arbitrary::Arbitrary))]
#[repr(C)]
#[derive(Pod, Zeroable)]
pub struct BoneWeightFlags : u32 {
const VISUALIZE_WEIGHTS = 1;
}
}
#[repr(u8)]
#[non_exhaustive]
#[derive(
Copy, Clone, Debug, PartialEq, Eq, IntoPrimitive, TryFromPrimitive, NoUninit, CheckedBitPattern,
)]
#[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "with_speedy", derive(speedy::Writable, speedy::Readable))]
pub enum AudioSourceOperation {
Start = 0,
Stop = 1,
Noop = 2,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u64)]
pub enum RigidBodyMode {
Off = 0,
Static = 1,
Dynamic = 2,
Kinematic = 3,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u64)]
pub enum JointLimitType {
Off = 0,
Hard = 1,
Spring = 2,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u64)]
pub enum D6MotionType {
Locked = 0,
Limited = 1,
Free = 2,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u64)]
pub enum D6Axis {
X = 0,
Y = 1,
Z = 2,
Twist = 3,
Swing1 = 4,
Swing2 = 5,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u64)]
#[non_exhaustive]
pub enum D6Drive {
X = 0,
Y = 1,
Z = 2,
Swing = 3,
Twist = 4,
SLERP = 5,
}
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, NoUninit, CheckedBitPattern)]
#[repr(u32)]
pub enum TriggerEvent {
Enter = 0,
Leave = 1,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum EntityInfo {
Name = 0,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum Transform {
Position = 0,
Rotation = 1,
#[deprecated(note = "Use ScaleUniform")] Scale = 2,
ParentId = 3,
WorldPosition = 4,
WorldRotation = 5,
#[deprecated(note = "Use WorldScaleUniform")] WorldScale = 6,
ScaleUniform = 7,
WorldScaleUniform = 8,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum Physics {
Velocity = 0,
AngularVelocity = 1,
PhysxEnable = 3,
PhysxDynamicEnable = 4,
PhysxDensity = 5,
PhysxShape = 6,
PhysxDynamicFriction = 7,
PhysxStaticFriction = 8,
PhysxRestitution = 9,
PhysxCreateSleeping = 10,
PhysxKinematic = 11,
PhysxGravityEnabled = 12,
PhysxCollisionEventsMask = 13,
PhysxDynamicLockFlags = 14,
PhysxCompoundShape = 15,
Mass = 16,
CenterOfMass = 17,
MassRotation = 18,
InertiaTensor = 19,
LinearDamping = 20,
AngularDamping = 21,
TriggerVolume = 22,
RigidBodyMode = 23,
SolverPositionIterations = 24,
SolverVelocityIterations = 25,
PhysxSleeping = 26,
PhysxSleepThreshold = 27,
FrictionCombineMode = 28,
RestitutionCombineMode = 29,
NonUniformScale = 30,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum Joint {
Type = 0,
FirstEntity = 1,
SecondEntity = 2,
FirstOffset = 3,
SecondOffset = 4,
FirstOrientation = 5,
SecondOrientation = 6,
Limits = 7,
LimitType = 8,
Velocity = 9,
DriveEnabled = 10,
DriveVelocity = 11,
DriveForceLimit = 12,
DriveGearRatio = 13,
DriveFreespin = 14,
BreakForce = 15,
BreakTorque = 16,
IsBroken = 17,
AngleOrPosition = 18,
LimitSpring = 19,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum D6Joint {
Entity1 = 0,
Entity2 = 1,
RelativePosition1 = 2,
RelativeOrientation1 = 3,
RelativePosition2 = 4,
RelativeOrientation2 = 5,
BreakForce = 6,
BreakTorque = 7,
IsBroken = 8,
ProjectionLinearTolerance = 9,
ProjectionAngularTolerance = 10,
RelativePosition = 11,
RelativeRotation = 12,
RelativeAngles = 13,
MotionX = 14,
MotionY = 15,
MotionZ = 16,
MotionTwist = 17,
MotionSwing1 = 18,
MotionSwing2 = 19,
LinearLimit = 20,
LinearLimitSpring = 21,
LinearLimitType = 22,
TwistLimit = 23,
TwistLimitSpring = 24,
TwistLimitType = 25,
SwingLimit = 26,
SwingLimitSpring = 27,
SwingLimitType = 28,
DriveEnabled = 29,
DrivePosition = 30,
DriveRotation = 31,
DriveLinearVelocity = 32,
DriveAngularVelocity = 33,
DriveParamsX = 34,
DriveParamsY = 35,
DriveParamsZ = 36,
DriveParamsSwing = 37,
DriveParamsTwist = 38,
DriveParamsSLERP = 39,
DriveIsAcceleration = 40,
LinearForce = 41,
AngularForce = 42,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum Render {
Shape = 0,
MeshStyle = 1,
Visible = 2,
PlayerIdSet = 3,
DynamicModuleData = 4,
NonUniformScale = 5,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum MeshStyle {
DiffuseTint = 0,
Flags = 1,
Legacy = 2,
MorphTargetWeights = 3,
MaterialOverrides = 4,
BillboardOffset = 5,
OutlineColor = 6,
OutlineThickness = 7,
MeshVisibility = 8,
MeshVisibilityPlayerIdSetFlags = 9,
MeshVisibilityPlayerIdSet = 10,
MeshStylePlayerIdSetFlags = 11,
MeshStylePlayerIdSet = 12,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum Environment {
SunDirection = 0,
GravityVector = 5,
FogDensity = 6,
FogHeight = 7,
FogHeightFalloff = 8,
FogStart = 9,
FogColor = 10,
Exposure = 11,
SunSizeMultiplier = 12,
GiVolumeSize = 13,
SunColorMultiplier = 14,
AmbientColor = 15,
PlanetRadius = 16,
AtmosphereDensity = 17,
AtmosphereHeight = 18,
RayleighHeight = 19,
OzoneHeight = 20,
MieHeight = 21,
OzoneWidth = 22,
SkyIntensity = 23,
SunIntensity = 24,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum Camera {
ProjectionMode = 0,
LocalOrigin = 1,
#[deprecated(note = "Use `LocalForwardVector")] LocalTarget = 2,
LocalUpVector = 4,
FieldOfView = 3,
FocalPoint = 5,
FStop = 6,
LocalForwardVector = 7,
ScreenSpaceOffset = 8,
FocalPointSmoothing = 9,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum Bounds {
BoundingBoxMin = 0,
BoundingBoxMax = 1,
BoundingSphereRadius = 2,
MatchRenderShape = 3,
BoundingShape = 4,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum Tag {
Tag = 0,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum Layer {
Mask = 0,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum SdfModel {
Program = 0,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum AudioSource {
AudioClip = 0,
Volume = 1,
Rate = 2,
Looping = 3,
Force2d = 4,
AllowInterruption = 5,
NextOperation = 6,
StopOnDestroy = 7,
PlayerIdSet = 8,
IsPlaying = 9,
DynamicModuleData = 10,
}
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryCommon {
pub id: u64, pub max_entities: u32,
pub result_data: u32,
pub layer_mask: u64,
}
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryRaycast {
pub info: SpatialQueryCommon,
pub direction: [f32; 3],
pub min_t: f32,
pub max_t: f32,
pub _pad: u32,
}
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryWithinSphere {
pub info: SpatialQueryCommon,
pub radius: f32,
pub _pad: u32,
}
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryBehindPlane {
pub info: SpatialQueryCommon,
pub normal: [f32; 3],
pub _pad: u32,
}
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryResultPayload {
pub raycast_hitpoint: [f32; 3], }
#[deprecated(note = "Use `SpatialQueryHits` instead")] #[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryResult {
pub id: u64,
pub num_entities: u64, pub raycast_result: SpatialQueryResultPayload,
pub _pad: u32,
}
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryHits {
pub id: u64,
pub num_hits: u32,
pub _pad: u32,
}
bitflags! {
#[derive(Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryOptions : u8 {
#[deprecated] const APPLY_ENTITY_POSITION = 0b0000_0001;
#[deprecated] const APPLY_ENTITY_ROTATION = 0b0000_0010;
#[deprecated] const APPLY_ENTITY_SCALE = 0b0000_0100;
#[deprecated] const APPLY_ENTITY_TRANSFORM = Self::APPLY_ENTITY_POSITION.bits() | Self::APPLY_ENTITY_ROTATION.bits() | Self::APPLY_ENTITY_SCALE.bits();
#[deprecated] const FORCE_WORLD_SPACE_DIRECTION_OR_NORMAL = 0b000_1000;
const PHYSX_QUERY = 0b0001_0000;
const IGNORE_INTERIOR_HITS = 0b0010_0000;
}
}
#[deprecated] #[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryCommon2 {
pub id: u64, pub max_hits: u32,
pub hits_data_ptr: u32,
pub layer_mask: u64,
pub position: [f32; 3],
pub options: SpatialQueryOptions,
pub _pad: [u8; 3],
}
#[deprecated] #[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryRaycast2 {
pub direction: [f32; 3],
pub min_t: f32,
pub max_t: f32,
pub _pad: u32,
pub common: SpatialQueryCommon2,
}
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQuerySpherecast {
pub direction: [f32; 3],
pub min_t: f32,
pub max_t: f32,
pub _pad0: u32,
pub common: SpatialQueryCommon2,
pub spherecast_radius: f32,
pub _pad1: u32,
}
#[deprecated] #[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryWithinSphere2 {
pub radius: f32,
pub _pad: u32,
pub common: SpatialQueryCommon2,
}
#[deprecated] #[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct SpatialQueryBehindPlane2 {
pub normal: [f32; 3],
pub _pad: u32,
pub common: SpatialQueryCommon2,
}
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct OnCollision {
pub entity: EntityHandle,
pub other: EntityHandle,
pub world_pos_approximate: [f32; 3],
pub force: f32,
}
#[derive(Copy, Clone, Debug, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct OnTrigger {
pub entity: EntityHandle,
pub other: EntityHandle,
pub event: TriggerEvent,
pub _pad: u32,
}
crate::impl_checked_bit_pattern_for_transparent_pad!(OnTrigger);
#[derive(Copy, Clone, Debug, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct PhysicsForceRequest {
pub force_type: ForceType,
pub force_mode: ForceMode,
pub vector: [f32; 3],
}
crate::impl_checked_bit_pattern_for_transparent_pad!(PhysicsForceRequest);
#[derive(Copy, Clone, Debug, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct PhysicsForceRequest2 {
pub force_type: ForceType,
pub force_mode: ForceMode,
pub force_space: Space,
pub pos_space: Space,
pub vector: [f32; 3],
pub pos: [f32; 3],
}
crate::impl_checked_bit_pattern_for_transparent_pad!(PhysicsForceRequest2);
#[derive(Copy, Clone, Debug, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct SetActive {
pub component_type: ComponentType,
}
crate::impl_checked_bit_pattern_for_transparent_pad!(SetActive);
#[derive(Copy, Clone, Debug, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct SetActiveForPlayer {
pub component_type: ComponentType,
pub player_id: PlayerId,
}
crate::impl_checked_bit_pattern_for_transparent_pad!(SetActiveForPlayer);
#[derive(Copy, Clone, Debug, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct SetValue {
pub component_type: ComponentType,
pub param_id: u32,
pub _pad: u32,
pub value: Value,
}
crate::impl_checked_bit_pattern_for_transparent_pad!(SetValue);
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum AnimationCurve {
Linear = 0,
QuadraticEaseIn = 1,
QuadraticEaseOut = 2,
QuadraticEaseInOut = 3,
}
#[derive(Copy, Clone, Debug, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct AnimationOptions {
pub curve: AnimationCurve,
pub duration: f32,
pub loop_count: u32,
pub delay: f32,
pub smoothing: f32,
}
pub const ANIMATION_REQUEST_ID_NONE: u64 = !0u64;
#[derive(Copy, Clone, Debug, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct AnimateValue {
pub id: u64, pub param: SetValue,
pub options: AnimationOptions,
pub _pad: u32,
}
crate::impl_checked_bit_pattern_for_transparent_pad!(AnimateValue);
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum AnimationReplyType {
AnimationFinished = 0,
AnimationCancelled = 1,
}
#[derive(Copy, Clone, Debug, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct AnimationReply {
pub reply_type: AnimationReplyType,
pub _pad: u32,
pub id: u64, }
crate::impl_checked_bit_pattern_for_transparent_pad!(AnimationReply);
#[derive(Copy, Clone, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct CollisionMatrixRow {
pub index: u32, pub _pad: u32,
pub row: u64,
}
crate::impl_checked_bit_pattern_for_transparent_pad!(CollisionMatrixRow);
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum MessageType {
Invalid = 0,
#[deprecated(note = "Use `SpatialQueryHits` instead")] SpatialQueryResult = 2,
OnCollision = 3, PhysicsForceRequest = 4,
SetValue = 5,
AnimateValue = 6, StopAnimatingValue = 7,
AnimationReply = 8, PhysicsForceRequest2 = 10,
SpatialQueryRaycast = 11,
SpatialQueryWithinSphere = 12,
SpatialQueryBehindPlane = 13,
AnimateValueEnqueue = 14,
SetCollisionMatrixRow = 15,
SpatialQueryRaycast2 = 16,
SpatialQueryWithinSphere2 = 17,
SpatialQueryBehindPlane2 = 18,
SetActive = 19,
OnTrigger = 20,
SetActiveForPlayer = 24,
SpatialQuerySpherecast = 25,
SpatialQueryHits = 26, }
#[derive(Copy, Clone)]
#[repr(C)]
#[ark_api_macros::ffi_union(size = 72, checked_accessors)]
pub union MessagePayload {
pub set_active: SetActive,
pub set_active_for_player: SetActiveForPlayer,
pub spatial_query_raycast: SpatialQueryRaycast,
pub spatial_query_within_sphere: SpatialQueryWithinSphere,
pub spatial_query_result: SpatialQueryResult,
pub on_collision: OnCollision,
pub on_trigger: OnTrigger,
pub physics_force_request: PhysicsForceRequest,
pub set_value: SetValue,
pub animate_value: AnimateValue,
pub stop_animating_value: SetValue, pub animation_reply: AnimationReply,
pub spatial_query_behind_plane: SpatialQueryBehindPlane,
pub physics_force_request2: PhysicsForceRequest2,
pub collision_matrix_row: CollisionMatrixRow,
pub spatial_query_raycast2: SpatialQueryRaycast2,
pub spatial_query_within_sphere2: SpatialQueryWithinSphere2,
pub spatial_query_behind_plane2: SpatialQueryBehindPlane2,
pub empty: u8,
pub spatial_query_spherecast: SpatialQuerySpherecast,
pub spatial_query_hits: SpatialQueryHits,
}
impl core::fmt::Debug for MessagePayload {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let bytes = bytemuck::cast_ref::<Self, [u8; 72]>(self);
write!(f, "MessagePayload {{ <opaque>: {bytes:?} }}")
}
}
#[derive(Copy, Clone, NoUninit, CheckedBitPattern)]
#[repr(C)]
pub struct Message {
pub msg_type: MessageType,
pub _pad: u32,
pub msg_payload: MessagePayload,
}
impl Message {
pub fn invalid() -> Self {
let mut msg: Message = unsafe { core::mem::MaybeUninit::zeroed().assume_init() };
msg.msg_type = MessageType::Invalid;
msg
}
}
impl std::fmt::Debug for Message {
#[allow(clippy::unwrap_used)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.msg_type {
MessageType::SpatialQueryRaycast => write!(
f,
"SpatialQueryRaycast {:?}",
self.msg_payload.as_spatial_query_raycast()
),
MessageType::SpatialQueryWithinSphere => write!(
f,
"SpatialQueryWithinSphere {:?}",
self.msg_payload.as_spatial_query_within_sphere()
),
MessageType::SpatialQueryBehindPlane => write!(
f,
"SpatialQueryBehindPlane {:?}",
self.msg_payload.as_spatial_query_behind_plane()
),
MessageType::SpatialQueryResult => write!(
f,
"SpatialQueryResult {:?}",
self.msg_payload.as_spatial_query_behind_plane()
),
MessageType::OnCollision => {
write!(f, "OnCollision {:?}", self.msg_payload.as_on_collision())
}
MessageType::OnTrigger => {
write!(f, "OnTrigger {:?}", self.msg_payload.as_on_trigger())
}
MessageType::PhysicsForceRequest => write!(
f,
"PhysicsForceRequest {:?}",
self.msg_payload.as_physics_force_request()
),
MessageType::SetValue => {
write!(f, "SetValue {:?}", self.msg_payload.as_set_value())
}
MessageType::AnimateValue => {
write!(f, "AnimateValue {:?}", self.msg_payload.as_animate_value())
}
MessageType::AnimateValueEnqueue => write!(
f,
"AnimateValueEnqueue {:?}",
self.msg_payload.as_animate_value()
),
MessageType::StopAnimatingValue => write!(
f,
"StopAnimatingValue {:?}",
self.msg_payload.as_stop_animating_value()
),
MessageType::AnimationReply => write!(
f,
"AnimationReply {:?}",
self.msg_payload.as_animation_reply()
),
MessageType::PhysicsForceRequest2 => write!(
f,
"PhysicsForceRequest2 {:?}",
self.msg_payload.as_physics_force_request2()
),
MessageType::SetCollisionMatrixRow => {
let matrix_row = self.msg_payload.as_collision_matrix_row();
write!(
f,
"SetCollisionMatrixRow: [{}] = {}",
matrix_row.index, matrix_row.row,
)
}
MessageType::SpatialQueryRaycast2 => write!(
f,
"SpatialQueryRaycast2 {:?}",
self.msg_payload.as_spatial_query_raycast2()
),
MessageType::SpatialQuerySpherecast => write!(
f,
"SpatialQuerySpherecast {:?}",
self.msg_payload.as_spatial_query_spherecast()
),
MessageType::SpatialQueryWithinSphere2 => write!(
f,
"SpatialQueryWithinSphere2 {:?}",
self.msg_payload.as_spatial_query_within_sphere2()
),
MessageType::SpatialQueryBehindPlane2 => write!(
f,
"SpatialQueryBehindPlane2 {:?}",
self.msg_payload.as_spatial_query_behind_plane2()
),
MessageType::SpatialQueryHits => write!(
f,
"SpatialQueryHits {:?}",
self.msg_payload.as_spatial_query_hits()
),
MessageType::SetActive => {
write!(f, "SetActive {:?}", self.msg_payload.as_set_active())
}
MessageType::SetActiveForPlayer => write!(
f,
"SetActiveForPlayer {:?}",
self.msg_payload.as_set_active_for_player()
),
MessageType::Invalid => write!(f, "Invalid"),
}
}
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
#[non_exhaustive]
pub enum ForceType {
Force = 0,
Torque = 1,
Teleport = 2,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
#[non_exhaustive]
pub enum ForceMode {
Force = 0,
Impulse = 1,
VelocityChange = 2,
Acceleration = 3,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
pub enum Space {
World = 0,
Local = 1,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
#[non_exhaustive]
pub enum PhysicsShape {
Sphere = 0,
Box = 1,
Capsule = 2,
Mesh = 3,
Compound = 4,
ConvexMesh = 5, }
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "with_speedy", derive(speedy::Writable, speedy::Readable))]
#[cfg_attr(feature = "with_arbitrary", derive(arbitrary::Arbitrary))]
#[repr(u32)]
#[non_exhaustive]
pub enum CombineMode {
Average = 0,
Min = 1,
Multiply = 2,
Max = 3,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
#[non_exhaustive]
pub enum MeshOrigin {
Top = 0,
Center = 1,
Bottom = 2,
}
#[derive(
Copy,
Clone,
Debug,
Hash,
Eq,
PartialEq,
IntoPrimitive,
TryFromPrimitive,
NoUninit,
CheckedBitPattern,
)]
#[repr(u32)]
#[non_exhaustive]
pub enum CameraProjectionMode {
Orthographic = 0,
Perspective = 1,
}