[PATCH] Fix export of transformed soft volumes
Posted: Tue Jul 15, 2008 12:11 pm
Is this the right place to submit bug fixes for PyPRP?
PyPRP does not correctly export soft volumes that have a rotation or scale - it neglects to apply the transform to the plane normals. This is fixed by the attached patch. For reference, since the forum wouldn't let me attach it unzipped:
I decided to learn about soft volumes today and ended up spending a few hours trying to figure out why one of my volumes wouldn't work. Even though the forum posts I found mentioned that people usually apply transforms to the mesh data before exporting, I didn't bother checking that on my volume because I was so sure I hadn't rotated it... and of course I was wrong .
Plus another comment about a few lines above my change (just outside of the context in the patch): Is it safe to transpose the object's matrix in-place, without making a copy first? When I tried that in the interactive Python console, it seemed that the matrix would reset when switching from edit mode back to object mode, but can we rely on that?
PyPRP does not correctly export soft volumes that have a rotation or scale - it neglects to apply the transform to the plane normals. This is fixed by the attached patch. For reference, since the forum wouldn't let me attach it unzipped:
- Code: Select all
Index: src/prp_VolumeIsect.py
===================================================================
--- src/prp_VolumeIsect.py (revision 275)
+++ src/prp_VolumeIsect.py (working copy)
@@ -214,7 +214,8 @@
for face in obj.data.faces:
if (len(face.v) > 0):
# reversed uru space
- Nor = Blender.Mathutils.Vector(face.no) * -1
+ Nor = tmatrix.rotationPart().invert().transpose() * Blender.Mathutils.Vector(face.no) * -1
+ Nor.normalize()
# transform verts into world space (transposed for uru's reversed space)
Pos = tmatrix * Blender.Mathutils.Vector(face.v[0].co.x, face.v[0].co.y, face.v[0].co.z)
self.AddPlane(Nor, Pos)
I decided to learn about soft volumes today and ended up spending a few hours trying to figure out why one of my volumes wouldn't work. Even though the forum posts I found mentioned that people usually apply transforms to the mesh data before exporting, I didn't bother checking that on my volume because I was so sure I hadn't rotated it... and of course I was wrong .
Plus another comment about a few lines above my change (just outside of the context in the patch): Is it safe to transpose the object's matrix in-place, without making a copy first? When I tried that in the interactive Python console, it seemed that the matrix would reset when switching from edit mode back to object mode, but can we rely on that?