forked from bartvdbraak/blender
Code cleanup:
* Separate some common code for sculpt raycasting * Cleanup to radial operator commit
This commit is contained in:
parent
1c22ba1e0e
commit
b701c92588
@ -4309,34 +4309,15 @@ static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin)
|
||||
}
|
||||
}
|
||||
|
||||
/* Do a raycast in the tree to find the 3d brush location
|
||||
* (This allows us to ignore the GL depth buffer)
|
||||
* Returns 0 if the ray doesn't hit the mesh, non-zero otherwise
|
||||
*/
|
||||
bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
|
||||
static float sculpt_raycast_init (ViewContext *vc, const float mouse[2], float ray_start[3], float ray_end[3], float ray_normal[3], bool original)
|
||||
{
|
||||
ViewContext vc;
|
||||
Object *ob;
|
||||
SculptSession *ss;
|
||||
StrokeCache *cache;
|
||||
float ray_start[3], ray_end[3], ray_normal[3], dist;
|
||||
float obimat[4][4];
|
||||
SculptRaycastData srd;
|
||||
bool original;
|
||||
RegionView3D *rv3d;
|
||||
|
||||
view3d_set_viewcontext(C, &vc);
|
||||
|
||||
rv3d = vc.ar->regiondata;
|
||||
ob = vc.obact;
|
||||
ss = ob->sculpt;
|
||||
cache = ss->cache;
|
||||
original = (cache) ? cache->original : 0;
|
||||
|
||||
sculpt_stroke_modifiers_check(C, ob);
|
||||
float dist;
|
||||
Object *ob = vc->obact;
|
||||
RegionView3D *rv3d = vc->ar->regiondata;
|
||||
|
||||
/* TODO: what if the segment is totally clipped? (return == 0) */
|
||||
ED_view3d_win_to_segment(vc.ar, vc.v3d, mouse, ray_start, ray_end, true);
|
||||
ED_view3d_win_to_segment(vc->ar, vc->v3d, mouse, ray_start, ray_end, true);
|
||||
|
||||
invert_m4_m4(obimat, ob->obmat);
|
||||
mul_m4_v3(obimat, ray_start);
|
||||
@ -4346,15 +4327,44 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
|
||||
dist = normalize_v3(ray_normal);
|
||||
|
||||
if (!rv3d->is_persp) {
|
||||
BKE_pbvh_raycast_project_ray_root(ss->pbvh, original, ray_start, ray_end, ray_normal);
|
||||
BKE_pbvh_raycast_project_ray_root(ob->sculpt->pbvh, original, ray_start, ray_end, ray_normal);
|
||||
|
||||
/* recalculate the normal */
|
||||
sub_v3_v3v3(ray_normal, ray_end, ray_start);
|
||||
dist = normalize_v3(ray_normal);
|
||||
}
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
/* Do a raycast in the tree to find the 3d brush location
|
||||
* (This allows us to ignore the GL depth buffer)
|
||||
* Returns 0 if the ray doesn't hit the mesh, non-zero otherwise
|
||||
*/
|
||||
bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
|
||||
{
|
||||
Object *ob;
|
||||
SculptSession *ss;
|
||||
StrokeCache *cache;
|
||||
float ray_start[3], ray_end[3], ray_normal[3], dist;
|
||||
SculptRaycastData srd;
|
||||
bool original;
|
||||
ViewContext vc;
|
||||
|
||||
view3d_set_viewcontext(C, &vc);
|
||||
|
||||
ob = vc.obact;
|
||||
|
||||
ss = ob->sculpt;
|
||||
cache = ss->cache;
|
||||
original = (cache) ? cache->original : 0;
|
||||
|
||||
sculpt_stroke_modifiers_check(C, ob);
|
||||
|
||||
dist = sculpt_raycast_init (&vc, mouse, ray_start, ray_end, ray_normal, original);
|
||||
|
||||
srd.original = original;
|
||||
srd.ss = vc.obact->sculpt;
|
||||
srd.ss = ob->sculpt;
|
||||
srd.hit = 0;
|
||||
srd.ray_start = ray_start;
|
||||
srd.ray_normal = ray_normal;
|
||||
@ -5304,36 +5314,16 @@ static void sample_detail(bContext *C, int ss_co[2])
|
||||
Object *ob;
|
||||
Sculpt *sd;
|
||||
float ray_start[3], ray_end[3], ray_normal[3], dist;
|
||||
float obimat[4][4];
|
||||
SculptDetailRaycastData srd;
|
||||
RegionView3D *rv3d;
|
||||
float mouse[2] = {ss_co[0], ss_co[1]};
|
||||
view3d_set_viewcontext(C, &vc);
|
||||
|
||||
rv3d = vc.ar->regiondata;
|
||||
ob = vc.obact;
|
||||
|
||||
sd = CTX_data_tool_settings(C)->sculpt;
|
||||
ob = vc.obact;
|
||||
|
||||
sculpt_stroke_modifiers_check(C, ob);
|
||||
|
||||
/* TODO: what if the segment is totally clipped? (return == 0) */
|
||||
ED_view3d_win_to_segment(vc.ar, vc.v3d, mouse, ray_start, ray_end, true);
|
||||
|
||||
invert_m4_m4(obimat, ob->obmat);
|
||||
mul_m4_v3(obimat, ray_start);
|
||||
mul_m4_v3(obimat, ray_end);
|
||||
|
||||
sub_v3_v3v3(ray_normal, ray_end, ray_start);
|
||||
dist = normalize_v3(ray_normal);
|
||||
|
||||
if (!rv3d->is_persp) {
|
||||
BKE_pbvh_raycast_project_ray_root(ob->sculpt->pbvh, false, ray_start, ray_end, ray_normal);
|
||||
|
||||
/* recalculate the normal */
|
||||
sub_v3_v3v3(ray_normal, ray_end, ray_start);
|
||||
dist = normalize_v3(ray_normal);
|
||||
}
|
||||
dist = sculpt_raycast_init (&vc, mouse, ray_start, ray_end, ray_normal, false);
|
||||
|
||||
srd.hit = 0;
|
||||
srd.ray_start = ray_start;
|
||||
|
@ -3779,6 +3779,9 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd
|
||||
case PROP_ANGLE:
|
||||
r1 = r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE;
|
||||
alpha = 0.75;
|
||||
rmin = WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE;
|
||||
BLI_snprintf(str, WM_RADIAL_MAX_STR, "%3f", RAD2DEGF(rc->current_value));
|
||||
strdrawlen = BLI_strlen_utf8(str);
|
||||
break;
|
||||
default:
|
||||
tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; /* note, this is a dummy value */
|
||||
@ -3822,14 +3825,8 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd
|
||||
glRotatef(RAD2DEGF(rc->current_value - rc->initial_value), 0, 0, 1);
|
||||
fdrawline((float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f);
|
||||
glPopMatrix();
|
||||
rmin = WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE;
|
||||
BLI_snprintf(str, WM_RADIAL_MAX_STR, "%3f", RAD2DEGF(rc->current_value));
|
||||
strdrawlen = BLI_strlen_utf8(str);
|
||||
}
|
||||
|
||||
/* adjust dpi for rmin here to account for angle */
|
||||
rmin *= U.pixelsize;
|
||||
|
||||
/* draw circles on top */
|
||||
glutil_draw_lined_arc(0.0, (float)(M_PI * 2.0), r1, 40);
|
||||
glutil_draw_lined_arc(0.0, (float)(M_PI * 2.0), r2, 40);
|
||||
|
Loading…
Reference in New Issue
Block a user