Page Menu
Home
Search
Configure Global Search
Log In
Paste
P2724
Versioning Issue
Active
Public
Actions
Authored by
Johnny Matthews (guitargeek)
on Jan 12 2022, 8:11 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
/* Function to do Additions */
/**
* If the node is a Triangulate Mesh node and has the Minimum Vertices input, update it to the new
* version and add 2 nodes before it. Add the Face Neighbors (Vertex Count Socket) node going into
* a compare node (integer type, greater than or equal mode) first socket. The second socket value
* is set to the old value of Minimum Vertices. The output of the compare node is put in the
* Selection socket of Triangulate.
*/
static
void
version_geometry_nodes_update_triangulate_node
(
bNodeTree
*
ntree
)
{
LISTBASE_FOREACH_MUTABLE
(
bNode
*
,
node
,
&
ntree
->
nodes
)
{
if
(
node
->
type
!=
GEO_NODE_TRIANGULATE
)
{
continue
;
}
bNodeSocket
*
geometry_socket
=
node
->
inputs
.
first
;
bNodeSocket
*
second_socket
=
geometry_socket
->
next
;
if
(
STREQ
(
geometry_socket
->
next
->
name
,
"Selection"
))
{
return
;
}
const
bNodeSocketValueInt
*
socket_value
=
(
const
bNodeSocketValueInt
*
)
second_socket
->
default_value
;
nodeRemoveSocket
(
ntree
,
node
,
second_socket
);
bNodeSocket
*
selection_socket
=
nodeAddSocket
(
ntree
,
node
,
SOCK_IN
,
nodeStaticSocketType
(
SOCK_BOOLEAN
,
PROP_NONE
),
"Selection"
,
"Selection"
);
bNode
*
compare_node
=
nodeAddStaticNode
(
NULL
,
ntree
,
FN_NODE_COMPARE
);
compare_node
->
parent
=
node
->
parent
;
compare_node
->
locx
=
node
->
locx
-
175.0f
;
compare_node
->
locy
=
node
->
locy
;
NodeFunctionCompare
*
data
=
MEM_callocN
(
sizeof
(
NodeFunctionCompare
),
__func__
);
data
->
data_type
=
CD_PROP_INT32
;
data
->
mode
=
NODE_COMPARE_GREATER_EQUAL
;
compare_node
->
storage
=
data
;
bNodeSocket
*
b_socket
=
compare_node
->
inputs
.
last
;
b_socket
->
default_value
=
socket_value
;
nodeAddLink
(
ntree
,
compare_node
,
compare_node
->
outputs
.
first
,
node
,
selection_socket
);
bNode
*
face_neighbors
=
nodeAddStaticNode
(
NULL
,
ntree
,
GEO_NODE_INPUT_MESH_FACE_NEIGHBORS
);
face_neighbors
->
parent
=
node
->
parent
;
face_neighbors
->
locx
=
compare_node
->
locx
-
175.0f
;
face_neighbors
->
locy
=
compare_node
->
locy
;
nodeAddLink
(
ntree
,
face_neighbors
,
face_neighbors
->
outputs
.
first
,
compare_node
,
compare_node
->
inputs
.
last
);
}
}
/* In the "Save this block" block */
/* Add extra nodes for Triangulate changes. */
LISTBASE_FOREACH
(
bNodeTree
*
,
ntree
,
&
bmain
->
nodetrees
)
{
if
(
ntree
->
type
==
NTREE_GEOMETRY
)
{
version_geometry_nodes_update_triangulate_node
(
ntree
);
}
}
Event Timeline
Johnny Matthews (guitargeek)
created this paste.
Jan 12 2022, 8:11 PM
Log In to Comment