Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Release/v0.0.14 #513

Merged
merged 7 commits into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
Version v0.0.14
===============

- #512 Two small Collision fixes
- Fix for importing an empty (convex) collision shape
- Closes #499 by moving it to a setting rather than using the collision physics property.
- Closes #511 Blender 3.1 python errors importing and exporting collisions
- #497 Slight fix for triangle assignment to bodypart on partition import
- Added warning for too many bones per partition (since some games will crash with that
- Closes #496 "Some polygons of Parthurnax not assigned to any body part." error on unmodified model
- #505 Import animation by default


Version v0.0.13
==============

Expand Down
2 changes: 1 addition & 1 deletion io_scene_niftools/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.13
v0.0.14
2 changes: 1 addition & 1 deletion io_scene_niftools/modules/nif_export/collision/havok.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def export_bhk_rigid_body(self, b_obj, n_col_obj):
n_r_body.restitution = b_r_body.restitution
n_r_body.max_linear_velocity = b_obj.nifcollision.max_linear_velocity
n_r_body.max_angular_velocity = b_obj.nifcollision.max_angular_velocity
n_r_body.penetration_depth = b_obj.collision.permeability
n_r_body.penetration_depth = b_obj.nifcollision.penetration_depth
n_r_body.motion_system = b_obj.nifcollision.motion_system
n_r_body.deactivator_type = b_obj.nifcollision.deactivator_type
n_r_body.solver_deactivation = b_obj.nifcollision.solver_deactivation
Expand Down
30 changes: 18 additions & 12 deletions io_scene_niftools/modules/nif_export/geometry/mesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,24 @@ def export_tri_shapes(self, b_obj, n_parent, n_root, trishape_name=None):

if NifData.data.version >= 0x04020100 and NifOp.props.skin_partition:
NifLog.info("Creating skin partition")

# warn on bad config settings
if game == 'OBLIVION':
if NifOp.props.pad_bones:
NifLog.warn("Using padbones on Oblivion export. Disable the pad bones option to get higher quality skin partitions.")
if game in ('OBLIVION', 'FALLOUT_3'):
if NifOp.props.max_bones_per_partition < 18:
NifLog.warn("Using less than 18 bones per partition on Oblivion/Fallout 3 export."
"Set it to 18 to get higher quality skin partitions.")
elif NifOp.props.max_bones_per_partition > 18:
NifLog.warn("Using more than 18 bones per partition on Oblivion/Fallout 3 export."
"This may cause issues in-game.")
if game == 'SKYRIM':
if NifOp.props.max_bones_per_partition < 24:
NifLog.warn("Using less than 24 bones per partition on Skyrim export."
"Set it to 24 to get higher quality skin partitions.")
# Skyrim Special Edition has a limit of 80 bones per partition, but export is not yet supported

part_order = [getattr(NifFormat.BSDismemberBodyPartType, face_map.name, None) for face_map in b_obj.face_maps]
part_order = [body_part for body_part in part_order if body_part is not None]
# override pyffi trishape.update_skin_partition with custom one (that allows ordering)
Expand All @@ -475,18 +493,6 @@ def export_tri_shapes(self, b_obj, n_parent, n_root, trishape_name=None):
maximize_bone_sharing=(game in ('FALLOUT_3', 'SKYRIM')),
part_sort_order=part_order)

# warn on bad config settings
if game == 'OBLIVION':
if NifOp.props.pad_bones:
NifLog.warn("Using padbones on Oblivion export. Disable the pad bones option to get higher quality skin partitions.")
if game in ('OBLIVION', 'FALLOUT_3'):
if NifOp.props.max_bones_per_partition < 18:
NifLog.warn("Using less than 18 bones per partition on Oblivion/Fallout 3 export."
"Set it to 18 to get higher quality skin partitions.")
if game == 'SKYRIM':
if NifOp.props.max_bones_per_partition < 24:
NifLog.warn("Using less than 24 bones per partition on Skyrim export."
"Set it to 24 to get higher quality skin partitions.")
if lostweight > NifOp.props.epsilon:
NifLog.warn(f"Lost {lostweight:f} in vertex weights while creating a skin partition for Blender object '{b_obj.name}' (nif block '{trishape.name}')")

