Merge branch 'master' into sculpt-dev
This commit is contained in:
commit
ea12ba5441
|
@ -682,6 +682,7 @@ void BVHEmbree::refit(Progress &progress)
|
|||
if (mesh->num_triangles() > 0) {
|
||||
RTCGeometry geom = rtcGetGeometry(scene, geom_id);
|
||||
set_tri_vertex_buffer(geom, mesh, true);
|
||||
rtcSetGeometryUserData(geom, (void *)mesh->optix_prim_offset);
|
||||
rtcCommitGeometry(geom);
|
||||
}
|
||||
}
|
||||
|
@ -690,6 +691,7 @@ void BVHEmbree::refit(Progress &progress)
|
|||
if (hair->num_curves() > 0) {
|
||||
RTCGeometry geom = rtcGetGeometry(scene, geom_id + 1);
|
||||
set_curve_vertex_buffer(geom, hair, true);
|
||||
rtcSetGeometryUserData(geom, (void *)hair->optix_prim_offset);
|
||||
rtcCommitGeometry(geom);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,11 +248,14 @@ class MultiDevice : public Device {
|
|||
void build_bvh(BVH *bvh, Progress &progress, bool refit) override
|
||||
{
|
||||
/* Try to build and share a single acceleration structure, if possible */
|
||||
if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) {
|
||||
if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2 || bvh->params.bvh_layout == BVH_LAYOUT_EMBREE) {
|
||||
devices.back().device->build_bvh(bvh, progress, refit);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX ||
|
||||
bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE);
|
||||
|
||||
BVHMulti *const bvh_multi = static_cast<BVHMulti *>(bvh);
|
||||
bvh_multi->sub_bvhs.resize(devices.size());
|
||||
|
||||
|
|
|
@ -280,6 +280,15 @@ void Geometry::tag_update(Scene *scene, bool rebuild)
|
|||
scene->object_manager->need_update = true;
|
||||
}
|
||||
|
||||
void Geometry::tag_bvh_update(bool rebuild)
|
||||
{
|
||||
tag_modified();
|
||||
|
||||
if (rebuild) {
|
||||
need_update_rebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Geometry Manager */
|
||||
|
||||
GeometryManager::GeometryManager()
|
||||
|
@ -915,7 +924,7 @@ void GeometryManager::device_update_attributes(Device *device,
|
|||
scene->object_manager->device_update_mesh_offsets(device, dscene, scene);
|
||||
}
|
||||
|
||||
void GeometryManager::mesh_calc_offset(Scene *scene)
|
||||
void GeometryManager::mesh_calc_offset(Scene *scene, BVHLayout bvh_layout)
|
||||
{
|
||||
size_t vert_size = 0;
|
||||
size_t tri_size = 0;
|
||||
|
@ -930,6 +939,14 @@ void GeometryManager::mesh_calc_offset(Scene *scene)
|
|||
size_t optix_prim_size = 0;
|
||||
|
||||
foreach (Geometry *geom, scene->geometry) {
|
||||
if (geom->optix_prim_offset != optix_prim_size) {
|
||||
/* Need to rebuild BVH in OptiX, since refit only allows modified mesh data there */
|
||||
const bool has_optix_bvh = bvh_layout == BVH_LAYOUT_OPTIX ||
|
||||
bvh_layout == BVH_LAYOUT_MULTI_OPTIX ||
|
||||
bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE;
|
||||
geom->tag_bvh_update(has_optix_bvh);
|
||||
}
|
||||
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
|
||||
|
@ -1526,7 +1543,9 @@ void GeometryManager::device_update(Device *device,
|
|||
/* Device update. */
|
||||
device_free(device, dscene);
|
||||
|
||||
mesh_calc_offset(scene);
|
||||
const BVHLayout bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout,
|
||||
device->get_bvh_layout_mask());
|
||||
mesh_calc_offset(scene, bvh_layout);
|
||||
if (true_displacement_used) {
|
||||
scoped_callback_timer timer([scene](double time) {
|
||||
if (scene->update_stats) {
|
||||
|
@ -1553,8 +1572,6 @@ void GeometryManager::device_update(Device *device,
|
|||
}
|
||||
|
||||
/* Update displacement. */
|
||||
BVHLayout bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout,
|
||||
device->get_bvh_layout_mask());
|
||||
bool displacement_done = false;
|
||||
size_t num_bvh = 0;
|
||||
|
||||
|
|
|
@ -157,6 +157,8 @@ class Geometry : public Node {
|
|||
|
||||
/* Updates */
|
||||
void tag_update(Scene *scene, bool rebuild);
|
||||
|
||||
void tag_bvh_update(bool rebuild);
|
||||
};
|
||||
|
||||
/* Geometry Manager */
|
||||
|
@ -198,7 +200,7 @@ class GeometryManager {
|
|||
vector<AttributeRequestSet> &object_attributes);
|
||||
|
||||
/* Compute verts/triangles/curves offsets in global arrays. */
|
||||
void mesh_calc_offset(Scene *scene);
|
||||
void mesh_calc_offset(Scene *scene, BVHLayout bvh_layout);
|
||||
|
||||
void device_update_object(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -142,7 +142,10 @@ typedef struct UndoType {
|
|||
|
||||
bool use_context;
|
||||
|
||||
int step_size;
|
||||
/**
|
||||
* The size of the undo struct 'inherited' from #UndoStep for that specific type. Used for
|
||||
* generic allocation in BKE's `undo_system.c`. */
|
||||
size_t step_size;
|
||||
} UndoType;
|
||||
|
||||
/* Expose since we need to perform operations on specific undo types (rarely). */
|
||||
|
|
|
@ -1365,6 +1365,17 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode,
|
|||
TaskParallelSettings settings;
|
||||
BKE_pbvh_parallel_range_settings(&settings, true, totnode);
|
||||
BLI_task_parallel_range(0, totnode, &data, pbvh_update_draw_buffer_cb, &settings);
|
||||
|
||||
for (int i = 0; i < totnode; i++) {
|
||||
PBVHNode *node = nodes[i];
|
||||
|
||||
if (node->flag & PBVH_UpdateDrawBuffers) {
|
||||
/* Flush buffers uses OpenGL, so not in parallel. */
|
||||
GPU_pbvh_buffers_update_flush(node->draw_buffers);
|
||||
}
|
||||
|
||||
node->flag &= ~(PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers);
|
||||
}
|
||||
}
|
||||
|
||||
static int pbvh_flush_bb(PBVH *pbvh, PBVHNode *node, int flag)
|
||||
|
@ -2704,49 +2715,35 @@ void BKE_pbvh_draw_cb(PBVH *pbvh,
|
|||
{
|
||||
PBVHNode **nodes;
|
||||
int totnode;
|
||||
int update_flag = 0;
|
||||
|
||||
const int update_flag = PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers;
|
||||
|
||||
if (!update_only_visible) {
|
||||
/* Update all draw buffers, also those outside the view. */
|
||||
/* Search for nodes that need updates. */
|
||||
if (update_only_visible) {
|
||||
/* Get visible nodes with draw updates. */
|
||||
PBVHDrawSearchData data = {.frustum = update_frustum, .accum_update_flag = 0};
|
||||
BKE_pbvh_search_gather(pbvh, pbvh_draw_search_cb, &data, &nodes, &totnode);
|
||||
update_flag = data.accum_update_flag;
|
||||
}
|
||||
else {
|
||||
/* Get all nodes with draw updates, also those outside the view. */
|
||||
const int search_flag = PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers;
|
||||
BKE_pbvh_search_gather(
|
||||
pbvh, update_search_cb, POINTER_FROM_INT(update_flag), &nodes, &totnode);
|
||||
|
||||
if (totnode) {
|
||||
pbvh_update_draw_buffers(pbvh, nodes, totnode, update_flag);
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(nodes);
|
||||
pbvh, update_search_cb, POINTER_FROM_INT(search_flag), &nodes, &totnode);
|
||||
update_flag = PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers;
|
||||
}
|
||||
|
||||
/* Gather visible nodes. */
|
||||
PBVHDrawSearchData data = {.frustum = update_frustum, .accum_update_flag = 0};
|
||||
BKE_pbvh_search_gather(pbvh, pbvh_draw_search_cb, &data, &nodes, &totnode);
|
||||
|
||||
if (update_only_visible && (data.accum_update_flag & update_flag)) {
|
||||
/* Update draw buffers in visible nodes. */
|
||||
pbvh_update_draw_buffers(pbvh, nodes, totnode, data.accum_update_flag);
|
||||
/* Update draw buffers. */
|
||||
if (totnode != 0 && (update_flag & (PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers))) {
|
||||
pbvh_update_draw_buffers(pbvh, nodes, totnode, update_flag);
|
||||
}
|
||||
|
||||
/* Draw. */
|
||||
for (int a = 0; a < totnode; a++) {
|
||||
PBVHNode *node = nodes[a];
|
||||
|
||||
if (node->flag & PBVH_UpdateDrawBuffers) {
|
||||
/* Flush buffers uses OpenGL, so not in parallel. */
|
||||
GPU_pbvh_buffers_update_flush(node->draw_buffers);
|
||||
}
|
||||
|
||||
node->flag &= ~(PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers);
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(nodes);
|
||||
|
||||
/* Draw visible nodes. */
|
||||
PBVHDrawSearchData draw_data = {.frustum = draw_frustum, .accum_update_flag = 0};
|
||||
BKE_pbvh_search_gather(pbvh, pbvh_draw_search_cb, &draw_data, &nodes, &totnode);
|
||||
|
||||
for (int a = 0; a < totnode; a++) {
|
||||
PBVHNode *node = nodes[a];
|
||||
for (int i = 0; i < totnode; i++) {
|
||||
PBVHNode *node = nodes[i];
|
||||
if (!(node->flag & PBVH_FullyHidden)) {
|
||||
draw_fn(user_data, node->draw_buffers);
|
||||
}
|
||||
|
|
|
@ -1166,7 +1166,6 @@ static bool edbm_connect_vert_pair(BMEditMesh *em, struct Mesh *me, wmOperator *
|
|||
int len = 0;
|
||||
bool check_degenerate = true;
|
||||
|
||||
BMVert **verts;
|
||||
bool checks_succeded = true;
|
||||
|
||||
/* sanity check */
|
||||
|
@ -1174,7 +1173,7 @@ static bool edbm_connect_vert_pair(BMEditMesh *em, struct Mesh *me, wmOperator *
|
|||
return false;
|
||||
}
|
||||
|
||||
verts = MEM_mallocN(sizeof(*verts) * verts_len, __func__);
|
||||
BMVert **verts = MEM_mallocN(sizeof(*verts) * verts_len, __func__);
|
||||
{
|
||||
BMIter iter;
|
||||
BMVert *v;
|
||||
|
@ -2510,9 +2509,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
|
|||
Object *obedit = objects[ob_index];
|
||||
Mesh *me = obedit->data;
|
||||
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
||||
ModifierData *md;
|
||||
bool mirrx = false, mirry = false, mirrz = false;
|
||||
int i;
|
||||
float clip_dist = 0.0f;
|
||||
const bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
|
||||
|
||||
|
@ -2528,7 +2525,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
|
|||
/* if there is a mirror modifier with clipping, flag the verts that
|
||||
* are within tolerance of the plane(s) of reflection
|
||||
*/
|
||||
for (md = obedit->modifiers.first; md; md = md->next) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &obedit->modifiers) {
|
||||
if (md->type == eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) {
|
||||
MirrorModifierData *mmd = (MirrorModifierData *)md;
|
||||
|
||||
|
@ -2548,7 +2545,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < repeat; i++) {
|
||||
for (int i = 0; i < repeat; i++) {
|
||||
if (!EDBM_op_callf(
|
||||
em,
|
||||
op,
|
||||
|
@ -3276,16 +3273,14 @@ static const EnumPropertyItem *merge_type_itemf(bContext *C,
|
|||
PropertyRNA *UNUSED(prop),
|
||||
bool *r_free)
|
||||
{
|
||||
Object *obedit;
|
||||
EnumPropertyItem *item = NULL;
|
||||
int totitem = 0;
|
||||
|
||||
if (!C) { /* needed for docs */
|
||||
return merge_type_items;
|
||||
}
|
||||
|
||||
obedit = CTX_data_edit_object(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
if (obedit && obedit->type == OB_MESH) {
|
||||
EnumPropertyItem *item = NULL;
|
||||
int totitem = 0;
|
||||
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
||||
|
||||
/* Only active object supported:
|
||||
|
@ -4011,10 +4006,9 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
|
|||
BMEdge *be;
|
||||
BMOperator bmop;
|
||||
float isect = 0.0f;
|
||||
int len = 0, isected, i;
|
||||
int isected, i;
|
||||
short numcuts = 1;
|
||||
const short mode = RNA_int_get(op->ptr, "type");
|
||||
BMOpSlot *slot_edge_percents;
|
||||
|
||||
/* allocd vars */
|
||||
float(*screen_vert_coords)[2], (*sco)[2], (*mouse_path)[2];
|
||||
|
@ -4029,7 +4023,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
len = RNA_collection_length(op->ptr, "path");
|
||||
const int len = RNA_collection_length(op->ptr, "path");
|
||||
|
||||
if (len < 2) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Mouse path too short");
|
||||
|
@ -4070,7 +4064,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
/* store percentage of edge cut for KNIFE_EXACT here.*/
|
||||
slot_edge_percents = BMO_slot_get(bmop.slots_in, "edge_percents");
|
||||
BMOpSlot *slot_edge_percents = BMO_slot_get(bmop.slots_in, "edge_percents");
|
||||
BM_ITER_MESH (be, &iter, bm, BM_EDGES_OF_MESH) {
|
||||
bool is_cut = false;
|
||||
if (BM_elem_flag_test(be, BM_ELEM_SELECT)) {
|
||||
|
@ -4168,14 +4162,11 @@ enum {
|
|||
static Base *mesh_separate_tagged(
|
||||
Main *bmain, Scene *scene, ViewLayer *view_layer, Base *base_old, BMesh *bm_old)
|
||||
{
|
||||
Base *base_new;
|
||||
Object *obedit = base_old->object;
|
||||
BMesh *bm_new;
|
||||
|
||||
bm_new = BM_mesh_create(&bm_mesh_allocsize_default,
|
||||
&((struct BMeshCreateParams){
|
||||
.use_toolflags = true,
|
||||
}));
|
||||
BMesh *bm_new = BM_mesh_create(&bm_mesh_allocsize_default,
|
||||
&((struct BMeshCreateParams){
|
||||
.use_toolflags = true,
|
||||
}));
|
||||
BM_mesh_elem_toolflags_ensure(bm_new); /* needed for 'duplicate' bmo */
|
||||
|
||||
CustomData_copy(&bm_old->vdata, &bm_new->vdata, CD_MASK_BMESH.vmask, CD_CALLOC, 0);
|
||||
|
@ -4190,7 +4181,7 @@ static Base *mesh_separate_tagged(
|
|||
|
||||
/* Take into account user preferences for duplicating actions. */
|
||||
const eDupli_ID_Flags dupflag = USER_DUP_MESH | (U.dupflag & USER_DUP_ACT);
|
||||
base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, dupflag);
|
||||
Base *base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, dupflag);
|
||||
|
||||
/* normally would call directly after but in this case delay recalc */
|
||||
/* DAG_relations_tag_update(bmain); */
|
||||
|
@ -4250,7 +4241,6 @@ static Base *mesh_separate_arrays(Main *bmain,
|
|||
};
|
||||
const bool use_custom_normals = (bm_old->lnor_spacearr != NULL);
|
||||
|
||||
Base *base_new;
|
||||
Object *obedit = base_old->object;
|
||||
|
||||
BMesh *bm_new = BM_mesh_create(&bm_new_allocsize, &((struct BMeshCreateParams){0}));
|
||||
|
@ -4265,7 +4255,7 @@ static Base *mesh_separate_arrays(Main *bmain,
|
|||
|
||||
/* Take into account user preferences for duplicating actions. */
|
||||
const eDupli_ID_Flags dupflag = USER_DUP_MESH | (U.dupflag & USER_DUP_ACT);
|
||||
base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, dupflag);
|
||||
Base *base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, dupflag);
|
||||
|
||||
/* normally would call directly after but in this case delay recalc */
|
||||
/* DAG_relations_tag_update(bmain); */
|
||||
|
@ -4320,11 +4310,8 @@ static void mesh_separate_material_assign_mat_nr(Main *bmain, Object *ob, const
|
|||
{
|
||||
ID *obdata = ob->data;
|
||||
|
||||
Material ***matarar;
|
||||
const short *totcolp;
|
||||
|
||||
totcolp = BKE_id_material_len_p(obdata);
|
||||
matarar = BKE_id_material_array_p(obdata);
|
||||
const short *totcolp = BKE_id_material_len_p(obdata);
|
||||
Material ***matarar = BKE_id_material_array_p(obdata);
|
||||
|
||||
if ((totcolp && matarar) == 0) {
|
||||
BLI_assert(0);
|
||||
|
|
|
@ -148,7 +148,6 @@ static void paintcurve_undosys_foreach_ID_ref(UndoStep *us_p,
|
|||
void ED_paintcurve_undosys_type(UndoType *ut)
|
||||
{
|
||||
ut->name = "Paint Curve";
|
||||
/* don't poll for now */
|
||||
ut->poll = paintcurve_undosys_poll;
|
||||
ut->step_encode_init = paintcurve_undosys_step_encode_init;
|
||||
ut->step_encode = paintcurve_undosys_step_encode;
|
||||
|
|
|
@ -1570,6 +1570,7 @@ void ED_sculpt_undo_geometry_end(struct Object *ob)
|
|||
void ED_sculpt_undosys_type(UndoType *ut)
|
||||
{
|
||||
ut->name = "Sculpt";
|
||||
ut->poll = NULL; /* No poll from context for now. */
|
||||
ut->step_encode_init = sculpt_undosys_step_encode_init;
|
||||
ut->step_encode = sculpt_undosys_step_encode;
|
||||
ut->step_decode = sculpt_undosys_step_decode;
|
||||
|
|
Loading…
Reference in New Issue