Skip to content

Commit

Permalink
Merge pull request #442 from kromar/fix-error-with-empty-vertex-colors
Browse files Browse the repository at this point in the history
fix error when trying to export empty vertex colors
  • Loading branch information
kromar authored Oct 29, 2023
2 parents 26ae7d9 + 2a4b75c commit bf4bce9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
64 changes: 43 additions & 21 deletions GoB.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,28 @@ def exportGoZ(self, path, scn, obj, pathImport):
vcolArray[vert_idx*3] = int(255*vcoldata[loop.index].color[0])
vcolArray[vert_idx*3+1] = int(255*vcoldata[loop.index].color[1])
vcolArray[vert_idx*3+2] = int(255*vcoldata[loop.index].color[2])

if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: loop")

goz_file.write(pack('<4B', 0xb9, 0x88, 0x00, 0x00))
goz_file.write(pack('<I', numVertices*4+16))
goz_file.write(pack('<Q', numVertices))
if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: write numVertices")

for i in range(0, len(vcolArray), 3):
goz_file.write(pack('<B', vcolArray[i+2]))
goz_file.write(pack('<B', vcolArray[i+1]))
goz_file.write(pack('<B', vcolArray[i]))
goz_file.write(pack('<B', 0))
if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: write color")

vcolArray.clear()
if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: vcolArray.clear")

else:
if obj.data.color_attributes.active_color_name:
vcoldata = me.color_attributes[obj.data.color_attributes.active_color_name].data
Expand All @@ -954,30 +976,30 @@ def exportGoZ(self, path, scn, obj, pathImport):
vcolArray[v.index * 3] = int(255*vcoldata[v.index].color_srgb[0])
vcolArray[v.index * 3+1] = int(255*vcoldata[v.index].color_srgb[1])
vcolArray[v.index * 3+2] = int(255*vcoldata[v.index].color_srgb[2])

if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: loop")

if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: loop")

goz_file.write(pack('<4B', 0xb9, 0x88, 0x00, 0x00))
goz_file.write(pack('<I', numVertices*4+16))
goz_file.write(pack('<Q', numVertices))
if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: write numVertices")
goz_file.write(pack('<4B', 0xb9, 0x88, 0x00, 0x00))
goz_file.write(pack('<I', numVertices*4+16))
goz_file.write(pack('<Q', numVertices))
if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: write numVertices")

for i in range(0, len(vcolArray), 3):
goz_file.write(pack('<B', vcolArray[i+2]))
goz_file.write(pack('<B', vcolArray[i+1]))
goz_file.write(pack('<B', vcolArray[i]))
goz_file.write(pack('<B', 0))
if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: write color")
for i in range(0, len(vcolArray), 3):
goz_file.write(pack('<B', vcolArray[i+2]))
goz_file.write(pack('<B', vcolArray[i+1]))
goz_file.write(pack('<B', vcolArray[i]))
goz_file.write(pack('<B', 0))
if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: write color")

vcolArray.clear()
if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: vcolArray.clear")

if prefs().performance_profiling:
start_time = profiler(start_time, "Write Polypaint")
vcolArray.clear()
if prefs().performance_profiling:
start_time = profiler(start_time, " Polypaint: vcolArray.clear")
if prefs().performance_profiling:
start_time = profiler(start_time, "Write Polypaint")

# --Mask--
if not prefs().export_clear_mask:
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"name": "GoB",
"description": "An unofficial GOZ-like addon for Blender",
"author": "ODe, JoseConseco, Daniel Grauer",
"version": (3, 6, 2),
"version": (3, 6, 3),
"blender": (2, 93, 0),
"location": "In the info header",
"doc_url": "https://github.com/JoseConseco/GoB/wiki",
Expand Down

0 comments on commit bf4bce9

Please sign in to comment.