Merge branch 'blender-v2.90-release'

This commit is contained in:
Pablo Dobarro 2020-07-29 17:22:50 +02:00
commit 03acbc7b71
4 changed files with 51 additions and 20 deletions

View File

@ -717,11 +717,14 @@ BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
/* printf("BVHTree built and saved on cache\n"); */
BVHCache *bvh_cache = *bvh_cache_p;
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
bvhcache_unlock(bvh_cache, lock_started);
in_cache = true;
}
}
if (bvh_cache_p) {
bvhcache_unlock(*bvh_cache_p, lock_started);
}
/* Setup BVHTreeFromMesh */
bvhtree_from_mesh_verts_setup_data(data, tree, in_cache, vert, vert_allocated);
@ -929,11 +932,14 @@ BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
/* Save on cache for later use */
/* printf("BVHTree built and saved on cache\n"); */
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
bvhcache_unlock(bvh_cache, lock_started);
in_cache = true;
}
}
if (bvh_cache_p) {
bvhcache_unlock(*bvh_cache_p, lock_started);
}
/* Setup BVHTreeFromMesh */
bvhtree_from_mesh_edges_setup_data(
data, tree, in_cache, vert, vert_allocated, edge, edge_allocated);
@ -1058,11 +1064,14 @@ BVHTree *bvhtree_from_mesh_faces_ex(BVHTreeFromMesh *data,
/* printf("BVHTree built and saved on cache\n"); */
BVHCache *bvh_cache = *bvh_cache_p;
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
bvhcache_unlock(bvh_cache, lock_started);
in_cache = true;
}
}
if (bvh_cache_p) {
bvhcache_unlock(*bvh_cache_p, lock_started);
}
/* Setup BVHTreeFromMesh */
bvhtree_from_mesh_faces_setup_data(
data, tree, in_cache, vert, vert_allocated, face, face_allocated);
@ -1298,11 +1307,14 @@ BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
if (bvh_cache_p) {
BVHCache *bvh_cache = *bvh_cache_p;
bvhcache_insert(bvh_cache, tree, bvh_cache_type);
bvhcache_unlock(bvh_cache, lock_started);
in_cache = true;
}
}
if (bvh_cache_p) {
bvhcache_unlock(*bvh_cache_p, lock_started);
}
/* Setup BVHTreeFromMesh */
bvhtree_from_mesh_looptri_setup_data(data,
tree,
@ -1428,8 +1440,6 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
mesh->medge, mesh->totedge, mesh->mvert, verts_len, &loose_vert_len);
}
/* TODO: a global mutex lock held during the expensive operation of
* building the BVH tree is really bad for performance. */
tree = bvhtree_from_mesh_verts_ex(data,
mesh->mvert,
verts_len,

View File

@ -126,14 +126,27 @@ void PreviewOperation::determineResolution(unsigned int resolution[2],
unsigned int preferredResolution[2])
{
NodeOperation::determineResolution(resolution, preferredResolution);
int width = resolution[0];
int height = resolution[1];
/* If resolution is 0 there are two possible scenarios:
* - Either node is not connected at all
* - It is connected to input which doesn't have own resolution (i.e. color input).
*
* In the former case we rely on the execution system to not evaluate this node.
*
* For the latter case we use 1 pixel preview, so that it's possible to see preview color in the
* preview. This is how final F12 render will behave (flood-fill final frame with the color).
*
* Having things consistent in terms that node preview is scaled down F12 render is a very
* natural thing to do. */
int width = max_ii(1, resolution[0]);
int height = max_ii(1, resolution[1]);
this->m_divider = 0.0f;
if (width > height) {
this->m_divider = COM_PREVIEW_SIZE / (width - 1);
this->m_divider = (float)COM_PREVIEW_SIZE / (width);
}
else {
this->m_divider = COM_PREVIEW_SIZE / (height - 1);
this->m_divider = (float)COM_PREVIEW_SIZE / (height);
}
width = width * this->m_divider;
height = height * this->m_divider;

View File

@ -5516,7 +5516,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
SculptSearchSphereData data = {
.ss = ss,
.sd = sd,
.radius_squared = square_f(ss->cache->radius * (1.0 + brush->cloth_sim_limit)),
.radius_squared = square_f(ss->cache->initial_radius * (1.0 + brush->cloth_sim_limit)),
.original = false,
.ignore_fully_ineffective = false,
.center = ss->cache->initial_location,
@ -7208,11 +7208,16 @@ static void sculpt_restore_mesh(Sculpt *sd, Object *ob)
SculptSession *ss = ob->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
/* For the cloth brush it makes more sense to not restore the mesh state to keep running the
* simulation from the previous state. */
if (brush->sculpt_tool == SCULPT_TOOL_CLOTH) {
return;
}
/* Restore the mesh before continuing with anchored stroke. */
if ((brush->flag & BRUSH_ANCHORED) ||
((brush->sculpt_tool == SCULPT_TOOL_GRAB ||
brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM ||
brush->sculpt_tool == SCULPT_TOOL_CLOTH) &&
brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM) &&
BKE_brush_use_size_pressure(brush)) ||
(brush->flag & BRUSH_DRAG_DOT)) {

View File

@ -254,8 +254,7 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
/* Gravity */
float gravity[3] = {0.0f};
if (ss->cache->supports_gravity) {
madd_v3_v3fl(
gravity, ss->cache->gravity_direction, -ss->cache->radius * data->sd->gravity_factor);
madd_v3_v3fl(gravity, ss->cache->gravity_direction, -data->sd->gravity_factor);
}
/* Original data for deform brushes. */
@ -279,6 +278,11 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
copy_v3_v3(current_vertex_location, vd.co);
}
/* Apply gravity in the entire simulation area. */
float vertex_gravity[3];
mul_v3_v3fl(vertex_gravity, gravity, sim_factor);
cloth_brush_apply_force_to_vertex(ss, ss->cache->cloth_sim, vertex_gravity, vd.index);
/* When using the plane falloff mode the falloff is not constrained by the brush radius. */
if (sculpt_brush_test_sq_fn(&test, current_vertex_location) || use_falloff_plane) {
@ -356,8 +360,6 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
break;
}
madd_v3_v3fl(force, gravity, fade);
cloth_brush_apply_force_to_vertex(ss, ss->cache->cloth_sim, force, vd.index);
}
}
@ -639,12 +641,13 @@ void SCULPT_do_cloth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
/* In the first brush step of each symmetry pass, build the constraints for the vertices in all
* nodes inside the simulation's limits. */
/* Brush stroke types that restore the mesh on each brush step also need the cloth sim data to be
* created on each step. */
/* Brushes that use anchored strokes and restore the mesh can't rely on symmetry passes and steps
* count as it is always the first step, so the simulation needs to be created when it does not
* exist for this stroke. */
if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) || !ss->cache->cloth_sim) {
/* The simulation structure only needs to be created on the first symmetry pass. */
if (SCULPT_stroke_is_first_brush_step(ss->cache)) {
if (SCULPT_stroke_is_first_brush_step(ss->cache) || !ss->cache->cloth_sim) {
ss->cache->cloth_sim = cloth_brush_simulation_create(
ss, brush->cloth_mass, brush->cloth_damping);
for (int i = 0; i < totverts; i++) {