[Bf-blender-cvs] [8d17efaf7b7] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Pablo Dobarro
noreply at git.blender.org
Sat Jun 22 18:30:22 CEST 2019
Commit: 8d17efaf7b71afa6cee252fa81b9e49016dbc118
Author: Pablo Dobarro
Date: Sat Jun 22 18:30:34 2019 +0200
Branches: sculpt-mode-features
https://developer.blender.org/rB8d17efaf7b71afa6cee252fa81b9e49016dbc118
Merge branch 'master' into sculpt-mode-features
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_pbvh.h
index 2e096991eeb,4779a27853e..01c8091e7b0
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@@ -141,9 -134,8 +142,10 @@@ bool BKE_pbvh_node_raycast(PBVH *bvh
float (*origco)[3],
bool use_origco,
const float ray_start[3],
+ const float ray_normal[3],
- float *depth,
- RaycastOutputData *output_data);
++ RaycastOutputData *output_data,
+ struct IsectRayPrecalc *isect_precalc,
+ float *depth);
bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node,
const float ray_start[3],
diff --cc source/blender/blenkernel/intern/pbvh.c
index b13ba9ddc20,ffc4ec65d4d..540489e38fe
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -1755,9 -1753,8 +1754,10 @@@ static bool pbvh_faces_node_raycast(PBV
const PBVHNode *node,
float (*origco)[3],
const float ray_start[3],
+ const float ray_normal[3],
- float *depth,
- RaycastOutputData *output_data)
++ RaycastOutputData *output_data,
+ struct IsectRayPrecalc *isect_precalc,
+ float *depth)
{
const MVert *vert = bvh->verts;
const MLoop *mloop = bvh->mloop;
@@@ -1818,9 -1797,8 +1818,10 @@@ static bool pbvh_grids_node_raycast(PBV
PBVHNode *node,
float (*origco)[3],
const float ray_start[3],
+ const float ray_normal[3],
- float *depth,
- RaycastOutputData *output_data)
++ RaycastOutputData *output_data,
+ struct IsectRayPrecalc *isect_precalc,
+ float *depth)
{
const int totgrid = node->totprim;
const int gridsize = bvh->gridkey.grid_size;
@@@ -1899,9 -1857,8 +1900,10 @@@ bool BKE_pbvh_node_raycast(PBVH *bvh
float (*origco)[3],
bool use_origco,
const float ray_start[3],
+ const float ray_normal[3],
- float *depth,
- RaycastOutputData *output_data)
++ RaycastOutputData *output_data,
+ struct IsectRayPrecalc *isect_precalc,
+ float *depth)
{
bool hit = false;
@@@ -1911,13 -1868,13 +1913,16 @@@
switch (bvh->type) {
case PBVH_FACES:
- hit |= pbvh_faces_node_raycast(bvh, node, origco, ray_start, ray_normal, depth, output_data);
- hit |= pbvh_faces_node_raycast(bvh, node, origco, ray_start, isect_precalc, depth);
++ hit |= pbvh_faces_node_raycast(
++ bvh, node, origco, ray_start, ray_normal, output_data, isect_precalc, depth);
break;
case PBVH_GRIDS:
- hit |= pbvh_grids_node_raycast(bvh, node, origco, ray_start, ray_normal, depth, output_data);
- hit |= pbvh_grids_node_raycast(bvh, node, origco, ray_start, isect_precalc, depth);
++ hit |= pbvh_grids_node_raycast(
++ bvh, node, origco, ray_start, ray_normal, output_data, isect_precalc, depth);
break;
case PBVH_BMESH:
- hit = pbvh_bmesh_node_raycast(node, ray_start, ray_normal, depth, use_origco, output_data);
- hit = pbvh_bmesh_node_raycast(node, ray_start, isect_precalc, depth, use_origco);
++ hit = pbvh_bmesh_node_raycast(
++ node, ray_start, ray_normal, isect_precalc, depth, use_origco, output_data);
break;
}
diff --cc source/blender/blenkernel/intern/pbvh_bmesh.c
index b1414fe290b,1d8088c6605..e58d95d86b4
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@@ -1508,10 -1508,9 +1508,11 @@@ static bool pbvh_bmesh_collapse_short_e
bool pbvh_bmesh_node_raycast(PBVHNode *node,
const float ray_start[3],
+ const float ray_normal[3],
+ struct IsectRayPrecalc *isect_precalc,
float *depth,
- bool use_original)
+ bool use_original,
+ RaycastOutputData *output_data)
{
bool hit = false;
@@@ -1540,18 -1537,7 +1541,18 @@@
BM_face_as_array_vert_tri(f, v_tri);
hit |= ray_face_intersection_tri(
- ray_start, ray_normal, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, depth);
+ ray_start, isect_precalc, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, depth);
+ if (hit && *depth < min_depth) {
+ min_depth = *depth;
+ normal_tri_v3(output_data->normal, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co);
+ madd_v3_v3v3fl(location, ray_start, ray_normal, *depth);
+ for (int j = 0; j < 3; j++) {
+ if (len_squared_v3v3(location, v_tri[j]->co) <
+ len_squared_v3v3(location, output_data->nearest_vertex_co)) {
+ copy_v3_v3(output_data->nearest_vertex_co, v_tri[j]->co);
+ }
+ }
+ }
}
}
}
diff --cc source/blender/blenkernel/intern/pbvh_intern.h
index 7fe1840b8b5,dc9d796075b..f3dffc40b5e
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@@ -210,10 -208,9 +210,11 @@@ void pbvh_update_BB_redraw(PBVH *bvh, P
/* pbvh_bmesh.c */
bool pbvh_bmesh_node_raycast(PBVHNode *node,
const float ray_start[3],
+ const float ray_normal[3],
+ struct IsectRayPrecalc *isect_precalc,
float *dist,
- bool use_original);
+ bool use_original,
+ RaycastOutputData *output_data);
bool pbvh_bmesh_node_nearest_to_ray(PBVHNode *node,
const float ray_start[3],
const float ray_normal[3],
diff --cc source/blender/editors/sculpt_paint/sculpt.c
index d398f113c81,ec7cb410f2c..56c6c9e6382
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@@ -1956,13 -1730,12 +1956,15 @@@ typedef struct SculptDoBrushSmoothGridD
typedef struct {
SculptSession *ss;
- const float *ray_start, *ray_normal;
+ const float *ray_start;
++ const float *ray_normal;
bool hit;
float depth;
bool original;
-
+ float *normal;
+ float *nearest_vertex_co;
+ RaycastOutputData output;
+ struct IsectRayPrecalc isect_precalc;
} SculptRaycastData;
typedef struct {
@@@ -5906,9 -4953,8 +5910,10 @@@ static void sculpt_raycast_cb(PBVHNode
origco,
use_origco,
srd->ray_start,
+ srd->ray_normal,
- &srd->depth,
- &srd->output)) {
++ &srd->output,
+ &srd->isect_precalc,
+ &srd->depth)) {
srd->hit = 1;
*tmin = srd->depth;
}
@@@ -5996,112 -5042,6 +6001,113 @@@ static float sculpt_raycast_init(ViewCo
return dist;
}
+bool sculpt_stroke_get_geometry_info(bContext *C, StrokeGeometryInfo *out, const float mouse[2])
+{
+ Scene *scene = CTX_data_scene(C);
+ Sculpt *sd = scene->toolsettings->sculpt;
+ Object *ob;
+ SculptSession *ss;
+ float ray_start[3], ray_end[3], ray_normal[3], depth, face_normal[3], sampled_normal[3],
+ viewDir[3], mat[3][3];
+ float nearest_vetex_co[3] = {0.0f};
+ int totnode;
- bool original, hit = false;
++ bool original = false, hit = false;
+ ViewContext vc;
+ const Brush *brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
+
+ ED_view3d_viewcontext_init(C, &vc);
+
+ ob = vc.obact;
+ ss = ob->sculpt;
+
+ if (!ss->pbvh) {
+ copy_v3_fl(out->location, 0.0f);
+ copy_v3_fl(out->normal, 0.0f);
+ copy_v3_fl(out->nearest_vertex_co, 0.0f);
+ return false;
+ }
+
+ depth = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original);
+ sculpt_stroke_modifiers_check(C, ob, brush);
+
+ SculptRaycastData srd = {
+ .original = original,
+ .ss = ob->sculpt,
+ .hit = 0,
+ .ray_start = ray_start,
+ .ray_normal = ray_normal,
+ .depth = depth,
+ .normal = face_normal,
+ .nearest_vertex_co = nearest_vetex_co,
+ };
++ isect_ray_tri_watertight_v3_precalc(&srd.isect_precalc, ray_normal);
+ BKE_pbvh_raycast(ss->pbvh, sculpt_raycast_cb, &srd, ray_start, ray_normal, srd.original);
+
+ copy_v3_v3(srd.nearest_vertex_co, srd.output.nearest_vertex_co);
+ copy_v3_v3(srd.normal, srd.output.normal);
+
+ if (srd.hit) {
+ hit = true;
+
+ ss->active_vertex_mesh = srd.output.active_vertex_mesh;
+ ss->active_vertex_mesh_index = srd.output.active_vertex_mesh_index;
+
+ copy_v3_v3(out->location, ray_normal);
+ mul_v3_fl(out->location, srd.depth);
+ add_v3_v3(out->location, ray_start);
+ copy_v3_v3(out->nearest_vertex_co, srd.nearest_vertex_co);
+
+ if (!out->use_sampled_normal) {
+ copy_v3_v3(out->normal, srd.normal);
+ return hit;
+ }
+ const float radius_scale = 1.0f;
+ float radius;
+
+ invert_m4_m4(ob->imat, ob->obmat);
+ copy_m3_m4(mat, vc.rv3d->viewinv);
+ mul_m3_v3(
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list