[Bf-blender-cvs] [8dff7bb4eb1] refactor-mesh-position-generic: Merge branch 'master' into refactor-mesh-position-generic
Commit: 8dff7bb4eb1c2d6cf03e4bc1380c5c8c96395846 Author: Hans Goudey Date: Mon Dec 12 21:58:24 2022 -0600 Branches: refactor-mesh-position-generic https://developer.blender.org/rB8dff7bb4eb1c2d6cf03e4bc1380c5c8c96395846 Merge branch 'master' into refactor-mesh-position-generic === === diff --cc source/blender/blenkernel/intern/mesh.cc index f50d6651170,1fafec810ba..e7e5e26c573 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@@ -513,7 -511,25 +516,9 @@@ static int customdata_compare } /* At this point `l1` and `l2` have the same name and type, so they should be compared. */ + found_corresponding_layer = true; + switch (l1->type) { - -case CD_MVERT: { - MVert *v1 = (MVert *)l1->data; - MVert *v2 = (MVert *)l2->data; - int vtot = m1->totvert; - - for (j = 0; j < vtot; j++, v1++, v2++) { -for (int k = 0; k < 3; k++) { - if (compare_threshold_relative(v1->co[k], v2->co[k], thresh)) { -return MESHCMP_VERTCOMISMATCH; - } -} - } - break; -} - /* We're order-agnostic for edges here. */ case CD_MEDGE: { MEdge *e1 = (MEdge *)l1->data; diff --cc source/blender/modifiers/intern/MOD_array.cc index a09756b03aa,1478ca0ecc5..92e8662af50 --- a/source/blender/modifiers/intern/MOD_array.cc +++ b/source/blender/modifiers/intern/MOD_array.cc @@@ -162,14 -161,16 +161,16 @@@ static void dm_mvert_map_doubles(int *d source_end = source_start + source_verts_num; /* build array of MVerts to be tested for merging */ - sorted_verts_target = MEM_malloc_arrayN(target_verts_num, sizeof(SortVertsElem), __func__); - sorted_verts_source = MEM_malloc_arrayN(source_verts_num, sizeof(SortVertsElem), __func__); + SortVertsElem *sorted_verts_target = static_cast( + MEM_malloc_arrayN(target_verts_num, sizeof(SortVertsElem), __func__)); + SortVertsElem *sorted_verts_source = static_cast( + MEM_malloc_arrayN(source_verts_num, sizeof(SortVertsElem), __func__)); /* Copy target vertices index and cos into SortVertsElem array */ - svert_from_mvert(sorted_verts_target, mverts + target_start, target_start, target_end); + svert_from_mvert(sorted_verts_target, positions, target_start, target_end); /* Copy source vertices index and cos into SortVertsElem array */ - svert_from_mvert(sorted_verts_source, mverts + source_start, source_start, source_end); + svert_from_mvert(sorted_verts_source, positions, source_start, source_end); /* sort arrays according to sum of vertex coordinates (sumco) */ qsort(sorted_verts_target, target_verts_num, sizeof(SortVertsElem), svert_sum_cmp); diff --cc source/blender/modifiers/intern/MOD_screw.cc index 2023d459f92,930fa0c1aab..5d7a652ff28 --- a/source/blender/modifiers/intern/MOD_screw.cc +++ b/source/blender/modifiers/intern/MOD_screw.cc @@@ -242,9 -241,11 +242,9 @@@ static Mesh *modifyMesh(ModifierData *m MPoly *mp_new; MLoop *ml_new; MEdge *med_new, *med_new_firstloop; - MVert *mv_new, *mv_new_base; - const MVert *mv_orig; Object *ob_axis = ltmd->ob_axis; - ScrewVertConnect *vc, *vc_tmp, *vert_connect = NULL; + ScrewVertConnect *vc, *vc_tmp, *vert_connect = nullptr; const char mpoly_flag = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) ? ME_SMOOTH : 0; @@@ -379,9 -380,9 +379,9 @@@ const bool do_remove_doubles = (ltmd->flag & MOD_SCREW_MERGE) && (screw_ofs == 0.0f); result = BKE_mesh_new_nomain_from_template( - mesh, (int)maxVerts, (int)maxEdges, 0, (int)maxPolys * 4, (int)maxPolys); + mesh, int(maxVerts), int(maxEdges), 0, int(maxPolys) * 4, int(maxPolys)); - const MVert *mvert_orig = BKE_mesh_verts(mesh); + const float(*positions_orig)[3] = BKE_mesh_positions(mesh); const MEdge *medge_orig = BKE_mesh_edges(mesh); const MPoly *mpoly_orig = BKE_mesh_polys(mesh); const MLoop *mloop_orig = BKE_mesh_loops(mesh); @@@ -495,16 -503,17 +499,16 @@@ // printf("\n\n\n\n\nStarting Modifier\n"); /* set edge users */ med_new = medge_new; - mv_new = mvert_new; - if (ob_axis != NULL) { + if (ob_axis != nullptr) { /* `mtx_tx` is initialized early on. */ -for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) { - vc->co[0] = mv_new->co[0] = mv_orig->co[0]; - vc->co[1] = mv_new->co[1] = mv_orig->co[1]; - vc->co[2] = mv_new->co[2] = mv_orig->co[2]; +for (i = 0; i < totvert; i++, vc++) { + vc->co[0] = positions_new[i][0] = positions_orig[i][0]; + vc->co[1] = positions_new[i][1] = positions_orig[i][1]; + vc->co[2] = positions_new[i][2] = positions_orig[i][2]; vc
[Bf-blender-cvs] [303216d3d3a] temp-win32-dead-key-fix: Fix for T103119 by harley, see: P3387
Commit: 303216d3d3ab84f410ae1300bc397f757ffc5dfd Author: Campbell Barton Date: Tue Dec 13 13:07:26 2022 +1100 Branches: temp-win32-dead-key-fix https://developer.blender.org/rB303216d3d3ab84f410ae1300bc397f757ffc5dfd Fix for T103119 by harley, see: P3387 === M intern/ghost/intern/GHOST_SystemWin32.cpp === diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 7aef23b39b6..089b2bcec88 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1210,11 +1210,8 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA const bool ctrl_pressed = has_state && state[VK_CONTROL] & 0x80; const bool alt_pressed = has_state && state[VK_MENU] & 0x80; -if (!key_down) { - /* Pass. */ -} /* No text with control key pressed (Alt can be used to insert special characters though!). */ -else if (ctrl_pressed && !alt_pressed) { +if (ctrl_pressed && !alt_pressed) { /* Pass. */ } /* Don't call #ToUnicodeEx on dead keys as it clears the buffer and so won't allow diacritical @@ -1234,6 +1231,9 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA utf8_char[0] = '\0'; } } + if (!key_down) { +utf8_char[0] = '\0'; + } } #ifdef WITH_INPUT_IME ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e6e57cebecd] master: CMake: add missing headers
Commit: e6e57cebecd13c2f30cee3a8262eda3c3191acbd Author: Campbell Barton Date: Tue Dec 13 12:46:12 2022 +1100 Branches: master https://developer.blender.org/rBe6e57cebecd13c2f30cee3a8262eda3c3191acbd CMake: add missing headers === M source/blender/blenkernel/CMakeLists.txt M source/blender/draw/CMakeLists.txt M source/blender/editors/util/CMakeLists.txt === diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 227c9bd8c66..7bd87323ede 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -480,6 +480,7 @@ set(SRC BKE_type_conversions.hh BKE_undo_system.h BKE_unit.h + BKE_uv_islands.hh BKE_vfont.h BKE_vfontdata.h BKE_viewer_path.h @@ -504,6 +505,7 @@ set(SRC intern/multires_unsubdivide.h intern/ocean_intern.h intern/pbvh_intern.h + intern/pbvh_uv_islands.hh intern/subdiv_converter.h intern/subdiv_inline.h ) diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 513029bc675..2093c8a2331 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -280,6 +280,7 @@ set(SRC engines/image/image_buffer_cache.hh engines/image/image_drawing_mode.hh engines/image/image_engine.h + engines/image/image_enums.hh engines/image/image_instance_data.hh engines/image/image_partial_updater.hh engines/image/image_private.hh @@ -534,6 +535,7 @@ set(GLSL_SRC intern/draw_command_shared.hh intern/draw_common_shader_shared.h intern/draw_defines.h + intern/draw_pointcloud_private.hh intern/draw_shader_shared.h engines/gpencil/shaders/gpencil_frag.glsl diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index 8430f69b632..c15db57d3b7 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -63,6 +63,7 @@ set(SRC ../include/ED_mball.h ../include/ED_mesh.h ../include/ED_node.h + ../include/ED_node.hh ../include/ED_numinput.h ../include/ED_object.h ../include/ED_outliner.h ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [17a20ed7feb] master: Cleanup: resolve missing-declarations warning
Commit: 17a20ed7feb4b8d3f44afa4bd68e2fb7f4bd5e4c Author: Campbell Barton Date: Tue Dec 13 12:21:44 2022 +1100 Branches: master https://developer.blender.org/rB17a20ed7feb4b8d3f44afa4bd68e2fb7f4bd5e4c Cleanup: resolve missing-declarations warning === M source/blender/editors/space_node/node_select.cc === diff --git a/source/blender/editors/space_node/node_select.cc b/source/blender/editors/space_node/node_select.cc index 8b25e173d47..7ecacde3874 100644 --- a/source/blender/editors/space_node/node_select.cc +++ b/source/blender/editors/space_node/node_select.cc @@ -26,7 +26,8 @@ #include "BKE_node_tree_update.h" #include "BKE_workspace.h" -#include "ED_node.h" /* own include */ +#include "ED_node.h" /* own include */ +#include "ED_node.hh" /* own include */ #include "ED_screen.h" #include "ED_select_utils.h" #include "ED_view3d.h" ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [adb49ffa240] master: Cleanup: spelling in comments
Commit: adb49ffa240e2ef99a6a2ddb8b2f06514b27 Author: Campbell Barton Date: Tue Dec 13 12:34:32 2022 +1100 Branches: master https://developer.blender.org/rBadb49ffa240e2ef99a6a2ddb8b2f06514b27 Cleanup: spelling in comments === M source/blender/blenkernel/intern/boids.c M source/blender/blenkernel/intern/key.cc M source/blender/blenkernel/intern/volume.cc M source/blender/draw/engines/eevee/eevee_shaders.cc M source/blender/draw/engines/eevee/shaders/infos/eevee_legacy_common_info.hh M source/blender/draw/engines/eevee/shaders/infos/eevee_legacy_volume_info.hh M source/blender/editors/interface/interface_handlers.cc M source/blender/editors/interface/interface_icons.cc M source/blender/gpu/GPU_texture.h M source/blender/gpu/intern/gpu_shader_create_info.cc M source/blender/gpu/intern/gpu_shader_create_info.hh M source/blender/gpu/intern/gpu_texture_private.hh M source/blender/gpu/metal/mtl_batch.mm M source/blender/gpu/metal/mtl_texture.mm M source/blender/nodes/composite/nodes/node_composite_glare.cc === diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index a0458f0f8d8..63e393aa4f0 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -1127,7 +1127,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) /* decide on jumping & liftoff */ if (bpa->data.mode == eBoidMode_OnLand) { -/* fuzziness makes boids capable of misjudgement */ +/* Fuzziness makes boids capable of misjudgment. */ float mul = 1.0f + state->rule_fuzziness; if (boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f) { diff --git a/source/blender/blenkernel/intern/key.cc b/source/blender/blenkernel/intern/key.cc index d3eb56d1563..7db815e7f9d 100644 --- a/source/blender/blenkernel/intern/key.cc +++ b/source/blender/blenkernel/intern/key.cc @@ -1877,7 +1877,7 @@ KeyBlock *BKE_keyblock_add_ctime(Key *key, const char *name, const bool do_force const float cpos = key->ctime / 100.0f; /* In case of absolute keys, there is no point in adding more than one key with the same pos. - * Hence only set new keybloc pos to current time if none previous one already use it. + * Hence only set new key-block pos to current time if none previous one already use it. * Now at least people just adding absolute keys without touching to ctime * won't have to systematically use retiming func (and have ordering issues, too). See T39897. */ diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index ae921764de4..b768ad07aa0 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -320,11 +320,11 @@ struct VolumeGrid { openvdb::io::File file(filepath); -/* Isolate file loading since that's potentially multithreaded and we are +/* Isolate file loading since that's potentially multi-threaded and we are * holding a mutex lock. */ blender::threading::isolate_task([&] { try { -/* Disably delay loading and file copying, this has poor performance +/* Disable delay loading and file copying, this has poor performance * on network drivers. */ const bool delay_load = false; file.setCopyMaxBytes(0); @@ -886,7 +886,7 @@ bool BKE_volume_load(const Volume *volume, const Main *bmain) openvdb::GridPtrVec vdb_grids; try { -/* Disably delay loading and file copying, this has poor performance +/* Disable delay loading and file copying, this has poor performance * on network drivers. */ const bool delay_load = false; file.setCopyMaxBytes(0); diff --git a/source/blender/draw/engines/eevee/eevee_shaders.cc b/source/blender/draw/engines/eevee/eevee_shaders.cc index fbdefcd8bee..d7901a9fac4 100644 --- a/source/blender/draw/engines/eevee/eevee_shaders.cc +++ b/source/blender/draw/engines/eevee/eevee_shaders.cc @@ -1158,7 +1158,7 @@ World *EEVEE_world_default_get(void) * Source is provided separately, rather than via create-info as source is manipulated * by `eevee_shader_material_create_info_amend`. * - * We also retain the previous behaviour for ensuring library includes occur in the + * We also retain the previous behavior for ensuring library includes occur in the * correct order. */ static const char *eevee_get_vert_info(int options, char **r_src) { @@ -1288,7 +1288,7 @@ static char *eevee_get_defines(int options) * CreateInfo's for EEVEE materials are declared in: * `eevee/shaders/infos/eevee_legacy_material_info.hh` * - * This function should only contain defines which alter behaviour, but do not affect shader + * This function should only contain
[Bf-blender-cvs] [b751c28f78d] master: Build: resolve build error with vulkan_loader not finding Wayland
Commit: b751c28f78d9cf89d410c990df7eb3b7bedc16e0 Author: Campbell Barton Date: Tue Dec 13 11:44:41 2022 +1100 Branches: master https://developer.blender.org/rBb751c28f78d9cf89d410c990df7eb3b7bedc16e0 Build: resolve build error with vulkan_loader not finding Wayland === M build_files/build_environment/cmake/vulkan.cmake === diff --git a/build_files/build_environment/cmake/vulkan.cmake b/build_files/build_environment/cmake/vulkan.cmake index 1fd94dd59be..578e02ced3e 100644 --- a/build_files/build_environment/cmake/vulkan.cmake +++ b/build_files/build_environment/cmake/vulkan.cmake @@ -30,6 +30,17 @@ set(VULKAN_LOADER_EXTRA_ARGS -DVULKAN_HEADERS_INSTALL_DIR=${LIBDIR}/vulkan_headers ) +if(UNIX AND NOT APPLE) + # These are used in `cmake/FindWayland.cmake` from `external_vulkan_loader`. + # NOTE: When upgrading to CMAKE 3.22 we it would be cleaner to use: `PKG_CONFIG_ARGN`, + # so `pkgconfig` would find wayland. + set(VULKAN_LOADER_EXTRA_ARGS +${VULKAN_LOADER_EXTRA_ARGS} +-DPKG_WAYLAND_INCLUDE_DIRS=${LIBDIR}/wayland/include +-DPKG_WAYLAND_LIBRARY_DIRS=${LIBDIR}/wayland/lib64 + ) +endif() + ExternalProject_Add(external_vulkan_loader URL file://${PACKAGE_DIR}/${VULKAN_LOADER_FILE} URL_HASH ${VULKAN_LOADER_HASH_TYPE}=${VULKAN_LOADER_HASH} @@ -43,7 +54,12 @@ add_dependencies( external_vulkan_headers ) -if(WIN32) +if(UNIX AND NOT APPLE) + add_dependencies( +external_vulkan_loader +external_wayland + ) +elseif(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_vulkan_loader after_install COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/vulkan_loader/ ${HARVEST_TARGET}/vulkan ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [cfcc728de63] master: Cleanup: split python packages across multiple lines
Commit: cfcc728de636963203ca5697226cebd7a314428f Author: Campbell Barton Date: Tue Dec 13 12:02:26 2022 +1100 Branches: master https://developer.blender.org/rBcfcc728de636963203ca5697226cebd7a314428f Cleanup: split python packages across multiple lines Having all packages on one line made reviewing changes difficult. Also note why Python modules are needed (with some TODO's where I wasn't able to find any reason given for their inclusion). === M build_files/build_environment/cmake/options.cmake M build_files/build_environment/cmake/python_site_packages.cmake M build_files/build_environment/cmake/versions.cmake === diff --git a/build_files/build_environment/cmake/options.cmake b/build_files/build_environment/cmake/options.cmake index 44eca741e77..0a7548f95fb 100644 --- a/build_files/build_environment/cmake/options.cmake +++ b/build_files/build_environment/cmake/options.cmake @@ -117,7 +117,7 @@ else() set(LIBEXT ".a") set(LIBPREFIX "lib") set(MESON ${LIBDIR}/python/bin/meson) -if(APPLE) + if(APPLE) set(SHAREDLIBEXT ".dylib") # Use same Xcode detection as Blender itself. diff --git a/build_files/build_environment/cmake/python_site_packages.cmake b/build_files/build_environment/cmake/python_site_packages.cmake index 4c0e7b1996c..93bfd00a721 100644 --- a/build_files/build_environment/cmake/python_site_packages.cmake +++ b/build_files/build_environment/cmake/python_site_packages.cmake @@ -5,7 +5,11 @@ if(WIN32 AND BUILD_MODE STREQUAL Debug) # zstandard is determined to build and link release mode libs in a debug # configuration, the only way to make it happy is to bend to its will # and give it a library to link with. - set(PIP_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}_d.lib ${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib) + set( +PIP_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy +${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}_d.lib +${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib + ) else() set(PIP_CONFIGURE_COMMAND echo ".") endif() @@ -15,9 +19,23 @@ ExternalProject_Add(external_python_site_packages CONFIGURE_COMMAND ${PIP_CONFIGURE_COMMAND} BUILD_COMMAND "" PREFIX ${BUILD_DIR}/site_packages - # setuptools is downgraded to 63.2.0 (same as python 3.10.8) since numpy 1.23.x seemingly has + + # setuptools is downgraded to 63.2.0 (same as python 3.10.8) since numpy 1.23.x seemingly has # issues building on windows with the newer versions that ships with python 3.10.9+ - INSTALL_COMMAND ${PYTHON_BINARY} -m pip install --no-cache-dir ${SITE_PACKAGES_EXTRA} setuptools==63.2.0 cython==${CYTHON_VERSION} idna==${IDNA_VERSION} charset-normalizer==${CHARSET_NORMALIZER_VERSION} urllib3==${URLLIB3_VERSION} certifi==${CERTIFI_VERSION} requests==${REQUESTS_VERSION} zstandard==${ZSTANDARD_VERSION} autopep8==${AUTOPEP8_VERSION} pycodestyle==${PYCODESTYLE_VERSION} toml==${TOML_VERSION} meson==${MESON_VERSION} --no-binary :all: + INSTALL_COMMAND ${PYTHON_BINARY} -m pip install --no-cache-dir ${SITE_PACKAGES_EXTRA} + setuptools==63.2.0 + cython==${CYTHON_VERSION} + idna==${IDNA_VERSION} + charset-normalizer==${CHARSET_NORMALIZER_VERSION} + urllib3==${URLLIB3_VERSION} + certifi==${CERTIFI_VERSION} + requests==${REQUESTS_VERSION} + zstandard==${ZSTANDARD_VERSION} + autopep8==${AUTOPEP8_VERSION} + pycodestyle==${PYCODESTYLE_VERSION} + toml==${TOML_VERSION} + meson==${MESON_VERSION} + --no-binary :all: ) if(USE_PIP_NUMPY) diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index 86f9d8349b1..097f632b356 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -203,7 +203,7 @@ set(OSL_FILE OpenShadingLanguage-${OSL_VERSION}.tar.gz) # NOTE: When updating the python version, it's required to check the versions of # it wants to use in PCbuild/get_externals.bat for the following dependencies: -# BZIP2, FFI, SQLITE and change the versions in this file as well. For compliance +# BZIP2, FFI, SQLITE and change the versions in this file as well. For compliance # reasons there can be no exceptions to this. set(PYTHON_VERSION 3.10.9) @@ -229,20 +229,34 @@ set(OPENVDB_HASH 64301c737e16b26c8f3085a31e6397e9) set(OPENVDB_HASH_TYPE MD5) set(OPENVDB_FILE openvdb-${OPENVDB_VERSION}.tar.gz) +# -- +# Python Modules + +# Needed by: TODO. set(IDNA_VERSION 3.3) +# Needed by: TODO. set(CHARSET_NORMALIZER_VERSION 2.0.10) +# Needed by: TODO. set(URLLIB3_VERSION 1.26.8) set(URLLIB3_CPE "cpe:2.3:a:urllib3:urllib3:${URLLIB3_VERSION}:*:*:*:*:*:*:*") +# Needed by: Python's `requests` modu
[Bf-blender-cvs] [9f11129d28d] master: Build: fix building sndfile with OPUS on Linux
Commit: 9f11129d28da4e361becc8b7dd8bfada0cc0b52d Author: Campbell Barton Date: Tue Dec 13 11:41:05 2022 +1100 Branches: master https://developer.blender.org/rB9f11129d28da4e361becc8b7dd8bfada0cc0b52d Build: fix building sndfile with OPUS on Linux The PKGCONFIG file exposes the OPUS include: requiring to be replaced with . Manipulate the PKGCONFIG file instead of patching the source since the small change is only needed in one place. === M build_files/build_environment/cmake/sndfile.cmake === diff --git a/build_files/build_environment/cmake/sndfile.cmake b/build_files/build_environment/cmake/sndfile.cmake index 1e4249e7e53..60a33c6a236 100644 --- a/build_files/build_environment/cmake/sndfile.cmake +++ b/build_files/build_environment/cmake/sndfile.cmake @@ -1,9 +1,10 @@ # SPDX-License-Identifier: GPL-2.0-or-later set(SNDFILE_EXTRA_ARGS) -set(SNDFILE_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/flac/lib/pkgconfig:${mingw_LIBDIR}/opus/lib/pkgconfig:${mingw_LIBDIR}) +set(SNDFILE_ENV) if(WIN32) + set(SNDFILE_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/flac/lib/pkgconfig:${mingw_LIBDIR}/opus/lib/pkgconfig:${mingw_LIBDIR}) set(SNDFILE_ENV set ${SNDFILE_ENV} &&) # Shared for windows because static libs will drag in a libgcc dependency. set(SNDFILE_OPTIONS --disable-static --enable-shared ) @@ -11,6 +12,16 @@ else() set(SNDFILE_OPTIONS --enable-static --disable-shared ) endif() +if(UNIX AND NOT APPLE) + # NOTE(@campbellbarton): For some reason OPUS is alone in referencing the sub-directory, + # manipulate the package-config file to prevent this from happening. + # There is no problem with applying this change multiple times. + # + # Replace: Cflags: -I${includedir}/opus + # With:Cflags: -I${includedir} + set(SNDFILE_ENV sed -i s/{includedir}\\/opus/{includedir}/g ${LIBDIR}/opus/lib/pkgconfig/opus.pc && ${SNDFILE_ENV}) +endif() + ExternalProject_Add(external_sndfile URL file://${PACKAGE_DIR}/${SNDFILE_FILE} DOWNLOAD_DIR ${DOWNLOAD_DIR} ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2761f7c4a5b] master: Build: fix MESA failing to build with missing EXPAT dependency
Commit: 2761f7c4a5bda3111ca0948a8ffcb17802f88cbb Author: Campbell Barton Date: Tue Dec 13 11:34:41 2022 +1100 Branches: master https://developer.blender.org/rB2761f7c4a5bda3111ca0948a8ffcb17802f88cbb Build: fix MESA failing to build with missing EXPAT dependency === M build_files/build_environment/cmake/mesa.cmake === diff --git a/build_files/build_environment/cmake/mesa.cmake b/build_files/build_environment/cmake/mesa.cmake index 8c7ec8fac07..ab07c09cc00 100644 --- a/build_files/build_environment/cmake/mesa.cmake +++ b/build_files/build_environment/cmake/mesa.cmake @@ -33,6 +33,8 @@ set(MESA_EXTRA_FLAGS # At some point we will likely want to support Wayland. # Disable for now since it's not officially supported. -Dplatforms=x11 + # Needed to find the local expat. + --pkg-config-path=${LIBDIR}/expat/lib/pkgconfig --native-file ${BUILD_DIR}/mesa/tmp/native-file.ini ) @@ -53,6 +55,8 @@ add_dependencies( external_mesa ll external_zlib + # Run-time dependency. + external_expat # Needed for `MESON`. external_python_site_packages ) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [dd6f7c13181] master: Build: remove patch to build with older meson version for Wayland
Commit: dd6f7c131818b12b44e5603427ea3c3438898eaf Author: Campbell Barton Date: Tue Dec 13 11:22:05 2022 +1100 Branches: master https://developer.blender.org/rBdd6f7c131818b12b44e5603427ea3c3438898eaf Build: remove patch to build with older meson version for Wayland Revert part of [0] which was required to build with meson 0.55.1, rocky8 has version 0.58.2. [0]; 8bb084cda3c9079ddb55288bd03b0a10df88bf59 === M build_files/build_environment/cmake/wayland.cmake D build_files/build_environment/patches/wayland.diff === diff --git a/build_files/build_environment/cmake/wayland.cmake b/build_files/build_environment/cmake/wayland.cmake index 76fbbcf3f97..ab573a8dca9 100644 --- a/build_files/build_environment/cmake/wayland.cmake +++ b/build_files/build_environment/cmake/wayland.cmake @@ -5,7 +5,6 @@ ExternalProject_Add(external_wayland DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${WAYLAND_HASH_TYPE}=${WAYLAND_HASH} PREFIX ${BUILD_DIR}/wayland - PATCH_COMMAND ${PATCH_CMD} -d ${BUILD_DIR}/wayland/src/external_wayland < ${PATCH_DIR}/wayland.diff # Use `-E` so the `PKG_CONFIG_PATH` can be defined to link against our own LIBEXPAT & LIBXML2. # # NOTE: passing link args "ffi/lib" should not be needed, but diff --git a/build_files/build_environment/patches/wayland.diff b/build_files/build_environment/patches/wayland.diff deleted file mode 100644 index c080b7b2964..000 --- a/build_files/build_environment/patches/wayland.diff +++ /dev/null @@ -1,11 +0,0 @@ meson.build.orig 2022-06-30 22:59:11.0 +0100 -+++ meson.build2022-09-27 13:21:26.428517668 +0100 -@@ -2,7 +2,7 @@ - 'wayland', 'c', - version: '1.21.0', - license: 'MIT', -- meson_version: '>= 0.56.0', -+ meson_version: '>= 0.55.1', - default_options: [ - 'warning_level=2', - 'buildtype=debugoptimized', ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6ce95c34ae1] master: Build: disable cairo for harfbuzz
Commit: 6ce95c34ae1497ab94ba61f99ed426eadc1bf85d Author: Campbell Barton Date: Tue Dec 13 11:30:37 2022 +1100 Branches: master https://developer.blender.org/rB6ce95c34ae1497ab94ba61f99ed426eadc1bf85d Build: disable cairo for harfbuzz This is only used for command line utilities, disable the dependency. === M build_files/build_environment/cmake/harfbuzz.cmake === diff --git a/build_files/build_environment/cmake/harfbuzz.cmake b/build_files/build_environment/cmake/harfbuzz.cmake index d889e7e6cb4..3eb994f72fe 100644 --- a/build_files/build_environment/cmake/harfbuzz.cmake +++ b/build_files/build_environment/cmake/harfbuzz.cmake @@ -5,7 +5,7 @@ if(WIN32) set(HARFBUZZ_PKG_ENV FREETYPE_DIR=${LIBDIR}/freetype) else() set(HARFBUZZ_CONFIGURE_ENV ${CONFIGURE_ENV}) - set(HARFBUZZ_PKG_ENV PKG_CONFIG_PATH=${LIBDIR}/freetype/lib/pkgconfig:${LIBDIR}/brotli/lib/pkgconfig:$PKG_CONFIG_PATH) + set(HARFBUZZ_PKG_ENV PKG_CONFIG_PATH=${LIBDIR}/freetype/lib/pkgconfig:${LIBDIR}/brotli/lib/pkgconfig:${LIBDIR}/lib/python3.10/pkgconfig:$PKG_CONFIG_PATH) endif() set(HARFBUZZ_EXTRA_OPTIONS @@ -13,6 +13,9 @@ set(HARFBUZZ_EXTRA_OPTIONS -Dfreetype=enabled -Dglib=disabled -Dgobject=disabled + # Only used for command line utilities, + # disable as this would add an addition & unnecessary build-dependency. + -Dcairo=disabled ) ExternalProject_Add(external_harfbuzz ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [982fb66fb13] master: Build: ensure meson is built before use
Commit: 982fb66fb133bbae2d9a80c086b131f4ffdb879f Author: Campbell Barton Date: Tue Dec 13 11:12:39 2022 +1100 Branches: master https://developer.blender.org/rB982fb66fb133bbae2d9a80c086b131f4ffdb879f Build: ensure meson is built before use Meson is built as part of external_python_site_packages, without this dependency it would be called before being built. Also remove Meson as a build requirement since the version is used. === M build_files/build_environment/cmake/check_software.cmake M build_files/build_environment/cmake/epoxy.cmake M build_files/build_environment/cmake/fribidi.cmake M build_files/build_environment/cmake/harfbuzz.cmake M build_files/build_environment/cmake/mesa.cmake M build_files/build_environment/cmake/wayland.cmake M build_files/build_environment/cmake/wayland_protocols.cmake === diff --git a/build_files/build_environment/cmake/check_software.cmake b/build_files/build_environment/cmake/check_software.cmake index 34544ca176b..93ea3ff071d 100644 --- a/build_files/build_environment/cmake/check_software.cmake +++ b/build_files/build_environment/cmake/check_software.cmake @@ -12,7 +12,6 @@ if(UNIX) automake bison ${_libtoolize_name} -meson ninja pkg-config tclsh diff --git a/build_files/build_environment/cmake/epoxy.cmake b/build_files/build_environment/cmake/epoxy.cmake index 312784598d4..da9c204d5ec 100644 --- a/build_files/build_environment/cmake/epoxy.cmake +++ b/build_files/build_environment/cmake/epoxy.cmake @@ -26,5 +26,6 @@ endif() add_dependencies( external_epoxy + # Needed for `MESON`. external_python_site_packages ) diff --git a/build_files/build_environment/cmake/fribidi.cmake b/build_files/build_environment/cmake/fribidi.cmake index 6e063eb5b26..9d83191741f 100644 --- a/build_files/build_environment/cmake/fribidi.cmake +++ b/build_files/build_environment/cmake/fribidi.cmake @@ -18,6 +18,7 @@ ExternalProject_Add(external_fribidi add_dependencies( external_fribidi external_python + # Needed for `MESON`. external_python_site_packages ) diff --git a/build_files/build_environment/cmake/harfbuzz.cmake b/build_files/build_environment/cmake/harfbuzz.cmake index 619ed66f603..d889e7e6cb4 100644 --- a/build_files/build_environment/cmake/harfbuzz.cmake +++ b/build_files/build_environment/cmake/harfbuzz.cmake @@ -30,6 +30,7 @@ ExternalProject_Add(external_harfbuzz add_dependencies( external_harfbuzz external_python + # Needed for `MESON`. external_python_site_packages ) diff --git a/build_files/build_environment/cmake/mesa.cmake b/build_files/build_environment/cmake/mesa.cmake index 63b17189e10..8c7ec8fac07 100644 --- a/build_files/build_environment/cmake/mesa.cmake +++ b/build_files/build_environment/cmake/mesa.cmake @@ -53,4 +53,6 @@ add_dependencies( external_mesa ll external_zlib + # Needed for `MESON`. + external_python_site_packages ) diff --git a/build_files/build_environment/cmake/wayland.cmake b/build_files/build_environment/cmake/wayland.cmake index 279ca6a787c..76fbbcf3f97 100644 --- a/build_files/build_environment/cmake/wayland.cmake +++ b/build_files/build_environment/cmake/wayland.cmake @@ -24,4 +24,7 @@ add_dependencies( external_expat external_xml2 external_ffi + + # Needed for `MESON`. + external_python_site_packages ) diff --git a/build_files/build_environment/cmake/wayland_protocols.cmake b/build_files/build_environment/cmake/wayland_protocols.cmake index 6d5ff3eb89e..708d9adba1e 100644 --- a/build_files/build_environment/cmake/wayland_protocols.cmake +++ b/build_files/build_environment/cmake/wayland_protocols.cmake @@ -15,4 +15,6 @@ ExternalProject_Add(external_wayland_protocols add_dependencies( external_wayland_protocols external_wayland + # Needed for `MESON`. + external_python_site_packages ) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [485c5abedc3] master: Fix T103067: Regression: Workbench render crash in 3.4
Commit: 485c5abedc3abda3118e5ba280243093a30b4143 Author: Lukas Stockner Date: Tue Dec 13 01:45:52 2022 +0100 Branches: master https://developer.blender.org/rB485c5abedc3abda3118e5ba280243093a30b4143 Fix T103067: Regression: Workbench render crash in 3.4 The workbench engine assumes that the Z pass exists, but didn't register it before. Since rB3411a96e7493, this is mandatory. === M source/blender/draw/engines/workbench/workbench_render.c === diff --git a/source/blender/draw/engines/workbench/workbench_render.c b/source/blender/draw/engines/workbench/workbench_render.c index c49578ff170..1ed391400b6 100644 --- a/source/blender/draw/engines/workbench/workbench_render.c +++ b/source/blender/draw/engines/workbench/workbench_render.c @@ -217,4 +217,7 @@ void workbench_render(void *ved, RenderEngine *engine, RenderLayer *render_layer void workbench_render_update_passes(RenderEngine *engine, Scene *scene, ViewLayer *view_layer) { RE_engine_register_pass(engine, scene, view_layer, RE_PASSNAME_COMBINED, 4, "RGBA", SOCK_RGBA); + if ((view_layer->passflag & SCE_PASS_Z) != 0) { +RE_engine_register_pass(engine, scene, view_layer, RE_PASSNAME_Z, 1, "Z", SOCK_FLOAT); + } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ab1c36ad3f0] master: Cleanup: Move two modifier files to C++
Commit: ab1c36ad3f0e6568fc951e4f75c5fbf01c463dd1 Author: Hans Goudey Date: Mon Dec 12 18:19:32 2022 -0600 Branches: master https://developer.blender.org/rBab1c36ad3f0e6568fc951e4f75c5fbf01c463dd1 Cleanup: Move two modifier files to C++ === M source/blender/modifiers/CMakeLists.txt R089source/blender/modifiers/intern/MOD_array.c source/blender/modifiers/intern/MOD_array.cc R087source/blender/modifiers/intern/MOD_screw.c source/blender/modifiers/intern/MOD_screw.cc M source/blender/modifiers/intern/MOD_skin.c === diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 807d5012681..63be9581175 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -34,7 +34,7 @@ set(INC_SYS set(SRC intern/MOD_armature.c - intern/MOD_array.c + intern/MOD_array.cc intern/MOD_bevel.c intern/MOD_boolean.cc intern/MOD_build.c @@ -71,7 +71,7 @@ set(SRC intern/MOD_particleinstance.c intern/MOD_particlesystem.cc intern/MOD_remesh.c - intern/MOD_screw.c + intern/MOD_screw.cc intern/MOD_shapekey.c intern/MOD_shrinkwrap.c intern/MOD_simpledeform.c diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.cc similarity index 89% rename from source/blender/modifiers/intern/MOD_array.c rename to source/blender/modifiers/intern/MOD_array.cc index 2d725af7fe4..1478ca0ecc5 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.cc @@ -73,11 +73,11 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte { ArrayModifierData *amd = (ArrayModifierData *)md; bool need_transform_dependency = false; - if (amd->start_cap != NULL) { + if (amd->start_cap != nullptr) { DEG_add_object_relation( ctx->node, amd->start_cap, DEG_OB_COMP_GEOMETRY, "Array Modifier Start Cap"); } - if (amd->end_cap != NULL) { + if (amd->end_cap != nullptr) { DEG_add_object_relation( ctx->node, amd->end_cap, DEG_OB_COMP_GEOMETRY, "Array Modifier End Cap"); } @@ -86,7 +86,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte ctx->node, amd->curve_ob, DEG_OB_COMP_GEOMETRY, "Array Modifier Curve"); DEG_add_special_eval_flag(ctx->node, &amd->curve_ob->id, DAG_EVAL_NEED_CURVE_PATH); } - if (amd->offset_ob != NULL) { + if (amd->offset_ob != nullptr) { DEG_add_object_relation( ctx->node, amd->offset_ob, DEG_OB_COMP_TRANSFORM, "Array Modifier Offset"); need_transform_dependency = true; @@ -103,16 +103,16 @@ BLI_INLINE float sum_v3(const float v[3]) } /* Structure used for sorting vertices, when processing doubles */ -typedef struct SortVertsElem { +struct SortVertsElem { int vertex_num; /* The original index of the vertex, prior to sorting */ float co[3];/* Its coordinates */ float sum_co; /* `sum_v3(co)`: just so we don't do the sum many times. */ -} SortVertsElem; +}; static int svert_sum_cmp(const void *e1, const void *e2) { - const SortVertsElem *sv1 = e1; - const SortVertsElem *sv2 = e2; + const SortVertsElem *sv1 = static_cast(e1); + const SortVertsElem *sv2 = static_cast(e2); if (sv1->sum_co > sv2->sum_co) { return 1; @@ -152,9 +152,8 @@ static void dm_mvert_map_doubles(int *doubles_map, const int source_verts_num, const float dist) { - const float dist3 = ((float)M_SQRT3 + 0.5f) * dist; /* Just above sqrt(3) */ + const float dist3 = (float(M_SQRT3) + 0.5f) * dist; /* Just above sqrt(3) */ int i_source, i_target, i_target_low_bound, target_end, source_end; - SortVertsElem *sorted_verts_target, *sorted_verts_source; SortVertsElem *sve_source, *sve_target, *sve_target_low_bound; bool target_scan_completed; @@ -162,8 +161,10 @@ static void dm_mvert_map_doubles(int *doubles_map, source_end = source_start + source_verts_num; /* build array of MVerts to be tested for merging */ - sorted_verts_target = MEM_malloc_arrayN(target_verts_num, sizeof(SortVertsElem), __func__); - sorted_verts_source = MEM_malloc_arrayN(source_verts_num, sizeof(SortVertsElem), __func__); + SortVertsElem *sorted_verts_target = static_cast( + MEM_malloc_arrayN(target_verts_num, sizeof(SortVertsElem), __func__)); + SortVertsElem *sorted_verts_source = static_cast( + MEM_malloc_arrayN(source_verts_num, sizeof(SortVertsElem), __func__)); /* Copy target vertices index and cos into SortVertsElem array */ svert_from_mvert(sorted_verts_target, mverts + target_start, target_start, target_end); @@ -305,7 +306,7 @@ static void mesh_merge_transform(Mesh *result, } /* remap the vertex groups if necessary */ - if (BKE_mesh_deform
[Bf-blender-cvs] [e41abf9e261] master: Cleanup: Remove runtime node flag, various node transform cleanups
Commit: e41abf9e26178ee4844004566be43acb7c7e39fb Author: Hans Goudey Date: Mon Dec 12 16:16:59 2022 -0600 Branches: master https://developer.blender.org/rBe41abf9e26178ee4844004566be43acb7c7e39fb Cleanup: Remove runtime node flag, various node transform cleanups Remove another runtime node flag that's simpler as a local variable. Use references, C++ types, simpler for loops, etc. === M source/blender/editors/include/ED_node.hh M source/blender/editors/space_node/node_group.cc M source/blender/editors/space_node/node_intern.hh M source/blender/editors/transform/transform_convert_node.cc M source/blender/makesdna/DNA_node_types.h === diff --git a/source/blender/editors/include/ED_node.hh b/source/blender/editors/include/ED_node.hh index 3929f5952e4..7b35bbf0b6e 100644 --- a/source/blender/editors/include/ED_node.hh +++ b/source/blender/editors/include/ED_node.hh @@ -2,6 +2,7 @@ #pragma once +#include "BLI_vector_set.hh" #include "ED_node.h" struct SpaceNode; @@ -11,6 +12,8 @@ struct bNodeTree; namespace blender::ed::space_node { +VectorSet get_selected_nodes(bNodeTree &node_tree); + void node_insert_on_link_flags_set(SpaceNode &snode, const ARegion ®ion); /** diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc index 93d2774c4b8..be9a6c69601 100644 --- a/source/blender/editors/space_node/node_group.cc +++ b/source/blender/editors/space_node/node_group.cc @@ -33,6 +33,7 @@ #include "DEG_depsgraph_build.h" #include "ED_node.h" /* own include */ +#include "ED_node.hh" #include "ED_render.h" #include "ED_screen.h" diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh index ff1a0e55fd5..1a6859a3078 100644 --- a/source/blender/editors/space_node/node_intern.hh +++ b/source/blender/editors/space_node/node_intern.hh @@ -183,7 +183,6 @@ void node_keymap(wmKeyConfig *keyconf); rctf node_frame_rect_inside(const bNode &node); bool node_or_socket_isect_event(const bContext &C, const wmEvent &event); -VectorSet get_selected_nodes(bNodeTree &node_tree); void node_deselect_all(SpaceNode &snode); void node_socket_select(bNode *node, bNodeSocket &sock); void node_socket_deselect(bNode *node, bNodeSocket &sock, bool deselect_node); diff --git a/source/blender/editors/transform/transform_convert_node.cc b/source/blender/editors/transform/transform_convert_node.cc index 7f54fa723f0..8b15302853b 100644 --- a/source/blender/editors/transform/transform_convert_node.cc +++ b/source/blender/editors/transform/transform_convert_node.cc @@ -9,8 +9,8 @@ #include "MEM_guardedalloc.h" -#include "BLI_listbase.h" -#include "BLI_math.h" +#include "BLI_math_vector.h" +#include "BLI_math_vector.hh" #include "BLI_rect.h" #include "BKE_context.h" @@ -39,58 +39,60 @@ struct TransCustomDataNode { /** \name Node Transform Creation * \{ */ -/* transcribe given node into TransData2D for Transforming */ -static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node, const float dpi_fac) +static void create_transform_data_for_node(TransData &td, + TransData2D &td2d, + bNode &node, + const float dpi_fac) { float locx, locy; /* account for parents (nested nodes) */ - if (node->parent) { -nodeToView(node->parent, node->locx, node->locy, &locx, &locy); + if (node.parent) { +nodeToView(node.parent, node.locx, node.locy, &locx, &locy); } else { -locx = node->locx; -locy = node->locy; +locx = node.locx; +locy = node.locy; } /* use top-left corner as the transform origin for nodes */ /* Weirdo - but the node system is a mix of free 2d elements and DPI sensitive UI. */ #ifdef USE_NODE_CENTER - td2d->loc[0] = (locx * dpi_fac) + (BLI_rctf_size_x(&node->runtime->totr) * +0.5f); - td2d->loc[1] = (locy * dpi_fac) + (BLI_rctf_size_y(&node->runtime->totr) * -0.5f); + td2d.loc[0] = (locx * dpi_fac) + (BLI_rctf_size_x(&node.runtime->totr) * +0.5f); + td2d.loc[1] = (locy * dpi_fac) + (BLI_rctf_size_y(&node.runtime->totr) * -0.5f); #else - td2d->loc[0] = locx * dpi_fac; - td2d->loc[1] = locy * dpi_fac; + td2d.loc[0] = locx * dpi_fac; + td2d.loc[1] = locy * dpi_fac; #endif - td2d->loc[2] = 0.0f; - td2d->loc2d = td2d->loc; /* current location */ + td2d.loc[2] = 0.0f; + td2d.loc2d = td2d.loc; /* current location */ - td->loc = td2d->loc; - copy_v3_v3(td->iloc, td->loc); + td.loc = td2d.loc; + copy_v3_v3(td.iloc, td.loc); /* use node center instead of origin (top-left corner) */ - td->center[0] = td2d->loc[0]; - td->center[1] = td2d->loc[1]; - td->center[2] = 0.0f; + td.center[0] = td2d.loc[0]; + td.center[1] = td2d.loc[1]; + t
[Bf-blender-cvs] [57090a4b722] master: Cleanup: Remove ifdef'd node transform code
Commit: 57090a4b7228f065c22fcf2ac2e70e7a0ab10c2d Author: Hans Goudey Date: Mon Dec 12 17:09:58 2022 -0600 Branches: master https://developer.blender.org/rB57090a4b7228f065c22fcf2ac2e70e7a0ab10c2d Cleanup: Remove ifdef'd node transform code This has been turned off since 2013. === M source/blender/editors/transform/transform.h M source/blender/editors/transform/transform_convert_node.cc M source/blender/editors/transform/transform_snap.cc === diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index a73b82b9092..169937d17e2 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -23,10 +23,6 @@ extern "C" { #endif -/* use node center for transform instead of upper-left corner. - * disabled since it makes absolute snapping not work so nicely - */ -// #define USE_NODE_CENTER /* */ /** \name Types/ diff --git a/source/blender/editors/transform/transform_convert_node.cc b/source/blender/editors/transform/transform_convert_node.cc index 8b15302853b..f07baa09e8c 100644 --- a/source/blender/editors/transform/transform_convert_node.cc +++ b/source/blender/editors/transform/transform_convert_node.cc @@ -57,13 +57,8 @@ static void create_transform_data_for_node(TransData &td, /* use top-left corner as the transform origin for nodes */ /* Weirdo - but the node system is a mix of free 2d elements and DPI sensitive UI. */ -#ifdef USE_NODE_CENTER - td2d.loc[0] = (locx * dpi_fac) + (BLI_rctf_size_x(&node.runtime->totr) * +0.5f); - td2d.loc[1] = (locy * dpi_fac) + (BLI_rctf_size_y(&node.runtime->totr) * -0.5f); -#else td2d.loc[0] = locx * dpi_fac; td2d.loc[1] = locy * dpi_fac; -#endif td2d.loc[2] = 0.0f; td2d.loc2d = td2d.loc; /* current location */ @@ -235,11 +230,6 @@ static void flushTransNodes(TransInfo *t) float loc[2]; add_v2_v2v2(loc, td2d->loc, offset); -#ifdef USE_NODE_CENTER - loc[0] -= 0.5f * BLI_rctf_size_x(&node->runtime->totr); - loc[1] += 0.5f * BLI_rctf_size_y(&node->runtime->totr); -#endif - /* Weirdo - but the node system is a mix of free 2d elements and DPI sensitive UI. */ loc[0] /= dpi_fac; loc[1] /= dpi_fac; diff --git a/source/blender/editors/transform/transform_snap.cc b/source/blender/editors/transform/transform_snap.cc index 5373bdd7834..0157f478b57 100644 --- a/source/blender/editors/transform/transform_snap.cc +++ b/source/blender/editors/transform/transform_snap.cc @@ -1190,36 +1190,19 @@ static void TargetSnapOffset(TransInfo *t, TransData *td) if (t->spacetype == SPACE_NODE && td != nullptr) { bNode *node = static_cast(td->extra); char border = t->tsnap.snapNodeBorder; -float width = BLI_rctf_size_x(&node->runtime->totr); -float height = BLI_rctf_size_y(&node->runtime->totr); -#ifdef USE_NODE_CENTER -if (border & NODE_LEFT) { - t->tsnap.snapTarget[0] -= 0.5f * width; -} -if (border & NODE_RIGHT) { - t->tsnap.snapTarget[0] += 0.5f * width; -} -if (border & NODE_BOTTOM) { - t->tsnap.snapTarget[1] -= 0.5f * height; -} -if (border & NODE_TOP) { - t->tsnap.snapTarget[1] += 0.5f * height; -} -#else if (border & NODE_LEFT) { t->tsnap.snapTarget[0] -= 0.0f; } if (border & NODE_RIGHT) { - t->tsnap.snapTarget[0] += width; + t->tsnap.snapTarget[0] += BLI_rctf_size_x(&node->runtime->totr); } if (border & NODE_BOTTOM) { - t->tsnap.snapTarget[1] -= height; + t->tsnap.snapTarget[1] -= BLI_rctf_size_y(&node->runtime->totr); } if (border & NODE_TOP) { t->tsnap.snapTarget[1] += 0.0f; } -#endif } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4ee2504eff3] master: Cleanup: Remove cryptic "PET" acronym
Commit: 4ee2504eff3175e9b22320a06a8c9cadfe103ae6 Author: Hans Goudey Date: Mon Dec 12 15:45:41 2022 -0600 Branches: master https://developer.blender.org/rB4ee2504eff3175e9b22320a06a8c9cadfe103ae6 Cleanup: Remove cryptic "PET" acronym There is no need to make this an acronym, it only makes the code less accessible. It's a comment anyway, so brevity isn't the goal. === M source/blender/editors/transform/transform.c M source/blender/editors/transform/transform_convert.c M source/blender/editors/transform/transform_convert_curve.c M source/blender/editors/transform/transform_convert_lattice.c M source/blender/editors/transform/transform_convert_mball.c M source/blender/editors/transform/transform_convert_mesh.c M source/blender/editors/transform/transform_convert_mesh_skin.c M source/blender/editors/transform/transform_convert_mesh_uv.c M source/blender/editors/transform/transform_convert_mesh_vert_cdata.c M source/blender/editors/transform/transform_convert_node.cc M source/blender/editors/transform/transform_generics.c M source/blender/editors/transform/transform_mode_curveshrinkfatten.c M source/blender/editors/transform/transform_mode_gpopacity.c M source/blender/editors/transform/transform_mode_gpshrinkfatten.c M source/blender/editors/transform/transform_mode_maskshrinkfatten.c === diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index fcc5051d841..77b6f169a08 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1336,7 +1336,7 @@ bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], floa t->state = TRANS_RUNNING; - /* avoid calculating PET */ + /* Avoid calculating proportional editing. */ t->options = CTX_NO_PET; t->mode = TFM_DUMMY; diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index 00e7b15c59a..f9ad09b7a10 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -709,7 +709,7 @@ static int countAndCleanTransDataContainer(TransInfo *t) static void init_proportional_edit(TransInfo *t) { - /* NOTE: PET is not usable in pose mode yet T32444. */ + /* NOTE: Proportional editing is not usable in pose mode yet T32444. */ if (!ELEM(t->data_type, &TransConvertType_Action, &TransConvertType_Curve, @@ -726,7 +726,7 @@ static void init_proportional_edit(TransInfo *t) &TransConvertType_Node, &TransConvertType_Object, &TransConvertType_Particle)) { -/* Disable PET */ +/* Disable proportional editing */ t->options |= CTX_NO_PET; t->flag &= ~T_PROP_EDIT_ALL; return; diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c index 13ba28ec3d0..3a4098cf06f 100644 --- a/source/blender/editors/transform/transform_convert_curve.c +++ b/source/blender/editors/transform/transform_convert_curve.c @@ -131,7 +131,8 @@ static void createTransCurveVerts(bContext *UNUSED(C), TransInfo *t) } } -/* Support other objects using PET to adjust these, unless connected is enabled. */ +/* Support other objects using proportional editing to adjust these, unless connected is + * enabled. */ if (((is_prop_edit && !is_prop_connected) ? count : countsel) == 0) { tc->data_len = 0; continue; diff --git a/source/blender/editors/transform/transform_convert_lattice.c b/source/blender/editors/transform/transform_convert_lattice.c index e9b3401974b..cb391b4930b 100644 --- a/source/blender/editors/transform/transform_convert_lattice.c +++ b/source/blender/editors/transform/transform_convert_lattice.c @@ -52,7 +52,8 @@ static void createTransLatticeVerts(bContext *UNUSED(C), TransInfo *t) bp++; } -/* Support other objects using PET to adjust these, unless connected is enabled. */ +/* Support other objects using proportional editing to adjust these, unless connected is + * enabled. */ if (((is_prop_edit && !is_prop_connected) ? count : countsel) == 0) { tc->data_len = 0; continue; diff --git a/source/blender/editors/transform/transform_convert_mball.c b/source/blender/editors/transform/transform_convert_mball.c index c90052e9e8c..bae2ea8b20d 100644 --- a/source/blender/editors/transform/transform_convert_mball.c +++ b/source/blender/editors/transform/transform_convert_mball.c @@ -44,7 +44,8 @@ static void createTransMBallVerts(bContext *UNUSED(C), TransInfo *t) } } -/* Support other objects using PET to adjust these, unless connected is enabled. */
[Bf-blender-cvs] [9437abdbcee] master: Cleanup: Use LISTBASE_FOREACH macro
Commit: 9437abdbceeed688d40b78da70465fd1ef415647 Author: Hans Goudey Date: Mon Dec 12 15:14:45 2022 -0600 Branches: master https://developer.blender.org/rB9437abdbceeed688d40b78da70465fd1ef415647 Cleanup: Use LISTBASE_FOREACH macro === M source/blender/editors/space_view3d/view3d_cursor_snap.c M source/blender/editors/transform/transform.c === diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c b/source/blender/editors/space_view3d/view3d_cursor_snap.c index 6ddd47e0f52..771a964dbcd 100644 --- a/source/blender/editors/space_view3d/view3d_cursor_snap.c +++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c @@ -524,7 +524,7 @@ static bool v3d_cursor_is_snap_invert(SnapCursorDataIntern *data_intern, const w const int snap_on = data_intern->snap_on; wmKeyMap *keymap = WM_keymap_active(wm, data_intern->keymap); - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (const wmKeyMapItem *, kmi, &keymap->items) { if (kmi->flag & KMI_INACTIVE) { continue; } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 767e217117c..fcc5051d841 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1859,9 +1859,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve * lead to keymap conflicts for other modes (see T31584) */ if (ELEM(mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) { - wmKeyMapItem *kmi; - - for (kmi = t->keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (const wmKeyMapItem *, kmi, &t->keymap->items) { if (kmi->flag & KMI_INACTIVE) { continue; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b08301c865f] master: Geometry Nodes: Optimization in Set Position node
Commit: b08301c865f42ab51b29efb80fcf68074a947d93 Author: Erik Abrahamsson Date: Mon Dec 12 23:01:49 2022 +0100 Branches: master https://developer.blender.org/rBb08301c865f42ab51b29efb80fcf68074a947d93 Geometry Nodes: Optimization in Set Position node Adds an early return if Position/Offset inputs won't lead to any changes in the Geometry. It now also compares with the read-only Position attribute instead of getting it for write only, to work correctly with Copy-on-Write. Before, the `is_same`-check only worked for geometry created in the node tree. Differential Revision: https://developer.blender.org/D16738 === M source/blender/nodes/geometry/nodes/node_geo_set_position.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc index e243fe3614c..e219d5bc0a1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc @@ -29,15 +29,22 @@ static void set_computed_position_and_offset(GeometryComponent &component, const IndexMask selection) { MutableAttributeAccessor attributes = *component.attributes_for_write(); - AttributeWriter positions = attributes.lookup_for_write("position"); + const VArray positions_read_only = attributes.lookup("position"); + if (in_positions.is_same(positions_read_only)) { +if (const std::optional offset = in_offsets.get_if_single()) { + if (math::is_zero(offset.value())) { +return; + } +} + } const int grain_size = 1; switch (component.type()) { case GEO_COMPONENT_TYPE_MESH: { Mesh *mesh = static_cast(component).get_for_write(); MutableSpan verts = mesh->verts_for_write(); - if (in_positions.is_same(positions.varray)) { + if (in_positions.is_same(positions_read_only)) { devirtualize_varray(in_offsets, [&](const auto in_offsets) { threading::parallel_for( selection.index_range(), grain_size, [&](const IndexRange range) { @@ -63,15 +70,16 @@ static void set_computed_position_and_offset(GeometryComponent &component, break; } case GEO_COMPONENT_TYPE_CURVE: { - CurveComponent &curve_component = static_cast(component); - Curves &curves_id = *curve_component.get_for_write(); - bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); if (attributes.contains("handle_right") && attributes.contains("handle_left")) { +CurveComponent &curve_component = static_cast(component); +Curves &curves_id = *curve_component.get_for_write(); +bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); SpanAttributeWriter handle_right_attribute = attributes.lookup_or_add_for_write_span("handle_right", ATTR_DOMAIN_POINT); SpanAttributeWriter handle_left_attribute = attributes.lookup_or_add_for_write_span("handle_left", ATTR_DOMAIN_POINT); +AttributeWriter positions = attributes.lookup_for_write("position"); MutableVArraySpan out_positions_span = positions.varray; devirtualize_varray2( in_positions, in_offsets, [&](const auto in_positions, const auto in_offsets) { @@ -88,6 +96,7 @@ static void set_computed_position_and_offset(GeometryComponent &component, }); out_positions_span.save(); +positions.finish(); handle_right_attribute.finish(); handle_left_attribute.finish(); @@ -95,13 +104,12 @@ static void set_computed_position_and_offset(GeometryComponent &component, curves.calculate_bezier_auto_handles(); break; } - else { -ATTR_FALLTHROUGH; - } + ATTR_FALLTHROUGH; } default: { + AttributeWriter positions = attributes.lookup_for_write("position"); MutableVArraySpan out_positions_span = positions.varray; - if (in_positions.is_same(positions.varray)) { + if (in_positions.is_same(positions_read_only)) { devirtualize_varray(in_offsets, [&](const auto in_offsets) { threading::parallel_for( selection.index_range(), grain_size, [&](const IndexRange range) { @@ -123,11 +131,10 @@ static void set_computed_position_and_offset(GeometryComponent &component, }); } out_positions_span.save(); + positions.finish(); break; } } - - positions.finish(); } static void set_position_in_component(GeometryComponent &component, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f3515ffed99] temp-py-gpubatch-draw-advanced: Python: Add index and instance based parameter to GPUBatch.draw.
Commit: f3515ffed996b5cba63a46316c14ca9d7e903658 Author: Jeroen Bakker Date: Mon Dec 12 21:38:51 2022 +0100 Branches: temp-py-gpubatch-draw-advanced https://developer.blender.org/rBf3515ffed996b5cba63a46316c14ca9d7e903658 Python: Add index and instance based parameter to GPUBatch.draw. GPUBatch.draw only supported basic drawing methods. Although all supported platforms support drawing a subset of the index buffer and/or drawing of multiple instances of the same set of indexes. This patch adds parameters to the existing `GPUBatch.draw` method to add support for these drawing methods. For drawing a subset of the index buffer the parameters `index_start` and `index_count` can be used. `my_batch.draw(my_shader, index_start=10, index_count=5)` For drawing multiple indexes the parameters `instance_start` and `instance_count` can be used. `my_batch.draw(my_shader, instance_start=0, instance_count=10)` Both set of parameters can be used together. `my_batch.draw(my_shader, index_start=10, index_count=5, instance_start=0, instance_count=10)` For compatibility reasons the `program` isn't required to be named as demonstrated by `my_shader`. === M source/blender/python/gpu/gpu_py_batch.c === diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c index 25fe31322b1..97001598a44 100644 --- a/source/blender/python/gpu/gpu_py_batch.c +++ b/source/blender/python/gpu/gpu_py_batch.c @@ -204,18 +204,56 @@ static PyObject *pygpu_batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_sha } PyDoc_STRVAR(pygpu_batch_draw_doc, - ".. method:: draw(program=None)\n" + ".. method:: draw(" + "program=None, " + "index_start=0, " + "index_count=0, " + "instance_start=0, " + "instance_count=0)\n" "\n" " Run the drawing program with the parameters assigned to the batch.\n" "\n" " :arg program: Program that performs the drawing operations.\n" " If ``None`` is passed, the last program set to this batch will run.\n" - " :type program: :class:`gpu.types.GPUShader`\n"); -static PyObject *pygpu_batch_draw(BPyGPUBatch *self, PyObject *args) + " :type program: :class:`gpu.types.GPUShader`\n" + " :arg index_start: First index to draw.\n" + " :type index_start: int\n" + " :arg index_count: Number of indexes to draw.\n" + " :type index_count: int\n" + " :arg instance_start: First instance to draw.\n" + " :type instance_start: int\n" + " :arg instance_count: Number of instances to draw.\n" + " :type instance_count: int\n"); +static PyObject *pygpu_batch_draw(BPyGPUBatch *self, PyObject *args, PyObject *kw) { BPyGPUShader *py_program = NULL; + int index_start = 0; + int index_count = 0; + int instance_start = 0; + int instance_count = 0; - if (!PyArg_ParseTuple(args, "|O!:GPUBatch.draw", &BPyGPUShader_Type, &py_program)) { + static const char *_keywords[] = { + "program", "index_start", "index_count", "instance_start", "instance_count", NULL}; + static _PyArg_Parser _parser = { + "O!" /* `program` Optional argument for compatibility reasons. */ + "|$" /* Optional, keyword only arguments. */ + "i" /* `index_start' */ + "i" /* `index_count' */ + "i" /* `instance_start' */ + "i" /* `instance_count' */ + ":GPUBatch.draw", + _keywords, + 0, + }; + if (!_PyArg_ParseTupleAndKeywordsFast(args, +kw, +&_parser, +&BPyGPUShader_Type, +&py_program, +&index_start, +&index_count, +&instance_start, +&instance_count)) { return NULL; } if (py_program == NULL) { @@ -227,7 +265,7 @@ static PyObject *pygpu_batch_draw(BPyGPUBatch *self, PyObject *args) GPU_batch_set_shader(self->batch, py_program->shader); } - GPU_batch_draw(self->batch); + GPU_batch_draw_advanced(self->batch, index_start, index_count, instance_start, instance_count); Py_RETURN_NONE; } @@ -252,7 +290,7 @@ static PyObject *pygpu_batch_program_use_end(BPyGPUBatch *self) static struct PyMethodDef pygpu_batch__tp_methods[] = { {"vertbuf_add", (PyCFunction)pygpu_batch_vertbuf_add, METH_O, pygpu_batch_vertbuf_add_doc}, {"program_set", (PyCFunction)pygpu_batch_program_set, METH_O, pygpu_batch_program_set_doc}, -{"draw", (PyCFunction)pygpu_batch_draw, METH_VARARGS, pygpu_batch_draw_doc}, +
[Bf-blender-cvs] [f56488c20f4] master: Fix Cycles ellipse area light returns zero pdf in volume segment
Commit: f56488c20f44acaf31d75ba0a1e5dd2539c8f8a6 Author: Weizhen Huang Date: Mon Dec 12 21:38:23 2022 +0100 Branches: master https://developer.blender.org/rBf56488c20f44acaf31d75ba0a1e5dd2539c8f8a6 Fix Cycles ellipse area light returns zero pdf in volume segment === M intern/cycles/kernel/light/light.h === diff --git a/intern/cycles/kernel/light/light.h b/intern/cycles/kernel/light/light.h index d04bffe8f8b..fe1df22bd60 100644 --- a/intern/cycles/kernel/light/light.h +++ b/intern/cycles/kernel/light/light.h @@ -156,7 +156,7 @@ ccl_device_noinline bool light_sample(KernelGlobals kg, } ls->pdf *= ls->pdf_selection; - return (ls->pdf > 0.0f); + return in_volume_segment || (ls->pdf > 0.0f); } /* Intersect ray with individual light. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e378bd70ed6] master: Cleanup: remove code duplication in cycles light sampling
Commit: e378bd70ed6cb255f9a1cc092b88515bbf25d37c Author: Weizhen Huang Date: Thu Dec 8 12:56:49 2022 +0100 Branches: master https://developer.blender.org/rBe378bd70ed6cb255f9a1cc092b88515bbf25d37c Cleanup: remove code duplication in cycles light sampling There has been an attempt to reorganize this part, however, it seems that didn't compile on HIP, and is reverted in rBc2dc65dfa4ae60fa5d2c3b0cfe86f99dcb5bf16f. This is another attempt of refactoring. as I have no idea why some things don't work on HIP, it's best to check whether this compiles on other platforms. The main changes are creating a new struct named `MeshLight` that is shared between `KernelLightDistribution` and `KernelLightTreeEmitter`, and a bit of renaming, so that light sampling with or without light tree could call the same function. Also, I noticed a patch D16714 referring to HIP compilation error. Not sure if it's related, but browsing https://builder.blender.org/admin/#/builders/30/builds/7826/steps/7/logs/stdio, it didn't work on gfx1102, not gfx9*. Differential Revision: https://developer.blender.org/D16722 === M intern/cycles/kernel/light/distribution.h M intern/cycles/kernel/light/light.h M intern/cycles/kernel/light/tree.h M intern/cycles/kernel/light/triangle.h M intern/cycles/kernel/types.h M intern/cycles/scene/light.cpp === diff --git a/intern/cycles/kernel/light/distribution.h b/intern/cycles/kernel/light/distribution.h index 2f75a53ec2a..97c60376748 100644 --- a/intern/cycles/kernel/light/distribution.h +++ b/intern/cycles/kernel/light/distribution.h @@ -59,41 +59,9 @@ ccl_device_noinline bool light_distribution_sample(KernelGlobals kg, { /* Sample light index from distribution. */ const int index = light_distribution_sample(kg, &randu); - ccl_global const KernelLightDistribution *kdistribution = &kernel_data_fetch(light_distribution, - index); - const int prim = kdistribution->prim; - - if (prim >= 0) { -/* Mesh light. */ -const int object = kdistribution->mesh_light.object_id; - -/* Exclude synthetic meshes from shadow catcher pass. */ -if ((path_flag & PATH_RAY_SHADOW_CATCHER_PASS) && -!(kernel_data_fetch(object_flag, object) & SD_OBJECT_SHADOW_CATCHER)) { - return false; -} - -const int shader_flag = kdistribution->mesh_light.shader_flag; -if (!triangle_light_sample(kg, prim, object, randu, randv, time, ls, P)) { - return false; -} -ls->shader |= shader_flag; - } - else { -const int lamp = -prim - 1; - -if (UNLIKELY(light_select_reached_max_bounces(kg, lamp, bounce))) { - return false; -} - -if (!light_sample(kg, lamp, randu, randv, P, path_flag, ls)) { - return false; -} -ls->pdf_selection = kernel_data.integrator.distribution_pdf_lights; - } - - ls->pdf *= ls->pdf_selection; - return (ls->pdf > 0.0f); + const float pdf_selection = kernel_data.integrator.distribution_pdf_lights; + return light_sample( + kg, randu, randv, time, P, bounce, path_flag, index, pdf_selection, ls); } ccl_device_inline float light_distribution_pdf_lamp(KernelGlobals kg) diff --git a/intern/cycles/kernel/light/light.h b/intern/cycles/kernel/light/light.h index b33aecf8b62..d04bffe8f8b 100644 --- a/intern/cycles/kernel/light/light.h +++ b/intern/cycles/kernel/light/light.h @@ -14,6 +14,13 @@ CCL_NAMESPACE_BEGIN +/* Light info. */ + +ccl_device_inline bool light_select_reached_max_bounces(KernelGlobals kg, int index, int bounce) +{ + return (bounce > kernel_data_fetch(lights, index).max_bounces); +} + /* Sample point on an individual light. */ template @@ -90,6 +97,68 @@ ccl_device_inline bool light_sample(KernelGlobals kg, return in_volume_segment || (ls->pdf > 0.0f); } +/* Sample a point on the chosen emitter. */ + +template +ccl_device_noinline bool light_sample(KernelGlobals kg, + const float randu, + const float randv, + const float time, + const float3 P, + const int bounce, + const uint32_t path_flag, + const int emitter_index, + const float pdf_selection, + ccl_private LightSample *ls) +{ + int prim; + MeshLight mesh_light; + if (kernel_data.integrator.use_light_tree) { +ccl_global const KernelLightTreeEmitter *kemitter = &kernel_data_fetch(light_tree_emitters, + emitter_index); +prim = kemitter->prim; +mesh_light = kemitter->mesh_light;
[Bf-blender-cvs] [42def76831e] master: Cleanup: Add a bit more detail to curves offsets comment
Commit: 42def76831e043febd2188a9a7a06a438920b96f Author: Hans Goudey Date: Mon Dec 12 13:40:06 2022 -0600 Branches: master https://developer.blender.org/rB42def76831e043febd2188a9a7a06a438920b96f Cleanup: Add a bit more detail to curves offsets comment === M source/blender/makesdna/DNA_curves_types.h === diff --git a/source/blender/makesdna/DNA_curves_types.h b/source/blender/makesdna/DNA_curves_types.h index a72a9bf4c68..847a4b8a02c 100644 --- a/source/blender/makesdna/DNA_curves_types.h +++ b/source/blender/makesdna/DNA_curves_types.h @@ -97,10 +97,10 @@ typedef struct CurvesGeometry { * this array is allocated with a length one larger than the number of curves. This is allowed * to be null when there are no curves. * - * Every curve offset must be at least one larger than the previous. - * In other words, every curve must have at least one point. + * Every curve offset must be at least one larger than the previous. In other words, every curve + * must have at least one point. The first value is 0 and the last value is #point_num. * - * \note This is *not* stored in #CustomData because its size is one larger than #curve_data. + * \note This is *not* stored as an attribute because its size is one larger than #curve_num. */ int *curve_offsets; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d2c76b4a237] gpencil-new-data-proposal: Fix: Using MEM_freeN on a non-trivial struct/class
Commit: d2c76b4a23734189df4acd9f7cef819bb71e335a Author: Hans Goudey Date: Mon Dec 12 13:35:42 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rBd2c76b4a23734189df4acd9f7cef819bb71e335a Fix: Using MEM_freeN on a non-trivial struct/class === M source/blender/blenkernel/intern/gpencil_new_proposal.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc b/source/blender/blenkernel/intern/gpencil_new_proposal.cc index 5f91d050f6b..92be1059619 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc @@ -89,7 +89,7 @@ GPFrame::GPFrame(const GPFrame &other) : GPFrame(other.layer_index) { if (other.strokes != nullptr) { /* Make sure old strokes are freed before copying. */ -MEM_SAFE_FREE(this->strokes); +MEM_delete(reinterpret_cast(this->strokes)); this->strokes = MEM_new(__func__); *reinterpret_cast(this->strokes) = CurvesGeometry::wrap(*other.strokes); @@ -102,7 +102,7 @@ GPFrame &GPFrame::operator=(const GPFrame &other) { if (this != &other && other.strokes != nullptr) { /* Make sure old strokes are freed before copying. */ -MEM_SAFE_FREE(this->strokes); +MEM_delete(reinterpret_cast(this->strokes)); this->strokes = MEM_new(__func__); *reinterpret_cast(this->strokes) = CurvesGeometry::wrap(*other.strokes); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b20c05aa2b1] gpencil-new-data-proposal: Tests: Avoid repeatedly resizing curves
Commit: b20c05aa2b1782660bc06440d922e116e0171bc9 Author: Hans Goudey Date: Mon Dec 12 13:19:50 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rBb20c05aa2b1782660bc06440d922e116e0171bc9 Tests: Avoid repeatedly resizing curves This is around four times faster === M source/blender/blenkernel/intern/gpencil_new_proposal_test.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc index a40da2a6719..3b1c56baa01 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc @@ -10,6 +10,7 @@ #include "BLI_math_vec_types.hh" #include "BKE_curves.hh" +#include "BKE_curves_utils.hh" #include "BKE_gpencil.h" #include "DNA_gpencil_types.h" @@ -36,12 +37,16 @@ static GPData build_gpencil_data(int num_layers, gpd.add_frames_on_layer(i, test_start_frames); } - for (const int i : gpd.frames().index_range()) { -for (const int j : IndexRange(strokes_per_frame)) { - GPStroke stroke = gpd.frames_for_write(i).add_new_stroke(points_per_stroke); - for (const int k : stroke.points_positions_for_write().index_range()) { -stroke.points_positions_for_write()[k] = { -float(k), float((k * j) % stroke.points_num()), float(k + j)}; + for (const int frame_i : gpd.frames().index_range()) { +CurvesGeometry &strokes = gpd.frames_for_write(frame_i).strokes_as_curves(); +strokes.resize(points_per_stroke * strokes_per_frame, strokes_per_frame); +strokes.offsets_for_write().drop_back(1).fill(points_per_stroke); +curves::accumulate_counts_to_offsets(strokes.offsets_for_write()); +MutableSpan positions = strokes.positions_for_write(); +for (const int curve_i : strokes.curves_range()) { + const IndexRange points = strokes.points_for_curve(curve_i); + for (const int i : IndexRange(points.size())) { +positions[points[i]] = {float(i), float(curve_i * i % points.size()), float(i + curve_i)}; } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [18302f3dfa5] gpencil-new-data-proposal: Fix: `strokes_as_curves()` can return null curves
Commit: 18302f3dfa5fb5e3299c8609cbf4425467048322 Author: Hans Goudey Date: Mon Dec 12 13:08:01 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rB18302f3dfa5fb5e3299c8609cbf4425467048322 Fix: `strokes_as_curves()` can return null curves === M source/blender/blenkernel/intern/gpencil_new_proposal.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc b/source/blender/blenkernel/intern/gpencil_new_proposal.cc index 551e0bd58fe..5f91d050f6b 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc @@ -164,11 +164,15 @@ bool GPFrame::operator==(const GPFrame &other) const CurvesGeometry &GPFrame::strokes_as_curves() { + if (!this->strokes) { +this->strokes = MEM_new(__func__); + } return CurvesGeometry::wrap(*this->strokes); } const CurvesGeometry &GPFrame::strokes_as_curves() const { + BLI_assert(this->strokes != nullptr); return CurvesGeometry::wrap(*this->strokes); } @@ -206,9 +210,6 @@ Vector GPFrame::strokes_for_write() GPStroke GPFrame::add_new_stroke(int new_points_num) { - if (this->strokes == nullptr) { -this->strokes = MEM_new(__func__); - } CurvesGeometry &strokes = this->strokes_as_curves(); int orig_last_offset = strokes.offsets().last(); @@ -667,4 +668,4 @@ void GPData::update_frames_array() this->runtime->frames_index_range_cache.clear(); } -} // namespace blender::bke \ No newline at end of file +} // namespace blender::bke ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [153644cefff] gpencil-new-data-proposal: Use CurvesGeometry directly instead of GPStroke, as an example
Commit: 153644cefff5ab2853d6aa4cb6ec5751fac2184d Author: Hans Goudey Date: Mon Dec 12 13:35:25 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rB153644cefff5ab2853d6aa4cb6ec5751fac2184d Use CurvesGeometry directly instead of GPStroke, as an example === M source/blender/blenkernel/intern/gpencil_new_proposal_test.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc index c3bc8347693..befd94eacd0 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc @@ -419,14 +419,17 @@ TEST(gpencil_proposal, ChangeStrokePoints) const int frame_index = data.add_frame_on_layer(layer1_index, 0); EXPECT_NE(frame_index, -1); - GPStroke stroke = data.frames_for_write(frame_index).add_new_stroke(test_positions.size()); - for (const int i : stroke.points_positions_for_write().index_range()) { -stroke.points_positions_for_write()[i] = test_positions[i]; - } + CurvesGeometry &curves = data.frames_for_write(frame_index).strokes_as_curves(); + curves.resize(curves.points_num() + test_positions.size(), curves.curves_num() + 1); + curves.offsets_for_write().last() = curves.offsets().last(1) + test_positions.size(); + + const IndexRange new_points = curves.points_for_curve(curves.curves_range().last()); + MutableSpan new_positions = curves.positions_for_write().slice(new_points); + new_positions.copy_from(test_positions); - for (const int i : stroke.points_positions().index_range()) { -EXPECT_V3_NEAR(stroke.points_positions()[i], test_positions[i], 1e-5f); + for (const int i : curves.positions().index_range()) { +EXPECT_V3_NEAR(new_positions[i], test_positions[i], 1e-5f); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4e73f60a15b] gpencil-new-data-proposal: Tests: Avoid unnecessary work when transforming curve points
Commit: 4e73f60a15b4c4b83567799e5aee88c5da4bd2a5 Author: Hans Goudey Date: Mon Dec 12 13:22:48 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rB4e73f60a15b4c4b83567799e5aee88c5da4bd2a5 Tests: Avoid unnecessary work when transforming curve points === M source/blender/blenkernel/intern/gpencil_new_proposal_test.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc index 3b1c56baa01..c3bc8347693 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc @@ -514,13 +514,8 @@ TEST(gpencil_proposal, TimeMultiFrameTransformStrokes) SCOPED_TIMER("TimeMultiFrameTransformStrokes"); for (const int i : data.frames_on_active_layer()) { GPFrame &gpf = data.frames_for_write(i); - Vector gpf_strokes = gpf.strokes_for_write(); - MutableSpan strokes_span = gpf_strokes.as_mutable_span(); - threading::parallel_for(strokes_span.index_range(), 256, [&](const IndexRange range) { -for (GPStroke &stroke : strokes_span.slice(range)) { - stroke.transform(translate_mat); -} - }); + CurvesGeometry &curves = gpf.strokes_as_curves(); + curves.transform(translate_mat); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0bdcf21a2f3] gpencil-new-data-proposal: Cleanup: Use const variables
Commit: 0bdcf21a2f3f1f96c33bfd211feca75f7ead2ec4 Author: Hans Goudey Date: Mon Dec 12 12:39:57 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rB0bdcf21a2f3f1f96c33bfd211feca75f7ead2ec4 Cleanup: Use const variables === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index 26fa75a54f5..db22449198d 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -15,10 +15,10 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) GPData new_gpd; int layer_index; - LISTBASE_FOREACH_INDEX (bGPDlayer *, old_gpl, &old_gpd->layers, layer_index) { + LISTBASE_FOREACH_INDEX (const bGPDlayer *, old_gpl, &old_gpd->layers, layer_index) { new_gpd.add_layer(std::string(old_gpl->info)); -LISTBASE_FOREACH (bGPDframe *, old_gpf, &old_gpl->frames) { +LISTBASE_FOREACH (const bGPDframe *, old_gpf, &old_gpl->frames) { int new_gpf_index{new_gpd.add_frame_on_layer(layer_index, old_gpf->framenum)}; GPFrame &new_gpf{new_gpd.frames_for_write(new_gpf_index)}; @@ -37,10 +37,10 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) "radius", ATTR_DOMAIN_POINT); int stroke_index; LISTBASE_FOREACH_INDEX (const bGPDstroke *, old_gps, &old_gpf->strokes, stroke_index) { -IndexRange point_index_in_curve{new_gps.points_for_curve(stroke_index)}; +const IndexRange point_index_in_curve{new_gps.points_for_curve(stroke_index)}; for (int point_index = 0; point_index < old_gps->totpoints; point_index++) { - bGPDspoint *old_pt{old_gps->points + point_index}; + const bGPDspoint *old_pt{old_gps->points + point_index}; new_gps_positions[point_index_in_curve[point_index]] = {old_pt->x, old_pt->y, old_pt->z}; radii.span[point_index_in_curve[point_index]] = old_pt->pressure; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [352f9eb7b66] gpencil-new-data-proposal: Fix missing resize
Commit: 352f9eb7b66cfec0bf89ad0d148ed4552b8286bb Author: Hans Goudey Date: Mon Dec 12 13:07:45 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rB352f9eb7b66cfec0bf89ad0d148ed4552b8286bb Fix missing resize === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index db22449198d..14ce1de9d04 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -29,6 +29,7 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) CurvesGeometry &new_gps{new_gpf.strokes_as_curves()}; MutableAttributeAccessor attributes = new_gps.attributes_for_write(); + new_gps.resize(offsets.last(), offsets.size() - 1); new_gps.offsets_for_write().copy_from(offsets); new_gps.curve_types_for_write().fill(CURVE_TYPE_POLY); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8ddfe747310] gpencil-new-data-proposal: Conversion: Copy radii to the curves also
Commit: 8ddfe747310a90f3077fa4977c5ab527acc924b0 Author: Hans Goudey Date: Mon Dec 12 12:39:16 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rB8ddfe747310a90f3077fa4977c5ab527acc924b0 Conversion: Copy radii to the curves also === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index 3a84cc852e6..26fa75a54f5 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -28,10 +28,13 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) } CurvesGeometry &new_gps{new_gpf.strokes_as_curves()}; + MutableAttributeAccessor attributes = new_gps.attributes_for_write(); new_gps.offsets_for_write().copy_from(offsets); new_gps.curve_types_for_write().fill(CURVE_TYPE_POLY); MutableSpan new_gps_positions{new_gps.positions_for_write()}; + SpanAttributeWriter radii = attributes.lookup_or_add_for_write_only_span( + "radius", ATTR_DOMAIN_POINT); int stroke_index; LISTBASE_FOREACH_INDEX (const bGPDstroke *, old_gps, &old_gpf->strokes, stroke_index) { IndexRange point_index_in_curve{new_gps.points_for_curve(stroke_index)}; @@ -39,8 +42,11 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) for (int point_index = 0; point_index < old_gps->totpoints; point_index++) { bGPDspoint *old_pt{old_gps->points + point_index}; new_gps_positions[point_index_in_curve[point_index]] = {old_pt->x, old_pt->y, old_pt->z}; + radii.span[point_index_in_curve[point_index]] = old_pt->pressure; } } + + radii.finish(); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [423044b7a30] gpencil-new-data-proposal: Conversion: Avoid resizing curves repeatedly
Commit: 423044b7a30eee500db3388edcce66be631a49b2 Author: Hans Goudey Date: Mon Dec 12 12:37:06 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rB423044b7a30eee500db3388edcce66be631a49b2 Conversion: Avoid resizing curves repeatedly Find the size and offsets only once, then resize, then fill the data. === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index f3181211ab8..3a84cc852e6 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -22,13 +22,17 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) int new_gpf_index{new_gpd.add_frame_on_layer(layer_index, old_gpf->framenum)}; GPFrame &new_gpf{new_gpd.frames_for_write(new_gpf_index)}; - int stroke_index; - LISTBASE_FOREACH_INDEX (const bGPDstroke *, old_gps, &old_gpf->strokes, stroke_index) { -new_gpf.add_new_stroke(old_gps->totpoints); + Vector offsets({0}); + LISTBASE_FOREACH (const bGPDstroke *, old_gps, &old_gpf->strokes) { +offsets.append(old_gps->totpoints + offsets.last()); } CurvesGeometry &new_gps{new_gpf.strokes_as_curves()}; + new_gps.offsets_for_write().copy_from(offsets); + new_gps.curve_types_for_write().fill(CURVE_TYPE_POLY); + MutableSpan new_gps_positions{new_gps.positions_for_write()}; + int stroke_index; LISTBASE_FOREACH_INDEX (const bGPDstroke *, old_gps, &old_gpf->strokes, stroke_index) { IndexRange point_index_in_curve{new_gps.points_for_curve(stroke_index)}; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b15a1270e96] gpencil-new-data-proposal: Cleanup: Use LISTBASE_FOREACH_INDEX
Commit: b15a1270e960e01f3532447b4dc89cb6d0e4303c Author: Hans Goudey Date: Mon Dec 12 12:30:59 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rBb15a1270e960e01f3532447b4dc89cb6d0e4303c Cleanup: Use LISTBASE_FOREACH_INDEX === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index 1397bf51ba0..f3181211ab8 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -14,8 +14,8 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) { GPData new_gpd; - int layer_index{0}; - LISTBASE_FOREACH (bGPDlayer *, old_gpl, &old_gpd->layers) { + int layer_index; + LISTBASE_FOREACH_INDEX (bGPDlayer *, old_gpl, &old_gpd->layers, layer_index) { new_gpd.add_layer(std::string(old_gpl->info)); LISTBASE_FOREACH (bGPDframe *, old_gpf, &old_gpl->frames) { @@ -38,8 +38,6 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) } } } - -++layer_index; } return new_gpd; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5b43c0ce2dc] gpencil-new-data-proposal: Cleanup: Comment formatting
Commit: 5b43c0ce2dc4a62a79adb6198cced36af4039e61 Author: Hans Goudey Date: Mon Dec 12 12:22:05 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rB5b43c0ce2dc4a62a79adb6198cced36af4039e61 Cleanup: Comment formatting === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index 88df6a38e60..1397bf51ba0 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -63,8 +63,8 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData &new_gpd) BLI_listbase_clear(&old_gpl->frames); /* Add frames of correct layer index. - Assumes that frames in new data structure are sorted by layer index. -*/ + * Assumes that frames in new data structure are sorted by layer index. + */ while ((frame_index < new_gpd.frames_size) && (new_gpd.frames_array[frame_index].layer_index == layer_index)) { bGPDframe *old_gpf = reinterpret_cast(MEM_mallocN(sizeof(bGPDframe), __func__)); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b75ca244216] gpencil-new-data-proposal: Cleanup: Use simpler for loop syntax
Commit: b75ca244216bf654a5745182840dc9ec818e304a Author: Hans Goudey Date: Mon Dec 12 12:21:35 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rBb75ca244216bf654a5745182840dc9ec818e304a Cleanup: Use simpler for loop syntax This also means the index can be const so it's impossible to change it inside the loop. === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index 964b0bd10e8..88df6a38e60 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -53,7 +53,7 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData &new_gpd) old_gpd->totlayer = old_gpd->totframe = old_gpd->totstroke = 0; int frame_index{0}; - for (int layer_index = 0; layer_index < new_gpd.layers_size; layer_index++) { + for (const int layer_index : IndexRange(new_gpd.layers_size)) { bGPDlayer *old_gpl = reinterpret_cast(MEM_mallocN(sizeof(bGPDlayer), __func__)); const ::GPLayer *new_gpl{new_gpd.layers_array + layer_index}; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3c81c77cf14] gpencil-new-data-proposal: Merge branch 'master' into gpencil-new-data-proposal
Commit: 3c81c77cf142b59173b7f2b1426274aece9a8d12 Author: Hans Goudey Date: Mon Dec 12 12:15:44 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rB3c81c77cf142b59173b7f2b1426274aece9a8d12 Merge branch 'master' into gpencil-new-data-proposal === === diff --cc source/blender/blenlib/BLI_memory_utils.hh index c97a4424d95,6f119a49f01..b82108f66a1 --- a/source/blender/blenlib/BLI_memory_utils.hh +++ b/source/blender/blenlib/BLI_memory_utils.hh @@@ -147,119 -58,21 +58,42 @@@ template void uninitialized template void uninitialized_convert_n(const From *src, int64_t n, To *dst) { - BLI_assert(n >= 0); - - int64_t current = 0; - try { - for (; current < n; current++) { - new (static_cast(dst + current)) To(static_cast(src[current])); - } - } - catch (...) { - destruct_n(dst, current); - throw; - } + std::uninitialized_copy_n(src, n, dst); } - /** - * Move n values from src to dst. - * - * Exception Safety: Basic. - * - * Before: - * src: initialized - * dst: initialized - * After: - * src: initialized, moved-from - * dst: initialized - */ template void initialized_move_n(T *src, int64_t n, T *dst) { - BLI_assert(n >= 0); - - for (int64_t i = 0; i < n; i++) { - dst[i] = std::move(src[i]); - } + std::copy_n(std::make_move_iterator(src), n, dst); } - /** - * Move n values from src to dst. - * - * Exception Safety: Basic. - * - * Before: - * src: initialized - * dst: uninitialized - * After: - * src: initialized, moved-from - * dst: initialized - */ template void uninitialized_move_n(T *src, int64_t n, T *dst) { - BLI_assert(n >= 0); - - int64_t current = 0; - try { - for (; current < n; current++) { - new (static_cast(dst + current)) T(std::move(src[current])); - } - } - catch (...) { - destruct_n(dst, current); - throw; - } + std::uninitialized_copy_n(std::make_move_iterator(src), n, dst); } +/** + * Move n values from src to dst starting with the last value. + * + * Exception Safety: Basic. + * + * Before: + * src: initialized + * dst: initialized + * After: + * src: initialized, moved-from + * dst: initialized + */ +template void initialized_reversed_move_n(T *src, int64_t n, T *dst) +{ + BLI_assert(n >= 0); + + for (int64_t i = n - 1; i >= 0; i--) { +dst[i] = std::move(src[i]); + } +} + - /** - * Relocate n values from src to dst. Relocation is a move followed by destruction of the src - * value. - * - * Exception Safety: Basic. - * - * Before: - * src: initialized - * dst: initialized - * After: - * src: uninitialized - * dst: initialized - */ template void initialized_relocate_n(T *src, int64_t n, T *dst) { - BLI_assert(n >= 0); - initialized_move_n(src, n, dst); destruct_n(src, n); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [934316b925d] gpencil-new-data-proposal: Cleanup: Use LISTBASE_FOREACH_INDEX
Commit: 934316b925dd580a58aad5906a63eff001a7ac69 Author: Hans Goudey Date: Mon Dec 12 12:20:42 2022 -0600 Branches: gpencil-new-data-proposal https://developer.blender.org/rB934316b925dd580a58aad5906a63eff001a7ac69 Cleanup: Use LISTBASE_FOREACH_INDEX Avoid the need to manually incremend the index === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index c81e200c25c..964b0bd10e8 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -22,24 +22,20 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) int new_gpf_index{new_gpd.add_frame_on_layer(layer_index, old_gpf->framenum)}; GPFrame &new_gpf{new_gpd.frames_for_write(new_gpf_index)}; - int stroke_index{0}; - LISTBASE_FOREACH (const bGPDstroke *, old_gps, &old_gpf->strokes) { + int stroke_index; + LISTBASE_FOREACH_INDEX (const bGPDstroke *, old_gps, &old_gpf->strokes, stroke_index) { new_gpf.add_new_stroke(old_gps->totpoints); -++stroke_index; } CurvesGeometry &new_gps{new_gpf.strokes_as_curves()}; MutableSpan new_gps_positions{new_gps.positions_for_write()}; - stroke_index = 0; - LISTBASE_FOREACH (const bGPDstroke *, old_gps, &old_gpf->strokes) { + LISTBASE_FOREACH_INDEX (const bGPDstroke *, old_gps, &old_gpf->strokes, stroke_index) { IndexRange point_index_in_curve{new_gps.points_for_curve(stroke_index)}; for (int point_index = 0; point_index < old_gps->totpoints; point_index++) { bGPDspoint *old_pt{old_gps->points + point_index}; new_gps_positions[point_index_in_curve[point_index]] = {old_pt->x, old_pt->y, old_pt->z}; } - -++stroke_index; } } @@ -113,4 +109,4 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData &new_gpd) return old_gpd; } -} // namespace blender::bke \ No newline at end of file +} // namespace blender::bke ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f95de78ca2f] master: Fix memory leak in lite build with animation rendering
Commit: f95de78ca2f14ad42bf06dae71ae0122045e31a9 Author: Iliya Katueshenock Date: Mon Dec 12 17:16:08 2022 +0100 Branches: master https://developer.blender.org/rBf95de78ca2f14ad42bf06dae71ae0122045e31a9 Fix memory leak in lite build with animation rendering Differential Revision: https://developer.blender.org/D16745 === M source/blender/render/intern/pipeline.cc === diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index c3a6aa95700..4a926bb47cd 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -2126,6 +2126,7 @@ void RE_RenderAnim(Render *re, mh = BKE_movie_handle_get(rd.im_format.imtype); if (mh == nullptr) { + render_pipeline_free(re); BKE_report(re->reports, RPT_ERROR, "Movie format unsupported"); return; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e4f9c50928d] master: Fix T102990: OpenVDB files load very slow from network drives
Commit: e4f9c50928d36b5eb61b36f2393439bd2d72e004 Author: Brecht Van Lommel Date: Mon Dec 12 18:21:34 2022 +0100 Branches: master https://developer.blender.org/rBe4f9c50928d36b5eb61b36f2393439bd2d72e004 Fix T102990: OpenVDB files load very slow from network drives The OpenVDB delay loading of voxel leaf data using mmap works poorly on network drives. It has a mechanism to make a temporary local file copy to avoid this, but we disabled that as it leads to other problems. Now disable delay loading entirely. It's not clear that this has much benefit in Blender. For rendering we need to load the entire grid to convert to NanoVDB, and for geometry nodes there also are no cases where we only need part of grids. === M intern/cycles/hydra/field.cpp M source/blender/blenkernel/intern/volume.cc === diff --git a/intern/cycles/hydra/field.cpp b/intern/cycles/hydra/field.cpp index 67945be9d52..7cdb4c80d79 100644 --- a/intern/cycles/hydra/field.cpp +++ b/intern/cycles/hydra/field.cpp @@ -26,9 +26,12 @@ class HdCyclesVolumeLoader : public VDBImageLoader { HdCyclesVolumeLoader(const std::string &filePath, const std::string &gridName) : VDBImageLoader(gridName) { +/* Disably delay loading and file copying, this has poor performance + * on network drivers. */ +const bool delay_load = false; openvdb::io::File file(filePath); file.setCopyMaxBytes(0); -if (file.open()) { +if (file.open(delay_load)) { grid = file.readGrid(gridName); } } diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index e81657f9ef0..ae921764de4 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -324,8 +324,11 @@ struct VolumeGrid { * holding a mutex lock. */ blender::threading::isolate_task([&] { try { +/* Disably delay loading and file copying, this has poor performance + * on network drivers. */ +const bool delay_load = false; file.setCopyMaxBytes(0); -file.open(); +file.open(delay_load); openvdb::GridBase::Ptr vdb_grid = file.readGrid(name()); entry->grid->setTree(vdb_grid->baseTreePtr()); } @@ -883,8 +886,11 @@ bool BKE_volume_load(const Volume *volume, const Main *bmain) openvdb::GridPtrVec vdb_grids; try { +/* Disably delay loading and file copying, this has poor performance + * on network drivers. */ +const bool delay_load = false; file.setCopyMaxBytes(0); -file.open(); +file.open(delay_load); vdb_grids = *(file.readAllGridMetadata()); grids.metadata = file.getMetadata(); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [95a792a6338] master: Fix wrong Cycles standalone exposure default value, should be 1
Commit: 95a792a6338b8c72cd186e029cdb6056303dc0bd Author: Brecht Van Lommel Date: Mon Dec 12 17:52:51 2022 +0100 Branches: master https://developer.blender.org/rB95a792a6338b8c72cd186e029cdb6056303dc0bd Fix wrong Cycles standalone exposure default value, should be 1 === M intern/cycles/scene/film.cpp === diff --git a/intern/cycles/scene/film.cpp b/intern/cycles/scene/film.cpp index cffa6acad59..67439b25868 100644 --- a/intern/cycles/scene/film.cpp +++ b/intern/cycles/scene/film.cpp @@ -88,7 +88,7 @@ NODE_DEFINE(Film) { NodeType *type = NodeType::add("film", create); - SOCKET_FLOAT(exposure, "Exposure", 0.8f); + SOCKET_FLOAT(exposure, "Exposure", 1.0f); SOCKET_FLOAT(pass_alpha_threshold, "Pass Alpha Threshold", 0.0f); static NodeEnum filter_enum; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [312e42708f8] master: Fix T103066: Cycles missing full constant foler for mix float and mix vector
Commit: 312e42708f8073ef0882d11376c30dee5ac1aef8 Author: Brecht Van Lommel Date: Mon Dec 12 17:28:59 2022 +0100 Branches: master https://developer.blender.org/rB312e42708f8073ef0882d11376c30dee5ac1aef8 Fix T103066: Cycles missing full constant foler for mix float and mix vector === M intern/cycles/scene/constant_fold.cpp M intern/cycles/scene/constant_fold.h M intern/cycles/scene/shader_nodes.cpp === diff --git a/intern/cycles/scene/constant_fold.cpp b/intern/cycles/scene/constant_fold.cpp index 1aa4515a087..224c8774cc6 100644 --- a/intern/cycles/scene/constant_fold.cpp +++ b/intern/cycles/scene/constant_fold.cpp @@ -386,6 +386,46 @@ void ConstantFolder::fold_mix_color(NodeMix type, bool clamp_factor, bool clamp) } } +void ConstantFolder::fold_mix_float(bool clamp_factor, bool clamp) const +{ + ShaderInput *fac_in = node->input("Factor"); + ShaderInput *float1_in = node->input("A"); + ShaderInput *float2_in = node->input("B"); + + float fac = clamp_factor ? saturatef(node->get_float(fac_in->socket_type)) : + node->get_float(fac_in->socket_type); + bool fac_is_zero = !fac_in->link && fac == 0.0f; + bool fac_is_one = !fac_in->link && fac == 1.0f; + + /* remove no-op node when factor is 0.0 */ + if (fac_is_zero) { +if (try_bypass_or_make_constant(float1_in, clamp)) { + return; +} + } + + /* remove useless mix floats nodes */ + if (float1_in->link && float2_in->link) { +if (float1_in->link == float2_in->link) { + try_bypass_or_make_constant(float1_in, clamp); + return; +} + } + else if (!float1_in->link && !float2_in->link) { +float value1 = node->get_float(float1_in->socket_type); +float value2 = node->get_float(float2_in->socket_type); +if (value1 == value2) { + try_bypass_or_make_constant(float1_in, clamp); + return; +} + } + /* remove no-op mix float node when factor is 1.0 */ + if (fac_is_one) { +try_bypass_or_make_constant(float2_in, clamp); +return; + } +} + void ConstantFolder::fold_math(NodeMathType type) const { ShaderInput *value1_in = node->input("Value1"); diff --git a/intern/cycles/scene/constant_fold.h b/intern/cycles/scene/constant_fold.h index 246ff2d31ee..14097e1a0e4 100644 --- a/intern/cycles/scene/constant_fold.h +++ b/intern/cycles/scene/constant_fold.h @@ -52,6 +52,7 @@ class ConstantFolder { /* Specific nodes. */ void fold_mix(NodeMix type, bool clamp) const; void fold_mix_color(NodeMix type, bool clamp_factor, bool clamp) const; + void fold_mix_float(bool clamp_factor, bool clamp) const; void fold_math(NodeMathType type) const; void fold_vector_math(NodeVectorMathType type) const; void fold_mapping(NodeMappingType type) const; diff --git a/intern/cycles/scene/shader_nodes.cpp b/intern/cycles/scene/shader_nodes.cpp index f032c52c1af..a64953c03ec 100644 --- a/intern/cycles/scene/shader_nodes.cpp +++ b/intern/cycles/scene/shader_nodes.cpp @@ -5132,6 +5132,9 @@ void MixFloatNode::constant_fold(const ConstantFolder &folder) } folder.make_constant(a * (1 - fac) + b * fac); } + else { +folder.fold_mix_float(use_clamp, false); + } } /* Mix Vector */ @@ -5185,6 +5188,9 @@ void MixVectorNode::constant_fold(const ConstantFolder &folder) } folder.make_constant(a * (one_float3() - fac) + b * fac); } + else { +folder.fold_mix_color(NODE_MIX_BLEND, use_clamp, false); + } } /* Mix Vector Non Uniform */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f53bd178366] master: Cycles: take into account film exposure for light sampling threshold
Commit: f53bd178366a95c3cef8c4b1b99b4d7a0cdcf4eb Author: Brecht Van Lommel Date: Mon Dec 12 17:51:21 2022 +0100 Branches: master https://developer.blender.org/rBf53bd178366a95c3cef8c4b1b99b4d7a0cdcf4eb Cycles: take into account film exposure for light sampling threshold To avoid issues with lights being either skipped or sampled unnecessarily when the exposure is set low or high. Contributed by Alaska. Differential Revision: https://developer.blender.org/D16703 === M intern/cycles/scene/integrator.cpp === diff --git a/intern/cycles/scene/integrator.cpp b/intern/cycles/scene/integrator.cpp index 64af0dadaa6..1aaac121c31 100644 --- a/intern/cycles/scene/integrator.cpp +++ b/intern/cycles/scene/integrator.cpp @@ -253,7 +253,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene kintegrator->use_light_tree = scene->integrator->use_light_tree; if (light_sampling_threshold > 0.0f) { -kintegrator->light_inv_rr_threshold = 1.0f / light_sampling_threshold; +kintegrator->light_inv_rr_threshold = scene->film->get_exposure() / light_sampling_threshold; } else { kintegrator->light_inv_rr_threshold = 0.0f; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [18abc2feaad] master: Fix Cycles light tree not working with negative light strength
Commit: 18abc2feaad6ccf162ee4a254405f854f705d101 Author: Brecht Van Lommel Date: Mon Dec 12 17:22:04 2022 +0100 Branches: master https://developer.blender.org/rB18abc2feaad6ccf162ee4a254405f854f705d101 Fix Cycles light tree not working with negative light strength Use absolute value of emission as estimate to make this work. Contributed by Alaska. Differential Revision: https://developer.blender.org/D16718 === M intern/cycles/scene/light_tree.cpp M intern/cycles/scene/shader.cpp === diff --git a/intern/cycles/scene/light_tree.cpp b/intern/cycles/scene/light_tree.cpp index 9bf4bdca097..f9bd479cf1c 100644 --- a/intern/cycles/scene/light_tree.cpp +++ b/intern/cycles/scene/light_tree.cpp @@ -181,7 +181,9 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id) strength *= lamp->get_shader()->emission_estimate; } -energy = average(strength); +/* Use absolute value of energy so lights with negative strength are properly + * supported in the light tree. */ +energy = fabsf(average(strength)); } } diff --git a/intern/cycles/scene/shader.cpp b/intern/cycles/scene/shader.cpp index ca15d0e1c44..09255d7cee4 100644 --- a/intern/cycles/scene/shader.cpp +++ b/intern/cycles/scene/shader.cpp @@ -349,7 +349,7 @@ void Shader::estimate_emission() } ShaderInput *surf = graph->output()->input("Surface"); - emission_estimate = output_estimate_emission(surf->link, emission_is_constant); + emission_estimate = fabs(output_estimate_emission(surf->link, emission_is_constant)); if (is_zero(emission_estimate)) { emission_sampling = EMISSION_SAMPLING_NONE; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6a478622151] universal-scene-description: USD: Path Mask import option improvements.
Commit: 6a478622151cce676f28e2c02b35b5e2c8200c24 Author: Michael Kowalski Date: Mon Dec 12 12:26:29 2022 -0500 Branches: universal-scene-description https://developer.blender.org/rB6a478622151cce676f28e2c02b35b5e2c8200c24 USD: Path Mask import option improvements. The prim_path_mask USD import option string property length is now unlimited. Updated the Path Mask option tooltip. === M source/blender/editors/io/io_usd.c === diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c index 05dc0cbf986..0e26d6e8820 100644 --- a/source/blender/editors/io/io_usd.c +++ b/source/blender/editors/io/io_usd.c @@ -1374,9 +1374,10 @@ void WM_OT_usd_import(struct wmOperatorType *ot) RNA_def_string(ot->srna, "prim_path_mask", NULL, - 1024, + 0, "Path Mask", - "Import only the subset of the USD scene rooted at the given primitive"); + "Import only the primitive at the given path and its descendents. " + "Multiple paths may be specified in a list delimited by spaces, commas or somicolons"); RNA_def_boolean(ot->srna, "import_guide", false, "Guide", "Import guide geometry"); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a560f39ee89] gpencil-new-data-proposal: add conversion of point positions
Commit: a560f39ee89882a97ba46841c345affd9f25f768 Author: Amelie Fondevilla Date: Mon Dec 12 18:18:20 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rBa560f39ee89882a97ba46841c345affd9f25f768 add conversion of point positions === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index 9541e88106b..c81e200c25c 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -22,8 +22,24 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) int new_gpf_index{new_gpd.add_frame_on_layer(layer_index, old_gpf->framenum)}; GPFrame &new_gpf{new_gpd.frames_for_write(new_gpf_index)}; + int stroke_index{0}; LISTBASE_FOREACH (const bGPDstroke *, old_gps, &old_gpf->strokes) { new_gpf.add_new_stroke(old_gps->totpoints); +++stroke_index; + } + + CurvesGeometry &new_gps{new_gpf.strokes_as_curves()}; + MutableSpan new_gps_positions{new_gps.positions_for_write()}; + stroke_index = 0; + LISTBASE_FOREACH (const bGPDstroke *, old_gps, &old_gpf->strokes) { +IndexRange point_index_in_curve{new_gps.points_for_curve(stroke_index)}; + +for (int point_index = 0; point_index < old_gps->totpoints; point_index++) { + bGPDspoint *old_pt{old_gps->points + point_index}; + new_gps_positions[point_index_in_curve[point_index]] = {old_pt->x, old_pt->y, old_pt->z}; +} + +++stroke_index; } } @@ -73,6 +89,15 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData &new_gpd) old_gps->editcurve = nullptr; old_gps->dvert = nullptr; +Span new_gps_positions = new_gps.positions(); + +int point_index{0}; +for (int new_gps_point_index : new_gps.points_for_curve(stroke_index)) { + bGPDspoint *pt = &old_gps->points[point_index]; + copy_v3_v3(&pt->x, new_gps_positions[new_gps_point_index]); + ++point_index; +} + BLI_addtail(&old_gpf->strokes, old_gps); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [53885b6eaab] gpencil-new-data-proposal: adding stroke comparison test from new to old data structure
Commit: 53885b6eaabfc8cfea509107719a8f0b2f92f337 Author: Amelie Fondevilla Date: Mon Dec 12 17:16:21 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rB53885b6eaabfc8cfea509107719a8f0b2f92f337 adding stroke comparison test from new to old data structure === M source/blender/blenkernel/intern/gpencil_new_proposal_test.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc index 4a73ba82b80..23a4e20a224 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc @@ -145,6 +145,22 @@ static void insert_new_stroke_old_gpencil_data(bGPDframe *gpf, BLI_addtail(&gpf->strokes, gps); } +static void insert_new_stroke_new_gpencil_data(GPFrame &gpf, + int point_num, + float *position, + float *pressure) +{ + gpf.add_new_stroke(point_num); + CurvesGeometry &curves = gpf.strokes_as_curves(); + int point_index{0}; + for (float3 &pos : curves.positions_for_write()) { +pos.x = position[3 * point_index]; +pos.y = position[3 * point_index + 1]; +pos.z = position[3 * point_index + 2]; +++point_index; + } +} + static void compare_gpencil_stroke_data(const CurvesGeometry &curves, int curve_index, const bGPDstroke *stk) @@ -570,4 +586,22 @@ TEST(gpencil_proposal, OldToNewStrokeConversion) free_old_gpencil_data(old_data); } + +TEST(gpencil_proposal, NewToOldStrokeConversion) +{ + int layers_num = 1, frames_num = 1, strokes_num = 0, points_num = 0; + + GPData data = build_gpencil_data(layers_num, frames_num, strokes_num, points_num); + + const int point_num{5}; + float pos[point_num * 3] = {0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7}; + float prs[point_num] = {0.5, 0.75, 1, 1.5, 1.75}; + insert_new_stroke_new_gpencil_data(data.frames_for_write(0), point_num, pos, prs); + + bGPdata *old_data = convert_new_to_old_gpencil_data(data); + + compare_gpencil_data_structures(data, old_data); + + free_old_gpencil_data(old_data); +} } // namespace blender::bke::gpencil::tests ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [274eda29933] gpencil-new-data-proposal: conversion functions adds strokes and points
Commit: 274eda2993316f4a5b33dedf8a4e1be7906151ab Author: Amelie Fondevilla Date: Mon Dec 12 16:48:54 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rB274eda2993316f4a5b33dedf8a4e1be7906151ab conversion functions adds strokes and points === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index 267d6cf067a..9541e88106b 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -21,6 +21,10 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) LISTBASE_FOREACH (bGPDframe *, old_gpf, &old_gpl->frames) { int new_gpf_index{new_gpd.add_frame_on_layer(layer_index, old_gpf->framenum)}; GPFrame &new_gpf{new_gpd.frames_for_write(new_gpf_index)}; + + LISTBASE_FOREACH (const bGPDstroke *, old_gps, &old_gpf->strokes) { +new_gpf.add_new_stroke(old_gps->totpoints); + } } ++layer_index; @@ -36,10 +40,10 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData &new_gpd) BLI_listbase_clear(&old_gpd->layers); old_gpd->totlayer = old_gpd->totframe = old_gpd->totstroke = 0; - int frm_offset{0}; - for (int lay_i = 0; lay_i < new_gpd.layers_size; lay_i++) { + int frame_index{0}; + for (int layer_index = 0; layer_index < new_gpd.layers_size; layer_index++) { bGPDlayer *old_gpl = reinterpret_cast(MEM_mallocN(sizeof(bGPDlayer), __func__)); -const ::GPLayer *new_gpl{new_gpd.layers_array + lay_i}; +const ::GPLayer *new_gpl{new_gpd.layers_array + layer_index}; sprintf(old_gpl->info, "%s", new_gpl->name); @@ -49,17 +53,32 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData &new_gpd) /* Add frames of correct layer index. Assumes that frames in new data structure are sorted by layer index. */ -while ((frm_offset < new_gpd.frames_size) && - (new_gpd.frames_array[frm_offset].layer_index == lay_i)) { - bGPDframe *gpf = reinterpret_cast(MEM_mallocN(sizeof(bGPDframe), __func__)); - const ::GPFrame *new_gpf{new_gpd.frames_array + frm_offset}; - gpf->framenum = new_gpf->start_time; - - BLI_listbase_clear(&gpf->strokes); +while ((frame_index < new_gpd.frames_size) && + (new_gpd.frames_array[frame_index].layer_index == layer_index)) { + bGPDframe *old_gpf = reinterpret_cast(MEM_mallocN(sizeof(bGPDframe), __func__)); + const GPFrame &new_gpf{new_gpd.frames(frame_index)}; + old_gpf->framenum = new_gpf.start_time; + + BLI_listbase_clear(&old_gpf->strokes); + const CurvesGeometry &new_gps{new_gpf.strokes_as_curves()}; + for (int stroke_index = 0; stroke_index < new_gpf.strokes_num(); stroke_index++) { +bGPDstroke *old_gps = reinterpret_cast( +MEM_mallocN(sizeof(bGPDstroke), __func__)); + +int point_num{new_gps.points_num_for_curve(stroke_index)}; +old_gps->points = reinterpret_cast( +MEM_calloc_arrayN(point_num, sizeof(bGPDspoint), __func__)); +old_gps->totpoints = point_num; +old_gps->triangles = nullptr; +old_gps->editcurve = nullptr; +old_gps->dvert = nullptr; + +BLI_addtail(&old_gpf->strokes, old_gps); + } ++(old_gpd->totframe); - BLI_addtail(&old_gpl->frames, gpf); - ++frm_offset; + BLI_addtail(&old_gpl->frames, old_gpf); + ++frame_index; } ++(old_gpd->totlayer); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [509445955c2] gpencil-new-data-proposal: fix stroke insertion in new data structure
Commit: 509445955c24d905e9cf63e7f039bc36985dac1a Author: Amelie Fondevilla Date: Mon Dec 12 18:03:11 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rB509445955c24d905e9cf63e7f039bc36985dac1a fix stroke insertion in new data structure === M source/blender/blenkernel/intern/gpencil_new_proposal_test.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc index 23a4e20a224..a40da2a6719 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc @@ -150,13 +150,16 @@ static void insert_new_stroke_new_gpencil_data(GPFrame &gpf, float *position, float *pressure) { + int stroke_index{gpf.strokes_num()}; gpf.add_new_stroke(point_num); CurvesGeometry &curves = gpf.strokes_as_curves(); + int point_index{0}; - for (float3 &pos : curves.positions_for_write()) { -pos.x = position[3 * point_index]; -pos.y = position[3 * point_index + 1]; -pos.z = position[3 * point_index + 2]; + MutableSpan pos = curves.positions_for_write(); + for (int point_index_in_curve : curves.points_for_curve(stroke_index)) { +pos[point_index_in_curve].x = position[3 * point_index]; +pos[point_index_in_curve].y = position[3 * point_index + 1]; +pos[point_index_in_curve].z = position[3 * point_index + 2]; ++point_index; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9929b367df6] gpencil-new-data-proposal: refactor
Commit: 9929b367df68cc8028d1a342d6b822fd269d6baf Author: Amelie Fondevilla Date: Mon Dec 12 16:29:13 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rB9929b367df68cc8028d1a342d6b822fd269d6baf refactor === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index 853d43f..267d6cf067a 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -15,11 +15,12 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) GPData new_gpd; int layer_index{0}; - LISTBASE_FOREACH (bGPDlayer *, lay, &old_gpd->layers) { -new_gpd.add_layer(std::string(lay->info)); + LISTBASE_FOREACH (bGPDlayer *, old_gpl, &old_gpd->layers) { +new_gpd.add_layer(std::string(old_gpl->info)); -LISTBASE_FOREACH (bGPDframe *, frm, &lay->frames) { - new_gpd.add_frame_on_layer(layer_index, frm->framenum); +LISTBASE_FOREACH (bGPDframe *, old_gpf, &old_gpl->frames) { + int new_gpf_index{new_gpd.add_frame_on_layer(layer_index, old_gpf->framenum)}; + GPFrame &new_gpf{new_gpd.frames_for_write(new_gpf_index)}; } ++layer_index; @@ -30,19 +31,20 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) bGPdata *convert_new_to_old_gpencil_data(const GPData &new_gpd) { - bGPdata *gpd = reinterpret_cast(MEM_mallocN(sizeof(bGPdata), __func__)); + bGPdata *old_gpd = reinterpret_cast(MEM_mallocN(sizeof(bGPdata), __func__)); - BLI_listbase_clear(&gpd->layers); - gpd->totlayer = gpd->totframe = gpd->totstroke = 0; + BLI_listbase_clear(&old_gpd->layers); + old_gpd->totlayer = old_gpd->totframe = old_gpd->totstroke = 0; int frm_offset{0}; for (int lay_i = 0; lay_i < new_gpd.layers_size; lay_i++) { -bGPDlayer *gpl = reinterpret_cast(MEM_mallocN(sizeof(bGPDlayer), __func__)); -const ::GPLayer *lay{new_gpd.layers_array + lay_i}; -sprintf(gpl->info, "%s", lay->name); +bGPDlayer *old_gpl = reinterpret_cast(MEM_mallocN(sizeof(bGPDlayer), __func__)); +const ::GPLayer *new_gpl{new_gpd.layers_array + lay_i}; -BLI_listbase_clear(&gpl->mask_layers); -BLI_listbase_clear(&gpl->frames); +sprintf(old_gpl->info, "%s", new_gpl->name); + +BLI_listbase_clear(&old_gpl->mask_layers); +BLI_listbase_clear(&old_gpl->frames); /* Add frames of correct layer index. Assumes that frames in new data structure are sorted by layer index. @@ -50,21 +52,21 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData &new_gpd) while ((frm_offset < new_gpd.frames_size) && (new_gpd.frames_array[frm_offset].layer_index == lay_i)) { bGPDframe *gpf = reinterpret_cast(MEM_mallocN(sizeof(bGPDframe), __func__)); - const ::GPFrame *frm{new_gpd.frames_array + frm_offset}; - gpf->framenum = frm->start_time; + const ::GPFrame *new_gpf{new_gpd.frames_array + frm_offset}; + gpf->framenum = new_gpf->start_time; BLI_listbase_clear(&gpf->strokes); - ++(gpd->totframe); - BLI_addtail(&gpl->frames, gpf); + ++(old_gpd->totframe); + BLI_addtail(&old_gpl->frames, gpf); ++frm_offset; } -++(gpd->totlayer); -BLI_addtail(&gpd->layers, gpl); +++(old_gpd->totlayer); +BLI_addtail(&old_gpd->layers, old_gpl); } - return gpd; + return old_gpd; } } // namespace blender::bke \ No newline at end of file ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7c123f2da59] gpencil-new-data-proposal: refactor
Commit: 7c123f2da590f6fc4bc8a079f0f2822e05b647dd Author: Amelie Fondevilla Date: Mon Dec 12 15:47:09 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rB7c123f2da590f6fc4bc8a079f0f2822e05b647dd refactor === M source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc index ccd71823821..853d43f 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc @@ -14,21 +14,15 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd) { GPData new_gpd; - /* Add all layers */ - Vector layer_names; + int layer_index{0}; LISTBASE_FOREACH (bGPDlayer *, lay, &old_gpd->layers) { -layer_names.append(std::string(lay->info)); - } - new_gpd.add_layers(layer_names.as_span()); +new_gpd.add_layer(std::string(lay->info)); - /* Add all frames */ - int layer_index{-1}; - LISTBASE_FOREACH (bGPDlayer *, lay, &old_gpd->layers) { -Vector frame_indices; LISTBASE_FOREACH (bGPDframe *, frm, &lay->frames) { - frame_indices.append(frm->framenum); + new_gpd.add_frame_on_layer(layer_index, frm->framenum); } -new_gpd.add_frames_on_layer(++layer_index, frame_indices.as_span()); + +++layer_index; } return new_gpd; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [dabc06f4893] gpencil-new-data-proposal: minor fix
Commit: dabc06f48932e9a457c3a5b251da43265ff57d6c Author: Amelie Fondevilla Date: Mon Dec 12 16:19:28 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rBdabc06f48932e9a457c3a5b251da43265ff57d6c minor fix === M source/blender/blenkernel/intern/gpencil_new_proposal_test.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc index 7665e6ea987..4a73ba82b80 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc @@ -215,6 +215,7 @@ static void compare_gpencil_data_structures(const GPData &new_gpd, const bGPdata ++frame_id; } +++layer_id; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4fdeccf829b] gpencil-new-data-proposal: test compare stroke point positions
Commit: 4fdeccf829b57142f8a973ae80c5e29fa56517ac Author: Amelie Fondevilla Date: Mon Dec 12 14:59:34 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rB4fdeccf829b57142f8a973ae80c5e29fa56517ac test compare stroke point positions === M source/blender/blenkernel/intern/gpencil_new_proposal_test.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc index c000f818edd..061b1e027fd 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc @@ -9,6 +9,7 @@ #include "BLI_index_mask_ops.hh" #include "BLI_math_vec_types.hh" +#include "BKE_curves.hh" #include "BKE_gpencil.h" #include "DNA_gpencil_types.h" @@ -121,6 +122,58 @@ static void free_old_gpencil_data(bGPdata *gpd) MEM_SAFE_FREE(gpd); } +static void insert_new_stroke_old_gpencil_data(bGPDframe *gpf, + int point_num, + float *position, + float *pressure) +{ + + bGPDstroke *gps = reinterpret_cast(MEM_mallocN(sizeof(bGPDstroke), __func__)); + gps->totpoints = point_num; + gps->points = reinterpret_cast( + MEM_calloc_arrayN(point_num, sizeof(bGPDspoint), __func__)); + gps->triangles = nullptr; + gps->editcurve = nullptr; + gps->dvert = nullptr; + + for (int pt_i = 0; pt_i < point_num; pt_i++) { +bGPDspoint *pt = &gps->points[pt_i]; +copy_v3_v3(&pt->x, position + 3 * pt_i); +pt->pressure = pressure[pt_i]; + } + + BLI_addtail(&gpf->strokes, gps); +} + +static void compare_gpencil_stroke_data(const CurvesGeometry &curves, +int curve_index, +const bGPDstroke *stk) +{ + /* Stroke/Curve length */ + int curve_point_num{curves.points_num_for_curve(curve_index)}; + EXPECT_EQ(curve_point_num, stk->totpoints); + if (curve_point_num != stk->totpoints) { +return; + } + + /* Get curve attributes */ + Span curve_positions{curves.positions()}; + + IndexRange curve_id{curves.points_for_curve(curve_index)}; + int stk_point_id{0}; + for (int curve_point_id : curve_id) { +const bGPDspoint *stk_point{stk->points + stk_point_id}; +const float3 &curve_pos{curve_positions[curve_point_id]}; + +/* Point positions */ +EXPECT_EQ(curve_pos.x, stk_point->x); +EXPECT_EQ(curve_pos.y, stk_point->y); +EXPECT_EQ(curve_pos.z, stk_point->z); + +++stk_point_id; + } +} + static void compare_gpencil_data_structures(const GPData &new_gpd, const bGPdata *old_gpd) { /* Compare Layers */ @@ -128,6 +181,9 @@ static void compare_gpencil_data_structures(const GPData &new_gpd, const bGPdata int index{-1}; LISTBASE_FOREACH (bGPDlayer *, old_gpl, &old_gpd->layers) { +if (index >= new_gpd.layers_size) { + break; +} const ::GPLayer *new_gpl = &(new_gpd.layers_array[++index]); EXPECT_EQ(std::strcmp(new_gpl->name, old_gpl->info), 0); } @@ -136,22 +192,34 @@ static void compare_gpencil_data_structures(const GPData &new_gpd, const bGPdata EXPECT_EQ(new_gpd.frames_size, old_gpd->totframe); /* Get vector of frames. */ - Vector> old_gpd_frames; + Vector> old_gpd_frames; int layer_id{0}; LISTBASE_FOREACH (bGPDlayer *, old_gpl, &old_gpd->layers) { LISTBASE_FOREACH (bGPDframe *, old_gpf, &old_gpl->frames) { - old_gpd_frames.append_as(layer_id, old_gpf->framenum); + old_gpd_frames.append_as(layer_id, old_gpf); } ++layer_id; } for (int i = 0; i < new_gpd.frames_size; i++) { -const ::GPFrame *new_gpf = new_gpd.frames_array + i; +const GPFrame &new_gpf{new_gpd.frames(i)}; int old_gpf_layer_index{old_gpd_frames[i].first}; -int old_gpf_frame_number{old_gpd_frames[i].second}; +const bGPDframe *old_gpf{old_gpd_frames[i].second}; + +EXPECT_EQ(new_gpf.layer_index, old_gpf_layer_index); +EXPECT_EQ(new_gpf.start_time, old_gpf->framenum); -EXPECT_EQ(new_gpf->layer_index, old_gpf_layer_index); -EXPECT_EQ(new_gpf->start_time, old_gpf_frame_number); +EXPECT_EQ(new_gpf.strokes_num(), BLI_listbase_count(&old_gpf->strokes)); + +int curve_index{0}; +LISTBASE_FOREACH (const bGPDstroke *, stk, &old_gpf->strokes) { + if (curve_index >= new_gpf.strokes_num()) { +break; + } + compare_gpencil_stroke_data(new_gpf.strokes_as_curves(), curve_index, stk); + + ++curve_index; +} } } @@ -484,4 +552,26 @@ TEST(gpencil_proposal, NewToOldConversion) free_old_gpencil_data(old_data); } +TEST(gpencil_proposal, OldToNewStrokeConversion) +{ + int layers_num = 1, frames_num = 1, strokes_num = 0, points_num = 0; + + bGPdata *old_data = build_old_
[Bf-blender-cvs] [382e189e375] gpencil-new-data-proposal: refactor
Commit: 382e189e375a97cc0c1a2be4e10ef09ef4685cd7 Author: Amelie Fondevilla Date: Mon Dec 12 15:33:37 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rB382e189e375a97cc0c1a2be4e10ef09ef4685cd7 refactor === M source/blender/blenkernel/intern/gpencil_new_proposal_test.cc === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc index 061b1e027fd..7665e6ea987 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc @@ -149,14 +149,14 @@ static void compare_gpencil_stroke_data(const CurvesGeometry &curves, int curve_index, const bGPDstroke *stk) { - /* Stroke/Curve length */ + // Stroke/Curve length int curve_point_num{curves.points_num_for_curve(curve_index)}; EXPECT_EQ(curve_point_num, stk->totpoints); if (curve_point_num != stk->totpoints) { return; } - /* Get curve attributes */ + // Get curve attributes Span curve_positions{curves.positions()}; IndexRange curve_id{curves.points_for_curve(curve_index)}; @@ -165,7 +165,7 @@ static void compare_gpencil_stroke_data(const CurvesGeometry &curves, const bGPDspoint *stk_point{stk->points + stk_point_id}; const float3 &curve_pos{curve_positions[curve_point_id]}; -/* Point positions */ +// Point positions EXPECT_EQ(curve_pos.x, stk_point->x); EXPECT_EQ(curve_pos.y, stk_point->y); EXPECT_EQ(curve_pos.z, stk_point->z); @@ -176,49 +176,44 @@ static void compare_gpencil_stroke_data(const CurvesGeometry &curves, static void compare_gpencil_data_structures(const GPData &new_gpd, const bGPdata *old_gpd) { - /* Compare Layers */ EXPECT_EQ(new_gpd.layers_size, old_gpd->totlayer); + EXPECT_EQ(new_gpd.frames_size, old_gpd->totframe); - int index{-1}; + int layer_id{0}; + int frame_id{0}; LISTBASE_FOREACH (bGPDlayer *, old_gpl, &old_gpd->layers) { -if (index >= new_gpd.layers_size) { +if (layer_id >= new_gpd.layers_size) { break; } -const ::GPLayer *new_gpl = &(new_gpd.layers_array[++index]); -EXPECT_EQ(std::strcmp(new_gpl->name, old_gpl->info), 0); - } - /* Compare Frames */ - EXPECT_EQ(new_gpd.frames_size, old_gpd->totframe); +// Compare layer data +const ::GPLayer *new_gpl = &(new_gpd.layers_array[layer_id]); +EXPECT_EQ(std::strcmp(new_gpl->name, old_gpl->info), 0); - /* Get vector of frames. */ - Vector> old_gpd_frames; - int layer_id{0}; - LISTBASE_FOREACH (bGPDlayer *, old_gpl, &old_gpd->layers) { LISTBASE_FOREACH (bGPDframe *, old_gpf, &old_gpl->frames) { - old_gpd_frames.append_as(layer_id, old_gpf); -} -++layer_id; - } + if (frame_id >= new_gpd.frames_size) { +break; + } + const GPFrame &new_gpf{new_gpd.frames(frame_id)}; - for (int i = 0; i < new_gpd.frames_size; i++) { -const GPFrame &new_gpf{new_gpd.frames(i)}; -int old_gpf_layer_index{old_gpd_frames[i].first}; -const bGPDframe *old_gpf{old_gpd_frames[i].second}; + // Compare frame data + EXPECT_EQ(new_gpf.layer_index, layer_id); + EXPECT_EQ(new_gpf.start_time, old_gpf->framenum); + EXPECT_EQ(new_gpf.strokes_num(), BLI_listbase_count(&old_gpf->strokes)); -EXPECT_EQ(new_gpf.layer_index, old_gpf_layer_index); -EXPECT_EQ(new_gpf.start_time, old_gpf->framenum); + int curve_index{0}; + LISTBASE_FOREACH (const bGPDstroke *, stk, &old_gpf->strokes) { +if (curve_index >= new_gpf.strokes_num()) { + break; +} -EXPECT_EQ(new_gpf.strokes_num(), BLI_listbase_count(&old_gpf->strokes)); +// Compare stroke data +compare_gpencil_stroke_data(new_gpf.strokes_as_curves(), curve_index, stk); -int curve_index{0}; -LISTBASE_FOREACH (const bGPDstroke *, stk, &old_gpf->strokes) { - if (curve_index >= new_gpf.strokes_num()) { -break; +++curve_index; } - compare_gpencil_stroke_data(new_gpf.strokes_as_curves(), curve_index, stk); - ++curve_index; + ++frame_id; } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6e2b594d98d] gpencil-new-data-proposal: adding is empty method for gpencil frame in the API
Commit: 6e2b594d98d00d3259b914f1ca35efa954fcf52c Author: Amelie Fondevilla Date: Mon Dec 12 12:17:39 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rB6e2b594d98d00d3259b914f1ca35efa954fcf52c adding is empty method for gpencil frame in the API === M source/blender/blenkernel/intern/gpencil_new_proposal.cc M source/blender/blenkernel/intern/gpencil_new_proposal.hh === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc b/source/blender/blenkernel/intern/gpencil_new_proposal.cc index f176c451040..551e0bd58fe 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc @@ -172,9 +172,14 @@ const CurvesGeometry &GPFrame::strokes_as_curves() const return CurvesGeometry::wrap(*this->strokes); } +bool GPFrame::is_empty() const +{ + return (this->strokes == nullptr) || (this->strokes->curve_num == 0); +} + int GPFrame::strokes_num() const { - if (this->strokes == nullptr) { + if (this->is_empty()) { return 0; } return this->strokes->curve_num; diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh b/source/blender/blenkernel/intern/gpencil_new_proposal.hh index 0a15315172c..6c485b897e1 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh +++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh @@ -257,6 +257,7 @@ class GPFrame : public ::GPFrame { CurvesGeometry &strokes_as_curves(); const CurvesGeometry &strokes_as_curves() const; + bool is_empty() const; int strokes_num() const; int points_num() const; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [702c4eaaeb4] gpencil-new-data-proposal: overload strokes getter for const
Commit: 702c4eaaeb46a9e07cb8ff3b2a3e1e9b26488bc0 Author: Amelie Fondevilla Date: Mon Dec 12 12:07:16 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rB702c4eaaeb46a9e07cb8ff3b2a3e1e9b26488bc0 overload strokes getter for const === M source/blender/blenkernel/intern/gpencil_new_proposal.cc M source/blender/blenkernel/intern/gpencil_new_proposal.hh === diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc b/source/blender/blenkernel/intern/gpencil_new_proposal.cc index 61200bff594..f176c451040 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc @@ -167,6 +167,11 @@ CurvesGeometry &GPFrame::strokes_as_curves() return CurvesGeometry::wrap(*this->strokes); } +const CurvesGeometry &GPFrame::strokes_as_curves() const +{ + return CurvesGeometry::wrap(*this->strokes); +} + int GPFrame::strokes_num() const { if (this->strokes == nullptr) { diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh b/source/blender/blenkernel/intern/gpencil_new_proposal.hh index a4a68345578..0a15315172c 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh +++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh @@ -255,6 +255,7 @@ class GPFrame : public ::GPFrame { bool operator==(const GPFrame &other) const; CurvesGeometry &strokes_as_curves(); + const CurvesGeometry &strokes_as_curves() const; int strokes_num() const; int points_num() const; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [54aec4629ec] master: Cleanup: Remove unused code in Cycles
Commit: 54aec4629ecd5d679daff167fc9eb7b7d99a3daa Author: Thomas Dinges Date: Mon Dec 12 18:15:41 2022 +0100 Branches: master https://developer.blender.org/rB54aec4629ecd5d679daff167fc9eb7b7d99a3daa Cleanup: Remove unused code in Cycles * preempt_attr was copied from CUDA, but not used in HIP. * Remove shadowed variable before conditional in EnvironmentTextureNode code. Differential Revision: https://developer.blender.org/D16741 === M intern/cycles/device/hip/device.cpp M intern/cycles/scene/light.cpp === diff --git a/intern/cycles/device/hip/device.cpp b/intern/cycles/device/hip/device.cpp index 518239f9877..d3566347834 100644 --- a/intern/cycles/device/hip/device.cpp +++ b/intern/cycles/device/hip/device.cpp @@ -163,10 +163,10 @@ void device_hip_info(vector &devices) /* If device has a kernel timeout and no compute preemption, we assume * it is connected to a display and will freeze the display while doing * computations. */ -int timeout_attr = 0, preempt_attr = 0; +int timeout_attr = 0; hipDeviceGetAttribute(&timeout_attr, hipDeviceAttributeKernelExecTimeout, num); -if (timeout_attr && !preempt_attr) { +if (timeout_attr) { VLOG_INFO << "Device is recognized as display."; info.description += " (Display)"; info.display_device = true; diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp index f6e9098cd2b..b8addeaffd6 100644 --- a/intern/cycles/scene/light.cpp +++ b/intern/cycles/scene/light.cpp @@ -726,7 +726,6 @@ void LightManager::device_update_background(Device *device, foreach (ShaderNode *node, shader->graph->nodes) { if (node->type == EnvironmentTextureNode::get_node_type()) { EnvironmentTextureNode *env = (EnvironmentTextureNode *)node; - ImageMetaData metadata; if (!env->handle.empty()) { ImageMetaData metadata = env->handle.metadata(); environment_res.x = max(environment_res.x, (int)metadata.width); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [014ffc4615b] master: Cycles: using concentric mapping when sampling disk
Commit: 014ffc4615b8fc04ef37e9147074c0c86e347b06 Author: Weizhen Huang Date: Mon Dec 12 17:07:57 2022 +0100 Branches: master https://developer.blender.org/rB014ffc4615b8fc04ef37e9147074c0c86e347b06 Cycles: using concentric mapping when sampling disk === M intern/cycles/kernel/light/common.h === diff --git a/intern/cycles/kernel/light/common.h b/intern/cycles/kernel/light/common.h index 9a08bbcf43a..bd2803eeade 100644 --- a/intern/cycles/kernel/light/common.h +++ b/intern/cycles/kernel/light/common.h @@ -30,8 +30,8 @@ typedef struct LightSample { ccl_device_inline float3 ellipse_sample(float3 ru, float3 rv, float randu, float randv) { - to_unit_disk(&randu, &randv); - return ru * randu + rv * randv; + const float2 rand = concentric_sample_disk(randu, randv); + return ru * rand.x + rv * rand.y; } ccl_device_inline float3 rectangle_sample(float3 ru, float3 rv, float randu, float randv) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [85d92afbd4d] master: Cleanup: Move asset catalog tree tests to own file
Commit: 85d92afbd4dd961327191ecc68579d25a8e653ea Author: Julian Eisel Date: Mon Dec 12 17:07:55 2022 +0100 Branches: master https://developer.blender.org/rB85d92afbd4dd961327191ecc68579d25a8e653ea Cleanup: Move asset catalog tree tests to own file The catalog tree is a unit on its own, and should be tested separately. This makes the testing files smaller and more focused, which can help maintaining them. === M source/blender/asset_system/CMakeLists.txt M source/blender/asset_system/tests/asset_catalog_test.cc A source/blender/asset_system/tests/asset_catalog_tree_test.cc M source/blender/asset_system/tests/asset_library_test_common.hh === diff --git a/source/blender/asset_system/CMakeLists.txt b/source/blender/asset_system/CMakeLists.txt index 6f4e058e78d..f8e1df40d80 100644 --- a/source/blender/asset_system/CMakeLists.txt +++ b/source/blender/asset_system/CMakeLists.txt @@ -48,6 +48,7 @@ if(WITH_GTESTS) set(TEST_SRC tests/asset_catalog_path_test.cc tests/asset_catalog_test.cc +tests/asset_catalog_tree_test.cc tests/asset_library_service_test.cc tests/asset_library_test.cc diff --git a/source/blender/asset_system/tests/asset_catalog_test.cc b/source/blender/asset_system/tests/asset_catalog_test.cc index 144912d62a1..87819f3683b 100644 --- a/source/blender/asset_system/tests/asset_catalog_test.cc +++ b/source/blender/asset_system/tests/asset_catalog_test.cc @@ -80,77 +80,6 @@ class TestableAssetCatalogService : public AssetCatalogService { class AssetCatalogTest : public AssetLibraryTestBase { protected: - void assert_expected_item(const AssetCatalogPath &expected_path, -const AssetCatalogTreeItem &actual_item) - { -if (expected_path != actual_item.catalog_path().str()) { - /* This will fail, but with a nicer error message than just calling FAIL(). */ - EXPECT_EQ(expected_path, actual_item.catalog_path()); - return; -} - -/* Is the catalog name as expected? "character", "Ellie", ... */ -EXPECT_EQ(expected_path.name(), actual_item.get_name()); - -/* Does the computed number of parents match? */ -const std::string expected_path_str = expected_path.str(); -const size_t expected_parent_count = std::count( -expected_path_str.begin(), expected_path_str.end(), AssetCatalogPath::SEPARATOR); -EXPECT_EQ(expected_parent_count, actual_item.count_parents()); - } - - /** - * Recursively iterate over all tree items using #AssetCatalogTree::foreach_item() and check if - * the items map exactly to \a expected_paths. - */ - void assert_expected_tree_items(AssetCatalogTree *tree, - const std::vector &expected_paths) - { -int i = 0; -tree->foreach_item([&](const AssetCatalogTreeItem &actual_item) { - ASSERT_LT(i, expected_paths.size()) - << "More catalogs in tree than expected; did not expect " << actual_item.catalog_path(); - assert_expected_item(expected_paths[i], actual_item); - i++; -}); - } - - /** - * Iterate over the root items of \a tree and check if the items map exactly to \a - * expected_paths. Similar to #assert_expected_tree_items() but calls - * #AssetCatalogTree::foreach_root_item() instead of #AssetCatalogTree::foreach_item(). - */ - void assert_expected_tree_root_items(AssetCatalogTree *tree, - const std::vector &expected_paths) - { -int i = 0; -tree->foreach_root_item([&](const AssetCatalogTreeItem &actual_item) { - ASSERT_LT(i, expected_paths.size()) - << "More catalogs in tree root than expected; did not expect " - << actual_item.catalog_path(); - assert_expected_item(expected_paths[i], actual_item); - i++; -}); - } - - /** - * Iterate over the child items of \a parent_item and check if the items map exactly to \a - * expected_paths. Similar to #assert_expected_tree_items() but calls - * #AssetCatalogTreeItem::foreach_child() instead of #AssetCatalogTree::foreach_item(). - */ - void assert_expected_tree_item_child_items(AssetCatalogTreeItem *parent_item, - const std::vector &expected_paths) - { -int i = 0; -parent_item->foreach_child([&](const AssetCatalogTreeItem &actual_item) { - ASSERT_LT(i, expected_paths.size()) - << "More catalogs in tree item than expected; did not expect " - << actual_item.catalog_path(); - assert_expected_item(expected_paths[i], actual_item); - i++; -}); - } - /* Used by on_blendfile_save__from_memory_into_existing_asset_lib* test functions. */ void save_from_memory_into_existing_asset_lib(const bool should_top_level_cdf_exist) { @@ -307,149 +236,6 @@ TEST_F(AssetCatalogTest, is_first_loaded_flag) << "The
[Bf-blender-cvs] [dbd3822329f] master: Cleanup: Extract asset test class into own header
Commit: dbd3822329f16b24d46ac1336a792cb4f6b8a92e Author: Julian Eisel Date: Mon Dec 12 16:06:23 2022 +0100 Branches: master https://developer.blender.org/rBdbd3822329f16b24d46ac1336a792cb4f6b8a92e Cleanup: Extract asset test class into own header This manages setting up asset library directories for testing, which is useful for testing multiple asset library related compontents. So move it to a common header. No reason to squeeze everything into one file then. === M source/blender/asset_system/CMakeLists.txt M source/blender/asset_system/tests/asset_catalog_test.cc A source/blender/asset_system/tests/asset_library_test_common.hh === diff --git a/source/blender/asset_system/CMakeLists.txt b/source/blender/asset_system/CMakeLists.txt index de1f41667d5..6f4e058e78d 100644 --- a/source/blender/asset_system/CMakeLists.txt +++ b/source/blender/asset_system/CMakeLists.txt @@ -46,10 +46,12 @@ blender_add_lib(bf_asset_system "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") if(WITH_GTESTS) set(TEST_SRC -tests/asset_catalog_test.cc tests/asset_catalog_path_test.cc +tests/asset_catalog_test.cc tests/asset_library_service_test.cc tests/asset_library_test.cc + +tests/asset_library_test_common.hh ) set(TEST_LIB bf_asset_system diff --git a/source/blender/asset_system/tests/asset_catalog_test.cc b/source/blender/asset_system/tests/asset_catalog_test.cc index 0a051bfd51f..144912d62a1 100644 --- a/source/blender/asset_system/tests/asset_catalog_test.cc +++ b/source/blender/asset_system/tests/asset_catalog_test.cc @@ -17,6 +17,8 @@ #include "testing/testing.h" +#include "asset_library_test_common.hh" + namespace blender::asset_system::tests { /* UUIDs from lib/tests/asset_library/blender_assets.cats.txt */ @@ -76,59 +78,8 @@ class TestableAssetCatalogService : public AssetCatalogService { } }; -class AssetCatalogTest : public testing::Test { +class AssetCatalogTest : public AssetLibraryTestBase { protected: - CatalogFilePath asset_library_root_; - CatalogFilePath temp_library_path_; - - static void SetUpTestSuite() - { -testing::Test::SetUpTestSuite(); -CLG_init(); - } - - static void TearDownTestSuite() - { -CLG_exit(); -testing::Test::TearDownTestSuite(); - } - - void SetUp() override - { -const std::string test_files_dir = blender::tests::flags_test_asset_dir(); -if (test_files_dir.empty()) { - FAIL(); -} - -asset_library_root_ = test_files_dir + SEP_STR + "asset_library"; -temp_library_path_ = ""; - } - - void TearDown() override - { -if (!temp_library_path_.empty()) { - BLI_delete(temp_library_path_.c_str(), true, true); - temp_library_path_ = ""; -} - } - - /* Register a temporary path, which will be removed at the end of the test. - * The returned path ends in a slash. */ - CatalogFilePath use_temp_path() - { -BKE_tempdir_init(""); -const CatalogFilePath tempdir = BKE_tempdir_session(); -temp_library_path_ = tempdir + "test-temporary-path" + SEP_STR; -return temp_library_path_; - } - - CatalogFilePath create_temp_path() - { -CatalogFilePath path = use_temp_path(); -BLI_dir_create_recursive(path.c_str()); -return path; - } - void assert_expected_item(const AssetCatalogPath &expected_path, const AssetCatalogTreeItem &actual_item) { diff --git a/source/blender/asset_system/tests/asset_library_test_common.hh b/source/blender/asset_system/tests/asset_library_test_common.hh new file mode 100644 index 000..d8a8966487f --- /dev/null +++ b/source/blender/asset_system/tests/asset_library_test_common.hh @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#pragma once + +#include + +#include "BKE_appdir.h" + +#include "BLI_fileops.h" +#include "BLI_path_util.h" + +#include "CLG_log.h" + +#include "testing/testing.h" + +namespace blender::asset_system::tests { + +/** + * Functionality to setup and access directories on disk within which asset library related testing + * can be done. + */ +class AssetLibraryTestBase : public testing::Test { + protected: + std::string asset_library_root_; + std::string temp_library_path_; + + static void SetUpTestSuite() + { +testing::Test::SetUpTestSuite(); +CLG_init(); + } + + static void TearDownTestSuite() + { +CLG_exit(); +testing::Test::TearDownTestSuite(); + } + + void SetUp() override + { +const std::string test_files_dir = blender::tests::flags_test_asset_dir(); +if (test_files_dir.empty()) { + FAIL(); +} + +asset_library_root_ = test_files_dir + SEP_STR + "asset_library"; +temp_library_path_ = ""; + } + + void TearDown() override + { +if (!temp_library_path_.empty()) { + BLI_delete(temp_library_path_.c_str(), true, true); + temp_library_path_ = ""; +
[Bf-blender-cvs] [2049960aa3d] refactor-mesh-uv-map-generic: Make BM_ensure_selection_and_pin_attributes() loop over all CD_PROP_FLOAT2 layers
Commit: 2049960aa3d9de4d3c8d02d41d9949358b9f8574 Author: Baardaap Date: Mon Dec 12 17:00:00 2022 +0100 Branches: refactor-mesh-uv-map-generic https://developer.blender.org/rB2049960aa3d9de4d3c8d02d41d9949358b9f8574 Make BM_ensure_selection_and_pin_attributes() loop over all CD_PROP_FLOAT2 layers Passing in the name does not work when adding layers, because the names passed to CustomData_add_layer_named() can change the name to make it unique. === M source/blender/bmesh/intern/bmesh_interp.c M source/blender/bmesh/intern/bmesh_interp.h M source/blender/editors/mesh/mesh_data.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc M source/blender/python/bmesh/bmesh_py_types_customdata.c === diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 7c13b2e7663..745257dd919 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -873,15 +873,19 @@ void BM_data_layer_ensure_named(BMesh *bm, CustomData *data, int type, const cha } } -void BM_uv_map_ensure_selection_and_pin_attributes(BMesh *bm, const char *uv_map_name) +void BM_uv_map_ensure_selection_and_pin_attributes(BMesh *bm) { - char name[MAX_CUSTOMDATA_LAYER_NAME]; - BM_data_layer_ensure_named( - bm, &bm->ldata, CD_PROP_BOOL, BKE_get_uv_map_vert_selection_name(uv_map_name, name)); - BM_data_layer_ensure_named( - bm, &bm->ldata, CD_PROP_BOOL, BKE_get_uv_map_edge_selection_name(uv_map_name, name)); - BM_data_layer_ensure_named( - bm, &bm->ldata, CD_PROP_BOOL, BKE_get_uv_map_pin_name(uv_map_name, name)); + const int nr_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_PROP_FLOAT2); + for (int l = 0; l < nr_uv_layers; l++ ) { +/* note: you can't re-use the returnvalue of CustomData_get_layer_name() because adding layers can invalidate that. */ +char name[MAX_CUSTOMDATA_LAYER_NAME]; +BM_data_layer_ensure_named( +bm, &bm->ldata, CD_PROP_BOOL, BKE_get_uv_map_vert_selection_name(CustomData_get_layer_name(&bm->ldata, CD_PROP_FLOAT2, l), name)); +BM_data_layer_ensure_named( +bm, &bm->ldata, CD_PROP_BOOL, BKE_get_uv_map_edge_selection_name(CustomData_get_layer_name(&bm->ldata, CD_PROP_FLOAT2, l), name)); +BM_data_layer_ensure_named( +bm, &bm->ldata, CD_PROP_BOOL, BKE_get_uv_map_pin_name(CustomData_get_layer_name(&bm->ldata, CD_PROP_FLOAT2, l), name)); + } } void BM_uv_map_ensure_vert_selection_attribute(BMesh *bm, const char *uv_map_name) diff --git a/source/blender/bmesh/intern/bmesh_interp.h b/source/blender/bmesh/intern/bmesh_interp.h index 0b7b5197074..c7ce6d36453 100644 --- a/source/blender/bmesh/intern/bmesh_interp.h +++ b/source/blender/bmesh/intern/bmesh_interp.h @@ -65,7 +65,9 @@ void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char * void BM_data_layer_ensure_named(BMesh *bm, CustomData *data, int type, const char *name); void BM_data_layer_free(BMesh *bm, CustomData *data, int type); -void BM_uv_map_ensure_selection_and_pin_attributes(BMesh *bm, const char *uv_map_name); +/* This ensures the dependent bool layers exist for all CD_PROP_FLOAT2 layers */ +void BM_uv_map_ensure_selection_and_pin_attributes(BMesh *bm); + void BM_uv_map_ensure_vert_selection_attribute(BMesh *bm, const char *uv_map_name); void BM_uv_map_ensure_edge_selection_attribute(BMesh *bm, const char *uv_map_name); void BM_uv_map_ensure_pin_attribute(BMesh *bm, const char *uv_map_name); diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index 496678ede3d..0c2d2eaf3d2 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -246,7 +246,7 @@ int ED_mesh_uv_add( } BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_PROP_FLOAT2, name); -BM_uv_map_ensure_selection_and_pin_attributes(em->bm, name); +BM_uv_map_ensure_selection_and_pin_attributes(em->bm); /* copy data from active UV */ if (layernum_dst && do_init) { const int layernum_src = CustomData_get_active_layer(&em->bm->ldata, CD_PROP_FLOAT2); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc index 2543b21e7fb..4d59d904405 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc @@ -40,8 +40,7 @@ static Mesh *create_ico_sphere_mesh(const int subdivisions, const float radius) * Normally this would be done when adding a UV layer via python * or when copying from Mesh, but when we 'manually' create the UV layer * we need to make sure the bool layers exist as we
[Bf-blender-cvs] [db68e2d4d3c] master: Build: install shaderc and vulkan libraries for Linux and macOS
Commit: db68e2d4d3cc466198ec2f03fa0d03a6016d45f4 Author: Brecht Van Lommel Date: Mon Dec 12 16:52:45 2022 +0100 Branches: master https://developer.blender.org/rBdb68e2d4d3cc466198ec2f03fa0d03a6016d45f4 Build: install shaderc and vulkan libraries for Linux and macOS === M build_files/build_environment/cmake/harvest.cmake === diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake index 10d0c414303..2660d55d899 100644 --- a/build_files/build_environment/cmake/harvest.cmake +++ b/build_files/build_environment/cmake/harvest.cmake @@ -268,6 +268,10 @@ harvest(haru/include haru/include "*.h") harvest(haru/lib haru/lib "*.a") harvest(zstd/include zstd/include "*.h") harvest(zstd/lib zstd/lib "*.a") +harvest(shaderc shaderc "*") +harvest(vulkan_headers vulkan "*") +harvest_rpath_lib(vulkan_loader/lib vulkan/lib "*${SHAREDLIBEXT}*") +harvest(vulkan_loader/loader vulkan/loader "*") if(UNIX AND NOT APPLE) harvest(libglu/lib mesa/lib "*${SHAREDLIBEXT}*") ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d17858cb370] master: Fix Cycles rectangular area light in volume segment sampled by ellipse
Commit: d17858cb37025c9732ef0987de5de884bd95 Author: Weizhen Huang Date: Mon Dec 12 15:56:50 2022 +0100 Branches: master https://developer.blender.org/rBd17858cb37025c9732ef0987de5de884bd95 Fix Cycles rectangular area light in volume segment sampled by ellipse === M intern/cycles/kernel/light/area.h M intern/cycles/kernel/light/common.h === diff --git a/intern/cycles/kernel/light/area.h b/intern/cycles/kernel/light/area.h index 69cf810f800..9c0ca0c8a70 100644 --- a/intern/cycles/kernel/light/area.h +++ b/intern/cycles/kernel/light/area.h @@ -255,8 +255,9 @@ ccl_device_inline bool area_light_sample(const ccl_global KernelLight *klight, float3 inplane; if (in_volume_segment) { -/* FIXME: handle rectangular light. */ -inplane = ellipse_sample(axis_u * len_u * 0.5f, axis_v * len_v * 0.5f, randu, randv); +inplane = sample_rectangle ? + rectangle_sample(axis_u * len_u * 0.5f, axis_v * len_v * 0.5f, randu, randv) : + ellipse_sample(axis_u * len_u * 0.5f, axis_v * len_v * 0.5f, randu, randv); ls->P += inplane; ls->pdf = invarea; } diff --git a/intern/cycles/kernel/light/common.h b/intern/cycles/kernel/light/common.h index 5f0a3218ae1..9a08bbcf43a 100644 --- a/intern/cycles/kernel/light/common.h +++ b/intern/cycles/kernel/light/common.h @@ -34,6 +34,11 @@ ccl_device_inline float3 ellipse_sample(float3 ru, float3 rv, float randu, float return ru * randu + rv * randv; } +ccl_device_inline float3 rectangle_sample(float3 ru, float3 rv, float randu, float randv) +{ + return ru * (2.0f * randu - 1.0f) + rv * (2.0f * randv - 1.0f); +} + ccl_device float3 disk_light_sample(float3 v, float randu, float randv) { float3 ru, rv; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8f773072a97] refactor-mesh-corners-generic: Merge branch 'refactor-mesh-position-generic' into refactor-mesh-corners-generic
Commit: 8f773072a97f021e41e415ee8947b17491743bfe Author: Hans Goudey Date: Sun Dec 11 23:56:50 2022 -0600 Branches: refactor-mesh-corners-generic https://developer.blender.org/rB8f773072a97f021e41e415ee8947b17491743bfe Merge branch 'refactor-mesh-position-generic' into refactor-mesh-corners-generic === === diff --cc source/blender/blenkernel/BKE_mesh_mapping.h index 34194f901e9,fd68adc2584..948cd1027ec --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@@ -351,14 -349,12 +351,14 @@@ namespace blender::bke::mesh_topology Array build_loop_to_poly_map(Span polys, int loops_num); Array> build_vert_to_edge_map(Span edges, int verts_num); -Array> build_vert_to_poly_map(Span polys, Span loops, int verts_num); -Array> build_vert_to_loop_map(Span loops, int verts_num); -Array> build_edge_to_loop_map(Span loops, int edges_num); -Vector> build_edge_to_loop_map_resizable(Span loops, int edges_num); +Array> build_vert_to_poly_map(Span polys, + Span corner_verts, + int verts_num); +Array> build_vert_to_loop_map(Span corner_verts, int verts_num); +Array> build_edge_to_loop_map(Span corner_edges, int edges_num); +Vector> build_edge_to_loop_map_resizable(Span corner_edges, int edges_num); - inline int previous_poly_loop(const MPoly &poly, int loop_i) + inline int poly_loop_prev(const MPoly &poly, int loop_i) { return loop_i - 1 + (loop_i == poly.loopstart) * poly.totloop; } diff --cc source/blender/blenkernel/intern/geometry_component_mesh.cc index eb7a0c39817,a482f56a178..9558be4f09d --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@@ -605,11 -618,11 +605,11 @@@ void adapt_mesh_domain_edge_to_corner_i /* For every corner, mix the values from the adjacent edges on the face. */ for (const int loop_index : IndexRange(poly.loopstart, poly.totloop)) { - const int loop_index_prev = mesh_topology::previous_poly_loop(poly, loop_index); + const int loop_index_prev = mesh_topology::poly_loop_prev(poly, loop_index); - const MLoop &loop = loops[loop_index]; - const MLoop &loop_prev = loops[loop_index_prev]; - mixer.mix_in(loop_index, old_values[loop.e]); - mixer.mix_in(loop_index, old_values[loop_prev.e]); + const int edge_i = corner_edges[loop_index]; + const int edge_i_prev = corner_edges[loop_index_prev]; + mixer.mix_in(loop_index, old_values[edge_i]); + mixer.mix_in(loop_index, old_values[edge_i_prev]); } } @@@ -632,10 -645,10 +632,10 @@@ void adapt_mesh_domain_edge_to_corner_i for (const int poly_index : range) { const MPoly &poly = polys[poly_index]; for (const int loop_index : IndexRange(poly.loopstart, poly.totloop)) { - const int loop_index_prev = mesh_topology::previous_poly_loop(poly, loop_index); + const int loop_index_prev = mesh_topology::poly_loop_prev(poly, loop_index); -const MLoop &loop = loops[loop_index]; -const MLoop &loop_prev = loops[loop_index_prev]; -if (old_values[loop.e] && old_values[loop_prev.e]) { +const int edge_i = corner_edges[loop_index]; +const int edge_i_prev = corner_edges[loop_index_prev]; +if (old_values[edge_i] && old_values[edge_i_prev]) { r_values[loop_index] = true; } } diff --cc source/blender/blenkernel/intern/mesh_normals.cc index 3569c7b3a1d,9bfe1f8d8c1..02f81ae98c9 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@@ -773,10 -772,9 +772,10 @@@ struct LoopSplitTaskDataCommon /* Read-only. */ Span positions; Span edges; - Span loops; + Span corner_verts; + Span corner_edges; Span polys; - MutableSpan edge_to_loops; + Span edge_to_loops; Span loop_to_poly; Span polynors; Span vert_normals; @@@ -910,7 -905,8 +909,8 @@@ static void loop_manifold_fan_around_ve int *r_mlfan_vert_index, int *r_mpfan_curr_index) { - const int fan_vert_curr = corner_verts[*r_mlfan_curr_index]; + const int mlfan_curr_orig = *r_mlfan_curr_index; - const uint vert_fan_orig = loops[mlfan_curr_orig].v; ++ const uint vert_fan_orig = corner_verts[mlfan_curr_orig]; /* WARNING: This is rather complex! * We have to find our next edge around the vertex (fan mode). @@@ -925,12 -921,10 +925,10 @@@ BLI_assert(*r_mlfan_curr_index >= 0); BLI_assert(*r_mpfan_curr_index >= 0); - const int fan_vert_next = corner_verts[*r_mlfan_curr_index]; - - const uint vert_fan_next = loops[*r_mlfan_curr_index].v; ++ const
[Bf-blender-cvs] [4cdddcca87b] refactor-mesh-corners-generic: Small cleanups
Commit: 4cdddcca87b79e0311ee74d1e0dfd91cf724e1d0 Author: Hans Goudey Date: Mon Dec 12 08:50:53 2022 -0600 Branches: refactor-mesh-corners-generic https://developer.blender.org/rB4cdddcca87b79e0311ee74d1e0dfd91cf724e1d0 Small cleanups === M intern/cycles/blender/mesh.cpp M source/blender/blenkernel/intern/data_transfer.cc M source/blender/blenkernel/intern/mesh_normals.cc === diff --git a/intern/cycles/blender/mesh.cpp b/intern/cycles/blender/mesh.cpp index d0a98fca5ff..2dee09f7188 100644 --- a/intern/cycles/blender/mesh.cpp +++ b/intern/cycles/blender/mesh.cpp @@ -886,7 +886,7 @@ static void attr_create_random_per_island(Scene *scene, BL::IntAttribute corner_verts = *find_corner_vert_attribute(b_mesh); for (int i = 0; i < polys_num; i++) { const MPoly &b_poly = polys[i]; -const int vert = corner_verts->data[b_poly.loopstart].value(); +const int vert = corner_verts.data[b_poly.loopstart].value(); data[i] = hash_uint_to_float(vertices_sets.find(vert)); } } diff --git a/source/blender/blenkernel/intern/data_transfer.cc b/source/blender/blenkernel/intern/data_transfer.cc index be9eeb699ad..28fbaf5a84d 100644 --- a/source/blender/blenkernel/intern/data_transfer.cc +++ b/source/blender/blenkernel/intern/data_transfer.cc @@ -291,8 +291,8 @@ static void data_transfer_dtdata_type_preprocess(Mesh *me_src, num_verts_dst, edges_dst, num_edges_dst, - BKE_mesh_corner_verts(me_dst), - BKE_mesh_corner_edges(me_dst), + me_dst->corner_verts().data(), + me_dst->corner_edges().data(), loop_nors_dst, num_loops_dst, polys_dst, @@ -346,8 +346,8 @@ static void data_transfer_dtdata_type_postprocess(Object *UNUSED(ob_src), num_verts_dst, edges_dst, num_edges_dst, - BKE_mesh_corner_verts(me_dst), - BKE_mesh_corner_edges(me_dst), + me_dst->corner_verts().data(), + me_dst->corner_edges().data(), loop_nors_dst, num_loops_dst, polys_dst, @@ -1513,8 +1513,8 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph, const int num_edges_dst = me_dst->totedge; const MPoly *polys_dst = BKE_mesh_polys(me_dst); const int num_polys_dst = me_dst->totpoly; - const int *corner_verts_dst = BKE_mesh_corner_verts(me_dst); - const int *corner_edges_dst = BKE_mesh_corner_edges(me_dst); + const int *corner_verts_dst = me_dst->corner_verts().data(); + const int *corner_edges_dst = me_dst->corner_edges().data(); const int num_loops_dst = me_dst->totloop; CustomData *ldata_dst = &me_dst->ldata; @@ -1615,7 +1615,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph, const int num_verts_dst = me_dst->totvert; const MPoly *polys_dst = BKE_mesh_polys(me_dst); const int num_polys_dst = me_dst->totpoly; - const int *corner_verts_dst = BKE_mesh_corner_verts(me_dst); + const int *corner_verts_dst = me_dst->corner_verts().data(); const int num_loops_dst = me_dst->totloop; if (!geom_map_init[PDATA]) { diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 02f81ae98c9..4ba951461a0 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -1558,7 +1558,7 @@ void BKE_mesh_normals_loop_split(const float (*positions)[3], common_data.loopnors = {reinterpret_cast(r_loopnors), numLoops}; common_data.clnors_data = {reinterpret_cast(clnors_data), clnors_data ? numLoops : 0}; common_data.positions = {reinterpret_cast(positions), numVerts}; - common_data.edges = {const_cast(medges), numEdges}; + common_data.edges = {medges, numEdges}; common_data.polys = {mpolys, numPolys}; common_data.corner_verts = {corner_verts, numLoops}; common_data.corner_edges = {corner_edges, numLoops}; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a683d5f9349] temp-asset-library-all: Merge branch 'master' into temp-asset-library-all
Commit: a683d5f934951b8862e98546bd70b40526f04217 Author: Julian Eisel Date: Mon Dec 12 15:35:48 2022 +0100 Branches: temp-asset-library-all https://developer.blender.org/rBa683d5f934951b8862e98546bd70b40526f04217 Merge branch 'master' into temp-asset-library-all === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6ce3e0495ae] universal-scene-description: USD export: support authoring Kind
Commit: 6ce3e0495ae11efc91a4bc759609a0317d5baeda Author: Michael Kowalski Date: Fri Dec 9 18:37:54 2022 -0500 Branches: universal-scene-description https://developer.blender.org/rB6ce3e0495ae11efc91a4bc759609a0317d5baeda USD export: support authoring Kind Added a switch to the exporter to write USD Kind. Added options to add USD Kind to the Default Prim. Added a special case for the IDProperty "usdkind", which is now written as the Kind through the UsdModelAPI. === M source/blender/editors/io/io_usd.c M source/blender/io/usd/intern/usd_capi_export.cc M source/blender/io/usd/intern/usd_writer_abstract.cc M source/blender/io/usd/intern/usd_writer_abstract.h M source/blender/io/usd/usd.h === diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c index e82aefc4383..05dc0cbf986 100644 --- a/source/blender/editors/io/io_usd.c +++ b/source/blender/editors/io/io_usd.c @@ -164,6 +164,16 @@ const EnumPropertyItem prop_usdz_downscale_size[] = { {0, NULL, 0, NULL, NULL}, }; +const EnumPropertyItem prop_default_prim_kind_items[] = { +{ USD_KIND_NONE, "NONE", 0, "None", "No kind is exported for default prim" }, +{ USD_KIND_COMPONENT, "COMPONENT", 0, "Component", "Set Default Prim Kind to Component" }, +{ USD_KIND_GROUP, "GROUP", 0, "Group", "Set Default Prim Kind to Group" }, +{ USD_KIND_ASSEMBLY, "ASSEMBLY", 0, "Assembly", "Set Default Prim Kind to Assembly" }, +{ USD_KIND_CUSTOM,"CUSTOM", 0, "Custom", "Specify a custom Kind for the Default Prim" }, +{0, NULL, 0, NULL, NULL}, +}; + + /* Stored in the wmOperator's customdata field to indicate it should run as a background job. * This is set when the operator is invoked, and not set when it is only executed. */ enum { AS_BACKGROUND_JOB = 1 }; @@ -314,6 +324,11 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op) const bool export_blender_metadata = RNA_boolean_get(op->ptr, "export_blender_metadata"); + /* USDKind support. */ + const bool export_usd_kind = RNA_boolean_get(op->ptr, "export_usd_kind"); + const int default_prim_kind = RNA_enum_get(op->ptr, "default_prim_kind"); + char *default_prim_custom_kind = RNA_string_get_alloc(op->ptr, "default_prim_custom_kind", NULL, 0, NULL); + struct USDExportParams params = {RNA_int_get(op->ptr, "start"), RNA_int_get(op->ptr, "end"), export_animation, @@ -377,7 +392,11 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op) export_blender_metadata, triangulate_meshes, quad_method, - ngon_method}; + ngon_method, + .export_usd_kind = export_usd_kind, + .default_prim_kind = default_prim_kind, + .default_prim_custom_kind = default_prim_custom_kind + }; /* Take some defaults from the scene, if not specified explicitly. */ Scene *scene = CTX_data_scene(C); @@ -427,6 +446,7 @@ static void wm_usd_export_draw(bContext *C, wmOperator *op) uiItemR(box, ptr, "end", 0, NULL, ICON_NONE); uiItemR(box, ptr, "frame_step", 0, NULL, ICON_NONE); } + uiItemR(box, ptr, "export_usd_kind", 0, NULL, ICON_NONE); uiItemR(box, ptr, "export_as_overs", 0, NULL, ICON_NONE); uiItemR(box, ptr, "merge_transform_and_shape", 0, NULL, ICON_NONE); uiItemR(box, ptr, "export_identity_transforms", 0, NULL, ICON_NONE); @@ -493,6 +513,12 @@ static void wm_usd_export_draw(bContext *C, wmOperator *op) uiItemR(box, ptr, "default_prim_path", 0, NULL, ICON_NONE); uiItemR(box, ptr, "root_prim_path", 0, NULL, ICON_NONE); uiItemR(box, ptr, "material_prim_path", 0, NULL, ICON_NONE); + if (RNA_boolean_get(ptr, "export_usd_kind")) { +uiItemR(box, ptr, "default_prim_kind", 0, NULL, ICON_NONE); +if (RNA_enum_get(ptr, "default_prim_kind") == USD_KIND_CUSTOM) { +uiItemR(box, ptr, "default_prim_custom_kind", 0, NULL, ICON_NONE); + } + } box = uiLayoutBox(layout); uiItemL(box, IFACE_("Conversion:"), ICON_ORIENTATION_GLOBAL); @@ -1010,6 +1036,26 @@ void WM_OT_usd_export(struct wmOperatorType *ot) MOD_TRIANGULATE_NGON_BEAUTY, "N-gon Method", "Method for splitting the n-gons into triangles"); + + RNA_def_boolean(ot->srna, + "export_usd_kind", + true, + "Export USD Kind", + "Export Kind per-prim when specified through 'usdkind' custom property."); + + RNA_def_enum(ot->srna, + "default_prim_kind", + prop_default_prim_kind_i
[Bf-blender-cvs] [0dccfd732e3] temp-pbvh-seam-texturing-tweaks: Use std::array for MeshPrimitive edges
Commit: 0dccfd732e3e2f5dafcd90e5697f18a105c0bcf7 Author: Hans Goudey Date: Tue Sep 27 22:00:34 2022 -0500 Branches: temp-pbvh-seam-texturing-tweaks https://developer.blender.org/rB0dccfd732e3e2f5dafcd90e5697f18a105c0bcf7 Use std::array for MeshPrimitive edges === M source/blender/blenkernel/intern/pbvh_uv_islands.cc M source/blender/blenkernel/intern/pbvh_uv_islands.hh === diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.cc b/source/blender/blenkernel/intern/pbvh_uv_islands.cc index 484d78fe0f8..6120eb0991e 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.cc +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.cc @@ -107,10 +107,7 @@ static void mesh_data_init_primitives(MeshData &mesh_data) const MLoopTri &tri = mesh_data.looptris[i]; MeshPrimitive primitive; primitive.poly = tri.poly; - -for (int j = 0; j < 3; j++) { - primitive.loops.append(tri.tri[j]); -} +std::copy(std::begin(tri.tri), std::end(tri.tri), std::begin(primitive.loops)); mesh_data.primitives.append(primitive); } } @@ -122,6 +119,7 @@ static void mesh_data_init_edges(MeshData &mesh_data) for (int64_t i = 0; i < mesh_data.looptris.size(); i++) { const MLoopTri &tri = mesh_data.looptris[i]; MeshPrimitive &primitive = mesh_data.primitives[i]; +Vector edges; for (int j = 0; j < 3; j++) { int v1 = mesh_data.loops[tri.tri[j]].v; int v2 = mesh_data.loops[tri.tri[(j + 1) % 3]].v; @@ -142,8 +140,9 @@ static void mesh_data_init_edges(MeshData &mesh_data) mesh_data.vert_to_edge_map.add(edge_index, v1, v2); } - primitive.edges.append(edge_index); + edges.append(edge_index); } +std::copy(std::begin(edges), std::end(edges), std::begin(primitive.edges)); } /* Build edge to neighboring triangle map. */ mesh_data.edge_to_primitive_map = EdgeToPrimitiveMap(mesh_data.edges.size()); @@ -1132,7 +1131,7 @@ bool UVPrimitive::has_shared_edge(const UVPrimitive &other) const bool UVPrimitive::has_shared_edge(const Span uv_map, const MeshPrimitive &primitive) const { for (const UVEdge *uv_edge : edges) { -int loop_1 = primitive.loops.last(); +int loop_1 = primitive.loops[2]; for (int i = 0; i < primitive.loops.size(); i++) { int loop_2 = primitive.loops[i]; if (uv_edge->has_shared_edge(uv_map, loop_1, loop_2)) { diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.hh b/source/blender/blenkernel/intern/pbvh_uv_islands.hh index 2f543731a25..6060f5a5d27 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.hh +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.hh @@ -97,8 +97,8 @@ class EdgeToPrimitiveMap { /** Represents a triangle in 3d space (MLoopTri). */ struct MeshPrimitive { int64_t poly; - Vector edges; - Vector loops; + std::array edges; + std::array loops; /** Get the vertex that is not given. Both given vertices must be part of the MeshPrimitive. */ int get_other_uv_vertex(const MeshData &mesh_data, const int v1, const int v2) const; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [400284565fa] temp-pbvh-seam-texturing-tweaks: Remove MeshPrimitive completely
Commit: 400284565fa75f63048b3a7aacb974b4c1eedcc6 Author: Hans Goudey Date: Tue Sep 27 22:56:01 2022 -0500 Branches: temp-pbvh-seam-texturing-tweaks https://developer.blender.org/rB400284565fa75f63048b3a7aacb974b4c1eedcc6 Remove MeshPrimitive completely Now the existing MLoopTri array is used instead, in addition to a separate triangle -> edge connection array. This saves 16 bytes per face corner of memory usage during this process. It also makes the code more "standard", making it possible to share tooling with other areas that deal with UVs and looptriangles === M source/blender/blenkernel/intern/pbvh_pixels.cc M source/blender/blenkernel/intern/pbvh_uv_islands.cc M source/blender/blenkernel/intern/pbvh_uv_islands.hh === diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index d74ffa71ffe..a53d8e63753 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -106,10 +106,10 @@ static void update_geom_primitives(PBVH &pbvh, const uv_islands::MeshData &mesh_ { PBVHData &pbvh_data = BKE_pbvh_pixels_data_get(pbvh); pbvh_data.clear_data(); - for (const uv_islands::MeshPrimitive &mesh_primitive : mesh_data.primitives) { - pbvh_data.geom_primitives.append(int3(mesh_data.loops[mesh_primitive.loops[0]].v, - mesh_data.loops[mesh_primitive.loops[1]].v, - mesh_data.loops[mesh_primitive.loops[2]].v)); + for (const MLoopTri &looptri : mesh_data.looptris) { +pbvh_data.geom_primitives.append(int3(mesh_data.loops[looptri.tri[0]].v, + mesh_data.loops[looptri.tri[1]].v, + mesh_data.loops[looptri.tri[2]].v)); } } diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.cc b/source/blender/blenkernel/intern/pbvh_uv_islands.cc index 6120eb0991e..97ac97a 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.cc +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.cc @@ -28,15 +28,24 @@ static void uv_primitive_append_to_uv_vertices(UVPrimitive &uv_primitive) } /* */ -/** \name MeshPrimitive +/** \name Mesh Primitives * \{ */ -int MeshPrimitive::get_other_uv_vertex(const MeshData &mesh_data, const int v1, const int v2) const +int primitive_get_other_uv_vertex(const MeshData &mesh_data, + const MLoopTri &looptri, + const int v1, + const int v2) { const Span mesh_loops = mesh_data.loops; - BLI_assert(ELEM(v1, mesh_loops[loops[0]].v, mesh_loops[loops[1]].v, mesh_loops[loops[2]].v)); - BLI_assert(ELEM(v2, mesh_loops[loops[0]].v, mesh_loops[loops[1]].v, mesh_loops[loops[2]].v)); - for (const int loop : loops) { + BLI_assert(ELEM(v1, + mesh_loops[looptri.tri[0]].v, + mesh_loops[looptri.tri[1]].v, + mesh_loops[looptri.tri[2]].v)); + BLI_assert(ELEM(v2, + mesh_loops[looptri.tri[0]].v, + mesh_loops[looptri.tri[1]].v, + mesh_loops[looptri.tri[2]].v)); + for (const int loop : looptri.tri) { const int vert = mesh_loops[loop].v; if (vert != v1 && vert != v2) { return vert; @@ -45,11 +54,13 @@ int MeshPrimitive::get_other_uv_vertex(const MeshData &mesh_data, const int v1, return -1; } -bool MeshPrimitive::has_shared_uv_edge(const Span uv_map, const MeshPrimitive &other) const +bool primitive_has_shared_uv_edge(const Span uv_map, + const MLoopTri &looptri, + const MLoopTri &other) { int shared_uv_verts = 0; - for (const int loop : loops) { -for (const int other_loop : other.loops) { + for (const int loop : looptri.tri) { +for (const int other_loop : other.tri) { if (uv_map[loop] == uv_map[other_loop]) { shared_uv_verts += 1; } @@ -58,25 +69,21 @@ bool MeshPrimitive::has_shared_uv_edge(const Span uv_map, const MeshPrim return shared_uv_verts >= 2; } -static int get_uv_loop(const MeshData &mesh_data, - const MeshPrimitive &mesh_primitive, - const int vert) +static int get_uv_loop(const MeshData &mesh_data, const MLoopTri &looptri, const int vert) { - for (const int loop : mesh_primitive.loops) { + for (const int loop : looptri.tri) { if (mesh_data.loops[loop].v == vert) { return loop; } } BLI_assert_unreachable(); - return mesh_primitive.loops[0]; + return looptri.tri[0]; } -static bool has_vertex(const MeshData &mesh_data, - const MeshPrimitive &mesh_pri
[Bf-blender-cvs] [cedfba2248a] temp-pbvh-seam-texturing-tweaks: Remove MeshUVVert, use loop indices instead of "UV verts"
Commit: cedfba2248aa598e53382b4def4084ef8b378130 Author: Hans Goudey Date: Tue Sep 27 21:51:40 2022 -0500 Branches: temp-pbvh-seam-texturing-tweaks https://developer.blender.org/rBcedfba2248aa598e53382b4def4084ef8b378130 Remove MeshUVVert, use loop indices instead of "UV verts" === M source/blender/blenkernel/intern/pbvh_pixels.cc M source/blender/blenkernel/intern/pbvh_uv_islands.cc M source/blender/blenkernel/intern/pbvh_uv_islands.hh === diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index fa40d6b6909..d74ffa71ffe 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -107,9 +107,9 @@ static void update_geom_primitives(PBVH &pbvh, const uv_islands::MeshData &mesh_ PBVHData &pbvh_data = BKE_pbvh_pixels_data_get(pbvh); pbvh_data.clear_data(); for (const uv_islands::MeshPrimitive &mesh_primitive : mesh_data.primitives) { -pbvh_data.geom_primitives.append(int3(mesh_primitive.vertices[0].vertex, - mesh_primitive.vertices[1].vertex, - mesh_primitive.vertices[2].vertex)); + pbvh_data.geom_primitives.append(int3(mesh_data.loops[mesh_primitive.loops[0]].v, + mesh_data.loops[mesh_primitive.loops[1]].v, + mesh_data.loops[mesh_primitive.loops[2]].v)); } } @@ -149,7 +149,6 @@ struct EncodePixelsUserData { ImageUser *image_user; PBVH *pbvh; Vector *nodes; - const MLoopUV *ldata_uv; const uv_islands::UVIslandsMask *uv_masks; /** Lookup to retrieve the UV primitives based on the primitive index. */ const UVPrimitiveLookup *uv_primitive_lookup; @@ -358,16 +357,16 @@ static void update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image return; } - const MLoopUV *ldata_uv = static_cast( - CustomData_get_layer(&mesh->ldata, CD_MLOOPUV)); - if (ldata_uv == nullptr) { + const StringRef active_uv_name = CustomData_get_active_layer_name(&mesh->ldata, CD_MLOOPUV); + if (active_uv_name.is_empty()) { return; } - uv_islands::MeshData mesh_data({pbvh->looptri, pbvh->totprim}, - {pbvh->mloop, mesh->totloop}, - pbvh->totvert, - {ldata_uv, mesh->totloop}); + const AttributeAccessor attributes = mesh->attributes(); + const VArraySpan uv_map = attributes.lookup(active_uv_name, ATTR_DOMAIN_CORNER); + + uv_islands::MeshData mesh_data( + {pbvh->looptri, pbvh->totprim}, {pbvh->mloop, mesh->totloop}, pbvh->totvert, uv_map); uv_islands::UVIslands islands(mesh_data); uv_islands::UVIslandsMask uv_masks; @@ -397,7 +396,6 @@ static void update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image user_data.pbvh = pbvh; user_data.image = image; user_data.image_user = image_user; - user_data.ldata_uv = ldata_uv; user_data.nodes = &nodes_to_update; user_data.uv_primitive_lookup = &uv_primitive_lookup; user_data.uv_masks = &uv_masks; diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.cc b/source/blender/blenkernel/intern/pbvh_uv_islands.cc index 80b5ca0909d..608b9d1ae93 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.cc +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.cc @@ -31,24 +31,26 @@ static void uv_primitive_append_to_uv_vertices(UVPrimitive &uv_primitive) /** \name MeshPrimitive * \{ */ -int MeshPrimitive::get_other_uv_vertex(const int v1, const int v2) const -{ - BLI_assert(vertices[0].vertex == v1 || vertices[1].vertex == v1 || vertices[2].vertex == v1); - BLI_assert(vertices[0].vertex == v2 || vertices[1].vertex == v2 || vertices[2].vertex == v2); - for (const MeshUVVert &uv_vertex : vertices) { -if (uv_vertex.vertex != v1 && uv_vertex.vertex != v2) { - return uv_vertex.vertex; +int MeshPrimitive::get_other_uv_vertex(const MeshData &mesh_data, const int v1, const int v2) const +{ + const Span mesh_loops = mesh_data.loops; + BLI_assert(ELEM(v1, mesh_loops[loops[0]].v, mesh_loops[loops[1]].v, mesh_loops[loops[2]].v)); + BLI_assert(ELEM(v2, mesh_loops[loops[0]].v, mesh_loops[loops[1]].v, mesh_loops[loops[2]].v)); + for (const int loop : loops) { +const int vert = mesh_loops[loop].v; +if (vert != v1 && vert != v2) { + return vert; } } return -1; } -bool MeshPrimitive::has_shared_uv_edge(const MeshPrimitive &other) const +bool MeshPrimitive::has_shared_uv_edge(const Span uv_map, const MeshPrimitive &other) const { int shared_uv_verts = 0; - for (const MeshUVVert &vert : vertices) { -for (const MeshUVVert &other_vert : other.vertices) { - if (vert.uv == other_vert.uv) { + for (const
[Bf-blender-cvs] [47d22029f7d] temp-pbvh-seam-texturing-tweaks: Remove MeshPrimitive.index
Commit: 47d22029f7dbe4dc6e3d62af59f6dfdd50558348 Author: Hans Goudey Date: Tue Sep 27 21:53:45 2022 -0500 Branches: temp-pbvh-seam-texturing-tweaks https://developer.blender.org/rB47d22029f7dbe4dc6e3d62af59f6dfdd50558348 Remove MeshPrimitive.index === M source/blender/blenkernel/intern/pbvh_uv_islands.cc M source/blender/blenkernel/intern/pbvh_uv_islands.hh === diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.cc b/source/blender/blenkernel/intern/pbvh_uv_islands.cc index 608b9d1ae93..484d78fe0f8 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.cc +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.cc @@ -106,7 +106,6 @@ static void mesh_data_init_primitives(MeshData &mesh_data) for (int64_t i = 0; i < mesh_data.looptris.size(); i++) { const MLoopTri &tri = mesh_data.looptris[i]; MeshPrimitive primitive; -primitive.index = i; primitive.poly = tri.poly; for (int j = 0; j < 3; j++) { diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.hh b/source/blender/blenkernel/intern/pbvh_uv_islands.hh index ec6fa15d557..2f543731a25 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.hh +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.hh @@ -96,7 +96,6 @@ class EdgeToPrimitiveMap { /** Represents a triangle in 3d space (MLoopTri). */ struct MeshPrimitive { - int64_t index; int64_t poly; Vector edges; Vector loops; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [670e20d15f8] temp-pbvh-seam-texturing-tweaks: Applied 54dae0fb3cdf
Commit: 670e20d15f8d928a4f3eaf0c7a5ae193a114acf6 Author: Jeroen Bakker Date: Mon Dec 12 14:28:50 2022 +0100 Branches: temp-pbvh-seam-texturing-tweaks https://developer.blender.org/rB670e20d15f8d928a4f3eaf0c7a5ae193a114acf6 Applied 54dae0fb3cdf === M source/blender/blenkernel/intern/pbvh_pixels.cc M source/blender/blenkernel/intern/pbvh_uv_islands.cc M source/blender/blenkernel/intern/pbvh_uv_islands.hh === diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index bb7e912fd94..fa40d6b6909 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later * Copyright 2022 Blender Foundation. All rights reserved. */ +#include "BKE_attribute.hh" #include "BKE_customdata.h" #include "BKE_mesh.h" #include "BKE_mesh_mapping.h" @@ -106,9 +107,9 @@ static void update_geom_primitives(PBVH &pbvh, const uv_islands::MeshData &mesh_ PBVHData &pbvh_data = BKE_pbvh_pixels_data_get(pbvh); pbvh_data.clear_data(); for (const uv_islands::MeshPrimitive &mesh_primitive : mesh_data.primitives) { -pbvh_data.geom_primitives.append(int3(mesh_primitive.vertices[0].vertex->v, - mesh_primitive.vertices[1].vertex->v, - mesh_primitive.vertices[2].vertex->v)); +pbvh_data.geom_primitives.append(int3(mesh_primitive.vertices[0].vertex, + mesh_primitive.vertices[1].vertex, + mesh_primitive.vertices[2].vertex)); } } @@ -134,7 +135,7 @@ struct UVPrimitiveLookup { for (VectorList::UsedVector &uv_primitives : uv_island.uv_primitives) { for (uv_islands::UVPrimitive &uv_primitive : uv_primitives) { - lookup[uv_primitive.primitive->index].append_as(Entry(&uv_primitive, uv_island_index)); + lookup[uv_primitive.primitive_i].append_as(Entry(&uv_primitive, uv_island_index)); } } uv_island_index++; @@ -143,6 +144,7 @@ struct UVPrimitiveLookup { }; struct EncodePixelsUserData { + const uv_islands::MeshData *mesh_data; Image *image; ImageUser *image_user; PBVH *pbvh; @@ -158,6 +160,7 @@ static void do_encode_pixels(void *__restrict userdata, const TaskParallelTLS *__restrict /*tls*/) { EncodePixelsUserData *data = static_cast(userdata); + const uv_islands::MeshData &mesh_data = *data->mesh_data; Image *image = data->image; ImageUser image_user = *data->image_user; PBVHNode *node = (*data->nodes)[n]; @@ -183,9 +186,9 @@ static void do_encode_pixels(void *__restrict userdata, data->uv_primitive_lookup->lookup[geom_prim_index]) { uv_islands::UVBorder uv_border = entry.uv_primitive->extract_border(); float2 uvs[3] = { -entry.uv_primitive->get_uv_vertex(0)->uv - tile_offset, -entry.uv_primitive->get_uv_vertex(1)->uv - tile_offset, -entry.uv_primitive->get_uv_vertex(2)->uv - tile_offset, +entry.uv_primitive->get_uv_vertex(mesh_data, 0)->uv - tile_offset, +entry.uv_primitive->get_uv_vertex(mesh_data, 1)->uv - tile_offset, +entry.uv_primitive->get_uv_vertex(mesh_data, 2)->uv - tile_offset, }; const float minv = clamp_f(min_fff(uvs[0].y, uvs[1].y, uvs[2].y), 0.0f, 1.0f); const int miny = floor(minv * image_buffer->y); @@ -362,9 +365,9 @@ static void update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image } uv_islands::MeshData mesh_data({pbvh->looptri, pbvh->totprim}, - {pbvh->mloop, pbvh->totprim}, + {pbvh->mloop, mesh->totloop}, pbvh->totvert, - {ldata_uv, pbvh->totprim}); + {ldata_uv, mesh->totloop}); uv_islands::UVIslands islands(mesh_data); uv_islands::UVIslandsMask uv_masks; @@ -380,16 +383,17 @@ static void update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image ushort2(tile_buffer->x, tile_buffer->y)); BKE_image_release_ibuf(image, tile_buffer, nullptr); } - uv_masks.add(islands); + uv_masks.add(mesh_data, islands); uv_masks.dilate(image->seam_margin); islands.extract_borders(); - islands.extend_borders(uv_masks); + islands.extend_borders(mesh_data, uv_masks); update_geom_primitives(*pbvh, mesh_data); UVPrimitiveLookup uv_primitive_lookup(mesh_data.looptris.size(), islands); EncodePixelsUserData user_data; + user_data.mesh_data = &mesh_data; user_data.pbvh = pbvh; user_data.image = image; user_data.image_user = image_user; di
[Bf-blender-cvs] [baf8b3bb887] master: Cleanup: Standardize variable names, use spans to pbvh uv islands.
Commit: baf8b3bb8874836ed0862e8381602d34184a98d9 Author: Hans Goudey Date: Tue Sep 27 15:56:15 2022 -0500 Branches: master https://developer.blender.org/rBbaf8b3bb8874836ed0862e8381602d34184a98d9 Cleanup: Standardize variable names, use spans to pbvh uv islands. === M source/blender/blenkernel/intern/pbvh_pixels.cc M source/blender/blenkernel/intern/pbvh_uv_islands.cc M source/blender/blenkernel/intern/pbvh_uv_islands.hh === diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index 4e073f195a9..bb7e912fd94 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -361,8 +361,10 @@ static void update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image return; } - uv_islands::MeshData mesh_data( - pbvh->looptri, pbvh->totprim, pbvh->totvert, pbvh->mloop, ldata_uv); + uv_islands::MeshData mesh_data({pbvh->looptri, pbvh->totprim}, + {pbvh->mloop, pbvh->totprim}, + pbvh->totvert, + {ldata_uv, pbvh->totprim}); uv_islands::UVIslands islands(mesh_data); uv_islands::UVIslandsMask uv_masks; @@ -385,7 +387,7 @@ static void update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image islands.extend_borders(uv_masks); update_geom_primitives(*pbvh, mesh_data); - UVPrimitiveLookup uv_primitive_lookup(mesh_data.looptri_len, islands); + UVPrimitiveLookup uv_primitive_lookup(mesh_data.looptris.size(), islands); EncodePixelsUserData user_data; user_data.pbvh = pbvh; diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.cc b/source/blender/blenkernel/intern/pbvh_uv_islands.cc index aec4929c5fa..21645e50e7e 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.cc +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.cc @@ -95,8 +95,8 @@ rctf MeshPrimitive::uv_bounds() const static void mesh_data_init_vertices(MeshData &mesh_data) { - mesh_data.vertices.reserve(mesh_data.vert_len); - for (int64_t i = 0; i < mesh_data.vert_len; i++) { + mesh_data.vertices.reserve(mesh_data.verts_num); + for (int64_t i = 0; i < mesh_data.verts_num; i++) { MeshVertex vert; vert.v = i; mesh_data.vertices.append(vert); @@ -105,9 +105,9 @@ static void mesh_data_init_vertices(MeshData &mesh_data) static void mesh_data_init_primitives(MeshData &mesh_data) { - mesh_data.primitives.reserve(mesh_data.looptri_len); - for (int64_t i = 0; i < mesh_data.looptri_len; i++) { -const MLoopTri &tri = mesh_data.looptri[i]; + mesh_data.primitives.reserve(mesh_data.looptris.size()); + for (int64_t i = 0; i < mesh_data.looptris.size(); i++) { +const MLoopTri &tri = mesh_data.looptris[i]; MeshPrimitive primitive; primitive.index = i; primitive.poly = tri.poly; @@ -115,7 +115,7 @@ static void mesh_data_init_primitives(MeshData &mesh_data) for (int j = 0; j < 3; j++) { MeshUVVert uv_vert; uv_vert.loop = tri.tri[j]; - uv_vert.vertex = &mesh_data.vertices[mesh_data.mloop[uv_vert.loop].v]; + uv_vert.vertex = &mesh_data.vertices[mesh_data.loops[uv_vert.loop].v]; uv_vert.uv = mesh_data.mloopuv[uv_vert.loop].uv; primitive.vertices.append(uv_vert); } @@ -125,14 +125,14 @@ static void mesh_data_init_primitives(MeshData &mesh_data) static void mesh_data_init_edges(MeshData &mesh_data) { - mesh_data.edges.reserve(mesh_data.looptri_len * 2); - EdgeHash *eh = BLI_edgehash_new_ex(__func__, mesh_data.looptri_len * 3); - for (int64_t i = 0; i < mesh_data.looptri_len; i++) { -const MLoopTri &tri = mesh_data.looptri[i]; + mesh_data.edges.reserve(mesh_data.looptris.size() * 2); + EdgeHash *eh = BLI_edgehash_new_ex(__func__, mesh_data.looptris.size() * 3); + for (int64_t i = 0; i < mesh_data.looptris.size(); i++) { +const MLoopTri &tri = mesh_data.looptris[i]; MeshPrimitive &primitive = mesh_data.primitives[i]; for (int j = 0; j < 3; j++) { - int v1 = mesh_data.mloop[tri.tri[j]].v; - int v2 = mesh_data.mloop[tri.tri[(j + 1) % 3]].v; + int v1 = mesh_data.loops[tri.tri[j]].v; + int v2 = mesh_data.loops[tri.tri[(j + 1) % 3]].v; void **edge_index_ptr; int64_t edge_index; @@ -215,16 +215,11 @@ static void mesh_data_init(MeshData &mesh_data) mesh_data_init_primitive_uv_island_ids(mesh_data); } -MeshData::MeshData(const MLoopTri *looptri, - const int64_t looptri_len, - const int64_t vert_len, - const MLoop *mloop, - const MLoopUV *mloopuv) -: looptri(looptri), - looptri_len(looptri_len), - vert_len(vert_len), - mloop(mloop), - mloopuv(mloopuv) +MeshData::MeshData(const Span looptris, +
[Bf-blender-cvs] [018c9e9da89] xr-dev: Merge branch 'master' into xr-dev
Commit: 018c9e9da89d069a3509c2431da8c62e2b69a409 Author: Peter Kim Date: Mon Dec 12 21:33:25 2022 +0900 Branches: xr-dev https://developer.blender.org/rB018c9e9da89d069a3509c2431da8c62e2b69a409 Merge branch 'master' into xr-dev === === diff --cc source/blender/editors/interface/interface_templates.cc index aae10de2573,6c71c1bcc65..9cad8226883 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@@ -6523,44 -6567,6 +6567,44 @@@ void uiTemplateKeymapItemProperties(uiL /** \} */ +/* */ +/** \name XR Actionmap Template + * \{ */ + +#ifdef WITH_XR_OPENXR +static void xr_actionmap_item_modified(bContext *UNUSED(C), + void *UNUSED(ami_p), + void *UNUSED(unused)) +{ +} +#endif + +void uiTemplateXrActionmapItemProperties(uiLayout *layout, PointerRNA *ptr) +{ +#ifdef WITH_XR_OPENXR + PointerRNA propptr = RNA_pointer_get(ptr, "op_properties"); + + if (propptr.data) { - uiBut *but = uiLayoutGetBlock(layout)->buttons.last; ++uiBut *but = static_cast(uiLayoutGetBlock(layout)->buttons.last); + +WM_operator_properties_sanitize(&propptr, false); +/* Use same template as keymap item properties. */ - template_keymap_item_properties(layout, NULL, &propptr); ++template_keymap_item_properties(layout, nullptr, &propptr); + +for (; but; but = but->next) { + if (but->rnaprop) { - UI_but_func_set(but, xr_actionmap_item_modified, ptr->data, NULL); ++UI_but_func_set(but, xr_actionmap_item_modified, ptr->data, nullptr); +UI_but_flag_enable(but, UI_BUT_UPDATE_DELAY); + } +} + } +#else + UNUSED_VARS(layout, ptr); +#endif +} + +/** \} */ + /* */ /** \name Event Icon Template * \{ */ diff --cc source/blender/nodes/NOD_shader.h index 681851eab85,57c1b6c8c5e..e9dbf48b5c4 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@@ -15,122 -15,6 +15,8 @@@ extern "C" extern struct bNodeTreeType *ntreeType_Shader; - /* the type definitions array */ - /* ** types array for all shaders ** */ - - void register_node_tree_type_sh(void); - - void register_node_type_sh_group(void); - - void register_node_type_sh_camera(void); - void register_node_type_sh_value(void); - void register_node_type_sh_rgb(void); - void register_node_type_sh_mix_rgb(void); - void register_node_type_sh_mix(void); - void register_node_type_sh_valtorgb(void); - void register_node_type_sh_rgbtobw(void); - void register_node_type_sh_shadertorgb(void); - void register_node_type_sh_normal(void); - void register_node_type_sh_gamma(void); - void register_node_type_sh_brightcontrast(void); - void register_node_type_sh_mapping(void); - void register_node_type_sh_curve_float(void); - void register_node_type_sh_curve_vec(void); - void register_node_type_sh_curve_rgb(void); - void register_node_type_sh_map_range(void); - void register_node_type_sh_clamp(void); - void register_node_type_sh_math(void); - void register_node_type_sh_vect_math(void); - void register_node_type_sh_squeeze(void); - void register_node_type_sh_dynamic(void); - void register_node_type_sh_invert(void); - void register_node_type_sh_sepcolor(void); - void register_node_type_sh_combcolor(void); - void register_node_type_sh_seprgb(void); - void register_node_type_sh_combrgb(void); - void register_node_type_sh_sephsv(void); - void register_node_type_sh_combhsv(void); - void register_node_type_sh_sepxyz(void); - void register_node_type_sh_combxyz(void); - void register_node_type_sh_hue_sat(void); - void register_node_type_sh_tex_brick(void); - void register_node_type_sh_tex_pointdensity(void); - - void register_node_type_sh_attribute(void); - void register_node_type_sh_bevel(void); - void register_node_type_sh_displacement(void); - void register_node_type_sh_vector_displacement(void); - void register_node_type_sh_geometry(void); - void register_node_type_sh_light_path(void); - void register_node_type_sh_light_falloff(void); - void register_node_type_sh_object_info(void); - void register_node_type_sh_fresnel(void); - void register_node_type_sh_wireframe(void); - void register_node_type_sh_wavelength(void); - void register_node_type_sh_blackbody(void); - void register_node_type_sh_layer_weight(void); - void register_node_type_sh_tex_coord(void); - void register_node_type_sh_particle_info(void); - void register_node_type_sh_hair_info(void); - void register_node_type_sh_point_info(void); - void register_node_type_sh_volume_info(void); - void register_node_type_sh_script(void); - void register_node_type_sh_normal_map(void); - vo
[Bf-blender-cvs] [d1b2ed706cd] xr-dev: XR: Add mouse event simulation
Commit: d1b2ed706cd22defd109729e5809e20011fa5d7b Author: Peter Kim Date: Mon Dec 12 21:26:01 2022 +0900 Branches: xr-dev https://developer.blender.org/rBd1b2ed706cd22defd109729e5809e20011fa5d7b XR: Add mouse event simulation Updated version of https://developer.blender.org/D13153. This enables practical use of more Blender operators in VR by converting 3D controller positions to 2D mouse positions as well as simulating the event type (LEFTMOUSE, MOUSEMOVE...) and value (PRESS, CLICK...) based on VR controller inputs. In this way, the view3d.select operator can be used in VR without any modifications to the operator logic, enabling selection of armatures, empties, etc. in VR. If an XR action's simulate_mouse property is set, the 3D position of the corresponding controller aim pose will be projected to a 2D mouse position using the perspective of the user's preferred eye (XrSessionSettings.projection_eye) and the result stored in wmEvent.xy/mval. In this way, operators can make use of these mouse values as usual, without needing to know that the event is an XR event. Along with mouse coordinate simulation, the XR event type and value can be simulated as a different wmEvent type/value during handling, where this mapping is configurable via the XrActionMapItem.simulate (XrSimulateMouseParams) property of an XR action map item. The simulated type/value can be individually set for press, hold (modal operators only), and release VR button interactions, depending on the operator execution mode (XrActionMapItem.op_mode). === M source/blender/editors/include/ED_view3d.h M source/blender/makesdna/DNA_xr_types.h M source/blender/makesrna/intern/rna_wm.c M source/blender/makesrna/intern/rna_xr.c M source/blender/windowmanager/WM_api.h M source/blender/windowmanager/WM_types.h M source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c M source/blender/windowmanager/intern/wm_event_system.cc M source/blender/windowmanager/wm_event_system.h M source/blender/windowmanager/xr/intern/wm_xr_action.c M source/blender/windowmanager/xr/intern/wm_xr_draw.c M source/blender/windowmanager/xr/intern/wm_xr_intern.h M source/blender/windowmanager/xr/intern/wm_xr_session.c === diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 040a2b13adb..6af7400d458 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -1346,7 +1346,7 @@ void ED_view3d_local_collections_reset(struct bContext *C, bool reset_all); #ifdef WITH_XR_OPENXR void ED_view3d_xr_mirror_update(const struct ScrArea *area, const struct View3D *v3d, bool enable); void ED_view3d_xr_shading_update(struct wmWindowManager *wm, - const View3D *v3d, + const struct View3D *v3d, const struct Scene *scene); bool ED_view3d_is_region_xr_mirror_active(const struct wmWindowManager *wm, const struct View3D *v3d, diff --git a/source/blender/makesdna/DNA_xr_types.h b/source/blender/makesdna/DNA_xr_types.h index fa590c69728..502d711ae5a 100644 --- a/source/blender/makesdna/DNA_xr_types.h +++ b/source/blender/makesdna/DNA_xr_types.h @@ -30,7 +30,9 @@ typedef struct XrSessionSettings { char draw_flags; /** Draw style for controller visualization. */ char controller_draw_style; - char _pad2[2]; + /** The eye (view) used for 3D->2D projection when simulating mouse. */ + char projection_eye; + char _pad2; /** Clipping distance. */ float clip_start, clip_end; @@ -71,6 +73,11 @@ typedef enum eXrSessionControllerDrawStyle { XR_CONTROLLER_DRAW_LIGHT_RAY = 3, } eXrSessionControllerDrawStyle; +typedef enum eXrSessionEye { + XR_EYE_LEFT = 0, + XR_EYE_RIGHT = 1, +} eXrSessionEye; + /** XR action type. Enum values match those in GHOST_XrActionType enum for consistency. */ typedef enum eXrActionType { XR_BOOLEAN_INPUT = 1, @@ -90,6 +97,8 @@ typedef enum eXrOpFlag { typedef enum eXrActionFlag { /** Action depends on two sub-action paths (i.e. two-handed/bi-manual action). */ XR_ACTION_BIMANUAL = (1 << 0), + /** Whether to use controller inputs to simulate mouse inputs. */ + XR_ACTION_SIMULATE_MOUSE = (1 << 1), } eXrActionFlag; typedef enum eXrHapticFlag { @@ -174,6 +183,16 @@ typedef struct XrUserPath { char path[64]; /* XR_MAX_USER_PATH_LENGTH */ } XrUserPath; +typedef struct XrSimulateMouseParams { + short press_type; /* wmEvent.type */ + short press_val; /* wmEvent.val */ + short hold_type; + short hold_val; + short release_type; + short release_val; + short _pad[2]; +} XrSimulateMouseParams; + typedef struct XrActionMapItem { struct XrActionMapItem *next, *prev; @@ -193,6 +21
[Bf-blender-cvs] [786aad68b2c] xr-dev: Fix virtual camera-related crashes due to failed assert
Commit: 786aad68b2c210bcb2f56e2ae2bf5daa92b669eb Author: Peter Kim Date: Mon Dec 12 21:25:43 2022 +0900 Branches: xr-dev https://developer.blender.org/rB786aad68b2c210bcb2f56e2ae2bf5daa92b669eb Fix virtual camera-related crashes due to failed assert See comment on https://developer.blender.org/D16366. When browsing materials, showing material properties, or changing camera settings for the virtual camera, Blender would crash due to a failed assert in gpu_offscreen_fb_get() (gpu_framebuffer.cc L602), where the framebuffer list for the virtual camera offscreen would appear to contain corrupted data. This was likely caused by the pointer to the virtual camera offscreen (stored as camera->runtime.virtual_monitor_offscreen) being shared among src and dst camera data-blocks in camera_copy_data(), which is called from depsgraph copy-on-write (when showing material properties, changing camera settings, etc.). This should probably not be the case, as if one data-block is freed (freeing the runtime data), then the other will have a dangling pointer to the offscreen. As a tentative solution, free the runtime data for the dst camera in camera_copy_data() to prevent sharing virtual monitor offscreens across cameras. In this way, no two virtual camera data-blocks should share the same offscreen pointer and a new offscreen will be created for the dst camera if necessary in view3d_virtual_camera_update(). === M source/blender/blenkernel/intern/camera.c === diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index e3a72c5d69e..b475d49d8e7 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -59,6 +59,20 @@ static void camera_init_data(ID *id) MEMCPY_STRUCT_AFTER(cam, DNA_struct_default_get(Camera), id); } +/** Free (or release) any data used by this camera (does not free the camera itself). */ +static void camera_free_runtime_data(Camera *cam, const Camera *cam_src) +{ + if (cam->runtime.virtual_monitor_offscreen) { +if (!cam_src || +(cam_src->runtime.virtual_monitor_offscreen != cam->runtime.virtual_monitor_offscreen)) { + GPU_offscreen_free(cam->runtime.virtual_monitor_offscreen); +} +cam->runtime.virtual_monitor_offscreen = NULL; + } + /* GPU texture is owned by the GPUOffscreen instance. */ + cam->runtime.offscreen_color_texture = NULL; +} + /** * Only copy internal data of Camera ID from source * to already allocated/initialized destination. @@ -82,24 +96,17 @@ static void camera_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, CameraBGImage *bgpic_dst = BKE_camera_background_image_copy(bgpic_src, flag_subdata); BLI_addtail(&cam_dst->bg_images, bgpic_dst); } -} -/** Free (or release) any data used by this camera (does not free the camera itself). */ -static void camera_free_runtime_data(Camera *camera) -{ - if (camera->runtime.virtual_monitor_offscreen) { -GPU_offscreen_free(camera->runtime.virtual_monitor_offscreen); -camera->runtime.virtual_monitor_offscreen = NULL; - } - /* GPU texture is owned by the GPUOffscreen instance. */ - camera->runtime.offscreen_color_texture = NULL; + /* Free runtime data to prevent virtual monitor offscreen from being shared across data-blocks. + */ + camera_free_runtime_data(cam_dst, cam_src); } static void camera_free_data(ID *id) { Camera *cam = (Camera *)id; BLI_freelistN(&cam->bg_images); - camera_free_runtime_data(cam); + camera_free_runtime_data(cam, NULL); } static void camera_foreach_id(ID *id, LibraryForeachIDData *data) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1e8d4dcd3ee] asset-lite-greasepencil: Merge branch 'master' into asset-lite-greasepencil
Commit: 1e8d4dcd3eec655b103b8596c8be5f87eb4737b8 Author: Antonio Vazquez Date: Mon Dec 12 12:41:08 2022 +0100 Branches: asset-lite-greasepencil https://developer.blender.org/rB1e8d4dcd3eec655b103b8596c8be5f87eb4737b8 Merge branch 'master' into asset-lite-greasepencil === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3e1152428d5] master: Cleanup: Code comments in tree.h
Commit: 3e1152428d591db65b947308c91739344ef1dd51 Author: Alaska Date: Mon Dec 12 12:32:11 2022 +0100 Branches: master https://developer.blender.org/rB3e1152428d591db65b947308c91739344ef1dd51 Cleanup: Code comments in tree.h Differential Revision: https://developer.blender.org/D16751 === M intern/cycles/kernel/light/tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index ad9fd3d10e4..3b683b5562f 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -22,16 +22,15 @@ CCL_NAMESPACE_BEGIN -/* TODO: this seems like a relative expensive computation, and we can make it a lot cheaper - * by using a bounding sphere instead of a bounding box. This will be more inaccurate, but it - * might be fine when used along with the adaptive splitting. */ +/* TODO: this seems like a relative expensive computation. We can make it a lot cheaper by using a + * bounding sphere instead of a bounding box, but this will reduce the accuracy sometimes. */ ccl_device float light_tree_cos_bounding_box_angle(const BoundingBox bbox, const float3 P, const float3 point_to_centroid) { if (P.x > bbox.min.x && P.y > bbox.min.y && P.z > bbox.min.z && P.x < bbox.max.x && P.y < bbox.max.y && P.z < bbox.max.z) { -/* If P is inside the bbox, `theta_u` covers the whole sphere */ +/* If P is inside the bbox, `theta_u` covers the whole sphere. */ return -1.0f; } float cos_theta_u = 1.0f; @@ -53,7 +52,7 @@ ccl_device_forceinline float sin_from_cos(const float c) return safe_sqrtf(1.0f - sqr(c)); } -/* Compute vector v as in Fig .8. P_v is the corresponding point along the ray ccl_device float3 */ +/* Compute vector v as in Fig .8. P_v is the corresponding point along the ray. */ ccl_device float3 compute_v( const float3 centroid, const float3 P, const float3 D, const float3 bcone_axis, const float t) { @@ -95,12 +94,12 @@ ccl_device void light_tree_importance(const float3 N_or_D, const float sin_theta_u = sin_from_cos(cos_theta_u); - /* cos(theta_i') in the paper, omitted for volume */ + /* cos(theta_i') in the paper, omitted for volume. */ float cos_min_incidence_angle = 1.0f; float cos_max_incidence_angle = 1.0f; - /* when sampling the light tree for the second time in `shade_volume.h` and when query the pdf in - * `sample.h` */ + /* When sampling the light tree for the second time in `shade_volume.h` and when query the pdf in + * `sample.h`. */ const bool in_volume = is_zero(N_or_D); if (!in_volume_segment && !in_volume) { const float3 N = N_or_D; @@ -116,7 +115,7 @@ ccl_device void light_tree_importance(const float3 N_or_D, /* If the node is guaranteed to be behind the surface we're sampling, and the surface is * opaque, then we can give the node an importance of 0 as it contributes nothing to the * surface. This is more accurate than the bbox test if we are calculating the importance of - * an emitter with radius */ + * an emitter with radius. */ if (!has_transmission && cos_min_incidence_angle < 0) { return; } @@ -133,8 +132,8 @@ ccl_device void light_tree_importance(const float3 N_or_D, float cos_theta_o, sin_theta_o; fast_sincosf(bcone.theta_o, &sin_theta_o, &cos_theta_o); - /* minimum angle an emitter’s axis would form with the direction to the shading point, - * cos(theta') in the paper */ + /* Minimum angle an emitter’s axis would form with the direction to the shading point, + * cos(theta') in the paper. */ float cos_min_outgoing_angle; if ((cos_theta >= cos_theta_u) || (cos_theta_minus_theta_u >= cos_theta_o)) { /* theta - theta_o - theta_u <= 0 */ @@ -151,7 +150,7 @@ ccl_device void light_tree_importance(const float3 N_or_D, sin_theta_minus_theta_u * sin_theta_o; } else { -/* cluster invisible */ +/* Cluster is invisible. */ return; } @@ -200,14 +199,14 @@ ccl_device bool compute_emitter_centroid_and_dir(KernelGlobals kg, dir = klight->spot.dir; break; case LIGHT_POINT: -/* Disk-oriented normal */ +/* Disk-oriented normal. */ dir = safe_normalize(P - centroid); break; case LIGHT_AREA: dir = klight->area.dir; break; case LIGHT_BACKGROUND: -/* Aarbitrary centroid and direction */ +/* Arbitrary centroid and direction. */ centroid = make_float3(0.0f, 0.0f, 1.0f); dir = make_float3(0.0f, 0.0f, -1.0f); return !in_volume_segment; @@ -231,7 +230,7 @@ ccl_device bool compute_emitter_centroid_and_dir(KernelGlobals kg, dir = -safe_normalize(cross(vertices[1] - vertices[0], ve
[Bf-blender-cvs] [97b0719f7dc] tmp-workbench-rewrite2: WIP: Compute based culling for workbench shadows
Commit: 97b0719f7dc10159ca45fabc54496647ff070e6f Author: Miguel Pozo Date: Mon Dec 12 12:33:50 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rB97b0719f7dc10159ca45fabc54496647ff070e6f WIP: Compute based culling for workbench shadows === M source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh A source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl M source/blender/draw/engines/workbench/workbench_shadow.cc M source/blender/draw/intern/draw_view.hh === diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh index a77af467ec8..ad6b3560117 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "draw_defines.h" + #include "gpu_shader_create_info.hh" /* */ @@ -29,6 +31,20 @@ GPU_SHADER_CREATE_INFO(workbench_next_shadow_common) .additional_info("draw_modelmat_new") .additional_info("draw_resource_handle_new"); +GPU_SHADER_CREATE_INFO(workbench_next_shadow_visibility_compute) +.do_static_compilation(true) +.local_group_size(DRW_VISIBILITY_GROUP_SIZE) +.define("DRW_VIEW_LEN", "64") +.storage_buf(0, Qualifier::READ, "ObjectBounds", "bounds_buf[]") +.storage_buf(1, Qualifier::READ_WRITE, "uint", "visibility_buf[]") +.storage_buf(2, Qualifier::READ, "uint", "pass_technique_buf[]") +.push_constant(Type::INT, "resource_len") +.push_constant(Type::INT, "view_len") +.push_constant(Type::INT, "visibility_word_per_draw") +.push_constant(Type::VEC3, "shadow_direction") +.compute_source("draw_visibility_comp.glsl") +.additional_info("draw_view", "draw_view_culling"); + /** \} */ /* */ diff --git a/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl b/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl new file mode 100644 index 000..7e89120a79f --- /dev/null +++ b/source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl @@ -0,0 +1,53 @@ + +/** + * Compute visibility of each resource bounds for a given view. + */ +/* TODO(fclem): This could be augmented by a 2 pass occlusion culling system. */ + +#pragma BLENDER_REQUIRE(common_math_lib.glsl) +#pragma BLENDER_REQUIRE(common_intersect_lib.glsl) + +shared uint shared_result; + +void mask_visibility_bit(uint view_id) +{ + if (view_len > 1) { +uint index = gl_GlobalInvocationID.x * uint(visibility_word_per_draw) + (view_id / 32u); +visibility_buf[index] &= ~(1u << view_id); + } + else { +atomicAnd(visibility_buf[gl_WorkGroupID.x], ~(1u << gl_LocalInvocationID.x)); + } +} + +void main() +{ + if (gl_GlobalInvocationID.x >= resource_len) { +return; + } + + ObjectBounds bounds = bounds_buf[gl_GlobalInvocationID.x]; + + if (bounds.bounding_sphere.w != -1.0) { +IsectBox box = isect_data_setup(bounds.bounding_corners[0].xyz, +bounds.bounding_corners[1].xyz, +bounds.bounding_corners[2].xyz, +bounds.bounding_corners[3].xyz); +Sphere bounding_sphere = Sphere(bounds.bounding_sphere.xyz, bounds.bounding_sphere.w); +Sphere inscribed_sphere = Sphere(bounds.bounding_sphere.xyz, bounds._inner_sphere_radius); + +for (drw_view_id = 0; drw_view_id < view_len; drw_view_id++) { + if (intersect_view(inscribed_sphere) == true) { +/* Visible. */ + } + else if (intersect_view(bounding_sphere) == false) { +/* Not visible. */ +mask_visibility_bit(drw_view_id); + } + else if (intersect_view(box) == false) { +/* Not visible. */ +mask_visibility_bit(drw_view_id); + } +} + } +} diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 3632cc54f5a..21d092eaba9 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -17,13 +17,117 @@ #include "BKE_object.h" #include "BLI_math.h" #include "DRW_render.h" +#include "GPU_compute.h" #include "workbench_private.hh" +#include "draw_shader.h" //REMOVE! + #define DEBUG_SHADOW_VOLUME 0 +#define GPU_CULLING 0 namespace blender::workbench { +class ShadowView : public View { + float3 direction_; + + public: + ShadowView(const char
[Bf-blender-cvs] [bc73c1cd167] tmp-workbench-rewrite2: add TODO
Commit: bc73c1cd16740f3b8a5c9ba58ef50c190158a867 Author: Miguel Pozo Date: Mon Dec 5 19:12:58 2022 +0100 Branches: tmp-workbench-rewrite2 https://developer.blender.org/rBbc73c1cd16740f3b8a5c9ba58ef50c190158a867 add TODO === M source/blender/draw/engines/workbench/workbench_shadow.cc === diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 61207337d86..3632cc54f5a 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -221,6 +221,10 @@ void ShadowPass::object_sync(Manager &manager, use_shadow_pass_technique = false; } +/* TODO (Miguel Pozo): + * Disable use_shadow_pass_tecnique when there are "in front" objects in the scene. + */ + /* We cannot use Shadow Pass technique on non-manifold object (see T76168). */ if (use_shadow_pass_technique && !is_manifold && (scene_state.cull_state != 0)) { use_shadow_pass_technique = false; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9c0d822737f] master: GPU: Compile vulkan shaders to Spir-V binaries.
Commit: 9c0d822737ff9bfca05424667ead642581325733 Author: Jeroen Bakker Date: Mon Dec 12 12:22:38 2022 +0100 Branches: master https://developer.blender.org/rB9c0d822737ff9bfca05424667ead642581325733 GPU: Compile vulkan shaders to Spir-V binaries. Compile each static shader using shaderc to Spir-V binaries. The main goal is to make sure that the GLSL created using ShaderCreateInfo and able to compile to Spir-V. For the second stage a correct pipeline needs to be created and some shader would need more adjustments (push constants size). With this patch future changes to GLSL sources can already be checked against vulkan, without the backend finished. Mechanism has been tested using MacOS and MoltenVK. For other OS, we should finetune CMake files to find the right location to shaderc. ``` *** Build Mon 12 Dec 2022 11:08:07 CET Shader Test compilation result: 463 / 463 passed (skipped 118 for compatibility reasons) OpenGL backend shader compilation succeeded. Shader Test compilation result: 529 / 529 passed (skipped 52 for compatibility reasons) Vulkan backend shader compilation succeeded. ``` Reviewed By: fclem Maniphest Tasks: T102760 Differential Revision: https://developer.blender.org/D16610 === M build_files/cmake/platform/platform_apple.cmake M source/blender/compositor/realtime_compositor/shaders/compositor_screen_lens_distortion.glsl M source/blender/compositor/realtime_compositor/shaders/library/gpu_shader_compositor_texture_utilities.glsl M source/blender/draw/engines/eevee_next/eevee_defines.hh M source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_tiles_flatten_comp.glsl M source/blender/draw/engines/overlay/shaders/overlay_motion_path_line_vert.glsl M source/blender/draw/engines/workbench/shaders/workbench_shadow_vert.glsl M source/blender/draw/intern/shaders/common_smaa_lib.glsl M source/blender/draw/intern/shaders/common_view_lib.glsl M source/blender/gpu/CMakeLists.txt M source/blender/gpu/intern/gpu_shader.cc M source/blender/gpu/intern/gpu_shader_builder.cc M source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl M source/blender/gpu/vulkan/vk_backend.cc M source/blender/gpu/vulkan/vk_backend.hh M source/blender/gpu/vulkan/vk_context.cc M source/blender/gpu/vulkan/vk_context.hh M source/blender/gpu/vulkan/vk_shader.cc M source/blender/gpu/vulkan/vk_shader.hh A source/blender/gpu/vulkan/vk_shader_log.cc A source/blender/gpu/vulkan/vk_shader_log.hh === diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 7a39e6ffda3..b2101662969 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -105,9 +105,10 @@ if(WITH_VULKAN_BACKEND) set(VULKAN_ROOT_DIR ${LIBDIR}/vulkan/macOS) set(VULKAN_INCLUDE_DIR ${VULKAN_ROOT_DIR}/include) set(VULKAN_LIBRARY ${VULKAN_ROOT_DIR}/lib/libvulkan.1.dylib) +set(SHADERC_LIBRARY ${VULKAN_ROOT_DIR}/lib/libshaderc_combined.a) set(VULKAN_INCLUDE_DIRS ${VULKAN_INCLUDE_DIR} ${MOLTENVK_INCLUDE_DIRS}) -set(VULKAN_LIBRARIES ${VULKAN_LIBRARY} ${MOLTENVK_LIBRARIES}) +set(VULKAN_LIBRARIES ${VULKAN_LIBRARY} ${SHADERC_LIBRARY} ${MOLTENVK_LIBRARIES}) else() message(WARNING "Vulkan SDK was not found, disabling WITH_VULKAN_BACKEND") set(WITH_VULKAN_BACKEND OFF) diff --git a/source/blender/compositor/realtime_compositor/shaders/compositor_screen_lens_distortion.glsl b/source/blender/compositor/realtime_compositor/shaders/compositor_screen_lens_distortion.glsl index dc572ea5aaf..58c1d97e81d 100644 --- a/source/blender/compositor/realtime_compositor/shaders/compositor_screen_lens_distortion.glsl +++ b/source/blender/compositor/realtime_compositor/shaders/compositor_screen_lens_distortion.glsl @@ -20,9 +20,9 @@ vec3 compute_chromatic_distortion_scale(float distance_squared) /* Compute the image coordinates after distortion by the given distortion scale computed by the * compute_distortion_scale function. Note that the function expects centered normalized UV * coordinates but outputs non-centered image coordinates. */ -vec2 compute_distorted_uv(vec2 uv, float scale) +vec2 compute_distorted_uv(vec2 uv, float uv_scale) { - return (uv * scale + 0.5) * texture_size(input_tx) - 0.5; + return (uv * uv_scale + 0.5) * texture_size(input_tx) - 0.5; } /* Compute the number of integration steps that should be used to approximate the distorted pixel diff --git a/source/blender/compositor/realtime_compositor/shaders/library/gpu_shader_compositor_texture_utilities.glsl b/source/blender/compositor/rea
[Bf-blender-cvs] [192719bdca3] temp-vulkan-shader: Don't make a local variable to load the WorldClipPlanes.
Commit: 192719bdca3833120062f6844e61b963dddcbf95 Author: Jeroen Bakker Date: Mon Dec 12 12:21:05 2022 +0100 Branches: temp-vulkan-shader https://developer.blender.org/rB192719bdca3833120062f6844e61b963dddcbf95 Don't make a local variable to load the WorldClipPlanes. === M source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl === diff --git a/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl b/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl index 110bfe4148e..35f1c7a2427 100644 --- a/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl @@ -10,15 +10,14 @@ uniform vec4 WorldClipPlanes[6]; void world_clip_planes_calc_clip_distance(vec3 wpos) { - vec4 clip_planes[6] = WorldClipPlanes; vec4 pos = vec4(wpos, 1.0); - gl_ClipDistance[0] = dot(clip_planes[0], pos); - gl_ClipDistance[1] = dot(clip_planes[1], pos); - gl_ClipDistance[2] = dot(clip_planes[2], pos); - gl_ClipDistance[3] = dot(clip_planes[3], pos); - gl_ClipDistance[4] = dot(clip_planes[4], pos); - gl_ClipDistance[5] = dot(clip_planes[5], pos); + gl_ClipDistance[0] = dot(WorldClipPlanes[0], pos); + gl_ClipDistance[1] = dot(WorldClipPlanes[1], pos); + gl_ClipDistance[2] = dot(WorldClipPlanes[2], pos); + gl_ClipDistance[3] = dot(WorldClipPlanes[3], pos); + gl_ClipDistance[4] = dot(WorldClipPlanes[4], pos); + gl_ClipDistance[5] = dot(WorldClipPlanes[5], pos); } # endif ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [275bbb8a4c2] temp-vulkan-shader: Use GPU_SHADER; not GPU_VULKAN.
Commit: 275bbb8a4c28644914904033fe96ffce389062c6 Author: Jeroen Bakker Date: Mon Dec 12 12:20:23 2022 +0100 Branches: temp-vulkan-shader https://developer.blender.org/rB275bbb8a4c28644914904033fe96ffce389062c6 Use GPU_SHADER; not GPU_VULKAN. === M source/blender/draw/engines/eevee_next/eevee_defines.hh === diff --git a/source/blender/draw/engines/eevee_next/eevee_defines.hh b/source/blender/draw/engines/eevee_next/eevee_defines.hh index 2c08aabbcfe..55d3921e39b 100644 --- a/source/blender/draw/engines/eevee_next/eevee_defines.hh +++ b/source/blender/draw/engines/eevee_next/eevee_defines.hh @@ -9,7 +9,7 @@ * dragging larger headers into the createInfo pipeline which would cause problems. */ -#ifndef GPU_VULKAN +#ifndef GPU_SHADER # pragma once #endif ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [719513dd9fe] master: Tests: make mesh comparisons more strict
Commit: 719513dd9fe40a8efb12d847ed6ac3bfc6167261 Author: Jacques Lucke Date: Mon Dec 12 12:13:33 2022 +0100 Branches: master https://developer.blender.org/rB719513dd9fe40a8efb12d847ed6ac3bfc6167261 Tests: make mesh comparisons more strict Previously, it wouldn't detect the case when one mesh had an attribute that the other one did not. Not sure if this always was the case or whether this less strict test was implemented accidentally at some point. === M source/blender/blenkernel/intern/mesh.cc === diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index f59cd4f3a7c..1fafec810ba 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -500,14 +500,19 @@ static int customdata_compare( for (int i1 = 0; i1 < c1->totlayer; i1++) { l1 = c1->layers + i1; +if (l1->anonymous_id != nullptr) { + continue; +} +bool found_corresponding_layer = false; for (int i2 = 0; i2 < c2->totlayer; i2++) { l2 = c2->layers + i2; - if (l1->type != l2->type || !STREQ(l1->name, l2->name) || l1->anonymous_id != nullptr || - l2->anonymous_id != nullptr) { + if (l1->type != l2->type || !STREQ(l1->name, l2->name) || l2->anonymous_id != nullptr) { continue; } /* At this point `l1` and `l2` have the same name and type, so they should be compared. */ + found_corresponding_layer = true; + switch (l1->type) { case CD_MVERT: { @@ -719,6 +724,11 @@ static int customdata_compare( } } } +if (!found_corresponding_layer) { + if ((1 << l1->type) & CD_MASK_PROP_ALL) { +return MESHCMP_CDLAYERS_MISMATCH; + } +} } return 0; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c14af6b4d72] temp-vulkan-shader: Prefix push constants to work around double macro expansion.
Commit: c14af6b4d72d36cb144f1bcf76a505198f580549 Author: Jeroen Bakker Date: Mon Dec 12 09:47:04 2022 +0100 Branches: temp-vulkan-shader https://developer.blender.org/rBc14af6b4d72d36cb144f1bcf76a505198f580549 Prefix push constants to work around double macro expansion. === M source/blender/gpu/vulkan/vk_shader.cc === diff --git a/source/blender/gpu/vulkan/vk_shader.cc b/source/blender/gpu/vulkan/vk_shader.cc index c4dfbc4b19d..368c529fbf5 100644 --- a/source/blender/gpu/vulkan/vk_shader.cc +++ b/source/blender/gpu/vulkan/vk_shader.cc @@ -741,7 +741,7 @@ std::string VKShader::resources_declare(const shader::ShaderCreateInfo &info) co ss << "layout(push_constant) uniform constants\n"; ss << "{\n"; for (const ShaderCreateInfo::PushConst &uniform : info.push_constants_) { - ss << " " << to_string(uniform.type) << " " << uniform.name; + ss << " " << to_string(uniform.type) << " pc_" << uniform.name; if (uniform.array_size > 0) { ss << "[" << uniform.array_size << "]"; } @@ -749,7 +749,7 @@ std::string VKShader::resources_declare(const shader::ShaderCreateInfo &info) co } ss << "} PushConstants;\n"; for (const ShaderCreateInfo::PushConst &uniform : info.push_constants_) { - ss << "#define " << uniform.name << " (PushConstants." << uniform.name << ")\n"; + ss << "#define " << uniform.name << " (PushConstants.pc_" << uniform.name << ")\n"; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f676dbebf50] temp-vulkan-shader: Merge branch 'master' into temp-vulkan-shader
Commit: f676dbebf508a170eca05e4d1d7a5ca291ca4bc8 Author: Jeroen Bakker Date: Mon Dec 12 09:29:27 2022 +0100 Branches: temp-vulkan-shader https://developer.blender.org/rBf676dbebf508a170eca05e4d1d7a5ca291ca4bc8 Merge branch 'master' into temp-vulkan-shader === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3a4d2df7b17] temp-vulkan-shader: Vulkan: add cube map array.
Commit: 3a4d2df7b17a34fcfa6117f68a2a023e7463d05c Author: Jeroen Bakker Date: Mon Dec 12 11:06:04 2022 +0100 Branches: temp-vulkan-shader https://developer.blender.org/rB3a4d2df7b17a34fcfa6117f68a2a023e7463d05c Vulkan: add cube map array. === M source/blender/gpu/vulkan/vk_shader.cc === diff --git a/source/blender/gpu/vulkan/vk_shader.cc b/source/blender/gpu/vulkan/vk_shader.cc index 368c529fbf5..40408759679 100644 --- a/source/blender/gpu/vulkan/vk_shader.cc +++ b/source/blender/gpu/vulkan/vk_shader.cc @@ -504,6 +504,7 @@ static char *glsl_patch_get() STR_CONCAT(patch, slen, "#define gl_VertexID gl_VertexIndex\n"); STR_CONCAT(patch, slen, "#define gpu_BaseInstance (0)\n"); STR_CONCAT(patch, slen, "#define gpu_InstanceIndex (gl_InstanceIndex)\n"); + STR_CONCAT(patch, slen, "#define GPU_ARB_texture_cube_map_array\n"); STR_CONCAT(patch, slen, "#define gl_InstanceID gpu_InstanceIndex\n"); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs