skelform-python 0.4.0__tar.gz → 0.4.2__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.
- {skelform_python-0.4.0 → skelform_python-0.4.2}/PKG-INFO +1 -1
- {skelform_python-0.4.0 → skelform_python-0.4.2}/pyproject.toml +1 -1
- {skelform_python-0.4.0 → skelform_python-0.4.2}/skelform_python/__init__.py +31 -11
- skelform_python-0.4.0/uv.lock +0 -8
- {skelform_python-0.4.0 → skelform_python-0.4.2}/.gitignore +0 -0
- {skelform_python-0.4.0 → skelform_python-0.4.2}/README.md +0 -0
- {skelform_python-0.4.0 → skelform_python-0.4.2}/readme.md +0 -0
- {skelform_python-0.4.0 → skelform_python-0.4.2}/skelform_python/tests.py +0 -0
|
@@ -115,6 +115,7 @@ class Atlas:
|
|
|
115
115
|
@dataclass
|
|
116
116
|
class Armature:
|
|
117
117
|
bones: list[Bone]
|
|
118
|
+
cached_bones: Optional[list[Bone]]
|
|
118
119
|
ik_root_ids: list[int]
|
|
119
120
|
animations: Optional[list[Animation]]
|
|
120
121
|
atlases: list[Atlas]
|
|
@@ -131,7 +132,6 @@ def animate(
|
|
|
131
132
|
ikf = interpolate_keyframes
|
|
132
133
|
|
|
133
134
|
for bone in armature.bones:
|
|
134
|
-
bone = copy.deepcopy(bone)
|
|
135
135
|
bones.append(bone)
|
|
136
136
|
id = bone.id
|
|
137
137
|
# yapf: disable
|
|
@@ -178,6 +178,17 @@ def rotate(point: Vec2, rot: float):
|
|
|
178
178
|
)
|
|
179
179
|
|
|
180
180
|
|
|
181
|
+
# Call this before running inheritance.
|
|
182
|
+
def reset_inheritance(bones, og_bones):
|
|
183
|
+
for b in range(len(bones)):
|
|
184
|
+
bones[b].pos.x = og_bones[b].pos.x
|
|
185
|
+
bones[b].pos.y = og_bones[b].pos.y
|
|
186
|
+
bones[b].rot = og_bones[b].rot
|
|
187
|
+
bones[b].scale.x = og_bones[b].scale.x
|
|
188
|
+
bones[b].scale.y = og_bones[b].scale.y
|
|
189
|
+
|
|
190
|
+
return bones
|
|
191
|
+
|
|
181
192
|
def inheritance(bones, ik_rots):
|
|
182
193
|
for bone in bones:
|
|
183
194
|
if bone.parent_id != -1:
|
|
@@ -210,27 +221,28 @@ def normalize(vec):
|
|
|
210
221
|
|
|
211
222
|
|
|
212
223
|
def construct(armature: Armature):
|
|
213
|
-
|
|
224
|
+
if armature.cached_bones is None:
|
|
225
|
+
armature.cached_bones = copy.deepcopy(armature.bones)
|
|
214
226
|
|
|
215
|
-
|
|
216
|
-
|
|
227
|
+
armature.cached_bones = reset_inheritance(armature.cached_bones, armature.bones)
|
|
228
|
+
armature.cached_bones = inheritance(armature.cached_bones, {})
|
|
229
|
+
ik_rots = inverse_kinematics(armature.cached_bones, armature.ik_root_ids)
|
|
217
230
|
|
|
218
|
-
|
|
219
|
-
|
|
231
|
+
armature.cached_bones = reset_inheritance(armature.cached_bones, armature.bones)
|
|
232
|
+
armature.cached_bones = inheritance(armature.cached_bones, ik_rots)
|
|
220
233
|
|
|
221
|
-
|
|
234
|
+
armature.cached_bones = construct_verts(armature.cached_bones)
|
|
222
235
|
|
|
223
|
-
return
|
|
236
|
+
return armature.cached_bones
|
|
224
237
|
|
|
225
238
|
|
|
226
239
|
def construct_verts(bones: list[Bone]):
|
|
227
240
|
for b in range(len(bones)):
|
|
228
241
|
if not bones[b].vertices:
|
|
229
242
|
continue
|
|
230
|
-
bone = copy.deepcopy(bones[b])
|
|
231
243
|
|
|
232
|
-
for v in range(len(
|
|
233
|
-
|
|
244
|
+
for v in range(len(bones[b].vertices)):
|
|
245
|
+
bones[b].vertices[v].pos = inherit_vert(bones[b].vertices[v].pos, bones[b])
|
|
234
246
|
|
|
235
247
|
if not bones[b].binds:
|
|
236
248
|
continue
|
|
@@ -413,6 +425,14 @@ def check_bone_flip(bone_rot: float, scale: Vec2):
|
|
|
413
425
|
return bone_rot
|
|
414
426
|
|
|
415
427
|
|
|
428
|
+
def get_bone_texture(bone_tex: str, styles: [Style]):
|
|
429
|
+
for style in styles:
|
|
430
|
+
for tex in style.textures:
|
|
431
|
+
if tex.name == bone_tex:
|
|
432
|
+
return tex
|
|
433
|
+
return False
|
|
434
|
+
|
|
435
|
+
|
|
416
436
|
# Returns a (bone.id, Texture) map of textures to draw bones with.
|
|
417
437
|
def setup_bone_textures(bones: [Bone], styles: [Style]):
|
|
418
438
|
final_textures = {}
|
skelform_python-0.4.0/uv.lock
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|