skelform-python 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: skelform_python
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: SkelForm runtime for Python
5
5
  Author-email: Retropaint <darkglasses1122@gmail.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "skelform_python"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  authors = [
9
9
  { name="Retropaint", email="darkglasses1122@gmail.com" },
10
10
  ]
@@ -116,9 +116,36 @@ def animate(
116
116
  bone.scale.x = ikf(3, bone.scale.x, bone.init_scale.x, kf, frames[a], id, bf)
117
117
  bone.scale.y = ikf(4, bone.scale.y, bone.init_scale.y, kf, frames[a], id, bf)
118
118
 
119
+ for bone in bones:
120
+ bone = reset_bone(bone, animations, bone.id, frames[0], blend_frames[0])
121
+
119
122
  return bones
120
123
 
121
124
 
125
+ def is_animated(anims: [Animation], bone_id: int, element: int) -> bool:
126
+ for anim in anims:
127
+ for kf in anim.keyframes:
128
+ if kf.bone_id == bone_id and kf.element == element:
129
+ return True
130
+
131
+ return False
132
+
133
+
134
+ def reset_bone(
135
+ bone: Bone, anims: [Animation], bone_id: int, frame: int, blend_frame: int
136
+ ):
137
+ if not is_animated(anims, bone_id, 0):
138
+ interpolate(frame, blend_frame, bone.pos.x, bone.init_pos.x)
139
+ if not is_animated(anims, bone_id, 1):
140
+ interpolate(frame, blend_frame, bone.pos.y, bone.init_pos.y)
141
+ if not is_animated(anims, bone_id, 2):
142
+ interpolate(frame, blend_frame, bone.rot, bone.init_rot)
143
+ if not is_animated(anims, bone_id, 3):
144
+ interpolate(frame, blend_frame, bone.scale.x, bone.init_scale.x)
145
+ if not is_animated(anims, bone_id, 4):
146
+ interpolate(frame, blend_frame, bone.scale.y, bone.init_scale.y)
147
+
148
+
122
149
  def rotate(point: Vec2, rot: float):
123
150
  return Vec2(
124
151
  point.x * math.cos(rot) - point.y * math.sin(rot),
@@ -177,7 +204,7 @@ def inverse_kinematics(bones: list[Bone], ik_root_ids: list[int]):
177
204
  if (
178
205
  family.ik_target_id == -1
179
206
  or not family.ik_bone_ids
180
- or not family.ik_target_id
207
+ or family.ik_target_id == -1
181
208
  ):
182
209
  continue
183
210
 
File without changes