[Bf-blender-cvs] [a582abd9233] blender-v3.4-release: Cleanup: add a system reference to the wayland window
Commit: a582abd92337c7901a7315c4e688b149415b79c6 Author: Campbell Barton Date: Sat Nov 12 17:35:17 2022 +1100 Branches: blender-v3.4-release https://developer.blender.org/rBa582abd92337c7901a7315c4e688b149415b79c6 Cleanup: add a system reference to the wayland window Avoid relying on GHOST_ISystem::getSystem(), store the system instead. === M intern/ghost/intern/GHOST_WindowWayland.cpp === diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp index 942cb02dd4f..ef53f6a02e6 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cpp +++ b/intern/ghost/intern/GHOST_WindowWayland.cpp @@ -83,6 +83,7 @@ static void gwl_xdg_decor_window_destroy(WGL_XDG_Decor_Window *decor) struct GWL_Window { GHOST_WindowWayland *ghost_window = nullptr; + GHOST_SystemWayland *ghost_system = nullptr; struct wl_surface *wl_surface = nullptr; /** * Outputs on which the window is currently shown on. @@ -389,7 +390,7 @@ static void frame_handle_configure(struct libdecor_frame *frame, win->is_maximised = window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED; win->is_fullscreen = window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN; - GHOST_SystemWayland *system = static_cast(GHOST_ISystem::getSystem()); + GHOST_SystemWayland *system = win->ghost_system; const bool is_active_prev_ghost = (win->ghost_window == system->getWindowManager()->getActiveWindow()); win->is_active = window_state & LIBDECOR_WINDOW_STATE_ACTIVE; @@ -500,7 +501,7 @@ static void xdg_surface_handle_configure(void *data, win->ghost_window->notify_size(); } - GHOST_SystemWayland *system = static_cast(GHOST_ISystem::getSystem()); + GHOST_SystemWayland *system = win->ghost_system; const bool is_active_prev_ghost = (win->ghost_window == system->getWindowManager()->getActiveWindow()); if (is_active_prev_ghost != win->is_active) { @@ -606,6 +607,7 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system, } window_->ghost_window = this; + window_->ghost_system = system; window_->size[0] = int32_t(width); window_->size[1] = int32_t(height); @@ -1125,7 +1127,7 @@ bool GHOST_WindowWayland::outputs_changed_update_scale() /* As this is a low-level function, we might want adding this event to be optional, * always add the event unless it causes issues. */ -GHOST_System *system = (GHOST_System *)GHOST_ISystem::getSystem(); +GHOST_SystemWayland *system = window_->ghost_system; system->pushEvent( new GHOST_Event(system->getMilliSeconds(), GHOST_kEventWindowDPIHintChanged, this)); } ___ 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] [4737f9cff23] master: Merge branch 'blender-v3.4-release'
Commit: 4737f9cff2383e962fbcebaa6f59600e70345f7f Author: Campbell Barton Date: Sat Nov 12 17:10:42 2022 +1100 Branches: master https://developer.blender.org/rB4737f9cff2383e962fbcebaa6f59600e70345f7f Merge branch 'blender-v3.4-release' === === ___ 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] [935d6a965af] master: Merge branch 'blender-v3.4-release'
Commit: 935d6a965af1cf035367cdd884686609d4095f0d Author: Campbell Barton Date: Sat Nov 12 17:10:39 2022 +1100 Branches: master https://developer.blender.org/rB935d6a965af1cf035367cdd884686609d4095f0d Merge branch 'blender-v3.4-release' === === ___ 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] [b973e273276] master: Merge branch 'blender-v3.4-release'
Commit: b973e273276dfdb708d334c0acf7ca36b4df6219 Author: Campbell Barton Date: Sat Nov 12 17:10:36 2022 +1100 Branches: master https://developer.blender.org/rBb973e273276dfdb708d334c0acf7ca36b4df6219 Merge branch 'blender-v3.4-release' === === ___ 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] [cd659f7bbff] master: Merge branch 'blender-v3.4-release'
Commit: cd659f7bbffe3e7a7eace33d1b3bd6ea390d14d3 Author: Campbell Barton Date: Sat Nov 12 17:10:32 2022 +1100 Branches: master https://developer.blender.org/rBcd659f7bbffe3e7a7eace33d1b3bd6ea390d14d3 Merge branch 'blender-v3.4-release' === === ___ 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] [fcfa9ac219f] master: Merge branch 'blender-v3.4-release'
Commit: fcfa9ac219ffa7cd7acfa9975ed17350c9ec1f72 Author: Campbell Barton Date: Sat Nov 12 17:10:21 2022 +1100 Branches: master https://developer.blender.org/rBfcfa9ac219ffa7cd7acfa9975ed17350c9ec1f72 Merge branch 'blender-v3.4-release' === === ___ 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] [41137eb7a51] master: Merge branch 'blender-v3.4-release'
Commit: 41137eb7a511f1bbbc9284370ab56c227f508657 Author: Campbell Barton Date: Sat Nov 12 17:10:29 2022 +1100 Branches: master https://developer.blender.org/rB41137eb7a511f1bbbc9284370ab56c227f508657 Merge branch 'blender-v3.4-release' === === ___ 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] [e87b99d7f32] master: Merge branch 'blender-v3.4-release'
Commit: e87b99d7f32a5f75816dfaaa9d419a014620dc1f Author: Campbell Barton Date: Sat Nov 12 17:10:25 2022 +1100 Branches: master https://developer.blender.org/rBe87b99d7f32a5f75816dfaaa9d419a014620dc1f Merge branch 'blender-v3.4-release' === === ___ 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] [436e6dca242] blender-v3.4-release: Fix window title not redrawing with Wayland/libdecor
Commit: 436e6dca242cedcc53655609248c04fdea2cd89b Author: Campbell Barton Date: Sat Nov 12 17:06:58 2022 +1100 Branches: blender-v3.4-release https://developer.blender.org/rB436e6dca242cedcc53655609248c04fdea2cd89b Fix window title not redrawing with Wayland/libdecor === M intern/ghost/intern/GHOST_WindowWayland.cpp === diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp index d395888f600..942cb02dd4f 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cpp +++ b/intern/ghost/intern/GHOST_WindowWayland.cpp @@ -363,6 +363,7 @@ static void frame_handle_configure(struct libdecor_frame *frame, int size_next[2]; enum libdecor_window_state window_state; struct libdecor_state *state; + bool do_redraw = false; if (!libdecor_configuration_get_content_size( configuration, frame, _next[0], _next[1])) { @@ -387,14 +388,34 @@ static void frame_handle_configure(struct libdecor_frame *frame, win->is_maximised = window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED; win->is_fullscreen = window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN; + + GHOST_SystemWayland *system = static_cast(GHOST_ISystem::getSystem()); + const bool is_active_prev_ghost = (win->ghost_window == + system->getWindowManager()->getActiveWindow()); win->is_active = window_state & LIBDECOR_WINDOW_STATE_ACTIVE; + if (is_active_prev_ghost != win->is_active) { +if (win->is_active) { + win->ghost_window->activate(); +} +else { + win->ghost_window->deactivate(); +} + } - win->is_active ? win->ghost_window->activate() : win->ghost_window->deactivate(); + const bool is_active_prev_decor = win->is_active; + if (is_active_prev_decor) { +/* Without this, activating another window doesn't refresh the title-bar as inactive. */ +do_redraw = true; + } state = libdecor_state_new(UNPACK2(size_next)); libdecor_frame_commit(frame, state, configuration); libdecor_state_free(state); + if (do_redraw) { +win->ghost_window->swapBuffers(); + } + win->libdecor->configured = true; } @@ -479,11 +500,16 @@ static void xdg_surface_handle_configure(void *data, win->ghost_window->notify_size(); } - if (win->is_active) { -win->ghost_window->activate(); - } - else { -win->ghost_window->deactivate(); + GHOST_SystemWayland *system = static_cast(GHOST_ISystem::getSystem()); + const bool is_active_prev_ghost = (win->ghost_window == + system->getWindowManager()->getActiveWindow()); + if (is_active_prev_ghost != win->is_active) { +if (win->is_active) { + win->ghost_window->activate(); +} +else { + win->ghost_window->deactivate(); +} } xdg_surface_ack_configure(xdg_surface, serial); ___ 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] [787ae01dad5] blender-v3.4-release: Cleanup: move title into GWL_Window
Commit: 787ae01dad539d8dfdcdcae7c918f6cd4a907a7b Author: Campbell Barton Date: Sat Nov 12 16:26:53 2022 +1100 Branches: blender-v3.4-release https://developer.blender.org/rB787ae01dad539d8dfdcdcae7c918f6cd4a907a7b Cleanup: move title into GWL_Window Nearly all Wayland window data is stored in this struct, follow this convention so GWL_Window functions can be self contained. === M intern/ghost/intern/GHOST_WindowWayland.cpp M intern/ghost/intern/GHOST_WindowWayland.h === diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp index 561ef921187..58c6025f24c 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cpp +++ b/intern/ghost/intern/GHOST_WindowWayland.cpp @@ -106,6 +106,8 @@ struct GWL_Window { WGL_XDG_Decor_Window *xdg_decor = nullptr; wl_egl_window *egl_window = nullptr; + + std::string title; bool is_maximised = false; bool is_fullscreen = false; bool is_active = false; @@ -128,6 +130,8 @@ static void gwl_window_title_set(GWL_Window *win, const char *title) WGL_XDG_Decor_Window = *win->xdg_decor; xdg_toplevel_set_title(decor.toplevel, title); } + + win->title = title; } static GHOST_TWindowState gwl_window_state_get(const GWL_Window *win) @@ -664,7 +668,6 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system, } gwl_window_title_set(window_, title); - title_ = title; wl_surface_set_user_data(window_->wl_surface, this); @@ -754,13 +757,11 @@ GHOST_TSuccess GHOST_WindowWayland::getCursorBitmap(GHOST_CursorBitmapRef *bitma void GHOST_WindowWayland::setTitle(const char *title) { gwl_window_title_set(window_, title); - - title_ = title; } std::string GHOST_WindowWayland::getTitle() const { - return title_.empty() ? "untitled" : title_; + return window_->title.empty() ? "untitled" : window_->title; } void GHOST_WindowWayland::getWindowBounds(GHOST_Rect ) const diff --git a/intern/ghost/intern/GHOST_WindowWayland.h b/intern/ghost/intern/GHOST_WindowWayland.h index ec473c4a710..b9ef45358f2 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.h +++ b/intern/ghost/intern/GHOST_WindowWayland.h @@ -119,7 +119,6 @@ class GHOST_WindowWayland : public GHOST_Window { private: GHOST_SystemWayland *system_; struct GWL_Window *window_; - std::string title_; /** * \param type: The type of rendering context create. ___ 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] [bc3f5c7e146] blender-v3.4-release: GHOST/Wayland: skip resizing the EGL surface unnecessarily
Commit: bc3f5c7e146c080cbfb17c7af75574b13c287fcb Author: Campbell Barton Date: Sat Nov 12 16:38:11 2022 +1100 Branches: blender-v3.4-release https://developer.blender.org/rBbc3f5c7e146c080cbfb17c7af75574b13c287fcb GHOST/Wayland: skip resizing the EGL surface unnecessarily wl_egl_window_resize ran when the window became active/inactive for e.g. === M intern/ghost/intern/GHOST_WindowWayland.cpp === diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp index 58c6025f24c..d395888f600 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cpp +++ b/intern/ghost/intern/GHOST_WindowWayland.cpp @@ -370,11 +370,16 @@ static void frame_handle_configure(struct libdecor_frame *frame, size_next[1] = win->size[1] / win->scale; } + const int size_prev[2] = {UNPACK2(win->size)}; win->size[0] = win->scale * size_next[0]; win->size[1] = win->scale * size_next[1]; - wl_egl_window_resize(win->egl_window, UNPACK2(win->size), 0, 0); - win->ghost_window->notify_size(); + const bool do_resize = (size_prev[0] != win->size[0]) || (size_prev[1] != win->size[1]); + + if (do_resize) { +wl_egl_window_resize(win->egl_window, UNPACK2(win->size), 0, 0); +win->ghost_window->notify_size(); + } if (!libdecor_configuration_get_window_state(configuration, _state)) { window_state = LIBDECOR_WINDOW_STATE_NONE; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [19ba2293910] blender-v3.4-release: Cleanup: move Wayland window state utilities into lower level functions
Commit: 19ba2293910f213132804569c0ea5f60ead68c2a Author: Campbell Barton Date: Sat Nov 12 16:26:51 2022 +1100 Branches: blender-v3.4-release https://developer.blender.org/rB19ba2293910f213132804569c0ea5f60ead68c2a Cleanup: move Wayland window state utilities into lower level functions Add low level gwl_window_* functions. === M intern/ghost/intern/GHOST_WindowWayland.cpp === diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp index 0541c79bf78..561ef921187 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cpp +++ b/intern/ghost/intern/GHOST_WindowWayland.cpp @@ -77,6 +77,10 @@ static void gwl_xdg_decor_window_destroy(WGL_XDG_Decor_Window *decor) delete decor; } +/* */ +/** \name Internal #GWL_Window + * \{ */ + struct GWL_Window { GHOST_WindowWayland *ghost_window = nullptr; struct wl_surface *wl_surface = nullptr; @@ -111,6 +115,113 @@ struct GWL_Window { int32_t size_pending[2] = {0, 0}; }; +static void gwl_window_title_set(GWL_Window *win, const char *title) +{ +#ifdef WITH_GHOST_WAYLAND_LIBDECOR + if (use_libdecor) { +WGL_LibDecor_Window = *win->libdecor; +libdecor_frame_set_title(decor.frame, title); + } + else +#endif + { +WGL_XDG_Decor_Window = *win->xdg_decor; +xdg_toplevel_set_title(decor.toplevel, title); + } +} + +static GHOST_TWindowState gwl_window_state_get(const GWL_Window *win) +{ + if (win->is_fullscreen) { +return GHOST_kWindowStateFullScreen; + } + if (win->is_maximised) { +return GHOST_kWindowStateMaximized; + } + return GHOST_kWindowStateNormal; +} + +static bool gwl_window_state_set(GWL_Window *win, const GHOST_TWindowState state) +{ + const GHOST_TWindowState state_current = gwl_window_state_get(win); + switch (state) { +case GHOST_kWindowStateNormal: + /* Unset states. */ + switch (state_current) { +case GHOST_kWindowStateMaximized: { +#ifdef WITH_GHOST_WAYLAND_LIBDECOR + if (use_libdecor) { +libdecor_frame_unset_maximized(win->libdecor->frame); + } + else +#endif + { +xdg_toplevel_unset_maximized(win->xdg_decor->toplevel); + } + break; +} +case GHOST_kWindowStateFullScreen: { +#ifdef WITH_GHOST_WAYLAND_LIBDECOR + if (use_libdecor) { +libdecor_frame_unset_fullscreen(win->libdecor->frame); + } + else +#endif + { +xdg_toplevel_unset_fullscreen(win->xdg_decor->toplevel); + } + break; +} +default: { + break; +} + } + break; +case GHOST_kWindowStateMaximized: { +#ifdef WITH_GHOST_WAYLAND_LIBDECOR + if (use_libdecor) { +libdecor_frame_set_maximized(win->libdecor->frame); + } + else +#endif + { +xdg_toplevel_set_maximized(win->xdg_decor->toplevel); + } + break; +} +case GHOST_kWindowStateMinimized: { +#ifdef WITH_GHOST_WAYLAND_LIBDECOR + if (use_libdecor) { +libdecor_frame_set_minimized(win->libdecor->frame); + } + else +#endif + { +xdg_toplevel_set_minimized(win->xdg_decor->toplevel); + } + break; +} +case GHOST_kWindowStateFullScreen: { +#ifdef WITH_GHOST_WAYLAND_LIBDECOR + if (use_libdecor) { +libdecor_frame_set_fullscreen(win->libdecor->frame, nullptr); + } + else +#endif + { +xdg_toplevel_set_fullscreen(win->xdg_decor->toplevel, nullptr); + } + break; +} +case GHOST_kWindowStateEmbedded: { + return GHOST_kFailure; +} + } + return GHOST_kSuccess; +} + +/** \} */ + /* */ /** \name Internal Utilities * \{ */ @@ -552,7 +663,8 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system, } } - setTitle(title); + gwl_window_title_set(window_, title); + title_ = title; wl_surface_set_user_data(window_->wl_surface, this); @@ -582,7 +694,7 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system, if (use_libdecor == false) #endif { -setState(state); +gwl_window_state_set(window_, state); } /* EGL context. */ @@ -641,17 +753,7 @@ GHOST_TSuccess GHOST_WindowWayland::getCursorBitmap(GHOST_CursorBitmapRef *bitma void GHOST_WindowWayland::setTitle(const char *title) { -#ifdef WITH_GHOST_WAYLAND_LIBDECOR - if (use_libdecor) { -WGL_LibDecor_Window = *window_->libdecor; -libdecor_frame_set_title(decor.frame, title); - } - else -#endif - { -WGL_XDG_Decor_Window = *window_->xdg_decor; -xdg_toplevel_set_title(decor.toplevel, title); - } + gwl_window_title_set(window_, title); title_ = title; } @@
[Bf-blender-cvs] [2a17fd40a56] blender-v3.4-release: Fix non-interactive window borders after changes to event handling
Commit: 2a17fd40a56349ee576745e4b544e1e81ba7568a Author: Campbell Barton Date: Sat Nov 12 16:26:50 2022 +1100 Branches: blender-v3.4-release https://developer.blender.org/rB2a17fd40a56349ee576745e4b544e1e81ba7568a Fix non-interactive window borders after changes to event handling Regression in [0] causes LIBDECOR interactions not to be detected. [0]: deb8ae6bd1edb0983d9ac972b2c95090f4c5e642 === M intern/ghost/intern/GHOST_SystemWayland.cpp === diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 057c049792d..ed0dc9b5949 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -1522,6 +1522,10 @@ static int ghost_wl_display_event_pump(struct wl_display *wl_display) { /* Based on SDL's `Wayland_PumpEvents`. */ int err; + + /* NOTE: Without this, interactions with window borders via LIBDECOR doesn't function. */ + wl_display_flush(wl_display); + if (wl_display_prepare_read(wl_display) == 0) { /* Use #GWL_IOR_NO_RETRY to ensure #SIGINT will break us out of our wait. */ if (file_descriptor_is_io_ready( ___ 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] [1a8516163fa] master: Cleanup: Simplify handling of loop to poly map in normal calculation
Commit: 1a8516163fa921e857b17ff152cc5264ab42b898 Author: Hans Goudey Date: Fri Nov 11 22:56:44 2022 -0600 Branches: master https://developer.blender.org/rB1a8516163fa921e857b17ff152cc5264ab42b898 Cleanup: Simplify handling of loop to poly map in normal calculation A Loop to poly map was passed as an optional output to the loop normal calculation. That meant it was often recalculated more than necessary. Instead, treat it as an optional argument. This also helps relieve unnecessary responsibilities from the already-complicated loop normal calculation code. === M source/blender/blenkernel/BKE_mesh.h M source/blender/blenkernel/intern/data_transfer.c M source/blender/blenkernel/intern/key.c M source/blender/blenkernel/intern/mesh.cc M source/blender/blenkernel/intern/mesh_mirror.c M source/blender/blenkernel/intern/mesh_normals.cc M source/blender/blenkernel/intern/mesh_remap.c M source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc M source/blender/modifiers/intern/MOD_normal_edit.cc M source/blender/modifiers/intern/MOD_weighted_normal.cc === diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index bb0b4467bd2..b1488c93ba6 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -621,6 +621,8 @@ void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space, * Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals'). * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry * (splitting edges). + * + * \param loop_to_poly_map: Optional pre-created map from loops to their polygon. */ void BKE_mesh_normals_loop_split(const struct MVert *mverts, const float (*vert_normals)[3], @@ -635,9 +637,9 @@ void BKE_mesh_normals_loop_split(const struct MVert *mverts, int numPolys, bool use_split_normals, float split_angle, + const int *loop_to_poly_map, MLoopNorSpaceArray *r_lnors_spacearr, - short (*clnors_data)[2], - int *r_loop_to_poly); + short (*clnors_data)[2]); void BKE_mesh_normals_loop_custom_set(const struct MVert *mverts, const float (*vert_normals)[3], diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c index e6afca11b40..7b81f74206d 100644 --- a/source/blender/blenkernel/intern/data_transfer.c +++ b/source/blender/blenkernel/intern/data_transfer.c @@ -300,8 +300,8 @@ static void data_transfer_dtdata_type_preprocess(Mesh *me_src, use_split_nors_dst, split_angle_dst, NULL, - custom_nors_dst, - NULL); + NULL, + custom_nors_dst); } } } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 2ba81c54872..53147c94f43 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -2296,8 +2296,8 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb, (mesh->flag & ME_AUTOSMOOTH) != 0, mesh->smoothresh, NULL, -clnors, -NULL); +NULL, +clnors); } if (free_vert_normals) { diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index 2d613f24a0a..b8658139161 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -1829,9 +1829,9 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, polys.size(), use_split_normals, split_angle, + nullptr, r_lnors_spacearr, - clnors, - nullptr); + clnors); BKE_mesh_assert_normals_dirty_or_calculated(mesh); } diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c index ce3fc5d99c8..9f00d8860b8 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.c +++
[Bf-blender-cvs] [7c519aa5d87] master: Cleanup: Make loop normal calculation function static
Commit: 7c519aa5d8731b168b0750349bab98946564d6d8 Author: Hans Goudey Date: Fri Nov 11 21:58:38 2022 -0600 Branches: master https://developer.blender.org/rB7c519aa5d8731b168b0750349bab98946564d6d8 Cleanup: Make loop normal calculation function static === M source/blender/blenkernel/BKE_mesh.h M source/blender/blenkernel/intern/mesh_normals.cc === diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 8f6786d4113..bb0b4467bd2 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -494,15 +494,6 @@ void BKE_mesh_calc_normals_looptri(const struct MVert *mverts, const struct MLoopTri *looptri, int looptri_num, float (*r_tri_nors)[3]); -void BKE_mesh_loop_manifold_fan_around_vert_next(const struct MLoop *mloops, - const struct MPoly *mpolys, - const int *loop_to_poly, - const int *e2lfan_curr, - uint mv_pivot_index, - const struct MLoop **r_mlfan_curr, - int *r_mlfan_curr_index, - int *r_mlfan_vert_index, - int *r_mpfan_curr_index); /** * Define sharp edges as needed to mimic 'autosmooth' from angle threshold. diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 347532028f5..23e3e1e604b 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -966,15 +966,15 @@ void BKE_edges_sharp_from_angle_set(const MVert *mverts, MEM_freeN(loop_to_poly); } -void BKE_mesh_loop_manifold_fan_around_vert_next(const MLoop *mloops, - const MPoly *mpolys, - const int *loop_to_poly, - const int *e2lfan_curr, - const uint mv_pivot_index, - const MLoop **r_mlfan_curr, - int *r_mlfan_curr_index, - int *r_mlfan_vert_index, - int *r_mpfan_curr_index) +void loop_manifold_fan_around_vert_next(const MLoop *mloops, +const MPoly *mpolys, +const int *loop_to_poly, +const int *e2lfan_curr, +const uint mv_pivot_index, +const MLoop **r_mlfan_curr, +int *r_mlfan_curr_index, +int *r_mlfan_vert_index, +int *r_mpfan_curr_index) { /* WARNING: This is rather complex! * We have to find our next edge around the vertex (fan mode). @@ -1214,15 +1214,15 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli copy_v3_v3(vec_prev, vec_curr); /* Find next loop of the smooth fan. */ -BKE_mesh_loop_manifold_fan_around_vert_next(loops.data(), -polys.data(), -loop_to_poly.data(), -e2lfan_curr, -mv_pivot_index, -_curr, -_curr_index, -_vert_index, -_curr_index); +loop_manifold_fan_around_vert_next(loops.data(), + polys.data(), + loop_to_poly.data(), + e2lfan_curr, + mv_pivot_index, + _curr, + _curr_index, + _vert_index, + _curr_index); e2lfan_curr = edge_to_loops[mlfan_curr->e]; } @@ -1369,15 +1369,15 @@ static bool loop_split_generator_check_cyclic_smooth_fan(const Span mloop while (true) { /* Find next loop of the smooth fan. */ -
[Bf-blender-cvs] [78bfb74743e] master: Cleanup: Decrease variable scope in mesh loop normal calculation
Commit: 78bfb74743e2d021164d4464a02c1ad01b6ffaf7 Author: Hans Goudey Date: Fri Nov 11 21:56:17 2022 -0600 Branches: master https://developer.blender.org/rB78bfb74743e2d021164d4464a02c1ad01b6ffaf7 Cleanup: Decrease variable scope in mesh loop normal calculation === M source/blender/blenkernel/intern/mesh_normals.cc === diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index ddc06ff185b..347532028f5 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -976,9 +976,6 @@ void BKE_mesh_loop_manifold_fan_around_vert_next(const MLoop *mloops, int *r_mlfan_vert_index, int *r_mpfan_curr_index) { - const MLoop *mlfan_next; - const MPoly *mpfan_next; - /* WARNING: This is rather complex! * We have to find our next edge around the vertex (fan mode). * First we find the next loop, which is either previous or next to mlfan_curr_index, depending @@ -992,20 +989,20 @@ void BKE_mesh_loop_manifold_fan_around_vert_next(const MLoop *mloops, BLI_assert(*r_mlfan_curr_index >= 0); BLI_assert(*r_mpfan_curr_index >= 0); - mlfan_next = [*r_mlfan_curr_index]; - mpfan_next = [*r_mpfan_curr_index]; - if (((*r_mlfan_curr)->v == mlfan_next->v && (*r_mlfan_curr)->v == mv_pivot_index) || - ((*r_mlfan_curr)->v != mlfan_next->v && (*r_mlfan_curr)->v != mv_pivot_index)) { + const MLoop _next = mloops[*r_mlfan_curr_index]; + const MPoly _next = mpolys[*r_mpfan_curr_index]; + if (((*r_mlfan_curr)->v == mlfan_next.v && (*r_mlfan_curr)->v == mv_pivot_index) || + ((*r_mlfan_curr)->v != mlfan_next.v && (*r_mlfan_curr)->v != mv_pivot_index)) { /* We need the previous loop, but current one is our vertex's loop. */ *r_mlfan_vert_index = *r_mlfan_curr_index; -if (--(*r_mlfan_curr_index) < mpfan_next->loopstart) { - *r_mlfan_curr_index = mpfan_next->loopstart + mpfan_next->totloop - 1; +if (--(*r_mlfan_curr_index) < mpfan_next.loopstart) { + *r_mlfan_curr_index = mpfan_next.loopstart + mpfan_next.totloop - 1; } } else { /* We need the next loop, which is also our vertex's loop. */ -if (++(*r_mlfan_curr_index) >= mpfan_next->loopstart + mpfan_next->totloop) { - *r_mlfan_curr_index = mpfan_next->loopstart; +if (++(*r_mlfan_curr_index) >= mpfan_next.loopstart + mpfan_next.totloop) { + *r_mlfan_curr_index = mpfan_next.loopstart; } *r_mlfan_vert_index = *r_mlfan_curr_index; } @@ -1113,13 +1110,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli /* `ml_curr` would be mlfan_prev if we needed that one. */ const MEdge *me_org = [ml_curr->e]; - const int *e2lfan_curr; float vec_curr[3], vec_prev[3], vec_org[3]; - const MLoop *mlfan_curr; float lnor[3] = {0.0f, 0.0f, 0.0f}; - /* `mlfan_vert_index` the loop of our current edge might not be the loop of our current vertex! - */ - int mlfan_curr_index, mlfan_vert_index, mpfan_curr_index; /* We validate clnors data on the fly - cheapest way to do! */ int clnors_avg[2] = {0, 0}; @@ -1132,11 +1124,13 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli /* Temp clnors stack. */ BLI_SMALLSTACK_DECLARE(clnors, short *); - e2lfan_curr = e2l_prev; - mlfan_curr = ml_prev; - mlfan_curr_index = ml_prev_index; - mlfan_vert_index = ml_curr_index; - mpfan_curr_index = mp_index; + const int *e2lfan_curr = e2l_prev; + const MLoop *mlfan_curr = ml_prev; + /* `mlfan_vert_index` the loop of our current edge might not be the loop of our current vertex! + */ + int mlfan_curr_index = ml_prev_index; + int mlfan_vert_index = ml_curr_index; + int mpfan_curr_index = mp_index; BLI_assert(mlfan_curr_index >= 0); BLI_assert(mlfan_vert_index >= 0); @@ -1352,22 +1346,19 @@ static bool loop_split_generator_check_cyclic_smooth_fan(const Span mloop const int mp_curr_index) { const uint mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */ - const int *e2lfan_curr; - const MLoop *mlfan_curr; - /* `mlfan_vert_index` the loop of our current edge might not be the loop of our current vertex! - */ - int mlfan_curr_index, mlfan_vert_index, mpfan_curr_index; - e2lfan_curr = e2l_prev; + const int *e2lfan_curr = e2l_prev; if (IS_EDGE_SHARP(e2lfan_curr)) { /* Sharp loop, so not a cyclic smooth fan. */ return false; } - mlfan_curr = ml_prev; - mlfan_curr_index = ml_prev_index; - mlfan_vert_index = ml_curr_index; - mpfan_curr_index = mp_curr_index; + /* `mlfan_vert_index` the loop of our current edge might not be the loop of our current
[Bf-blender-cvs] [d63ada602d3] master: Cleanup: Use simpler timers for mesh normals debug timing
Commit: d63ada602d37e5bf0f4f4c7984c538fcfed5bf39 Author: Hans Goudey Date: Fri Nov 11 22:11:01 2022 -0600 Branches: master https://developer.blender.org/rBd63ada602d37e5bf0f4f4c7984c538fcfed5bf39 Cleanup: Use simpler timers for mesh normals debug timing === M source/blender/blenkernel/intern/mesh_normals.cc === diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 23e3e1e604b..510301b7192 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -42,11 +42,10 @@ using blender::MutableSpan; using blender::short2; using blender::Span; -// #define DEBUG_TIME +#define DEBUG_TIME #ifdef DEBUG_TIME -# include "PIL_time.h" -# include "PIL_time_utildefines.h" +# include "BLI_timeit.hh" #endif /* */ @@ -458,12 +457,9 @@ void BKE_mesh_ensure_normals_for_display(Mesh *mesh) void BKE_mesh_calc_normals(Mesh *mesh) { #ifdef DEBUG_TIME - TIMEIT_START_AVERAGED(BKE_mesh_calc_normals); + SCOPED_TIMER_AVERAGED(__func__); #endif BKE_mesh_vertex_normals_ensure(mesh); -#ifdef DEBUG_TIME - TIMEIT_END_AVERAGED(BKE_mesh_calc_normals); -#endif } void BKE_mesh_calc_normals_looptri(const MVert *mverts, @@ -944,7 +940,7 @@ void BKE_edges_sharp_from_angle_set(const MVert *mverts, return; } - /* Mapping edge -> loops. See BKE_mesh_normals_loop_split() for details. */ + /* Mapping edge -> loops. See #BKE_mesh_normals_loop_split for details. */ int(*edge_to_loops)[2] = (int(*)[2])MEM_calloc_arrayN( size_t(numEdges), sizeof(*edge_to_loops), __func__); @@ -966,15 +962,15 @@ void BKE_edges_sharp_from_angle_set(const MVert *mverts, MEM_freeN(loop_to_poly); } -void loop_manifold_fan_around_vert_next(const MLoop *mloops, -const MPoly *mpolys, -const int *loop_to_poly, -const int *e2lfan_curr, -const uint mv_pivot_index, -const MLoop **r_mlfan_curr, -int *r_mlfan_curr_index, -int *r_mlfan_vert_index, -int *r_mpfan_curr_index) +static void loop_manifold_fan_around_vert_next(const Span loops, + const Span polys, + const Span loop_to_poly, + const int *e2lfan_curr, + const uint mv_pivot_index, + const MLoop **r_mlfan_curr, + int *r_mlfan_curr_index, + int *r_mlfan_vert_index, + int *r_mpfan_curr_index) { /* WARNING: This is rather complex! * We have to find our next edge around the vertex (fan mode). @@ -989,8 +985,8 @@ void loop_manifold_fan_around_vert_next(const MLoop *mloops, BLI_assert(*r_mlfan_curr_index >= 0); BLI_assert(*r_mpfan_curr_index >= 0); - const MLoop _next = mloops[*r_mlfan_curr_index]; - const MPoly _next = mpolys[*r_mpfan_curr_index]; + const MLoop _next = loops[*r_mlfan_curr_index]; + const MPoly _next = polys[*r_mpfan_curr_index]; if (((*r_mlfan_curr)->v == mlfan_next.v && (*r_mlfan_curr)->v == mv_pivot_index) || ((*r_mlfan_curr)->v != mlfan_next.v && (*r_mlfan_curr)->v != mv_pivot_index)) { /* We need the previous loop, but current one is our vertex's loop. */ @@ -1006,7 +1002,7 @@ void loop_manifold_fan_around_vert_next(const MLoop *mloops, } *r_mlfan_vert_index = *r_mlfan_curr_index; } - *r_mlfan_curr = [*r_mlfan_curr_index]; + *r_mlfan_curr = [*r_mlfan_curr_index]; /* And now we are back in sync, mlfan_curr_index is the index of `mlfan_curr`! Pff! */ } @@ -1214,9 +1210,9 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli copy_v3_v3(vec_prev, vec_curr); /* Find next loop of the smooth fan. */ -loop_manifold_fan_around_vert_next(loops.data(), - polys.data(), - loop_to_poly.data(), +loop_manifold_fan_around_vert_next(loops, + polys, + loop_to_poly, e2lfan_curr, mv_pivot_index, _curr, @@ -1306,10 +1302,6 @@ static void loop_split_worker(TaskPool *__restrict pool, void *taskdata)
[Bf-blender-cvs] [d9e5a3e6ade] master: Cleanup: Use spans for loop normal calculation input data
Commit: d9e5a3e6ade047e415234643bda70d1d1502d2d1 Author: Hans Goudey Date: Fri Nov 11 21:49:43 2022 -0600 Branches: master https://developer.blender.org/rBd9e5a3e6ade047e415234643bda70d1d1502d2d1 Cleanup: Use spans for loop normal calculation input data === M source/blender/blenkernel/intern/mesh_normals.cc M source/blender/blenlib/BLI_math_vec_types.hh === diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index ddc8af99fc5..ddc06ff185b 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -37,7 +37,9 @@ #include "atomic_ops.h" using blender::BitVector; +using blender::float3; using blender::MutableSpan; +using blender::short2; using blender::Span; // #define DEBUG_TIME @@ -788,7 +790,7 @@ struct LoopSplitTaskData { /** We have to create those outside of tasks, since #MemArena is not thread-safe. */ MLoopNorSpace *lnor_space; - float (*lnor)[3]; + float3 *lnor; const MLoop *ml_curr; const MLoop *ml_prev; int ml_curr_index; @@ -809,22 +811,18 @@ struct LoopSplitTaskDataCommon { * Note we do not need to protect it, though, since two different tasks will *always* affect * different elements in the arrays. */ MLoopNorSpaceArray *lnors_spacearr; - float (*loopnors)[3]; - short (*clnors_data)[2]; + MutableSpan loopnors; + MutableSpan clnors_data; /* Read-only. */ - const MVert *mverts; - const MEdge *medges; - const MLoop *mloops; - const MPoly *mpolys; + Span verts; + MutableSpan edges; + Span loops; + Span polys; int (*edge_to_loops)[2]; - int *loop_to_poly; - const float (*polynors)[3]; - const float (*vert_normals)[3]; - - int numEdges; - int numLoops; - int numPolys; + MutableSpan loop_to_poly; + Span polynors; + Span vert_normals; }; #define INDEX_UNSET INT_MIN @@ -837,37 +835,30 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data, const float split_angle, const bool do_sharp_edges_tag) { - const MEdge *medges = data->medges; - const MLoop *mloops = data->mloops; - - const MPoly *mpolys = data->mpolys; + MutableSpan edges = data->edges; + const Span polys = data->polys; + const Span loops = data->loops; - const int numEdges = data->numEdges; - const int numPolys = data->numPolys; - - float(*loopnors)[3] = data->loopnors; /* NOTE: loopnors may be nullptr here. */ - const float(*polynors)[3] = data->polynors; + MutableSpan loopnors = data->loopnors; /* NOTE: loopnors may be empty here. */ + const Span polynors = data->polynors; int(*edge_to_loops)[2] = data->edge_to_loops; - int *loop_to_poly = data->loop_to_poly; + MutableSpan loop_to_poly = data->loop_to_poly; BitVector sharp_edges; if (do_sharp_edges_tag) { -sharp_edges.resize(numEdges, false); +sharp_edges.resize(edges.size(), false); } - const MPoly *mp; - int mp_index; - const float split_angle_cos = check_angle ? cosf(split_angle) : -1.0f; - for (mp = mpolys, mp_index = 0; mp_index < numPolys; mp++, mp_index++) { -const MLoop *ml_curr; + for (const int mp_index : polys.index_range()) { +const MPoly = polys[mp_index]; int *e2l; -int ml_curr_index = mp->loopstart; -const int ml_last_index = (ml_curr_index + mp->totloop) - 1; +int ml_curr_index = poly.loopstart; +const int ml_last_index = (ml_curr_index + poly.totloop) - 1; -ml_curr = [ml_curr_index]; +const MLoop *ml_curr = [ml_curr_index]; for (; ml_curr_index <= ml_last_index; ml_curr++, ml_curr_index++) { e2l = edge_to_loops[ml_curr->e]; @@ -877,7 +868,7 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data, /* Pre-populate all loop normals as if their verts were all-smooth, * this way we don't have to compute those later! */ - if (loopnors) { + if (!loopnors.is_empty()) { copy_v3_v3(loopnors[ml_curr_index], data->vert_normals[ml_curr->v]); } @@ -886,7 +877,7 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data, /* 'Empty' edge until now, set e2l[0] (and e2l[1] to INDEX_UNSET to tag it as unset). */ e2l[0] = ml_curr_index; /* We have to check this here too, else we might miss some flat faces!!! */ -e2l[1] = (mp->flag & ME_SMOOTH) ? INDEX_UNSET : INDEX_INVALID; +e2l[1] = (poly.flag & ME_SMOOTH) ? INDEX_UNSET : INDEX_INVALID; } else if (e2l[1] == INDEX_UNSET) { const bool is_angle_sharp = (check_angle && @@ -898,8 +889,8 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data, * or both poly have opposed (flipped) normals, i.e. both loops on the same edge share the * same vertex, or angle
[Bf-blender-cvs] [d0522d4ef15] master: Cleanup: Remove unnecessary struct keywords
Commit: d0522d4ef15fa8ee21527404a4b0f7a5423a4027 Author: Hans Goudey Date: Fri Nov 11 19:05:22 2022 -0600 Branches: master https://developer.blender.org/rBd0522d4ef15fa8ee21527404a4b0f7a5423a4027 Cleanup: Remove unnecessary struct keywords === M source/blender/blenkernel/intern/mesh_normals.cc === diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index ebb5a72d137..ddc8af99fc5 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -442,7 +442,7 @@ void BKE_mesh_ensure_normals_for_display(Mesh *mesh) BKE_mesh_poly_normals_ensure(mesh); break; case ME_WRAPPER_TYPE_BMESH: { - struct BMEditMesh *em = mesh->edit_mesh; + BMEditMesh *em = mesh->edit_mesh; EditMeshData *emd = mesh->runtime->edit_data; if (emd->vertexCos) { BKE_editmesh_cache_ensure_vert_normals(em, emd); @@ -939,13 +939,13 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data, } } -void BKE_edges_sharp_from_angle_set(const struct MVert *mverts, +void BKE_edges_sharp_from_angle_set(const MVert *mverts, const int /*numVerts*/, -struct MEdge *medges, +MEdge *medges, const int numEdges, -const struct MLoop *mloops, +const MLoop *mloops, const int numLoops, -const struct MPoly *mpolys, +const MPoly *mpolys, const float (*polynors)[3], const int numPolys, const float split_angle) ___ 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] [7931ae0df3f] blender-v3.4-release: Cleanup: use snake-case for WAYLAND utility functions
Commit: 7931ae0df3f2541316871c7b2ce7be3bd114e848 Author: Campbell Barton Date: Sat Nov 12 15:23:19 2022 +1100 Branches: blender-v3.4-release https://developer.blender.org/rB7931ae0df3f2541316871c7b2ce7be3bd114e848 Cleanup: use snake-case for WAYLAND utility functions It wasn't so obvious which functions were part of the GHOST API and which system functions were utilities. This convention was already in place but not always followed. === M intern/ghost/intern/GHOST_SystemWayland.cpp M intern/ghost/intern/GHOST_SystemWayland.h M intern/ghost/intern/GHOST_WindowWayland.cpp === diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 7948112c53c..057c049792d 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -5990,7 +5990,7 @@ static bool cursor_is_software(const GHOST_TGrabCursorMode mode, const bool use_ return false; } -GHOST_TSuccess GHOST_SystemWayland::setCursorShape(const GHOST_TStandardCursor shape) +GHOST_TSuccess GHOST_SystemWayland::cursor_shape_set(const GHOST_TStandardCursor shape) { GWL_Seat *seat = gwl_display_seat_active_get(display_); if (UNLIKELY(!seat)) { @@ -6032,7 +6032,7 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorShape(const GHOST_TStandardCursor s return GHOST_kSuccess; } -GHOST_TSuccess GHOST_SystemWayland::hasCursorShape(const GHOST_TStandardCursor cursorShape) +GHOST_TSuccess GHOST_SystemWayland::cursor_shape_check(const GHOST_TStandardCursor cursorShape) { auto cursor_find = ghost_wl_cursors.find(cursorShape); if (cursor_find == ghost_wl_cursors.end()) { @@ -6045,13 +6045,13 @@ GHOST_TSuccess GHOST_SystemWayland::hasCursorShape(const GHOST_TStandardCursor c return GHOST_kSuccess; } -GHOST_TSuccess GHOST_SystemWayland::setCustomCursorShape(uint8_t *bitmap, - uint8_t *mask, - const int sizex, - const int sizey, - const int hotX, - const int hotY, - const bool /*canInvertColor*/) +GHOST_TSuccess GHOST_SystemWayland::cursor_shape_custom_set(uint8_t *bitmap, +uint8_t *mask, +const int sizex, +const int sizey, +const int hotX, +const int hotY, +const bool /*canInvertColor*/) { GWL_Seat *seat = gwl_display_seat_active_get(display_); if (UNLIKELY(!seat)) { @@ -6121,7 +6121,7 @@ GHOST_TSuccess GHOST_SystemWayland::setCustomCursorShape(uint8_t *bitmap, return GHOST_kSuccess; } -GHOST_TSuccess GHOST_SystemWayland::getCursorBitmap(GHOST_CursorBitmapRef *bitmap) +GHOST_TSuccess GHOST_SystemWayland::cursor_bitmap_get(GHOST_CursorBitmapRef *bitmap) { GWL_Seat *seat = gwl_display_seat_active_get(display_); if (UNLIKELY(!seat)) { @@ -6147,7 +6147,7 @@ GHOST_TSuccess GHOST_SystemWayland::getCursorBitmap(GHOST_CursorBitmapRef *bitma return GHOST_kSuccess; } -GHOST_TSuccess GHOST_SystemWayland::setCursorVisibility(const bool visible) +GHOST_TSuccess GHOST_SystemWayland::cursor_visibility_set(const bool visible) { GWL_Seat *seat = gwl_display_seat_active_get(display_); if (UNLIKELY(!seat)) { @@ -6171,7 +6171,7 @@ bool GHOST_SystemWayland::supportsWindowPosition() return false; } -bool GHOST_SystemWayland::getCursorGrabUseSoftwareDisplay(const GHOST_TGrabCursorMode mode) +bool GHOST_SystemWayland::cursor_grab_use_software_display_get(const GHOST_TGrabCursorMode mode) { GWL_Seat *seat = gwl_display_seat_active_get(display_); if (UNLIKELY(!seat)) { diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h index a8e8d8ddc45..45eb1d9d3e3 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.h +++ b/intern/ghost/intern/GHOST_SystemWayland.h @@ -137,26 +137,28 @@ class GHOST_SystemWayland : public GHOST_System { const bool is_dialog, const GHOST_IWindow *parentWindow) override; - GHOST_TSuccess setCursorShape(GHOST_TStandardCursor shape); + bool supportsCursorWarp() override; + bool supportsWindowPosition() override; - GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor cursorShape); + /* WAYLAND utility functions (share window/system logic). */ -
[Bf-blender-cvs] [deb8ae6bd1e] blender-v3.4-release: GHOST/Wayland: replace roundtrip with dispatch_pending
Commit: deb8ae6bd1edb0983d9ac972b2c95090f4c5e642 Author: Campbell Barton Date: Thu Nov 10 18:03:32 2022 +1100 Branches: blender-v3.4-release https://developer.blender.org/rBdeb8ae6bd1edb0983d9ac972b2c95090f4c5e642 GHOST/Wayland: replace roundtrip with dispatch_pending Add a non-blocking version wrapper for wl_display_dispatch_pending. This uses roughly the same logic as Wayland_PumpEvents in SDL. Noticed this when investigating T100855. Note that performing a round-trip doesn't seem necessary from looking into QT/GTK & SDL event handling loops. === M intern/ghost/CMakeLists.txt M intern/ghost/intern/GHOST_SystemWayland.cpp M intern/wayland_dynload/extern/wayland_dynload_client.h === diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index ea21d831b0c..5c559072625 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -310,6 +310,11 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND) add_definitions(-DHAVE_MEMFD_CREATE) endif() +check_symbol_exists(poll "poll.h" HAVE_POLL) +if(HAVE_POLL) + add_definitions(-DHAVE_POLL) +endif() + list(APPEND SRC intern/GHOST_SystemWayland.cpp intern/GHOST_WindowWayland.cpp diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 528aa6e1884..7948112c53c 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -69,6 +69,10 @@ #include #include +#ifdef HAVE_POLL +# include +#endif + /* Logging, use `ghost.wl.*` prefix. */ #include "CLG_log.h" @@ -1456,6 +1460,85 @@ static int memfd_create_sealed(const char *name) #endif /* !HAVE_MEMFD_CREATE */ } +enum { + GWL_IOR_READ = 1 << 0, + GWL_IOR_WRITE = 1 << 1, + GWL_IOR_NO_RETRY = 1 << 2, +}; + +static int file_descriptor_is_io_ready(int fd, const int flags, const int timeout_ms) +{ + int result; + + GHOST_ASSERT(flags & (GWL_IOR_READ | GWL_IOR_WRITE), "X"); + + /* Note: We don't bother to account for elapsed time if we get EINTR */ + do { +#ifdef HAVE_POLL +struct pollfd info; + +info.fd = fd; +info.events = 0; +if (flags & GWL_IOR_READ) { + info.events |= POLLIN | POLLPRI; +} +if (flags & GWL_IOR_WRITE) { + info.events |= POLLOUT; +} +result = poll(, 1, timeout_ms); +#else +fd_set rfdset, *rfdp = nullptr; +fd_set wfdset, *wfdp = nullptr; +struct timeval tv, *tvp = nullptr; + +/* If this assert triggers we'll corrupt memory here */ +GHOST_ASSERT(fd >= 0 && fd < FD_SETSIZE, "X"); + +if (flags & GWL_IOR_READ) { + FD_ZERO(); + FD_SET(fd, ); + rfdp = +} +if (flags & GWL_IOR_WRITE) { + FD_ZERO(); + FD_SET(fd, ); + wfdp = +} + +if (timeout_ms >= 0) { + tv.tv_sec = timeout_ms / 1000; + tv.tv_usec = (timeout_ms % 1000) * 1000; + tvp = +} + +result = select(fd + 1, rfdp, wfdp, nullptr, tvp); +#endif /* !HAVE_POLL */ + } while (result < 0 && errno == EINTR && !(flags & GWL_IOR_NO_RETRY)); + + return result; +} + +static int ghost_wl_display_event_pump(struct wl_display *wl_display) +{ + /* Based on SDL's `Wayland_PumpEvents`. */ + int err; + if (wl_display_prepare_read(wl_display) == 0) { +/* Use #GWL_IOR_NO_RETRY to ensure #SIGINT will break us out of our wait. */ +if (file_descriptor_is_io_ready( +wl_display_get_fd(wl_display), GWL_IOR_READ | GWL_IOR_NO_RETRY, 0) > 0) { + err = wl_display_read_events(wl_display); +} +else { + wl_display_cancel_read(wl_display); + err = 0; +} + } + else { +err = wl_display_dispatch_pending(wl_display); + } + return err; +} + static size_t ghost_wl_shm_format_as_size(enum wl_shm_format format) { switch (format) { @@ -5169,7 +5252,7 @@ bool GHOST_SystemWayland::processEvents(bool waitForEvent) } } else { -if (wl_display_roundtrip(display_->wl_display) == -1) { +if (ghost_wl_display_event_pump(display_->wl_display) == -1) { ghost_wl_display_report_error(display_->wl_display); } } diff --git a/intern/wayland_dynload/extern/wayland_dynload_client.h b/intern/wayland_dynload/extern/wayland_dynload_client.h index bf1e2f89c18..22ec33b1ef2 100644 --- a/intern/wayland_dynload/extern/wayland_dynload_client.h +++ b/intern/wayland_dynload/extern/wayland_dynload_client.h @@ -14,6 +14,11 @@ extern "C" { WAYLAND_DYNLOAD_FN(wl_display_connect) WAYLAND_DYNLOAD_FN(wl_display_disconnect) WAYLAND_DYNLOAD_FN(wl_display_dispatch) +WAYLAND_DYNLOAD_FN(wl_display_dispatch_pending) +WAYLAND_DYNLOAD_FN(wl_display_get_fd) +WAYLAND_DYNLOAD_FN(wl_display_prepare_read) +WAYLAND_DYNLOAD_FN(wl_display_read_events) +WAYLAND_DYNLOAD_FN(wl_display_cancel_read) WAYLAND_DYNLOAD_FN(wl_display_roundtrip) WAYLAND_DYNLOAD_FN(wl_display_flush)
[Bf-blender-cvs] [f14dd870a95] refactor-mesh-uv-map-generic: Cleanup: clang-format
Commit: f14dd870a956b6d357b47600dcffd5bf092a6a5c Author: Martijn Versteegh Date: Sat Nov 12 00:08:48 2022 +0100 Branches: refactor-mesh-uv-map-generic https://developer.blender.org/rBf14dd870a956b6d357b47600dcffd5bf092a6a5c Cleanup: clang-format === M source/blender/blenloader/intern/versioning_defaults.cc M source/blender/bmesh/bmesh_class.h M source/blender/bmesh/intern/bmesh_interp.c M source/blender/draw/engines/overlay/overlay_edit_uv.cc M source/blender/editors/transform/transform_convert_mesh_uv.c M source/blender/editors/uvedit/uvedit_islands.cc M source/blender/python/bmesh/bmesh_py_types_customdata.c M source/blender/python/bmesh/bmesh_py_types_meshdata.c === diff --git a/source/blender/blenloader/intern/versioning_defaults.cc b/source/blender/blenloader/intern/versioning_defaults.cc index cfc56250bcd..3d924bc9c05 100644 --- a/source/blender/blenloader/intern/versioning_defaults.cc +++ b/source/blender/blenloader/intern/versioning_defaults.cc @@ -357,7 +357,8 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) {0.125, 0.50}, {0.375, 0.50}, {0.375, 0.75}, {0.125, 0.75}, {0.375, 0.50}, {0.625, 0.50}, {0.625, 0.75}, {0.375, 0.75}, {0.375, 0.25}, {0.625, 0.25}, {0.625, 0.50}, {0.375, 0.50}, }; -float(*mloopuv)[2] = static_cast(CustomData_get_layer(>ldata, CD_PROP_FLOAT2)); +float(*mloopuv)[2] = static_cast( +CustomData_get_layer(>ldata, CD_PROP_FLOAT2)); memcpy(mloopuv, uv_values, sizeof(float[2]) * me->totloop); } diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index 5139cbec692..4b56c5a1b78 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -532,7 +532,6 @@ typedef bool (*BMLoopPairFilterFunc)(const BMLoop *, const BMLoop *, void *user_ #define BM_ELEM_CD_GET_OPT_BOOL(ele, offset) \ (offset == -1 ? false : *((bool *)((char *)(ele)->head.data + (offset - #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) # define BM_ELEM_CD_GET_BOOL_P(ele, offset) \ (BLI_assert(offset != -1), \ @@ -549,17 +548,17 @@ typedef bool (*BMLoopPairFilterFunc)(const BMLoop *, const BMLoop *, void *user_ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) # define BM_ELEM_CD_GET_OPT_BOOL_P(ele, offset) \ ((offset != -1) ? \ - _Generic(ele, \ - GENERIC_TYPE_ANY((bool *)POINTER_OFFSET((ele)->head.data, offset), \ - _BM_GENERIC_TYPE_ELEM_NONCONST), \ - GENERIC_TYPE_ANY((const bool *)POINTER_OFFSET((ele)->head.data, offset), \ - _BM_GENERIC_TYPE_ELEM_CONST)) : NULL) + _Generic(ele, \ + GENERIC_TYPE_ANY((bool *)POINTER_OFFSET((ele)->head.data, offset), \ + _BM_GENERIC_TYPE_ELEM_NONCONST), \ + GENERIC_TYPE_ANY((const bool *)POINTER_OFFSET((ele)->head.data, offset), \ + _BM_GENERIC_TYPE_ELEM_CONST)) : \ + NULL) #else # define BM_ELEM_CD_GET_OPT_BOOL_P(ele, offset) \ ((offset != -1) ? (bool *)((char *)(ele)->head.data + (offset)) : NULL) #endif - #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) # define BM_ELEM_CD_GET_VOID_P(ele, offset) \ (BLI_assert(offset != -1), \ diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 0198cb6818f..86f86d79fac 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -898,8 +898,7 @@ void BM_uv_map_ensure_edge_selection_attribute(BMesh *bm, const char *uv_map_nam void BM_uv_map_ensure_pin_attribute(BMesh *bm, const char *uv_map_name) { char name[MAX_CUSTOMDATA_LAYER_NAME]; - BM_data_layer_ensure_named( - bm, >ldata, CD_PROP_BOOL, get_uv_map_pin_name(uv_map_name, name)); + BM_data_layer_ensure_named(bm, >ldata, CD_PROP_BOOL, get_uv_map_pin_name(uv_map_name, name)); } void BM_data_layer_free(BMesh *bm, CustomData *data, int type) diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.cc b/source/blender/draw/engines/overlay/overlay_edit_uv.cc index 83aa2aac3e8..9d34e7559dc 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc @@ -116,10 +116,10 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) const bool show_modified_uvs = sima->flag & SI_DRAWSHADOW; const bool is_tiled_image = image && (image->source == IMA_SRC_TILED); const bool do_edges_only = (ts->uv_flag & UV_SYNC_SELECTION) ? - /* NOTE: Ignore #SCE_SELECT_EDGE because a single selected edge - * on the mesh may cause single UV vertices to be
[Bf-blender-cvs] [cbdb2207a44] refactor-mesh-uv-map-generic: Fix some more mistakes found when checking the whole diff.
Commit: cbdb2207a44aae54420d19b583b7b2a354f9ed91 Author: Martijn Versteegh Date: Sat Nov 12 00:02:10 2022 +0100 Branches: refactor-mesh-uv-map-generic https://developer.blender.org/rBcbdb2207a44aae54420d19b583b7b2a354f9ed91 Fix some more mistakes found when checking the whole diff. === M source/blender/editors/transform/transform_convert_mesh_uv.c M source/blender/editors/uvedit/uvedit_ops.c M source/blender/editors/uvedit/uvedit_unwrap_ops.c M source/blender/python/bmesh/bmesh_py_types_meshdata.c === diff --git a/source/blender/editors/transform/transform_convert_mesh_uv.c b/source/blender/editors/transform/transform_convert_mesh_uv.c index 96bcbaa412a..a36aa05f8db 100644 --- a/source/blender/editors/transform/transform_convert_mesh_uv.c +++ b/source/blender/editors/transform/transform_convert_mesh_uv.c @@ -375,7 +375,7 @@ static void createTransUVs(bContext *C, TransInfo *t) } } -luv = BM_ELEM_CD_GET_VOID_P(l, offsets.uv); +luv = (float (*)[2])BM_ELEM_CD_GET_FLOAT_P(l, offsets.uv); UVsToTransData(t->aspect, td++, td2d++, *luv, center, prop_distance, selected); } } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 392a415c701..b05bc011b78 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1481,7 +1481,7 @@ static int uv_hide_exec(bContext *C, wmOperator *op) BM_ITER_ELEM (l, , efa, BM_LOOPS_OF_FACE) { -if (UV_VERT_SEL_TEST(l, !swap)) { +if (UV_VERT_SEL_TEST(l, !swap) || UV_EDGE_SEL_TEST(l, !swap)) { hide = 1; break; } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 1924c4c4e65..1e55d091e1a 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -340,7 +340,7 @@ static void uvedit_prepare_pinned_indices(ParamHandle *handle, BMIter liter; BMLoop *l; BM_ITER_ELEM (l, , efa, BM_LOOPS_OF_FACE) { -bool pin = BM_ELEM_CD_GET_BOOL(l, offsets.pin); +bool pin = BM_ELEM_CD_GET_OPT_BOOL(l, offsets.pin); if (options->pin_unselected && !pin) { pin = !uvedit_uv_select_test(scene, l, offsets); } diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index af66d531d82..a090ed30da3 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -70,6 +70,7 @@ static PyObject *bpy_bmloopuv_pin_uv_get(BPy_BMLoopUV *self, void *UNUSED(closur } static int bpy_bmloopuv_pin_uv_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED(closure)) { + BLI_assert(self->pinned); if (self->pinned) { *self->pinned = PyC_Long_AsBool(value); } @@ -87,6 +88,7 @@ static PyObject *bpy_bmloopuv_select_get(BPy_BMLoopUV *self, void *UNUSED(closur } static int bpy_bmloopuv_select_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED(closure)) { + BLI_assert(self->vertsel); if (self->vertsel) { *self->vertsel = PyC_Long_AsBool(value); } @@ -99,6 +101,7 @@ static PyObject *bpy_bmloopuv_select_edge_get(BPy_BMLoopUV *self, void *UNUSED(c } static int bpy_bmloopuv_select_edge_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED(closure)) { + BLI_assert(self->edgesel); if (self->edgesel) { *self->edgesel = PyC_Long_AsBool(value); } ___ 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] [b4757873bf1] refactor-mesh-uv-map-generic: Merge branch 'master' into refactor-mesh-uv-map-generic
Commit: b4757873bf1c2fb5e3f858a085af62359d3c1b3f Author: Martijn Versteegh Date: Fri Nov 11 19:44:16 2022 +0100 Branches: refactor-mesh-uv-map-generic https://developer.blender.org/rBb4757873bf1c2fb5e3f858a085af62359d3c1b3f Merge branch 'master' into refactor-mesh-uv-map-generic === === diff --cc source/blender/editors/geometry/geometry_attributes.cc index 1a4c93afcdc,7f163da493b..5b0202dcbe1 --- a/source/blender/editors/geometry/geometry_attributes.cc +++ b/source/blender/editors/geometry/geometry_attributes.cc @@@ -290,23 -290,32 +289,15 @@@ static int geometry_attribute_convert_e * 4. Create a new attribute based on the previously copied data. */ switch (mode) { case ConvertAttributeMode::Generic: { - const eAttrDomain dst_domain = static_cast(RNA_enum_get(op->ptr, "domain")); - const eCustomDataType dst_type = static_cast( - RNA_enum_get(op->ptr, "data_type")); - - if (ELEM(dst_type, CD_PROP_STRING)) { - BKE_report(op->reports, RPT_ERROR, "Cannot convert to the selected type"); + if (!ED_geometry_attribute_convert(mesh, + name.c_str(), + eCustomDataType(RNA_enum_get(op->ptr, "data_type")), + eAttrDomain(RNA_enum_get(op->ptr, "domain")), + op->reports)) { return OPERATOR_CANCELLED; } - - GVArray src_varray = attributes.lookup_or_default(name, dst_domain, dst_type); - const CPPType _type = src_varray.type(); - void *new_data = MEM_malloc_arrayN(src_varray.size(), cpp_type.size(), __func__); - src_varray.materialize_to_uninitialized(new_data); - attributes.remove(name); - attributes.add(name, dst_domain, dst_type, blender::bke::AttributeInitMoveArray(new_data)); break; } -case ConvertAttributeMode::UVMap: { - MLoopUV *dst_uvs = static_cast( - MEM_calloc_arrayN(mesh->totloop, sizeof(MLoopUV), __func__)); - VArray src_varray = attributes.lookup_or_default( - name, ATTR_DOMAIN_CORNER, {0.0f, 0.0f}); - for (const int i : IndexRange(mesh->totloop)) { -copy_v2_v2(dst_uvs[i].uv, src_varray[i]); - } - attributes.remove(name); - CustomData_add_layer_named( - >ldata, CD_MLOOPUV, CD_ASSIGN, dst_uvs, mesh->totloop, name.c_str()); - int *active_index = BKE_id_attributes_active_index_p(>id); - if (*active_index > 0) { -*active_index -= 1; - } - break; -} case ConvertAttributeMode::VertexGroup: { Array src_weights(mesh->totvert); VArray src_varray = attributes.lookup_or_default( ___ 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] [1bbb48a5d10] refactor-mesh-uv-map-generic: Cleanup: fix typos in comments. make diff minimal for layout.
Commit: 1bbb48a5d10cde6240cb66c69fe38e971d3129de Author: Martijn Versteegh Date: Sat Nov 12 00:03:09 2022 +0100 Branches: refactor-mesh-uv-map-generic https://developer.blender.org/rB1bbb48a5d10cde6240cb66c69fe38e971d3129de Cleanup: fix typos in comments. make diff minimal for layout. === M source/blender/editors/uvedit/uvedit_ops.c M source/blender/editors/uvedit/uvedit_path.c M source/blender/io/collada/GeometryExporter.cpp M source/blender/io/wavefront_obj/importer/obj_import_mesh.cc M source/blender/python/bmesh/bmesh_py_types_customdata.c === diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index b05bc011b78..7032e73bf9b 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1848,8 +1848,8 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op) continue; } -bool changed = false; const BMUVOffsets offsets = BM_uv_map_get_offsets(em->bm); +bool changed = false; BMFace *f; BM_ITER_MESH (f, , bm, BM_FACES_OF_MESH) { diff --git a/source/blender/editors/uvedit/uvedit_path.c b/source/blender/editors/uvedit/uvedit_path.c index 248f97392ae..82d8c536fba 100644 --- a/source/blender/editors/uvedit/uvedit_path.c +++ b/source/blender/editors/uvedit/uvedit_path.c @@ -567,7 +567,6 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; - const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float aspect_y; diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp index 44f52dc797c..a14d941ed43 100644 --- a/source/blender/io/collada/GeometryExporter.cpp +++ b/source/blender/io/collada/GeometryExporter.cpp @@ -370,6 +370,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index, int layer_index = CustomData_get_layer_index_n(>ldata, CD_PROP_FLOAT2, i); if (!this->export_settings.get_active_uv_only() || layer_index == active_uv_index) { + // char *name = CustomData_get_layer_name(>ldata, CD_PROP_FLOAT2, i); COLLADASW::Input texcoord_input( COLLADASW::InputSemantic::TEXCOORD, makeUrl(makeTexcoordSourceId(geom_id, i, this->export_settings.get_active_uv_only())), diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc index f27bbd296e4..5a54874aae1 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc @@ -293,7 +293,7 @@ void MeshFromGeometry::create_uv_verts(Mesh *mesh) uv_map.finish(); /* If we have an object without UVs which resides in the same .obj file - * as an object which *does* have UVs we can end up adding and UV layer + * as an object which *does* have UVs we can end up adding a UV layer * filled with zeroes. * We could maybe check before creating this layer but that would need * iterating over the whole mesh to check for UVs and as this is probably diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c index 239e21b6ffb..1f5c2f57e01 100644 --- a/source/blender/python/bmesh/bmesh_py_types_customdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c @@ -462,7 +462,8 @@ static PyObject *bpy_bmlayercollection_verify(BPy_BMLayerCollection *self) BM_data_layer_add(self->bm, data, self->type); index = 0; /* Because addingCustomData layers to a bmesh will invalidate any existing pointers - * in Py objects we can't lazily add the associated bool layers. So add htem right now. + * in Py objects we can't lazily add the associated bool layers. So add them all right + * now. */ if (self->type == CD_PROP_FLOAT2 && self->htype == BM_LOOP) { const char *active_uv_name = CustomData_get_active_layer_name(>bm->ldata, CD_PROP_FLOAT2); ___ 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] [62effd67918] refactor-mesh-uv-map-generic: Fix merge error of release/scripts/addons
Commit: 62effd6791858221392ff7b92104a22ed44ebf7d Author: Martijn Versteegh Date: Fri Nov 11 19:41:14 2022 +0100 Branches: refactor-mesh-uv-map-generic https://developer.blender.org/rB62effd6791858221392ff7b92104a22ed44ebf7d Fix merge error of release/scripts/addons === M release/scripts/addons === diff --git a/release/scripts/addons b/release/scripts/addons index 85c414a2023..68419fb3659 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 85c414a2023c1fdf16b6f3c9dc462fe242a625b9 +Subproject commit 68419fb3659f09e8447d351a25b1bd8e56211a5a ___ 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] [350271f4709] refactor-mesh-uv-map-generic: Fix some mistakes after reviewing half of the patch.
Commit: 350271f47094ee8e0ca65d77bafc50c513a87653 Author: Martijn Versteegh Date: Fri Nov 11 17:10:40 2022 +0100 Branches: refactor-mesh-uv-map-generic https://developer.blender.org/rB350271f47094ee8e0ca65d77bafc50c513a87653 Fix some mistakes after reviewing half of the patch. Turns out I forgot to merge with master before reviewing the diff(to master). Halfway I encountered unmerged code, so the second half of the review will happen after the merge. ;-) === M source/blender/blenkernel/intern/object_update.cc M source/blender/bmesh/tools/bmesh_path_uv.c === diff --git a/source/blender/blenkernel/intern/object_update.cc b/source/blender/blenkernel/intern/object_update.cc index bea7ec19b25..32d332cf07e 100644 --- a/source/blender/blenkernel/intern/object_update.cc +++ b/source/blender/blenkernel/intern/object_update.cc @@ -158,7 +158,7 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o #endif if (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER) { /* Always compute UVs, vertex colors as orcos for render. */ -cddata_masks.lmask |= CD_MASK_PROP_BYTE_COLOR; +cddata_masks.lmask |= CD_MASK_PROP_FLOAT2 | CD_MASK_PROP_BYTE_COLOR; cddata_masks.vmask |= CD_MASK_ORCO | CD_MASK_PROP_COLOR; } makeDerivedMesh(depsgraph, scene, ob, _masks); /* was CD_MASK_BAREMESH */ diff --git a/source/blender/bmesh/tools/bmesh_path_uv.c b/source/blender/bmesh/tools/bmesh_path_uv.c index 58d5104cc74..26726fe4bac 100644 --- a/source/blender/bmesh/tools/bmesh_path_uv.c +++ b/source/blender/bmesh/tools/bmesh_path_uv.c @@ -398,7 +398,7 @@ static float facetag_cut_cost_edge_uv(BMFace *f_a, BM_face_uv_calc_center_median_weighted(f_b, aspect_v2, cd_loop_uv_offset, f_b_cent); const float *co_v1 = BM_ELEM_CD_GET_FLOAT_P(l_edge, cd_loop_uv_offset); - const float *co_v2 = BM_ELEM_CD_GET_VOID_P(l_edge->next, cd_loop_uv_offset); + const float *co_v2 = BM_ELEM_CD_GET_FLOAT_P(l_edge->next, cd_loop_uv_offset); #if 0 mid_v2_v2v2(e_cent, co_v1, co_v2); ___ 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] [c29795452cc] temp-sculpt-roll-mapping: Merge branch 'master' into temp-sculpt-roll-mapping
Commit: c29795452cc71cb9f5a571a4aff0f593a2d7acaf Author: Joseph Eagar Date: Fri Nov 11 14:18:46 2022 -0800 Branches: temp-sculpt-roll-mapping https://developer.blender.org/rBc29795452cc71cb9f5a571a4aff0f593a2d7acaf Merge branch 'master' into temp-sculpt-roll-mapping === === ___ 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] [03ccf37162d] master: Cleanup: Rename curves sculpt selection variable
Commit: 03ccf37162d365f3fdc8d8cd0cd6e9ff314fec6e Author: Hans Goudey Date: Fri Nov 11 15:32:51 2022 -0600 Branches: master https://developer.blender.org/rB03ccf37162d365f3fdc8d8cd0cd6e9ff314fec6e Cleanup: Rename curves sculpt selection variable It's a bit simpler to skip the "indices" in the name, that can be assumed from the type. === M source/blender/editors/sculpt_paint/curves_sculpt_ops.cc === diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index df23bdf0079..d6c4d43d5fc 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -592,8 +592,8 @@ namespace select_grow { struct GrowOperatorDataPerCurve : NonCopyable, NonMovable { Curves *curves_id; - Vector selected_point_indices; - Vector unselected_point_indices; + Vector selected_points; + Vector unselected_points; Array distances_to_selected; Array distances_to_unselected; @@ -612,34 +612,32 @@ static void update_points_selection(const GrowOperatorDataPerCurve , { if (distance > 0.0f) { threading::parallel_for( -data.unselected_point_indices.index_range(), 256, [&](const IndexRange range) { +data.unselected_points.index_range(), 256, [&](const IndexRange range) { for (const int i : range) { -const int point_i = data.unselected_point_indices[i]; +const int point_i = data.unselected_points[i]; const float distance_to_selected = data.distances_to_selected[i]; const float selection = distance_to_selected <= distance ? 1.0f : 0.0f; points_selection[point_i] = selection; } }); -threading::parallel_for( -data.selected_point_indices.index_range(), 512, [&](const IndexRange range) { - for (const int point_i : data.selected_point_indices.as_span().slice(range)) { -points_selection[point_i] = 1.0f; - } -}); +threading::parallel_for(data.selected_points.index_range(), 512, [&](const IndexRange range) { + for (const int point_i : data.selected_points.as_span().slice(range)) { +points_selection[point_i] = 1.0f; + } +}); } else { +threading::parallel_for(data.selected_points.index_range(), 256, [&](const IndexRange range) { + for (const int i : range) { +const int point_i = data.selected_points[i]; +const float distance_to_unselected = data.distances_to_unselected[i]; +const float selection = distance_to_unselected <= -distance ? 0.0f : 1.0f; +points_selection[point_i] = selection; + } +}); threading::parallel_for( -data.selected_point_indices.index_range(), 256, [&](const IndexRange range) { - for (const int i : range) { -const int point_i = data.selected_point_indices[i]; -const float distance_to_unselected = data.distances_to_unselected[i]; -const float selection = distance_to_unselected <= -distance ? 0.0f : 1.0f; -points_selection[point_i] = selection; - } -}); -threading::parallel_for( -data.unselected_point_indices.index_range(), 512, [&](const IndexRange range) { - for (const int point_i : data.unselected_point_indices.as_span().slice(range)) { +data.unselected_points.index_range(), 512, [&](const IndexRange range) { + for (const int point_i : data.unselected_points.as_span().slice(range)) { points_selection[point_i] = 0.0f; } }); @@ -707,10 +705,10 @@ static void select_grow_invoke_per_curve(Curves _id, for (const int point_i : points_selection.index_range()) { const float point_selection = points_selection[point_i]; if (point_selection > 0.0f) { - curve_op_data.selected_point_indices.append(point_i); + curve_op_data.selected_points.append(point_i); } else { - curve_op_data.unselected_point_indices.append(point_i); + curve_op_data.unselected_points.append(point_i); } } @@ -725,12 +723,12 @@ static void select_grow_invoke_per_curve(Curves _id, const IndexRange points = curves.points_for_curve(curve_i); if (curve_selection > 0.0f) { for (const int point_i : points) { -curve_op_data.selected_point_indices.append(point_i); +curve_op_data.selected_points.append(point_i); } } else { for (const int point_i : points) { -curve_op_data.unselected_point_indices.append(point_i); +curve_op_data.unselected_points.append(point_i); } } } @@ -739,50 +737,46 @@ static void
[Bf-blender-cvs] [5465aa63d57] master: Merge branch 'blender-v3.4-release'
Commit: 5465aa63d57939febdbc92f7b2ef0cfe8b3ae402 Author: Ray Molenkamp Date: Fri Nov 11 13:49:55 2022 -0700 Branches: master https://developer.blender.org/rB5465aa63d57939febdbc92f7b2ef0cfe8b3ae402 Merge branch 'blender-v3.4-release' === === ___ 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] [c5b36aa9404] blender-v3.4-release: tests: Disable lattice_deform_performance test
Commit: c5b36aa9404be6859fee7c3d212e484ea9b1d1dc Author: Ray Molenkamp Date: Fri Nov 11 13:49:12 2022 -0700 Branches: blender-v3.4-release https://developer.blender.org/rBc5b36aa9404be6859fee7c3d212e484ea9b1d1dc tests: Disable lattice_deform_performance test This test is disabled for the following reasons: This test is one of the longer ones in this suite (2979 out of 3559ms total) and nothing is currently monitoring the performance, if this test were to be 20% slower one day, no-one would actually notice. there are no asserts, the test actually cannot fail. it's good to have some benchmark code, so like some of the other mesh benchmark code, exclude it using an `#ifdef` guard so i can be easily re-enabled when needed. reviewed by: jbakker Differential Revision: https://developer.blender.org/D16314 === M source/blender/blenkernel/intern/lattice_deform_test.cc === diff --git a/source/blender/blenkernel/intern/lattice_deform_test.cc b/source/blender/blenkernel/intern/lattice_deform_test.cc index 58aadf652b7..c66feedc878 100644 --- a/source/blender/blenkernel/intern/lattice_deform_test.cc +++ b/source/blender/blenkernel/intern/lattice_deform_test.cc @@ -13,6 +13,9 @@ #include "BLI_rand.hh" +#define DO_PERF_TESTS 0 + +#if DO_PERF_TESTS namespace blender::bke::tests { struct LatticeDeformTestContext { @@ -122,3 +125,4 @@ TEST(lattice_deform_performance, performance_no_dvert_1000) } } // namespace blender::bke::tests +#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] [9d827a1834a] master: Fix OSL object matrix with Cycles on the GPU
Commit: 9d827a1834ab0e2211488251dc9133e7164652dd Author: Patrick Mours Date: Fri Nov 11 20:20:47 2022 +0100 Branches: master https://developer.blender.org/rB9d827a1834ab0e2211488251dc9133e7164652dd Fix OSL object matrix with Cycles on the GPU The OSL GPU services implementation of "osl_get_matrix" and "osl_get_inverse_matrix" was missing support for the "common", "shader" and "object" matrices and thus any matrix operations in OSL shaders using these would not work. This patch adds the proper implementation copied from the OSL CPU services. Maniphest Tasks: T101222 === M intern/cycles/kernel/osl/services_gpu.h === diff --git a/intern/cycles/kernel/osl/services_gpu.h b/intern/cycles/kernel/osl/services_gpu.h index f762c7258df..75cf39919a0 100644 --- a/intern/cycles/kernel/osl/services_gpu.h +++ b/intern/cycles/kernel/osl/services_gpu.h @@ -15,6 +15,14 @@ namespace DeviceStrings { /* "" */ ccl_device_constant DeviceString _emptystring_ = {0ull}; +/* "common" */ +ccl_device_constant DeviceString u_common = {14645198576927606093ull}; +/* "world" */ +ccl_device_constant DeviceString u_world = {16436542438370751598ull}; +/* "shader" */ +ccl_device_constant DeviceString u_shader = {4279676006089868ull}; +/* "object" */ +ccl_device_constant DeviceString u_object = {973692718279674627ull}; /* "NDC" */ ccl_device_constant DeviceString u_ndc = {5148305047403260775ull}; /* "screen" */ @@ -23,10 +31,6 @@ ccl_device_constant DeviceString u_screen = {14159088609039777114ull}; ccl_device_constant DeviceString u_camera = {2159505832145726196ull}; /* "raster" */ ccl_device_constant DeviceString u_raster = {7759263238610201778ull}; -/* "world" */ -ccl_device_constant DeviceString u_world = {16436542438370751598ull}; -/* "common" */ -ccl_device_constant DeviceString u_common = {14645198576927606093ull}; /* "hsv" */ ccl_device_constant DeviceString u_hsv = {2177035556331879497ull}; /* "hsl" */ @@ -425,6 +429,7 @@ ccl_device_extern bool osl_transformc(ccl_private ShaderGlobals *sg, /* Matrix Utilities */ +#include "kernel/geom/object.h" #include "util/transform.h" ccl_device_forceinline void copy_matrix(ccl_private float *res, const Transform ) @@ -465,24 +470,24 @@ ccl_device_forceinline void copy_matrix(ccl_private float *res, const Projection res[14] = tfm.z.w; res[15] = tfm.w.w; } -ccl_device_forceinline void copy_identity_matrix(ccl_private float *res) +ccl_device_forceinline void copy_identity_matrix(ccl_private float *res, float value = 1.0f) { - res[0] = 1.0f; + res[0] = value; res[1] = 0.0f; res[2] = 0.0f; res[3] = 0.0f; res[4] = 0.0f; - res[5] = 1.0f; + res[5] = value; res[6] = 0.0f; res[7] = 0.0f; res[8] = 0.0f; res[9] = 0.0f; - res[10] = 1.0f; + res[10] = value; res[11] = 0.0f; res[12] = 0.0f; res[13] = 0.0f; res[14] = 0.0f; - res[15] = 1.0f; + res[15] = value; } ccl_device_forceinline Transform convert_transform(ccl_private const float *m) { @@ -534,22 +539,7 @@ ccl_device_extern void osl_div_mfm(ccl_private float *res, float a, ccl_private ccl_device_extern void osl_div_m_ff(ccl_private float *res, float a, float b) { float f = (b == 0) ? 0.0f : (a / b); - res[0] = f; - res[1] = 0.0f; - res[2] = 0.0f; - res[3] = 0.0f; - res[4] = 0.0f; - res[5] = f; - res[6] = 0.0f; - res[7] = 0.0f; - res[8] = 0.0f; - res[9] = 0.0f; - res[10] = f; - res[11] = 0.0f; - res[12] = 0.0f; - res[13] = 0.0f; - res[14] = 0.0f; - res[15] = f; + copy_identity_matrix(res, f); } ccl_device_extern void osl_transform_vmv(ccl_private float3 *res, @@ -607,27 +597,43 @@ ccl_device_extern void osl_transformn_dvmdv(ccl_private float3 *res, } ccl_device_extern bool osl_get_matrix(ccl_private ShaderGlobals *sg, - ccl_private float *result, + ccl_private float *res, DeviceString from) { - if (from == DeviceStrings::u_ndc) { -copy_matrix(result, kernel_data.cam.ndctoworld); + if (from == DeviceStrings::u_common || from == DeviceStrings::u_world) { +copy_identity_matrix(res); return true; } - if (from == DeviceStrings::u_raster) { -copy_matrix(result, kernel_data.cam.rastertoworld); + if (from == DeviceStrings::u_shader || from == DeviceStrings::u_object) { +KernelGlobals kg = nullptr; +ccl_private ShaderData *const sd = static_cast(sg->renderstate); +int object = sd->object; + +if (object != OBJECT_NONE) { + const Transform tfm = object_get_transform(kg, sd); + copy_matrix(res, tfm); + return true; +} +else if (sd->type == PRIMITIVE_LAMP) { + const Transform tfm = lamp_fetch_transform(kg, sd->lamp, false); + copy_matrix(res, tfm); + return true; +} + } + else if (from == DeviceStrings::u_ndc) { +
[Bf-blender-cvs] [1fdaf748bf4] master: Add poll messages for marker operators
Commit: 1fdaf748bf4a6b65465602aefa36868e69b4c30f Author: Colin Basnett Date: Fri Nov 11 11:13:00 2022 -0800 Branches: master https://developer.blender.org/rB1fdaf748bf4a6b65465602aefa36868e69b4c30f Add poll messages for marker operators A number of operators were missing poll messages when disabled. These are the following new error messages: 1. "No markers are selected" 2. "Markers are locked" Reviewed By: sybren Differential Revision: https://developer.blender.org/D16403 === M source/blender/editors/animation/anim_markers.c === diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 94746837259..c980fd73342 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -663,11 +663,16 @@ static bool ed_markers_poll_selected_markers(bContext *C) ListBase *markers = ED_context_get_markers(C); if (!ED_operator_markers_region_active(C)) { -return 0; +return false; } /* check if some marker is selected */ - return ED_markers_get_first_selected(markers) != NULL; + if (ED_markers_get_first_selected(markers) == NULL) { +CTX_wm_operator_poll_msg_set(C, "No markers are selected"); +return false; + } + + return true; } static bool ed_markers_poll_selected_no_locked_markers(bContext *C) @@ -675,12 +680,22 @@ static bool ed_markers_poll_selected_no_locked_markers(bContext *C) ListBase *markers = ED_context_get_markers(C); ToolSettings *ts = CTX_data_tool_settings(C); - if (ts->lock_markers || !ED_operator_markers_region_active(C)) { -return 0; + if (!ED_operator_markers_region_active(C)) { +return false; + } + + if (ts->lock_markers) { +CTX_wm_operator_poll_msg_set(C, "Markers are locked"); +return false; } /* check if some marker is selected */ - return ED_markers_get_first_selected(markers) != NULL; + if (ED_markers_get_first_selected(markers) == NULL) { +CTX_wm_operator_poll_msg_set(C, "No markers are selected"); +return false; + } + + return true; } /* special poll() which checks if there are any markers at all first */ ___ 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] [5671e7a92c3] master: Cleanup: Fixing anti-patterns in fcurve.c
Commit: 5671e7a92c397e3558f346cc2796da452f016b17 Author: Colin Basnett Date: Fri Nov 11 11:07:30 2022 -0800 Branches: master https://developer.blender.org/rB5671e7a92c397e3558f346cc2796da452f016b17 Cleanup: Fixing anti-patterns in fcurve.c This is a clean-up pass that eliminates a few problematic patterns: * Eliminating redundant parentheses around simple expressions. * Combing declaration and assignment of variables where appropriate. * Moving variable declarations closer to their first use. * Many variables and arguments have been marked as `const`. * Using `LISTBASE_FOREACH_*` variants where applicable instead of manually managing loop control flow. There are no functional changes. Reviewed By: sybren Differential Revision: https://developer.blender.org/D16459 === M source/blender/blenkernel/intern/fcurve.c === diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index aa99a5f605a..3e772e37177 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -85,8 +85,6 @@ void BKE_fcurve_free(FCurve *fcu) void BKE_fcurves_free(ListBase *list) { - FCurve *fcu, *fcn; - /* Sanity check. */ if (list == NULL) { return; @@ -96,7 +94,8 @@ void BKE_fcurves_free(ListBase *list) * as we store reference to next, and freeing only touches the curve * it's given. */ - for (fcu = list->first; fcu; fcu = fcn) { + FCurve *fcn = NULL; + for (FCurve *fcu = list->first; fcu; fcu = fcn) { fcn = fcu->next; BKE_fcurve_free(fcu); } @@ -113,15 +112,13 @@ void BKE_fcurves_free(ListBase *list) FCurve *BKE_fcurve_copy(const FCurve *fcu) { - FCurve *fcu_d; - /* Sanity check. */ if (fcu == NULL) { return NULL; } /* Make a copy. */ - fcu_d = MEM_dupallocN(fcu); + FCurve *fcu_d = MEM_dupallocN(fcu); fcu_d->next = fcu_d->prev = NULL; fcu_d->grp = NULL; @@ -145,8 +142,6 @@ FCurve *BKE_fcurve_copy(const FCurve *fcu) void BKE_fcurves_copy(ListBase *dst, ListBase *src) { - FCurve *dfcu, *sfcu; - /* Sanity checks. */ if (ELEM(NULL, dst, src)) { return; @@ -156,8 +151,8 @@ void BKE_fcurves_copy(ListBase *dst, ListBase *src) BLI_listbase_clear(dst); /* Copy one-by-one. */ - for (sfcu = src->first; sfcu; sfcu = sfcu->next) { -dfcu = BKE_fcurve_copy(sfcu); + LISTBASE_FOREACH (FCurve *, sfcu, src) { +FCurve *dfcu = BKE_fcurve_copy(sfcu); BLI_addtail(dst, dfcu); } } @@ -203,12 +198,10 @@ FCurve *id_data_find_fcurve( { /* Anim vars */ AnimData *adt = BKE_animdata_from_id(id); - FCurve *fcu = NULL; /* Rna vars */ PointerRNA ptr; PropertyRNA *prop; - char *path; if (r_driven) { *r_driven = false; @@ -225,7 +218,7 @@ FCurve *id_data_find_fcurve( return NULL; } - path = RNA_path_from_ID_to_property(, prop); + char *path = RNA_path_from_ID_to_property(, prop); if (path == NULL) { return NULL; } @@ -233,7 +226,7 @@ FCurve *id_data_find_fcurve( /* FIXME: The way drivers are handled here (always NULL-ifying `fcu`) is very weird, this needs * to be re-checked I think?. */ bool is_driven = false; - fcu = BKE_animadata_fcurve_find_by_rna_path(adt, path, index, NULL, _driven); + FCurve *fcu = BKE_animadata_fcurve_find_by_rna_path(adt, path, index, NULL, _driven); if (is_driven) { if (r_driven != NULL) { *r_driven = is_driven; @@ -248,15 +241,13 @@ FCurve *id_data_find_fcurve( FCurve *BKE_fcurve_find(ListBase *list, const char rna_path[], const int array_index) { - FCurve *fcu; - /* Sanity checks. */ - if (ELEM(NULL, list, rna_path) || (array_index < 0)) { + if (ELEM(NULL, list, rna_path) || array_index < 0) { return NULL; } /* Check paths of curves, then array indices... */ - for (fcu = list->first; fcu; fcu = fcu->next) { + LISTBASE_FOREACH (FCurve *, fcu, list) { /* Check indices first, much cheaper than a string comparison. */ /* Simple string-compare (this assumes that they have the same root...) */ if (UNLIKELY(fcu->array_index == array_index && fcu->rna_path && @@ -276,15 +267,13 @@ FCurve *BKE_fcurve_find(ListBase *list, const char rna_path[], const int array_i FCurve *BKE_fcurve_iter_step(FCurve *fcu_iter, const char rna_path[]) { - FCurve *fcu; - /* Sanity checks. */ if (ELEM(NULL, fcu_iter, rna_path)) { return NULL; } /* Check paths of curves, then array indices... */ - for (fcu = fcu_iter; fcu; fcu = fcu->next) { + for (FCurve *fcu = fcu_iter; fcu; fcu = fcu->next) { /* Simple string-compare (this assumes that they have the same root...) */ if (fcu->rna_path && STREQ(fcu->rna_path, rna_path)) { return fcu; @@ -296,7 +285,6 @@ FCurve *BKE_fcurve_iter_step(FCurve *fcu_iter, const char rna_path[]) int BKE_fcurves_filter(ListBase
[Bf-blender-cvs] [abbbf9f0023] master: Merge branch 'blender-v3.4-release'
Commit: abbbf9f002334fd61ea6a05f48c8dfe3dfb95bab Author: Hans Goudey Date: Fri Nov 11 12:41:04 2022 -0600 Branches: master https://developer.blender.org/rBabbbf9f002334fd61ea6a05f48c8dfe3dfb95bab Merge branch 'blender-v3.4-release' === === ___ 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] [864af51d6a8] blender-v3.4-release: Fix: Failing instance visibility test after recent commit
Commit: 864af51d6a88e1408367ab7083825b3b40b75e24 Author: Hans Goudey Date: Fri Nov 11 12:31:50 2022 -0600 Branches: blender-v3.4-release https://developer.blender.org/rB864af51d6a88e1408367ab7083825b3b40b75e24 Fix: Failing instance visibility test after recent commit The "visibility_instances.blend" cycles test was failing.. The stack of dupli generator types added in e508de041712cc31588 wasn't "popped" correctly after recursive duplis were generated. === M source/blender/blenkernel/intern/object_dupli.cc === diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index 54a26a897d8..cca609a2e0d 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -344,6 +344,9 @@ static void make_recursive_duplis(const DupliContext *ctx, ctx->instance_stack->append(ob); rctx.gen->make_duplis(); ctx->instance_stack->remove_last(); + if (!ctx->dupli_gen_type_stack->is_empty()) { +ctx->dupli_gen_type_stack->remove_last(); + } } } } @@ -388,6 +391,9 @@ static void make_child_duplis(const DupliContext *ctx, ob->flag |= OB_DONE; /* Doesn't render. */ } make_child_duplis_cb(, userdata, ob); + if (!ctx->dupli_gen_type_stack->is_empty()) { +ctx->dupli_gen_type_stack->remove_last(); + } } } } @@ -413,6 +419,9 @@ static void make_child_duplis(const DupliContext *ctx, } make_child_duplis_cb(, userdata, ob); + if (!ctx->dupli_gen_type_stack->is_empty()) { +ctx->dupli_gen_type_stack->remove_last(); + } } } persistent_dupli_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] [5b80b5d7d7c] soc-2022-many-lights-sampling: Fix: wrong argument passed to `sample_resevoir()`
Commit: 5b80b5d7d7c3c84146a8ced7b47e3ac37e8d67ac Author: Weizhen Huang Date: Fri Nov 11 19:12:23 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rB5b80b5d7d7c3c84146a8ced7b47e3ac37e8d67ac Fix: wrong argument passed to `sample_resevoir()` === M intern/cycles/kernel/light/tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index 226553e0cdb..f13c20ac106 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -502,10 +502,10 @@ ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg, selected_prim_index_min = -1; for (int i = 0; i < knode->num_prims; i++) { int current_prim_index = -knode->child_index + i; - selected_min_importance = float(has_importance & 1); + min_importance = float(has_importance & 1); has_importance >>= 1; sample_resevoir(current_prim_index, - selected_min_importance, + min_importance, selected_prim_index_min, selected_min_importance, total_min_importance, ___ 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] [2c596319a48] master: Cycles: Cache only up to 5 kernels of each type on Metal
Commit: 2c596319a4888aa40bfdf41f9ea5d446179141d0 Author: Michael Jones Date: Fri Nov 11 18:10:16 2022 + Branches: master https://developer.blender.org/rB2c596319a4888aa40bfdf41f9ea5d446179141d0 Cycles: Cache only up to 5 kernels of each type on Metal This patch adapts D14754 for the Metal backend. Kernels of the same type are already organised into subdirectories which simplifies type matching. Reviewed By: brecht Differential Revision: https://developer.blender.org/D16469 === M intern/cycles/device/metal/kernel.mm M intern/cycles/util/path.cpp M intern/cycles/util/path.h === diff --git a/intern/cycles/device/metal/kernel.mm b/intern/cycles/device/metal/kernel.mm index dc8af9a5358..35cf832c537 100644 --- a/intern/cycles/device/metal/kernel.mm +++ b/intern/cycles/device/metal/kernel.mm @@ -618,7 +618,9 @@ void MetalKernelPipeline::compile() metalbin_path = path_cache_get(path_join("kernels", metalbin_name)); path_create_directories(metalbin_path); -if (path_exists(metalbin_path) && use_binary_archive) { +/* Retrieve shader binary from disk, and update the file timestamp for LRU purging to work as + * intended. */ +if (use_binary_archive && path_cache_kernel_exists_and_mark_used(metalbin_path)) { if (@available(macOS 11.0, *)) { MTLBinaryArchiveDescriptor *archiveDesc = [[MTLBinaryArchiveDescriptor alloc] init]; archiveDesc.url = [NSURL fileURLWithPath:@(metalbin_path.c_str())]; @@ -695,6 +697,9 @@ void MetalKernelPipeline::compile() metal_printf("Failed to save binary archive, error:\n%s\n", [[error localizedDescription] UTF8String]); } +else { + path_cache_kernel_mark_added_and_clear_old(metalbin_path); +} } } }; diff --git a/intern/cycles/util/path.cpp b/intern/cycles/util/path.cpp index 17cff2f2977..cb6b8d7a740 100644 --- a/intern/cycles/util/path.cpp +++ b/intern/cycles/util/path.cpp @@ -2,8 +2,11 @@ * Copyright 2011-2022 Blender Foundation */ #include "util/path.h" +#include "util/algorithm.h" +#include "util/map.h" #include "util/md5.h" #include "util/string.h" +#include "util/vector.h" #include #include @@ -898,19 +901,54 @@ FILE *path_fopen(const string , const string ) #endif } -void path_cache_clear_except(const string , const set ) +/* LRU Cache for Kernels */ + +static void path_cache_kernel_mark_used(const string ) { - string dir = path_user_get("cache"); + std::time_t current_time = std::time(nullptr); + OIIO::Filesystem::last_write_time(path, current_time); +} - if (path_exists(dir)) { -directory_iterator it(dir), it_end; +bool path_cache_kernel_exists_and_mark_used(const string ) +{ + if (path_exists(path)) { +path_cache_kernel_mark_used(path); +return true; + } + else { +return false; + } +} -for (; it != it_end; ++it) { - string filename = path_filename(it->path()); +void path_cache_kernel_mark_added_and_clear_old(const string _path, +const size_t max_old_kernel_of_same_type) +{ + path_cache_kernel_mark_used(new_path); + + string dir = path_dirname(new_path); + if (!path_exists(dir)) { +return; + } + + /* Remove older kernels within the same directory. */ + directory_iterator it(dir), it_end; + vector> same_kernel_types; + + for (; it != it_end; ++it) { +const string = it->path(); +if (path == new_path) { + continue; +} + +std::time_t last_time = OIIO::Filesystem::last_write_time(path); +same_kernel_types.emplace_back(last_time, path); + } + + if (same_kernel_types.size() > max_old_kernel_of_same_type) { +sort(same_kernel_types.begin(), same_kernel_types.end()); - if (string_startswith(filename, name.c_str())) -if (except.find(filename) == except.end()) - path_remove(it->path()); +for (int i = 0; i < same_kernel_types.size() - max_old_kernel_of_same_type; i++) { + path_remove(same_kernel_types[i].second); } } } diff --git a/intern/cycles/util/path.h b/intern/cycles/util/path.h index 48b1fb65919..6d02267e182 100644 --- a/intern/cycles/util/path.h +++ b/intern/cycles/util/path.h @@ -55,8 +55,15 @@ bool path_remove(const string ); /* source code utility */ string path_source_replace_includes(const string , const string ); -/* cache utility */ -void path_cache_clear_except(const string , const set ); +/* Simple least-recently-used cache for kernels. + * + * Kernels of same type are cached in the same directory. + * Whenever a kernel is used, its last modified time is updated. + * When a new kernel is added to the cache, clear old entries of the same type (i.e. in the same + * directory). */ +bool path_cache_kernel_exists_and_mark_used(const string ); +void path_cache_kernel_mark_added_and_clear_old(const
[Bf-blender-cvs] [6f6a0185f2b] master: Merge branch 'blender-v3.4-release'
Commit: 6f6a0185f2be5074bcde4082dd3d1e31843151d9 Author: Brecht Van Lommel Date: Fri Nov 11 19:05:44 2022 +0100 Branches: master https://developer.blender.org/rB6f6a0185f2be5074bcde4082dd3d1e31843151d9 Merge branch 'blender-v3.4-release' === === ___ 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] [8799ab201d3] blender-v3.4-release: Fix T96481: make color picker RGB display consistent
Commit: 8799ab201d332ff2fe1a52815b595152639fdcb7 Author: Hallam Roberts Date: Fri Nov 11 15:50:35 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB8799ab201d332ff2fe1a52815b595152639fdcb7 Fix T96481: make color picker RGB display consistent Show RGB value "1.000" instead of "1", jus like HSV mode. Also uses full labels "Red", "Green" and "Blue" rather than the shortened labels "R", "G" and "B", for both RGB and HSV. Differential Revision: https://developer.blender.org/D14387 === M source/blender/editors/interface/interface_region_color_picker.cc === diff --git a/source/blender/editors/interface/interface_region_color_picker.cc b/source/blender/editors/interface/interface_region_color_picker.cc index 0b2c538331a..8b28e9fece1 100644 --- a/source/blender/editors/interface/interface_region_color_picker.cc +++ b/source/blender/editors/interface/interface_region_color_picker.cc @@ -199,7 +199,7 @@ static void ui_update_color_picker_buts_rgb(uiBut *from_but, * push, so disable it on RNA buttons in the color picker block */ UI_but_flag_disable(bt, UI_BUT_UNDO); } -else if (STREQ(bt->str, "Hex: ")) { +else if (STREQ(bt->str, "Hex:")) { float rgb_hex[3]; uchar rgb_hex_uchar[3]; char col[16]; @@ -613,7 +613,7 @@ static void ui_block_colorpicker(uiBlock *block, bt = uiDefButR_prop(block, UI_BTYPE_NUM_SLIDER, 0, - IFACE_("R:"), + IFACE_("Red:"), 0, yco, butwidth, @@ -623,7 +623,7 @@ static void ui_block_colorpicker(uiBlock *block, 0, 0.0, 0.0, - 0, + 10, 3, TIP_("Red")); UI_but_func_set(bt, ui_colorpicker_rgba_update_cb, bt, nullptr); @@ -631,7 +631,7 @@ static void ui_block_colorpicker(uiBlock *block, bt = uiDefButR_prop(block, UI_BTYPE_NUM_SLIDER, 0, - IFACE_("G:"), + IFACE_("Green:"), 0, yco -= UI_UNIT_Y, butwidth, @@ -641,7 +641,7 @@ static void ui_block_colorpicker(uiBlock *block, 1, 0.0, 0.0, - 0, + 10, 3, TIP_("Green")); UI_but_func_set(bt, ui_colorpicker_rgba_update_cb, bt, nullptr); @@ -649,7 +649,7 @@ static void ui_block_colorpicker(uiBlock *block, bt = uiDefButR_prop(block, UI_BTYPE_NUM_SLIDER, 0, - IFACE_("B:"), + IFACE_("Blue:"), 0, yco -= UI_UNIT_Y, butwidth, @@ -659,7 +659,7 @@ static void ui_block_colorpicker(uiBlock *block, 2, 0.0, 0.0, - 0, + 10, 3, TIP_("Blue")); UI_but_func_set(bt, ui_colorpicker_rgba_update_cb, bt, nullptr); @@ -675,7 +675,7 @@ static void ui_block_colorpicker(uiBlock *block, bt = uiDefButF(block, UI_BTYPE_NUM_SLIDER, 0, - IFACE_("H:"), + IFACE_("Hue:"), 0, yco, butwidth, @@ -692,7 +692,7 @@ static void ui_block_colorpicker(uiBlock *block, bt = uiDefButF(block, UI_BTYPE_NUM_SLIDER, 0, - IFACE_("S:"), + IFACE_("Saturation:"), 0, yco -= UI_UNIT_Y, butwidth, @@ -710,7 +710,7 @@ static void ui_block_colorpicker(uiBlock *block, bt = uiDefButF(block, UI_BTYPE_NUM_SLIDER, 0, - IFACE_("L:"), + IFACE_("Lightness:"), 0, yco -= UI_UNIT_Y, butwidth, @@ -726,7 +726,7 @@ static void ui_block_colorpicker(uiBlock *block, bt = uiDefButF(block, UI_BTYPE_NUM_SLIDER, 0, - IFACE_("V:"), + IFACE_("Value:"), 0, yco -= UI_UNIT_Y, butwidth, @@ -750,7 +750,7 @@ static void ui_block_colorpicker(uiBlock *block, bt = uiDefButR_prop(block, UI_BTYPE_NUM_SLIDER, 0, -IFACE_("A: "), +IFACE_("Alpha:"), 0,
[Bf-blender-cvs] [ba2072524bb] blender-v3.4-release: Fix CMake error when pkg-config is not installed
Commit: ba2072524bbf06068bec5c12e185a222b4d57f76 Author: Brecht Van Lommel Date: Fri Nov 11 17:55:07 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rBba2072524bbf06068bec5c12e185a222b4d57f76 Fix CMake error when pkg-config is not installed Don't assume xxx_FOUND variables are defined. === M build_files/cmake/macros.cmake === diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 73883376060..824c587c86e 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -1240,7 +1240,7 @@ endmacro() macro(set_and_warn_library_found _library_name _library_found _setting) - if(NOT ${${_library_found}} AND ${${_setting}}) + if(((NOT ${_library_found}) OR (NOT ${${_library_found}})) AND ${${_setting}}) if(WITH_STRICT_BUILD_OPTIONS) message(SEND_ERROR "${_library_name} required but not found") else() ___ 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] [aa191c7ac1d] soc-2022-many-lights-sampling: Cleanup: renaming a few confusing variables
Commit: aa191c7ac1ddc544f815ea7b0ba24681766db77d Author: Weizhen Huang Date: Fri Nov 11 17:41:29 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBaa191c7ac1ddc544f815ea7b0ba24681766db77d Cleanup: renaming a few confusing variables === M intern/cycles/kernel/light/area.h M intern/cycles/kernel/light/background.h M intern/cycles/kernel/light/spot.h M intern/cycles/kernel/types.h M intern/cycles/scene/light.cpp === diff --git a/intern/cycles/kernel/light/area.h b/intern/cycles/kernel/light/area.h index 2e863cf81c2..7d6f2a5bef9 100644 --- a/intern/cycles/kernel/light/area.h +++ b/intern/cycles/kernel/light/area.h @@ -15,18 +15,18 @@ CCL_NAMESPACE_BEGIN * NOTE: light_p is modified when sample_coord is true. */ ccl_device_inline float area_light_rect_sample(float3 P, ccl_private float3 *light_p, - float3 axisu, - float3 axisv, + float3 extentu, + float3 extentv, float randu, float randv, bool sample_coord) { /* In our name system we're using P for the center, which is o in the paper. */ - float3 corner = *light_p - axisu * 0.5f - axisv * 0.5f; - float axisu_len, axisv_len; + float3 corner = *light_p - extentu * 0.5f - extentv * 0.5f; + float extentu_len, extentv_len; /* Compute local reference system R. */ - float3 x = normalize_len(axisu, _len); - float3 y = normalize_len(axisv, _len); + float3 x = normalize_len(extentu, _len); + float3 y = normalize_len(extentv, _len); float3 z = cross(x, y); /* Compute rectangle coords in local reference system. */ float3 dir = corner - P; @@ -38,8 +38,8 @@ ccl_device_inline float area_light_rect_sample(float3 P, } float x0 = dot(dir, x); float y0 = dot(dir, y); - float x1 = x0 + axisu_len; - float y1 = y0 + axisv_len; + float x1 = x0 + extentu_len; + float y1 = y0 + extentv_len; /* Compute internal angles (gamma_i). */ float4 diff = make_float4(x0, y1, x1, y0) - make_float4(x1, y0, x0, y1); float4 nz = make_float4(y0, x1, y1, x0) * diff; @@ -106,8 +106,8 @@ ccl_device float area_light_spread_attenuation(const float3 D, ccl_device bool area_light_spread_clamp_area_light(const float3 P, const float3 lightNg, ccl_private float3 *lightP, - ccl_private float3 *axisu, - ccl_private float3 *axisv, + ccl_private float3 *extentu, + ccl_private float3 *extentv, const float tan_spread) { /* Closest point in area light plane and distance to that plane. */ @@ -120,8 +120,8 @@ ccl_device bool area_light_spread_clamp_area_light(const float3 P, /* TODO: would be faster to store as normalized vector + length, also in area_light_rect_sample. */ float len_u, len_v; - const float3 u = normalize_len(*axisu, _u); - const float3 v = normalize_len(*axisv, _v); + const float3 u = normalize_len(*extentu, _u); + const float3 v = normalize_len(*extentv, _v); /* Local uv coordinates of closest point. */ const float closest_u = dot(u, closest_P - *lightP); @@ -147,8 +147,8 @@ ccl_device bool area_light_spread_clamp_area_light(const float3 P, const float new_len_v = max_v - min_v; *lightP = *lightP + new_center_u * u + new_center_v * v; - *axisu = u * new_len_u; - *axisv = v * new_len_v; + *extentu = u * new_len_u; + *extentv = v * new_len_v; return true; } @@ -164,8 +164,10 @@ ccl_device_inline bool area_light_sample(const ccl_global KernelLight *klight, { ls->P = make_float3(klight->co[0], klight->co[1], klight->co[2]); - float3 axisu = make_float3(klight->area.axisu[0], klight->area.axisu[1], klight->area.axisu[2]); - float3 axisv = make_float3(klight->area.axisv[0], klight->area.axisv[1], klight->area.axisv[2]); + float3 extentu = make_float3( + klight->area.extentu[0], klight->area.extentu[1], klight->area.extentu[2]); + float3 extentv = make_float3( + klight->area.extentv[0], klight->area.extentv[1], klight->area.extentv[2]); float3 Ng = make_float3(klight->area.dir[0], klight->area.dir[1], klight->area.dir[2]); float invarea = fabsf(klight->area.invarea); bool is_round = (klight->area.invarea < 0.0f); @@ -179,29 +181,30 @@ ccl_device_inline bool
[Bf-blender-cvs] [097a13f5be1] master: Fix broken Cycles rendering with recent OSL versions
Commit: 097a13f5be143bd37bfd635cbf31515d531d7a8a Author: Patrick Mours Date: Fri Nov 11 16:42:49 2022 +0100 Branches: master https://developer.blender.org/rB097a13f5be143bd37bfd635cbf31515d531d7a8a Fix broken Cycles rendering with recent OSL versions Commit c8dd33f5a37b6a6db0b6950d24f9a7cff5ceb799 in OSL changed behavior of shader parameters that reference each other and are also overwritten with an instance value. This is causing the "NormalIn" parameter of a few OSL nodes in Cycles to be set to zero somehow, which should instead have received the value from a "node_geometry" node Cycles generates and connects automatically. I am not entirely sure why that is happening, but these parameters are superfluous anyway, since OSL already provides the necessary data in the global variable "N". So this patch simply removes those parameters (which mimics SVM, where these parameters do not exist either), which also fixes the rendering artifacts that occured with recent OSL. Maniphest Tasks: T101222 Differential Revision: https://developer.blender.org/D16470 === M intern/cycles/kernel/osl/services_gpu.h M intern/cycles/kernel/osl/shaders/node_geometry.osl M intern/cycles/kernel/osl/shaders/node_normal_map.osl M intern/cycles/kernel/osl/shaders/node_tangent.osl M intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl M intern/cycles/scene/shader_nodes.cpp M intern/cycles/scene/shader_nodes.h === diff --git a/intern/cycles/kernel/osl/services_gpu.h b/intern/cycles/kernel/osl/services_gpu.h index e6e19b8c484..f762c7258df 100644 --- a/intern/cycles/kernel/osl/services_gpu.h +++ b/intern/cycles/kernel/osl/services_gpu.h @@ -419,6 +419,8 @@ ccl_device_extern bool osl_transformc(ccl_private ShaderGlobals *sg, c_out[i] = rgb; } } + + return true; } /* Matrix Utilities */ diff --git a/intern/cycles/kernel/osl/shaders/node_geometry.osl b/intern/cycles/kernel/osl/shaders/node_geometry.osl index cc891abd6e3..5d9284deac2 100644 --- a/intern/cycles/kernel/osl/shaders/node_geometry.osl +++ b/intern/cycles/kernel/osl/shaders/node_geometry.osl @@ -3,8 +3,7 @@ #include "stdcycles.h" -shader node_geometry(normal NormalIn = N, - string bump_offset = "center", +shader node_geometry(string bump_offset = "center", output point Position = point(0.0, 0.0, 0.0), output normal Normal = normal(0.0, 0.0, 0.0), @@ -17,7 +16,7 @@ shader node_geometry(normal NormalIn = N, output float RandomPerIsland = 0.0) { Position = P; - Normal = NormalIn; + Normal = N; TrueNormal = Ng; Incoming = I; Parametric = point(1.0 - u - v, u, 0.0); diff --git a/intern/cycles/kernel/osl/shaders/node_normal_map.osl b/intern/cycles/kernel/osl/shaders/node_normal_map.osl index 3cda485c686..7e41bbf1720 100644 --- a/intern/cycles/kernel/osl/shaders/node_normal_map.osl +++ b/intern/cycles/kernel/osl/shaders/node_normal_map.osl @@ -3,13 +3,12 @@ #include "stdcycles.h" -shader node_normal_map(normal NormalIn = N, - float Strength = 1.0, +shader node_normal_map(float Strength = 1.0, color Color = color(0.5, 0.5, 1.0), string space = "tangent", string attr_name = "geom:tangent", string attr_sign_name = "geom:tangent_sign", - output normal Normal = NormalIn) + output normal Normal = N) { color mcolor = 2.0 * color(Color[0] - 0.5, Color[1] - 0.5, Color[2] - 0.5); int is_backfacing = backfacing(); @@ -71,5 +70,5 @@ shader node_normal_map(normal NormalIn = N, } if (Strength != 1.0) -Normal = normalize(NormalIn + (Normal - NormalIn) * max(Strength, 0.0)); +Normal = normalize(N + (Normal - N) * max(Strength, 0.0)); } diff --git a/intern/cycles/kernel/osl/shaders/node_tangent.osl b/intern/cycles/kernel/osl/shaders/node_tangent.osl index a302c001f08..b3808778b2f 100644 --- a/intern/cycles/kernel/osl/shaders/node_tangent.osl +++ b/intern/cycles/kernel/osl/shaders/node_tangent.osl @@ -3,8 +3,7 @@ #include "stdcycles.h" -shader node_tangent(normal NormalIn = N, -string attr_name = "geom:tangent", +shader node_tangent(string attr_name = "geom:tangent", string direction_type = "radial", string axis = "z", output normal Tangent = normalize(dPdu)) @@ -29,5 +28,5 @@ shader node_tangent(normal NormalIn = N, } T = transform("object", "world", T); - Tangent = cross(NormalIn, normalize(cross(T, NormalIn))); + Tangent = cross(N, normalize(cross(T, N))); } diff --git a/intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl b/intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl index
[Bf-blender-cvs] [dad3574a8c0] soc-2022-many-lights-sampling: Merge branch 'master' into soc-2022-many-lights-sampling
Commit: dad3574a8c0b673efa9d7f7c890d9562e3f6a267 Author: Weizhen Huang Date: Fri Nov 11 16:17:58 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBdad3574a8c0b673efa9d7f7c890d9562e3f6a267 Merge branch 'master' into soc-2022-many-lights-sampling === === ___ 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] [e9260afa930] soc-2022-many-lights-sampling: Cleanup: wrap `left_probability` into a function to reduce repetition
Commit: e9260afa93068d0181de6e3223f65e7bb016aecc Author: Weizhen Huang Date: Fri Nov 11 16:15:27 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBe9260afa93068d0181de6e3223f65e7bb016aecc Cleanup: wrap `left_probability` into a function to reduce repetition === M intern/cycles/kernel/light/tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index cab7162f582..226553e0cdb 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -529,6 +529,42 @@ ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg, return selected_prim_index; } +template +ccl_device_inline bool get_left_probability(KernelGlobals kg, +const float3 P, +const float3 N_or_D, +const float t, +const bool has_transmission, +const int left_index, +const int right_index, +ccl_private float _probability) +{ + /* If we don't split, then we need to choose sampling between the left or right child. */ + const ccl_global KernelLightTreeNode *left = _data_fetch(light_tree_nodes, left_index); + const ccl_global KernelLightTreeNode *right = _data_fetch(light_tree_nodes, right_index); + + float min_left_importance, max_left_importance, min_right_importance, max_right_importance; + light_tree_node_importance( + kg, P, N_or_D, t, has_transmission, left, max_left_importance, min_left_importance); + light_tree_node_importance( + kg, P, N_or_D, t, has_transmission, right, max_right_importance, min_right_importance); + + const float total_max_importance = max_left_importance + max_right_importance; + if (total_max_importance == 0.0f) { +return false; + } + const float total_min_importance = min_left_importance + min_right_importance; + + /* average two probabilities of picking the left child node using lower and upper bounds */ + const float probability_max = max_left_importance / total_max_importance; + const float probability_min = total_min_importance > 0 ? +min_left_importance / total_min_importance : +0.5f * (float(max_left_importance > 0) + +float(max_right_importance == 0.0f)); + left_probability = 0.5f * (probability_max + probability_min); + return true; +} + template ccl_device bool light_tree_sample(KernelGlobals kg, ccl_private const RNGState *rng_state, @@ -621,33 +657,13 @@ ccl_device bool light_tree_sample(KernelGlobals kg, continue; } -/* If we don't split, then we need to choose sampling between the left or right child. */ -const ccl_global KernelLightTreeNode *left = _data_fetch(light_tree_nodes, left_index); -const ccl_global KernelLightTreeNode *right = _data_fetch(light_tree_nodes, - right_index); - -float min_left_importance, max_left_importance, min_right_importance, max_right_importance; -light_tree_node_importance( -kg, P, N_or_D, t, has_transmission, left, max_left_importance, min_left_importance); -light_tree_node_importance( -kg, P, N_or_D, t, has_transmission, right, max_right_importance, min_right_importance); - -const float total_max_importance = max_left_importance + max_right_importance; -const float total_min_importance = min_left_importance + min_right_importance; - -if (total_max_importance == 0.0f) { +float left_probability; +if (!get_left_probability( +kg, P, N_or_D, t, has_transmission, left_index, right_index, left_probability)) { stack_index--; continue; } -/* average two probabilities of picking the left child node using lower and upper bounds */ -const float probability_max = max_left_importance / total_max_importance; -const float probability_min = total_min_importance > 0 ? - min_left_importance / total_min_importance : - 0.5f * (float(max_left_importance > 0) + - float(max_right_importance == 0.0f)); -const float left_probability = 0.5f * (probability_max + probability_min); - if (*randu <= left_probability) { stack[stack_index] = left_index; *randu = *randu / left_probability; @@ -928,33 +944,13 @@ ccl_device float light_tree_pdf(KernelGlobals kg, continue; } -/* No splitting, choose between the left or the
[Bf-blender-cvs] [dc8a1d38b73] master: Merge branch 'blender-v3.4-release'
Commit: dc8a1d38b73420428f9fb878386b99ebb69dd841 Author: Hans Goudey Date: Fri Nov 11 09:09:28 2022 -0600 Branches: master https://developer.blender.org/rBdc8a1d38b73420428f9fb878386b99ebb69dd841 Merge branch 'blender-v3.4-release' === === ___ 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] [ff7645c5edd] blender-v3.4-release: Fix T102404: Behavior change in CustomData API
Commit: ff7645c5edd211c5317b5fd9e6d0320c20667a21 Author: Hans Goudey Date: Fri Nov 11 09:07:54 2022 -0600 Branches: blender-v3.4-release https://developer.blender.org/rBff7645c5edd211c5317b5fd9e6d0320c20667a21 Fix T102404: Behavior change in CustomData API Previously the `CustomData_add_layer` function always returned the existing layer data when used for types that can only have one layer. This made it work like an "ensure layer exists" function for those types. That was used in various places to make code more concise. 0a7308a0f149 changed that to always "recreate" the layer even when it existed. Maybe this is more logical for an "add layer" function, but that's not clear, and it breaks a bunch of existing code that relied on the current behavior. Rather than spending a bunch of time going through uses of the CustomData API, this patch resets the behavior to what it was before, but adds an assert and a comment to help avoid memory leaks and other issues. We should focus on moving to the attribute API instead. Differential Revision: https://developer.blender.org/D16458 === M source/blender/blenkernel/intern/customdata.cc === diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 01017466764..15d92614c42 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -2799,6 +2799,14 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, const LayerTypeInfo *typeInfo = layerType_getInfo(type); int flag = 0; + /* Some layer types only support a single layer. */ + if (!typeInfo->defaultname && CustomData_has_layer(data, type)) { +/* This function doesn't support dealing with existing layer data for these layer types when + * the layer already exists. */ +BLI_assert(layerdata == nullptr); +return >layers[CustomData_get_layer_index(data, type)]; + } + void *newlayerdata = nullptr; switch (alloctype) { case CD_SET_DEFAULT: @@ -2851,21 +2859,6 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, break; } - /* Some layer types only support a single layer. */ - const bool reuse_existing_layer = !typeInfo->defaultname && CustomData_has_layer(data, type); - if (reuse_existing_layer) { -CustomDataLayer = data->layers[CustomData_get_layer_index(data, type)]; -if (layer.data != nullptr) { - if (typeInfo->free) { -typeInfo->free(layer.data, totelem, typeInfo->size); - } - MEM_SAFE_FREE(layer.data); -} -layer.data = newlayerdata; -layer.flag = flag; -return - } - int index = data->totlayer; if (index >= data->maxlayer) { if (!customData_resize(data, CUSTOMDATA_GROW)) { ___ 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] [e508de04171] blender-v3.4-release: Fix T100706: Object instances with different geometry type invisible
Commit: e508de041712cc31588cbc8d63f81970eedf3be0 Author: Hans Goudey Date: Fri Nov 11 09:06:50 2022 -0600 Branches: blender-v3.4-release https://developer.blender.org/rBe508de041712cc31588cbc8d63f81970eedf3be0 Fix T100706: Object instances with different geometry type invisible Code in `deg_object_hide_original` uses the dupli object type to decide whether to hide the original object. The geometry component system changed the dupli object generator types, which made this not work. To maintain existing behavior, maintain a stack of non-geometry-nodes generator types while building the dupli list, and assign that to the dupli object instead. I think this code is on its last legs. It can't handle too many more hacky fixes like this, and should be replaced soon. Hopefully that is possible by using a `bke::Instances` type instead. However, this bug is bad enough that it's worth fixing like this. Differential Revisions: https://developer.blender.org/D16460 === M source/blender/blenkernel/intern/object_dupli.cc === diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index 3d35cea1e93..54a26a897d8 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -79,6 +79,8 @@ namespace geo_log = blender::nodes::geo_eval_log; /** \name Internal Duplicate Context * \{ */ +static constexpr short GEOMETRY_SET_DUPLI_GENERATOR_TYPE = 1; + struct DupliContext { Depsgraph *depsgraph; /** XXX child objects are selected from this group if set, could be nicer. */ @@ -109,6 +111,14 @@ struct DupliContext { */ Vector *instance_stack; + /** + * Older code relies on the "dupli generator type" for various visibility or processing + * decisions. However, new code uses geometry instances in places that weren't using the dupli + * system previously. To fix this, keep track of the last dupli generator type that wasn't a + * geometry set instance. + * */ + Vector *dupli_gen_type_stack; + int persistent_id[MAX_DUPLI_RECUR]; int64_t instance_idx[MAX_DUPLI_RECUR]; const GeometrySet *instance_data[MAX_DUPLI_RECUR]; @@ -135,7 +145,8 @@ static void init_context(DupliContext *r_ctx, Scene *scene, Object *ob, const float space_mat[4][4], - Vector _stack) + Vector _stack, + Vector _gen_type_stack) { r_ctx->depsgraph = depsgraph; r_ctx->scene = scene; @@ -145,6 +156,7 @@ static void init_context(DupliContext *r_ctx, r_ctx->object = ob; r_ctx->obedit = OBEDIT_FROM_OBACT(ob); r_ctx->instance_stack = _stack; + r_ctx->dupli_gen_type_stack = _gen_type_stack; if (space_mat) { copy_m4_m4(r_ctx->space_mat, space_mat); } @@ -154,6 +166,9 @@ static void init_context(DupliContext *r_ctx, r_ctx->level = 0; r_ctx->gen = get_dupli_generator(r_ctx); + if (r_ctx->gen && r_ctx->gen->type != GEOMETRY_SET_DUPLI_GENERATOR_TYPE) { +r_ctx->dupli_gen_type_stack->append(r_ctx->gen->type); + } r_ctx->duplilist = nullptr; r_ctx->preview_instance_index = -1; @@ -195,6 +210,9 @@ static bool copy_dupli_context(DupliContext *r_ctx, } r_ctx->gen = get_dupli_generator(r_ctx); + if (r_ctx->gen && r_ctx->gen->type != GEOMETRY_SET_DUPLI_GENERATOR_TYPE) { +r_ctx->dupli_gen_type_stack->append(r_ctx->gen->type); + } return true; } @@ -227,7 +245,7 @@ static DupliObject *make_dupli(const DupliContext *ctx, dob->ob = ob; dob->ob_data = const_cast(object_data); mul_m4_m4m4(dob->mat, (float(*)[4])ctx->space_mat, mat); - dob->type = ctx->gen == nullptr ? 0 : ctx->gen->type; + dob->type = ctx->gen == nullptr ? 0 : ctx->dupli_gen_type_stack->last(); dob->preview_base_geometry = ctx->preview_base_geometry; dob->preview_instance_index = ctx->preview_instance_index; @@ -996,7 +1014,7 @@ static void make_duplis_geometry_set(const DupliContext *ctx) } static const DupliGenerator gen_dupli_geometry_set = { -0, +GEOMETRY_SET_DUPLI_GENERATOR_TYPE, make_duplis_geometry_set, }; @@ -1717,8 +1735,9 @@ ListBase *object_duplilist(Depsgraph *depsgraph, Scene *sce, Object *ob) ListBase *duplilist = MEM_cnew("duplilist"); DupliContext ctx; Vector instance_stack; + Vector dupli_gen_type_stack({0}); instance_stack.append(ob); - init_context(, depsgraph, sce, ob, nullptr, instance_stack); + init_context(, depsgraph, sce, ob, nullptr, instance_stack, dupli_gen_type_stack); if (ctx.gen) { ctx.duplilist = duplilist; ctx.gen->make_duplis(); @@ -1735,8 +1754,9 @@ ListBase *object_duplilist_preview(Depsgraph *depsgraph, ListBase *duplilist = MEM_cnew("duplilist"); DupliContext ctx; Vector instance_stack; + Vector
[Bf-blender-cvs] [80f0d9e29dc] temp-xr-virtual-camera-experiment: Add support for XrSession (untested).
Commit: 80f0d9e29dcb282935995ef1c87c9c7097f851ff Author: Jeroen Bakker Date: Fri Nov 11 16:06:09 2022 +0100 Branches: temp-xr-virtual-camera-experiment https://developer.blender.org/rB80f0d9e29dcb282935995ef1c87c9c7097f851ff Add support for XrSession (untested). === M source/blender/draw/DRW_engine.h M source/blender/draw/engines/eevee/eevee_materials.c M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_manager.h M source/blender/editors/include/ED_view3d_offscreen.h M source/blender/editors/space_view3d/view3d_draw.cc M source/blender/gpu/GPU_material.h M source/blender/gpu/intern/gpu_node_graph.c M source/blender/python/gpu/gpu_py_offscreen.c === diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index 8c5f1b70cc0..d7b43b85199 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -99,6 +99,7 @@ void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph, bool is_image_render, bool draw_background, bool do_color_management, +bool is_virtual_camera, struct GPUOffScreen *ofs, struct GPUViewport *viewport); void DRW_draw_render_loop_2d_ex(struct Depsgraph *depsgraph, diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index b4874514bd9..e6de676bc29 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -861,10 +861,9 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, continue; } -/* Virtual cameras can only be used in the main scene. TODO: needs to be a different - * DRW_state.*/ -if (DRW_state_is_opengl_render() && -GPU_material_flag_get(gpumat_array[i], GPU_MATFLAG_VIRTUAL_CAMERA)) { +/* Virtual cameras can only be used in the main scene. */ +if (DRW_state_is_virtual_camera() && +GPU_material_flag_get(gpumat_array[i], GPU_MATFLAG_VIRTUAL_MONITOR)) { continue; } diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index b9444c58191..a4aed0f7e77 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -885,6 +885,10 @@ bool DRW_state_is_scene_render(void); */ bool DRW_state_is_opengl_render(void); bool DRW_state_is_playback(void); +/** + * Whether we are rendering a virtual camera, false when rendering the main camera/viewport. + */ +bool DRW_state_is_virtual_camera(void); /** * Is the user navigating the region. */ diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 4fcfec833eb..5e7be9c7fb7 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1807,6 +1807,7 @@ void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph, const bool is_image_render, const bool draw_background, const bool do_color_management, +const bool is_virtual_camera, GPUOffScreen *ofs, GPUViewport *viewport) { @@ -1830,6 +1831,7 @@ void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph, drw_state_prepare_clean_for_draw(); DST.options.is_image_render = is_image_render; DST.options.draw_background = draw_background; + DST.options.is_virtual_camera = is_virtual_camera; DRW_draw_render_loop_ex(depsgraph, engine_type, region, v3d, render_viewport, NULL); if (draw_background) { @@ -2920,6 +2922,11 @@ bool DRW_state_is_opengl_render(void) return DST.options.is_image_render && !DST.options.is_scene_render; } +bool DRW_state_is_virtual_camera(void) +{ + return DST.options.is_virtual_camera; +} + bool DRW_state_is_playback(void) { if (DST.draw_ctx.evil_C != NULL) { diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 52129049269..b1d097145c8 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -612,6 +612,7 @@ typedef struct DRWManager { uint is_depth : 1; uint is_image_render : 1; uint is_scene_render : 1; +uint is_virtual_camera : 1; uint draw_background : 1; uint draw_text : 1; } options; diff --git
[Bf-blender-cvs] [e37d254170c] temp-xr-virtual-camera-experiment: Rename to virtual monitor.
Commit: e37d254170c3ab2c54d4082926d9c685cafdfc45 Author: Jeroen Bakker Date: Fri Nov 11 14:53:21 2022 +0100 Branches: temp-xr-virtual-camera-experiment https://developer.blender.org/rBe37d254170c3ab2c54d4082926d9c685cafdfc45 Rename to virtual monitor. === M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/intern/camera.c M source/blender/editors/space_node/drawnode.cc M source/blender/editors/space_view3d/view3d_draw.cc M source/blender/gpu/intern/gpu_node_graph.c M source/blender/makesdna/DNA_camera_types.h M source/blender/makesrna/intern/rna_nodetree.c M source/blender/nodes/NOD_static_types.h M source/blender/nodes/shader/CMakeLists.txt R055source/blender/nodes/shader/nodes/node_shader_virtual_camera.cc source/blender/nodes/shader/nodes/node_shader_virtual_monitor.cc === diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index cf78c954e44..b332f90ee83 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -1222,7 +1222,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i #define SH_NODE_COMBINE_COLOR 711 #define SH_NODE_SEPARATE_COLOR 712 #define SH_NODE_MIX 713 -#define SH_NODE_VIRTUAL_CAMERA 714 +#define SH_NODE_VIRTUAL_MONITOR 714 /** \} */ diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 93be310b3b3..e3a72c5d69e 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -41,6 +41,8 @@ #include "DEG_depsgraph_query.h" +#include "GPU_viewport.h" + #include "MEM_guardedalloc.h" #include "BLO_read_write.h" @@ -83,10 +85,21 @@ static void camera_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, } /** Free (or release) any data used by this camera (does not free the camera itself). */ +static void camera_free_runtime_data(Camera *camera) +{ + if (camera->runtime.virtual_monitor_offscreen) { +GPU_offscreen_free(camera->runtime.virtual_monitor_offscreen); +camera->runtime.virtual_monitor_offscreen = NULL; + } + /* GPU texture is owned by the GPUOffscreen instance. */ + camera->runtime.offscreen_color_texture = NULL; +} + static void camera_free_data(ID *id) { Camera *cam = (Camera *)id; BLI_freelistN(>bg_images); + camera_free_runtime_data(cam); } static void camera_foreach_id(ID *id, LibraryForeachIDData *data) @@ -137,8 +150,8 @@ static void camera_blend_read_data(BlendDataReader *reader, ID *id) bgpic->flag &= ~CAM_BGIMG_FLAG_OVERRIDE_LIBRARY_LOCAL; } } - ca->runtime.virtual_display_texture = NULL; - ca->runtime.gpu_texture = NULL; + ca->runtime.virtual_monitor_offscreen = NULL; + ca->runtime.offscreen_color_texture = NULL; } static void camera_blend_read_lib(BlendLibReader *reader, ID *id) diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index b713b225638..196726a2a14 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -432,7 +432,7 @@ static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, Poin node_buts_image_user(layout, C, , , , false, true); } -static void node_shader_buts_virtual_camera(uiLayout *layout, bContext *C, PointerRNA *ptr) +static void node_shader_buts_virtual_monitor(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiTemplateID(layout, C, @@ -513,8 +513,8 @@ static void node_shader_set_butfunc(bNodeType *ntype) ntype->draw_buttons = node_shader_buts_tex_environment; ntype->draw_buttons_ex = node_shader_buts_tex_environment_ex; break; -case SH_NODE_VIRTUAL_CAMERA: - ntype->draw_buttons = node_shader_buts_virtual_camera; +case SH_NODE_VIRTUAL_MONITOR: + ntype->draw_buttons = node_shader_buts_virtual_monitor; break; case SH_NODE_DISPLACEMENT: case SH_NODE_VECTOR_DISPLACEMENT: diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 468de37a9a2..c06d0981cb0 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -1552,16 +1552,16 @@ static void view3d_virtual_camera_update(const bContext *C, ARegion *region, Obj int2 resolution(1920 / 2, 1080 / 2); RegionView3D *old_rv3d = static_cast(region->regiondata); - RegionView3D rv3d = {*old_rv3d}; - region->regiondata = + RegionView3D rv3d; + memcpy(, old_rv3d, sizeof(RegionView3D)); Object *old_camera = v3d->camera; v3d->camera = object; rv3d.persp = RV3D_CAMOB; Camera *camera = static_cast(object->data); - if (camera->runtime.virtual_display_texture ==
[Bf-blender-cvs] [3a3947bcf83] temp-xr-virtual-camera-experiment: Revert incorrect change.
Commit: 3a3947bcf83228e1e7977556baff3de02b16ea07 Author: Jeroen Bakker Date: Fri Nov 11 15:07:23 2022 +0100 Branches: temp-xr-virtual-camera-experiment https://developer.blender.org/rB3a3947bcf83228e1e7977556baff3de02b16ea07 Revert incorrect change. === M source/blender/editors/space_view3d/view3d_draw.cc === diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index c06d0981cb0..57bf8e557c2 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -1554,6 +1554,7 @@ static void view3d_virtual_camera_update(const bContext *C, ARegion *region, Obj RegionView3D *old_rv3d = static_cast(region->regiondata); RegionView3D rv3d; memcpy(, old_rv3d, sizeof(RegionView3D)); + region->regiondata = Object *old_camera = v3d->camera; v3d->camera = object; ___ 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] [a304dfdb691] master: Cleanup: Improve curves sculpt code section names
Commit: a304dfdb6917d80d5a5de6361c65f633114b2238 Author: Hans Goudey Date: Fri Nov 11 08:50:07 2022 -0600 Branches: master https://developer.blender.org/rBa304dfdb6917d80d5a5de6361c65f633114b2238 Cleanup: Improve curves sculpt code section names === M source/blender/editors/sculpt_paint/curves_sculpt_ops.cc === diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index df7dd871a94..df23bdf0079 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -76,7 +76,7 @@ namespace blender::ed::sculpt_paint { using blender::bke::CurvesGeometry; /* */ -/** \name * SCULPT_CURVES_OT_brush_stroke +/** \name Brush Stroke Operator * \{ */ float brush_radius_factor(const Brush , const StrokeExtension _extension) @@ -271,7 +271,7 @@ static void SCULPT_CURVES_OT_brush_stroke(struct wmOperatorType *ot) /** \} */ /* */ -/** \name * CURVES_OT_sculptmode_toggle +/** \name Toggle Sculpt Mode * \{ */ static void curves_sculptmode_enter(bContext *C) @@ -1269,7 +1269,7 @@ static void SCULPT_CURVES_OT_min_distance_edit(wmOperatorType *ot) } // namespace blender::ed::sculpt_paint /* */ -/** \name * Registration +/** \name Registration * \{ */ void ED_operatortypes_sculpt_curves() ___ 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] [d9804022955] soc-2022-many-lights-sampling: Do not sample node with zero importance
Commit: d9804022955b65e5b9bc1643c43dd252e996622b Author: Weizhen Huang Date: Fri Nov 11 15:49:36 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBd9804022955b65e5b9bc1643c43dd252e996622b Do not sample node with zero importance === M intern/cycles/kernel/light/tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index 16a7a9f8ece..cab7162f582 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -63,8 +63,9 @@ ccl_device void light_tree_cluster_importance(const float3 N_or_D, float cos_theta, cos_theta_i, sin_theta_i; /* cos(theta_i') in the paper, omitted for volume */ float cos_min_incidence_angle = 1.0f; - /* when sampling the light tree for the second time in `shade_volume.h`*/ - const bool in_volume = (dot(N_or_D, N_or_D) == 0.0f); + /* when sampling the light tree for the second time in `shade_volume.h` and when query the pdf in + * `sample.h` */ + const bool in_volume = (dot(N_or_D, N_or_D) < 5e-4f); if (in_volume_segment) { const float3 D = N_or_D; @@ -441,7 +442,7 @@ ccl_device_inline void sample_resevoir(const int current_index, } /* pick an emitter from a leaf node using resevoir sampling, keep two reservoirs for upper and -+ * lower bounds */ + * lower bounds */ template ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg, ccl_private float *randu, @@ -464,12 +465,18 @@ ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg, float total_min_importance = min_importance; float selected_min_importance = min_importance; + /* Mark emitters with zero importance. Used for resevoir when total_min_importance = 0 */ + kernel_assert(knode->num_prims <= sizeof(uint) * 8); + uint has_importance = max_importance > 0; + for (int i = 1; i < knode->num_prims; i++) { int current_prim_index = -knode->child_index + i; light_tree_emitter_importance( kg, P, N_or_D, t, has_transmission, current_prim_index, max_importance, min_importance); -/* resevoir sampling using the maximum weights */ +has_importance |= ((max_importance > 0) << i); + +/* resevoir sampling using the maximum importance */ sample_resevoir(current_prim_index, max_importance, selected_prim_index_max, @@ -477,7 +484,7 @@ ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg, total_max_importance, randu); -/* resevoir sampling using the mininum weights */ +/* resevoir sampling using the mininum importance */ sample_resevoir(current_prim_index, min_importance, selected_prim_index_min, @@ -491,12 +498,12 @@ ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg, } if (total_min_importance == 0.0f) { -/* uniformly sample */ -selected_min_importance = 1.0f; -total_min_importance = selected_min_importance; -selected_prim_index_min = -knode->child_index; -for (int i = 1; i < knode->num_prims; i++) { +/* uniformly sample emitters with positive max_importance */ +selected_prim_index_min = -1; +for (int i = 0; i < knode->num_prims; i++) { int current_prim_index = -knode->child_index + i; + selected_min_importance = float(has_importance & 1); + has_importance >>= 1; sample_resevoir(current_prim_index, selected_min_importance, selected_prim_index_min, @@ -633,10 +640,13 @@ ccl_device bool light_tree_sample(KernelGlobals kg, continue; } -/* average two probabilities of picking child nodes using lower and upper bounds */ -float left_probability = -0.5f * (max_left_importance / total_max_importance + -(total_min_importance > 0 ? min_left_importance / total_min_importance : 0.5f)); +/* average two probabilities of picking the left child node using lower and upper bounds */ +const float probability_max = max_left_importance / total_max_importance; +const float probability_min = total_min_importance > 0 ? + min_left_importance / total_min_importance : + 0.5f * (float(max_left_importance > 0) + + float(max_right_importance == 0.0f)); +const float left_probability = 0.5f * (probability_max + probability_min); if (*randu <= left_probability) { stack[stack_index] = left_index; @@ -858,11 +868,13 @@ ccl_device float light_tree_pdf(KernelGlobals kg, float target_min_importance = 0.0f; float total_max_importance = 0.0f; float total_min_importance = 0.0f; +int
[Bf-blender-cvs] [111974234c6] master: Addons submodule version bump
Commit: 111974234c697876c486efc0c065581702cd41e6 Author: demeterdza...@gmail.com Date: Fri Nov 11 15:10:30 2022 +0100 Branches: master https://developer.blender.org/rB111974234c697876c486efc0c065581702cd41e6 Addons submodule version bump (Previous attempt was accidentally 4 days outdated) === M release/scripts/addons === diff --git a/release/scripts/addons b/release/scripts/addons index d477a245c03..c226f867aff 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit d477a245c03c2c5227c97825b20e62d1469e24b2 +Subproject commit c226f867affd12881533a54c8c90ac6eebfaca6c ___ 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] [80f5a5a8aa1] blender-v3.4-release: Fix T101270: Object Info > Random not unique for nested instances and curves
Commit: 80f5a5a8aa12594fb724e9ba45185e13c914f7dd Author: Brecht Van Lommel Date: Fri Nov 11 12:54:01 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB80f5a5a8aa12594fb724e9ba45185e13c914f7dd Fix T101270: Object Info > Random not unique for nested instances and curves This random number is intended to be unique for every instance, however for some cases with more than one level of nesting this was failing. This also affected curves after they were refactored to use geometry sets. For simple cases the random number is the same as before, however for more complex nesting it will be different than before, changing the render result. === M source/blender/blenkernel/intern/object_dupli.cc === diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index 5efd44c620b..3d35cea1e93 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -87,6 +87,9 @@ struct DupliContext { Object *obedit; Scene *scene; + /** Root parent object at the scene level. */ + Object *root_object; + /** Immediate parent object in the context. */ Object *object; float space_mat[4][4]; /** @@ -138,6 +141,7 @@ static void init_context(DupliContext *r_ctx, r_ctx->scene = scene; r_ctx->collection = nullptr; + r_ctx->root_object = ob; r_ctx->object = ob; r_ctx->obedit = OBEDIT_FROM_OBACT(ob); r_ctx->instance_stack = _stack; @@ -264,8 +268,9 @@ static DupliObject *make_dupli(const DupliContext *ctx, dob->no_draw = true; } - /* Random number. - * The logic here is designed to match Cycles. */ + /* Random number per instance. + * The root object in the scene, persistent ID up to the instance object, and the instance object + * name together result in a unique random number. */ dob->random_id = BLI_hash_string(dob->ob->id.name + 2); if (dob->persistent_id[0] != INT_MAX) { @@ -277,8 +282,8 @@ static DupliObject *make_dupli(const DupliContext *ctx, dob->random_id = BLI_hash_int_2d(dob->random_id, 0); } - if (ctx->object != ob) { -dob->random_id ^= BLI_hash_int(BLI_hash_string(ctx->object->id.name + 2)); + if (ctx->root_object != ob) { +dob->random_id ^= BLI_hash_int(BLI_hash_string(ctx->root_object->id.name + 2)); } return dob; ___ 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] [3da57487873] temp-xr-virtual-camera-experiment: Fix corrupt rv3d.
Commit: 3da57487873dcac70e29b4f4b82d93889477fed9 Author: Jeroen Bakker Date: Fri Nov 11 14:09:19 2022 +0100 Branches: temp-xr-virtual-camera-experiment https://developer.blender.org/rB3da57487873dcac70e29b4f4b82d93889477fed9 Fix corrupt rv3d. === M source/blender/editors/space_view3d/view3d_draw.cc === diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 2da8e86b043..468de37a9a2 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -1551,11 +1551,13 @@ static void view3d_virtual_camera_update(const bContext *C, ARegion *region, Obj View3D *v3d = CTX_wm_view3d(C); int2 resolution(1920 / 2, 1080 / 2); - RegionView3D *rv3d = static_cast(region->regiondata); - int old_persp = rv3d->persp; + RegionView3D *old_rv3d = static_cast(region->regiondata); + RegionView3D rv3d = {*old_rv3d}; + region->regiondata = + Object *old_camera = v3d->camera; v3d->camera = object; - rv3d->persp = RV3D_CAMOB; + rv3d.persp = RV3D_CAMOB; Camera *camera = static_cast(object->data); if (camera->runtime.virtual_display_texture == nullptr) { @@ -1599,7 +1601,7 @@ static void view3d_virtual_camera_update(const bContext *C, ARegion *region, Obj camera->runtime.virtual_display_texture); v3d->camera = old_camera; - rv3d->persp = old_persp; + region->regiondata = old_rv3d; } static void view3d_draw_virtual_camera(const bContext *C, ARegion *region) ___ 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] [fe2be365106] master: Merge branch 'blender-v3.4-release'
Commit: fe2be365106f968cf6686618b9f87c2f63993665 Author: Philipp Oeser Date: Fri Nov 11 13:27:27 2022 +0100 Branches: master https://developer.blender.org/rBfe2be365106f968cf6686618b9f87c2f63993665 Merge branch 'blender-v3.4-release' === === ___ 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] [38430c384a2] blender-v3.4-release: Fix: Curves sculptmode: paintcurve stroke points cannot be transformed
Commit: 38430c384a29b8fc900eef839c2dd307d0d96ea4 Author: Philipp Oeser Date: Fri Nov 11 13:05:47 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB38430c384a29b8fc900eef839c2dd307d0d96ea4 Fix: Curves sculptmode: paintcurve stroke points cannot be transformed As part of rB3f91540cef7e, we already made `OB_MODE_SCULPT_CURVES` to be allowed in `paint_curve_poll` (alongside `OB_MODE_ALL_PAINT`). Now, to get the paintcurves transform systems to work with curves sculptmode as well, we introduce this "additional case" in the appropriate place in the transform system as well. NOTE: as a next step, considering `OB_MODE_SCULPT_CURVES` to be generally part of `OB_MODE_ALL_PAINT` is to be done (this might fix another couple of bugs, but also has to be carefully checked in many places, so this patch is just fixing this very specific case) Fixes T102204. Maniphest Tasks: T102204 Differential Revision: https://developer.blender.org/D16466 === M source/blender/editors/transform/transform_convert.c M source/blender/editors/transform/transform_generics.c === diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index a5b2442f11c..d71a3897cbc 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -1109,7 +1109,7 @@ static TransConvertTypeInfo *convert_type_get(const TransInfo *t, Object **r_obj PE_start_edit(PE_get_current(t->depsgraph, t->scene, ob))) { return _Particle; } - if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { + if (ob && ((ob->mode & OB_MODE_ALL_PAINT) || (ob->mode & OB_MODE_SCULPT_CURVES))) { if ((t->options & CTX_PAINT_CURVE) && !ELEM(t->mode, TFM_SHEAR, TFM_SHRINKFATTEN)) { return _PaintCurve; } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index e1f93bf881b..e7ef408b848 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -309,7 +309,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->flag |= T_V3D_ALIGN; } -if (object_mode & OB_MODE_ALL_PAINT) { +if ((object_mode & OB_MODE_ALL_PAINT) || (object_mode & OB_MODE_SCULPT_CURVES)) { Paint *p = BKE_paint_get_active_from_context(C); if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) { t->options |= CTX_PAINT_CURVE; ___ 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] [5f35e7f12aa] master: Addons submodule version bump
Commit: 5f35e7f12aa924198e78e248fb19c57db86313c2 Author: demeterdza...@gmail.com Date: Fri Nov 11 12:45:43 2022 +0100 Branches: master https://developer.blender.org/rB5f35e7f12aa924198e78e248fb19c57db86313c2 Addons submodule version bump === M release/scripts/addons === diff --git a/release/scripts/addons b/release/scripts/addons index 5a818af9508..d477a245c03 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 5a818af95080cccf04dfa8317f0e966bff515c64 +Subproject commit d477a245c03c2c5227c97825b20e62d1469e24b2 ___ 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] [a3877d8fe40] master: Merge branch 'blender-v3.4-release'
Commit: a3877d8fe4094c0502acdacfd15880da10260769 Author: Jacques Lucke Date: Fri Nov 11 11:49:54 2022 +0100 Branches: master https://developer.blender.org/rBa3877d8fe4094c0502acdacfd15880da10260769 Merge branch 'blender-v3.4-release' === === ___ 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] [57dd1b7799e] blender-v3.4-release: Fix T102386: crash when trying to link sockets from different node trees
Commit: 57dd1b7799e7453e34c3a50d0eadfa87af17 Author: Jacques Lucke Date: Fri Nov 11 11:48:56 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB57dd1b7799e7453e34c3a50d0eadfa87af17 Fix T102386: crash when trying to link sockets from different node trees This was caused by rBc39eb09ae587e1d9. The optimization broke the case when the socket is not in the provided node tree. Now there are two separate functions, one that always does the slow check to see of the socket is really in the node tree and a potentially much faster version when we are sure that the socket is in the tree. === M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/intern/node.cc M source/blender/editors/interface/interface_ops.cc M source/blender/makesrna/intern/rna_nodetree.c === diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 6eb9650348a..4e2fc55a222 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -746,7 +746,14 @@ struct bNode *nodeFindNodebyName(struct bNodeTree *ntree, const char *name); /** * Finds a node based on given socket and returns true on success. */ -bool nodeFindNode(struct bNodeTree *ntree, +bool nodeFindNodeTry(struct bNodeTree *ntree, + struct bNodeSocket *sock, + struct bNode **r_node, + int *r_sockindex); +/** + * Same as above but expects that the socket definitely is in the node tree. + */ +void nodeFindNode(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **r_node, int *r_sockindex); diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index eb0c78e9361..59c2769869d 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2019,7 +2019,7 @@ bNode *nodeFindNodebyName(bNodeTree *ntree, const char *name) return (bNode *)BLI_findstring(>nodes, name, offsetof(bNode, name)); } -bool nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_sockindex) +void nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_sockindex) { *r_node = nullptr; if (!ntree->runtime->topology_cache_is_dirty) { @@ -2029,9 +2029,15 @@ bool nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_so ListBase *sockets = (sock->in_out == SOCK_IN) ? >inputs : >outputs; *r_sockindex = BLI_findindex(sockets, sock); } -return true; +return; } + const bool success = nodeFindNodeTry(ntree, sock, r_node, r_sockindex); + BLI_assert(success); + UNUSED_VARS_NDEBUG(success); +} +bool nodeFindNodeTry(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_sockindex) +{ LISTBASE_FOREACH (bNode *, node, >nodes) { ListBase *sockets = (sock->in_out == SOCK_IN) ? >inputs : >outputs; int i; diff --git a/source/blender/editors/interface/interface_ops.cc b/source/blender/editors/interface/interface_ops.cc index 2d06dd2c465..1b576583291 100644 --- a/source/blender/editors/interface/interface_ops.cc +++ b/source/blender/editors/interface/interface_ops.cc @@ -1165,7 +1165,7 @@ bool UI_context_copy_to_selected_list(bContext *C, if (RNA_struct_is_a(ptr->type, _NodeSocket)) { bNodeTree *ntree = (bNodeTree *)ptr->owner_id; bNodeSocket *sock = static_cast(ptr->data); - if (nodeFindNode(ntree, sock, , nullptr)) { + if (nodeFindNodeTry(ntree, sock, , nullptr)) { if ((path = RNA_path_resolve_from_type_to_property(ptr, prop, _Node)) != nullptr) { /* we're good! */ } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 14122ddb878..c6115711c1a 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1302,8 +1302,8 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, return NULL; } - nodeFindNode(ntree, fromsock, , NULL); - nodeFindNode(ntree, tosock, , NULL); + nodeFindNodeTry(ntree, fromsock, , NULL); + nodeFindNodeTry(ntree, tosock, , NULL); /* check validity of the sockets: * if sockets from different trees are passed in this will fail! */ @@ -2789,9 +2789,7 @@ static char *rna_NodeSocket_path(const PointerRNA *ptr) int socketindex; char name_esc[sizeof(node->name) * 2]; - if (!nodeFindNode(ntree, sock, , )) { -return NULL; - } + nodeFindNode(ntree, sock, , ); BLI_str_escape(name_esc, node->name, sizeof(name_esc)); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe:
[Bf-blender-cvs] [824d5984aab] master: Merge branch 'blender-v3.4-release'
Commit: 824d5984aab497e2914e99561f7f0a4bdafa4055 Author: Jacques Lucke Date: Fri Nov 11 10:10:15 2022 +0100 Branches: master https://developer.blender.org/rB824d5984aab497e2914e99561f7f0a4bdafa4055 Merge branch 'blender-v3.4-release' === === ___ 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] [84c66fe9db9] blender-v3.4-release: Fix T102406: OSL script node no longer updates its in and outputs
Commit: 84c66fe9db932b82ebf445a63dfb629fb3c1b35c Author: Jacques Lucke Date: Fri Nov 11 10:08:49 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB84c66fe9db932b82ebf445a63dfb629fb3c1b35c Fix T102406: OSL script node no longer updates its in and outputs This special case was missing in rB52bd198153ede3c7131df. === M source/blender/makesrna/intern/rna_nodetree.c === diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index cfec020c739..14122ddb878 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2417,6 +2417,11 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value) BKE_animdata_fix_paths_rename_all(NULL, "nodes", oldname, node->name); } +static bool allow_changing_sockets(bNode *node) +{ + return ELEM(node->type, NODE_CUSTOM, SH_NODE_SCRIPT); +} + static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, Main *bmain, @@ -2425,7 +2430,7 @@ static bNodeSocket *rna_Node_inputs_new(ID *id, const char *name, const char *identifier) { - if (node->type != NODE_CUSTOM) { + if (!allow_changing_sockets(node)) { BKE_report(reports, RPT_ERROR, "Cannot add socket to built-in node"); return NULL; } @@ -2452,7 +2457,7 @@ static bNodeSocket *rna_Node_outputs_new(ID *id, const char *name, const char *identifier) { - if (node->type != NODE_CUSTOM) { + if (!allow_changing_sockets(node)) { BKE_report(reports, RPT_ERROR, "Cannot add socket to built-in node"); return NULL; } @@ -2474,7 +2479,7 @@ static bNodeSocket *rna_Node_outputs_new(ID *id, static void rna_Node_socket_remove( ID *id, bNode *node, Main *bmain, ReportList *reports, bNodeSocket *sock) { - if (node->type != NODE_CUSTOM) { + if (!allow_changing_sockets(node)) { BKE_report(reports, RPT_ERROR, "Unable to remove socket from built-in node"); return; } @@ -2494,7 +2499,7 @@ static void rna_Node_socket_remove( static void rna_Node_inputs_clear(ID *id, bNode *node, Main *bmain, ReportList *reports) { - if (node->type != NODE_CUSTOM) { + if (!allow_changing_sockets(node)) { BKE_report(reports, RPT_ERROR, "Unable to remove sockets from built-in node"); return; } @@ -2513,7 +2518,7 @@ static void rna_Node_inputs_clear(ID *id, bNode *node, Main *bmain, ReportList * static void rna_Node_outputs_clear(ID *id, bNode *node, Main *bmain, ReportList *reports) { - if (node->type != NODE_CUSTOM) { + if (!allow_changing_sockets(node)) { BKE_report(reports, RPT_ERROR, "Unable to remove socket from built-in node"); return; } @@ -2533,7 +2538,7 @@ static void rna_Node_outputs_clear(ID *id, bNode *node, Main *bmain, ReportList static void rna_Node_inputs_move( ID *id, bNode *node, Main *bmain, ReportList *reports, int from_index, int to_index) { - if (node->type != NODE_CUSTOM) { + if (!allow_changing_sockets(node)) { BKE_report(reports, RPT_ERROR, "Unable to move sockets in built-in node"); return; } @@ -2571,7 +2576,7 @@ static void rna_Node_inputs_move( static void rna_Node_outputs_move( ID *id, bNode *node, Main *bmain, ReportList *reports, int from_index, int to_index) { - if (node->type != NODE_CUSTOM) { + if (!allow_changing_sockets(node)) { BKE_report(reports, RPT_ERROR, "Unable to move sockets in built-in node"); return; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs