Skip to content

Commit 0f0e35a

Browse files
authored
Merge pull request #513 from neomonkeus/release/v0.0.14
Release/v0.0.14
2 parents fc28f56 + a2e7f74 commit 0f0e35a

8 files changed

Lines changed: 56 additions & 20 deletions

File tree

CHANGELOG.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
Version v0.0.14
2+
===============
3+
4+
- #512 Two small Collision fixes
5+
- Fix for importing an empty (convex) collision shape
6+
- Closes #499 by moving it to a setting rather than using the collision physics property.
7+
- Closes #511 Blender 3.1 python errors importing and exporting collisions
8+
- #497 Slight fix for triangle assignment to bodypart on partition import
9+
- Added warning for too many bones per partition (since some games will crash with that
10+
- Closes #496 "Some polygons of Parthurnax not assigned to any body part." error on unmodified model
11+
- #505 Import animation by default
12+
13+
114
Version v0.0.13
215
==============
316

io_scene_niftools/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.0.13
1+
v0.0.14

io_scene_niftools/modules/nif_export/collision/havok.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def export_bhk_rigid_body(self, b_obj, n_col_obj):
173173
n_r_body.restitution = b_r_body.restitution
174174
n_r_body.max_linear_velocity = b_obj.nifcollision.max_linear_velocity
175175
n_r_body.max_angular_velocity = b_obj.nifcollision.max_angular_velocity
176-
n_r_body.penetration_depth = b_obj.collision.permeability
176+
n_r_body.penetration_depth = b_obj.nifcollision.penetration_depth
177177
n_r_body.motion_system = b_obj.nifcollision.motion_system
178178
n_r_body.deactivator_type = b_obj.nifcollision.deactivator_type
179179
n_r_body.solver_deactivation = b_obj.nifcollision.solver_deactivation

io_scene_niftools/modules/nif_export/geometry/mesh/__init__.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,24 @@ def export_tri_shapes(self, b_obj, n_parent, n_root, trishape_name=None):
460460

461461
if NifData.data.version >= 0x04020100 and NifOp.props.skin_partition:
462462
NifLog.info("Creating skin partition")
463+
464+
# warn on bad config settings
465+
if game == 'OBLIVION':
466+
if NifOp.props.pad_bones:
467+
NifLog.warn("Using padbones on Oblivion export. Disable the pad bones option to get higher quality skin partitions.")
468+
if game in ('OBLIVION', 'FALLOUT_3'):
469+
if NifOp.props.max_bones_per_partition < 18:
470+
NifLog.warn("Using less than 18 bones per partition on Oblivion/Fallout 3 export."
471+
"Set it to 18 to get higher quality skin partitions.")
472+
elif NifOp.props.max_bones_per_partition > 18:
473+
NifLog.warn("Using more than 18 bones per partition on Oblivion/Fallout 3 export."
474+
"This may cause issues in-game.")
475+
if game == 'SKYRIM':
476+
if NifOp.props.max_bones_per_partition < 24:
477+
NifLog.warn("Using less than 24 bones per partition on Skyrim export."
478+
"Set it to 24 to get higher quality skin partitions.")
479+
# Skyrim Special Edition has a limit of 80 bones per partition, but export is not yet supported
480+
463481
part_order = [getattr(NifFormat.BSDismemberBodyPartType, face_map.name, None) for face_map in b_obj.face_maps]
464482
part_order = [body_part for body_part in part_order if body_part is not None]
465483
# override pyffi trishape.update_skin_partition with custom one (that allows ordering)
@@ -475,18 +493,6 @@ def export_tri_shapes(self, b_obj, n_parent, n_root, trishape_name=None):
475493
maximize_bone_sharing=(game in ('FALLOUT_3', 'SKYRIM')),
476494
part_sort_order=part_order)
477495

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

io_scene_niftools/modules/nif_import/collision/havok.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def _import_bhk_rigid_body(self, bhkshape, collision_objs):
197197
b_r_body.deactivate_angular_velocity = mathutils.Vector([ang_vel.w, ang_vel.x, ang_vel.y, ang_vel.z]).magnitude
198198

199199
# Custom Niftools properties
200-
b_col_obj.collision.permeability = bhkshape.penetration_depth
200+
b_col_obj.nifcollision.penetration_depth = bhkshape.penetration_depth
201201
b_col_obj.nifcollision.deactivator_type = NifFormat.DeactivatorType._enumkeys[bhkshape.deactivator_type]
202202
b_col_obj.nifcollision.solver_deactivation = NifFormat.SolverDeactivation._enumkeys[bhkshape.solver_deactivation]
203203
b_col_obj.nifcollision.max_linear_velocity = bhkshape.max_linear_velocity
@@ -269,7 +269,11 @@ def import_bhkconvex_vertices_shape(self, bhk_shape):
269269
# find vertices (and fix scale)
270270
scaled_verts = [(self.HAVOK_SCALE * n_vert.x, self.HAVOK_SCALE * n_vert.y, self.HAVOK_SCALE * n_vert.z)
271271
for n_vert in bhk_shape.vertices]
272-
verts, faces = qhull3d(scaled_verts)
272+
if scaled_verts:
273+
verts, faces = qhull3d(scaled_verts)
274+
else:
275+
verts = []
276+
faces = []
273277

274278
b_obj = Object.mesh_from_data("convexpoly", verts, faces)
275279
radius = bhk_shape.radius * self.HAVOK_SCALE

io_scene_niftools/modules/nif_import/geometry/vertex/groups.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,14 @@ def import_skin(ni_block, b_obj):
164164
v_group.add([vert], w, 'REPLACE')
165165

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

180186
# add the triangles to the face map
181-
f_group.add([tri_map[frozenset(vertices)] for vertices in skinpartblock.get_mapped_triangles()])
187+
for vertices in skinpartblock.get_mapped_triangles():
188+
f_group.add(tri_map[frozenset(vertices)])

io_scene_niftools/operators/nif_import_op.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class NifImportOperator(Operator, ImportHelper, CommonScale, CommonDevOperator,
6565
animation: bpy.props.BoolProperty(
6666
name="Animation",
6767
description="Import animation",
68-
default=False)
68+
default=True)
6969

7070
# Merge skeleton roots.
7171
merge_skeleton_roots: bpy.props.BoolProperty(

io_scene_niftools/properties/collision.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ class CollisionProperty(PropertyGroup):
8282
items=game_specific_col_layer_items,
8383
)
8484

85+
penetration_depth: FloatProperty(
86+
name='Penetration Depth',
87+
description='The maximum allowed penetration for this object.',
88+
default=0.15
89+
)
90+
8591
deactivator_type: EnumProperty(
8692
name='Deactivator Type',
8793
description='Motion deactivation setting',

0 commit comments

Comments
 (0)