49 float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2];
55 if (
fabsf(view[0]) < 0.1f) {
56 nonortho[0] = view[0] + 1.0f;
57 nonortho[1] = view[1];
58 nonortho[2] = view[2];
60 else if (
fabsf(view[1]) < 0.1f) {
61 nonortho[0] = view[0];
62 nonortho[1] = view[1] + 1.0f;
63 nonortho[2] = view[2];
66 nonortho[0] = view[0];
67 nonortho[1] = view[1];
68 nonortho[2] = view[2] + 1.0f;
118 const float location[3])
123 float projected_radius;
130 projected_radius = 8;
287 switch (
brush.sculpt_brush_type) {
308 const float3 red = {1.0f, 0.2f, 0.2f};
333 const float true_location[3],
334 const float obmat[4][4],
337 float translation_vertex_cursor[3], location[3];
342 if (translation_vertex_cursor[2] <= 1.0f) {
344 gpuattr, translation_vertex_cursor[0], translation_vertex_cursor[1], size, 10);
350 const float true_location[3],
358 mesh = id_cast<const Mesh *>(ob.
data);
361 float orgLoc[3], location[3];
369 for (
int dim = 0; dim < 3; dim++) {
371 start[dim] = (
bounds.min[dim] - orgLoc[dim] - radius) /
step[dim];
372 end[dim] = (
bounds.max[dim] - orgLoc[dim] + radius) /
step[dim];
375 start[dim] = end[dim] = 0;
379 for (cur[0] = start[0]; cur[0] <= end[0]; cur[0]++) {
380 for (cur[1] = start[1]; cur[1] <= end[1]; cur[1]++) {
381 for (cur[2] = start[2]; cur[2] <= end[2]; cur[2]++) {
382 if (!cur[0] && !cur[1] && !cur[2]) {
387 for (
int dim = 0; dim < 3; dim++) {
388 location[dim] = cur[dim] *
step[dim] + orgLoc[dim];
401 const float true_location[3],
409 float symm_rot_mat[4][4];
411 for (
int i = 0; i <= symm; i++) {
424 for (
char raxis = 0; raxis < 3; raxis++) {
425 for (
int r = 1; r <
mesh->radial_symmetry[raxis]; r++) {
426 float angle = 2 *
M_PI * r /
mesh->radial_symmetry[int(raxis)];
446 const float tip_scale_x = has_cube_tip ? pcontext.
brush->
tip_scale_x : 1.0f;
466 pcontext.
final_radius * alpha * roundness * tip_scale_x),
503 pcontext.
vc.
obact->object_to_world().ptr(),
519 pcontext.
vc.
obact->object_to_world().ptr(),
604 pcontext.
pos, pcontext.
region,
position, active_object.object_to_world().ptr(), 2);
611 switch (
brush.sculpt_brush_type) {
659 switch (
brush.sculpt_brush_type) {
692 float local_mat[4][4];
693 float local_mat_inv[4][4];
700 pcontext.
vc, pcontext.
location, tip_rotation);
711 const float3 z_axis = {0.0f, 0.0f, 1.0f};
724 const float tip_scale_x = has_cube_tip ? pcontext.
brush->
tip_scale_x : 1.0f;
746 pcontext.
radius * alpha * roundness * tip_scale_x),
753 const float line_width,
754 const float3 &outline_col,
782 switch (
brush.sculpt_brush_type) {
786 const float3 white = {1.0f, 1.0f, 1.0f};
792 pcontext.
pos,
brush, zero_v, zero_v, pcontext.
radius, 1.0f, white, 0.25f);
General operations, lookup, etc. for blender objects.
#define PRF_scope(category)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
bool supports_tilt(const Brush &brush)
pbvh::Tree & pbvh_ensure(Depsgraph &depsgraph, Object &object)
pbvh::Tree * pbvh_get(Object &object)
bool supports_symmetry_tiling(PaintMode paint_mode, const Brush &brush)
bool supports_scene_size(PaintMode paint_mode, const Brush &brush)
Span< float3 > vert_positions_eval(const Depsgraph &depsgraph, const Object &object_orig)
void pivot_line_preview_draw(const uint gpuattr, SculptSession &ss)
std::unique_ptr< SculptBoundaryPreview > preview_data_init(const Depsgraph &depsgraph, Object &object, const Brush *brush, const float radius)
void edges_preview_draw(const uint gpuattr, SculptSession &ss, const float outline_col[3], const float outline_alpha)
void multiplane_scrape_preview_draw(uint gpuattr, const Brush &brush, const SculptSession &ss, const float outline_col[3], float outline_alpha)
void plane_falloff_preview_draw(const uint gpuattr, Brush &brush, SculptSession &ss, const float outline_col[3], float outline_alpha)
void simulation_limits_draw(const uint gpuattr, const Brush &brush, const float location[3], const float normal[3], const float rds, const float line_width, const float outline_col[3], const float alpha)
std::unique_ptr< SculptPoseIKChainPreview > preview_ik_chain_init(const Depsgraph &depsgraph, Object &ob, SculptSession &ss, const Brush &brush, const float3 &initial_location, const float radius)
void mesh_cursor_inactive_draw(PaintCursorContext &pcontext)
static void object_space_radius_update(PaintCursorContext &pcontext)
static void screen_space_overlays_draw(const PaintCursorContext &pcontext)
static void geometry_preview_lines_draw(const Depsgraph &depsgraph, const uint gpuattr, const Brush &brush, const Object &object)
void vert_random_access_ensure(Object &object)
bool stroke_is_first_brush_step_of_symmetry_pass(const StrokeCache &cache)
float3 symmetry_flip(const float3 &src, const ePaintSymmetryFlags symm)
static float3 get_active_vertex_position(const PaintCursorContext &pcontext)
ePaintSymmetryFlags mesh_symmetry_xyz_get(const Object &object)
static int brush_radius_project(ViewContext *vc, float radius, const float location[3])
float3 calc_motion_normal_from_angle(const ViewContext &vc, const float3 &tip_location, const float angle)
static void inactive_cursor_draw(PaintCursorContext &pcontext)
void mesh_cursor_active_draw(PaintCursorContext &pcontext)
static void object_space_overlays_draw(const PaintCursorContext &pcontext)
static void pose_brush_segments_draw(const PaintCursorContext &pcontext)
float object_space_radius_get(const ViewContext &vc, const Paint &paint, const Brush &brush, const float3 &location, const float scale_factor)
static void pixel_radius_update(PaintCursorContext &pcontext)
static void point_with_symmetry_draw(const PaintMode paint_mode, const Brush &brush, const uint gpuattr, const ARegion *region, const float true_location[3], const Paint &paint, const Object &ob, const float radius)
std::optional< CursorGeometryInfo > cursor_geometry_info_update(bContext *C, const float2 &mval, const bool use_sampled_normal)
static void tiling_preview_draw(const uint gpuattr, const ARegion *region, const float true_location[3], const Paint &paint, const Object &ob, const float radius)
static void cursor_space_overlays_draw(const PaintCursorContext &pcontext)
void mesh_cursor_update_and_init(PaintCursorContext &pcontext)
static void layer_brush_height_preview_draw(const uint gpuattr, const Brush &brush, const float rds, const float line_width, const float3 &outline_col, const float alpha)
static void pose_brush_origins_draw(const PaintCursorContext &pcontext)
static void main_inactive_cursor_draw(const PaintCursorContext &pcontext)
void calc_brush_local_mat(const float3 &tip_normal, const float3 &motion_normal_local, const float3 &tip_location, const float radius, float local_mat[4][4], float local_mat_inv[4][4])
static void boundary_preview_update(const PaintCursorContext &pcontext)
static void brush_unprojected_size_update(Paint &paint, Brush &brush, const ViewContext &vc, const float location[3])
static void cursor_space_drawing_setup(const PaintCursorContext &pcontext)
static void screen_space_point_draw(const uint gpuattr, const ARegion *region, const float true_location[3], const float obmat[4][4], const int size)
static void boundary_preview_pivot_draw(const PaintCursorContext &pcontext)
void geometry_preview_lines_update(Depsgraph &depsgraph, Object &object, SculptSession &ss, float radius)
Span< float3 > vert_positions_for_grab_active_get(const Depsgraph &depsgraph, const Object &object)
float3 tilt_apply_to_normal(const Object &object, const float4x4 &view_inverse, const float3 &normal, const float2 &tilt, const float tilt_strength)
bool is_symmetry_iteration_valid(const char i, const char symm)
void imm_draw_rounded_box_wire_3d(uint pos, float x, float y, float2 radius, float2 corner_radius, int nsegments)
T distance(const T &a, const T &b)
AxisAngleBase< float, AngleRadianBase< float > > AxisAngle
MatBase< T, NumCol, NumRow > translate(const MatBase< T, NumCol, NumRow > &mat, const VectorT &translation)
MatT from_rotation(const RotationT &rotation)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void wmViewport(const rcti *winrct)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void wmWindowViewport(const wmWindow *win)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
GPUDepthTest GPU_depth_test_get()
float BKE_brush_radius_get(const Paint *paint, const Brush *brush)
@ PAINT_FALLOFF_SHAPE_SPHERE
MINLINE void copy_v3_v3_int(int r[3], const int a[3])
void immBegin(GPUPrimType, uint vertex_len)
MatBase< float, 4, 4 > float4x4
void ED_view3d_global_to_vector(const RegionView3D *rv3d, const float coord[3], float r_out[3])
void GPU_matrix_mul(const float m[4][4])
MINLINE void mul_v3_fl(float r[3], float f)
void GPU_line_width(float width)
@ SCULPT_BRUSH_TYPE_CLOTH
@ SCULPT_BRUSH_TYPE_LAYER
@ SCULPT_BRUSH_TYPE_BOUNDARY
@ SCULPT_BRUSH_TYPE_MULTIPLANE_SCRAPE
float BKE_brush_unprojected_radius_get(const Paint *paint, const Brush *brush)
void BKE_brush_unprojected_size_set(Paint *paint, Brush *brush, float unprojected_size)
void mul_m4_v3(const float M[4][4], float r[3])
VecBase< float, 2 > float2
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
eV3DProjStatus ED_view3d_project_float_global(const ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
void immUniformColor4f(float r, float g, float b, float a)
void unit_m4(float m[4][4])
bool BKE_brush_use_locked_size(const Paint *paint, const Brush *brush)
void ED_view3d_project_v3(const ARegion *region, const float world[3], float r_region_co[3])
void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegments)
void BKE_brush_size_set(Paint *paint, Brush *brush, int size)
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
bool BKE_brush_use_size_pressure(const Brush *brush)
MINLINE float normalize_v3(float n[3])
void immVertex3fv(uint attr_id, const float data[3])
void rotate_m4(float mat[4][4], char axis, float angle)
void GPU_matrix_pop_projection()
bool BKE_brush_has_cube_tip(const Brush *brush, PaintMode paint_mode)
MINLINE float len_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
float paint_calc_object_space_radius(const ViewContext &vc, const float3 ¢er, float pixel_radius)
void BKE_sculptsession_update_for_edit(Depsgraph *depsgraph, Object *ob_orig, bool is_paint_tool)
@ BRUSH_GRAB_ACTIVE_VERTEX
void ED_view3d_draw_setup_view(const wmWindowManager *wm, wmWindow *win, Depsgraph *depsgraph, Scene *scene, ARegion *region, View3D *v3d, const float viewmat[4][4], const float winmat[4][4], const rcti *rect)
VecBase< float, 3 > float3
void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments)
void immUniformColor3fvAlpha(const float rgb[3], float a)
void GPU_matrix_push_projection()
void GPU_depth_test(GPUDepthTest test)
Mesh * BKE_object_get_evaluated_mesh_no_subsurf(const Object *object_eval)
@ BRUSH_CLOTH_SIMULATION_AREA_GLOBAL
@ BRUSH_CLOTH_SIMULATION_AREA_LOCAL
float BKE_brush_alpha_get(const Paint *paint, const Brush *brush)
@ BRUSH_CLOTH_FORCE_FALLOFF_PLANE
@ BRUSH_CLOTH_FORCE_FALLOFF_RADIAL
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
float tilt_strength_factor
eBrushFalloffShape falloff_shape
const c_style_mat & ptr() const
static MatBase identity()
bke::PaintRuntime * runtime
ed::sculpt_paint::StrokeCache * cache
float3 active_vert_position(const Depsgraph &depsgraph, const Object &object) const
std::unique_ptr< SculptBoundaryPreview > boundary_preview
ActiveVert active_vert() const
ed::sculpt_paint::expand::Cache * expand_cache
Array< int > preview_verts
int active_vert_index() const
std::unique_ptr< SculptPoseIKChainPreview > pose_ik_chain_preview
bool deform_modifiers_active
Array< float3 > positions
float size_pressure_value
float3 scene_space_location
int prev_active_vert_index