Page MenuHome

OBJ Exporter crashes when exporting smoothed normals in 2.5 alpha0
Closed, ArchivedPublicPATCH

Description

When setting mesh faces to smooth and exporting the normals, the export crashes. The problem is that the face does not have a reference to the VerticeMesh anymore (or so i think). The following changes fix the problem for the "if f_smooth" statement:

if EXPORT_NORMALS:
if f_smooth: # Smoothed, use vertex normals
for vi, v in enumerate(f_v):
file.write( ' %d/%d/%d' % \
(v["index"] + totverts,
totuvco + uv_face_mapping[f_index][vi],
globalNormals[ veckey3d(v["vertex"].normal) ]) ) # vert, uv, normal

else: # No smoothing, face normals
no = globalNormals[ veckey3d(f.normal) ]
for vi, v in enumerate(f_v):
file.write( ' %d/%d/%d' % \
(v["index"] + totverts,
totuvco + uv_face_mapping[f_index][vi],
no) ) # vert, uv, normal
else: # No Normals
for vi, v in enumerate(f_v):
file.write( ' %d/%d' % (\
v["index"] + totverts,\
totuvco + uv_face_mapping[f_index][vi])) # vert, uv

face_vert_index += len(f_v)

Hope this helps. Keep up the good work.

Event Timeline

Sorry my bad... First attempt of posting failed. The pasted snippet is wrong. The correct part is:

if EXPORT_NORMALS:
if f.smooth:
for v in me.verts:
noKey = veckey3d(v.normal)
if noKey not in globalNormals:
globalNormals[noKey] = totno
totno +=1
file.write('vn %.6f %.6f %.6f\n' % noKey)
else:
for f in faces:
# Hard, 1 normal from the face.
noKey = veckey3d(f.normal)
if noKey not in globalNormals:
globalNormals[noKey] = totno
totno +=1
file.write('vn %.6f %.6f %.6f\n' % noKey)

Sorry. And good luck.

Hi, I'd like to look into why this crashes further, so not ignore the patch but like to understand what goes wrong incase the API can be fixed.

also, if you can submit a patch its much more clear to me what changes.

- Thanks for looking into this.

Thanks for considering the changes. I wanted to present the changes in a patch file but didn't really know where in the svn repo the file was located.

The export still crashes blender from time to time as you correctly pointed out. After thinking about the fix, it actually doesn't work correct. When it finds the f_smooth flag it treats all faces as smooth although some might be set to flat.

That is ok for the project i am working on but not correct behavior.

So you should just consider this as a starting point. Anyways, thanks for looking into it.

Hi in svn they are located in blender/release/scripts/io

Campbell Barton (campbellbarton) changed the task status from Unknown Status to Unknown Status.Aug 3 2011, 5:49 PM