Sculpt-dev: Fix merge errors
* Cleaned up a few old bmesh-only pbvh functions into generic ones. * Sculpt colors from master is now merged in. * Implemenation for querying original verts is now inside pbvh instead of sculpt.
This commit is contained in:
parent
d75932cbef
commit
a38889b2bd
|
@ -1151,7 +1151,8 @@ def km_uv_editor(params):
|
|||
{"type": params.select_mouse, "value": params.select_mouse_value_fallback, "ctrl": True, "shift": True},
|
||||
{"properties": [("use_fill", True)]}),
|
||||
("uv.select_split", {"type": 'Y', "value": 'PRESS'}, None),
|
||||
op_tool_optional(("uv.select_box", {"type": 'B', "value": 'PRESS'},
|
||||
op_tool_optional(
|
||||
("uv.select_box", {"type": 'B', "value": 'PRESS'},
|
||||
{"properties": [("pinned", False)]}),
|
||||
(op_tool, "builtin.select_box"), params),
|
||||
("uv.select_box", {"type": 'B', "value": 'PRESS', "ctrl": True},
|
||||
|
@ -5850,7 +5851,8 @@ def km_image_editor_tool_uv_select(params, *, fallback):
|
|||
|
||||
|
||||
def km_image_editor_tool_uv_select_box(params, *, fallback):
|
||||
return (_fallback_id("Image Editor Tool: Uv, Select Box", fallback),
|
||||
return (
|
||||
_fallback_id("Image Editor Tool: Uv, Select Box", fallback),
|
||||
{"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
|
||||
{"items": [
|
||||
*([] if (fallback and not params.use_fallback_tool) else _template_items_tool_select_actions_simple(
|
||||
|
|
|
@ -663,7 +663,6 @@ classes = (MESH_MT_vertex_group_context_menu,
|
|||
MESH_UL_shape_keys,
|
||||
MESH_UL_uvmaps,
|
||||
MESH_UL_attributes,
|
||||
MESH_UL_color_attributes,
|
||||
DATA_PT_context_mesh,
|
||||
DATA_PT_vertex_groups,
|
||||
DATA_PT_shape_keys,
|
||||
|
|
|
@ -334,22 +334,13 @@ struct BMLog *BKE_pbvh_get_bm_log(PBVH *pbvh);
|
|||
|
||||
/* update MSculptVerts, doesn't take pbvh argument to allow usage if pbvh doesn't currently exist
|
||||
*/
|
||||
void BKE_pbvh_update_sculpt_verts(struct BMesh *bm,
|
||||
const int cd_sculpt_vert,
|
||||
const int cd_faceset_offset,
|
||||
const int cd_vert_node_offset,
|
||||
const int cd_face_node_offset,
|
||||
const int boundary_symmetry,
|
||||
const int vcol_type,
|
||||
const AttributeDomain vcol_domain,
|
||||
const int cd_vcol_offset,
|
||||
bool do_uvs);
|
||||
void BKE_pbvh_update_sculpt_verts(PBVH *pbvh);
|
||||
|
||||
/** update original data, only data whose r_** parameters are passed in will be updated*/
|
||||
void BKE_pbvh_bmesh_update_origvert(
|
||||
PBVH *pbvh, struct BMVert *v, float **r_co, float **r_no, float **r_color);
|
||||
bool BKE_pbvh_get_origvert(
|
||||
PBVH *pbvh, SculptVertRef vertex, float **r_co, float **r_no, float **r_color);
|
||||
|
||||
/**
|
||||
/**
|
||||
checks if original data needs to be updated for v, and if so updates it. Stroke_id
|
||||
is provided by the sculpt code and is used to detect updates. The reason we do it
|
||||
inside the verts and not in the nodes is to allow splitting of the pbvh during the stroke.
|
||||
|
@ -1148,8 +1139,6 @@ void BKE_dyntopo_remesh(DynTopoState *ds,
|
|||
DynRemeshParams *params,
|
||||
int steps,
|
||||
PBVHTopologyUpdateMode mode);
|
||||
void BKE_pbvh_bmesh_get_vcol(
|
||||
struct BMVert *v, float color[4], int vcol_type, AttributeDomain vcol_domain, int vcol_offset);
|
||||
/*
|
||||
|
||||
use pmap to build an array of edge indices surrounding vertex
|
||||
|
|
|
@ -540,7 +540,7 @@ CustomDataLayer *BKE_id_attribute_subset_active_get(const ID *id,
|
|||
CustomDataLayer *layer = cdata->layers + j;
|
||||
|
||||
if (!(CD_TYPE_AS_MASK(layer->type) & mask) ||
|
||||
(CD_TYPE_AS_MASK(layer->type) & CD_FLAG_TEMPORARY)) {
|
||||
(CD_TYPE_AS_MASK(layer->flag) & CD_FLAG_TEMPORARY)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -615,6 +615,21 @@ void BKE_id_attributes_render_color_set(ID *id, CustomDataLayer *active_layer)
|
|||
id, active_layer, CD_FLAG_COLOR_RENDER, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL);
|
||||
}
|
||||
|
||||
CustomDataLayer *BKE_id_attributes_color_find(const ID *id, const char *name)
|
||||
{
|
||||
CustomDataLayer *layer = BKE_id_attribute_find(id, name, CD_PROP_COLOR, ATTR_DOMAIN_POINT);
|
||||
if (layer == NULL) {
|
||||
layer = BKE_id_attribute_find(id, name, CD_PROP_COLOR, ATTR_DOMAIN_CORNER);
|
||||
}
|
||||
if (layer == NULL) {
|
||||
layer = BKE_id_attribute_find(id, name, CD_MLOOPCOL, ATTR_DOMAIN_POINT);
|
||||
}
|
||||
if (layer == NULL) {
|
||||
layer = BKE_id_attribute_find(id, name, CD_MLOOPCOL, ATTR_DOMAIN_CORNER);
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
|
||||
void BKE_id_attribute_copy_domains_temp(short id_type,
|
||||
const CustomData *vdata,
|
||||
const CustomData *edata,
|
||||
|
|
|
@ -1758,6 +1758,11 @@ static void sculpt_update_object(Depsgraph *depsgraph,
|
|||
ss->medge = me->medge;
|
||||
ss->mpoly = me->mpoly;
|
||||
ss->mloop = me->mloop;
|
||||
ss->vdata = &me->vdata;
|
||||
ss->pdata = &me->pdata;
|
||||
ss->edata = &me->edata;
|
||||
ss->ldata = &me->ldata;
|
||||
|
||||
ss->multires.active = false;
|
||||
ss->multires.modifier = NULL;
|
||||
ss->multires.level = 0;
|
||||
|
@ -1800,6 +1805,8 @@ static void sculpt_update_object(Depsgraph *depsgraph,
|
|||
|
||||
PBVH *pbvh = BKE_sculpt_object_pbvh_ensure(depsgraph, ob);
|
||||
|
||||
BKE_pbvh_update_active_vcol(pbvh, me);
|
||||
|
||||
if (BKE_pbvh_type(pbvh) == PBVH_FACES) {
|
||||
ss->vert_normals = BKE_pbvh_get_vert_normals(ss->pbvh);
|
||||
}
|
||||
|
@ -3427,6 +3434,8 @@ void BKE_sculptsession_update_attr_refs(Object *ob)
|
|||
ss->vcol = layer->data;
|
||||
}
|
||||
}
|
||||
|
||||
BKE_pbvh_update_active_vcol(ss->pbvh, me);
|
||||
}
|
||||
|
||||
if (ss->bm) {
|
||||
|
|
|
@ -160,8 +160,8 @@ static void update_node_vb(PBVH *pbvh, PBVHNode *node, int updateflag)
|
|||
BB_reset(&vb);
|
||||
BB_reset(&orig_vb);
|
||||
|
||||
bool do_orig = updateflag & PBVH_UpdateOriginalBB;
|
||||
bool do_normal = updateflag & PBVH_UpdateBB;
|
||||
bool do_orig = true; // XXX updateflag & PBVH_UpdateOriginalBB;
|
||||
bool do_normal = true; // XXX updateflag & PBVH_UpdateBB;
|
||||
|
||||
if (node->flag & PBVH_Leaf) {
|
||||
PBVHVertexIter vd;
|
||||
|
@ -1411,7 +1411,6 @@ static int pbvh_get_buffers_update_flags(PBVH *UNUSED(pbvh))
|
|||
return update_flags;
|
||||
}
|
||||
|
||||
|
||||
bool BKE_pbvh_get_color_layer(const Mesh *me, CustomDataLayer **r_layer, AttributeDomain *r_attr)
|
||||
{
|
||||
CustomDataLayer *layer = BKE_id_attributes_active_color_get((ID *)me);
|
||||
|
@ -1452,7 +1451,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
|
|||
AttributeDomain vcol_domain;
|
||||
|
||||
BKE_pbvh_get_color_layer(me, &vcol_layer, &vcol_domain);
|
||||
|
||||
|
||||
CustomData *vdata, *ldata;
|
||||
|
||||
if (!pbvh->bm) {
|
||||
|
@ -1703,7 +1702,8 @@ static void pbvh_update_draw_buffers(
|
|||
pbvh->vcol_type,
|
||||
pbvh->vcol_domain,
|
||||
vcol_layer,
|
||||
render_vcol_layer)) {
|
||||
render_vcol_layer,
|
||||
!GPU_pbvh_need_full_render_get())) {
|
||||
// attribute layout changed; force rebuild
|
||||
for (int i = 0; i < pbvh->totnode; i++) {
|
||||
PBVHNode *node = pbvh->nodes + i;
|
||||
|
@ -4289,9 +4289,9 @@ void BKE_pbvh_check_tri_areas(PBVH *pbvh, PBVHNode *node)
|
|||
continue;
|
||||
}
|
||||
|
||||
MVert *mv1 = pbvh->verts + pbvh->mloop[lt->tri[0]].v;
|
||||
MVert *mv2 = pbvh->verts + pbvh->mloop[lt->tri[1]].v;
|
||||
MVert *mv3 = pbvh->verts + pbvh->mloop[lt->tri[2]].v;
|
||||
const MVert *mv1 = pbvh->verts + pbvh->mloop[lt->tri[0]].v;
|
||||
const MVert *mv2 = pbvh->verts + pbvh->mloop[lt->tri[1]].v;
|
||||
const MVert *mv3 = pbvh->verts + pbvh->mloop[lt->tri[2]].v;
|
||||
|
||||
float area = area_tri_v3(mv1->co, mv2->co, mv3->co);
|
||||
|
||||
|
@ -4973,6 +4973,8 @@ PBVH *BKE_pbvh_get_or_free_cached(Object *ob, Mesh *me, PBVHType pbvh_type)
|
|||
break;
|
||||
}
|
||||
|
||||
BKE_pbvh_update_active_vcol(pbvh, me);
|
||||
|
||||
return pbvh;
|
||||
}
|
||||
|
||||
|
@ -5159,7 +5161,6 @@ bool BKE_pbvh_pmap_release(SculptPMap *pmap)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool BKE_pbvh_is_drawing(const PBVH *pbvh)
|
||||
{
|
||||
return pbvh->is_drawing;
|
||||
|
@ -5182,7 +5183,23 @@ void BKE_pbvh_node_num_loops(PBVH *pbvh, PBVHNode *node, int *r_totloop)
|
|||
|
||||
void BKE_pbvh_update_active_vcol(PBVH *pbvh, const Mesh *mesh)
|
||||
{
|
||||
CustomDataLayer *last_layer = pbvh->color_layer;
|
||||
|
||||
BKE_pbvh_get_color_layer(mesh, &pbvh->color_layer, &pbvh->color_domain);
|
||||
|
||||
if (pbvh->color_layer) {
|
||||
pbvh->color_type = pbvh->color_layer->type;
|
||||
}
|
||||
|
||||
if (pbvh->color_layer != last_layer) {
|
||||
for (int i = 0; i < pbvh->totnode; i++) {
|
||||
PBVHNode *node = pbvh->nodes + i;
|
||||
|
||||
if (node->flag & PBVH_Leaf) {
|
||||
BKE_pbvh_node_mark_update_color(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_pbvh_pmap_set(PBVH *pbvh, SculptPMap *pmap)
|
||||
|
@ -5238,3 +5255,75 @@ void BKE_pbvh_ensure_node_loops(PBVH *pbvh)
|
|||
|
||||
MEM_SAFE_FREE(visit);
|
||||
}
|
||||
|
||||
bool BKE_pbvh_get_origvert(
|
||||
PBVH *pbvh, SculptVertRef vertex, float **r_co, float **r_no, float **r_color)
|
||||
{
|
||||
MSculptVert *mv;
|
||||
|
||||
switch (pbvh->type) {
|
||||
case PBVH_FACES:
|
||||
case PBVH_GRIDS:
|
||||
mv = pbvh->mdyntopo_verts + vertex.i;
|
||||
|
||||
if (mv->stroke_id != pbvh->stroke_id) {
|
||||
mv->stroke_id = pbvh->stroke_id;
|
||||
|
||||
if (pbvh->type == PBVH_FACES) {
|
||||
copy_v3_v3(mv->origco, pbvh->verts[vertex.i].co);
|
||||
copy_v3_v3(mv->origno, pbvh->vert_normals[vertex.i]);
|
||||
}
|
||||
else {
|
||||
const CCGKey *key = BKE_pbvh_get_grid_key(pbvh);
|
||||
const int grid_index = vertex.i / key->grid_area;
|
||||
const int vertex_index = vertex.i - grid_index * key->grid_area;
|
||||
CCGElem *elem = BKE_pbvh_get_grids(pbvh)[grid_index];
|
||||
|
||||
copy_v3_v3(mv->origco, CCG_elem_co(key, CCG_elem_offset(key, elem, vertex_index)));
|
||||
copy_v3_v3(mv->origno, CCG_elem_no(key, CCG_elem_offset(key, elem, vertex_index)));
|
||||
}
|
||||
|
||||
float *mask = (float *)CustomData_get_layer(pbvh->vdata, CD_PAINT_MASK);
|
||||
|
||||
if (mask) {
|
||||
mv->origmask = mask[vertex.i];
|
||||
}
|
||||
|
||||
if (pbvh->color_layer) {
|
||||
BKE_pbvh_vertex_color_get(pbvh, vertex, mv->origcolor);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PBVH_BMESH: {
|
||||
BMVert *v = (BMVert *)vertex.i;
|
||||
mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
|
||||
|
||||
if (mv->stroke_id != pbvh->stroke_id) {
|
||||
mv->stroke_id = pbvh->stroke_id;
|
||||
|
||||
if (pbvh->cd_vert_mask_offset != -1) {
|
||||
mv->origmask = (short)(BM_ELEM_CD_GET_FLOAT(v, pbvh->cd_vert_mask_offset) * 65535.0f);
|
||||
}
|
||||
|
||||
if (pbvh->cd_vcol_offset != -1) {
|
||||
BKE_pbvh_vertex_color_get(pbvh, vertex, mv->origcolor);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (r_co) {
|
||||
*r_co = mv->origco;
|
||||
}
|
||||
|
||||
if (r_no) {
|
||||
*r_no = mv->origno;
|
||||
}
|
||||
|
||||
if (r_color) {
|
||||
*r_color = mv->origcolor;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ static void pbvh_vertex_color_get_bmesh(const PBVH &pbvh, SculptVertRef vertex,
|
|||
float temp[4];
|
||||
|
||||
T *ptr = static_cast<T*>(BM_ELEM_CD_GET_VOID_P(l, pbvh.cd_vcol_offset));
|
||||
to_float(ptr, temp);
|
||||
to_float(*ptr, temp);
|
||||
|
||||
add_v4_v4(r_color, temp);
|
||||
count++;
|
||||
|
@ -164,7 +164,7 @@ static void pbvh_vertex_color_get_bmesh(const PBVH &pbvh, SculptVertRef vertex,
|
|||
}
|
||||
else {
|
||||
T *ptr = static_cast<T *>(BM_ELEM_CD_GET_VOID_P(v, pbvh.cd_vcol_offset));
|
||||
to_float(ptr, r_color);
|
||||
to_float(*ptr, r_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,12 +217,12 @@ static void pbvh_vertex_color_set_bmesh(PBVH &pbvh, SculptVertRef vertex, const
|
|||
|
||||
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
|
||||
T *ptr = static_cast<T *>(BM_ELEM_CD_GET_VOID_P(l, pbvh.cd_vcol_offset));
|
||||
from_float(color, ptr);
|
||||
from_float(color, *ptr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
T *ptr = static_cast<T *>(BM_ELEM_CD_GET_VOID_P(v, pbvh.cd_vcol_offset));
|
||||
from_float(color, ptr);
|
||||
from_float(color, *ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ static void pbvh_vertex_color_set(PBVH &pbvh, SculptVertRef vertex, const float
|
|||
extern "C" {
|
||||
void BKE_pbvh_vertex_color_get(const PBVH *pbvh, SculptVertRef vertex, float r_color[4])
|
||||
{
|
||||
blender::bke::to_static_color_type(CustomDataType(pbvh->color_layer->type), [&](auto dummy) {
|
||||
blender::bke::to_static_color_type(CustomDataType(pbvh->color_type), [&](auto dummy) {
|
||||
using T = decltype(dummy);
|
||||
blender::bke::pbvh_vertex_color_get<T>(*pbvh, vertex, r_color);
|
||||
});
|
||||
|
@ -254,7 +254,7 @@ void BKE_pbvh_vertex_color_get(const PBVH *pbvh, SculptVertRef vertex, float r_c
|
|||
|
||||
void BKE_pbvh_vertex_color_set(PBVH *pbvh, SculptVertRef vertex, const float color[4])
|
||||
{
|
||||
blender::bke::to_static_color_type(CustomDataType(pbvh->color_layer->type), [&](auto dummy) {
|
||||
blender::bke::to_static_color_type(CustomDataType(pbvh->color_type), [&](auto dummy) {
|
||||
using T = decltype(dummy);
|
||||
blender::bke::pbvh_vertex_color_set<T>(*pbvh, vertex, color);
|
||||
});
|
||||
|
@ -276,7 +276,7 @@ void BKE_pbvh_swap_colors(PBVH *pbvh,
|
|||
});
|
||||
}
|
||||
|
||||
void BKE_pbvh_store_colors(PBVH *pbvh,
|
||||
ATTR_NO_OPT void BKE_pbvh_store_colors(PBVH *pbvh,
|
||||
const int *indices,
|
||||
const int indices_num,
|
||||
float (*r_colors)[4])
|
||||
|
|
|
@ -864,124 +864,13 @@ void BKE_pbvh_bmesh_regen_node_verts(PBVH *pbvh)
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_pbvh_bmesh_get_vcol(
|
||||
BMVert *v, float color[4], int vcol_type, AttributeDomain vcol_domain, int vcol_offset)
|
||||
{
|
||||
if (vcol_domain == ATTR_DOMAIN_POINT) {
|
||||
switch (vcol_type) {
|
||||
case CD_PROP_COLOR:
|
||||
copy_v4_v4(color, (float *)BM_ELEM_CD_GET_VOID_P(v, vcol_offset));
|
||||
break;
|
||||
case CD_MLOOPCOL: {
|
||||
MLoopCol *mp = (MLoopCol *)BM_ELEM_CD_GET_VOID_P(v, vcol_offset);
|
||||
|
||||
rgba_uchar_to_float(color, (const char *)mp);
|
||||
srgb_to_linearrgb_v3_v3(color, color);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /*average all loop colors*/
|
||||
BMEdge *e = v->e;
|
||||
|
||||
zero_v4(color);
|
||||
|
||||
if (!e) {
|
||||
return;
|
||||
}
|
||||
|
||||
int tot = 0;
|
||||
|
||||
do {
|
||||
BMLoop *l = e->l;
|
||||
|
||||
if (!l) {
|
||||
continue;
|
||||
}
|
||||
|
||||
do {
|
||||
switch (vcol_type) {
|
||||
case CD_PROP_COLOR:
|
||||
add_v4_v4(color, (float *)BM_ELEM_CD_GET_VOID_P(l, vcol_offset));
|
||||
tot++;
|
||||
|
||||
break;
|
||||
case CD_MLOOPCOL: {
|
||||
MLoopCol *mp = (MLoopCol *)BM_ELEM_CD_GET_VOID_P(l, vcol_offset);
|
||||
|
||||
float temp[4];
|
||||
|
||||
rgba_uchar_to_float(temp, (const char *)mp);
|
||||
srgb_to_linearrgb_v3_v3(temp, temp);
|
||||
|
||||
add_v4_v4(color, temp);
|
||||
tot++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while ((l = l->radial_next) != e->l);
|
||||
} while ((e = BM_DISK_EDGE_NEXT(e, v)) != v->e);
|
||||
|
||||
if (tot > 0) {
|
||||
mul_v4_fl(color, 1.0f / (float)tot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_pbvh_bmesh_update_origvert(
|
||||
PBVH *pbvh, BMVert *v, float **r_co, float **r_no, float **r_color)
|
||||
{
|
||||
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
|
||||
|
||||
if (pbvh->cd_vert_mask_offset) {
|
||||
mv->origmask = (short)(BM_ELEM_CD_GET_FLOAT(v, pbvh->cd_vert_mask_offset) * 65535.0f);
|
||||
}
|
||||
|
||||
if (r_co || r_no) {
|
||||
|
||||
copy_v3_v3(mv->origco, v->co);
|
||||
copy_v3_v3(mv->origno, v->no);
|
||||
|
||||
if (r_co) {
|
||||
*r_co = mv->origco;
|
||||
}
|
||||
|
||||
if (r_no) {
|
||||
*r_no = mv->origno;
|
||||
}
|
||||
}
|
||||
|
||||
if (r_color && pbvh->vcol_type != -1) {
|
||||
BKE_pbvh_bmesh_get_vcol(
|
||||
v, mv->origcolor, pbvh->vcol_type, pbvh->vcol_domain, pbvh->cd_vcol_offset);
|
||||
|
||||
if (r_color) {
|
||||
*r_color = mv->origcolor;
|
||||
}
|
||||
}
|
||||
else if (r_color) {
|
||||
*r_color = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/************************* Called from pbvh.c *************************/
|
||||
|
||||
bool BKE_pbvh_bmesh_check_origdata(PBVH *pbvh, BMVert *v, int stroke_id)
|
||||
{
|
||||
// keep this up to date with surface_smooth_v_safe in dyntopo.c
|
||||
SculptVertRef vertex = {(intptr_t)v};
|
||||
|
||||
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
|
||||
|
||||
if (mv->stroke_id != stroke_id) {
|
||||
float *dummy;
|
||||
|
||||
BKE_pbvh_bmesh_update_origvert(pbvh, v, &dummy, &dummy, &dummy);
|
||||
mv->stroke_id = stroke_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return BKE_pbvh_get_origvert(pbvh, vertex, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
bool pbvh_bmesh_node_raycast(PBVH *pbvh,
|
||||
|
@ -2312,48 +2201,14 @@ static void coalese_pbvh(PBVH *pbvh, BMesh *bm)
|
|||
BLI_array_free(nodes);
|
||||
}
|
||||
|
||||
void BKE_pbvh_update_sculpt_verts(BMesh *bm,
|
||||
const int cd_sculpt_vert,
|
||||
const int cd_faceset_offset,
|
||||
const int cd_vert_node_offset,
|
||||
const int cd_face_node_offset,
|
||||
const int boundary_symmetry,
|
||||
const int vcol_type,
|
||||
const AttributeDomain vcol_domain,
|
||||
const int cd_vcol_offset,
|
||||
bool do_uvs)
|
||||
void BKE_pbvh_update_sculpt_verts(PBVH *pbvh)
|
||||
{
|
||||
BMVert *v;
|
||||
BMIter iter;
|
||||
int totvert = pbvh->totvert;
|
||||
|
||||
int totuv = do_uvs ? CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV) : 0;
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vertex = BKE_pbvh_table_index_to_vertex(pbvh, i);
|
||||
|
||||
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
|
||||
MSculptVert *mv = BKE_PBVH_SCULPTVERT(cd_sculpt_vert, v);
|
||||
|
||||
mv->flag = SCULPTVERT_NEED_DISK_SORT | SCULPTVERT_NEED_VALENCE;
|
||||
|
||||
bke_pbvh_update_vert_boundary(cd_sculpt_vert,
|
||||
cd_faceset_offset,
|
||||
cd_vert_node_offset,
|
||||
cd_face_node_offset,
|
||||
-1,
|
||||
v,
|
||||
boundary_symmetry,
|
||||
&bm->ldata,
|
||||
totuv);
|
||||
|
||||
BKE_pbvh_bmesh_update_valence(cd_sculpt_vert, (SculptVertRef){(intptr_t)v});
|
||||
|
||||
copy_v3_v3(mv->origco, v->co);
|
||||
copy_v3_v3(mv->origno, v->no);
|
||||
|
||||
if (vcol_type != -1) {
|
||||
BKE_pbvh_bmesh_get_vcol(v, mv->origcolor, vcol_type, vcol_domain, cd_vcol_offset);
|
||||
}
|
||||
else {
|
||||
zero_v4(mv->origcolor);
|
||||
}
|
||||
BKE_pbvh_get_origvert(pbvh, vertex, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2514,16 +2369,7 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
|
|||
}
|
||||
|
||||
if (update_sculptverts) {
|
||||
BKE_pbvh_update_sculpt_verts(pbvh->bm,
|
||||
pbvh->cd_sculpt_vert,
|
||||
pbvh->cd_faceset_offset,
|
||||
pbvh->cd_vert_node_offset,
|
||||
pbvh->cd_face_node_offset,
|
||||
pbvh->boundary_symmetry,
|
||||
pbvh->vcol_type,
|
||||
pbvh->vcol_domain,
|
||||
pbvh->cd_vcol_offset,
|
||||
!(pbvh->flags & PBVH_IGNORE_UVS));
|
||||
BKE_pbvh_update_sculpt_verts(pbvh);
|
||||
}
|
||||
|
||||
pbvh_print_mem_size(pbvh);
|
||||
|
|
|
@ -248,6 +248,7 @@ struct PBVH {
|
|||
bool invalid;
|
||||
|
||||
CustomDataLayer *color_layer;
|
||||
CustomDataType color_type;
|
||||
AttributeDomain color_domain;
|
||||
|
||||
bool is_drawing;
|
||||
|
|
|
@ -2720,58 +2720,6 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 301, 3)) {
|
||||
LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) {
|
||||
AttributeRef ref;
|
||||
|
||||
for (int step = 0; step < 2; step++) {
|
||||
bool bad = false;
|
||||
CustomDataLayer *actlayer = NULL;
|
||||
int actidx = step ? me->render_color_index : me->active_color_index;
|
||||
|
||||
if (BKE_id_attribute_ref_from_index(
|
||||
&me->id, actidx, ATTR_DOMAIN_MASK_ALL, CD_MASK_PROP_ALL, &ref)) {
|
||||
if (!ELEM(ref.type, CD_PROP_COLOR, CD_MLOOPCOL) ||
|
||||
!ELEM(ref.domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CORNER)) {
|
||||
bad = true;
|
||||
}
|
||||
else {
|
||||
actlayer = BKE_id_attribute_find(&me->id, ref.name, ref.type, ref.domain);
|
||||
}
|
||||
}
|
||||
|
||||
if (bad) {
|
||||
int vact1, vact2;
|
||||
|
||||
if (step) {
|
||||
vact1 = CustomData_get_render_layer_index(&me->vdata, CD_PROP_COLOR);
|
||||
vact2 = CustomData_get_render_layer_index(&me->ldata, CD_MLOOPCOL);
|
||||
}
|
||||
else {
|
||||
vact1 = CustomData_get_active_layer_index(&me->vdata, CD_PROP_COLOR);
|
||||
vact2 = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPCOL);
|
||||
}
|
||||
|
||||
if (vact1 != -1) {
|
||||
actlayer = me->vdata.layers + vact1;
|
||||
}
|
||||
else if (vact2 != -1) {
|
||||
actlayer = me->ldata.layers + vact2;
|
||||
}
|
||||
}
|
||||
|
||||
if (actlayer) {
|
||||
if (step) {
|
||||
BKE_id_attributes_render_color_set(&me->id, actlayer);
|
||||
}
|
||||
else {
|
||||
BKE_id_attributes_active_color_set(&me->id, actlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 301, 4)) {
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
if (!scene->toolsettings || !scene->toolsettings->sculpt ||
|
||||
|
|
|
@ -76,8 +76,8 @@ void DRW_draw_view(const struct bContext *C);
|
|||
void DRW_draw_region_engine_info(int xoffset, int *yoffset, int line_height);
|
||||
void DRW_make_cdlayer_attr_aliases(struct GPUVertFormat *format,
|
||||
char *base_name,
|
||||
struct CustomData *data,
|
||||
struct CustomDataLayer *cl,
|
||||
const struct CustomData *data,
|
||||
const struct CustomDataLayer *cl,
|
||||
bool is_active_render,
|
||||
bool is_active_layer);
|
||||
|
||||
|
|
|
@ -482,8 +482,8 @@ static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lo
|
|||
|
||||
void DRW_make_cdlayer_attr_aliases(GPUVertFormat *format,
|
||||
char *base_name,
|
||||
CustomData *data,
|
||||
CustomDataLayer *cl,
|
||||
const CustomData *data,
|
||||
const CustomDataLayer *cl,
|
||||
bool is_active_render,
|
||||
bool is_active_layer)
|
||||
{
|
||||
|
|
|
@ -8606,9 +8606,7 @@ static void button_activate_exit(
|
|||
{
|
||||
/* only RNA from this button is used */
|
||||
|
||||
unpoison_ui_but(but);
|
||||
uiBut but_temp = *but;
|
||||
poison_ui_but(but);
|
||||
|
||||
uiSelectContextStore *selctx_data = &data->select_others;
|
||||
for (int i = 0; i < selctx_data->elems_len; i++) {
|
||||
|
|
|
@ -2754,24 +2754,7 @@ void SCULPT_orig_vert_data_init(SculptOrigVertData *data,
|
|||
|
||||
bool SCULPT_vertex_check_origdata(SculptSession *ss, SculptVertRef vertex)
|
||||
{
|
||||
// check if we need to update original data for current stroke
|
||||
MSculptVert *mv = ss->bm ? BKE_PBVH_SCULPTVERT(ss->cd_sculpt_vert, (BMVert *)vertex.i) :
|
||||
ss->mdyntopo_verts + vertex.i;
|
||||
|
||||
if (mv->stroke_id != ss->stroke_id) {
|
||||
mv->stroke_id = ss->stroke_id;
|
||||
|
||||
copy_v3_v3(mv->origco, SCULPT_vertex_co_get(ss, vertex));
|
||||
SCULPT_vertex_normal_get(ss, vertex, mv->origno);
|
||||
|
||||
SCULPT_vertex_color_get(ss, vertex, mv->origcolor);
|
||||
|
||||
mv->origmask = unit_float_to_ushort_clamp(SCULPT_vertex_mask_get(ss, vertex));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return BKE_pbvh_get_origvert(ss->pbvh, vertex, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7806,10 +7789,10 @@ static void sculpt_cache_dyntopo_settings(BrushChannelSet *chset,
|
|||
r_settings->constant_detail = BRUSHSET_GET_FLOAT(chset, dyntopo_constant_detail, input_data);
|
||||
};
|
||||
|
||||
static void sculpt_stroke_update_step(bContext *C,
|
||||
wmOperator *UNUSED(op),
|
||||
struct PaintStroke *stroke,
|
||||
PointerRNA *itemptr)
|
||||
ATTR_NO_OPT static void sculpt_stroke_update_step(bContext *C,
|
||||
wmOperator *UNUSED(op),
|
||||
struct PaintStroke *stroke,
|
||||
PointerRNA *itemptr)
|
||||
|
||||
{
|
||||
|
||||
|
@ -7823,6 +7806,8 @@ static void sculpt_stroke_update_step(bContext *C,
|
|||
BKE_brush_channelset_free(ss->cache->channels_final);
|
||||
}
|
||||
|
||||
BKE_pbvh_update_active_vcol(ss->pbvh, BKE_object_get_original_mesh(ob));
|
||||
|
||||
if (!brush->channels) {
|
||||
// should not happen!
|
||||
printf("had to create brush->channels for brush '%s'!", brush->id.name + 2);
|
||||
|
|
|
@ -493,32 +493,6 @@ void SCULPT_pbvh_clear(Object *ob, bool cache_pbvh)
|
|||
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
void SCULPT_dyntopo_save_origverts(SculptSession *ss)
|
||||
{
|
||||
BMIter iter;
|
||||
BMVert *v;
|
||||
|
||||
if (ss->vcol_type == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
BM_ITER_MESH (v, &iter, ss->bm, BM_VERTS_OF_MESH) {
|
||||
MSculptVert *mv = BKE_PBVH_SCULPTVERT(ss->cd_sculpt_vert, v);
|
||||
|
||||
copy_v3_v3(mv->origco, v->co);
|
||||
copy_v3_v3(mv->origno, v->no);
|
||||
|
||||
if (ss->cd_vert_mask_offset >= 0) {
|
||||
mv->origmask = BM_ELEM_CD_GET_FLOAT(v, ss->cd_vert_mask_offset);
|
||||
}
|
||||
|
||||
if (ss->vcol_type != -1) {
|
||||
BKE_pbvh_bmesh_get_vcol(
|
||||
v, mv->origcolor, ss->vcol_type, ss->vcol_domain, ss->cd_vcol_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern char dyntopop_node_idx_layer_id[];
|
||||
|
||||
void SCULPT_dyntopo_node_layers_update_offsets(SculptSession *ss, Object *ob)
|
||||
|
@ -727,7 +701,7 @@ void SCULPT_dynamic_topology_enable_ex(Main *bmain, Depsgraph *depsgraph, Scene
|
|||
#endif
|
||||
|
||||
SCULPT_dyntopo_node_layers_add(ss, ob);
|
||||
SCULPT_dyntopo_save_origverts(ss);
|
||||
BKE_pbvh_update_sculpt_verts(ss->pbvh);
|
||||
|
||||
if (SCULPT_has_persistent_base(ss)) {
|
||||
SCULPT_ensure_persistent_layers(ss, ob);
|
||||
|
@ -742,16 +716,7 @@ void SCULPT_dynamic_topology_enable_ex(Main *bmain, Depsgraph *depsgraph, Scene
|
|||
e->head.hflag |= BM_ELEM_DRAW;
|
||||
}
|
||||
|
||||
BKE_pbvh_update_sculpt_verts(ss->bm,
|
||||
ss->cd_sculpt_vert,
|
||||
ss->cd_faceset_offset,
|
||||
ss->cd_vert_node_offset,
|
||||
ss->cd_face_node_offset,
|
||||
ss->boundary_symmetry,
|
||||
ss->vcol_type,
|
||||
ss->vcol_domain,
|
||||
ss->cd_vcol_offset,
|
||||
!ss->ignore_uvs);
|
||||
BKE_pbvh_update_sculpt_verts(ss->pbvh);
|
||||
|
||||
/* Make sure the data for existing faces are initialized. */
|
||||
if (me->totpoly != ss->bm->totface) {
|
||||
|
|
|
@ -1572,7 +1572,6 @@ bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *bru
|
|||
|
||||
void SCULPT_dynamic_topology_triangulate(struct SculptSession *ss, struct BMesh *bm);
|
||||
void SCULPT_dyntopo_node_layers_add(struct SculptSession *ss, Object *ob);
|
||||
void SCULPT_dyntopo_save_origverts(struct SculptSession *ss);
|
||||
void SCULPT_dyntopo_node_layers_update_offsets(SculptSession *ss, Object *ob);
|
||||
void SCULPT_dynamic_topology_sync_layers(Object *ob, struct Mesh *me);
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ static void do_color_smooth_task_cb_exec(void *__restrict userdata,
|
|||
BKE_pbvh_vertex_iter_end;
|
||||
}
|
||||
|
||||
static void do_paint_brush_task_cb_ex(void *__restrict userdata,
|
||||
ATTR_NO_OPT static void do_paint_brush_task_cb_ex(void *__restrict userdata,
|
||||
const int n,
|
||||
const TaskParallelTLS *__restrict tls)
|
||||
{
|
||||
|
|
|
@ -353,11 +353,11 @@ static bool sculpt_undo_restore_hidden(bContext *C, SculptUndoNode *unode)
|
|||
return true;
|
||||
}
|
||||
|
||||
static int *sculpt_undo_get_indices32(SculptUndoNode *unode)
|
||||
static int *sculpt_undo_get_indices32(SculptUndoNode *unode, int allvert)
|
||||
{
|
||||
int *indices = MEM_malloc_arrayN(unode->totvert, sizeof(int), __func__);
|
||||
int *indices = MEM_malloc_arrayN(allvert, sizeof(int), __func__);
|
||||
|
||||
for (int i = 0; i < unode->totvert; i++) {
|
||||
for (int i = 0; i < allvert; i++) {
|
||||
indices[i] = (int)unode->index[i].i;
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ static bool sculpt_undo_restore_color(bContext *C, SculptUndoNode *unode)
|
|||
/* NOTE: even with loop colors we still store derived
|
||||
* vertex colors for original data lookup.*/
|
||||
if (unode->col && !unode->loop_col) {
|
||||
int *indices = sculpt_undo_get_indices32(unode);
|
||||
int *indices = sculpt_undo_get_indices32(unode, unode->totvert);
|
||||
|
||||
BKE_pbvh_swap_colors(ss->pbvh, indices, unode->totvert, unode->col);
|
||||
modified = true;
|
||||
|
@ -794,16 +794,7 @@ static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode, bool is_
|
|||
SCULPT_dyntopo_node_layers_add(ss, ob);
|
||||
SCULPT_update_customdata_refs(ss, ob);
|
||||
|
||||
BKE_pbvh_update_sculpt_verts(ss->bm,
|
||||
ss->cd_sculpt_vert,
|
||||
ss->cd_faceset_offset,
|
||||
ss->cd_vert_node_offset,
|
||||
ss->cd_face_node_offset,
|
||||
ss->boundary_symmetry,
|
||||
ss->vcol_type,
|
||||
ss->vcol_domain,
|
||||
ss->cd_vcol_offset,
|
||||
!ss->ignore_uvs);
|
||||
BKE_pbvh_update_sculpt_verts(ss->pbvh);
|
||||
|
||||
if (!ss->bm_log) {
|
||||
/* Restore the BMLog using saved entries. */
|
||||
|
@ -1772,7 +1763,7 @@ static void sculpt_undo_store_mask(Object *ob, SculptUndoNode *unode)
|
|||
BKE_pbvh_vertex_iter_end;
|
||||
}
|
||||
|
||||
static void sculpt_undo_store_color(Object *ob, SculptUndoNode *unode)
|
||||
ATTR_NO_OPT static void sculpt_undo_store_color(Object *ob, SculptUndoNode *unode)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
||||
|
@ -1781,17 +1772,18 @@ static void sculpt_undo_store_color(Object *ob, SculptUndoNode *unode)
|
|||
int allvert;
|
||||
BKE_pbvh_node_num_verts(ss->pbvh, unode->node, NULL, &allvert);
|
||||
|
||||
int *indices = sculpt_undo_get_indices32(unode);
|
||||
int *indices = sculpt_undo_get_indices32(unode, allvert);
|
||||
|
||||
/* NOTE: even with loop colors we still store (derived)
|
||||
* vertex colors for original data lookup. */
|
||||
BKE_pbvh_store_colors_vertex(ss->pbvh, indices, allvert, unode->col);
|
||||
|
||||
MEM_SAFE_FREE(indices);
|
||||
BKE_pbvh_store_colors_vertex(ss->pbvh, indices, allvert, unode->col);
|
||||
|
||||
if (unode->loop_col && unode->totloop) {
|
||||
BKE_pbvh_store_colors(ss->pbvh, unode->loop_index, unode->totloop, unode->loop_col);
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(indices);
|
||||
}
|
||||
|
||||
static SculptUndoNodeGeometry *sculpt_undo_geometry_get(SculptUndoNode *unode)
|
||||
|
@ -2191,7 +2183,11 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
|
|||
int allvert, allloop;
|
||||
|
||||
BKE_pbvh_node_num_verts(ss->pbvh, unode->node, NULL, &allvert);
|
||||
memcpy(unode->index, vert_indices, sizeof(int) * allvert);
|
||||
BKE_pbvh_node_get_verts(ss->pbvh, node, &vert_indices, NULL);
|
||||
|
||||
for (int i = 0; i < allvert; i++) {
|
||||
unode->index[i].i = vert_indices[i];
|
||||
}
|
||||
|
||||
if (unode->loop_index) {
|
||||
BKE_pbvh_node_num_loops(ss->pbvh, unode->node, &allloop);
|
||||
|
@ -2286,7 +2282,8 @@ static void sculpt_save_active_attribute_color(Object *ob, SculptAttrRef *attr)
|
|||
|
||||
attr->was_set = true;
|
||||
}
|
||||
void SCULPT_undo_push_begin_ex(Object *ob, const char *name, bool no_first_entry_check)
|
||||
|
||||
static void sculpt_undo_push_begin_ex(Object *ob, const char *name, bool no_first_entry_check)
|
||||
{
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
|
||||
|
|
|
@ -122,14 +122,15 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
|||
const float (*vert_normals)[3]);
|
||||
|
||||
bool GPU_pbvh_update_attribute_names(
|
||||
CustomData *vdata,
|
||||
CustomData *ldata,
|
||||
const CustomData *vdata,
|
||||
const CustomData *ldata,
|
||||
bool need_full_render,
|
||||
bool fast_mode, // fast mode renders without vcol, uv, facesets, even mask, etc
|
||||
int active_vcol_type,
|
||||
int active_vcol_domain,
|
||||
struct CustomDataLayer *active_vcol_layer,
|
||||
struct CustomDataLayer *render_vcol_layer);
|
||||
const struct CustomDataLayer *active_vcol_layer,
|
||||
const struct CustomDataLayer *render_vcol_layer,
|
||||
bool active_attrs_only);
|
||||
|
||||
/**
|
||||
* Creates a vertex buffer (coordinate, normal, color) and,
|
||||
|
|
|
@ -150,7 +150,7 @@ static int gpu_pbvh_make_attr_offs(AttributeDomainMask domain_mask,
|
|||
|
||||
void gpu_pbvh_init()
|
||||
{
|
||||
GPU_pbvh_update_attribute_names(NULL, NULL, false, false, -1, -1, NULL, NULL);
|
||||
GPU_pbvh_update_attribute_names(NULL, NULL, false, false, -1, -1, NULL, NULL, true);
|
||||
}
|
||||
|
||||
void gpu_pbvh_exit()
|
||||
|
@ -238,22 +238,22 @@ static bool gpu_pbvh_is_looptri_visible(const MLoopTri *lt,
|
|||
sculpt_face_sets[lt->poly] > SCULPT_FACE_SET_NONE);
|
||||
}
|
||||
|
||||
void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
||||
const MVert *mvert,
|
||||
const MLoop *mloop,
|
||||
const MPoly *mpoly,
|
||||
const MLoopTri *looptri,
|
||||
const CustomData *vdata,
|
||||
const CustomData *ldata,
|
||||
const float *vmask,
|
||||
const CustomDataLayer *active_vcol_layer,
|
||||
const CustomDataLayer *render_vcol_layer,
|
||||
const AttributeDomain active_vcol_domain,
|
||||
const int *sculpt_face_sets,
|
||||
const int face_sets_color_seed,
|
||||
const int face_sets_color_default,
|
||||
const int update_flags,
|
||||
const float (*vert_normals)[3])
|
||||
ATTR_NO_OPT void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
||||
const MVert *mvert,
|
||||
const MLoop *mloop,
|
||||
const MPoly *mpoly,
|
||||
const MLoopTri *looptri,
|
||||
const CustomData *vdata,
|
||||
const CustomData *ldata,
|
||||
const float *vmask,
|
||||
const CustomDataLayer *active_vcol_layer,
|
||||
const CustomDataLayer *render_vcol_layer,
|
||||
const AttributeDomain active_vcol_domain,
|
||||
const int *sculpt_face_sets,
|
||||
const int face_sets_color_seed,
|
||||
const int face_sets_color_default,
|
||||
const int update_flags,
|
||||
const float (*vert_normals)[3])
|
||||
{
|
||||
GPUAttrRef vcol_refs[MAX_GPU_ATTR];
|
||||
GPUAttrRef cd_uvs[MAX_GPU_ATTR];
|
||||
|
@ -484,14 +484,14 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
|||
buffers->mvert = mvert;
|
||||
}
|
||||
|
||||
GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const MPoly *mpoly,
|
||||
const MLoop *mloop,
|
||||
const MLoopTri *looptri,
|
||||
const MVert *mvert,
|
||||
const int *face_indices,
|
||||
const int *sculpt_face_sets,
|
||||
const int face_indices_len,
|
||||
const struct Mesh *mesh)
|
||||
ATTR_NO_OPT GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const MPoly *mpoly,
|
||||
const MLoop *mloop,
|
||||
const MLoopTri *looptri,
|
||||
const MVert *mvert,
|
||||
const int *face_indices,
|
||||
const int *sculpt_face_sets,
|
||||
const int face_indices_len,
|
||||
const struct Mesh *mesh)
|
||||
{
|
||||
GPU_PBVH_Buffers *buffers;
|
||||
int i, tottri;
|
||||
|
@ -1271,105 +1271,87 @@ static bool gpu_pbvh_format_equals(PBVHGPUFormat *a, PBVHGPUFormat *b)
|
|||
return !bad;
|
||||
}
|
||||
|
||||
bool GPU_pbvh_update_attribute_names(CustomData *vdata,
|
||||
CustomData *ldata,
|
||||
bool need_full_render,
|
||||
bool fast_mode,
|
||||
int active_vcol_type,
|
||||
int active_vcol_domain,
|
||||
CustomDataLayer *active_vcol_layer,
|
||||
CustomDataLayer *render_vcol_layer)
|
||||
bool GPU_pbvh_update_attribute_names(
|
||||
const CustomData *vdata,
|
||||
const CustomData *ldata,
|
||||
bool need_full_render,
|
||||
bool fast_mode, // fast mode renders without vcol, uv, facesets, even mask, etc
|
||||
int active_vcol_type,
|
||||
int active_vcol_domain,
|
||||
const CustomDataLayer *active_vcol_layer,
|
||||
const CustomDataLayer *render_vcol_layer,
|
||||
bool active_attrs_only)
|
||||
{
|
||||
const bool active_only = !need_full_render;
|
||||
PBVHGPUFormat old_format = g_vbo_id;
|
||||
PBVHGPUFormat *vbo_id = &g_vbo_id;
|
||||
const bool active_only = active_attrs_only;
|
||||
PBVHGPUFormat old_format = *vbo_id;
|
||||
|
||||
debug_pass++;
|
||||
GPU_vertformat_clear(&vbo_id->format);
|
||||
|
||||
GPU_vertformat_clear(&g_vbo_id.format);
|
||||
|
||||
g_vbo_id.fast_mode = fast_mode;
|
||||
|
||||
// g_vbo_id.loop_attrs = build_cd_layers(vdata, )
|
||||
/* Initialize vertex buffer (match 'VertexBufferFormat'). */
|
||||
if (g_vbo_id.format.attr_len == 0) {
|
||||
g_vbo_id.pos = GPU_vertformat_attr_add(
|
||||
&g_vbo_id.format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
g_vbo_id.nor = GPU_vertformat_attr_add(
|
||||
&g_vbo_id.format, "nor", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
if (vbo_id->format.attr_len == 0) {
|
||||
vbo_id->pos = GPU_vertformat_attr_add(
|
||||
&vbo_id->format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
vbo_id->nor = GPU_vertformat_attr_add(
|
||||
&vbo_id->format, "nor", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
/* TODO: Do not allocate these `.msk` and `.col` when they are not used. */
|
||||
vbo_id->msk = GPU_vertformat_attr_add(
|
||||
&vbo_id->format, "msk", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
if (!fast_mode) {
|
||||
g_vbo_id.msk = GPU_vertformat_attr_add(
|
||||
&g_vbo_id.format, "msk", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
}
|
||||
vbo_id->totcol = 0;
|
||||
|
||||
g_vbo_id.totcol = 0;
|
||||
int ci = 0;
|
||||
|
||||
if (active_vcol_type != -1) {
|
||||
int ci = 0;
|
||||
GPUAttrRef vcol_layers[MAX_GPU_ATTR];
|
||||
int totlayer = gpu_pbvh_make_attr_offs(ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER,
|
||||
CD_MASK_PROP_COLOR | CD_MASK_MLOOPCOL,
|
||||
vdata,
|
||||
NULL,
|
||||
ldata,
|
||||
NULL,
|
||||
vcol_layers,
|
||||
active_only,
|
||||
active_vcol_type,
|
||||
active_vcol_domain,
|
||||
active_vcol_layer,
|
||||
render_vcol_layer);
|
||||
|
||||
GPUAttrRef vcol_layers[MAX_GPU_ATTR];
|
||||
int totlayer = gpu_pbvh_make_attr_offs(ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER,
|
||||
CD_MASK_PROP_COLOR | CD_MASK_MLOOPCOL,
|
||||
vdata,
|
||||
NULL,
|
||||
ldata,
|
||||
NULL,
|
||||
vcol_layers,
|
||||
active_only,
|
||||
active_vcol_type,
|
||||
active_vcol_domain,
|
||||
active_vcol_layer,
|
||||
render_vcol_layer);
|
||||
for (int i = 0; i < totlayer; i++) {
|
||||
GPUAttrRef *ref = vcol_layers + i;
|
||||
const CustomData *cdata = ref->domain == ATTR_DOMAIN_POINT ? vdata : ldata;
|
||||
|
||||
for (int i = 0; i < totlayer; i++) {
|
||||
GPUAttrRef *ref = vcol_layers + i;
|
||||
CustomData *cdata = ref->domain == ATTR_DOMAIN_POINT ? vdata : ldata;
|
||||
const CustomDataLayer *cl = cdata->layers + ref->layer_idx;
|
||||
|
||||
CustomDataLayer *cl = cdata->layers + ref->layer_idx;
|
||||
if (vbo_id->totcol < MAX_GPU_ATTR) {
|
||||
vbo_id->col[ci++] = GPU_vertformat_attr_add(
|
||||
&vbo_id->format, "c", GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
vbo_id->totcol++;
|
||||
|
||||
if (g_vbo_id.totcol < MAX_GPU_ATTR) {
|
||||
g_vbo_id.col[ci++] = GPU_vertformat_attr_add(
|
||||
&g_vbo_id.format, "c", GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
g_vbo_id.totcol++;
|
||||
bool is_render = render_vcol_layer == cl;
|
||||
bool is_active = active_vcol_layer == cl;
|
||||
|
||||
bool is_render = render_vcol_layer == cl;
|
||||
bool is_active = active_vcol_layer == cl;
|
||||
|
||||
DRW_make_cdlayer_attr_aliases(&g_vbo_id.format, "c", cdata, cl, is_render, is_active);
|
||||
}
|
||||
DRW_make_cdlayer_attr_aliases(&vbo_id->format, "c", cdata, cl, is_render, is_active);
|
||||
}
|
||||
}
|
||||
|
||||
// ensure at least one vertex color layer
|
||||
if (!fast_mode && g_vbo_id.totcol == 0) {
|
||||
g_vbo_id.col[0] = GPU_vertformat_attr_add(
|
||||
&g_vbo_id.format, "c", GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
g_vbo_id.totcol = 1;
|
||||
/* ensure at least one vertex color layer */
|
||||
if (vbo_id->totcol == 0) {
|
||||
vbo_id->col[0] = GPU_vertformat_attr_add(
|
||||
&vbo_id->format, "c", GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
vbo_id->totcol = 1;
|
||||
|
||||
GPU_vertformat_alias_add(&g_vbo_id.format, "ac");
|
||||
GPU_vertformat_alias_add(&vbo_id->format, "ac");
|
||||
}
|
||||
|
||||
if (!fast_mode) {
|
||||
g_vbo_id.fset = GPU_vertformat_attr_add(
|
||||
&g_vbo_id.format, "fset", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
}
|
||||
vbo_id->fset = GPU_vertformat_attr_add(
|
||||
&vbo_id->format, "fset", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||
|
||||
if (ldata && CustomData_has_layer(ldata, CD_MLOOPUV)) {
|
||||
GPUAttrRef uv_layers[MAX_GPU_ATTR];
|
||||
CustomDataLayer *active = NULL, *render = NULL;
|
||||
int idx;
|
||||
|
||||
idx = CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
|
||||
if (idx != -1) {
|
||||
active = ldata->layers + idx;
|
||||
}
|
||||
|
||||
idx = CustomData_get_render_layer_index(ldata, CD_MLOOPUV);
|
||||
if (idx != -1) {
|
||||
render = ldata->layers + idx;
|
||||
}
|
||||
active = get_active_layer(ldata, CD_MLOOPUV);
|
||||
render = get_render_layer(ldata, CD_MLOOPUV);
|
||||
|
||||
int totlayer = gpu_pbvh_make_attr_offs(ATTR_DOMAIN_MASK_CORNER,
|
||||
CD_MASK_MLOOPUV,
|
||||
|
@ -1384,24 +1366,23 @@ bool GPU_pbvh_update_attribute_names(CustomData *vdata,
|
|||
active,
|
||||
render);
|
||||
|
||||
g_vbo_id.totuv = totlayer;
|
||||
vbo_id->totuv = totlayer;
|
||||
|
||||
for (int i = 0; i < totlayer; i++) {
|
||||
GPUAttrRef *ref = uv_layers + i;
|
||||
|
||||
g_vbo_id.uv[i] = GPU_vertformat_attr_add(
|
||||
&g_vbo_id.format, "uvs", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
vbo_id->uv[i] = GPU_vertformat_attr_add(
|
||||
&vbo_id->format, "uvs", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
|
||||
CustomDataLayer *cl = ldata->layers + ref->layer_idx;
|
||||
bool is_active = ref->layer_idx == CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
|
||||
|
||||
DRW_make_cdlayer_attr_aliases(&g_vbo_id.format, "u", ldata, cl, cl == render, is_active);
|
||||
DRW_make_cdlayer_attr_aliases(&vbo_id->format, "u", ldata, cl, cl == render, is_active);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!gpu_pbvh_format_equals(&old_format, &g_vbo_id)) {
|
||||
printf("gpu format update detected\n");
|
||||
if (!gpu_pbvh_format_equals(&old_format, vbo_id)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue