Commit Graph

104 Commits

Author SHA1 Message Date
Pablo Dobarro 38d6533f21 Sculpt Face Sets
Face Sets are the new system to control the visibility state of the mesh in sculpt and paint modes. They are designed to work in modes where brushes are the primary way of interaction and they provide much more control when working with meshes with complex shapes and overlapping surfaces.

This initial commit includes:
- Sculpt Face Sets data structures and PBVH rendering.
- Face Set overlay and opacity controls.
- Sculpt Undo support.
- Remesher reprojection support. The visibility state of the mesh is also preserved when remeshing.
- Automasking and Mesh filter support.
- Mask expand operator mode to expand Face Sets (Shift + W) and flood fill areas by connectivity (press Ctrl while expanding).
- Sculpt Mode Face Sets and Visibility API.
- Sculpt Face Sets creation and visibility management operators.
- Operator to randomize the Face Sets colors.
- Draw Face Sets brush tool to create and edit the Face Sets. Drawing on the mesh creates a new Face Set. Pressing Ctrl before drawing modifies the Face Set under the brush at the beginning of the stroke.
- Updated keymap and menu to work with Face Sets from Sculpt Mode (H to toggle visibility, Alt + H to show all, Shit + H to hide).
- Pie menu on the W key with Face common Sets operations.

Know limitations:
- Multires support. The Face Sets and Visibility API needs to be implemented for Multires.

Reviewed By: jbakker, #user_interface, Severin

Differential Revision: https://developer.blender.org/D6070
2020-03-05 21:07:20 +01:00
Campbell Barton 5dcb6fb22f Cleanup: unused enums 2020-02-20 12:19:55 +11:00
Campbell Barton 96ebdbc90f Fix deprecated DNA define checks
Also remove dead code which checked for SPACE_TIME.
2019-12-17 09:49:23 +11:00
Campbell Barton 249f4423ee Cleanup: doxygen comments
Also correct some outdated symbol references,
add missing 'name' commands.
2019-11-25 01:51:11 +11:00
Brecht Van Lommel 490f966af5 Fix multires modifier using too much memory outside of sculpt mode
This reduce memory usage by about 25% in object mode for multires meshes.
2019-08-27 18:22:29 +02:00
Campbell Barton 760dbd1cbf Cleanup: misc spelling fixes
T68035 by @luzpaz
2019-08-01 14:02:41 +10:00
Bastien Montagne c441448359 Fix T66369: Excessive WARN messages in console when opening older files
CDData checking on file load was not taking into account deprecated
CD_MTEXPOLY datatype, which unfortunately shows same weird glitch as
CD_PAINT_MASK and CD_FACEMAP ones...

Note that it was annoying (due to amount of warnings in console), but
totally harmless, since that data type is just deleted anyway.

This commit also generally cleans up the CD_MTEXPOLY deprecation code, we
have a system to handle that, let's use it, instead of defining local
static values to replace it...
2019-07-03 16:05:31 +02:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Brecht Van Lommel 489c015e70 Fix T62891: particle even distribution is not even.
CD_ORCO coordinates are stored normalized by convention, this code path did
not store them correctly.
2019-03-25 14:28:29 +01:00
Bastien Montagne ab0bc65c24 Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.

Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!

As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).

Reviewers: brecht, campbellbarton, sergey

Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:29:50 +01:00
Campbell Barton 6a03199b50 Cleanup: use '_pad' convention for padding in all DNA structs
Avoids mixing these in with regular variables in code-completion.

Use char for pad members except for 'void *', to make size clearer.

Removed/shrink a few redundant padding vars which were >= 8 bytes.
2019-02-27 15:09:48 +11:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton 88a80fcec8 Cleanup: commas at the end of enums
Without this clang-format may wrap them onto a single line.
2019-01-16 00:03:03 +11:00
Campbell Barton 5a43406e1b Cleanup: move DNA comments before struct members
Needed for clang-format in some cases, see: T53211
2019-01-08 00:43:00 +11:00
Campbell Barton d888453244 Face Maps: custom-data, UI and RNA API
Add face maps, needed for face-map widgets,
only data structure, widgets will be separate commit.

This comes from 'custom-manipulator' branch with only minor changes.
2017-05-30 18:05:59 +10:00
Campbell Barton bdbf4471a6 TexFace removal part 3
- MTexPoly structure & layer type.
- The 'Mesh.uv_textures' layers.
- DerivedMesh TexFace drawing.
- Scripts & UI.
2017-05-25 15:19:58 +10:00
Sergey Sharybin a830280688 Support Vertex Color in GLSL viewport for Cycles
The title says it all actually.

Added special custom data type, because we don't know in advance
whether we're referencing UV or Color layer. Also made it so vertex
attributes are normalized.

TODO: Border render in viewport ignores the normalization of the
attribute array for some reason, will be looked into still.

Reviewers: mont29, brecht, campbellbarton

Reviewed By: brecht, campbellbarton

