OBJ Exporter crashes when exporting smoothed normals in 2.5 alpha0 #20559

Closed
opened 2010-01-04 00:28:24 +01:00 by Moritz Post · 7 comments

%%%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.%%%

%%%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.%%%
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

%%%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.%%%

%%%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.%%%
%%%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.%%%
Author

%%%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.%%%

%%%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.%%%
Member

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

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

%%%fixed in svn.%%%

%%%fixed in svn.%%%

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#20559
No description provided.