2019-07-14 16:49:44 +02: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
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* Copyright 2019, Blender Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* \ingroup draw
|
|
|
|
*/
|
|
|
|
|
2020-08-07 09:50:34 +02:00
|
|
|
#pragma once
|
2019-07-14 16:49:44 +02:00
|
|
|
|
2020-06-02 15:07:17 +02:00
|
|
|
struct TaskGraph;
|
|
|
|
|
2019-07-14 16:49:44 +02:00
|
|
|
/* Vertex Group Selection and display options */
|
|
|
|
typedef struct DRW_MeshWeightState {
|
|
|
|
int defgroup_active;
|
|
|
|
int defgroup_len;
|
|
|
|
|
|
|
|
short flags;
|
|
|
|
char alert_mode;
|
|
|
|
|
|
|
|
/* Set of all selected bones for Multipaint. */
|
|
|
|
bool *defgroup_sel; /* [defgroup_len] */
|
|
|
|
int defgroup_sel_count;
|
2018-10-07 18:25:51 +03:00
|
|
|
|
|
|
|
/* Set of all locked and unlocked deform bones for Lock Relative mode. */
|
|
|
|
bool *defgroup_locked; /* [defgroup_len] */
|
|
|
|
bool *defgroup_unlocked; /* [defgroup_len] */
|
2019-07-14 16:49:44 +02:00
|
|
|
} DRW_MeshWeightState;
|
|
|
|
|
|
|
|
/* DRW_MeshWeightState.flags */
|
|
|
|
enum {
|
|
|
|
DRW_MESH_WEIGHT_STATE_MULTIPAINT = (1 << 0),
|
|
|
|
DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE = (1 << 1),
|
2018-10-07 18:25:51 +03:00
|
|
|
DRW_MESH_WEIGHT_STATE_LOCK_RELATIVE = (1 << 2),
|
2019-07-14 16:49:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct DRW_MeshCDMask {
|
|
|
|
uint32_t uv : 8;
|
|
|
|
uint32_t tan : 8;
|
|
|
|
uint32_t vcol : 8;
|
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
|
|
|
uint32_t sculpt_vcol : 8;
|
2019-07-14 16:49:44 +02:00
|
|
|
uint32_t orco : 1;
|
|
|
|
uint32_t tan_orco : 1;
|
2019-10-08 18:35:57 +02:00
|
|
|
/** Edit uv layer is from the base edit mesh as
|
|
|
|
* modifiers could remove it. (see T68857) */
|
|
|
|
uint32_t edit_uv : 1;
|
2019-07-14 16:49:44 +02:00
|
|
|
} DRW_MeshCDMask;
|
2020-07-06 08:41:28 +02:00
|
|
|
/* Keep `DRW_MeshCDMask` struct within an `uint64_t`.
|
|
|
|
* bit-wise and atomic operations are used to compare and update the struct.
|
|
|
|
* See `mesh_cd_layers_type_*` functions. */
|
|
|
|
BLI_STATIC_ASSERT(sizeof(DRW_MeshCDMask) <= sizeof(uint64_t), "DRW_MeshCDMask exceeds 64 bits")
|
2019-07-14 16:49:44 +02:00
|
|
|
|
|
|
|
typedef enum eMRIterType {
|
|
|
|
MR_ITER_LOOPTRI = 1 << 0,
|
2020-07-01 00:13:39 +10:00
|
|
|
MR_ITER_POLY = 1 << 1,
|
2019-07-14 16:49:44 +02:00
|
|
|
MR_ITER_LEDGE = 1 << 2,
|
|
|
|
MR_ITER_LVERT = 1 << 3,
|
|
|
|
} eMRIterType;
|
|
|
|
|
|
|
|
typedef enum eMRDataType {
|
|
|
|
MR_DATA_POLY_NOR = 1 << 1,
|
|
|
|
MR_DATA_LOOP_NOR = 1 << 2,
|
|
|
|
MR_DATA_LOOPTRI = 1 << 3,
|
|
|
|
/** Force loop normals calculation. */
|
|
|
|
MR_DATA_TAN_LOOP_NOR = 1 << 4,
|
|
|
|
} eMRDataType;
|
|
|
|
|
|
|
|
typedef enum eMRExtractType {
|
|
|
|
MR_EXTRACT_BMESH,
|
|
|
|
MR_EXTRACT_MAPPED,
|
|
|
|
MR_EXTRACT_MESH,
|
|
|
|
} eMRExtractType;
|
|
|
|
|
|
|
|
BLI_INLINE int mesh_render_mat_len_get(Mesh *me)
|
|
|
|
{
|
|
|
|
return MAX2(1, me->totcol);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct MeshBufferCache {
|
|
|
|
/* Every VBO below contains at least enough
|
2019-10-15 01:49:53 +02:00
|
|
|
* data for every loops in the mesh (except fdots and skin roots).
|
2019-07-14 16:49:44 +02:00
|
|
|
* For some VBOs, it extends to (in this exact order) :
|
|
|
|
* loops + loose_edges*2 + loose_verts */
|
|
|
|
struct {
|
|
|
|
GPUVertBuf *pos_nor; /* extend */
|
|
|
|
GPUVertBuf *lnor; /* extend */
|
|
|
|
GPUVertBuf *edge_fac; /* extend */
|
|
|
|
GPUVertBuf *weights; /* extend */
|
2019-08-14 22:43:44 +02:00
|
|
|
GPUVertBuf *uv;
|
|
|
|
GPUVertBuf *tan;
|
2019-07-14 16:49:44 +02:00
|
|
|
GPUVertBuf *vcol;
|
|
|
|
GPUVertBuf *orco;
|
|
|
|
/* Only for edit mode. */
|
|
|
|
GPUVertBuf *edit_data; /* extend */
|
|
|
|
GPUVertBuf *edituv_data;
|
|
|
|
GPUVertBuf *stretch_area;
|
|
|
|
GPUVertBuf *stretch_angle;
|
|
|
|
GPUVertBuf *mesh_analysis;
|
|
|
|
GPUVertBuf *fdots_pos;
|
|
|
|
GPUVertBuf *fdots_nor;
|
|
|
|
GPUVertBuf *fdots_uv;
|
|
|
|
// GPUVertBuf *fdots_edit_data; /* inside fdots_nor for now. */
|
|
|
|
GPUVertBuf *fdots_edituv_data;
|
2019-10-15 01:49:53 +02:00
|
|
|
GPUVertBuf *skin_roots;
|
2019-07-14 16:49:44 +02:00
|
|
|
/* Selection */
|
|
|
|
GPUVertBuf *vert_idx; /* extend */
|
|
|
|
GPUVertBuf *edge_idx; /* extend */
|
|
|
|
GPUVertBuf *poly_idx;
|
|
|
|
GPUVertBuf *fdot_idx;
|
|
|
|
} vbo;
|
|
|
|
/* Index Buffers:
|
|
|
|
* Only need to be updated when topology changes. */
|
|
|
|
struct {
|
|
|
|
/* Indices to vloops. */
|
2019-12-03 08:27:55 +01:00
|
|
|
GPUIndexBuf *tris; /* Ordered per material. */
|
|
|
|
GPUIndexBuf *lines; /* Loose edges last. */
|
|
|
|
GPUIndexBuf *lines_loose; /* sub buffer of `lines` only containing the loose edges. */
|
2019-07-14 16:49:44 +02:00
|
|
|
GPUIndexBuf *points;
|
|
|
|
GPUIndexBuf *fdots;
|
|
|
|
/* 3D overlays. */
|
|
|
|
GPUIndexBuf *lines_paint_mask; /* no loose edges. */
|
|
|
|
GPUIndexBuf *lines_adjacency;
|
|
|
|
/* Uv overlays. (visibility can differ from 3D view) */
|
|
|
|
GPUIndexBuf *edituv_tris;
|
|
|
|
GPUIndexBuf *edituv_lines;
|
|
|
|
GPUIndexBuf *edituv_points;
|
|
|
|
GPUIndexBuf *edituv_fdots;
|
|
|
|
} ibo;
|
|
|
|
} MeshBufferCache;
|
|
|
|
|
|
|
|
typedef enum DRWBatchFlag {
|
|
|
|
MBC_SURFACE = (1 << 0),
|
|
|
|
MBC_SURFACE_WEIGHTS = (1 << 1),
|
|
|
|
MBC_EDIT_TRIANGLES = (1 << 2),
|
|
|
|
MBC_EDIT_VERTICES = (1 << 3),
|
|
|
|
MBC_EDIT_EDGES = (1 << 4),
|
|
|
|
MBC_EDIT_VNOR = (1 << 5),
|
|
|
|
MBC_EDIT_LNOR = (1 << 6),
|
|
|
|
MBC_EDIT_FACEDOTS = (1 << 7),
|
|
|
|
MBC_EDIT_MESH_ANALYSIS = (1 << 8),
|
2019-09-03 13:42:11 +02:00
|
|
|
MBC_EDITUV_FACES_STRETCH_AREA = (1 << 9),
|
|
|
|
MBC_EDITUV_FACES_STRETCH_ANGLE = (1 << 10),
|
2019-07-14 16:49:44 +02:00
|
|
|
MBC_EDITUV_FACES = (1 << 11),
|
|
|
|
MBC_EDITUV_EDGES = (1 << 12),
|
|
|
|
MBC_EDITUV_VERTS = (1 << 13),
|
|
|
|
MBC_EDITUV_FACEDOTS = (1 << 14),
|
|
|
|
MBC_EDIT_SELECTION_VERTS = (1 << 15),
|
|
|
|
MBC_EDIT_SELECTION_EDGES = (1 << 16),
|
|
|
|
MBC_EDIT_SELECTION_FACES = (1 << 17),
|
|
|
|
MBC_EDIT_SELECTION_FACEDOTS = (1 << 18),
|
|
|
|
MBC_ALL_VERTS = (1 << 19),
|
|
|
|
MBC_ALL_EDGES = (1 << 20),
|
|
|
|
MBC_LOOSE_EDGES = (1 << 21),
|
|
|
|
MBC_EDGE_DETECTION = (1 << 22),
|
|
|
|
MBC_WIRE_EDGES = (1 << 23),
|
|
|
|
MBC_WIRE_LOOPS = (1 << 24),
|
|
|
|
MBC_WIRE_LOOPS_UVS = (1 << 25),
|
2020-07-17 13:47:10 +02:00
|
|
|
MBC_SKIN_ROOTS = (1 << 26),
|
2019-07-14 16:49:44 +02:00
|
|
|
} DRWBatchFlag;
|
|
|
|
|
|
|
|
#define MBC_EDITUV \
|
2019-09-03 13:42:11 +02:00
|
|
|
(MBC_EDITUV_FACES_STRETCH_AREA | MBC_EDITUV_FACES_STRETCH_ANGLE | MBC_EDITUV_FACES | \
|
2019-07-14 16:49:44 +02:00
|
|
|
MBC_EDITUV_EDGES | MBC_EDITUV_VERTS | MBC_EDITUV_FACEDOTS | MBC_WIRE_LOOPS_UVS)
|
|
|
|
|
|
|
|
#define FOREACH_MESH_BUFFER_CACHE(batch_cache, mbc) \
|
|
|
|
for (MeshBufferCache *mbc = &batch_cache->final; \
|
|
|
|
mbc == &batch_cache->final || mbc == &batch_cache->cage || mbc == &batch_cache->uv_cage; \
|
|
|
|
mbc = (mbc == &batch_cache->final) ? \
|
|
|
|
&batch_cache->cage : \
|
|
|
|
((mbc == &batch_cache->cage) ? &batch_cache->uv_cage : NULL))
|
|
|
|
|
|
|
|
typedef struct MeshBatchCache {
|
|
|
|
MeshBufferCache final, cage, uv_cage;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
/* Surfaces / Render */
|
|
|
|
GPUBatch *surface;
|
|
|
|
GPUBatch *surface_weights;
|
|
|
|
/* Edit mode */
|
|
|
|
GPUBatch *edit_triangles;
|
|
|
|
GPUBatch *edit_vertices;
|
|
|
|
GPUBatch *edit_edges;
|
|
|
|
GPUBatch *edit_vnor;
|
|
|
|
GPUBatch *edit_lnor;
|
|
|
|
GPUBatch *edit_fdots;
|
|
|
|
GPUBatch *edit_mesh_analysis;
|
2019-10-15 01:49:53 +02:00
|
|
|
GPUBatch *edit_skin_roots;
|
2019-07-14 16:49:44 +02:00
|
|
|
/* Edit UVs */
|
2019-09-03 13:42:11 +02:00
|
|
|
GPUBatch *edituv_faces_stretch_area;
|
|
|
|
GPUBatch *edituv_faces_stretch_angle;
|
2019-07-14 16:49:44 +02:00
|
|
|
GPUBatch *edituv_faces;
|
|
|
|
GPUBatch *edituv_edges;
|
|
|
|
GPUBatch *edituv_verts;
|
|
|
|
GPUBatch *edituv_fdots;
|
|
|
|
/* Edit selection */
|
|
|
|
GPUBatch *edit_selection_verts;
|
|
|
|
GPUBatch *edit_selection_edges;
|
|
|
|
GPUBatch *edit_selection_faces;
|
|
|
|
GPUBatch *edit_selection_fdots;
|
|
|
|
/* Common display / Other */
|
|
|
|
GPUBatch *all_verts;
|
|
|
|
GPUBatch *all_edges;
|
|
|
|
GPUBatch *loose_edges;
|
|
|
|
GPUBatch *edge_detection;
|
|
|
|
GPUBatch *wire_edges; /* Individual edges with face normals. */
|
|
|
|
GPUBatch *wire_loops; /* Loops around faces. no edges between selected faces */
|
|
|
|
GPUBatch *wire_loops_uvs; /* Same as wire_loops but only has uvs. */
|
|
|
|
} batch;
|
|
|
|
|
|
|
|
GPUBatch **surface_per_mat;
|
|
|
|
|
|
|
|
DRWBatchFlag batch_requested;
|
|
|
|
DRWBatchFlag batch_ready;
|
|
|
|
|
|
|
|
/* settings to determine if cache is invalid */
|
|
|
|
int edge_len;
|
|
|
|
int tri_len;
|
|
|
|
int poly_len;
|
|
|
|
int vert_len;
|
|
|
|
int mat_len;
|
|
|
|
bool is_dirty; /* Instantly invalidates cache, skipping mesh check */
|
|
|
|
bool is_editmode;
|
|
|
|
bool is_uvsyncsel;
|
|
|
|
|
|
|
|
struct DRW_MeshWeightState weight_state;
|
|
|
|
|
|
|
|
DRW_MeshCDMask cd_used, cd_needed, cd_used_over_time;
|
|
|
|
|
|
|
|
int lastmatch;
|
|
|
|
|
|
|
|
/* Valid only if edge_detection is up to date. */
|
|
|
|
bool is_manifold;
|
|
|
|
|
2019-09-03 13:42:11 +02:00
|
|
|
/* Total areas for drawing UV Stretching. Contains the summed area in mesh
|
|
|
|
* space (`tot_area`) and the summed area in uv space (`tot_uvarea`).
|
|
|
|
*
|
|
|
|
* Only valid after `DRW_mesh_batch_cache_create_requested` has been called. */
|
|
|
|
float tot_area, tot_uv_area;
|
|
|
|
|
2019-07-14 16:49:44 +02:00
|
|
|
bool no_loose_wire;
|
|
|
|
} MeshBatchCache;
|
|
|
|
|
2020-06-02 15:07:17 +02:00
|
|
|
void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
|
|
|
|
MeshBatchCache *cache,
|
2019-07-14 16:49:44 +02:00
|
|
|
MeshBufferCache mbc,
|
|
|
|
Mesh *me,
|
2020-01-08 22:20:45 +11:00
|
|
|
const bool is_editmode,
|
2020-04-04 11:14:45 +02:00
|
|
|
const bool is_paint_mode,
|
2020-08-25 23:49:55 +10:00
|
|
|
const bool is_mode_active,
|
2020-01-07 14:06:33 +11:00
|
|
|
const float obmat[4][4],
|
2019-07-14 16:49:44 +02:00
|
|
|
const bool do_final,
|
|
|
|
const bool do_uvedit,
|
|
|
|
const bool use_subsurf_fdots,
|
|
|
|
const DRW_MeshCDMask *cd_layer_used,
|
2020-02-19 01:44:52 +01:00
|
|
|
const Scene *scene,
|
2019-07-14 16:49:44 +02:00
|
|
|
const ToolSettings *ts,
|
|
|
|
const bool use_hide);
|