Differential Revision: https://developer.blender.org/D2022
2016-05-23 10:23:43 +02:00
Bastien Montagne ff3d535bc2 Fix T45471: Blend file: Bad old_addr handling in mesh's customdata writing.
Issue is rather well explained in T45471: our current customdata writing code easily generates several different blocks in blend file with same 'old' address. This is bad, because those addresses are used as 'uid' during reading process (it kind of work in Blender's own reading process, by mere luck mostly, but breaks the file specs).

Solution (suggested by Campbell, thanks) implemented by this patch is to avoid duplicating everything, and instead just overwrite what we needs to skip some cdlayers on write:
* the CustomData's `totlayer` number;
* the CustomData's `layers` array of CustomDataLayer (keeping its original address using the `writestruct_at_address` helper).

New design allows us to get completely rid of the no_free flag stuff in `write_customdata()`.

Note that this implies written data is **not** directly valid from Blend PoV, since its written typemap does not match written layers (this is not an issue because typemap is rebuilt on read anyway - and it's easy to fix this if really needed).

Also, the backward compatibility saving of mface data remains an issue here, see comment in code.

Reviewers: sergey, campbellbarton

Projects: #bf_blender

Maniphest Tasks: T45471

Differential Revision: https://developer.blender.org/D1425
2015-07-21 12:02:11 +02:00
Campbell Barton 595a491e63 Add tessellation data to DerivedMesh (LoopTri)
This stores loop indices into the loop array giving easier acess
to data such as vertex-colors and UV's,
removing the need to store an MFace duplicate of custom-data.

This doesn't yet move all internal code from MFace to LoopTri just yet.

Only applies to:
- opengl drawing
- sculpting (pbvh)
- vertex/weight paint

Thanks to @psy-fi for review, fixes and improvements to drawing!
2015-07-17 03:55:14 +10:00
Campbell Barton a8b8d60c50 CustomData: deprecate CD_ID_MCOL 2015-07-10 16:47:39 +10:00
Bastien Montagne 138c9dba9b Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.

See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.

Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.

Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.

Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:32:57 +01:00
Nicholas Bishop 8cafa0afa6 Code cleanup: give anomymous enum used for CustomData.type a name
Used this in GPU module to clarify what some "ints" really are.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D1026
2015-01-26 16:34:39 +01:00
Antony Riakiotakis 38eef8deee Refactor to Dyntopo node customdata commit.
Don't use a dedicated node layer but use temporary int layer instead.
Works like a charm as long as we are careful resetting the layer when
needed (after pbvh clearing and always after bmesh has been filled in
undo)

Tip by Campbell, thanks!
2014-04-17 19:03:08 +03:00
Antony Riakiotakis 556590fa3a Dyntopo:
Store PBVH node ID in CustomData. This avoids a number of hash deletions
and checks/insertions on big hashes.
2014-04-16 05:31:02 +03:00
Bastien Montagne 18e4224142 Split Normals I (1/5): basis for split normals (nearly nothing user-visible here):
* Add a new calcLoopNormals function to DerivedMesh struct, and implement it for CDDM and CCGDM (subsurf).
  EditDerivedBMesh (edit mode DM) only gets a dummy one in this commit.
* Add a tessellated version of CD_LOOPNORMAL layer (CD_TESSLOOPNORMAL), with relevant code to handle it
  (tessellation, rna access, etc.).
* Change auto_smooth options of Mesh (angle now in radian internaly, and toggle is now used to enable/disable
  split normals in DM creation process). Note BI render code is not touched here, hence its behavior regarding
  this option is now incoherent, will be addressed in a separate commit.

Reviewers: campbellbarton

CC: brecht

Differential Revision: https://developer.blender.org/D365
2014-04-13 12:19:00 +02:00
Campbell Barton 82628a6b0e Code cleanup: use struct type for mempool & style edits 2014-04-10 06:49:25 +10:00
Bastien Montagne 8952f58375 Add tangent space computation/access from RNA (i.e. python).
This simply mimics code used for loopnormals, to enable py scripts to generate and access (temporary)
a tangent 3D vector and bitangent sign for each loop. Together with the split normals, this allow
to recreate a complete tangent space for normal mapping (bitangent = bitangent_sign * cross(normal, tangent)).

Expects all faces to be tri or quads.

Reviewed By: Brecht, campbellbarton

Differential Revision: https://developer.blender.org/D185
2014-01-11 11:51:19 +01:00
Nathan Letwory 4e24e31f8b Change the enum for CustomDataMask bits back to #defines.
enum is an int, and values from CD_PREVIEW_MLOOPCOL (32) onwards
will not give what apparently was expected.

Found with help from Oscurart in #blendercoders while trying to figure
out compile error with CMake/msvc9. Occasionally it is good to heed
the warnings given by compilers!
2013-09-12 20:43:29 +00:00
Bastien Montagne 17a7c2425c Another DNA cleanup (enums instead of defines). 2013-09-10 13:13:04 +00:00
Brecht Van Lommel 2c662f8be8 Fix #35171: crash rendering cube with two subsurf modifier in some circumstances.
Problem was actually integer overflow in the requested data layers (1 << 31) does
not fit in an integer, it only goes up to (1 << 31) - 1.
2013-05-01 12:35:31 +00:00
Tamito Kajiyama 894c240f9d New implementation of Freestyle edge/face marks
The previous implementation of Freestyle edge/face marks was refactored
based on suggestions from the latest code review by Campbell.  The new
implementation relies on mesh CustomData to store edge/face marks, instead
of introducing extra flags in the core Mesh and BMesh data structures.
The CustomData-based implementation will allow further additions of new
edge/face attributes because of the independence from Mesh/BMesh.

This revision is work in progress, mainly intended to address the review
comments and ask for further code review in view of the trunk merger in
the upcoming 2.67 release.
2013-03-13 06:44:43 +00:00
Campbell Barton 8f01b50e14 code cleanup: clarify comment about virtial-modifiers, also add comments to DNA headers when its not so obvious what their purpose is. 2013-03-02 07:27:19 +00:00
Campbell Barton 9a469b62ca replace strcpy with BLI_strncpy or memcpy when the size is known. 2012-12-16 08:43:05 +00:00
Campbell Barton 00acdb6292 remove CD_POLYINDEX customdata layer:
reported as [#29376] BMESH_TODO: remove tessface CD_ORIGINDEX layer

for a single mesh there could be 3 origindex mappings stored, one on the polygons and 2 on the tessfaces.
(CD_POLYINDEX and CD_ORIGINDEX).

as Andrew suggests, now tessfaces (which are really a cache of polygons), using origindex to point to polygons on
the same derived mesh, and polygons only store the original index values.
2012-10-30 19:20:17 +00:00
Campbell Barton f609d0f22e code cleanup: remove USE_BMESH_FORWARD_COMPAT - this was added to load bmesh in pre-bmesh blender version, remove MODSTACK_DEBUG, was never used. 2012-10-04 09:12:08 +00:00
Campbell Barton 3d1cdfbb38 remove sticky coords from blender and the internal render engine. 2012-09-21 11:37:51 +00:00
Nicholas Bishop 396a3d31cc Add MVertSkin DNA/RNA and customdata (CD_MVERT_SKIN).
The MVertSkin currently just stores local skin radii and skin
flags (MVertSkinFlag).

Skin modifier documentation:
http://wiki.blender.org/index.php/User:Nicholasbishop/SkinModifier

Reviewed by Campbell Barton.
2012-05-22 15:18:43 +00:00
Nicholas Bishop aa77bbd38d Add DNA and customdata entries for paint masks.
CD_PAINT_MASK is a layer of per-vertex floats for non-multires
meshes. Multires meshes use CD_GRID_PAINT_MASK, which is a layer of
per-loop GridPaintMask structures. GridPaintMask is similar to MDisp,
but contains an array of scalar floats.

Note: the GridPaintMask could be folded into MDisp, but this way
should be easier to add mask layers in the future (if we do fold
GridPaintMask into MDisp, the mask array should probably be an array
of arrays with a 'totmask' field so that mask layers can be easily
supported.)

Includes blenload read/write support for CD_PAINT_MASK and
CD_GRID_PAINT_MASK.
2012-05-10 20:33:24 +00:00
Bastien Montagne 9751653410 Renaming CD_WEIGHT_MCOL/MLOOPCOL and their masks from WEIGHT to PREVIEW, as this layer is now also used for various preview tasks in Object mode.
“Cleanup” commit, no functional changes.
2012-03-22 08:41:50 +00:00
Campbell Barton 79d97ca509 style cleanup - spelling. 2012-03-08 04:12:11 +00:00
Campbell Barton 92c47145fd bmesh python api change in internal behavior.
* Only have 1 python object per bmesh, vertex, edge, loop, face.
* Store pointers back to the python data in a custom data layer so as not to use more memory for normal editing operations (when pythons not running).
* Currently this data is created and freed along with the BMesh PyObject.
* Incidentally - this fixes comparisons for bmesh elements which wasnt working before.
2012-02-22 16:08:30 +00:00
Campbell Barton 48006292d8 svn merge ^/trunk/blender -r44189:44204 2012-02-17 20:56:25 +00:00
Campbell Barton 2b7ca2304a unify include guard defines, __$FILENAME__
without the underscores these clogged up the namespace for autocompleation which was annoying.
2012-02-17 18:59:41 +00:00
Antony Riakiotakis d1833a2c99 Ported UvElementMap code to bmesh, still untested but at least compiling.
Next, uv sculpting will be ported.
Also fixed "initializer element is not computable at load time" compile error caused due to bit-shifting a constant past its precision length (1L should be 1LL for 32 positions left shift).
2012-02-06 19:25:12 +00:00
Campbell Barton 543fb27fd0 support for 'origspace' data layer - used for hair on subsurf mesh.
currently only works for 3/4 sided faces.
2012-02-05 11:30:26 +00:00
Campbell Barton 4966982a5a svn merge ^/trunk/blender -r43564:43609 2012-01-22 18:04:35 +00:00
Campbell Barton ae771e742b change filepath limit from 240 to 1024 2012-01-21 14:54:53 +00:00
Campbell Barton a7b0a11811 svn merge ^/trunk/blender -r43278:43294 2012-01-11 15:04:54 +00:00