add checks for NoneType to ignore empty shape nodes #3
@ -1,7 +1,7 @@
|
||||
schema_version = "1.0.0"
|
||||
id = "web3d_x3d_vrml2_format"
|
||||
name = "Web3D X3D/VRML2 format"
|
||||
version = "2.3.3"
|
||||
version = "2.3.4"
|
||||
tagline = "Import-Export X3D, Import VRML2"
|
||||
maintainer = "Community"
|
||||
type = "add-on"
|
||||
|
@ -1979,16 +1979,37 @@ def importMesh_IndexedFaceSet(geom, ancestry):
|
||||
|
||||
color_per_vertex = geom.getFieldAsBool('colorPerVertex', True, ancestry)
|
||||
color_index = geom.getFieldAsArray('colorIndex', 0, ancestry)
|
||||
has_color_index = len(color_index) != 0
|
||||
has_valid_color_index = index.count(-1) == color_index.count(-1)
|
||||
|
||||
d = bpymesh.vertex_colors.new().data
|
||||
if color_per_vertex:
|
||||
|
||||
# rebuild a corrupted colorIndex field (assuming the end of face markers -1 are missing)
|
||||
if has_color_index and not has_valid_color_index:
|
||||
# remove all -1 beforehand to ensure clean working copy
|
||||
color_index = [x for x in color_index if x != -1]
|
||||
# copy all -1 from coordIndex to colorIndex
|
||||
for i, v in enumerate(index):
|
||||
if v == -1:
|
||||
color_index.insert(i, -1)
|
||||
|
||||
if color_per_vertex and has_color_index: # Color per vertex with index
|
||||
cco = [cco for f in processPerVertexIndex(color_index)
|
||||
for v in f
|
||||
for cco in rgb[v]]
|
||||
for v in f
|
||||
for cco in rgb[v]]
|
||||
elif color_per_vertex: # Color per vertex without index
|
||||
cco = [cco for f in faces
|
||||
for (i, v) in enumerate(f)
|
||||
for cco in rgb[i]]
|
||||
elif color_index: # Color per face with index
|
||||
cco = [cco for (i, f) in enumerate(faces)
|
||||
for j in f
|
||||
for cco in rgb[color_index[i]]]
|
||||
elif len(faces) > len(rgb): # Static color per face without index, when all faces have the same color.
|
||||
# Exported from SOLIDWORKS, see: `blender/blender-addons#105398`.
|
||||
cco = [cco for (i, f) in enumerate(faces)
|
||||
for j in f
|
||||
for cco in rgb[0]]
|
||||
else: # Color per face without index
|
||||
cco = [cco for (i, f) in enumerate(faces)
|
||||
for j in f
|
||||
|
Loading…
Reference in New Issue
Block a user