Skip to content

Commit

Permalink
Merge pull request #12 from alanpq/dev
Browse files Browse the repository at this point in the history
bump patch
  • Loading branch information
alanpq authored Aug 17, 2024
2 parents 0273e6a + e0e9014 commit e612502
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions addons/lol_blender/operators/skinned/Export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -137,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:
Expand All @@ -147,7 +150,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
Expand Down
5 changes: 3 additions & 2 deletions bindings/src/skinned/export/skl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn topological_sort(graph: &HashMap<String, Vec<String>>) -> Option<Vec<String>>
pub fn export_skl(
bones: HashMap<String, PyRef<'_, Bone>>,
path: Option<PathBuf>,
) -> PyResult<HashMap<String, i16>> {
) -> PyResult<HashMap<String, u8>> {
let mut skl = RigResource::builder("skeleton_name", "skeleton_asset_name");

let orig_bone_count = bones.len();
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
'';

Expand Down

0 comments on commit e612502

Please sign in to comment.