Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 1,007 Lines • ▼ Show 20 Lines | void ED_sculpt_redraw_planes_get(float planes[4][4], ARegion *ar, Object *ob) | ||||
| } | } | ||||
| } | } | ||||
| /************************ Brush Testing *******************/ | /************************ Brush Testing *******************/ | ||||
| void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test) | void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test) | ||||
| { | { | ||||
| RegionView3D *rv3d = ss->cache ? ss->cache->vc->rv3d : ss->rv3d; | RegionView3D *rv3d = ss->cache ? ss->cache->vc->rv3d : ss->rv3d; | ||||
| View3D *v3d = ss->cache ? ss->cache->vc->v3d : ss->v3d; | |||||
| test->radius_squared = ss->cache ? ss->cache->radius_squared : | test->radius_squared = ss->cache ? ss->cache->radius_squared : | ||||
| ss->cursor_radius * ss->cursor_radius; | ss->cursor_radius * ss->cursor_radius; | ||||
| if (ss->cache) { | if (ss->cache) { | ||||
| copy_v3_v3(test->location, ss->cache->location); | copy_v3_v3(test->location, ss->cache->location); | ||||
| test->mirror_symmetry_pass = ss->cache->mirror_symmetry_pass; | test->mirror_symmetry_pass = ss->cache->mirror_symmetry_pass; | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(test->location, ss->cursor_location); | copy_v3_v3(test->location, ss->cursor_location); | ||||
| test->mirror_symmetry_pass = 0; | test->mirror_symmetry_pass = 0; | ||||
| } | } | ||||
| test->dist = 0.0f; /* just for initialize */ | test->dist = 0.0f; /* just for initialize */ | ||||
| /* Only for 2D projection. */ | /* Only for 2D projection. */ | ||||
| zero_v4(test->plane_view); | zero_v4(test->plane_view); | ||||
| zero_v4(test->plane_tool); | zero_v4(test->plane_tool); | ||||
| test->mirror_symmetry_pass = ss->cache ? ss->cache->mirror_symmetry_pass : 0; | test->mirror_symmetry_pass = ss->cache ? ss->cache->mirror_symmetry_pass : 0; | ||||
| if (rv3d->rflag & RV3D_CLIPPING) { | if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) { | ||||
| test->clip_rv3d = rv3d; | test->clip_rv3d = rv3d; | ||||
| } | } | ||||
| else { | else { | ||||
| test->clip_rv3d = NULL; | test->clip_rv3d = NULL; | ||||
| } | } | ||||
| } | } | ||||
| BLI_INLINE bool sculpt_brush_test_clipping(const SculptBrushTest *test, const float co[3]) | BLI_INLINE bool sculpt_brush_test_clipping(const SculptBrushTest *test, const float co[3]) | ||||
| ▲ Show 20 Lines • Show All 5,846 Lines • ▼ Show 20 Lines | static float sculpt_raycast_init(ViewContext *vc, | ||||
| float ray_end[3], | float ray_end[3], | ||||
| float ray_normal[3], | float ray_normal[3], | ||||
| bool original) | bool original) | ||||
| { | { | ||||
| float obimat[4][4]; | float obimat[4][4]; | ||||
| float dist; | float dist; | ||||
| Object *ob = vc->obact; | Object *ob = vc->obact; | ||||
| RegionView3D *rv3d = vc->ar->regiondata; | RegionView3D *rv3d = vc->ar->regiondata; | ||||
| View3D *v3d = vc->v3d; | |||||
| /* TODO: what if the segment is totally clipped? (return == 0) */ | /* TODO: what if the segment is totally clipped? (return == 0) */ | ||||
| ED_view3d_win_to_segment_clipped( | ED_view3d_win_to_segment_clipped( | ||||
| vc->depsgraph, vc->ar, vc->v3d, mouse, ray_start, ray_end, true); | vc->depsgraph, vc->ar, vc->v3d, mouse, ray_start, ray_end, true); | ||||
| invert_m4_m4(obimat, ob->obmat); | invert_m4_m4(obimat, ob->obmat); | ||||
| mul_m4_v3(obimat, ray_start); | mul_m4_v3(obimat, ray_start); | ||||
| mul_m4_v3(obimat, ray_end); | mul_m4_v3(obimat, ray_end); | ||||
| sub_v3_v3v3(ray_normal, ray_end, ray_start); | sub_v3_v3v3(ray_normal, ray_end, ray_start); | ||||
| dist = normalize_v3(ray_normal); | dist = normalize_v3(ray_normal); | ||||
| if ((rv3d->is_persp == false) && | if ((rv3d->is_persp == false) && | ||||
| /* if the ray is clipped, don't adjust its start/end */ | /* if the ray is clipped, don't adjust its start/end */ | ||||
| ((rv3d->rflag & RV3D_CLIPPING) == 0)) { | RV3D_CLIPPING_ENABLED(v3d, rv3d)) { | ||||
| BKE_pbvh_raycast_project_ray_root(ob->sculpt->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 */ | /* recalculate the normal */ | ||||
| sub_v3_v3v3(ray_normal, ray_end, ray_start); | sub_v3_v3v3(ray_normal, ray_end, ray_start); | ||||
| dist = normalize_v3(ray_normal); | dist = normalize_v3(ray_normal); | ||||
| } | } | ||||
| return dist; | return dist; | ||||
| ▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | bool sculpt_cursor_geometry_info_update(bContext *C, | ||||
| copy_m3_m4(mat, vc.rv3d->viewinv); | copy_m3_m4(mat, vc.rv3d->viewinv); | ||||
| mul_m3_v3(mat, viewDir); | mul_m3_v3(mat, viewDir); | ||||
| copy_m3_m4(mat, ob->imat); | copy_m3_m4(mat, ob->imat); | ||||
| mul_m3_v3(mat, viewDir); | mul_m3_v3(mat, viewDir); | ||||
| normalize_v3_v3(ss->cursor_view_normal, viewDir); | normalize_v3_v3(ss->cursor_view_normal, viewDir); | ||||
| copy_v3_v3(ss->cursor_normal, srd.face_normal); | copy_v3_v3(ss->cursor_normal, srd.face_normal); | ||||
| copy_v3_v3(ss->cursor_location, out->location); | copy_v3_v3(ss->cursor_location, out->location); | ||||
| ss->rv3d = vc.rv3d; | ss->rv3d = vc.rv3d; | ||||
| ss->v3d = vc.v3d; | |||||
| if (!BKE_brush_use_locked_size(scene, brush)) { | if (!BKE_brush_use_locked_size(scene, brush)) { | ||||
| radius = paint_calc_object_space_radius(&vc, out->location, BKE_brush_size_get(scene, brush)); | radius = paint_calc_object_space_radius(&vc, out->location, BKE_brush_size_get(scene, brush)); | ||||
| } | } | ||||
| else { | else { | ||||
| radius = BKE_brush_unprojected_radius_get(scene, brush); | radius = BKE_brush_unprojected_radius_get(scene, brush); | ||||
| } | } | ||||
| ss->cursor_radius = radius; | ss->cursor_radius = radius; | ||||
| ▲ Show 20 Lines • Show All 3,327 Lines • Show Last 20 Lines | |||||