2009-01-06 21:23:42 +00:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-05-09 17:14:35 +10:00
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-01-06 21:23:42 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2006 by Nicholas Bishop
|
|
|
|
* All rights reserved.
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup edsculpt
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2009-01-06 21:23:42 +00:00
|
|
|
|
2020-04-03 21:05:20 +02:00
|
|
|
#include "DNA_brush_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_key_types.h"
|
2009-01-06 21:23:42 +00:00
|
|
|
#include "DNA_listBase.h"
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
#include "DNA_meshdata_types.h"
|
2009-01-06 21:23:42 +00:00
|
|
|
#include "DNA_vec_types.h"
|
2010-07-14 14:11:03 +00:00
|
|
|
|
2012-03-14 06:32:43 +00:00
|
|
|
#include "BLI_bitmap.h"
|
2020-03-01 13:59:51 -07:00
|
|
|
#include "BLI_gsqueue.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_threads.h"
|
2017-09-28 01:38:17 +10:00
|
|
|
|
2020-03-01 19:53:40 +01:00
|
|
|
#include "BKE_paint.h"
|
2012-12-15 15:59:25 +00:00
|
|
|
#include "BKE_pbvh.h"
|
2009-01-06 21:23:42 +00:00
|
|
|
|
2020-10-15 19:34:54 +02:00
|
|
|
struct AutomaskingCache;
|
2009-12-09 11:09:56 +00:00
|
|
|
struct KeyBlock;
|
2009-01-06 21:23:42 +00:00
|
|
|
struct Object;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct SculptUndoNode;
|
|
|
|
struct bContext;
|
2009-01-06 21:23:42 +00:00
|
|
|
|
2020-03-01 19:53:40 +01:00
|
|
|
enum ePaintSymmetryFlags;
|
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
bool SCULPT_mode_poll(struct bContext *C);
|
|
|
|
bool SCULPT_mode_poll_view3d(struct bContext *C);
|
2013-07-16 06:49:03 +00:00
|
|
|
/* checks for a brush, not just sculpt mode */
|
2020-03-06 15:24:15 +01:00
|
|
|
bool SCULPT_poll(struct bContext *C);
|
|
|
|
bool SCULPT_poll_view3d(struct bContext *C);
|
2009-09-18 15:48:49 +00:00
|
|
|
|
2020-07-09 17:16:24 +02:00
|
|
|
bool SCULPT_vertex_colors_poll(struct bContext *C);
|
|
|
|
|
2019-09-30 15:56:12 +02:00
|
|
|
/* Updates */
|
|
|
|
|
|
|
|
typedef enum SculptUpdateType {
|
|
|
|
SCULPT_UPDATE_COORDS = 1 << 0,
|
|
|
|
SCULPT_UPDATE_MASK = 1 << 1,
|
2020-03-05 14:53:23 +01:00
|
|
|
SCULPT_UPDATE_VISIBILITY = 1 << 2,
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
SCULPT_UPDATE_COLOR = 1 << 3,
|
2019-09-30 15:56:12 +02:00
|
|
|
} SculptUpdateType;
|
|
|
|
|
2020-04-03 19:42:48 +02:00
|
|
|
void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags);
|
|
|
|
void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags);
|
|
|
|
void SCULPT_flush_stroke_deform(struct Sculpt *sd, Object *ob, bool is_proxy_used);
|
|
|
|
|
2020-10-14 01:54:46 +02:00
|
|
|
/* Should be used after modifying the mask or Face Sets IDs. */
|
|
|
|
void SCULPT_tag_update_overlays(bContext *C);
|
|
|
|
|
2009-01-06 21:23:42 +00:00
|
|
|
/* Stroke */
|
2019-08-30 16:27:31 +02:00
|
|
|
|
|
|
|
typedef struct SculptCursorGeometryInfo {
|
|
|
|
float location[3];
|
|
|
|
float normal[3];
|
|
|
|
float active_vertex_co[3];
|
|
|
|
} SculptCursorGeometryInfo;
|
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
bool SCULPT_stroke_get_location(struct bContext *C, float out[3], const float mouse[2]);
|
|
|
|
bool SCULPT_cursor_geometry_info_update(bContext *C,
|
2019-08-30 16:27:31 +02:00
|
|
|
SculptCursorGeometryInfo *out,
|
|
|
|
const float mouse[2],
|
|
|
|
bool use_sampled_normal);
|
2020-03-06 15:24:15 +01:00
|
|
|
void SCULPT_geometry_preview_lines_update(bContext *C, struct SculptSession *ss, float radius);
|
2020-01-07 16:46:56 +01:00
|
|
|
|
2020-04-03 23:41:54 +02:00
|
|
|
void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush);
|
|
|
|
float SCULPT_raycast_init(struct ViewContext *vc,
|
|
|
|
const float mouse[2],
|
|
|
|
float ray_start[3],
|
|
|
|
float ray_end[3],
|
|
|
|
float ray_normal[3],
|
|
|
|
bool original);
|
|
|
|
|
2020-09-18 19:58:48 +02:00
|
|
|
/* Symmetry */
|
|
|
|
char SCULPT_mesh_symmetry_xyz_get(Object *object);
|
|
|
|
|
2019-09-09 22:23:54 +02:00
|
|
|
/* Sculpt PBVH abstraction API */
|
2020-08-11 02:12:08 +02:00
|
|
|
void SCULPT_vertex_random_access_ensure(struct SculptSession *ss);
|
2020-03-01 19:53:40 +01:00
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
int SCULPT_vertex_count_get(struct SculptSession *ss);
|
|
|
|
const float *SCULPT_vertex_co_get(struct SculptSession *ss, int index);
|
2020-04-03 21:46:08 +02:00
|
|
|
void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3]);
|
2020-03-06 15:24:15 +01:00
|
|
|
float SCULPT_vertex_mask_get(struct SculptSession *ss, int index);
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
const float *SCULPT_vertex_color_get(SculptSession *ss, int index);
|
2020-02-28 14:40:40 +01:00
|
|
|
|
2020-07-30 01:36:12 +02:00
|
|
|
const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, int index);
|
|
|
|
void SCULPT_vertex_persistent_normal_get(SculptSession *ss, int index, float no[3]);
|
|
|
|
|
2020-09-07 17:24:52 +02:00
|
|
|
/* Coordinates used for manipulating the base mesh when Grab Active Vertex is enabled. */
|
|
|
|
const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, int index);
|
|
|
|
|
2020-08-17 12:34:05 +10:00
|
|
|
/* Returns the info of the limit surface when Multires is available, otherwise it returns the
|
2020-08-12 16:57:36 +02:00
|
|
|
* current coordinate of the vertex. */
|
|
|
|
void SCULPT_vertex_limit_surface_get(SculptSession *ss, int index, float r_co[3]);
|
|
|
|
|
2020-08-18 15:11:51 +02:00
|
|
|
/* Returns the pointer to the coordinates that should be edited from a brush tool iterator
|
|
|
|
* depending on the given deformation target. */
|
|
|
|
float *SCULPT_brush_deform_target_vertex_co_get(SculptSession *ss,
|
|
|
|
const int deform_target,
|
|
|
|
PBVHVertexIter *iter);
|
|
|
|
|
2020-02-28 14:40:40 +01:00
|
|
|
#define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY 256
|
|
|
|
typedef struct SculptVertexNeighborIter {
|
|
|
|
/* Storage */
|
|
|
|
int *neighbors;
|
|
|
|
int size;
|
|
|
|
int capacity;
|
|
|
|
int neighbors_fixed[SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY];
|
|
|
|
|
|
|
|
/* Internal iterator. */
|
|
|
|
int num_duplicates;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Public */
|
|
|
|
int index;
|
|
|
|
bool is_duplicate;
|
|
|
|
} SculptVertexNeighborIter;
|
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
void SCULPT_vertex_neighbors_get(struct SculptSession *ss,
|
2020-02-28 14:40:40 +01:00
|
|
|
const int index,
|
|
|
|
const bool include_duplicates,
|
|
|
|
SculptVertexNeighborIter *iter);
|
|
|
|
|
|
|
|
/* Iterator over neighboring vertices. */
|
2020-03-27 10:52:14 +11:00
|
|
|
#define SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN(ss, v_index, neighbor_iterator) \
|
2020-03-06 15:24:15 +01:00
|
|
|
SCULPT_vertex_neighbors_get(ss, v_index, false, &neighbor_iterator); \
|
2020-02-28 14:40:40 +01:00
|
|
|
for (neighbor_iterator.i = 0; neighbor_iterator.i < neighbor_iterator.size; \
|
|
|
|
neighbor_iterator.i++) { \
|
2020-05-18 15:35:14 +02:00
|
|
|
neighbor_iterator.index = neighbor_iterator.neighbors[neighbor_iterator.i];
|
2020-02-28 14:40:40 +01:00
|
|
|
|
|
|
|
/* Iterate over neighboring and duplicate vertices (for PBVH_GRIDS). Duplicates come
|
|
|
|
* first since they are nearest for floodfill. */
|
2020-03-27 10:52:14 +11:00
|
|
|
#define SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN(ss, v_index, neighbor_iterator) \
|
2020-03-06 15:52:36 +01:00
|
|
|
SCULPT_vertex_neighbors_get(ss, v_index, true, &neighbor_iterator); \
|
2020-02-28 14:40:40 +01:00
|
|
|
for (neighbor_iterator.i = neighbor_iterator.size - 1; neighbor_iterator.i >= 0; \
|
|
|
|
neighbor_iterator.i--) { \
|
2020-05-18 15:35:14 +02:00
|
|
|
neighbor_iterator.index = neighbor_iterator.neighbors[neighbor_iterator.i]; \
|
|
|
|
neighbor_iterator.is_duplicate = (neighbor_iterator.i >= \
|
2020-02-28 14:40:40 +01:00
|
|
|
neighbor_iterator.size - neighbor_iterator.num_duplicates);
|
|
|
|
|
2020-03-27 10:52:14 +11:00
|
|
|
#define SCULPT_VERTEX_NEIGHBORS_ITER_END(neighbor_iterator) \
|
2020-02-28 14:40:40 +01:00
|
|
|
} \
|
|
|
|
if (neighbor_iterator.neighbors != neighbor_iterator.neighbors_fixed) { \
|
|
|
|
MEM_freeN(neighbor_iterator.neighbors); \
|
|
|
|
} \
|
|
|
|
((void)0)
|
2009-01-06 21:23:42 +00:00
|
|
|
|
2020-03-27 18:14:14 +01:00
|
|
|
int SCULPT_active_vertex_get(SculptSession *ss);
|
|
|
|
const float *SCULPT_active_vertex_co_get(SculptSession *ss);
|
2020-04-03 21:46:08 +02:00
|
|
|
void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]);
|
2020-03-27 18:14:14 +01:00
|
|
|
|
2020-11-04 23:39:36 +01:00
|
|
|
/* Returns PBVH deformed vertices array if shape keys or deform modifiers are used, otherwise
|
|
|
|
* returns mesh original vertices array. */
|
|
|
|
struct MVert *SCULPT_mesh_deformed_mverts_get(SculptSession *ss);
|
|
|
|
|
2020-06-23 16:10:47 +02:00
|
|
|
/* Fake Neighbors */
|
|
|
|
|
|
|
|
#define FAKE_NEIGHBOR_NONE -1
|
|
|
|
|
|
|
|
void SCULPT_fake_neighbors_ensure(struct Sculpt *sd, Object *ob, const float max_dist);
|
|
|
|
void SCULPT_fake_neighbors_enable(Object *ob);
|
|
|
|
void SCULPT_fake_neighbors_disable(Object *ob);
|
|
|
|
void SCULPT_fake_neighbors_free(struct Object *ob);
|
|
|
|
|
Fix T78747: Fix mesh boundary detection and automasking
This issue was produced by a hack in the sculpt mode code from 2.80
when the sculpt API for connectivity info was not available.
The smooth brush was the only brush that needed connectivity info,
so there were 3 different smooth functions with the connectivity
queries implemented for dyntopo, meshes and grids. The mesh version
of smoothing was checking the number of connected faces to a vertex
to mask the mesh boundaries, which was not covering all cases and
was hardcoded in the smooth function itself.
This patch removes all those legacy functions and unifies all
smooth functions into a single one using the new API and the
automasking system. In order to achieve this, there were needed
some extra changes:
- The smooth brush now does not automasks the boundaries by default,
so its default preset needs to be updated to enable automasking
- The mesh boundary info is extracted once and cached in a
bitmap, similar to the disconnected elements IDs. This makes
boundary detection work as expected in all cases, solving a lot
of known issues with the smooth brush. In multires, this info is
extracted and cached only at the base mesh level, so it is much
more memory efficient than the previous automasking system.
- In order to keep the brushes responsive as they were before,
the automasking system can now skip creating the cache when it
is not needed for the requested options. This means that for
high poly meshes and simple automasking options the brushes
won't lag on start.
Reviewed By: sergey
Maniphest Tasks: T78747
Differential Revision: https://developer.blender.org/D8260
2020-07-15 16:24:03 +02:00
|
|
|
/* Vertex Info. */
|
|
|
|
void SCULPT_boundary_info_ensure(Object *object);
|
|
|
|
/* Boundary Info needs to be initialized in order to use this function. */
|
|
|
|
bool SCULPT_vertex_is_boundary(const SculptSession *ss, const int index);
|
|
|
|
|
Sculpt: Expand Operator
Expand is a new operator for Sculpt Mode which is intended to be the main
tool for masking, Face Set editing, interacting with the filters and pattern
creation.
The fundamentals of the tool are similar to the previous sculpt.mask_expand
operator. It shares the same default shortcuts and functionality, making
the previous operator obsolete.
The shortcuts to execute the operator are:
- Shift + A: Expand mask
- Shift + Alt + A: Expand mask by normals
- Shift + W: Expand Face Set
- Shift + Alt + W: Resize current Face Set
The main changes compared to the previous sculpt.mask_expand operator are:
- Modal keymap, all operator options can be changed in real time while the
operator is running.
- Supports creating Mask, Face Sets and Sculpt Vertex Colors.
- Much better code, new features can be easily integrated.
Limitations:
- All Mask operations are supported for Sculpt Vertex colors, but not exposed
by default as their support is still experimental.
- Dyntopo does not support any Face Set or Sculpt Vertex Colors. functionality
(they are not implemented in general for Dyntopo).
- Multires does not support any feature related to geodesic distances.
- Multires does not support vertex colors.
- Multires does not support recursions.
- In Multires, Face Sets snaping does not initialize all current enabled Face
Sets when toggling snapping.
- In Multires, Face Sets are created at base mesh level (works by this by
design, like any other tool).
- Unlike the previous mask_expand operator, this one does not blur the mask
by default after finishing Expand as that does not fit the new design.
The mask can still be blurred by using the mask filter manually.
Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D10455
2021-03-01 23:37:48 +01:00
|
|
|
void SCULPT_connected_components_ensure(Object *ob);
|
|
|
|
|
2020-04-03 19:16:49 +02:00
|
|
|
/* Sculpt Visibility API */
|
|
|
|
|
|
|
|
void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible);
|
|
|
|
bool SCULPT_vertex_visible_get(SculptSession *ss, int index);
|
|
|
|
|
2020-10-12 00:46:50 +02:00
|
|
|
void SCULPT_visibility_sync_all_face_sets_to_vertices(struct Object *ob);
|
2020-04-03 19:16:49 +02:00
|
|
|
void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss);
|
|
|
|
|
|
|
|
/* Face Sets API */
|
|
|
|
|
|
|
|
int SCULPT_active_face_set_get(SculptSession *ss);
|
|
|
|
int SCULPT_vertex_face_set_get(SculptSession *ss, int index);
|
|
|
|
void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_set);
|
|
|
|
|
|
|
|
bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set);
|
|
|
|
bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index);
|
|
|
|
|
|
|
|
int SCULPT_face_set_next_available_get(SculptSession *ss);
|
|
|
|
|
|
|
|
void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible);
|
Fix T78747: Fix mesh boundary detection and automasking
This issue was produced by a hack in the sculpt mode code from 2.80
when the sculpt API for connectivity info was not available.
The smooth brush was the only brush that needed connectivity info,
so there were 3 different smooth functions with the connectivity
queries implemented for dyntopo, meshes and grids. The mesh version
of smoothing was checking the number of connected faces to a vertex
to mask the mesh boundaries, which was not covering all cases and
was hardcoded in the smooth function itself.
This patch removes all those legacy functions and unifies all
smooth functions into a single one using the new API and the
automasking system. In order to achieve this, there were needed
some extra changes:
- The smooth brush now does not automasks the boundaries by default,
so its default preset needs to be updated to enable automasking
- The mesh boundary info is extracted once and cached in a
bitmap, similar to the disconnected elements IDs. This makes
boundary detection work as expected in all cases, solving a lot
of known issues with the smooth brush. In multires, this info is
extracted and cached only at the base mesh level, so it is much
more memory efficient than the previous automasking system.
- In order to keep the brushes responsive as they were before,
the automasking system can now skip creating the cache when it
is not needed for the requested options. This means that for
high poly meshes and simple automasking options the brushes
won't lag on start.
Reviewed By: sergey
Maniphest Tasks: T78747
Differential Revision: https://developer.blender.org/D8260
2020-07-15 16:24:03 +02:00
|
|
|
bool SCULPT_vertex_all_face_sets_visible_get(const SculptSession *ss, int index);
|
2020-04-03 19:16:49 +02:00
|
|
|
bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index);
|
|
|
|
|
|
|
|
void SCULPT_face_sets_visibility_invert(SculptSession *ss);
|
|
|
|
void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible);
|
|
|
|
|
2020-06-30 21:53:48 +02:00
|
|
|
bool SCULPT_stroke_is_main_symmetry_pass(struct StrokeCache *cache);
|
|
|
|
bool SCULPT_stroke_is_first_brush_step(struct StrokeCache *cache);
|
|
|
|
bool SCULPT_stroke_is_first_brush_step_of_symmetry_pass(struct StrokeCache *cache);
|
|
|
|
|
2020-03-01 19:53:40 +01:00
|
|
|
/* Sculpt Original Data */
|
|
|
|
typedef struct {
|
|
|
|
struct BMLog *bm_log;
|
|
|
|
|
|
|
|
struct SculptUndoNode *unode;
|
|
|
|
float (*coords)[3];
|
|
|
|
short (*normals)[3];
|
|
|
|
const float *vmasks;
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
float (*colors)[4];
|
2020-03-01 19:53:40 +01:00
|
|
|
|
|
|
|
/* Original coordinate, normal, and mask. */
|
|
|
|
const float *co;
|
|
|
|
const short *no;
|
|
|
|
float mask;
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
const float *col;
|
2020-03-01 19:53:40 +01:00
|
|
|
} SculptOrigVertData;
|
|
|
|
|
|
|
|
void SCULPT_orig_vert_data_init(SculptOrigVertData *data, Object *ob, PBVHNode *node);
|
|
|
|
void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertexIter *iter);
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
void SCULPT_orig_vert_data_unode_init(SculptOrigVertData *data,
|
|
|
|
Object *ob,
|
|
|
|
struct SculptUndoNode *unode);
|
2020-03-01 19:53:40 +01:00
|
|
|
|
2020-02-28 14:40:40 +01:00
|
|
|
/* Utils. */
|
|
|
|
void SCULPT_calc_brush_plane(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct PBVHNode **nodes,
|
|
|
|
int totnode,
|
|
|
|
float r_area_no[3],
|
|
|
|
float r_area_co[3]);
|
2020-03-06 16:00:33 +01:00
|
|
|
|
|
|
|
void SCULPT_calc_area_normal(
|
|
|
|
Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float r_area_no[3]);
|
|
|
|
|
2020-03-01 19:53:40 +01:00
|
|
|
int SCULPT_nearest_vertex_get(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
const float co[3],
|
|
|
|
float max_distance,
|
|
|
|
bool use_original);
|
|
|
|
|
2020-03-06 16:00:33 +01:00
|
|
|
int SCULPT_plane_point_side(const float co[3], const float plane[4]);
|
|
|
|
int SCULPT_plane_trim(const struct StrokeCache *cache,
|
|
|
|
const struct Brush *brush,
|
|
|
|
const float val[3]);
|
2020-04-03 21:05:20 +02:00
|
|
|
void SCULPT_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3]);
|
2020-03-06 16:00:33 +01:00
|
|
|
|
|
|
|
float SCULPT_brush_plane_offset_get(Sculpt *sd, SculptSession *ss);
|
|
|
|
|
2020-03-01 19:53:40 +01:00
|
|
|
ePaintSymmetryAreas SCULPT_get_vertex_symm_area(const float co[3]);
|
|
|
|
bool SCULPT_check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm);
|
2020-04-03 21:05:20 +02:00
|
|
|
bool SCULPT_is_vertex_inside_brush_radius_symm(const float vertex[3],
|
|
|
|
const float br_co[3],
|
|
|
|
float radius,
|
|
|
|
char symm);
|
2020-03-01 19:53:40 +01:00
|
|
|
bool SCULPT_is_symmetry_iteration_valid(char i, char symm);
|
|
|
|
void SCULPT_flip_v3_by_symm_area(float v[3],
|
|
|
|
const ePaintSymmetryFlags symm,
|
|
|
|
const ePaintSymmetryAreas symmarea,
|
|
|
|
const float pivot[3]);
|
|
|
|
void SCULPT_flip_quat_by_symm_area(float quat[3],
|
|
|
|
const ePaintSymmetryFlags symm,
|
|
|
|
const ePaintSymmetryAreas symmarea,
|
|
|
|
const float pivot[3]);
|
|
|
|
|
|
|
|
/* Flood Fill. */
|
|
|
|
typedef struct {
|
2020-03-01 13:59:51 -07:00
|
|
|
GSQueue *queue;
|
2020-05-27 17:42:06 +02:00
|
|
|
BLI_bitmap *visited_vertices;
|
2020-03-01 19:53:40 +01:00
|
|
|
} SculptFloodFill;
|
|
|
|
|
|
|
|
void SCULPT_floodfill_init(struct SculptSession *ss, SculptFloodFill *flood);
|
|
|
|
void SCULPT_floodfill_add_active(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct SculptSession *ss,
|
|
|
|
SculptFloodFill *flood,
|
|
|
|
float radius);
|
2020-03-27 18:14:14 +01:00
|
|
|
void SCULPT_floodfill_add_initial_with_symmetry(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct SculptSession *ss,
|
|
|
|
SculptFloodFill *flood,
|
|
|
|
int index,
|
|
|
|
float radius);
|
2020-04-03 21:05:20 +02:00
|
|
|
void SCULPT_floodfill_add_initial(SculptFloodFill *flood, int index);
|
Sculpt: Expand Operator
Expand is a new operator for Sculpt Mode which is intended to be the main
tool for masking, Face Set editing, interacting with the filters and pattern
creation.
The fundamentals of the tool are similar to the previous sculpt.mask_expand
operator. It shares the same default shortcuts and functionality, making
the previous operator obsolete.
The shortcuts to execute the operator are:
- Shift + A: Expand mask
- Shift + Alt + A: Expand mask by normals
- Shift + W: Expand Face Set
- Shift + Alt + W: Resize current Face Set
The main changes compared to the previous sculpt.mask_expand operator are:
- Modal keymap, all operator options can be changed in real time while the
operator is running.
- Supports creating Mask, Face Sets and Sculpt Vertex Colors.
- Much better code, new features can be easily integrated.
Limitations:
- All Mask operations are supported for Sculpt Vertex colors, but not exposed
by default as their support is still experimental.
- Dyntopo does not support any Face Set or Sculpt Vertex Colors. functionality
(they are not implemented in general for Dyntopo).
- Multires does not support any feature related to geodesic distances.
- Multires does not support vertex colors.
- Multires does not support recursions.
- In Multires, Face Sets snaping does not initialize all current enabled Face
Sets when toggling snapping.
- In Multires, Face Sets are created at base mesh level (works by this by
design, like any other tool).
- Unlike the previous mask_expand operator, this one does not blur the mask
by default after finishing Expand as that does not fit the new design.
The mask can still be blurred by using the mask filter manually.
Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D10455
2021-03-01 23:37:48 +01:00
|
|
|
void SCULPT_floodfill_add_and_skip_initial(SculptFloodFill *flood, int index);
|
2020-03-01 19:53:40 +01:00
|
|
|
void SCULPT_floodfill_execute(
|
|
|
|
struct SculptSession *ss,
|
|
|
|
SculptFloodFill *flood,
|
|
|
|
bool (*func)(SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata),
|
|
|
|
void *userdata);
|
|
|
|
void SCULPT_floodfill_free(SculptFloodFill *flood);
|
2020-02-28 14:40:40 +01:00
|
|
|
|
2020-04-03 19:42:48 +02:00
|
|
|
/* Dynamic topology */
|
2020-04-03 23:41:54 +02:00
|
|
|
|
|
|
|
enum eDynTopoWarnFlag {
|
|
|
|
DYNTOPO_WARN_VDATA = (1 << 0),
|
|
|
|
DYNTOPO_WARN_EDATA = (1 << 1),
|
|
|
|
DYNTOPO_WARN_LDATA = (1 << 2),
|
|
|
|
DYNTOPO_WARN_MODIFIER = (1 << 3),
|
|
|
|
};
|
|
|
|
|
|
|
|
void SCULPT_dynamic_topology_enable_ex(struct Main *bmain,
|
|
|
|
struct Depsgraph *depsgraph,
|
|
|
|
Scene *scene,
|
|
|
|
Object *ob);
|
|
|
|
void SCULPT_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode);
|
|
|
|
void sculpt_dynamic_topology_disable_with_undo(struct Main *bmain,
|
|
|
|
struct Depsgraph *depsgraph,
|
|
|
|
Scene *scene,
|
|
|
|
Object *ob);
|
|
|
|
|
2020-04-03 21:05:20 +02:00
|
|
|
bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush);
|
2020-04-03 19:42:48 +02:00
|
|
|
|
2020-04-03 23:41:54 +02:00
|
|
|
void SCULPT_dynamic_topology_triangulate(struct BMesh *bm);
|
|
|
|
void SCULPT_dyntopo_node_layers_add(struct SculptSession *ss);
|
|
|
|
|
|
|
|
enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob);
|
|
|
|
|
|
|
|
void SCULPT_pbvh_clear(Object *ob);
|
|
|
|
|
2020-10-16 11:46:48 +11:00
|
|
|
/* Auto-masking. */
|
2020-10-15 19:34:54 +02:00
|
|
|
float SCULPT_automasking_factor_get(struct AutomaskingCache *automasking,
|
|
|
|
SculptSession *ss,
|
|
|
|
int vert);
|
2020-03-09 19:04:37 +01:00
|
|
|
|
2020-10-15 19:34:54 +02:00
|
|
|
/* Returns the automasking cache depending on the active tool. Used for code that can run both for
|
|
|
|
* brushes and filter. */
|
|
|
|
struct AutomaskingCache *SCULPT_automasking_active_cache_get(SculptSession *ss);
|
|
|
|
|
|
|
|
struct AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object *ob);
|
|
|
|
void SCULPT_automasking_cache_free(struct AutomaskingCache *automasking);
|
2020-04-03 21:05:20 +02:00
|
|
|
|
|
|
|
bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd,
|
|
|
|
const Brush *br,
|
|
|
|
const eAutomasking_flag mode);
|
|
|
|
bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br);
|
|
|
|
|
|
|
|
typedef enum eBoundaryAutomaskMode {
|
|
|
|
AUTOMASK_INIT_BOUNDARY_EDGES = 1,
|
|
|
|
AUTOMASK_INIT_BOUNDARY_FACE_SETS = 2,
|
|
|
|
} eBoundaryAutomaskMode;
|
|
|
|
float *SCULPT_boundary_automasking_init(Object *ob,
|
|
|
|
eBoundaryAutomaskMode mode,
|
|
|
|
int propagation_steps,
|
|
|
|
float *automask_factor);
|
|
|
|
|
Sculpt: Expand Operator
Expand is a new operator for Sculpt Mode which is intended to be the main
tool for masking, Face Set editing, interacting with the filters and pattern
creation.
The fundamentals of the tool are similar to the previous sculpt.mask_expand
operator. It shares the same default shortcuts and functionality, making
the previous operator obsolete.
The shortcuts to execute the operator are:
- Shift + A: Expand mask
- Shift + Alt + A: Expand mask by normals
- Shift + W: Expand Face Set
- Shift + Alt + W: Resize current Face Set
The main changes compared to the previous sculpt.mask_expand operator are:
- Modal keymap, all operator options can be changed in real time while the
operator is running.
- Supports creating Mask, Face Sets and Sculpt Vertex Colors.
- Much better code, new features can be easily integrated.
Limitations:
- All Mask operations are supported for Sculpt Vertex colors, but not exposed
by default as their support is still experimental.
- Dyntopo does not support any Face Set or Sculpt Vertex Colors. functionality
(they are not implemented in general for Dyntopo).
- Multires does not support any feature related to geodesic distances.
- Multires does not support vertex colors.
- Multires does not support recursions.
- In Multires, Face Sets snaping does not initialize all current enabled Face
Sets when toggling snapping.
- In Multires, Face Sets are created at base mesh level (works by this by
design, like any other tool).
- Unlike the previous mask_expand operator, this one does not blur the mask
by default after finishing Expand as that does not fit the new design.
The mask can still be blurred by using the mask filter manually.
Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D10455
2021-03-01 23:37:48 +01:00
|
|
|
/* Geodesic distances. */
|
|
|
|
|
|
|
|
/* Returns an array indexed by vertex index containing the geodesic distance to the closest vertex
|
|
|
|
in the initial vertex set. The caller is responsible for freeing the array.
|
|
|
|
Geodesic distances will only work when used with PBVH_FACES, for other types of PBVH it will
|
|
|
|
fallback to euclidean distances to one of the initial vertices in the set. */
|
|
|
|
float *SCULPT_geodesic_distances_create(struct Object *ob,
|
|
|
|
struct GSet *initial_vertices,
|
|
|
|
const float limit_radius);
|
|
|
|
float *SCULPT_geodesic_from_vertex_and_symm(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
const int vertex,
|
|
|
|
const float limit_radius);
|
|
|
|
float *SCULPT_geodesic_from_vertex(Object *ob, const int vertex, const float limit_radius);
|
|
|
|
|
2020-04-03 19:42:48 +02:00
|
|
|
/* Filters. */
|
2020-08-17 18:47:00 +02:00
|
|
|
void SCULPT_filter_cache_init(struct bContext *C, Object *ob, Sculpt *sd, const int undo_type);
|
2020-04-03 19:42:48 +02:00
|
|
|
void SCULPT_filter_cache_free(SculptSession *ss);
|
|
|
|
|
2020-04-03 21:46:08 +02:00
|
|
|
void SCULPT_mask_filter_smooth_apply(
|
|
|
|
Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations);
|
|
|
|
|
2020-02-28 14:40:40 +01:00
|
|
|
/* Brushes. */
|
|
|
|
|
|
|
|
/* Cloth Brush. */
|
|
|
|
void SCULPT_do_cloth_brush(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct PBVHNode **nodes,
|
|
|
|
int totnode);
|
2020-08-18 15:11:51 +02:00
|
|
|
|
2020-02-28 14:40:40 +01:00
|
|
|
void SCULPT_cloth_simulation_free(struct SculptClothSimulation *cloth_sim);
|
|
|
|
|
2020-10-12 23:24:45 +02:00
|
|
|
struct SculptClothSimulation *SCULPT_cloth_brush_simulation_create(
|
|
|
|
struct SculptSession *ss,
|
|
|
|
const float cloth_mass,
|
|
|
|
const float cloth_damping,
|
|
|
|
const float cloth_softbody_strength,
|
|
|
|
const bool use_collisions,
|
|
|
|
const bool needs_deform_coords);
|
2020-08-17 22:18:26 +02:00
|
|
|
void SCULPT_cloth_brush_simulation_init(struct SculptSession *ss,
|
|
|
|
struct SculptClothSimulation *cloth_sim);
|
2020-10-01 18:50:52 +02:00
|
|
|
|
|
|
|
void SCULPT_cloth_sim_activate_nodes(struct SculptClothSimulation *cloth_sim,
|
|
|
|
PBVHNode **nodes,
|
|
|
|
int totnode);
|
|
|
|
|
2020-08-17 22:18:26 +02:00
|
|
|
void SCULPT_cloth_brush_store_simulation_state(struct SculptSession *ss,
|
|
|
|
struct SculptClothSimulation *cloth_sim);
|
|
|
|
|
|
|
|
void SCULPT_cloth_brush_do_simulation_step(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct SculptClothSimulation *cloth_sim,
|
|
|
|
struct PBVHNode **nodes,
|
|
|
|
int totnode);
|
|
|
|
|
2020-10-01 18:50:52 +02:00
|
|
|
void SCULPT_cloth_brush_ensure_nodes_constraints(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct PBVHNode **nodes,
|
|
|
|
int totnode,
|
|
|
|
struct SculptClothSimulation *cloth_sim,
|
|
|
|
float initial_location[3],
|
|
|
|
const float radius);
|
2020-08-17 22:18:26 +02:00
|
|
|
|
2020-02-28 14:40:40 +01:00
|
|
|
void SCULPT_cloth_simulation_limits_draw(const uint gpuattr,
|
|
|
|
const struct 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);
|
|
|
|
void SCULPT_cloth_plane_falloff_preview_draw(const uint gpuattr,
|
|
|
|
struct SculptSession *ss,
|
|
|
|
const float outline_col[3],
|
|
|
|
float outline_alpha);
|
2020-05-19 00:00:21 +02:00
|
|
|
|
2020-12-06 23:11:33 +01:00
|
|
|
PBVHNode **SCULPT_cloth_brush_affected_nodes_gather(SculptSession *ss,
|
|
|
|
Brush *brush,
|
|
|
|
int *r_totnode);
|
|
|
|
|
2020-05-19 00:00:21 +02:00
|
|
|
BLI_INLINE bool SCULPT_is_cloth_deform_brush(const Brush *brush)
|
|
|
|
{
|
2020-08-24 23:26:37 +02:00
|
|
|
return (brush->sculpt_tool == SCULPT_TOOL_CLOTH && ELEM(brush->cloth_deform_type,
|
|
|
|
BRUSH_CLOTH_DEFORM_GRAB,
|
|
|
|
BRUSH_CLOTH_DEFORM_SNAKE_HOOK)) ||
|
2020-08-18 15:11:51 +02:00
|
|
|
/* All brushes that are not the cloth brush deform the simulation using softbody
|
2020-10-14 15:24:42 +11:00
|
|
|
* constraints instead of applying forces. */
|
2020-08-18 15:11:51 +02:00
|
|
|
(brush->sculpt_tool != SCULPT_TOOL_CLOTH &&
|
|
|
|
brush->deform_target == BRUSH_DEFORM_TARGET_CLOTH_SIM);
|
2020-05-19 00:00:21 +02:00
|
|
|
}
|
|
|
|
|
2020-12-09 22:19:34 +01:00
|
|
|
BLI_INLINE bool SCULPT_tool_needs_all_pbvh_nodes(const Brush *brush)
|
|
|
|
{
|
|
|
|
if (brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM) {
|
|
|
|
/* Elastic deformations in any brush need all nodes to avoid artifacts as the effect
|
|
|
|
* of the Kelvinlet is not constrained by the radius. */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
|
|
|
|
/* Pose needs all nodes because it applies all symmetry iterations at the same time
|
|
|
|
* and the IK chain can grow to any area of the model. */
|
|
|
|
/* TODO: This can be optimized by filtering the nodes after calculating the chain. */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) {
|
|
|
|
/* Boundary needs all nodes because it is not possible to know where the boundary
|
|
|
|
* deformation is going to be propagated before calculating it. */
|
2020-12-11 14:51:43 +11:00
|
|
|
/* TODO: after calculating the boundary info in the first iteration, it should be
|
2020-12-09 22:19:34 +01:00
|
|
|
* possible to get the nodes that have vertices included in any boundary deformation
|
|
|
|
* and cache them. */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK &&
|
|
|
|
brush->snake_hook_deform_type == BRUSH_SNAKE_HOOK_DEFORM_ELASTIC) {
|
|
|
|
/* Snake hook in elastic deform type has same requirements as the elastic deform tool. */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-03-01 19:53:40 +01:00
|
|
|
/* Pose Brush. */
|
|
|
|
void SCULPT_do_pose_brush(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct PBVHNode **nodes,
|
|
|
|
int totnode);
|
|
|
|
void SCULPT_pose_calc_pose_data(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct SculptSession *ss,
|
|
|
|
float initial_location[3],
|
|
|
|
float radius,
|
|
|
|
float pose_offset,
|
|
|
|
float *r_pose_origin,
|
|
|
|
float *r_pose_factor);
|
|
|
|
void SCULPT_pose_brush_init(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct SculptSession *ss,
|
|
|
|
struct Brush *br);
|
|
|
|
struct SculptPoseIKChain *SCULPT_pose_ik_chain_init(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct SculptSession *ss,
|
|
|
|
struct Brush *br,
|
|
|
|
const float initial_location[3],
|
|
|
|
const float radius);
|
|
|
|
void SCULPT_pose_ik_chain_free(struct SculptPoseIKChain *ik_chain);
|
2020-02-28 14:40:40 +01:00
|
|
|
|
Sculpt: Boundary Brush
This brush includes a set of deformation modes designed to deform and
control the shape of the mesh boundaries, which are really hard to do
with regular sculpt brushes (and even in edit mode). This is useful
for creating cloth assets and hard surface base meshes.
The brush detects the mesh boundary closest to the active vertex and
propagates the deformation using the brush falloff into the mesh.
It includes bend, expand, inflate, grab and twist deform modes.
The main use cases of this brush are the Bend and Expand deformation
modes, which depend on a grid topology to create the best results.
In order to do further adjustments and tweaks to the result of these
deformation modes, the brush also includes the Inflate, Grab and
Twist deformation modes, which do not depend that much on the topology.
Grab and Inflate are the same operation that is implemented in the
Grab and Inflate tools, they are also available in the boundary brush
as producing deformations with regular brushes in these areas is very
hard to control.
Even if this brush can produce deformations in triangle meshes and
meshes with a non-regular quad grid, the more regular and clean the
topology is, the better. Most of the assets this brush is intended to
deform are always created from a cylindrical or plane quad grid, so it
should be fine. Also, its algorithms can be improved in future versions
to handle more corner cases and topology patterns.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D8356
2020-08-10 17:57:01 +02:00
|
|
|
/* Boundary Brush. */
|
|
|
|
struct SculptBoundary *SCULPT_boundary_data_init(Object *object,
|
2020-08-11 16:33:35 +02:00
|
|
|
Brush *brush,
|
Sculpt: Boundary Brush
This brush includes a set of deformation modes designed to deform and
control the shape of the mesh boundaries, which are really hard to do
with regular sculpt brushes (and even in edit mode). This is useful
for creating cloth assets and hard surface base meshes.
The brush detects the mesh boundary closest to the active vertex and
propagates the deformation using the brush falloff into the mesh.
It includes bend, expand, inflate, grab and twist deform modes.
The main use cases of this brush are the Bend and Expand deformation
modes, which depend on a grid topology to create the best results.
In order to do further adjustments and tweaks to the result of these
deformation modes, the brush also includes the Inflate, Grab and
Twist deformation modes, which do not depend that much on the topology.
Grab and Inflate are the same operation that is implemented in the
Grab and Inflate tools, they are also available in the boundary brush
as producing deformations with regular brushes in these areas is very
hard to control.
Even if this brush can produce deformations in triangle meshes and
meshes with a non-regular quad grid, the more regular and clean the
topology is, the better. Most of the assets this brush is intended to
deform are always created from a cylindrical or plane quad grid, so it
should be fine. Also, its algorithms can be improved in future versions
to handle more corner cases and topology patterns.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D8356
2020-08-10 17:57:01 +02:00
|
|
|
const int initial_vertex,
|
|
|
|
const float radius);
|
2020-08-12 23:38:36 +02:00
|
|
|
void SCULPT_boundary_data_free(struct SculptBoundary *boundary);
|
Sculpt: Boundary Brush
This brush includes a set of deformation modes designed to deform and
control the shape of the mesh boundaries, which are really hard to do
with regular sculpt brushes (and even in edit mode). This is useful
for creating cloth assets and hard surface base meshes.
The brush detects the mesh boundary closest to the active vertex and
propagates the deformation using the brush falloff into the mesh.
It includes bend, expand, inflate, grab and twist deform modes.
The main use cases of this brush are the Bend and Expand deformation
modes, which depend on a grid topology to create the best results.
In order to do further adjustments and tweaks to the result of these
deformation modes, the brush also includes the Inflate, Grab and
Twist deformation modes, which do not depend that much on the topology.
Grab and Inflate are the same operation that is implemented in the
Grab and Inflate tools, they are also available in the boundary brush
as producing deformations with regular brushes in these areas is very
hard to control.
Even if this brush can produce deformations in triangle meshes and
meshes with a non-regular quad grid, the more regular and clean the
topology is, the better. Most of the assets this brush is intended to
deform are always created from a cylindrical or plane quad grid, so it
should be fine. Also, its algorithms can be improved in future versions
to handle more corner cases and topology patterns.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D8356
2020-08-10 17:57:01 +02:00
|
|
|
void SCULPT_do_boundary_brush(struct Sculpt *sd,
|
|
|
|
struct Object *ob,
|
|
|
|
struct PBVHNode **nodes,
|
|
|
|
int totnode);
|
|
|
|
|
|
|
|
void SCULPT_boundary_edges_preview_draw(const uint gpuattr,
|
|
|
|
struct SculptSession *ss,
|
|
|
|
const float outline_col[3],
|
|
|
|
const float outline_alpha);
|
|
|
|
void SCULPT_boundary_pivot_line_preview_draw(const uint gpuattr, struct SculptSession *ss);
|
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Multi-plane Scrape Brush. */
|
2020-03-06 16:00:33 +01:00
|
|
|
void SCULPT_do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
|
|
|
|
void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr,
|
2020-08-06 01:30:34 +02:00
|
|
|
Brush *brush,
|
2020-03-06 16:00:33 +01:00
|
|
|
SculptSession *ss,
|
|
|
|
const float outline_col[3],
|
|
|
|
const float outline_alpha);
|
2020-04-03 19:16:49 +02:00
|
|
|
/* Draw Face Sets Brush. */
|
|
|
|
void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
|
2020-03-06 16:00:33 +01:00
|
|
|
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
/* Paint Brush. */
|
|
|
|
void SCULPT_do_paint_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
|
|
|
|
|
|
|
|
/* Smear Brush. */
|
|
|
|
void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
|
|
|
|
|
2020-04-03 21:05:20 +02:00
|
|
|
/* Smooth Brush. */
|
|
|
|
void SCULPT_bmesh_four_neighbor_average(float avg[3], float direction[3], struct BMVert *v);
|
|
|
|
|
|
|
|
void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index);
|
|
|
|
float SCULPT_neighbor_mask_average(SculptSession *ss, int index);
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
void SCULPT_neighbor_color_average(SculptSession *ss, float result[4], int index);
|
2020-04-03 21:05:20 +02:00
|
|
|
|
Fix T78747: Fix mesh boundary detection and automasking
This issue was produced by a hack in the sculpt mode code from 2.80
when the sculpt API for connectivity info was not available.
The smooth brush was the only brush that needed connectivity info,
so there were 3 different smooth functions with the connectivity
queries implemented for dyntopo, meshes and grids. The mesh version
of smoothing was checking the number of connected faces to a vertex
to mask the mesh boundaries, which was not covering all cases and
was hardcoded in the smooth function itself.
This patch removes all those legacy functions and unifies all
smooth functions into a single one using the new API and the
automasking system. In order to achieve this, there were needed
some extra changes:
- The smooth brush now does not automasks the boundaries by default,
so its default preset needs to be updated to enable automasking
- The mesh boundary info is extracted once and cached in a
bitmap, similar to the disconnected elements IDs. This makes
boundary detection work as expected in all cases, solving a lot
of known issues with the smooth brush. In multires, this info is
extracted and cached only at the base mesh level, so it is much
more memory efficient than the previous automasking system.
- In order to keep the brushes responsive as they were before,
the automasking system can now skip creating the cache when it
is not needed for the requested options. This means that for
high poly meshes and simple automasking options the brushes
won't lag on start.
Reviewed By: sergey
Maniphest Tasks: T78747
Differential Revision: https://developer.blender.org/D8260
2020-07-15 16:24:03 +02:00
|
|
|
/* Mask the mesh boundaries smoothing only the mesh surface without using automasking. */
|
|
|
|
void SCULPT_neighbor_coords_average_interior(SculptSession *ss, float result[3], int index);
|
|
|
|
|
2020-04-03 21:05:20 +02:00
|
|
|
void SCULPT_smooth(Sculpt *sd,
|
|
|
|
Object *ob,
|
|
|
|
PBVHNode **nodes,
|
|
|
|
const int totnode,
|
|
|
|
float bstrength,
|
|
|
|
const bool smooth_mask);
|
|
|
|
void SCULPT_do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
|
|
|
|
|
|
|
|
/* Surface Smooth Brush. */
|
|
|
|
|
|
|
|
void SCULPT_surface_smooth_laplacian_step(SculptSession *ss,
|
|
|
|
float *disp,
|
|
|
|
const float co[3],
|
|
|
|
float (*laplacian_disp)[3],
|
|
|
|
const int v_index,
|
|
|
|
const float origco[3],
|
|
|
|
const float alpha);
|
|
|
|
void SCULPT_surface_smooth_displace_step(SculptSession *ss,
|
|
|
|
float *co,
|
|
|
|
float (*laplacian_disp)[3],
|
|
|
|
const int v_index,
|
|
|
|
const float beta,
|
|
|
|
const float fade);
|
|
|
|
void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
|
|
|
|
|
2020-03-09 20:03:48 +01:00
|
|
|
/* Slide/Relax */
|
|
|
|
void SCULPT_relax_vertex(struct SculptSession *ss,
|
|
|
|
struct PBVHVertexIter *vd,
|
|
|
|
float factor,
|
|
|
|
bool filter_boundary_face_sets,
|
|
|
|
float *r_final_pos);
|
|
|
|
|
2010-07-14 14:11:03 +00:00
|
|
|
/* Undo */
|
|
|
|
|
2012-03-14 06:32:43 +00:00
|
|
|
typedef enum {
|
|
|
|
SCULPT_UNDO_COORDS,
|
2012-05-10 20:34:47 +00:00
|
|
|
SCULPT_UNDO_HIDDEN,
|
Add dynamic topology support to sculpt mode
* User documentation:
wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Dynamic_Topology_Sculpting
* Code review for this and the other dynamic-topology commits:
https://codereview.appspot.com/6947064/
Thanks to Sergey for doing code review!
* Add SCULPT_OT_dynamic_topology_toggle operator to enable or disable
dynamic topology mode
* Most brushes need little modification for dynamic topology, but for
some it won't work well and is disabled. This decision is made in
sculpt_stroke_dynamic_topology().
* For brushes that need original data (e.g. grab brush) the topology
is not updated during the stroke, but some changes to original
vertex data is accessed were made since BMesh works a little
differently from mesh/multires. This is abstracted with
SculptOrigVertData and associated functions.
* Smooth brush gets yet another set of functions, for mesh and
multires and dynamic topology and, separetely, masking
* For most brushes, the topology is updated during the stroke right
before the regular brush action takes place. This is handled in
sculpt_topology_update().
* Exiting sculpt mode also disables dynamic topology
* Sculpt undo works differently with BMesh. Since the contents of
nodes in the PBVH do not remain static during a sculpt session, the
SculptUndoNodes do not correspond with PBVHNodes if dynamic topology
is enabled. Rather, each SculptUndoNode is associated with a
BMLogEntry.
* Sculpt undo gets a few new cases: entering and exiting dynamic
topology does an undo push of all mesh data. Symmetrize will
similarly push a full copy of BMesh data, although it does so
through the BMLog API.
* Undo and redo in dynamic-topology mode will do a full recalculation
of the PBVH.
* Add some documentation to doc/sculpt.org. This could stand to be
expanded a lot more, for now it mostly contains test cases for the
undo system.
* Add SCULPT_OT_optimize operator to recalculate the BVH. The BVH gets
less optimal more quickly with dynamic topology than regular
sculpting. There is no doubt more clever stuff we can do to optimize
it on the fly, but for now this gives the user a nicer way to
recalculate it than toggling modes.
2012-12-30 18:29:07 +00:00
|
|
|
SCULPT_UNDO_MASK,
|
|
|
|
SCULPT_UNDO_DYNTOPO_BEGIN,
|
|
|
|
SCULPT_UNDO_DYNTOPO_END,
|
|
|
|
SCULPT_UNDO_DYNTOPO_SYMMETRIZE,
|
2019-08-14 18:37:46 +02:00
|
|
|
SCULPT_UNDO_GEOMETRY,
|
2020-03-05 14:53:23 +01:00
|
|
|
SCULPT_UNDO_FACE_SETS,
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
SCULPT_UNDO_COLOR,
|
2012-03-14 06:32:43 +00:00
|
|
|
} SculptUndoType;
|
|
|
|
|
2020-03-27 16:37:29 +01:00
|
|
|
/* Storage of geometry for the undo node.
|
|
|
|
* Is used as a storage for either original or modified geometry. */
|
|
|
|
typedef struct SculptUndoNodeGeometry {
|
|
|
|
/* Is used for sanity check, helping with ensuring that two and only two
|
2020-04-03 12:38:04 +11:00
|
|
|
* geometry pushes happened in the undo stack. */
|
2020-03-27 16:37:29 +01:00
|
|
|
bool is_initialized;
|
|
|
|
|
|
|
|
CustomData vdata;
|
|
|
|
CustomData edata;
|
|
|
|
CustomData ldata;
|
|
|
|
CustomData pdata;
|
|
|
|
int totvert;
|
|
|
|
int totedge;
|
|
|
|
int totloop;
|
|
|
|
int totpoly;
|
|
|
|
} SculptUndoNodeGeometry;
|
|
|
|
|
2010-07-14 14:11:03 +00:00
|
|
|
typedef struct SculptUndoNode {
|
|
|
|
struct SculptUndoNode *next, *prev;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-14 06:32:43 +00:00
|
|
|
SculptUndoType type;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-11 08:05:47 +00:00
|
|
|
char idname[MAX_ID_NAME]; /* name instead of pointer*/
|
|
|
|
void *node; /* only during push, not valid afterwards! */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-14 14:11:03 +00:00
|
|
|
float (*co)[3];
|
2011-01-31 20:02:51 +00:00
|
|
|
float (*orig_co)[3];
|
2010-07-14 14:11:03 +00:00
|
|
|
short (*no)[3];
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
float (*col)[4];
|
2012-05-10 20:34:47 +00:00
|
|
|
float *mask;
|
2010-07-14 14:11:03 +00:00
|
|
|
int totvert;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-14 14:11:03 +00:00
|
|
|
/* non-multires */
|
2012-05-11 08:05:47 +00:00
|
|
|
int maxvert; /* to verify if totvert it still the same */
|
|
|
|
int *index; /* to restore into right location */
|
2013-07-22 23:20:48 +00:00
|
|
|
BLI_bitmap *vert_hidden;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-14 14:11:03 +00:00
|
|
|
/* multires */
|
2012-05-11 08:05:47 +00:00
|
|
|
int maxgrid; /* same for grid */
|
|
|
|
int gridsize; /* same for grid */
|
|
|
|
int totgrid; /* to restore into right location */
|
|
|
|
int *grids; /* to restore into right location */
|
2013-07-22 23:20:48 +00:00
|
|
|
BLI_bitmap **grid_hidden;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Add dynamic topology support to sculpt mode
* User documentation:
wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Dynamic_Topology_Sculpting
* Code review for this and the other dynamic-topology commits:
https://codereview.appspot.com/6947064/
Thanks to Sergey for doing code review!
* Add SCULPT_OT_dynamic_topology_toggle operator to enable or disable
dynamic topology mode
* Most brushes need little modification for dynamic topology, but for
some it won't work well and is disabled. This decision is made in
sculpt_stroke_dynamic_topology().
* For brushes that need original data (e.g. grab brush) the topology
is not updated during the stroke, but some changes to original
vertex data is accessed were made since BMesh works a little
differently from mesh/multires. This is abstracted with
SculptOrigVertData and associated functions.
* Smooth brush gets yet another set of functions, for mesh and
multires and dynamic topology and, separetely, masking
* For most brushes, the topology is updated during the stroke right
before the regular brush action takes place. This is handled in
sculpt_topology_update().
* Exiting sculpt mode also disables dynamic topology
* Sculpt undo works differently with BMesh. Since the contents of
nodes in the PBVH do not remain static during a sculpt session, the
SculptUndoNodes do not correspond with PBVHNodes if dynamic topology
is enabled. Rather, each SculptUndoNode is associated with a
BMLogEntry.
* Sculpt undo gets a few new cases: entering and exiting dynamic
topology does an undo push of all mesh data. Symmetrize will
similarly push a full copy of BMesh data, although it does so
through the BMLog API.
* Undo and redo in dynamic-topology mode will do a full recalculation
of the PBVH.
* Add some documentation to doc/sculpt.org. This could stand to be
expanded a lot more, for now it mostly contains test cases for the
undo system.
* Add SCULPT_OT_optimize operator to recalculate the BVH. The BVH gets
less optimal more quickly with dynamic topology than regular
sculpting. There is no doubt more clever stuff we can do to optimize
it on the fly, but for now this gives the user a nicer way to
recalculate it than toggling modes.
2012-12-30 18:29:07 +00:00
|
|
|
/* bmesh */
|
|
|
|
struct BMLogEntry *bm_entry;
|
2014-03-31 23:39:08 +11:00
|
|
|
bool applied;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-14 14:11:03 +00:00
|
|
|
/* shape keys */
|
2011-03-05 10:37:59 +00:00
|
|
|
char shapeName[sizeof(((KeyBlock *)0))->name];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-27 16:37:29 +01:00
|
|
|
/* Geometry modification operations.
|
|
|
|
*
|
|
|
|
* Original geometry is stored before some modification is run and is used to restore state of
|
|
|
|
* the object when undoing the operation
|
|
|
|
*
|
|
|
|
* Modified geometry is stored after the modification and is used to redo the modification. */
|
2020-03-30 09:35:01 +02:00
|
|
|
bool geometry_clear_pbvh;
|
2020-03-27 16:37:29 +01:00
|
|
|
SculptUndoNodeGeometry geometry_original;
|
|
|
|
SculptUndoNodeGeometry geometry_modified;
|
|
|
|
|
|
|
|
/* Geometry at the bmesh enter moment. */
|
|
|
|
SculptUndoNodeGeometry geometry_bmesh_enter;
|
2019-08-14 18:37:46 +02:00
|
|
|
|
2019-09-10 19:55:15 +02:00
|
|
|
/* pivot */
|
|
|
|
float pivot_pos[3];
|
|
|
|
float pivot_rot[4];
|
|
|
|
|
2020-03-05 14:53:23 +01:00
|
|
|
/* Sculpt Face Sets */
|
|
|
|
int *face_sets;
|
|
|
|
|
2018-03-19 14:17:59 +01:00
|
|
|
size_t undo_size;
|
2010-07-14 14:11:03 +00:00
|
|
|
} SculptUndoNode;
|
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* Factor of brush to have rake point following behind
|
2018-01-10 19:57:02 +11:00
|
|
|
* (could be configurable but this is reasonable default). */
|
2017-09-28 01:38:17 +10:00
|
|
|
#define SCULPT_RAKE_BRUSH_FACTOR 0.25f
|
|
|
|
|
|
|
|
struct SculptRakeData {
|
|
|
|
float follow_dist;
|
|
|
|
float follow_co[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Single struct used by all BLI_task threaded callbacks, let's avoid adding 10's of those... */
|
|
|
|
typedef struct SculptThreadedTaskData {
|
2017-09-29 20:03:58 +10:00
|
|
|
struct bContext *C;
|
2017-09-28 01:38:17 +10:00
|
|
|
struct Sculpt *sd;
|
|
|
|
struct Object *ob;
|
2017-10-03 18:43:18 +11:00
|
|
|
const struct Brush *brush;
|
2017-09-28 01:38:17 +10:00
|
|
|
struct PBVHNode **nodes;
|
|
|
|
int totnode;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
struct VPaint *vp;
|
|
|
|
struct VPaintData *vpd;
|
|
|
|
struct WPaintData *wpd;
|
|
|
|
struct WeightPaintInfo *wpi;
|
|
|
|
unsigned int *lcol;
|
|
|
|
struct Mesh *me;
|
|
|
|
/* For passing generic params. */
|
|
|
|
void *custom_data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* Data specific to some callbacks. */
|
2019-04-22 00:18:34 +10:00
|
|
|
|
|
|
|
/* Note: even if only one or two of those are used at a time,
|
|
|
|
* keeping them separated, names help figuring out
|
|
|
|
* what it is, and memory overhead is ridiculous anyway. */
|
2017-09-28 01:38:17 +10:00
|
|
|
float flippedbstrength;
|
|
|
|
float angle;
|
|
|
|
float strength;
|
|
|
|
bool smooth_mask;
|
|
|
|
bool has_bm_orco;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
struct SculptProjectVector *spvc;
|
|
|
|
float *offset;
|
|
|
|
float *grab_delta;
|
|
|
|
float *cono;
|
|
|
|
float *area_no;
|
|
|
|
float *area_no_sp;
|
|
|
|
float *area_co;
|
|
|
|
float (*mat)[4];
|
|
|
|
float (*vertCos)[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-02 20:11:51 +01:00
|
|
|
/* X and Z vectors aligned to the stroke direction for operations where perpendicular vectors to
|
|
|
|
* the stroke direction are needed. */
|
|
|
|
float (*stroke_xz)[3];
|
|
|
|
|
2019-09-10 19:55:15 +02:00
|
|
|
int filter_type;
|
|
|
|
float filter_strength;
|
2020-06-30 03:25:49 +02:00
|
|
|
float *filter_fill_color;
|
2019-09-10 19:55:15 +02:00
|
|
|
|
2019-10-09 16:27:04 +02:00
|
|
|
bool use_area_cos;
|
|
|
|
bool use_area_nos;
|
2019-12-16 23:16:21 +01:00
|
|
|
|
|
|
|
/* 0=towards view, 1=flipped */
|
|
|
|
float (*area_cos)[3];
|
|
|
|
float (*area_nos)[3];
|
|
|
|
int *count_no;
|
|
|
|
int *count_co;
|
|
|
|
|
2019-08-30 16:27:31 +02:00
|
|
|
bool any_vertex_sampled;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
float *wet_mix_sampled_color;
|
|
|
|
|
2019-09-09 16:20:40 +02:00
|
|
|
float *prev_mask;
|
|
|
|
|
2019-09-27 18:03:18 +02:00
|
|
|
float *pose_factor;
|
2020-01-07 16:46:56 +01:00
|
|
|
float *pose_initial_co;
|
|
|
|
int pose_chain_segment;
|
2019-09-09 17:44:08 +02:00
|
|
|
|
2019-11-06 19:39:34 +01:00
|
|
|
float multiplane_scrape_angle;
|
|
|
|
float multiplane_scrape_planes[2][4];
|
|
|
|
|
2019-09-09 16:58:09 +02:00
|
|
|
float max_distance_squared;
|
|
|
|
float nearest_vertex_search_co[3];
|
|
|
|
|
2020-01-22 02:23:51 +01:00
|
|
|
/* Stabilized strength for the Clay Thumb brush. */
|
|
|
|
float clay_strength;
|
|
|
|
|
2019-09-10 15:11:33 +02:00
|
|
|
int mask_expand_update_it;
|
|
|
|
bool mask_expand_invert_mask;
|
|
|
|
bool mask_expand_use_normals;
|
|
|
|
bool mask_expand_keep_prev_mask;
|
2020-03-05 14:53:23 +01:00
|
|
|
bool mask_expand_create_face_set;
|
2019-09-10 15:11:33 +02:00
|
|
|
|
2019-09-10 19:55:15 +02:00
|
|
|
float transform_mats[8][4][4];
|
|
|
|
|
Sculpt: Boundary Brush
This brush includes a set of deformation modes designed to deform and
control the shape of the mesh boundaries, which are really hard to do
with regular sculpt brushes (and even in edit mode). This is useful
for creating cloth assets and hard surface base meshes.
The brush detects the mesh boundary closest to the active vertex and
propagates the deformation using the brush falloff into the mesh.
It includes bend, expand, inflate, grab and twist deform modes.
The main use cases of this brush are the Bend and Expand deformation
modes, which depend on a grid topology to create the best results.
In order to do further adjustments and tweaks to the result of these
deformation modes, the brush also includes the Inflate, Grab and
Twist deformation modes, which do not depend that much on the topology.
Grab and Inflate are the same operation that is implemented in the
Grab and Inflate tools, they are also available in the boundary brush
as producing deformations with regular brushes in these areas is very
hard to control.
Even if this brush can produce deformations in triangle meshes and
meshes with a non-regular quad grid, the more regular and clean the
topology is, the better. Most of the assets this brush is intended to
deform are always created from a cylindrical or plane quad grid, so it
should be fine. Also, its algorithms can be improved in future versions
to handle more corner cases and topology patterns.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D8356
2020-08-10 17:57:01 +02:00
|
|
|
/* Boundary brush */
|
|
|
|
float boundary_deform_strength;
|
|
|
|
|
2020-02-28 14:40:40 +01:00
|
|
|
float cloth_time_step;
|
2020-06-01 22:36:26 +02:00
|
|
|
SculptClothSimulation *cloth_sim;
|
|
|
|
float *cloth_sim_initial_location;
|
|
|
|
float cloth_sim_radius;
|
2020-02-28 14:40:40 +01:00
|
|
|
|
2019-09-30 15:37:37 +02:00
|
|
|
float dirty_mask_min;
|
|
|
|
float dirty_mask_max;
|
|
|
|
bool dirty_mask_dirty_only;
|
|
|
|
|
2020-07-01 19:19:30 +02:00
|
|
|
/* Mask By Color Tool */
|
|
|
|
|
|
|
|
float mask_by_color_threshold;
|
|
|
|
bool mask_by_color_invert;
|
|
|
|
bool mask_by_color_preserve_mask;
|
|
|
|
|
|
|
|
/* Index of the vertex that is going to be used as a reference for the colors. */
|
|
|
|
int mask_by_color_vertex;
|
|
|
|
float *mask_by_color_floodfill;
|
|
|
|
|
2020-03-05 14:53:23 +01:00
|
|
|
int face_set;
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
int filter_undo_type;
|
2020-03-05 14:53:23 +01:00
|
|
|
|
2021-03-12 21:35:56 +01:00
|
|
|
int mask_init_mode;
|
|
|
|
int mask_init_seed;
|
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
ThreadMutex mutex;
|
|
|
|
|
|
|
|
} SculptThreadedTaskData;
|
|
|
|
|
|
|
|
/*************** Brush testing declarations ****************/
|
|
|
|
typedef struct SculptBrushTest {
|
|
|
|
float radius_squared;
|
2020-03-26 16:46:32 +01:00
|
|
|
float radius;
|
2017-09-28 01:38:17 +10:00
|
|
|
float location[3];
|
|
|
|
float dist;
|
|
|
|
int mirror_symmetry_pass;
|
|
|
|
|
2020-10-06 12:50:11 +02:00
|
|
|
int radial_symmetry_pass;
|
|
|
|
float symm_rot_mat_inv[4][4];
|
|
|
|
|
2017-10-02 13:21:23 +11:00
|
|
|
/* For circle (not sphere) projection. */
|
2017-10-06 00:18:11 +11:00
|
|
|
float plane_view[4];
|
|
|
|
|
|
|
|
/* Some tool code uses a plane for its calculations. */
|
|
|
|
float plane_tool[4];
|
2017-10-02 13:21:23 +11:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* View3d clipping - only set rv3d for clipping */
|
|
|
|
struct RegionView3D *clip_rv3d;
|
|
|
|
} SculptBrushTest;
|
|
|
|
|
2017-10-02 21:07:25 +11:00
|
|
|
typedef bool (*SculptBrushTestFn)(SculptBrushTest *test, const float co[3]);
|
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
typedef struct {
|
|
|
|
struct Sculpt *sd;
|
|
|
|
struct SculptSession *ss;
|
|
|
|
float radius_squared;
|
2020-01-07 16:46:56 +01:00
|
|
|
const float *center;
|
2017-09-28 01:38:17 +10:00
|
|
|
bool original;
|
2020-07-08 18:10:31 +02:00
|
|
|
/* This ignores fully masked and fully hidden nodes. */
|
|
|
|
bool ignore_fully_ineffective;
|
2017-09-28 01:38:17 +10:00
|
|
|
} SculptSearchSphereData;
|
|
|
|
|
2017-10-02 21:07:25 +11:00
|
|
|
typedef struct {
|
|
|
|
struct Sculpt *sd;
|
|
|
|
struct SculptSession *ss;
|
|
|
|
float radius_squared;
|
|
|
|
bool original;
|
2020-07-08 18:10:31 +02:00
|
|
|
bool ignore_fully_ineffective;
|
2017-10-02 21:07:25 +11:00
|
|
|
struct DistRayAABB_Precalc *dist_ray_to_aabb_precalc;
|
|
|
|
} SculptSearchCircleData;
|
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
void SCULPT_brush_test_init(struct SculptSession *ss, SculptBrushTest *test);
|
|
|
|
bool SCULPT_brush_test_sphere(SculptBrushTest *test, const float co[3]);
|
|
|
|
bool SCULPT_brush_test_sphere_sq(SculptBrushTest *test, const float co[3]);
|
|
|
|
bool SCULPT_brush_test_sphere_fast(const SculptBrushTest *test, const float co[3]);
|
|
|
|
bool SCULPT_brush_test_cube(SculptBrushTest *test,
|
2020-02-11 20:04:41 +01:00
|
|
|
const float co[3],
|
2020-02-13 14:01:52 +11:00
|
|
|
const float local[4][4],
|
2020-02-11 20:04:41 +01:00
|
|
|
const float roundness);
|
2020-03-06 15:24:15 +01:00
|
|
|
bool SCULPT_brush_test_circle_sq(SculptBrushTest *test, const float co[3]);
|
|
|
|
bool SCULPT_search_sphere_cb(PBVHNode *node, void *data_v);
|
|
|
|
bool SCULPT_search_circle_cb(PBVHNode *node, void *data_v);
|
2017-10-06 00:18:11 +11:00
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
SculptBrushTestFn SCULPT_brush_test_init_with_falloff_shape(SculptSession *ss,
|
2017-10-06 00:18:11 +11:00
|
|
|
SculptBrushTest *test,
|
|
|
|
char falloff_shape);
|
2020-03-06 15:24:15 +01:00
|
|
|
const float *SCULPT_brush_frontface_normal_from_falloff_shape(SculptSession *ss,
|
2017-10-06 19:10:33 +11:00
|
|
|
char falloff_shape);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
float SCULPT_brush_strength_factor(struct SculptSession *ss,
|
|
|
|
const struct Brush *br,
|
|
|
|
const float point[3],
|
|
|
|
const float len,
|
|
|
|
const short vno[3],
|
|
|
|
const float fno[3],
|
|
|
|
const float mask,
|
|
|
|
const int vertex_index,
|
|
|
|
const int thread_id);
|
2017-09-28 01:38:17 +10:00
|
|
|
|
Sculpt: Experimental Pen Tilt Support
This adds support for pen tilt in sculpt mode. For now, pen tilt is used
by tweaking the tilt strength property, which controls how much the pen
angle affects the sculpt normal. This is available in Draw, Draw Sharp,
Flatten, Fill, Scrape and Clay Strips brushes, but it can be enabled in
more tools later.
The purpose of this patch is to have a usable implementation of pen tilt
in a painting mode, so users can test and see in which hardware and
platforms this feature is supported and how well it works. If it works
ok, more tools and features that rely on pen tilt can be implemented,
like brushes that blend between two deformations depending on the angle.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D8893
2020-10-08 00:00:36 +02:00
|
|
|
/* Tilts a normal by the x and y tilt values using the view axis. */
|
|
|
|
void SCULPT_tilt_apply_to_normal(float r_normal[3],
|
|
|
|
struct StrokeCache *cache,
|
|
|
|
const float tilt_strength);
|
|
|
|
|
2020-10-20 13:44:30 +02:00
|
|
|
/* Get effective surface normal with pen tilt and tilt strength applied to it. */
|
|
|
|
void SCULPT_tilt_effective_normal_get(const SculptSession *ss, const Brush *brush, float r_no[3]);
|
|
|
|
|
2017-09-29 22:47:08 +10:00
|
|
|
/* just for vertex paint. */
|
2020-03-06 15:24:15 +01:00
|
|
|
bool SCULPT_pbvh_calc_area_normal(const struct Brush *brush,
|
2017-09-29 22:47:08 +10:00
|
|
|
Object *ob,
|
|
|
|
PBVHNode **nodes,
|
|
|
|
int totnode,
|
|
|
|
bool use_threading,
|
|
|
|
float r_area_no[3]);
|
2017-09-28 01:38:17 +10:00
|
|
|
|
|
|
|
/* Cache stroke properties. Used because
|
2018-01-10 19:57:02 +11:00
|
|
|
* RNA property lookup isn't particularly fast.
|
|
|
|
*
|
|
|
|
* For descriptions of these settings, check the operator properties.
|
|
|
|
*/
|
2017-09-28 01:38:17 +10:00
|
|
|
|
2020-03-27 10:52:14 +11:00
|
|
|
#define SCULPT_CLAY_STABILIZER_LEN 10
|
2020-01-22 02:23:51 +01:00
|
|
|
|
Fix T78747: Fix mesh boundary detection and automasking
This issue was produced by a hack in the sculpt mode code from 2.80
when the sculpt API for connectivity info was not available.
The smooth brush was the only brush that needed connectivity info,
so there were 3 different smooth functions with the connectivity
queries implemented for dyntopo, meshes and grids. The mesh version
of smoothing was checking the number of connected faces to a vertex
to mask the mesh boundaries, which was not covering all cases and
was hardcoded in the smooth function itself.
This patch removes all those legacy functions and unifies all
smooth functions into a single one using the new API and the
automasking system. In order to achieve this, there were needed
some extra changes:
- The smooth brush now does not automasks the boundaries by default,
so its default preset needs to be updated to enable automasking
- The mesh boundary info is extracted once and cached in a
bitmap, similar to the disconnected elements IDs. This makes
boundary detection work as expected in all cases, solving a lot
of known issues with the smooth brush. In multires, this info is
extracted and cached only at the base mesh level, so it is much
more memory efficient than the previous automasking system.
- In order to keep the brushes responsive as they were before,
the automasking system can now skip creating the cache when it
is not needed for the requested options. This means that for
high poly meshes and simple automasking options the brushes
won't lag on start.
Reviewed By: sergey
Maniphest Tasks: T78747
Differential Revision: https://developer.blender.org/D8260
2020-07-15 16:24:03 +02:00
|
|
|
typedef struct AutomaskingSettings {
|
|
|
|
/* Flags from eAutomasking_flag. */
|
|
|
|
int flags;
|
|
|
|
int initial_face_set;
|
|
|
|
} AutomaskingSettings;
|
|
|
|
|
2020-10-15 19:34:54 +02:00
|
|
|
typedef struct AutomaskingCache {
|
|
|
|
AutomaskingSettings settings;
|
2020-10-16 11:46:48 +11:00
|
|
|
/* Precomputed auto-mask factor indexed by vertex, owned by the auto-masking system and
|
|
|
|
* initialized in #SCULPT_automasking_cache_init when needed. */
|
2020-10-15 19:34:54 +02:00
|
|
|
float *factor;
|
|
|
|
} AutomaskingCache;
|
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
typedef struct StrokeCache {
|
|
|
|
/* Invariants */
|
|
|
|
float initial_radius;
|
|
|
|
float scale[3];
|
|
|
|
int flag;
|
|
|
|
float clip_tolerance[3];
|
|
|
|
float initial_mouse[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* Variants */
|
|
|
|
float radius;
|
|
|
|
float radius_squared;
|
|
|
|
float true_location[3];
|
|
|
|
float true_last_location[3];
|
|
|
|
float location[3];
|
|
|
|
float last_location[3];
|
2019-11-24 21:15:48 +01:00
|
|
|
|
2020-03-09 20:03:48 +01:00
|
|
|
/* Used for alternating between deformation in brushes that need to apply different ones to
|
|
|
|
* achieve certain effects. */
|
|
|
|
int iteration_count;
|
|
|
|
|
2019-12-01 20:29:11 +01:00
|
|
|
/* Original pixel radius with the pressure curve applied for dyntopo detail size */
|
|
|
|
float dyntopo_pixel_radius;
|
2019-11-24 21:15:48 +01:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
bool is_last_valid;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
bool pen_flip;
|
|
|
|
bool invert;
|
|
|
|
float pressure;
|
|
|
|
float bstrength;
|
|
|
|
float normal_weight; /* from brush (with optional override) */
|
Sculpt: Experimental Pen Tilt Support
This adds support for pen tilt in sculpt mode. For now, pen tilt is used
by tweaking the tilt strength property, which controls how much the pen
angle affects the sculpt normal. This is available in Draw, Draw Sharp,
Flatten, Fill, Scrape and Clay Strips brushes, but it can be enabled in
more tools later.
The purpose of this patch is to have a usable implementation of pen tilt
in a painting mode, so users can test and see in which hardware and
platforms this feature is supported and how well it works. If it works
ok, more tools and features that rely on pen tilt can be implemented,
like brushes that blend between two deformations depending on the angle.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D8893
2020-10-08 00:00:36 +02:00
|
|
|
float x_tilt;
|
|
|
|
float y_tilt;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-12 20:32:26 +02:00
|
|
|
/* Position of the mouse corresponding to the stroke location, modified by the paint_stroke
|
2020-10-16 11:46:48 +11:00
|
|
|
* operator according to the stroke type. */
|
2020-10-12 20:32:26 +02:00
|
|
|
float mouse[2];
|
|
|
|
/* Position of the mouse event in screen space, not modified by the stroke type. */
|
|
|
|
float mouse_event[2];
|
|
|
|
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
float (*prev_colors)[4];
|
|
|
|
|
2020-12-11 22:49:49 +01:00
|
|
|
/* Multires Displacement Smear. */
|
|
|
|
float (*prev_displacement)[3];
|
|
|
|
float (*limit_surface_co)[3];
|
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* The rest is temporary storage that isn't saved as a property */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
bool first_time; /* Beginning of stroke may do some things special */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* from ED_view3d_ob_project_mat_get() */
|
|
|
|
float projection_mat[4][4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* Clean this up! */
|
|
|
|
struct ViewContext *vc;
|
2017-10-03 18:43:18 +11:00
|
|
|
const struct Brush *brush;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
float special_rotation;
|
|
|
|
float grab_delta[3], grab_delta_symmetry[3];
|
|
|
|
float old_grab_location[3], orig_grab_location[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* screen-space rotation defined by mouse motion */
|
|
|
|
float rake_rotation[4], rake_rotation_symmetry[4];
|
|
|
|
bool is_rake_rotation_valid;
|
|
|
|
struct SculptRakeData rake_data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-05 14:53:23 +01:00
|
|
|
/* Face Sets */
|
|
|
|
int paint_face_set;
|
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* Symmetry index between 0 and 7 bit combo 0 is Brush only;
|
|
|
|
* 1 is X mirror; 2 is Y mirror; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
|
|
|
|
int symmetry;
|
|
|
|
int mirror_symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/
|
|
|
|
float true_view_normal[3];
|
|
|
|
float view_normal[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* sculpt_normal gets calculated by calc_sculpt_normal(), then the
|
2018-01-10 19:57:02 +11:00
|
|
|
* sculpt_normal_symm gets updated quickly with the usual symmetry
|
|
|
|
* transforms */
|
2017-09-28 01:38:17 +10:00
|
|
|
float sculpt_normal[3];
|
|
|
|
float sculpt_normal_symm[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
/* Used for area texture mode, local_mat gets calculated by
|
2018-01-10 19:57:02 +11:00
|
|
|
* calc_brush_local_mat() and used in tex_strength(). */
|
2017-09-28 01:38:17 +10:00
|
|
|
float brush_local_mat[4][4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
float plane_offset[3]; /* used to shift the plane around when doing tiled strokes */
|
|
|
|
int tile_pass;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
float last_center[3];
|
|
|
|
int radial_symmetry_pass;
|
|
|
|
float symm_rot_mat[4][4];
|
|
|
|
float symm_rot_mat_inv[4][4];
|
|
|
|
bool original;
|
|
|
|
float anchored_location[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-20 00:37:41 +02:00
|
|
|
/* Paint Brush. */
|
|
|
|
struct {
|
|
|
|
float hardness;
|
|
|
|
float flow;
|
|
|
|
float wet_mix;
|
|
|
|
float wet_persistence;
|
|
|
|
float density;
|
|
|
|
} paint_brush;
|
|
|
|
|
2019-09-09 17:44:08 +02:00
|
|
|
/* Pose brush */
|
2020-01-08 12:59:48 +11:00
|
|
|
struct SculptPoseIKChain *pose_ik_chain;
|
2019-09-09 17:44:08 +02:00
|
|
|
|
2020-08-18 16:13:43 +02:00
|
|
|
/* Enhance Details. */
|
|
|
|
float (*detail_directions)[3];
|
|
|
|
|
2020-01-22 02:23:51 +01:00
|
|
|
/* Clay Thumb brush */
|
|
|
|
/* Angle of the front tilting plane of the brush to simulate clay accumulation. */
|
|
|
|
float clay_thumb_front_angle;
|
|
|
|
/* Stores pressure samples to get an stabilized strength and radius variation. */
|
2020-03-27 10:52:14 +11:00
|
|
|
float clay_pressure_stabilizer[SCULPT_CLAY_STABILIZER_LEN];
|
2020-01-22 02:23:51 +01:00
|
|
|
int clay_pressure_stabilizer_index;
|
|
|
|
|
2020-02-28 14:40:40 +01:00
|
|
|
/* Cloth brush */
|
|
|
|
struct SculptClothSimulation *cloth_sim;
|
|
|
|
float initial_location[3];
|
|
|
|
float true_initial_location[3];
|
|
|
|
float initial_normal[3];
|
|
|
|
float true_initial_normal[3];
|
|
|
|
|
Sculpt: Boundary Brush
This brush includes a set of deformation modes designed to deform and
control the shape of the mesh boundaries, which are really hard to do
with regular sculpt brushes (and even in edit mode). This is useful
for creating cloth assets and hard surface base meshes.
The brush detects the mesh boundary closest to the active vertex and
propagates the deformation using the brush falloff into the mesh.
It includes bend, expand, inflate, grab and twist deform modes.
The main use cases of this brush are the Bend and Expand deformation
modes, which depend on a grid topology to create the best results.
In order to do further adjustments and tweaks to the result of these
deformation modes, the brush also includes the Inflate, Grab and
Twist deformation modes, which do not depend that much on the topology.
Grab and Inflate are the same operation that is implemented in the
Grab and Inflate tools, they are also available in the boundary brush
as producing deformations with regular brushes in these areas is very
hard to control.
Even if this brush can produce deformations in triangle meshes and
meshes with a non-regular quad grid, the more regular and clean the
topology is, the better. Most of the assets this brush is intended to
deform are always created from a cylindrical or plane quad grid, so it
should be fine. Also, its algorithms can be improved in future versions
to handle more corner cases and topology patterns.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D8356
2020-08-10 17:57:01 +02:00
|
|
|
/* Boundary brush */
|
2020-08-12 23:38:36 +02:00
|
|
|
struct SculptBoundary *boundaries[PAINT_SYMM_AREAS];
|
Sculpt: Boundary Brush
This brush includes a set of deformation modes designed to deform and
control the shape of the mesh boundaries, which are really hard to do
with regular sculpt brushes (and even in edit mode). This is useful
for creating cloth assets and hard surface base meshes.
The brush detects the mesh boundary closest to the active vertex and
propagates the deformation using the brush falloff into the mesh.
It includes bend, expand, inflate, grab and twist deform modes.
The main use cases of this brush are the Bend and Expand deformation
modes, which depend on a grid topology to create the best results.
In order to do further adjustments and tweaks to the result of these
deformation modes, the brush also includes the Inflate, Grab and
Twist deformation modes, which do not depend that much on the topology.
Grab and Inflate are the same operation that is implemented in the
Grab and Inflate tools, they are also available in the boundary brush
as producing deformations with regular brushes in these areas is very
hard to control.
Even if this brush can produce deformations in triangle meshes and
meshes with a non-regular quad grid, the more regular and clean the
topology is, the better. Most of the assets this brush is intended to
deform are always created from a cylindrical or plane quad grid, so it
should be fine. Also, its algorithms can be improved in future versions
to handle more corner cases and topology patterns.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D8356
2020-08-10 17:57:01 +02:00
|
|
|
|
2020-03-26 16:05:46 +01:00
|
|
|
/* Surface Smooth Brush */
|
|
|
|
/* Stores the displacement produced by the laplacian step of HC smooth. */
|
|
|
|
float (*surface_smooth_laplacian_disp)[3];
|
|
|
|
|
2020-04-14 21:06:49 +02:00
|
|
|
/* Layer brush */
|
|
|
|
float *layer_displacement_factor;
|
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
float vertex_rotation; /* amount to rotate the vertices when using rotate brush */
|
|
|
|
struct Dial *dial;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
char saved_active_brush_name[MAX_ID_NAME];
|
|
|
|
char saved_mask_brush_tool;
|
|
|
|
int saved_smooth_size; /* smooth tool copies the size of the current tool */
|
|
|
|
bool alt_smooth;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
float plane_trim_squared;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
bool supports_gravity;
|
|
|
|
float true_gravity_direction[3];
|
|
|
|
float gravity_direction[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-16 11:46:48 +11:00
|
|
|
/* Auto-masking. */
|
2020-10-15 19:34:54 +02:00
|
|
|
AutomaskingCache *automasking;
|
2019-09-09 16:58:09 +02:00
|
|
|
|
2019-11-06 19:39:34 +01:00
|
|
|
float stroke_local_mat[4][4];
|
2020-03-01 19:12:30 +01:00
|
|
|
float multiplane_scrape_angle;
|
2019-11-06 19:39:34 +01:00
|
|
|
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
float wet_mix_prev_color[4];
|
|
|
|
float density_seed;
|
|
|
|
|
2017-09-28 01:38:17 +10:00
|
|
|
rcti previous_r; /* previous redraw rectangle */
|
|
|
|
rcti current_r; /* current redraw rectangle */
|
|
|
|
|
|
|
|
} StrokeCache;
|
|
|
|
|
2020-08-17 18:47:00 +02:00
|
|
|
/* Sculpt Filters */
|
|
|
|
typedef enum SculptFilterOrientation {
|
|
|
|
SCULPT_FILTER_ORIENTATION_LOCAL = 0,
|
|
|
|
SCULPT_FILTER_ORIENTATION_WORLD = 1,
|
|
|
|
SCULPT_FILTER_ORIENTATION_VIEW = 2,
|
|
|
|
} SculptFilterOrientation;
|
|
|
|
|
2020-11-26 00:37:56 +01:00
|
|
|
/* Defines how transform tools are going to apply its displacement. */
|
|
|
|
typedef enum SculptTransformDisplacementMode {
|
|
|
|
/* Displaces the elements from their original coordinates. */
|
|
|
|
SCULPT_TRANSFORM_DISPLACEMENT_ORIGINAL = 0,
|
|
|
|
/* Displaces the elements incrementally from their previous position. */
|
|
|
|
SCULPT_TRANSFORM_DISPLACEMENT_INCREMENTAL = 1,
|
|
|
|
} SculptTransformDisplacementMode;
|
|
|
|
|
2020-08-17 18:47:00 +02:00
|
|
|
void SCULPT_filter_to_orientation_space(float r_v[3], struct FilterCache *filter_cache);
|
|
|
|
void SCULPT_filter_to_object_space(float r_v[3], struct FilterCache *filter_cache);
|
2020-09-18 01:17:33 +02:00
|
|
|
void SCULPT_filter_zero_disabled_axis_components(float r_v[3], struct FilterCache *filter_cache);
|
2020-08-17 18:47:00 +02:00
|
|
|
|
Sculpt: Expand Operator
Expand is a new operator for Sculpt Mode which is intended to be the main
tool for masking, Face Set editing, interacting with the filters and pattern
creation.
The fundamentals of the tool are similar to the previous sculpt.mask_expand
operator. It shares the same default shortcuts and functionality, making
the previous operator obsolete.
The shortcuts to execute the operator are:
- Shift + A: Expand mask
- Shift + Alt + A: Expand mask by normals
- Shift + W: Expand Face Set
- Shift + Alt + W: Resize current Face Set
The main changes compared to the previous sculpt.mask_expand operator are:
- Modal keymap, all operator options can be changed in real time while the
operator is running.
- Supports creating Mask, Face Sets and Sculpt Vertex Colors.
- Much better code, new features can be easily integrated.
Limitations:
- All Mask operations are supported for Sculpt Vertex colors, but not exposed
by default as their support is still experimental.
- Dyntopo does not support any Face Set or Sculpt Vertex Colors. functionality
(they are not implemented in general for Dyntopo).
- Multires does not support any feature related to geodesic distances.
- Multires does not support vertex colors.
- Multires does not support recursions.
- In Multires, Face Sets snaping does not initialize all current enabled Face
Sets when toggling snapping.
- In Multires, Face Sets are created at base mesh level (works by this by
design, like any other tool).
- Unlike the previous mask_expand operator, this one does not blur the mask
by default after finishing Expand as that does not fit the new design.
The mask can still be blurred by using the mask filter manually.
Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D10455
2021-03-01 23:37:48 +01:00
|
|
|
/* Sculpt Expand. */
|
|
|
|
typedef enum eSculptExpandFalloffType {
|
|
|
|
SCULPT_EXPAND_FALLOFF_GEODESIC,
|
|
|
|
SCULPT_EXPAND_FALLOFF_TOPOLOGY,
|
|
|
|
SCULPT_EXPAND_FALLOFF_TOPOLOGY_DIAGONALS,
|
|
|
|
SCULPT_EXPAND_FALLOFF_NORMALS,
|
|
|
|
SCULPT_EXPAND_FALLOFF_SPHERICAL,
|
|
|
|
SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY,
|
|
|
|
SCULPT_EXPAND_FALLOFF_BOUNDARY_FACE_SET,
|
|
|
|
SCULPT_EXPAND_FALLOFF_ACTIVE_FACE_SET,
|
|
|
|
} eSculptExpandFalloffType;
|
|
|
|
|
|
|
|
typedef enum eSculptExpandTargetType {
|
|
|
|
SCULPT_EXPAND_TARGET_MASK,
|
|
|
|
SCULPT_EXPAND_TARGET_FACE_SETS,
|
|
|
|
SCULPT_EXPAND_TARGET_COLORS,
|
|
|
|
} eSculptExpandTargetType;
|
|
|
|
|
|
|
|
typedef enum eSculptExpandRecursionType {
|
|
|
|
SCULPT_EXPAND_RECURSION_TOPOLOGY,
|
|
|
|
SCULPT_EXPAND_RECURSION_GEODESICS,
|
|
|
|
} eSculptExpandRecursionType;
|
|
|
|
|
|
|
|
#define EXPAND_SYMM_AREAS 8
|
|
|
|
|
|
|
|
typedef struct ExpandCache {
|
|
|
|
/* Target data elements that the expand operation will affect. */
|
|
|
|
eSculptExpandTargetType target;
|
|
|
|
|
|
|
|
/* Falloff data. */
|
|
|
|
eSculptExpandFalloffType falloff_type;
|
|
|
|
|
|
|
|
/* Indexed by vertex index, precalculated falloff value of that vertex (without any falloff
|
|
|
|
* editing modification applied). */
|
|
|
|
float *vert_falloff;
|
|
|
|
/* Max falloff value in *vert_falloff. */
|
|
|
|
float max_vert_falloff;
|
|
|
|
|
|
|
|
/* Indexed by base mesh poly index, precalculated falloff value of that face. These values are
|
|
|
|
* calculated from the per vertex falloff (*vert_falloff) when needed. */
|
|
|
|
float *face_falloff;
|
|
|
|
float max_face_falloff;
|
|
|
|
|
|
|
|
/* Falloff value of the active element (vertex or base mesh face) that Expand will expand to. */
|
|
|
|
float active_falloff;
|
|
|
|
|
|
|
|
/* When set to true, expand skips all falloff computations and considers all elements as enabled.
|
|
|
|
*/
|
|
|
|
bool all_enabled;
|
|
|
|
|
|
|
|
/* Initial mouse and cursor data from where the current falloff started. This data can be changed
|
|
|
|
* during the execution of Expand by moving the origin. */
|
|
|
|
float initial_mouse_move[2];
|
|
|
|
float initial_mouse[2];
|
|
|
|
int initial_active_vertex;
|
|
|
|
int initial_active_face_set;
|
|
|
|
|
|
|
|
/* Maximum number of vertices allowed in the SculptSession for previewing the falloff using
|
|
|
|
* geodesic distances. */
|
|
|
|
int max_geodesic_move_preview;
|
|
|
|
|
|
|
|
/* Original falloff type before starting the move operation. */
|
|
|
|
eSculptExpandFalloffType move_original_falloff_type;
|
|
|
|
/* Falloff type using when moving the origin for preview. */
|
|
|
|
eSculptExpandFalloffType move_preview_falloff_type;
|
|
|
|
|
|
|
|
/* Face set ID that is going to be used when creating a new Face Set. */
|
|
|
|
int next_face_set;
|
|
|
|
|
|
|
|
/* Face Set ID of the Face set selected for editing. */
|
|
|
|
int update_face_set;
|
|
|
|
|
|
|
|
/* Mouse position since the last time the origin was moved. Used for reference when moving the
|
|
|
|
* initial position of Expand. */
|
|
|
|
float original_mouse_move[2];
|
|
|
|
|
|
|
|
/* Active components checks. */
|
|
|
|
/* Indexed by symmetry pass index, contains the connected component ID found in
|
|
|
|
* SculptSession->vertex_info.connected_component. Other connected components not found in this
|
|
|
|
* array will be ignored by Expand. */
|
|
|
|
int active_connected_components[EXPAND_SYMM_AREAS];
|
|
|
|
|
|
|
|
/* Snapping. */
|
|
|
|
/* GSet containing all Face Sets IDs that Expand will use to snap the new data. */
|
|
|
|
GSet *snap_enabled_face_sets;
|
|
|
|
|
|
|
|
/* Texture distortion data. */
|
|
|
|
Brush *brush;
|
|
|
|
struct Scene *scene;
|
|
|
|
struct MTex *mtex;
|
|
|
|
|
|
|
|
/* Controls how much texture distortion will be applied to the current falloff */
|
|
|
|
float texture_distortion_strength;
|
|
|
|
|
|
|
|
/* Cached PBVH nodes. This allows to skip gathering all nodes from the PBVH each time expand
|
|
|
|
* needs to update the state of the elements. */
|
|
|
|
PBVHNode **nodes;
|
|
|
|
int totnode;
|
|
|
|
|
|
|
|
/* Expand state options. */
|
|
|
|
|
|
|
|
/* Number of loops (times that the falloff is going to be repeated). */
|
|
|
|
int loop_count;
|
|
|
|
|
|
|
|
/* Invert the falloff result. */
|
|
|
|
bool invert;
|
|
|
|
|
|
|
|
/* When set to true, preserves the previous state of the data and adds the new one on top. */
|
|
|
|
bool preserve;
|
|
|
|
|
|
|
|
/* When set to true, the mask or colors will be applied as a gradient. */
|
|
|
|
bool falloff_gradient;
|
|
|
|
|
|
|
|
/* When set to true, Expand will use the Brush falloff curve data to shape the gradient. */
|
|
|
|
bool brush_gradient;
|
|
|
|
|
|
|
|
/* When set to true, Expand will move the origin (initial active vertex and cursor position)
|
|
|
|
* instead of updating the active vertex and active falloff. */
|
|
|
|
bool move;
|
|
|
|
|
|
|
|
/* When set to true, Expand will snap the new data to the Face Sets IDs found in
|
|
|
|
* *original_face_sets. */
|
|
|
|
bool snap;
|
|
|
|
|
|
|
|
/* When set to true, Expand will use the current Face Set ID to modify an existing Face Set
|
|
|
|
* instead of creating a new one. */
|
|
|
|
bool modify_active_face_set;
|
|
|
|
|
|
|
|
/* When set to true, Expand will reposition the sculpt pivot to the boundary of the expand result
|
|
|
|
* after finishing the operation. */
|
|
|
|
bool reposition_pivot;
|
|
|
|
|
|
|
|
/* Color target data type related data. */
|
|
|
|
float fill_color[4];
|
|
|
|
short blend_mode;
|
|
|
|
|
|
|
|
/* Face Sets at the first step of the expand operation, before starting modifying the active
|
|
|
|
* vertex and active falloff. These are not the original Face Sets of the sculpt before starting
|
|
|
|
* the operator as they could have been modified by Expand when initializing the operator and
|
|
|
|
* before starting changing the active vertex. These Face Sets are used for restoring and
|
|
|
|
* checking the Face Sets state while the Expand operation modal runs. */
|
|
|
|
int *initial_face_sets;
|
|
|
|
|
|
|
|
/* Original data of the sculpt as it was before running the Expand operator. */
|
|
|
|
float *original_mask;
|
|
|
|
int *original_face_sets;
|
|
|
|
float (*original_colors)[4];
|
|
|
|
} ExpandCache;
|
|
|
|
|
2019-09-09 15:42:51 +02:00
|
|
|
typedef struct FilterCache {
|
|
|
|
bool enabled_axis[3];
|
2020-08-18 13:27:58 +02:00
|
|
|
bool enabled_force_axis[3];
|
2019-09-09 15:42:51 +02:00
|
|
|
int random_seed;
|
|
|
|
|
2020-03-09 20:03:48 +01:00
|
|
|
/* Used for alternating between filter operations in filters that need to apply different ones to
|
|
|
|
* achieve certain effects. */
|
|
|
|
int iteration_count;
|
|
|
|
|
2020-03-26 16:05:46 +01:00
|
|
|
/* Stores the displacement produced by the laplacian step of HC smooth. */
|
|
|
|
float (*surface_smooth_laplacian_disp)[3];
|
|
|
|
float surface_smooth_shape_preservation;
|
|
|
|
float surface_smooth_current_vertex;
|
|
|
|
|
2020-04-05 02:00:50 +02:00
|
|
|
/* Sharpen mesh filter. */
|
|
|
|
float sharpen_smooth_ratio;
|
2020-08-04 23:42:48 +02:00
|
|
|
float sharpen_intensify_detail_strength;
|
|
|
|
int sharpen_curvature_smooth_iterations;
|
2020-04-05 02:00:50 +02:00
|
|
|
float *sharpen_factor;
|
2020-08-18 16:53:00 +02:00
|
|
|
float (*detail_directions)[3];
|
2020-04-05 02:00:50 +02:00
|
|
|
|
2021-03-12 12:52:23 +11:00
|
|
|
/* Filter orientation. */
|
2020-08-17 18:47:00 +02:00
|
|
|
SculptFilterOrientation orientation;
|
|
|
|
float obmat[4][4];
|
|
|
|
float obmat_inv[4][4];
|
|
|
|
float viewmat[4][4];
|
|
|
|
float viewmat_inv[4][4];
|
|
|
|
|
2020-08-18 15:22:51 +02:00
|
|
|
/* Displacement eraser. */
|
|
|
|
float (*limit_surface_co)[3];
|
|
|
|
|
2019-09-09 15:42:51 +02:00
|
|
|
/* unmasked nodes */
|
|
|
|
PBVHNode **nodes;
|
|
|
|
int totnode;
|
|
|
|
|
2020-06-01 22:36:26 +02:00
|
|
|
/* Cloth filter. */
|
|
|
|
SculptClothSimulation *cloth_sim;
|
|
|
|
float cloth_sim_pinch_point[3];
|
|
|
|
|
2019-09-09 15:42:51 +02:00
|
|
|
/* mask expand iteration caches */
|
|
|
|
int mask_update_current_it;
|
|
|
|
int mask_update_last_it;
|
|
|
|
int *mask_update_it;
|
2019-09-10 15:11:33 +02:00
|
|
|
float *normal_factor;
|
2019-10-08 14:57:37 +02:00
|
|
|
float *edge_factor;
|
2019-09-10 15:11:33 +02:00
|
|
|
float *prev_mask;
|
2019-09-10 19:55:15 +02:00
|
|
|
float mask_expand_initial_co[3];
|
2020-03-05 14:53:23 +01:00
|
|
|
|
|
|
|
int new_face_set;
|
|
|
|
int *prev_face_set;
|
|
|
|
|
|
|
|
int active_face_set;
|
2020-10-15 19:34:54 +02:00
|
|
|
|
2020-11-26 00:37:56 +01:00
|
|
|
/* Transform. */
|
|
|
|
SculptTransformDisplacementMode transform_displacement_mode;
|
|
|
|
|
2020-10-16 11:46:48 +11:00
|
|
|
/* Auto-masking. */
|
2020-10-15 19:34:54 +02:00
|
|
|
AutomaskingCache *automasking;
|
2019-09-09 15:42:51 +02:00
|
|
|
} FilterCache;
|
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
void SCULPT_cache_calc_brushdata_symm(StrokeCache *cache,
|
2017-09-29 22:47:08 +10:00
|
|
|
const char symm,
|
|
|
|
const char axis,
|
|
|
|
const float angle);
|
2020-03-06 15:24:15 +01:00
|
|
|
void SCULPT_cache_free(StrokeCache *cache);
|
2017-09-28 01:38:17 +10:00
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type);
|
|
|
|
SculptUndoNode *SCULPT_undo_get_node(PBVHNode *node);
|
2020-05-06 08:17:27 +10:00
|
|
|
SculptUndoNode *SCULPT_undo_get_first_node(void);
|
2020-11-12 10:41:33 +01:00
|
|
|
void SCULPT_undo_push_begin(struct Object *ob, const char *name);
|
2020-03-06 15:24:15 +01:00
|
|
|
void SCULPT_undo_push_end(void);
|
2020-04-03 02:35:25 +02:00
|
|
|
void SCULPT_undo_push_end_ex(const bool use_nested_undo);
|
2010-07-14 14:11:03 +00:00
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
void SCULPT_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3]);
|
2010-07-14 14:11:03 +00:00
|
|
|
|
2020-03-06 15:24:15 +01:00
|
|
|
void SCULPT_update_object_bounding_box(struct Object *ob);
|
2014-02-04 19:47:17 +06:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
bool SCULPT_get_redraw_rect(struct ARegion *region,
|
|
|
|
struct RegionView3D *rv3d,
|
|
|
|
Object *ob,
|
|
|
|
rcti *rect);
|
2017-09-28 01:38:17 +10:00
|
|
|
|
2020-04-03 21:05:20 +02:00
|
|
|
/* Operators. */
|
2020-04-03 19:16:49 +02:00
|
|
|
|
Sculpt: Expand Operator
Expand is a new operator for Sculpt Mode which is intended to be the main
tool for masking, Face Set editing, interacting with the filters and pattern
creation.
The fundamentals of the tool are similar to the previous sculpt.mask_expand
operator. It shares the same default shortcuts and functionality, making
the previous operator obsolete.
The shortcuts to execute the operator are:
- Shift + A: Expand mask
- Shift + Alt + A: Expand mask by normals
- Shift + W: Expand Face Set
- Shift + Alt + W: Resize current Face Set
The main changes compared to the previous sculpt.mask_expand operator are:
- Modal keymap, all operator options can be changed in real time while the
operator is running.
- Supports creating Mask, Face Sets and Sculpt Vertex Colors.
- Much better code, new features can be easily integrated.
Limitations:
- All Mask operations are supported for Sculpt Vertex colors, but not exposed
by default as their support is still experimental.
- Dyntopo does not support any Face Set or Sculpt Vertex Colors. functionality
(they are not implemented in general for Dyntopo).
- Multires does not support any feature related to geodesic distances.
- Multires does not support vertex colors.
- Multires does not support recursions.
- In Multires, Face Sets snaping does not initialize all current enabled Face
Sets when toggling snapping.
- In Multires, Face Sets are created at base mesh level (works by this by
design, like any other tool).
- Unlike the previous mask_expand operator, this one does not blur the mask
by default after finishing Expand as that does not fit the new design.
The mask can still be blurred by using the mask filter manually.
Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D10455
2021-03-01 23:37:48 +01:00
|
|
|
/* Expand. */
|
|
|
|
void SCULPT_OT_expand(struct wmOperatorType *ot);
|
|
|
|
void sculpt_expand_modal_keymap(struct wmKeyConfig *keyconf);
|
|
|
|
|
2020-09-03 16:15:20 +02:00
|
|
|
/* Gestures. */
|
|
|
|
void SCULPT_OT_face_set_lasso_gesture(struct wmOperatorType *ot);
|
|
|
|
void SCULPT_OT_face_set_box_gesture(struct wmOperatorType *ot);
|
|
|
|
|
2020-09-05 20:06:27 +02:00
|
|
|
void SCULPT_OT_trim_lasso_gesture(struct wmOperatorType *ot);
|
|
|
|
void SCULPT_OT_trim_box_gesture(struct wmOperatorType *ot);
|
|
|
|
|
2020-09-29 22:46:38 +02:00
|
|
|
void SCULPT_OT_project_line_gesture(struct wmOperatorType *ot);
|
|
|
|
|
2020-04-03 21:05:20 +02:00
|
|
|
/* Face Sets. */
|
2020-04-03 19:16:49 +02:00
|
|
|
void SCULPT_OT_face_sets_randomize_colors(struct wmOperatorType *ot);
|
|
|
|
void SCULPT_OT_face_sets_change_visibility(struct wmOperatorType *ot);
|
|
|
|
void SCULPT_OT_face_sets_init(struct wmOperatorType *ot);
|
|
|
|
void SCULPT_OT_face_sets_create(struct wmOperatorType *ot);
|
2020-06-04 00:23:29 +02:00
|
|
|
void SCULPT_OT_face_sets_edit(struct wmOperatorType *ot);
|
2020-04-03 19:16:49 +02:00
|
|
|
|
2020-04-03 21:05:20 +02:00
|
|
|
/* Transform. */
|
2020-04-03 19:42:48 +02:00
|
|
|
void SCULPT_OT_set_pivot_position(struct wmOperatorType *ot);
|
|
|
|
|
2020-04-03 21:05:20 +02:00
|
|
|
/* Mesh Filter. */
|
|
|
|
void SCULPT_OT_mesh_filter(struct wmOperatorType *ot);
|
|
|
|
|
2020-06-01 22:36:26 +02:00
|
|
|
/* Cloth Filter. */
|
|
|
|
void SCULPT_OT_cloth_filter(struct wmOperatorType *ot);
|
|
|
|
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
/* Color Filter. */
|
|
|
|
void SCULPT_OT_color_filter(struct wmOperatorType *ot);
|
|
|
|
|
2020-04-03 21:46:08 +02:00
|
|
|
/* Mask filter and Dirty Mask. */
|
|
|
|
void SCULPT_OT_mask_filter(struct wmOperatorType *ot);
|
|
|
|
void SCULPT_OT_dirty_mask(struct wmOperatorType *ot);
|
|
|
|
|
|
|
|
/* Mask and Face Sets Expand. */
|
|
|
|
void SCULPT_OT_mask_expand(struct wmOperatorType *ot);
|
|
|
|
|
2021-03-12 21:35:56 +01:00
|
|
|
/* Mask Init. */
|
|
|
|
void SCULPT_OT_mask_init(struct wmOperatorType *ot);
|
|
|
|
|
2020-04-03 23:41:54 +02:00
|
|
|
/* Detail size. */
|
|
|
|
void SCULPT_OT_detail_flood_fill(struct wmOperatorType *ot);
|
|
|
|
void SCULPT_OT_sample_detail_size(struct wmOperatorType *ot);
|
|
|
|
void SCULPT_OT_set_detail_size(struct wmOperatorType *ot);
|
2020-12-16 13:13:13 +01:00
|
|
|
void SCULPT_OT_dyntopo_detail_size_edit(struct wmOperatorType *ot);
|
2020-04-03 23:41:54 +02:00
|
|
|
|
|
|
|
/* Dyntopo. */
|
|
|
|
void SCULPT_OT_dynamic_topology_toggle(struct wmOperatorType *ot);
|