Skip to content

Commit

Permalink
Fix Mesh Object Output for boolean attributes
Browse files Browse the repository at this point in the history
Booleans lists are stored as char arrays, so we need to convert them to
boolean arrays first.
  • Loading branch information
OmarEmaraDev committed Mar 2, 2024
1 parent 67d67b4 commit fe45013
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- Fixed *Set Vertex Weight* node for new API changes.
- Fixed *Set Edge Weight* node for new API changes.
- Fixed *Set Edge Crease* node for new API changes.
- Fixed *Mesh Object Output* node for boolean custom attributes.

### Changed

Expand Down
5 changes: 4 additions & 1 deletion animation_nodes/nodes/mesh/mesh_object_output.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bpy
import bmesh
import numpy
from bpy.props import *
from ... utils.layout import writeText
from ... base_types import AnimationNode
Expand Down Expand Up @@ -171,10 +172,12 @@ def setMesh(self, outMesh, mesh, object):

attributeOut = outMesh.attributes.new(attribute.name, dataType, domain)

if dataType in ("FLOAT", "INT", "INT32_2D", "BOOLEAN"):
if dataType in ("FLOAT", "INT", "INT32_2D"):
attributeOut.data.foreach_set("value", data.asMemoryView())
elif dataType in ("FLOAT2", "FLOAT_VECTOR"):
attributeOut.data.foreach_set("vector", data.asMemoryView())
elif dataType == "BOOLEAN":
attributeOut.data.foreach_set("value", data.asNumpyArray() != 0)
else:
attributeOut.data.foreach_set("color", data.asMemoryView())

Expand Down

0 comments on commit fe45013

Please sign in to comment.