From 789bf6bcc40b5dbe50d3006575e239b5bbbb8e9f Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 3 Feb 2020 20:53:42 -0500 Subject: [PATCH] Fix incorrect soft volume normal export. The soft volumes were previously in aproximately the correct location but the exported normals were not unit vectors. This seems to have made the resulting soft volumes not function as intended. --- korman/properties/modifiers/region.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/korman/properties/modifiers/region.py b/korman/properties/modifiers/region.py index aa84f45..1ce022a 100644 --- a/korman/properties/modifiers/region.py +++ b/korman/properties/modifiers/region.py @@ -278,11 +278,19 @@ class PlasmaSoftVolume(idprops.IDPropMixin, PlasmaModifierProperties): # Initialize the plVolumeIsect. Currently, we only support convex isects. If you want parallel # isects from empties, be my guest... with TemporaryObject(bo.to_mesh(bpy.context.scene, True, "RENDER", calc_tessface=False), bpy.data.meshes.remove) as mesh: - mesh.transform(bo.matrix_world) + matrix = bo.matrix_world + #l2w = utils.matrix44(matrix) + xform = matrix.inverted() + xform.transpose() isect = plConvexIsect() - for i in mesh.vertices: - isect.addPlane(hsVector3(*i.normal), hsVector3(*i.co)) + for ngon in mesh.polygons: + normal = xform * ngon.normal * -1 + normal.normalize() + normal = hsVector3(*normal) + for vertex in (mesh.vertices[i] for i in ngon.vertices): + pos = matrix * vertex.co + isect.addPlane(normal, hsVector3(*pos)) sv.volume = isect def _export_sv_nodes(self, exporter, bo, so):