skelform-python 0.4.1__tar.gz → 0.4.3__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.1 → skelform_python-0.4.3}/PKG-INFO +1 -1
- {skelform_python-0.4.1 → skelform_python-0.4.3}/pyproject.toml +1 -1
- {skelform_python-0.4.1 → skelform_python-0.4.3}/skelform_python/__init__.py +26 -14
- skelform_python-0.4.1/uv.lock +0 -8
- {skelform_python-0.4.1 → skelform_python-0.4.3}/.gitignore +0 -0
- {skelform_python-0.4.1 → skelform_python-0.4.3}/README.md +0 -0
- {skelform_python-0.4.1 → skelform_python-0.4.3}/readme.md +0 -0
- {skelform_python-0.4.1 → skelform_python-0.4.3}/skelform_python/tests.py +0 -0
|
@@ -15,7 +15,6 @@ class Vec2:
|
|
|
15
15
|
|
|
16
16
|
def __add__(self, other):
|
|
17
17
|
return Vec2(self.x + other.x, self.y + other.y)
|
|
18
|
-
|
|
19
18
|
def __mul__(self, other):
|
|
20
19
|
if isinstance(other, float):
|
|
21
20
|
return Vec2(self.x * other, self.y * other)
|
|
@@ -115,6 +114,7 @@ class Atlas:
|
|
|
115
114
|
@dataclass
|
|
116
115
|
class Armature:
|
|
117
116
|
bones: list[Bone]
|
|
117
|
+
cached_bones: Optional[list[Bone]]
|
|
118
118
|
ik_root_ids: list[int]
|
|
119
119
|
animations: Optional[list[Animation]]
|
|
120
120
|
atlases: list[Atlas]
|
|
@@ -131,7 +131,6 @@ def animate(
|
|
|
131
131
|
ikf = interpolate_keyframes
|
|
132
132
|
|
|
133
133
|
for bone in armature.bones:
|
|
134
|
-
bone = copy.deepcopy(bone)
|
|
135
134
|
bones.append(bone)
|
|
136
135
|
id = bone.id
|
|
137
136
|
# yapf: disable
|
|
@@ -178,6 +177,17 @@ def rotate(point: Vec2, rot: float):
|
|
|
178
177
|
)
|
|
179
178
|
|
|
180
179
|
|
|
180
|
+
# Call this before running inheritance.
|
|
181
|
+
def reset_inheritance(bones, og_bones):
|
|
182
|
+
for b in range(len(bones)):
|
|
183
|
+
bones[b].pos.x = og_bones[b].pos.x
|
|
184
|
+
bones[b].pos.y = og_bones[b].pos.y
|
|
185
|
+
bones[b].rot = og_bones[b].rot
|
|
186
|
+
bones[b].scale.x = og_bones[b].scale.x
|
|
187
|
+
bones[b].scale.y = og_bones[b].scale.y
|
|
188
|
+
|
|
189
|
+
return bones
|
|
190
|
+
|
|
181
191
|
def inheritance(bones, ik_rots):
|
|
182
192
|
for bone in bones:
|
|
183
193
|
if bone.parent_id != -1:
|
|
@@ -210,27 +220,29 @@ def normalize(vec):
|
|
|
210
220
|
|
|
211
221
|
|
|
212
222
|
def construct(armature: Armature):
|
|
213
|
-
|
|
223
|
+
if armature.cached_bones is None:
|
|
224
|
+
armature.cached_bones = copy.deepcopy(armature.bones)
|
|
214
225
|
|
|
215
|
-
|
|
216
|
-
|
|
226
|
+
armature.cached_bones = reset_inheritance(armature.cached_bones, armature.bones)
|
|
227
|
+
armature.cached_bones = inheritance(armature.cached_bones, {})
|
|
228
|
+
ik_rots = inverse_kinematics(armature.cached_bones, armature.ik_root_ids)
|
|
217
229
|
|
|
218
|
-
|
|
219
|
-
|
|
230
|
+
armature.cached_bones = reset_inheritance(armature.cached_bones, armature.bones)
|
|
231
|
+
armature.cached_bones = inheritance(armature.cached_bones, ik_rots)
|
|
220
232
|
|
|
221
|
-
|
|
233
|
+
armature.cached_bones = construct_verts(armature.cached_bones)
|
|
222
234
|
|
|
223
|
-
return
|
|
235
|
+
return armature.cached_bones
|
|
224
236
|
|
|
225
237
|
|
|
226
238
|
def construct_verts(bones: list[Bone]):
|
|
227
239
|
for b in range(len(bones)):
|
|
228
240
|
if not bones[b].vertices:
|
|
229
241
|
continue
|
|
230
|
-
bone = copy.deepcopy(bones[b])
|
|
231
242
|
|
|
232
|
-
for v in range(len(
|
|
233
|
-
|
|
243
|
+
for v in range(len(bones[b].vertices)):
|
|
244
|
+
bones[b].vertices[v].pos = bones[b].vertices[v].init_pos
|
|
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
|
|
@@ -251,8 +263,8 @@ def construct_verts(bones: list[Bone]):
|
|
|
251
263
|
if not bind.is_path:
|
|
252
264
|
vert: Vertex = bones[b].vertices[id]
|
|
253
265
|
weight: float = bind.verts[v].weight
|
|
254
|
-
endpos: Vec2 = inherit_vert(vert.
|
|
255
|
-
vert.pos +=
|
|
266
|
+
endpos: Vec2 = inherit_vert(vert.init_pos, bindBone) - vert.pos
|
|
267
|
+
vert.pos += endpos * weight
|
|
256
268
|
continue
|
|
257
269
|
|
|
258
270
|
binds = bones[b].binds
|
skelform_python-0.4.1/uv.lock
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|