GPv3: Curve to Mesh node #113659

Manually merged
Dalai Felinto merged 86 commits from dfelinto/blender:grease-nodes-curve-to-mesh into main 2023-10-16 11:49:25 +02:00
2 changed files with 50 additions and 47 deletions
Showing only changes of commit d9225ac121 - Show all commits

View File

@ -2668,6 +2668,35 @@ static void node_draw_extra_info_row(const bNode &node,
}
}
static void node_draw_extra_info_panel_back(const bNode &node, const rctf &extra_info_rect)
{
const rctf &node_rect = node.runtime->totr;
rctf panel_back_rect = extra_info_rect;
/* Extend the panel behind hidden nodes to accomodate the large rounded corners. */
if (node.flag & NODE_HIDDEN) {
panel_back_rect.ymin = BLI_rctf_cent_y(&node_rect);
}
ColorTheme4f color;
if (node.flag & NODE_MUTED) {
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color);
}
else {
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.75f, color);
}
color.a -= 0.35f;
ColorTheme4f color_outline;
UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color_outline);
const float outline_width = U.pixelsize;
BLI_rctf_pad(&panel_back_rect, outline_width, outline_width);
UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
UI_draw_roundbox_4fv_ex(
&panel_back_rect, color, nullptr, 0.0f, color_outline, outline_width, BASIS_RAD);
}
static void node_draw_extra_info_panel(const Scene *scene,
TreeDrawContext &tree_draw_ctx,
const SpaceNode &snode,
@ -2688,11 +2717,8 @@ static void node_draw_extra_info_panel(const Scene *scene,
}
const rctf &rct = node.runtime->totr;
float color[4];
rctf extra_info_rect;
const float width = (node.width - 6.0f) * UI_SCALE_FAC;
if (node.is_frame()) {
extra_info_rect.xmin = rct.xmin;
extra_info_rect.xmax = rct.xmin + 95.0f * UI_SCALE_FAC;
@ -2700,62 +2726,40 @@ static void node_draw_extra_info_panel(const Scene *scene,
extra_info_rect.ymax = rct.ymin + 2.0f * UI_SCALE_FAC;
}
else {
float preview_height = 0;
rctf preview_rect;
const float padding = 3.0f * UI_SCALE_FAC;
extra_info_rect.xmin = rct.xmin + 3.0f * UI_SCALE_FAC;
extra_info_rect.xmax = extra_info_rect.xmin + width;
extra_info_rect.xmin = rct.xmin + padding;
extra_info_rect.xmax = rct.xmax - padding;
extra_info_rect.ymin = rct.ymax;
extra_info_rect.ymax = rct.ymax + extra_info_rows.size() * (20.0f * UI_SCALE_FAC);
float preview_height = 0.0f;
rctf preview_rect;
if (preview) {
const float width = BLI_rctf_size_x(&extra_info_rect);
if (preview->x > preview->y) {
const float preview_padding = 3.0f * UI_SCALE_FAC;
preview_height = (width - 2.0 * preview_padding) * float(preview->y) / float(preview->x) +
2.0 * preview_padding;
preview_rect.ymin = extra_info_rect.ymin + preview_padding;
preview_rect.ymax = extra_info_rect.ymin + preview_height - preview_padding;
preview_rect.xmin = extra_info_rect.xmin + preview_padding;
preview_rect.xmax = extra_info_rect.xmax - preview_padding;
preview_height = (width - 2.0f * padding) * float(preview->y) / float(preview->x) +
2.0f * padding;
preview_rect.ymin = extra_info_rect.ymin + padding;
preview_rect.ymax = extra_info_rect.ymin + preview_height - padding;
preview_rect.xmin = extra_info_rect.xmin + padding;
preview_rect.xmax = extra_info_rect.xmax - padding;
extra_info_rect.ymax += preview_height;
}
else {
const float preview_padding = 3.0f * UI_SCALE_FAC;
preview_height = width;
const float preview_width = (width - 2.0 * preview_padding) * float(preview->x) /
const float preview_width = (width - 2.0f * padding) * float(preview->x) /
float(preview->y) +
2.0 * preview_padding;
preview_rect.ymin = extra_info_rect.ymin + preview_padding;
preview_rect.ymax = extra_info_rect.ymin + preview_height - preview_padding;
preview_rect.xmin = extra_info_rect.xmin + preview_padding + (width - preview_width) / 2;
preview_rect.xmax = extra_info_rect.xmax - preview_padding - (width - preview_width) / 2;
2.0f * padding;
preview_rect.ymin = extra_info_rect.ymin + padding;
preview_rect.ymax = extra_info_rect.ymin + preview_height - padding;
preview_rect.xmin = extra_info_rect.xmin + padding + (width - preview_width) / 2;
preview_rect.xmax = extra_info_rect.xmax - padding - (width - preview_width) / 2;
extra_info_rect.ymax += preview_height;
}
}
if (node.flag & NODE_MUTED) {
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color);
}
else {
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.75f, color);
}
color[3] -= 0.35f;
UI_draw_roundbox_corner_set(
UI_CNR_ALL & ~UI_CNR_BOTTOM_LEFT &
((rct.xmax) > extra_info_rect.xmax ? ~UI_CNR_BOTTOM_RIGHT : UI_CNR_ALL));
UI_draw_roundbox_4fv(&extra_info_rect, true, BASIS_RAD, color);
/* Draw outline. */
const float outline_width = 1.0f;
extra_info_rect.xmin -= outline_width;
extra_info_rect.xmax += outline_width;
extra_info_rect.ymin -= outline_width;
extra_info_rect.ymax += outline_width;
UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color);
UI_draw_roundbox_corner_set(
UI_CNR_ALL & ~UI_CNR_BOTTOM_LEFT &
((rct.xmax) > extra_info_rect.xmax ? ~UI_CNR_BOTTOM_RIGHT : UI_CNR_ALL));
UI_draw_roundbox_4fv(&extra_info_rect, false, BASIS_RAD, color);
node_draw_extra_info_panel_back(node, extra_info_rect);
if (preview) {
node_draw_preview(scene, preview, &preview_rect);

View File

@ -162,8 +162,7 @@ static void createTransMeshVertCData(bContext * /*C*/, TransInfo *t)
if (mirror_data.vert_map) {
tc->data_mirror_len = mirror_data.mirror_elem_len;
tc->data_mirror = static_cast<TransDataMirror *>(
MEM_mallocN(mirror_data.mirror_elem_len * sizeof(*tc->data_mirror), __func__));
tc->data_mirror = MEM_cnew_array<TransDataMirror>(mirror_data.mirror_elem_len, __func__);
BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) {