Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-03-25 01:46:30 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-03-25 01:46:30 +0400
commitb701c92588f16b25c773b1d7ba6d71a0122bbb64 (patch)
tree1bd1b38657dfaa227b481fb3c99a0d7482c5633d /source/blender
parent1c22ba1e0e728655462725127f19010387456b3b (diff)
Code cleanup:
* Separate some common code for sculpt raycasting * Cleanup to radial operator commit
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c80
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c9
2 files changed, 38 insertions, 51 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 06a918252c2..5f47de3232d 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4309,52 +4309,62 @@ static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin)
}
}
+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)
+{
+ float obimat[4][4];
+ 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);
+
+ 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, 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])
{
- 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;
+ ViewContext vc;
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);
- /* 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(ss->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);
- }
+ 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;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 8b06a4037cc..50db23303ff 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -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);