From 0040851eede6da56f744d77ddbf489f19199ca18 Mon Sep 17 00:00:00 2001 From: Alan Panayotov Date: Sat, 17 Aug 2024 19:43:58 +0100 Subject: [PATCH 1/4] fix: handle bones w/ no blend weight --- addons/lol_blender/operators/skinned/Export.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/lol_blender/operators/skinned/Export.py b/addons/lol_blender/operators/skinned/Export.py index 1bc7410..9460c42 100644 --- a/addons/lol_blender/operators/skinned/Export.py +++ b/addons/lol_blender/operators/skinned/Export.py @@ -38,7 +38,7 @@ def get_armature_for_mesh(mesh): raise RuntimeError("Mesh must have only one armature modifier") return modifiers[0].object -def get_mesh_and_armature_from_context(context): +def get_mesh_and_armature_from_context(context) -> tuple[bpy.types.Object, bpy.types.Object]: if len(context.view_layer.objects.selected) == 0: raise RuntimeError("At least one object must be selected") @@ -70,7 +70,6 @@ def get_mesh_and_armature_from_context(context): if mesh is not None: raise RuntimeError("Armature must have only one mesh associated") mesh_arm = get_armature_for_mesh(child) - print("mesh_arm", mesh_arm) if mesh_arm == armature: mesh = child @@ -147,7 +146,7 @@ def map_bone(b: bpy.types.Bone): ibm = b.matrix_local # local = b.matrix.to_4x4() @ mat local = Matrix() - return (b.name, l.Bone(parent, local, ibm.inverted() @ mat.inverted(), is_influence[b.name])) + return (b.name, l.Bone(parent, local, ibm.inverted() @ mat.inverted(), is_influence.get(b.name, False))) # map of blender bone names to league influence joint indices From 8d48b4b5890afe6ed341c1a05ec46c5c4f7bfeac Mon Sep 17 00:00:00 2001 From: Alan Panayotov Date: Sat, 17 Aug 2024 20:11:44 +0100 Subject: [PATCH 2/4] fix: joint_map calculation --- bindings/src/skinned/export/skl.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bindings/src/skinned/export/skl.rs b/bindings/src/skinned/export/skl.rs index b72a780..2d006be 100644 --- a/bindings/src/skinned/export/skl.rs +++ b/bindings/src/skinned/export/skl.rs @@ -63,7 +63,7 @@ fn topological_sort(graph: &HashMap>) -> Option> pub fn export_skl( bones: HashMap>, path: Option, -) -> PyResult> { +) -> PyResult> { let mut skl = RigResource::builder("skeleton_name", "skeleton_asset_name"); let orig_bone_count = bones.len(); @@ -156,7 +156,8 @@ pub fn export_skl( .influences() .iter() .copied() - .map(|i| (rig.joints()[i as usize].name().to_string(), i)) + .enumerate() + .map(|(i, joint_idx)| (rig.joints()[joint_idx as usize].name().to_string(), i as _)) .collect(); debug!("joint_map: {joint_map:?}"); Ok(joint_map) From 11216cf657b269799c8d5f2243b136be39f0e161 Mon Sep 17 00:00:00 2001 From: Alan Panayotov Date: Sat, 17 Aug 2024 20:14:46 +0100 Subject: [PATCH 3/4] chore: add is_influence explanation --- addons/lol_blender/operators/skinned/Export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/lol_blender/operators/skinned/Export.py b/addons/lol_blender/operators/skinned/Export.py index 9460c42..765a4bd 100644 --- a/addons/lol_blender/operators/skinned/Export.py +++ b/addons/lol_blender/operators/skinned/Export.py @@ -136,6 +136,10 @@ def poll(cls, context): def export_armature(self, context: bpy.types.Context, l: Any, mat): influences = list(map(lambda v: get_influences(v, self.mesh), range(len(self.mesh.data.vertices)))) + + # we can't just check if a vertex group exists for a bone, because we cap a vertex's influence count to 4, + # which means there can be a bone that would've been the 5th strongest influence on a vertex, + # and influence no other vertices - which means that bone should NOT be included in the rig's influence list is_influence = {} for influence in influences: for (bone, _) in influence: From e0e901491f92dab77fad5172cf1559e4db67ad97 Mon Sep 17 00:00:00 2001 From: Alan Panayotov Date: Sat, 17 Aug 2024 20:14:57 +0100 Subject: [PATCH 4/4] fix: update nix flake wheel path --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index daca457..f0c5ca0 100644 --- a/flake.nix +++ b/flake.nix @@ -112,7 +112,7 @@ export BLENDER_SYSTEM_PYTHON="$(which python)"; export PYTHONPATH="$VIRTUAL_ENV/lib/site-packages"; export PYTHONUSERBASE="$VIRTUAL_ENV"; - export __LOL_WHEEL_PATH="$FLAKE_ROOT/bindings/target/wheels/league_toolkit-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl"; + export __LOL_WHEEL_PATH="$FLAKE_ROOT/bindings/target/wheels/league_toolkit-0.1.0-cp310-abi3-manylinux_2_34_x86_64.whl"; cd - '';