[Bf-blender-cvs] [e58e023e1a3] master: GHOST/Wayland: support dynamic loading libraries for Wayland

2022-07-05 Thread Campbell Barton
Commit: e58e023e1a3e10f4ff2557aedcd730b5dba23579
Author: Campbell Barton
Date:   Tue Jul 5 14:49:36 2022 +1000
Branches: master
https://developer.blender.org/rBe58e023e1a3e10f4ff2557aedcd730b5dba23579

GHOST/Wayland: support dynamic loading libraries for Wayland

Add intern/wayland_dynload which is used when WITH_GHOST_WAYLAND_DYNLOAD
is enabled (off by default). When enabled, systems without Wayland
installed will fall back to X11.

This allows Blender to dynamically load:
- libwayland-client
- libwayland-cursor
- libwayland-egl
- libdecor-0 (when WITH_GHOST_WAYLAND_LIBDECOR is enabled).

===

M   CMakeLists.txt
M   build_files/cmake/platform/platform_unix.cmake
M   intern/CMakeLists.txt
M   intern/ghost/CMakeLists.txt
M   intern/ghost/intern/GHOST_ISystem.cpp
M   intern/ghost/intern/GHOST_SystemWayland.cpp
M   intern/ghost/intern/GHOST_SystemWayland.h
M   intern/ghost/intern/GHOST_WindowWayland.cpp
A   intern/wayland_dynload/CMakeLists.txt
A   intern/wayland_dynload/extern/wayland_dynload_API.h
A   intern/wayland_dynload/extern/wayland_dynload_client.h
A   intern/wayland_dynload/extern/wayland_dynload_cursor.h
A   intern/wayland_dynload/extern/wayland_dynload_egl.h
A   intern/wayland_dynload/extern/wayland_dynload_libdecor.h
A   intern/wayland_dynload/intern/wayland_dynload_client.c
A   intern/wayland_dynload/intern/wayland_dynload_cursor.c
A   intern/wayland_dynload/intern/wayland_dynload_egl.c
A   intern/wayland_dynload/intern/wayland_dynload_libdecor.c
A   intern/wayland_dynload/intern/wayland_dynload_utils.c
A   intern/wayland_dynload/intern/wayland_dynload_utils.h

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b2b8c56001b..1416b5b4189 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -229,6 +229,9 @@ if(UNIX AND NOT (APPLE OR HAIKU))
 
 option(WITH_GHOST_WAYLAND_DBUS "Optionally build with DBUS support (used 
for Cursor themes). May hang on startup systems where DBUS is not used." OFF)
 mark_as_advanced(WITH_GHOST_WAYLAND_DBUS)
