2011-02-18 14:58:08 +01:00
|
|
|
/*
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01: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,
|
2010-02-12 14:34:04 +01:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
*/
|
|
|
|
|
2012-12-30 19:31:31 +01:00
|
|
|
#ifndef __BKE_PBVH_H__
|
|
|
|
#define __BKE_PBVH_H__
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
|
|
|
* \brief A BVH for high poly meshes.
|
2011-02-18 14:58:08 +01:00
|
|
|
*/
|
|
|
|
|
2012-03-14 07:32:25 +01:00
|
|
|
#include "BLI_bitmap.h"
|
2012-12-30 19:28:36 +01:00
|
|
|
#include "BLI_ghash.h"
|
|
|
|
|
2019-10-01 13:02:44 +02:00
|
|
|
/* For embedding CCGKey in iterator. */
|
|
|
|
#include "BKE_ccg.h"
|
|
|
|
|
2019-10-09 16:27:04 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-01-28 11:08:24 +01:00
|
|
|
struct BMLog;
|
|
|
|
struct BMesh;
|
2012-05-10 22:33:09 +02:00
|
|
|
struct CCGElem;
|
|
|
|
struct CCGKey;
|
2012-05-10 22:33:36 +02:00
|
|
|
struct CustomData;
|
2012-03-06 03:40:08 +01:00
|
|
|
struct DMFlagMat;
|
2019-05-14 12:20:01 +02:00
|
|
|
struct GPU_PBVH_Buffers;
|
2019-06-28 02:06:57 +02:00
|
|
|
struct IsectRayPrecalc;
|
2015-07-16 19:36:03 +02:00
|
|
|
struct MLoop;
|
|
|
|
struct MLoopTri;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct MPoly;
|
2012-03-06 03:40:08 +01:00
|
|
|
struct MVert;
|
2019-12-17 00:08:47 +01:00
|
|
|
struct Mesh;
|
2009-10-27 20:53:34 +01:00
|
|
|
struct PBVH;
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
struct PBVHNode;
|
2019-05-31 12:51:12 +02:00
|
|
|
struct SubdivCCG;
|
2020-04-30 07:59:23 +02:00
|
|
|
struct TaskParallelSettings;
|
2020-05-03 05:45:14 +02:00
|
|
|
struct TaskParallelTLS;
|
2009-10-27 20:53:34 +01:00
|
|
|
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
typedef struct PBVH PBVH;
|
|
|
|
typedef struct PBVHNode PBVHNode;
|
2009-10-27 20:53:34 +01:00
|
|
|
|
2010-07-14 16:11:03 +02:00
|
|
|
typedef struct {
|
2019-04-17 06:17:24 +02:00
|
|
|
float (*co)[3];
|
2010-07-14 16:11:03 +02:00
|
|
|
} PBVHProxyNode;
|
|
|
|
|
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
|
|
|
typedef struct {
|
|
|
|
float (*color)[4];
|
|
|
|
} PBVHColorBufferNode;
|
|
|
|
|
2019-05-04 01:39:35 +02:00
|
|
|
typedef enum {
|
2019-09-30 15:56:12 +02:00
|
|
|
PBVH_Leaf = 1 << 0,
|
2019-05-04 01:39:35 +02:00
|
|
|
|
2019-09-30 15:56:12 +02:00
|
|
|
PBVH_UpdateNormals = 1 << 1,
|
|
|
|
PBVH_UpdateBB = 1 << 2,
|
|
|
|
PBVH_UpdateOriginalBB = 1 << 3,
|
|
|
|
PBVH_UpdateDrawBuffers = 1 << 4,
|
|
|
|
PBVH_UpdateRedraw = 1 << 5,
|
|
|
|
PBVH_UpdateMask = 1 << 6,
|
2020-02-06 22:14:18 +01:00
|
|
|
PBVH_UpdateVisibility = 1 << 8,
|
2019-05-04 01:39:35 +02:00
|
|
|
|
2020-02-06 22:14:18 +01:00
|
|
|
PBVH_RebuildDrawBuffers = 1 << 9,
|
|
|
|
PBVH_FullyHidden = 1 << 10,
|
|
|
|
PBVH_FullyMasked = 1 << 11,
|
|
|
|
PBVH_FullyUnmasked = 1 << 12,
|
2019-05-04 01:39:35 +02:00
|
|
|
|
2020-02-06 22:14:18 +01:00
|
|
|
PBVH_UpdateTopology = 1 << 13,
|
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
|
|
|
PBVH_UpdateColor = 1 << 14,
|
2019-05-04 01:39:35 +02:00
|
|
|
} PBVHNodeFlags;
|
|
|
|
|
2019-09-27 14:44:45 +02:00
|
|
|
typedef struct PBVHFrustumPlanes {
|
|
|
|
float (*planes)[4];
|
|
|
|
int num_planes;
|
|
|
|
} PBVHFrustumPlanes;
|
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_set_frustum_planes(PBVH *pbvh, PBVHFrustumPlanes *planes);
|
|
|
|
void BKE_pbvh_get_frustum_planes(PBVH *pbvh, PBVHFrustumPlanes *planes);
|
2020-03-12 17:51:39 +01:00
|
|
|
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
/* Callbacks */
|
2009-10-27 20:53:34 +01:00
|
|
|
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
/* returns 1 if the search should continue from this node, 0 otherwise */
|
2014-02-03 08:55:59 +01:00
|
|
|
typedef bool (*BKE_pbvh_SearchCallback)(PBVHNode *node, void *data);
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
|
2012-12-30 19:31:31 +01:00
|
|
|
typedef void (*BKE_pbvh_HitCallback)(PBVHNode *node, void *data);
|
|
|
|
typedef void (*BKE_pbvh_HitOccludedCallback)(PBVHNode *node, void *data, float *tmin);
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
|
2017-10-05 12:16:25 +02:00
|
|
|
typedef void (*BKE_pbvh_SearchNearestCallback)(PBVHNode *node, void *data, float *tmin);
|
|
|
|
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
/* Building */
|
|
|
|
|
2012-12-30 19:31:31 +01:00
|
|
|
PBVH *BKE_pbvh_new(void);
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_build_mesh(PBVH *pbvh,
|
2019-10-09 19:03:57 +02:00
|
|
|
const struct Mesh *mesh,
|
2019-04-17 06:17:24 +02:00
|
|
|
const struct MPoly *mpoly,
|
|
|
|
const struct MLoop *mloop,
|
|
|
|
struct MVert *verts,
|
|
|
|
int totvert,
|
|
|
|
struct CustomData *vdata,
|
2019-04-16 14:00:16 +02:00
|
|
|
struct CustomData *ldata,
|
2020-03-05 14:53:23 +01:00
|
|
|
struct CustomData *pdata,
|
2019-04-17 06:17:24 +02:00
|
|
|
const struct MLoopTri *looptri,
|
|
|
|
int looptri_num);
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_build_grids(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
struct CCGElem **grid_elems,
|
2015-05-27 19:52:12 +02:00
|
|
|
int totgrid,
|
2019-04-17 06:17:24 +02:00
|
|
|
struct CCGKey *key,
|
|
|
|
void **gridfaces,
|
|
|
|
struct DMFlagMat *flagmats,
|
2012-05-11 10:05:47 +02:00
|
|
|
unsigned int **grid_hidden);
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_build_bmesh(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
struct BMesh *bm,
|
|
|
|
bool smooth_shading,
|
|
|
|
struct BMLog *log,
|
|
|
|
const int cd_vert_node_offset,
|
|
|
|
const int cd_face_node_offset);
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_free(PBVH *pbvh);
|
2009-10-27 20:53:34 +01:00
|
|
|
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
/* Hierarchical Search in the BVH, two methods:
|
2012-03-03 21:19:11 +01:00
|
|
|
* - for each hit calling a callback
|
|
|
|
* - gather nodes in an array (easy to multithread) */
|
2009-10-27 20:53:34 +01:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_search_callback(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_pbvh_SearchCallback scb,
|
|
|
|
void *search_data,
|
|
|
|
BKE_pbvh_HitCallback hcb,
|
|
|
|
void *hit_data);
|
2009-10-27 20:53:34 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void BKE_pbvh_search_gather(
|
2020-05-31 00:12:57 +02:00
|
|
|
PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode ***array, int *tot);
|
2009-10-27 20:53:34 +01:00
|
|
|
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
/* Raycast
|
2012-03-03 21:19:11 +01:00
|
|
|
* the hit callback is called for all leaf nodes intersecting the ray;
|
|
|
|
* it's up to the callback to find the primitive within the leaves that is
|
|
|
|
* hit first */
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_raycast(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_pbvh_HitOccludedCallback cb,
|
|
|
|
void *data,
|
|
|
|
const float ray_start[3],
|
|
|
|
const float ray_normal[3],
|
|
|
|
bool original);
|
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
bool BKE_pbvh_node_raycast(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
PBVHNode *node,
|
|
|
|
float (*origco)[3],
|
|
|
|
bool use_origco,
|
|
|
|
const float ray_start[3],
|
2019-08-30 16:27:31 +02:00
|
|
|
const float ray_normal[3],
|
2019-06-17 14:16:13 +02:00
|
|
|
struct IsectRayPrecalc *isect_precalc,
|
2019-08-30 16:27:31 +02:00
|
|
|
float *depth,
|
|
|
|
int *active_vertex_index,
|
2020-04-01 17:51:59 +02:00
|
|
|
int *active_face_grid_index,
|
2019-08-30 16:27:31 +02:00
|
|
|
float *face_normal);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node,
|
|
|
|
const float ray_start[3],
|
2019-06-17 14:16:13 +02:00
|
|
|
struct IsectRayPrecalc *isect_precalc,
|
2019-04-17 06:17:24 +02:00
|
|
|
float *depth,
|
|
|
|
float *r_edge_length);
|
2014-03-22 22:35:07 +01:00
|
|
|
|
2013-12-18 17:34:02 +01:00
|
|
|
/* for orthographic cameras, project the far away ray segment points to the root node so
|
2013-12-18 17:36:07 +01:00
|
|
|
* we can have better precision. */
|
2015-04-30 00:07:15 +02:00
|
|
|
void BKE_pbvh_raycast_project_ray_root(
|
2020-05-31 00:12:57 +02:00
|
|
|
PBVH *pbvh, bool original, float ray_start[3], float ray_end[3], float ray_normal[3]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_find_nearest_to_ray(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_pbvh_HitOccludedCallback cb,
|
|
|
|
void *data,
|
|
|
|
const float ray_start[3],
|
|
|
|
const float ray_normal[3],
|
|
|
|
bool original);
|
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
bool BKE_pbvh_node_find_nearest_to_ray(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
PBVHNode *node,
|
|
|
|
float (*origco)[3],
|
|
|
|
bool use_origco,
|
|
|
|
const float ray_start[3],
|
|
|
|
const float ray_normal[3],
|
|
|
|
float *depth,
|
|
|
|
float *dist_sq);
|
2017-10-05 12:16:25 +02:00
|
|
|
|
2009-11-25 14:40:43 +01:00
|
|
|
/* Drawing */
|
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_draw_cb(PBVH *pbvh,
|
2019-09-29 02:27:53 +02:00
|
|
|
bool update_only_visible,
|
2020-03-12 17:51:39 +01:00
|
|
|
PBVHFrustumPlanes *update_frustum,
|
|
|
|
PBVHFrustumPlanes *draw_frustum,
|
2019-05-04 01:39:35 +02:00
|
|
|
void (*draw_fn)(void *user_data, struct GPU_PBVH_Buffers *buffers),
|
2019-04-17 06:17:24 +02:00
|
|
|
void *user_data);
|
2009-10-27 20:53:34 +01:00
|
|
|
|
2019-05-04 01:39:35 +02:00
|
|
|
void BKE_pbvh_draw_debug_cb(
|
2020-05-31 00:12:57 +02:00
|
|
|
PBVH *pbvh,
|
2019-05-04 01:39:35 +02:00
|
|
|
void (*draw_fn)(void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag),
|
|
|
|
void *user_data);
|
|
|
|
|
2012-03-13 00:03:43 +01:00
|
|
|
/* PBVH Access */
|
|
|
|
typedef enum {
|
2019-04-17 06:17:24 +02:00
|
|
|
PBVH_FACES,
|
|
|
|
PBVH_GRIDS,
|
|
|
|
PBVH_BMESH,
|
2012-03-13 00:03:43 +01:00
|
|
|
} PBVHType;
|
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
PBVHType BKE_pbvh_type(const PBVH *pbvh);
|
|
|
|
bool BKE_pbvh_has_faces(const PBVH *pbvh);
|
2012-03-13 00:03:43 +01:00
|
|
|
|
2013-01-20 01:19:57 +01:00
|
|
|
/* Get the PBVH root's bounding box */
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_bounding_box(const PBVH *pbvh, float min[3], float max[3]);
|
2013-01-20 01:19:57 +01:00
|
|
|
|
2012-03-14 07:32:03 +01:00
|
|
|
/* multires hidden data, only valid for type == PBVH_GRIDS */
|
2020-05-31 00:12:57 +02:00
|
|
|
unsigned int **BKE_pbvh_grid_hidden(const PBVH *pbvh);
|
2012-03-14 07:32:03 +01:00
|
|
|
|
2014-05-05 21:21:30 +02:00
|
|
|
int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
|
2020-07-13 11:27:09 +02:00
|
|
|
const int *grid_indices,
|
2019-04-17 06:17:24 +02:00
|
|
|
int totgrid,
|
2014-05-06 22:11:28 +02:00
|
|
|
int gridsize);
|
2014-05-05 21:21:30 +02:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_sync_face_sets_to_grids(PBVH *pbvh);
|
2020-04-01 01:03:20 +02:00
|
|
|
|
2012-05-10 22:33:09 +02:00
|
|
|
/* multires level, only valid for type == PBVH_GRIDS */
|
2019-10-01 13:02:44 +02:00
|
|
|
const struct CCGKey *BKE_pbvh_get_grid_key(const PBVH *pbvh);
|
2012-05-10 22:33:09 +02:00
|
|
|
|
2019-09-30 16:33:04 +02:00
|
|
|
struct CCGElem **BKE_pbvh_get_grids(const PBVH *pbvh);
|
2020-05-30 22:56:04 +02:00
|
|
|
BLI_bitmap **BKE_pbvh_get_grid_visibility(const PBVH *pbvh);
|
2019-09-30 16:33:04 +02:00
|
|
|
int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh);
|
2018-09-14 10:56:54 +02:00
|
|
|
|
2012-12-30 19:28:36 +01:00
|
|
|
/* Only valid for type == PBVH_BMESH */
|
2013-05-30 04:16:22 +02:00
|
|
|
struct BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh);
|
2012-12-30 19:31:31 +01:00
|
|
|
void BKE_pbvh_bmesh_detail_size_set(PBVH *pbvh, float detail_size);
|
2012-12-30 19:28:36 +01:00
|
|
|
|
|
|
|
typedef enum {
|
2019-04-17 06:17:24 +02:00
|
|
|
PBVH_Subdivide = 1,
|
|
|
|
PBVH_Collapse = 2,
|
2012-12-30 19:28:36 +01:00
|
|
|
} PBVHTopologyUpdateMode;
|
2020-05-31 00:12:57 +02:00
|
|
|
bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
PBVHTopologyUpdateMode mode,
|
|
|
|
const float center[3],
|
|
|
|
const float view_normal[3],
|
|
|
|
float radius,
|
|
|
|
const bool use_frontface,
|
|
|
|
const bool use_projected);
|
2012-12-30 19:28:36 +01:00
|
|
|
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
/* Node Access */
|
2009-10-27 20:53:34 +01:00
|
|
|
|
2012-12-30 19:31:31 +01:00
|
|
|
void BKE_pbvh_node_mark_update(PBVHNode *node);
|
2019-09-30 15:56:12 +02:00
|
|
|
void BKE_pbvh_node_mark_update_mask(PBVHNode *node);
|
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 BKE_pbvh_node_mark_update_color(PBVHNode *node);
|
2020-03-05 14:53:23 +01:00
|
|
|
void BKE_pbvh_node_mark_update_visibility(PBVHNode *node);
|
2012-12-30 19:31:31 +01:00
|
|
|
void BKE_pbvh_node_mark_rebuild_draw(PBVHNode *node);
|
2013-11-15 22:00:15 +01:00
|
|
|
void BKE_pbvh_node_mark_redraw(PBVHNode *node);
|
2014-05-29 04:22:44 +02:00
|
|
|
void BKE_pbvh_node_mark_normals_update(PBVHNode *node);
|
2012-12-30 19:31:31 +01:00
|
|
|
void BKE_pbvh_node_mark_topology_update(PBVHNode *node);
|
2013-11-15 22:00:15 +01:00
|
|
|
void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden);
|
2020-07-08 18:10:31 +02:00
|
|
|
bool BKE_pbvh_node_fully_hidden_get(PBVHNode *node);
|
2019-09-30 15:56:12 +02:00
|
|
|
void BKE_pbvh_node_fully_masked_set(PBVHNode *node, int fully_masked);
|
|
|
|
bool BKE_pbvh_node_fully_masked_get(PBVHNode *node);
|
|
|
|
void BKE_pbvh_node_fully_unmasked_set(PBVHNode *node, int fully_masked);
|
|
|
|
bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node);
|
2009-10-27 20:53:34 +01:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_node_get_grids(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
PBVHNode *node,
|
|
|
|
int **grid_indices,
|
|
|
|
int *totgrid,
|
|
|
|
int *maxgrid,
|
|
|
|
int *gridsize,
|
|
|
|
struct CCGElem ***grid_elems);
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_node_num_verts(PBVH *pbvh, PBVHNode *node, int *r_uniquevert, int *r_totvert);
|
|
|
|
void BKE_pbvh_node_get_verts(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
PBVHNode *node,
|
|
|
|
const int **r_vert_indices,
|
|
|
|
struct MVert **r_verts);
|
2009-11-25 14:40:43 +01:00
|
|
|
|
2013-03-26 08:29:01 +01:00
|
|
|
void BKE_pbvh_node_get_BB(PBVHNode *node, float bb_min[3], float bb_max[3]);
|
|
|
|
void BKE_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max[3]);
|
2009-10-27 20:53:34 +01:00
|
|
|
|
2012-12-30 19:31:31 +01:00
|
|
|
float BKE_pbvh_node_get_tmin(PBVHNode *node);
|
2010-07-14 16:11:03 +02:00
|
|
|
|
2019-09-27 14:44:45 +02:00
|
|
|
/* test if AABB is at least partially inside the PBVHFrustumPlanes volume */
|
|
|
|
bool BKE_pbvh_node_frustum_contain_AABB(PBVHNode *node, void *frustum);
|
|
|
|
/* test if AABB is at least partially outside the PBVHFrustumPlanes volume */
|
|
|
|
bool BKE_pbvh_node_frustum_exclude_AABB(PBVHNode *node, void *frustum);
|
2012-03-14 07:32:25 +01:00
|
|
|
|
2013-08-25 22:03:45 +02:00
|
|
|
struct GSet *BKE_pbvh_bmesh_node_unique_verts(PBVHNode *node);
|
|
|
|
struct GSet *BKE_pbvh_bmesh_node_other_verts(PBVHNode *node);
|
2014-04-10 21:31:39 +02:00
|
|
|
struct GSet *BKE_pbvh_bmesh_node_faces(PBVHNode *node);
|
2019-11-08 02:13:23 +01:00
|
|
|
void BKE_pbvh_bmesh_node_save_orig(struct BMesh *bm, PBVHNode *node);
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_bmesh_after_stroke(PBVH *pbvh);
|
2012-12-30 19:28:36 +01:00
|
|
|
|
2019-05-31 12:51:12 +02:00
|
|
|
/* Update Bounding Box/Redraw and clear flags */
|
2009-10-27 20:53:34 +01:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_update_bounds(PBVH *pbvh, int flags);
|
|
|
|
void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flags);
|
|
|
|
void BKE_pbvh_update_visibility(PBVH *pbvh);
|
|
|
|
void BKE_pbvh_update_normals(PBVH *pbvh, struct SubdivCCG *subdiv_ccg);
|
|
|
|
void BKE_pbvh_redraw_BB(PBVH *pbvh, float bb_min[3], float bb_max[3]);
|
|
|
|
void BKE_pbvh_get_grid_updates(PBVH *pbvh, bool clear, void ***r_gridfaces, int *r_totface);
|
|
|
|
void BKE_pbvh_grids_update(PBVH *pbvh,
|
2019-04-17 06:17:24 +02:00
|
|
|
struct CCGElem **grid_elems,
|
2015-05-27 19:52:12 +02:00
|
|
|
void **gridfaces,
|
2019-04-17 06:17:24 +02:00
|
|
|
struct DMFlagMat *flagmats,
|
|
|
|
unsigned int **grid_hidden);
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_subdiv_cgg_set(PBVH *pbvh, struct SubdivCCG *subdiv_ccg);
|
|
|
|
void BKE_pbvh_face_sets_set(PBVH *pbvh, int *face_sets);
|
2009-11-25 14:40:43 +01:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_face_sets_color_set(PBVH *pbvh, int seed, int color_default);
|
2020-03-05 14:53:23 +01:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void BKE_pbvh_respect_hide_set(PBVH *pbvh, bool respect_hide);
|
2020-05-19 09:53:26 +02:00
|
|
|
|
2010-06-21 22:10:59 +02:00
|
|
|
/* vertex deformer */
|
2019-08-21 22:28:35 +02:00
|
|
|
float (*BKE_pbvh_vert_coords_alloc(struct PBVH *pbvh))[3];
|
|
|
|
void BKE_pbvh_vert_coords_apply(struct PBVH *pbvh, const float (*vertCos)[3], const int totvert);
|
|
|
|
bool BKE_pbvh_is_deformed(struct PBVH *pbvh);
|
2010-06-21 22:10:59 +02:00
|
|
|
|
2009-11-25 14:40:43 +01:00
|
|
|
/* Vertex Iterator */
|
|
|
|
|
|
|
|
/* this iterator has quite a lot of code, but it's designed to:
|
2012-03-03 21:19:11 +01:00
|
|
|
* - allow the compiler to eliminate dead code and variables
|
|
|
|
* - spend most of the time in the relatively simple inner loop */
|
2009-11-25 14:40:43 +01:00
|
|
|
|
2012-03-14 07:32:25 +01:00
|
|
|
/* note: PBVH_ITER_ALL does not skip hidden vertices,
|
2012-04-22 13:54:53 +02:00
|
|
|
* PBVH_ITER_UNIQUE does */
|
2019-04-17 06:17:24 +02:00
|
|
|
#define PBVH_ITER_ALL 0
|
|
|
|
#define PBVH_ITER_UNIQUE 1
|
2009-11-25 14:40:43 +01:00
|
|
|
|
|
|
|
typedef struct PBVHVertexIter {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* iteration */
|
|
|
|
int g;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int gx;
|
|
|
|
int gy;
|
|
|
|
int i;
|
2019-08-14 22:54:23 +02:00
|
|
|
int index;
|
2020-05-19 09:53:26 +02:00
|
|
|
bool respect_hide;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* grid */
|
2019-10-01 13:02:44 +02:00
|
|
|
struct CCGKey key;
|
2019-04-17 06:17:24 +02:00
|
|
|
struct CCGElem **grids;
|
|
|
|
struct CCGElem *grid;
|
|
|
|
BLI_bitmap **grid_hidden, *gh;
|
|
|
|
int *grid_indices;
|
|
|
|
int totgrid;
|
|
|
|
int gridsize;
|
|
|
|
|
|
|
|
/* mesh */
|
|
|
|
struct MVert *mverts;
|
|
|
|
int totvert;
|
|
|
|
const int *vert_indices;
|
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
|
|
|
struct MPropCol *vcol;
|
2019-04-17 06:17:24 +02:00
|
|
|
float *vmask;
|
|
|
|
|
|
|
|
/* bmesh */
|
|
|
|
struct GSetIterator bm_unique_verts;
|
|
|
|
struct GSetIterator bm_other_verts;
|
|
|
|
struct CustomData *bm_vdata;
|
|
|
|
int cd_vert_mask_offset;
|
|
|
|
|
|
|
|
/* result: these are all computed in the macro, but we assume
|
|
|
|
* that compiler optimization's will skip the ones we don't use */
|
|
|
|
struct MVert *mvert;
|
|
|
|
struct BMVert *bm_vert;
|
|
|
|
float *co;
|
|
|
|
short *no;
|
|
|
|
float *fno;
|
|
|
|
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
|
|
|
float *col;
|
2020-03-05 14:53:23 +01:00
|
|
|
bool visible;
|
2009-11-25 14:40:43 +01:00
|
|
|
} PBVHVertexIter;
|
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int mode);
|
2012-02-22 23:37:01 +01:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
#define BKE_pbvh_vertex_iter_begin(pbvh, node, vi, mode) \
|
|
|
|
pbvh_vertex_iter_init(pbvh, node, &vi, mode); \
|
2019-04-17 06:17:24 +02:00
|
|
|
\
|
|
|
|
for (vi.i = 0, vi.g = 0; vi.g < vi.totgrid; vi.g++) { \
|
|
|
|
if (vi.grids) { \
|
|
|
|
vi.width = vi.gridsize; \
|
|
|
|
vi.height = vi.gridsize; \
|
2019-09-30 16:33:04 +02:00
|
|
|
vi.index = vi.grid_indices[vi.g] * vi.key.grid_area - 1; \
|
2019-04-17 06:17:24 +02:00
|
|
|
vi.grid = vi.grids[vi.grid_indices[vi.g]]; \
|
|
|
|
if (mode == PBVH_ITER_UNIQUE) \
|
|
|
|
vi.gh = vi.grid_hidden[vi.grid_indices[vi.g]]; \
|
|
|
|
} \
|
|
|
|
else { \
|
|
|
|
vi.width = vi.totvert; \
|
|
|
|
vi.height = 1; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
for (vi.gy = 0; vi.gy < vi.height; vi.gy++) { \
|
|
|
|
for (vi.gx = 0; vi.gx < vi.width; vi.gx++, vi.i++) { \
|
|
|
|
if (vi.grid) { \
|
2019-10-01 13:02:44 +02:00
|
|
|
vi.co = CCG_elem_co(&vi.key, vi.grid); \
|
|
|
|
vi.fno = CCG_elem_no(&vi.key, vi.grid); \
|
|
|
|
vi.mask = vi.key.has_mask ? CCG_elem_mask(&vi.key, vi.grid) : NULL; \
|
|
|
|
vi.grid = CCG_elem_next(&vi.key, vi.grid); \
|
2019-09-30 16:33:04 +02:00
|
|
|
vi.index++; \
|
2020-03-05 14:53:23 +01:00
|
|
|
vi.visible = true; \
|
2019-04-17 06:17:24 +02:00
|
|
|
if (vi.gh) { \
|
|
|
|
if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) \
|
|
|
|
continue; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
else if (vi.mverts) { \
|
|
|
|
vi.mvert = &vi.mverts[vi.vert_indices[vi.gx]]; \
|
2020-05-19 09:53:26 +02:00
|
|
|
if (vi.respect_hide) { \
|
|
|
|
vi.visible = !(vi.mvert->flag & ME_HIDE); \
|
|
|
|
if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \
|
|
|
|
continue; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
else { \
|
|
|
|
BLI_assert(vi.visible); \
|
|
|
|
} \
|
2019-04-17 06:17:24 +02:00
|
|
|
vi.co = vi.mvert->co; \
|
|
|
|
vi.no = vi.mvert->no; \
|
2019-08-14 22:54:23 +02:00
|
|
|
vi.index = vi.vert_indices[vi.i]; \
|
2019-04-17 06:17:24 +02:00
|
|
|
if (vi.vmask) \
|
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
|
|
|
vi.mask = &vi.vmask[vi.index]; \
|
|
|
|
if (vi.vcol) \
|
|
|
|
vi.col = vi.vcol[vi.index].color; \
|
2019-04-17 06:17:24 +02:00
|
|
|
} \
|
|
|
|
else { \
|
|
|
|
if (!BLI_gsetIterator_done(&vi.bm_unique_verts)) { \
|
|
|
|
vi.bm_vert = BLI_gsetIterator_getKey(&vi.bm_unique_verts); \
|
|
|
|
BLI_gsetIterator_step(&vi.bm_unique_verts); \
|
|
|
|
} \
|
|
|
|
else { \
|
|
|
|
vi.bm_vert = BLI_gsetIterator_getKey(&vi.bm_other_verts); \
|
|
|
|
BLI_gsetIterator_step(&vi.bm_other_verts); \
|
|
|
|
} \
|
2020-03-05 14:53:23 +01:00
|
|
|
vi.visible = !BM_elem_flag_test_bool(vi.bm_vert, BM_ELEM_HIDDEN); \
|
|
|
|
if (mode == PBVH_ITER_UNIQUE && !vi.visible) \
|
2019-04-17 06:17:24 +02:00
|
|
|
continue; \
|
|
|
|
vi.co = vi.bm_vert->co; \
|
|
|
|
vi.fno = vi.bm_vert->no; \
|
2019-08-14 22:54:23 +02:00
|
|
|
vi.index = BM_elem_index_get(vi.bm_vert); \
|
2019-04-17 06:17:24 +02:00
|
|
|
vi.mask = BM_ELEM_CD_GET_VOID_P(vi.bm_vert, vi.cd_vert_mask_offset); \
|
|
|
|
}
|
2009-11-25 14:40:43 +01:00
|
|
|
|
2012-12-30 19:31:31 +01:00
|
|
|
#define BKE_pbvh_vertex_iter_end \
|
2019-04-17 06:17:24 +02:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
((void)0)
|
2009-11-25 14:40:43 +01:00
|
|
|
|
2012-12-30 19:31:31 +01:00
|
|
|
void BKE_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count);
|
|
|
|
void BKE_pbvh_node_free_proxies(PBVHNode *node);
|
2020-05-31 00:12:57 +02:00
|
|
|
PBVHProxyNode *BKE_pbvh_node_add_proxy(PBVH *pbvh, PBVHNode *node);
|
2019-04-17 06:17:24 +02:00
|
|
|
void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***nodes, int *totnode);
|
|
|
|
void BKE_pbvh_node_get_bm_orco_data(PBVHNode *node,
|
|
|
|
int (**r_orco_tris)[3],
|
|
|
|
int *r_orco_tris_num,
|
|
|
|
float (**r_orco_coords)[3]);
|
2010-07-14 16:11:03 +02:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node);
|
2016-02-13 07:58:44 +01:00
|
|
|
|
2019-05-01 03:09:22 +02:00
|
|
|
// void BKE_pbvh_node_BB_reset(PBVHNode *node);
|
|
|
|
// void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3]);
|
Sculpt: Multithreading & PBVH Changes
* Sculpting, normal update and bounding box code is now multithreaded
using OpenMP.
* Fix a number of update issues: normals on node boundaries, outdated
bounding boxes, partial redraw, .. . There's probably still a few
left, but should be better now.
* Clicking once now does a single paint instead of two (was also
painting on mouse up event).
* Smooth shading now is enabled for the full mesh when the first face
uses it (so it can be tested at least).
Implementation Notes:
* PBVH search can now be done either using a callback or bt gathering the
nodes in an array. The latter makes multithreading with OpenMP easier.
* Normals update code is now inside PBVH, was doing it per node before but
should do all faces first and only then vertices.
* Instead of using search modes + 1 modified flag, now nodes get 4 flags
to indicate what needs to be updated for them, found that this makes it
easier for me to understand the code and fix update bugs.
* PBVHNode is now exposed as an abstract type, I think this makes it more
clear what is happening than having it's data passed as part of callback
functions.
* Active_verts list was replaced by looping over nodes and the vertices
inside them. However the grab brush still uses the active_verts system,
will fix that later.
* Some micro-optimizations, like avoiding a few multiplications/divisions,
using local variables instead of pointers, or looping over fewer vertices
to update the bounding boxes.
2009-11-02 19:47:03 +01:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
bool pbvh_has_mask(PBVH *pbvh);
|
|
|
|
void pbvh_show_mask_set(PBVH *pbvh, bool show_mask);
|
2012-10-22 19:33:53 +02:00
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
bool pbvh_has_face_sets(PBVH *pbvh);
|
|
|
|
void pbvh_show_face_sets_set(PBVH *pbvh, bool show_face_sets);
|
2020-03-05 14:53:23 +01:00
|
|
|
|
2019-10-09 16:27:04 +02:00
|
|
|
/* Parallelization */
|
2020-04-30 07:59:23 +02:00
|
|
|
void BKE_pbvh_parallel_range_settings(struct TaskParallelSettings *settings,
|
2019-10-09 16:27:04 +02:00
|
|
|
bool use_threading,
|
|
|
|
int totnode);
|
|
|
|
|
2020-05-31 00:12:57 +02:00
|
|
|
struct MVert *BKE_pbvh_get_verts(const PBVH *pbvh);
|
2020-02-28 15:58:04 +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
|
|
|
PBVHColorBufferNode *BKE_pbvh_node_color_buffer_get(PBVHNode *node);
|
|
|
|
void BKE_pbvh_node_color_buffer_free(PBVH *pbvh);
|
|
|
|
|
2019-10-09 16:27:04 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-12-30 19:31:31 +01:00
|
|
|
#endif /* __BKE_PBVH_H__ */
|