blender/intern
Hans Goudey f1c0249f34 Mesh: Move material indices to a generic attribute
This patch moves material indices from the mesh `MPoly` struct to a
generic integer attribute. The builtin material index was already
exposed in geometry nodes, but this makes it a "proper" attribute
accessible with Python and visible in the "Attributes" panel.

The goals of the refactor are code simplification and memory and
performance improvements, mainly because the attribute doesn't have
to be stored and processed if there are no materials. However, until
4.0, material indices will still be read and written in the old
format, meaning there may be a temporary increase in memory usage.

Further notes:
* Completely removing the `MPoly.mat_nr` after 4.0 may require
  changes to DNA or introducing a new `MPoly` type.
* Geometry nodes regression tests didn't look at material indices,
  so the change reveals a bug in the realize instances node that I fixed.
* Access to material indices from the RNA `MeshPolygon` type is slower
  with this patch. The `material_index` attribute can be used instead.
* Cycles is changed to read from the attribute instead.
* BMesh isn't changed in this patch. Theoretically it could be though,
  to save 2 bytes per face when less than two materials are used.
* Eventually we could use a 16 bit integer attribute type instead.

Ref T95967

Differential Revision: https://developer.blender.org/D15675
2022-08-31 09:09:01 -05:00
..
atomic Intern/atomic: Fix const qualifier for atomic_load_ptr. 2022-05-31 21:05:15 +08:00
audaspace CMake: fix AUDASPACE disabling WITH_PYTHON for Blender 2022-05-20 11:18:49 +10:00
clog File headers: SPDX License migration 2022-02-11 09:14:36 +11:00
cycles Mesh: Move material indices to a generic attribute 2022-08-31 09:09:01 -05:00
dualcon Cleanup: Compilation warnings 2022-03-18 12:07:08 +01:00
eigen File headers: manually convert files to use SPDX headers 2022-02-11 15:15:49 +11:00
ffmpeg Merge branch 'blender-v3.1-release' 2022-02-22 17:34:07 +01:00
ghost Fix resource leak dropping files in GHOST/Win32 2022-08-31 16:28:32 +10:00
guardedalloc Cleanup: spelling in comments 2022-08-30 16:22:49 +10:00
iksolver Cleanup: spelling in comments, capitalize tags 2022-05-13 09:29:25 +10:00
itasc Cleanup: remove argument to doxygen \file 2022-03-25 12:10:30 +11:00
libc_compat Fix build error in libc_compat when using musl libc 2022-08-15 13:46:13 +02:00
libmv Cleanup: spelling in comments, capitalize tags 2022-05-13 09:29:25 +10:00
locale File headers: add missing copyright, add MIT to SPDX licenses 2022-02-11 14:56:03 +11:00
mantaflow Merge branch 'blender-v3.3-release' 2022-08-22 16:13:30 +02:00
memutil File headers: SPDX License migration 2022-02-11 09:14:36 +11:00
mikktspace Mikktspace: Reduce number of data queries to caller 2022-04-23 15:09:41 +02:00
opencolorio Cleanup OpenGL linking and related code after libepoxy merge 2022-08-15 16:47:20 +02:00
opensubdiv Cleanup: match names between functions & declarations 2022-08-23 11:05:50 +10:00
openvdb File headers: SPDX License migration 2022-02-11 09:14:36 +11:00
quadriflow File headers: SPDX License migration 2022-02-11 09:14:36 +11:00
rigidbody Cleanup: spelling in comments, capitalize tags 2022-05-13 09:29:25 +10:00
sky Cleanup: spelling in comments 2022-06-30 12:14:22 +10:00
utfconv Cleanup: use C++ comments for disabled code 2022-04-13 13:47:04 +10:00
wayland_dynload GHOST/Wayland: support dynamic loading libraries for Wayland 2022-07-06 15:30:47 +10:00
CMakeLists.txt GPU: replace GLEW with libepoxy 2022-08-15 16:10:29 +02:00