+
+option(WITH_GHOST_WAYLAND_DYNLOAD  "Enable runtime dynamic WAYLAND 
libraries loading" OFF)
+mark_as_advanced(WITH_GHOST_WAYLAND_DYNLOAD)
   endif()
 endif()
 
diff --git a/build_files/cmake/platform/platform_unix.cmake 
b/build_files/cmake/platform/platform_unix.cmake
index dff860d9876..4b654420531 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -641,12 +641,17 @@ if(WITH_GHOST_WAYLAND)
   endif()
 
   list(APPEND PLATFORM_LINKLIBS
-${wayland-client_LINK_LIBRARIES}
-${wayland-egl_LINK_LIBRARIES}
 ${xkbcommon_LINK_LIBRARIES}
-${wayland-cursor_LINK_LIBRARIES}
   )
 
+  if(NOT WITH_GHOST_WAYLAND_DYNLOAD)
+list(APPEND PLATFORM_LINKLIBS
+  ${wayland-client_LINK_LIBRARIES}
+  ${wayland-egl_LINK_LIBRARIES}
+  ${wayland-cursor_LINK_LIBRARIES}
+)
+  endif()
+
   if(WITH_GHOST_WAYLAND_DBUS)
 list(APPEND PLATFORM_LINKLIBS
   ${dbus_LINK_LIBRARIES}
@@ -655,9 +660,11 @@ if(WITH_GHOST_WAYLAND)
   endif()
 
   if(WITH_GHOST_WAYLAND_LIBDECOR)
-list(APPEND PLATFORM_LINKLIBS
-  ${libdecor_LIBRARIES}
-)
+if(NOT WITH_GHOST_WAYLAND_DYNLOAD)
+  list(APPEND PLATFORM_LINKLIBS
+${libdecor_LIBRARIES}
+  )
+endif()
 add_definitions(-DWITH_GHOST_WAYLAND_LIBDECOR)
   endif()
 endif()
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index 2ff2fb39806..6387fd016ba 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -67,3 +67,10 @@ endif()
 if(UNIX AND NOT APPLE)
   add_subdirectory(libc_compat)
 endif()
+
+if(UNIX AND NOT APPLE)
+  # Important this comes after "ghost" as it uses includes defined by GHOST's 
CMake.
+  if(WITH_GHOST_WAYLAND AND WITH_GHOST_WAYLAND_DYNLOAD)
+add_subdirectory(wayland_dynload)
+  endif()
+endif()
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 6a11d00cbc4..0203c5ecf5d 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -270,6 +270,16 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
   ${wayland-cursor_INCLUDE_DIRS}
 )
 
+if(WITH_GHOST_WAYLAND_DYNLOAD)
+  list(APPEND INC_SYS
+../../intern/wayland_dynload/extern
+  )
+  list(APPEND LIB
+bf_intern_wayland_dynload
+  )
+  add_definitions(-DWITH_GHOST_WAYLAND_DYNLOAD)
+endif()
+
 if(WITH_GHOST_WAYLAND_DBUS)
   list(APPEND INC_SYS
 ${dbus_INCLUDE_DIRS}
diff --git a/intern/ghost/intern/GHOST_ISystem.cpp 
b/intern/ghost/intern/GHOST_ISystem.cpp
index 745d5faeed4..4f6a9531077 100644
--- a/intern/ghost/intern/GHOST_ISystem.cpp
+++ b/intern/ghost/intern/GHOST_ISystem.cpp
@@ -37,12 +37,23 @@ GHOST_TSuccess GHOST_ISystem::createSystem()
 {
   GHOST_TSuccess success;
   if (!m_system) {
+
+#if 

[Bf-blender-cvs] [db9e08a0d18] master: Cleanup: spelling in comments

2022-07-05 Thread Campbell Barton
Commit: db9e08a0d1843d0d9efbc941f1dc85db22954dff
Author: Campbell Barton
Date:   Wed Jul 6 14:24:37 2022 +1000
Branches: master
https://developer.blender.org/rBdb9e08a0d1843d0d9efbc941f1dc85db22954dff

Cleanup: spelling in comments

===

M   intern/ghost/intern/GHOST_SystemCocoa.mm
M   source/blender/blenkernel/BKE_nla.h
M   source/blender/makesrna/intern/rna_nla.c
M   source/blender/windowmanager/xr/intern/wm_xr_intern.h

===

diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm 
b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 4b2529f5169..0a905f5093e 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -787,7 +787,7 @@ GHOST_IWindow 
*GHOST_SystemCocoa::getWindowUnderCursor(int32_t x, int32_t y)
 }
 
 /**
- * \note : returns coordinates in Cocoa screen coordinates
+ * \note returns coordinates in Cocoa screen coordinates.
  */
 GHOST_TSuccess GHOST_SystemCocoa::getCursorPosition(int32_t , int32_t ) 
const
 {
@@ -800,7 +800,7 @@ GHOST_TSuccess GHOST_SystemCocoa::getCursorPosition(int32_t 
, int32_t ) cons
 }
 
 /**
- * \note : expect Cocoa screen coordinates
+ * \note expect Cocoa screen coordinates.
  */
 GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(int32_t x, int32_t y)
 {
diff --git a/source/blender/blenkernel/BKE_nla.h 
b/source/blender/blenkernel/BKE_nla.h
index 11642763074..2613f4286f0 100644
--- a/source/blender/blenkernel/BKE_nla.h
+++ b/source/blender/blenkernel/BKE_nla.h
@@ -228,7 +228,7 @@ bool BKE_nlatrack_is_nonlocal_in_liboverride(const struct 
ID *id, const struct N
  * - the end frame of the previous strip, if the strip's track contains 
another strip on it left
  * - the macro MINFRAMEF, if no strips are to the left of this strip in its 
track
  *
- * \param strip The strip to compute the left-hand-side 'frame limit' of.
+ * \param strip: The strip to compute the left-hand-side 'frame limit' of.
  * \return The beginning frame of the previous strip, or MINFRAMEF if no 
strips are next in that
  * track.
  */
@@ -241,7 +241,7 @@ float BKE_nlastrip_compute_frame_from_previous_strip(struct 
NlaStrip *strip);
  * - the begin frame of the next strip, if the strip's track contains another 
strip on it right
  * - the macro MAXFRAMEF, if no strips are to the right of this strip in its 
track
  *
- * \param strip The strip to compute the right-hand-side 'frame limit' of.
+ * \param strip: The strip to compute the right-hand-side 'frame limit' of.
  * \return The beginning frame of the next strip, or MAXFRAMEF if no strips 
are next in that track.
  */
 float BKE_nlastrip_compute_frame_to_next_strip(struct NlaStrip *strip);
diff --git a/source/blender/makesrna/intern/rna_nla.c 
b/source/blender/makesrna/intern/rna_nla.c
index bbe9ea13a0b..524e3134f9c 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -165,9 +165,9 @@ static void rna_NlaStrip_start_frame_set(PointerRNA *ptr, 
float value)
   /* Simply set the frame start in a valid range : if there are any NLA strips 
before/after, clamp
* the start value. If the new start value is past-the-end, clamp it. 
Otherwise, set it.
*
-   * NOTE : Unless neighbouring strips are transitions, 
NLASTRIP_MIN_LEN_THRESH is not needed, as
+   * NOTE: Unless neighboring strips are transitions, NLASTRIP_MIN_LEN_THRESH 
is not needed, as
* strips can be 'glued' to one another. If they are however, ensure 
transitions have a bit of
-   * time alloted in order to be performed.
+   * time allotted in order to be performed.
*/
   NlaStrip *data = (NlaStrip *)ptr->data;
 
@@ -255,11 +255,11 @@ static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, 
float value)
   data->end = value;
 
   /* The ONLY case where we actively modify the value set by the user, is in 
case the start value
-   * value is past the old end frame (here delta = NLASTRIP_MIN_LEN_THRESH) :
+   * value is past the old end frame (here delta = NLASTRIP_MIN_LEN_THRESH):
* - if there's no "room" for the end frame to be placed at (new_start + 
delta), move old_end to
-   * the limit, and new_start to (limit - delta)
+   *   the limit, and new_start to (limit - delta)
* - otherwise, do _not_ change the end frame. This property is not 
accessible from the UI, and
-   * can only be set via scripts. The script should be responsable for 
setting the end frame.
+   *   can only be set via scripts. The script should be responsible for 
setting the end frame.
*/
   if (data->end < (data->start + NLASTRIP_MIN_LEN_THRESH)) {
 /* If before-the-allowed-start : */
@@ -269,7 +269,7 @@ static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, 
float value)
 }
   }
 
-  /* Ensure transitions are kept "glued" to the strip : */
+  /* Ensure transitions are kept "glued" to the strip: */
   if (data->next && data->next->type == 

[Bf-blender-cvs] [d9505831a45] master: Cleanup: declare local variables static

2022-07-05 Thread Campbell Barton
Commit: d9505831a4549e872bcef023ac082d002e8d8392
Author: Campbell Barton
Date:   Wed Jul 6 14:25:33 2022 +1000
Branches: master
https://developer.blender.org/rBd9505831a4549e872bcef023ac082d002e8d8392

Cleanup: declare local variables static

===

M   intern/ghost/intern/GHOST_SystemWayland.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index c360423c256..8cd3476c4d6 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -1205,7 +1205,7 @@ static void cursor_buffer_handle_release(void *data, 
struct wl_buffer *wl_buffer
   }
 }
 
-const struct wl_buffer_listener cursor_buffer_listener = {
+static const struct wl_buffer_listener cursor_buffer_listener = {
 cursor_buffer_handle_release,
 };
 
@@ -1264,7 +1264,7 @@ static void cursor_surface_handle_leave(void *data,
   update_cursor_scale(input->cursor, input->system->shm());
 }
 
-struct wl_surface_listener cursor_surface_listener = {
+static const struct wl_surface_listener cursor_surface_listener = {
 cursor_surface_handle_enter,
 cursor_surface_handle_leave,
 };
@@ -1750,7 +1750,7 @@ static void tablet_seat_handle_pad_added(void * /*data*/,
   /* Pass. */
 }
 
-const struct zwp_tablet_seat_v2_listener tablet_seat_listener = {
+static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = {
 tablet_seat_handle_tablet_added,
 tablet_seat_handle_tool_added,
 tablet_seat_handle_pad_added,

___
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] [1f0048cc2dc] master: Cleanup: Fix compiler warnings

2022-07-05 Thread Loren Osborn
Commit: 1f0048cc2dc37097dce99157e8b0c88311fe42bc
Author: Loren Osborn
Date:   Wed Jul 6 00:06:16 2022 -0500
Branches: master
https://developer.blender.org/rB1f0048cc2dc37097dce99157e8b0c88311fe42bc

Cleanup: Fix compiler warnings

Use consistent class/struct declaration in forward declarations.

Differential Revision: https://developer.blender.org/D15382

===

M   source/blender/geometry/GEO_set_curve_type.hh
M   source/blender/geometry/GEO_subdivide_curves.hh

===

diff --git a/source/blender/geometry/GEO_set_curve_type.hh 
b/source/blender/geometry/GEO_set_curve_type.hh
index f7ac8be5889..6a75450006b 100644
--- a/source/blender/geometry/GEO_set_curve_type.hh
+++ b/source/blender/geometry/GEO_set_curve_type.hh
@@ -8,7 +8,7 @@
 #include "BLI_index_mask.hh"
 
 struct Curves;
-struct CurveComponent;
+class CurveComponent;
 
 namespace blender::bke {
 class CurvesGeometry;
diff --git a/source/blender/geometry/GEO_subdivide_curves.hh 
b/source/blender/geometry/GEO_subdivide_curves.hh
index 4f671467b24..66c2eb53496 100644
--- a/source/blender/geometry/GEO_subdivide_curves.hh
+++ b/source/blender/geometry/GEO_subdivide_curves.hh
@@ -7,7 +7,7 @@
 
 #include "BKE_curves.hh"
 
-struct CurveComponent;
+class CurveComponent;
 
 namespace blender::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] [faac25fefed] master: Fix T99284: Undefined values output from UV nodes

2022-07-05 Thread Hans Goudey
Commit: faac25fefedf4b3318d4f129ebda9efca16e48c5
Author: Hans Goudey
Date:   Tue Jul 5 18:01:08 2022 -0500
Branches: master
https://developer.blender.org/rBfaac25fefedf4b3318d4f129ebda9efca16e48c5

Fix T99284: Undefined values output from UV nodes

When committing D14389 I assumed that the output arrays didn't need
to be initialized, but the UV parameterizer uses the intial values of UVs.

===

M   source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc 
b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc
index bf960c5c809..364106455b6 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc
@@ -82,7 +82,7 @@ static VArray construct_uv_gvarray(const 
MeshComponent ,
   edge_evaluator.evaluate();
   const IndexMask seam = edge_evaluator.get_evaluated_as_mask(0);
 
-  Array uv(mesh->totloop);
+  Array uv(mesh->totloop, float3(0));
 
   ParamHandle *handle = GEO_uv_parametrizer_construct_begin();
   for (const int mp_index : selection) {

___
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] [1a820680a1b] master: Fix: Tests: Incorrect curve construction

2022-07-05 Thread Iliay Katueshenock
Commit: 1a820680a1bafda79ac3edc328f75662513029f9
Author: Iliay Katueshenock
Date:   Tue Jul 5 17:50:59 2022 -0500
Branches: master
https://developer.blender.org/rB1a820680a1bafda79ac3edc328f75662513029f9

Fix: Tests: Incorrect curve construction

The offsets were filled with the same value,
but they must be the total accumulated point count.

Differential Revision: https://developer.blender.org/D15374

===

M   source/blender/blenkernel/intern/curves_geometry_test.cc

===

diff --git a/source/blender/blenkernel/intern/curves_geometry_test.cc 
b/source/blender/blenkernel/intern/curves_geometry_test.cc
index 48493743cfc..2c87fc539fe 100644
--- a/source/blender/blenkernel/intern/curves_geometry_test.cc
+++ b/source/blender/blenkernel/intern/curves_geometry_test.cc
@@ -16,7 +16,7 @@ static CurvesGeometry create_basic_curves(const int 
points_size, const int curve
 
   const int curve_length = points_size / curves_size;
   for (const int i : curves.curves_range()) {
-curves.offsets_for_write()[i] = points_size * curve_length;
+curves.offsets_for_write()[i] = curve_length * i;
   }
   curves.offsets_for_write().last() = points_size;

___
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] [9435ee8c651] master: Curves: Port subdivide node to the new data-block

2022-07-05 Thread Hans Goudey
Commit: 9435ee8c65193e3d4af8f1ac5b07b7884cf62bd5
Author: Hans Goudey
Date:   Tue Jul 5 16:08:37 2022 -0500
Branches: master
https://developer.blender.org/rB9435ee8c65193e3d4af8f1ac5b07b7884cf62bd5

Curves: Port subdivide node to the new data-block

This commit moves the subdivide curve node implementation to the
geometry module, changes it to work on the new curves data-block,
and adds support for Catmull Rom curves. Internally I also added
support for a curve domain selection. That isn't used, but it's
nice to have the option anyway.

Users should notice better performance as well, since we can avoid
many small allocations, and there is no conversion to and from the
old curve type.

The code uses a similar structure to the resample node (60a6fbf5b599)
and the set type node (9e393fc2f125). The resample curves node can be
restructured to be more similar to this soon though.

Differential Revision: https://developer.blender.org/D15334

===

M   source/blender/blenkernel/BKE_curves.hh
M   source/blender/blenkernel/intern/curve_bezier.cc
M   source/blender/blenkernel/intern/curve_catmull_rom.cc
M   source/blender/blenlib/BLI_index_range.hh
M   source/blender/geometry/CMakeLists.txt
A   source/blender/geometry/GEO_subdivide_curves.hh
A   source/blender/geometry/intern/subdivide_curves.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc

===

diff --git a/source/blender/blenkernel/BKE_curves.hh 
b/source/blender/blenkernel/BKE_curves.hh
index 767936e2a26..3e00dc78b74 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -483,6 +483,8 @@ namespace bezier {
  * Return true if the handles that make up a segment both have a vector type. 
Vector segments for
  * Bezier curves have special behavior because they aren't divided into many 
evaluated points.
  */
+bool segment_is_vector(const HandleType left, const HandleType right);
+bool segment_is_vector(const int8_t left, const int8_t right);
 bool segment_is_vector(Span handle_types_left,
Span handle_types_right,
int segment_index);
@@ -515,6 +517,35 @@ void calculate_evaluated_offsets(Span 
handle_types_left,
  int resolution,
  MutableSpan evaluated_offsets);
 
+/** See #insert. */
+struct Insertion {
+  float3 handle_prev;
+  float3 left_handle;
+  float3 position;
+  float3 right_handle;
+  float3 handle_next;
+};
+
+/**
+ * Compute the Bezier segment insertion for the given parameter on the 
segment, returning
+ * the position and handles of the new point and the updated existing handle 
positions.
+ * 
+ *   handle_prev handle_next
+ *x-x
+ *   /   \
+ *  /  x---O---x  \
+ * /result \
+ */ \
+ *   O   O
+ *   point_prev   point_next
+ * 
+ */
+Insertion insert(const float3 _prev,
+ const float3 _prev,
+ const float3 _next,
+ const float3 _next,
+ float parameter);
+
 /**
  * Calculate the automatically defined positions for a vector handle 
(#BEZIER_HANDLE_VECTOR). While
  * this can be calculated automatically with #calculate_auto_handles, when 
more context is
@@ -607,6 +638,15 @@ int calculate_evaluated_num(int points_num, bool cyclic, 
int resolution);
  */
 void interpolate_to_evaluated(GSpan src, bool cyclic, int resolution, 
GMutableSpan dst);
 
+/**
+ * Evaluate the Catmull Rom curve. The size of each segment and its offset in 
the #dst span
+ * is encoded in #evaluated_offsets, with the same method as 
#CurvesGeometry::offsets().
+ */
+void interpolate_to_evaluated(const GSpan src,
+  const bool cyclic,
+  const Span evaluated_offsets,
+  GMutableSpan dst);
+
 }  // namespace catmull_rom
 
 /** \} */
@@ -827,6 +867,16 @@ inline bool point_is_sharp(const Span 
handle_types_left,
  ELEM(handle_types_right[index], BEZIER_HANDLE_VECTOR, 
BEZIER_HANDLE_FREE);
 }
 
+inline bool segment_is_vector(const HandleType left, const HandleType right)
+{
+  return left == BEZIER_HANDLE_VECTOR && right == BEZIER_HANDLE_VECTOR;
+}
+
+inline bool segment_is_vector(const int8_t left, const int8_t right)
+{
+  return segment_is_vector(HandleType(left), HandleType(right));
+}
+
 inline float3 calculate_vector_handle(const float3 , const float3 
_point)
 {
   return math::interpolate(point, next_point, 1.0f / 3.0f);
diff --git a/source/blender/blenkernel/intern/curve_bezier.cc 
b/source/blender/blenkernel/intern/curve_bezier.cc
index 1d6ee4938b5..59b09384698 100644
--- 

[Bf-blender-cvs] [7688f0ace7a] master: Curves: Move type conversion to the geometry module

2022-07-05 Thread Hans Goudey
Commit: 7688f0ace7a6c45aaa8304d2a26a760be0056aa6
Author: Hans Goudey
Date:   Tue Jul 5 15:51:12 2022 -0500
Branches: master
https://developer.blender.org/rB7688f0ace7a6c45aaa8304d2a26a760be0056aa6

Curves: Move type conversion to the geometry module

This helps to separate concerns, and makes the functionality
available for edit mode.

===

M   source/blender/geometry/CMakeLists.txt
A   source/blender/geometry/GEO_set_curve_type.hh
A   source/blender/geometry/intern/set_curve_type.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc

===

diff --git a/source/blender/geometry/CMakeLists.txt 
b/source/blender/geometry/CMakeLists.txt
index f0fb5c5c9af..21b2071d0e6 100644
--- a/source/blender/geometry/CMakeLists.txt
+++ b/source/blender/geometry/CMakeLists.txt
@@ -24,6 +24,7 @@ set(SRC
   intern/realize_instances.cc
   intern/resample_curves.cc
   intern/reverse_uv_sampler.cc
+  intern/set_curve_type.cc
   intern/uv_parametrizer.c
 
   GEO_add_curves_on_mesh.hh
@@ -35,6 +36,7 @@ set(SRC
   GEO_realize_instances.hh
   GEO_resample_curves.hh
   GEO_reverse_uv_sampler.hh
+  GEO_set_curve_type.hh
   GEO_uv_parametrizer.h
 )
 
diff --git a/source/blender/geometry/GEO_set_curve_type.hh 
b/source/blender/geometry/GEO_set_curve_type.hh
new file mode 100644
index 000..f7ac8be5889
--- /dev/null
+++ b/source/blender/geometry/GEO_set_curve_type.hh
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#pragma once
+
+#include "DNA_curves_types.h"
+
+#include "BLI_function_ref.hh"
+#include "BLI_index_mask.hh"
+
+struct Curves;
+struct CurveComponent;
+
+namespace blender::bke {
+class CurvesGeometry;
+}
+
+namespace blender::geometry {
+
+/**
+ * Try the conversion to the #dst_type-- avoiding the majority of the work 
done in
+ * #convert_curves by modifying an existing object in place rather than 
creating a new one.
+ *
+ * \note This function is necessary because attributes do not have proper 
support for CoW.
+ *
+ * \param get_writable_curves_fn: Should return the write-able curves to 
change directly if
+ * possible. This is a function in order to avoid the cost of retrieval when 
unnecessary.
+ */
+bool try_curves_conversion_in_place(IndexMask selection,
+CurveType dst_type,
+FunctionRef 
get_writable_curves_fn);
+
+/**
+ * Change the types of the selected curves, potentially changing the total 
point count.
+ */
+Curves *convert_curves(const CurveComponent _component,
+   const bke::CurvesGeometry _curves,
+   IndexMask selection,
+   CurveType dst_type);
+
+}  // namespace blender::geometry
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc 
b/source/blender/geometry/intern/set_curve_type.cc
similarity index 80%
copy from source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc
copy to source/blender/geometry/intern/set_curve_type.cc
index 5c836391abe..d7a5bc9b27d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc
+++ b/source/blender/geometry/intern/set_curve_type.cc
@@ -1,41 +1,15 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
-#include 
-
 #include "BKE_attribute_math.hh"
 #include "BKE_curves.hh"
 #include "BKE_curves_utils.hh"
+#include "BKE_geometry_set.hh"
 
 #include "BLI_task.hh"
 
-#include "UI_interface.h"
-#include "UI_resources.h"
-
-#include "node_geometry_util.hh"
-
-namespace blender::nodes::node_geo_curve_spline_type_cc {
-
-NODE_STORAGE_FUNCS(NodeGeometryCurveSplineType)
-
-static void node_declare(NodeDeclarationBuilder )
-{
-  
b.add_input(N_("Curve")).supported_type(GEO_COMPONENT_TYPE_CURVE);
-  
b.add_input(N_("Selection")).default_value(true).hide_value().supports_field();
-  b.add_output(N_("Curve"));
-}
-
-static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
-  uiItemR(layout, ptr, "spline_type", 0, "", ICON_NONE);
-}
+#include "GEO_set_curve_type.hh"
 
-static void node_init(bNodeTree *UNUSED(tree), bNode *node)
-{
-  NodeGeometryCurveSplineType *data = 
MEM_cnew(__func__);
-
-  data->spline_type = CURVE_TYPE_POLY;
-  node->storage = data;
-}
+namespace blender::geometry {
 
 /**
  * This function answers the question about possible conversion method for 
NURBS-to-Bezier. In
@@ -303,11 +277,20 @@ static int to_nurbs_size(const CurveType src_type, const 
int src_size)
   }
 }
 
+static void retrieve_curve_sizes(const bke::CurvesGeometry , 
MutableSpan sizes)
+{
+  threading::parallel_for(curves.curves_range(), 4096, [&](IndexRange range) {
+for (const int i : range) {
+  sizes[i] = curves.points_for_curve(i).size();
+}
+  });
+}
+
 struct GenericAttributes : NonCopyable, NonMovable {
   Vector src;
   Vector dst;
 
-  Vector attributes;
+  Vector attributes;
 };
 

[Bf-blender-cvs] [b4c5db0a1a5] principled-v2: Add special handling for specular case in Glass closure

2022-07-05 Thread Lukas Stockner
Commit: b4c5db0a1a55ead78ec4188f5e496c6b0f8590e4
Author: Lukas Stockner
Date:   Tue Jul 5 22:09:24 2022 +0200
Branches: principled-v2
https://developer.blender.org/rBb4c5db0a1a55ead78ec4188f5e496c6b0f8590e4

Add special handling for specular case in Glass closure

===

M   intern/cycles/kernel/closure/bsdf_microfacet_glass.h

===

diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_glass.h 
b/intern/cycles/kernel/closure/bsdf_microfacet_glass.h
index 942812aaa71..121b9a2dd50 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet_glass.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet_glass.h
@@ -74,7 +74,13 @@ ccl_device float3 
bsdf_microfacet_ggx_glass_eval_reflect(ccl_private const Shade
   ccl_private const MicrofacetBsdf *bsdf = (ccl_private const MicrofacetBsdf 
*)sc;
   float alpha_x = bsdf->alpha_x;
   float alpha_y = bsdf->alpha_y;
-  kernel_assert(alpha_x * alpha_y > 1e-7f);
+  float alpha2 = alpha_x * alpha_y;
+
+  if (alpha2 <= 1e-7f) {
+*pdf = 0.0f;
+return zero_float3();
+  }
+
   float3 N = bsdf->N;
 
   float cosNO = dot(N, I);
@@ -85,7 +91,6 @@ ccl_device float3 
bsdf_microfacet_ggx_glass_eval_reflect(ccl_private const Shade
   }
 
   float3 m = normalize(omega_in + I);
-  float alpha2 = alpha_x * alpha_y;
   float D = microfacet_ggx_D(dot(N, m), alpha2);
   float lambdaO = microfacet_ggx_lambda(cosNO, alpha2);
   float lambdaI = microfacet_ggx_lambda(cosNI, alpha2);
@@ -111,10 +116,15 @@ ccl_device float3 
bsdf_microfacet_ggx_glass_eval_transmit(ccl_private const Shad
   ccl_private const MicrofacetBsdf *bsdf = (ccl_private const MicrofacetBsdf 
*)sc;
   float alpha_x = bsdf->alpha_x;
   float alpha_y = bsdf->alpha_y;
-  kernel_assert(alpha_x * alpha_y > 1e-7f);
+  float alpha2 = alpha_x * alpha_y;
   float eta = bsdf->ior;
   float3 N = bsdf->N;
 
+  if (alpha2 <= 1e-7f) {
+*pdf = 0.0f;
+return zero_float3();
+  }
+
   float cosNO = dot(N, I);
   float cosNI = dot(N, omega_in);
   if (cosNO <= 0 || cosNI >= 0) {
@@ -134,7 +144,6 @@ ccl_device float3 
bsdf_microfacet_ggx_glass_eval_transmit(ccl_private const Shad
 return zero_float3();
   }
 
-  float alpha2 = alpha_x * alpha_y;
   float D = microfacet_ggx_D(dot(N, m), alpha2);
   float lambdaO = microfacet_ggx_lambda(cosNO, alpha2);
   float lambdaI = microfacet_ggx_lambda(cosNI, alpha2);
@@ -168,7 +177,6 @@ ccl_device int bsdf_microfacet_ggx_glass_sample(ccl_private 
const ShaderClosure
   ccl_private const MicrofacetBsdf *bsdf = (ccl_private const MicrofacetBsdf 
*)sc;
   float alpha_x = bsdf->alpha_x;
   float alpha_y = bsdf->alpha_y;
-  kernel_assert(alpha_x * alpha_y > 1e-7f);
   float eta = bsdf->ior;
   float3 N = bsdf->N;
   int label;
@@ -220,8 +228,26 @@ ccl_device int 
bsdf_microfacet_ggx_glass_sample(ccl_private const ShaderClosure
   float randw = hash_float2_to_float(make_float2(randu, randv));
   bool do_reflect = randw < fresnel;
 
-  /* Common microfacet model terms. */
   float alpha2 = alpha_x * alpha_y;
+  if (alpha2 <= 1e-7f) {
+/* Specular case, just return some high number for MIS */
+*pdf = 1e6f;
+*eval = make_float3(1e6f, 1e6f, 1e6f);
+
+*omega_in = do_reflect ? R : T;
+#ifdef __RAY_DIFFERENTIALS__
+*domega_in_dx = do_reflect ? dRdx : dTdx;
+*domega_in_dy = do_reflect ? dRdy : dTdy;
+#endif
+
+if (bsdf->type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID) {
+  *eval *= do_reflect ? reflection_color(bsdf, *omega_in, m) : 
bsdf->extra->color;
+}
+
+return LABEL_SINGULAR | (do_reflect ? LABEL_REFLECT : LABEL_TRANSMIT);
+  }
+
+  /* Common microfacet model terms. */
   float D = microfacet_ggx_D(cosThetaM, alpha2);
   float lambdaO = microfacet_ggx_lambda(cosNO, alpha2);
 
@@ -269,7 +295,7 @@ ccl_device int bsdf_microfacet_ggx_glass_sample(ccl_private 
const ShaderClosure
   *eval = make_float3(out, out, out);
 
   if (bsdf->type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID) {
-*eval *= (label & LABEL_REFLECT) ? reflection_color(bsdf, *omega_in, m) : 
bsdf->extra->color;
+*eval *= do_reflect ? reflection_color(bsdf, *omega_in, m) : 
bsdf->extra->color;
   }
   return label;
 }

___
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] [c68542de707] principled-v2: Remove LCG from Glass closure by hashing 2d random input to get third variable instead

2022-07-05 Thread Lukas Stockner
Commit: c68542de70722a1ed5964bb8512af1c3f3658ba5
Author: Lukas Stockner
Date:   Tue Jul 5 18:10:27 2022 +0200
Branches: principled-v2
https://developer.blender.org/rBc68542de70722a1ed5964bb8512af1c3f3658ba5

Remove LCG from Glass closure by hashing 2d random input to get third variable 
instead

===

M   intern/cycles/app/cycles_precompute.cpp
M   intern/cycles/kernel/closure/bsdf.h
M   intern/cycles/kernel/closure/bsdf_microfacet_glass.h

===

diff --git a/intern/cycles/app/cycles_precompute.cpp 
b/intern/cycles/app/cycles_precompute.cpp
index 7c6d5d72241..4ce62d2298a 100644
--- a/intern/cycles/app/cycles_precompute.cpp
+++ b/intern/cycles/app/cycles_precompute.cpp
@@ -173,7 +173,7 @@ static float precompute_ggx_refract_E(float rough, float 
mu, float eta, float u1
 }
 
 static float precompute_ggx_glass_E(
-float rough, float mu, float eta, float u1, float u2, uint *rng)
+float rough, float mu, float eta, float u1, float u2)
 {
   MicrofacetBsdf bsdf;
   bsdf.weight = one_float3();
@@ -198,8 +198,7 @@ static float precompute_ggx_glass_E(
_in,
_in_dx,
_in_dy,
-   ,
-   rng);
+   );
   if (pdf != 0.0f) {
 return average(eval) / pdf;
   }
@@ -274,7 +273,7 @@ static float precompute_ggx_dielectric_E(float rough, float 
mu, float eta, float
 
 struct PrecomputeTerm {
   int dim, samples, res;
-  std::function evaluation;
+  std::function evaluation;
 };
 
 bool cycles_precompute(std::string name);
@@ -282,44 +281,44 @@ bool cycles_precompute(std::string name)
 {
   std::map precompute_terms;
   precompute_terms["sheen_E"] = {
-  2, 1 << 23, 32, [](float rough, float mu, float ior, float u1, float u2, 
uint *rng) {
+  2, 1 << 23, 32, [](float rough, float mu, float ior, float u1, float u2) 
{
 return precompute_sheen_E(rough, mu, u1, u2);
   }};
   precompute_terms["clearcoat_E"] = {
-  2, 1 << 23, 16, [](float rough, float mu, float ior, float u1, float u2, 
uint *rng) {
+  2, 1 << 23, 16, [](float rough, float mu, float ior, float u1, float u2) 
{
 return precompute_clearcoat_E(rough, mu, u1, u2);
   }};
   precompute_terms["ggx_E"] = {
-  2, 1 << 23, 32, [](float rough, float mu, float ior, float u1, float u2, 
uint *rng) {
+  2, 1 << 23, 32, [](float rough, float mu, float ior, float u1, float u2) 
{
 return precompute_ggx_E(rough, mu, u1, u2);
   }};
   precompute_terms["ggx_E_avg"] = {
-  1, 1 << 23, 32, [](float rough, float mu, float ior, float u1, float u2, 
uint *rng) {
+  1, 1 << 23, 32, [](float rough, float mu, float ior, float u1, float u2) 
{
 return 2.0f * mu * precompute_ggx_E(rough, mu, u1, u2);
   }};
   precompute_terms["ggx_glass_E"] = {
-  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2, 
uint *rng) {
-return precompute_ggx_glass_E(rough, mu, ior, u1, u2, rng);
+  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2) 
{
+return precompute_ggx_glass_E(rough, mu, ior, u1, u2);
   }};
   precompute_terms["ggx_glass_inv_E"] = {
-  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2, 
uint *rng) {
-return precompute_ggx_glass_E(rough, mu, 1.0f / ior, u1, u2, rng);
+  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2) 
{
+return precompute_ggx_glass_E(rough, mu, 1.0f / ior, u1, u2);
   }};
   precompute_terms["ggx_refract_E"] = {
-  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2, 
uint *rng) {
+  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2) 
{
 return precompute_ggx_refract_E(rough, mu, ior, u1, u2);
   }};
   precompute_terms["ggx_refract_inv_E"] = {
-  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2, 
uint *rng) {
+  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2) 
{
 return precompute_ggx_refract_E(rough, mu, 1.0f / ior, u1, u2);
   }};
   precompute_terms["ggx_dielectric_E"] = {
-  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2, 
uint *rng) {
+  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2) 
{
 return precompute_ggx_dielectric_E(rough, mu, ior, u1, u2);
   }};
   // TODO: Consider more X resolution for this table.
   precompute_terms["ggx_dielectric_inv_E"] = {
-  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2, 
uint *rng) {
+  3, 1 << 20, 16, [](float rough, float mu, float ior, float u1, float u2) 
{
 return precompute_ggx_dielectric_E(rough, mu, 1.0f / ior, u1, u2);
 

[Bf-blender-cvs] [fe3d875dabc] principled-v2: Disable HIP directly in CMake to prevent the buildbot command line from overriding it

2022-07-05 Thread Lukas Stockner
Commit: fe3d875dabcf6388316f68de16357b88e68ccf33
Author: Lukas Stockner
Date:   Tue Jul 5 22:14:02 2022 +0200
Branches: principled-v2
https://developer.blender.org/rBfe3d875dabcf6388316f68de16357b88e68ccf33

Disable HIP directly in CMake to prevent the buildbot command line from 
overriding it

===

M   build_files/cmake/config/blender_release.cmake
M   intern/cycles/kernel/CMakeLists.txt

===

diff --git a/build_files/cmake/config/blender_release.cmake 
b/build_files/cmake/config/blender_release.cmake
index 0b8ac269231..42759fec7cc 100644
--- a/build_files/cmake/config/blender_release.cmake
+++ b/build_files/cmake/config/blender_release.cmake
@@ -91,7 +91,7 @@ if(NOT APPLE)
   set(WITH_CYCLES_DEVICE_OPTIXON  CACHE BOOL "" FORCE)
   set(WITH_CYCLES_CUDA_BINARIES   ON  CACHE BOOL "" FORCE)
   set(WITH_CYCLES_CUBIN_COMPILER  OFF CACHE BOOL "" FORCE)
-  set(WITH_CYCLES_HIP_BINARIESOFF CACHE BOOL "" FORCE)
+  set(WITH_CYCLES_HIP_BINARIESON  CACHE BOOL "" FORCE)
 
   # Disable AoT kernels compilations until buildbot can deliver them in a 
reasonabel time.
   set(WITH_CYCLES_ONEAPI_BINARIES OFF CACHE BOOL "" FORCE)
diff --git a/intern/cycles/kernel/CMakeLists.txt 
b/intern/cycles/kernel/CMakeLists.txt
index 4eaae9fdb00..4c8e71e3ca7 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -540,7 +540,8 @@ endif()
 
 # HIP module
 
-if(WITH_CYCLES_HIP_BINARIES AND WITH_CYCLES_DEVICE_HIP)
+# TODO: Re-enable HIP and figure out compiler crash
+if(WITH_CYCLES_HIP_BINARIES AND WITH_CYCLES_DEVICE_HIP AND FALSE)
   # build for each arch
   set(hip_sources device/hip/kernel.cpp
 ${SRC_KERNEL_HEADERS}

___
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] [8d9d8075516] principled-v2: Skip specular closure if it will have weight zero

2022-07-05 Thread Lukas Stockner
Commit: 8d9d80755169599472ddd0a0f9277813d797e40e
Author: Lukas Stockner
Date:   Tue Jul 5 22:08:50 2022 +0200
Branches: principled-v2
https://developer.blender.org/rB8d9d80755169599472ddd0a0f9277813d797e40e

Skip specular closure if it will have weight zero

===

M   intern/cycles/kernel/svm/closure_principled.h

===

diff --git a/intern/cycles/kernel/svm/closure_principled.h 
b/intern/cycles/kernel/svm/closure_principled.h
index d915f0707bb..8e6d0b141e2 100644
--- a/intern/cycles/kernel/svm/closure_principled.h
+++ b/intern/cycles/kernel/svm/closure_principled.h
@@ -611,6 +611,10 @@ ccl_device_inline float 
principled_v2_specular(KernelGlobals kg,
 {
   // TODO Handle caustics flag
 
+  if (metallic + (1.0f - transmission) <= CLOSURE_WEIGHT_CUTOFF) {
+return 0.0f;
+  }
+
   uint falloff_offset, edge_offset, dummy;
   uint aniso_offset, rotation_offset, tangent_offset;
   svm_unpack_node_uchar4(data1, _offset, _offset, , );

___
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] [cae7778db79] bevelv2: Added start of a class for a delta to a mesh.

2022-07-05 Thread Howard Trickey
Commit: cae7778db79cf08f7139002d8c018f204bd23312
Author: Howard Trickey
Date:   Tue Jul 5 15:58:03 2022 -0400
Branches: bevelv2
https://developer.blender.org/rBcae7778db79cf08f7139002d8c018f204bd23312

Added start of a class for a delta to a mesh.

===

M   source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc 
b/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
index 838c67097d4..7de1138760c 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
@@ -660,6 +660,144 @@ void BevelData::calculate_vertex_bevels(const IndexMask 
to_bevel, VArray
   setup_vert_map();
 }
 
+/* IndexAlloc allocates sequential integers, starting from a given start 
value. */
+class IndexAlloc {
+  int start_;
+  int first_free_;
+
+ public:
+  IndexAlloc(int start) : start_(start), first_free_(start)
+  {
+  }
+
+  int alloc()
+  {
+return first_free_++;
+  }
+  int start() const
+  {
+return start_;
+  }
+  int allocated_size() const
+  {
+return first_free_ - start_;
+  }
+};
+
+/* MeshDelta represents a delta to a Mesh: additions and deletions
+ * of Mesh elements.
+ */
+class MeshDelta {
+  Mesh _;
+  IndexAlloc vert_alloc_;
+  IndexAlloc edge_alloc_;
+  IndexAlloc poly_alloc_;
+  IndexAlloc loop_alloc_;
+  Set vert_deletes_;
+  Set edge_deletes_;
+  Set poly_deletes_;
+  Set loop_deletes_;
+  Vector new_verts_;
+  Vector new_edges_;
+  Vector new_polys_;
+  Vector new_loops_;
+
+ public:
+  MeshDelta(Mesh );
+
+  /* TODO: provide arguments or methods to set the attributes. */
+  int new_vert(const float3 );
+  int new_edge(int v1, int v2);
+  int new_loop(int v, int e);
+  int new_face(int loopstart, int totloop);
+
+  void delete_vert(int v)
+  {
+vert_deletes_.add(v);
+  }
+  void delete_edge(int e)
+  {
+edge_deletes_.add(e);
+  }
+  void delete_face(int f);
+
+  /* Change Mesh in place to delete and add what is required, closing up the
+   * gaps in the index spaces. */
+  void apply_delta_to_mesh();
+};
+
+MeshDelta::MeshDelta(Mesh )
+: mesh_(mesh),
+  vert_alloc_(mesh_.totvert),
+  edge_alloc_(mesh_.totedge),
+  poly_alloc_(mesh_.totpoly),
+  loop_alloc_(mesh_.totloop)
+{
+}
+
+int MeshDelta::new_vert(const float3 )
+{
+  int v = vert_alloc_.alloc();
+  MVert mvert;
+  copy_v3_v3(mvert.co, co);
+  mvert.flag = 0;
+  mvert.bweight = 0;
+  new_verts_.append(mvert);
+  BLI_assert(v == new_verts_.size() - 1);
+  return v;
+}
+
+int MeshDelta::new_edge(int v1, int v2)
+{
+  int e = edge_alloc_.alloc();
+  MEdge medge;
+  medge.v1 = v1;
+  medge.v2 = v2;
+  medge.crease = 0;
+  medge.bweight = 0;
+  medge.flag = ME_EDGEDRAW;
+  new_edges_.append(medge);
+  BLI_assert(e == new_edges_.size() - 1);
+  return e;
+}
+
+int MeshDelta::new_loop(int v, int e)
+{
+  int l = loop_alloc_.alloc();
+  MLoop mloop;
+  mloop.v = v;
+  mloop.e = e;
+  new_loops_.append(mloop);
+  BLI_assert(l == new_loops_.size() - 1);
+  return l;
+}
+
+int MeshDelta::new_face(int loopstart, int totloop)
+{
+  int f = poly_alloc_.alloc();
+  MPoly mpoly;
+  mpoly.loopstart = loopstart;
+  mpoly.totloop = totloop;
+  mpoly.mat_nr = 0;
+  mpoly.flag = 0;
+  new_polys_.append(mpoly);
+  BLI_assert(f = new_polys_.size() - 1);
+  return f;
+}
+
+/* Delete the MPoly and the loops.
+ * The edges and vertices need to be deleted elsewhere, if necessary
+ */
+void MeshDelta::delete_face(int f)
+{
+  poly_deletes_.add(f);
+  BLI_assert(f >= 0 && f < mesh_.totpoly);
+  const MPoly  = mesh_.mpoly[f];
+  for (int l = mpoly.loopstart; l < mpoly.loopstart + mpoly.totloop; l++) {
+loop_deletes_.add(l);
+  }
+}
+
 static void bevel_mesh_vertices(MeshComponent ,
 const Field _field,
 const Field _field)

___
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] [c52a18abf84] master: UI: Curves Sculpting - Remove duplicated entry for Curve Length

2022-07-05 Thread Dalai Felinto
Commit: c52a18abf84b29ca19aa79ef1ce580e67a437779
Author: Dalai Felinto
Date:   Tue Jul 5 17:43:34 2022 +0200
Branches: master
https://developer.blender.org/rBc52a18abf84b29ca19aa79ef1ce580e67a437779

UI: Curves Sculpting - Remove duplicated entry for Curve Length

===

M   release/scripts/startup/bl_ui/properties_paint_common.py

===

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py 
b/release/scripts/startup/bl_ui/properties_paint_common.py
index f0034a3d710..9b1cf11f6e7 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -782,7 +782,6 @@ def brush_settings(layout, context, brush, popover=False):
 elif mode == 'SCULPT_CURVES':
 if brush.curves_sculpt_tool == 'ADD':
 layout.prop(brush.curves_sculpt_settings, "add_amount")
-layout.prop(brush.curves_sculpt_settings, "curve_length")
 col = layout.column(heading="Interpolate", align=True)
 col.prop(brush.curves_sculpt_settings, "interpolate_length", 
text="Length")
 col.prop(brush.curves_sculpt_settings, "interpolate_shape", 
text="Shape")

___
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] [a2d59b2dac9] blender-v3.2-release: Fix T99191: Boolean modifier creates invalid material indices

2022-07-05 Thread Hans Goudey
Commit: a2d59b2dac9e68d158c11723a5cc30ecd4102804
Author: Hans Goudey
Date:   Tue Jul 5 10:44:56 2022 -0500
Branches: blender-v3.2-release
https://developer.blender.org/rBa2d59b2dac9e68d158c11723a5cc30ecd4102804

Fix T99191: Boolean modifier creates invalid material indices

This changes the boolean modifier material index handling to be
consistent with the mesh boolean geometry nodes, which was
last changed in 1a6d0ec71cf3b0c2c22bc1. The issues was that the
material maps were retrieved at the object level, which doesn't
really make sense because the boolean is a geometry-level
operation. It was also confusing and prone to incorrect behavior
because it's more complex to retrieve information from two places.

Differential Revision: https://developer.blender.org/D15365

===

M   source/blender/modifiers/intern/MOD_boolean.cc

===

diff --git a/source/blender/modifiers/intern/MOD_boolean.cc 
b/source/blender/modifiers/intern/MOD_boolean.cc
index d47f2a130e3..fa8662e7d77 100644
--- a/source/blender/modifiers/intern/MOD_boolean.cc
+++ b/source/blender/modifiers/intern/MOD_boolean.cc
@@ -14,6 +14,7 @@
 #include "BLI_math_geom.h"
 #include "BLI_math_matrix.h"
 #include "BLI_vector.hh"
+#include "BLI_vector_set.hh"
 
 #include "BLT_translation.h"
 
@@ -62,7 +63,11 @@
 
 using blender::Array;
 using blender::float4x4;
+using blender::IndexRange;
+using blender::MutableSpan;
+using blender::Span;
 using blender::Vector;
+using blender::VectorSet;
 
 static void initData(ModifierData *md)
 {
@@ -375,19 +380,20 @@ static void BMD_mesh_intersection(BMesh *bm,
 
 #ifdef WITH_GMP
 
-/* Get a mapping from material slot numbers in the src_ob to slot numbers in 
the dst_ob.
- * If a material doesn't exist in the dst_ob, the mapping just goes to the 
same slot
- * or to zero if there aren't enough slots in the destination.
+/* Get a mapping from material slot numbers in the source geometry to slot 
numbers in the result
+ * geometry. The material is added to the result geometry if it doesn't 
already use it.
  * Caller owns the returned array. */
-static Array get_material_remap(Object *dest_ob, Object *src_ob)
+static Array get_material_remap(const Mesh , VectorSet 
)
 {
-  int n = src_ob->totcol;
-  if (n <= 0) {
-n = 1;
+  if (mesh.totcol == 0) {
+/* Necessary for faces using the default material when there are no 
material slots. */
+return Array({materials.index_of_or_add(nullptr)});
   }
-  Array remap(n);
-  BKE_object_material_remap_calc(dest_ob, src_ob, remap.data());
-  return remap;
+  Array map(mesh.totcol);
+  for (const int i : IndexRange(mesh.totcol)) {
+map[i] = materials.index_of_or_add(mesh.mat[i]);
+  }
+  return map;
 }
 
 static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
@@ -396,6 +402,8 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
 {
   Vector meshes;
   Vector obmats;
+
+  VectorSet materials;
   Vector> material_remaps;
 
 #  ifdef DEBUG_TIME
@@ -409,6 +417,14 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
   meshes.append(mesh);
   obmats.append((float4x4 *)>object->obmat);
   material_remaps.append({});
+  if (mesh->totcol == 0) {
+/* Necessary for faces using the default material when there are no 
material slots. */
+materials.add(nullptr);
+  }
+  else {
+materials.add_multiple({mesh->mat, mesh->totcol});
+  }
+
   if (bmd->flag & eBooleanModifierFlag_Object) {
 Mesh *mesh_operand = 
BKE_modifier_get_evaluated_mesh_from_evaluated_object(bmd->object, false);
 if (!mesh_operand) {
@@ -417,7 +433,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
 BKE_mesh_wrapper_ensure_mdata(mesh_operand);
 meshes.append(mesh_operand);
 obmats.append((float4x4 *)>object->obmat);
-material_remaps.append(get_material_remap(ctx->object, bmd->object));
+material_remaps.append(get_material_remap(*mesh_operand, materials));
   }
   else if (bmd->flag & eBooleanModifierFlag_Collection) {
 Collection *collection = bmd->collection;
@@ -432,7 +448,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
   BKE_mesh_wrapper_ensure_mdata(collection_mesh);
   meshes.append(collection_mesh);
   obmats.append((float4x4 *)>obmat);
-  material_remaps.append(get_material_remap(ctx->object, ob));
+  material_remaps.append(get_material_remap(*collection_mesh, 
materials));
 }
   }
   FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
@@ -441,13 +457,18 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
 
   const bool use_self = (bmd->flag & eBooleanModifierFlag_Self) != 0;
   const bool hole_tolerant = (bmd->flag & eBooleanModifierFlag_HoleTolerant) 
!= 0;
-  return blender::meshintersect::direct_mesh_boolean(meshes,
- obmats,
- 

[Bf-blender-cvs] [bcfabdc09da] blender-v3.2-release: Fix T98960: Baking to active color attribute uses wrong layer

2022-07-05 Thread Hans Goudey
Commit: bcfabdc09da77ba2f9b56c27d4555e0d53c20e06
Author: Hans Goudey
Date:   Tue Jun 21 14:15:18 2022 -0500
Branches: blender-v3.2-release
https://developer.blender.org/rBbcfabdc09da77ba2f9b56c27d4555e0d53c20e06

Fix T98960: Baking to active color attribute uses wrong layer

Baking assumed that color attributes could only have two configurations:
float color data type on vertices, or byte color type on face corners.
In reality the options can be combined to make four total options.
This commit handles the four cases explicitly with a somewhat
more scaleable approach (though this should really be C++ code).

Differential Revision: https://developer.blender.org/D15244

===

M   source/blender/editors/object/object_bake_api.c

===

diff --git a/source/blender/editors/object/object_bake_api.c 
b/source/blender/editors/object/object_bake_api.c
index a7379d7e492..82f31536be8 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -21,6 +21,8 @@
 #include "BLI_path_util.h"
 #include "BLI_string.h"
 
+#include "BKE_attribute.h"
+#include "BKE_callbacks.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
@@ -446,10 +448,7 @@ static bool bake_object_check(ViewLayer *view_layer,
   }
 
   if (target == R_BAKE_TARGET_VERTEX_COLORS) {
-MPropCol *mcol = CustomData_get_layer(>vdata, CD_PROP_COLOR);
-const bool mcol_valid = (mcol != NULL);
-MLoopCol *mloopcol = CustomData_get_layer(>ldata, CD_PROP_BYTE_COLOR);
-if (mloopcol == NULL && !mcol_valid) {
+if (BKE_id_attributes_active_color_get(>id) == NULL) {
   BKE_reportf(reports,
   RPT_ERROR,
   "No vertex colors layer found in the object \"%s\"",
@@ -943,10 +942,8 @@ static bool bake_targets_init_vertex_colors(BakeTargets 
*targets, Object *ob, Re
   }
 
   Mesh *me = ob->data;
-  MPropCol *mcol = CustomData_get_layer(>vdata, CD_PROP_COLOR);
-  const bool mcol_valid = (mcol != NULL);
-  MLoopCol *mloopcol = CustomData_get_layer(>ldata, CD_PROP_BYTE_COLOR);
-  if (mloopcol == NULL && !mcol_valid) {
+
+  if (BKE_id_attributes_active_color_get(>id) == NULL) {
 BKE_report(reports, RPT_ERROR, "No vertex colors layer found to bake to");
 return false;
   }
@@ -996,10 +993,10 @@ static int find_original_loop(const Mesh *me_orig,
   return ORIGINDEX_NONE;
 }
 
-static void bake_targets_populate_pixels_vertex_colors(BakeTargets *targets,
-   Object *ob,
-   Mesh *me_eval,
-   BakePixel *pixel_array)
+static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets,
+  Object *ob,
+  Mesh *me_eval,
+  BakePixel 
*pixel_array)
 {
   Mesh *me = ob->data;
   const int pixels_num = targets->pixels_num;
@@ -1094,19 +1091,42 @@ static void bake_result_add_to_rgba(float rgba[4], 
const float *result, const in
   }
 }
 
+static void convert_float_color_to_byte_color(const MPropCol *float_colors,
+  const int num,
+  const bool is_noncolor,
+  MLoopCol *byte_colors)
+{
+  if (is_noncolor) {
+for (int i = 0; i < num; i++) {
+  unit_float_to_uchar_clamp_v4(_colors->r, float_colors[i].color);
+}
+  }
+  else {
+for (int i = 0; i < num; i++) {
+  linearrgb_to_srgb_uchar4(_colors[i].r, float_colors[i].color);
+}
+  }
+}
+
 static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
 {
   Mesh *me = ob->data;
-  MPropCol *mcol = CustomData_get_layer(>vdata, CD_PROP_COLOR);
-  const bool mcol_valid = (mcol != NULL);
-  MLoopCol *mloopcol = CustomData_get_layer(>ldata, CD_PROP_BYTE_COLOR);
+  CustomDataLayer *active_color_layer = 
BKE_id_attributes_active_color_get(>id);
+  BLI_assert(active_color_layer != NULL);
+  const AttributeDomain domain = BKE_id_attribute_domain(>id, 
active_color_layer);
+
   const int channels_num = targets->channels_num;
+  const bool is_noncolor = targets->is_noncolor;
   const float *result = targets->result;
 
-  if (mcol_valid) {
+  if (domain == ATTR_DOMAIN_POINT) {
 const int totvert = me->totvert;
 const int totloop = me->totloop;
 
+MPropCol *mcol = active_color_layer->type == CD_PROP_COLOR ?
+ active_color_layer->data :
+ MEM_malloc_arrayN(totvert, sizeof(MPropCol), 
__func__);
+
 /* Accumulate float vertex colors in scene linear color space. */
 int *num_loops_for_vertex = MEM_callocN(sizeof(int) * me->totvert, 

[Bf-blender-cvs] [883d8ea16c3] master: Fix: Memleak in sequencer drag and drop code

2022-07-05 Thread Sebastian Parborg
Commit: 883d8ea16c36a0e1d56826e3bc4f072d6aa58618
Author: Sebastian Parborg
Date:   Tue Jul 5 16:31:13 2022 +0200
Branches: master
https://developer.blender.org/rB883d8ea16c36a0e1d56826e3bc4f072d6aa58618

Fix: Memleak in sequencer drag and drop code

===

M   source/blender/editors/space_sequencer/sequencer_drag_drop.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_drag_drop.c 
b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
index 94427009939..f6561cf07b9 100644
--- a/source/blender/editors/space_sequencer/sequencer_drag_drop.c
+++ b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
@@ -179,6 +179,7 @@ static void sequencer_drop_copy(bContext *C, wmDrag *drag, 
wmDropBox *drop)
   if (max_channel != -1) {
 RNA_int_set(drop->ptr, "channel", max_channel);
   }
+  SEQ_collection_free(strips);
 }
   }
 }

___
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] [7bfe60675ef] blender-v3.2-release: Blender 3.2.1: Change version char to release.

2022-07-05 Thread Thomas Dinges
Commit: 7bfe60675efd0c2db6d79ef3fc2d8574569fcd98
Author: Thomas Dinges
Date:   Tue Jul 5 16:30:24 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB7bfe60675efd0c2db6d79ef3fc2d8574569fcd98

Blender 3.2.1: Change version char to release.

===

M   source/blender/blenkernel/BKE_blender_version.h

===

diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index 0c2a843bec3..9d935d76e5f 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -21,7 +21,7 @@ extern "C" {
 /* Blender patch version for bugfix releases. */
 #define BLENDER_VERSION_PATCH 1
 /** Blender release cycle stage: alpha/beta/rc/release. */
-#define BLENDER_VERSION_CYCLE rc
+#define BLENDER_VERSION_CYCLE release
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION

___
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] [1b54fd391e5] blender-v3.2-release: Revert "Fix T98773: GPU Subdivision breaks auto selection in UV edit mode"

2022-07-05 Thread Thomas Dinges
Commit: 1b54fd391e5b2a8fbf9183df8caa15a8a5cb81d2
Author: Thomas Dinges
Date:   Tue Jul 5 16:26:52 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB1b54fd391e5b2a8fbf9183df8caa15a8a5cb81d2

Revert "Fix T98773: GPU Subdivision breaks auto selection in UV edit mode"

This reverts commit e2c02655c78b2c669468ae568ddf4b17953cc98d.

It caused regression T99323 which is more severe than the original fixed T98773.

===

M   source/blender/draw/intern/draw_cache_extract_mesh_render_data.c

===

diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c 
b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c
index 4fb1b9a7bc7..0a93f346b37 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c
@@ -502,8 +502,8 @@ MeshRenderData *mesh_render_data_create(Object *object,
 
 /* Seems like the mesh_eval_final do not have the right origin indices.
  * Force not mapped in this case. */
-if (use_mapped && do_final && editmesh_eval_final != editmesh_eval_cage) {
-  // mr->edit_bmesh = nullptr;
+if (has_mdata && do_final && editmesh_eval_final != editmesh_eval_cage) {
+  // mr->edit_bmesh = NULL;
   mr->extract_type = MR_EXTRACT_MESH;
 }
   }

___
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] [329efa23d0e] master: Cleanup: Unused headers in generic compositor nodes header

2022-07-05 Thread Sergey Sharybin
Commit: 329efa23d0e243a413407e8d6cc9e4cf7d65
Author: Sergey Sharybin
Date:   Tue Jul 5 15:56:39 2022 +0200
Branches: master
https://developer.blender.org/rB329efa23d0e243a413407e8d6cc9e4cf7d65

Cleanup: Unused headers in generic compositor nodes header

Move headers to node files which actually need those.
There is no need for all nodes to have all those headers
included indirectly.

===

M   source/blender/nodes/composite/node_composite_util.hh
M   source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc
M   source/blender/nodes/composite/nodes/node_composite_curves.cc
M   source/blender/nodes/composite/nodes/node_composite_huecorrect.cc
M   source/blender/nodes/composite/nodes/node_composite_image.cc
M   source/blender/nodes/composite/nodes/node_composite_map_value.cc
M   source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc
M   source/blender/nodes/composite/nodes/node_composite_trackpos.cc
M   source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc

===

diff --git a/source/blender/nodes/composite/node_composite_util.hh 
b/source/blender/nodes/composite/node_composite_util.hh
index 3e9c43aa7d2..14210cedc95 100644
--- a/source/blender/nodes/composite/node_composite_util.hh
+++ b/source/blender/nodes/composite/node_composite_util.hh
@@ -8,24 +8,12 @@
 #pragma once
 
 #include "DNA_ID.h"
-#include "DNA_movieclip_types.h"
 #include "DNA_node_types.h"
 
 #include "BLT_translation.h"
 
-#include "BKE_colorband.h"
-#include "BKE_colortools.h"
-#include "BKE_image.h"
-#include "BKE_texture.h"
-#include "BKE_tracking.h"
-
 #include "node_util.h"
 
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-
-#include "RE_pipeline.h"
-
 #include "NOD_composite.h"
 #include "NOD_socket.h"
 #include "NOD_socket_declarations.hh"
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc 
b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc
index 9193f91087a..5462441660c 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc
@@ -17,12 +17,15 @@
 #include "BKE_context.h"
 #include "BKE_cryptomatte.hh"
 #include "BKE_global.h"
+#include "BKE_image.h"
 #include "BKE_lib_id.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 
 #include "MEM_guardedalloc.h"
 
+#include "RE_pipeline.h"
+
 #include 
 
 /*  */
diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.cc 
b/source/blender/nodes/composite/nodes/node_composite_curves.cc
index fff0d467f75..802664d7934 100644
--- a/source/blender/nodes/composite/nodes/node_composite_curves.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_curves.cc
@@ -5,6 +5,8 @@
  * \ingroup cmpnodes
  */
 
+#include "BKE_colortools.h"
+
 #include "UI_interface.h"
 #include "UI_resources.h"
 
diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc 
b/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc
index bb5e6bf06a8..d252d96f8c3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc
@@ -7,6 +7,8 @@
 
 #include "node_composite_util.hh"
 
+#include "BKE_colortools.h"
+
 namespace blender::nodes::node_composite_huecorrect_cc {
 
 static void cmp_node_huecorrect_declare(NodeDeclarationBuilder )
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.cc 
b/source/blender/nodes/composite/nodes/node_composite_image.cc
index d071e9f13db..d75aa575395 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_image.cc
@@ -12,6 +12,7 @@
 
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_image.h"
 #include "BKE_lib_id.h"
 #include "BKE_main.h"
 #include "BKE_scene.h"
@@ -19,6 +20,7 @@
 #include "DNA_scene_types.h"
 
 #include "RE_engine.h"
+#include "RE_pipeline.h"
 
 #include "RNA_access.h"
 
diff --git a/source/blender/nodes/composite/nodes/node_composite_map_value.cc 
b/source/blender/nodes/composite/nodes/node_composite_map_value.cc
index b069cce93fc..bb42628ed3d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_map_value.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_map_value.cc
@@ -5,6 +5,8 @@
  * \ingroup cmpnodes
  */
 
+#include "BKE_texture.h"
+
 #include "RNA_access.h"
 
 #include "UI_interface.h"
diff --git 
a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc 
b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc
index 9c6c6a40b2c..4d52a767b8a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc
+++ 

[Bf-blender-cvs] [31f0845b7e5] master: Fix tracking header not being self-sufficient

2022-07-05 Thread Sergey Sharybin
Commit: 31f0845b7e5e86a4e99dc586e2a7ed89f5271d80
Author: Sergey Sharybin
Date:   Tue Jul 5 15:55:53 2022 +0200
Branches: master
https://developer.blender.org/rB31f0845b7e5e86a4e99dc586e2a7ed89f5271d80

Fix tracking header not being self-sufficient

It used size_t type without including any header to define it.

===

M   source/blender/blenkernel/BKE_tracking.h

===

diff --git a/source/blender/blenkernel/BKE_tracking.h 
b/source/blender/blenkernel/BKE_tracking.h
index 23b1f7c09bb..89f30ce8ef8 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -7,6 +7,8 @@
  * \ingroup bke
  */
 
+#include "BLI_sys_types.h"
+
 #ifdef __cplusplus
 extern "C" {
 #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] [d4099465cdd] master: Cleanup: extract function to snap curves to surface

2022-07-05 Thread Jacques Lucke
Commit: d4099465cddc2d3ec3653220f6b775ba3ffb3ea0
Author: Jacques Lucke
Date:   Tue Jul 5 15:37:34 2022 +0200
Branches: master
https://developer.blender.org/rBd4099465cddc2d3ec3653220f6b775ba3ffb3ea0

Cleanup: extract function to snap curves to surface

This makes it possible to use this function without having
to call an operator. This is currently used by D14864.

===

M   source/blender/editors/curves/intern/curves_ops.cc

===

diff --git a/source/blender/editors/curves/intern/curves_ops.cc 
b/source/blender/editors/curves/intern/curves_ops.cc
index aca074a1d61..d9f207103ae 100644
--- a/source/blender/editors/curves/intern/curves_ops.cc
+++ b/source/blender/editors/curves/intern/curves_ops.cc
@@ -517,152 +517,167 @@ static bool snap_curves_to_surface_poll(bContext *C)
   return true;
 }
 
+static void snap_curves_to_surface_exec_object(Object _ob,
+   const Object _ob,
+   const AttachMode attach_mode,
+   bool *r_invalid_uvs,
+   bool *r_missing_uvs)
+{
+  Curves _id = *static_cast(curves_ob.data);
+  CurvesGeometry  = CurvesGeometry::wrap(curves_id.geometry);
+
+  Mesh _mesh = *static_cast(surface_ob.data);
+
+  MeshComponent surface_mesh_component;
+  surface_mesh_component.replace(_mesh, 
GeometryOwnershipType::ReadOnly);
+
+  VArraySpan surface_uv_map;
+  if (curves_id.surface_uv_map != nullptr) {
+surface_uv_map = surface_mesh_component
+ .attribute_try_get_for_read(
+ curves_id.surface_uv_map, ATTR_DOMAIN_CORNER, 
CD_PROP_FLOAT2)
+ .typed();
+  }
+
+  MutableSpan positions_cu = curves.positions_for_write();
+  MutableSpan surface_uv_coords = curves.surface_uv_coords_for_write();
+
+  const Span surface_looptris = 
{BKE_mesh_runtime_looptri_ensure(_mesh),
+   
BKE_mesh_runtime_looptri_len(_mesh)};
+
+  const bke::CurvesSurfaceTransforms transforms{curves_ob, _ob};
+
+  switch (attach_mode) {
+case AttachMode::Nearest: {
+  BVHTreeFromMesh surface_bvh;
+  BKE_bvhtree_from_mesh_get(_bvh, _mesh, 
BVHTREE_FROM_LOOPTRI, 2);
+  BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(_bvh); });
+
+  threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange 
curves_range) {
+for (const int curve_i : curves_range) {
+  const IndexRange points = curves.points_for_curve(curve_i);
+  const int first_point_i = points.first();
+  const float3 old_first_point_pos_cu = positions_cu[first_point_i];
+  const float3 old_first_point_pos_su = transforms.curves_to_surface *
+old_first_point_pos_cu;
+
+  BVHTreeNearest nearest;
+  nearest.index = -1;
+  nearest.dist_sq = FLT_MAX;
+  BLI_bvhtree_find_nearest(surface_bvh.tree,
+   old_first_point_pos_su,
+   ,
+   surface_bvh.nearest_callback,
+   _bvh);
+  const int looptri_index = nearest.index;
+  if (looptri_index == -1) {
+continue;
+  }
+
+  const float3 new_first_point_pos_su = nearest.co;
+  const float3 new_first_point_pos_cu = transforms.surface_to_curves *
+new_first_point_pos_su;
+  const float3 pos_diff_cu = new_first_point_pos_cu - 
old_first_point_pos_cu;
+
+  for (float3 _cu : positions_cu.slice(points)) {
+pos_cu += pos_diff_cu;
+  }
+
+  if (!surface_uv_map.is_empty()) {
+const MLoopTri  = surface_looptris[looptri_index];
+const int corner0 = looptri.tri[0];
+const int corner1 = looptri.tri[1];
+const int corner2 = looptri.tri[2];
+const float2  = surface_uv_map[corner0];
+const float2  = surface_uv_map[corner1];
+const float2  = surface_uv_map[corner2];
+const float3 _su = 
surface_mesh.mvert[surface_mesh.mloop[corner0].v].co;
+const float3 _su = 
surface_mesh.mvert[surface_mesh.mloop[corner1].v].co;
+const float3 _su = 
surface_mesh.mvert[surface_mesh.mloop[corner2].v].co;
+float3 bary_coords;
+interp_weights_tri_v3(bary_coords, p0_su, p1_su, p2_su, 
new_first_point_pos_su);
+const float2 uv = attribute_math::mix3(bary_coords, uv0, uv1, uv2);
+surface_uv_coords[curve_i] = uv;
+  }
+}
+  });
+  break;
+}
+case AttachMode::Deform: {
+  if (surface_uv_map.is_empty()) {
+*r_missing_uvs = true;
+break;
+  }

[Bf-blender-cvs] [8f0907b7970] master: BLI: add float3x3 * float3 operator overload

2022-07-05 Thread Jacques Lucke
Commit: 8f0907b79701f3fa13b66528cfaeb901bf84e930
Author: Jacques Lucke
Date:   Tue Jul 5 15:38:30 2022 +0200
Branches: master
https://developer.blender.org/rB8f0907b79701f3fa13b66528cfaeb901bf84e930

BLI: add float3x3 * float3 operator overload

===

M   source/blender/blenlib/BLI_float3x3.hh

===

diff --git a/source/blender/blenlib/BLI_float3x3.hh 
b/source/blender/blenlib/BLI_float3x3.hh
index 62478556d9b..6a9e7dd04f0 100644
--- a/source/blender/blenlib/BLI_float3x3.hh
+++ b/source/blender/blenlib/BLI_float3x3.hh
@@ -152,6 +152,13 @@ struct float3x3 {
 return result;
   }
 
+  friend float3 operator*(const float3x3 , const float3 )
+  {
+float3 result;
+mul_v3_m3v3(result, a.values, b);
+return result;
+  }
+
   void operator*=(const float3x3 )
   {
 mul_m3_m3_post(values, other.values);

___
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] [b98d116257a] master: BLI: use a slightly less trivial reverse uv sampler

2022-07-05 Thread Jacques Lucke
Commit: b98d116257aee64f2e79490c89f4aa7bcca4a9cd
Author: Jacques Lucke
Date:   Tue Jul 5 15:36:00 2022 +0200
Branches: master
https://developer.blender.org/rBb98d116257aee64f2e79490c89f4aa7bcca4a9cd

BLI: use a slightly less trivial reverse uv sampler

This approach is still far from ideal, but at least it has linear
complexity in the common case instead of quadratic.

===

M   source/blender/geometry/GEO_reverse_uv_sampler.hh
M   source/blender/geometry/intern/reverse_uv_sampler.cc

===

diff --git a/source/blender/geometry/GEO_reverse_uv_sampler.hh 
b/source/blender/geometry/GEO_reverse_uv_sampler.hh
index d392b65eaf4..ee91e0b0731 100644
--- a/source/blender/geometry/GEO_reverse_uv_sampler.hh
+++ b/source/blender/geometry/GEO_reverse_uv_sampler.hh
@@ -5,6 +5,7 @@
 #include 
 
 #include "BLI_math_vector.hh"
+#include "BLI_multi_value_map.hh"
 #include "BLI_span.hh"
 
 #include "DNA_meshdata_types.h"
@@ -20,6 +21,8 @@ class ReverseUVSampler {
  private:
   const Span uv_map_;
   const Span looptris_;
+  int resolution_;
+  MultiValueMap looptris_by_cell_;
 
  public:
   ReverseUVSampler(const Span uv_map, const Span looptris);
@@ -37,6 +40,7 @@ class ReverseUVSampler {
   };
 
   Result sample(const float2 _uv) const;
+  void sample_many(Span query_uvs, MutableSpan r_results) 
const;
 };
 
 }  // namespace blender::geometry
diff --git a/source/blender/geometry/intern/reverse_uv_sampler.cc 
b/source/blender/geometry/intern/reverse_uv_sampler.cc
index 9aa98895a86..87ba2c77657 100644
--- a/source/blender/geometry/intern/reverse_uv_sampler.cc
+++ b/source/blender/geometry/intern/reverse_uv_sampler.cc
@@ -3,22 +3,55 @@
 #include "GEO_reverse_uv_sampler.hh"
 
 #include "BLI_math_geom.h"
+#include "BLI_math_vector.hh"
+#include "BLI_task.hh"
+#include "BLI_timeit.hh"
 
 namespace blender::geometry {
 
+static int2 uv_to_cell_key(const float2 , const int resolution)
+{
+  return int2{uv * resolution};
+}
+
 ReverseUVSampler::ReverseUVSampler(const Span uv_map, const 
Span looptris)
 : uv_map_(uv_map), looptris_(looptris)
 {
+  resolution_ = std::max(3, std::sqrt(looptris.size()) * 2);
+
+  for (const int looptri_index : looptris.index_range()) {
+const MLoopTri  = looptris[looptri_index];
+const float2 _0 = uv_map_[looptri.tri[0]];
+const float2 _1 = uv_map_[looptri.tri[1]];
+const float2 _2 = uv_map_[looptri.tri[2]];
+
+const int2 key_0 = uv_to_cell_key(uv_0, resolution_);
+const int2 key_1 = uv_to_cell_key(uv_1, resolution_);
+const int2 key_2 = uv_to_cell_key(uv_2, resolution_);
+
+const int2 min_key = math::min(math::min(key_0, key_1), key_2);
+const int2 max_key = math::max(math::max(key_0, key_1), key_2);
+
+for (int key_x = min_key.x; key_x <= max_key.x; key_x++) {
+  for (int key_y = min_key.y; key_y <= max_key.y; key_y++) {
+const int2 key{key_x, key_y};
+looptris_by_cell_.add(key, looptri_index);
+  }
+}
+  }
 }
 
 ReverseUVSampler::Result ReverseUVSampler::sample(const float2 _uv) const
 {
-  for (const MLoopTri  : looptris_) {
-const float2  = uv_map_[looptri.tri[0]];
-const float2  = uv_map_[looptri.tri[1]];
-const float2  = uv_map_[looptri.tri[2]];
+  const int2 cell_key = uv_to_cell_key(query_uv, resolution_);
+  const Span looptri_indices = looptris_by_cell_.lookup(cell_key);
+  for (const int looptri_index : looptri_indices) {
+const MLoopTri  = looptris_[looptri_index];
+const float2 _0 = uv_map_[looptri.tri[0]];
+const float2 _1 = uv_map_[looptri.tri[1]];
+const float2 _2 = uv_map_[looptri.tri[2]];
 float3 bary_weights;
-if (!barycentric_coords_v2(uv0, uv1, uv2, query_uv, bary_weights)) {
+if (!barycentric_coords_v2(uv_0, uv_1, uv_2, query_uv, bary_weights)) {
   continue;
 }
 if (IN_RANGE_INCL(bary_weights.x, 0.0f, 1.0f) && 
IN_RANGE_INCL(bary_weights.y, 0.0f, 1.0f) &&
@@ -29,4 +62,15 @@ ReverseUVSampler::Result ReverseUVSampler::sample(const 
float2 _uv) const
   return Result{};
 }
 
+void ReverseUVSampler::sample_many(const Span query_uvs,
+   MutableSpan r_results) const
+{
+  BLI_assert(query_uvs.size() == r_results.size());
+  threading::parallel_for(query_uvs.index_range(), 256, [&](const IndexRange 
range) {
+for (const int i : range) {
+  r_results[i] = this->sample(query_uvs[i]);
+}
+  });
+}
+
 }  // namespace blender::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] [7306aedca59] temp-T95933-object-mode-curve-selection: Use drw_view.winmat for projection matrix.

2022-07-05 Thread Jeroen Bakker
Commit: 7306aedca592c2c821795b24da326cb960c4c0de
Author: Jeroen Bakker
Date:   Tue Jul 5 15:16:35 2022 +0200
Branches: temp-T95933-object-mode-curve-selection
https://developer.blender.org/rB7306aedca592c2c821795b24da326cb960c4c0de

Use drw_view.winmat for projection matrix.

===

M   
source/blender/draw/engines/overlay/shaders/overlay_outline_prepass_curves_vert.glsl

===

diff --git 
a/source/blender/draw/engines/overlay/shaders/overlay_outline_prepass_curves_vert.glsl
 
b/source/blender/draw/engines/overlay/shaders/overlay_outline_prepass_curves_vert.glsl
index 6ee32c37b27..f2124895b32 100644
--- 
a/source/blender/draw/engines/overlay/shaders/overlay_outline_prepass_curves_vert.glsl
+++ 
b/source/blender/draw/engines/overlay/shaders/overlay_outline_prepass_curves_vert.glsl
@@ -29,7 +29,7 @@ uint outline_colorid_get(void)
 
 void main()
 {
-  bool is_persp = (ProjectionMatrix[3][3] == 0.0);
+  bool is_persp = (drw_view.winmat[3][3] == 0.0);
   float time, thick_time, thickness;
   vec3 center_world_pos, world_pos, tan, binor;

___
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] [3dbe1b0160b] temp-T95933-object-mode-curve-selection: Disable show_bounds for curve objects.

2022-07-05 Thread Jeroen Bakker
Commit: 3dbe1b0160b749a9df3b15f064f34df0c8ddcb8c
Author: Jeroen Bakker
Date:   Tue Jul 5 15:09:41 2022 +0200
Branches: temp-T95933-object-mode-curve-selection
https://developer.blender.org/rB3dbe1b0160b749a9df3b15f064f34df0c8ddcb8c

Disable show_bounds for curve objects.

===

M   source/blender/blenloader/intern/versioning_300.c
M   source/blender/draw/engines/overlay/overlay_extra.c
M   source/blender/editors/curves/intern/curves_ops.cc
M   source/blender/editors/object/object_add.cc

===

diff --git a/source/blender/blenloader/intern/versioning_300.c 
b/source/blender/blenloader/intern/versioning_300.c
index 34b32ebc175..14204479849 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -3276,5 +3276,13 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
   }
   brush->curves_sculpt_settings->density_add_attempts = 100;
 }
+
+/* Disable 'show_bounds' option of curve objects. Option was set as there 
was no object mode
+ * outline implementation. See T95933. */
+LISTBASE_FOREACH (Object *, ob, >objects) {
+  if (ob->type == OB_CURVES) {
+ob->dtx &= ~OB_DRAWBOUNDOX;
+  }
+}
   }
 }
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c 
b/source/blender/draw/engines/overlay/overlay_extra.c
index a880930a485..9d478310104 100644
--- a/source/blender/draw/engines/overlay/overlay_extra.c
+++ b/source/blender/draw/engines/overlay/overlay_extra.c
@@ -1527,8 +1527,7 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, 
Object *ob)
   const bool is_paint_mode = (draw_ctx->object_mode &
   (OB_MODE_ALL_PAINT | OB_MODE_ALL_PAINT_GPENCIL)) 
!= 0;
   const bool from_dupli = (ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI)) 
!= 0;
-  const bool has_bounds = !ELEM(
-  ob->type, OB_LAMP, OB_CAMERA, OB_EMPTY, OB_SPEAKER, OB_LIGHTPROBE, 
OB_CURVES);
+  const bool has_bounds = !ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_EMPTY, 
OB_SPEAKER, OB_LIGHTPROBE);
   const bool has_texspace = has_bounds &&
 !ELEM(ob->type, OB_EMPTY, OB_LATTICE, OB_ARMATURE, 
OB_GPENCIL);
 
diff --git a/source/blender/editors/curves/intern/curves_ops.cc 
b/source/blender/editors/curves/intern/curves_ops.cc
index dd7edf66920..5f79365551b 100644
--- a/source/blender/editors/curves/intern/curves_ops.cc
+++ b/source/blender/editors/curves/intern/curves_ops.cc
@@ -467,7 +467,6 @@ static int 
curves_convert_from_particle_system_exec(bContext *C, wmOperator *UNU
   }
 
   Object *ob_new = BKE_object_add(, _layer, OB_CURVES, 
psys_eval->name);
-  ob_new->dtx |= OB_DRAWBOUNDOX; /* TODO: Remove once there is actual drawing. 
*/
   Curves *curves_id = static_cast(ob_new->data);
   BKE_object_apply_mat4(ob_new, ob_from_orig->obmat, true, false);
   bke::CurvesGeometry::wrap(curves_id->geometry) = 
particles_to_curves(*ob_from_eval, *psys_eval);
diff --git a/source/blender/editors/object/object_add.cc 
b/source/blender/editors/object/object_add.cc
index 41aaede8d6f..62eded7ad03 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -2043,7 +2043,6 @@ static int object_curves_random_add_exec(bContext *C, 
wmOperator *op)
   }
 
   Object *object = ED_object_add_type(C, OB_CURVES, nullptr, loc, rot, false, 
local_view_bits);
-  object->dtx |= OB_DRAWBOUNDOX; /* TODO: remove once there is actual drawing. 
*/
 
   Curves *curves_id = static_cast(object->data);
   bke::CurvesGeometry::wrap(curves_id->geometry) = 
ed::curves::primitive_random_sphere(500, 8);
@@ -2080,7 +2079,6 @@ static int object_curves_empty_hair_add_exec(bContext *C, 
wmOperator *op)
   Object *surface_ob = CTX_data_active_object(C);
 
   Object *object = ED_object_add_type(C, OB_CURVES, nullptr, loc, rot, false, 
local_view_bits);
-  object->dtx |= OB_DRAWBOUNDOX; /* TODO: remove once there is actual drawing. 
*/
 
   if (surface_ob != nullptr && surface_ob->type == OB_MESH) {
 Curves *curves_id = static_cast(object->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] [c46d4d9fad5] master: Curves: move curves surface transforms to blenkernel

2022-07-05 Thread Jacques Lucke
Commit: c46d4d9fad5e16daa9f50e30e6373d20b8386bbb
Author: Jacques Lucke
Date:   Tue Jul 5 14:56:04 2022 +0200
Branches: master
https://developer.blender.org/rBc46d4d9fad5e16daa9f50e30e6373d20b8386bbb

Curves: move curves surface transforms to blenkernel

This utility struct is useful outside of sculpting code as well.

===

M   source/blender/blenkernel/BKE_curves.hh
M   source/blender/blenkernel/intern/curves.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_add.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_brush.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_comb.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_delete.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_density.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_intern.hh
M   source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_puff.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_selection_paint.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_slide.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc

===

diff --git a/source/blender/blenkernel/BKE_curves.hh 
b/source/blender/blenkernel/BKE_curves.hh
index cc0c607f9bb..767936e2a26 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -836,4 +836,17 @@ inline float3 calculate_vector_handle(const float3 , 
const float3 _po
 
 }  // namespace curves::bezier
 
+struct CurvesSurfaceTransforms {
+  float4x4 curves_to_world;
+  float4x4 curves_to_surface;
+  float4x4 world_to_curves;
+  float4x4 world_to_surface;
+  float4x4 surface_to_world;
+  float4x4 surface_to_curves;
+  float4x4 surface_to_curves_normal;
+
+  CurvesSurfaceTransforms() = default;
+  CurvesSurfaceTransforms(const Object _ob, const Object *surface_ob);
+};
+
 }  // namespace blender::bke
diff --git a/source/blender/blenkernel/intern/curves.cc 
b/source/blender/blenkernel/intern/curves.cc
index 7ad83263b73..78791b55b4d 100644
--- a/source/blender/blenkernel/intern/curves.cc
+++ b/source/blender/blenkernel/intern/curves.cc
@@ -388,4 +388,18 @@ Curves *curves_new_nomain(CurvesGeometry curves)
   return curves_id;
 }
 
+CurvesSurfaceTransforms::CurvesSurfaceTransforms(const Object _ob, 
const Object *surface_ob)
+{
+  this->curves_to_world = curves_ob.obmat;
+  this->world_to_curves = this->curves_to_world.inverted();
+
+  if (surface_ob != nullptr) {
+this->surface_to_world = surface_ob->obmat;
+this->world_to_surface = this->surface_to_world.inverted();
+this->surface_to_curves = this->world_to_curves * this->surface_to_world;
+this->curves_to_surface = this->world_to_surface * this->curves_to_world;
+this->surface_to_curves_normal = 
this->surface_to_curves.inverted().transposed();
+  }
+}
+
 }  // namespace blender::bke
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc 
b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
index b7f496889c0..e5e6cfef8ae 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
@@ -97,7 +97,7 @@ struct AddOperationExecutor {
   float brush_radius_re_;
   float2 brush_pos_re_;
 
-  CurvesSculptTransforms transforms_;
+  CurvesSurfaceTransforms transforms_;
 
   BVHTreeFromMesh surface_bvh_;
 
@@ -123,7 +123,7 @@ struct AddOperationExecutor {
   return;
 }
 
-transforms_ = CurvesSculptTransforms(*object_, curves_id_->surface);
+transforms_ = CurvesSurfaceTransforms(*object_, curves_id_->surface);
 
 surface_ob_ = curves_id_->surface;
 surface_ = static_cast(surface_ob_->data);
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc 
b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc
index 7d17db515fb..10564942ab9 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc
@@ -258,7 +258,7 @@ std::optional sample_curves_surface_3d_brush(
 const Depsgraph ,
 const ARegion ,
 const View3D ,
-const CurvesSculptTransforms ,
+const CurvesSurfaceTransforms ,
 const BVHTreeFromMesh _bvh,
 const float2 _pos_re,
 const float brush_radius_re)
@@ -380,18 +380,4 @@ CurvesSculptCommonContext::CurvesSculptCommonContext(const 
bContext )
   this->rv3d = CTX_wm_region_view3d();
 }
 
-CurvesSculptTransforms::CurvesSculptTransforms(const Object _ob, const 
Object *surface_ob)
-{
-  this->curves_to_world = curves_ob.obmat;
-  this->world_to_curves = this->curves_to_world.inverted();
-
-  if (surface_ob != nullptr) {
-

[Bf-blender-cvs] [7ff054c6d1b] master: Cleanup: use curves surface transform utility in operators

2022-07-05 Thread Jacques Lucke
Commit: 7ff054c6d1be0e9f022215c86426805032adc196
Author: Jacques Lucke
Date:   Tue Jul 5 15:06:14 2022 +0200
Branches: master
https://developer.blender.org/rB7ff054c6d1be0e9f022215c86426805032adc196

Cleanup: use curves surface transform utility in operators

===

M   source/blender/editors/curves/intern/curves_ops.cc

===

diff --git a/source/blender/editors/curves/intern/curves_ops.cc 
b/source/blender/editors/curves/intern/curves_ops.cc
index 2ac1a576286..aca074a1d61 100644
--- a/source/blender/editors/curves/intern/curves_ops.cc
+++ b/source/blender/editors/curves/intern/curves_ops.cc
@@ -243,17 +243,14 @@ static void try_convert_single_object(Object _ob,
   }
 
   /* Prepare transformation matrices. */
-  const float4x4 curves_to_world_mat = curves_ob.obmat;
-  const float4x4 surface_to_world_mat = surface_ob.obmat;
-  const float4x4 world_to_surface_mat = surface_to_world_mat.inverted();
-  const float4x4 curves_to_surface_mat = world_to_surface_mat * 
curves_to_world_mat;
+  const bke::CurvesSurfaceTransforms transforms{curves_ob, _ob};
 
   for (const int new_hair_i : IndexRange(hair_num)) {
 const int curve_i = new_hair_i;
 const IndexRange points = curves.points_for_curve(curve_i);
 
 const float3 _pos_cu = positions_cu[points.first()];
-const float3 root_pos_su = curves_to_surface_mat * root_pos_cu;
+const float3 root_pos_su = transforms.curves_to_surface * root_pos_cu;
 
 BVHTreeNearest nearest;
 nearest.dist_sq = FLT_MAX;
@@ -293,7 +290,7 @@ static void try_convert_single_object(Object _ob,
 
 for (const int key_i : hair_keys.index_range()) {
   const float3 _pos_cu = positions_cu[points[key_i]];
-  const float3 key_pos_su = curves_to_surface_mat * key_pos_cu;
+  const float3 key_pos_su = transforms.curves_to_surface * key_pos_cu;
   const float3 key_pos_ha = surface_to_hair_mat * key_pos_su;
 
   HairKey  = hair_keys[key_i];
@@ -558,12 +555,7 @@ static int snap_curves_to_surface_exec(bContext *C, 
wmOperator *op)
 const Span surface_looptris = 
{BKE_mesh_runtime_looptri_ensure(_mesh),
  
BKE_mesh_runtime_looptri_len(_mesh)};
 
-const float4x4 curves_to_world_mat = curves_ob->obmat;
-const float4x4 world_to_curves_mat = curves_to_world_mat.inverted();
-const float4x4 surface_to_world_mat = surface_ob.obmat;
-const float4x4 world_to_surface_mat = surface_to_world_mat.inverted();
-const float4x4 curves_to_surface_mat = world_to_surface_mat * 
curves_to_world_mat;
-const float4x4 surface_to_curves_mat = world_to_curves_mat * 
surface_to_world_mat;
+const bke::CurvesSurfaceTransforms transforms{*curves_ob, _ob};
 
 switch (attach_mode) {
   case AttachMode::Nearest: {
@@ -576,7 +568,8 @@ static int snap_curves_to_surface_exec(bContext *C, 
wmOperator *op)
 const IndexRange points = curves.points_for_curve(curve_i);
 const int first_point_i = points.first();
 const float3 old_first_point_pos_cu = positions_cu[first_point_i];
-const float3 old_first_point_pos_su = curves_to_surface_mat * 
old_first_point_pos_cu;
+const float3 old_first_point_pos_su = transforms.curves_to_surface 
*
+  old_first_point_pos_cu;
 
 BVHTreeNearest nearest;
 nearest.index = -1;
@@ -592,7 +585,8 @@ static int snap_curves_to_surface_exec(bContext *C, 
wmOperator *op)
 }
 
 const float3 new_first_point_pos_su = nearest.co;
-const float3 new_first_point_pos_cu = surface_to_curves_mat * 
new_first_point_pos_su;
+const float3 new_first_point_pos_cu = transforms.surface_to_curves 
*
+  new_first_point_pos_su;
 const float3 pos_diff_cu = new_first_point_pos_cu - 
old_first_point_pos_cu;
 
 for (float3 _cu : positions_cu.slice(points)) {
@@ -651,7 +645,8 @@ static int snap_curves_to_surface_exec(bContext *C, 
wmOperator *op)
 
 float3 new_first_point_pos_su;
 interp_v3_v3v3v3(new_first_point_pos_su, p0_su, p1_su, p2_su, 
bary_coords);
-const float3 new_first_point_pos_cu = surface_to_curves_mat * 
new_first_point_pos_su;
+const float3 new_first_point_pos_cu = transforms.surface_to_curves 
*
+  new_first_point_pos_su;
 
 const float3 pos_diff_cu = new_first_point_pos_cu - 
old_first_point_pos_cu;
 for (float3 _cu : positions_cu.slice(points)) {

___
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] [6be9b26bec0] temp-T97352-3d-texturing-seam-bleeding-b2: Something was missing in previous commit. Half of the file was committed....

2022-07-05 Thread Jeroen Bakker
Commit: 6be9b26bec0790bd1979bb20e88abb0f23819c90
Author: Jeroen Bakker
Date:   Tue Jul 5 13:09:49 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB6be9b26bec0790bd1979bb20e88abb0f23819c90

Something was missing in previous commit. Half of the file was committed

===

M   source/blender/blenkernel/BKE_uv_islands.hh

===

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh 
b/source/blender/blenkernel/BKE_uv_islands.hh
index c60f1e08c90..295f5f25a04 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -699,12 +699,25 @@ struct UVIsland {
 return result;
   }
 
+  UVEdge *lookup (const UVEdge) {
+UVVertex * found_vertex = lookup(*edge.vertices[0]);
+if (found_vertex == nullptr) {
+  return nullptr;
+}
+for (UVEdge*e: found_vertex->uv_edges) {
+  UVVertex*other_vertex = e->get_other_uv_vertex(found_vertex->vertex);
+  if (other_vertex->vertex == edge.vertices[1]->vertex && other_vertex->uv 
== edge.vertices[1]->uv) {
+return e;
+  }
+}
+return nullptr;
+  }
+
   UVEdge *lookup_or_create(const UVEdge )
   {
-for (UVEdge _edge : uv_edges) {
-  if (uv_edge.has_same_uv_vertices(edge)) {
-return _edge;
-  }
+UVEdge *found_edge = lookup(edge);
+if (found_edge != nullptr) {
+  return found_edge;
 }
 
 uv_edges.append(edge);

___
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] [ab2ace99a7b] temp-T97352-3d-texturing-seam-bleeding-b2: Use vertex lookup to lookup edges as well.

2022-07-05 Thread Jeroen Bakker
Commit: ab2ace99a7b6d264aa16d571768a857cf238520c
Author: Jeroen Bakker
Date:   Tue Jul 5 13:08:29 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rBab2ace99a7b6d264aa16d571768a857cf238520c

Use vertex lookup to lookup edges as well.

===

M   source/blender/blenkernel/BKE_uv_islands.hh

===

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh 
b/source/blender/blenkernel/BKE_uv_islands.hh
index 27172e7ed40..c60f1e08c90 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -9,7 +9,7 @@
 #include "BLI_array.hh"
 #include "BLI_edgehash.h"
 #include "BLI_float3x3.hh"
-#include "BLI_kdtree.h"
+#include "BLI_map.hh"
 #include "BLI_math.h"
 #include "BLI_math_vec_types.hh"
 #include "BLI_rect.h"
@@ -644,30 +644,13 @@ struct UVIsland {
* be completely encapsulated by another one.
*/
   Vector borders;
-  KDTree_2d *uv_vertex_lookup;
+  Map> uv_vertex_lookup;
 
   UVIsland()
   {
 uv_vertices.reserve(10);
 uv_edges.reserve(10);
 uv_primitives.reserve(10);
-uv_vertex_lookup = BLI_kdtree_2d_new(uv_vertices.capacity());
-BLI_kdtree_2d_balance(uv_vertex_lookup);
-  }
-
-  UVIsland(UVIsland &)
-  {
-uv_vertices = std::move(other.uv_vertices);
-uv_edges = std::move(other.uv_edges);
-uv_primitives = std::move(other.uv_primitives);
-borders = std::move(other.borders);
-uv_vertex_lookup = other.uv_vertex_lookup;
-other.uv_vertex_lookup = nullptr;
-  }
-
-  ~UVIsland()
-  {
-BLI_kdtree_2d_free(uv_vertex_lookup);
   }
 
   UVPrimitive *add_primitive(MeshPrimitive )
@@ -689,39 +672,30 @@ struct UVIsland {
 return uv_primitive_ptr;
   }
 
-  UVVertex *lookup_or_create(const UVVertex )
+  UVVertex *lookup(const UVVertex )
   {
-struct CallbackData {
-  UVVertex *found_vertex;
-  const UVVertex 
-  Vector _vertices;
-} callback_data = {nullptr, vertex, uv_vertices};
-BLI_kdtree_2d_range_search_cb(
-uv_vertex_lookup,
-vertex.uv,
-0.0001f,
-[](void *user_data, int index, const float *UNUSED(co), float 
UNUSED(dist_sq)) {
-  CallbackData *data = static_cast(user_data);
-  UVVertex  = data->uv_vertices[index];
-  if (vertex.uv == data->vertex.uv && vertex.vertex == 
data->vertex.vertex) {
-data->found_vertex = 
-return false;
-  }
-
-  return true;
-},
-static_cast(_data));
+int64_t vert_index = vertex.vertex->v;
+Vector  = 
uv_vertex_lookup.lookup_or_add_default(vert_index);
+for (UVVertex *v : vertices) {
+  if (v->uv == vertex.uv) {
+return v;
+  }
+}
+return nullptr;
+  }
 
-if (callback_data.found_vertex != nullptr) {
-  return callback_data.found_vertex;
+  UVVertex *lookup_or_create(const UVVertex )
+  {
+UVVertex *found_vertex = lookup(vertex);
+if (found_vertex != nullptr) {
+  return found_vertex;
 }
 
-int64_t vert_index = uv_vertices.size();
-BLI_kdtree_2d_insert(uv_vertex_lookup, vert_index, vertex.uv);
-BLI_kdtree_2d_balance(uv_vertex_lookup);
 uv_vertices.append(vertex);
 UVVertex *result = _vertices.last();
 result->uv_edges.clear();
+/* v is already a key. Ensured by UVIsland::lookup in this method. */
+uv_vertex_lookup.lookup(vertex.vertex->v).append(result);
 return result;
   }

___
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] [7f24d90f11a] master: Fix T99272: Regression: location override ignored when used in a shadertree.

2022-07-05 Thread Bastien Montagne
Commit: 7f24d90f11a6d26b2737bf28df1c66d169e7e8c2
Author: Bastien Montagne
Date:   Tue Jul 5 12:49:53 2022 +0200
Branches: master
https://developer.blender.org/rB7f24d90f11a6d26b2737bf28df1c66d169e7e8c2

Fix T99272: Regression: location override ignored when used in a shadertree.

This is not strictly speaking a regression, this worked before partial
resync was introduced purely because the whole override hierarchy was
systematically re-built.

But support for material pointers in obdata (meshes etc.) was simply not
implemented.

NOTE: This commit also greatly improves general support of materials in
liboverrides, although there is still more work needed in that area to
consider it properly supported.

===

M   source/blender/makesrna/intern/rna_mesh.c

===

diff --git a/source/blender/makesrna/intern/rna_mesh.c 
b/source/blender/makesrna/intern/rna_mesh.c
index 015b6d4055b..65468977ccb 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -1723,6 +1723,56 @@ static void UNUSED_FUNCTION(rna_mesh_unused)(void)
   /* end unused function block */
 }
 
+static bool rna_Mesh_materials_override_apply(Main *bmain,
+  PointerRNA *ptr_dst,
+  PointerRNA *UNUSED(ptr_src),
+  PointerRNA *UNUSED(ptr_storage),
+  PropertyRNA *prop_dst,
+  PropertyRNA *UNUSED(prop_src),
+  PropertyRNA 
*UNUSED(prop_storage),
+  const int UNUSED(len_dst),
+  const int UNUSED(len_src),
+  const int UNUSED(len_storage),
+  PointerRNA *ptr_item_dst,
+  PointerRNA *ptr_item_src,
+  PointerRNA 
*UNUSED(ptr_item_storage),
+  
IDOverrideLibraryPropertyOperation *opop)
+{
+  BLI_assert_msg(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE,
+ "Unsupported RNA override operation on collections' objects");
+  UNUSED_VARS_NDEBUG(opop);
+
+  Mesh *mesh_dst = (Mesh *)ptr_dst->owner_id;
+
+  if (ptr_item_dst->type == NULL || ptr_item_src->type == NULL) {
+// BLI_assert_msg(0, "invalid source or destination material.");
+return false;
+  }
+
+  Material *mat_dst = ptr_item_dst->data;
+  Material *mat_src = ptr_item_src->data;
+
+  if (mat_src == mat_dst) {
+return true;
+  }
+
+  bool is_modified = false;
+  for (int i = 0; i < mesh_dst->totcol; i++) {
+if (mesh_dst->mat[i] == mat_dst) {
+  id_us_min(_dst->id);
+  mesh_dst->mat[i] = mat_src;
+  id_us_plus(_src->id);
+  is_modified = true;
+}
+  }
+
+  if (is_modified) {
+RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);
+  }
+
+  return true;
+}
+
 /** \} */
 
 #else
@@ -2478,6 +2528,8 @@ void rna_def_texmat_common(StructRNA *srna, const char 
*texspace_editable)
   RNA_def_property_struct_type(prop, "Material");
   RNA_def_property_ui_text(prop, "Materials", "");
   RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
+  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+  RNA_def_property_override_funcs(prop, NULL, NULL, 
"rna_Mesh_materials_override_apply");
   RNA_def_property_collection_funcs(
   prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
"rna_IDMaterials_assign_int");
 }

___
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] [ce1d023667c] master: Fix (unreported) liboverride: incomplete hierarchy when root is not object/collection.

2022-07-05 Thread Bastien Montagne
Commit: ce1d023667c8d3ca565a67f8205e532b9aaad848
Author: Bastien Montagne
Date:   Tue Jul 5 12:45:54 2022 +0200
Branches: master
https://developer.blender.org/rBce1d023667c8d3ca565a67f8205e532b9aaad848

Fix (unreported) liboverride: incomplete hierarchy when root is not 
object/collection.

We do not (currently) consider other ID types as 'end points' justifying
to create an override hierarchy, however if the 'root' ID (i.e. the ID
the user selected as base to create the override) is not an object or
collection, we still want to check all of its dependencies.

This fixes e.g. if a material depends on another Empty object, and user
tries to hierarchy-override that material, its Empty dependency not
being overridden.

===

M   source/blender/blenkernel/intern/lib_override.cc

===

diff --git a/source/blender/blenkernel/intern/lib_override.cc 
b/source/blender/blenkernel/intern/lib_override.cc
index feb6fb95f5c..d816b5ede5f 100644
--- a/source/blender/blenkernel/intern/lib_override.cc
+++ b/source/blender/blenkernel/intern/lib_override.cc
@@ -937,11 +937,6 @@ static void 
lib_override_linked_group_tag(LibOverrideGroupTagData *data)
 id_root->tag |= data->tag;
   }
 
-  /* Only objects and groups are currently considered as 'keys' in override 
hierarchies. */
-  if (!ELEM(GS(id_root->name), ID_OB, ID_GR)) {
-return;
-  }
-
   /* Tag all collections and objects recursively. */
   lib_override_linked_group_tag_recursive(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] [1e2f4fac009] temp-T97352-3d-texturing-seam-bleeding-b2: Use KDTree for uvvertex lookup (currently slowing down due to rebalancing overhead.

2022-07-05 Thread Jeroen Bakker
Commit: 1e2f4fac00982ba967b0a542a3389f8f4c63c478
Author: Jeroen Bakker
Date:   Tue Jul 5 12:10:35 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB1e2f4fac00982ba967b0a542a3389f8f4c63c478

Use KDTree for uvvertex lookup (currently slowing down due to rebalancing 
overhead.

===

M   source/blender/blenkernel/BKE_uv_islands.hh

===

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh 
b/source/blender/blenkernel/BKE_uv_islands.hh
index c7cbcff8d8e..27172e7ed40 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -644,12 +644,30 @@ struct UVIsland {
* be completely encapsulated by another one.
*/
   Vector borders;
+  KDTree_2d *uv_vertex_lookup;
 
   UVIsland()
   {
 uv_vertices.reserve(10);
 uv_edges.reserve(10);
 uv_primitives.reserve(10);
+uv_vertex_lookup = BLI_kdtree_2d_new(uv_vertices.capacity());
+BLI_kdtree_2d_balance(uv_vertex_lookup);
+  }
+
+  UVIsland(UVIsland &)
+  {
+uv_vertices = std::move(other.uv_vertices);
+uv_edges = std::move(other.uv_edges);
+uv_primitives = std::move(other.uv_primitives);
+borders = std::move(other.borders);
+uv_vertex_lookup = other.uv_vertex_lookup;
+other.uv_vertex_lookup = nullptr;
+  }
+
+  ~UVIsland()
+  {
+BLI_kdtree_2d_free(uv_vertex_lookup);
   }
 
   UVPrimitive *add_primitive(MeshPrimitive )
@@ -673,12 +691,34 @@ struct UVIsland {
 
   UVVertex *lookup_or_create(const UVVertex )
   {
-for (UVVertex _vertex : uv_vertices) {
-  if (uv_vertex.uv == vertex.uv && uv_vertex.vertex == vertex.vertex) {
-return _vertex;
-  }
+struct CallbackData {
+  UVVertex *found_vertex;
+  const UVVertex 
+  Vector _vertices;
+} callback_data = {nullptr, vertex, uv_vertices};
+BLI_kdtree_2d_range_search_cb(
+uv_vertex_lookup,
+vertex.uv,
+0.0001f,
+[](void *user_data, int index, const float *UNUSED(co), float 
UNUSED(dist_sq)) {
+  CallbackData *data = static_cast(user_data);
+  UVVertex  = data->uv_vertices[index];
+  if (vertex.uv == data->vertex.uv && vertex.vertex == 
data->vertex.vertex) {
+data->found_vertex = 
+return false;
+  }
+
+  return true;
+},
+static_cast(_data));
+
+if (callback_data.found_vertex != nullptr) {
+  return callback_data.found_vertex;
 }
 
+int64_t vert_index = uv_vertices.size();
+BLI_kdtree_2d_insert(uv_vertex_lookup, vert_index, vertex.uv);
+BLI_kdtree_2d_balance(uv_vertex_lookup);
 uv_vertices.append(vertex);
 UVVertex *result = _vertices.last();
 result->uv_edges.clear();
@@ -819,7 +859,7 @@ struct UVIslands {
 islands.reserve(mesh_data.uv_island_len);
 
 for (int64_t uv_island_id = 0; uv_island_id < mesh_data.uv_island_len; 
uv_island_id++) {
-  islands.append(UVIsland());
+  islands.append_as(UVIsland());
   UVIsland *uv_island = ();
   for (MeshPrimitive  : mesh_data.primitives) {
 if (primitive.uv_island_id == uv_island_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] [ff726055167] temp-T97352-3d-texturing-seam-bleeding-b2: Remove early exit as with the new extraction method it would always fail.

2022-07-05 Thread Jeroen Bakker
Commit: ff7260551677ce449fbf08a963b17b7965ac4cc8
Author: Jeroen Bakker
Date:   Tue Jul 5 09:17:27 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rBff7260551677ce449fbf08a963b17b7965ac4cc8

Remove early exit as with the new extraction method it would always fail.

===

M   source/blender/blenkernel/BKE_uv_islands.hh

===

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh 
b/source/blender/blenkernel/BKE_uv_islands.hh
index 43802d03c56..c7cbcff8d8e 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -645,15 +645,11 @@ struct UVIsland {
*/
   Vector borders;
 
-  /* UV bounds of this island to add early exits. */
-  rctf uv_bounds;
-
   UVIsland()
   {
 uv_vertices.reserve(10);
 uv_edges.reserve(10);
 uv_primitives.reserve(10);
-BLI_rctf_init_minmax(_bounds);
   }
 
   UVPrimitive *add_primitive(MeshPrimitive )
@@ -671,7 +667,6 @@ struct UVIsland {
   uv_primitive_ptr->edges.append(uv_edge);
   uv_edge->append_to_uv_vertices();
   uv_edge->uv_primitives.append(uv_primitive_ptr);
-  BLI_rctf_do_minmax_v(_bounds, v1.uv);
 }
 return uv_primitive_ptr;
   }
@@ -738,12 +733,6 @@ struct UVIsland {
 
   bool has_shared_edge(const MeshPrimitive ) const
   {
-/* Early exit, uv bounds of the primitive should intersect with the uv 
bounds of the island. */
-rctf prim_uv_bounds = primitive.uv_bounds();
-if (!BLI_rctf_isect(_bounds, _uv_bounds, nullptr)) {
-  return false;
-}
-
 for (const UVPrimitive  : uv_primitives) {
   if (prim.has_shared_edge(primitive)) {
 return true;

___
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] [92725760c70] principled-v2: Disable HIP for now to make the buildbot not crash

2022-07-05 Thread Lukas Stockner
Commit: 92725760c7059f3296fec66c2ad65e78645fe314
Author: Lukas Stockner
Date:   Tue Jul 5 12:05:36 2022 +0200
Branches: principled-v2
https://developer.blender.org/rB92725760c7059f3296fec66c2ad65e78645fe314

Disable HIP for now to make the buildbot not crash

===

M   build_files/cmake/config/blender_release.cmake

===

diff --git a/build_files/cmake/config/blender_release.cmake 
b/build_files/cmake/config/blender_release.cmake
index 42759fec7cc..0b8ac269231 100644
--- a/build_files/cmake/config/blender_release.cmake
+++ b/build_files/cmake/config/blender_release.cmake
@@ -91,7 +91,7 @@ if(NOT APPLE)
   set(WITH_CYCLES_DEVICE_OPTIXON  CACHE BOOL "" FORCE)
   set(WITH_CYCLES_CUDA_BINARIES   ON  CACHE BOOL "" FORCE)
   set(WITH_CYCLES_CUBIN_COMPILER  OFF CACHE BOOL "" FORCE)
-  set(WITH_CYCLES_HIP_BINARIESON  CACHE BOOL "" FORCE)
+  set(WITH_CYCLES_HIP_BINARIESOFF CACHE BOOL "" FORCE)
 
   # Disable AoT kernels compilations until buildbot can deliver them in a 
reasonabel time.
   set(WITH_CYCLES_ONEAPI_BINARIES OFF CACHE BOOL "" FORCE)

___
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] [fab5234f14b] blender-v3.2-release: Fix T98884: Fix edge case crashes in gpu subdiv cache code

2022-07-05 Thread Joseph Eagar
Commit: fab5234f14b74f57cfbcbe622e0fb5a3a7bbad62
Author: Joseph Eagar
Date:   Mon Jul 4 01:34:54 2022 -0700
Branches: blender-v3.2-release
https://developer.blender.org/rBfab5234f14b74f57cfbcbe622e0fb5a3a7bbad62

Fix T98884: Fix edge case crashes in gpu subdiv cache code

===

M   source/blender/draw/intern/draw_cache_impl_subdivision.cc
M   source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc

===

diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc 
b/source/blender/draw/intern/draw_cache_impl_subdivision.cc
index 3f63b711724..2411eb6bee0 100644
--- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc
+++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc
@@ -1424,6 +1424,11 @@ void draw_subdiv_interp_custom_data(const DRWSubdivCache 
*cache,
 {
   GPUShader *shader = nullptr;
 
+  if (!draw_subdiv_cache_need_polygon_data(cache)) {
+/* Happens on meshes with only loose geometry. */
+return;
+  }
+
   if (dimensions == 1) {
 shader = get_subdiv_shader(SHADER_COMP_CUSTOM_DATA_INTERP_1D,
"#define SUBDIV_POLYGON_OFFSET\n"
diff --git 
a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc 
b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc
index 5deabaed7ea..93139956af7 100644
--- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc
@@ -183,17 +183,43 @@ static void extract_lines_loose_geom_subdiv(const 
DRWSubdivCache *subdiv_cache,
 
   uint *flags_data = static_cast(GPU_vertbuf_get_data(flags));
 
-  if (mr->extract_type == MR_EXTRACT_MESH) {
-const MEdge *medge = mr->medge;
-for (DRWSubdivLooseEdge edge : loose_edges) {
-  *flags_data++ = (medge[edge.coarse_edge_index].flag & ME_HIDE) != 0;
+  switch (mr->extract_type) {
+case MR_EXTRACT_MESH: {
+  const MEdge *medge = mr->medge;
+  for (DRWSubdivLooseEdge edge : loose_edges) {
+*flags_data++ = (medge[edge.coarse_edge_index].flag & ME_HIDE) != 0;
+  }
+  break;
 }
-  }
-  else {
-BMesh *bm = mr->bm;
-for (DRWSubdivLooseEdge edge : loose_edges) {
-  const BMEdge *bm_edge = BM_edge_at_index(bm, edge.coarse_edge_index);
-  *flags_data++ = BM_elem_flag_test_bool(bm_edge, BM_ELEM_HIDDEN) != 0;
+case MR_EXTRACT_MAPPED: {
+  if (mr->bm) {
+for (DRWSubdivLooseEdge edge : loose_edges) {
+  const BMEdge *bm_edge = bm_original_edge_get(mr, 
edge.coarse_edge_index);
+  *flags_data++ = BM_elem_flag_test_bool(bm_edge, BM_ELEM_HIDDEN) != 0;
+}
+  }
+  else {
+for (DRWSubdivLooseEdge edge : loose_edges) {
+  int e = edge.coarse_edge_index;
+
+  if (mr->e_origindex && mr->e_origindex[e] != ORIGINDEX_NONE) {
+*flags_data++ = (mr->medge[mr->e_origindex[e]].flag & ME_HIDE) != 
0;
+  }
+  else {
+*flags_data++ = false;
+  }
+}
+  }
+
+  break;
+}
+case MR_EXTRACT_BMESH: {
+  BMesh *bm = mr->bm;
+  for (DRWSubdivLooseEdge edge : loose_edges) {
+const BMEdge *bm_edge = BM_edge_at_index(bm, edge.coarse_edge_index);
+*flags_data++ = BM_elem_flag_test_bool(bm_edge, BM_ELEM_HIDDEN) != 0;
+  }
+  break;
 }
   }

___
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] [3faaacc50d9] temp-T97352-3d-texturing-seam-bleeding-b2: Improve performance initial uv island extraction.

2022-07-05 Thread Jeroen Bakker
Commit: 3faaacc50d98118484cecddc402147f60506ef56
Author: Jeroen Bakker
Date:   Tue Jul 5 08:58:18 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB3faaacc50d98118484cecddc402147f60506ef56

Improve performance initial uv island extraction.

===

M   source/blender/blenkernel/BKE_uv_islands.hh

===

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh 
b/source/blender/blenkernel/BKE_uv_islands.hh
index f03bc7e55ae..43802d03c56 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -68,6 +68,12 @@ struct MeshPrimitive {
   Vector edges;
   Vector vertices;
 
+  /**
+   * UV island this primitive belongs to. This is used to speed up the initial 
uv island
+   * extraction, but should not be used when extending uv islands.
+   */
+  int64_t uv_island_id;
+
   const MeshUVVert _uv_vert(const MeshVertex *vert) const
   {
 for (const MeshUVVert _vert : vertices) {
@@ -110,6 +116,19 @@ struct MeshPrimitive {
 }
 return result;
   }
+
+  bool has_shared_uv_edge(const MeshPrimitive *other) const
+  {
+int shared_uv_verts = 0;
+for (const MeshUVVert  : vertices) {
+  for (const MeshUVVert _vert : other->vertices) {
+if (vert.uv == other_vert.uv) {
+  shared_uv_verts += 1;
+}
+  }
+}
+return shared_uv_verts >= 2;
+  }
 };
 
 /** Wrapper to contain all required mesh data. */
@@ -125,6 +144,7 @@ struct MeshData {
   Vector primitives;
   Vector edges;
   Vector vertices;
+  int64_t uv_island_len;
 
   explicit MeshData(const MLoopTri *looptri,
 const int64_t looptri_len,
@@ -141,6 +161,7 @@ struct MeshData {
 init_vertices();
 init_primitives();
 init_edges();
+init_primitive_uv_island_ids();
 
 #ifdef VALIDATE
 for (const MeshVertex  : vertices) {
@@ -194,7 +215,7 @@ struct MeshData {
   {
 /* TODO: use actual sized. */
 edges.reserve(looptri_len * 2);
-EdgeHash *eh = BLI_edgehash_new_ex(__func__, looptri_len * 2);
+EdgeHash *eh = BLI_edgehash_new_ex(__func__, looptri_len * 3);
 for (int64_t i = 0; i < looptri_len; i++) {
   const MLoopTri  = looptri[i];
   MeshPrimitive  = primitives[i];
@@ -226,6 +247,55 @@ struct MeshData {
 }
 BLI_edgehash_free(eh, nullptr);
   }
+
+  static const int64_t INVALID_UV_ISLAND_ID = -1;
+  /**
+   * NOTE: doesn't support weird topology where unconnected mesh primitives 
share the same uv
+   * island. For a accurate implementation we should use uv_prim_lookup.
+   */
+  static void _extract_uv_neighbors(Vector _to_add,
+MeshPrimitive *primitive)
+  {
+for (MeshEdge *edge : primitive->edges) {
+  for (MeshPrimitive *other_primitive : edge->primitives) {
+if (primitive == other_primitive) {
+  continue;
+}
+if (other_primitive->uv_island_id != MeshData::INVALID_UV_ISLAND_ID) {
+  continue;
+}
+
+if (primitive->has_shared_uv_edge(other_primitive)) {
+  prims_to_add.append(other_primitive);
+}
+  }
+}
+  }
+
+  void init_primitive_uv_island_ids()
+  {
+for (MeshPrimitive  : primitives) {
+  primitive.uv_island_id = INVALID_UV_ISLAND_ID;
+}
+
+int64_t uv_island_id = 0;
+Vector prims_to_add;
+for (MeshPrimitive  : primitives) {
+  /* Early exit when uv island id is already extracted during uv neighbor 
extractions. */
+  if (primitive.uv_island_id != INVALID_UV_ISLAND_ID) {
+continue;
+  }
+
+  prims_to_add.append();
+  while (!prims_to_add.is_empty()) {
+MeshPrimitive *primitive = prims_to_add.pop_last();
+primitive->uv_island_id = uv_island_id;
+_extract_uv_neighbors(prims_to_add, primitive);
+  }
+  uv_island_id++;
+}
+uv_island_len = uv_island_id;
+  }
 };
 
 struct UVVertex {
@@ -602,7 +672,6 @@ struct UVIsland {
   uv_edge->append_to_uv_vertices();
   uv_edge->uv_primitives.append(uv_primitive_ptr);
   BLI_rctf_do_minmax_v(_bounds, v1.uv);
-  BLI_rctf_do_minmax_v(_bounds, v2.uv);
 }
 return uv_primitive_ptr;
   }
@@ -692,20 +761,6 @@ struct UVIsland {
 }
   }
 
-  /**
-   * Join 2 uv islands together where the primitive gives the location that 
joins the two islands
-   * together.
-   *
-   * NOTE: this cannot be used to join two islands that have multiple shared 
primitives, or
-   * connecting via multiple primitives.
-   * */
-  void join(const UVIsland )
-  {
-for (const UVPrimitive _prim : other.uv_primitives) {
-  append(other_prim);
-}
-  }
-
 #ifdef VALIDATE
   void validate_primitives() const
   {
@@ -772,24 +827,27 @@ struct UVIslands {
   explicit UVIslands(MeshData _data)
   {
 TIMEIT_START(uv_islands);
-islands.reserve(1000);
+