-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
734 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use crate::{ | ||
c::{ | ||
spBone, spIkConstraint, spIkConstraintData, spIkConstraint_setToSetupPose, | ||
spIkConstraint_update, | ||
}, | ||
c_interface::{NewFromPtr, SyncPtr}, | ||
Bone, IkConstraintData, | ||
}; | ||
|
||
/// [Spine API Reference](https://esotericsoftware.com/spine-api-reference#IkConstraint) | ||
#[derive(Debug)] | ||
pub struct IkConstraint { | ||
c_ik_constraint: SyncPtr<spIkConstraint>, | ||
} | ||
|
||
impl NewFromPtr<spIkConstraint> for IkConstraint { | ||
unsafe fn new_from_ptr(c_slot: *mut spIkConstraint) -> Self { | ||
Self { | ||
c_ik_constraint: SyncPtr(c_slot), | ||
} | ||
} | ||
} | ||
|
||
impl IkConstraint { | ||
pub fn update(&self) { | ||
unsafe { | ||
spIkConstraint_update(self.c_ik_constraint.0); | ||
} | ||
} | ||
|
||
pub fn set_to_setup_pose(&self) { | ||
unsafe { | ||
spIkConstraint_setToSetupPose(self.c_ik_constraint.0); | ||
} | ||
} | ||
|
||
c_accessor_tmp_ptr_mut!(data, data_mut, data, IkConstraintData, spIkConstraintData); | ||
|
||
c_accessor_bool!(active, active); | ||
c_accessor_mut!(bend_direction, set_bend_direction, bendDirection, i32); | ||
c_accessor_bool_mut!(compress, set_compress, compress); | ||
c_accessor_mut!(mix, set_mix, mix, f32); | ||
c_accessor_mut!(softness, set_softness, softness, f32); | ||
c_accessor_bool_mut!(stretch, set_stretch, stretch); | ||
|
||
c_accessor!(bones_count, bonesCount, usize); | ||
c_accessor_array!( | ||
bones, | ||
bone_at_index, | ||
IkConstraint, | ||
Bone, | ||
spBone, | ||
bones, | ||
bones_count | ||
); | ||
c_accessor_tmp_ptr_mut!(target, target_mut, target, Bone, spBone); | ||
|
||
c_ptr!(c_ik_constraint, spIkConstraint); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::{ | ||
c::{spBoneData, spIkConstraintData}, | ||
c_interface::{NewFromPtr, SyncPtr}, | ||
BoneData, | ||
}; | ||
|
||
/// [Spine API Reference](https://esotericsoftware.com/spine-api-reference#IkConstraintData) | ||
#[derive(Debug)] | ||
pub struct IkConstraintData { | ||
c_ik_constraint_data: SyncPtr<spIkConstraintData>, | ||
} | ||
|
||
impl NewFromPtr<spIkConstraintData> for IkConstraintData { | ||
unsafe fn new_from_ptr(c_slot: *mut spIkConstraintData) -> Self { | ||
Self { | ||
c_ik_constraint_data: SyncPtr(c_slot), | ||
} | ||
} | ||
} | ||
|
||
impl IkConstraintData { | ||
c_accessor_string!(name, name); | ||
c_accessor!(order, order, i32); | ||
c_accessor_bool!(skin_required, skinRequired); | ||
|
||
c_accessor!(bend_direction, bendDirection, i32); | ||
c_accessor_bool!(compress, compress); | ||
c_accessor!(mix, mix, f32); | ||
c_accessor!(softness, softness, f32); | ||
c_accessor_bool!(stretch, stretch); | ||
c_accessor_bool!(uniform, uniform); | ||
|
||
c_accessor!(bones_count, bonesCount, usize); | ||
c_accessor_array!( | ||
bones, | ||
bone_at_index, | ||
IkConstraintData, | ||
BoneData, | ||
spBoneData, | ||
bones, | ||
bones_count | ||
); | ||
c_accessor_tmp_ptr!(target, target, BoneData, spBoneData); | ||
|
||
c_ptr!(c_ik_constraint_data, spIkConstraintData); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use crate::{ | ||
c::{ | ||
spBone, spPathConstraint, spPathConstraintData, spPathConstraint_setToSetupPose, | ||
spPathConstraint_update, spSlot, | ||
}, | ||
c_interface::{NewFromPtr, SyncPtr}, | ||
Bone, PathConstraintData, Slot, | ||
}; | ||
|
||
/// [Spine API Reference](https://esotericsoftware.com/spine-api-reference#PathConstraint) | ||
#[derive(Debug)] | ||
pub struct PathConstraint { | ||
c_path_constraint: SyncPtr<spPathConstraint>, | ||
} | ||
|
||
impl NewFromPtr<spPathConstraint> for PathConstraint { | ||
unsafe fn new_from_ptr(c_slot: *mut spPathConstraint) -> Self { | ||
Self { | ||
c_path_constraint: SyncPtr(c_slot), | ||
} | ||
} | ||
} | ||
|
||
impl PathConstraint { | ||
pub fn update(&self) { | ||
unsafe { | ||
spPathConstraint_update(self.c_path_constraint.0); | ||
} | ||
} | ||
|
||
pub fn set_to_setup_pose(&self) { | ||
unsafe { | ||
spPathConstraint_setToSetupPose(self.c_path_constraint.0); | ||
} | ||
} | ||
|
||
c_accessor_tmp_ptr_mut!( | ||
data, | ||
data_mut, | ||
data, | ||
PathConstraintData, | ||
spPathConstraintData | ||
); | ||
|
||
c_accessor_bool!(active, active); | ||
c_accessor_mut!(mix_rotate, set_mix_rotate, mixRotate, f32); | ||
c_accessor_mut!(mix_x, set_mix_x, mixX, f32); | ||
c_accessor_mut!(mix_y, set_mix_y, mixY, f32); | ||
c_accessor_mut!(position, set_position, position, f32); | ||
c_accessor_mut!(spacing, set_spacing, spacing, f32); | ||
|
||
c_accessor!(bones_count, bonesCount, usize); | ||
c_accessor_array!( | ||
bones, | ||
bone_at_index, | ||
PathConstraint, | ||
Bone, | ||
spBone, | ||
bones, | ||
bones_count | ||
); | ||
c_accessor_tmp_ptr_mut!(target, target_mut, target, Slot, spSlot); | ||
|
||
c_ptr!(c_path_constraint, spPathConstraint); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
use crate::{ | ||
c::{ | ||
spBoneData, spPathConstraintData, spPositionMode, spRotateMode, spSlotData, spSpacingMode, | ||
}, | ||
c_interface::{NewFromPtr, SyncPtr}, | ||
BoneData, SlotData, | ||
}; | ||
|
||
#[cfg(feature = "mint")] | ||
use mint::Vector2; | ||
|
||
/// [Spine API Reference](https://esotericsoftware.com/spine-api-reference#PathConstraintData) | ||
#[derive(Debug)] | ||
pub struct PathConstraintData { | ||
c_path_constraint_data: SyncPtr<spPathConstraintData>, | ||
} | ||
|
||
impl NewFromPtr<spPathConstraintData> for PathConstraintData { | ||
unsafe fn new_from_ptr(c_slot: *mut spPathConstraintData) -> Self { | ||
Self { | ||
c_path_constraint_data: SyncPtr(c_slot), | ||
} | ||
} | ||
} | ||
|
||
impl PathConstraintData { | ||
c_accessor_string!(name, name); | ||
c_accessor!(order, order, i32); | ||
c_accessor_bool!(skin_required, skinRequired); | ||
|
||
c_accessor_enum!(position_mode, positionMode, PositionMode); | ||
c_accessor_enum!(spacing_mode, spacingMode, SpacingMode); | ||
c_accessor_enum!(rotate_mode, rotateMode, RotateMode); | ||
|
||
c_accessor!(offset_rotation, offsetRotation, f32); | ||
c_accessor!(position, position, f32); | ||
c_accessor!(spacing, spacing, f32); | ||
c_accessor!(mix_rotate, mixRotate, f32); | ||
c_accessor!(mix_x, mixX, f32); | ||
c_accessor!(mix_y, mixY, f32); | ||
|
||
c_accessor!(bones_count, bonesCount, usize); | ||
c_accessor_array!( | ||
bones, | ||
bone_at_index, | ||
PathConstraintData, | ||
BoneData, | ||
spBoneData, | ||
bones, | ||
bones_count | ||
); | ||
c_accessor_tmp_ptr!(target, target, SlotData, spSlotData); | ||
|
||
c_ptr!(c_path_constraint_data, spPathConstraintData); | ||
} | ||
|
||
/// Functions available if using the `mint` feature. | ||
#[cfg(feature = "mint")] | ||
impl PathConstraintData { | ||
#[must_use] | ||
pub fn mix(&self) -> Vector2<f32> { | ||
Vector2 { | ||
x: self.mix_x(), | ||
y: self.mix_y(), | ||
} | ||
} | ||
} | ||
|
||
pub enum PositionMode { | ||
Fixed = 0, | ||
Percent = 1, | ||
Unknown = 99, | ||
} | ||
|
||
impl From<spPositionMode> for PositionMode { | ||
fn from(mode: spPositionMode) -> Self { | ||
match mode { | ||
0 => Self::Fixed, | ||
1 => Self::Percent, | ||
_ => Self::Unknown, | ||
} | ||
} | ||
} | ||
|
||
pub enum SpacingMode { | ||
Length = 0, | ||
Fixed = 1, | ||
Percent = 2, | ||
Proportional = 3, | ||
Unknown = 99, | ||
} | ||
|
||
impl From<spSpacingMode> for SpacingMode { | ||
fn from(mode: spSpacingMode) -> Self { | ||
match mode { | ||
0 => Self::Length, | ||
1 => Self::Fixed, | ||
2 => Self::Percent, | ||
3 => Self::Proportional, | ||
_ => Self::Unknown, | ||
} | ||
} | ||
} | ||
|
||
pub enum RotateMode { | ||
Tangent = 0, | ||
Chain = 1, | ||
ChainScale = 2, | ||
Unknown = 99, | ||
} | ||
|
||
impl From<spRotateMode> for RotateMode { | ||
fn from(mode: spRotateMode) -> Self { | ||
match mode { | ||
0 => Self::Tangent, | ||
1 => Self::Chain, | ||
2 => Self::ChainScale, | ||
_ => Self::Unknown, | ||
} | ||
} | ||
} |
Oops, something went wrong.