Expand Down
8 changes: 6 additions & 2 deletions io_scene_niftools/modules/nif_import/collision/havok.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def _import_bhk_rigid_body(self, bhkshape, collision_objs):
b_r_body.deactivate_angular_velocity = mathutils.Vector([ang_vel.w, ang_vel.x, ang_vel.y, ang_vel.z]).magnitude

# Custom Niftools properties
b_col_obj.collision.permeability = bhkshape.penetration_depth
b_col_obj.nifcollision.penetration_depth = bhkshape.penetration_depth
b_col_obj.nifcollision.deactivator_type = NifFormat.DeactivatorType._enumkeys[bhkshape.deactivator_type]
b_col_obj.nifcollision.solver_deactivation = NifFormat.SolverDeactivation._enumkeys[bhkshape.solver_deactivation]
b_col_obj.nifcollision.max_linear_velocity = bhkshape.max_linear_velocity
Expand Down Expand Up @@ -269,7 +269,11 @@ def import_bhkconvex_vertices_shape(self, bhk_shape):
# find vertices (and fix scale)
scaled_verts = [(self.HAVOK_SCALE * n_vert.x, self.HAVOK_SCALE * n_vert.y, self.HAVOK_SCALE * n_vert.z)
for n_vert in bhk_shape.vertices]
verts, faces = qhull3d(scaled_verts)
if scaled_verts:
verts, faces = qhull3d(scaled_verts)
else:
verts = []
faces = []

b_obj = Object.mesh_from_data("convexpoly", verts, faces)
radius = bhk_shape.radius * self.HAVOK_SCALE
Expand Down
13 changes: 10 additions & 3 deletions io_scene_niftools/modules/nif_import/geometry/vertex/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,14 @@ def import_skin(ni_block, b_obj):
v_group.add([vert], w, 'REPLACE')

# import body parts as face maps
# get faces (triangles) as map of tuples to index
tri_map = {frozenset(polygon.vertices): polygon.index for polygon in b_obj.data.polygons}
# get faces (triangles) as map of unordered vertices to list of indices
tri_map = {}
for polygon in b_obj.data.polygons:
vertices = frozenset(polygon.vertices)
if vertices in tri_map:
tri_map[vertices].append(polygon.index)
else:
tri_map[vertices] = [polygon.index]
if isinstance(skininst, NifFormat.BSDismemberSkinInstance):
skinpart = ni_block.get_skin_partition()
for bodypart, skinpartblock in zip(skininst.partitions, skinpart.skin_partition_blocks):
Expand All @@ -178,4 +184,5 @@ def import_skin(ni_block, b_obj):
f_group = b_obj.face_maps.new(name=group_name)

# add the triangles to the face map
f_group.add([tri_map[frozenset(vertices)] for vertices in skinpartblock.get_mapped_triangles()])
for vertices in skinpartblock.get_mapped_triangles():
f_group.add(tri_map[frozenset(vertices)])
2 changes: 1 addition & 1 deletion io_scene_niftools/operators/nif_import_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class NifImportOperator(Operator, ImportHelper, CommonScale, CommonDevOperator,
animation: bpy.props.BoolProperty(
name="Animation",
description="Import animation",
default=False)
default=True)

# Merge skeleton roots.
merge_skeleton_roots: bpy.props.BoolProperty(
Expand Down
6 changes: 6 additions & 0 deletions io_scene_niftools/properties/collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ class CollisionProperty(PropertyGroup):
items=game_specific_col_layer_items,
)

penetration_depth: FloatProperty(
name='Penetration Depth',
description='The maximum allowed penetration for this object.',
default=0.15
)

deactivator_type: EnumProperty(
name='Deactivator Type',
description='Motion deactivation setting',
Expand Down