Skip to content

Commit

Permalink
use translation verbiage
Browse files Browse the repository at this point in the history
  • Loading branch information
jabuwu committed May 5, 2024
1 parent cedb6f6 commit 2c2673f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 37 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# 0.8.0 (UNRELEASED)
- Upgrade runtime to Spine 4.2
- Fix `memcpy` crash in Rust 1.78 (when not using `libc` feature)
- Consistently use "translation" instead of "position" verbiage.
- Functions with `position` in their name renamed to use `translation` (except those referring to other types of positions).
- Add `Physics` enum
- Add `physics` parameter to `Skeleton::update_world_transform` and `Skeleton::update_world_transform_with`
- Add `physics` parameter to `Controller::update`
Expand Down
2 changes: 1 addition & 1 deletion src/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ pub mod atlas {
#[cfg(feature = "mint")]
impl AtlasRegion {
#[must_use]
pub fn position(&self) -> Vector2<i32> {
pub fn translation(&self) -> Vector2<i32> {
Vector2 {
x: self.x(),
y: self.y(),
Expand Down
46 changes: 23 additions & 23 deletions src/bone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,18 @@ impl Bone {
f32
);
c_accessor_mut!(
/// Set the world X position.
/// Set the world X translation.
world_x,
/// The world X position. If changed,
/// The world X translation. If changed,
/// [`update_applied_transform`](`Self::update_applied_transform`) should be called.
set_world_x,
worldX,
f32
);
c_accessor_mut!(
/// The world Y position.
/// The world Y translation.
world_y,
/// Set the world Y position. If changed,
/// Set the world Y translation. If changed,
/// [`update_applied_transform`](`Self::update_applied_transform`) should be called.
set_world_y,
worldY,
Expand Down Expand Up @@ -424,50 +424,50 @@ impl Bone {
impl Bone {
/// The local translation.
#[must_use]
pub fn position(&self) -> Vector2<f32> {
pub fn translation(&self) -> Vector2<f32> {
Vector2 {
x: self.x(),
y: self.y(),
}
}

/// Set the local translation.
pub fn set_position(&mut self, position: impl Into<Vector2<f32>>) {
let position: Vector2<f32> = position.into();
self.set_x(position.x);
self.set_y(position.y);
pub fn set_translation(&mut self, translation: impl Into<Vector2<f32>>) {
let translation: Vector2<f32> = translation.into();
self.set_x(translation.x);
self.set_y(translation.y);
}

/// The world translation.
#[must_use]
pub fn world_position(&self) -> Vector2<f32> {
pub fn world_translation(&self) -> Vector2<f32> {
Vector2 {
x: self.world_x(),
y: self.world_y(),
}
}

/// Set the world translation.
pub fn set_world_position(&mut self, position: impl Into<Vector2<f32>>) {
let position: Vector2<f32> = position.into();
self.set_world_x(position.x);
self.set_world_y(position.y);
pub fn set_world_translation(&mut self, translation: impl Into<Vector2<f32>>) {
let translation: Vector2<f32> = translation.into();
self.set_world_x(translation.x);
self.set_world_y(translation.y);
}

/// The applied translation.
#[must_use]
pub fn applied_position(&self) -> Vector2<f32> {
pub fn applied_translation(&self) -> Vector2<f32> {
Vector2 {
x: self.world_x(),
y: self.world_y(),
}
}

/// Set the applied translation.
pub fn set_applied_position(&mut self, position: impl Into<Vector2<f32>>) {
let position: Vector2<f32> = position.into();
self.set_applied_x(position.x);
self.set_applied_y(position.y);
pub fn set_applied_translation(&mut self, translation: impl Into<Vector2<f32>>) {
let translation: Vector2<f32> = translation.into();
self.set_applied_x(translation.x);
self.set_applied_y(translation.y);
}

/// The local scale.
Expand Down Expand Up @@ -553,16 +553,16 @@ impl Bone {

pub fn update_world_transform_with2(
&mut self,
position: mint::Vector2<f32>,
translation: mint::Vector2<f32>,
rotation: f32,
scale: mint::Vector2<f32>,
shear: mint::Vector2<f32>,
) {
unsafe {
spBone_updateWorldTransformWith(
self.c_ptr(),
position.x,
position.y,
translation.x,
translation.y,
rotation,
scale.x,
scale.y,
Expand Down Expand Up @@ -637,7 +637,7 @@ impl BoneData {
#[cfg(feature = "mint")]
impl BoneData {
#[must_use]
pub fn position(&self) -> Vector2<f32> {
pub fn translation(&self) -> Vector2<f32> {
Vector2 {
x: self.x(),
y: self.y(),
Expand Down
4 changes: 2 additions & 2 deletions src/point_attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
#[cfg(feature = "mint")]
use mint::Vector2;

/// A lightweight, single point attachment with a position and rotation.
/// A lightweight, single point attachment with a translation and rotation.
///
/// [Spine API Reference](http://esotericsoftware.com/spine-api-reference#PointAttachment)
#[derive(Debug)]
Expand Down Expand Up @@ -63,7 +63,7 @@ impl PointAttachment {
#[cfg(feature = "mint")]
impl PointAttachment {
#[must_use]
pub fn position(&self) -> Vector2<f32> {
pub fn translation(&self) -> Vector2<f32> {
Vector2 {
x: self.x(),
y: self.y(),
Expand Down
2 changes: 1 addition & 1 deletion src/region_attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl RegionAttachment {
#[cfg(feature = "mint")]
impl RegionAttachment {
#[must_use]
pub fn position(&self) -> Vector2<f32> {
pub fn translation(&self) -> Vector2<f32> {
Vector2 {
x: self.x(),
y: self.y(),
Expand Down
18 changes: 9 additions & 9 deletions src/skeleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,18 +448,18 @@ impl Skeleton {
f32
);
c_accessor_mut!(
/// The skeleton X position, which is added to the root bone worldX position.
/// The skeleton X translation, which is added to the root bone worldX translation.
x,
/// Sets the skeleton X position, which is added to the root bone worldX position.
/// Sets the skeleton X translation, which is added to the root bone worldX translation.
/// Bones that do not inherit translation are still affected by this property.
set_x,
x,
f32
);
c_accessor_mut!(
/// The skeleton Y position, which is added to the root bone worldY position.
/// The skeleton Y translation, which is added to the root bone worldY translation.
y,
/// Sets the skeleton Y position, which is added to the root bone worldY position.
/// Sets the skeleton Y translation, which is added to the root bone worldY translation.
/// Bones that do not inherit translation are still affected by this property.
set_y,
y,
Expand Down Expand Up @@ -562,17 +562,17 @@ impl Skeleton {
#[cfg(feature = "mint")]
impl Skeleton {
#[must_use]
pub fn position(&self) -> Vector2<f32> {
pub fn translation(&self) -> Vector2<f32> {
Vector2 {
x: self.x(),
y: self.y(),
}
}

pub fn set_position(&mut self, position: impl Into<Vector2<f32>>) {
let position: Vector2<f32> = position.into();
self.set_x(position.x);
self.set_y(position.y);
pub fn set_translation(&mut self, translation: impl Into<Vector2<f32>>) {
let translation: Vector2<f32> = translation.into();
self.set_x(translation.x);
self.set_y(translation.y);
}

#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion src/skeleton_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl SkeletonData {
impl SkeletonData {
/// The translation of the skeleton's axis aligned bounding box in the setup pose.
#[must_use]
pub fn position(&self) -> Vector2<f32> {
pub fn translation(&self) -> Vector2<f32> {
Vector2 {
x: self.x(),
y: self.y(),
Expand Down

0 comments on commit 2c2673f

Please sign in to comment.