Page Menu
Home
Search
Configure Global Search
Log In
Paste
P1058
(An Untitled Masterwork)
Active
Public
Actions
Authored by
Brecht Van Lommel (brecht)
on Jul 31 2019, 1:30 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
#define SCULPT_VERTEX_FIXED_CAPACITY 256
typedef
struct
SculptVertexNeighbourIter
{
int
*
neighbours
;
int
size
;
int
capacity
;
int
neighbours_fixed
[
SCULPT_VERTEX_FIXED_CAPACITY
];
int
index
;
int
i
;
}
SculptVertexNeighbourIter
;
static
void
sculpt_vertex_neighbour_add
(
SculptVertexNeighbourIter
*
iter
,
int
neighbour_index
)
{
for
(
int
i
=
0
;
i
<
iter
->
size
;
i
++
)
{
if
(
iter
->
neighbours
[
i
]
==
neighbour_index
)
{
return
;
}
}
if
(
iter
->
count
>=
iter
->
capacity
)
{
iter
->
capacity
+=
SCULPT_VERTEX_FIXED_CAPACITY
;
if
(
iter
->
neighbours
==
iter
->
neighbours_fixed
)
{
iter
->
neighbours
=
MEM_mallocN
(
iter
->
capacity
*
sizeof
(
int
),
"neighbour array"
);
memcpy
(
iter
->
neighbours
,
iter
->
neighbours_fixed
,
sizeof
(
int
)
*
iter
->
count
);
}
else
{
iter
->
neighbours
=
MEM_reallocN_id
(
iter
->
neighbours
,
iter
->
capacity
*
sizeof
(
int
),
"neighbour array"
);
}
}
iter
->
neighbours
[
iter
->
size
]
=
neighbour_index
;
iter
->
size
++
;
}
static
void
sculpt_vertex_neighbours_get_bmesh
(
SculptSession
*
ss
,
int
index
,
SculptVertexNeighbourIter
*
iter
)
{
BMVert
*
v
=
BM_vert_at_index
(
ss
->
bm
,
index
);
BMIter
liter
;
BMLoop
*
l
;
iter
->
size
=
0
;
iter
->
capacity
=
SCULPT_VERTEX_FIXED_CAPACITY
;
iter
->
neighbours
=
iter
->
neighbours_fixed
;
...
#define sculpt_vertex_neighbours_iter_end(neighbour_iterator) \
} \
if (neighbour_iterator.neighbours != neighbour_iterator.neighbours_fixed) { \
MEM_freeN
(
neighbour_iterator
.
neighbours
);
\
}
\
Event Timeline
Brecht Van Lommel (brecht)
created this paste.
Jul 31 2019, 1:30 AM
Brecht Van Lommel (brecht)
updated the paste's language from
autodetect
to
c
.
Brecht Van Lommel (brecht)
mentioned this in
D5352: Sculpt mesh abstraction API
.
Log In to Comment